Merge pull request #8057 from deepseek-harness/refactor/tool-errors-agent
feat(subagent,workflow,plan): give delegation, workflow, plan, and interaction tool failures error codes
This commit is contained in:
commit
bc45c6c17c
133 files changed
+757
-290
No files matched your search
+2
-2
@@ -9,8 +9,8 @@
|
||||
en: 990d46f713fb6303
|
||||
zh: 592cd6128a9640b1
|
||||
/agent-note-one-remote-failure-vocabulary-for-ctx-remote/decision:
|
||||
en: 120e2fb97ac765d8
|
||||
zh: 5d5f110db4a9b717
|
||||
en: b54b9d98a34eeaa1
|
||||
zh: ac8e3d493b554c2d
|
||||
/agent-note-one-remote-failure-vocabulary-for-ctx-remote/code-ownership:
|
||||
en: cc1d8b88f7349b77
|
||||
zh: 70f010e3310e2667
|
||||
|
||||
@@ -16,12 +16,12 @@ Fixed Host facts bypassed `ctx.remote` too: the Host home came from `(ctx.get('c
|
||||
|
||||
## Decision
|
||||
|
||||
`@deepseek-ai/dsh-typert-protocol` exports one failure class, `RemoteError<Code>`: a real `Error` carrying readonly `code` and `details`, the structural marker `isDSHRemoteError`, and standard `ErrorOptions` (`cause` holds in-process only). The correspondence between codes and details lives in one merge-extensible `RemoteErrorDetailsMap`; `RemoteFailure` is the code-distributed union of instances, and `RemoteResult<T>` keeps its shape.
|
||||
`@deepseek-ai/dsh-typert-protocol` exports one failure class, `RemoteError<Code>`: a `HarnessError` from the dependency-free `@deepseek-ai/dsh-error` carrying readonly `code` and `details`, the structural marker `isDSHRemoteError`, and standard `ErrorOptions` (`cause` holds in-process only). The correspondence between codes and details lives in one merge-extensible `RemoteErrorDetailsMap`; `RemoteFailure` is the code-distributed union of instances, and `RemoteResult<T>` keeps its shape.
|
||||
|
||||
```text
|
||||
export class RemoteError<Code extends RemoteErrorCode = RemoteErrorCode> extends Error {
|
||||
export class RemoteError<Code extends RemoteErrorCode = RemoteErrorCode> extends HarnessError {
|
||||
readonly isDSHRemoteError: true = true
|
||||
constructor(readonly code: Code, message: string,
|
||||
constructor(override readonly code: Code, message: string,
|
||||
readonly details: RemoteErrorDetailsMap[Code], options?: ErrorOptions)
|
||||
}
|
||||
export type RemoteFailure = { [C in RemoteErrorCode]: RemoteError<C> }[RemoteErrorCode]
|
||||
|
||||
+3
-3
@@ -16,12 +16,12 @@ Host 固定事实同样绕过了 `ctx.remote`:Host home 取自 `(ctx.get('conn
|
||||
|
||||
## Decision
|
||||
|
||||
`@deepseek-ai/dsh-typert-protocol` 导出唯一的失败类 `RemoteError<Code>`:一个真 `Error`,带只读 `code` 与 `details`、结构标记 `isDSHRemoteError`,以及标准 `ErrorOptions`(`cause` 只在进程内有效)。码与 details 的对应关系收进一张 merge-extensible 的 `RemoteErrorDetailsMap`;`RemoteFailure` 是按码分布的实例 union,`RemoteResult<T>` 形状不变。
|
||||
`@deepseek-ai/dsh-typert-protocol` 导出唯一的失败类 `RemoteError<Code>`:一个继承无依赖包 `@deepseek-ai/dsh-error` 中 `HarnessError` 的错误,带只读 `code` 与 `details`、结构标记 `isDSHRemoteError`,以及标准 `ErrorOptions`(`cause` 只在进程内有效)。码与 details 的对应关系收进一张 merge-extensible 的 `RemoteErrorDetailsMap`;`RemoteFailure` 是按码分布的实例 union,`RemoteResult<T>` 形状不变。
|
||||
|
||||
```text
|
||||
export class RemoteError<Code extends RemoteErrorCode = RemoteErrorCode> extends Error {
|
||||
export class RemoteError<Code extends RemoteErrorCode = RemoteErrorCode> extends HarnessError {
|
||||
readonly isDSHRemoteError: true = true
|
||||
constructor(readonly code: Code, message: string,
|
||||
constructor(override readonly code: Code, message: string,
|
||||
readonly details: RemoteErrorDetailsMap[Code], options?: ErrorOptions)
|
||||
}
|
||||
export type RemoteFailure = { [C in RemoteErrorCode]: RemoteError<C> }[RemoteErrorCode]
|
||||
|
||||
@@ -2762,7 +2762,7 @@ export interface Config {
|
||||
## `@deepseek-ai/dsh-plan-mode`
|
||||
|
||||
- `inject`: `tools` · `systemPrompt` · `sessionProjections` · `agents`
|
||||
- `source`: [`packages/plan/plan-mode/src/index.ts:67`](../packages/plan/plan-mode/src/index.ts)
|
||||
- `source`: [`packages/plan/plan-mode/src/index.ts:69`](../packages/plan/plan-mode/src/index.ts)
|
||||
|
||||
```ts config-catalog
|
||||
/** Deployment-owned plan guidance. */
|
||||
@@ -4577,7 +4577,7 @@ export interface Config {
|
||||
|
||||
- `inject`: `tools` · `subagents` · `systemPrompt` · `sessionProjections`
|
||||
- `refs`: [`AgentOptions`](subsystems/core.md)
|
||||
- `source`: [`packages/subagent/tool-subagent/src/index.ts:45`](../packages/subagent/tool-subagent/src/index.ts)
|
||||
- `source`: [`packages/subagent/tool-subagent/src/index.ts:46`](../packages/subagent/tool-subagent/src/index.ts)
|
||||
|
||||
```ts config-catalog
|
||||
/** Config: which registered provider this tool delegates to, plus child defaults. */
|
||||
@@ -4724,7 +4724,7 @@ export interface Config {
|
||||
## `@deepseek-ai/dsh-tool-workflow`
|
||||
|
||||
- `inject`: `tools` · `workflowEngine` · `systemPrompt`
|
||||
- `source`: [`packages/workflow/tool-workflow/src/index.ts:45`](../packages/workflow/tool-workflow/src/index.ts)
|
||||
- `source`: [`packages/workflow/tool-workflow/src/index.ts:46`](../packages/workflow/tool-workflow/src/index.ts)
|
||||
|
||||
```ts config-catalog
|
||||
/** Config: the model-facing tool name plus result rendering caps. */
|
||||
|
||||
@@ -2764,7 +2764,7 @@ export interface Config {
|
||||
## `@deepseek-ai/dsh-plan-mode`
|
||||
|
||||
- `inject`: `tools` · `systemPrompt` · `sessionProjections` · `agents`
|
||||
- `source`: [`packages/plan/plan-mode/src/index.ts:67`](../packages/plan/plan-mode/src/index.ts)
|
||||
- `source`: [`packages/plan/plan-mode/src/index.ts:69`](../packages/plan/plan-mode/src/index.ts)
|
||||
|
||||
```ts config-catalog
|
||||
/** Deployment-owned plan guidance. */
|
||||
@@ -4579,7 +4579,7 @@ export interface Config {
|
||||
|
||||
- `inject`: `tools` · `subagents` · `systemPrompt` · `sessionProjections`
|
||||
- `refs`: [`AgentOptions`](subsystems/core.zh.md)
|
||||
- `source`: [`packages/subagent/tool-subagent/src/index.ts:45`](../packages/subagent/tool-subagent/src/index.ts)
|
||||
- `source`: [`packages/subagent/tool-subagent/src/index.ts:46`](../packages/subagent/tool-subagent/src/index.ts)
|
||||
|
||||
```ts config-catalog
|
||||
/** Config: which registered provider this tool delegates to, plus child defaults. */
|
||||
@@ -4726,7 +4726,7 @@ export interface Config {
|
||||
## `@deepseek-ai/dsh-tool-workflow`
|
||||
|
||||
- `inject`: `tools` · `workflowEngine` · `systemPrompt`
|
||||
- `source`: [`packages/workflow/tool-workflow/src/index.ts:45`](../packages/workflow/tool-workflow/src/index.ts)
|
||||
- `source`: [`packages/workflow/tool-workflow/src/index.ts:46`](../packages/workflow/tool-workflow/src/index.ts)
|
||||
|
||||
```ts config-catalog
|
||||
/** Config: the model-facing tool name plus result rendering caps. */
|
||||
|
||||
@@ -54,7 +54,7 @@ Application listeners are outside this package matrix. Desktop Host subscribes t
|
||||
| `fs/observed` | `emit` | [`packages/fs/fs/src/index.ts:93`](../packages/fs/fs/src/index.ts) | `liveshare` (`emit`), [`tool-fs`](../packages/fs/tool-fs) (`emit`), [`tool-str-replace-editor`](../packages/fs/tool-str-replace-editor) (`emit`) | [`fs-observation-policy`](../packages/fs/fs-observation-policy), [`skill-filesystem`](../packages/skill/skill-filesystem), `workspace-files` |
|
||||
| `fs/write-intent` | `waterfall` | [`packages/fs/fs/src/index.ts:67`](../packages/fs/fs/src/index.ts) | `liveshare` (`waterfall`), [`tool-fs`](../packages/fs/tool-fs) (`waterfall`), [`tool-str-replace-editor`](../packages/fs/tool-str-replace-editor) (`waterfall`) | [`fs-observation-policy`](../packages/fs/fs-observation-policy), [`workspace-changes`](../packages/deliverables/workspace-changes) |
|
||||
| `goal/activation-changed` | `emit` | [`packages/goal/goal/src/types.ts:147`](../packages/goal/goal/src/types.ts) | [`goal`](../packages/goal/goal) (`emit`) | `remotes`, `server` |
|
||||
| `goal/changed` | `emit` | [`packages/goal/goal/src/domain.ts:114`](../packages/goal/goal/src/domain.ts) | [`goal`](../packages/goal/goal) (`emit`) | [`goal-round-driver`](../packages/goal/goal-round-driver) |
|
||||
| `goal/changed` | `emit` | [`packages/goal/goal/src/domain.ts:115`](../packages/goal/goal/src/domain.ts) | [`goal`](../packages/goal/goal) (`emit`) | [`goal-round-driver`](../packages/goal/goal-round-driver) |
|
||||
| `hmr/change` | `emit` | [`packages/boot/hmr/src/index.ts:35`](../packages/boot/hmr/src/index.ts) | [`hmr`](../packages/boot/hmr) (`emit`) | - |
|
||||
| `hmr/reload` | `emit` | [`packages/boot/hmr/src/index.ts:40`](../packages/boot/hmr/src/index.ts) | [`hmr`](../packages/boot/hmr) (`emit`) | - |
|
||||
| `llm-pi-ai/request-headers` | `waterfall` | [`packages/llm/llm-pi-ai/src/index.ts:113`](../packages/llm/llm-pi-ai/src/index.ts) | [`llm-pi-ai`](../packages/llm/llm-pi-ai) (`waterfall`) | - |
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
| `fs/observed` | `emit` | [`packages/fs/fs/src/index.ts:93`](../packages/fs/fs/src/index.ts) | `liveshare` (`emit`), [`tool-fs`](../packages/fs/tool-fs) (`emit`), [`tool-str-replace-editor`](../packages/fs/tool-str-replace-editor) (`emit`) | [`fs-observation-policy`](../packages/fs/fs-observation-policy), [`skill-filesystem`](../packages/skill/skill-filesystem), `workspace-files` |
|
||||
| `fs/write-intent` | `waterfall` | [`packages/fs/fs/src/index.ts:67`](../packages/fs/fs/src/index.ts) | `liveshare` (`waterfall`), [`tool-fs`](../packages/fs/tool-fs) (`waterfall`), [`tool-str-replace-editor`](../packages/fs/tool-str-replace-editor) (`waterfall`) | [`fs-observation-policy`](../packages/fs/fs-observation-policy), [`workspace-changes`](../packages/deliverables/workspace-changes) |
|
||||
| `goal/activation-changed` | `emit` | [`packages/goal/goal/src/types.ts:147`](../packages/goal/goal/src/types.ts) | [`goal`](../packages/goal/goal) (`emit`) | `remotes`, `server` |
|
||||
| `goal/changed` | `emit` | [`packages/goal/goal/src/domain.ts:114`](../packages/goal/goal/src/domain.ts) | [`goal`](../packages/goal/goal) (`emit`) | [`goal-round-driver`](../packages/goal/goal-round-driver) |
|
||||
| `goal/changed` | `emit` | [`packages/goal/goal/src/domain.ts:115`](../packages/goal/goal/src/domain.ts) | [`goal`](../packages/goal/goal) (`emit`) | [`goal-round-driver`](../packages/goal/goal-round-driver) |
|
||||
| `hmr/change` | `emit` | [`packages/boot/hmr/src/index.ts:35`](../packages/boot/hmr/src/index.ts) | [`hmr`](../packages/boot/hmr) (`emit`) | - |
|
||||
| `hmr/reload` | `emit` | [`packages/boot/hmr/src/index.ts:40`](../packages/boot/hmr/src/index.ts) | [`hmr`](../packages/boot/hmr) (`emit`) | - |
|
||||
| `llm-pi-ai/request-headers` | `waterfall` | [`packages/llm/llm-pi-ai/src/index.ts:113`](../packages/llm/llm-pi-ai/src/index.ts) | [`llm-pi-ai`](../packages/llm/llm-pi-ai) (`waterfall`) | - |
|
||||
|
||||
@@ -509,8 +509,8 @@ flowchart TD
|
||||
pkg_subprocess --> pkg_error
|
||||
pkg_subprocess --> pkg_http_proxy
|
||||
pkg_win32_process --> pkg_error
|
||||
pkg_remote_mock --> pkg_typert_protocol
|
||||
pkg_typert_loader --> pkg_typert_registry
|
||||
pkg_typert_protocol --> pkg_error
|
||||
pkg_util_ripgrep --> pkg_subprocess
|
||||
pkg_system_prompt --> pkg_llm
|
||||
pkg_system_prompt --> pkg_scope
|
||||
@@ -554,6 +554,7 @@ flowchart TD
|
||||
pkg_subprocess_local --> pkg_subprocess
|
||||
pkg_subprocess_local --> pkg_timeout
|
||||
pkg_otel --> pkg_session
|
||||
pkg_remote_mock --> pkg_typert_protocol
|
||||
pkg_session_snapshot --> pkg_http_proxy
|
||||
pkg_session_snapshot --> pkg_session
|
||||
pkg_fs --> pkg_llm
|
||||
@@ -901,6 +902,7 @@ flowchart TD
|
||||
pkg_tool_todo --> pkg_tools
|
||||
pkg_plan_mode --> pkg_agent
|
||||
pkg_plan_mode --> pkg_commands
|
||||
pkg_plan_mode --> pkg_error
|
||||
pkg_plan_mode --> pkg_llm
|
||||
pkg_plan_mode --> pkg_session
|
||||
pkg_plan_mode --> pkg_session_projection
|
||||
@@ -1687,7 +1689,6 @@ flowchart TD
|
||||
| [`storage`](../packages/storage/storage) | `storage` | — |
|
||||
| [`llm-mock-server`](../packages/test-support/llm-mock-server) | `test-support` | — |
|
||||
| [`typert-generator`](../packages/typert/generator) | `typert` | — |
|
||||
| [`typert-protocol`](../packages/typert/protocol) | `typert` | — |
|
||||
| [`typert-registry`](../packages/typert/registry) | `typert` | — |
|
||||
| [`llm`](../packages/llm/llm) | `llm` | [`error`](../packages/util/error) |
|
||||
| [`session`](../packages/core/session) | `core` | [`scope`](../packages/core/scope) |
|
||||
@@ -1704,8 +1705,8 @@ flowchart TD
|
||||
| [`storage-sqlite`](../packages/storage/storage-sqlite) | `storage` | [`storage`](../packages/storage/storage) |
|
||||
| [`subprocess`](../packages/subprocess/subprocess) | `subprocess` | [`error`](../packages/util/error), [`http-proxy`](../packages/util/http-proxy) |
|
||||
| [`win32-process`](../packages/subprocess/win32-process) | `subprocess` | [`error`](../packages/util/error) |
|
||||
| [`remote-mock`](../packages/test-support/remote-mock) | `test-support` | [`typert-protocol`](../packages/typert/protocol) |
|
||||
| [`typert-loader`](../packages/typert/loader) | `typert` | [`typert-registry`](../packages/typert/registry) |
|
||||
| [`typert-protocol`](../packages/typert/protocol) | `typert` | [`error`](../packages/util/error) |
|
||||
| [`util-ripgrep`](../packages/util/ripgrep) | `util` | [`subprocess`](../packages/subprocess/subprocess) |
|
||||
| [`system-prompt`](../packages/core/system-prompt) | `core` | [`llm`](../packages/llm/llm), [`scope`](../packages/core/scope) |
|
||||
| [`skill`](../packages/skill/skill) | `skill` | [`llm`](../packages/llm/llm), [`scope`](../packages/core/scope) |
|
||||
@@ -1728,6 +1729,7 @@ flowchart TD
|
||||
| [`settings`](../packages/settings/settings) | `settings` | [`brand`](../packages/util/brand), [`session`](../packages/core/session) |
|
||||
| [`subprocess-local`](../packages/subprocess/subprocess-local) | `subprocess` | [`subprocess`](../packages/subprocess/subprocess), [`timeout`](../packages/util/timeout) |
|
||||
| [`otel`](../packages/telemetry/otel) | `telemetry` | [`session`](../packages/core/session) |
|
||||
| [`remote-mock`](../packages/test-support/remote-mock) | `test-support` | [`typert-protocol`](../packages/typert/protocol) |
|
||||
| [`session-snapshot`](../packages/test-support/session-snapshot) | `test-support` | [`http-proxy`](../packages/util/http-proxy), [`session`](../packages/core/session) |
|
||||
| [`fs`](../packages/fs/fs) | `fs` | [`llm`](../packages/llm/llm), [`sandbox`](../packages/sandbox/sandbox) |
|
||||
| [`skill-office`](../packages/skill/skill-office) | `skill` | [`skill`](../packages/skill/skill) |
|
||||
@@ -1813,7 +1815,7 @@ flowchart TD
|
||||
| [`tool-web`](../packages/web/tool-web) | `web` | [`llm`](../packages/llm/llm), [`system-prompt`](../packages/core/system-prompt), [`tools`](../packages/core/tools), [`web`](../packages/web/web) |
|
||||
| [`web-deepseek-api`](../packages/web/web-deepseek-api) | `web` | [`agent`](../packages/core/agent), [`credentials`](../packages/credentials/credentials), [`deepseek-account`](../packages/credentials/deepseek-account), [`launch-environment`](../packages/util/launch-environment), [`llm`](../packages/llm/llm), [`llm-deepseek`](../packages/llm/llm-deepseek), [`llm-deepseek-account`](../packages/llm/llm-deepseek-account), [`llm-deepseek-api-key`](../packages/llm/llm-deepseek-api-key), [`session`](../packages/core/session), [`web`](../packages/web/web) |
|
||||
| [`tool-todo`](../packages/todo/tool-todo) | `todo` | [`agent`](../packages/core/agent), [`session`](../packages/core/session), [`session-projection`](../packages/session/session-projection), [`tools`](../packages/core/tools) |
|
||||
| [`plan-mode`](../packages/plan/plan-mode) | `plan` | [`agent`](../packages/core/agent), [`commands`](../packages/interaction/commands), [`llm`](../packages/llm/llm), [`session`](../packages/core/session), [`session-projection`](../packages/session/session-projection), [`system-prompt`](../packages/core/system-prompt), [`tools`](../packages/core/tools), [`user-questions`](../packages/interaction/user-questions) |
|
||||
| [`plan-mode`](../packages/plan/plan-mode) | `plan` | [`agent`](../packages/core/agent), [`commands`](../packages/interaction/commands), [`error`](../packages/util/error), [`llm`](../packages/llm/llm), [`session`](../packages/core/session), [`session-projection`](../packages/session/session-projection), [`system-prompt`](../packages/core/system-prompt), [`tools`](../packages/core/tools), [`user-questions`](../packages/interaction/user-questions) |
|
||||
| [`command-compact`](../packages/compaction/command-compact) | `compaction` | [`commands`](../packages/interaction/commands), [`compaction`](../packages/compaction/compaction) |
|
||||
| [`compaction-image-offload`](../packages/compaction/compaction-image-offload) | `compaction` | [`agent`](../packages/core/agent), [`compaction`](../packages/compaction/compaction), [`llm`](../packages/llm/llm), [`session`](../packages/core/session) |
|
||||
| [`agent-instructions`](../packages/context/agent-instructions) | `context` | [`agent`](../packages/core/agent), [`fs`](../packages/fs/fs), [`home-paths`](../packages/util/home-paths), [`llm`](../packages/llm/llm), [`session`](../packages/core/session), [`tools`](../packages/core/tools), [`working-directory`](../packages/session/working-directory) |
|
||||
|
||||
@@ -511,8 +511,8 @@ flowchart TD
|
||||
pkg_subprocess --> pkg_error
|
||||
pkg_subprocess --> pkg_http_proxy
|
||||
pkg_win32_process --> pkg_error
|
||||
pkg_remote_mock --> pkg_typert_protocol
|
||||
pkg_typert_loader --> pkg_typert_registry
|
||||
pkg_typert_protocol --> pkg_error
|
||||
pkg_util_ripgrep --> pkg_subprocess
|
||||
pkg_system_prompt --> pkg_llm
|
||||
pkg_system_prompt --> pkg_scope
|
||||
@@ -556,6 +556,7 @@ flowchart TD
|
||||
pkg_subprocess_local --> pkg_subprocess
|
||||
pkg_subprocess_local --> pkg_timeout
|
||||
pkg_otel --> pkg_session
|
||||
pkg_remote_mock --> pkg_typert_protocol
|
||||
pkg_session_snapshot --> pkg_http_proxy
|
||||
pkg_session_snapshot --> pkg_session
|
||||
pkg_fs --> pkg_llm
|
||||
@@ -903,6 +904,7 @@ flowchart TD
|
||||
pkg_tool_todo --> pkg_tools
|
||||
pkg_plan_mode --> pkg_agent
|
||||
pkg_plan_mode --> pkg_commands
|
||||
pkg_plan_mode --> pkg_error
|
||||
pkg_plan_mode --> pkg_llm
|
||||
pkg_plan_mode --> pkg_session
|
||||
pkg_plan_mode --> pkg_session_projection
|
||||
@@ -1689,7 +1691,6 @@ flowchart TD
|
||||
| [`storage`](../packages/storage/storage) | `storage` | — |
|
||||
| [`llm-mock-server`](../packages/test-support/llm-mock-server) | `test-support` | — |
|
||||
| [`typert-generator`](../packages/typert/generator) | `typert` | — |
|
||||
| [`typert-protocol`](../packages/typert/protocol) | `typert` | — |
|
||||
| [`typert-registry`](../packages/typert/registry) | `typert` | — |
|
||||
| [`llm`](../packages/llm/llm) | `llm` | [`error`](../packages/util/error) |
|
||||
| [`session`](../packages/core/session) | `core` | [`scope`](../packages/core/scope) |
|
||||
@@ -1706,8 +1707,8 @@ flowchart TD
|
||||
| [`storage-sqlite`](../packages/storage/storage-sqlite) | `storage` | [`storage`](../packages/storage/storage) |
|
||||
| [`subprocess`](../packages/subprocess/subprocess) | `subprocess` | [`error`](../packages/util/error), [`http-proxy`](../packages/util/http-proxy) |
|
||||
| [`win32-process`](../packages/subprocess/win32-process) | `subprocess` | [`error`](../packages/util/error) |
|
||||
| [`remote-mock`](../packages/test-support/remote-mock) | `test-support` | [`typert-protocol`](../packages/typert/protocol) |
|
||||
| [`typert-loader`](../packages/typert/loader) | `typert` | [`typert-registry`](../packages/typert/registry) |
|
||||
| [`typert-protocol`](../packages/typert/protocol) | `typert` | [`error`](../packages/util/error) |
|
||||
| [`util-ripgrep`](../packages/util/ripgrep) | `util` | [`subprocess`](../packages/subprocess/subprocess) |
|
||||
| [`system-prompt`](../packages/core/system-prompt) | `core` | [`llm`](../packages/llm/llm), [`scope`](../packages/core/scope) |
|
||||
| [`skill`](../packages/skill/skill) | `skill` | [`llm`](../packages/llm/llm), [`scope`](../packages/core/scope) |
|
||||
@@ -1730,6 +1731,7 @@ flowchart TD
|
||||
| [`settings`](../packages/settings/settings) | `settings` | [`brand`](../packages/util/brand), [`session`](../packages/core/session) |
|
||||
| [`subprocess-local`](../packages/subprocess/subprocess-local) | `subprocess` | [`subprocess`](../packages/subprocess/subprocess), [`timeout`](../packages/util/timeout) |
|
||||
| [`otel`](../packages/telemetry/otel) | `telemetry` | [`session`](../packages/core/session) |
|
||||
| [`remote-mock`](../packages/test-support/remote-mock) | `test-support` | [`typert-protocol`](../packages/typert/protocol) |
|
||||
| [`session-snapshot`](../packages/test-support/session-snapshot) | `test-support` | [`http-proxy`](../packages/util/http-proxy), [`session`](../packages/core/session) |
|
||||
| [`fs`](../packages/fs/fs) | `fs` | [`llm`](../packages/llm/llm), [`sandbox`](../packages/sandbox/sandbox) |
|
||||
| [`skill-office`](../packages/skill/skill-office) | `skill` | [`skill`](../packages/skill/skill) |
|
||||
@@ -1815,7 +1817,7 @@ flowchart TD
|
||||
| [`tool-web`](../packages/web/tool-web) | `web` | [`llm`](../packages/llm/llm), [`system-prompt`](../packages/core/system-prompt), [`tools`](../packages/core/tools), [`web`](../packages/web/web) |
|
||||
| [`web-deepseek-api`](../packages/web/web-deepseek-api) | `web` | [`agent`](../packages/core/agent), [`credentials`](../packages/credentials/credentials), [`deepseek-account`](../packages/credentials/deepseek-account), [`launch-environment`](../packages/util/launch-environment), [`llm`](../packages/llm/llm), [`llm-deepseek`](../packages/llm/llm-deepseek), [`llm-deepseek-account`](../packages/llm/llm-deepseek-account), [`llm-deepseek-api-key`](../packages/llm/llm-deepseek-api-key), [`session`](../packages/core/session), [`web`](../packages/web/web) |
|
||||
| [`tool-todo`](../packages/todo/tool-todo) | `todo` | [`agent`](../packages/core/agent), [`session`](../packages/core/session), [`session-projection`](../packages/session/session-projection), [`tools`](../packages/core/tools) |
|
||||
| [`plan-mode`](../packages/plan/plan-mode) | `plan` | [`agent`](../packages/core/agent), [`commands`](../packages/interaction/commands), [`llm`](../packages/llm/llm), [`session`](../packages/core/session), [`session-projection`](../packages/session/session-projection), [`system-prompt`](../packages/core/system-prompt), [`tools`](../packages/core/tools), [`user-questions`](../packages/interaction/user-questions) |
|
||||
| [`plan-mode`](../packages/plan/plan-mode) | `plan` | [`agent`](../packages/core/agent), [`commands`](../packages/interaction/commands), [`error`](../packages/util/error), [`llm`](../packages/llm/llm), [`session`](../packages/core/session), [`session-projection`](../packages/session/session-projection), [`system-prompt`](../packages/core/system-prompt), [`tools`](../packages/core/tools), [`user-questions`](../packages/interaction/user-questions) |
|
||||
| [`command-compact`](../packages/compaction/command-compact) | `compaction` | [`commands`](../packages/interaction/commands), [`compaction`](../packages/compaction/compaction) |
|
||||
| [`compaction-image-offload`](../packages/compaction/compaction-image-offload) | `compaction` | [`agent`](../packages/core/agent), [`compaction`](../packages/compaction/compaction), [`llm`](../packages/llm/llm), [`session`](../packages/core/session) |
|
||||
| [`agent-instructions`](../packages/context/agent-instructions) | `context` | [`agent`](../packages/core/agent), [`fs`](../packages/fs/fs), [`home-paths`](../packages/util/home-paths), [`llm`](../packages/llm/llm), [`session`](../packages/core/session), [`tools`](../packages/core/tools), [`working-directory`](../packages/session/working-directory) |
|
||||
|
||||
@@ -153,8 +153,8 @@
|
||||
en: 4294f78d26ed985b
|
||||
zh: 4294f78d26ed985b
|
||||
/session-persistence-event-catalog/events/plan/plan-mode-log-only:
|
||||
en: 9ae5537eeae238de
|
||||
zh: 6be761c7fd83fdce
|
||||
en: bcc1f048e7a31f1e
|
||||
zh: a9c29711722cd6c7
|
||||
/session-persistence-event-catalog/events/request:
|
||||
en: a8df82440ebdf5f8
|
||||
zh: a8df82440ebdf5f8
|
||||
@@ -1227,8 +1227,8 @@
|
||||
en: b45c7e8370d7be1e
|
||||
zh: 252fdc0ff2b9338c
|
||||
/session-persistence-event-catalog/resolved-persistence-types/sessiontitlemodelidentity:
|
||||
en: 000a71d4e566c418
|
||||
zh: 906ebdbdee6aa500
|
||||
en: 7a7245bb23c38655
|
||||
zh: 6d96a94c367fbe64
|
||||
/session-persistence-event-catalog/resolved-persistence-types/sessiontitlemodelidentity~2:
|
||||
en: 13de8e35b749db45
|
||||
zh: 01e4f3bcb6784fc8
|
||||
@@ -1344,11 +1344,11 @@
|
||||
en: f36c65420460fcf1
|
||||
zh: 4208e6734c0672df
|
||||
/session-persistence-event-catalog/resolved-persistence-types/workflowagentoutcome:
|
||||
en: d0a3f9aab18c3de5
|
||||
zh: 76ac69a835ca4e29
|
||||
en: 711564ea7898e156
|
||||
zh: 36b88b84a6dc3c7e
|
||||
/session-persistence-event-catalog/resolved-persistence-types/workflowstopreason:
|
||||
en: a0d0018c68abc564
|
||||
zh: 299d86dbba56b528
|
||||
en: 88b6ae5b98ebee96
|
||||
zh: 6ee7103d36787f72
|
||||
/session-persistence-event-catalog/resolved-persistence-types/boolean:
|
||||
en: 40616917f0b8f9cc
|
||||
zh: 40616917f0b8f9cc
|
||||
@@ -1368,8 +1368,8 @@
|
||||
en: 7660c41e4129b466
|
||||
zh: bcbb1b15cb872214
|
||||
/session-persistence-event-catalog/resolved-persistence-types/string:
|
||||
en: b394e62f8785c8c7
|
||||
zh: dbc5d6d6aafd790e
|
||||
en: e855396a65482550
|
||||
zh: 0729e0b86b4d9681
|
||||
/session-persistence-event-catalog/resolved-persistence-types/string~2:
|
||||
en: 0089620bf4638263
|
||||
zh: 1922bef1713094bb
|
||||
@@ -1425,8 +1425,8 @@
|
||||
en: a74e3dfa51c987af
|
||||
zh: 6c3c87974d7a7260
|
||||
/session-persistence-event-catalog/resolved-persistence-types/active~2:
|
||||
en: c861888d6239b700
|
||||
zh: a9b2271d3c6b8737
|
||||
en: 235f08eeb284a1a5
|
||||
zh: b6ebffbfd7b44a9b
|
||||
/session-persistence-event-catalog/resolved-persistence-types/agentpreset:
|
||||
en: 1282a0b3d5fa8d4d
|
||||
zh: aa533aea643dbefb
|
||||
|
||||
@@ -735,7 +735,7 @@ Source: [`packages/interaction/permission-presets/src/index.ts:54`](../packages/
|
||||
'plan/mode': { active: boolean }
|
||||
```
|
||||
|
||||
Source: [`packages/plan/plan-mode/src/index.ts:53`](../packages/plan/plan-mode/src/index.ts)
|
||||
Source: [`packages/plan/plan-mode/src/index.ts:55`](../packages/plan/plan-mode/src/index.ts)
|
||||
|
||||
### `request/*`
|
||||
|
||||
@@ -4779,7 +4779,7 @@ Sources: [`packages/session/session-title-llm/src/index.ts:43`](../packages/sess
|
||||
|
||||
SHA-256: `07e1a58c58b593f507b8e7f25723bb0aa42baae6e00f5ecfddf28cb1e64d3235`
|
||||
|
||||
Sources: [`packages/session/session-title/src/types.ts:20`](../packages/session/session-title/src/types.ts) · [`packages/subagent/tool-subagent/src/model-selection.ts:10`](../packages/subagent/tool-subagent/src/model-selection.ts)
|
||||
Sources: [`packages/session/session-title/src/types.ts:20`](../packages/session/session-title/src/types.ts) · [`packages/subagent/tool-subagent/src/model-selection.ts:12`](../packages/subagent/tool-subagent/src/model-selection.ts)
|
||||
|
||||
| Property | Presence | Type |
|
||||
|---|---|---|
|
||||
@@ -5479,7 +5479,7 @@ Array of [`UserMessage`](#persistence-type-sha256-74e0e5885d2ddf04530ddf341b25cd
|
||||
|
||||
SHA-256: `c2deb7c9183735d4e0fffddf5c623f4e34daa1c8e96b111982e957dfcbbcf896`
|
||||
|
||||
Sources: [`packages/workflow/workflow/src/types.ts:110`](../packages/workflow/workflow/src/types.ts)
|
||||
Sources: [`packages/workflow/workflow/src/types.ts:116`](../packages/workflow/workflow/src/types.ts)
|
||||
|
||||
One of:
|
||||
|
||||
@@ -5497,7 +5497,7 @@ One of:
|
||||
|
||||
SHA-256: `8465ece5e9d9007c038b357015d849c15262cb0bc25abc59e47692d87ee01a15`
|
||||
|
||||
Sources: [`packages/workflow/workflow/src/types.ts:63`](../packages/workflow/workflow/src/types.ts)
|
||||
Sources: [`packages/workflow/workflow/src/types.ts:64`](../packages/workflow/workflow/src/types.ts)
|
||||
|
||||
One of:
|
||||
|
||||
@@ -5657,7 +5657,7 @@ Array of `number`.
|
||||
|
||||
SHA-256: `4cd48f3e5108bd6ebedf7301c3638839b8b2b9db8dbd493974177fbdeb91a01b`
|
||||
|
||||
Sources: [`packages/api/session-controller/src/types.ts:391`](../packages/api/session-controller/src/types.ts) · [`packages/attachment/attachment/src/brand.ts:6`](../packages/attachment/attachment/src/brand.ts) · [`packages/compaction/compaction/src/brand.ts:4`](../packages/compaction/compaction/src/brand.ts) · [`packages/core/session/src/types.ts:21`](../packages/core/session/src/types.ts) · [`packages/experimental/webhook/src/brand.ts:12`](../packages/experimental/webhook/src/brand.ts) · [`packages/experimental/webhook/src/brand.ts:6`](../packages/experimental/webhook/src/brand.ts) · [`packages/experimental/webhook/src/brand.ts:9`](../packages/experimental/webhook/src/brand.ts) · [`packages/feedback/message-feedback/src/types.ts:14`](../packages/feedback/message-feedback/src/types.ts) · [`packages/goal/goal/src/types.ts:17`](../packages/goal/goal/src/types.ts) · [`packages/interaction/commands/src/brand.ts:31`](../packages/interaction/commands/src/brand.ts) · [`packages/interaction/user-approval/src/types.ts:17`](../packages/interaction/user-approval/src/types.ts) · [`packages/jobs/jobs/src/brand.ts:19`](../packages/jobs/jobs/src/brand.ts) · [`packages/llm/llm-retry/src/brand.ts:4`](../packages/llm/llm-retry/src/brand.ts) · [`packages/llm/llm/src/brand.ts:16`](../packages/llm/llm/src/brand.ts) · [`packages/llm/llm/src/brand.ts:31`](../packages/llm/llm/src/brand.ts) · [`packages/llm/llm/src/brand.ts:43`](../packages/llm/llm/src/brand.ts) · [`packages/llm/llm/src/brand.ts:67`](../packages/llm/llm/src/brand.ts) · [`packages/schedule/schedule/src/types.ts:14`](../packages/schedule/schedule/src/types.ts) · [`packages/session/session-title/src/types.ts:17`](../packages/session/session-title/src/types.ts) · [`packages/team/agent-team/src/types.ts:20`](../packages/team/agent-team/src/types.ts) · [`packages/team/agent-team/src/types.ts:32`](../packages/team/agent-team/src/types.ts) · [`packages/team/agent-team/src/types.ts:8`](../packages/team/agent-team/src/types.ts) · [`packages/workflow/workflow/src/types.ts:13`](../packages/workflow/workflow/src/types.ts)
|
||||
Sources: [`packages/api/session-controller/src/types.ts:391`](../packages/api/session-controller/src/types.ts) · [`packages/attachment/attachment/src/brand.ts:6`](../packages/attachment/attachment/src/brand.ts) · [`packages/compaction/compaction/src/brand.ts:4`](../packages/compaction/compaction/src/brand.ts) · [`packages/core/session/src/types.ts:21`](../packages/core/session/src/types.ts) · [`packages/experimental/webhook/src/brand.ts:12`](../packages/experimental/webhook/src/brand.ts) · [`packages/experimental/webhook/src/brand.ts:6`](../packages/experimental/webhook/src/brand.ts) · [`packages/experimental/webhook/src/brand.ts:9`](../packages/experimental/webhook/src/brand.ts) · [`packages/feedback/message-feedback/src/types.ts:14`](../packages/feedback/message-feedback/src/types.ts) · [`packages/goal/goal/src/types.ts:17`](../packages/goal/goal/src/types.ts) · [`packages/interaction/commands/src/brand.ts:31`](../packages/interaction/commands/src/brand.ts) · [`packages/interaction/user-approval/src/types.ts:17`](../packages/interaction/user-approval/src/types.ts) · [`packages/jobs/jobs/src/brand.ts:19`](../packages/jobs/jobs/src/brand.ts) · [`packages/llm/llm-retry/src/brand.ts:4`](../packages/llm/llm-retry/src/brand.ts) · [`packages/llm/llm/src/brand.ts:16`](../packages/llm/llm/src/brand.ts) · [`packages/llm/llm/src/brand.ts:31`](../packages/llm/llm/src/brand.ts) · [`packages/llm/llm/src/brand.ts:43`](../packages/llm/llm/src/brand.ts) · [`packages/llm/llm/src/brand.ts:67`](../packages/llm/llm/src/brand.ts) · [`packages/schedule/schedule/src/types.ts:14`](../packages/schedule/schedule/src/types.ts) · [`packages/session/session-title/src/types.ts:17`](../packages/session/session-title/src/types.ts) · [`packages/team/agent-team/src/types.ts:20`](../packages/team/agent-team/src/types.ts) · [`packages/team/agent-team/src/types.ts:32`](../packages/team/agent-team/src/types.ts) · [`packages/team/agent-team/src/types.ts:8`](../packages/team/agent-team/src/types.ts) · [`packages/workflow/workflow/src/types.ts:14`](../packages/workflow/workflow/src/types.ts)
|
||||
|
||||
`string`
|
||||
|
||||
@@ -5868,7 +5868,7 @@ Array of `unknown` (opaque).
|
||||
|
||||
SHA-256: `20a57544bbf204dacd1ae6beb2ab29444365c3c869f2afdf489dcdcbc3d9c8c5`
|
||||
|
||||
Sources: [`packages/plan/plan-mode/src/index.ts:53`](../packages/plan/plan-mode/src/index.ts)
|
||||
Sources: [`packages/plan/plan-mode/src/index.ts:55`](../packages/plan/plan-mode/src/index.ts)
|
||||
|
||||
| Property | Presence | Type |
|
||||
|---|---|---|
|
||||
|
||||
@@ -737,7 +737,7 @@ export type SessionEvent<T extends SessionEventType = SessionEventType> = {
|
||||
'plan/mode': { active: boolean }
|
||||
```
|
||||
|
||||
来源:[`packages/plan/plan-mode/src/index.ts:53`](../packages/plan/plan-mode/src/index.ts)
|
||||
来源:[`packages/plan/plan-mode/src/index.ts:55`](../packages/plan/plan-mode/src/index.ts)
|
||||
|
||||
### `request/*`
|
||||
|
||||
@@ -4781,7 +4781,7 @@ SHA-256: `bec5ca3a376f56f3d69df7f12a48e1cc07d4ea8305968773394c8734799faeb4`
|
||||
|
||||
SHA-256: `07e1a58c58b593f507b8e7f25723bb0aa42baae6e00f5ecfddf28cb1e64d3235`
|
||||
|
||||
来源:[`packages/session/session-title/src/types.ts:20`](../packages/session/session-title/src/types.ts) · [`packages/subagent/tool-subagent/src/model-selection.ts:10`](../packages/subagent/tool-subagent/src/model-selection.ts)
|
||||
来源:[`packages/session/session-title/src/types.ts:20`](../packages/session/session-title/src/types.ts) · [`packages/subagent/tool-subagent/src/model-selection.ts:12`](../packages/subagent/tool-subagent/src/model-selection.ts)
|
||||
|
||||
| 属性 | 存在性 | 类型 |
|
||||
|---|---|---|
|
||||
@@ -5481,7 +5481,7 @@ SHA-256: `8a54d228b1b7d8453e4304d32723d489f28b4b33b221f335342146926ad94fc6`
|
||||
|
||||
SHA-256: `c2deb7c9183735d4e0fffddf5c623f4e34daa1c8e96b111982e957dfcbbcf896`
|
||||
|
||||
来源:[`packages/workflow/workflow/src/types.ts:110`](../packages/workflow/workflow/src/types.ts)
|
||||
来源:[`packages/workflow/workflow/src/types.ts:116`](../packages/workflow/workflow/src/types.ts)
|
||||
|
||||
以下类型之一:
|
||||
|
||||
@@ -5499,7 +5499,7 @@ SHA-256: `c2deb7c9183735d4e0fffddf5c623f4e34daa1c8e96b111982e957dfcbbcf896`
|
||||
|
||||
SHA-256: `8465ece5e9d9007c038b357015d849c15262cb0bc25abc59e47692d87ee01a15`
|
||||
|
||||
来源:[`packages/workflow/workflow/src/types.ts:63`](../packages/workflow/workflow/src/types.ts)
|
||||
来源:[`packages/workflow/workflow/src/types.ts:64`](../packages/workflow/workflow/src/types.ts)
|
||||
|
||||
以下类型之一:
|
||||
|
||||
@@ -5659,7 +5659,7 @@ SHA-256: `5d03ba38734809bcbd2a55221bd938b3b3fc34b49bb686c6113e9e4931e3aa78`
|
||||
|
||||
SHA-256: `4cd48f3e5108bd6ebedf7301c3638839b8b2b9db8dbd493974177fbdeb91a01b`
|
||||
|
||||
来源:[`packages/api/session-controller/src/types.ts:391`](../packages/api/session-controller/src/types.ts) · [`packages/attachment/attachment/src/brand.ts:6`](../packages/attachment/attachment/src/brand.ts) · [`packages/compaction/compaction/src/brand.ts:4`](../packages/compaction/compaction/src/brand.ts) · [`packages/core/session/src/types.ts:21`](../packages/core/session/src/types.ts) · [`packages/experimental/webhook/src/brand.ts:12`](../packages/experimental/webhook/src/brand.ts) · [`packages/experimental/webhook/src/brand.ts:6`](../packages/experimental/webhook/src/brand.ts) · [`packages/experimental/webhook/src/brand.ts:9`](../packages/experimental/webhook/src/brand.ts) · [`packages/feedback/message-feedback/src/types.ts:14`](../packages/feedback/message-feedback/src/types.ts) · [`packages/goal/goal/src/types.ts:17`](../packages/goal/goal/src/types.ts) · [`packages/interaction/commands/src/brand.ts:31`](../packages/interaction/commands/src/brand.ts) · [`packages/interaction/user-approval/src/types.ts:17`](../packages/interaction/user-approval/src/types.ts) · [`packages/jobs/jobs/src/brand.ts:19`](../packages/jobs/jobs/src/brand.ts) · [`packages/llm/llm-retry/src/brand.ts:4`](../packages/llm/llm-retry/src/brand.ts) · [`packages/llm/llm/src/brand.ts:16`](../packages/llm/llm/src/brand.ts) · [`packages/llm/llm/src/brand.ts:31`](../packages/llm/llm/src/brand.ts) · [`packages/llm/llm/src/brand.ts:43`](../packages/llm/llm/src/brand.ts) · [`packages/llm/llm/src/brand.ts:67`](../packages/llm/llm/src/brand.ts) · [`packages/schedule/schedule/src/types.ts:14`](../packages/schedule/schedule/src/types.ts) · [`packages/session/session-title/src/types.ts:17`](../packages/session/session-title/src/types.ts) · [`packages/team/agent-team/src/types.ts:20`](../packages/team/agent-team/src/types.ts) · [`packages/team/agent-team/src/types.ts:32`](../packages/team/agent-team/src/types.ts) · [`packages/team/agent-team/src/types.ts:8`](../packages/team/agent-team/src/types.ts) · [`packages/workflow/workflow/src/types.ts:13`](../packages/workflow/workflow/src/types.ts)
|
||||
来源:[`packages/api/session-controller/src/types.ts:391`](../packages/api/session-controller/src/types.ts) · [`packages/attachment/attachment/src/brand.ts:6`](../packages/attachment/attachment/src/brand.ts) · [`packages/compaction/compaction/src/brand.ts:4`](../packages/compaction/compaction/src/brand.ts) · [`packages/core/session/src/types.ts:21`](../packages/core/session/src/types.ts) · [`packages/experimental/webhook/src/brand.ts:12`](../packages/experimental/webhook/src/brand.ts) · [`packages/experimental/webhook/src/brand.ts:6`](../packages/experimental/webhook/src/brand.ts) · [`packages/experimental/webhook/src/brand.ts:9`](../packages/experimental/webhook/src/brand.ts) · [`packages/feedback/message-feedback/src/types.ts:14`](../packages/feedback/message-feedback/src/types.ts) · [`packages/goal/goal/src/types.ts:17`](../packages/goal/goal/src/types.ts) · [`packages/interaction/commands/src/brand.ts:31`](../packages/interaction/commands/src/brand.ts) · [`packages/interaction/user-approval/src/types.ts:17`](../packages/interaction/user-approval/src/types.ts) · [`packages/jobs/jobs/src/brand.ts:19`](../packages/jobs/jobs/src/brand.ts) · [`packages/llm/llm-retry/src/brand.ts:4`](../packages/llm/llm-retry/src/brand.ts) · [`packages/llm/llm/src/brand.ts:16`](../packages/llm/llm/src/brand.ts) · [`packages/llm/llm/src/brand.ts:31`](../packages/llm/llm/src/brand.ts) · [`packages/llm/llm/src/brand.ts:43`](../packages/llm/llm/src/brand.ts) · [`packages/llm/llm/src/brand.ts:67`](../packages/llm/llm/src/brand.ts) · [`packages/schedule/schedule/src/types.ts:14`](../packages/schedule/schedule/src/types.ts) · [`packages/session/session-title/src/types.ts:17`](../packages/session/session-title/src/types.ts) · [`packages/team/agent-team/src/types.ts:20`](../packages/team/agent-team/src/types.ts) · [`packages/team/agent-team/src/types.ts:32`](../packages/team/agent-team/src/types.ts) · [`packages/team/agent-team/src/types.ts:8`](../packages/team/agent-team/src/types.ts) · [`packages/workflow/workflow/src/types.ts:14`](../packages/workflow/workflow/src/types.ts)
|
||||
|
||||
`string`
|
||||
|
||||
@@ -5870,7 +5870,7 @@ SHA-256: `b1664fa89f8eab49a14e7e3168d8bc4da4aa9fd76332f6c4a053d839e5276ae7`
|
||||
|
||||
SHA-256: `20a57544bbf204dacd1ae6beb2ab29444365c3c869f2afdf489dcdcbc3d9c8c5`
|
||||
|
||||
来源:[`packages/plan/plan-mode/src/index.ts:53`](../packages/plan/plan-mode/src/index.ts)
|
||||
来源:[`packages/plan/plan-mode/src/index.ts:55`](../packages/plan/plan-mode/src/index.ts)
|
||||
|
||||
| 属性 | 存在性 | 类型 |
|
||||
|---|---|---|
|
||||
|
||||
Generated
+5
-5
@@ -80,7 +80,7 @@
|
||||
{"digest":"05a2796621b1ee6c03ef7abe560b25116bb4da4d592312117242a78415a32b04","names":[],"sources":[]},
|
||||
{"digest":"05d2ae1e0c7f8770f83f9a09047afb39a335d8ac986df3193659aa1e581472cf","names":["packages/interaction/user-approval/src/index.ts#ApprovalPolicy"],"sources":["packages/interaction/user-approval/src/index.ts:69"]},
|
||||
{"digest":"0657d3ca5ac4e7bf79b00bcf860b1c7159d01a9da137497221ec2f1776e365f7","names":["packages/core/session/src/types.ts#SessionSeq"],"sources":["packages/core/session/src/types.ts:33"]},
|
||||
{"digest":"07e1a58c58b593f507b8e7f25723bb0aa42baae6e00f5ecfddf28cb1e64d3235","names":["packages/session/session-title/src/types.ts#SessionTitleModelIdentity","packages/subagent/tool-subagent/src/model-selection.ts#AllowedModelRoute"],"sources":["packages/session/session-title/src/types.ts:20","packages/subagent/tool-subagent/src/model-selection.ts:10"]},
|
||||
{"digest":"07e1a58c58b593f507b8e7f25723bb0aa42baae6e00f5ecfddf28cb1e64d3235","names":["packages/session/session-title/src/types.ts#SessionTitleModelIdentity","packages/subagent/tool-subagent/src/model-selection.ts#AllowedModelRoute"],"sources":["packages/session/session-title/src/types.ts:20","packages/subagent/tool-subagent/src/model-selection.ts:12"]},
|
||||
{"digest":"07eccc9ea2f9b5439d76cc77d5e062936677d43f07a23da749819b0a22ee36b7","names":[],"sources":[]},
|
||||
{"digest":"09655b34d7f3cf1e9005974de2357de2d4a60deea165d16dac1eadaa6ec539a8","names":[],"sources":[]},
|
||||
{"digest":"09f3f8dc417f278257202714132f98ba7b52957d7b558c4a04456603890eb363","names":["packages/llm/llm/src/message.ts#SystemMessage"],"sources":["packages/llm/llm/src/message.ts:151"]},
|
||||
@@ -155,7 +155,7 @@
|
||||
{"digest":"1f1385dbc3e875c021e387c7096d671d606f22daec51b25c80348735b6bbfa10","names":[],"sources":[]},
|
||||
{"digest":"1f8c126cfab3df812cd115cfc23e3256f0fa2383400f4ce91ecad313577e59b0","names":["packages/core/session/src/types.ts#TurnEndCancelCause"],"sources":["packages/core/session/src/types.ts:201"]},
|
||||
{"digest":"1fdad624334d354820dfb3a26e28d0bc9fc1b62a33f87bab63f715b3f4391bfd","names":[],"sources":[]},
|
||||
{"digest":"20a57544bbf204dacd1ae6beb2ab29444365c3c869f2afdf489dcdcbc3d9c8c5","names":[],"sources":["packages/plan/plan-mode/src/index.ts:53"]},
|
||||
{"digest":"20a57544bbf204dacd1ae6beb2ab29444365c3c869f2afdf489dcdcbc3d9c8c5","names":[],"sources":["packages/plan/plan-mode/src/index.ts:55"]},
|
||||
{"digest":"2142e391b9ccb60d487afcf373ce74db98d952f69e8289eddb352a7e16e996c5","names":[],"sources":[]},
|
||||
{"digest":"2152caf1a71e588e4df2358a806dea24936c1c47131134f01a12939d12cdc0c0","names":["packages/team/agent-team/src/types.ts#TeamMessageSource"],"sources":["packages/team/agent-team/src/types.ts:121"]},
|
||||
{"digest":"21fb6a90d5068f6a0003b7ab316ed2f56342477146a65c00db0f13c4d8df667d","names":[],"sources":[]},
|
||||
@@ -259,7 +259,7 @@
|
||||
{"digest":"4b259f7f8f0a44ad5e90b70a73553ced1df27012d126921d397ff403b6c86731","names":["packages/llm/llm/src/message.ts#ToolResultMessage"],"sources":["packages/llm/llm/src/message.ts:173"]},
|
||||
{"digest":"4b7ddaf3710b88ff9b8df66304f5f97bf03688fd19730eedc2e9535203c820ea","names":[],"sources":[]},
|
||||
{"digest":"4bb451330ff699f36b45539ceb0eb2606ead72084e2c5bb637c36cc80e2252db","names":[],"sources":["packages/core/session/src/types.ts:198"]},
|
||||
{"digest":"4cd48f3e5108bd6ebedf7301c3638839b8b2b9db8dbd493974177fbdeb91a01b","names":["packages/api/session-controller/src/types.ts#SessionRequestId","packages/attachment/attachment/src/brand.ts#AttachmentId","packages/compaction/compaction/src/brand.ts#CompactionId","packages/core/session/src/types.ts#SessionId","packages/experimental/webhook/src/brand.ts#WebhookDeliveryId","packages/experimental/webhook/src/brand.ts#WebhookRuleId","packages/experimental/webhook/src/brand.ts#WebhookSourceId","packages/feedback/message-feedback/src/types.ts#MessageFeedbackVersion","packages/goal/goal/src/types.ts#GoalId","packages/interaction/commands/src/brand.ts#CommandId","packages/interaction/user-approval/src/types.ts#ApprovalRequestId","packages/jobs/jobs/src/brand.ts#JobId","packages/llm/llm-retry/src/brand.ts#RetryId","packages/llm/llm/src/brand.ts#MessageId","packages/llm/llm/src/brand.ts#ProviderRequestId","packages/llm/llm/src/brand.ts#ReasoningEffortId","packages/llm/llm/src/brand.ts#ToolCallId","packages/schedule/schedule/src/types.ts#ScheduleId","packages/session/session-title/src/types.ts#SessionTitleProviderId","packages/team/agent-team/src/types.ts#TeamId","packages/team/agent-team/src/types.ts#TeamMessageId","packages/team/agent-team/src/types.ts#TeamTaskId","packages/workflow/workflow/src/types.ts#WorkflowRunId"],"sources":["packages/api/session-controller/src/types.ts:391","packages/attachment/attachment/src/brand.ts:6","packages/compaction/compaction/src/brand.ts:4","packages/core/session/src/types.ts:21","packages/experimental/webhook/src/brand.ts:12","packages/experimental/webhook/src/brand.ts:6","packages/experimental/webhook/src/brand.ts:9","packages/feedback/message-feedback/src/types.ts:14","packages/goal/goal/src/types.ts:17","packages/interaction/commands/src/brand.ts:31","packages/interaction/user-approval/src/types.ts:17","packages/jobs/jobs/src/brand.ts:19","packages/llm/llm-retry/src/brand.ts:4","packages/llm/llm/src/brand.ts:16","packages/llm/llm/src/brand.ts:31","packages/llm/llm/src/brand.ts:43","packages/llm/llm/src/brand.ts:67","packages/schedule/schedule/src/types.ts:14","packages/session/session-title/src/types.ts:17","packages/team/agent-team/src/types.ts:20","packages/team/agent-team/src/types.ts:32","packages/team/agent-team/src/types.ts:8","packages/workflow/workflow/src/types.ts:13"]},
|
||||
{"digest":"4cd48f3e5108bd6ebedf7301c3638839b8b2b9db8dbd493974177fbdeb91a01b","names":["packages/api/session-controller/src/types.ts#SessionRequestId","packages/attachment/attachment/src/brand.ts#AttachmentId","packages/compaction/compaction/src/brand.ts#CompactionId","packages/core/session/src/types.ts#SessionId","packages/experimental/webhook/src/brand.ts#WebhookDeliveryId","packages/experimental/webhook/src/brand.ts#WebhookRuleId","packages/experimental/webhook/src/brand.ts#WebhookSourceId","packages/feedback/message-feedback/src/types.ts#MessageFeedbackVersion","packages/goal/goal/src/types.ts#GoalId","packages/interaction/commands/src/brand.ts#CommandId","packages/interaction/user-approval/src/types.ts#ApprovalRequestId","packages/jobs/jobs/src/brand.ts#JobId","packages/llm/llm-retry/src/brand.ts#RetryId","packages/llm/llm/src/brand.ts#MessageId","packages/llm/llm/src/brand.ts#ProviderRequestId","packages/llm/llm/src/brand.ts#ReasoningEffortId","packages/llm/llm/src/brand.ts#ToolCallId","packages/schedule/schedule/src/types.ts#ScheduleId","packages/session/session-title/src/types.ts#SessionTitleProviderId","packages/team/agent-team/src/types.ts#TeamId","packages/team/agent-team/src/types.ts#TeamMessageId","packages/team/agent-team/src/types.ts#TeamTaskId","packages/workflow/workflow/src/types.ts#WorkflowRunId"],"sources":["packages/api/session-controller/src/types.ts:391","packages/attachment/attachment/src/brand.ts:6","packages/compaction/compaction/src/brand.ts:4","packages/core/session/src/types.ts:21","packages/experimental/webhook/src/brand.ts:12","packages/experimental/webhook/src/brand.ts:6","packages/experimental/webhook/src/brand.ts:9","packages/feedback/message-feedback/src/types.ts:14","packages/goal/goal/src/types.ts:17","packages/interaction/commands/src/brand.ts:31","packages/interaction/user-approval/src/types.ts:17","packages/jobs/jobs/src/brand.ts:19","packages/llm/llm-retry/src/brand.ts:4","packages/llm/llm/src/brand.ts:16","packages/llm/llm/src/brand.ts:31","packages/llm/llm/src/brand.ts:43","packages/llm/llm/src/brand.ts:67","packages/schedule/schedule/src/types.ts:14","packages/session/session-title/src/types.ts:17","packages/team/agent-team/src/types.ts:20","packages/team/agent-team/src/types.ts:32","packages/team/agent-team/src/types.ts:8","packages/workflow/workflow/src/types.ts:14"]},
|
||||
{"digest":"4d60dddaa65d3da8d4cd014d85ce3d2c2875664dd0433e331d8e9d395289686b","names":["packages/experimental/liveshare/src/host/viewer-principal.ts#ShareViewerPrincipal"],"sources":["packages/experimental/liveshare/src/host/viewer-principal.ts:24"]},
|
||||
{"digest":"4e011753f8263f436efaabfbb3b4db53a98fc55342c5ded2daf7208b217be159","names":[],"sources":[]},
|
||||
{"digest":"4e44c9118152f6829634bfd508e47669ab0497caffa380c94b4be91f9390d35d","names":[],"sources":[]},
|
||||
@@ -396,7 +396,7 @@
|
||||
{"digest":"8338ee303e2bd448e9e6144069942f63e3cfd5868962bddc9347d7009e8919d6","names":[],"sources":[]},
|
||||
{"digest":"83d6916021eede8f2d83a1872716caa1efdec39a3681890996c55147187fdd12","names":[],"sources":[]},
|
||||
{"digest":"83da72c6857601c75da11212ef847f57d457b9c99f0a82246dcdff3e26700239","names":["packages/context/agent-instructions/src/render.ts#AgentInstructionChange"],"sources":["packages/context/agent-instructions/src/render.ts:62"]},
|
||||
{"digest":"8465ece5e9d9007c038b357015d849c15262cb0bc25abc59e47692d87ee01a15","names":["packages/workflow/workflow/src/types.ts#WorkflowStopReason"],"sources":["packages/workflow/workflow/src/types.ts:63"]},
|
||||
{"digest":"8465ece5e9d9007c038b357015d849c15262cb0bc25abc59e47692d87ee01a15","names":["packages/workflow/workflow/src/types.ts#WorkflowStopReason"],"sources":["packages/workflow/workflow/src/types.ts:64"]},
|
||||
{"digest":"848639f8787f035b480ec53cb5686850897c5e8006d87ca231cd8a9ee8634936","names":["packages/subagent/subagent/src/continuation-messages.ts#SubagentSettledMessageSource"],"sources":["packages/subagent/subagent/src/continuation-messages.ts:29"]},
|
||||
{"digest":"84ac8c1a66ffc697262e181f42e851259eae14038c113ca329fb4700ccdb1f7c","names":["packages/goal/goal/src/types.ts#GoalBlockReason"],"sources":["packages/goal/goal/src/types.ts:52"]},
|
||||
{"digest":"84bbfdce7d2eab5b0c53e72ff7406db856c8bfd621b965b72fd86598ba493bf7","names":[],"sources":[]},
|
||||
@@ -570,7 +570,7 @@
|
||||
{"digest":"c1f9e0405de6d18cabb9ee70782a027f9bbdc57e5abec9dcccdd56119e2e9058","names":[],"sources":[]},
|
||||
{"digest":"c219efbdfd53b836786202ab4532913d555798f0a8615a4e9629736e3799fb70","names":[],"sources":[]},
|
||||
{"digest":"c2a13242efc3bea4b36a843ddf1524ff4d33c765a71b582fa1fdbfa4fa148434","names":[],"sources":["packages/team/agent-team/src/types.ts:177"]},
|
||||
{"digest":"c2deb7c9183735d4e0fffddf5c623f4e34daa1c8e96b111982e957dfcbbcf896","names":["packages/workflow/workflow/src/types.ts#WorkflowAgentOutcome"],"sources":["packages/workflow/workflow/src/types.ts:110"]},
|
||||
{"digest":"c2deb7c9183735d4e0fffddf5c623f4e34daa1c8e96b111982e957dfcbbcf896","names":["packages/workflow/workflow/src/types.ts#WorkflowAgentOutcome"],"sources":["packages/workflow/workflow/src/types.ts:116"]},
|
||||
{"digest":"c2f49004d9ae38a964e80850c87bc6849d6a872091a1d43e99eedf00c641e2a3","names":[],"sources":[]},
|
||||
{"digest":"c43b119ce579b3e9983a0d3adc4ba402ebb9ba773d89738a2dab01ecf5813943","names":[],"sources":[]},
|
||||
{"digest":"c51f0d0a405bb96fcb008c0dc560a512dcd8c3919b6b446937f449ea2f7d21d8","names":["packages/llm/llm/src/message.ts#Message"],"sources":["packages/llm/llm/src/message.ts:196"]},
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
en: ee04468005fae8e1
|
||||
zh: 1347d554102951f2
|
||||
/plan-mode/the-exit-tool-and-the-plan-command:
|
||||
en: 32ecfb7086dd1578
|
||||
zh: 0aaeaa69bb63f255
|
||||
en: c9e86f6312dab80f
|
||||
zh: 41b763216d6b1a54
|
||||
/plan-mode/the-service:
|
||||
en: f3e6d5a7fe0b67f0
|
||||
zh: 774cc97e493991fa
|
||||
@@ -30,7 +30,7 @@ A missing, blank, or non-string `section` and any unknown key fail at plugin loa
|
||||
|
||||
## The exit tool and the `/plan` command
|
||||
|
||||
[`exit_plan_mode`](../tool-catalog.md#deepseek-aidsh-plan-mode) is disclosed progressively: it is admitted from the first step whose selected plan state is active and stays admitted for the rest of the Session, so the first plan-mode entry adds it to the request tool declarations and later transitions change only the plan guidance. Native and PTC execution use the same admitted set; a call before the first entry returns `UNKNOWN_TOOL`, and a call while plan mode is not committed fails. In plan mode it requires a complete markdown plan starting with a `#` heading and presents it for review through the [user-questions seam](user-questions.md). Approval returns `{ approved: true }` and records a silent (non-narrated) pending exit that is appended at the next accepted in-turn pre-step. Plan guidance therefore remains active for the rest of the assistant's current tool batch, and the tool result itself reports the transition. Keep-planning is a failed call carrying the user's feedback, so the model revises and presents again. A dismissed review returns `{ approved: false }` and concludes the turn, so plan mode stays active until the user's next message. A missing interaction channel and a service reload during review also fail the call rather than silently leaving plan mode.
|
||||
[`exit_plan_mode`](../tool-catalog.md#deepseek-aidsh-plan-mode) is disclosed progressively: it is admitted from the first step whose selected plan state is active and stays admitted for the rest of the Session, so the first plan-mode entry adds it to the request tool declarations and later transitions change only the plan guidance. Native and PTC execution use the same admitted set; a call before the first entry returns `UNKNOWN_TOOL`, and a call while plan mode is not committed fails with `PlanModeError` `PLAN_NOT_ACTIVE`. In plan mode it requires a complete markdown plan starting with a `#` heading, rejecting any other plan with `ToolArgsError`, and presents it for review through the [user-questions seam](user-questions.md). Approval returns `{ approved: true }` and records a silent (non-narrated) pending exit that is appended at the next accepted in-turn pre-step. Plan guidance therefore remains active for the rest of the assistant's current tool batch, and the tool result itself reports the transition. Keep-planning is a failed call with `PlanModeError` `PLAN_REVISION_REQUESTED` carrying the user's feedback, so the model revises and presents again. A dismissed review returns `{ approved: false }` and concludes the turn, so plan mode stays active until the user's next message. A missing interaction channel (`ToolContextUnavailableError`) and a service reload during review (`PLAN_REVIEW_INTERRUPTED`) also fail the call rather than silently leaving plan mode.
|
||||
|
||||
When [`ctx.commands`](commands.md) is composed, the plugin registers `/plan [off|message]`: bare `/plan` selects plan mode, any other non-empty message selects it and then submits the text through `agent.steer()` so it becomes the next step's ordinary logged user message under plan guidance, and the exact argument `off` selects inactive, which also cancels a pending entry before it is appended and becomes visible to a request.
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ interface PlanModeConfig {
|
||||
|
||||
## 退出工具与 `/plan` 命令
|
||||
|
||||
[`exit_plan_mode`](../tool-catalog.zh.md#deepseek-aidsh-plan-mode) 采用渐进式披露:从已选计划状态首次为激活的步骤起准入,并在会话剩余部分保持准入,因此首次进入计划模式时它进入请求的工具声明,之后的切换只改变计划指引。原生与 PTC 执行使用同一准入集合;首次进入之前调用返回 `UNKNOWN_TOOL`,计划模式未提交时调用会失败。在计划模式中,它要求一份以 `#` 标题开头的完整 markdown 计划,并通过[用户交互 seam](user-questions.zh.md) 呈交评审。批准返回 `{ approved: true }`,并记录一个静默(不叙述)的待生效退出,由下一个被接受的轮内 pre-step 追加。因此,计划指引在 assistant 当前这批工具调用的剩余部分继续生效,而工具结果本身会报告这次转换。「继续规划」则是一次携带用户反馈的失败调用,模型据此修订并再次呈交。放弃评审返回 `{ approved: false }` 并结束当前轮次,计划模式保持激活,直到用户发出下一条消息。评审期间交互通道缺失或服务重载同样使调用失败,而不是静默离开计划模式。
|
||||
[`exit_plan_mode`](../tool-catalog.zh.md#deepseek-aidsh-plan-mode) 采用渐进式披露:从已选计划状态首次为激活的步骤起准入,并在会话剩余部分保持准入,因此首次进入计划模式时它进入请求的工具声明,之后的切换只改变计划指引。原生与 PTC 执行使用同一准入集合;首次进入之前调用返回 `UNKNOWN_TOOL`,计划模式未提交时调用以 `PlanModeError` `PLAN_NOT_ACTIVE` 失败。在计划模式中,它要求一份以 `#` 标题开头的完整 markdown 计划,其他计划以 `ToolArgsError` 拒绝,并通过[用户交互 seam](user-questions.zh.md) 呈交评审。批准返回 `{ approved: true }`,并记录一个静默(不叙述)的待生效退出,由下一个被接受的轮内 pre-step 追加。因此,计划指引在 assistant 当前这批工具调用的剩余部分继续生效,而工具结果本身会报告这次转换。「继续规划」则是一次以 `PlanModeError` `PLAN_REVISION_REQUESTED` 失败并携带用户反馈的调用,模型据此修订并再次呈交。放弃评审返回 `{ approved: false }` 并结束当前轮次,计划模式保持激活,直到用户发出下一条消息。交互通道缺失(`ToolContextUnavailableError`)或评审期间服务重载(`PLAN_REVIEW_INTERRUPTED`)同样使调用失败,而不是静默离开计划模式。
|
||||
|
||||
当 [`ctx.commands`](commands.zh.md) 被组合时,插件注册 `/plan [off|message]`:单独的 `/plan` 选择计划模式;任何其他非空消息先选择计划模式,再通过 `agent.steer()` 提交该文本,使其在计划指引下成为下一步骤的普通已记录用户消息;确切参数 `off` 选择未激活,这还会在待生效条目被追加并对请求可见之前将其取消。
|
||||
|
||||
|
||||
@@ -24,5 +24,5 @@
|
||||
en: 74fa698d4a115e80
|
||||
zh: 4e9b03b5eab2ae5e
|
||||
/user-interaction/errors:
|
||||
en: 5762b1498a426ab6
|
||||
zh: bb9987ec82103620
|
||||
en: 832b165cfa48839d
|
||||
zh: 6989f734b373c1f9
|
||||
@@ -209,7 +209,7 @@ After a Host restart, the Remote layer resumes the root agent when the Session r
|
||||
|
||||
## Errors
|
||||
|
||||
`UserQuestionError` extends `HarnessError`, so `ctx.tools.execute()` preserves `{ name, code }` for model-facing tool failures such as `EMPTY_QUESTIONS`, `BAD_INTENT`, `NO_PROVIDER`, `ASK_ABORTED`, or UI-side cancellation.
|
||||
`UserQuestionError` extends `HarnessError`, so `ctx.tools.execute()` preserves `{ name, code }` for model-facing tool failures such as `EMPTY_QUESTIONS`, `BAD_INTENT`, `NO_PROVIDER`, `ASK_ABORTED`, or UI-side cancellation. An answerer failure that is not a `HarnessError` becomes `PROVIDER_ERROR` with the original message and the original as `cause`; another `HarnessError` keeps its own `name` and `code`.
|
||||
|
||||
```ts type-equiv
|
||||
/** Stable error taxonomy for user-questions failures. */
|
||||
@@ -286,8 +286,11 @@ async askTimed( request: AskUserQuestionRequest & { agent: Agent }, callId: Tool
|
||||
* @returns The answer chosen or typed by the human.
|
||||
* @throws {UserQuestionError} code `ASK_ABORTED` when the supplied signal
|
||||
* is already or becomes aborted, `CALLER_NOT_LIVE` when a supplied agent
|
||||
* is not the registry's exact live instance, or `DELEGATED_CALLER` when
|
||||
* that live agent has subagent origin.
|
||||
* is not the registry's exact live instance, `DELEGATED_CALLER` when
|
||||
* that live agent has subagent origin, or `PROVIDER_ERROR`, keeping the
|
||||
* original message, when an answerer fails with a value that is not a
|
||||
* `HarnessError`; a coded `HarnessError` from an answerer keeps its `name`
|
||||
* and `code`.
|
||||
*/
|
||||
async ask(request: AskUserQuestionRequest): Promise<AskUserQuestionAnswer>
|
||||
```
|
||||
|
||||
@@ -209,7 +209,7 @@ Host 重启后,Session 重开时 Remote 层会恢复根 agent。之后的迟
|
||||
|
||||
## 错误
|
||||
|
||||
`UserQuestionError` 继承 `HarnessError`,因此 `ctx.tools.execute()` 会保留 `{ name, code }`,用于面向模型的工具失败,如 `EMPTY_QUESTIONS`、`BAD_INTENT`、`NO_PROVIDER`、`ASK_ABORTED` 或 UI 侧取消。
|
||||
`UserQuestionError` 继承 `HarnessError`,因此 `ctx.tools.execute()` 会保留 `{ name, code }`,用于面向模型的工具失败,如 `EMPTY_QUESTIONS`、`BAD_INTENT`、`NO_PROVIDER`、`ASK_ABORTED` 或 UI 侧取消。不是 `HarnessError` 的应答方失败会变为 `PROVIDER_ERROR`,保留原 message,原错误作为 `cause`;其他 `HarnessError` 保留自身的 `name` 与 `code`。
|
||||
|
||||
```ts type-equiv
|
||||
/** Stable error taxonomy for user-questions failures. */
|
||||
@@ -286,8 +286,11 @@ async askTimed( request: AskUserQuestionRequest & { agent: Agent }, callId: Tool
|
||||
* @returns The answer chosen or typed by the human.
|
||||
* @throws {UserQuestionError} code `ASK_ABORTED` when the supplied signal
|
||||
* is already or becomes aborted, `CALLER_NOT_LIVE` when a supplied agent
|
||||
* is not the registry's exact live instance, or `DELEGATED_CALLER` when
|
||||
* that live agent has subagent origin.
|
||||
* is not the registry's exact live instance, `DELEGATED_CALLER` when
|
||||
* that live agent has subagent origin, or `PROVIDER_ERROR`, keeping the
|
||||
* original message, when an answerer fails with a value that is not a
|
||||
* `HarnessError`; a coded `HarnessError` from an answerer keeps its `name`
|
||||
* and `code`.
|
||||
*/
|
||||
async ask(request: AskUserQuestionRequest): Promise<AskUserQuestionAnswer>
|
||||
```
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
en: a86b204323005042
|
||||
zh: 82b691e28ed4dcd3
|
||||
/workflow/failure-discipline-workflowerror-fatal:
|
||||
en: 4d390801bb07374c
|
||||
zh: 1099f053c2ee26ec
|
||||
en: 4a66b379e32c2583
|
||||
zh: 9745625863b836a8
|
||||
/workflow/events:
|
||||
en: de123821a128c1d1
|
||||
zh: e50bcaea2812575a
|
||||
|
||||
@@ -79,6 +79,11 @@ interface WorkflowResult {
|
||||
stopReason: WorkflowStopReason
|
||||
/** The failure message (present iff `stopReason` is not `completed`). */
|
||||
error?: string
|
||||
/**
|
||||
* The code of the fatal {@link WorkflowError} that ended an `error` run;
|
||||
* absent when the script's own exception or the engine runtime ended it.
|
||||
*/
|
||||
errorCode?: WorkflowErrorCode
|
||||
/**
|
||||
* How many `agent()` calls the run accepted over its whole lifetime. On a
|
||||
* graceful settlement this is the script-side count (calls still queued for
|
||||
@@ -113,7 +118,7 @@ interface WorkflowRun {
|
||||
|
||||
## Failure discipline: `WorkflowError.fatal`
|
||||
|
||||
Hook misuse inside a script — bad arguments, unknown/deferred `agent()` options, a schema outside the [structured-output subset](../../packages/core/tools/README.md), a tripped cap, a seam start failure, cancellation — throws a `WorkflowError` with `fatal: true`. The `parallel()`/`pipeline()` combinators RE-THROW fatal errors instead of mapping the item to `null`: a typo'd option must kill the script loudly, never dissolve into something that reads as an ordinary child failure. The per-item `null` is reserved for child-run failures (a non-`completed` stop reason) and ordinary in-stage script errors.
|
||||
Hook misuse inside a script — bad arguments, unknown/deferred `agent()` options, a schema outside the [structured-output subset](../../packages/core/tools/README.md), a tripped cap, a seam start failure, cancellation — throws a `WorkflowError` with `fatal: true`. The `parallel()`/`pipeline()` combinators RE-THROW fatal errors instead of mapping the item to `null`: a typo'd option must kill the script loudly, never dissolve into something that reads as an ordinary child failure. The per-item `null` is reserved for child-run failures (a non-`completed` stop reason) and ordinary in-stage script errors. When a fatal error ends a run, the engine reports its code as `WorkflowResult.errorCode`, and the `workflow` tool fails with that code, such as `AGENT_CAP`; a run that settled as `error` without one (the script's own exception or an engine runtime failure) fails with `RUN_FAILED`, and one that settled as `cancelled` with `CANCELLED`; when the calling step itself was aborted, the tool runtime's `AbortError` `ABORTED` result applies instead.
|
||||
|
||||
## Events
|
||||
|
||||
|
||||
@@ -79,6 +79,11 @@ interface WorkflowResult {
|
||||
stopReason: WorkflowStopReason
|
||||
/** The failure message (present iff `stopReason` is not `completed`). */
|
||||
error?: string
|
||||
/**
|
||||
* The code of the fatal {@link WorkflowError} that ended an `error` run;
|
||||
* absent when the script's own exception or the engine runtime ended it.
|
||||
*/
|
||||
errorCode?: WorkflowErrorCode
|
||||
/**
|
||||
* How many `agent()` calls the run accepted over its whole lifetime. On a
|
||||
* graceful settlement this is the script-side count (calls still queued for
|
||||
@@ -113,7 +118,7 @@ interface WorkflowRun {
|
||||
|
||||
## 失败纪律:`WorkflowError.fatal`
|
||||
|
||||
脚本内部的钩子误用:错误参数、未知或延迟的 `agent()` 选项、超出[结构化输出子集](../../packages/core/tools/README.zh.md)的 schema、超出上限、seam 启动失败、取消,都会抛出 `fatal: true` 的 `WorkflowError`。`parallel()`/`pipeline()` 组合器对 fatal 错误直接重新抛出,而非将该项映射为 `null`:一个拼写错误的选项必须明确报错并终止脚本,绝不能消融为看似普通子 agent 失败的结果。逐项的 `null` 保留给子运行失败(非 `completed` 的 stop reason)和阶段内的普通脚本错误。
|
||||
脚本内部的钩子误用:错误参数、未知或延迟的 `agent()` 选项、超出[结构化输出子集](../../packages/core/tools/README.zh.md)的 schema、超出上限、seam 启动失败、取消,都会抛出 `fatal: true` 的 `WorkflowError`。`parallel()`/`pipeline()` 组合器对 fatal 错误直接重新抛出,而非将该项映射为 `null`:一个拼写错误的选项必须明确报错并终止脚本,绝不能消融为看似普通子 agent 失败的结果。逐项的 `null` 保留给子运行失败(非 `completed` 的 stop reason)和阶段内的普通脚本错误。致命错误结束运行时,引擎把其 code 报告为 `WorkflowResult.errorCode`,`workflow` 工具以该 code(如 `AGENT_CAP`)失败;以 `error` 结束但没有该 code 的运行(脚本自身抛出的异常或引擎运行时失败)以 `RUN_FAILED` 失败,以 `cancelled` 结束的运行以 `CANCELLED` 失败;调用方步骤本身被中止时,改为使用工具运行时的 `AbortError` `ABORTED` 结果。
|
||||
|
||||
## 事件
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ function styleInjectionModule(
|
||||
* Everything else under @deepseek-ai/* is either a module-table entry
|
||||
* (external) or a leak the purity gate rejects.
|
||||
*/
|
||||
export const INLINE_SAFE = /^(?:@deepseek-ai\/dsh-(?:file-reference|fs-patch|session|llm|tools|brand|official-bundles|deque|output-retention|typert-protocol|util-crypto|util-time|util-values|util-workspace-path)(?:\/|$)|@deepseek-ai\/dsh-util-file-drag$|@deepseek-ai\/dsh-token-meter\/client$|@deepseek-ai\/dsh-commands\/builtin$|@deepseek-ai\/dsh-native-command\/types$|@deepseek-ai\/dsh-host-open-in-app\/shared$|@deepseek-ai\/dsh-plugin-manager\/registry$|@deepseek-ai\/dsh-agent-preset-registry\/display$|@deepseek-ai\/dsh-api-workspace-controller\/default-workspace$|@deepseek-ai\/dsh-spill-policy\/notice$)/
|
||||
export const INLINE_SAFE = /^(?:@deepseek-ai\/dsh-(?:file-reference|fs-patch|session|llm|tools|brand|error|official-bundles|deque|output-retention|typert-protocol|util-crypto|util-time|util-values|util-workspace-path)(?:\/|$)|@deepseek-ai\/dsh-util-file-drag$|@deepseek-ai\/dsh-token-meter\/client$|@deepseek-ai\/dsh-commands\/builtin$|@deepseek-ai\/dsh-native-command\/types$|@deepseek-ai\/dsh-host-open-in-app\/shared$|@deepseek-ai\/dsh-plugin-manager\/registry$|@deepseek-ai\/dsh-agent-preset-registry\/display$|@deepseek-ai\/dsh-api-workspace-controller\/default-workspace$|@deepseek-ai\/dsh-spill-policy\/notice$)/
|
||||
|
||||
/**
|
||||
* Vendored framework libraries: rescoped into @deepseek-ai, so the gate below
|
||||
|
||||
@@ -4564,7 +4564,7 @@ export const SERVICE_API: readonly ServiceApiEntry[] = [
|
||||
description: 'Ask the scoped answerer waterfall and wait for the user\'s answer.\n\nWhen a caller supplies an agent, human interaction is valid only for the exact live instance of an ordinary Session. Explicit subagent origin rejects delegated callers; historical ordinary forks may retain parent metadata and still ask normally.',
|
||||
parameters: [{ name: 'request', description: 'Questions, owner agent, and abort signal.' }],
|
||||
returns: 'The answer chosen or typed by the human.',
|
||||
throws: ['{UserQuestionError} code `ASK_ABORTED` when the supplied signal is already or becomes aborted, `CALLER_NOT_LIVE` when a supplied agent is not the registry\'s exact live instance, or `DELEGATED_CALLER` when that live agent has subagent origin.'],
|
||||
throws: ['{UserQuestionError} code `ASK_ABORTED` when the supplied signal is already or becomes aborted, `CALLER_NOT_LIVE` when a supplied agent is not the registry\'s exact live instance, `DELEGATED_CALLER` when that live agent has subagent origin, or `PROVIDER_ERROR`, keeping the original message, when an answerer fails with a value that is not a `HarnessError`; a coded `HarnessError` from an answerer keeps its `name` and `code`.'],
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -8526,7 +8526,7 @@ export const TYPE_API: readonly TypeApiEntry[] = [
|
||||
},
|
||||
{
|
||||
name: 'RemoteError',
|
||||
declaration: 'export class RemoteError<Code extends RemoteErrorCode = RemoteErrorCode> extends Error {\n readonly isDSHRemoteError: true;\n constructor(readonly code: Code, message: string, readonly details: RemoteErrorDetailsMap[Code], options?: ErrorOptions);\n}',
|
||||
declaration: 'export class RemoteError<Code extends RemoteErrorCode = RemoteErrorCode> extends HarnessError {\n readonly isDSHRemoteError: true;\n constructor(override readonly code: Code, message: string, readonly details: RemoteErrorDetailsMap[Code], options?: ErrorOptions);\n}',
|
||||
},
|
||||
{
|
||||
name: 'RemoteErrorCode',
|
||||
@@ -10736,6 +10736,10 @@ export const TYPE_API: readonly TypeApiEntry[] = [
|
||||
name: 'WorkflowAgentOutcome',
|
||||
declaration: 'export type WorkflowAgentOutcome = \'completed\' | \'failed\' | \'cancelled\';',
|
||||
},
|
||||
{
|
||||
name: 'WorkflowErrorCode',
|
||||
declaration: 'export type WorkflowErrorCode = \'SCRIPT_PARSE\' | \'META_INVALID\' | \'INVALID_ARGUMENT\' | \'UNSUPPORTED_OPTION\' | \'UNSUPPORTED_SCHEMA\' | \'AGENT_CAP\' | \'ITEM_CAP\' | \'AGENT_START\' | \'AGENT_RESULT\' | \'RESULT_UNSERIALIZABLE\' | \'CANCELLED\' | \'RUN_FAILED\';',
|
||||
},
|
||||
{
|
||||
name: 'WorkflowMeta',
|
||||
declaration: 'export interface WorkflowMeta {\n name: string;\n description: string;\n whenToUse?: string;\n phases?: WorkflowPhase[];\n}',
|
||||
@@ -10746,11 +10750,11 @@ export const TYPE_API: readonly TypeApiEntry[] = [
|
||||
},
|
||||
{
|
||||
name: 'WorkflowResult',
|
||||
declaration: 'export interface WorkflowResult {\n value: unknown;\n stopReason: WorkflowStopReason;\n error?: string;\n agentsStarted: number;\n}',
|
||||
declaration: 'export interface WorkflowResult {\n value: unknown;\n stopReason: WorkflowStopReason;\n error?: string;\n errorCode?: WorkflowErrorCode;\n agentsStarted: number;\n}',
|
||||
},
|
||||
{
|
||||
name: 'WorkflowResultInfo',
|
||||
declaration: 'export interface WorkflowResultInfo {\n stopReason: WorkflowStopReason;\n error?: string;\n agentsStarted: number;\n}',
|
||||
declaration: 'export interface WorkflowResultInfo {\n stopReason: WorkflowStopReason;\n error?: string;\n errorCode?: WorkflowErrorCode;\n agentsStarted: number;\n}',
|
||||
},
|
||||
{
|
||||
name: 'WorkflowRun',
|
||||
|
||||
@@ -33,8 +33,8 @@
|
||||
en: 7fba8a13f8452dc1
|
||||
zh: bbaba056cda78ec9
|
||||
/deepseek-ai-dsh-command-goal/understand-the-implementation/design:
|
||||
en: ab637815b21bf065
|
||||
zh: 56eb4ae2ad368994
|
||||
en: 47880a3aa7c982a2
|
||||
zh: eed5b31970e01a51
|
||||
/deepseek-ai-dsh-command-goal/understand-the-implementation/source-map:
|
||||
en: a34756578cce7cc4
|
||||
zh: 61079561a2bf742d
|
||||
|
||||
@@ -76,7 +76,7 @@ This section explains how the command parses input and renders output; the obser
|
||||
### Design
|
||||
|
||||
- **Grammar, not free text.** The parser recognizes only the exact control words (`clear`, `pause`, `resume`, `edit`) when they fill the whole input; every other non-empty suffix is an objective. `edit` alone is invalid, and `edit` refuses to replace an unfinished goal directly.
|
||||
- **Domain rejections become stable errors.** `GoalError` outcomes are converted into direct command errors with a fixed message; unexpected failures rethrow so adapters report a command failure rather than a domain result. Rendered output never exposes branded ids or revisions.
|
||||
- **Domain rejections become stable errors.** `GoalError` outcomes other than `GOAL_STATE_CORRUPT` are converted into direct command errors with a fixed message; corrupt goal state and unexpected failures rethrow so adapters report a command failure rather than a domain result. Rendered output never exposes branded ids or revisions.
|
||||
- **Attachments accompany the objective.** On a successful create or edit, the command submits one user followup carrying the admitted image and file blocks in selection order plus the fixed text `Reference attachments for the goal objective.` Every other path submits nothing, so the dispatching composer keeps the draft and cards.
|
||||
|
||||
### Source map
|
||||
|
||||
@@ -76,7 +76,7 @@ kind: "package-reference"
|
||||
### 设计
|
||||
|
||||
- **语法,而非自由文本。** 解析器只在控制词(`clear`、`pause`、`resume`、`edit`)填满整个输入时识别它们;其他任何非空后缀都是目标。单独的 `edit` 无效,且 `edit` 拒绝直接替换未完成的 goal。
|
||||
- **领域拒绝变成稳定错误。** `GoalError` 结果会转换为带固定消息的直接命令错误;意外失败会重新抛出,使适配器报告命令失败而非领域结果。渲染输出绝不暴露带品牌类型的 id 或 revision。
|
||||
- **领域拒绝变成稳定错误。** 除 `GOAL_STATE_CORRUPT` 外的 `GoalError` 结果会转换为带固定消息的直接命令错误;goal 状态损坏与意外失败会重新抛出,使适配器报告命令失败而非领域结果。渲染输出绝不暴露带品牌类型的 id 或 revision。
|
||||
- **附件随目标提交。** create 或 edit 成功时,命令提交一条用户 followup 消息,按选择顺序携带已准入的图片块与文件块,再附加固定文本 `Reference attachments for the goal objective.`。其他路径不提交消息,因此分发方 composer 保留草稿和附件卡。
|
||||
|
||||
### 源码地图
|
||||
|
||||
@@ -177,7 +177,8 @@ function executeGoalCommand(ctx: Context, invocation: CommandInvocation): Comman
|
||||
default: return assertNever(command, 'goal command')
|
||||
}
|
||||
} catch (error: unknown) {
|
||||
if (error instanceof GoalError) {
|
||||
// Corrupt goal state is not a command-shape problem; the command runtime reports its cause.
|
||||
if (error instanceof GoalError && error.code !== 'GOAL_STATE_CORRUPT') {
|
||||
return {
|
||||
kind: 'error',
|
||||
text: 'The goal command is not valid for the current state. Run /goal to view available commands.',
|
||||
|
||||
@@ -5,7 +5,7 @@ import AgentRegistry from '@deepseek-ai/dsh-agent'
|
||||
import type { Agent, AgentStatus } from '@deepseek-ai/dsh-agent'
|
||||
import CommandRuntime from '@deepseek-ai/dsh-commands'
|
||||
import GoalService from '@deepseek-ai/dsh-goal'
|
||||
import type { GoalRef } from '@deepseek-ai/dsh-goal'
|
||||
import { GoalError, type GoalRef } from '@deepseek-ai/dsh-goal'
|
||||
import SessionStore, { Session, type SessionId, type SessionEvent } from '@deepseek-ai/dsh-session'
|
||||
import SessionProjectionRegistry from '@deepseek-ai/dsh-session-projection'
|
||||
import * as commandGoal from '@deepseek-ai/dsh-command-goal'
|
||||
@@ -238,6 +238,13 @@ describe('/goal human command', () => {
|
||||
vi.spyOn(test.ctx.goals, 'get').mockImplementationOnce(() => { throw new Error('unexpected failure') })
|
||||
await expect(run(test)).rejects.toThrow('unexpected failure')
|
||||
})
|
||||
|
||||
it('reports corrupt goal state instead of the generic invalid-command result', async () => {
|
||||
const test = await harness()
|
||||
const corrupt = new GoalError('goal replay failed at session event 3: invalid goal stream', 'GOAL_STATE_CORRUPT')
|
||||
vi.spyOn(test.ctx.goals, 'get').mockImplementationOnce(() => { throw corrupt })
|
||||
await expect(run(test)).rejects.toBe(corrupt)
|
||||
})
|
||||
})
|
||||
|
||||
describe('/goal attachments', () => {
|
||||
|
||||
@@ -39,8 +39,8 @@
|
||||
en: 592af7e68423bd1c
|
||||
zh: 9b1f08393db1b14e
|
||||
/deepseek-ai-dsh-goal/understand-the-implementation/design:
|
||||
en: 6f19e891ffc79754
|
||||
zh: 9599e3b142f1e6b5
|
||||
en: c14410306499e607
|
||||
zh: 99d1d91259127aba
|
||||
/deepseek-ai-dsh-goal/understand-the-implementation/source-map:
|
||||
en: aef62dff93f32796
|
||||
zh: dba79da0466218a7
|
||||
|
||||
@@ -98,7 +98,7 @@ This section explains how the service realizes the behavior above; the observabl
|
||||
- **Compare-and-set mutations.** `ctx.goals` accepts only the exact live `Agent` registered under its id. `get()` returns a detached `GoalView`; mutations take a `GoalRef { id, revision }` and reject stale refs. Creation resolves the deployment default internally before committing.
|
||||
- **Activation is process-local.** `armed` and `disarmed` live in a per-session cache and are never persisted. A fresh cache and every `agent/created` edge disarm continuation even when replay finds an active durable phase; `disarm()` removes authority without writing a revision or emitting a mutation.
|
||||
- **Strict replay.** The fold derives lifecycle mutations only from `goal/change` and rejects malformed shapes, discontinuous revisions, illegal phase transitions, non-monotonic per-goal timestamps, and non-sequential admitted rounds. Positive rounds advance only on admitted goal-sourced `user/message` events, and mutation timestamps clamp against the preceding update when wall time moves backward.
|
||||
- **Projection unit.** The package requires the projection registry and registers a strict `goal` unit. Its host state retains replay validation data and the first failure, while its client view exposes the latest valid whole goal or `null`; `GoalService` rejects access after a retained replay failure.
|
||||
- **Projection unit.** The package requires the projection registry and registers a strict `goal` unit. Its host state retains replay validation data and the first failure, while its client view exposes the latest valid whole goal or `null`; `GoalService` rejects access after a retained replay failure with `GoalError` `GOAL_STATE_CORRUPT`.
|
||||
|
||||
### Source map
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ view.activation // 'armed' | 'disarmed' — not persisted
|
||||
- **比较并设置的变更。** `ctx.goals` 只接受以对应 id 注册的完全相同的活跃 `Agent` 实例。`get()` 返回脱离状态的 `GoalView`;变更携带 `GoalRef { id, revision }` 并拒绝陈旧引用。创建在提交前于内部解析部署默认值。
|
||||
- **续行启用状态是进程本地的。** `armed` 与 `disarmed` 保存在每会话缓存中,绝不持久化。新缓存与每次 `agent/created` 边界都会停用续行,即使回放发现持久 phase 为 active;`disarm()` 移除续行权限,不写入 revision 也不发出变更事件。
|
||||
- **严格回放。** 折叠只从 `goal/change` 派生生命周期变更,并拒绝形状错误、不连续 revision、非法 phase 转换、每目标时间戳非单调,以及不连续的已准入 Round。只有已准入的来源为 goal 的 `user/message` 事件会推进正数 Round;挂钟时间倒退时,变更时间戳会限制在不早于上一次更新的值。
|
||||
- **投影单元。** 本包要求提供投影注册表,并注册一个严格的 `goal` 单元。其宿主状态保留回放校验数据与第一次失败,客户端视图提供最新有效的完整 goal 或 `null`;保留回放失败后,`GoalService` 会拒绝访问。
|
||||
- **投影单元。** 本包要求提供投影注册表,并注册一个严格的 `goal` 单元。其宿主状态保留回放校验数据与第一次失败,客户端视图提供最新有效的完整 goal 或 `null`;保留回放失败后,`GoalService` 会以 `GoalError` `GOAL_STATE_CORRUPT` 拒绝访问。
|
||||
|
||||
### 源码地图
|
||||
|
||||
|
||||
@@ -100,6 +100,7 @@ export type GoalErrorCode =
|
||||
| 'GOAL_INVALID_BLOCK_REASON'
|
||||
| 'GOAL_INVALID_EDIT'
|
||||
| 'GOAL_INVALID_TRANSITION'
|
||||
| 'GOAL_STATE_CORRUPT'
|
||||
|
||||
declare module '@deepseek-ai/cordis' {
|
||||
interface Events {
|
||||
|
||||
@@ -478,7 +478,7 @@ export class GoalService extends TypertRemoteService {
|
||||
/** Read the current durable projection maintained by the registry. */
|
||||
private state(session: Session): GoalProjection | null {
|
||||
const state = this.goalProjectionHandle.stateOf(session)
|
||||
if (state.failure !== null) throw new Error(state.failure)
|
||||
if (state.failure !== null) throw new GoalError(state.failure, 'GOAL_STATE_CORRUPT')
|
||||
return state.current
|
||||
}
|
||||
|
||||
|
||||
@@ -22,9 +22,8 @@ export class GoalError extends HarnessError {
|
||||
* @param message - human-readable rejection reason.
|
||||
* @param code - stable machine-routable classification.
|
||||
*/
|
||||
// Keep the constructor to narrow HarnessError's string code at this boundary.
|
||||
// oxlint-disable-next-line typescript/no-useless-constructor -- type-only narrowing
|
||||
constructor(message: string, code: GoalErrorCode) {
|
||||
super(message, code)
|
||||
this.name = 'GoalError'
|
||||
}
|
||||
}
|
||||
@@ -245,7 +245,8 @@ describe('goal projection unit', () => {
|
||||
|
||||
await expect(agentEvents(bench.ctx, bench.agent).serial('agent/created', { source: 'resume' }))
|
||||
.resolves.toBeUndefined()
|
||||
expect(() => bench.ctx.goals.get(bench.agent)).toThrow(failure)
|
||||
expect(() => bench.ctx.goals.get(bench.agent))
|
||||
.toThrow(expect.objectContaining({ name: 'GoalError', code: 'GOAL_STATE_CORRUPT', message: failure }))
|
||||
expect(bench.tailValues().goal).toMatchObject({ goal: { objective: 'poisoned replay' } })
|
||||
})
|
||||
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
en: 3e4bc86d1d86eaab
|
||||
zh: 3c4c41666135f55d
|
||||
/deepseek-ai-dsh-tool-ask-user/use-this-package/when-the-call-fails:
|
||||
en: c4ac3c584f900230
|
||||
zh: bd8d227f0637b8f1
|
||||
en: 26053a73c0b2fa94
|
||||
zh: ee796e92c9dad9d0
|
||||
/deepseek-ai-dsh-tool-ask-user/understand-the-implementation:
|
||||
en: e9b9d46be0b45ca2
|
||||
zh: c02403486473cd80
|
||||
|
||||
@@ -71,7 +71,7 @@ For a finite timed call, `{ "pending": true, "callId": "…" }` means the foregr
|
||||
|
||||
### When the call fails
|
||||
|
||||
Legacy and `timeout: -1` calls wait for an answer or cancellation; without an accepting answerer, they return an error. A finite timed call without an answerer returns pending at its deadline. Cancellation and a caller that is not the exact live runtime root also return errors. A live child agent is rejected with `DELEGATED_CALLER` and must include the unresolved decision in its final result.
|
||||
Legacy and `timeout: -1` calls wait for an answer or cancellation; without an accepting answerer, they return an error. A finite timed call without an answerer returns pending at its deadline. Cancellation and a caller that is not the exact live runtime root also return errors. A timed call rejects an out-of-range `timeout` and a repeated question id with `ToolArgsError` `INVALID_ARGS`, and a missing calling agent with `ToolContextUnavailableError`. A live child agent is rejected with `DELEGATED_CALLER` and must include the unresolved decision in its final result.
|
||||
|
||||
-----
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ kind: "package-reference"
|
||||
|
||||
### 调用何时失败
|
||||
|
||||
Legacy 调用和 `timeout: -1` 调用会等待回答或取消;没有 answerer 接受时返回错误。有限时长的 timed 调用若没有 answerer,则在到期后返回 pending。取消调用,或调用方不是确切的存活运行时根时,也会返回错误。存活的子 agent 会以 `DELEGATED_CALLER` 被拒绝,必须在最终结果中包含尚未解决的决定。
|
||||
Legacy 调用和 `timeout: -1` 调用会等待回答或取消;没有 answerer 接受时返回错误。有限时长的 timed 调用若没有 answerer,则在到期后返回 pending。取消调用,或调用方不是确切的存活运行时根时,也会返回错误。timed 调用以 `ToolArgsError` `INVALID_ARGS` 拒绝超出范围的 `timeout` 与重复的问题 id,以 `ToolContextUnavailableError` 拒绝缺少调用方 agent 的调用。存活的子 agent 会以 `DELEGATED_CALLER` 被拒绝,必须在最终结果中包含尚未解决的决定。
|
||||
|
||||
-----
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*/
|
||||
|
||||
import type { Context } from '@deepseek-ai/cordis'
|
||||
import { defineTool, type ToolExecution } from '@deepseek-ai/dsh-tools'
|
||||
import { defineTool, ToolArgsError, ToolContextUnavailableError, type ToolExecution } from '@deepseek-ai/dsh-tools'
|
||||
import { TIMED_WAIT_PARAMETER } from '@deepseek-ai/dsh-user-questions'
|
||||
import type {
|
||||
AskUserQuestionAnswer, AskUserQuestionRequestEvent,
|
||||
@@ -11,7 +11,7 @@ import type {
|
||||
|
||||
function validateTimeout(timeout: number): number {
|
||||
if (timeout !== -1 && (!Number.isInteger(timeout) || timeout < 1 || timeout > 2_147_483)) {
|
||||
throw new Error('timeout must be -1 or a positive integer up to 2147483 seconds')
|
||||
throw new ToolArgsError(['timeout must be -1 or a positive integer up to 2147483 seconds'])
|
||||
}
|
||||
return timeout
|
||||
}
|
||||
@@ -19,7 +19,7 @@ function validateTimeout(timeout: number): number {
|
||||
function validateQuestionIds(questions: readonly { readonly id: string }[]): void {
|
||||
const ids = new Set<string>()
|
||||
for (const question of questions) {
|
||||
if (ids.has(question.id)) throw new Error(`question id ${JSON.stringify(question.id)} must be unique within this call`)
|
||||
if (ids.has(question.id)) throw new ToolArgsError([`question id ${JSON.stringify(question.id)} must be unique within this call`])
|
||||
ids.add(question.id)
|
||||
}
|
||||
}
|
||||
@@ -197,7 +197,7 @@ export function registerTimedAskUser(ctx: Context, timeout = 120): void {
|
||||
validateQuestionIds(args.questions)
|
||||
const request = questionRequest(args.questions, exec)
|
||||
if (timeout !== -1) {
|
||||
if (exec.agent === undefined) throw new Error('timed questions require a live agent')
|
||||
if (exec.agent === undefined) throw new ToolContextUnavailableError('timed questions require a live agent')
|
||||
const result = await ctx.userQuestions.askTimed({ ...request, agent: exec.agent }, exec.callId, timeout * 1000)
|
||||
return 'pending' in result ? { ...result, message: pendingNotice } : answerResult(result)
|
||||
}
|
||||
|
||||
@@ -555,6 +555,7 @@ describe('ask_user_question tool', () => {
|
||||
expect(result).toMatchObject({
|
||||
isError: true,
|
||||
content: [{ type: 'text', text: 'Error: timed questions require a live agent' }],
|
||||
error: { info: { name: 'ToolContextUnavailableError', code: 'TOOL_CONTEXT_UNAVAILABLE' } },
|
||||
})
|
||||
})
|
||||
|
||||
@@ -571,6 +572,7 @@ describe('ask_user_question tool', () => {
|
||||
expect(result.isError).toBe(true)
|
||||
expect(result.content[0]).toMatchObject({ type: 'text' })
|
||||
expect(result.content[0]?.type === 'text' ? result.content[0].text : '').toMatch(/timeout.*integer/i)
|
||||
expect(result.error?.info).toEqual({ name: 'ToolArgsError', code: 'INVALID_ARGS' })
|
||||
})
|
||||
|
||||
it('rejects duplicate question ids before dispatching a timed call', async () => {
|
||||
@@ -590,7 +592,8 @@ describe('ask_user_question tool', () => {
|
||||
|
||||
expect(result).toMatchObject({
|
||||
isError: true,
|
||||
content: [{ type: 'text', text: 'Error: question id "scope" must be unique within this call' }],
|
||||
content: [{ type: 'text', text: 'Error: invalid arguments: question id "scope" must be unique within this call' }],
|
||||
error: { info: { name: 'ToolArgsError', code: 'INVALID_ARGS' } },
|
||||
})
|
||||
expect(answerer).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
@@ -60,6 +60,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@deepseek-ai/dsh-agent": "workspace:*",
|
||||
"@deepseek-ai/dsh-error": "workspace:*",
|
||||
"@deepseek-ai/dsh-llm": "workspace:*",
|
||||
"@deepseek-ai/dsh-scope": "workspace:*",
|
||||
"@deepseek-ai/cordis": "workspace:~",
|
||||
|
||||
@@ -285,8 +285,11 @@ export class UserQuestionService extends TypertRemoteService {
|
||||
* @returns The answer chosen or typed by the human.
|
||||
* @throws {UserQuestionError} code `ASK_ABORTED` when the supplied signal
|
||||
* is already or becomes aborted, `CALLER_NOT_LIVE` when a supplied agent
|
||||
* is not the registry's exact live instance, or `DELEGATED_CALLER` when
|
||||
* that live agent has subagent origin.
|
||||
* is not the registry's exact live instance, `DELEGATED_CALLER` when
|
||||
* that live agent has subagent origin, or `PROVIDER_ERROR`, keeping the
|
||||
* original message, when an answerer fails with a value that is not a
|
||||
* `HarnessError`; a coded `HarnessError` from an answerer keeps its `name`
|
||||
* and `code`.
|
||||
*/
|
||||
async ask(request: AskUserQuestionRequest): Promise<AskUserQuestionAnswer> {
|
||||
if (request.signal?.aborted) {
|
||||
@@ -356,7 +359,9 @@ export class UserQuestionService extends TypertRemoteService {
|
||||
if (request.signal?.aborted) {
|
||||
throw abortedQuestion(error)
|
||||
}
|
||||
throw restored
|
||||
if (restored instanceof HarnessError) throw restored
|
||||
const message = error instanceof Error ? error.message : 'the user-questions answerer failed before the user answered'
|
||||
throw new UserQuestionError(message, 'PROVIDER_ERROR', { cause: error })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import UserQuestionService, {
|
||||
type AskUserQuestionRequest,
|
||||
} from '@deepseek-ai/dsh-user-questions'
|
||||
import { brandString } from '@deepseek-ai/dsh-brand'
|
||||
import { HarnessError } from '@deepseek-ai/dsh-error'
|
||||
import { createToolResultMessage, createUserMessage, type ToolCallId, type ToolSchema, type UserMessage } from '@deepseek-ai/dsh-llm'
|
||||
import { Session, type SessionId, SESSION_FORMAT_VERSION, TOOL_OUTCOME_UNKNOWN } from '@deepseek-ai/dsh-session'
|
||||
import SessionProjectionRegistry from '@deepseek-ai/dsh-session-projection'
|
||||
@@ -174,19 +175,21 @@ describe('UserQuestionService', () => {
|
||||
})
|
||||
|
||||
it.each([
|
||||
['an ordinary Error', new Error('provider failed')],
|
||||
['an ordinary Error', new Error('provider failed'), 'provider failed'],
|
||||
['a namesake Error without a string code', Object.assign(new Error('provider failed'), {
|
||||
name: 'UserQuestionError',
|
||||
})],
|
||||
['a non-Error rejection', { name: 'UserQuestionError', code: 'ASK_CANCELLED' }],
|
||||
])('preserves %s from the provider', async (_label, rejection) => {
|
||||
}), 'provider failed'],
|
||||
['a non-Error rejection', { name: 'UserQuestionError', code: 'ASK_CANCELLED' }, 'the user-questions answerer failed before the user answered'],
|
||||
])('classifies %s from the provider as PROVIDER_ERROR', async (_label, rejection, message) => {
|
||||
const ctx = new Context()
|
||||
await ctx.plugin(UserQuestionService)
|
||||
registerAnswerer(ctx, { ask: vi.fn().mockRejectedValue(rejection) })
|
||||
|
||||
await expect(ctx.userQuestions.ask({
|
||||
const failure = await ctx.userQuestions.ask({
|
||||
questions: [{ id: 'confirm', question: 'Proceed?' }],
|
||||
})).rejects.toBe(rejection)
|
||||
}).then(() => undefined, (error: unknown) => error)
|
||||
expect(failure).toBeInstanceOf(UserQuestionError)
|
||||
expect(failure).toMatchObject({ name: 'UserQuestionError', code: 'PROVIDER_ERROR', message, cause: rejection })
|
||||
})
|
||||
|
||||
it('rejects empty question batches before reaching the provider', async () => {
|
||||
@@ -290,10 +293,10 @@ describe('UserQuestionService', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('preserves a provider rejection outside the UserQuestionError taxonomy', async () => {
|
||||
it('preserves a coded provider rejection outside the UserQuestionError taxonomy', async () => {
|
||||
const ctx = new Context()
|
||||
await ctx.plugin(UserQuestionService)
|
||||
const failure = new Error('provider failed')
|
||||
const failure = new HarnessError('provider failed', 'PROVIDER_OFFLINE')
|
||||
registerAnswerer(ctx, { ask: () => Promise.reject(failure) })
|
||||
|
||||
await expect(ctx.userQuestions.ask({
|
||||
@@ -569,14 +572,15 @@ describe('askTimed', () => {
|
||||
}
|
||||
})
|
||||
|
||||
it('rethrows a provider failure that is not a question error', async () => {
|
||||
it('classifies a provider failure that is not a question error as PROVIDER_ERROR', async () => {
|
||||
const ctx = await timedContext()
|
||||
const agent = liveAgent('timed-provider-crash')
|
||||
ctx.agents.enter(agent)
|
||||
registerAnswerer(ctx, { ask: () => Promise.reject(new TypeError('provider crashed')) })
|
||||
const crash = new TypeError('provider crashed')
|
||||
registerAnswerer(ctx, { ask: () => Promise.reject(crash) })
|
||||
|
||||
await expect(ctx.userQuestions.askTimed({ agent, questions: timedQuestions }, timedCallId, 120_000))
|
||||
.rejects.toThrow(TypeError)
|
||||
.rejects.toMatchObject({ name: 'UserQuestionError', code: 'PROVIDER_ERROR', message: 'provider crashed', cause: crash })
|
||||
await ctx.fiber.dispose()
|
||||
})
|
||||
|
||||
|
||||
@@ -45,14 +45,14 @@
|
||||
en: a7bf35c2a9da52bc
|
||||
zh: dea9f4b3a41f1a6d
|
||||
/deepseek-ai-dsh-plan-mode/understand-the-implementation/the-exit-tool:
|
||||
en: 7736aea9e4934fa8
|
||||
zh: a595e477f54a199e
|
||||
en: d14383e9c8c404dc
|
||||
zh: 056ec01db0f9d63e
|
||||
/deepseek-ai-dsh-plan-mode/understand-the-implementation/session-projection-unit:
|
||||
en: 396d66816890f715
|
||||
zh: fab5d67c027b33f5
|
||||
en: 6765795517de7646
|
||||
zh: 82733b824550e594
|
||||
/deepseek-ai-dsh-plan-mode/understand-the-implementation/source-map:
|
||||
en: fa97e858495a8105
|
||||
zh: 8be1fbd7e420ff8a
|
||||
en: 7652cb216185fd60
|
||||
zh: 38717e3a06d0effa
|
||||
/deepseek-ai-dsh-plan-mode/further-exploration:
|
||||
en: 5008d6d632002f49
|
||||
zh: 65184d489ecdcec0
|
||||
@@ -90,8 +90,8 @@
|
||||
en: 9622e96bdc01276d
|
||||
zh: 53801e68a49f3d1d
|
||||
/deepseek-ai-dsh-plan-mode/model-experience/exit-tool-schema-and-review-exchange/what-the-model-sees:
|
||||
en: 1b978a7b6eecdffe
|
||||
zh: 338000d1bf8dd4a9
|
||||
en: 7f132783f06161cf
|
||||
zh: 571852401060940f
|
||||
/deepseek-ai-dsh-plan-mode/model-experience/exit-tool-schema-and-review-exchange/token-effect:
|
||||
en: 5ef9db72f91e4a8c
|
||||
zh: 6e96335cc3eb5976
|
||||
|
||||
@@ -90,11 +90,11 @@ The command child activates only when a commands service is composed. It maps ba
|
||||
|
||||
### The exit tool
|
||||
|
||||
`exit_plan_mode` is disclosed progressively: it is admitted from the first step whose selected plan state is active and stays admitted for the rest of the Session, so entering plan mode the first time adds it together with the guidance, and later transitions change only the guidance; Native and PTC execution use the same admitted set. A call while plan mode is not committed fails. An approved review records a silent pending exit that the next accepted in-turn pre-step appends, keeping plan guidance for the rest of the current tool batch. Without a user-questions channel, or after a service reload while the review is pending, the call fails closed and `/plan off` remains the manual escape.
|
||||
`exit_plan_mode` is disclosed progressively: it is admitted from the first step whose selected plan state is active and stays admitted for the rest of the Session, so entering plan mode the first time adds it together with the guidance, and later transitions change only the guidance; Native and PTC execution use the same admitted set. A call while plan mode is not committed fails with `PlanModeError` `PLAN_NOT_ACTIVE`, and a plan without a leading `#` heading fails with `ToolArgsError` before review. An approved review records a silent pending exit that the next accepted in-turn pre-step appends, keeping plan guidance for the rest of the current tool batch. Without a user-questions channel (`ToolContextUnavailableError`), or after a service reload while the review is pending (`PLAN_REVIEW_INTERRUPTED`), the call fails closed and `/plan off` remains the manual escape. [`src/error.ts`](src/error.ts) lists the `PlanModeError` codes.
|
||||
|
||||
### Session projection unit
|
||||
|
||||
The package requires `ctx.sessionProjections` and awaits registration of the `plan` unit during activation. Its prompt section is registered before that wait. Agent prompt assembly fails explicitly while the reader is unavailable, so a restored plan cannot run without its guidance. Callers must await plugin activation before running an agent.
|
||||
The package requires `ctx.sessionProjections` and awaits registration of the `plan` unit during activation. Its prompt section is registered before that wait. Agent prompt assembly, the `/plan` command, and `exit_plan_mode` fail with `PlanModeError` `PLAN_STATE_UNAVAILABLE` while the reader is unavailable, so a restored plan cannot run without its guidance. Callers must await plugin activation before running an agent.
|
||||
|
||||
The unit turns logged `/plan` command runs into a candidate target, commits the logged state on `plan/mode`, and derives `{ active, pending }` for `view`, where `pending` is true only while an unsettled or successful selection differs from the logged state — a pure replay quantity recoverable from the log alone. The key merges into `SessionProjectionMap` from [`src/types.ts`](src/types.ts); the framework drives the unit, and unloading the plugin fiber unregisters the key. State reads use the retained handle and remain available after unregistration.
|
||||
|
||||
@@ -104,6 +104,7 @@ The unit turns logged `/plan` command runs into a candidate target, commits the
|
||||
|---|---|
|
||||
| [`src/index.ts`](src/index.ts) | Plugin entry: `Config` schema, the `ctx.planMode` service, `plan:policy` section, `/plan` command, `exit_plan_mode` tool |
|
||||
| [`src/types.ts`](src/types.ts) | The `plan` projection-key declaration and `PlanProjection` wire value |
|
||||
| [`src/error.ts`](src/error.ts) | `PlanModeError` and its closed code union |
|
||||
| [`src/client.ts`](src/client.ts) | Client-namespace re-export of the types outlet |
|
||||
|
||||
The review intent carries the originating tool-call id, so the Web client can reopen the same submitted plan after the review closes. The complete Markdown remains in the existing native call or PTC dispatch log.
|
||||
@@ -166,7 +167,7 @@ The user block is append-only conversation growth. Entering or leaving plan mode
|
||||
|
||||
#### What the model sees
|
||||
|
||||
The [`exit_plan_mode` schema](../../../docs/tool-catalog.md#deepseek-aidsh-plan-mode) is offered from the first plan-mode entry in a Session; earlier calls return `UNKNOWN_TOOL`, calls after leaving plan mode fail as unavailable outside plan mode, and an approved in-mode review returns the canonical `{ approved: true }` value and renders the existing confirmation text. Rejection remains a failed call carrying review feedback. A dismissed review returns `{ approved: false }`, renders a note that the user will reply, and concludes the turn without another model request.
|
||||
The [`exit_plan_mode` schema](../../../docs/tool-catalog.md#deepseek-aidsh-plan-mode) is offered from the first plan-mode entry in a Session; earlier calls return `UNKNOWN_TOOL`, calls after leaving plan mode fail as unavailable outside plan mode, and an approved in-mode review returns the canonical `{ approved: true }` value and renders the existing confirmation text. Rejection remains a failed call with `PLAN_REVISION_REQUESTED` carrying review feedback. A dismissed review returns `{ approved: false }`, renders a note that the user will reply, and concludes the turn without another model request.
|
||||
|
||||
#### Token effect
|
||||
|
||||
|
||||
@@ -90,11 +90,11 @@ agent 完成计划后,会以 markdown 形式、从标题开头书写计划并
|
||||
|
||||
### 退出工具
|
||||
|
||||
`exit_plan_mode` 采用渐进式披露:从已选计划状态首次为激活的步骤起准入,并在会话剩余部分保持准入,因此首次进入计划模式时它与指引一起出现,之后的切换只改变指引;原生与 PTC 执行使用同一准入集合。计划模式未提交时调用会失败。经批准的评审会记录一个静默的待生效退出,由下一个被接受的轮内 pre-step 追加,当前这批工具调用剩余部分仍保留计划引导。缺少用户交互通道,或评审等待期间服务重载,调用都会以拒绝方式失败,`/plan off` 仍是手动退路。
|
||||
`exit_plan_mode` 采用渐进式披露:从已选计划状态首次为激活的步骤起准入,并在会话剩余部分保持准入,因此首次进入计划模式时它与指引一起出现,之后的切换只改变指引;原生与 PTC 执行使用同一准入集合。计划模式未提交时调用以 `PlanModeError` `PLAN_NOT_ACTIVE` 失败,没有前导 `#` 标题的计划在评审前以 `ToolArgsError` 失败。经批准的评审会记录一个静默的待生效退出,由下一个被接受的轮内 pre-step 追加,当前这批工具调用剩余部分仍保留计划引导。缺少用户交互通道(`ToolContextUnavailableError`),或评审等待期间服务重载(`PLAN_REVIEW_INTERRUPTED`),调用都会以拒绝方式失败,`/plan off` 仍是手动退路。[`src/error.ts`](src/error.ts) 列出 `PlanModeError` 的 code。
|
||||
|
||||
### 会话投影单元
|
||||
|
||||
本包要求 `ctx.sessionProjections`,并在激活期间等待 `plan` 单元注册完成。提示词段落在等待前注册。读取句柄不可用时,Agent 提示词装配会明确失败,避免恢复的计划模式缺少指引仍继续运行。调用方必须等待插件激活完成后再运行 Agent。
|
||||
本包要求 `ctx.sessionProjections`,并在激活期间等待 `plan` 单元注册完成。提示词段落在等待前注册。读取句柄不可用时,Agent 提示词装配、`/plan` 命令与 `exit_plan_mode` 会以 `PlanModeError` `PLAN_STATE_UNAVAILABLE` 明确失败,避免恢复的计划模式缺少指引仍继续运行。调用方必须等待插件激活完成后再运行 Agent。
|
||||
|
||||
该单元把已记录的 `/plan` 命令运行转为候选目标,在 `plan/mode` 上提交已记录状态,并为 `view` 推导 `{ active, pending }`,其中 `pending` 仅在未结算或已成功的选择与已记录状态不同时为 true——这是仅凭日志即可恢复的纯回放量。key 由 [`src/types.ts`](src/types.ts) 的声明合并加入 `SessionProjectionMap`;框架负责驱动该单元,卸载插件 fiber 会注销该 key。状态读取使用保留的句柄,注销后仍然可用。
|
||||
|
||||
@@ -104,6 +104,7 @@ agent 完成计划后,会以 markdown 形式、从标题开头书写计划并
|
||||
|---|---|
|
||||
| [`src/index.ts`](src/index.ts) | 插件入口:`Config` schema、`ctx.planMode` 服务、`plan:policy` 段落、`/plan` 命令、`exit_plan_mode` 工具 |
|
||||
| [`src/types.ts`](src/types.ts) | `plan` 投影 key 声明与 `PlanProjection` 协议值 |
|
||||
| [`src/error.ts`](src/error.ts) | `PlanModeError` 及其封闭 code 联合类型 |
|
||||
| [`src/client.ts`](src/client.ts) | types 出口的客户端命名空间再导出 |
|
||||
|
||||
审批意图携带发起工具调用的标识,让 Web 客户端在审批关闭后重新打开同一份计划。完整 Markdown 保留在已有的原生调用或 PTC dispatch 日志中。
|
||||
@@ -166,7 +167,7 @@ You are in plan mode. Explore and design before presenting the complete plan thr
|
||||
|
||||
#### 模型看到什么
|
||||
|
||||
[`exit_plan_mode` schema](../../../docs/tool-catalog.zh.md#deepseek-aidsh-plan-mode) 从会话首次进入计划模式起提供;此前的调用返回 `UNKNOWN_TOOL`,离开计划模式后的调用会以计划模式之外不可用而失败。模式内获批的评审返回规范值 `{ approved: true }` 并渲染现有确认文本。拒绝仍是携带评审反馈的失败调用。放弃评审返回 `{ approved: false }`,渲染一条说明用户将自行回复的文本,并结束当前轮次,不再发起模型请求。
|
||||
[`exit_plan_mode` schema](../../../docs/tool-catalog.zh.md#deepseek-aidsh-plan-mode) 从会话首次进入计划模式起提供;此前的调用返回 `UNKNOWN_TOOL`,离开计划模式后的调用会以计划模式之外不可用而失败。模式内获批的评审返回规范值 `{ approved: true }` 并渲染现有确认文本。拒绝仍是以 `PLAN_REVISION_REQUESTED` 失败并携带评审反馈的调用。放弃评审返回 `{ approved: false }`,渲染一条说明用户将自行回复的文本,并结束当前轮次,不再发起模型请求。
|
||||
|
||||
#### Token 影响
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
"peerDependencies": {
|
||||
"@deepseek-ai/dsh-agent": "workspace:*",
|
||||
"@deepseek-ai/dsh-commands": "workspace:*",
|
||||
"@deepseek-ai/dsh-error": "workspace:*",
|
||||
"@deepseek-ai/dsh-llm": "workspace:*",
|
||||
"@deepseek-ai/dsh-session": "workspace:*",
|
||||
"@deepseek-ai/dsh-session-projection": "workspace:*",
|
||||
@@ -65,6 +66,7 @@
|
||||
"@deepseek-ai/dsh-agent-loop": "workspace:*",
|
||||
"@deepseek-ai/dsh-ptc-runtime": "workspace:*",
|
||||
"@deepseek-ai/dsh-commands": "workspace:*",
|
||||
"@deepseek-ai/dsh-error": "workspace:*",
|
||||
"@deepseek-ai/dsh-llm": "workspace:*",
|
||||
"@deepseek-ai/dsh-session": "workspace:*",
|
||||
"@deepseek-ai/dsh-session-projection": "workspace:*",
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
/** Typed plan-mode failures. @module */
|
||||
|
||||
import { HarnessError } from '@deepseek-ai/dsh-error'
|
||||
|
||||
/**
|
||||
* Every machine-routable plan-mode failure:
|
||||
* - `PLAN_NOT_ACTIVE`: the caller's committed state is not plan mode; work without the exit tool.
|
||||
* - `PLAN_REVIEW_INTERRUPTED`: the plan-mode service was reloaded during the review; present the plan again.
|
||||
* - `PLAN_REVISION_REQUESTED`: the user chose to keep planning; revise the plan from the feedback in `message`.
|
||||
* - `PLAN_STATE_UNAVAILABLE`: the plan projection reader is not registered yet; await plugin activation before running an agent.
|
||||
*/
|
||||
export type PlanModeErrorCode =
|
||||
| 'PLAN_NOT_ACTIVE'
|
||||
| 'PLAN_REVIEW_INTERRUPTED'
|
||||
| 'PLAN_REVISION_REQUESTED'
|
||||
| 'PLAN_STATE_UNAVAILABLE'
|
||||
|
||||
/** Typed plan-mode failure; `code` is one {@link PlanModeErrorCode}. */
|
||||
export class PlanModeError extends HarnessError {
|
||||
override readonly code: PlanModeErrorCode
|
||||
|
||||
/**
|
||||
* @param message - reason and next step for the caller.
|
||||
* @param code - failure class.
|
||||
* @param options - standard `cause` chaining.
|
||||
*/
|
||||
constructor(message: string, code: PlanModeErrorCode, options?: ErrorOptions) {
|
||||
super(message, code, options)
|
||||
this.name = 'PlanModeError'
|
||||
this.code = code
|
||||
}
|
||||
}
|
||||
@@ -30,18 +30,20 @@ import type { Agent, PreStepDecision } from '@deepseek-ai/dsh-agent'
|
||||
import { createUserMessage } from '@deepseek-ai/dsh-llm'
|
||||
import type { ContextFormed } from '@deepseek-ai/dsh-llm'
|
||||
import type { Session, UserMessage } from '@deepseek-ai/dsh-session'
|
||||
import { defineTool } from '@deepseek-ai/dsh-tools'
|
||||
import { defineTool, ToolArgsError, ToolContextUnavailableError } from '@deepseek-ai/dsh-tools'
|
||||
import { UserQuestionError, type AskUserQuestionAnswer } from '@deepseek-ai/dsh-user-questions'
|
||||
import type { CommandDefinitionId, CommandId } from '@deepseek-ai/dsh-commands'
|
||||
import type {} from '@deepseek-ai/dsh-session-projection'
|
||||
import type { ProjectionDefinition, ProjectionHandle } from '@deepseek-ai/dsh-session-projection'
|
||||
import type { PlanProjection, PlanUnitState } from './types.ts'
|
||||
import { PlanModeError } from './error.ts'
|
||||
declare module '@deepseek-ai/dsh-llm' {
|
||||
interface MessageSourceMap {
|
||||
'plan-mode': { kind: 'plan-mode' } & ContextFormed
|
||||
}
|
||||
}
|
||||
export type * from './types.ts'
|
||||
export { PlanModeError, type PlanModeErrorCode } from './error.ts'
|
||||
|
||||
declare module '@deepseek-ai/dsh-session/types' {
|
||||
interface SessionEventMap {
|
||||
@@ -301,15 +303,20 @@ export class PlanModeController extends Service {
|
||||
execute: async (args, exec) => {
|
||||
const agent = exec.agent
|
||||
// Admission outlives plan mode and follows the selected state, so check the committed state.
|
||||
if (agent === undefined || !this.loggedActive(agent.session)) {
|
||||
throw new Error(`${EXIT_PLAN_MODE} is only available in plan mode`)
|
||||
if (agent === undefined) {
|
||||
throw new ToolContextUnavailableError(`${EXIT_PLAN_MODE} requires a calling agent`)
|
||||
}
|
||||
if (!this.loggedActive(agent.session)) {
|
||||
throw new PlanModeError(`${EXIT_PLAN_MODE} is only available in plan mode`, 'PLAN_NOT_ACTIVE')
|
||||
}
|
||||
if (!/^#\s+\S/.test(args.plan.trim())) {
|
||||
throw new Error(`${EXIT_PLAN_MODE} requires a non-empty markdown plan starting with a # heading`)
|
||||
throw new ToolArgsError([`${EXIT_PLAN_MODE} requires a non-empty markdown plan starting with a # heading`])
|
||||
}
|
||||
const interaction = ctx.get('userQuestions')
|
||||
if (interaction === undefined) {
|
||||
throw new Error('no user-questions channel is available to review the plan; ask the user to switch the session mode instead')
|
||||
throw new ToolContextUnavailableError(
|
||||
'no user-questions channel is available to review the plan; ask the user to switch the session mode instead',
|
||||
)
|
||||
}
|
||||
let answer: AskUserQuestionAnswer
|
||||
try {
|
||||
@@ -345,15 +352,18 @@ export class PlanModeController extends Service {
|
||||
// A review may outlive this plugin fiber. Without its pre-step listener,
|
||||
// an approved selection could never be appended, so fail and keep planning.
|
||||
if (disposed) {
|
||||
throw new Error('the plan-mode service was reloaded while the plan was under review; present the plan again')
|
||||
throw new PlanModeError(
|
||||
'the plan-mode service was reloaded while the plan was under review; present the plan again',
|
||||
'PLAN_REVIEW_INTERRUPTED',
|
||||
)
|
||||
}
|
||||
const reviewItems = answer.answers.filter(entry => entry.id === REVIEW_ID)
|
||||
const item = reviewItems.length === 1 ? reviewItems[0] : undefined
|
||||
if (item?.selected.length !== 1 || item.selected[0] !== APPROVE_LABEL || item.custom !== undefined) {
|
||||
const feedback = item?.custom ?? ''
|
||||
throw new Error(feedback === ''
|
||||
throw new PlanModeError(feedback === ''
|
||||
? 'The user chose to keep planning; revise the plan and present it again.'
|
||||
: `The user chose to keep planning; their feedback: ${feedback}`)
|
||||
: `The user chose to keep planning; their feedback: ${feedback}`, 'PLAN_REVISION_REQUESTED')
|
||||
}
|
||||
// Keep plan guidance for the rest of this assistant tool batch. The
|
||||
// silent selection is appended at the next accepted in-turn pre-step,
|
||||
@@ -394,7 +404,7 @@ export class PlanModeController extends Service {
|
||||
|
||||
private planState(session: Session): PlanUnitState {
|
||||
if (this.planProjectionHandle === undefined) {
|
||||
throw new Error('plan mode is not ready; await plugin activation before running an agent')
|
||||
throw new PlanModeError('plan mode is not ready; await plugin activation before running an agent', 'PLAN_STATE_UNAVAILABLE')
|
||||
}
|
||||
return this.planProjectionHandle.stateOf(session)
|
||||
}
|
||||
|
||||
@@ -46,7 +46,9 @@ describe('plan-mode activation', () => {
|
||||
agent.followup(prompt)
|
||||
await agent.whenIdle()
|
||||
expect(adapter.requests).toHaveLength(0)
|
||||
expect(errors.some(error => error instanceof Error && /plan.*not ready/.test(error.message))).toBe(true)
|
||||
expect(errors).toContainEqual(expect.objectContaining({
|
||||
name: 'PlanModeError', code: 'PLAN_STATE_UNAVAILABLE', message: expect.stringMatching(/plan.*not ready/) as string,
|
||||
}))
|
||||
expect(agent.session.snapshotEvents().filter(event => event.type === 'request/header')).toHaveLength(0)
|
||||
|
||||
release.resolve(undefined)
|
||||
|
||||
@@ -846,7 +846,11 @@ describe('exit_plan_mode', () => {
|
||||
arguments: { plan: '# P' }, token: Symbol('direct-exit') as ToolExecutionToken, signal: testToolSignal,
|
||||
deferContext() {}, concludeTurn() {},
|
||||
}
|
||||
await expect(exit?.execute({ plan: '# P' }, exec)).rejects.toThrow(`${EXIT_PLAN_MODE} is only available in plan mode`)
|
||||
await expect(exit?.execute({ plan: '# P' }, exec)).rejects.toMatchObject({
|
||||
name: 'ToolContextUnavailableError',
|
||||
code: 'TOOL_CONTEXT_UNAVAILABLE',
|
||||
message: `${EXIT_PLAN_MODE} requires a calling agent`,
|
||||
})
|
||||
})
|
||||
|
||||
it('keeps the exit tool after leaving plan mode and rejects a call outside it', async () => {
|
||||
@@ -857,6 +861,7 @@ describe('exit_plan_mode', () => {
|
||||
const result = await callExit(ctx, agent)
|
||||
expect(result.isError).toBe(true)
|
||||
expect(result.content).toEqual([{ type: 'text', text: 'Error: exit_plan_mode is only available in plan mode' }])
|
||||
expect(result.error?.info).toEqual({ name: 'PlanModeError', code: 'PLAN_NOT_ACTIVE' })
|
||||
})
|
||||
|
||||
it('admits the exit tool for a selected entry but rejects a call before the entry is logged', async () => {
|
||||
@@ -868,6 +873,7 @@ describe('exit_plan_mode', () => {
|
||||
const result = await callExit(ctx, agent)
|
||||
expect(result.isError).toBe(true)
|
||||
expect(result.content).toEqual([{ type: 'text', text: 'Error: exit_plan_mode is only available in plan mode' }])
|
||||
expect(result.error?.info).toEqual({ name: 'PlanModeError', code: 'PLAN_NOT_ACTIVE' })
|
||||
})
|
||||
|
||||
it('rejects an empty or heading-less plan before asking the reviewer', async () => {
|
||||
@@ -875,7 +881,8 @@ describe('exit_plan_mode', () => {
|
||||
for (const plan of ['', 'do things']) {
|
||||
const result = await callExit(ctx, agent, plan)
|
||||
expect(result.isError).toBe(true)
|
||||
expect(result.content).toEqual([{ type: 'text', text: 'Error: exit_plan_mode requires a non-empty markdown plan starting with a # heading' }])
|
||||
expect(result.content).toEqual([{ type: 'text', text: 'Error: invalid arguments: exit_plan_mode requires a non-empty markdown plan starting with a # heading' }])
|
||||
expect(result.error?.info).toEqual({ name: 'ToolArgsError', code: 'INVALID_ARGS' })
|
||||
}
|
||||
expect(asked).toHaveLength(0)
|
||||
expect(foldPlanMode(agent.session.snapshotEvents())).toBe(true)
|
||||
@@ -887,6 +894,7 @@ describe('exit_plan_mode', () => {
|
||||
const result = await callExit(ctx, agent)
|
||||
expect(result.isError).toBe(true)
|
||||
expect(result.content).toEqual([{ type: 'text', text: 'Error: no user-questions channel is available to review the plan; ask the user to switch the session mode instead' }])
|
||||
expect(result.error?.info).toEqual({ name: 'ToolContextUnavailableError', code: 'TOOL_CONTEXT_UNAVAILABLE' })
|
||||
expect(foldPlanMode(agent.session.snapshotEvents())).toBe(true)
|
||||
})
|
||||
|
||||
@@ -1024,6 +1032,7 @@ describe('exit_plan_mode', () => {
|
||||
const result = await callExit(ctx, agent)
|
||||
expect(result.isError).toBe(true)
|
||||
expect(result.content).toEqual([{ type: 'text', text: 'Error: The user chose to keep planning; their feedback: consider the resume path' }])
|
||||
expect(result.error?.info).toEqual({ name: 'PlanModeError', code: 'PLAN_REVISION_REQUESTED' })
|
||||
expect(foldPlanMode(agent.session.snapshotEvents())).toBe(true)
|
||||
})
|
||||
|
||||
@@ -1032,6 +1041,7 @@ describe('exit_plan_mode', () => {
|
||||
const result = await callExit(ctx, agent)
|
||||
expect(result.isError).toBe(true)
|
||||
expect(result.content).toEqual([{ type: 'text', text: 'Error: The user chose to keep planning; revise the plan and present it again.' }])
|
||||
expect(result.error?.info).toEqual({ name: 'PlanModeError', code: 'PLAN_REVISION_REQUESTED' })
|
||||
})
|
||||
|
||||
it('a custom-text-only answer is feedback, never consent', async () => {
|
||||
@@ -1039,6 +1049,7 @@ describe('exit_plan_mode', () => {
|
||||
const result = await callExit(ctx, agent)
|
||||
expect(result.isError).toBe(true)
|
||||
expect(result.content).toEqual([{ type: 'text', text: 'Error: The user chose to keep planning; their feedback: add tests first' }])
|
||||
expect(result.error?.info).toEqual({ name: 'PlanModeError', code: 'PLAN_REVISION_REQUESTED' })
|
||||
expect(foldPlanMode(agent.session.snapshotEvents())).toBe(true)
|
||||
})
|
||||
|
||||
@@ -1047,6 +1058,7 @@ describe('exit_plan_mode', () => {
|
||||
const result = await callExit(ctx, agent)
|
||||
expect(result.isError).toBe(true)
|
||||
expect(result.content).toEqual([{ type: 'text', text: 'Error: The user chose to keep planning; revise the plan and present it again.' }])
|
||||
expect(result.error?.info).toEqual({ name: 'PlanModeError', code: 'PLAN_REVISION_REQUESTED' })
|
||||
expect(foldPlanMode(agent.session.snapshotEvents())).toBe(true)
|
||||
})
|
||||
|
||||
@@ -1055,6 +1067,7 @@ describe('exit_plan_mode', () => {
|
||||
const result = await callExit(ctx, agent)
|
||||
expect(result.isError).toBe(true)
|
||||
expect(result.content).toEqual([{ type: 'text', text: 'Error: The user chose to keep planning; their feedback: change the tests' }])
|
||||
expect(result.error?.info).toEqual({ name: 'PlanModeError', code: 'PLAN_REVISION_REQUESTED' })
|
||||
expect(foldPlanMode(agent.session.snapshotEvents())).toBe(true)
|
||||
})
|
||||
|
||||
@@ -1069,6 +1082,7 @@ describe('exit_plan_mode', () => {
|
||||
const result = await callExit(ctx, agent)
|
||||
expect(result.isError).toBe(true)
|
||||
expect(result.content).toEqual([{ type: 'text', text: 'Error: The user chose to keep planning; revise the plan and present it again.' }])
|
||||
expect(result.error?.info).toEqual({ name: 'PlanModeError', code: 'PLAN_REVISION_REQUESTED' })
|
||||
expect(foldPlanMode(agent.session.snapshotEvents())).toBe(true)
|
||||
})
|
||||
|
||||
@@ -1078,6 +1092,7 @@ describe('exit_plan_mode', () => {
|
||||
const result = await callExit(ctx, agent)
|
||||
expect(result.isError).toBe(true)
|
||||
expect(result.content).toEqual([{ type: 'text', text: 'Error: The user chose to keep planning; revise the plan and present it again.' }])
|
||||
expect(result.error?.info).toEqual({ name: 'PlanModeError', code: 'PLAN_REVISION_REQUESTED' })
|
||||
})
|
||||
|
||||
it('declares the plan-review presentation intent naming its approve option', async () => {
|
||||
@@ -1155,6 +1170,7 @@ describe('exit_plan_mode', () => {
|
||||
const result = await pending
|
||||
expect(result.isError).toBe(true)
|
||||
expect(result.content).toEqual([{ type: 'text', text: 'Error: the plan-mode service was reloaded while the plan was under review; present the plan again' }])
|
||||
expect(result.error?.info).toEqual({ name: 'PlanModeError', code: 'PLAN_REVIEW_INTERRUPTED' })
|
||||
expect(foldPlanMode(agent.session.snapshotEvents())).toBe(true)
|
||||
})
|
||||
|
||||
@@ -1164,6 +1180,7 @@ describe('exit_plan_mode', () => {
|
||||
const result = await callExit(ctx, agent)
|
||||
expect(result.isError).toBe(true)
|
||||
expect(result.content).toEqual([{ type: 'text', text: 'Error: review aborted' }])
|
||||
expect(result.error?.info).toEqual({ name: 'UserQuestionError', code: 'PROVIDER_ERROR' })
|
||||
expect(foldPlanMode(agent.session.snapshotEvents())).toBe(true)
|
||||
})
|
||||
|
||||
|
||||
@@ -14,6 +14,9 @@
|
||||
{
|
||||
"path": "../../../vendor/cordis"
|
||||
},
|
||||
{
|
||||
"path": "../../util/error"
|
||||
},
|
||||
{
|
||||
"path": "../../core/tools"
|
||||
},
|
||||
|
||||
@@ -296,7 +296,8 @@ function internalError(): InternalScheduleError {
|
||||
* Run one Schedule operation for the root Agent that dispatched the call.
|
||||
*
|
||||
* A delegated subagent cannot use scheduled tasks, so every tool refuses it here even when its preset exposes the
|
||||
* tool. An input error keeps its code when the tool declares that code; every other failure becomes `internal_error`.
|
||||
* tool. An input error keeps its code when the tool declares that code; every other operation failure becomes
|
||||
* `internal_error`. An invalid runtime delegation depth is a caller defect and throws its `SubagentError`.
|
||||
* @param exec - Run context of the call.
|
||||
* @param codes - Error codes of the tool.
|
||||
* @param operation - Service call for the calling Agent.
|
||||
|
||||
@@ -243,6 +243,22 @@ describe('Schedule model tools', () => {
|
||||
expect((await test.service.list({})).total).toBe(0)
|
||||
})
|
||||
|
||||
it('fails with the coded depth error when the caller carries an invalid runtime delegation depth', async () => {
|
||||
const test = await harness(); tests.push(test)
|
||||
const caller = { ...agentFor(test.ctx, 'invalid-depth'), options: { subagentDepth: -1 } }
|
||||
await test.ctx.agents.register(caller)
|
||||
await mountToolSchedule(test.ctx, caller)
|
||||
for (const [name, args] of CALLS) {
|
||||
const result = await executeToolFixture(test.ctx, {
|
||||
callId: brandString<ToolCallId>('invalid-depth-call'), signal: new AbortController().signal, name, arguments: args, agent: caller,
|
||||
})
|
||||
expect(result.isError).toBe(true)
|
||||
expect(result.content).toEqual([{ type: 'text', text: 'Error: agent subagentDepth must be a non-negative safe integer' }])
|
||||
expect(result.error?.info).toEqual({ name: 'SubagentError', code: 'INVALID_DEPTH' })
|
||||
}
|
||||
expect((await test.service.list({})).total).toBe(0)
|
||||
})
|
||||
|
||||
it('describes the create parameters for the model', async () => {
|
||||
const test = await setup()
|
||||
const schema = test.ctx.tools.schemas(test.agent).find(candidate => candidate.name === 'schedule_create')
|
||||
|
||||
@@ -157,8 +157,9 @@ describe('SDK subagent routing and diagnostics through the production profile',
|
||||
expect(results[0]!.data.message.isError).toBe(true)
|
||||
expect(results[0]!.data.message.content).toEqual([{
|
||||
type: 'text',
|
||||
text: 'Error: child LLM `reasoning_effort` requires both `provider` and `model`; supply both or omit all three fields',
|
||||
text: 'Error: invalid arguments: child LLM `reasoning_effort` requires both `provider` and `model`; supply both or omit all three fields',
|
||||
}])
|
||||
expect(results[0]!.data.error).toEqual({ name: 'ToolArgsError', code: 'INVALID_ARGS' })
|
||||
expect(events.some(event => event.type === 'subagent/catalog')).toBe(false)
|
||||
expect(existsSync(join(child.childHome, 'sessions'))).toBe(false)
|
||||
},
|
||||
|
||||
@@ -132,7 +132,10 @@ describe('dsh-subagent-spawn-in-process', () => {
|
||||
const { ctx, parent } = await setup([])
|
||||
// parent is depth 0, child would be depth 1 — cap at 0 forbids any child.
|
||||
await expect(start(ctx, 'spawn', { prompt: [{ type: 'text', text: 'p' }], parent, maxDepth: 0 }))
|
||||
.rejects.toThrow('subagent depth 1 exceeds maxDepth 0')
|
||||
.rejects.toMatchObject({
|
||||
name: 'SubagentDepthError', code: 'DEPTH_EXCEEDED', message: 'subagent depth 1 exceeds maxDepth 0',
|
||||
attemptedDepth: 1, maxDepth: 0,
|
||||
})
|
||||
})
|
||||
|
||||
it('maps a child that hit its token ceiling to stopReason "max-tokens"', async () => {
|
||||
|
||||
@@ -39,8 +39,8 @@
|
||||
en: bf3175c2218a16dd
|
||||
zh: 4be9271efe71ddb7
|
||||
/deepseek-ai-dsh-subagent/use-this-package/failure-and-recovery:
|
||||
en: 0dc416ded19e304e
|
||||
zh: 4726e5fe5f188709
|
||||
en: c097c297e75f3bd4
|
||||
zh: 0b09f2870ccc6a64
|
||||
/deepseek-ai-dsh-subagent/understand-the-implementation:
|
||||
en: 74d91b364b23f88d
|
||||
zh: 19cc558105efe8df
|
||||
|
||||
@@ -79,7 +79,7 @@ In-process spawn accepts an independent `agentPreset`; fork and external backend
|
||||
|
||||
### Failure and recovery
|
||||
|
||||
Starting without the `agents` service rejects with `CONTINUATION_UNAVAILABLE`; an available runtime rejects a missing or replaced parent with `UNAUTHORIZED`. Providers implementing neither execution method are rejected at registration with `UNSUPPORTED_CAPABILITY`; unsupported requested capabilities reject creation with the same code. If a provider is removed or replaced while directory resolution is pending, creation rejects with `PROVIDER_CHANGED` before invoking either provider; retry the delegation against the current registration. The caller signal cancels only unpublished work; after publication, `dispose()` cancels the exact activation and waits for its resource cleanup. Creation descendants continue independently; hosts must await `drainDescendants([root])` before disposing the root handle to stop all members and await pending startup. `result` settles after teardown and notifications, carrying output, optional structured data, and a stop reason; capture failures reject it after teardown. Cleanup failures reject `dispose()` and mark the lifecycle end as failed; the result promise and parent notification retain the captured execution result.
|
||||
Every `SubagentError` carries one code from the closed `SubagentErrorCode` union in [`src/error.ts`](src/error.ts), which documents each condition. Starting without the `agents` service rejects with `CONTINUATION_UNAVAILABLE`; an available runtime rejects a missing or replaced parent with `UNAUTHORIZED`. Providers implementing neither execution method are rejected at registration with `UNSUPPORTED_CAPABILITY`; unsupported requested capabilities reject creation with the same code. If a provider is removed or replaced while directory resolution is pending, creation rejects with `PROVIDER_CHANGED` before invoking either provider; retry the delegation against the current registration. Every creation failure below is a `SubagentError`: a child beyond the requested depth rejects with the `SubagentDepthError` subclass and `DEPTH_EXCEEDED`, an invalid runtime `subagentDepth` with `INVALID_DEPTH`, a selected preset without the preset service with `PRESET_UNAVAILABLE` (an unknown or unloadable selected preset keeps the registry's `RemoteError` code), a local child without the working-directory service with `WORKING_DIRECTORY_UNAVAILABLE`, and an out-of-process child whose cwd is relative or not enterable with `INVALID_CWD`. A cold target whose persisted descriptor is corrupt rejects with `NOT_RESUMABLE`, and `structured_output` called while input is pending fails with `STRUCTURED_OUTPUT_PENDING_INPUT`. The caller signal cancels only unpublished work; after publication, `dispose()` cancels the exact activation and waits for its resource cleanup. Creation descendants continue independently; hosts must await `drainDescendants([root])` before disposing the root handle to stop all members and await pending startup. `result` settles after teardown and notifications, carrying output, optional structured data, and a stop reason; capture failures reject it after teardown. Cleanup failures reject `dispose()` and mark the lifecycle end as failed; the result promise and parent notification retain the captured execution result.
|
||||
|
||||
-----
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ kind: "package-reference"
|
||||
|
||||
### 失败与恢复
|
||||
|
||||
缺少 `agents` 服务时,启动请求以 `CONTINUATION_UNAVAILABLE` 拒绝;运行时可用但父级缺失或被替换时,以 `UNAUTHORIZED` 拒绝。未实现任何执行方法的提供方会在注册时以 `UNSUPPORTED_CAPABILITY` 被拒绝;请求不受支持的能力会以同一码使创建失败。如果等待目录解析期间提供方被移除或替换,创建会在调用任何一方之前以 `PROVIDER_CHANGED` 拒绝;调用方可根据当前注册重试委派。调用方信号仅取消尚未发布的工作;发布后通过 `dispose()` 取消该次 activation,并等待其资源清理完成。创建后代独立继续运行;宿主必须在释放根句柄前等待 `drainDescendants([root])`,以停止所有成员并等待正在启动的工作。`result` 在清理与通知结束后完成,携带输出、可选结构化数据与停止原因;结果捕获故障在清理后使其拒绝。清理失败使 `dispose()` 拒绝,并将生命周期结束事件标记为失败;结果 promise 与父级通知保留已捕获的执行结果。
|
||||
每个 `SubagentError` 都携带 [`src/error.ts`](src/error.ts) 中封闭联合类型 `SubagentErrorCode` 的一个 code,该文件逐条说明各条件。缺少 `agents` 服务时,启动请求以 `CONTINUATION_UNAVAILABLE` 拒绝;运行时可用但父级缺失或被替换时,以 `UNAUTHORIZED` 拒绝。未实现任何执行方法的提供方会在注册时以 `UNSUPPORTED_CAPABILITY` 被拒绝;请求不受支持的能力会以同一码使创建失败。如果等待目录解析期间提供方被移除或替换,创建会在调用任何一方之前以 `PROVIDER_CHANGED` 拒绝;调用方可根据当前注册重试委派。以下创建失败均为 `SubagentError`:超出请求深度的子代以 `SubagentDepthError` 子类和 `DEPTH_EXCEEDED` 拒绝,无效的运行时 `subagentDepth` 以 `INVALID_DEPTH` 拒绝,选择了 preset 但缺少 preset 服务时以 `PRESET_UNAVAILABLE` 拒绝(所选 preset 未知或无法加载时保留 registry 的 `RemoteError` code),缺少工作目录服务的本地子代以 `WORKING_DIRECTORY_UNAVAILABLE` 拒绝,cwd 为相对路径或不可进入的进程外子代以 `INVALID_CWD` 拒绝。持久化 descriptor 损坏的冷目标以 `NOT_RESUMABLE` 拒绝,有待处理输入时调用 `structured_output` 以 `STRUCTURED_OUTPUT_PENDING_INPUT` 失败。调用方信号仅取消尚未发布的工作;发布后通过 `dispose()` 取消该次 activation,并等待其资源清理完成。创建后代独立继续运行;宿主必须在释放根句柄前等待 `drainDescendants([root])`,以停止所有成员并等待正在启动的工作。`result` 在清理与通知结束后完成,携带输出、可选结构化数据与停止原因;结果捕获故障在清理后使其拒绝。清理失败使 `dispose()` 拒绝,并将生命周期结束事件标记为失败;结果 promise 与父级通知保留已捕获的执行结果。
|
||||
|
||||
-----
|
||||
|
||||
|
||||
@@ -109,6 +109,7 @@
|
||||
"@deepseek-ai/dsh-agent": "workspace:*",
|
||||
"@deepseek-ai/dsh-agent-preset-registry": "workspace:*",
|
||||
"@deepseek-ai/dsh-attachment": "workspace:*",
|
||||
"@deepseek-ai/dsh-error": "workspace:*",
|
||||
"@deepseek-ai/dsh-llm": "workspace:*",
|
||||
"@deepseek-ai/dsh-sandbox": "workspace:*",
|
||||
"@deepseek-ai/dsh-sandbox-policy": "workspace:*",
|
||||
|
||||
@@ -28,10 +28,10 @@ import type {} from '@deepseek-ai/dsh-agent-preset-registry'
|
||||
import { delegationDepthOf } from './depth.ts'
|
||||
import { SubagentError } from './error.ts'
|
||||
|
||||
/** Thrown when starting a child would exceed the requested depth cap. */
|
||||
export class SubagentDepthError extends Error {
|
||||
/** Thrown when starting a child would exceed the requested depth cap; `code` is `DEPTH_EXCEEDED`. */
|
||||
export class SubagentDepthError extends SubagentError {
|
||||
constructor(public readonly attemptedDepth: number, public readonly maxDepth: number) {
|
||||
super(`subagent depth ${attemptedDepth} exceeds maxDepth ${maxDepth}`)
|
||||
super(`subagent depth ${attemptedDepth} exceeds maxDepth ${maxDepth}`, 'DEPTH_EXCEEDED')
|
||||
this.name = 'SubagentDepthError'
|
||||
}
|
||||
}
|
||||
@@ -44,12 +44,12 @@ export class SubagentDepthError extends Error {
|
||||
* @param maxDepth - optional absolute cap the resolved depth must not exceed.
|
||||
* @returns the child's non-negative safe-integer depth.
|
||||
* @throws {SubagentDepthError} when the resolved depth exceeds `maxDepth`.
|
||||
* @throws {RangeError} when the resolved depth leaves the safe-integer range.
|
||||
* @throws {SubagentError} `INVALID_DEPTH` when the resolved depth leaves the safe-integer range.
|
||||
*/
|
||||
export function resolveChildDepth(parent: Agent, maxDepth: number | undefined): number {
|
||||
const childDepth = delegationDepthOf(parent) + 1
|
||||
if (!Number.isSafeInteger(childDepth)) {
|
||||
throw new RangeError('subagent child depth exceeds the safe-integer range')
|
||||
throw new SubagentError('subagent child depth exceeds the safe-integer range', 'INVALID_DEPTH')
|
||||
}
|
||||
if (maxDepth !== undefined && childDepth > maxDepth) {
|
||||
throw new SubagentDepthError(childDepth, maxDepth)
|
||||
@@ -183,6 +183,9 @@ export const SUBAGENT_DELEGATION_CONTEXT
|
||||
* @param parent - creator for fresh delegation; absent during target-only restoration.
|
||||
* @param composition - independent preset and any overrides read from a historical descriptor.
|
||||
* @returns A promise when mounting an independent preset; otherwise completes synchronously.
|
||||
* @throws {SubagentError} `PRESET_UNAVAILABLE` when a preset is selected but the preset
|
||||
* service is absent. An unknown or unloadable selected preset rejects with the registry's
|
||||
* `RemoteError` code.
|
||||
*/
|
||||
export function applyChildComposition(
|
||||
childCtx: Context,
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
import type { Agent } from '@deepseek-ai/dsh-agent'
|
||||
import { SubagentError } from './error.ts'
|
||||
|
||||
declare module '@deepseek-ai/dsh-agent' {
|
||||
interface AgentOptions {
|
||||
@@ -23,12 +24,12 @@ declare module '@deepseek-ai/dsh-agent' {
|
||||
* let it delegate as if it were top-level.
|
||||
* @param agent - the agent whose header and options carry the depth.
|
||||
* @returns its non-negative safe-integer depth.
|
||||
* @throws if the runtime `AgentOptions.subagentDepth` is not a non-negative safe integer.
|
||||
* @throws {SubagentError} `INVALID_DEPTH` if the runtime `AgentOptions.subagentDepth` is not a non-negative safe integer.
|
||||
*/
|
||||
export function delegationDepthOf(agent: Agent): number {
|
||||
const runtime = agent.options.subagentDepth
|
||||
if (runtime !== undefined && (!Number.isSafeInteger(runtime) || runtime < 0 || Object.is(runtime, -0))) {
|
||||
throw new TypeError('agent subagentDepth must be a non-negative safe integer')
|
||||
throw new SubagentError('agent subagentDepth must be a non-negative safe integer', 'INVALID_DEPTH')
|
||||
}
|
||||
// The header value was validated at the session boundary (creation and
|
||||
// persistence load both construct through the store).
|
||||
|
||||
@@ -6,10 +6,92 @@
|
||||
|
||||
import { HarnessError } from '@deepseek-ai/dsh-llm'
|
||||
|
||||
/** Typed failure for the subagent seam. */
|
||||
/**
|
||||
* Every machine-routable subagent failure. Each code names one condition;
|
||||
* reuse one only when the consumer action is the same.
|
||||
*/
|
||||
export type SubagentErrorCode =
|
||||
/** A provider registration or a request needs a capability the selected backend lacks. */
|
||||
| 'UNSUPPORTED_CAPABILITY'
|
||||
/** A provider with the same name is already registered. */
|
||||
| 'DUPLICATE_PROVIDER'
|
||||
/** No subagent provider is registered under the requested name. */
|
||||
| 'NO_PROVIDER'
|
||||
/** The provider was removed or replaced while a delegation was starting; retry against the current registration. */
|
||||
| 'PROVIDER_CHANGED'
|
||||
/** A child preset was selected but the agent-presets service is absent. */
|
||||
| 'PRESET_UNAVAILABLE'
|
||||
/** The tool instance exposes no agent preset choice. */
|
||||
| 'PRESET_SELECTION_DISABLED'
|
||||
/** The selected agent preset is outside the tool's allowlist. */
|
||||
| 'PRESET_NOT_ALLOWED'
|
||||
/** The tool instance does not accept child model selection. */
|
||||
| 'MODEL_SELECTION_DISABLED'
|
||||
/** The Session's model-selection policy does not authorize the requested child provider or route. */
|
||||
| 'MODEL_ROUTE_NOT_ALLOWED'
|
||||
/** The requested LLM provider is not registered with the LLM runtime. */
|
||||
| 'LLM_PROVIDER_NOT_FOUND'
|
||||
/** The child's target model cannot accept image input. */
|
||||
| 'MODEL_DOES_NOT_SUPPORT_IMAGES'
|
||||
/** Starting the child would exceed the requested delegation depth; thrown as `SubagentDepthError`. */
|
||||
| 'DEPTH_EXCEEDED'
|
||||
/** A runtime delegation depth is not a non-negative safe integer. */
|
||||
| 'INVALID_DEPTH'
|
||||
/** An out-of-process child's working directory is relative or not enterable. */
|
||||
| 'INVALID_CWD'
|
||||
/** A local child cannot start because the working-directory service is absent. */
|
||||
| 'WORKING_DIRECTORY_UNAVAILABLE'
|
||||
/** The caller is not the exact live agent, or does not own the target in its subagent tree. */
|
||||
| 'UNAUTHORIZED'
|
||||
/** The tree's activation capacity is exhausted. */
|
||||
| 'ACTIVATION_LIMIT_REACHED'
|
||||
/** The target activation is closing. */
|
||||
| 'ACTIVATION_CLOSING'
|
||||
/** Releasing an activation's resources failed. */
|
||||
| 'ACTIVATION_TEARDOWN_FAILED'
|
||||
/** A child with the same Session id already exists. */
|
||||
| 'DUPLICATE_CHILD'
|
||||
/** The subagent tree is draining and admits no new work. */
|
||||
| 'DRAINING'
|
||||
/** The child accepts no more input after its structured result. */
|
||||
| 'INPUT_CLOSED'
|
||||
/** `structured_output` was called while accepted input is still pending. */
|
||||
| 'STRUCTURED_OUTPUT_PENDING_INPUT'
|
||||
/** The operation was cancelled by its caller. */
|
||||
| 'CANCELLED'
|
||||
/** A cold child cannot be restored from its persisted state. */
|
||||
| 'NOT_RESUMABLE'
|
||||
/** The child was not started as continuable and accepts no follow-up. */
|
||||
| 'NOT_CONTINUABLE'
|
||||
/** Continuation needs the agent runtime or a live tree root that is absent. */
|
||||
| 'CONTINUATION_UNAVAILABLE'
|
||||
/** Continuation needs Session persistence that is absent or failed. */
|
||||
| 'PERSISTENCE_UNAVAILABLE'
|
||||
/** A requested agent name does not satisfy the naming rule. */
|
||||
| 'INVALID_AGENT_NAME'
|
||||
/** A requested agent name is already used by a sibling. */
|
||||
| 'DUPLICATE_AGENT_NAME'
|
||||
/** An agent path names no member of the tree. */
|
||||
| 'AGENT_NAME_NOT_FOUND'
|
||||
/** Listing children needs the session-query service. */
|
||||
| 'SUBAGENT_CONTROL_QUERY_UNAVAILABLE'
|
||||
/** Listing children needs the session-projection service. */
|
||||
| 'SUBAGENT_CONTROL_PROJECTIONS_UNAVAILABLE'
|
||||
/** Listing children needs the Session store. */
|
||||
| 'SUBAGENT_CONTROL_SESSION_STORE_UNAVAILABLE'
|
||||
|
||||
/** Typed failure for the subagent seam; `code` is one {@link SubagentErrorCode}. */
|
||||
export class SubagentError extends HarnessError {
|
||||
constructor(message: string, code: string, options?: ErrorOptions) {
|
||||
override readonly code: SubagentErrorCode
|
||||
|
||||
/**
|
||||
* @param message - reason and next step for the caller.
|
||||
* @param code - failure class.
|
||||
* @param options - standard `cause` chaining.
|
||||
*/
|
||||
constructor(message: string, code: SubagentErrorCode, options?: ErrorOptions) {
|
||||
super(message, code, options)
|
||||
this.name = 'SubagentError'
|
||||
this.code = code
|
||||
}
|
||||
}
|
||||
@@ -109,7 +109,7 @@ export type {
|
||||
SubagentDescriptorData,
|
||||
} from './descriptor.ts'
|
||||
export { STRUCTURED_OUTPUT_TOOL } from './structured.ts'
|
||||
export { SubagentError } from './error.ts'
|
||||
export { SubagentError, type SubagentErrorCode } from './error.ts'
|
||||
export { assertSubagentMaxDepth, delegationDepthOf } from './depth.ts'
|
||||
export {
|
||||
appendDelegatedPolicyOverrides,
|
||||
|
||||
@@ -836,7 +836,9 @@ export class SubagentManager {
|
||||
child.session.append('subagent/descriptor', create.descriptor)
|
||||
appendDelegatedPolicyOverrides(child.session, create.delegatedPolicies)
|
||||
const workingDirectory = childCtx.get('workingDirectory')
|
||||
if (workingDirectory === undefined) throw new Error('local subagents require the working-directory service')
|
||||
if (workingDirectory === undefined) {
|
||||
throw new SubagentError('local subagents require the working-directory service', 'WORKING_DIRECTORY_UNAVAILABLE')
|
||||
}
|
||||
await workingDirectory.set(child, create.cwd, inputs.signal)
|
||||
}
|
||||
if (inputs.composition.agentPreset === undefined) await applyChildComposition(childCtx, create?.parent, inputs.composition)
|
||||
@@ -1216,7 +1218,16 @@ export class SubagentManager {
|
||||
using source = await this.observeContinuation(childId, signal)
|
||||
this.assertAdmitting(root)
|
||||
const ownEvents = source.events.slice(source.inheritedEventCount)
|
||||
const descriptor = foldSubagentDescriptor(ownEvents)
|
||||
let descriptor: ReturnType<typeof foldSubagentDescriptor>
|
||||
try {
|
||||
descriptor = foldSubagentDescriptor(ownEvents)
|
||||
} catch (error: unknown) {
|
||||
throw new SubagentError(
|
||||
`subagent "${childId}" has a corrupt continuation descriptor and cannot be resumed; choose a different target`,
|
||||
'NOT_RESUMABLE',
|
||||
{ cause: error },
|
||||
)
|
||||
}
|
||||
if (descriptor === undefined || descriptor.mode !== 'continuable') {
|
||||
throw new SubagentError(
|
||||
`subagent "${childId}" has no supported continuation state and cannot be resumed; choose a different target`,
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
import { accessSync, constants, statSync } from 'node:fs'
|
||||
import { isAbsolute } from 'node:path'
|
||||
import type { ContentBlock } from '@deepseek-ai/dsh-llm'
|
||||
import { SubagentError } from './error.ts'
|
||||
import type { SubagentCapabilities, SubagentResult, SubagentRun, SubagentStopReason } from './types.ts'
|
||||
|
||||
/** Maximum UTF-8 size of {@link SubagentResult.diagnostic}. */
|
||||
@@ -100,13 +101,14 @@ function isEnterableDirectory(path: string): boolean {
|
||||
* @param label - which source supplied the value, for the diagnostic.
|
||||
* @param cwd - the candidate working directory.
|
||||
* @returns `cwd`, validated.
|
||||
* @throws {SubagentError} `INVALID_CWD` when `cwd` is relative or not an enterable directory.
|
||||
*/
|
||||
export function assertUsableCwd(prefix: string, label: string, cwd: string): string {
|
||||
if (!isAbsolute(cwd)) {
|
||||
throw new Error(`${prefix}: ${label} must be an absolute path: ${cwd}`)
|
||||
throw new SubagentError(`${prefix}: ${label} must be an absolute path: ${cwd}`, 'INVALID_CWD')
|
||||
}
|
||||
if (!isEnterableDirectory(cwd)) {
|
||||
throw new Error(`${prefix}: ${label} is not an accessible directory: ${cwd}`)
|
||||
throw new SubagentError(`${prefix}: ${label} is not an accessible directory: ${cwd}`, 'INVALID_CWD')
|
||||
}
|
||||
return cwd
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import type { Context } from '@deepseek-ai/cordis'
|
||||
import type { ToolSchema } from '@deepseek-ai/dsh-llm'
|
||||
import type { ToolExecution, ToolRunContext } from '@deepseek-ai/dsh-tools'
|
||||
import { ToolArgsError, validateJsonSchemaValue, type ObjectJsonSchema } from '@deepseek-ai/dsh-tools'
|
||||
import { SubagentError } from './error.ts'
|
||||
|
||||
/** The model-facing tool name a structured child must call to finish. */
|
||||
export const STRUCTURED_OUTPUT_TOOL = 'structured_output'
|
||||
@@ -96,7 +97,9 @@ export function attachStructuredRuntime(
|
||||
// ToolArgsError → isError result with INVALID_ARGS: the model retries
|
||||
// within the same turn, exactly like a schema-validated defineTool call.
|
||||
if (violations.length > 0) throw new ToolArgsError(violations)
|
||||
if (!canComplete()) throw new Error('Process pending messages before submitting structured output.')
|
||||
if (!canComplete()) {
|
||||
throw new SubagentError('Process pending messages before submitting structured output.', 'STRUCTURED_OUTPUT_PENDING_INPUT')
|
||||
}
|
||||
// Two-phase commit, keyed by THIS execution: later transformable
|
||||
// waterfalls may still turn the success into an error. ToolRuntime has
|
||||
// already frozen model-bound arguments at the actual input boundary.
|
||||
|
||||
@@ -93,12 +93,16 @@ describe('delegation depth limits', () => {
|
||||
it.each([-1, -0, 0.5, Number.NaN, Number.POSITIVE_INFINITY])('rejects an invalid runtime depth %s', (depth) => {
|
||||
const parent = parentAgent()
|
||||
parent.options.subagentDepth = depth
|
||||
expect(() => resolveChildDepth(parent, undefined)).toThrow('agent subagentDepth must be a non-negative safe integer')
|
||||
expect(() => resolveChildDepth(parent, undefined)).toThrow(expect.objectContaining({
|
||||
name: 'SubagentError', code: 'INVALID_DEPTH', message: 'agent subagentDepth must be a non-negative safe integer',
|
||||
}))
|
||||
})
|
||||
|
||||
it('rejects a child depth beyond the exact integer range', () => {
|
||||
const parent = parentAgent()
|
||||
parent.options.subagentDepth = Number.MAX_SAFE_INTEGER
|
||||
expect(() => resolveChildDepth(parent, undefined)).toThrow('subagent child depth exceeds the safe-integer range')
|
||||
expect(() => resolveChildDepth(parent, undefined)).toThrow(expect.objectContaining({
|
||||
name: 'SubagentError', code: 'INVALID_DEPTH', message: 'subagent child depth exceeds the safe-integer range',
|
||||
}))
|
||||
})
|
||||
})
|
||||
@@ -1,7 +1,7 @@
|
||||
/** Independent spawn presets and compatibility of persisted child compositions. */
|
||||
import { mountWorkingDirectoryFixture } from './working-directory-fixture.ts'
|
||||
|
||||
import { afterEach, describe, expect, it } from 'vitest'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { mkdtempSync, rmSync } from 'node:fs'
|
||||
import { tmpdir } from 'node:os'
|
||||
import { dirname, join } from 'node:path'
|
||||
@@ -13,6 +13,7 @@ import type { Agent } from '@deepseek-ai/dsh-agent'
|
||||
import AgentLoop from '@deepseek-ai/dsh-agent-loop'
|
||||
import { mountAgentLoopTestDependencies } from '@deepseek-ai/dsh-agent-loop-testkit'
|
||||
import AgentPresets from '@deepseek-ai/dsh-agent-preset-registry'
|
||||
import { HarnessError } from '@deepseek-ai/dsh-error'
|
||||
import { createUserMessage } from '@deepseek-ai/dsh-llm'
|
||||
import type { SessionId } from '@deepseek-ai/dsh-session'
|
||||
import * as JsonlSessionPersistence from '@deepseek-ai/dsh-session-persistence-jsonl'
|
||||
@@ -125,6 +126,25 @@ describe('child preset start validation', () => {
|
||||
expect(adapter.requests).toEqual([])
|
||||
})
|
||||
|
||||
it('propagates a registry join failure unchanged', async () => {
|
||||
const { ctx, parent, adapter } = await setup()
|
||||
const failure = new Error('Child already joined a preset')
|
||||
vi.spyOn(ctx.agentPresets, 'composeFrom').mockImplementation(() => { throw failure })
|
||||
|
||||
await expect(ctx.subagents.startActivation(startSpec(parent))).rejects.toBe(failure)
|
||||
expect(ctx.agents.list().map(agent => agent.id)).toEqual([parent.id])
|
||||
expect(adapter.requests).toEqual([])
|
||||
})
|
||||
|
||||
it('rejects an unknown independent preset with the registry RemoteError as a HarnessError', async () => {
|
||||
const { ctx, parent, adapter } = await setup()
|
||||
const failure: unknown = await ctx.subagents.startActivation(startSpec(parent, 'absent')).catch((error: unknown) => error)
|
||||
expect(failure).toBeInstanceOf(HarnessError)
|
||||
expect(failure).toMatchObject({ name: 'RemoteError', code: 'agent-preset/not-found', message: 'Unknown agent preset: absent' })
|
||||
expect(ctx.agents.list().map(agent => agent.id)).toEqual([parent.id])
|
||||
expect(adapter.requests).toEqual([])
|
||||
})
|
||||
|
||||
it('rolls back an independent spawn when the preset service has unloaded', async () => {
|
||||
const { ctx, parent, adapter, presets } = await setup()
|
||||
await presets.dispose()
|
||||
|
||||
@@ -767,7 +767,7 @@ describe('SubagentRuntime.startActivation', () => {
|
||||
delivery: 'parent',
|
||||
...startSpec(parent),
|
||||
prompt: message('deep'), parent, maxDepth: 0,
|
||||
})).rejects.toThrow(/exceeds maxDepth 0/)
|
||||
})).rejects.toMatchObject({ name: 'SubagentDepthError', code: 'DEPTH_EXCEEDED', message: expect.stringMatching(/exceeds maxDepth 0/) as string })
|
||||
expect(ctx.agents.list().map(agent => agent.id)).toEqual([brandString<SessionId>('parent')])
|
||||
})
|
||||
|
||||
@@ -1161,6 +1161,31 @@ describe('target-only Queue residency routing', () => {
|
||||
.rejects.toMatchObject({ code: 'NOT_RESUMABLE' })
|
||||
})
|
||||
|
||||
it('rejects a cold target whose persisted descriptor is corrupt as not resumable', async () => {
|
||||
const { ctx, parent } = await setup([])
|
||||
const childId = brandString<SessionId>('child-with-corrupt-descriptor')
|
||||
const child = await ctx.agents.create({
|
||||
sessionId: childId,
|
||||
meta: { origin: 'subagent', parentSession: parent.id },
|
||||
agentOptions: { provider: 'mock', model: 'mock' },
|
||||
setup: (_childCtx, agent) => {
|
||||
agent.session.append('subagent/descriptor', {
|
||||
version: SUBAGENT_DESCRIPTOR_VERSION, mode: 'continuable', provider: 'spawn', label: 7,
|
||||
} as never)
|
||||
},
|
||||
})
|
||||
await ctx.sessions.flush(child.agent.session)
|
||||
await child.dispose()
|
||||
|
||||
await expect(ctx.subagents.sendMessage(parent, childId, message('continue'), { signal: testSignal }))
|
||||
.rejects.toMatchObject({
|
||||
name: 'SubagentError',
|
||||
code: 'NOT_RESUMABLE',
|
||||
message: `subagent "${childId}" has a corrupt continuation descriptor and cannot be resumed; choose a different target`,
|
||||
cause: expect.objectContaining({ message: 'persisted subagent descriptor label must be a string' }) as Error,
|
||||
})
|
||||
})
|
||||
|
||||
it('reports an unknown child id as unavailable', async () => {
|
||||
const { ctx } = await setup([])
|
||||
await expect(queuePrompt(ctx, brandString<SessionId>('missing'), message('hello')))
|
||||
|
||||
@@ -10,6 +10,7 @@ import type { MessageId } from '@deepseek-ai/dsh-llm'
|
||||
import type { SessionId } from '@deepseek-ai/dsh-session'
|
||||
import SubagentRuntime, {
|
||||
SubagentError,
|
||||
type SubagentErrorCode,
|
||||
type SubagentPromptRequestId,
|
||||
} from '@deepseek-ai/dsh-subagent'
|
||||
import { subagentManager } from './manager-internals.ts'
|
||||
@@ -252,7 +253,7 @@ describe('subagent prompt Remote', () => {
|
||||
it('maps each admission failure onto its stable code and hides the rest', async () => {
|
||||
const { ctx, subagents } = await bench({ [PARENT]: { status: 'idle' } })
|
||||
const delivery = promptDelivery(ctx)
|
||||
const cases: readonly [string, string][] = [
|
||||
const cases: readonly [SubagentErrorCode, string][] = [
|
||||
['NOT_RESUMABLE', 'subagent/not-resumable'],
|
||||
['UNAUTHORIZED', 'subagent/unauthorized'],
|
||||
['DRAINING', 'subagent/delivery-unavailable'],
|
||||
|
||||
@@ -43,8 +43,8 @@ describe('assertPositiveFinite', () => {
|
||||
describe('child cwd resolution', () => {
|
||||
it('accepts an absolute enterable directory and rejects relative or missing paths', () => {
|
||||
expect(assertUsableCwd('p', 'config cwd', tmpdir())).toBe(tmpdir())
|
||||
expect(() => assertUsableCwd('p', 'config cwd', 'relative/path')).toThrow('must be an absolute path')
|
||||
expect(() => assertUsableCwd('p', 'config cwd', join(tmpdir(), 'dsh-no-such-dir-xyz'))).toThrow('not an accessible directory')
|
||||
expect(() => assertUsableCwd('p', 'config cwd', 'relative/path')).toThrow(expect.objectContaining({ name: 'SubagentError', code: 'INVALID_CWD', message: expect.stringContaining('must be an absolute path') as string }))
|
||||
expect(() => assertUsableCwd('p', 'config cwd', join(tmpdir(), 'dsh-no-such-dir-xyz'))).toThrow(expect.objectContaining({ name: 'SubagentError', code: 'INVALID_CWD', message: expect.stringContaining('not an accessible directory') as string }))
|
||||
})
|
||||
|
||||
it('rejects an existing path that is a file, not a directory', () => {
|
||||
@@ -52,7 +52,7 @@ describe('child cwd resolution', () => {
|
||||
const file = join(tmp, 'plain.txt')
|
||||
try {
|
||||
writeFileSync(file, 'not a dir\n')
|
||||
expect(() => assertUsableCwd('p', 'config cwd', file)).toThrow('not an accessible directory')
|
||||
expect(() => assertUsableCwd('p', 'config cwd', file)).toThrow(expect.objectContaining({ name: 'SubagentError', code: 'INVALID_CWD', message: expect.stringContaining('not an accessible directory') as string }))
|
||||
} finally {
|
||||
rmSync(tmp, { recursive: true, force: true })
|
||||
}
|
||||
@@ -65,7 +65,7 @@ describe('child cwd resolution', () => {
|
||||
const tmp = mkdtempSync(join(tmpdir(), 'oop-noexec-'))
|
||||
chmodSync(tmp, 0o600)
|
||||
try {
|
||||
expect(() => assertUsableCwd('p', 'config cwd', tmp)).toThrow('not an accessible directory')
|
||||
expect(() => assertUsableCwd('p', 'config cwd', tmp)).toThrow(expect.objectContaining({ name: 'SubagentError', code: 'INVALID_CWD', message: expect.stringContaining('not an accessible directory') as string }))
|
||||
} finally {
|
||||
chmodSync(tmp, 0o700)
|
||||
rmSync(tmp, { recursive: true, force: true })
|
||||
|
||||
@@ -139,6 +139,8 @@ describe('in-process structured output', () => {
|
||||
const events = run.localAgent.session.snapshotEvents()
|
||||
const first = events.find(event => event.type === 'tool/result' && event.data.message.toolCallId === 'before-input')
|
||||
expect(first?.type === 'tool/result' && first.data.message.isError).toBe(true)
|
||||
expect(first?.type === 'tool/result' && first.data.error)
|
||||
.toEqual({ name: 'SubagentError', code: 'STRUCTURED_OUTPUT_PENDING_INPUT' })
|
||||
expect(events.some(event => event.type === 'user/message' && event.data.id === messageId)).toBe(true)
|
||||
expect(JSON.stringify(adapter.requests.at(-1)?.messages)).toContain('Correction: submit answer 42 instead.')
|
||||
} finally {
|
||||
|
||||
@@ -102,7 +102,11 @@ describe('subagent working directories', () => {
|
||||
provider: 'spawn', label: 'unavailable directory service', childId,
|
||||
parent, cwd: second, prompt: [{ type: 'text', text: 'child' }],
|
||||
signal: new AbortController().signal,
|
||||
})).rejects.toThrow(/subagents require the working-directory service/)
|
||||
})).rejects.toMatchObject({
|
||||
name: 'SubagentError',
|
||||
code: 'WORKING_DIRECTORY_UNAVAILABLE',
|
||||
message: expect.stringMatching(/subagents require the working-directory service/) as string,
|
||||
})
|
||||
|
||||
expect(ctx.agents.list().map(agent => agent.id)).toEqual([parent.id])
|
||||
expect(parent.session.snapshotEvents().filter(event => event.type === 'subagent/catalog')).toEqual([])
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
import type { Context } from '@deepseek-ai/cordis'
|
||||
import z from '@deepseek-ai/schemastery'
|
||||
import { defineTool } from '@deepseek-ai/dsh-tools'
|
||||
import { defineTool, ToolContextUnavailableError } from '@deepseek-ai/dsh-tools'
|
||||
import type { ContentBlock } from '@deepseek-ai/dsh-llm'
|
||||
import { ROOT_AGENT_NAME } from '@deepseek-ai/dsh-subagent'
|
||||
import type {} from '@deepseek-ai/dsh-system-prompt'
|
||||
@@ -73,7 +73,7 @@ export function apply(ctx: Context, config: Config = {}): void {
|
||||
async execute(args, exec) {
|
||||
const sender = exec.agent
|
||||
if (!sender) {
|
||||
throw new Error('send_message requires a calling agent (exec.agent was undefined)')
|
||||
throw new ToolContextUnavailableError('send_message requires a calling agent (exec.agent was undefined)')
|
||||
}
|
||||
const message: ContentBlock[] = [{ type: 'text', text: args.message }]
|
||||
const targetId = await ctx.subagents.resolveName(sender, args.agent, exec.signal)
|
||||
@@ -146,7 +146,7 @@ export function apply(ctx: Context, config: Config = {}): void {
|
||||
const caller = exec.agent
|
||||
if (!caller) {
|
||||
// Ancestor authority requires an exact live calling agent.
|
||||
throw new Error('interrupt_agent requires a calling agent (exec.agent was undefined)')
|
||||
throw new ToolContextUnavailableError('interrupt_agent requires a calling agent (exec.agent was undefined)')
|
||||
}
|
||||
const targetId = await ctx.subagents.resolveName(caller, args.agent, exec.signal)
|
||||
// The service authorizes the exact live caller against the target's
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/** Discover the caller's entire subagent tree; the control plugin owns registration. */
|
||||
|
||||
import type { Context } from '@deepseek-ai/cordis'
|
||||
import { defineTool } from '@deepseek-ai/dsh-tools'
|
||||
import { defineTool, ToolContextUnavailableError } from '@deepseek-ai/dsh-tools'
|
||||
import type { ToolDefinition } from '@deepseek-ai/dsh-tools'
|
||||
import type { Agent } from '@deepseek-ai/dsh-agent'
|
||||
import type { SessionId } from '@deepseek-ai/dsh-session'
|
||||
@@ -80,7 +80,7 @@ export function registerListAgents(ctx: Context): ToolDefinition {
|
||||
const parent = exec.agent
|
||||
if (!parent) {
|
||||
// Non-agent callers have no session whose children could be listed.
|
||||
throw new Error('list_agents requires a calling agent (exec.agent was undefined)')
|
||||
throw new ToolContextUnavailableError('list_agents requires a calling agent (exec.agent was undefined)')
|
||||
}
|
||||
const root = ctx.subagents.rootOf(parent)
|
||||
const entries = await ctx.subagents.listDescendants(root.id, exec.signal)
|
||||
|
||||
@@ -273,6 +273,7 @@ describe('list_agents', () => {
|
||||
const result = await callTool(ctx, 'list_agents', {})
|
||||
expect(result.isError).toBe(true)
|
||||
expect(text(result)).toContain('requires a calling agent')
|
||||
expect(result.error?.info).toEqual({ name: 'ToolContextUnavailableError', code: 'TOOL_CONTEXT_UNAVAILABLE' })
|
||||
})
|
||||
|
||||
it('unregisters with its plugin fiber (HMR safety)', async () => {
|
||||
|
||||
@@ -260,7 +260,7 @@ describe('dsh-tool-subagent-control', () => {
|
||||
|
||||
it.each([
|
||||
new Error('root lookup failed'),
|
||||
new SubagentError('root data is unreadable', 'CORRUPT'),
|
||||
new SubagentError('root data is unreadable', 'PERSISTENCE_UNAVAILABLE'),
|
||||
])('propagates identity lookup errors other than an unavailable root: $message', async (error) => {
|
||||
const { ctx, parent } = await setup([])
|
||||
const lookup = vi.spyOn(ctx.subagents, 'namesOf').mockImplementation(() => { throw error })
|
||||
@@ -465,6 +465,7 @@ describe('dsh-tool-subagent-control', () => {
|
||||
const result = await callTool(ctx, 'send_message', { agent: 'x', message: 'y' })
|
||||
expect(result.isError).toBe(true)
|
||||
expect(text(result)).toContain('requires a calling agent')
|
||||
expect(result.error?.info).toEqual({ name: 'ToolContextUnavailableError', code: 'TOOL_CONTEXT_UNAVAILABLE' })
|
||||
})
|
||||
|
||||
it.each([{}, { interrupt: true }, { interrupt: false }])('unregisters and reloads with config %j (HMR safety)', async (config) => {
|
||||
@@ -694,5 +695,6 @@ describe('dsh-tool-subagent-control interrupt_agent', () => {
|
||||
const result = await callTool(ctx, 'interrupt_agent', { agent: 'x' })
|
||||
expect(result.isError).toBe(true)
|
||||
expect(text(result)).toContain('requires a calling agent')
|
||||
expect(result.error?.info).toEqual({ name: 'ToolContextUnavailableError', code: 'TOOL_CONTEXT_UNAVAILABLE' })
|
||||
})
|
||||
})
|
||||
@@ -36,8 +36,8 @@
|
||||
en: 373abf7c7aa3e4f1
|
||||
zh: be0b4d4a7371d360
|
||||
/deepseek-ai-dsh-tool-subagent/understand-the-implementation/activation-ownership:
|
||||
en: ef692c4d17290920
|
||||
zh: b1d0d3dab011e2cd
|
||||
en: 801820b3e64494ef
|
||||
zh: 3d81e9ffe69cd7da
|
||||
/deepseek-ai-dsh-tool-subagent/understand-the-implementation/result-acknowledgement:
|
||||
en: 3c2d70d479be8e38
|
||||
zh: 9aebdb72223a086e
|
||||
|
||||
@@ -94,7 +94,7 @@ One instance is one provider plus one tool name. The plugin registers its defini
|
||||
|
||||
### Activation ownership
|
||||
|
||||
The tool calls `ctx.subagents.startActivation()` with parent delivery selected. The runtime owns startup cancellation, execution, outcome reporting, and cleanup. A startup failure is an errored tool result; failures after publication arrive through the completion notice, with diagnostics and partial output preserved by the runtime.
|
||||
The tool calls `ctx.subagents.startActivation()` with parent delivery selected. The runtime owns startup cancellation, execution, outcome reporting, and cleanup. A startup failure is an errored tool result. Rejections before startup are coded: a missing calling Agent, `llm` service, or effective parent route throws `ToolContextUnavailableError`; an empty or unpaired route field throws `ToolArgsError`; and `SubagentError` reports a disabled selection (`MODEL_SELECTION_DISABLED`, `PRESET_SELECTION_DISABLED`), a preset outside the allowlist (`PRESET_NOT_ALLOWED`), a route the Session does not authorize (`MODEL_ROUTE_NOT_ALLOWED`), an LLM provider unknown to discovery (`LLM_PROVIDER_NOT_FOUND`), or a provider replaced during route preflight (`PROVIDER_CHANGED`). Failures after publication arrive through the completion notice, with diagnostics and partial output preserved by the runtime.
|
||||
|
||||
### Result acknowledgement
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ kind: "package-reference"
|
||||
|
||||
### Activation 所有权
|
||||
|
||||
工具调用 `ctx.subagents.startActivation()`,并选择向父任务交付。运行时拥有启动取消、执行、结果汇报与清理。启动失败产生出错的工具结果;发布后的失败通过完成通知到达,运行时保留诊断和部分输出。
|
||||
工具调用 `ctx.subagents.startActivation()`,并选择向父任务交付。运行时拥有启动取消、执行、结果汇报与清理。启动失败产生出错的工具结果。启动前的拒绝都带 code:缺少调用方 Agent、`llm` 服务或有效的父级路由时抛出 `ToolContextUnavailableError`;路由字段为空或未成对提供时抛出 `ToolArgsError`;`SubagentError` 报告选择被禁用(`MODEL_SELECTION_DISABLED`、`PRESET_SELECTION_DISABLED`)、preset 不在允许列表中(`PRESET_NOT_ALLOWED`)、会话未授权该路由(`MODEL_ROUTE_NOT_ALLOWED`)、发现查询的 LLM 提供方未注册(`LLM_PROVIDER_NOT_FOUND`),或路由预检期间提供方被替换(`PROVIDER_CHANGED`)。发布后的失败通过完成通知到达,运行时保留诊断和部分输出。
|
||||
|
||||
### 结果确认
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
import type { Context } from '@deepseek-ai/cordis'
|
||||
import z from '@deepseek-ai/schemastery'
|
||||
import type {} from '@deepseek-ai/dsh-agent-preset-registry'
|
||||
import { defineTool } from '@deepseek-ai/dsh-tools'
|
||||
import { defineTool, ToolContextUnavailableError } from '@deepseek-ai/dsh-tools'
|
||||
import type { ToolDefinition } from '@deepseek-ai/dsh-tools'
|
||||
import type { AgentOptions } from '@deepseek-ai/dsh-agent'
|
||||
import type { ReasoningEffortId } from '@deepseek-ai/dsh-llm/brand'
|
||||
@@ -18,6 +18,7 @@ import {
|
||||
assertSubagentMaxDepth,
|
||||
delegationDepthOf,
|
||||
parentAgentOptionsForDelegation,
|
||||
SubagentError,
|
||||
} from '@deepseek-ai/dsh-subagent'
|
||||
import type { SubagentProvider } from '@deepseek-ai/dsh-subagent'
|
||||
import {
|
||||
@@ -275,7 +276,7 @@ export async function apply(ctx: Context, config: Config): Promise<void> {
|
||||
const parent = exec.agent
|
||||
if (!parent) {
|
||||
// Non-agent callers provide no parent for delegation ownership.
|
||||
throw new Error('subagent tool requires a calling agent (exec.agent was undefined)')
|
||||
throw new ToolContextUnavailableError('subagent tool requires a calling agent (exec.agent was undefined)')
|
||||
}
|
||||
|
||||
const routes = subagentModelSelectionPolicy(subagentModelSelectionProjectionHandle, parent.session)
|
||||
@@ -298,7 +299,7 @@ export async function apply(ctx: Context, config: Config): Promise<void> {
|
||||
if (requiresRoutePreflight) {
|
||||
const llm = ctx.get('llm')
|
||||
if (llm === undefined) {
|
||||
throw new Error('cannot resolve the selected child LLM route because the `llm` service is unavailable')
|
||||
throw new ToolContextUnavailableError('cannot resolve the selected child LLM route because the `llm` service is unavailable')
|
||||
}
|
||||
const inheritParentReasoningEffort = providerRouteDefaults === undefined && !hasDelegationModelRequest(modelRequest)
|
||||
await preflightChildLlmRoute(
|
||||
@@ -309,7 +310,10 @@ export async function apply(ctx: Context, config: Config): Promise<void> {
|
||||
inheritParentReasoningEffort,
|
||||
)
|
||||
if (ctx.subagents.getProvider(config.provider) !== subagentProvider) {
|
||||
throw new Error(`subagent provider "${config.provider}" changed while resolving the child LLM route; retry the delegation`)
|
||||
throw new SubagentError(
|
||||
`subagent provider "${config.provider}" changed while resolving the child LLM route; retry the delegation`,
|
||||
'PROVIDER_CHANGED',
|
||||
)
|
||||
}
|
||||
}
|
||||
exec.signal.throwIfAborted()
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
import type { Context } from '@deepseek-ai/cordis'
|
||||
import type LlmRuntime from '@deepseek-ai/dsh-llm'
|
||||
import type { LlmProviderInfo } from '@deepseek-ai/dsh-llm'
|
||||
import { defineTool } from '@deepseek-ai/dsh-tools'
|
||||
import { parentAgentOptionsForDelegation } from '@deepseek-ai/dsh-subagent'
|
||||
import { defineTool, ToolArgsError, ToolContextUnavailableError } from '@deepseek-ai/dsh-tools'
|
||||
import { parentAgentOptionsForDelegation, SubagentError } from '@deepseek-ai/dsh-subagent'
|
||||
import type { ToolRunContext } from '@deepseek-ai/dsh-tools'
|
||||
import type { ProjectionHandle } from '@deepseek-ai/dsh-session-projection'
|
||||
import type { AllowedModelRoute, ModelSelectionPolicy } from './model-selection.ts'
|
||||
@@ -28,7 +28,7 @@ function registeredProvider(
|
||||
.filter(candidate => policy.routes.some(route => route.provider === candidate.id))
|
||||
.map(candidate => candidate.id)
|
||||
.join(', ') || '(none)'
|
||||
throw new Error(`LLM provider "${providerId}" is not registered; available providers: ${available}`)
|
||||
throw new SubagentError(`LLM provider "${providerId}" is not registered; available providers: ${available}`, 'LLM_PROVIDER_NOT_FOUND')
|
||||
}
|
||||
|
||||
/** Render one advertised or resolved model. */
|
||||
@@ -43,24 +43,24 @@ async function listSubagentModels(
|
||||
request: ListSubagentModelsRequest,
|
||||
exec: ToolRunContext,
|
||||
): Promise<string> {
|
||||
if (exec.agent === undefined) throw new Error('list_subagent_models requires a calling agent')
|
||||
if (exec.agent === undefined) throw new ToolContextUnavailableError('list_subagent_models requires a calling agent')
|
||||
const routes = subagentModelSelectionPolicy(policyHandle, exec.agent.session)
|
||||
let policy = routes === undefined ? undefined : { routes }
|
||||
const selectionEnabled = policy !== undefined
|
||||
if (policy === undefined) {
|
||||
const { provider, model } = parentAgentOptionsForDelegation(exec.agent)
|
||||
if (provider === undefined || model === undefined) {
|
||||
throw new Error('cannot discover child LLM routes without a parent provider and model')
|
||||
throw new ToolContextUnavailableError('cannot discover child LLM routes without a parent provider and model')
|
||||
}
|
||||
policy = { routes: [{ provider, model }] }
|
||||
}
|
||||
const { signal } = exec
|
||||
const llm = ctx.get('llm')
|
||||
if (llm === undefined) {
|
||||
throw new Error('cannot discover child LLM routes because the `llm` service is unavailable')
|
||||
throw new ToolContextUnavailableError('cannot discover child LLM routes because the `llm` service is unavailable')
|
||||
}
|
||||
if (request.model !== undefined && request.provider === undefined) {
|
||||
throw new Error('`model` requires `provider`')
|
||||
throw new ToolArgsError(['`model` requires `provider`'])
|
||||
}
|
||||
if (request.provider === undefined) {
|
||||
const providers = llm.listProviders()
|
||||
@@ -69,11 +69,11 @@ async function listSubagentModels(
|
||||
? '(no LLM providers)'
|
||||
: providers.map(provider => `${provider.id} — ${provider.name}`).join('\n')
|
||||
}
|
||||
if (request.provider.length === 0) throw new Error('`provider` must be non-empty')
|
||||
if (request.provider.length === 0) throw new ToolArgsError(['`provider` must be non-empty'])
|
||||
const allowedRoutes = policy.routes.filter(route => route.provider === request.provider)
|
||||
const [firstRoute] = allowedRoutes
|
||||
if (firstRoute === undefined) {
|
||||
throw new Error(`LLM provider "${request.provider}" is not allowed for this Session`)
|
||||
throw new SubagentError(`LLM provider "${request.provider}" is not allowed for this Session`, 'MODEL_ROUTE_NOT_ALLOWED')
|
||||
}
|
||||
const provider = registeredProvider(llm, policy, request.provider)
|
||||
if (request.model === undefined) {
|
||||
@@ -85,9 +85,9 @@ async function listSubagentModels(
|
||||
? `(no advertised models for ${provider.id})`
|
||||
: models.map(model => modelLine(provider.id, model)).join('\n')
|
||||
}
|
||||
if (request.model.length === 0) throw new Error('`model` must be non-empty')
|
||||
if (request.model.length === 0) throw new ToolArgsError(['`model` must be non-empty'])
|
||||
if (!allowedRoutes.some(route => route.model === request.model)) {
|
||||
throw new Error(`child LLM route "${provider.id}/${request.model}" is not allowed for this Session`)
|
||||
throw new SubagentError(`child LLM route "${provider.id}/${request.model}" is not allowed for this Session`, 'MODEL_ROUTE_NOT_ALLOWED')
|
||||
}
|
||||
const model = await llm.resolveModelInfo(provider.id, request.model, signal)
|
||||
const efforts = model.reasoning?.efforts.map(effort => (
|
||||
|
||||
@@ -4,6 +4,8 @@ import { brandString } from '@deepseek-ai/dsh-brand'
|
||||
import type { ReasoningEffortId } from '@deepseek-ai/dsh-llm/brand'
|
||||
import type { LlmRuntime } from '@deepseek-ai/dsh-llm'
|
||||
import type { AgentOptions } from '@deepseek-ai/dsh-agent'
|
||||
import { SubagentError } from '@deepseek-ai/dsh-subagent'
|
||||
import { ToolArgsError, ToolContextUnavailableError } from '@deepseek-ai/dsh-tools'
|
||||
import z from '@deepseek-ai/schemastery'
|
||||
|
||||
/** One exact child LLM route authorized by a user setting. */
|
||||
@@ -83,7 +85,7 @@ export function hasDelegationModelRequest(request: DelegationModelRequest): bool
|
||||
/** Reject an empty model-facing route value at the tool JSON boundary. */
|
||||
function assertNonEmpty(value: string | undefined, field: keyof DelegationModelRequest): void {
|
||||
if (value !== undefined && value.length === 0) {
|
||||
throw new Error(`child LLM \`${field}\` must be non-empty`)
|
||||
throw new ToolArgsError([`child LLM \`${field}\` must be non-empty`])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,6 +99,9 @@ function assertNonEmpty(value: string | undefined, field: keyof DelegationModelR
|
||||
* @param policy - Session allowlist; omission permits only the current parent route.
|
||||
* @param parentOptions - Current parent route used when no policy is recorded.
|
||||
* @returns Child Agent options, preserving omission when no layer contributes one.
|
||||
* @throws {SubagentError} `MODEL_SELECTION_DISABLED` when this tool instance
|
||||
* forbids selection, or `MODEL_ROUTE_NOT_ALLOWED` when the Session does not allow the route.
|
||||
* @throws {ToolArgsError} when a field is empty or `provider` and `model` are not supplied together.
|
||||
*/
|
||||
export function requestedAgentOptions(
|
||||
configured: AgentOptions | undefined,
|
||||
@@ -107,15 +112,15 @@ export function requestedAgentOptions(
|
||||
): AgentOptions | undefined {
|
||||
if (!hasDelegationModelRequest(request)) return configured
|
||||
if (!enabled) {
|
||||
throw new Error('child model selection is disabled for this tool instance')
|
||||
throw new SubagentError('child model selection is disabled for this tool instance', 'MODEL_SELECTION_DISABLED')
|
||||
}
|
||||
assertNonEmpty(request.provider, 'provider')
|
||||
assertNonEmpty(request.model, 'model')
|
||||
assertNonEmpty(request.reasoning_effort, 'reasoning_effort')
|
||||
if (request.provider === undefined || request.model === undefined) {
|
||||
throw new Error(request.reasoning_effort === undefined
|
||||
throw new ToolArgsError([request.reasoning_effort === undefined
|
||||
? 'child LLM `provider` and `model` must be supplied together'
|
||||
: 'child LLM `reasoning_effort` requires both `provider` and `model`; supply both or omit all three fields')
|
||||
: 'child LLM `reasoning_effort` requires both `provider` and `model`; supply both or omit all three fields'])
|
||||
}
|
||||
|
||||
assertAllowedModelSelection(policy, parentOptions, { provider: request.provider, model: request.model })
|
||||
@@ -133,6 +138,7 @@ export function requestedAgentOptions(
|
||||
* @param policy - Session allowlist; omission permits only the current parent route.
|
||||
* @param parentOptions - Current parent route used when no policy is recorded.
|
||||
* @param route - Validated provider/model pair from the tool call.
|
||||
* @throws {SubagentError} `MODEL_ROUTE_NOT_ALLOWED` when the Session does not allow the route.
|
||||
*/
|
||||
export function assertAllowedModelSelection(
|
||||
policy: ModelSelectionPolicy | undefined,
|
||||
@@ -144,10 +150,10 @@ export function assertAllowedModelSelection(
|
||||
? provider === parentOptions.provider && model === parentOptions.model
|
||||
: policy.routes.some(route => route.provider === provider && route.model === model)
|
||||
if (allowed) return
|
||||
throw new Error(`child LLM route "${provider}/${model}" is not allowed for this Session`
|
||||
throw new SubagentError(`child LLM route "${provider}/${model}" is not allowed for this Session`
|
||||
+ (policy === undefined
|
||||
? '; without a recorded model-selection policy, explicit selection is limited to the parent route'
|
||||
: ''))
|
||||
: ''), 'MODEL_ROUTE_NOT_ALLOWED')
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -181,7 +187,7 @@ export async function preflightChildLlmRoute(
|
||||
const provider = requested?.provider ?? parentOptions.provider
|
||||
const model = requested?.model ?? parentOptions.model
|
||||
if (provider === undefined || model === undefined) {
|
||||
throw new Error('cannot select child LLM values without an effective provider and model')
|
||||
throw new ToolContextUnavailableError('cannot select child LLM values without an effective provider and model')
|
||||
}
|
||||
const routeChanged = provider !== parentOptions.provider || model !== parentOptions.model
|
||||
const reasoningEffort = requested?.reasoningEffort
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
/** Deployment-owned preset choices for one delegation tool. */
|
||||
import { SubagentError } from '@deepseek-ai/dsh-subagent'
|
||||
import type { SubagentProvider } from '@deepseek-ai/dsh-subagent'
|
||||
|
||||
/** Optional default and model-selectable preset ids for a spawn tool. */
|
||||
@@ -59,13 +60,17 @@ export class SubagentPresetSelection {
|
||||
* Validate model input and apply the deployment default.
|
||||
* @param request - Model-supplied tool arguments.
|
||||
* @returns Selected preset id, or omission to inherit the parent.
|
||||
* @throws {SubagentError} `PRESET_SELECTION_DISABLED` when this tool exposes no
|
||||
* preset choice, or `PRESET_NOT_ALLOWED` when the id is outside the allowlist.
|
||||
*/
|
||||
resolve(request: PresetSelectionRequest): string | undefined {
|
||||
const id = request.agent_preset
|
||||
if (id === undefined) return this.config.agentPreset
|
||||
if (this.choices === undefined) throw new Error('agent_preset selection is disabled for this tool instance')
|
||||
if (this.choices === undefined) {
|
||||
throw new SubagentError('agent_preset selection is disabled for this tool instance', 'PRESET_SELECTION_DISABLED')
|
||||
}
|
||||
if (typeof id !== 'string' || !this.choices.includes(id)) {
|
||||
throw new Error(`agent_preset must be one of: ${this.choices.join(', ')}`)
|
||||
throw new SubagentError(`agent_preset must be one of: ${this.choices.join(', ')}`, 'PRESET_NOT_ALLOWED')
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
@@ -177,7 +177,9 @@ describe('list_subagent_models', () => {
|
||||
await mountWorkingDirectoryFixture(ctx)
|
||||
await ctx.plugin(SubagentRuntime)
|
||||
await ctx.plugin(tool, { provider: 'unused', modelDiscovery: true })
|
||||
expect(text(await call(ctx, {}))).toContain('requires a calling agent')
|
||||
const agentless = await call(ctx, {})
|
||||
expect(text(agentless)).toContain('requires a calling agent')
|
||||
expect(agentless.error?.info).toEqual({ name: 'ToolContextUnavailableError', code: 'TOOL_CONTEXT_UNAVAILABLE' })
|
||||
await ctx.fiber.dispose()
|
||||
|
||||
const parentContext = await setup({ provider: 'mock', withModelSelection: true, hostSelectionEnabled: false })
|
||||
@@ -188,6 +190,7 @@ describe('list_subagent_models', () => {
|
||||
})
|
||||
expect(result.isError).toBe(true)
|
||||
expect(text(result)).toContain('without a parent provider and model')
|
||||
expect(result.error?.info).toEqual({ name: 'ToolContextUnavailableError', code: 'TOOL_CONTEXT_UNAVAILABLE' })
|
||||
})
|
||||
|
||||
it('reads the recorded Session allowlist through the delegation plugin', async () => {
|
||||
@@ -217,6 +220,7 @@ describe('list_subagent_models', () => {
|
||||
const result = await call(ctx, {})
|
||||
expect(result.isError).toBe(true)
|
||||
expect(text(result)).toContain('`llm` service is unavailable')
|
||||
expect(result.error?.info).toEqual({ name: 'ToolContextUnavailableError', code: 'TOOL_CONTEXT_UNAVAILABLE' })
|
||||
})
|
||||
|
||||
it('lists registered providers and follows live registration changes', async () => {
|
||||
@@ -259,6 +263,7 @@ describe('list_subagent_models', () => {
|
||||
const denied = await call(ctx, { provider: 'alpha', model: 'plain' })
|
||||
expect(denied.isError).toBe(true)
|
||||
expect(text(denied)).toContain('is not allowed for this Session')
|
||||
expect(denied.error?.info).toEqual({ name: 'SubagentError', code: 'MODEL_ROUTE_NOT_ALLOWED' })
|
||||
})
|
||||
|
||||
it('rejects an unauthorized provider before calling its adapter catalog', async () => {
|
||||
@@ -271,6 +276,7 @@ describe('list_subagent_models', () => {
|
||||
|
||||
expect(result.isError).toBe(true)
|
||||
expect(text(result)).toContain('provider "secret" is not allowed for this Session')
|
||||
expect(result.error?.info).toEqual({ name: 'SubagentError', code: 'MODEL_ROUTE_NOT_ALLOWED' })
|
||||
expect(listModels).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
@@ -376,14 +382,15 @@ describe('list_subagent_models', () => {
|
||||
})
|
||||
|
||||
it.each([
|
||||
{ args: { model: 'fast' }, expected: '`model` requires `provider`' },
|
||||
{ args: { provider: '' }, expected: '`provider` must be non-empty' },
|
||||
{ args: { provider: 'missing' }, expected: 'is not allowed for this Session' },
|
||||
])('rejects incomplete or unavailable provider requests', async ({ args, expected }) => {
|
||||
{ args: { model: 'fast' }, expected: '`model` requires `provider`', info: { name: 'ToolArgsError', code: 'INVALID_ARGS' } },
|
||||
{ args: { provider: '' }, expected: '`provider` must be non-empty', info: { name: 'ToolArgsError', code: 'INVALID_ARGS' } },
|
||||
{ args: { provider: 'missing' }, expected: 'is not allowed for this Session', info: { name: 'SubagentError', code: 'MODEL_ROUTE_NOT_ALLOWED' } },
|
||||
])('rejects incomplete or unavailable provider requests', async ({ args, expected, info }) => {
|
||||
const ctx = await setupListTool()
|
||||
const result = await call(ctx, args)
|
||||
expect(result.isError).toBe(true)
|
||||
expect(text(result)).toContain(expected)
|
||||
expect(result.error?.info).toEqual(info)
|
||||
})
|
||||
|
||||
it('rejects an empty exact model after resolving the provider', async () => {
|
||||
@@ -392,6 +399,7 @@ describe('list_subagent_models', () => {
|
||||
const result = await call(ctx, { provider: 'alpha', model: '' })
|
||||
expect(result.isError).toBe(true)
|
||||
expect(text(result)).toContain('`model` must be non-empty')
|
||||
expect(result.error?.info).toEqual({ name: 'ToolArgsError', code: 'INVALID_ARGS' })
|
||||
})
|
||||
|
||||
it('reports registered alternatives for an unavailable provider', async () => {
|
||||
@@ -403,6 +411,7 @@ describe('list_subagent_models', () => {
|
||||
const result = await call(ctx, { provider: 'missing' })
|
||||
expect(result.isError).toBe(true)
|
||||
expect(text(result)).toContain('available providers: alpha')
|
||||
expect(result.error?.info).toEqual({ name: 'SubagentError', code: 'LLM_PROVIDER_NOT_FOUND' })
|
||||
expect(text(result)).not.toContain('secret')
|
||||
})
|
||||
|
||||
@@ -411,5 +420,6 @@ describe('list_subagent_models', () => {
|
||||
const result = await call(ctx, { provider: 'missing' })
|
||||
expect(result.isError).toBe(true)
|
||||
expect(text(result)).toContain('available providers: (none)')
|
||||
expect(result.error?.info).toEqual({ name: 'SubagentError', code: 'LLM_PROVIDER_NOT_FOUND' })
|
||||
})
|
||||
})
|
||||
@@ -286,6 +286,7 @@ describe('SubagentModelSelectionConfig', () => {
|
||||
|
||||
expect(result.isError).toBe(true)
|
||||
expect(text(result)).toContain('is not allowed for this Session')
|
||||
expect(result.error?.info).toEqual({ name: 'SubagentError', code: 'MODEL_ROUTE_NOT_ALLOWED' })
|
||||
await ctx.fiber.dispose()
|
||||
})
|
||||
|
||||
|
||||
@@ -120,6 +120,7 @@ describe('dsh-tool-subagent model selection', () => {
|
||||
})
|
||||
expect(result.isError).toBe(true)
|
||||
expect(text(result)).toContain('model selection is disabled for this tool instance')
|
||||
expect(result.error?.info).toEqual({ name: 'SubagentError', code: 'MODEL_SELECTION_DISABLED' })
|
||||
})
|
||||
|
||||
it('hides and rejects route fields without modelSelection', async () => {
|
||||
@@ -137,6 +138,7 @@ describe('dsh-tool-subagent model selection', () => {
|
||||
const result = await callSubagent(ctx, { description: 'forced route', prompt: 'do it', ...selection })
|
||||
expect(result.isError).toBe(true)
|
||||
expect(text(result)).toContain('child model selection is disabled for this tool instance')
|
||||
expect(result.error?.info).toEqual({ name: 'SubagentError', code: 'MODEL_SELECTION_DISABLED' })
|
||||
}
|
||||
})
|
||||
|
||||
@@ -174,6 +176,7 @@ describe('dsh-tool-subagent model selection', () => {
|
||||
})
|
||||
expect(result.isError).toBe(true)
|
||||
expect(text(result)).toContain('`reasoning_effort` requires both `provider` and `model`')
|
||||
expect(result.error?.info).toEqual({ name: 'ToolArgsError', code: 'INVALID_ARGS' })
|
||||
expect(start).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
@@ -200,6 +203,7 @@ describe('dsh-tool-subagent model selection', () => {
|
||||
})
|
||||
expect(result.isError).toBe(true)
|
||||
expect(text(result)).toContain('is not allowed for this Session')
|
||||
expect(result.error?.info).toEqual({ name: 'SubagentError', code: 'MODEL_ROUTE_NOT_ALLOWED' })
|
||||
})
|
||||
|
||||
it('discovers only the parent route without a Session policy and permits its explicit route and effort', async () => {
|
||||
@@ -404,12 +408,17 @@ describe('dsh-tool-subagent model selection', () => {
|
||||
})
|
||||
expect(result.isError).toBe(true)
|
||||
expect(text(result)).toContain('`reasoning_effort` requires both `provider` and `model`')
|
||||
expect(result.error?.info).toEqual({ name: 'ToolArgsError', code: 'INVALID_ARGS' })
|
||||
})
|
||||
|
||||
it('rejects preflight without an effective provider and model', async () => {
|
||||
const ctx = await setup({ provider: 'mock' })
|
||||
await expect(preflightChildLlmRoute(ctx.llm, {}, undefined, AbortSignal.abort()))
|
||||
.rejects.toThrow('without an effective provider and model')
|
||||
.rejects.toMatchObject({
|
||||
name: 'ToolContextUnavailableError',
|
||||
code: 'TOOL_CONTEXT_UNAVAILABLE',
|
||||
message: 'cannot select child LLM values without an effective provider and model',
|
||||
})
|
||||
})
|
||||
|
||||
it.each([
|
||||
@@ -421,6 +430,7 @@ describe('dsh-tool-subagent model selection', () => {
|
||||
const result = await callSubagent(ctx, { description: 'partial route', prompt: 'do it', ...route })
|
||||
expect(result.isError).toBe(true)
|
||||
expect(text(result)).toContain('`provider` and `model` must be supplied together')
|
||||
expect(result.error?.info).toEqual({ name: 'ToolArgsError', code: 'INVALID_ARGS' })
|
||||
expect(starts).toBe(0)
|
||||
})
|
||||
|
||||
@@ -433,6 +443,7 @@ describe('dsh-tool-subagent model selection', () => {
|
||||
const result = await callSubagent(ctx, { description: 'empty route', prompt: 'do it', ...selection })
|
||||
expect(result.isError).toBe(true)
|
||||
expect(text(result)).toContain(expected)
|
||||
expect(result.error?.info).toEqual({ name: 'ToolArgsError', code: 'INVALID_ARGS' })
|
||||
})
|
||||
|
||||
it('uses the LLM runtime for provider and reasoning-effort validation before child creation', async () => {
|
||||
@@ -525,6 +536,7 @@ describe('dsh-tool-subagent model selection', () => {
|
||||
const configured = await callSubagent(ctx, { description: 'configured effort', prompt: 'do it' }, { agent: parentWithRoute() })
|
||||
expect(configured.isError).toBe(true)
|
||||
expect(text(configured)).toContain('`llm` service is unavailable')
|
||||
expect(configured.error?.info).toEqual({ name: 'ToolContextUnavailableError', code: 'TOOL_CONTEXT_UNAVAILABLE' })
|
||||
|
||||
})
|
||||
|
||||
@@ -567,6 +579,7 @@ describe('dsh-tool-subagent model selection', () => {
|
||||
})
|
||||
expect(denied.isError).toBe(true)
|
||||
expect(text(denied)).toContain('is not allowed for this Session')
|
||||
expect(denied.error?.info).toEqual({ name: 'SubagentError', code: 'MODEL_ROUTE_NOT_ALLOWED' })
|
||||
|
||||
const invalidEffort = await callSubagent(ctx, {
|
||||
description: 'unsupported effort', prompt: 'do it', provider: 'alpha', model: 'fast-model', reasoning_effort: 'invalid',
|
||||
@@ -600,6 +613,7 @@ describe('dsh-tool-subagent model selection', () => {
|
||||
const result = await callSubagent(ctx, { description: 'fork work', prompt: 'do it', ...selection })
|
||||
expect(result.isError).toBe(true)
|
||||
expect(text(result)).toContain('model selection is disabled for this tool instance')
|
||||
expect(result.error?.info).toEqual({ name: 'SubagentError', code: 'MODEL_SELECTION_DISABLED' })
|
||||
}
|
||||
expect(started).not.toHaveBeenCalled()
|
||||
|
||||
|
||||
@@ -99,6 +99,7 @@ describe('spawn preset selection', () => {
|
||||
const forced = await callSubagent(ctx, { ...args, agent_preset: 'writer' })
|
||||
expect(forced.isError).toBe(true)
|
||||
expect(text(forced)).toContain('selection is disabled')
|
||||
expect(forced.error?.info).toEqual({ name: 'SubagentError', code: 'PRESET_SELECTION_DISABLED' })
|
||||
expect(onStart).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
@@ -135,8 +136,13 @@ describe('spawn preset selection', () => {
|
||||
|
||||
it('rejects forced selection at the model JSON resolver', () => {
|
||||
const selection = new SubagentPresetSelection({ allowedAgentPresets: ['writer'] })
|
||||
expect(() => selection.resolve({ agent_preset: 'unlisted' })).toThrow(/must be one of/)
|
||||
expect(() => selection.resolve({ agent_preset: 1 })).toThrow(/must be one of/)
|
||||
for (const agent_preset of ['unlisted', 1]) {
|
||||
expect(() => selection.resolve({ agent_preset })).toThrow(expect.objectContaining({
|
||||
name: 'SubagentError',
|
||||
code: 'PRESET_NOT_ALLOWED',
|
||||
message: 'agent_preset must be one of: writer',
|
||||
}))
|
||||
}
|
||||
})
|
||||
|
||||
it('requires the preset service when selection is configured', async () => {
|
||||
@@ -157,6 +163,7 @@ describe('spawn preset selection', () => {
|
||||
const result = await callSubagent(ctx, { ...args, ...selection }, { agent: parent.agent })
|
||||
expect(result.isError).toBe(true)
|
||||
expect(text(result)).toContain('Unknown agent preset: absent')
|
||||
expect(result.error?.info).toEqual({ name: 'RemoteError', code: 'agent-preset/not-found' })
|
||||
expect(ctx.agents.list()).toEqual([parent.agent])
|
||||
expect(ctx.sessions.list()).toEqual(sessions)
|
||||
})
|
||||
@@ -174,6 +181,7 @@ describe('spawn preset selection', () => {
|
||||
const result = await callSubagent(ctx, args, { agent: parent.agent })
|
||||
expect(result.isError).toBe(true)
|
||||
expect(text(result)).toContain('missing-plugin')
|
||||
expect(result.error?.info).toEqual({ name: 'RemoteError', code: 'agent-preset/invalid' })
|
||||
expect(ctx.agents.list()).toEqual([parent.agent])
|
||||
expect(ctx.sessions.list()).toEqual(sessions)
|
||||
})
|
||||
@@ -358,6 +366,7 @@ describe('spawn preset selection', () => {
|
||||
const failed = await callSubagent(ctx, args, { agent: handle.agent })
|
||||
expect(failed.isError).toBe(true)
|
||||
expect(text(failed)).toContain('Unknown agent preset: later')
|
||||
expect(failed.error?.info).toEqual({ name: 'RemoteError', code: 'agent-preset/not-found' })
|
||||
|
||||
await ctx.agentPresets.register({ id: 'later', plugins: [] })
|
||||
ctx.llm.registerAdapter(['mock'], new MockAdapter([textResponse('reviewed')]))
|
||||
|
||||
@@ -243,6 +243,7 @@ describe('dsh-tool-subagent', () => {
|
||||
const result = await pending
|
||||
expect(result.isError).toBe(true)
|
||||
expect(text(result)).toContain('changed while resolving the child LLM route')
|
||||
expect(result.error?.info).toEqual({ name: 'SubagentError', code: 'PROVIDER_CHANGED' })
|
||||
expect(oldStart).not.toHaveBeenCalled()
|
||||
expect(replacementStart).not.toHaveBeenCalled()
|
||||
})
|
||||
@@ -343,6 +344,7 @@ describe('dsh-tool-subagent', () => {
|
||||
const result = await callSubagent(ctx, { description: 'd', prompt: 'p' }, { agent: undefined })
|
||||
expect(result.isError).toBe(true)
|
||||
expect(text(result)).toContain('requires a calling agent')
|
||||
expect(result.error?.info).toEqual({ name: 'ToolContextUnavailableError', code: 'TOOL_CONTEXT_UNAVAILABLE' })
|
||||
})
|
||||
|
||||
it('registers when the provider appears LATER — no load-order requirement (Loader starts siblings concurrently)', async () => {
|
||||
|
||||
@@ -66,8 +66,8 @@
|
||||
en: a8baf51f2fcd6d49
|
||||
zh: 357c8db36823fe0e
|
||||
/deepseek-ai-dsh-agent-team/understand-the-implementation/browser-projection:
|
||||
en: ed33e64ea55d2b75
|
||||
zh: eb326025ff156dea
|
||||
en: 1f8e19f2c73b1cf5
|
||||
zh: 1e535d354ad47c08
|
||||
/deepseek-ai-dsh-agent-team/further-exploration:
|
||||
en: 60d969ec526f5556
|
||||
zh: ed4f813006f86215
|
||||
|
||||
@@ -147,7 +147,7 @@ Unloading the service unregisters the projection. The retained handle remains re
|
||||
|
||||
### Browser projection
|
||||
|
||||
The `agentTeam` projection publishes non-deleted task views and any failure beside the last valid state. Historical roster and mailbox records cannot cause a task-board projection failure. A failed projection rejects task reads and mutations without appending task events. Mode selections can still be saved and applied, including disabling Team; the projection failure remains visible. Invalid mode payloads retain the last valid selection and publish a projection failure. The [subsystem reference](../../../docs/subsystems/agent-team.md#web-projection) defines the wire types.
|
||||
The `agentTeam` projection publishes non-deleted task views and any failure beside the last valid state. Historical roster and mailbox records cannot cause a task-board projection failure. A failed projection rejects task reads and mutations with `TeamError` `TEAM_STATE_CORRUPT` without appending task events. Mode selections can still be saved and applied, including disabling Team; the projection failure remains visible. Invalid mode payloads retain the last valid selection and publish a projection failure. The [subsystem reference](../../../docs/subsystems/agent-team.md#web-projection) defines the wire types.
|
||||
|
||||
The [Web UI](../../client/ui-agent-team/README.md) displays tasks only. Ordinary subagent navigation owns the member list; task owner labels display the owner's full name, or its Session id when the owner has no name.
|
||||
|
||||
|
||||
@@ -147,7 +147,7 @@ Team 在激活前要求 `sessionPersistence` 可用。`Service.init` 等待 `age
|
||||
|
||||
### 浏览器投影
|
||||
|
||||
`agentTeam` 投影发布未删除任务视图,并在最后有效状态旁报告失败。历史名册与邮箱记录不会导致任务板投影失败。投影失败后,任务读取和修改均报错,不再追加任务事件。模式选择仍可保存并生效,包括关闭 Team;投影错误持续可见。无效模式载荷保留最后有效选择,并发布投影错误。[子系统参考](../../../docs/subsystems/agent-team.zh.md#web-projection)定义线上的类型。
|
||||
`agentTeam` 投影发布未删除任务视图,并在最后有效状态旁报告失败。历史名册与邮箱记录不会导致任务板投影失败。投影失败后,任务读取和修改均以 `TeamError` `TEAM_STATE_CORRUPT` 报错,不再追加任务事件。模式选择仍可保存并生效,包括关闭 Team;投影错误持续可见。无效模式载荷保留最后有效选择,并发布投影错误。[子系统参考](../../../docs/subsystems/agent-team.zh.md#web-projection)定义线上的类型。
|
||||
|
||||
[Web UI](../../client/ui-agent-team/README.zh.md)仅展示任务。普通 subagent 导航负责成员列表;任务所有者标签显示所有者的完整名称,所有者没有名称时显示其 Session id。
|
||||
|
||||
|
||||
@@ -28,11 +28,11 @@ export class TeamJournal {
|
||||
* Read authoritative Team state for one exact live Lead.
|
||||
* @param root - exact live Team Lead.
|
||||
* @returns current projected state selected by the Lead Team id.
|
||||
* @throws when the durable Team projection has failed.
|
||||
* @throws {TeamError} `TEAM_STATE_CORRUPT` when the durable Team projection has failed.
|
||||
*/
|
||||
state(root: Agent): TeamState {
|
||||
const projection = this.teamProjectionHandle.stateOf(root.session)
|
||||
if (projection.failure !== undefined) throw new Error(projection.failure)
|
||||
if (projection.failure !== undefined) throw new TeamError(projection.failure, 'TEAM_STATE_CORRUPT')
|
||||
return projection
|
||||
}
|
||||
|
||||
|
||||
@@ -282,10 +282,11 @@ describe('Tree-owned task boards', () => {
|
||||
status: 'pending', blockedBy: [], writeScopes: [],
|
||||
},
|
||||
})
|
||||
expect(() => ctx.agentTeams.listTasks(lead)).toThrow('must begin at revision 1')
|
||||
const corrupt = { name: 'TeamError', code: 'TEAM_STATE_CORRUPT', message: expect.stringContaining('must begin at revision 1') as string }
|
||||
expect(() => ctx.agentTeams.listTasks(lead)).toThrow(expect.objectContaining(corrupt))
|
||||
const eventCount = lead.session.snapshotEvents().length
|
||||
await expect(ctx.agentTeams.createTask(lead, { subject: 'blocked', description: 'blocked' }))
|
||||
.rejects.toThrow('must begin at revision 1')
|
||||
.rejects.toMatchObject(corrupt)
|
||||
expect(lead.session.snapshotEvents()).toHaveLength(eventCount)
|
||||
})
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import z from '@deepseek-ai/schemastery'
|
||||
import type { Agent } from '@deepseek-ai/dsh-agent'
|
||||
import { SubagentError } from '@deepseek-ai/dsh-subagent'
|
||||
import type { TeamTaskId, TeamTaskView } from '@deepseek-ai/dsh-agent-team'
|
||||
import { defineTool } from '@deepseek-ai/dsh-tools'
|
||||
import { defineTool, ToolArgsError, ToolContextUnavailableError } from '@deepseek-ai/dsh-tools'
|
||||
import type { InferValue, ValueSchemaSpec } from '@deepseek-ai/dsh-tools'
|
||||
import { brandString } from '@deepseek-ai/dsh-brand'
|
||||
|
||||
@@ -82,7 +82,7 @@ type NamedTaskView = Omit<TeamTaskView, 'ownerId' | 'ownerName'> & { readonly ow
|
||||
/** Recover the exact caller guaranteed by conditional Team-tool discovery. */
|
||||
function callingAgent(agent: Agent | undefined, toolName: string): Agent {
|
||||
/* v8 ignore next 2 -- The Team condition rejects callers without an Agent before execution. */
|
||||
if (agent === undefined) throw new Error(`${toolName} requires a calling Agent`)
|
||||
if (agent === undefined) throw new ToolContextUnavailableError(`${toolName} requires a calling Agent`)
|
||||
return agent
|
||||
}
|
||||
|
||||
@@ -161,10 +161,10 @@ export function apply(ctx: Context, config: Config = {}): void {
|
||||
async execute(args, exec) {
|
||||
const cursor = args.cursor ?? 0
|
||||
const limit = args.limit ?? 50
|
||||
if (!Number.isSafeInteger(cursor) || cursor < 0) throw new Error('cursor must be a non-negative safe integer')
|
||||
if (!Number.isSafeInteger(limit) || limit < 1 || limit > 100) throw new Error('limit must be an integer from 1 through 100')
|
||||
if (!Number.isSafeInteger(cursor) || cursor < 0) throw new ToolArgsError(['cursor must be a non-negative safe integer'])
|
||||
if (!Number.isSafeInteger(limit) || limit < 1 || limit > 100) throw new ToolArgsError(['limit must be an integer from 1 through 100'])
|
||||
const caller = callingAgent(exec.agent, 'team_task_list')
|
||||
if (args.owner !== undefined && args.unowned !== undefined) throw new Error('owner and unowned filters cannot be combined')
|
||||
if (args.owner !== undefined && args.unowned !== undefined) throw new ToolArgsError(['owner and unowned filters cannot be combined'])
|
||||
const owner = args.owner === undefined
|
||||
? undefined
|
||||
: await ctx.subagents.resolveName(caller, args.owner, exec.signal)
|
||||
|
||||
@@ -537,8 +537,8 @@ describe('dsh-tool-team', () => {
|
||||
expect(JSON.parse(text(await execute(ctx, lead, 'team_task_list', {
|
||||
cursor: 1,
|
||||
})))).not.toHaveProperty('nextCursor')
|
||||
expect((await execute(ctx, lead, 'team_task_list', { cursor: -1 })).isError).toBe(true)
|
||||
expect((await execute(ctx, lead, 'team_task_list', { limit: 101 })).isError).toBe(true)
|
||||
expect(await execute(ctx, lead, 'team_task_list', { cursor: -1 })).toMatchObject({ isError: true, error: { info: { name: 'ToolArgsError', code: 'INVALID_ARGS' } } })
|
||||
expect(await execute(ctx, lead, 'team_task_list', { limit: 101 })).toMatchObject({ isError: true, error: { info: { name: 'ToolArgsError', code: 'INVALID_ARGS' } } })
|
||||
|
||||
const edited = await execute(ctx, lead, 'team_task_update', {
|
||||
task_id: first.id,
|
||||
@@ -596,7 +596,7 @@ describe('dsh-tool-team', () => {
|
||||
expect(JSON.parse(text(await execute(ctx, lead, 'team_task_list', { owner: 'unowned' })))).toMatchObject({ tasks: [{ id: assigned.id }] })
|
||||
expect(JSON.parse(text(await execute(ctx, lead, 'team_task_list', { unowned: true })))).toMatchObject({ tasks: [{ id: pending.id }] })
|
||||
expect(JSON.parse(text(await execute(ctx, lead, 'team_task_list', { unowned: false })))).toMatchObject({ tasks: [{ id: assigned.id }] })
|
||||
expect((await execute(ctx, lead, 'team_task_list', { owner: 'unowned', unowned: true })).isError).toBe(true)
|
||||
expect(await execute(ctx, lead, 'team_task_list', { owner: 'unowned', unowned: true })).toMatchObject({ isError: true, error: { info: { name: 'ToolArgsError', code: 'INVALID_ARGS' } } })
|
||||
await child.dispose()
|
||||
})
|
||||
|
||||
@@ -1034,7 +1034,7 @@ describe('dsh-tool-team', () => {
|
||||
|
||||
it.each([
|
||||
new Error('root lookup failed'),
|
||||
new SubagentError('root lookup failed', 'INTERNAL_FAILURE'),
|
||||
new SubagentError('root lookup failed', 'CONTINUATION_UNAVAILABLE'),
|
||||
])('propagates unexpected identity lookup failures: %s', async (failure) => {
|
||||
const { ctx, lead } = await setup([])
|
||||
vi.spyOn(ctx.subagents, 'rootOf').mockImplementation(() => { throw failure })
|
||||
|
||||
@@ -15,6 +15,7 @@ const protocolPath = resolve(root, 'packages/typert/protocol/src/types.ts')
|
||||
const proxyPath = resolve(import.meta.dirname, '../src/remote-proxy.ts')
|
||||
const protocolEntry = resolve(import.meta.dirname, '__remote_protocol.d.ts')
|
||||
const brandEntry = resolve(root, 'packages/util/brand/src/index.ts')
|
||||
const errorEntry = resolve(root, 'packages/util/error/src/index.ts')
|
||||
const cordisEntry = resolve(import.meta.dirname, '__remote_cordis.d.ts')
|
||||
|
||||
function modulePath(path: string): string {
|
||||
@@ -42,6 +43,7 @@ function compile(source: string, artifact?: string) {
|
||||
paths: {
|
||||
'@deepseek-ai/cordis': [cordisEntry],
|
||||
'@deepseek-ai/dsh-brand': [brandEntry],
|
||||
'@deepseek-ai/dsh-error': [errorEntry],
|
||||
'@deepseek-ai/dsh-typert-protocol': [protocolEntry],
|
||||
'@deepseek-ai/fixture/remote': [artifactPath],
|
||||
},
|
||||
|
||||
@@ -69,8 +69,8 @@
|
||||
en: 9717b983b6a857e3
|
||||
zh: 611a2dadf7c0c706
|
||||
/deepseek-ai-dsh-tool-todo/model-experience/tool-call-history-and-result/what-the-model-sees:
|
||||
en: 05644654d1bce8c6
|
||||
zh: ea2a42470fbb2ee1
|
||||
en: 98dbd1d31d6179af
|
||||
zh: cd899d7c4ab9f2be
|
||||
/deepseek-ai-dsh-tool-todo/model-experience/tool-call-history-and-result/token-effect:
|
||||
en: 7763a0e875faf53d
|
||||
zh: fe33c3973215dc53
|
||||
|
||||
Loaded 100 of 133 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user