2026-07-19 22:11:59 +08:00
<!-- Generated by scripts/gen-website-api.ts — do not edit by hand. Run `pnpm run gen-website-api` to regenerate. -->
# ctx.commands
`CommandService` — provided by `@deepseek-ai/dsh-commands` .
Human-command registry. Plain-context definitions are global; definitions registered through a command-injected child of an agent context shadow globals for that agent.
2026-07-20 17:41:22 +08:00
[Source ](https://github.com/deepseek-harness/deepseek-harness/blob/master/packages/ui/commands/src/index.ts#L207 )
2026-07-19 22:11:59 +08:00
### ctx.commands.register(definition)
```ts website-api
/**
* Register a global or calling-agent-scoped command.
2026-07-20 17:41:22 +08:00
* @param definition - discovery metadata and direct UI handler.
2026-07-19 22:11:59 +08:00
* @returns the exact effect disposer that unregisters this definition.
*/
register(definition: CommandDefinition): () => void
` ``
Register a global or calling-agent-scoped command.
2026-07-20 17:41:22 +08:00
- ` definition` — discovery metadata and direct UI handler.
2026-07-19 22:11:59 +08:00
**Returns** the exact effect disposer that unregisters this definition.
2026-07-20 17:41:22 +08:00
[Source](https://github.com/deepseek-harness/deepseek-harness/blob/master/packages/ui/commands/src/index.ts#L220)
2026-07-19 22:11:59 +08:00
2026-07-20 17:41:22 +08:00
### ctx.commands.list(agent)
2026-07-19 22:11:59 +08:00
` ``ts website-api
/**
2026-07-20 17:41:22 +08:00
* List the effective immutable command descriptors for one agent.
2026-07-19 22:11:59 +08:00
* @param agent - exact receiving agent and scoped-layer key.
2026-07-20 17:41:22 +08:00
* @returns name-sorted descriptors after scoped shadowing.
2026-07-19 22:11:59 +08:00
*/
2026-07-20 17:41:22 +08:00
list(agent: Agent): readonly CommandDescriptor[]
2026-07-19 22:11:59 +08:00
` ``
2026-07-20 17:41:22 +08:00
List the effective immutable command descriptors for one agent.
2026-07-19 22:11:59 +08:00
- ` agent` — exact receiving agent and scoped-layer key.
2026-07-20 17:41:22 +08:00
**Returns** name-sorted descriptors after scoped shadowing.
2026-07-19 22:11:59 +08:00
2026-07-20 17:41:22 +08:00
[Source](https://github.com/deepseek-harness/deepseek-harness/blob/master/packages/ui/commands/src/index.ts#L247)
2026-07-19 22:11:59 +08:00
2026-07-20 17:41:22 +08:00
### ctx.commands.find(agent, name)
2026-07-19 22:11:59 +08:00
` ``ts website-api
/**
* Resolve one effective command definition.
* @param agent - exact receiving agent and scoped-layer key.
* @param name - command name without a slash.
2026-07-20 17:41:22 +08:00
* @returns the scoped shadow or global definition.
2026-07-19 22:11:59 +08:00
*/
2026-07-20 17:41:22 +08:00
find(agent: Agent, name: string): CommandDefinition | undefined
2026-07-19 22:11:59 +08:00
` ``
Resolve one effective command definition.
- ` agent` — exact receiving agent and scoped-layer key.
- ` name` — command name without a slash.
2026-07-20 17:41:22 +08:00
**Returns** the scoped shadow or global definition.
2026-07-19 22:11:59 +08:00
2026-07-20 17:41:22 +08:00
[Source](https://github.com/deepseek-harness/deepseek-harness/blob/master/packages/ui/commands/src/index.ts#L260)
2026-07-19 22:11:59 +08:00
2026-07-20 17:41:22 +08:00
### ctx.commands.execute(agent, line, signal)
2026-07-19 22:11:59 +08:00
` ``ts website-api
/**
* Parse and execute a known command without sending it to the model.
* @param agent - exact receiving agent.
* @param line - complete slash-command line.
* @param signal - cancellation signal owned by the UI request.
2026-07-20 17:41:22 +08:00
* @returns a detached result, or ` undefined` when syntax or name does not resolve.
2026-07-19 22:11:59 +08:00
*/
2026-07-20 17:41:22 +08:00
async execute( agent: Agent, line: string, signal: AbortSignal, ): Promise<CommandResult | undefined>
2026-07-19 22:11:59 +08:00
` ``
Parse and execute a known command without sending it to the model.
- ` agent` — exact receiving agent.
- ` line` — complete slash-command line.
- ` signal` — cancellation signal owned by the UI request.
2026-07-20 17:41:22 +08:00
**Returns** a detached result, or ` undefined` when syntax or name does not resolve.
2026-07-19 22:11:59 +08:00
2026-07-20 17:41:22 +08:00
[Source ](https://github.com/deepseek-harness/deepseek-harness/blob/master/packages/ui/commands/src/index.ts#L271 )