Signature
agent.start(): Promise<XsafAgent>Usage
import { agent } from "@xsaf/agent";
const bot = agent(config).memory(memory).channel(channel);
await bot.start();.start() seals the agent, initializes configured resources, and returns the running agent. Concurrent calls coalesce into the same startup operation.
Lifecycle behavior
Resources start in declaration order. If a resource fails, XSAF closes everything that already started before rejecting. Registration order matters when one capability depends on another—for example, call .mcp() before .serve() when remotely discovered tools must be included in the served snapshot.
A started agent forwards .invoke(), .ask(), and .fetch() to its runtime. Calling those methods before startup throws.
Always pair startup with .stop(), normally in a finally block or process-shutdown handler.