brain_deer.commands.registry¶
Command registry: the single source of truth for BrainDeer actions.
A Command is a named, schema-described, callable operation on the viewer.
The same registry powers both the human command palette (Cmd/Ctrl+K) and the
BrainDeer AI tool-calling loop, so anything a user can type, the assistant can
invoke, and vice-versa.
Design goals¶
Flat snake_case ids (e.g.
set_colormap,camera_rotate) so ids are valid LLM tool names without sanitisation, and stay backwards compatible with the AI plugin’s original action names.Typed params with light coercion + validation, and a JSON-schema view for provider-native function calling (OpenAI
tools/ Anthropictool_use).Safety metadata:
read_only(safe to auto-run, no state change) anddestructive(needs explicit confirmation) drive the approval policy.
Exceptions¶
Raised when a command cannot be dispatched (bad args, unknown id, handler error). |
Classes¶
One typed parameter of a command. |
|
A named, schema-described operation on the viewer/session. |
|
Structured outcome of a command dispatch. |
|
Holds commands and dispatches them by id. |
Module Contents¶
- exception brain_deer.commands.registry.CommandError¶
Bases:
ExceptionRaised when a command cannot be dispatched (bad args, unknown id, handler error).
- class brain_deer.commands.registry.CommandParam¶
One typed parameter of a command.
- coerce(value: Any) Any¶
Coerce a raw (often string/JSON) value to the declared type, with validation.
- class brain_deer.commands.registry.Command¶
A named, schema-described operation on the viewer/session.
- class brain_deer.commands.registry.CommandResult¶
Structured outcome of a command dispatch.
- class brain_deer.commands.registry.CommandRegistry¶
Holds commands and dispatches them by id.
- add_observer(callback: collections.abc.Callable[[Command, dict[str, Any], CommandResult], None]) None¶
Register a post-dispatch observer:
callback(command, clean_kwargs, result).
- add(command_id: str, title: str, category: str, handler: collections.abc.Callable[Ellipsis, Any], *, params: list[CommandParam] | None = None, description: str = '', read_only: bool = False, destructive: bool = False, keywords: list[str] | None = None) Command¶
Convenience factory + register in one call.