@namzu/sdk 7.0.0 → 8.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 (128) hide show
  1. package/CHANGELOG.md +437 -0
  2. package/dist/agents/SupervisorAgent.d.ts.map +1 -1
  3. package/dist/agents/SupervisorAgent.js +172 -162
  4. package/dist/agents/SupervisorAgent.js.map +1 -1
  5. package/dist/agents/__tests__/supervisor-inbox-scope.test.d.ts +2 -0
  6. package/dist/agents/__tests__/supervisor-inbox-scope.test.d.ts.map +1 -0
  7. package/dist/agents/__tests__/supervisor-inbox-scope.test.js +125 -0
  8. package/dist/agents/__tests__/supervisor-inbox-scope.test.js.map +1 -0
  9. package/dist/bridge/a2a/mapper.d.ts.map +1 -1
  10. package/dist/bridge/a2a/mapper.js +4 -0
  11. package/dist/bridge/a2a/mapper.js.map +1 -1
  12. package/dist/bridge/sse/mapper.d.ts.map +1 -1
  13. package/dist/bridge/sse/mapper.js +24 -0
  14. package/dist/bridge/sse/mapper.js.map +1 -1
  15. package/dist/contracts/api.d.ts +1 -1
  16. package/dist/contracts/api.d.ts.map +1 -1
  17. package/dist/gateway/__tests__/completion-inbox.test.js +292 -2
  18. package/dist/gateway/__tests__/completion-inbox.test.js.map +1 -1
  19. package/dist/gateway/completion-inbox.d.ts +94 -6
  20. package/dist/gateway/completion-inbox.d.ts.map +1 -1
  21. package/dist/gateway/completion-inbox.js +235 -15
  22. package/dist/gateway/completion-inbox.js.map +1 -1
  23. package/dist/manager/run/persistence.d.ts +8 -0
  24. package/dist/manager/run/persistence.d.ts.map +1 -1
  25. package/dist/manager/run/persistence.js +12 -0
  26. package/dist/manager/run/persistence.js.map +1 -1
  27. package/dist/run/reporter.d.ts.map +1 -1
  28. package/dist/run/reporter.js +11 -0
  29. package/dist/run/reporter.js.map +1 -1
  30. package/dist/runtime/query/__tests__/completion-does-not-erase-the-answer.test.d.ts +2 -0
  31. package/dist/runtime/query/__tests__/completion-does-not-erase-the-answer.test.d.ts.map +1 -0
  32. package/dist/runtime/query/__tests__/completion-does-not-erase-the-answer.test.js +142 -0
  33. package/dist/runtime/query/__tests__/completion-does-not-erase-the-answer.test.js.map +1 -0
  34. package/dist/runtime/query/__tests__/completion-notification.test.js +414 -32
  35. package/dist/runtime/query/__tests__/completion-notification.test.js.map +1 -1
  36. package/dist/runtime/query/__tests__/context-size-on-the-wire.test.d.ts +2 -0
  37. package/dist/runtime/query/__tests__/context-size-on-the-wire.test.d.ts.map +1 -0
  38. package/dist/runtime/query/__tests__/context-size-on-the-wire.test.js +100 -0
  39. package/dist/runtime/query/__tests__/context-size-on-the-wire.test.js.map +1 -0
  40. package/dist/runtime/query/guard.d.ts +28 -0
  41. package/dist/runtime/query/guard.d.ts.map +1 -1
  42. package/dist/runtime/query/guard.js +31 -0
  43. package/dist/runtime/query/guard.js.map +1 -1
  44. package/dist/runtime/query/iteration/__tests__/settle-grace.test.d.ts +2 -0
  45. package/dist/runtime/query/iteration/__tests__/settle-grace.test.d.ts.map +1 -0
  46. package/dist/runtime/query/iteration/__tests__/settle-grace.test.js +226 -0
  47. package/dist/runtime/query/iteration/__tests__/settle-grace.test.js.map +1 -0
  48. package/dist/runtime/query/iteration/index.d.ts +92 -0
  49. package/dist/runtime/query/iteration/index.d.ts.map +1 -1
  50. package/dist/runtime/query/iteration/index.js +814 -566
  51. package/dist/runtime/query/iteration/index.js.map +1 -1
  52. package/dist/runtime/query/iteration/phases/__tests__/compaction-declined.test.d.ts +2 -0
  53. package/dist/runtime/query/iteration/phases/__tests__/compaction-declined.test.d.ts.map +1 -0
  54. package/dist/runtime/query/iteration/phases/__tests__/compaction-declined.test.js +95 -0
  55. package/dist/runtime/query/iteration/phases/__tests__/compaction-declined.test.js.map +1 -0
  56. package/dist/runtime/query/iteration/phases/compaction.d.ts +34 -0
  57. package/dist/runtime/query/iteration/phases/compaction.d.ts.map +1 -1
  58. package/dist/runtime/query/iteration/phases/compaction.js +61 -4
  59. package/dist/runtime/query/iteration/phases/compaction.js.map +1 -1
  60. package/dist/tools/__tests__/untrusted-envelope.test.js +16 -0
  61. package/dist/tools/__tests__/untrusted-envelope.test.js.map +1 -1
  62. package/dist/tools/coordinator/__tests__/completion-delivery.test.js +117 -0
  63. package/dist/tools/coordinator/__tests__/completion-delivery.test.js.map +1 -1
  64. package/dist/tools/coordinator/__tests__/task-list.test.js +57 -0
  65. package/dist/tools/coordinator/__tests__/task-list.test.js.map +1 -1
  66. package/dist/tools/coordinator/index.d.ts.map +1 -1
  67. package/dist/tools/coordinator/index.js +109 -11
  68. package/dist/tools/coordinator/index.js.map +1 -1
  69. package/dist/tools/untrusted-envelope.d.ts.map +1 -1
  70. package/dist/tools/untrusted-envelope.js +9 -1
  71. package/dist/tools/untrusted-envelope.js.map +1 -1
  72. package/dist/types/agent/gateway.d.ts +18 -0
  73. package/dist/types/agent/gateway.d.ts.map +1 -1
  74. package/dist/types/provider/interface.d.ts +35 -0
  75. package/dist/types/provider/interface.d.ts.map +1 -1
  76. package/dist/types/run/entity.d.ts +16 -0
  77. package/dist/types/run/entity.d.ts.map +1 -1
  78. package/dist/types/run/events.d.ts +75 -0
  79. package/dist/types/run/events.d.ts.map +1 -1
  80. package/dist/types/run/events.js.map +1 -1
  81. package/dist/types/run/prepare-step.d.ts +17 -2
  82. package/dist/types/run/prepare-step.d.ts.map +1 -1
  83. package/dist/types/verification/index.d.ts +98 -0
  84. package/dist/types/verification/index.d.ts.map +1 -1
  85. package/dist/types/verification/index.js +10 -0
  86. package/dist/types/verification/index.js.map +1 -1
  87. package/dist/verification/__tests__/argument-pattern.test.d.ts +2 -0
  88. package/dist/verification/__tests__/argument-pattern.test.d.ts.map +1 -0
  89. package/dist/verification/__tests__/argument-pattern.test.js +122 -0
  90. package/dist/verification/__tests__/argument-pattern.test.js.map +1 -0
  91. package/dist/verification/gate.d.ts.map +1 -1
  92. package/dist/verification/gate.js +44 -0
  93. package/dist/verification/gate.js.map +1 -1
  94. package/dist/verification/rules.d.ts.map +1 -1
  95. package/dist/verification/rules.js +27 -0
  96. package/dist/verification/rules.js.map +1 -1
  97. package/package.json +1 -1
  98. package/src/agents/SupervisorAgent.ts +175 -166
  99. package/src/agents/__tests__/supervisor-inbox-scope.test.ts +149 -0
  100. package/src/bridge/a2a/mapper.ts +4 -0
  101. package/src/bridge/sse/mapper.ts +25 -0
  102. package/src/contracts/api.ts +1 -0
  103. package/src/gateway/__tests__/completion-inbox.test.ts +348 -2
  104. package/src/gateway/completion-inbox.ts +248 -16
  105. package/src/manager/run/persistence.ts +12 -0
  106. package/src/run/reporter.ts +12 -0
  107. package/src/runtime/query/__tests__/completion-does-not-erase-the-answer.test.ts +163 -0
  108. package/src/runtime/query/__tests__/completion-notification.test.ts +486 -34
  109. package/src/runtime/query/__tests__/context-size-on-the-wire.test.ts +122 -0
  110. package/src/runtime/query/guard.ts +32 -0
  111. package/src/runtime/query/iteration/__tests__/settle-grace.test.ts +265 -0
  112. package/src/runtime/query/iteration/index.ts +902 -636
  113. package/src/runtime/query/iteration/phases/__tests__/compaction-declined.test.ts +124 -0
  114. package/src/runtime/query/iteration/phases/compaction.ts +83 -10
  115. package/src/tools/__tests__/untrusted-envelope.test.ts +23 -0
  116. package/src/tools/coordinator/__tests__/completion-delivery.test.ts +147 -0
  117. package/src/tools/coordinator/__tests__/task-list.test.ts +72 -0
  118. package/src/tools/coordinator/index.ts +122 -15
  119. package/src/tools/untrusted-envelope.ts +9 -1
  120. package/src/types/agent/gateway.ts +18 -0
  121. package/src/types/provider/interface.ts +39 -0
  122. package/src/types/run/entity.ts +17 -0
  123. package/src/types/run/events.ts +75 -0
  124. package/src/types/run/prepare-step.ts +17 -2
  125. package/src/types/verification/index.ts +61 -0
  126. package/src/verification/__tests__/argument-pattern.test.ts +158 -0
  127. package/src/verification/gate.ts +45 -0
  128. package/src/verification/rules.ts +28 -0
@@ -30,6 +30,13 @@ export function describeRule(rule) {
30
30
  return `allowed by category (${rule.categories.join(', ')})`;
31
31
  case 'allow_by_tier':
32
32
  return `allowed by tier (${rule.tiers.join(', ')})`;
33
+ case 'argument_pattern': {
34
+ // Names the argument, not just the pattern. That is what tells a
35
+ // model whether a different value could get through — which is the
36
+ // difference between rewording once and rewording forever.
37
+ const verb = rule.decision === 'deny' ? 'denied' : 'allowed';
38
+ return `${verb} because the \`${rule.argument}\` argument matched ${rule.pattern} (this rule applies to ${rule.toolNames.join(', ')})`;
39
+ }
33
40
  case 'custom_pattern': {
34
41
  const where = rule.target === 'both' ? 'name or arguments' : rule.target;
35
42
  const verb = rule.decision === 'deny' ? 'denied' : 'allowed';
@@ -104,6 +111,43 @@ export class VerificationGate {
104
111
  });
105
112
  }
106
113
  }
114
+ if (rule.type === 'argument_pattern') {
115
+ // Needs BOTH, because it is the rule that names both.
116
+ //
117
+ // The name set is recorded only after the pattern compiles, so
118
+ // a rule with a typo'd regex leaves neither half behind. That
119
+ // ordering is defence in depth and NOT what makes the guarantee
120
+ // — `evaluateRule` returns null on a missing compiled pattern
121
+ // before it ever looks at the name set, so reversing these two
122
+ // lines changes no behaviour. Measured: reversing them fails no
123
+ // test, and the test that looks like it covers this is really
124
+ // covering the check in `evaluateRule`.
125
+ //
126
+ // Written down because the alternative is someone later reading
127
+ // the order as load-bearing and preserving it for the wrong
128
+ // reason, or removing the real check believing this one covers
129
+ // it.
130
+ if (rule.pattern.length > MAX_CUSTOM_PATTERN_LENGTH) {
131
+ this.log.warn('Argument pattern exceeds max length, skipping', {
132
+ index: i,
133
+ length: rule.pattern.length,
134
+ maxLength: MAX_CUSTOM_PATTERN_LENGTH,
135
+ });
136
+ continue;
137
+ }
138
+ try {
139
+ const compiled = new RegExp(rule.pattern);
140
+ this.compiledPatterns.set(i, compiled);
141
+ this.nameSets.set(i, new Set(rule.toolNames));
142
+ }
143
+ catch (err) {
144
+ this.log.warn('Invalid argument pattern regex, skipping', {
145
+ index: i,
146
+ pattern: rule.pattern,
147
+ error: err instanceof Error ? err.message : String(err),
148
+ });
149
+ }
150
+ }
107
151
  if (rule.type === 'allow_by_name') {
108
152
  this.nameSets.set(i, new Set(rule.toolNames));
109
153
  }
@@ -1 +1 @@
1
- {"version":3,"file":"gate.js","sourceRoot":"","sources":["../../src/verification/gate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAA;AAO9E,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAA;AAE7E,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAQzC;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,YAAY,CAAC,IAAsB;IAClD,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;QACnB,KAAK,yBAAyB;YAC7B,OAAO,kFAAkF,CAAA;QAC1F,KAAK,iBAAiB;YACrB,OAAO,yCAAyC,CAAA;QACjD,KAAK,eAAe;YACnB,OAAO,oBAAoB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAA;QACxD,KAAK,cAAc;YAClB,OAAO,mBAAmB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,gFAAgF,CAAA;QACpI,KAAK,mBAAmB;YACvB,OAAO,wBAAwB,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAA;QAC7D,KAAK,eAAe;YACnB,OAAO,oBAAoB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAA;QACpD,KAAK,gBAAgB,CAAC,CAAC,CAAC;YACvB,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAA;YACxE,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAA;YAC5D,OAAO,GAAG,IAAI,mCAAmC,KAAK,KAAK,IA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AC;QAED,OAAO,MAAM,CAAA;IACd,CAAC;CACD"}
@@ -1 +1 @@
1
- {"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../../src/verification/rules.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AAEpF,wBAAgB,YAAY,CAC3B,IAAI,EAAE,gBAAgB,EACtB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,OAAO,EAClB,OAAO,EAAE,cAAc,GAAG,SAAS,EACnC,eAAe,CAAC,EAAE,MAAM,EACxB,OAAO,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,GACnB,YAAY,GAAG,IAAI,CAkErB"}
1
+ {"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../../src/verification/rules.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AAEpF,wBAAgB,YAAY,CAC3B,IAAI,EAAE,gBAAgB,EACtB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,OAAO,EAClB,OAAO,EAAE,cAAc,GAAG,SAAS,EACnC,eAAe,CAAC,EAAE,MAAM,EACxB,OAAO,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,GACnB,YAAY,GAAG,IAAI,CA8FrB"}
@@ -46,6 +46,33 @@ export function evaluateRule(rule, toolName, toolInput, toolDef, compiledPattern
46
46
  }
47
47
  return compiledPattern.test(target) ? rule.decision : null;
48
48
  }
49
+ case 'argument_pattern': {
50
+ if (!compiledPattern)
51
+ return null;
52
+ if (!nameSet?.has(toolName))
53
+ return null;
54
+ if (typeof toolInput !== 'object' || toolInput === null)
55
+ return null;
56
+ const value = toolInput[rule.argument];
57
+ // The subject is the argument's own value, which is the whole point
58
+ // — `^git push` here means what a reader expects, where the same
59
+ // pattern against the serialised object could never match.
60
+ //
61
+ // Numbers and booleans are rendered rather than skipped, because
62
+ // `String(4000)` is unambiguous and anchorable. Objects and arrays
63
+ // are NOT: no string a pattern could match says anything true about
64
+ // a structured value, and serialising one would put us back where
65
+ // `custom_pattern` already is. A rule about the shape of an input
66
+ // is a rule about the tool, and `deny_by_name` is where it belongs.
67
+ const subject = typeof value === 'string'
68
+ ? value
69
+ : typeof value === 'number' || typeof value === 'boolean'
70
+ ? String(value)
71
+ : undefined;
72
+ if (subject === undefined)
73
+ return null;
74
+ return compiledPattern.test(subject) ? rule.decision : null;
75
+ }
49
76
  case 'allow_by_tier': {
50
77
  if (toolDef?.tier && rule.tiers.includes(toolDef.tier)) {
51
78
  return 'allow';
@@ -1 +1 @@
1
- {"version":3,"file":"rules.js","sourceRoot":"","sources":["../../src/verification/rules.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAA;AAIhE,MAAM,UAAU,YAAY,CAC3B,IAAsB,EACtB,QAAgB,EAChB,SAAkB,EAClB,OAAmC,EACnC,eAAwB,EACxB,OAAqB;IAErB,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;QACnB,KAAK,iBAAiB,CAAC,CAAC,CAAC;YACxB,OAAO,OAAO,EAAE,UAAU,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAA;QACzD,CAAC;QAED,KAAK,yBAAyB,CAAC,CAAC,CAAC;YAChC,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAA;YAC5C,KAAK,MAAM,OAAO,IAAI,kBAAkB,EAAE,CAAC;gBAC1C,IAAI,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;oBAC9B,OAAO,MAAM,CAAA;gBACd,CAAC;YACF,CAAC;YACD,OAAO,IAAI,CAAA;QACZ,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  {
2
2
  "name": "@namzu/sdk",
3
- "version": "7.0.0",
3
+ "version": "8.0.0",
4
4
  "description": "Open-source AI agent SDK with a built-in runtime. Nothing between you and your agents.",
5
5
  "license": "FSL-1.1-MIT",
6
6
  "type": "module",
@@ -185,181 +185,190 @@ export class SupervisorAgent extends AbstractAgent<SupervisorAgentConfig, Superv
185
185
  const completionInbox = new CompletionInbox()
186
186
  completionInbox.attach(gateway)
187
187
 
188
- const coordinatorToolDefs = buildCoordinatorTools({
189
- gateway,
190
- completionInbox,
191
- workingDirectory: input.workingDirectory,
192
- runtimeContext: input.runtimeContext,
193
- allowedAgentIds: config.agentIds,
194
- // The only hop between the config and the decision. Omit it and
195
- // everything still compiles: the field is settable, documented, and
196
- // read by nothing — which is the shape of a declaration this repo
197
- // has had to go and delete before.
198
- allowDelegation: config.allowDelegation,
199
- taskStore: input.taskStore,
200
- runId,
201
- getPlanManager: () => planManagerRef,
202
- onTaskLaunched: (agentTaskId, meta) => {
203
- launchedTasks.set(agentTaskId, meta)
204
- },
205
- // With a resume handler present the coordinator surface gains
206
- // ask_user_question — the model can park the run on a question
207
- // routed through the same HITL channel as plan approvals.
208
- ...(config.resumeHandler ? { resumeHandler: config.resumeHandler } : {}),
209
- questionParks,
210
- pendingAnswers,
211
- })
188
+ // From here to the return in a try/finally, so the listener is released
189
+ // on every way out. The registration loop below can throw
190
+ // ToolNameCollisionError, and a host that hits that fixes its config and
191
+ // runs again — which is how a leak of one listener per run becomes a leak
192
+ // of one per ATTEMPT.
193
+ try {
194
+ const coordinatorToolDefs = buildCoordinatorTools({
195
+ gateway,
196
+ completionInbox,
197
+ workingDirectory: input.workingDirectory,
198
+ runtimeContext: input.runtimeContext,
199
+ allowedAgentIds: config.agentIds,
200
+ // The only hop between the config and the decision. Omit it and
201
+ // everything still compiles: the field is settable, documented, and
202
+ // read by nothing — which is the shape of a declaration this repo
203
+ // has had to go and delete before.
204
+ allowDelegation: config.allowDelegation,
205
+ taskStore: input.taskStore,
206
+ runId,
207
+ getPlanManager: () => planManagerRef,
208
+ onTaskLaunched: (agentTaskId, meta) => {
209
+ launchedTasks.set(agentTaskId, meta)
210
+ },
211
+ // With a resume handler present the coordinator surface gains
212
+ // ask_user_question — the model can park the run on a question
213
+ // routed through the same HITL channel as plan approvals.
214
+ ...(config.resumeHandler ? { resumeHandler: config.resumeHandler } : {}),
215
+ questionParks,
216
+ pendingAnswers,
217
+ })
212
218
 
213
- const tools = new ToolRegistry()
214
- if (config.tools) {
215
- for (const tool of config.tools.getAll()) {
216
- tools.register(tool, config.tools.getAvailability(tool.name))
219
+ const tools = new ToolRegistry()
220
+ if (config.tools) {
221
+ for (const tool of config.tools.getAll()) {
222
+ tools.register(tool, config.tools.getAvailability(tool.name))
223
+ }
217
224
  }
218
- }
219
- // Registered the way every other kernel-mounted tool in this SDK is
220
- // registered: honouring `runtimeToolOverrides`, and refusing to take a
221
- // name the host already used.
222
- //
223
- // Both halves were missing here and nowhere else. `runtimeToolOverrides`
224
- // is declared on `AgentInput`, is forwarded into this very `drainQuery`
225
- // call below, and is consulted for the task tools and for the advisory
226
- // tools but the coordinator tools were registered before that and
227
- // unconditionally, so `{ create_task: 'disabled' }` was honoured
228
- // everywhere except the one surface a host would most want to decline.
229
- // A run that must not delegate had prompt text and a gateway refusal as
230
- // its only defences.
231
- //
232
- // Collision REFUSES rather than overwrites, and the principle is
233
- // complete mediation rather than fail-safe defaults: "proposals to gain
234
- // performance by remembering the result of an authority check [must] be
235
- // examined skeptically. If a change in authority occurs, such remembered
236
- // results must be systematically updated" (Saltzer & Schroeder 1975,
237
- // §I.A.3(c)). A registry entry is a remembered binding of a name to an
238
- // authority, and a later write that rebinds the name leaves every
239
- // decision made about the old binding stale.
240
- //
241
- // The counter-argument is that today the host's tool merely loses
242
- // quietly and the run still works, so six reserved names is a real cost
243
- // on a name a consumer may have chosen long ago. It does not hold,
244
- // because "loses quietly" is not what happens. `registerOne` ends with
245
- // `availability.set(id, state)` and this call passes no state, so a tool
246
- // the host registered `deferred` or `suspended` is silently PROMOTED to
247
- // active under someone else's implementation; and because the store is a
248
- // Map, the replacement inherits the host's insertion position in the
249
- // prompt-cache prefix. That is a different authorization surface, not a
250
- // lost registration. CWE-390 is the shape `ManagedRegistry` has here
251
- // detection of an error condition without action and CWE-694's own
252
- // mitigation is nearly this fix: do not operate any resource with a
253
- // non-unique identifier, and report the error.
254
- //
255
- // Refusing is also what the peer set does. One runtime's registry
256
- // primitive throws on both duplicate and reserved names; another refuses
257
- // its injected delegation name in a pre-flight that tells the author to
258
- // rename. Closer to home, `ProviderRegistry.register` already throws
259
- // unless the caller passes `{ replace: true }` declared intent is what
260
- // separates a legitimate replacement from an accidental one, and no such
261
- // intent is expressible here.
262
- const overrides = input.runtimeToolOverrides
263
- for (const tool of coordinatorToolDefs) {
264
- const override = overrides?.[tool.name]
265
- if (override === 'disabled') continue
266
- if (config.tools?.has(tool.name)) {
267
- throw new ToolNameCollisionError(tool.name, 'the supervisor coordinator surface')
225
+ // Registered the way every other kernel-mounted tool in this SDK is
226
+ // registered: honouring `runtimeToolOverrides`, and refusing to take a
227
+ // name the host already used.
228
+ //
229
+ // Both halves were missing here and nowhere else. `runtimeToolOverrides`
230
+ // is declared on `AgentInput`, is forwarded into this very `drainQuery`
231
+ // call below, and is consulted for the task tools and for the advisory
232
+ // tools but the coordinator tools were registered before that and
233
+ // unconditionally, so `{ create_task: 'disabled' }` was honoured
234
+ // everywhere except the one surface a host would most want to decline.
235
+ // A run that must not delegate had prompt text and a gateway refusal as
236
+ // its only defences.
237
+ //
238
+ // Collision REFUSES rather than overwrites, and the principle is
239
+ // complete mediation rather than fail-safe defaults: "proposals to gain
240
+ // performance by remembering the result of an authority check [must] be
241
+ // examined skeptically. If a change in authority occurs, such remembered
242
+ // results must be systematically updated" (Saltzer & Schroeder 1975,
243
+ // §I.A.3(c)). A registry entry is a remembered binding of a name to an
244
+ // authority, and a later write that rebinds the name leaves every
245
+ // decision made about the old binding stale.
246
+ //
247
+ // The counter-argument is that today the host's tool merely loses
248
+ // quietly and the run still works, so six reserved names is a real cost
249
+ // on a name a consumer may have chosen long ago. It does not hold,
250
+ // because "loses quietly" is not what happens. `registerOne` ends with
251
+ // `availability.set(id, state)` and this call passes no state, so a tool
252
+ // the host registered `deferred` or `suspended` is silently PROMOTED to
253
+ // active under someone else's implementation; and because the store is a
254
+ // Map, the replacement inherits the host's insertion position in the
255
+ // prompt-cache prefix. That is a different authorization surface, not a
256
+ // lost registration. CWE-390 is the shape `ManagedRegistry` has here
257
+ // detection of an error condition without action and CWE-694's own
258
+ // mitigation is nearly this fix: do not operate any resource with a
259
+ // non-unique identifier, and report the error.
260
+ //
261
+ // Refusing is also what the peer set does. One runtime's registry
262
+ // primitive throws on both duplicate and reserved names; another refuses
263
+ // its injected delegation name in a pre-flight that tells the author to
264
+ // rename. Closer to home, `ProviderRegistry.register` already throws
265
+ // unless the caller passes `{ replace: true }` declared intent is what
266
+ // separates a legitimate replacement from an accidental one, and no such
267
+ // intent is expressible here.
268
+ const overrides = input.runtimeToolOverrides
269
+ for (const tool of coordinatorToolDefs) {
270
+ const override = overrides?.[tool.name]
271
+ if (override === 'disabled') continue
272
+ if (config.tools?.has(tool.name)) {
273
+ throw new ToolNameCollisionError(tool.name, 'the supervisor coordinator surface')
274
+ }
275
+ tools.register(tool, override ?? 'active')
268
276
  }
269
- tools.register(tool, override ?? 'active')
270
- }
271
277
 
272
- const childInvocationState = deriveChildState(
273
- config.invocationState ?? { tenantId },
274
- this.metadata.id,
275
- )
278
+ const childInvocationState = deriveChildState(
279
+ config.invocationState ?? { tenantId },
280
+ this.metadata.id,
281
+ )
276
282
 
277
- const run = await drainQuery(
278
- {
279
- systemPrompt: config.systemPrompt,
280
- skills: config.skills,
281
- provider: config.provider,
282
- tools,
283
- runConfig: {
284
- model: config.model,
285
- tokenBudget: config.tokenBudget,
286
- timeoutMs: config.timeoutMs,
287
- maxIterations: config.maxIterations,
288
- temperature: config.temperature,
289
- env: config.env,
290
- // See ReactiveAgent: a hand-listed literal drops what nobody
291
- // remembered to add, and reports nothing when it does.
292
- ...(config.thinking ? { thinking: config.thinking } : {}),
293
- ...(config.effort ? { effort: config.effort } : {}),
294
- },
295
- questionParks,
296
- pendingAnswers,
297
- agentId: this.metadata.id,
298
- agentName: this.metadata.name,
299
- workingDirectory: input.workingDirectory,
300
- messages: input.messages,
301
- signal: input.signal,
302
- sessionId,
303
- threadId,
304
- projectId,
305
- tenantId,
306
- runId,
307
- parentRunId: config.parentRunId,
308
- depth: config.depth,
309
- contextLevel: 'full',
310
- onContextCreated: ({ planManager }) => {
311
- planManagerRef = planManager
283
+ const run = await drainQuery(
284
+ {
285
+ systemPrompt: config.systemPrompt,
286
+ skills: config.skills,
287
+ provider: config.provider,
288
+ tools,
289
+ runConfig: {
290
+ model: config.model,
291
+ tokenBudget: config.tokenBudget,
292
+ timeoutMs: config.timeoutMs,
293
+ maxIterations: config.maxIterations,
294
+ temperature: config.temperature,
295
+ env: config.env,
296
+ // See ReactiveAgent: a hand-listed literal drops what nobody
297
+ // remembered to add, and reports nothing when it does.
298
+ ...(config.thinking ? { thinking: config.thinking } : {}),
299
+ ...(config.effort ? { effort: config.effort } : {}),
300
+ },
301
+ questionParks,
302
+ pendingAnswers,
303
+ agentId: this.metadata.id,
304
+ agentName: this.metadata.name,
305
+ workingDirectory: input.workingDirectory,
306
+ messages: input.messages,
307
+ signal: input.signal,
308
+ sessionId,
309
+ threadId,
310
+ projectId,
311
+ tenantId,
312
+ runId,
313
+ parentRunId: config.parentRunId,
314
+ depth: config.depth,
315
+ contextLevel: 'full',
316
+ onContextCreated: ({ planManager }) => {
317
+ planManagerRef = planManager
318
+ },
319
+ taskStore: input.taskStore,
320
+ runtimeToolOverrides: input.runtimeToolOverrides,
321
+ runtimeContext: input.runtimeContext,
322
+ taskGateway: gateway,
323
+ completionInbox,
324
+ launchedTasks,
325
+ advisory: config.advisory,
326
+ invocationState: childInvocationState,
327
+ // HITL surface: forward optional review-time hooks so hosts can
328
+ // run "Ask before acting" supervisors instead of the default
329
+ // auto-approve. drainQuery falls back to autoApproveHandler
330
+ // when resumeHandler is omitted (= same behaviour as before).
331
+ ...(config.resumeHandler ? { resumeHandler: config.resumeHandler } : {}),
332
+ // Forwarded for the same reason the handler is. A capability the
333
+ // kernel honours in `drainQuery` but that never reaches the
334
+ // surface a host actually constructs is a capability nobody can
335
+ // use — which is the shape of defect this file has already been
336
+ // corrected for twice.
337
+ ...(config.steering ? { steering: config.steering } : {}),
338
+ ...(config.verificationGate ? { verificationGate: config.verificationGate } : {}),
339
+ ...(config.sandboxProvider ? { sandboxProvider: config.sandboxProvider } : {}),
340
+ // Working-memory / compaction seam (optional; absent => unchanged
341
+ // run path, byte-identical for every existing consumer).
342
+ ...(config.compactionConfig ? { compactionConfig: config.compactionConfig } : {}),
343
+ ...(config.workingMemoryProvider
344
+ ? { workingMemoryProvider: config.workingMemoryProvider }
345
+ : {}),
312
346
  },
313
- taskStore: input.taskStore,
314
- runtimeToolOverrides: input.runtimeToolOverrides,
315
- runtimeContext: input.runtimeContext,
316
- taskGateway: gateway,
317
- completionInbox,
318
- launchedTasks,
319
- advisory: config.advisory,
320
- invocationState: childInvocationState,
321
- // HITL surface: forward optional review-time hooks so hosts can
322
- // run "Ask before acting" supervisors instead of the default
323
- // auto-approve. drainQuery falls back to autoApproveHandler
324
- // when resumeHandler is omitted (= same behaviour as before).
325
- ...(config.resumeHandler ? { resumeHandler: config.resumeHandler } : {}),
326
- // Forwarded for the same reason the handler is. A capability the
327
- // kernel honours in `drainQuery` but that never reaches the
328
- // surface a host actually constructs is a capability nobody can
329
- // use — which is the shape of defect this file has already been
330
- // corrected for twice.
331
- ...(config.steering ? { steering: config.steering } : {}),
332
- ...(config.verificationGate ? { verificationGate: config.verificationGate } : {}),
333
- ...(config.sandboxProvider ? { sandboxProvider: config.sandboxProvider } : {}),
334
- // Working-memory / compaction seam (optional; absent => unchanged
335
- // run path, byte-identical for every existing consumer).
336
- ...(config.compactionConfig ? { compactionConfig: config.compactionConfig } : {}),
337
- ...(config.workingMemoryProvider
338
- ? { workingMemoryProvider: config.workingMemoryProvider }
339
- : {}),
340
- },
341
- listener,
342
- )
347
+ listener,
348
+ )
343
349
 
344
- const taskHandles = gateway.listTasks()
345
- const taskResults = synthesizeTaskResults(taskHandles, runId)
350
+ const taskHandles = gateway.listTasks()
351
+ const taskResults = synthesizeTaskResults(taskHandles, runId)
346
352
 
347
- const completedTasks = countCompletedTasks(taskResults)
353
+ const completedTasks = countCompletedTasks(taskResults)
348
354
 
349
- return {
350
- runId: run.id,
351
- status: run.status === 'completed' ? 'completed' : 'failed',
352
- stopReason: run.stopReason,
353
- usage: run.tokenUsage,
354
- cost: run.costInfo,
355
- iterations: run.currentIteration,
356
- durationMs: Date.now() - startTime,
357
- messages: run.messages,
358
- result: run.result,
359
- lastError: run.lastError,
360
- taskResults,
361
- completedTasks,
362
- totalTasks: taskResults.length,
355
+ return {
356
+ runId: run.id,
357
+ status: run.status === 'completed' ? 'completed' : 'failed',
358
+ stopReason: run.stopReason,
359
+ usage: run.tokenUsage,
360
+ cost: run.costInfo,
361
+ iterations: run.currentIteration,
362
+ durationMs: Date.now() - startTime,
363
+ messages: run.messages,
364
+ result: run.result,
365
+ lastError: run.lastError,
366
+ taskResults,
367
+ completedTasks,
368
+ totalTasks: taskResults.length,
369
+ }
370
+ } finally {
371
+ completionInbox.close()
363
372
  }
364
373
  }
365
374
  }