|
|
3 месяцев назад | |
|---|---|---|
| .. | ||
| src | 3 месяцев назад | |
| tests | 3 месяцев назад | |
| README.md | 3 месяцев назад | |
| package.json | 3 месяцев назад | |
| tsconfig.json | 3 месяцев назад | |
Agent interface, registry, and agent/* event vocabulary. Every plugin (UI,
hooks, orchestrators) programs against the Agent handle defined here — it has
zero loop dependency, so the loop is swappable.
AgentRegistry (ctx key: agents)Tracks live agents so UI, hook, and orchestrator plugins can find them without importing the concrete loop package.
ctx.agents.register(agent: Agent): () => void
Register a live agent. Disposed with the calling fiber.ctx.agents.get(id: string): Agent | undefinedctx.agents.list(): Agent[]The full agent/* event taxonomy is declared via declaration merging in
dsh-agent (not dsh-agent-loop), so plugins depend only on this package.
agent/created, agent/disposed — registration/deregistrationagent/status — idle / running / disposed transitionagent/queued — message entered inbox (source-resolved, steering flag)agent/turn-start, agent/turn-end (carries TurnEndReason)agent/step-start, agent/step-endagent/request — mutate GenerateOptions before the model call (hooks,
compaction, model switching, tool filtering)agent/step-result — post-process the assembled assistant message before tool
dispatch (validates what the log records)agent/turn-continuation — override the continue/stop decision
(force-continue /loop, force-stop budget guard)agent/stream-chunk — raw chunk from the model (token-level UI/log feed)agent/steering — steering content injected mid-turnagent/error — step/turn errortypes.ts)The handle every plugin programs against:
agent.send(content, options?) — queue a message; starts a turn when idleagent.steer(content, options?) — steer a running turn (inject between steps);
behaves like send when idleagent.inject(content, options?) — inject in-session context without triggering
a turn (context/message event); next request sees itagent.abort(reason?) — abort the in-flight stepagent.session, agent.status, agent.options, agent.idAgentLoop.create() is the concrete implementation (in
dsh-agent-loop). Replace the loop by implementing Agent and registering
via ctx.agents.register().agent/* events are declared here — no dependency on the
loop package needed.AgentLoop.create(), semantics deferred.