feat(ui): add plugin command registry
This commit is contained in:
@@ -46,6 +46,10 @@
|
||||
"text": "ctx.codeRuntime",
|
||||
"link": "/zh-CN/api/harness/code-runtime"
|
||||
},
|
||||
{
|
||||
"text": "ctx.commands",
|
||||
"link": "/zh-CN/api/harness/commands"
|
||||
},
|
||||
{
|
||||
"text": "ctx.compact",
|
||||
"link": "/zh-CN/api/harness/compact"
|
||||
|
||||
97
website/zh-CN/api/harness/commands.md
Normal file
97
website/zh-CN/api/harness/commands.md
Normal file
@@ -0,0 +1,97 @@
|
||||
<!-- 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)
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
# Harness events
|
||||
|
||||
Every event the harness packages declare on the cordis event bus (44 total), grouped by scope. The **mode** is the dispatch semantics (`emit` fire-and-forget, `parallel` awaited, `serial` first-bail, `waterfall` veto-chain — a waterfall listener MUST call `next()` to delegate).
|
||||
Every event the harness packages declare on the cordis event bus (45 total), grouped by scope. The **mode** is the dispatch semantics (`emit` fire-and-forget, `parallel` awaited, `serial` first-bail, `waterfall` veto-chain — a waterfall listener MUST call `next()` to delegate).
|
||||
|
||||
## agent/*
|
||||
|
||||
@@ -472,6 +472,25 @@ Ask composed answerers for one decision. Return an outcome to claim the request
|
||||
|
||||
[Source](https://github.com/deepseek-harness/deepseek-harness/blob/master/packages/ui/user-approval/src/index.ts#L31)
|
||||
|
||||
## commands/*
|
||||
|
||||
### commands/change
|
||||
|
||||
**Mode:** `emit`
|
||||
|
||||
```ts website-api
|
||||
/**
|
||||
* A command was registered or unregistered. This is an unfiltered registry
|
||||
* notification because a global or scoped change may affect any UI view.
|
||||
* @mode emit
|
||||
*/
|
||||
'commands/change'(): void
|
||||
```
|
||||
|
||||
A command was registered or unregistered. This is an unfiltered registry notification because a global or scoped change may affect any UI view.
|
||||
|
||||
[Source](https://github.com/deepseek-harness/deepseek-harness/blob/master/packages/ui/commands/src/index.ts#L93)
|
||||
|
||||
## fs/*
|
||||
|
||||
### fs/edit-intent
|
||||
|
||||
Reference in New Issue
Block a user