98 lines
3.7 KiB
Markdown
98 lines
3.7 KiB
Markdown
<!-- 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.
|
|
|
|
[Source](https://github.com/deepseek-harness/deepseek-harness/blob/master/packages/ui/commands/src/index.ts#L216)
|
|
|
|
### ctx.commands.register(definition)
|
|
|
|
```ts website-api
|
|
/**
|
|
* Register a global or calling-agent-scoped command.
|
|
* @param definition - discovery metadata, surface mask, and direct UI handler.
|
|
* @returns the exact effect disposer that unregisters this definition.
|
|
*/
|
|
register(definition: CommandDefinition): () => void
|
|
```
|
|
|
|
Register a global or calling-agent-scoped command.
|
|
|
|
- `definition` — discovery metadata, surface mask, and direct UI handler.
|
|
|
|
**Returns** the exact effect disposer that unregisters this definition.
|
|
|
|
[Source](https://github.com/deepseek-harness/deepseek-harness/blob/master/packages/ui/commands/src/index.ts#L229)
|
|
|
|
### ctx.commands.list(agent, surface)
|
|
|
|
```ts website-api
|
|
/**
|
|
* List the effective immutable command descriptors for one agent and surface.
|
|
* @param agent - exact receiving agent and scoped-layer key.
|
|
* @param surface - UI adapter requesting discovery metadata.
|
|
* @returns name-sorted descriptors after scoped shadowing and surface filtering.
|
|
*/
|
|
list(agent: Agent, surface: CommandSurface): readonly CommandDescriptor[]
|
|
```
|
|
|
|
List the effective immutable command descriptors for one agent and surface.
|
|
|
|
- `agent` — exact receiving agent and scoped-layer key.
|
|
- `surface` — UI adapter requesting discovery metadata.
|
|
|
|
**Returns** name-sorted descriptors after scoped shadowing and surface filtering.
|
|
|
|
[Source](https://github.com/deepseek-harness/deepseek-harness/blob/master/packages/ui/commands/src/index.ts#L257)
|
|
|
|
### ctx.commands.find(agent, surface, name)
|
|
|
|
```ts website-api
|
|
/**
|
|
* Resolve one effective command definition.
|
|
* @param agent - exact receiving agent and scoped-layer key.
|
|
* @param surface - UI adapter performing the lookup.
|
|
* @param name - command name without a slash.
|
|
* @returns the scoped shadow or global definition when visible on the surface.
|
|
*/
|
|
find(agent: Agent, surface: CommandSurface, name: string): CommandDefinition | undefined
|
|
```
|
|
|
|
Resolve one effective command definition.
|
|
|
|
- `agent` — exact receiving agent and scoped-layer key.
|
|
- `surface` — UI adapter performing the lookup.
|
|
- `name` — command name without a slash.
|
|
|
|
**Returns** the scoped shadow or global definition when visible on the surface.
|
|
|
|
[Source](https://github.com/deepseek-harness/deepseek-harness/blob/master/packages/ui/commands/src/index.ts#L272)
|
|
|
|
### ctx.commands.execute(agent, surface, line, signal)
|
|
|
|
```ts website-api
|
|
/**
|
|
* Parse and execute a known command without sending it to the model.
|
|
* @param agent - exact receiving agent.
|
|
* @param surface - dispatching UI adapter.
|
|
* @param line - complete slash-command line.
|
|
* @param signal - cancellation signal owned by the UI request.
|
|
* @returns a detached result, or `undefined` when syntax/name/surface does not resolve.
|
|
*/
|
|
async execute( agent: Agent, surface: CommandSurface, line: string, signal: AbortSignal, ): Promise<CommandResult | undefined>
|
|
```
|
|
|
|
Parse and execute a known command without sending it to the model.
|
|
|
|
- `agent` — exact receiving agent.
|
|
- `surface` — dispatching UI adapter.
|
|
- `line` — complete slash-command line.
|
|
- `signal` — cancellation signal owned by the UI request.
|
|
|
|
**Returns** a detached result, or `undefined` when syntax/name/surface does not resolve.
|
|
|
|
[Source](https://github.com/deepseek-harness/deepseek-harness/blob/master/packages/ui/commands/src/index.ts#L285)
|