@namzu/sdk 3.3.0 → 5.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 +430 -0
- package/dist/agents/SupervisorAgent.d.ts.map +1 -1
- package/dist/agents/SupervisorAgent.js +58 -2
- package/dist/agents/SupervisorAgent.js.map +1 -1
- package/dist/agents/__tests__/run-agent.test.d.ts +2 -0
- package/dist/agents/__tests__/run-agent.test.d.ts.map +1 -0
- package/dist/agents/__tests__/run-agent.test.js +143 -0
- package/dist/agents/__tests__/run-agent.test.js.map +1 -0
- package/dist/agents/__tests__/supervisor-coordinator-registration.test.d.ts +2 -0
- package/dist/agents/__tests__/supervisor-coordinator-registration.test.d.ts.map +1 -0
- package/dist/agents/__tests__/supervisor-coordinator-registration.test.js +122 -0
- package/dist/agents/__tests__/supervisor-coordinator-registration.test.js.map +1 -0
- package/dist/agents/index.d.ts +2 -0
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/agents/index.js +1 -0
- package/dist/agents/index.js.map +1 -1
- package/dist/agents/runAgent.d.ts +104 -0
- package/dist/agents/runAgent.d.ts.map +1 -0
- package/dist/agents/runAgent.js +92 -0
- package/dist/agents/runAgent.js.map +1 -0
- package/dist/connector/mcp/__tests__/prompt-as-tool.test.js +1 -1
- package/dist/connector/mcp/__tests__/prompt-as-tool.test.js.map +1 -1
- package/dist/connector/mcp/prompt-adapter.d.ts.map +1 -1
- package/dist/connector/mcp/prompt-adapter.js +16 -9
- package/dist/connector/mcp/prompt-adapter.js.map +1 -1
- package/dist/provider/__tests__/thinking-support.test.d.ts +2 -0
- package/dist/provider/__tests__/thinking-support.test.d.ts.map +1 -0
- package/dist/provider/__tests__/thinking-support.test.js +47 -0
- package/dist/provider/__tests__/thinking-support.test.js.map +1 -0
- package/dist/provider/thinking-support.d.ts +30 -0
- package/dist/provider/thinking-support.d.ts.map +1 -0
- package/dist/provider/thinking-support.js +32 -0
- package/dist/provider/thinking-support.js.map +1 -0
- package/dist/public-runtime.d.ts +5 -2
- package/dist/public-runtime.d.ts.map +1 -1
- package/dist/public-runtime.js +11 -2
- package/dist/public-runtime.js.map +1 -1
- package/dist/public-tools.d.ts +2 -0
- package/dist/public-tools.d.ts.map +1 -1
- package/dist/public-tools.js +3 -0
- package/dist/public-tools.js.map +1 -1
- package/dist/public-types.d.ts +1 -1
- package/dist/public-types.d.ts.map +1 -1
- package/dist/registry/index.d.ts +1 -1
- package/dist/registry/index.d.ts.map +1 -1
- package/dist/registry/index.js +1 -1
- package/dist/registry/index.js.map +1 -1
- package/dist/registry/tool/execute.d.ts +15 -0
- package/dist/registry/tool/execute.d.ts.map +1 -1
- package/dist/registry/tool/execute.js +19 -0
- package/dist/registry/tool/execute.js.map +1 -1
- package/dist/runtime/query/__tests__/steering-reaches-the-model.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/steering-reaches-the-model.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/steering-reaches-the-model.test.js +94 -0
- package/dist/runtime/query/__tests__/steering-reaches-the-model.test.js.map +1 -0
- package/dist/runtime/query/__tests__/steering.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/steering.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/steering.test.js +92 -0
- package/dist/runtime/query/__tests__/steering.test.js.map +1 -0
- package/dist/runtime/query/index.d.ts +10 -0
- package/dist/runtime/query/index.d.ts.map +1 -1
- package/dist/runtime/query/index.js +1 -0
- package/dist/runtime/query/index.js.map +1 -1
- package/dist/runtime/query/iteration/phases/context.d.ts +8 -0
- package/dist/runtime/query/iteration/phases/context.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/context.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 +7 -1
- package/dist/runtime/query/iteration/phases/tool-review.js.map +1 -1
- package/dist/runtime/query/steering.d.ts +81 -0
- package/dist/runtime/query/steering.d.ts.map +1 -0
- package/dist/runtime/query/steering.js +77 -0
- package/dist/runtime/query/steering.js.map +1 -0
- package/dist/sandbox/__tests__/exec-cancellation.test.d.ts +2 -0
- package/dist/sandbox/__tests__/exec-cancellation.test.d.ts.map +1 -0
- package/dist/sandbox/__tests__/exec-cancellation.test.js +59 -0
- package/dist/sandbox/__tests__/exec-cancellation.test.js.map +1 -0
- package/dist/sandbox/provider/local.d.ts.map +1 -1
- package/dist/sandbox/provider/local.js +30 -5
- package/dist/sandbox/provider/local.js.map +1 -1
- package/dist/session/workspace/shared-run.d.ts +31 -0
- package/dist/session/workspace/shared-run.d.ts.map +1 -1
- package/dist/session/workspace/shared-run.js +31 -0
- package/dist/session/workspace/shared-run.js.map +1 -1
- package/dist/tools/__tests__/file-tool-containment.test.d.ts +2 -0
- package/dist/tools/__tests__/file-tool-containment.test.d.ts.map +1 -0
- package/dist/tools/__tests__/file-tool-containment.test.js +134 -0
- package/dist/tools/__tests__/file-tool-containment.test.js.map +1 -0
- package/dist/tools/__tests__/sandboxed-search.test.js +51 -0
- package/dist/tools/__tests__/sandboxed-search.test.js.map +1 -1
- package/dist/tools/__tests__/untrusted-envelope.test.d.ts +2 -0
- package/dist/tools/__tests__/untrusted-envelope.test.d.ts.map +1 -0
- package/dist/tools/__tests__/untrusted-envelope.test.js +55 -0
- package/dist/tools/__tests__/untrusted-envelope.test.js.map +1 -0
- package/dist/tools/builtins/__tests__/edit-insert-reachable.test.d.ts +2 -0
- package/dist/tools/builtins/__tests__/edit-insert-reachable.test.d.ts.map +1 -0
- package/dist/tools/builtins/__tests__/edit-insert-reachable.test.js +114 -0
- package/dist/tools/builtins/__tests__/edit-insert-reachable.test.js.map +1 -0
- package/dist/tools/builtins/__tests__/edit.test.js +9 -2
- package/dist/tools/builtins/__tests__/edit.test.js.map +1 -1
- package/dist/tools/builtins/__tests__/write-file.test.js +59 -0
- package/dist/tools/builtins/__tests__/write-file.test.js.map +1 -1
- package/dist/tools/builtins/edit.d.ts.map +1 -1
- package/dist/tools/builtins/edit.js +66 -14
- package/dist/tools/builtins/edit.js.map +1 -1
- package/dist/tools/builtins/ls.d.ts +1 -1
- package/dist/tools/builtins/ls.d.ts.map +1 -1
- package/dist/tools/builtins/ls.js +95 -0
- package/dist/tools/builtins/ls.js.map +1 -1
- package/dist/tools/builtins/read-file.d.ts.map +1 -1
- package/dist/tools/builtins/read-file.js +3 -2
- package/dist/tools/builtins/read-file.js.map +1 -1
- package/dist/tools/builtins/write-file.d.ts.map +1 -1
- package/dist/tools/builtins/write-file.js +26 -12
- package/dist/tools/builtins/write-file.js.map +1 -1
- package/dist/tools/coordinator/__tests__/agent.test.js +6 -1
- package/dist/tools/coordinator/__tests__/agent.test.js.map +1 -1
- package/dist/tools/coordinator/__tests__/ask-user-question.test.js +47 -0
- package/dist/tools/coordinator/__tests__/ask-user-question.test.js.map +1 -1
- package/dist/tools/coordinator/__tests__/empty-roster.test.d.ts +2 -0
- package/dist/tools/coordinator/__tests__/empty-roster.test.d.ts.map +1 -0
- package/dist/tools/coordinator/__tests__/empty-roster.test.js +97 -0
- package/dist/tools/coordinator/__tests__/empty-roster.test.js.map +1 -0
- package/dist/tools/coordinator/agent.d.ts +22 -8
- package/dist/tools/coordinator/agent.d.ts.map +1 -1
- package/dist/tools/coordinator/agent.js +45 -2
- package/dist/tools/coordinator/agent.js.map +1 -1
- package/dist/tools/coordinator/index.d.ts.map +1 -1
- package/dist/tools/coordinator/index.js +80 -3
- package/dist/tools/coordinator/index.js.map +1 -1
- package/dist/tools/paths.d.ts +40 -0
- package/dist/tools/paths.d.ts.map +1 -1
- package/dist/tools/paths.js +70 -1
- package/dist/tools/paths.js.map +1 -1
- package/dist/tools/untrusted-envelope.d.ts +55 -0
- package/dist/tools/untrusted-envelope.d.ts.map +1 -0
- package/dist/tools/untrusted-envelope.js +65 -0
- package/dist/tools/untrusted-envelope.js.map +1 -0
- package/dist/types/agent/manager.d.ts +11 -4
- package/dist/types/agent/manager.d.ts.map +1 -1
- package/dist/types/agent/supervisor.d.ts +9 -0
- package/dist/types/agent/supervisor.d.ts.map +1 -1
- package/dist/types/common/index.d.ts +12 -0
- package/dist/types/common/index.d.ts.map +1 -1
- package/dist/types/common/index.js +7 -0
- package/dist/types/common/index.js.map +1 -1
- package/dist/types/provider/chat.d.ts +57 -5
- package/dist/types/provider/chat.d.ts.map +1 -1
- package/dist/types/provider/index.d.ts +1 -1
- package/dist/types/provider/index.d.ts.map +1 -1
- package/dist/types/sandbox/index.d.ts +10 -0
- package/dist/types/sandbox/index.d.ts.map +1 -1
- package/dist/types/sandbox/index.js.map +1 -1
- package/dist/types/toolset/index.d.ts +0 -24
- package/dist/types/toolset/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/agents/SupervisorAgent.ts +57 -2
- package/src/agents/__tests__/run-agent.test.ts +165 -0
- package/src/agents/__tests__/supervisor-coordinator-registration.test.ts +148 -0
- package/src/agents/index.ts +2 -0
- package/src/agents/runAgent.ts +179 -0
- package/src/connector/mcp/__tests__/prompt-as-tool.test.ts +1 -1
- package/src/connector/mcp/prompt-adapter.ts +19 -9
- package/src/provider/__tests__/thinking-support.test.ts +60 -0
- package/src/provider/thinking-support.ts +37 -0
- package/src/public-runtime.ts +11 -0
- package/src/public-tools.ts +4 -0
- package/src/public-types.ts +7 -1
- package/src/registry/index.ts +1 -1
- package/src/registry/tool/execute.ts +23 -0
- package/src/runtime/query/__tests__/steering-reaches-the-model.test.ts +117 -0
- package/src/runtime/query/__tests__/steering.test.ts +121 -0
- package/src/runtime/query/index.ts +12 -0
- package/src/runtime/query/iteration/phases/context.ts +9 -0
- package/src/runtime/query/iteration/phases/tool-review.ts +7 -1
- package/src/runtime/query/steering.ts +135 -0
- package/src/sandbox/__tests__/exec-cancellation.test.ts +72 -0
- package/src/sandbox/provider/local.ts +30 -4
- package/src/session/workspace/shared-run.ts +31 -0
- package/src/tools/__tests__/file-tool-containment.test.ts +190 -0
- package/src/tools/__tests__/sandboxed-search.test.ts +66 -0
- package/src/tools/__tests__/untrusted-envelope.test.ts +82 -0
- package/src/tools/builtins/__tests__/edit-insert-reachable.test.ts +166 -0
- package/src/tools/builtins/__tests__/edit.test.ts +10 -2
- package/src/tools/builtins/__tests__/write-file.test.ts +80 -0
- package/src/tools/builtins/edit.ts +69 -14
- package/src/tools/builtins/ls.ts +102 -0
- package/src/tools/builtins/read-file.ts +3 -2
- package/src/tools/builtins/write-file.ts +26 -12
- package/src/tools/coordinator/__tests__/agent.test.ts +6 -1
- package/src/tools/coordinator/__tests__/ask-user-question.test.ts +58 -0
- package/src/tools/coordinator/__tests__/empty-roster.test.ts +118 -0
- package/src/tools/coordinator/agent.ts +72 -11
- package/src/tools/coordinator/index.ts +86 -3
- package/src/tools/paths.ts +83 -1
- package/src/tools/untrusted-envelope.ts +78 -0
- package/src/types/agent/manager.ts +11 -4
- package/src/types/agent/supervisor.ts +10 -0
- package/src/types/common/index.ts +20 -0
- package/src/types/provider/chat.ts +61 -5
- package/src/types/provider/index.ts +1 -0
- package/src/types/sandbox/index.ts +10 -0
- package/src/types/toolset/index.ts +0 -25
|
@@ -10,6 +10,19 @@ export interface TokenUsage {
|
|
|
10
10
|
totalTokens: number
|
|
11
11
|
cachedTokens: number
|
|
12
12
|
cacheWriteTokens: number
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Output tokens the model spent on internal reasoning.
|
|
16
|
+
*
|
|
17
|
+
* A SUBSET of `completionTokens`, not an addition to it — reasoning is
|
|
18
|
+
* billed as output, so adding these to a total would double-count. Present
|
|
19
|
+
* so a caller can see what share of a turn went to thinking, which is the
|
|
20
|
+
* question budgeting and cost attribution actually ask.
|
|
21
|
+
*
|
|
22
|
+
* Optional because most drivers do not report it. Absent means unknown,
|
|
23
|
+
* not zero.
|
|
24
|
+
*/
|
|
25
|
+
reasoningTokens?: number
|
|
13
26
|
}
|
|
14
27
|
|
|
15
28
|
export function accumulateTokenUsage(current: TokenUsage, addition: TokenUsage): TokenUsage {
|
|
@@ -19,6 +32,13 @@ export function accumulateTokenUsage(current: TokenUsage, addition: TokenUsage):
|
|
|
19
32
|
totalTokens: current.totalTokens + addition.totalTokens,
|
|
20
33
|
cachedTokens: current.cachedTokens + addition.cachedTokens,
|
|
21
34
|
cacheWriteTokens: current.cacheWriteTokens + addition.cacheWriteTokens,
|
|
35
|
+
// Summed only when at least one side reported it. Coercing absent to
|
|
36
|
+
// zero would turn 'this driver does not tell us' into 'it spent none',
|
|
37
|
+
// and a run mixing a reporting driver with a silent one would read as
|
|
38
|
+
// though the silent turns did no thinking.
|
|
39
|
+
...(current.reasoningTokens !== undefined || addition.reasoningTokens !== undefined
|
|
40
|
+
? { reasoningTokens: (current.reasoningTokens ?? 0) + (addition.reasoningTokens ?? 0) }
|
|
41
|
+
: {}),
|
|
22
42
|
}
|
|
23
43
|
}
|
|
24
44
|
|
|
@@ -76,19 +76,75 @@ export interface ChatCompletionParams {
|
|
|
76
76
|
* Drivers that do not support it ignore the field.
|
|
77
77
|
*/
|
|
78
78
|
thinking?: ThinkingConfig
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* How much work to put into the response. See {@link ReasoningEffort}.
|
|
82
|
+
*
|
|
83
|
+
* Drivers that do not support it ignore the field.
|
|
84
|
+
*/
|
|
85
|
+
effort?: ReasoningEffort
|
|
79
86
|
}
|
|
80
87
|
|
|
81
88
|
export interface ThinkingConfig {
|
|
82
|
-
|
|
83
|
-
|
|
89
|
+
/**
|
|
90
|
+
* Which thinking mode to ask for.
|
|
91
|
+
*
|
|
92
|
+
* `'adaptive'` lets the model decide whether and how deeply to think per
|
|
93
|
+
* request; depth is steered by {@link ChatCompletionParams.effort} rather
|
|
94
|
+
* than a token budget. `'enabled'` is the older manual mode, where
|
|
95
|
+
* {@link budgetTokens} fixes the depth and the model thinks on every
|
|
96
|
+
* request.
|
|
97
|
+
*
|
|
98
|
+
* **These are not interchangeable, and a driver must not guess.** Vendors
|
|
99
|
+
* reject the wrong one for a given model outright rather than degrading:
|
|
100
|
+
* newer models refuse `'enabled'`, older ones refuse `'adaptive'`, and
|
|
101
|
+
* some refuse `'disabled'` because they cannot stop thinking at all. A
|
|
102
|
+
* driver that sends a mode the model does not accept produces a failed
|
|
103
|
+
* request, not a worse answer — which is why this is a declared intent
|
|
104
|
+
* that each driver resolves against the model it is about to call.
|
|
105
|
+
*/
|
|
106
|
+
type: 'adaptive' | 'enabled' | 'disabled'
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Token allowance for the thinking pass. Manual mode only — the adaptive
|
|
110
|
+
* mode has no budget, and depth is set by `effort`.
|
|
111
|
+
*/
|
|
84
112
|
budgetTokens?: number
|
|
113
|
+
|
|
85
114
|
/**
|
|
86
|
-
* Whether the
|
|
87
|
-
*
|
|
115
|
+
* Whether the thinking text comes back or only its signature.
|
|
116
|
+
*
|
|
117
|
+
* `'omitted'` returns the blocks with an empty body and a signature, which
|
|
118
|
+
* is enough to replay them on the next turn (see `replayReasoning`) while
|
|
119
|
+
* keeping the text out of the response. `'summarized'` returns a summary
|
|
120
|
+
* of the reasoning.
|
|
121
|
+
*
|
|
122
|
+
* Worth setting explicitly. This defaults to `'omitted'` on newer models,
|
|
123
|
+
* so a caller that wants to show reasoning and does not ask for it gets
|
|
124
|
+
* thinking blocks whose text is empty and no indication why.
|
|
125
|
+
*
|
|
126
|
+
* The values were `'full' | 'summarized'` here, and `'full'` was never a
|
|
127
|
+
* value any vendor accepted — a declared option that could only ever have
|
|
128
|
+
* been rejected, next to a real one that was missing.
|
|
88
129
|
*/
|
|
89
|
-
display?: '
|
|
130
|
+
display?: 'summarized' | 'omitted'
|
|
90
131
|
}
|
|
91
132
|
|
|
133
|
+
/**
|
|
134
|
+
* How much work the model should put into a response.
|
|
135
|
+
*
|
|
136
|
+
* A sibling of {@link ChatCompletionParams.thinking}, not a field inside it,
|
|
137
|
+
* because it is not exclusively a thinking control: it shapes the whole
|
|
138
|
+
* response, and at least one manual-mode model accepts it alongside a token
|
|
139
|
+
* budget, where effort shapes the answer and the budget sets thinking depth.
|
|
140
|
+
* Nesting it under `thinking` would have made that combination unsayable.
|
|
141
|
+
*
|
|
142
|
+
* In adaptive mode it is the primary depth lever — low effort may skip
|
|
143
|
+
* thinking entirely on easy input. In manual mode `budgetTokens` sets depth
|
|
144
|
+
* and effort does not move it.
|
|
145
|
+
*/
|
|
146
|
+
export type ReasoningEffort = 'low' | 'medium' | 'high' | 'xhigh' | 'max'
|
|
147
|
+
|
|
92
148
|
export interface ChatCompletionResponse {
|
|
93
149
|
id: string
|
|
94
150
|
model: string
|
|
@@ -110,6 +110,16 @@ export interface SandboxExecOptions {
|
|
|
110
110
|
* Without it a Stop (or a per-tool deadline) could only ever abandon
|
|
111
111
|
* the *wait* — the sandboxed process kept running after the host
|
|
112
112
|
* believed the run had been cancelled.
|
|
113
|
+
*
|
|
114
|
+
* **Who honours it.** The in-process local sandbox does: the signal is
|
|
115
|
+
* merged with the call's own deadline and reaches `spawn`, so the child
|
|
116
|
+
* dies. The remote backends do not, and deliberately: their wire has no
|
|
117
|
+
* cancel op, so aborting the request would abandon the wait and leave the
|
|
118
|
+
* command running — the failure above, wearing the appearance of a fix.
|
|
119
|
+
* They will honour it when their protocols carry a cancel.
|
|
120
|
+
*
|
|
121
|
+
* Passing it is therefore always safe and never harmful; whether it takes
|
|
122
|
+
* effect depends on the backend.
|
|
113
123
|
*/
|
|
114
124
|
readonly signal?: AbortSignal
|
|
115
125
|
}
|
|
@@ -1,23 +1,5 @@
|
|
|
1
1
|
import type { LLMToolSchema, ToolDefinition, ToolPermission } from '../tool/index.js'
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* @deprecated Slated for removal in the next major. Nothing produces or
|
|
5
|
-
* reads it — no code constructs any member, and `ToolsetPolicy.surfaces`,
|
|
6
|
-
* the only field that carries it, is never consulted.
|
|
7
|
-
*
|
|
8
|
-
* It is also the wrong axis. Which tools a run may use is already
|
|
9
|
-
* expressible four ways, all of them per-run and dynamic where this is
|
|
10
|
-
* fixed at definition: `allowedTools` on the query, `ToolAvailability`
|
|
11
|
-
* (`active` / `deferred` / `suspended`) with mid-run activation,
|
|
12
|
-
* `runtimeToolOverrides`, and capability negotiation stripping tools a
|
|
13
|
-
* driver cannot carry. Prefer `allowedTools`.
|
|
14
|
-
*
|
|
15
|
-
* The member names encode deployment shapes this kernel does not own,
|
|
16
|
-
* which is the deeper reason not to keep them: a host's surfaces are the
|
|
17
|
-
* host's to name.
|
|
18
|
-
*/
|
|
19
|
-
export type ToolCatalogSurface = 'chat' | 'supervised' | 'managed-agent' | 'worker' | 'code'
|
|
20
|
-
|
|
21
3
|
export type ToolSourceKind =
|
|
22
4
|
| 'host_tool'
|
|
23
5
|
| 'provider_builtin'
|
|
@@ -57,13 +39,6 @@ export interface ToolsetPolicy {
|
|
|
57
39
|
readonly enabled?: boolean
|
|
58
40
|
readonly loading?: ToolLoadingMode
|
|
59
41
|
readonly preferred?: boolean
|
|
60
|
-
/**
|
|
61
|
-
* @deprecated Slated for removal in the next major. Never read by
|
|
62
|
-
* anything — setting it has no effect today. Use `allowedTools` on the
|
|
63
|
-
* query to bound which tools a run may use; it says the same thing per
|
|
64
|
-
* run instead of per definition. See {@link ToolCatalogSurface}.
|
|
65
|
-
*/
|
|
66
|
-
readonly surfaces?: readonly ToolCatalogSurface[]
|
|
67
42
|
readonly providerConfig?: Record<string, unknown>
|
|
68
43
|
}
|
|
69
44
|
|