# Conflicts: # docs/architecture.md # docs/config-catalog.md # docs/cordis-catalog/events.md # docs/event-producer-consumer.md # docs/module-graph.md # examples/coding-agent/cordis.yml # examples/echo-agent/cordis.yml # knip.json # packages/core/agent-loop/README.md # packages/core/agent-loop/tests/config-session-id.spec.ts # packages/examples/README.md # packages/examples/stdio-demo/README.md # packages/examples/stdio-demo/tests/stdio-agent.spec.ts
4.9 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 (@deepseek-ai/dsh-agent-loop), registered via setFactory.
ctx.agents.setFactory(factory)
setFactory(factory: AgentFactory): () => void
Register the effect-scoped creation factory, rejecting a duplicate. Service factories are retraced through each create/resume caller for ownership.
factory— the loop-owned factorycreate/resumedelegate to.
Returns the exact Cordis effect disposer.
ctx.agents.create(options)
async create(options: CreateAgentOptions): Promise<AgentHandle>
Create and publish an owned agent and session through the active factory. Rejects if no factory is registered or creation, setup, or publication fails.
options— agent id, session id/seed/metadata, and agent options.
Returns the handle after setup, rollback-covered publication, and loop start complete.
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 or persistence/setup fails.
options— persisted identity, configuration, and optional setup.
Returns the handle after setup, rollback-covered publication, and loop start complete.
ctx.agents.register(agent)
register(agent: Agent): () => void
Register a live agent in the calling effect scope, with scope-filtered creation and disposal events. Duplicate ids throw.
agent— the already-constructed agent to record in the store.
Returns the exact Cordis effect disposer for nested teardown ordering.
ctx.agents.enter(agent)
enter(agent: Agent): () => void
Insert an unpublished agent for an ordered factory transaction.
agent— the prepared, unpublished agent.
Returns an idempotent closure that removes this exact entry and emits the paired disposal edge; detachment during creation dispatch is deferred.
ctx.agents.announce(agent)
announce(agent: Agent): void
Announce an agent previously inserted with enter.
agent— the live inserted agent to announce.
ctx.agents.reportStartFailure(id, error)
reportStartFailure(id: AgentId, error: Error): () => void
Report a contained declarative startup failure and retain it for late UI observers.
id— the configured agent id that failed before publication.error— the normalized startup error.
Returns a disposer that clears this exact failure record.
ctx.agents.getStartFailure(id)
getStartFailure(id: AgentId): Error | undefined
Return a retained declarative startup failure for an id that never became live.
id— the configured agent id.
Returns the startup error, or undefined when the id has no retained failure.
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.