@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.
Files changed (203) hide show
  1. package/CHANGELOG.md +430 -0
  2. package/dist/agents/SupervisorAgent.d.ts.map +1 -1
  3. package/dist/agents/SupervisorAgent.js +58 -2
  4. package/dist/agents/SupervisorAgent.js.map +1 -1
  5. package/dist/agents/__tests__/run-agent.test.d.ts +2 -0
  6. package/dist/agents/__tests__/run-agent.test.d.ts.map +1 -0
  7. package/dist/agents/__tests__/run-agent.test.js +143 -0
  8. package/dist/agents/__tests__/run-agent.test.js.map +1 -0
  9. package/dist/agents/__tests__/supervisor-coordinator-registration.test.d.ts +2 -0
  10. package/dist/agents/__tests__/supervisor-coordinator-registration.test.d.ts.map +1 -0
  11. package/dist/agents/__tests__/supervisor-coordinator-registration.test.js +122 -0
  12. package/dist/agents/__tests__/supervisor-coordinator-registration.test.js.map +1 -0
  13. package/dist/agents/index.d.ts +2 -0
  14. package/dist/agents/index.d.ts.map +1 -1
  15. package/dist/agents/index.js +1 -0
  16. package/dist/agents/index.js.map +1 -1
  17. package/dist/agents/runAgent.d.ts +104 -0
  18. package/dist/agents/runAgent.d.ts.map +1 -0
  19. package/dist/agents/runAgent.js +92 -0
  20. package/dist/agents/runAgent.js.map +1 -0
  21. package/dist/connector/mcp/__tests__/prompt-as-tool.test.js +1 -1
  22. package/dist/connector/mcp/__tests__/prompt-as-tool.test.js.map +1 -1
  23. package/dist/connector/mcp/prompt-adapter.d.ts.map +1 -1
  24. package/dist/connector/mcp/prompt-adapter.js +16 -9
  25. package/dist/connector/mcp/prompt-adapter.js.map +1 -1
  26. package/dist/provider/__tests__/thinking-support.test.d.ts +2 -0
  27. package/dist/provider/__tests__/thinking-support.test.d.ts.map +1 -0
  28. package/dist/provider/__tests__/thinking-support.test.js +47 -0
  29. package/dist/provider/__tests__/thinking-support.test.js.map +1 -0
  30. package/dist/provider/thinking-support.d.ts +30 -0
  31. package/dist/provider/thinking-support.d.ts.map +1 -0
  32. package/dist/provider/thinking-support.js +32 -0
  33. package/dist/provider/thinking-support.js.map +1 -0
  34. package/dist/public-runtime.d.ts +5 -2
  35. package/dist/public-runtime.d.ts.map +1 -1
  36. package/dist/public-runtime.js +11 -2
  37. package/dist/public-runtime.js.map +1 -1
  38. package/dist/public-tools.d.ts +2 -0
  39. package/dist/public-tools.d.ts.map +1 -1
  40. package/dist/public-tools.js +3 -0
  41. package/dist/public-tools.js.map +1 -1
  42. package/dist/public-types.d.ts +1 -1
  43. package/dist/public-types.d.ts.map +1 -1
  44. package/dist/registry/index.d.ts +1 -1
  45. package/dist/registry/index.d.ts.map +1 -1
  46. package/dist/registry/index.js +1 -1
  47. package/dist/registry/index.js.map +1 -1
  48. package/dist/registry/tool/execute.d.ts +15 -0
  49. package/dist/registry/tool/execute.d.ts.map +1 -1
  50. package/dist/registry/tool/execute.js +19 -0
  51. package/dist/registry/tool/execute.js.map +1 -1
  52. package/dist/runtime/query/__tests__/steering-reaches-the-model.test.d.ts +2 -0
  53. package/dist/runtime/query/__tests__/steering-reaches-the-model.test.d.ts.map +1 -0
  54. package/dist/runtime/query/__tests__/steering-reaches-the-model.test.js +94 -0
  55. package/dist/runtime/query/__tests__/steering-reaches-the-model.test.js.map +1 -0
  56. package/dist/runtime/query/__tests__/steering.test.d.ts +2 -0
  57. package/dist/runtime/query/__tests__/steering.test.d.ts.map +1 -0
  58. package/dist/runtime/query/__tests__/steering.test.js +92 -0
  59. package/dist/runtime/query/__tests__/steering.test.js.map +1 -0
  60. package/dist/runtime/query/index.d.ts +10 -0
  61. package/dist/runtime/query/index.d.ts.map +1 -1
  62. package/dist/runtime/query/index.js +1 -0
  63. package/dist/runtime/query/index.js.map +1 -1
  64. package/dist/runtime/query/iteration/phases/context.d.ts +8 -0
  65. package/dist/runtime/query/iteration/phases/context.d.ts.map +1 -1
  66. package/dist/runtime/query/iteration/phases/context.js.map +1 -1
  67. package/dist/runtime/query/iteration/phases/tool-review.d.ts.map +1 -1
  68. package/dist/runtime/query/iteration/phases/tool-review.js +7 -1
  69. package/dist/runtime/query/iteration/phases/tool-review.js.map +1 -1
  70. package/dist/runtime/query/steering.d.ts +81 -0
  71. package/dist/runtime/query/steering.d.ts.map +1 -0
  72. package/dist/runtime/query/steering.js +77 -0
  73. package/dist/runtime/query/steering.js.map +1 -0
  74. package/dist/sandbox/__tests__/exec-cancellation.test.d.ts +2 -0
  75. package/dist/sandbox/__tests__/exec-cancellation.test.d.ts.map +1 -0
  76. package/dist/sandbox/__tests__/exec-cancellation.test.js +59 -0
  77. package/dist/sandbox/__tests__/exec-cancellation.test.js.map +1 -0
  78. package/dist/sandbox/provider/local.d.ts.map +1 -1
  79. package/dist/sandbox/provider/local.js +30 -5
  80. package/dist/sandbox/provider/local.js.map +1 -1
  81. package/dist/session/workspace/shared-run.d.ts +31 -0
  82. package/dist/session/workspace/shared-run.d.ts.map +1 -1
  83. package/dist/session/workspace/shared-run.js +31 -0
  84. package/dist/session/workspace/shared-run.js.map +1 -1
  85. package/dist/tools/__tests__/file-tool-containment.test.d.ts +2 -0
  86. package/dist/tools/__tests__/file-tool-containment.test.d.ts.map +1 -0
  87. package/dist/tools/__tests__/file-tool-containment.test.js +134 -0
  88. package/dist/tools/__tests__/file-tool-containment.test.js.map +1 -0
  89. package/dist/tools/__tests__/sandboxed-search.test.js +51 -0
  90. package/dist/tools/__tests__/sandboxed-search.test.js.map +1 -1
  91. package/dist/tools/__tests__/untrusted-envelope.test.d.ts +2 -0
  92. package/dist/tools/__tests__/untrusted-envelope.test.d.ts.map +1 -0
  93. package/dist/tools/__tests__/untrusted-envelope.test.js +55 -0
  94. package/dist/tools/__tests__/untrusted-envelope.test.js.map +1 -0
  95. package/dist/tools/builtins/__tests__/edit-insert-reachable.test.d.ts +2 -0
  96. package/dist/tools/builtins/__tests__/edit-insert-reachable.test.d.ts.map +1 -0
  97. package/dist/tools/builtins/__tests__/edit-insert-reachable.test.js +114 -0
  98. package/dist/tools/builtins/__tests__/edit-insert-reachable.test.js.map +1 -0
  99. package/dist/tools/builtins/__tests__/edit.test.js +9 -2
  100. package/dist/tools/builtins/__tests__/edit.test.js.map +1 -1
  101. package/dist/tools/builtins/__tests__/write-file.test.js +59 -0
  102. package/dist/tools/builtins/__tests__/write-file.test.js.map +1 -1
  103. package/dist/tools/builtins/edit.d.ts.map +1 -1
  104. package/dist/tools/builtins/edit.js +66 -14
  105. package/dist/tools/builtins/edit.js.map +1 -1
  106. package/dist/tools/builtins/ls.d.ts +1 -1
  107. package/dist/tools/builtins/ls.d.ts.map +1 -1
  108. package/dist/tools/builtins/ls.js +95 -0
  109. package/dist/tools/builtins/ls.js.map +1 -1
  110. package/dist/tools/builtins/read-file.d.ts.map +1 -1
  111. package/dist/tools/builtins/read-file.js +3 -2
  112. package/dist/tools/builtins/read-file.js.map +1 -1
  113. package/dist/tools/builtins/write-file.d.ts.map +1 -1
  114. package/dist/tools/builtins/write-file.js +26 -12
  115. package/dist/tools/builtins/write-file.js.map +1 -1
  116. package/dist/tools/coordinator/__tests__/agent.test.js +6 -1
  117. package/dist/tools/coordinator/__tests__/agent.test.js.map +1 -1
  118. package/dist/tools/coordinator/__tests__/ask-user-question.test.js +47 -0
  119. package/dist/tools/coordinator/__tests__/ask-user-question.test.js.map +1 -1
  120. package/dist/tools/coordinator/__tests__/empty-roster.test.d.ts +2 -0
  121. package/dist/tools/coordinator/__tests__/empty-roster.test.d.ts.map +1 -0
  122. package/dist/tools/coordinator/__tests__/empty-roster.test.js +97 -0
  123. package/dist/tools/coordinator/__tests__/empty-roster.test.js.map +1 -0
  124. package/dist/tools/coordinator/agent.d.ts +22 -8
  125. package/dist/tools/coordinator/agent.d.ts.map +1 -1
  126. package/dist/tools/coordinator/agent.js +45 -2
  127. package/dist/tools/coordinator/agent.js.map +1 -1
  128. package/dist/tools/coordinator/index.d.ts.map +1 -1
  129. package/dist/tools/coordinator/index.js +80 -3
  130. package/dist/tools/coordinator/index.js.map +1 -1
  131. package/dist/tools/paths.d.ts +40 -0
  132. package/dist/tools/paths.d.ts.map +1 -1
  133. package/dist/tools/paths.js +70 -1
  134. package/dist/tools/paths.js.map +1 -1
  135. package/dist/tools/untrusted-envelope.d.ts +55 -0
  136. package/dist/tools/untrusted-envelope.d.ts.map +1 -0
  137. package/dist/tools/untrusted-envelope.js +65 -0
  138. package/dist/tools/untrusted-envelope.js.map +1 -0
  139. package/dist/types/agent/manager.d.ts +11 -4
  140. package/dist/types/agent/manager.d.ts.map +1 -1
  141. package/dist/types/agent/supervisor.d.ts +9 -0
  142. package/dist/types/agent/supervisor.d.ts.map +1 -1
  143. package/dist/types/common/index.d.ts +12 -0
  144. package/dist/types/common/index.d.ts.map +1 -1
  145. package/dist/types/common/index.js +7 -0
  146. package/dist/types/common/index.js.map +1 -1
  147. package/dist/types/provider/chat.d.ts +57 -5
  148. package/dist/types/provider/chat.d.ts.map +1 -1
  149. package/dist/types/provider/index.d.ts +1 -1
  150. package/dist/types/provider/index.d.ts.map +1 -1
  151. package/dist/types/sandbox/index.d.ts +10 -0
  152. package/dist/types/sandbox/index.d.ts.map +1 -1
  153. package/dist/types/sandbox/index.js.map +1 -1
  154. package/dist/types/toolset/index.d.ts +0 -24
  155. package/dist/types/toolset/index.d.ts.map +1 -1
  156. package/package.json +1 -1
  157. package/src/agents/SupervisorAgent.ts +57 -2
  158. package/src/agents/__tests__/run-agent.test.ts +165 -0
  159. package/src/agents/__tests__/supervisor-coordinator-registration.test.ts +148 -0
  160. package/src/agents/index.ts +2 -0
  161. package/src/agents/runAgent.ts +179 -0
  162. package/src/connector/mcp/__tests__/prompt-as-tool.test.ts +1 -1
  163. package/src/connector/mcp/prompt-adapter.ts +19 -9
  164. package/src/provider/__tests__/thinking-support.test.ts +60 -0
  165. package/src/provider/thinking-support.ts +37 -0
  166. package/src/public-runtime.ts +11 -0
  167. package/src/public-tools.ts +4 -0
  168. package/src/public-types.ts +7 -1
  169. package/src/registry/index.ts +1 -1
  170. package/src/registry/tool/execute.ts +23 -0
  171. package/src/runtime/query/__tests__/steering-reaches-the-model.test.ts +117 -0
  172. package/src/runtime/query/__tests__/steering.test.ts +121 -0
  173. package/src/runtime/query/index.ts +12 -0
  174. package/src/runtime/query/iteration/phases/context.ts +9 -0
  175. package/src/runtime/query/iteration/phases/tool-review.ts +7 -1
  176. package/src/runtime/query/steering.ts +135 -0
  177. package/src/sandbox/__tests__/exec-cancellation.test.ts +72 -0
  178. package/src/sandbox/provider/local.ts +30 -4
  179. package/src/session/workspace/shared-run.ts +31 -0
  180. package/src/tools/__tests__/file-tool-containment.test.ts +190 -0
  181. package/src/tools/__tests__/sandboxed-search.test.ts +66 -0
  182. package/src/tools/__tests__/untrusted-envelope.test.ts +82 -0
  183. package/src/tools/builtins/__tests__/edit-insert-reachable.test.ts +166 -0
  184. package/src/tools/builtins/__tests__/edit.test.ts +10 -2
  185. package/src/tools/builtins/__tests__/write-file.test.ts +80 -0
  186. package/src/tools/builtins/edit.ts +69 -14
  187. package/src/tools/builtins/ls.ts +102 -0
  188. package/src/tools/builtins/read-file.ts +3 -2
  189. package/src/tools/builtins/write-file.ts +26 -12
  190. package/src/tools/coordinator/__tests__/agent.test.ts +6 -1
  191. package/src/tools/coordinator/__tests__/ask-user-question.test.ts +58 -0
  192. package/src/tools/coordinator/__tests__/empty-roster.test.ts +118 -0
  193. package/src/tools/coordinator/agent.ts +72 -11
  194. package/src/tools/coordinator/index.ts +86 -3
  195. package/src/tools/paths.ts +83 -1
  196. package/src/tools/untrusted-envelope.ts +78 -0
  197. package/src/types/agent/manager.ts +11 -4
  198. package/src/types/agent/supervisor.ts +10 -0
  199. package/src/types/common/index.ts +20 -0
  200. package/src/types/provider/chat.ts +61 -5
  201. package/src/types/provider/index.ts +1 -0
  202. package/src/types/sandbox/index.ts +10 -0
  203. 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
- type: 'enabled' | 'disabled'
83
- /** Token allowance for the thinking pass. */
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 provider should return full thinking text or a summary.
87
- * Purely a request hint; the runtime stores whatever comes back.
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?: 'full' | 'summarized'
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
@@ -4,6 +4,7 @@ export type {
4
4
  CacheControl,
5
5
  ChatCompletionParams,
6
6
  ChatCompletionResponse,
7
+ ReasoningEffort,
7
8
  ThinkingConfig,
8
9
  } from './chat.js'
9
10
  export type { StreamChunk } from './stream.js'
@@ -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