pub async fn run(config: BlockConfig) -> BlockResult<()>Expand description
Primary SDK entry point: run one agent-block execution to completion.
Given a fully-populated BlockConfig, this drives the entire host
orchestration for a single run: it resolves the script / prompt / context /
secret-key sources, loads .env from the project root, spawns the main and
handler Lua Isles, opens the kv / sql / ts SQLite connections, optionally
connects to the mesh relay, initialises the MCP manager, injects the Lua
stdlib bridge plus any host-supplied tools / handlers, executes the script,
and finally tears everything down (MCP disconnect, Isle shutdown, auto-serve
dispatcher join).
The returned future is Send, so SDK consumers may tokio::spawn it.
ยงErrors
Returns BlockError when any stage fails: source resolution / file reads
(BlockError::Script), mesh connect (BlockError::Mesh), EventBus or
Isle setup (BlockError::Bus / BlockError::Runtime), or a script
runtime error (BlockError::Script). When a shutdown_token is supplied
and fires before the script finishes, returns BlockError::Cancelled
after the shutdown sequence completes.