@namzu/sdk 31.1.0 → 33.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +188 -0
- package/dist/agents/ReactiveAgent.d.ts.map +1 -1
- package/dist/agents/ReactiveAgent.js +4 -0
- package/dist/agents/ReactiveAgent.js.map +1 -1
- package/dist/agents/SupervisorAgent.d.ts.map +1 -1
- package/dist/agents/SupervisorAgent.js +4 -0
- package/dist/agents/SupervisorAgent.js.map +1 -1
- package/dist/agents/runAgent.d.ts +4 -0
- package/dist/agents/runAgent.d.ts.map +1 -1
- package/dist/agents/runAgent.js +4 -0
- package/dist/agents/runAgent.js.map +1 -1
- package/dist/authorization/gate.d.ts +1 -1
- package/dist/authorization/gate.js +1 -1
- package/dist/connector/index.d.ts +1 -1
- package/dist/connector/index.d.ts.map +1 -1
- package/dist/connector/index.js +1 -1
- package/dist/connector/index.js.map +1 -1
- package/dist/connector/mcp/adapter.d.ts.map +1 -1
- package/dist/connector/mcp/adapter.js +71 -16
- package/dist/connector/mcp/adapter.js.map +1 -1
- package/dist/connector/mcp/client.d.ts.map +1 -1
- package/dist/connector/mcp/client.js +3 -2
- package/dist/connector/mcp/client.js.map +1 -1
- package/dist/connector/mcp/http-redirect.d.ts +17 -0
- package/dist/connector/mcp/http-redirect.d.ts.map +1 -0
- package/dist/connector/mcp/http-redirect.js +31 -0
- package/dist/connector/mcp/http-redirect.js.map +1 -0
- package/dist/connector/mcp/http-sse.d.ts.map +1 -1
- package/dist/connector/mcp/http-sse.js +5 -0
- package/dist/connector/mcp/http-sse.js.map +1 -1
- package/dist/connector/mcp/image-admission.d.ts +16 -0
- package/dist/connector/mcp/image-admission.d.ts.map +1 -0
- package/dist/connector/mcp/image-admission.js +288 -0
- package/dist/connector/mcp/image-admission.js.map +1 -0
- package/dist/connector/mcp/stdio.d.ts +13 -0
- package/dist/connector/mcp/stdio.d.ts.map +1 -1
- package/dist/connector/mcp/stdio.js +66 -23
- package/dist/connector/mcp/stdio.js.map +1 -1
- package/dist/connector/mcp/streamable-http.d.ts.map +1 -1
- package/dist/connector/mcp/streamable-http.js +3 -0
- package/dist/connector/mcp/streamable-http.js.map +1 -1
- package/dist/constants/tools/index.js +1 -1
- package/dist/constants/tools/index.js.map +1 -1
- package/dist/directory/derive-supervisor.d.ts.map +1 -1
- package/dist/directory/derive-supervisor.js +5 -0
- package/dist/directory/derive-supervisor.js.map +1 -1
- package/dist/directory/derive.d.ts.map +1 -1
- package/dist/directory/derive.js +5 -0
- package/dist/directory/derive.js.map +1 -1
- package/dist/directory/load.d.ts.map +1 -1
- package/dist/directory/load.js +1 -0
- package/dist/directory/load.js.map +1 -1
- package/dist/directory/types.d.ts +2 -0
- package/dist/directory/types.d.ts.map +1 -1
- package/dist/execution/base.d.ts +13 -0
- package/dist/execution/base.d.ts.map +1 -1
- package/dist/execution/base.js +103 -8
- package/dist/execution/base.js.map +1 -1
- package/dist/execution/code-runtime/types.d.ts +11 -1
- package/dist/execution/code-runtime/types.d.ts.map +1 -1
- package/dist/execution/code-runtime/types.js.map +1 -1
- package/dist/execution/code-runtime/worker.d.ts.map +1 -1
- package/dist/execution/code-runtime/worker.js +67 -9
- package/dist/execution/code-runtime/worker.js.map +1 -1
- package/dist/execution/errors.d.ts +12 -0
- package/dist/execution/errors.d.ts.map +1 -0
- package/dist/execution/errors.js +21 -0
- package/dist/execution/errors.js.map +1 -0
- package/dist/execution/factory.d.ts.map +1 -1
- package/dist/execution/factory.js +1 -0
- package/dist/execution/factory.js.map +1 -1
- package/dist/execution/hybrid.d.ts +5 -0
- package/dist/execution/hybrid.d.ts.map +1 -1
- package/dist/execution/hybrid.js +36 -16
- package/dist/execution/hybrid.js.map +1 -1
- package/dist/execution/index.d.ts +1 -0
- package/dist/execution/index.d.ts.map +1 -1
- package/dist/execution/index.js +1 -0
- package/dist/execution/index.js.map +1 -1
- package/dist/execution/local.d.ts +13 -0
- package/dist/execution/local.d.ts.map +1 -1
- package/dist/execution/local.js +145 -19
- package/dist/execution/local.js.map +1 -1
- package/dist/execution/output.d.ts +27 -0
- package/dist/execution/output.d.ts.map +1 -0
- package/dist/execution/output.js +105 -0
- package/dist/execution/output.js.map +1 -0
- package/dist/execution/remote.d.ts +26 -2
- package/dist/execution/remote.d.ts.map +1 -1
- package/dist/execution/remote.js +86 -15
- package/dist/execution/remote.js.map +1 -1
- package/dist/manager/agent/lifecycle.d.ts.map +1 -1
- package/dist/manager/agent/lifecycle.js +1 -0
- package/dist/manager/agent/lifecycle.js.map +1 -1
- package/dist/plugin/lifecycle.d.ts.map +1 -1
- package/dist/plugin/lifecycle.js +9 -3
- package/dist/plugin/lifecycle.js.map +1 -1
- package/dist/process/kill-tree.d.ts +11 -13
- package/dist/process/kill-tree.d.ts.map +1 -1
- package/dist/process/kill-tree.js +11 -13
- package/dist/process/kill-tree.js.map +1 -1
- package/dist/provider/errors.d.ts +1 -0
- package/dist/provider/errors.d.ts.map +1 -1
- package/dist/provider/errors.js +39 -1
- package/dist/provider/errors.js.map +1 -1
- package/dist/provider/fallback.d.ts.map +1 -1
- package/dist/provider/fallback.js +31 -0
- package/dist/provider/fallback.js.map +1 -1
- package/dist/provider/idle-timeout.d.ts.map +1 -1
- package/dist/provider/idle-timeout.js +5 -0
- package/dist/provider/idle-timeout.js.map +1 -1
- package/dist/provider/retry.d.ts.map +1 -1
- package/dist/provider/retry.js +5 -0
- package/dist/provider/retry.js.map +1 -1
- package/dist/public-runtime.d.ts +7 -5
- package/dist/public-runtime.d.ts.map +1 -1
- package/dist/public-runtime.js +9 -4
- package/dist/public-runtime.js.map +1 -1
- package/dist/public-types.d.ts +2 -1
- package/dist/public-types.d.ts.map +1 -1
- package/dist/registry/tool/execute.d.ts +7 -1
- package/dist/registry/tool/execute.d.ts.map +1 -1
- package/dist/registry/tool/execute.js +201 -54
- package/dist/registry/tool/execute.js.map +1 -1
- package/dist/run/command-gate.d.ts.map +1 -1
- package/dist/run/command-gate.js +11 -0
- package/dist/run/command-gate.js.map +1 -1
- package/dist/run/reporter.d.ts.map +1 -1
- package/dist/run/reporter.js +6 -1
- package/dist/run/reporter.js.map +1 -1
- package/dist/run/workspace-fingerprint.d.ts +4 -4
- package/dist/run/workspace-fingerprint.d.ts.map +1 -1
- package/dist/run/workspace-fingerprint.js +6 -4
- package/dist/run/workspace-fingerprint.js.map +1 -1
- package/dist/runtime/bidi/index.d.ts +1 -1
- package/dist/runtime/bidi/index.d.ts.map +1 -1
- package/dist/runtime/bidi/index.js +1 -1
- package/dist/runtime/bidi/index.js.map +1 -1
- package/dist/runtime/bidi/session.d.ts +19 -0
- package/dist/runtime/bidi/session.d.ts.map +1 -1
- package/dist/runtime/bidi/session.js +150 -26
- package/dist/runtime/bidi/session.js.map +1 -1
- package/dist/runtime/query/executor.d.ts +43 -1
- package/dist/runtime/query/executor.d.ts.map +1 -1
- package/dist/runtime/query/executor.js +824 -174
- package/dist/runtime/query/executor.js.map +1 -1
- package/dist/runtime/query/index.d.ts +5 -0
- package/dist/runtime/query/index.d.ts.map +1 -1
- package/dist/runtime/query/index.js +47 -4
- package/dist/runtime/query/index.js.map +1 -1
- package/dist/runtime/query/iteration/index.d.ts +1 -0
- package/dist/runtime/query/iteration/index.d.ts.map +1 -1
- package/dist/runtime/query/iteration/index.js +34 -14
- package/dist/runtime/query/iteration/index.js.map +1 -1
- package/dist/runtime/query/iteration/phases/advisory.js +2 -2
- package/dist/runtime/query/iteration/phases/advisory.js.map +1 -1
- package/dist/runtime/query/iteration/phases/tool-review.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/tool-review.js +84 -22
- package/dist/runtime/query/iteration/phases/tool-review.js.map +1 -1
- package/dist/runtime/query/iteration/provider-rejected-image.d.ts +13 -0
- package/dist/runtime/query/iteration/provider-rejected-image.d.ts.map +1 -0
- package/dist/runtime/query/iteration/provider-rejected-image.js +91 -0
- package/dist/runtime/query/iteration/provider-rejected-image.js.map +1 -0
- package/dist/runtime/query/iteration/stream-turn.d.ts +4 -1
- package/dist/runtime/query/iteration/stream-turn.d.ts.map +1 -1
- package/dist/runtime/query/iteration/stream-turn.js +7 -3
- package/dist/runtime/query/iteration/stream-turn.js.map +1 -1
- package/dist/runtime/query/request-rich-content.d.ts +13 -0
- package/dist/runtime/query/request-rich-content.d.ts.map +1 -1
- package/dist/runtime/query/request-rich-content.js +173 -17
- package/dist/runtime/query/request-rich-content.js.map +1 -1
- package/dist/runtime/query/result.d.ts.map +1 -1
- package/dist/runtime/query/result.js +1 -0
- package/dist/runtime/query/result.js.map +1 -1
- package/dist/runtime/query/resume-pending.d.ts +5 -1
- package/dist/runtime/query/resume-pending.d.ts.map +1 -1
- package/dist/runtime/query/resume-pending.js +66 -1
- package/dist/runtime/query/resume-pending.js.map +1 -1
- package/dist/runtime/query/tool-output-budget.d.ts.map +1 -1
- package/dist/runtime/query/tool-output-budget.js +45 -16
- package/dist/runtime/query/tool-output-budget.js.map +1 -1
- package/dist/runtime/query/tooling.d.ts +6 -0
- package/dist/runtime/query/tooling.d.ts.map +1 -1
- package/dist/runtime/query/tooling.js +4 -0
- package/dist/runtime/query/tooling.js.map +1 -1
- package/dist/sandbox/provider/local.d.ts.map +1 -1
- package/dist/sandbox/provider/local.js +193 -41
- package/dist/sandbox/provider/local.js.map +1 -1
- package/dist/scheduler/delegating.d.ts +2 -1
- package/dist/scheduler/delegating.d.ts.map +1 -1
- package/dist/scheduler/delegating.js +6 -5
- package/dist/scheduler/delegating.js.map +1 -1
- package/dist/scheduler/local.d.ts +2 -1
- package/dist/scheduler/local.d.ts.map +1 -1
- package/dist/scheduler/local.js +2 -2
- package/dist/scheduler/local.js.map +1 -1
- package/dist/session/workspace/driver.d.ts +12 -4
- package/dist/session/workspace/driver.d.ts.map +1 -1
- package/dist/session/workspace/git-worktree.d.ts +17 -3
- package/dist/session/workspace/git-worktree.d.ts.map +1 -1
- package/dist/session/workspace/git-worktree.js +153 -34
- package/dist/session/workspace/git-worktree.js.map +1 -1
- package/dist/skills/registry.d.ts +15 -0
- package/dist/skills/registry.d.ts.map +1 -1
- package/dist/skills/registry.js +33 -0
- package/dist/skills/registry.js.map +1 -1
- package/dist/store/attachment/index.d.ts +24 -2
- package/dist/store/attachment/index.d.ts.map +1 -1
- package/dist/store/attachment/index.js +52 -5
- package/dist/store/attachment/index.js.map +1 -1
- package/dist/tools/builtins/computer-use.d.ts.map +1 -1
- package/dist/tools/builtins/computer-use.js +39 -2
- package/dist/tools/builtins/computer-use.js.map +1 -1
- package/dist/tools/builtins/lsp.d.ts +1 -1
- package/dist/tools/builtins/run-code.d.ts.map +1 -1
- package/dist/tools/builtins/run-code.js +24 -16
- package/dist/tools/builtins/run-code.js.map +1 -1
- package/dist/tools/builtins/skill.d.ts +2 -1
- package/dist/tools/builtins/skill.d.ts.map +1 -1
- package/dist/tools/builtins/skill.js +250 -6
- package/dist/tools/builtins/skill.js.map +1 -1
- package/dist/tools/coordinator/agent.d.ts.map +1 -1
- package/dist/tools/coordinator/agent.js +100 -30
- package/dist/tools/coordinator/agent.js.map +1 -1
- package/dist/types/agent/base.d.ts +4 -0
- package/dist/types/agent/base.d.ts.map +1 -1
- package/dist/types/agent/factory.d.ts +1 -0
- package/dist/types/agent/factory.d.ts.map +1 -1
- package/dist/types/agent/manager.d.ts +1 -1
- package/dist/types/agent/manager.d.ts.map +1 -1
- package/dist/types/agent/scheduler.d.ts +10 -1
- package/dist/types/agent/scheduler.d.ts.map +1 -1
- package/dist/types/authorization/index.d.ts +12 -12
- package/dist/types/bidi/index.d.ts +19 -2
- package/dist/types/bidi/index.d.ts.map +1 -1
- package/dist/types/computer-use/index.d.ts +18 -0
- package/dist/types/computer-use/index.d.ts.map +1 -1
- package/dist/types/connector/execution-context.d.ts +3 -1
- package/dist/types/connector/execution-context.d.ts.map +1 -1
- package/dist/types/execution/index.d.ts +43 -1
- package/dist/types/execution/index.d.ts.map +1 -1
- package/dist/types/hitl/index.d.ts +11 -0
- package/dist/types/hitl/index.d.ts.map +1 -1
- package/dist/types/hitl/index.js.map +1 -1
- package/dist/types/message/index.d.ts +31 -1
- package/dist/types/message/index.d.ts.map +1 -1
- package/dist/types/message/index.js +43 -0
- package/dist/types/message/index.js.map +1 -1
- package/dist/types/plugin/index.d.ts +14 -1
- package/dist/types/plugin/index.d.ts.map +1 -1
- package/dist/types/plugin/index.js +1 -0
- package/dist/types/plugin/index.js.map +1 -1
- package/dist/types/provider/error.d.ts +4 -1
- package/dist/types/provider/error.d.ts.map +1 -1
- package/dist/types/provider/interface.d.ts +14 -0
- package/dist/types/provider/interface.d.ts.map +1 -1
- package/dist/types/run/events.d.ts +10 -2
- package/dist/types/run/events.d.ts.map +1 -1
- package/dist/types/run/events.js.map +1 -1
- package/dist/types/sandbox/index.d.ts +15 -10
- package/dist/types/sandbox/index.d.ts.map +1 -1
- package/dist/types/sandbox/index.js.map +1 -1
- package/dist/types/tool/index.d.ts +129 -12
- package/dist/types/tool/index.d.ts.map +1 -1
- package/dist/types/tool/index.js.map +1 -1
- package/dist/types/workspace/ref.d.ts +5 -0
- package/dist/types/workspace/ref.d.ts.map +1 -1
- package/dist/utils/abort.d.ts +8 -0
- package/dist/utils/abort.d.ts.map +1 -1
- package/dist/utils/abort.js +16 -0
- package/dist/utils/abort.js.map +1 -1
- package/package.json +4 -4
- package/src/agents/ReactiveAgent.ts +4 -0
- package/src/agents/SupervisorAgent.ts +4 -0
- package/src/agents/runAgent.ts +8 -0
- package/src/authorization/gate.ts +1 -1
- package/src/connector/index.ts +2 -0
- package/src/connector/mcp/adapter.ts +82 -21
- package/src/connector/mcp/client.ts +2 -1
- package/src/connector/mcp/http-redirect.ts +32 -0
- package/src/connector/mcp/http-sse.ts +5 -0
- package/src/connector/mcp/image-admission.ts +272 -0
- package/src/connector/mcp/stdio.ts +63 -21
- package/src/connector/mcp/streamable-http.ts +3 -0
- package/src/constants/tools/index.ts +1 -1
- package/src/directory/derive-supervisor.ts +5 -0
- package/src/directory/derive.ts +5 -0
- package/src/directory/load.ts +1 -0
- package/src/directory/types.ts +2 -0
- package/src/execution/base.ts +124 -7
- package/src/execution/code-runtime/types.ts +15 -1
- package/src/execution/code-runtime/worker.ts +72 -9
- package/src/execution/errors.ts +24 -0
- package/src/execution/factory.ts +1 -0
- package/src/execution/hybrid.ts +47 -16
- package/src/execution/index.ts +1 -0
- package/src/execution/local.ts +164 -19
- package/src/execution/output.ts +104 -0
- package/src/execution/remote.ts +122 -17
- package/src/manager/agent/lifecycle.ts +1 -0
- package/src/plugin/lifecycle.ts +9 -3
- package/src/process/kill-tree.ts +11 -13
- package/src/provider/errors.ts +40 -1
- package/src/provider/fallback.ts +39 -0
- package/src/provider/idle-timeout.ts +8 -0
- package/src/provider/retry.ts +8 -0
- package/src/public-runtime.ts +23 -2
- package/src/public-types.ts +11 -0
- package/src/registry/tool/execute.ts +230 -64
- package/src/run/command-gate.ts +12 -0
- package/src/run/reporter.ts +7 -1
- package/src/run/workspace-fingerprint.ts +5 -4
- package/src/runtime/bidi/index.ts +1 -1
- package/src/runtime/bidi/session.ts +177 -28
- package/src/runtime/query/executor.ts +987 -172
- package/src/runtime/query/index.ts +59 -6
- package/src/runtime/query/iteration/index.ts +69 -29
- package/src/runtime/query/iteration/phases/advisory.ts +2 -2
- package/src/runtime/query/iteration/phases/tool-review.ts +87 -23
- package/src/runtime/query/iteration/provider-rejected-image.ts +106 -0
- package/src/runtime/query/iteration/stream-turn.ts +12 -2
- package/src/runtime/query/request-rich-content.ts +213 -15
- package/src/runtime/query/result.ts +1 -0
- package/src/runtime/query/resume-pending.ts +83 -1
- package/src/runtime/query/tool-output-budget.ts +52 -17
- package/src/runtime/query/tooling.ts +10 -0
- package/src/sandbox/provider/local.ts +213 -45
- package/src/scheduler/delegating.ts +6 -5
- package/src/scheduler/local.ts +3 -2
- package/src/session/workspace/driver.ts +12 -4
- package/src/session/workspace/git-worktree.ts +173 -34
- package/src/skills/registry.ts +47 -0
- package/src/store/attachment/index.ts +100 -15
- package/src/tools/builtins/computer-use.ts +45 -2
- package/src/tools/builtins/run-code.ts +24 -16
- package/src/tools/builtins/skill.ts +325 -7
- package/src/tools/coordinator/agent.ts +108 -33
- package/src/types/agent/base.ts +4 -0
- package/src/types/agent/factory.ts +1 -0
- package/src/types/agent/manager.ts +1 -1
- package/src/types/agent/scheduler.ts +10 -1
- package/src/types/bidi/index.ts +19 -2
- package/src/types/computer-use/index.ts +19 -0
- package/src/types/connector/execution-context.ts +3 -0
- package/src/types/execution/index.ts +46 -1
- package/src/types/hitl/index.ts +11 -0
- package/src/types/message/index.ts +78 -1
- package/src/types/plugin/index.ts +15 -0
- package/src/types/provider/error.ts +4 -1
- package/src/types/provider/interface.ts +18 -0
- package/src/types/run/events.ts +18 -4
- package/src/types/sandbox/index.ts +15 -10
- package/src/types/tool/index.ts +159 -15
- package/src/types/workspace/ref.ts +5 -0
- package/src/utils/abort.ts +18 -0
package/src/types/tool/index.ts
CHANGED
|
@@ -26,6 +26,32 @@ export interface ToolRegistryRef {
|
|
|
26
26
|
* filesystem imports into every consumer's type graph.
|
|
27
27
|
*/
|
|
28
28
|
export interface SkillRegistryRef {
|
|
29
|
+
/**
|
|
30
|
+
* Enumerate the metadata the model may use to discover a skill.
|
|
31
|
+
*
|
|
32
|
+
* Optional so an older structural registry that only supports named loads
|
|
33
|
+
* remains a valid host. `SkillTool` refuses its list mode when this member is
|
|
34
|
+
* absent: `names()` cannot distinguish a model skill from an operator-only
|
|
35
|
+
* one, so treating it as a safe catalog would disclose an authority boundary.
|
|
36
|
+
*/
|
|
37
|
+
catalog?():
|
|
38
|
+
| readonly {
|
|
39
|
+
/** The name the registry accepts, which may be namespaced by its host. */
|
|
40
|
+
registeredName: string
|
|
41
|
+
description: string
|
|
42
|
+
location: string
|
|
43
|
+
allowedTools?: string
|
|
44
|
+
invocation?: 'model' | 'operator' | 'both'
|
|
45
|
+
}[]
|
|
46
|
+
| Promise<
|
|
47
|
+
readonly {
|
|
48
|
+
registeredName: string
|
|
49
|
+
description: string
|
|
50
|
+
location: string
|
|
51
|
+
allowedTools?: string
|
|
52
|
+
invocation?: 'model' | 'operator' | 'both'
|
|
53
|
+
}[]
|
|
54
|
+
>
|
|
29
55
|
/**
|
|
30
56
|
* Load a skill's full body, or `undefined` for a name nobody registered.
|
|
31
57
|
*
|
|
@@ -68,7 +94,10 @@ export interface SkillRegistryRef {
|
|
|
68
94
|
* outlives, or is billed to, somebody else's run.
|
|
69
95
|
*/
|
|
70
96
|
export interface BackgroundJobRegistryRef {
|
|
71
|
-
start(params: { command: string; workingDirectory: string }): {
|
|
97
|
+
start(params: { command: string; workingDirectory: string }): {
|
|
98
|
+
id: string
|
|
99
|
+
status: string
|
|
100
|
+
}
|
|
72
101
|
get(id: string): { id: string; status: string; exitCode?: number }
|
|
73
102
|
read(
|
|
74
103
|
id: string,
|
|
@@ -158,6 +187,39 @@ export type ToolPauseOutcome =
|
|
|
158
187
|
|
|
159
188
|
export type RequestToolPause = (request: ToolPauseRequest) => Promise<ToolPauseOutcome>
|
|
160
189
|
|
|
190
|
+
/**
|
|
191
|
+
* Where one tool execution entered the runtime from.
|
|
192
|
+
*
|
|
193
|
+
* The executor owns this value. A nested caller supplies only its private
|
|
194
|
+
* operation context to {@link ToolContext.dispatchTool}; the executor derives
|
|
195
|
+
* the parent id from the context it already issued, so a tool cannot relabel
|
|
196
|
+
* itself as somebody else's child.
|
|
197
|
+
*/
|
|
198
|
+
export type ToolCallSource =
|
|
199
|
+
| { readonly kind: 'direct' }
|
|
200
|
+
| { readonly kind: 'nested'; readonly parentToolUseId: string }
|
|
201
|
+
| {
|
|
202
|
+
readonly kind: 'code'
|
|
203
|
+
readonly parentToolUseId: string
|
|
204
|
+
/** The code runtime's id, unique within the parent program. */
|
|
205
|
+
readonly runtimeToolCallId: string
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Operation authority a trusted tool may narrow when it dispatches another
|
|
210
|
+
* tool.
|
|
211
|
+
*
|
|
212
|
+
* `signal` is fused with the parent call's signal; it can revoke authority
|
|
213
|
+
* earlier but can never extend the parent's lifetime. `runtimeToolCallId`
|
|
214
|
+
* identifies one request inside a model-authored program. The executor still
|
|
215
|
+
* chooses the child's event identity and the parent lineage; durable pause
|
|
216
|
+
* ownership stays with the model-issued ancestor present in the checkpoint.
|
|
217
|
+
*/
|
|
218
|
+
export interface ToolDispatchOptions {
|
|
219
|
+
readonly signal?: AbortSignal
|
|
220
|
+
readonly runtimeToolCallId?: string
|
|
221
|
+
}
|
|
222
|
+
|
|
161
223
|
export interface ToolContext {
|
|
162
224
|
runId: RunId
|
|
163
225
|
workingDirectory: string
|
|
@@ -242,7 +304,11 @@ export interface ToolContext {
|
|
|
242
304
|
}>
|
|
243
305
|
}
|
|
244
306
|
readonly search?: {
|
|
245
|
-
search(request: {
|
|
307
|
+
search(request: {
|
|
308
|
+
query: string
|
|
309
|
+
limit?: number
|
|
310
|
+
signal?: AbortSignal
|
|
311
|
+
}): Promise<{
|
|
246
312
|
query: string
|
|
247
313
|
hits: readonly { title: string; url: string; snippet?: string }[]
|
|
248
314
|
}>
|
|
@@ -257,7 +323,20 @@ export interface ToolContext {
|
|
|
257
323
|
* the next batch — a skill loaded alongside other calls must not
|
|
258
324
|
* retroactively refuse them.
|
|
259
325
|
*/
|
|
260
|
-
adoptSkillScope?: (scope: {
|
|
326
|
+
adoptSkillScope?: (scope: {
|
|
327
|
+
skill: string
|
|
328
|
+
allowedTools: readonly string[]
|
|
329
|
+
}) => void
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Effective model-visible character cap for this tool result.
|
|
333
|
+
*
|
|
334
|
+
* Present on executor-owned calls so a tool that can paginate does so
|
|
335
|
+
* before the generic head+tail fallback loses its middle. `0` means the
|
|
336
|
+
* host disabled the cap; absent means a direct host invocation did not
|
|
337
|
+
* declare one.
|
|
338
|
+
*/
|
|
339
|
+
maxToolOutputChars?: number
|
|
261
340
|
|
|
262
341
|
/**
|
|
263
342
|
* Run another tool through the same dispatch this call came through.
|
|
@@ -268,14 +347,23 @@ export interface ToolContext {
|
|
|
268
347
|
* a property of holding a registry reference rather than a capability a
|
|
269
348
|
* host wired deliberately.
|
|
270
349
|
*
|
|
271
|
-
* Available
|
|
272
|
-
*
|
|
273
|
-
*
|
|
274
|
-
*
|
|
275
|
-
*
|
|
276
|
-
*
|
|
350
|
+
* Available only for this invocation. The executor closes it when the
|
|
351
|
+
* visible call settles or is abandoned, aborts calls already started by
|
|
352
|
+
* it, and waits for their executor-owned terminal records before reporting
|
|
353
|
+
* the parent complete. Retaining the function does not retain authority.
|
|
354
|
+
*
|
|
355
|
+
* Tools are host-installed code — the model cannot add one — so the trust
|
|
356
|
+
* boundary this protects is the MODEL's reach. `allowedTools` is enforced
|
|
357
|
+
* again at dispatch. When the run has an operator authorization gate, a
|
|
358
|
+
* nested call must be explicitly allowed by that gate; a deny or an
|
|
359
|
+
* undecided call fails closed because another durable human review cannot
|
|
360
|
+
* be opened from inside the already-executing parent.
|
|
277
361
|
*/
|
|
278
|
-
dispatchTool?: (
|
|
362
|
+
dispatchTool?: (
|
|
363
|
+
name: string,
|
|
364
|
+
input: unknown,
|
|
365
|
+
options?: ToolDispatchOptions,
|
|
366
|
+
) => Promise<ToolResult>
|
|
279
367
|
|
|
280
368
|
/**
|
|
281
369
|
* The `tool_use_id` of the assistant block that triggered this
|
|
@@ -287,6 +375,14 @@ export interface ToolContext {
|
|
|
287
375
|
*/
|
|
288
376
|
toolUseId?: string
|
|
289
377
|
|
|
378
|
+
/**
|
|
379
|
+
* How this execution entered the tool registry.
|
|
380
|
+
*
|
|
381
|
+
* Present on executor-owned calls. Optional because a host may invoke a
|
|
382
|
+
* tool directly outside a run and construct its own minimal context.
|
|
383
|
+
*/
|
|
384
|
+
source?: ToolCallSource
|
|
385
|
+
|
|
290
386
|
/**
|
|
291
387
|
* Raise a durable pause and wait for a human to resolve it.
|
|
292
388
|
*
|
|
@@ -335,10 +431,16 @@ export interface ToolContext {
|
|
|
335
431
|
* timed out.
|
|
336
432
|
*
|
|
337
433
|
* Fire-and-forget and never throws, so a tool can call it freely
|
|
338
|
-
* without wrapping it.
|
|
339
|
-
*
|
|
340
|
-
*
|
|
341
|
-
*
|
|
434
|
+
* without wrapping it. This is latest state, not a log: while a host is
|
|
435
|
+
* consuming one update, later calls replace the single pending update.
|
|
436
|
+
* Each published message is capped at 8 KiB of UTF-8 with a visible
|
|
437
|
+
* omission marker, and every accepted update settles before that call's
|
|
438
|
+
* terminal event. Put complete output in `ToolResult`, not here.
|
|
439
|
+
*
|
|
440
|
+
* The model never sees these: progress answers "is it still working?",
|
|
441
|
+
* which is a question only a human asks, and putting it in the
|
|
442
|
+
* conversation would spend tokens telling the model something it cannot
|
|
443
|
+
* act on.
|
|
342
444
|
*
|
|
343
445
|
* Absent when the executing surface has no event stream to write to.
|
|
344
446
|
*/
|
|
@@ -587,6 +689,27 @@ export interface ToolExecutionResult extends ToolResult {
|
|
|
587
689
|
permissionMessage?: string
|
|
588
690
|
}
|
|
589
691
|
|
|
692
|
+
/**
|
|
693
|
+
* An input decoded exactly once by its owning tool registry.
|
|
694
|
+
*
|
|
695
|
+
* `input` is the detached, deeply frozen JSON review projection:
|
|
696
|
+
* authorization, approval UI, probes and audit all inspect this value. The
|
|
697
|
+
* registry privately retains a separate detached copy that
|
|
698
|
+
* {@link ToolRegistryContract.executePrepared} gives the tool. Caller-owned
|
|
699
|
+
* aliases therefore cannot change either side after preparation. A
|
|
700
|
+
* preparation is registry-owned and cannot be executed by a different
|
|
701
|
+
* registry or after that tool registration is replaced.
|
|
702
|
+
*/
|
|
703
|
+
export interface PreparedToolExecution {
|
|
704
|
+
readonly toolName: string
|
|
705
|
+
readonly input: unknown
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
/** Result of decoding a tool input at the execution boundary. */
|
|
709
|
+
export type ToolPreparationResult =
|
|
710
|
+
| { readonly success: true; readonly prepared: PreparedToolExecution }
|
|
711
|
+
| { readonly success: false; readonly result: ToolExecutionResult }
|
|
712
|
+
|
|
590
713
|
/**
|
|
591
714
|
* Full tool registry contract — registration, lookup, execution, prompt generation.
|
|
592
715
|
* Concrete implementation: `ToolRegistry` in `registry/tool/execute.ts`.
|
|
@@ -614,6 +737,23 @@ export interface ToolRegistryContract {
|
|
|
614
737
|
searchDeferred(query: string): ToolDefinition[]
|
|
615
738
|
getCallableTools(toolNames?: string[]): ToolDefinition[]
|
|
616
739
|
|
|
740
|
+
/**
|
|
741
|
+
* Decode/transform an input once, before authorization or human review.
|
|
742
|
+
*
|
|
743
|
+
* The returned preparation is opaque registry authority. Implementations
|
|
744
|
+
* must not run tool code here. They must detach both the executable value
|
|
745
|
+
* and `prepared.input` from caller/schema aliases, and make the latter a
|
|
746
|
+
* deeply immutable JSON projection of the exact value retained for
|
|
747
|
+
* execution. Unsupported mutable/exotic graphs fail closed.
|
|
748
|
+
*/
|
|
749
|
+
prepareExecution(toolName: string, rawInput: unknown): ToolPreparationResult
|
|
750
|
+
|
|
751
|
+
/** Execute the exact value retained by `prepareExecution`, without parsing again. */
|
|
752
|
+
executePrepared(
|
|
753
|
+
prepared: PreparedToolExecution,
|
|
754
|
+
context: ToolContext,
|
|
755
|
+
): Promise<ToolExecutionResult>
|
|
756
|
+
|
|
617
757
|
execute(toolName: string, rawInput: unknown, context: ToolContext): Promise<ToolExecutionResult>
|
|
618
758
|
|
|
619
759
|
size(): number
|
|
@@ -626,4 +766,8 @@ export interface ToolRegistryContract {
|
|
|
626
766
|
|
|
627
767
|
export * from './repair.js'
|
|
628
768
|
|
|
629
|
-
export type {
|
|
769
|
+
export type {
|
|
770
|
+
ToolCallView,
|
|
771
|
+
ToolPresentation,
|
|
772
|
+
ToolResultView,
|
|
773
|
+
} from './presentation.js'
|
|
@@ -49,6 +49,11 @@ export type WorkspaceBackendMeta = GitWorktreeBackendMeta
|
|
|
49
49
|
* "which project is this directory" across sessions and process restarts.
|
|
50
50
|
* The two words are close enough that the distinction has been rediscovered
|
|
51
51
|
* more than once; it is written here so it does not have to be again.
|
|
52
|
+
*
|
|
53
|
+
* A persisted ref is recovery data for the backend configuration that created
|
|
54
|
+
* it, not authority for another driver instance to operate on an arbitrary
|
|
55
|
+
* resource. Reference drivers validate that affiliation before inspection,
|
|
56
|
+
* branching, or disposal.
|
|
52
57
|
*/
|
|
53
58
|
export interface WorkspaceRef {
|
|
54
59
|
id: WorkspaceId
|
package/src/utils/abort.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { EventEmitter } from 'node:events'
|
|
1
2
|
import { toErrorMessage } from './error.js'
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -47,6 +48,23 @@ export function abortReasonText(reason: unknown): string | undefined {
|
|
|
47
48
|
return text.length > 0 ? text : undefined
|
|
48
49
|
}
|
|
49
50
|
|
|
51
|
+
/**
|
|
52
|
+
* Subscribe to caller cancellation without raising the Node 20.0 runtime floor.
|
|
53
|
+
*
|
|
54
|
+
* `addAbortListener` cannot be hidden by another listener calling
|
|
55
|
+
* `stopImmediatePropagation`. Both branches return an explicit disposer so a
|
|
56
|
+
* completed operation does not remain attached to a long-lived caller signal.
|
|
57
|
+
*/
|
|
58
|
+
export function subscribeToAbort(signal: AbortSignal, listener: () => void): () => void {
|
|
59
|
+
if (typeof EventEmitter.addAbortListener === 'function') {
|
|
60
|
+
const subscription = EventEmitter.addAbortListener(signal, listener)
|
|
61
|
+
return () => subscription[Symbol.dispose]()
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
signal.addEventListener('abort', listener, { once: true })
|
|
65
|
+
return () => signal.removeEventListener('abort', listener)
|
|
66
|
+
}
|
|
67
|
+
|
|
50
68
|
export function createChildAbortController(parent: AbortController): AbortController {
|
|
51
69
|
const child = new AbortController()
|
|
52
70
|
|