better-dsh 0.2.3-e → 0.2.3-g
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/50_test-reports/2026-09-13-preact-ui-shell/345/256/236/346/265/213/346/212/245/345/221/212.md +1 -1
- package/docs/50_test-reports/2026-09-14-4999-skill/346/270/205/345/215/225/344/270/216lsp-gate/345/256/236/346/265/213/346/212/245/345/221/212.md +54 -0
- package/docs/specs/agent/spec.md +54 -0
- package/docs/specs/ast/spec.md +34 -0
- package/docs/specs/compaction-recall/spec.md +46 -0
- package/docs/specs/ctx/spec.md +107 -0
- package/docs/specs/dsh/spec.md +47 -0
- package/docs/specs/dvc/spec.md +87 -0
- package/docs/specs/escalation-guidance/spec.md +44 -0
- package/docs/specs/fs-scheme-resolution/spec.md +37 -0
- package/docs/specs/hash-edit/spec.md +41 -0
- package/docs/specs/http-read/spec.md +73 -0
- package/docs/specs/kernel-provisioning/spec.md +53 -0
- package/docs/specs/lsp/spec.md +121 -0
- package/docs/specs/mobile-layout/spec.md +108 -0
- package/docs/specs/model-failover/spec.md +20 -0
- package/docs/specs/preact-ui-shell/spec.md +22 -0
- package/docs/specs/repl-dispatch-resilience/spec.md +21 -0
- package/docs/specs/skill/spec.md +58 -0
- package/docs/specs/tool-surface/spec.md +222 -0
- package/docs/specs/url-schema/spec.md +148 -0
- package/docs/specs/web-trust-fence/spec.md +43 -0
- package/dsh-docs/AGENTS.md +75 -0
- package/dsh-docs/agent-lifecycle.md +84 -0
- package/dsh-docs/agent-lifecycle.zh.md +86 -0
- package/dsh-docs/api-gateway.md +164 -0
- package/dsh-docs/api-gateway.zh.md +164 -0
- package/dsh-docs/architecture.md +150 -0
- package/dsh-docs/architecture.zh.md +154 -0
- package/dsh-docs/capability-seams.md +543 -0
- package/dsh-docs/capability-seams.zh.md +545 -0
- package/dsh-docs/config-catalog.md +3473 -0
- package/dsh-docs/config-catalog.zh.md +3474 -0
- package/dsh-docs/cookbook/adding-a-package.md +117 -0
- package/dsh-docs/cookbook/adding-a-package.zh.md +119 -0
- package/dsh-docs/cookbook/adding-a-remote-api.md +197 -0
- package/dsh-docs/cookbook/adding-a-remote-api.zh.md +197 -0
- package/dsh-docs/cookbook/adding-a-settings-card.md +102 -0
- package/dsh-docs/cookbook/adding-a-settings-card.zh.md +102 -0
- package/dsh-docs/cookbook/adding-a-tool.md +101 -0
- package/dsh-docs/cookbook/adding-a-tool.zh.md +103 -0
- package/dsh-docs/cookbook/adding-a-vendored-package.md +59 -0
- package/dsh-docs/cookbook/adding-a-vendored-package.zh.md +59 -0
- package/dsh-docs/cookbook/adding-an-llm-adapter.md +43 -0
- package/dsh-docs/cookbook/adding-an-llm-adapter.zh.md +43 -0
- package/dsh-docs/cookbook/extension-cookbook.md +132 -0
- package/dsh-docs/cookbook/extension-cookbook.zh.md +136 -0
- package/dsh-docs/cookbook/maintaining-dsh-code-review.md +64 -0
- package/dsh-docs/cookbook/maintaining-dsh-code-review.zh.md +64 -0
- package/dsh-docs/cookbook/responding-to-pr-review-on-a-stack.md +32 -0
- package/dsh-docs/cookbook/responding-to-pr-review-on-a-stack.zh.md +32 -0
- package/dsh-docs/cordis-api/context.md +364 -0
- package/dsh-docs/cordis-api/context.zh.md +366 -0
- package/dsh-docs/cordis-api/events.md +207 -0
- package/dsh-docs/cordis-api/events.zh.md +209 -0
- package/dsh-docs/cordis-api/fiber.md +375 -0
- package/dsh-docs/cordis-api/fiber.zh.md +377 -0
- package/dsh-docs/cordis-api/inherited.md +39 -0
- package/dsh-docs/cordis-api/registry.md +152 -0
- package/dsh-docs/cordis-api/registry.zh.md +154 -0
- package/dsh-docs/cordis-api/service.md +102 -0
- package/dsh-docs/cordis-api/service.zh.md +104 -0
- package/dsh-docs/cordis-primer.md +45 -0
- package/dsh-docs/cordis-primer.zh.md +51 -0
- package/dsh-docs/cordis-tutorial/01-first-plugin.md +95 -0
- package/dsh-docs/cordis-tutorial/01-first-plugin.zh.md +95 -0
- package/dsh-docs/cordis-tutorial/02-lifecycle-and-effects.md +98 -0
- package/dsh-docs/cordis-tutorial/02-lifecycle-and-effects.zh.md +98 -0
- package/dsh-docs/cordis-tutorial/03-services.md +98 -0
- package/dsh-docs/cordis-tutorial/03-services.zh.md +98 -0
- package/dsh-docs/cordis-tutorial/04-events.md +144 -0
- package/dsh-docs/cordis-tutorial/04-events.zh.md +144 -0
- package/dsh-docs/cordis-tutorial/05-config.md +84 -0
- package/dsh-docs/cordis-tutorial/05-config.zh.md +84 -0
- package/dsh-docs/cordis-tutorial/06-composition-and-hmr.md +113 -0
- package/dsh-docs/cordis-tutorial/06-composition-and-hmr.zh.md +113 -0
- package/dsh-docs/cordis-tutorial/07-into-the-harness.md +108 -0
- package/dsh-docs/cordis-tutorial/07-into-the-harness.zh.md +108 -0
- package/dsh-docs/cordis-tutorial/index.md +60 -0
- package/dsh-docs/cordis-tutorial/index.zh.md +62 -0
- package/dsh-docs/deepseek-llm-api-wire-extensions.md +163 -0
- package/dsh-docs/deepseek-llm-api-wire-extensions.zh.md +163 -0
- package/dsh-docs/defensive-patterns.md +33 -0
- package/dsh-docs/defensive-patterns.zh.md +35 -0
- package/dsh-docs/development.md +167 -0
- package/dsh-docs/development.zh.md +173 -0
- package/dsh-docs/event-producer-consumer.md +86 -0
- package/dsh-docs/event-producer-consumer.zh.md +88 -0
- package/dsh-docs/glossary.md +45 -0
- package/dsh-docs/glossary.zh.md +45 -0
- package/dsh-docs/graph-atlas.md +22 -0
- package/dsh-docs/graph-atlas.zh.md +24 -0
- package/dsh-docs/i18n/README.md +60 -0
- package/dsh-docs/i18n/README.zh.md +62 -0
- package/dsh-docs/i18n/style-samples.md +87 -0
- package/dsh-docs/i18n/terminology.md +214 -0
- package/dsh-docs/i18n/translation-prompt.md +263 -0
- package/dsh-docs/i18n/translation-rules.md +69 -0
- package/dsh-docs/i18n/translation-rules.zh.md +69 -0
- package/dsh-docs/module-graph.md +1411 -0
- package/dsh-docs/module-graph.zh.md +1413 -0
- package/dsh-docs/persistence-catalog.md +1075 -0
- package/dsh-docs/persistence-catalog.zh.md +1077 -0
- package/dsh-docs/postmortem/0001-acp-default-export-drops-inject.md +113 -0
- package/dsh-docs/postmortem/0001-acp-default-export-drops-inject.zh.md +113 -0
- package/dsh-docs/postmortem/0002-js-expression-disabled-filesystem-tools.md +47 -0
- package/dsh-docs/postmortem/0002-js-expression-disabled-filesystem-tools.zh.md +47 -0
- package/dsh-docs/postmortem/0003-web-agent-gui-feedback-loop.md +53 -0
- package/dsh-docs/postmortem/0003-web-agent-gui-feedback-loop.zh.md +53 -0
- package/dsh-docs/postmortem/0004-landlock-partial-notice-misclassified-child-failures.md +55 -0
- package/dsh-docs/postmortem/0004-landlock-partial-notice-misclassified-child-failures.zh.md +55 -0
- package/dsh-docs/postmortem/README.md +18 -0
- package/dsh-docs/postmortem/README.zh.md +18 -0
- package/dsh-docs/rescope.md +53 -0
- package/dsh-docs/rescope.zh.md +53 -0
- package/dsh-docs/subsystems/README.md +61 -0
- package/dsh-docs/subsystems/README.zh.md +61 -0
- package/dsh-docs/subsystems/agent-team.md +207 -0
- package/dsh-docs/subsystems/agent-team.zh.md +207 -0
- package/dsh-docs/subsystems/approval.md +170 -0
- package/dsh-docs/subsystems/approval.zh.md +170 -0
- package/dsh-docs/subsystems/attachment.md +351 -0
- package/dsh-docs/subsystems/attachment.zh.md +351 -0
- package/dsh-docs/subsystems/client-modules.md +168 -0
- package/dsh-docs/subsystems/client-modules.zh.md +168 -0
- package/dsh-docs/subsystems/code-runtime.md +195 -0
- package/dsh-docs/subsystems/code-runtime.zh.md +195 -0
- package/dsh-docs/subsystems/commands.md +219 -0
- package/dsh-docs/subsystems/commands.zh.md +219 -0
- package/dsh-docs/subsystems/compaction.md +238 -0
- package/dsh-docs/subsystems/compaction.zh.md +238 -0
- package/dsh-docs/subsystems/conversation.md +258 -0
- package/dsh-docs/subsystems/conversation.zh.md +258 -0
- package/dsh-docs/subsystems/core.md +1209 -0
- package/dsh-docs/subsystems/core.zh.md +1219 -0
- package/dsh-docs/subsystems/credentials.md +329 -0
- package/dsh-docs/subsystems/credentials.zh.md +329 -0
- package/dsh-docs/subsystems/extensions.md +382 -0
- package/dsh-docs/subsystems/extensions.zh.md +382 -0
- package/dsh-docs/subsystems/feedback.md +266 -0
- package/dsh-docs/subsystems/feedback.zh.md +266 -0
- package/dsh-docs/subsystems/filesystem.md +505 -0
- package/dsh-docs/subsystems/filesystem.zh.md +505 -0
- package/dsh-docs/subsystems/goal.md +277 -0
- package/dsh-docs/subsystems/goal.zh.md +277 -0
- package/dsh-docs/subsystems/invariants.md +88 -0
- package/dsh-docs/subsystems/invariants.zh.md +88 -0
- package/dsh-docs/subsystems/jobs.md +290 -0
- package/dsh-docs/subsystems/jobs.zh.md +290 -0
- package/dsh-docs/subsystems/llm-streaming.md +1080 -0
- package/dsh-docs/subsystems/llm-streaming.zh.md +1086 -0
- package/dsh-docs/subsystems/lsp.md +202 -0
- package/dsh-docs/subsystems/lsp.zh.md +202 -0
- package/dsh-docs/subsystems/permission-presets.md +131 -0
- package/dsh-docs/subsystems/permission-presets.zh.md +131 -0
- package/dsh-docs/subsystems/persistence.md +395 -0
- package/dsh-docs/subsystems/persistence.zh.md +395 -0
- package/dsh-docs/subsystems/plan.md +87 -0
- package/dsh-docs/subsystems/plan.zh.md +87 -0
- package/dsh-docs/subsystems/sandbox.md +220 -0
- package/dsh-docs/subsystems/sandbox.zh.md +220 -0
- package/dsh-docs/subsystems/schedule.md +192 -0
- package/dsh-docs/subsystems/schedule.zh.md +192 -0
- package/dsh-docs/subsystems/scope.md +59 -0
- package/dsh-docs/subsystems/scope.zh.md +59 -0
- package/dsh-docs/subsystems/session-projection.md +354 -0
- package/dsh-docs/subsystems/session-projection.zh.md +354 -0
- package/dsh-docs/subsystems/session-query.md +509 -0
- package/dsh-docs/subsystems/session-query.zh.md +509 -0
- package/dsh-docs/subsystems/session-reference.md +219 -0
- package/dsh-docs/subsystems/session-reference.zh.md +219 -0
- package/dsh-docs/subsystems/session-telemetry.md +194 -0
- package/dsh-docs/subsystems/session-telemetry.zh.md +194 -0
- package/dsh-docs/subsystems/session-title.md +204 -0
- package/dsh-docs/subsystems/session-title.zh.md +204 -0
- package/dsh-docs/subsystems/session.md +1155 -0
- package/dsh-docs/subsystems/session.zh.md +1159 -0
- package/dsh-docs/subsystems/settings.md +405 -0
- package/dsh-docs/subsystems/settings.zh.md +405 -0
- package/dsh-docs/subsystems/shell.md +303 -0
- package/dsh-docs/subsystems/shell.zh.md +303 -0
- package/dsh-docs/subsystems/skills.md +354 -0
- package/dsh-docs/subsystems/skills.zh.md +354 -0
- package/dsh-docs/subsystems/slots.md +175 -0
- package/dsh-docs/subsystems/slots.zh.md +175 -0
- package/dsh-docs/subsystems/spill.md +117 -0
- package/dsh-docs/subsystems/spill.zh.md +117 -0
- package/dsh-docs/subsystems/storage.md +260 -0
- package/dsh-docs/subsystems/storage.zh.md +260 -0
- package/dsh-docs/subsystems/subagent.md +766 -0
- package/dsh-docs/subsystems/subagent.zh.md +770 -0
- package/dsh-docs/subsystems/subprocess.md +324 -0
- package/dsh-docs/subsystems/subprocess.zh.md +324 -0
- package/dsh-docs/subsystems/system-prompt.md +220 -0
- package/dsh-docs/subsystems/system-prompt.zh.md +220 -0
- package/dsh-docs/subsystems/terminal.md +184 -0
- package/dsh-docs/subsystems/terminal.zh.md +184 -0
- package/dsh-docs/subsystems/todo.md +32 -0
- package/dsh-docs/subsystems/todo.zh.md +32 -0
- package/dsh-docs/subsystems/token-meter.md +105 -0
- package/dsh-docs/subsystems/token-meter.zh.md +105 -0
- package/dsh-docs/subsystems/tools.md +720 -0
- package/dsh-docs/subsystems/tools.zh.md +720 -0
- package/dsh-docs/subsystems/typert.md +343 -0
- package/dsh-docs/subsystems/typert.zh.md +343 -0
- package/dsh-docs/subsystems/user-questions.md +178 -0
- package/dsh-docs/subsystems/user-questions.zh.md +178 -0
- package/dsh-docs/subsystems/web-client.md +95 -0
- package/dsh-docs/subsystems/web-client.zh.md +95 -0
- package/dsh-docs/subsystems/web-server.md +154 -0
- package/dsh-docs/subsystems/web-server.zh.md +154 -0
- package/dsh-docs/subsystems/web.md +206 -0
- package/dsh-docs/subsystems/web.zh.md +206 -0
- package/dsh-docs/subsystems/webhook.md +70 -0
- package/dsh-docs/subsystems/webhook.zh.md +70 -0
- package/dsh-docs/subsystems/workflow.md +278 -0
- package/dsh-docs/subsystems/workflow.zh.md +278 -0
- package/dsh-docs/subsystems/workspace.md +321 -0
- package/dsh-docs/subsystems/workspace.zh.md +321 -0
- package/dsh-docs/testing.md +54 -0
- package/dsh-docs/testing.zh.md +54 -0
- package/dsh-docs/tool-catalog.md +2225 -0
- package/dsh-docs/tool-catalog.zh.md +2233 -0
- package/dsh-docs/tool-execution-pipeline.md +62 -0
- package/dsh-docs/tool-execution-pipeline.zh.md +64 -0
- package/dsh-docs/user/develop/basic/config.md +106 -0
- package/dsh-docs/user/develop/basic/config.zh.md +106 -0
- package/dsh-docs/user/develop/basic/index.md +144 -0
- package/dsh-docs/user/develop/basic/index.zh.md +144 -0
- package/dsh-docs/user/develop/basic/publish.md +183 -0
- package/dsh-docs/user/develop/basic/publish.zh.md +183 -0
- package/dsh-docs/user/develop/basic/tool.md +52 -0
- package/dsh-docs/user/develop/basic/tool.zh.md +52 -0
- package/dsh-docs/user/develop/framework/events.md +143 -0
- package/dsh-docs/user/develop/framework/events.zh.md +143 -0
- package/dsh-docs/user/develop/framework/index.md +137 -0
- package/dsh-docs/user/develop/framework/index.zh.md +137 -0
- package/dsh-docs/user/develop/framework/service.md +148 -0
- package/dsh-docs/user/develop/framework/service.zh.md +150 -0
- package/dsh-docs/user/develop/practice/dynamic-cordis.md +15 -0
- package/dsh-docs/user/develop/practice/dynamic-cordis.zh.md +15 -0
- package/dsh-docs/user/develop/practice/index.md +155 -0
- package/dsh-docs/user/develop/practice/index.zh.md +155 -0
- package/dsh-docs/user/develop/practice/llm-adapter.md +189 -0
- package/dsh-docs/user/develop/practice/llm-adapter.zh.md +189 -0
- package/dsh-docs/user/guide/github-review.md +102 -0
- package/dsh-docs/user/guide/github-review.zh.md +102 -0
- package/dsh-docs/user/guide/index.md +30 -0
- package/dsh-docs/user/guide/index.zh.md +30 -0
- package/dsh-docs/user/guide/mcp-memory.md +101 -0
- package/dsh-docs/user/guide/mcp-memory.zh.md +101 -0
- package/dsh-docs/user/guide/network-proxy.md +85 -0
- package/dsh-docs/user/guide/network-proxy.zh.md +85 -0
- package/dsh-docs/user/guide/providers.md +190 -0
- package/dsh-docs/user/guide/providers.zh.md +190 -0
- package/dsh-docs/user/guide/python-sdk.md +150 -0
- package/dsh-docs/user/guide/python-sdk.zh.md +150 -0
- package/dsh-docs/user/guide/schedule.md +21 -0
- package/dsh-docs/user/guide/schedule.zh.md +21 -0
- package/dsh-docs/user/index.md +11 -0
- package/dsh-docs/user/index.zh.md +11 -0
- package/dsh-docs/web-styling.md +29 -0
- package/dsh-docs/web-styling.zh.md +29 -0
- package/lib/client/index.js +268 -38
- package/lib/fs-aware/sandbox-plugin.js +1 -1
- package/lib/index.js +1112 -1261
- package/lib/lsp-server-registry-B8DNonhS.js +3 -0
- package/lib/lsp-server-registry-BexQagaK.js +943 -0
- package/lib/{wrap-DC8O3SYz.js → wrap-JFjcWwZf.js} +42 -16
- package/package.json +2 -1
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
# Human Commands
|
|
2
|
+
|
|
3
|
+
English | [中文](commands.zh.md)
|
|
4
|
+
|
|
5
|
+
The human-command registry service from [`dsh-commands`](../../packages/interaction/commands). Interactive adapters use it to discover and directly execute plugin-owned commands for an exact agent without creating a model message. The [command Agent Note](../../.agents/notes/implemented/feature/2026-07-19-plugin-command-registration.md) owns dispatch and lifecycle rationale; the [package README](../../packages/interaction/commands/README.md) owns composition and limitations.
|
|
6
|
+
|
|
7
|
+
Source: [`packages/interaction/commands/src/index.ts`](../../packages/interaction/commands/src/index.ts)
|
|
8
|
+
|
|
9
|
+
## Input metadata
|
|
10
|
+
|
|
11
|
+
The service exposes one optional unstructured-input descriptor: a hint plus an attachment-acceptance flag. Command availability follows plugin composition: every adapter consuming the registry sees every effective definition.
|
|
12
|
+
|
|
13
|
+
```ts type-equiv
|
|
14
|
+
/** Immutable metadata for a command's optional unstructured input. */
|
|
15
|
+
interface CommandInputDescriptor {
|
|
16
|
+
/** Placeholder shown before the user supplies free-form input. */
|
|
17
|
+
readonly hint: string
|
|
18
|
+
/**
|
|
19
|
+
* Whether composer attachments may accompany an invocation. Absent or
|
|
20
|
+
* false = the executor rejects an invocation carrying attachments and capable
|
|
21
|
+
* composers refuse the submission before dispatch. A declaring command's
|
|
22
|
+
* handler receives the admitted durable blocks and owns every further
|
|
23
|
+
* grammar decision, including rejecting sub-commands that cannot use them.
|
|
24
|
+
*/
|
|
25
|
+
readonly attachments?: boolean
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Definition
|
|
30
|
+
|
|
31
|
+
`CommandDefinition` is the plugin-authored registration. The registry validates and freezes a detached effective definition.
|
|
32
|
+
|
|
33
|
+
```ts type-equiv
|
|
34
|
+
/** Plugin-owned command registration. */
|
|
35
|
+
interface CommandDefinition {
|
|
36
|
+
/** Lowercase command name without the leading slash. */
|
|
37
|
+
readonly name: string
|
|
38
|
+
/** Human-readable summary used in discovery UI. */
|
|
39
|
+
readonly description: string
|
|
40
|
+
/** Optional free-form input hint advertised to capable clients. */
|
|
41
|
+
readonly input?: CommandInputDescriptor
|
|
42
|
+
/**
|
|
43
|
+
* Whether `command/run` records `rawInput`. Defaults to true. A command
|
|
44
|
+
* whose domain event owns the payload sets this false to avoid duplicating
|
|
45
|
+
* that payload in the session log.
|
|
46
|
+
*/
|
|
47
|
+
readonly recordInput?: boolean
|
|
48
|
+
/** Execute against the receiving agent without sending the command to the model. */
|
|
49
|
+
readonly handler: (invocation: CommandInvocation) => CommandResult | Promise<CommandResult>
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Invocation and result
|
|
54
|
+
|
|
55
|
+
The adapter owns cancellation and passes the exact target agent. `rawInput` begins immediately after the parsed name and retains the adapter-delivered separator and suffix. Results are direct UI outcomes, not tool results or session events.
|
|
56
|
+
|
|
57
|
+
```ts type-equiv
|
|
58
|
+
/** Invocation passed to one registered command handler. */
|
|
59
|
+
interface CommandInvocation {
|
|
60
|
+
/** Pairing id already written to this invocation's `command/run` event. */
|
|
61
|
+
readonly commandId: CommandId
|
|
62
|
+
/** Exact agent whose UI received the command. */
|
|
63
|
+
readonly agent: Agent
|
|
64
|
+
/** Exact text following the registered command name, including separator whitespace. */
|
|
65
|
+
readonly rawInput: string
|
|
66
|
+
/**
|
|
67
|
+
* Durably admitted image and file blocks accompanying this invocation, in submission
|
|
68
|
+
* order; empty unless the definition declares `input.attachments`. The handler
|
|
69
|
+
* owns their model-visible use — the registry never schedules them itself —
|
|
70
|
+
* and a handler whose grammar cannot use them in this invocation returns an
|
|
71
|
+
* error so the dispatching composer retains the originals.
|
|
72
|
+
*/
|
|
73
|
+
readonly attachments: readonly (ImageBlock | FileBlock)[]
|
|
74
|
+
/** Cancellation signal owned by the dispatching UI request. */
|
|
75
|
+
readonly signal: AbortSignal
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
```ts type-equiv
|
|
80
|
+
/** Expected command outcome rendered directly by the dispatching UI. */
|
|
81
|
+
type CommandResult =
|
|
82
|
+
| {
|
|
83
|
+
readonly kind: 'success'
|
|
84
|
+
readonly text?: string
|
|
85
|
+
/** Earlier authoritative domain event that owns a richer presentation. */
|
|
86
|
+
readonly sourceEventSeq?: SessionSeq
|
|
87
|
+
}
|
|
88
|
+
| { readonly kind: 'error'; readonly text: string }
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
`sourceEventSeq` is optional and success-only. When present, it names an earlier non-command event in the receiving session log; `command/done` persists the same reference so a client can combine the command lifecycle with that domain projection without parsing `text` or relying on adjacent rows.
|
|
92
|
+
|
|
93
|
+
## Discovery and parsing views
|
|
94
|
+
|
|
95
|
+
Adapters receive handler-free immutable descriptors after scope resolution. `parseCommand()` returns `ParsedCommand` before registry resolution; syntax-valid input can still name an unavailable command.
|
|
96
|
+
|
|
97
|
+
```ts type-equiv
|
|
98
|
+
/** Handler-free immutable command view returned to UI adapters. */
|
|
99
|
+
interface CommandDescriptor {
|
|
100
|
+
/** Lowercase command name without the leading slash. */
|
|
101
|
+
readonly name: string
|
|
102
|
+
/** Human-readable summary used in discovery UI. */
|
|
103
|
+
readonly description: string
|
|
104
|
+
/** Optional free-form input hint advertised to capable clients. */
|
|
105
|
+
readonly input?: CommandInputDescriptor
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
```ts type-equiv
|
|
110
|
+
/** Syntactically valid slash command before registry resolution. */
|
|
111
|
+
interface ParsedCommand {
|
|
112
|
+
/** Lowercase command name without the leading slash. */
|
|
113
|
+
readonly name: string
|
|
114
|
+
/** Exact text following the command name. */
|
|
115
|
+
readonly rawInput: string
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
<!-- BEGIN GENERATED cordis-surface (gen-cordis-catalog.ts) — do not edit between markers -->
|
|
120
|
+
|
|
121
|
+
<a id="cordis-surface"></a>
|
|
122
|
+
|
|
123
|
+
## Cordis API
|
|
124
|
+
|
|
125
|
+
Generated from source by `scripts/gen-cordis-catalog.ts` (verified fresh by `pnpm run verify-cordis-catalog` in doc-sync; regenerate with `pnpm run gen-cordis-catalog`) — the language sides differ only in locale-specific paired document paths. Signature blocks use a `ts cordis-catalog` fence and keep the original source JSDoc; dispatch modes are defined in the [primer](../cordis-primer.md#dispatch-modes), and the framework-inherited `ctx` API lives in [cordis-api/inherited.md](../cordis-api/inherited.md).
|
|
126
|
+
|
|
127
|
+
<a id="ctxcommands--commandruntime"></a>
|
|
128
|
+
|
|
129
|
+
### `ctx.commands` — `CommandRuntime`
|
|
130
|
+
|
|
131
|
+
Human-command registry. Plain-context definitions are global; definitions registered through a command-injected child of an agent context shadow globals for that agent.
|
|
132
|
+
|
|
133
|
+
```ts cordis-catalog
|
|
134
|
+
/**
|
|
135
|
+
* Register a global or calling-agent-scoped command.
|
|
136
|
+
* @param definition - discovery metadata and direct UI handler.
|
|
137
|
+
* @returns the exact effect disposer that unregisters this definition.
|
|
138
|
+
*/
|
|
139
|
+
register(definition: CommandDefinition): () => void
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Register the sole authority that resolves staged file receipts for command submissions.
|
|
143
|
+
* @param resolver - Session-aware receipt resolver.
|
|
144
|
+
* @returns disposer that removes this exact resolver.
|
|
145
|
+
*/
|
|
146
|
+
registerFileReceiptResolver(resolver: CommandFileReceiptResolver): () => void
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* List the effective immutable command descriptors for one agent.
|
|
150
|
+
* @param agent - exact receiving agent and scoped-layer key.
|
|
151
|
+
* @returns name-sorted descriptors after scoped shadowing.
|
|
152
|
+
*/
|
|
153
|
+
@Remote list(agent: Agent): readonly CommandDescriptor[]
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Resolve one effective command definition.
|
|
157
|
+
* @param agent - exact receiving agent and scoped-layer key.
|
|
158
|
+
* @param name - command name without a slash.
|
|
159
|
+
* @returns the scoped shadow or global definition.
|
|
160
|
+
*/
|
|
161
|
+
find(agent: Agent, name: string): CommandDefinition | undefined
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Parse and execute a known command without sending it to the model.
|
|
165
|
+
*
|
|
166
|
+
* A resolved command's lifecycle is logged: `command/run` is appended
|
|
167
|
+
* before the handler is invoked and `command/done` after settlement (a
|
|
168
|
+
* thrown or aborted handler settles as `kind: 'error'`). Both are direct
|
|
169
|
+
* log-only appends — no turn wraps them, and persistence drains them at
|
|
170
|
+
* ordinary checkpoints. Admission misses (syntax or unknown name) log
|
|
171
|
+
* nothing — they never entered a handler. A `command/run` append failure
|
|
172
|
+
* fails the execution loud; a `command/done` append failure on the
|
|
173
|
+
* handler-failure path is contained so the handler's own error stays the
|
|
174
|
+
* reported failure.
|
|
175
|
+
*
|
|
176
|
+
* Attachment admission is enforced here, not in the composer: attachments sent to a
|
|
177
|
+
* command that does not declare `input.attachments`, an absent attachment store,
|
|
178
|
+
* and an exceeded image limit each settle as an error result before
|
|
179
|
+
* the handler runs. Validation rejection starts no attachment writes;
|
|
180
|
+
* a storage failure can leave only unreachable content-addressed objects
|
|
181
|
+
* for deferred collection.
|
|
182
|
+
*
|
|
183
|
+
* @param agent - exact receiving agent.
|
|
184
|
+
* @param line - complete slash-command line.
|
|
185
|
+
* @param submittedAttachments - encoded images and staged file receipts accompanying the line,
|
|
186
|
+
* in submission order; empty for a plain invocation.
|
|
187
|
+
* @param signal - cancellation signal owned by the UI request.
|
|
188
|
+
* @returns the settled execution (result + lifecycle pairing id), or
|
|
189
|
+
* `undefined` when syntax or name does not resolve.
|
|
190
|
+
*/
|
|
191
|
+
@Remote async execute( agent: Agent, line: string, submittedAttachments: readonly CommandSubmitAttachment[], signal: AbortSignal, ): Promise<CommandExecution | undefined>
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
Types: [Agent](core.md)
|
|
195
|
+
|
|
196
|
+
Source: [`packages/interaction/commands/src/index.ts`](../../packages/interaction/commands/src/index.ts)
|
|
197
|
+
|
|
198
|
+
<a id="commands-events"></a>
|
|
199
|
+
|
|
200
|
+
### `commands/*` events
|
|
201
|
+
|
|
202
|
+
<a id="commandschange--emit"></a>
|
|
203
|
+
|
|
204
|
+
#### `commands/change` — emit
|
|
205
|
+
|
|
206
|
+
A command was registered or unregistered. This is an unfiltered registry notification because a global or scoped change may affect any UI view. Observer failures are contained and cannot veto the registry mutation.
|
|
207
|
+
|
|
208
|
+
```ts cordis-catalog
|
|
209
|
+
/**
|
|
210
|
+
* A command was registered or unregistered. This is an unfiltered registry
|
|
211
|
+
* notification because a global or scoped change may affect any UI view.
|
|
212
|
+
* Observer failures are contained and cannot veto the registry mutation.
|
|
213
|
+
* @mode emit
|
|
214
|
+
*/
|
|
215
|
+
'commands/change'(): void
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
Source: [`packages/interaction/commands/src/types.ts`](../../packages/interaction/commands/src/types.ts)
|
|
219
|
+
<!-- END GENERATED cordis-surface -->
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
# 用户命令
|
|
2
|
+
|
|
3
|
+
[English](commands.md) | 中文
|
|
4
|
+
|
|
5
|
+
[`dsh-commands`](../../packages/interaction/commands) 提供的用户命令注册表服务。交互式适配器用它发现插件拥有的命令,并针对确切的 agent(智能体)直接执行这些命令,而不创建模型消息。[命令 Agent Note](../../.agents/notes/implemented/feature/2026-07-19-plugin-command-registration.zh.md) 负责分发与生命周期的决策依据;[包 README](../../packages/interaction/commands/README.zh.md) 负责组合方式与限制。
|
|
6
|
+
|
|
7
|
+
来源:[`packages/interaction/commands/src/index.ts`](../../packages/interaction/commands/src/index.ts)
|
|
8
|
+
|
|
9
|
+
## 输入元数据
|
|
10
|
+
|
|
11
|
+
该服务公开一个可选的非结构化输入描述符:提示文本加附件接受标志。命令的可用性由插件组合决定:每个消费注册表的适配器都会看到全部生效定义。
|
|
12
|
+
|
|
13
|
+
```ts type-equiv
|
|
14
|
+
/** Immutable metadata for a command's optional unstructured input. */
|
|
15
|
+
interface CommandInputDescriptor {
|
|
16
|
+
/** Placeholder shown before the user supplies free-form input. */
|
|
17
|
+
readonly hint: string
|
|
18
|
+
/**
|
|
19
|
+
* Whether composer attachments may accompany an invocation. Absent or
|
|
20
|
+
* false = the executor rejects an invocation carrying attachments and capable
|
|
21
|
+
* composers refuse the submission before dispatch. A declaring command's
|
|
22
|
+
* handler receives the admitted durable blocks and owns every further
|
|
23
|
+
* grammar decision, including rejecting sub-commands that cannot use them.
|
|
24
|
+
*/
|
|
25
|
+
readonly attachments?: boolean
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## 定义
|
|
30
|
+
|
|
31
|
+
`CommandDefinition` 是由插件编写的注册定义。注册表会验证并冻结一份与原始注册对象脱离的生效定义。
|
|
32
|
+
|
|
33
|
+
```ts type-equiv
|
|
34
|
+
/** Plugin-owned command registration. */
|
|
35
|
+
interface CommandDefinition {
|
|
36
|
+
/** Lowercase command name without the leading slash. */
|
|
37
|
+
readonly name: string
|
|
38
|
+
/** Human-readable summary used in discovery UI. */
|
|
39
|
+
readonly description: string
|
|
40
|
+
/** Optional free-form input hint advertised to capable clients. */
|
|
41
|
+
readonly input?: CommandInputDescriptor
|
|
42
|
+
/**
|
|
43
|
+
* Whether `command/run` records `rawInput`. Defaults to true. A command
|
|
44
|
+
* whose domain event owns the payload sets this false to avoid duplicating
|
|
45
|
+
* that payload in the session log.
|
|
46
|
+
*/
|
|
47
|
+
readonly recordInput?: boolean
|
|
48
|
+
/** Execute against the receiving agent without sending the command to the model. */
|
|
49
|
+
readonly handler: (invocation: CommandInvocation) => CommandResult | Promise<CommandResult>
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## 调用与结果
|
|
54
|
+
|
|
55
|
+
取消由适配器负责,适配器会传入确切的目标 agent。`rawInput` 紧接在解析后的名称之后,并保留适配器传入的分隔符与后缀。结果会直接呈现给 UI,而不是工具结果或会话事件。
|
|
56
|
+
|
|
57
|
+
```ts type-equiv
|
|
58
|
+
/** Invocation passed to one registered command handler. */
|
|
59
|
+
interface CommandInvocation {
|
|
60
|
+
/** Pairing id already written to this invocation's `command/run` event. */
|
|
61
|
+
readonly commandId: CommandId
|
|
62
|
+
/** Exact agent whose UI received the command. */
|
|
63
|
+
readonly agent: Agent
|
|
64
|
+
/** Exact text following the registered command name, including separator whitespace. */
|
|
65
|
+
readonly rawInput: string
|
|
66
|
+
/**
|
|
67
|
+
* Durably admitted image and file blocks accompanying this invocation, in submission
|
|
68
|
+
* order; empty unless the definition declares `input.attachments`. The handler
|
|
69
|
+
* owns their model-visible use — the registry never schedules them itself —
|
|
70
|
+
* and a handler whose grammar cannot use them in this invocation returns an
|
|
71
|
+
* error so the dispatching composer retains the originals.
|
|
72
|
+
*/
|
|
73
|
+
readonly attachments: readonly (ImageBlock | FileBlock)[]
|
|
74
|
+
/** Cancellation signal owned by the dispatching UI request. */
|
|
75
|
+
readonly signal: AbortSignal
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
```ts type-equiv
|
|
80
|
+
/** Expected command outcome rendered directly by the dispatching UI. */
|
|
81
|
+
type CommandResult =
|
|
82
|
+
| {
|
|
83
|
+
readonly kind: 'success'
|
|
84
|
+
readonly text?: string
|
|
85
|
+
/** Earlier authoritative domain event that owns a richer presentation. */
|
|
86
|
+
readonly sourceEventSeq?: SessionSeq
|
|
87
|
+
}
|
|
88
|
+
| { readonly kind: 'error'; readonly text: string }
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
`sourceEventSeq` 是可选字段,且只用于成功结果。存在时,它指向接收会话日志中更早的一条非命令事件;`command/done` 会持久化同一引用,让客户端能够将命令生命周期与该领域投影合并,而无须解析 `text` 或依赖相邻行。
|
|
92
|
+
|
|
93
|
+
## 发现与解析视图
|
|
94
|
+
|
|
95
|
+
作用域解析后,适配器会获得不含处理器的不可变描述符。`parseCommand()` 在注册表解析前返回 `ParsedCommand`;语法有效的输入仍可能指向不可用的命令。
|
|
96
|
+
|
|
97
|
+
```ts type-equiv
|
|
98
|
+
/** Handler-free immutable command view returned to UI adapters. */
|
|
99
|
+
interface CommandDescriptor {
|
|
100
|
+
/** Lowercase command name without the leading slash. */
|
|
101
|
+
readonly name: string
|
|
102
|
+
/** Human-readable summary used in discovery UI. */
|
|
103
|
+
readonly description: string
|
|
104
|
+
/** Optional free-form input hint advertised to capable clients. */
|
|
105
|
+
readonly input?: CommandInputDescriptor
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
```ts type-equiv
|
|
110
|
+
/** Syntactically valid slash command before registry resolution. */
|
|
111
|
+
interface ParsedCommand {
|
|
112
|
+
/** Lowercase command name without the leading slash. */
|
|
113
|
+
readonly name: string
|
|
114
|
+
/** Exact text following the command name. */
|
|
115
|
+
readonly rawInput: string
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
<!-- BEGIN GENERATED cordis-surface (gen-cordis-catalog.ts) — do not edit between markers -->
|
|
120
|
+
|
|
121
|
+
<a id="cordis-surface"></a>
|
|
122
|
+
|
|
123
|
+
## Cordis API
|
|
124
|
+
|
|
125
|
+
Generated from source by `scripts/gen-cordis-catalog.ts` (verified fresh by `pnpm run verify-cordis-catalog` in doc-sync; regenerate with `pnpm run gen-cordis-catalog`) — the language sides differ only in locale-specific paired document paths. Signature blocks use a `ts cordis-catalog` fence and keep the original source JSDoc; dispatch modes are defined in the [primer](../cordis-primer.zh.md#dispatch-modes), and the framework-inherited `ctx` API lives in [cordis-api/inherited.md](../cordis-api/inherited.md).
|
|
126
|
+
|
|
127
|
+
<a id="ctxcommands--commandruntime"></a>
|
|
128
|
+
|
|
129
|
+
### `ctx.commands` — `CommandRuntime`
|
|
130
|
+
|
|
131
|
+
Human-command registry. Plain-context definitions are global; definitions registered through a command-injected child of an agent context shadow globals for that agent.
|
|
132
|
+
|
|
133
|
+
```ts cordis-catalog
|
|
134
|
+
/**
|
|
135
|
+
* Register a global or calling-agent-scoped command.
|
|
136
|
+
* @param definition - discovery metadata and direct UI handler.
|
|
137
|
+
* @returns the exact effect disposer that unregisters this definition.
|
|
138
|
+
*/
|
|
139
|
+
register(definition: CommandDefinition): () => void
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Register the sole authority that resolves staged file receipts for command submissions.
|
|
143
|
+
* @param resolver - Session-aware receipt resolver.
|
|
144
|
+
* @returns disposer that removes this exact resolver.
|
|
145
|
+
*/
|
|
146
|
+
registerFileReceiptResolver(resolver: CommandFileReceiptResolver): () => void
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* List the effective immutable command descriptors for one agent.
|
|
150
|
+
* @param agent - exact receiving agent and scoped-layer key.
|
|
151
|
+
* @returns name-sorted descriptors after scoped shadowing.
|
|
152
|
+
*/
|
|
153
|
+
@Remote list(agent: Agent): readonly CommandDescriptor[]
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Resolve one effective command definition.
|
|
157
|
+
* @param agent - exact receiving agent and scoped-layer key.
|
|
158
|
+
* @param name - command name without a slash.
|
|
159
|
+
* @returns the scoped shadow or global definition.
|
|
160
|
+
*/
|
|
161
|
+
find(agent: Agent, name: string): CommandDefinition | undefined
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Parse and execute a known command without sending it to the model.
|
|
165
|
+
*
|
|
166
|
+
* A resolved command's lifecycle is logged: `command/run` is appended
|
|
167
|
+
* before the handler is invoked and `command/done` after settlement (a
|
|
168
|
+
* thrown or aborted handler settles as `kind: 'error'`). Both are direct
|
|
169
|
+
* log-only appends — no turn wraps them, and persistence drains them at
|
|
170
|
+
* ordinary checkpoints. Admission misses (syntax or unknown name) log
|
|
171
|
+
* nothing — they never entered a handler. A `command/run` append failure
|
|
172
|
+
* fails the execution loud; a `command/done` append failure on the
|
|
173
|
+
* handler-failure path is contained so the handler's own error stays the
|
|
174
|
+
* reported failure.
|
|
175
|
+
*
|
|
176
|
+
* Attachment admission is enforced here, not in the composer: attachments sent to a
|
|
177
|
+
* command that does not declare `input.attachments`, an absent attachment store,
|
|
178
|
+
* and an exceeded image limit each settle as an error result before
|
|
179
|
+
* the handler runs. Validation rejection starts no attachment writes;
|
|
180
|
+
* a storage failure can leave only unreachable content-addressed objects
|
|
181
|
+
* for deferred collection.
|
|
182
|
+
*
|
|
183
|
+
* @param agent - exact receiving agent.
|
|
184
|
+
* @param line - complete slash-command line.
|
|
185
|
+
* @param submittedAttachments - encoded images and staged file receipts accompanying the line,
|
|
186
|
+
* in submission order; empty for a plain invocation.
|
|
187
|
+
* @param signal - cancellation signal owned by the UI request.
|
|
188
|
+
* @returns the settled execution (result + lifecycle pairing id), or
|
|
189
|
+
* `undefined` when syntax or name does not resolve.
|
|
190
|
+
*/
|
|
191
|
+
@Remote async execute( agent: Agent, line: string, submittedAttachments: readonly CommandSubmitAttachment[], signal: AbortSignal, ): Promise<CommandExecution | undefined>
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
Types: [Agent](core.zh.md)
|
|
195
|
+
|
|
196
|
+
Source: [`packages/interaction/commands/src/index.ts`](../../packages/interaction/commands/src/index.ts)
|
|
197
|
+
|
|
198
|
+
<a id="commands-events"></a>
|
|
199
|
+
|
|
200
|
+
### `commands/*` events
|
|
201
|
+
|
|
202
|
+
<a id="commandschange--emit"></a>
|
|
203
|
+
|
|
204
|
+
#### `commands/change` — emit
|
|
205
|
+
|
|
206
|
+
A command was registered or unregistered. This is an unfiltered registry notification because a global or scoped change may affect any UI view. Observer failures are contained and cannot veto the registry mutation.
|
|
207
|
+
|
|
208
|
+
```ts cordis-catalog
|
|
209
|
+
/**
|
|
210
|
+
* A command was registered or unregistered. This is an unfiltered registry
|
|
211
|
+
* notification because a global or scoped change may affect any UI view.
|
|
212
|
+
* Observer failures are contained and cannot veto the registry mutation.
|
|
213
|
+
* @mode emit
|
|
214
|
+
*/
|
|
215
|
+
'commands/change'(): void
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
Source: [`packages/interaction/commands/src/types.ts`](../../packages/interaction/commands/src/types.ts)
|
|
219
|
+
<!-- END GENERATED cordis-surface -->
|