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.
| Member | Object | Its methods |
|---|---|---|
ctx.plugin_id | plugin_id | |
ctx.path | Path(path) | |
ctx.api | api | |
ctx.system | system | |
ctx.subscriptions | DisposableStore | addappenddisposedisposedextend |
ctx.tools | ScopedToolApi | registerunregister |
ctx.commands | ScopedCommandApi | executeregister |
ctx.views | ScopedViewsApi | register_providerregister_tree_view |
ctx.handlers | ScopedHandlerApi | add: Contribute a core.protocol.handler.Handler class (system Plugins only). |
ctx.rpc | PluginRpc | forget: 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.http | ScopedHttpApi | add_routesapply: Mount the routes not yet mounted on server.app.base_path |
ctx.runs | ScopedRunsApi | emit: 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.fs | ProjectFs | delete: 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_lifecycle | ScopedSceneLifecycleApi | on |
ctx.components | ComponentsApi | add_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.parameters | ParametersApi(plugin_id, api) | |
ctx.walkthroughs | ScopedWalkthroughApi | completecomplete_event |
ctx.capabilities | ScopedCapabilityApi | providerequire |
ctx.events | ScopedEventApi | publishsubscribe |
ctx.agent | ScopedAgentApi | complete: 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.solvers | ScopedSolverApi | callcancelqueryread_result_refsolvestatus |
ctx.scene_time | api.scene_time | |
ctx.streams | ScopedStreamsApi | closeclose_ownererroropenpublish |
ctx.data_sources | ScopedDataSourcesApi | open_stream_sourcerefregisterregister_timeline_datasetsubscription_demand |
ctx.state | PluginState | for_scope |
ctx.global_state | self.state.global_state | |
ctx.workspace_state | self.state.workspace_state | |
ctx.storage | ScopedMemento | cleardeletegetget_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.cancellation | api.cancellation | |
ctx.output_channel | self._console.output_channel | |
ctx.track | method | Register a plugin-owned resource for automatic unload cleanup. |
ctx.on_startup | method | Run fn once the server has started (its Tool registry and Run queue exist). |
ctx.startup_hooks | method | |
ctx.dispose | method | |
ctx.scene | property | |
ctx.viewport | property | The plugin-scoped viewport facade (RFC-006 + RFC-010): render-spec push + built-in passes. |
ctx.console | property | |
ctx.complete_walkthrough | method |