scripts/gen-website-api.ts renders website/zh-CN/api/{cordis,harness}/* and the
api-sidebar.json fragment the VitePress config imports, so pages and navigation
can never drift from the code: signatures, @param/@returns prose, dispatch
modes, and GitHub source links are extracted, never transcribed, and the
generator hard-errors on any rendered member missing docs. verify-website-api
(doc-sync + run-gates) is the freshness gate.
Replaces the hand-written zh api pages (7 pages covering 7 of 15 services,
with phantom APIs: Context.current/Context.events, agent/post-step, tool/call,
compact/*, llm/pre-request none of which exist) with generated English
references: 5 cordis pages, 15 per-service pages, and a 35-event catalog
grouped by scope. The hand-written hub api/index.md stays and now indexes the
full surface; zh for these pages arrives with the unified translation flow.
3.5 KiB
ctx.agents
AgentRegistry — provided by @deepseek-ai/dsh-agent.
Agent registry (ctx.agents): tracks live agents so UI, hook, and orchestrator plugins can find them without depending on the concrete loop package. Agent creation is provided by whichever plugin implements the AgentFactory (phase 1: @deepseek-ai/dsh-agent-loop), registered via setFactory.
ctx.agents.setFactory(factory)
setFactory(factory: AgentFactory): () => void
Register the agent-creation factory (the loop calls this on construction, effect-scoped). Throws if a factory is already registered. Returns the disposer; on dispose the factory slot is cleared.
factory— the loop-owned factory {@link create}/{@link resume} delegate to.
Returns the disposer that clears the factory slot.
ctx.agents.create(options)
create(options: CreateAgentOptions): AgentHandle
Create, start, and register a new agent through the registered factory. Distinct from register (which records an already-constructed agent): this constructs the agent and its session. Throws if no factory is registered. Returns an AgentHandle — the owner disposes it to tear down exactly this agent.
options— agent id, session id/seed/metadata, and agent options.
Returns the handle whose dispose tears down exactly this agent.
ctx.agents.resume(options)
async resume(options: ResumeAgentOptions): Promise<AgentHandle>
Load a persisted session and resume an agent on it through the registered factory. Rejects if no factory is registered; the factory rejects if session persistence is not configured. Returns an AgentHandle.
options— the persisted session id plus agent id and options.
Returns the handle for the resumed agent.
ctx.agents.register(agent)
register(agent: Agent): () => void
Register a live agent. Throws if an agent with the same id is already registered. Emits agent/created on registration and agent/disposed when the calling fiber is disposed. Returns the disposer.
agent— the already-constructed agent to record in the store.
Returns the disposer that removes the agent and emits agent/disposed.
ctx.agents.get(id)
get(id: AgentId): Agent | undefined
Look up a live agent.
id— the agent id to look up.
Returns the agent, or undefined when no live agent has that id.
ctx.agents.list()
list(): Agent[]
All live agents, in registration order.
Returns a fresh array; mutating it does not affect the registry.