PluginContext (ctx)

Every member of the PluginContext passed to activate(ctx), with its methods, generated from the server code.

activate(ctx) and deactivate(ctx) of a Python half get one PluginContext (server/witwin_server/api/context.py). Everything registered through it is undone when the Plugin unloads. What each member is for: Python API.

MemberObjectIts methods
ctx.plugin_idplugin_id
ctx.pathPath(path)
ctx.apiapi
ctx.systemsystem
ctx.subscriptionsDisposableStoreaddappenddisposedisposedextend
ctx.toolsScopedToolApiregisterunregister
ctx.commandsScopedCommandApiexecuteregister
ctx.viewsScopedViewsApiregister_providerregister_tree_view
ctx.handlersScopedHandlerApiadd: Contribute a core.protocol.handler.Handler class (system Plugins only).
ctx.rpcPluginRpcforget: Drop the cached latest name event of a state topic this Plugin declared.include: Import core module module and own the methods and topics it declares.publish: Publish one event on a topic this Plugin declared, from anywhere.registerregister_domain: Claim core domain domain (system Plugins only).topictopic_head: Last seq published on log topic topic (0 before the first event, and before the server is bound).
ctx.httpScopedHttpApiadd_routesapply: Mount the routes not yet mounted on server.app.base_path
ctx.runsScopedRunsApiemit: Send one run_* event ({"type": "run_started", "runId": ...}) to every client.label: The Run's name as the Runs panel shows it (its label, a Study's name, Solve <solver>).on_event: Call listener(server, event) for every run_* event of each server's Runs.register_executor
ctx.fsProjectFsdelete: Delete a file, or a folder with everything in it.existsignore_next_change: Do not deliver the next watch event for path (a Project path) to anyone.is_diris_filelist: Entries of a folder: {name, path, is_dir, size}, .witwin left out.mkdirread_bytesread_textrelative: target (a server-side path) back as a Project path.renameresolve: The server-side file for path; raises ProjectPathError.rootwatch: Call callback(event) for changes on disk under the Project root.write_byteswrite_text
ctx.scene_lifecycleScopedSceneLifecycleApion
ctx.componentsComponentsApiadd_facet: Add fields to the registered component named component.catalog: Every registered component type, sorted by name, whoever registered it.facets: Facets registered on component by any Plugin (ComponentFacet records).register: Make this Plugin the owner of component classes it defines.
ctx.parametersParametersApi(plugin_id, api)
ctx.walkthroughsScopedWalkthroughApicompletecomplete_event
ctx.capabilitiesScopedCapabilityApiproviderequire
ctx.eventsScopedEventApipublishsubscribe
ctx.agentScopedAgentApicomplete: One model step with no Tools; returns the reply text (may be empty).register_argument_policy: fn(name, args, context) -> args before authorization; raise ToolArgumentRejected to refuse.register_follow_up: resolver(tool_result, history) -> {"name", "arguments"} | None after a source Tool succeeds.register_profile: A read-only Agent profile: an exact Tool allowlist enforced by tools/authorization.py.register_request_policy: fn(user_text, history, candidates) -> RequestScope | None narrows the turn's Tools.register_system_policy: Add text to the system prompt of turns whose Tools match a when prefix.
ctx.solversScopedSolverApicallcancelqueryread_result_refsolvestatus
ctx.scene_timeapi.scene_time
ctx.streamsScopedStreamsApicloseclose_ownererroropenpublish
ctx.data_sourcesScopedDataSourcesApiopen_stream_sourcerefregisterregister_timeline_datasetsubscription_demand
ctx.statePluginStatefor_scope
ctx.global_stateself.state.global_state
ctx.workspace_stateself.state.workspace_state
ctx.storageScopedMementocleardeletegetget_strict: Read without converting corrupt/non-object state into an empty map.keyspathplugin_idscopesetupdate_strict: Atomically read, transform and replace one value under the process lock.
ctx.cancellationapi.cancellation
ctx.output_channelself._console.output_channel
ctx.trackmethodRegister a plugin-owned resource for automatic unload cleanup.
ctx.on_startupmethodRun fn once the server has started (its Tool registry and Run queue exist).
ctx.startup_hooksmethod
ctx.disposemethod
ctx.sceneproperty
ctx.viewportpropertyThe plugin-scoped viewport facade (RFC-006 + RFC-010): render-spec push + built-in passes.
ctx.consoleproperty
ctx.complete_walkthroughmethod