2026-07-05 00:45:06 +08:00
<!-- Generated by scripts/gen-cordis-catalog.ts — do not edit by hand.
Run `pnpm run gen-cordis-catalog` to regenerate. -->
# Cordis Services Catalog
Every `ctx.<key>` service a plugin can call: the exact public interface plus the class JSDoc. This is one axis of the **wiring ** reference a plugin author works against — the events a plugin listens to are the sibling [events catalog ](events.md ), and [core-data-structures/ ](../core-data-structures/core.md ) catalogs the * data structures * these signatures move around. An abstract seam (e.g. `ctx.bash` ) is implemented by a separate package; the interface is what consumers code against.
This file is GENERATED from source (`scripts/gen-cordis-catalog.ts` ) and verified fresh by `pnpm run verify-cordis-catalog` (part of `doc-sync` ) — do not edit it by hand. Signature blocks use a `ts cordis-catalog` fence (skipped by doc-typecheck, since a bare signature is not standalone-compilable). Type names in a signature link to the page that documents them.
The **harness tier ** below (the `@deepseek-ai/dsh-*` packages) is the vocabulary this repo owns. The **inherited tier ** at the end is the cordis-core + loader/hmr/timer `ctx` surface a plugin also sees — pinned vendor source, summarized tersely.
## `ctx.agentLoop` — `AgentLoop`
2026-07-12 22:49:46 +08:00
Concrete ReactLoopAgent factory and driver service.
2026-07-05 00:45:06 +08:00
```ts cordis-catalog
2026-07-05 16:50:29 +08:00
create(id: AgentId, options: AgentOptions = {}, meta: Pick<SessionHeader, 'cwd'> = {}): ReactLoopAgent
2026-07-12 08:57:05 +08:00
async createAgent(ownerCtx: Context, options: CreateAgentOptions): Promise<AgentHandle>
async resume(ownerCtx: Context, options: ResumeAgentOptions): Promise<AgentHandle>
2026-07-05 00:45:06 +08:00
` ``
2026-07-13 23:27:00 +08:00
Source: [` packages/core/agent-loop/src/index.ts:335`](../../packages/core/agent-loop/src/index.ts)
2026-07-05 00:45:06 +08:00
## ` ctx.agents` — ` AgentRegistry`
2026-07-11 22:55:40 +08:00
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.
2026-07-05 00:45:06 +08:00
` ``ts cordis-catalog
2026-07-13 11:58:55 +08:00
setFactory(factory: AgentFactory): () => void
2026-07-11 22:55:40 +08:00
async create(options: CreateAgentOptions): Promise<AgentHandle>
2026-07-05 00:45:06 +08:00
async resume(options: ResumeAgentOptions): Promise<AgentHandle>
2026-07-13 11:58:55 +08:00
register(agent: Agent): () => void
2026-07-11 22:55:40 +08:00
enter(agent: Agent): () => void
announce(agent: Agent): void
2026-07-05 00:45:06 +08:00
get(id: AgentId): Agent | undefined
list(): Agent[]
` ``
Types: [Agent](../core-data-structures/core.md)
2026-07-13 23:27:00 +08:00
Source: [` packages/core/agent/src/index.ts:133`](../../packages/core/agent/src/index.ts)
2026-07-05 00:45:06 +08:00
2026-07-09 15:25:18 +08:00
## ` ctx.approval` — ` ApprovalService`
2026-07-13 16:24:32 +08:00
Approval request and policy service. It logs each ask/outcome pair, applies session policy before answerers, and exposes deterministic policy changes to the model through prompt and pre-step notices.
2026-07-09 16:41:03 +08:00
2026-07-09 15:25:18 +08:00
` ``ts cordis-catalog
async request(req: ApprovalRequest): Promise<ApprovalOutcome>
` ``
2026-07-11 21:37:38 +08:00
Types: [ApprovalOutcome](../core-data-structures/approval.md) · [ApprovalRequest](../core-data-structures/approval.md)
2026-07-13 23:27:00 +08:00
Source: [` packages/ui/user-approval/src/index.ts:229`](../../packages/ui/user-approval/src/index.ts)
2026-07-09 15:25:18 +08:00
2026-07-05 00:45:06 +08:00
## ` ctx.bash` — ` BashExecutor` (abstract seam)
2026-07-13 23:27:00 +08:00
Registers one ` ctx.bash` implementation. Runtime command failures resolve as BashRunResult; only infrastructure failures reject. Background starts return immediately without a timeout, report completion exactly once while live, and remain cancellable by signal or kill. Output reads are incremental and flag lost buffered data; disposal kills and awaits all tasks.
2026-07-05 00:45:06 +08:00
` ``ts cordis-catalog
abstract resolve(request: BashExecRequest): BashExecSpec
abstract run(spec: BashExecSpec): Promise<BashRunResult>
abstract start(spec: BashExecSpec): BashTask
abstract get(id: BashTaskId): BashTask | undefined
abstract ownerOf(id: BashTaskId): OwnerToken | undefined
abstract list(): BashTask[]
abstract readOutput(id: BashTaskId): BashTaskRead
abstract kill(id: BashTaskId): boolean
onTaskDone(listener: BashTaskListener): () => void
` ``
Types: [BashExecRequest](../core-data-structures/bash.md) · [BashExecSpec](../core-data-structures/bash.md) · [BashRunResult](../core-data-structures/bash.md) · [BashTask](../core-data-structures/bash.md) · [BashTaskRead](../core-data-structures/bash.md)
2026-07-13 23:27:00 +08:00
Source: [` packages/bash/bash/src/index.ts:38`](../../packages/bash/bash/src/index.ts)
2026-07-05 00:45:06 +08:00
2026-07-08 02:17:24 +08:00
## ` ctx.codeRuntime` — ` CodeRuntime` (abstract seam)
2026-07-13 23:27:00 +08:00
Registers one ` ctx.codeRuntime` implementation. Program, budget, abort, and substrate failures resolve in CodeRunResult; only seam misuse rejects. Implementations bridge structured-cloneable bindings while treating programs as hostile peers, isolate runs from one another, and terminate and await in-flight runs during disposal.
2026-07-08 02:17:24 +08:00
` ``ts cordis-catalog
abstract run(request: CodeRunRequest): Promise<CodeRunResult>
` ``
2026-07-08 02:38:47 +08:00
Types: [CodeRunRequest](../core-data-structures/code-runtime.md) · [CodeRunResult](../core-data-structures/code-runtime.md)
2026-07-13 23:27:00 +08:00
Source: [` packages/code-runtime/code-runtime/src/index.ts:31`](../../packages/code-runtime/code-runtime/src/index.ts)
2026-07-08 02:17:24 +08:00
2026-07-05 00:45:06 +08:00
## ` ctx.compact` — ` CompactService` (abstract seam)
2026-07-13 23:44:44 +08:00
Abstract compaction service. Implementations own token estimation, retention, and summarization, but a successful run must replace the selected surface span with one summary node and prevent concurrent compaction of the same session. Load one implementation per context as ` ctx.compact`.
2026-07-05 00:45:06 +08:00
` ``ts cordis-catalog
2026-07-08 20:30:10 +08:00
abstract compactIfNeeded( agent: CompactAgentContext, fullSystemPrompt: string, sessionPrefix: readonly Message[], signal: AbortSignal, ): Promise<CompactionResult | null>
2026-07-06 02:16:11 +08:00
abstract compactRegion( session: Session, start: number, end: number, agent: CompactAgentContext, signal?: AbortSignal, ): Promise<CompactionResult>
2026-07-05 00:45:06 +08:00
` ``
2026-07-08 20:30:10 +08:00
Types: [Message](../core-data-structures/core.md)
2026-07-13 23:44:44 +08:00
Source: [` packages/compact/compact/src/index.ts:34`](../../packages/compact/compact/src/index.ts)
2026-07-05 00:45:06 +08:00
## ` ctx.fs` — ` FileSystem` (abstract seam)
2026-07-13 23:27:00 +08:00
Abstract filesystem provider. Targets must preserve identity across aliases; reads expose regular UTF-8 text or typed errors, listings are stable and content-free, and mutations are atomic. Optional guards add stale protection without changing the unguarded provider contract.
2026-07-05 00:45:06 +08:00
` ``ts cordis-catalog
abstract resolve(path: string, opts?: { cwd?: string }): Promise<FsTarget>
abstract stat(target: FsTarget, signal?: AbortSignal): Promise<FsInfo | undefined>
abstract readText(target: FsTarget, signal?: AbortSignal): Promise<string>
abstract streamText(target: FsTarget, signal?: AbortSignal): Promise<AsyncIterable<string>>
abstract listDir(target: FsTarget, signal?: AbortSignal): Promise<FsDirEntry[]>
abstract writeText(target: FsTarget, content: string, expected?: FsWriteIntent, signal?: AbortSignal): Promise<FsWriteOutcome>
abstract editText(target: FsTarget, edit: FsEditRequest, expected?: { version: FsVersion }, signal?: AbortSignal): Promise<FsEditOutcome>
` ``
Types: [FsEditOutcome](../core-data-structures/filesystem.md) · [FsEditRequest](../core-data-structures/filesystem.md) · [FsInfo](../core-data-structures/filesystem.md) · [FsTarget](../core-data-structures/filesystem.md) · [FsVersion](../core-data-structures/filesystem.md) · [FsWriteIntent](../core-data-structures/filesystem.md) · [FsWriteOutcome](../core-data-structures/filesystem.md)
2026-07-12 03:36:43 +08:00
Source: [` packages/fs/fs/src/index.ts:78`](../../packages/fs/fs/src/index.ts)
2026-07-05 00:45:06 +08:00
## ` ctx.llm` — ` LlmService`
The abstract ` llm` service: an adapter registry plus a streaming model-call surface, interceptable via the ` llm/stream` waterfall.
` ``ts cordis-catalog
registerAdapter(models: string[], adapter: LlmAdapter): () => void
models(): string[]
stream(options: GenerateOptions): AsyncIterable<StreamChunk>
` ``
Types: [GenerateOptions](../core-data-structures/core.md) · [StreamChunk](../core-data-structures/llm-streaming.md)
2026-07-13 23:27:00 +08:00
Source: [` packages/llm/llm/src/index.ts:75`](../../packages/llm/llm/src/index.ts)
2026-07-05 00:45:06 +08:00
2026-07-09 15:42:37 +08:00
## ` ctx.sandbox` — ` SandboxProvider` (abstract seam)
2026-07-13 23:27:00 +08:00
Abstract process-sandbox service. confine must return enforcing argv or fail closed at wrap or runner-execution time; silent unconfined passthrough is forbidden. Functional probes arbitrate multi-runner chains and may be skipped for a sole candidate, whose own refusal remains the fail-closed end.
2026-07-09 15:42:37 +08:00
` ``ts cordis-catalog
abstract confine(argv: readonly string[], policy: SandboxPolicy): ConfinedArgv
` ``
2026-07-11 21:37:38 +08:00
Types: [ConfinedArgv](../core-data-structures/sandbox.md) · [SandboxPolicy](../core-data-structures/sandbox.md)
2026-07-13 23:27:00 +08:00
Source: [` packages/sandbox/sandbox/src/index.ts:114`](../../packages/sandbox/sandbox/src/index.ts)
2026-07-09 15:42:37 +08:00
2026-07-05 00:45:06 +08:00
## ` ctx.sessionPersistence` — ` SessionPersistence` (abstract seam)
2026-07-13 16:24:32 +08:00
Durable append-only session storage. Implementations preserve contiguous, losslessly JSON-serializable events; append resolves only after durability, and load balances a complete interrupted tail without rewriting committed events.
2026-07-05 00:45:06 +08:00
` ``ts cordis-catalog
abstract create(meta: SessionHeader): Promise<void>
abstract append(id: SessionId, events: readonly SessionEvent[]): Promise<void>
abstract load(id: SessionId): Promise<{ meta: SessionHeader; events: SessionEvent[] }>
abstract list(): Promise<SessionHeader[]>
` ``
Types: [SessionEvent](../core-data-structures/core.md)
2026-07-13 23:27:00 +08:00
Source: [` packages/session-persistence/session-persistence/src/index.ts:60`](../../packages/session-persistence/session-persistence/src/index.ts)
2026-07-05 00:45:06 +08:00
## ` ctx.sessions` — ` SessionStore`
In-memory session store (` ctx.sessions`).
Persistence is intentionally not implemented here — persistence plugins subscribe to ` session/event` and flush on ` session/flush` / dispose.
` ``ts cordis-catalog
create(id?: SessionId, options?: CreateSessionOptions): Session
prepare(id?: SessionId, options?: CreateSessionOptions): Session
enter(session: Session): () => void
announce(session: Session): void
2026-07-09 01:21:27 +08:00
async flush(session: Session): Promise<void>
2026-07-05 00:45:06 +08:00
get(id: SessionId): Session | undefined
list(): Session[]
2026-07-07 09:04:49 +08:00
fork(source: SessionForkSource, boundary?: number, childSessionId?: SessionId): Session
2026-07-05 00:45:06 +08:00
` ``
2026-07-13 23:27:00 +08:00
Source: [` packages/core/session/src/index.ts:560`](../../packages/core/session/src/index.ts)
2026-07-05 00:45:06 +08:00
2026-07-05 16:50:29 +08:00
## ` ctx.skills` — ` SkillService`
2026-07-10 14:19:06 +08:00
Registry of skill providers. It merges provider catalogs with stable first-wins duplicate handling, exposes sorted model-visible summaries, and loads full skill bodies on demand.
2026-07-05 16:50:29 +08:00
` ``ts cordis-catalog
2026-07-13 11:58:55 +08:00
registerProvider(provider: SkillProvider): () => void
register(skill: SkillRegistration): () => void
2026-07-05 16:50:29 +08:00
async list(options: SkillLookupOptions = {}): Promise<SkillSummary[]>
async get(name: string, options: SkillLookupOptions = {}): Promise<SkillDefinition | undefined>
` ``
2026-07-12 22:49:46 +08:00
Source: [` packages/skill/skill/src/index.ts:158`](../../packages/skill/skill/src/index.ts)
2026-07-05 16:50:29 +08:00
2026-07-05 00:45:06 +08:00
## ` ctx.subagents` — ` SubagentService`
2026-07-12 22:49:46 +08:00
Named provider registry and capability-checked start surface.
2026-07-05 00:45:06 +08:00
` ``ts cordis-catalog
2026-07-13 11:58:55 +08:00
registerProvider(provider: SubagentProvider): () => void
2026-07-05 00:45:06 +08:00
getProvider(name: string): SubagentProvider | undefined
list(): string[]
2026-07-12 22:49:46 +08:00
async start(name: string, request: SubagentStartRequest): Promise<SubagentRun>
2026-07-05 00:45:06 +08:00
` ``
2026-07-12 22:49:46 +08:00
Source: [` packages/subagent/subagent/src/index.ts:123`](../../packages/subagent/subagent/src/index.ts)
2026-07-05 00:45:06 +08:00
## ` ctx.systemPrompt` — ` SystemPrompt`
2026-07-13 16:24:32 +08:00
Registry service for the prompt inputs assembled before each model step.
2026-07-05 00:45:06 +08:00
` ``ts cordis-catalog
2026-07-13 11:58:55 +08:00
section(section: PromptSection): () => void
tools(provider: (context: AssembleContext) => ToolProviderResult): () => void
variable(name: string, provider: (context: AssembleContext) => string | undefined): () => void
2026-07-07 20:48:41 +08:00
async assemble(context: AssembleContext = {}): Promise<PromptAssembly>
2026-07-05 00:45:06 +08:00
` ``
2026-07-13 23:44:44 +08:00
Source: [` packages/core/system-prompt/src/index.ts:213`](../../packages/core/system-prompt/src/index.ts)
2026-07-05 00:45:06 +08:00
## ` ctx.tools` — ` ToolRegistry`
2026-07-13 16:24:32 +08:00
Tool registry and execution pipeline. Scoped registrations shadow globals; one visibility resolver feeds presentation, lookup, and dispatch.
2026-07-09 01:21:27 +08:00
2026-07-05 00:45:06 +08:00
` ``ts cordis-catalog
2026-07-13 11:58:55 +08:00
register(definition: ToolDefinition): () => void
restrict(filter: ToolRestriction): () => void
guard(guard: ToolGuard): () => void
2026-07-09 01:21:27 +08:00
get(name: string, scope?: ScopeKey): ToolDefinition | undefined
schemas(scope?: ScopeKey): ToolSchema[]
2026-07-11 22:55:40 +08:00
async execute(exec: ToolExecutionInput): Promise<ToolExecutionResult>
2026-07-05 00:45:06 +08:00
` ``
2026-07-11 22:55:40 +08:00
Types: [ToolDefinition](../core-data-structures/tools.md) · [ToolExecutionInput](../core-data-structures/tools.md) · [ToolExecutionResult](../core-data-structures/tools.md)
2026-07-05 00:45:06 +08:00
2026-07-13 23:27:00 +08:00
Source: [` packages/core/tools/src/index.ts:364`](../../packages/core/tools/src/index.ts)
2026-07-05 00:45:06 +08:00
2026-07-05 17:05:33 +08:00
## ` ctx.userInteraction` — ` UserInteractionService`
` ctx.userInteraction`: one active UI provider plus an ` ask()` surface.
` ``ts cordis-catalog
registerProvider(provider: UserInteractionProvider): () => void
async ask(request: AskUserQuestionRequest): Promise<AskUserQuestionAnswer>
` ``
2026-07-09 17:55:01 +08:00
Source: [` packages/ui/user-interaction/src/index.ts:82`](../../packages/ui/user-interaction/src/index.ts)
2026-07-05 00:45:06 +08:00
## ` ctx.web` — ` WebService`
The web access service. Registered as ` ctx.web` (one instance per context).
Selection semantics (resolved at execution time, never order-dependent):
- A configured id that is registered and ` status().available` → that provider.
- A configured id not registered → ` WEB_PROVIDER_CONFIGURED_MISSING`.
- A configured id registered but unavailable → ` WEB_PROVIDER_CONFIGURED_UNAVAILABLE`.
- No id configured, exactly one registered usable provider → that provider.
- No id configured, multiple usable providers → ` WEB_PROVIDER_AMBIGUOUS`.
- No id configured, no usable provider → ` WEB_PROVIDER_UNAVAILABLE`.
` ``ts cordis-catalog
registerSearchProvider(provider: WebSearchProvider): () => void
registerFetchProvider(provider: WebFetchProvider): () => void
async search(request: WebSearchRequest, exec?: WebExecContext): Promise<WebSearchResult>
async fetch(request: WebFetchRequest, exec?: WebExecContext): Promise<WebFetchResult>
` ``
2026-07-13 23:27:00 +08:00
Source: [` packages/web/web/src/index.ts:78`](../../packages/web/web/src/index.ts)
2026-07-05 00:45:06 +08:00
2026-07-05 13:29:35 +08:00
## ` ctx.workflows` — ` WorkflowService` (abstract seam)
2026-07-13 23:44:44 +08:00
Workflow execution seam. Invalid requests throw before publication; a live run is holder-owned, its result never rejects, cancellation and disposal are bounded, and disposal waits for child cleanup within that bound. Lifecycle listener failures are contained, and ` workflow/end` fires exactly once as the result settles.
2026-07-05 13:29:35 +08:00
` ``ts cordis-catalog
abstract start(request: WorkflowStartRequest): WorkflowRun
` ``
2026-07-13 23:44:44 +08:00
Source: [` packages/workflow/workflow/src/index.ts:159`](../../packages/workflow/workflow/src/index.ts)
2026-07-05 13:29:35 +08:00
2026-07-05 00:45:06 +08:00
## Inherited ` ctx` members (cordis core + loader/hmr/timer)
The framework ` ctx` surface every plugin also sees, beyond the harness services above. This is pinned vendor source ([vendoring policy](../../vendor/README.md)); it is summarized here so the page is a complete picture of what ` ctx` offers, without elevating framework internals to the harness tier's prominence.
- ` ctx.on / ctx.once` — Register an event listener (disposable). ([` vendor/cordis/src/events.ts:29`](../../vendor/cordis/src/events.ts))
- ` ctx.emit / ctx.parallel / ctx.serial / ctx.bail / ctx.waterfall` — Dispatch an event (sync / awaited / first-bail / veto-chain). ([` vendor/cordis/src/events.ts:29`](../../vendor/cordis/src/events.ts))
- ` ctx.plugin / ctx.inject` — Load a plugin / declare required services. ([` vendor/cordis/src/registry.ts:144`](../../vendor/cordis/src/registry.ts))
- ` ctx.effect` — Register a disposable side effect tied to the fiber. ([` vendor/cordis/src/fiber.ts:9`](../../vendor/cordis/src/fiber.ts))
- ` ctx.get / ctx.set / ctx.provide / ctx.accessor / ctx.mixin` — Low-level service-store access and binding. ([` vendor/cordis/src/reflect.ts:7`](../../vendor/cordis/src/reflect.ts))
- ` ctx.extend / ctx.isolate / ctx.intercept` — Derive a child context (scoped services / isolation / interception). ([` vendor/cordis/src/context.ts:35`](../../vendor/cordis/src/context.ts))
- ` ctx.root / ctx.scope / ctx.fiber / ctx.registry / ctx.reflect / ctx.events / ctx.logger` — Ambient handles onto the running context graph. ([` vendor/cordis/src/context.ts:16`](../../vendor/cordis/src/context.ts))
- ` ctx.timer (+ interval / timeout / throttle / debounce / setTimeout / setInterval)` — Disposable timer helpers. The ` timer` key is provided at runtime; the six helpers are mixed onto ctx directly (declared via Pick). ([` vendor/timer/src/index.ts:4`](../../vendor/timer/src/index.ts))
- ` ctx.loader` — The config Loader that booted the app (present under the loader). ([` vendor/loader/src/index.ts:30`](../../vendor/loader/src/index.ts))
- ` ctx.hmr` — The hot-module-reload watcher (present under the hmr plugin). ([` vendor/hmr/src/index.ts:15`](../../vendor/hmr/src/index.ts))