@namzu/sdk 3.2.0 → 4.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 (188) hide show
  1. package/CHANGELOG.md +294 -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__/supervisor-coordinator-registration.test.d.ts +2 -0
  6. package/dist/agents/__tests__/supervisor-coordinator-registration.test.d.ts.map +1 -0
  7. package/dist/agents/__tests__/supervisor-coordinator-registration.test.js +122 -0
  8. package/dist/agents/__tests__/supervisor-coordinator-registration.test.js.map +1 -0
  9. package/dist/agents/__tests__/supervisor-hands-down-hitl.test.d.ts +2 -0
  10. package/dist/agents/__tests__/supervisor-hands-down-hitl.test.d.ts.map +1 -0
  11. package/dist/agents/__tests__/supervisor-hands-down-hitl.test.js +112 -0
  12. package/dist/agents/__tests__/supervisor-hands-down-hitl.test.js.map +1 -0
  13. package/dist/connector/index.d.ts +1 -0
  14. package/dist/connector/index.d.ts.map +1 -1
  15. package/dist/connector/index.js +1 -0
  16. package/dist/connector/index.js.map +1 -1
  17. package/dist/connector/mcp/__tests__/prompt-as-tool.test.d.ts +2 -0
  18. package/dist/connector/mcp/__tests__/prompt-as-tool.test.d.ts.map +1 -0
  19. package/dist/connector/mcp/__tests__/prompt-as-tool.test.js +122 -0
  20. package/dist/connector/mcp/__tests__/prompt-as-tool.test.js.map +1 -0
  21. package/dist/connector/mcp/discovery.d.ts +15 -1
  22. package/dist/connector/mcp/discovery.d.ts.map +1 -1
  23. package/dist/connector/mcp/discovery.js +39 -1
  24. package/dist/connector/mcp/discovery.js.map +1 -1
  25. package/dist/connector/mcp/index.d.ts +2 -1
  26. package/dist/connector/mcp/index.d.ts.map +1 -1
  27. package/dist/connector/mcp/index.js +2 -1
  28. package/dist/connector/mcp/index.js.map +1 -1
  29. package/dist/connector/mcp/policy.d.ts +17 -0
  30. package/dist/connector/mcp/policy.d.ts.map +1 -1
  31. package/dist/connector/mcp/policy.js +18 -7
  32. package/dist/connector/mcp/policy.js.map +1 -1
  33. package/dist/connector/mcp/prompt-adapter.d.ts +39 -0
  34. package/dist/connector/mcp/prompt-adapter.d.ts.map +1 -0
  35. package/dist/connector/mcp/prompt-adapter.js +120 -0
  36. package/dist/connector/mcp/prompt-adapter.js.map +1 -0
  37. package/dist/manager/agent/__tests__/hitl-across-spawn.test.d.ts +2 -0
  38. package/dist/manager/agent/__tests__/hitl-across-spawn.test.d.ts.map +1 -0
  39. package/dist/manager/agent/__tests__/hitl-across-spawn.test.js +226 -0
  40. package/dist/manager/agent/__tests__/hitl-across-spawn.test.js.map +1 -0
  41. package/dist/manager/agent/lifecycle.d.ts.map +1 -1
  42. package/dist/manager/agent/lifecycle.js +13 -0
  43. package/dist/manager/agent/lifecycle.js.map +1 -1
  44. package/dist/plugin/__tests__/mcp-admission.test.js +37 -2
  45. package/dist/plugin/__tests__/mcp-admission.test.js.map +1 -1
  46. package/dist/plugin/lifecycle.d.ts.map +1 -1
  47. package/dist/plugin/lifecycle.js +10 -0
  48. package/dist/plugin/lifecycle.js.map +1 -1
  49. package/dist/public-runtime.d.ts +2 -2
  50. package/dist/public-runtime.d.ts.map +1 -1
  51. package/dist/public-runtime.js +2 -2
  52. package/dist/public-runtime.js.map +1 -1
  53. package/dist/public-tools.d.ts +2 -0
  54. package/dist/public-tools.d.ts.map +1 -1
  55. package/dist/public-tools.js +3 -0
  56. package/dist/public-tools.js.map +1 -1
  57. package/dist/registry/index.d.ts +1 -1
  58. package/dist/registry/index.d.ts.map +1 -1
  59. package/dist/registry/index.js +1 -1
  60. package/dist/registry/index.js.map +1 -1
  61. package/dist/registry/tool/execute.d.ts +15 -0
  62. package/dist/registry/tool/execute.d.ts.map +1 -1
  63. package/dist/registry/tool/execute.js +19 -0
  64. package/dist/registry/tool/execute.js.map +1 -1
  65. package/dist/runtime/query/iteration/index.d.ts.map +1 -1
  66. package/dist/runtime/query/iteration/index.js +1 -46
  67. package/dist/runtime/query/iteration/index.js.map +1 -1
  68. package/dist/sandbox/__tests__/exec-cancellation.test.d.ts +2 -0
  69. package/dist/sandbox/__tests__/exec-cancellation.test.d.ts.map +1 -0
  70. package/dist/sandbox/__tests__/exec-cancellation.test.js +59 -0
  71. package/dist/sandbox/__tests__/exec-cancellation.test.js.map +1 -0
  72. package/dist/sandbox/provider/local.d.ts.map +1 -1
  73. package/dist/sandbox/provider/local.js +30 -5
  74. package/dist/sandbox/provider/local.js.map +1 -1
  75. package/dist/session/workspace/shared-run.d.ts +31 -0
  76. package/dist/session/workspace/shared-run.d.ts.map +1 -1
  77. package/dist/session/workspace/shared-run.js +31 -0
  78. package/dist/session/workspace/shared-run.js.map +1 -1
  79. package/dist/telemetry/__tests__/model-call-span.test.js +13 -8
  80. package/dist/telemetry/__tests__/model-call-span.test.js.map +1 -1
  81. package/dist/tools/__tests__/file-tool-containment.test.d.ts +2 -0
  82. package/dist/tools/__tests__/file-tool-containment.test.d.ts.map +1 -0
  83. package/dist/tools/__tests__/file-tool-containment.test.js +134 -0
  84. package/dist/tools/__tests__/file-tool-containment.test.js.map +1 -0
  85. package/dist/tools/__tests__/sandboxed-search.test.js +51 -0
  86. package/dist/tools/__tests__/sandboxed-search.test.js.map +1 -1
  87. package/dist/tools/__tests__/untrusted-envelope.test.d.ts +2 -0
  88. package/dist/tools/__tests__/untrusted-envelope.test.d.ts.map +1 -0
  89. package/dist/tools/__tests__/untrusted-envelope.test.js +55 -0
  90. package/dist/tools/__tests__/untrusted-envelope.test.js.map +1 -0
  91. package/dist/tools/builtins/__tests__/edit-insert-reachable.test.d.ts +2 -0
  92. package/dist/tools/builtins/__tests__/edit-insert-reachable.test.d.ts.map +1 -0
  93. package/dist/tools/builtins/__tests__/edit-insert-reachable.test.js +114 -0
  94. package/dist/tools/builtins/__tests__/edit-insert-reachable.test.js.map +1 -0
  95. package/dist/tools/builtins/__tests__/edit.test.js +9 -2
  96. package/dist/tools/builtins/__tests__/edit.test.js.map +1 -1
  97. package/dist/tools/builtins/__tests__/write-file.test.js +59 -0
  98. package/dist/tools/builtins/__tests__/write-file.test.js.map +1 -1
  99. package/dist/tools/builtins/edit.d.ts.map +1 -1
  100. package/dist/tools/builtins/edit.js +66 -14
  101. package/dist/tools/builtins/edit.js.map +1 -1
  102. package/dist/tools/builtins/ls.d.ts +1 -1
  103. package/dist/tools/builtins/ls.d.ts.map +1 -1
  104. package/dist/tools/builtins/ls.js +95 -0
  105. package/dist/tools/builtins/ls.js.map +1 -1
  106. package/dist/tools/builtins/read-file.d.ts.map +1 -1
  107. package/dist/tools/builtins/read-file.js +3 -2
  108. package/dist/tools/builtins/read-file.js.map +1 -1
  109. package/dist/tools/builtins/write-file.d.ts.map +1 -1
  110. package/dist/tools/builtins/write-file.js +26 -12
  111. package/dist/tools/builtins/write-file.js.map +1 -1
  112. package/dist/tools/coordinator/__tests__/agent.test.js +6 -1
  113. package/dist/tools/coordinator/__tests__/agent.test.js.map +1 -1
  114. package/dist/tools/coordinator/__tests__/ask-user-question.test.js +47 -0
  115. package/dist/tools/coordinator/__tests__/ask-user-question.test.js.map +1 -1
  116. package/dist/tools/coordinator/__tests__/empty-roster.test.d.ts +2 -0
  117. package/dist/tools/coordinator/__tests__/empty-roster.test.d.ts.map +1 -0
  118. package/dist/tools/coordinator/__tests__/empty-roster.test.js +97 -0
  119. package/dist/tools/coordinator/__tests__/empty-roster.test.js.map +1 -0
  120. package/dist/tools/coordinator/agent.d.ts +22 -8
  121. package/dist/tools/coordinator/agent.d.ts.map +1 -1
  122. package/dist/tools/coordinator/agent.js +45 -2
  123. package/dist/tools/coordinator/agent.js.map +1 -1
  124. package/dist/tools/coordinator/index.d.ts.map +1 -1
  125. package/dist/tools/coordinator/index.js +80 -3
  126. package/dist/tools/coordinator/index.js.map +1 -1
  127. package/dist/tools/paths.d.ts +40 -0
  128. package/dist/tools/paths.d.ts.map +1 -1
  129. package/dist/tools/paths.js +70 -1
  130. package/dist/tools/paths.js.map +1 -1
  131. package/dist/tools/untrusted-envelope.d.ts +55 -0
  132. package/dist/tools/untrusted-envelope.d.ts.map +1 -0
  133. package/dist/tools/untrusted-envelope.js +65 -0
  134. package/dist/tools/untrusted-envelope.js.map +1 -0
  135. package/dist/types/agent/base.d.ts +26 -0
  136. package/dist/types/agent/base.d.ts.map +1 -1
  137. package/dist/types/agent/task.d.ts +17 -0
  138. package/dist/types/agent/task.d.ts.map +1 -1
  139. package/dist/types/agent/task.js.map +1 -1
  140. package/dist/types/sandbox/index.d.ts +10 -0
  141. package/dist/types/sandbox/index.d.ts.map +1 -1
  142. package/dist/types/sandbox/index.js.map +1 -1
  143. package/dist/types/toolset/index.d.ts +0 -24
  144. package/dist/types/toolset/index.d.ts.map +1 -1
  145. package/package.json +1 -1
  146. package/src/agents/SupervisorAgent.ts +57 -2
  147. package/src/agents/__tests__/supervisor-coordinator-registration.test.ts +148 -0
  148. package/src/agents/__tests__/supervisor-hands-down-hitl.test.ts +131 -0
  149. package/src/connector/index.ts +1 -0
  150. package/src/connector/mcp/__tests__/prompt-as-tool.test.ts +157 -0
  151. package/src/connector/mcp/discovery.ts +48 -1
  152. package/src/connector/mcp/index.ts +2 -1
  153. package/src/connector/mcp/policy.ts +23 -8
  154. package/src/connector/mcp/prompt-adapter.ts +149 -0
  155. package/src/manager/agent/__tests__/hitl-across-spawn.test.ts +273 -0
  156. package/src/manager/agent/lifecycle.ts +12 -0
  157. package/src/plugin/__tests__/mcp-admission.test.ts +46 -2
  158. package/src/plugin/lifecycle.ts +11 -0
  159. package/src/public-runtime.ts +3 -0
  160. package/src/public-tools.ts +4 -0
  161. package/src/registry/index.ts +1 -1
  162. package/src/registry/tool/execute.ts +23 -0
  163. package/src/runtime/query/iteration/index.ts +0 -48
  164. package/src/sandbox/__tests__/exec-cancellation.test.ts +72 -0
  165. package/src/sandbox/provider/local.ts +30 -4
  166. package/src/session/workspace/shared-run.ts +31 -0
  167. package/src/telemetry/__tests__/model-call-span.test.ts +13 -7
  168. package/src/tools/__tests__/file-tool-containment.test.ts +190 -0
  169. package/src/tools/__tests__/sandboxed-search.test.ts +66 -0
  170. package/src/tools/__tests__/untrusted-envelope.test.ts +82 -0
  171. package/src/tools/builtins/__tests__/edit-insert-reachable.test.ts +166 -0
  172. package/src/tools/builtins/__tests__/edit.test.ts +10 -2
  173. package/src/tools/builtins/__tests__/write-file.test.ts +80 -0
  174. package/src/tools/builtins/edit.ts +69 -14
  175. package/src/tools/builtins/ls.ts +102 -0
  176. package/src/tools/builtins/read-file.ts +3 -2
  177. package/src/tools/builtins/write-file.ts +26 -12
  178. package/src/tools/coordinator/__tests__/agent.test.ts +6 -1
  179. package/src/tools/coordinator/__tests__/ask-user-question.test.ts +58 -0
  180. package/src/tools/coordinator/__tests__/empty-roster.test.ts +118 -0
  181. package/src/tools/coordinator/agent.ts +72 -11
  182. package/src/tools/coordinator/index.ts +86 -3
  183. package/src/tools/paths.ts +83 -1
  184. package/src/tools/untrusted-envelope.ts +78 -0
  185. package/src/types/agent/base.ts +27 -0
  186. package/src/types/agent/task.ts +18 -0
  187. package/src/types/sandbox/index.ts +10 -0
  188. package/src/types/toolset/index.ts +0 -25
package/CHANGELOG.md CHANGED
@@ -1,5 +1,299 @@
1
1
  # Changelog
2
2
 
3
+ ## 4.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - c3cb587: `read`, `write` and `edit` are now contained to the working directory.
8
+
9
+ All three called `resolve(workingDirectory, input.path)` bare, so
10
+ `path: "../../.."` reached whatever sits above the working directory and the
11
+ tool used it. No sandbox had to be misconfigured for this — it holds with no
12
+ sandbox at all, which is the common case, so a model that asks for a parent
13
+ directory got one. `resolveWithin` existed the whole time and these three
14
+ never reached it; the search tools (`glob`, `grep`, `ls`) did.
15
+
16
+ A lexical check alone would not have been the fix. `atomicWriteFile` resolves
17
+ its destination and writes _through_ a symlink deliberately, so that editing a
18
+ linked file updates the target rather than replacing the link with a regular
19
+ file. Paired with a lexical check that is check-then-follow: a link inside the
20
+ working directory pointing outside it climbs nothing on paper, and the write
21
+ lands outside anyway (CWE-59). Containment is therefore decided after
22
+ canonicalization, which is the ordering CWE-22 states as the mitigation for
23
+ the family: canonicalize, then validate the canonical form.
24
+
25
+ Two details the new resolver has to get right, because getting either wrong
26
+ breaks ordinary use rather than failing safe:
27
+
28
+ - The root can itself be a symlink — `os.tmpdir()` is one on macOS — so both
29
+ sides are canonicalized. Canonicalizing only the candidate would refuse
30
+ every path under a temp directory.
31
+ - The target may not exist yet, and `realpath` throws on a missing path. The
32
+ deepest existing ancestor is canonicalized and the remainder appended
33
+ lexically; the remainder cannot hide a link because nothing is there to be
34
+ one.
35
+
36
+ This does not claim TOCTOU safety. A component swapped for a symlink between
37
+ the check and the open would still be followed — closing that needs
38
+ per-component `openat`/`O_NOFOLLOW`, which Node does not expose. The threat
39
+ addressed is a link that is already present.
40
+
41
+ **Migration.** If a host relied on these tools reaching outside
42
+ `workingDirectory` — reading a config beside the repo, writing to a sibling
43
+ output directory — those calls now fail with "Path escapes the working
44
+ directory". Point `workingDirectory` at a root that contains everything the
45
+ run legitimately needs. Sandboxed runs are unaffected: the sandbox has its own
46
+ root and its own resolver, and the host-side canonicalization deliberately
47
+ does not run on that branch.
48
+
49
+ - a1f67f3: Two allow-lists in the delegation surface stop failing open, and a host can
50
+ now decline a coordinator tool.
51
+
52
+ ## An empty delegate roster means nobody
53
+
54
+ `create_task` derived its `agent_id` parameter from `allowedAgentIds` but
55
+ widened it from the roster enum to a bare string whenever that roster was
56
+ empty — so the one configuration meaning "this run may delegate to nobody" was
57
+ the only one that let the model name anybody. An allow-list _is_ the
58
+ enumeration of what is permitted; an empty one enumerates nothing and admits
59
+ nothing. Degrading it to an open string to keep functioning is failing open
60
+ (CWE-636), and the rule it breaks is fail-safe defaults (Saltzer & Schroeder
61
+ 1975, §I.A.3(b)), restated in NIST SP 800-53 Rev. 5 as SC-7(5) "deny by
62
+ default, allow by exception".
63
+
64
+ What that reached is why this is worth a break. The id was not merely rejected
65
+ downstream: it went to the gateway, which resolves against an `AgentManager`
66
+ that is typically **shared**, so an agent the host deliberately left out of
67
+ `agentIds` could still launch if it happened to be registered there. When it
68
+ was not registered, the failure text listed every registered agent id back to
69
+ the model, and the plan row was left stranded at `in_progress` because the
70
+ store write precedes the gateway call while the reconciling update follows it.
71
+
72
+ `create_task` is now **not mounted** when the roster is empty, rather than
73
+ mounted with a schema nothing satisfies — refusing per call reaches the same
74
+ verdict while paying prompt-prefix tokens and an iteration for it (NIST SP
75
+ 800-53 CM-7, least functionality). It is the only coordinator tool that reads
76
+ the roster, so `agent_task_list`, `approve_plan` and `ask_user_question` are
77
+ untouched: "no delegates, but still planning and a human channel" remains a
78
+ supported configuration. The schema stays closed underneath as defence in
79
+ depth. If you construct a supervisor with `agentIds: []` and expected
80
+ `create_task` to be callable, populate the roster — there is no flag that
81
+ restores the old shape, because the old shape could not correctly succeed.
82
+
83
+ `buildAgentTool` carried the identical fallback and now throws at construction
84
+ instead: it returns exactly one tool and that tool _is_ the delegation surface,
85
+ so "do not mount it" and "do not build it" are the same statement. It also
86
+ never checked `subagent_type` against the roster inside `execute`, which is
87
+ reachable without going through the registry; it does now.
88
+
89
+ ## A host can decline a coordinator tool
90
+
91
+ `runtimeToolOverrides` is this SDK's declared way to decline a kernel-mounted
92
+ tool. It is honoured for the task tools and the advisory tools, and
93
+ `SupervisorAgent` forwards it into its own `drainQuery` call — but it
94
+ registered the coordinator tools before that, unconditionally, so
95
+ `{ create_task: 'disabled' }` was obeyed everywhere except the one surface a
96
+ host would most want to decline. A run that must not delegate had prompt text
97
+ and a gateway refusal as its only defences. This half is pure gap-closure: the
98
+ mechanism, the type and two other call sites already existed, and coordinator
99
+ registration now uses the same idiom.
100
+
101
+ ## Collisions refuse instead of overwriting
102
+
103
+ This half is new policy, not a gap-closure. Registration now throws
104
+ `ToolNameCollisionError` (exported, carrying `toolName`) when a coordinator
105
+ tool's name is already registered on the supervisor's `tools`, instead of the
106
+ registry's warn-and-overwrite. The reserved names are `create_task`,
107
+ `agent_task_list`, `approve_plan`, and `ask_user_question` — grep for those
108
+ four.
109
+
110
+ The old behaviour was not "the host's tool quietly loses and the run works".
111
+ `registerOne` ends by setting availability, and the coordinator call passed
112
+ none, so a tool the host registered `deferred` or `suspended` was silently
113
+ promoted to `active` under someone else's implementation; and because the
114
+ backing store is a `Map`, the replacement inherited the host's insertion
115
+ position in the prompt-cache prefix. That is a different authorization surface,
116
+ not a lost registration — detection of an error condition without action
117
+ (CWE-390), where CWE-694's own mitigation is nearly this fix. Complete
118
+ mediation is the principle (§I.A.3(c)): a registry entry is a remembered
119
+ binding of a name to an authority, and rebinding it leaves every decision made
120
+ about the old binding stale.
121
+
122
+ To migrate: rename your tool, or keep your name and decline the coordinator one
123
+ with `runtimeToolOverrides: { "create_task": "disabled" }`. The error names
124
+ both routes.
125
+
126
+ - df07db8: Removes `ToolCatalogSurface` and `ToolsetPolicy.surfaces`.
127
+
128
+ Both were deprecated in 3.2.0 and shipped deprecated again in 3.3.0, so the
129
+ window SemVer asks for — at least one minor release in which working code
130
+ compiles and warns — has been served twice. The deprecation said "slated for
131
+ removal in the next major"; this is that major, and letting it pass would move
132
+ the promise to 5.0.0.
133
+
134
+ Nothing produced or read either one. No code constructed a member of the
135
+ union, and `surfaces` was the only field carrying it and was never consulted,
136
+ so there is no runtime behaviour to change and no working code to migrate:
137
+ setting it did nothing before and the field is gone now. Under this repo's
138
+ release rule that is the case where a removal may go straight to major, and it
139
+ is being said here as that rule asks.
140
+
141
+ It was also the wrong axis. Which tools a run may use is already expressible
142
+ four ways, all per-run and dynamic where this was fixed at definition:
143
+ `allowedTools` on the query, `ToolAvailability` (`active` / `deferred` /
144
+ `suspended`) with mid-run activation, `runtimeToolOverrides`, and capability
145
+ negotiation stripping tools a driver cannot carry. If you set `surfaces`,
146
+ `allowedTools` is the replacement — it says the same thing per run.
147
+
148
+ `SharedRunWorkspace` is unchanged and stays exported without an SDK-side
149
+ caller. That is deliberate and now documented on the class: its config asks for
150
+ a host filesystem root and the path an agent will see, which is a deployment
151
+ shape the kernel does not own. `runtimeRoot` and the paths `refs()` derives
152
+ from it are the contract.
153
+
154
+ - 19f390a: A delegated agent's output is now framed as untrusted material, and the
155
+ framing itself can no longer be forged.
156
+
157
+ **Why the child→parent return.** A delegated worker is the component most
158
+ likely to have consumed something nobody in the run authored: it was handed a
159
+ task like "read these files and report", it ran `read`, `grep`, possibly a
160
+ connector fetch over material the user did not write, and its final text
161
+ landed directly in the parent's context — where the parent typically holds a
162
+ broader tool grant than the child that produced the text. An unlabelled block
163
+ there reads as the parent's own reasoning. Connector-supplied prompts already
164
+ got this treatment; the delegation surface had none.
165
+
166
+ `create_task` and the `Agent` tool now wrap their `output` in a
167
+ `<namzu-untrusted kind="agent-result">` frame naming the agent and task, with
168
+ one line saying the content is material rather than direction. The worker's
169
+ text is unaltered inside it, and `data.result` carries it verbatim, so a host
170
+ reading the result programmatically is unaffected — only the model-facing
171
+ string changed.
172
+
173
+ **The framing was forgeable, and that is fixed.** The existing envelope around
174
+ connector prompts built its tag by hand and interpolated remote text straight
175
+ into the body. A prompt whose content contained `</mcp-prompt>` closed the
176
+ block early, and everything the server wrote after that read as unlabelled —
177
+ which is to say, as this agent's own instructions. The label was the entire
178
+ mitigation and the labelled party could remove it. `wrapUntrusted` now defangs
179
+ the delimiter case-insensitively (a model reads `</NAMZU-UNTRUSTED>` as the
180
+ same tag) and escapes attribute values, so a source name carrying a quote
181
+ cannot rewrite the tag it appears in.
182
+
183
+ Two decisions worth stating because the obvious alternatives are wrong:
184
+
185
+ - **No length threshold.** Skipping short payloads to save tokens leaves the
186
+ cheapest carrier unframed; an instruction fits in a tweet.
187
+ - **No "already wrapped, skip it" fast path.** That check is forgeable —
188
+ content merely beginning with the opening tag would pass through with no
189
+ framing at all. Wrapping twice is harmless; not wrapping once is not.
190
+
191
+ `wrapUntrusted`, `neutralizeEnvelopeDelimiter` and `UntrustedEnvelope` are
192
+ exported, so a host surfacing its own untrusted content to a model can use the
193
+ same framing rather than inventing one.
194
+
195
+ **Migration.** If you assert on `create_task` or `Agent` output text, read
196
+ `data.result` instead — it is the worker's text with nothing added. If you
197
+ call `renderPromptMessages` directly, its output opens with
198
+ `<namzu-untrusted kind="mcp-prompt" …>` rather than `<mcp-prompt …>`.
199
+
200
+ ### Minor Changes
201
+
202
+ - 2b9d90e: `edit` can do the thing its own description tells the model to do.
203
+
204
+ The tool description says _"For insertions, pass insertLine … use `insertLine: "end"` to extend a file at the end"_, and `write-file` and `bash` point at the same idiom. But `modelInputSchema` advertised only `path`/`old_string`/`new_string`/`replace_all` with `additionalProperties: false`, and `enforceModelInput: true` — so under constrained decoding the append idiom the prompt recommends was the one idiom a model could not emit. A consuming host measured the result over seven days on one tenant: **94 of 159 tool failures** were `edit` rejecting an `insertLine` whose spelling the model had guessed.
205
+
206
+ `insertLine` is now in the model-facing schema as `oneOf: [integer ≥ 0, "end"]`. Declaring the union that way also removes the synonym problem at its source: for a provider that constrains generation, `"EOF"` is not emittable, because `"end"` is the only string the schema admits.
207
+
208
+ `old_string` leaves `required`, because an insert has no text to match — requiring it is exactly what made the idiom unexpressible. Which of `old_string` / `insertLine` is present is decided by the two refinements the execution schema already carries. That is deliberate over a top-level `oneOf`: strict structured-output modes are least surprising with a flat object, and a discriminated union at the root is the construct most likely to be rejected or quietly ignored. The cost is that an incomplete call is now expressible and caught at execution rather than generation — paid knowingly, since the alternative is a working capability nothing can reach.
209
+
210
+ For providers that do **not** constrain, `insertLine` also accepts `eof`, `append`, `last` and `end_of_file`. Liberal at execution and strict in the schema is the right way round: none of those is ambiguous, and refusing one bought strictness at the price of a full model round trip. The rejection message now names the value it received.
211
+
212
+ Also here, same file family: **`write` refuses a whitespace-only path**, which `edit` has always refused. `.min(1)` admits `" "`, which resolves to the working directory and fails as an unreadable directory-write error. Two mutating tools disagreeing about the same input is the kind of gap a model finds and a reviewer does not.
213
+
214
+ - 4be54ca: Three sandbox and delegation gaps, all of the same kind: something declared,
215
+ threaded through types, and never driven.
216
+
217
+ **`SandboxExecOptions.signal` now works — on the backend where it can.** The
218
+ option was declared, documented and exported, with a docstring stating that
219
+ without it "a Stop could only ever abandon the _wait_ — the sandboxed process
220
+ kept running after the host believed the run had been cancelled". Every
221
+ backend dropped it, so that is exactly what happened. The local sandbox now
222
+ merges the caller's signal with the call's own deadline and hands the result to
223
+ `spawn`, so the child actually dies; a cancelled run is no longer reported as
224
+ `timedOut`, because a run someone stopped did not run too long, and telling the
225
+ model otherwise invites a retry with a bigger budget.
226
+
227
+ The remote backends still ignore it, now explicitly and with the reason in the
228
+ source. Their wire has no cancel op, so aborting the request would abandon the
229
+ wait while the command kept running — the original failure, wearing the
230
+ appearance of a fix. `SandboxExecOptions.signal` documents which backends
231
+ honour it.
232
+
233
+ **`ls` respects the sandbox.** It read the host through `node:fs` and named
234
+ `context.sandbox` nowhere, in the one builtin whose whole job is telling the
235
+ model what exists — so under a container or microVM backend the model's picture
236
+ of the filesystem was the host's. Its paths were host-relative too, while
237
+ `read`, `grep` and `glob` all resolve inside the sandbox, so an ls-to-read
238
+ handoff either failed or opened a different file than the one listed. `glob`
239
+ had the identical defect, was fixed, and its fix notes that "every sibling
240
+ builtin already remembers this branch"; this was the sibling that did not.
241
+
242
+ One behaviour difference worth knowing: inside a sandbox, directories are
243
+ derived from file paths, because `listFiles` reports files. An empty directory
244
+ is invisible there.
245
+
246
+ **The `Agent` tool's header described a design that no longer exists.** It told
247
+ readers to prefer `Agent` because `create_task` was a non-blocking trio driven
248
+ by notification callbacks. `create_task` blocks and returns the worker's output
249
+ as its own result, and `continue_task` / `cancel_task` are not registered at
250
+ all. The two tools are separated by how much of the coordinator surface they
251
+ bring, not by timing.
252
+
253
+ ## 3.3.0
254
+
255
+ ### Minor Changes
256
+
257
+ - 635ffa9: A human's approval now crosses the spawn boundary.
258
+
259
+ `BaseAgentConfig` carried no resume handler. `SendMessageOptions.configOverrides` is a `Partial` of it, so a parent could not hand its decision channel to a child **at the type level** — and no runtime path could carry one either. Every delegated child fell through to the SDK's `autoApproveHandler`, however carefully its parent had been wired.
260
+
261
+ **What that cost, exactly.** A `VerificationGate` _deny_ still bit inside a child: denials are threaded into the executor and no later approval releases them. What was lost is the **review** tier — every call the gate left undecided reached the resume handler, and for a child that handler auto-approved. So a host running "ask before acting" had a human review `write` at the top level and never see the same `write` issued one hop down. The shipped CLI encodes the workaround as policy: its sub-agent prompt says _"do not ask the parent questions; make reasonable assumptions"_, because a question had nowhere to go.
262
+
263
+ `AgentTaskContext.resumeHandler` carries the parent's channel and `AgentManager` stamps it onto the child config — beside the trace parent and the tenant triple, for the same reason: a `configBuilder` is written by whoever registered the agent and cannot be trusted to forward something it was never told about. An explicit `configOverrides.resumeHandler` still wins, so one child can be given a different channel or none. `SupervisorAgent` now puts its own handler on the spawn context; it already gave that handler to its own run and its own coordinator tools, so the two had disagreed — the supervisor paused for a human while the workers it launched approved themselves.
264
+
265
+ Absent still means auto-approve. A host that never wired a handler is unaffected.
266
+
267
+ The handler is passed as the function itself, which works because delegation is in-process — `LocalTaskGateway` is the only gateway in the tree. A gateway dispatching across a process boundary could not carry a closure and would have to proxy the request onto the parent's event stream and route the answer back by request id. The upward half of that already exists: `wrapChildListener` stamps lineage on every child event the parent sees, and `user_question_asked` / `tool_review_requested` / `run_paused` are already typed events.
268
+
269
+ - 6015989: A published MCP prompt reaches the model.
270
+
271
+ `listPrompts` and `getPrompt` landed on the client and server last release and stopped there: a server could publish prompts, the SDK could fetch them, and nothing ever put one in front of a model. That shipped the protocol half without the consumer half — the same primitive-with-no-driver shape this series exists to remove, created by the fix for it.
272
+
273
+ A prompt is now adapted into a tool the model can call, `mcp_prompt_<server>_<name>`, with an input schema built from the arguments the prompt declares.
274
+
275
+ **Why a tool and not system content.** Folding a prompt into the system prompt puts remote text in the cached prefix, so every turn pays for it and the cache breaks whenever the server changes its wording — and system position _reads_ as instruction, which is the last thing text from a remote party should read as. A slash command would route through the host's UI, so a headless run could never use one. A tool call is explicit, auditable, passes the same admission policy and `allowedTools` filter as every other capability, and its answer arrives as a `tool_result`, which a model already treats as data returned by something rather than as direction.
276
+
277
+ The result is wrapped in an envelope naming the server and the prompt, and saying the content is material to work with rather than instructions. Untrusted content arriving through a tool result is the standard injection surface, and the mitigation that survives contact is saying plainly whose words these are. A server that returns an `assistant` message has that role reported inside the envelope, never turned into an assistant turn in the run's own history.
278
+
279
+ Prompts pass the **same admission policy** as tools, via a shared name check — a server publishing a prompt is the same trust question as one publishing a tool, and two copies of an allow/deny rule are two chances for one to drift permissive. They are namespaced apart from tools, since a server may publish both under one name and collapsing them would let whichever registered second replace the first.
280
+
281
+ A fetch that fails is returned to the model rather than thrown: a read-only lookup that a server cannot answer is something an agent can work around, and ending the run over it is the wrong trade.
282
+
283
+ ### Patch Changes
284
+
285
+ - 82888c6: One `chat` span per model call, not two.
286
+
287
+ 3.2.0 shipped a second `chat {model}` span. `stream-turn.ts` already opened one — with the same justification, that `chatSpanName` had no call sites — and 3.2.0 added another beside it, same name, same parent, both carrying token counts. A consumer summing spans double-counted latency and tokens.
288
+
289
+ Verified by execution rather than by reading: one scripted model call produced two `chat mock-model` spans, both with `gen_ai.usage.input_tokens`.
290
+
291
+ The one added in 3.2.0 is removed and the earlier one kept, because it is strictly better — it wraps the call itself and records time to first delta, which the later one did not.
292
+
293
+ **How it shipped, since that matters more than the fix.** The search that concluded "zero call sites" covered `telemetry/attributes.ts` and `constants/telemetry/` and never the runtime. Then the test asserting `toHaveLength(1)` failed with `2`, and the failure was explained away — attributed to a forced-final turn — and relaxed to `>= 1`. That relaxation is now reverted to an exact count, and a mutation confirms it catches a re-introduced duplicate as well as a removed span. The reasoning is recorded next to the assertion so the next person to see it fail with `2` reads the history instead of re-deriving the same wrong explanation.
294
+
295
+ Reported by a consuming host reading 3.2.0 against its own telemetry.
296
+
3
297
  ## 3.2.0
4
298
 
5
299
  ### Minor Changes
@@ -1 +1 @@
1
- {"version":3,"file":"SupervisorAgent.d.ts","sourceRoot":"","sources":["../../src/agents/SupervisorAgent.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAe,UAAU,EAAE,MAAM,2BAA2B,CAAA;AACxE,OAAO,KAAK,EACX,UAAU,EACV,aAAa,EACb,eAAe,EACf,qBAAqB,EACrB,qBAAqB,EACrB,MAAM,yBAAyB,CAAA;AAEhC,OAAO,KAAK,EAAW,KAAK,EAAU,MAAM,uBAAuB,CAAA;AAEnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAG7D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAElD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,qBAAqB,CACpC,WAAW,EAAE,SAAS,UAAU,EAAE,EAClC,KAAK,EAAE,KAAK,EACZ,GAAG,GAAE,MAAmB,GACtB,eAAe,EAAE,CAcnB;AAED,4DAA4D;AAC5D,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,SAAS,eAAe,EAAE,GAAG,MAAM,CAEnF;AAED,qBAAa,eAAgB,SAAQ,aAAa,CAAC,qBAAqB,EAAE,qBAAqB,CAAC;IAC/F,QAAQ,CAAC,IAAI,EAAG,YAAY,CAAS;gBAEzB,QAAQ,EAAE,IAAI,CAAC,aAAa,EAAE,MAAM,GAAG,cAAc,CAAC;IAalE;;;;;;;;OAQG;IACG,GAAG,CACR,KAAK,EAAE,UAAU,EACjB,MAAM,EAAE,qBAAqB,EAC7B,QAAQ,CAAC,EAAE,gBAAgB,GACzB,OAAO,CAAC,qBAAqB,CAAC;YAMnB,YAAY;CAqL1B"}
1
+ {"version":3,"file":"SupervisorAgent.d.ts","sourceRoot":"","sources":["../../src/agents/SupervisorAgent.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAe,UAAU,EAAE,MAAM,2BAA2B,CAAA;AACxE,OAAO,KAAK,EACX,UAAU,EACV,aAAa,EACb,eAAe,EACf,qBAAqB,EACrB,qBAAqB,EACrB,MAAM,yBAAyB,CAAA;AAEhC,OAAO,KAAK,EAAW,KAAK,EAAU,MAAM,uBAAuB,CAAA;AAEnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAG7D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAElD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,qBAAqB,CACpC,WAAW,EAAE,SAAS,UAAU,EAAE,EAClC,KAAK,EAAE,KAAK,EACZ,GAAG,GAAE,MAAmB,GACtB,eAAe,EAAE,CAcnB;AAED,4DAA4D;AAC5D,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,SAAS,eAAe,EAAE,GAAG,MAAM,CAEnF;AAED,qBAAa,eAAgB,SAAQ,aAAa,CAAC,qBAAqB,EAAE,qBAAqB,CAAC;IAC/F,QAAQ,CAAC,IAAI,EAAG,YAAY,CAAS;gBAEzB,QAAQ,EAAE,IAAI,CAAC,aAAa,EAAE,MAAM,GAAG,cAAc,CAAC;IAalE;;;;;;;;OAQG;IACG,GAAG,CACR,KAAK,EAAE,UAAU,EACjB,MAAM,EAAE,qBAAqB,EAC7B,QAAQ,CAAC,EAAE,gBAAgB,GACzB,OAAO,CAAC,qBAAqB,CAAC;YAMnB,YAAY;CA4O1B"}
@@ -1,6 +1,6 @@
1
1
  import { EMPTY_TOKEN_USAGE } from '../constants/limits.js';
2
2
  import { LocalTaskGateway } from '../gateway/local.js';
3
- import { ToolRegistry } from '../registry/tool/execute.js';
3
+ import { ToolNameCollisionError, ToolRegistry } from '../registry/tool/execute.js';
4
4
  import { drainQuery } from '../runtime/query/index.js';
5
5
  import { PendingAnswers, QuestionParkBinding } from '../runtime/query/question-park.js';
6
6
  import { buildCoordinatorTools } from '../tools/coordinator/index.js';
@@ -108,6 +108,12 @@ export class SupervisorAgent extends AbstractAgent {
108
108
  remaining: config.tokenBudget,
109
109
  },
110
110
  factoryOptions: mergedFactoryOptions,
111
+ // The supervisor already hands this to its OWN run and its own
112
+ // coordinator tools; handing it to the spawn context is what
113
+ // makes a worker ask the same person the supervisor asks.
114
+ // Without it the two disagreed: the supervisor paused for a
115
+ // human and the workers it launched approved themselves.
116
+ ...(config.resumeHandler ? { resumeHandler: config.resumeHandler } : {}),
111
117
  tenantId,
112
118
  threadId,
113
119
  sessionId,
@@ -150,8 +156,58 @@ export class SupervisorAgent extends AbstractAgent {
150
156
  tools.register(tool, config.tools.getAvailability(tool.name));
151
157
  }
152
158
  }
159
+ // Registered the way every other kernel-mounted tool in this SDK is
160
+ // registered: honouring `runtimeToolOverrides`, and refusing to take a
161
+ // name the host already used.
162
+ //
163
+ // Both halves were missing here and nowhere else. `runtimeToolOverrides`
164
+ // is declared on `AgentInput`, is forwarded into this very `drainQuery`
165
+ // call below, and is consulted for the task tools and for the advisory
166
+ // tools — but the coordinator tools were registered before that and
167
+ // unconditionally, so `{ create_task: 'disabled' }` was honoured
168
+ // everywhere except the one surface a host would most want to decline.
169
+ // A run that must not delegate had prompt text and a gateway refusal as
170
+ // its only defences.
171
+ //
172
+ // Collision REFUSES rather than overwrites, and the principle is
173
+ // complete mediation rather than fail-safe defaults: "proposals to gain
174
+ // performance by remembering the result of an authority check [must] be
175
+ // examined skeptically. If a change in authority occurs, such remembered
176
+ // results must be systematically updated" (Saltzer & Schroeder 1975,
177
+ // §I.A.3(c)). A registry entry is a remembered binding of a name to an
178
+ // authority, and a later write that rebinds the name leaves every
179
+ // decision made about the old binding stale.
180
+ //
181
+ // The counter-argument is that today the host's tool merely loses
182
+ // quietly and the run still works, so six reserved names is a real cost
183
+ // on a name a consumer may have chosen long ago. It does not hold,
184
+ // because "loses quietly" is not what happens. `registerOne` ends with
185
+ // `availability.set(id, state)` and this call passes no state, so a tool
186
+ // the host registered `deferred` or `suspended` is silently PROMOTED to
187
+ // active under someone else's implementation; and because the store is a
188
+ // Map, the replacement inherits the host's insertion position in the
189
+ // prompt-cache prefix. That is a different authorization surface, not a
190
+ // lost registration. CWE-390 is the shape `ManagedRegistry` has here —
191
+ // detection of an error condition without action — and CWE-694's own
192
+ // mitigation is nearly this fix: do not operate any resource with a
193
+ // non-unique identifier, and report the error.
194
+ //
195
+ // Refusing is also what the peer set does. One runtime's registry
196
+ // primitive throws on both duplicate and reserved names; another refuses
197
+ // its injected delegation name in a pre-flight that tells the author to
198
+ // rename. Closer to home, `ProviderRegistry.register` already throws
199
+ // unless the caller passes `{ replace: true }` — declared intent is what
200
+ // separates a legitimate replacement from an accidental one, and no such
201
+ // intent is expressible here.
202
+ const overrides = input.runtimeToolOverrides;
153
203
  for (const tool of coordinatorToolDefs) {
154
- tools.register(tool);
204
+ const override = overrides?.[tool.name];
205
+ if (override === 'disabled')
206
+ continue;
207
+ if (config.tools?.has(tool.name)) {
208
+ throw new ToolNameCollisionError(tool.name, 'the supervisor coordinator surface');
209
+ }
210
+ tools.register(tool, override ?? 'active');
155
211
  }
156
212
  const childInvocationState = deriveChildState(config.invocationState ?? { tenantId }, this.metadata.id);
157
213
  const run = await drainQuery({
@@ -1 +1 @@
1
- {"version":3,"file":"SupervisorAgent.js","sourceRoot":"","sources":["../../src/agents/SupervisorAgent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAA;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AAEtD,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAA;AACvF,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAA;AAWrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAA;AAG/D,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAElD;;;;;;;;;;;;;;;G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,0 +1 @@
1
+ {"version":3,"file":"supervisor-coordinator-registration.test.d.ts","sourceRoot":"","sources":["../../../src/agents/__tests__/supervisor-coordinator-registration.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,122 @@
1
+ import { mkdtemp } from 'node:fs/promises';
2
+ import { tmpdir } from 'node:os';
3
+ import { join } from 'node:path';
4
+ import { describe, expect, it, vi } from 'vitest';
5
+ import { z } from 'zod';
6
+ import { MockLLMProvider } from '../../provider/mock.js';
7
+ import { ToolNameCollisionError, ToolRegistry } from '../../registry/tool/execute.js';
8
+ import { defineTool } from '../../tools/defineTool.js';
9
+ import { SupervisorAgent } from '../SupervisorAgent.js';
10
+ /**
11
+ * How the supervisor mounts its own coordinator tools.
12
+ *
13
+ * `runtimeToolOverrides` is this SDK's declared way for a host to decline a
14
+ * kernel-mounted tool. It is honoured for the task tools and the advisory
15
+ * tools inside `drainQuery`, and the supervisor forwards it there — but the
16
+ * supervisor registered the coordinator tools BEFORE that call and
17
+ * unconditionally, so `{ create_task: 'disabled' }` was obeyed everywhere
18
+ * except the one surface a host would most want to decline.
19
+ *
20
+ * The second case is the collision: `ManagedRegistry` warns and overwrites, so
21
+ * a host tool sharing a coordinator name vanished into a log line and the
22
+ * model kept a `create_task` whose behaviour depended on registration order.
23
+ */
24
+ const HOST_TOOL_DESCRIPTION = 'a tool this host registered deliberately';
25
+ function stubManager() {
26
+ return {
27
+ sendMessage: vi.fn(async () => ({ taskId: 'task_1', status: 'completed' })),
28
+ await: vi.fn(async () => undefined),
29
+ cancel: vi.fn(),
30
+ dispose: vi.fn(),
31
+ on: vi.fn(),
32
+ off: vi.fn(),
33
+ };
34
+ }
35
+ const hostTool = (name) => defineTool({
36
+ name,
37
+ description: HOST_TOOL_DESCRIPTION,
38
+ inputSchema: z.object({}),
39
+ category: 'custom',
40
+ permissions: [],
41
+ readOnly: true,
42
+ destructive: false,
43
+ concurrencySafe: true,
44
+ async execute() {
45
+ return { success: true, output: 'host tool ran' };
46
+ },
47
+ });
48
+ async function runWith(options) {
49
+ const agent = new SupervisorAgent({
50
+ id: 'supervisor',
51
+ name: 'Supervisor',
52
+ version: '1',
53
+ category: 'test',
54
+ description: 'coordinates workers',
55
+ });
56
+ const provider = new MockLLMProvider({ turns: [{ text: 'nothing to delegate' }] });
57
+ const tools = new ToolRegistry();
58
+ for (const name of options.hostTools ?? [])
59
+ tools.register(hostTool(name));
60
+ await agent.run({
61
+ messages: [{ role: 'user', content: 'go', timestamp: 1 }],
62
+ workingDirectory: await mkdtemp(join(tmpdir(), 'namzu-sup-reg-')),
63
+ ...(options.runtimeToolOverrides
64
+ ? { runtimeToolOverrides: options.runtimeToolOverrides }
65
+ : {}),
66
+ }, {
67
+ provider,
68
+ agentIds: ['worker'],
69
+ agentManager: stubManager(),
70
+ tools,
71
+ systemPrompt: 'You coordinate.',
72
+ model: 'mock-model',
73
+ tokenBudget: 100_000,
74
+ timeoutMs: 30_000,
75
+ maxIterations: 2,
76
+ sessionId: 'ses_sup',
77
+ threadId: 'thd_sup',
78
+ projectId: 'prj_sup',
79
+ tenantId: 'tnt_sup',
80
+ });
81
+ const advertised = provider.requests[0]?.tools ?? [];
82
+ return {
83
+ names: new Set(advertised.map((t) => t.function.name)),
84
+ describedAs: (name) => advertised.find((t) => t.function.name === name)?.function.description ?? '',
85
+ };
86
+ }
87
+ describe('supervisor coordinator-tool registration', () => {
88
+ it('advertises create_task by default', async () => {
89
+ expect((await runWith({})).names).toContain('create_task');
90
+ });
91
+ it('does not advertise a coordinator tool the host disabled', async () => {
92
+ const { names } = await runWith({ runtimeToolOverrides: { create_task: 'disabled' } });
93
+ expect(names).not.toContain('create_task');
94
+ // Declining one coordinator tool must not decline the rest.
95
+ expect(names).toContain('agent_task_list');
96
+ });
97
+ it('leaves a host tool that shares no coordinator name alone', async () => {
98
+ const { names } = await runWith({ hostTools: ['host_only'] });
99
+ expect(names).toContain('host_only');
100
+ expect(names).toContain('create_task');
101
+ });
102
+ it('refuses to take a name the host already registered', async () => {
103
+ // Named and carrying the name, so a host can catch it narrowly rather
104
+ // than match on message text — the shape `DuplicateProviderError`
105
+ // already set in this repo.
106
+ await expect(runWith({ hostTools: ['create_task'] })).rejects.toThrow(ToolNameCollisionError);
107
+ await expect(runWith({ hostTools: ['create_task'] })).rejects.toThrow(/runtimeToolOverrides: \{ "create_task": "disabled" \}/);
108
+ });
109
+ it('lets the host keep its own tool under that name by declining the coordinator one', async () => {
110
+ const { names, describedAs } = await runWith({
111
+ hostTools: ['create_task'],
112
+ runtimeToolOverrides: { create_task: 'disabled' },
113
+ });
114
+ expect(names).toContain('create_task');
115
+ expect(names).toContain('agent_task_list');
116
+ // The name surviving is not the assertion — WHOSE tool holds it is.
117
+ // Overwriting also leaves the name present, so a membership check
118
+ // alone passes against the very behaviour this replaces.
119
+ expect(describedAs('create_task')).toBe(HOST_TOOL_DESCRIPTION);
120
+ });
121
+ });
122
+ //# sourceMappingURL=supervisor-coordinator-registration.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"supervisor-coordinator-registration.test.js","sourceRoot":"","sources":["../../../src/agents/__tests__/supervisor-coordinator-registration.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AACjD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAA;AACrF,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAEvD;;;;;;;;;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CAAC,sBAAsB,CAAC,CAAA;QAC7F,MAAM,MAAM,CAAC,OAAO,CAAC,EAAE,SAAS,EAAE,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CACpE,uDAAuD,CACvD,CAAA;IACF,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,kFAAkF,EAAE,KAAK,IAAI,EAAE;QACjG,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,MAAM,OAAO,CAAC;YAC5C,SAAS,EAAE,CAAC,aAAa,CAAC;YAC1B,oBAAoB,EAAE,EAAE,WAAW,EAAE,UAAU,EAAE;SACjD,CAAC,CAAA;QAEF,MAAM,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,aAAa,CAAC,CAAA;QACtC,MAAM,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAA;QAC1C,oEAAoE;QACpE,kEAAkE;QAClE,yDAAyD;QACzD,MAAM,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAA;IAC/D,CAAC,CAAC,CAAA;AACH,CAAC,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=supervisor-hands-down-hitl.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"supervisor-hands-down-hitl.test.d.ts","sourceRoot":"","sources":["../../../src/agents/__tests__/supervisor-hands-down-hitl.test.ts"],"names":[],"mappings":""}