Skip to main content

Module command_executor

Module command_executor 

Source
Expand description

Running ObjectiveAI CLI commands from inside a plugin.

A plugin cannot run the CLI itself — there is no binary in its container and no daemon it is allowed to dial. What it has is the MCP connection the host already opened, and an extension that runs backwards along it: the plugin declares the objectiveai capability, pushes a notifications/objectiveai/cli_request frame naming the command it wants, and the HOST runs it and POSTs the results back, one frame per item, to {mcp_url}/objectiveai/command.

command_executor wraps that exchange in the SDK’s own [CommandExecutor] trait, so a plugin issues commands exactly the way anything else in ObjectiveAI does.

let executor = objectiveai_mcp_plugin_framework::command_executor();
let _item: serde_json::Value = executor.execute_one(request, None).await?;

An executor can be taken before serve is called. All of its state is process-global, so the value itself carries nothing that has to exist yet. Used before a client has connected, execute simply WAITS for one rather than failing: there is no peer to push a notification to until then, and a plugin that built its executor during startup should not be punished for it.

Every exchange is independent. Each run has its own correlation id and its own channel, and the response endpoint routes purely by id through a sharded map — so any number of commands run at once and none of them queue behind another. Frame order is guaranteed per run, never across runs.

Structs§

Executor
An executor that runs commands through the host.

Enums§

Error
Everything a command run can fail with.

Functions§

command_executor
An executor for ObjectiveAI CLI commands, run by the host on this plugin’s behalf.