pi-daddy 0.43.0 → 0.44.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +104 -33
- package/README.md +27 -5
- package/THIRD_PARTY_LICENSES/musl-COPYRIGHT.txt +193 -0
- package/THIRD_PARTY_LICENSES/zig-MIT.txt +21 -0
- package/THIRD_PARTY_NOTICES.md +9 -0
- package/contracts/ledger-record/v1/README.md +40 -25
- package/dist/cli.d.ts +2 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +10 -5
- package/dist/cli.js.map +1 -1
- package/dist/executors/activity-session.js +116 -65
- package/dist/executors/activity-session.js.map +1 -1
- package/dist/executors/captured-execution.d.ts +13 -0
- package/dist/executors/captured-execution.d.ts.map +1 -0
- package/dist/executors/captured-execution.js +53 -0
- package/dist/executors/captured-execution.js.map +1 -0
- package/dist/executors/child-final.d.ts +31 -0
- package/dist/executors/child-final.d.ts.map +1 -0
- package/dist/executors/child-final.js +197 -0
- package/dist/executors/child-final.js.map +1 -0
- package/dist/executors/executor.d.ts +2 -1
- package/dist/executors/executor.d.ts.map +1 -1
- package/dist/executors/executor.js +12 -0
- package/dist/executors/executor.js.map +1 -1
- package/dist/executors/owned-worker.d.ts +18 -0
- package/dist/executors/owned-worker.d.ts.map +1 -0
- package/dist/executors/owned-worker.js +295 -0
- package/dist/executors/owned-worker.js.map +1 -0
- package/dist/executors/worker-artifact.d.ts +3 -0
- package/dist/executors/worker-artifact.d.ts.map +1 -0
- package/dist/executors/worker-artifact.js +3 -0
- package/dist/executors/worker-artifact.js.map +1 -0
- package/dist/governance/approval-prompt.d.ts +4 -3
- package/dist/governance/approval-prompt.d.ts.map +1 -1
- package/dist/governance/approval-prompt.js +13 -6
- package/dist/governance/approval-prompt.js.map +1 -1
- package/dist/governance/captured-worker-record.d.ts +9 -0
- package/dist/governance/captured-worker-record.d.ts.map +1 -0
- package/dist/governance/captured-worker-record.js +123 -0
- package/dist/governance/captured-worker-record.js.map +1 -0
- package/dist/governance/lease-record.d.ts +4 -0
- package/dist/governance/lease-record.d.ts.map +1 -1
- package/dist/governance/lease-record.js +19 -2
- package/dist/governance/lease-record.js.map +1 -1
- package/dist/governance/ledger-events.d.ts +5 -5
- package/dist/governance/ledger-events.d.ts.map +1 -1
- package/dist/governance/ledger-v3-validation.js +1 -1
- package/dist/governance/ledger-v3-validation.js.map +1 -1
- package/dist/governance/workspace-acceptance.d.ts +3 -1
- package/dist/governance/workspace-acceptance.d.ts.map +1 -1
- package/dist/governance/workspace-acceptance.js +21 -5
- package/dist/governance/workspace-acceptance.js.map +1 -1
- package/dist/governance/workspace-lease.d.ts.map +1 -1
- package/dist/governance/workspace-lease.js +44 -1
- package/dist/governance/workspace-lease.js.map +1 -1
- package/dist/kernel/authority-text.d.ts +3 -0
- package/dist/kernel/authority-text.d.ts.map +1 -0
- package/dist/kernel/authority-text.js +22 -0
- package/dist/kernel/authority-text.js.map +1 -0
- package/dist/kernel/bounded-read-failures.d.ts +9 -0
- package/dist/kernel/bounded-read-failures.d.ts.map +1 -0
- package/dist/kernel/bounded-read-failures.js +33 -0
- package/dist/kernel/bounded-read-failures.js.map +1 -0
- package/dist/kernel/bounded-read-sync.d.ts +24 -0
- package/dist/kernel/bounded-read-sync.d.ts.map +1 -0
- package/dist/kernel/bounded-read-sync.js +75 -0
- package/dist/kernel/bounded-read-sync.js.map +1 -0
- package/dist/kernel/bounded-read.d.ts +29 -2
- package/dist/kernel/bounded-read.d.ts.map +1 -1
- package/dist/kernel/bounded-read.js +98 -9
- package/dist/kernel/bounded-read.js.map +1 -1
- package/dist/kernel/capacity.d.ts +36 -0
- package/dist/kernel/capacity.d.ts.map +1 -0
- package/dist/kernel/capacity.js +94 -0
- package/dist/kernel/capacity.js.map +1 -0
- package/dist/kernel/captured-worker-contract.d.ts +38 -0
- package/dist/kernel/captured-worker-contract.d.ts.map +1 -0
- package/dist/kernel/captured-worker-contract.js +2 -0
- package/dist/kernel/captured-worker-contract.js.map +1 -0
- package/dist/kernel/catalog.d.ts +12 -3
- package/dist/kernel/catalog.d.ts.map +1 -1
- package/dist/kernel/catalog.js +28 -8
- package/dist/kernel/catalog.js.map +1 -1
- package/dist/kernel/chain.d.ts +1 -0
- package/dist/kernel/chain.d.ts.map +1 -1
- package/dist/kernel/chain.js.map +1 -1
- package/dist/kernel/definitions.d.ts +11 -1
- package/dist/kernel/definitions.d.ts.map +1 -1
- package/dist/kernel/definitions.js +6 -3
- package/dist/kernel/definitions.js.map +1 -1
- package/dist/kernel/fanout.d.ts +5 -25
- package/dist/kernel/fanout.d.ts.map +1 -1
- package/dist/kernel/fanout.js +15 -30
- package/dist/kernel/fanout.js.map +1 -1
- package/dist/kernel/grant-env.d.ts +0 -2
- package/dist/kernel/grant-env.d.ts.map +1 -1
- package/dist/kernel/grant-env.js +0 -1
- package/dist/kernel/grant-env.js.map +1 -1
- package/dist/kernel/model-preflight.d.ts +8 -0
- package/dist/kernel/model-preflight.d.ts.map +1 -1
- package/dist/kernel/model-preflight.js +23 -0
- package/dist/kernel/model-preflight.js.map +1 -1
- package/dist/kernel/selected-definitions.d.ts +15 -0
- package/dist/kernel/selected-definitions.d.ts.map +1 -0
- package/dist/kernel/selected-definitions.js +146 -0
- package/dist/kernel/selected-definitions.js.map +1 -0
- package/dist/kernel/skill-packages.d.ts +4 -2
- package/dist/kernel/skill-packages.d.ts.map +1 -1
- package/dist/kernel/skill-packages.js +34 -41
- package/dist/kernel/skill-packages.js.map +1 -1
- package/dist/kernel/skill-resources.d.ts.map +1 -1
- package/dist/kernel/skill-resources.js +8 -11
- package/dist/kernel/skill-resources.js.map +1 -1
- package/dist/kernel/workspace.d.ts +6 -3
- package/dist/kernel/workspace.d.ts.map +1 -1
- package/dist/kernel/workspace.js +10 -6
- package/dist/kernel/workspace.js.map +1 -1
- package/dist/products/dashboard-cli.js +1 -1
- package/dist/products/dashboard-cli.js.map +1 -1
- package/dist/products/dashboard-render.d.ts +1 -2
- package/dist/products/dashboard-render.d.ts.map +1 -1
- package/dist/products/dashboard-render.js +3 -1
- package/dist/products/dashboard-render.js.map +1 -1
- package/dist/products/dashboard-session-client.d.ts +1 -2
- package/dist/products/dashboard-session-client.d.ts.map +1 -1
- package/dist/products/dashboard-session-client.js.map +1 -1
- package/dist/products/episode-report.d.ts +12 -8
- package/dist/products/episode-report.d.ts.map +1 -1
- package/dist/products/episode-report.js +61 -12
- package/dist/products/episode-report.js.map +1 -1
- package/extensions/approvals.ts +1 -1
- package/extensions/chain-plan.ts +9 -3
- package/extensions/context-staging.ts +30 -35
- package/extensions/dashboard-session-server.ts +1 -2
- package/extensions/definition-describe.ts +44 -0
- package/extensions/definition-runtime.ts +89 -26
- package/extensions/delegate-chain.ts +273 -256
- package/extensions/delegation-activation.ts +1 -1
- package/extensions/delegation.ts +41 -53
- package/extensions/execute-child.ts +167 -134
- package/extensions/fanout-outcome.ts +1 -9
- package/extensions/grants-command.ts +2 -9
- package/extensions/grants.ts +106 -38
- package/extensions/init-command.ts +52 -12
- package/extensions/reload-environment.ts +21 -2
- package/extensions/retired-inputs.ts +7 -0
- package/extensions/run-delegation.ts +212 -265
- package/extensions/session-capacity.ts +53 -0
- package/extensions/session-environment.ts +5 -2
- package/extensions/session-model-prompt.ts +33 -32
- package/extensions/session-report.ts +28 -11
- package/extensions/session.ts +200 -157
- package/extensions/workspace-runtime.ts +2 -1
- package/native/README.md +25 -0
- package/native/linux-x64/worker +0 -0
- package/native/linux-x64/worker.sha256 +1 -0
- package/native/provenance.json +42 -0
- package/native/toolchain.json +18 -0
- package/native/worker.c +209 -0
- package/package.json +15 -7
- package/src/cli.ts +16 -6
- package/src/executors/activity-session.ts +120 -66
- package/src/executors/captured-execution.ts +61 -0
- package/src/executors/child-final.ts +190 -0
- package/src/executors/executor.ts +14 -1
- package/src/executors/owned-worker.ts +322 -0
- package/src/executors/worker-artifact.ts +2 -0
- package/src/governance/approval-prompt.ts +18 -8
- package/src/governance/captured-worker-record.ts +138 -0
- package/src/governance/lease-record.ts +21 -2
- package/src/governance/ledger-events.ts +5 -5
- package/src/governance/ledger-v3-validation.ts +1 -1
- package/src/governance/workspace-acceptance.ts +20 -4
- package/src/governance/workspace-lease.ts +59 -1
- package/src/kernel/authority-text.ts +17 -0
- package/src/kernel/bounded-read-failures.ts +42 -0
- package/src/kernel/bounded-read-sync.ts +87 -0
- package/src/kernel/bounded-read.ts +128 -11
- package/src/kernel/capacity.ts +123 -0
- package/src/kernel/captured-worker-contract.ts +29 -0
- package/src/kernel/catalog.ts +45 -16
- package/src/kernel/chain.ts +1 -0
- package/src/kernel/definitions.ts +11 -2
- package/src/kernel/fanout.ts +17 -32
- package/src/kernel/grant-env.ts +0 -3
- package/src/kernel/model-preflight.ts +29 -0
- package/src/kernel/selected-definitions.ts +156 -0
- package/src/kernel/skill-packages.ts +40 -38
- package/src/kernel/skill-resources.ts +8 -9
- package/src/kernel/workspace.ts +12 -5
- package/src/products/dashboard-cli.ts +1 -1
- package/src/products/dashboard-render.ts +6 -2
- package/src/products/dashboard-session-client.ts +1 -2
- package/src/products/episode-report.ts +80 -17
- package/dist/advisors/advisor.d.ts +0 -90
- package/dist/advisors/advisor.d.ts.map +0 -1
- package/dist/advisors/advisor.js +0 -154
- package/dist/advisors/advisor.js.map +0 -1
- package/dist/advisors/decider.d.ts +0 -88
- package/dist/advisors/decider.d.ts.map +0 -1
- package/dist/advisors/decider.js +0 -29
- package/dist/advisors/decider.js.map +0 -1
- package/dist/advisors/jev.d.ts +0 -41
- package/dist/advisors/jev.d.ts.map +0 -1
- package/dist/advisors/jev.js +0 -139
- package/dist/advisors/jev.js.map +0 -1
- package/dist/advisors/settings.d.ts +0 -49
- package/dist/advisors/settings.d.ts.map +0 -1
- package/dist/advisors/settings.js +0 -99
- package/dist/advisors/settings.js.map +0 -1
- package/dist/governance/episode-cost-gate.d.ts +0 -31
- package/dist/governance/episode-cost-gate.d.ts.map +0 -1
- package/dist/governance/episode-cost-gate.js +0 -112
- package/dist/governance/episode-cost-gate.js.map +0 -1
- package/extensions/advisor-session.ts +0 -67
- package/extensions/effort-advice.ts +0 -112
- package/extensions/pruning-advice.ts +0 -133
- package/src/advisors/advisor.ts +0 -246
- package/src/advisors/decider.ts +0 -74
- package/src/advisors/jev.ts +0 -163
- package/src/advisors/settings.ts +0 -115
- package/src/governance/episode-cost-gate.ts +0 -128
package/extensions/delegation.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { reconcileDelegationCapacity, reserveDelegationCapacity } from "./session-capacity.ts";
|
|
2
|
+
import { registerDefinitionDescribe } from "./definition-describe.ts";
|
|
1
3
|
/**
|
|
2
4
|
* Governed delegation, as pi sees it: the `delegate` and `delegate_all` tool registrations.
|
|
3
5
|
*
|
|
@@ -37,7 +39,7 @@ import { newDelegationOccurrence } from "./execution-occurrence.ts";
|
|
|
37
39
|
import { correlationShape as buildCorrelationShape } from "./correlation-shape.ts";
|
|
38
40
|
import { assertDelegationAuthority } from "./delegation-authority.ts";
|
|
39
41
|
import { contextShape } from "./context-shape.ts";
|
|
40
|
-
import {
|
|
42
|
+
import { withoutRetiredDelegationArguments } from "./retired-inputs.ts";
|
|
41
43
|
|
|
42
44
|
/**
|
|
43
45
|
* Wire a set of children to pi's partial-result channel — ADR-0032.
|
|
@@ -186,6 +188,9 @@ export function registerDelegationTools(pi: ExtensionAPI, session: GrantsSession
|
|
|
186
188
|
),
|
|
187
189
|
);
|
|
188
190
|
const childShape = Type.Object({
|
|
191
|
+
definitionId: Type.Optional(
|
|
192
|
+
Type.String({ description: "Snapshot id returned by delegate_describe; required for Principal phases." }),
|
|
193
|
+
),
|
|
189
194
|
task: Type.String({ description: "The task for this sub-agent. It receives only this." }),
|
|
190
195
|
agent: Type.Optional(Type.String({ description: describeAgent(spawnable()) })),
|
|
191
196
|
tools: Type.Optional(Type.Array(Type.String(), { description: "Capabilities, when no 'agent' fits." })),
|
|
@@ -202,12 +207,12 @@ export function registerDelegationTools(pi: ExtensionAPI, session: GrantsSession
|
|
|
202
207
|
maxItems: MAX_CHILDREN_PER_CALL,
|
|
203
208
|
description: "The sub-agents to run concurrently. Each is independent and unaware of the others.",
|
|
204
209
|
}),
|
|
205
|
-
episodeCostCeiling: Type.Optional(
|
|
206
|
-
Type.Number({ exclusiveMinimum: 0, description: "Override the USD ceiling for this whole episode." }),
|
|
207
|
-
),
|
|
208
210
|
});
|
|
209
211
|
|
|
210
212
|
const delegateParams = Type.Object({
|
|
213
|
+
definitionId: Type.Optional(
|
|
214
|
+
Type.String({ description: "Snapshot id returned by delegate_describe; required for Principal phases." }),
|
|
215
|
+
),
|
|
211
216
|
task: Type.String({ description: "The task for the sub-agent. It receives only this." }),
|
|
212
217
|
agent: Type.Optional(Type.String({ description: describeAgent(spawnable()) })),
|
|
213
218
|
tools: Type.Optional(
|
|
@@ -227,9 +232,6 @@ export function registerDelegationTools(pi: ExtensionAPI, session: GrantsSession
|
|
|
227
232
|
}),
|
|
228
233
|
),
|
|
229
234
|
thinking: thinkingShape,
|
|
230
|
-
episodeCostCeiling: Type.Optional(
|
|
231
|
-
Type.Number({ exclusiveMinimum: 0, description: "Override the USD ceiling for this whole episode." }),
|
|
232
|
-
),
|
|
233
235
|
context: Type.Optional(contextShape()),
|
|
234
236
|
correlation: Type.Optional(correlationShape),
|
|
235
237
|
workspace: Type.Optional(workspaceShape),
|
|
@@ -244,60 +246,54 @@ export function registerDelegationTools(pi: ExtensionAPI, session: GrantsSession
|
|
|
244
246
|
"written by the operator. Use 'tools' only when no definition fits. Grant 'delegate' if the " +
|
|
245
247
|
"sub-agent must itself delegate further; withhold it to make the sub-agent a leaf.",
|
|
246
248
|
parameters: delegateParams,
|
|
249
|
+
prepareArguments: withoutRetiredDelegationArguments,
|
|
247
250
|
async execute(_toolCallId, params, signal, onUpdate, ctx) {
|
|
248
251
|
assertDelegationAuthority(session);
|
|
249
|
-
await ensureSessionModelPrompt(session, params.agent ? [params.agent] : [], {
|
|
250
|
-
hasUI: ctx.hasUI && typeof ctx.ui.input === "function",
|
|
251
|
-
input: (title, placeholder) => ctx.ui.input(title, placeholder),
|
|
252
|
-
notify: (message, type) => ctx.ui.notify(message, type),
|
|
253
|
-
});
|
|
254
252
|
// ADR-0032: one child, same block. `_onUpdate` was discarded here, so a delegation showed the bare word
|
|
255
253
|
// `delegate` for up to DEFAULT_TIMEOUT_MS — sixty minutes by default.
|
|
256
254
|
const progress = progressReporter(session, [params.agent ?? "delegate"], onUpdate as never);
|
|
257
255
|
const outcome = await runOneDelegation(
|
|
258
256
|
session,
|
|
259
257
|
{
|
|
258
|
+
definitionId: params.definitionId,
|
|
260
259
|
task: params.task,
|
|
261
260
|
agent: params.agent,
|
|
262
261
|
tools: params.tools,
|
|
263
262
|
model: params.model,
|
|
264
263
|
thinking: params.thinking,
|
|
265
|
-
episodeCostCeiling: params.episodeCostCeiling,
|
|
266
264
|
context: params.context,
|
|
267
265
|
correlation: params.correlation,
|
|
268
266
|
workspace: params.workspace,
|
|
269
267
|
},
|
|
270
268
|
newDelegationOccurrence(session, 0),
|
|
271
|
-
//
|
|
272
|
-
|
|
273
|
-
// budget through unchanged means a child can still fan out with what this session was given.
|
|
274
|
-
session.fanoutBudget,
|
|
269
|
+
// Reserve one actual child plus the currently available disjoint subtree allowance.
|
|
270
|
+
undefined,
|
|
275
271
|
ctx,
|
|
276
272
|
signal,
|
|
277
273
|
{ onProgress: progress.sink(0), toolCallId: _toolCallId },
|
|
278
274
|
);
|
|
279
275
|
progress.settle([outcome]);
|
|
280
276
|
|
|
281
|
-
if (
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
// Returning `isError: true` was silently discarded, so every refusal this package made was
|
|
286
|
-
// recorded by pi as a SUCCESSFUL tool call. Found by the integration suite on its first run.
|
|
287
|
-
const detail = outcome.text ? `\n\n${outcome.text}` : "";
|
|
288
|
-
const message = `delegation refused: ${outcome.reason}${detail}`;
|
|
277
|
+
if (isCriticalAssuranceBlock(outcome)) throw new Error(outcome.text);
|
|
278
|
+
// A pre-launch refusal has no executed work/final to preserve; keep its established typed refusal.
|
|
279
|
+
if (!outcome.ok && !outcome.work && !outcome.final && !outcome.cleanup) {
|
|
280
|
+
const message = `delegation refused: ${outcome.reason}`;
|
|
289
281
|
if (outcome.refusal) throw new GovernanceRefusal({ ...outcome.refusal, message });
|
|
290
282
|
throw new Error(message);
|
|
291
283
|
}
|
|
292
|
-
|
|
284
|
+
// Pi 1.0.4 preserves returned isError. Keep every outcome dimension and useful output together.
|
|
285
|
+
const failed = !outcome.ok || outcome.control === "failed";
|
|
293
286
|
return {
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
287
|
+
isError: failed,
|
|
288
|
+
content: [
|
|
289
|
+
{
|
|
290
|
+
type: "text",
|
|
291
|
+
text: failed
|
|
292
|
+
? `delegation failed: ${outcome.reason ?? "required control failed"}${outcome.text ? `\n\n${outcome.text}` : ""}`
|
|
293
|
+
: outcome.text || "(no output)",
|
|
294
|
+
},
|
|
295
|
+
],
|
|
296
|
+
details: outcome,
|
|
301
297
|
};
|
|
302
298
|
},
|
|
303
299
|
});
|
|
@@ -323,32 +319,24 @@ export function registerDelegationTools(pi: ExtensionAPI, session: GrantsSession
|
|
|
323
319
|
description:
|
|
324
320
|
"Run several sub-agents CONCURRENTLY and return all their results. Each child is governed exactly " +
|
|
325
321
|
"as with `delegate`: it holds only what you grant it, and you cannot grant what you do not hold. " +
|
|
326
|
-
`At most ${MAX_CHILDREN_PER_CALL} children per call, and
|
|
322
|
+
`At most ${MAX_CHILDREN_PER_CALL} children per call, and shared capacity bounds active descendants ` +
|
|
327
323
|
"across the whole delegation subtree. Children cannot see each other or share context. Use this " +
|
|
328
324
|
"when independent tasks can proceed in parallel — several reviewers over one diff, say — and read " +
|
|
329
325
|
"every child's outcome, because one can be refused while the others succeed.",
|
|
330
326
|
parameters: delegateAllParams,
|
|
327
|
+
prepareArguments: withoutRetiredDelegationArguments,
|
|
331
328
|
async execute(_toolCallId, params, signal, onUpdate, ctx) {
|
|
332
329
|
assertDelegationAuthority(session);
|
|
333
330
|
const children = params.children ?? [];
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
{
|
|
338
|
-
hasUI: ctx.hasUI && typeof ctx.ui.input === "function",
|
|
339
|
-
input: (title, placeholder) => ctx.ui.input(title, placeholder),
|
|
340
|
-
notify: (message, type) => ctx.ui.notify(message, type),
|
|
341
|
-
},
|
|
342
|
-
);
|
|
343
|
-
const split = splitBudget(session.fanoutBudget, children.length);
|
|
331
|
+
if (session.capacityRefusal) throw new GovernanceRefusal(session.capacityRefusal);
|
|
332
|
+
await reconcileDelegationCapacity(session);
|
|
333
|
+
const split = splitBudget(session.capacity.available, children.length);
|
|
344
334
|
if (!split.ok) {
|
|
345
335
|
// Thrown, not returned: a returned `isError` is discarded by pi, so a refusal that came back as a
|
|
346
336
|
// normal result would read to the orchestrator as a successful fan-out of zero children.
|
|
347
337
|
throw new GovernanceRefusal(refusal("FANOUT_EXCEEDED", `fan-out refused: ${split.reason}`));
|
|
348
338
|
}
|
|
349
339
|
|
|
350
|
-
if (params.episodeCostCeiling !== undefined) session.episodeCostGate.setCeiling(params.episodeCostCeiling);
|
|
351
|
-
|
|
352
340
|
// ADR-0032: ONE status block covering every child. `onUpdate` replaces the tool's rendered result, so a
|
|
353
341
|
// painter per child would have each overwriting the others.
|
|
354
342
|
const progress = progressReporter(
|
|
@@ -369,6 +357,8 @@ export function registerDelegationTools(pi: ExtensionAPI, session: GrantsSession
|
|
|
369
357
|
const pending = children.map(async (child, index): Promise<DelegationOutcome> => {
|
|
370
358
|
try {
|
|
371
359
|
return await runOneDelegation(session, child, occurrences[index], split.perChild, ctx, signal, {
|
|
360
|
+
// Reserve each batch share synchronously here, before another dispatch can interleave.
|
|
361
|
+
capacityReservation: reserveDelegationCapacity(session, occurrences[index].executionId, split.perChild),
|
|
372
362
|
onProgress: progress.sink(index),
|
|
373
363
|
toolCallId: _toolCallId,
|
|
374
364
|
});
|
|
@@ -390,17 +380,14 @@ export function registerDelegationTools(pi: ExtensionAPI, session: GrantsSession
|
|
|
390
380
|
// be indistinguishable from an empty one, and a fan-out that hid its refusals would let an
|
|
391
381
|
// orchestrator summarise four reviews when only three happened.
|
|
392
382
|
const report = buildFanoutReport(outcomes, children);
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
// All of them failed, so there is no partial result to hand back — and a tool that returns text
|
|
396
|
-
// when nothing ran is exactly how a wrong summary gets written.
|
|
397
|
-
const message = `fan-out failed: every child was refused or failed.\n\n${report}`;
|
|
398
|
-
throw totalFanoutFailure(failed, message);
|
|
399
|
-
}
|
|
383
|
+
if (failed.length === children.length && outcomes.every((o) => !o.work && !o.final && !o.cleanup))
|
|
384
|
+
throw totalFanoutFailure(failed, `fan-out failed: every child was refused or failed.\n\n${report}`);
|
|
400
385
|
|
|
401
386
|
return {
|
|
387
|
+
isError: outcomes.some((o) => !o.ok || o.control === "failed"),
|
|
402
388
|
content: [{ type: "text", text: report }],
|
|
403
389
|
details: {
|
|
390
|
+
outcomes,
|
|
404
391
|
children: outcomes.length,
|
|
405
392
|
failed: failed.length,
|
|
406
393
|
budgetPerChild: split.perChild,
|
|
@@ -415,6 +402,7 @@ export function registerDelegationTools(pi: ExtensionAPI, session: GrantsSession
|
|
|
415
402
|
// ADR-0033. Registered here so all three tools appear together and share the `mayDelegate` guard, but its logic
|
|
416
403
|
// lives in its own file: `delegate` and `delegate_all` differ only in cardinality, while a chain differs in
|
|
417
404
|
// composition, and this file is near the 400-line ceiling.
|
|
405
|
+
registerDefinitionDescribe(pi, session);
|
|
418
406
|
registerChainTool(pi, session);
|
|
419
407
|
|
|
420
408
|
return {
|