@caupulican/pi-adaptative 0.85.8 → 0.86.2
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 +42 -0
- package/dist/core/agent-paths.d.ts +6 -3
- package/dist/core/agent-paths.d.ts.map +1 -1
- package/dist/core/agent-paths.js +10 -3
- package/dist/core/agent-paths.js.map +1 -1
- package/dist/core/agent-session.d.ts +5 -2
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +7 -1
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/autonomy/bounded-completion.d.ts.map +1 -1
- package/dist/core/autonomy/bounded-completion.js +19 -8
- package/dist/core/autonomy/bounded-completion.js.map +1 -1
- package/dist/core/autonomy/lane-tool-surface.d.ts +11 -5
- package/dist/core/autonomy/lane-tool-surface.d.ts.map +1 -1
- package/dist/core/autonomy/lane-tool-surface.js +34 -8
- package/dist/core/autonomy/lane-tool-surface.js.map +1 -1
- package/dist/core/autonomy/subagent-prompt.d.ts +3 -3
- package/dist/core/autonomy/subagent-prompt.js +9 -9
- package/dist/core/autonomy/subagent-prompt.js.map +1 -1
- package/dist/core/background-lane-controller.d.ts +10 -8
- package/dist/core/background-lane-controller.d.ts.map +1 -1
- package/dist/core/background-lane-controller.js +23 -13
- package/dist/core/background-lane-controller.js.map +1 -1
- package/dist/core/bash-execution-controller.d.ts +4 -0
- package/dist/core/bash-execution-controller.d.ts.map +1 -1
- package/dist/core/bash-execution-controller.js +11 -4
- package/dist/core/bash-execution-controller.js.map +1 -1
- package/dist/core/bash-executor.d.ts +2 -0
- package/dist/core/bash-executor.d.ts.map +1 -1
- package/dist/core/bash-executor.js +2 -1
- package/dist/core/bash-executor.js.map +1 -1
- package/dist/core/capability-contract.d.ts +1 -1
- package/dist/core/capability-contract.d.ts.map +1 -1
- package/dist/core/capability-contract.js +0 -1
- package/dist/core/capability-contract.js.map +1 -1
- package/dist/core/default-tool-surface.d.ts +1 -0
- package/dist/core/default-tool-surface.d.ts.map +1 -1
- package/dist/core/default-tool-surface.js +3 -2
- package/dist/core/default-tool-surface.js.map +1 -1
- package/dist/core/delegation/worker-agent-control-coordinator.d.ts +27 -8
- package/dist/core/delegation/worker-agent-control-coordinator.d.ts.map +1 -1
- package/dist/core/delegation/worker-agent-control-coordinator.js +191 -33
- package/dist/core/delegation/worker-agent-control-coordinator.js.map +1 -1
- package/dist/core/delegation/worker-agent-control.d.ts +45 -6
- package/dist/core/delegation/worker-agent-control.d.ts.map +1 -1
- package/dist/core/delegation/worker-agent-control.js +110 -13
- package/dist/core/delegation/worker-agent-control.js.map +1 -1
- package/dist/core/delegation/worker-attempt-executor.d.ts.map +1 -1
- package/dist/core/delegation/worker-attempt-executor.js +177 -158
- package/dist/core/delegation/worker-attempt-executor.js.map +1 -1
- package/dist/core/delegation/worker-authority-resolver.d.ts +23 -0
- package/dist/core/delegation/worker-authority-resolver.d.ts.map +1 -0
- package/dist/core/delegation/worker-authority-resolver.js +128 -0
- package/dist/core/delegation/worker-authority-resolver.js.map +1 -0
- package/dist/core/delegation/worker-conversation-store.d.ts.map +1 -1
- package/dist/core/delegation/worker-conversation-store.js +1 -1
- package/dist/core/delegation/worker-conversation-store.js.map +1 -1
- package/dist/core/delegation/worker-delegation-controller.d.ts +7 -1
- package/dist/core/delegation/worker-delegation-controller.d.ts.map +1 -1
- package/dist/core/delegation/worker-delegation-controller.js +260 -87
- package/dist/core/delegation/worker-delegation-controller.js.map +1 -1
- package/dist/core/delegation/worker-delegation-request.d.ts +25 -4
- package/dist/core/delegation/worker-delegation-request.d.ts.map +1 -1
- package/dist/core/delegation/worker-delegation-request.js +90 -1
- package/dist/core/delegation/worker-delegation-request.js.map +1 -1
- package/dist/core/delegation/worker-execution-policy.d.ts +2 -0
- package/dist/core/delegation/worker-execution-policy.d.ts.map +1 -1
- package/dist/core/delegation/worker-execution-policy.js +22 -12
- package/dist/core/delegation/worker-execution-policy.js.map +1 -1
- package/dist/core/delegation/worker-lifecycle.d.ts +1 -0
- package/dist/core/delegation/worker-lifecycle.d.ts.map +1 -1
- package/dist/core/delegation/worker-lifecycle.js +4 -2
- package/dist/core/delegation/worker-lifecycle.js.map +1 -1
- package/dist/core/delegation/worker-profile-resolver.d.ts +0 -2
- package/dist/core/delegation/worker-profile-resolver.d.ts.map +1 -1
- package/dist/core/delegation/worker-profile-resolver.js +8 -35
- package/dist/core/delegation/worker-profile-resolver.js.map +1 -1
- package/dist/core/delegation/worker-recovery-coordinator.d.ts.map +1 -1
- package/dist/core/delegation/worker-recovery-coordinator.js +1 -0
- package/dist/core/delegation/worker-recovery-coordinator.js.map +1 -1
- package/dist/core/delegation/worker-runner.d.ts +6 -1
- package/dist/core/delegation/worker-runner.d.ts.map +1 -1
- package/dist/core/delegation/worker-runner.js +20 -6
- package/dist/core/delegation/worker-runner.js.map +1 -1
- package/dist/core/delegation/worker-tree-budget-coordinator.d.ts +47 -0
- package/dist/core/delegation/worker-tree-budget-coordinator.d.ts.map +1 -0
- package/dist/core/delegation/worker-tree-budget-coordinator.js +210 -0
- package/dist/core/delegation/worker-tree-budget-coordinator.js.map +1 -0
- package/dist/core/memory/providers/file-store.d.ts +2 -0
- package/dist/core/memory/providers/file-store.d.ts.map +1 -1
- package/dist/core/memory/providers/file-store.js +22 -20
- package/dist/core/memory/providers/file-store.js.map +1 -1
- package/dist/core/models/runtime-process.d.ts.map +1 -1
- package/dist/core/models/runtime-process.js +5 -18
- package/dist/core/models/runtime-process.js.map +1 -1
- package/dist/core/orchestration/bounded-string-array.d.ts +11 -0
- package/dist/core/orchestration/bounded-string-array.d.ts.map +1 -0
- package/dist/core/orchestration/bounded-string-array.js +17 -0
- package/dist/core/orchestration/bounded-string-array.js.map +1 -0
- package/dist/core/orchestration/capability-gateway.d.ts +16 -0
- package/dist/core/orchestration/capability-gateway.d.ts.map +1 -1
- package/dist/core/orchestration/capability-gateway.js +38 -0
- package/dist/core/orchestration/capability-gateway.js.map +1 -1
- package/dist/core/orchestration/contracts.d.ts +11 -3
- package/dist/core/orchestration/contracts.d.ts.map +1 -1
- package/dist/core/orchestration/contracts.js +0 -1
- package/dist/core/orchestration/contracts.js.map +1 -1
- package/dist/core/orchestration/delegation-ledger.d.ts +1 -0
- package/dist/core/orchestration/delegation-ledger.d.ts.map +1 -1
- package/dist/core/orchestration/delegation-ledger.js +3 -0
- package/dist/core/orchestration/delegation-ledger.js.map +1 -1
- package/dist/core/orchestration/event-store.d.ts +12 -10
- package/dist/core/orchestration/event-store.d.ts.map +1 -1
- package/dist/core/orchestration/event-store.js +94 -104
- package/dist/core/orchestration/event-store.js.map +1 -1
- package/dist/core/orchestration/lane-tool-manifests.d.ts +2 -2
- package/dist/core/orchestration/lane-tool-manifests.d.ts.map +1 -1
- package/dist/core/orchestration/lane-tool-manifests.js +4 -1
- package/dist/core/orchestration/lane-tool-manifests.js.map +1 -1
- package/dist/core/orchestration/policy-compiler.d.ts.map +1 -1
- package/dist/core/orchestration/policy-compiler.js +8 -9
- package/dist/core/orchestration/policy-compiler.js.map +1 -1
- package/dist/core/orchestration/profile-registry.d.ts.map +1 -1
- package/dist/core/orchestration/profile-registry.js +4 -10
- package/dist/core/orchestration/profile-registry.js.map +1 -1
- package/dist/core/orchestration/task-runtime.d.ts +1 -0
- package/dist/core/orchestration/task-runtime.d.ts.map +1 -1
- package/dist/core/orchestration/task-runtime.js +58 -3
- package/dist/core/orchestration/task-runtime.js.map +1 -1
- package/dist/core/orchestration/worker-execution-contract.d.ts.map +1 -1
- package/dist/core/orchestration/worker-execution-contract.js +10 -17
- package/dist/core/orchestration/worker-execution-contract.js.map +1 -1
- package/dist/core/risk-classifier.js +3 -3
- package/dist/core/risk-classifier.js.map +1 -1
- package/dist/core/runtime-builder.d.ts +4 -1
- package/dist/core/runtime-builder.d.ts.map +1 -1
- package/dist/core/runtime-builder.js +34 -15
- package/dist/core/runtime-builder.js.map +1 -1
- package/dist/core/secrets/bitwarden-credential-storage.d.ts +51 -0
- package/dist/core/secrets/bitwarden-credential-storage.d.ts.map +1 -0
- package/dist/core/secrets/bitwarden-credential-storage.js +345 -0
- package/dist/core/secrets/bitwarden-credential-storage.js.map +1 -0
- package/dist/core/secrets/credential-exposure-guard.d.ts +8 -4
- package/dist/core/secrets/credential-exposure-guard.d.ts.map +1 -1
- package/dist/core/secrets/credential-exposure-guard.js +30 -31
- package/dist/core/secrets/credential-exposure-guard.js.map +1 -1
- package/dist/core/secrets/credential-manager.d.ts +109 -0
- package/dist/core/secrets/credential-manager.d.ts.map +1 -0
- package/dist/core/secrets/credential-manager.js +384 -0
- package/dist/core/secrets/credential-manager.js.map +1 -0
- package/dist/core/secrets/credential-project.d.ts +4 -0
- package/dist/core/secrets/credential-project.d.ts.map +1 -0
- package/dist/core/secrets/credential-project.js +145 -0
- package/dist/core/secrets/credential-project.js.map +1 -0
- package/dist/core/secrets/secret-dotenv.d.ts +1 -1
- package/dist/core/secrets/secret-dotenv.js +1 -1
- package/dist/core/secrets/secret-dotenv.js.map +1 -1
- package/dist/core/settings-manager.d.ts +4 -2
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +9 -5
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +1 -0
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/system-prompt.js +1 -1
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tool-capability-policy.js +2 -2
- package/dist/core/tool-capability-policy.js.map +1 -1
- package/dist/core/tools/delegate.d.ts +29 -1
- package/dist/core/tools/delegate.d.ts.map +1 -1
- package/dist/core/tools/delegate.js +179 -28
- package/dist/core/tools/delegate.js.map +1 -1
- package/dist/core/tools/git-filter.d.ts +1 -0
- package/dist/core/tools/git-filter.d.ts.map +1 -1
- package/dist/core/tools/git-filter.js +1 -1
- package/dist/core/tools/git-filter.js.map +1 -1
- package/dist/core/tools/profile-writer.js +3 -3
- package/dist/core/tools/profile-writer.js.map +1 -1
- package/dist/core/tools/python.d.ts +2 -0
- package/dist/core/tools/python.d.ts.map +1 -1
- package/dist/core/tools/python.js +17 -12
- package/dist/core/tools/python.js.map +1 -1
- package/dist/core/tools/run-process.d.ts +2 -0
- package/dist/core/tools/run-process.d.ts.map +1 -1
- package/dist/core/tools/run-process.js +7 -3
- package/dist/core/tools/run-process.js.map +1 -1
- package/dist/core/tools/secret-store.d.ts +8 -18
- package/dist/core/tools/secret-store.d.ts.map +1 -1
- package/dist/core/tools/secret-store.js +83 -348
- package/dist/core/tools/secret-store.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/migrations.d.ts.map +1 -1
- package/dist/migrations.js +38 -1
- package/dist/migrations.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +35 -14
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +26 -3
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/secret-menu-controller.d.ts +21 -0
- package/dist/modes/interactive/secret-menu-controller.d.ts.map +1 -0
- package/dist/modes/interactive/secret-menu-controller.js +276 -0
- package/dist/modes/interactive/secret-menu-controller.js.map +1 -0
- package/dist/utils/tools-manager.d.ts +2 -1
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/tools-manager.js +43 -48
- package/dist/utils/tools-manager.js.map +1 -1
- package/dist/utils/zip-extractor.d.ts +8 -0
- package/dist/utils/zip-extractor.d.ts.map +1 -0
- package/dist/utils/zip-extractor.js +275 -0
- package/dist/utils/zip-extractor.js.map +1 -0
- package/docs/harness-architecture.md +34 -22
- package/docs/index.md +1 -1
- package/docs/resources.md +1 -1
- package/docs/settings.md +39 -103
- package/docs/usage.md +7 -5
- package/docs/worker-profiles.md +9 -7
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +12 -12
- package/package.json +4 -4
- package/dist/core/secrets/secret-vault-format.d.ts +0 -112
- package/dist/core/secrets/secret-vault-format.d.ts.map +0 -1
- package/dist/core/secrets/secret-vault-format.js +0 -396
- package/dist/core/secrets/secret-vault-format.js.map +0 -1
- package/dist/core/secrets/secret-vault.d.ts +0 -72
- package/dist/core/secrets/secret-vault.d.ts.map +0 -1
- package/dist/core/secrets/secret-vault.js +0 -663
- package/dist/core/secrets/secret-vault.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bounded-completion.d.ts","sourceRoot":"","sources":["../../../src/core/autonomy/bounded-completion.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,WAAW,iBAAiB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,MAAM,8BAA8B,GAAG,UAAU,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE/E,MAAM,WAAW,wBAAwB;IACxC,oGAAoG;IACpG,UAAU,CAAC,EAAE,iBAAiB,CAAC;IAC/B,OAAO,CAAC,EAAE;QAAE,MAAM,EAAE,8BAA8B,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC;CACzE;
|
|
1
|
+
{"version":3,"file":"bounded-completion.d.ts","sourceRoot":"","sources":["../../../src/core/autonomy/bounded-completion.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,WAAW,iBAAiB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,MAAM,8BAA8B,GAAG,UAAU,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE/E,MAAM,WAAW,wBAAwB;IACxC,oGAAoG;IACpG,UAAU,CAAC,EAAE,iBAAiB,CAAC;IAC/B,OAAO,CAAC,EAAE;QAAE,MAAM,EAAE,8BAA8B,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC;CACzE;AAeD,wBAAsB,oBAAoB,CAAC,IAAI,EAAE;IAChD,qDAAqD;IACrD,cAAc,EAAE,MAAM,CAAC;IACvB,qDAAqD;IACrD,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,OAAO,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,OAAO,CAAC,iBAAiB,CAAC,CAAC;CAC7D,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAmFpC"}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Composes an optional external abort signal with an internal wall-clock timeout, executes the
|
|
4
4
|
* injected completion, and maps every failure to a stable status/reasonCode pair. Never throws.
|
|
5
5
|
*/
|
|
6
|
+
const MAX_HOST_TIMER_DELAY_MS = 2_147_483_647;
|
|
6
7
|
function abortFailure(args) {
|
|
7
8
|
if (args.externalSignal?.aborted)
|
|
8
9
|
return { status: "canceled", reasonCode: "external_abort" };
|
|
@@ -18,16 +19,26 @@ export async function runBoundedCompletion(args) {
|
|
|
18
19
|
});
|
|
19
20
|
const onExternalAbort = () => resolveAbort();
|
|
20
21
|
args.signal?.addEventListener("abort", onExternalAbort, { once: true });
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
let timeoutTimer;
|
|
23
|
+
let remainingWallClockMs = args.maxWallClockMs;
|
|
24
|
+
const armTimeout = () => {
|
|
25
|
+
const delayMs = Math.min(remainingWallClockMs, MAX_HOST_TIMER_DELAY_MS);
|
|
26
|
+
timeoutTimer = setTimeout(() => {
|
|
27
|
+
remainingWallClockMs -= delayMs;
|
|
28
|
+
if (remainingWallClockMs > 0) {
|
|
29
|
+
armTimeout();
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
23
32
|
timeoutController.abort();
|
|
24
33
|
resolveAbort();
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
34
|
+
}, delayMs);
|
|
35
|
+
if (typeof timeoutTimer === "object" && "unref" in timeoutTimer) {
|
|
36
|
+
const { unref } = timeoutTimer;
|
|
37
|
+
unref?.call(timeoutTimer);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
if (args.maxWallClockMs > 0)
|
|
41
|
+
armTimeout();
|
|
31
42
|
const signals = [timeoutController.signal];
|
|
32
43
|
if (args.signal)
|
|
33
44
|
signals.push(args.signal);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bounded-completion.js","sourceRoot":"","sources":["../../../src/core/autonomy/bounded-completion.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAkBH,SAAS,YAAY,CAAC,IAGrB;IACA,IAAI,IAAI,CAAC,cAAc,EAAE,OAAO;QAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,gBAAgB,EAAE,CAAC;IAC9F,IAAI,IAAI,CAAC,aAAa,CAAC,OAAO;QAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,qBAAqB,EAAE,CAAC;IAChG,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,kBAAkB,EAAE,CAAC;AAC7D,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,IAM1C;IACA,MAAM,iBAAiB,GAAG,IAAI,eAAe,EAAE,CAAC;IAChD,IAAI,YAAyB,CAAC;IAC9B,MAAM,YAAY,GAAG,IAAI,OAAO,CAAoB,CAAC,OAAO,EAAE,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CAAC;oBACxF,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,kBAAkB,EAAE;aACxD,CAAC;QACH,CAAC;QAED,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;QACrC,IAAI,IAAI,CAAC,MAAM,EAAE,OAAO,IAAI,iBAAiB,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YAC9D,OAAO;gBACN,UAAU;gBACV,OAAO,EAAE,YAAY,CAAC,EAAE,cAAc,EAAE,IAAI,CAAC,MAAM,EAAE,aAAa,EAAE,iBAAiB,CAAC,MAAM,EAAE,CAAC;aAC/F,CAAC;QACH,CAAC;QACD,OAAO,EAAE,UAAU,EAAE,CAAC;IACvB,CAAC;YAAS,CAAC;QACV,IAAI,YAAY,KAAK,SAAS;YAAE,YAAY,CAAC,YAAY,CAAC,CAAC;QAC3D,IAAI,CAAC,MAAM,EAAE,mBAAmB,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;IAC5D,CAAC;AACF,CAAC","sourcesContent":["/**\n * Shared wall-clock/cancellation envelope for one-shot lane completions (research and delegated workers).\n * Composes an optional external abort signal with an internal wall-clock timeout, executes the\n * injected completion, and maps every failure to a stable status/reasonCode pair. Never throws.\n */\n\nexport interface BoundedCompletion {\n\ttext: string;\n\tcostUsd: number;\n\tstopReason: string;\n}\n\nexport type BoundedCompletionFailureStatus = \"canceled\" | \"timeout\" | \"failed\";\n\nexport interface BoundedCompletionOutcome {\n\t/** Present when the executor settled; may coexist with `failure` when an abort raced the result. */\n\tcompletion?: BoundedCompletion;\n\tfailure?: { status: BoundedCompletionFailureStatus; reasonCode: string };\n}\n\ntype ExecutorSettlement = { kind: \"completion\"; completion: BoundedCompletion } | { kind: \"error\"; error: unknown };\n\nconst MAX_HOST_TIMER_DELAY_MS = 2_147_483_647;\n\nfunction abortFailure(args: {\n\texternalSignal?: AbortSignal;\n\ttimeoutSignal: AbortSignal;\n}): BoundedCompletionOutcome[\"failure\"] {\n\tif (args.externalSignal?.aborted) return { status: \"canceled\", reasonCode: \"external_abort\" };\n\tif (args.timeoutSignal.aborted) return { status: \"timeout\", reasonCode: \"wall_clock_exceeded\" };\n\treturn { status: \"failed\", reasonCode: \"completion_error\" };\n}\n\nexport async function runBoundedCompletion(args: {\n\t/** Wall-clock budget in milliseconds; 0 disables. */\n\tmaxWallClockMs: number;\n\t/** External cancellation (e.g. session disposal). */\n\tsignal?: AbortSignal;\n\texecute: (signal: AbortSignal) => Promise<BoundedCompletion>;\n}): Promise<BoundedCompletionOutcome> {\n\tconst timeoutController = new AbortController();\n\tlet resolveAbort!: () => void;\n\tconst abortPromise = new Promise<{ kind: \"abort\" }>((resolve) => {\n\t\tresolveAbort = () => resolve({ kind: \"abort\" });\n\t});\n\tconst onExternalAbort = (): void => resolveAbort();\n\targs.signal?.addEventListener(\"abort\", onExternalAbort, { once: true });\n\tlet timeoutTimer: ReturnType<typeof setTimeout> | undefined;\n\tlet remainingWallClockMs = args.maxWallClockMs;\n\tconst armTimeout = (): void => {\n\t\tconst delayMs = Math.min(remainingWallClockMs, MAX_HOST_TIMER_DELAY_MS);\n\t\ttimeoutTimer = setTimeout(() => {\n\t\t\tremainingWallClockMs -= delayMs;\n\t\t\tif (remainingWallClockMs > 0) {\n\t\t\t\tarmTimeout();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\ttimeoutController.abort();\n\t\t\tresolveAbort();\n\t\t}, delayMs);\n\t\tif (typeof timeoutTimer === \"object\" && \"unref\" in timeoutTimer) {\n\t\t\tconst { unref } = timeoutTimer as { unref?: () => void };\n\t\t\tunref?.call(timeoutTimer);\n\t\t}\n\t};\n\tif (args.maxWallClockMs > 0) armTimeout();\n\tconst signals: AbortSignal[] = [timeoutController.signal];\n\tif (args.signal) signals.push(args.signal);\n\tconst signal = AbortSignal.any(signals);\n\n\tlet settled: ExecutorSettlement | undefined;\n\tconst execution = Promise.resolve()\n\t\t.then(() => args.execute(signal))\n\t\t.then<ExecutorSettlement, ExecutorSettlement>(\n\t\t\t(completion) => {\n\t\t\t\tsettled = { kind: \"completion\", completion };\n\t\t\t\treturn settled;\n\t\t\t},\n\t\t\t(error: unknown) => {\n\t\t\t\tsettled = { kind: \"error\", error };\n\t\t\t\treturn settled;\n\t\t\t},\n\t\t);\n\tif (args.signal?.aborted) resolveAbort();\n\n\ttry {\n\t\tconst winner = await Promise.race([execution, abortPromise]);\n\t\tif (winner.kind === \"abort\") {\n\t\t\t// An abort and a completion can settle in the same microtask turn. Give the already-queued\n\t\t\t// executor handlers one chance to retain that completion (and its visible spend) without\n\t\t\t// ever waiting for a non-cooperative executor. Later settlement remains observed by\n\t\t\t// `execution`'s rejection handler, preventing an unhandled rejection after this returns.\n\t\t\tfor (let flush = 0; flush < 4 && settled === undefined; flush++) {\n\t\t\t\tawait Promise.resolve();\n\t\t\t}\n\t\t\treturn {\n\t\t\t\t...(settled?.kind === \"completion\" ? { completion: settled.completion } : {}),\n\t\t\t\tfailure: abortFailure({ externalSignal: args.signal, timeoutSignal: timeoutController.signal }),\n\t\t\t};\n\t\t}\n\n\t\tif (winner.kind === \"error\") {\n\t\t\treturn {\n\t\t\t\tfailure:\n\t\t\t\t\targs.signal?.aborted || timeoutController.signal.aborted\n\t\t\t\t\t\t? abortFailure({ externalSignal: args.signal, timeoutSignal: timeoutController.signal })\n\t\t\t\t\t\t: { status: \"failed\", reasonCode: \"completion_error\" },\n\t\t\t};\n\t\t}\n\n\t\tconst completion = winner.completion;\n\t\tif (args.signal?.aborted || timeoutController.signal.aborted) {\n\t\t\treturn {\n\t\t\t\tcompletion,\n\t\t\t\tfailure: abortFailure({ externalSignal: args.signal, timeoutSignal: timeoutController.signal }),\n\t\t\t};\n\t\t}\n\t\treturn { completion };\n\t} finally {\n\t\tif (timeoutTimer !== undefined) clearTimeout(timeoutTimer);\n\t\targs.signal?.removeEventListener(\"abort\", onExternalAbort);\n\t}\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AgentLoopConfig, AgentTool } from "@caupulican/pi-agent-core";
|
|
2
|
-
import { CapabilityGateway, type GatewayInitialUsage } from "../orchestration/capability-gateway.ts";
|
|
2
|
+
import { CapabilityGateway, type GatewayInitialUsage, type SharedCapabilityBudget } from "../orchestration/capability-gateway.ts";
|
|
3
3
|
import type { ExecutionGrant, OrchestrationExecutionPolicy, ToolCapabilityManifest } from "../orchestration/contracts.ts";
|
|
4
4
|
import type { NormalizedProfile } from "../profile-registry.ts";
|
|
5
5
|
export interface LaneToolSurface {
|
|
@@ -31,19 +31,25 @@ export interface LaneToolSurfaceOptions {
|
|
|
31
31
|
/** Present only for process-capable owner profiles; absent means no process tool is materialized. */
|
|
32
32
|
executionPolicy?: OrchestrationExecutionPolicy;
|
|
33
33
|
processMaxWallClockMs?: number;
|
|
34
|
+
/** Stable per-agent shell identity. Omitted when the compiled plan does not grant a host shell. */
|
|
35
|
+
shellSessionKey?: string;
|
|
34
36
|
/** Compiled policy path. When present, it is the only authorization source for this surface. */
|
|
35
37
|
grant?: ExecutionGrant;
|
|
36
38
|
toolManifests?: readonly ToolCapabilityManifest[];
|
|
39
|
+
/** Runtime-owned classified tools composed specifically for this lane (for example delegation control). */
|
|
40
|
+
additionalTools?: readonly AgentTool[];
|
|
37
41
|
/** Durable cumulative active usage to seed the compiled grant's gateway on resume. */
|
|
38
42
|
initialUsage?: GatewayInitialUsage;
|
|
43
|
+
/** Root-tree aggregate meter shared by this attempt and every descendant. */
|
|
44
|
+
sharedBudget?: SharedCapabilityBudget;
|
|
39
45
|
}
|
|
40
46
|
/**
|
|
41
47
|
* Materialize a fresh, fail-closed tool surface for one isolated lane.
|
|
42
48
|
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
49
|
+
* Admission selects classified built-ins plus runtime-owned injected controls. A compiled grant is
|
|
50
|
+
* the only authority source for worker lanes; host shell and recursive delegation are materialized
|
|
51
|
+
* when named by that grant. Write/edit additionally require the global write switch and a positive
|
|
52
|
+
* path scope.
|
|
47
53
|
*/
|
|
48
54
|
export declare function createLaneToolSurface(options: LaneToolSurfaceOptions): LaneToolSurface;
|
|
49
55
|
//# sourceMappingURL=lane-tool-surface.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lane-tool-surface.d.ts","sourceRoot":"","sources":["../../../src/core/autonomy/lane-tool-surface.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"lane-tool-surface.d.ts","sourceRoot":"","sources":["../../../src/core/autonomy/lane-tool-surface.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAG5E,OAAO,EACN,iBAAiB,EAEjB,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,MAAM,wCAAwC,CAAC;AAChD,OAAO,KAAK,EACX,cAAc,EACd,4BAA4B,EAC5B,sBAAsB,EACtB,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AA6BhE,MAAM,WAAW,eAAe;IAC/B,oGAAoG;IACpG,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,yEAAyE;IACzE,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACzB,8FAA8F;IAC9F,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,yEAAyE;IACzE,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,iGAAiG;IACjG,oBAAoB,EAAE,MAAM,EAAE,CAAC;IAC/B,qEAAqE;IACrE,cAAc,EAAE,WAAW,CAAC,eAAe,CAAC,gBAAgB,CAAC,CAAC,CAAC;IAC/D,+EAA+E;IAC/E,OAAO,CAAC,EAAE,iBAAiB,CAAC;CAC5B;AAED,MAAM,WAAW,sBAAsB;IACtC,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,iBAAiB,CAAC;IAC5B,yEAAyE;IACzE,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAChC,wGAAwG;IACxG,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IAChD,4FAA4F;IAC5F,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/B,qGAAqG;IACrG,eAAe,CAAC,EAAE,4BAA4B,CAAC;IAC/C,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,mGAAmG;IACnG,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gGAAgG;IAChG,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB,aAAa,CAAC,EAAE,SAAS,sBAAsB,EAAE,CAAC;IAClD,2GAA2G;IAC3G,eAAe,CAAC,EAAE,SAAS,SAAS,EAAE,CAAC;IACvC,sFAAsF;IACtF,YAAY,CAAC,EAAE,mBAAmB,CAAC;IACnC,6EAA6E;IAC7E,YAAY,CAAC,EAAE,sBAAsB,CAAC;CACtC;AA0ED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,sBAAsB,GAAG,eAAe,CA4HtF"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { Type } from "typebox";
|
|
3
|
+
import { STABLE_SHELL_TOOL_NAME } from "../default-tool-surface.js";
|
|
3
4
|
import { CapabilityGateway, CapabilityGatewayDeniedError, } from "../orchestration/capability-gateway.js";
|
|
4
5
|
import { wrapToolWithCredentialExposureGuard } from "../secrets/credential-exposure-guard.js";
|
|
5
6
|
import { matchesResourceProfilePattern } from "../settings-manager.js";
|
|
7
|
+
import { createBashTool } from "../tools/bash.js";
|
|
6
8
|
import { createEditTool } from "../tools/edit.js";
|
|
7
9
|
import { FileMutationIntentController } from "../tools/file-mutation-intent.js";
|
|
8
10
|
import { createFindTool } from "../tools/find.js";
|
|
@@ -38,7 +40,7 @@ function strictLaneProfilePatterns(profile) {
|
|
|
38
40
|
function resolveWriteRoots(cwd, writePaths) {
|
|
39
41
|
return writePaths.map((entry) => (path.isAbsolute(entry) ? path.resolve(entry) : path.resolve(cwd, entry)));
|
|
40
42
|
}
|
|
41
|
-
function createLaneTools(cwd, names, fileMutationIntents, readMemory, executionPolicy, processMaxWallClockMs = 0) {
|
|
43
|
+
function createLaneTools(cwd, names, fileMutationIntents, additionalTools, readMemory, executionPolicy, processMaxWallClockMs = 0, shellSessionKey) {
|
|
42
44
|
const factories = new Map([
|
|
43
45
|
["read", () => createReadTool(cwd)],
|
|
44
46
|
["grep", () => createGrepTool(cwd)],
|
|
@@ -50,6 +52,9 @@ function createLaneTools(cwd, names, fileMutationIntents, readMemory, executionP
|
|
|
50
52
|
if (executionPolicy) {
|
|
51
53
|
factories.set(PROCESS_LANE_TOOL_NAME, () => createRunProcessTool(cwd, { policy: executionPolicy, maxWallClockMs: processMaxWallClockMs }));
|
|
52
54
|
}
|
|
55
|
+
if (shellSessionKey) {
|
|
56
|
+
factories.set(STABLE_SHELL_TOOL_NAME, () => createBashTool(cwd, { sessionKey: shellSessionKey }));
|
|
57
|
+
}
|
|
53
58
|
if (readMemory) {
|
|
54
59
|
factories.set(MEMORY_LANE_TOOL_NAME, () => ({
|
|
55
60
|
name: MEMORY_LANE_TOOL_NAME,
|
|
@@ -69,6 +74,9 @@ function createLaneTools(cwd, names, fileMutationIntents, readMemory, executionP
|
|
|
69
74
|
}));
|
|
70
75
|
}
|
|
71
76
|
return names.flatMap((name) => {
|
|
77
|
+
const additional = additionalTools.get(name);
|
|
78
|
+
if (additional)
|
|
79
|
+
return [additional];
|
|
72
80
|
const factory = factories.get(name);
|
|
73
81
|
return factory ? [wrapToolWithCredentialExposureGuard(factory(), cwd)] : [];
|
|
74
82
|
});
|
|
@@ -76,20 +84,35 @@ function createLaneTools(cwd, names, fileMutationIntents, readMemory, executionP
|
|
|
76
84
|
/**
|
|
77
85
|
* Materialize a fresh, fail-closed tool surface for one isolated lane.
|
|
78
86
|
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
87
|
+
* Admission selects classified built-ins plus runtime-owned injected controls. A compiled grant is
|
|
88
|
+
* the only authority source for worker lanes; host shell and recursive delegation are materialized
|
|
89
|
+
* when named by that grant. Write/edit additionally require the global write switch and a positive
|
|
90
|
+
* path scope.
|
|
83
91
|
*/
|
|
84
92
|
export function createLaneToolSurface(options) {
|
|
85
93
|
const fileMutationIntents = new FileMutationIntentController();
|
|
94
|
+
const additionalTools = new Map();
|
|
95
|
+
for (const tool of options.additionalTools ?? []) {
|
|
96
|
+
if (!tool.name.trim())
|
|
97
|
+
throw new Error("An injected lane tool must have a name.");
|
|
98
|
+
if (additionalTools.has(tool.name))
|
|
99
|
+
throw new Error(`Injected lane tool '${tool.name}' is duplicated.`);
|
|
100
|
+
additionalTools.set(tool.name, tool);
|
|
101
|
+
}
|
|
86
102
|
const writeCapable = options.writeEnabled === true && (options.writePaths?.length ?? 0) > 0;
|
|
87
|
-
const
|
|
103
|
+
const builtInCandidateNames = [
|
|
88
104
|
...READ_ONLY_LANE_TOOL_NAMES,
|
|
89
105
|
...(options.readMemory ? [MEMORY_LANE_TOOL_NAME] : []),
|
|
90
106
|
...(writeCapable ? WRITE_LANE_TOOL_NAMES : []),
|
|
91
107
|
...(options.executionPolicy ? [PROCESS_LANE_TOOL_NAME] : []),
|
|
108
|
+
...(options.shellSessionKey ? [STABLE_SHELL_TOOL_NAME] : []),
|
|
92
109
|
];
|
|
110
|
+
for (const name of additionalTools.keys()) {
|
|
111
|
+
if (builtInCandidateNames.includes(name)) {
|
|
112
|
+
throw new Error(`Injected lane tool '${name}' conflicts with a built-in lane tool.`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
const candidateNames = [...builtInCandidateNames, ...additionalTools.keys()];
|
|
93
116
|
const patterns = strictLaneProfilePatterns(options.profile);
|
|
94
117
|
const compiledToolNames = new Set(options.grant?.allowedTools ?? []);
|
|
95
118
|
const deniedTools = candidateNames.filter((name) => options.grant ? !compiledToolNames.has(name) : matchesResourceProfilePattern(name, patterns.block));
|
|
@@ -110,6 +133,7 @@ export function createLaneToolSurface(options) {
|
|
|
110
133
|
grant: options.grant,
|
|
111
134
|
cwd: options.cwd,
|
|
112
135
|
...(options.initialUsage !== undefined ? { initialUsage: options.initialUsage } : {}),
|
|
136
|
+
...(options.sharedBudget ? { sharedBudget: options.sharedBudget } : {}),
|
|
113
137
|
})
|
|
114
138
|
: undefined;
|
|
115
139
|
const deniedPaths = options.deniedPaths?.map((entry) => path.resolve(entry));
|
|
@@ -118,7 +142,9 @@ export function createLaneToolSurface(options) {
|
|
|
118
142
|
capabilities: [
|
|
119
143
|
"filesystem.read",
|
|
120
144
|
...(allowedToolSet.has(MEMORY_LANE_TOOL_NAME) ? ["memory.query"] : []),
|
|
121
|
-
...(allowedToolSet.has(PROCESS_LANE_TOOL_NAME)
|
|
145
|
+
...(allowedToolSet.has(PROCESS_LANE_TOOL_NAME) || allowedToolSet.has(STABLE_SHELL_TOOL_NAME)
|
|
146
|
+
? ["process.exec"]
|
|
147
|
+
: []),
|
|
122
148
|
],
|
|
123
149
|
allowedTools,
|
|
124
150
|
deniedTools,
|
|
@@ -134,7 +160,7 @@ export function createLaneToolSurface(options) {
|
|
|
134
160
|
...(deniedPaths && deniedPaths.length > 0 ? { deniedPaths } : {}),
|
|
135
161
|
};
|
|
136
162
|
return {
|
|
137
|
-
tools: createLaneTools(options.cwd, allowedTools, fileMutationIntents, options.readMemory, options.executionPolicy, options.processMaxWallClockMs),
|
|
163
|
+
tools: createLaneTools(options.cwd, allowedTools, fileMutationIntents, additionalTools, options.readMemory, options.executionPolicy, options.processMaxWallClockMs, options.shellSessionKey),
|
|
138
164
|
dispose: () => fileMutationIntents.dispose(),
|
|
139
165
|
allowedTools,
|
|
140
166
|
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AI,CAAC,CAAC;oBACzD,OAAO,SAAS,CAAC;gBAClB,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBAChB,IAAI,KAAK,YAAY,4BAA4B,EAAE,CAAC;wBACnD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,sBAAsB,KAAK,CAAC,UAAU,MAAM,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC;oBAC7F,CAAC;oBACD,MAAM,KAAK,CAAC;gBACb,CAAC;YACF,CAAC;YACD,MAAM,OAAO,GAAG,gBAAgB,CAAC;gBAChC,QAAQ,EAAE,QAAQ,CAAC,IAAI;gBACvB,IAAI;gBACJ,GAAG,EAAE,OAAO,CAAC,GAAG;gBAChB,QAAQ,EAAE,wBAAwB,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,YAAY;aACpF,CAAC,CAAC;YACH,IAAI,OAAO,CAAC,OAAO,KAAK,OAAO;gBAAE,OAAO,SAAS,CAAC;YAClD,OAAO;gBACN,KAAK,EAAE,IAAI;gBACX,MAAM,EAAE,sBAAsB,OAAO,CAAC,UAAU,MAAM,OAAO,CAAC,OAAO,IAAI,2BAA2B,EAAE;aACtG,CAAC;QACH,CAAC;QACD,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC/B,CAAC;AACH,CAAC","sourcesContent":["import path from \"node:path\";\nimport type { AgentLoopConfig, AgentTool } from \"@caupulican/pi-agent-core\";\nimport { type Static, Type } from \"typebox\";\nimport {\n\tCapabilityGateway,\n\tCapabilityGatewayDeniedError,\n\ttype GatewayInitialUsage,\n} from \"../orchestration/capability-gateway.ts\";\nimport type {\n\tExecutionGrant,\n\tOrchestrationExecutionPolicy,\n\tToolCapabilityManifest,\n} from \"../orchestration/contracts.ts\";\nimport type { NormalizedProfile } from \"../profile-registry.ts\";\nimport { wrapToolWithCredentialExposureGuard } from \"../secrets/credential-exposure-guard.ts\";\nimport { matchesResourceProfilePattern } from \"../settings-manager.ts\";\nimport { createEditTool } from \"../tools/edit.ts\";\nimport { FileMutationIntentController } from \"../tools/file-mutation-intent.ts\";\nimport { createFindTool } from \"../tools/find.ts\";\nimport { createGrepTool } from \"../tools/grep.ts\";\nimport { createLsTool } from \"../tools/ls.ts\";\nimport { createReadTool } from \"../tools/read.ts\";\nimport { createRunProcessTool } from \"../tools/run-process.ts\";\nimport { createWriteTool } from \"../tools/write.ts\";\nimport type { CapabilityEnvelope } from \"./contracts.ts\";\nimport { evaluateToolGate } from \"./gates.ts\";\n\nconst READ_ONLY_LANE_TOOL_NAMES = [\"read\", \"grep\", \"find\", \"ls\"] as const;\nconst MEMORY_LANE_TOOL_NAME = \"memory\" as const;\nconst WRITE_LANE_TOOL_NAMES = [\"write\", \"edit\"] as const;\nconst PROCESS_LANE_TOOL_NAME = \"run_process\" as const;\nconst MAX_LANE_MEMORY_QUERY_CHARS = 4_096;\nconst laneMemorySchema = Type.Object({\n\tquery: Type.String({\n\t\tmaxLength: MAX_LANE_MEMORY_QUERY_CHARS,\n\t\tdescription: \"What relevant standing memory or prior evidence to retrieve\",\n\t}),\n});\ntype LaneMemoryParams = Static<typeof laneMemorySchema>;\nconst WRITE_LANE_TOOL_NAME_SET = new Set<string>(WRITE_LANE_TOOL_NAMES);\n\nexport interface LaneToolSurface {\n\t/** Fresh tools owned by this lane only; no foreground tool instances or extension state leak in. */\n\ttools: AgentTool[];\n\t/** Release exact mutation payload leases owned by this isolated lane. */\n\tdispose(): Promise<void>;\n\t/** Exact names after profile globs are expanded. Safe to persist in a capability envelope. */\n\tallowedTools: string[];\n\t/** Exact safe-candidate names denied by the profile's block patterns. */\n\tdeniedTools: string[];\n\t/** Explicit grants that bind to no classified lane candidate (opaque tools stay fail-closed). */\n\tunboundAllowPatterns: string[];\n\t/** Per-call path and capability gate for the isolated child loop. */\n\tbeforeToolCall: NonNullable<AgentLoopConfig[\"beforeToolCall\"]>;\n\t/** Canonical cumulative authority/budget meter for a compiled worker grant. */\n\tgateway?: CapabilityGateway;\n}\n\nexport interface LaneToolSurfaceOptions {\n\tcwd: string;\n\tprofile?: NormalizedProfile;\n\t/** Private harness state that generic file tools must never traverse. */\n\tdeniedPaths?: readonly string[];\n\t/** Orchestrator-requested, policy-filtered read-only memory retrieval. Omitted means no memory tool. */\n\treadMemory?: (query: string) => Promise<string>;\n\t/** Research never sets this. Workers require both this flag and at least one write path. */\n\twriteEnabled?: boolean;\n\twritePaths?: readonly string[];\n\t/** Present only for process-capable owner profiles; absent means no process tool is materialized. */\n\texecutionPolicy?: OrchestrationExecutionPolicy;\n\tprocessMaxWallClockMs?: number;\n\t/** Compiled policy path. When present, it is the only authorization source for this surface. */\n\tgrant?: ExecutionGrant;\n\ttoolManifests?: readonly ToolCapabilityManifest[];\n\t/** Durable cumulative active usage to seed the compiled grant's gateway on resume. */\n\tinitialUsage?: GatewayInitialUsage;\n}\n\nfunction strictLaneProfilePatterns(profile: NormalizedProfile | undefined): {\n\tallow: string[];\n\tblock: string[];\n} {\n\tif (!profile) return { allow: [], block: [] };\n\tconst filter = profile.resources.tools;\n\tconst allow = [...(filter?.allow ?? [])];\n\tconst block = [...(filter?.block ?? [])];\n\t// Strict UAC: a shipped profile is the complete authority grant. Grant-all must be explicit.\n\tif (allow.length === 0 && block.length === 0) return { allow: [], block: [\"*\"] };\n\treturn { allow, block };\n}\n\nfunction resolveWriteRoots(cwd: string, writePaths: readonly string[]): string[] {\n\treturn writePaths.map((entry) => (path.isAbsolute(entry) ? path.resolve(entry) : path.resolve(cwd, entry)));\n}\n\nfunction createLaneTools(\n\tcwd: string,\n\tnames: readonly string[],\n\tfileMutationIntents: FileMutationIntentController,\n\treadMemory?: (query: string) => Promise<string>,\n\texecutionPolicy?: OrchestrationExecutionPolicy,\n\tprocessMaxWallClockMs = 0,\n): AgentTool[] {\n\tconst factories = new Map<string, () => AgentTool>([\n\t\t[\"read\", () => createReadTool(cwd)],\n\t\t[\"grep\", () => createGrepTool(cwd)],\n\t\t[\"find\", () => createFindTool(cwd)],\n\t\t[\"ls\", () => createLsTool(cwd)],\n\t\t[\"write\", () => createWriteTool(cwd, { intentController: fileMutationIntents })],\n\t\t[\"edit\", () => createEditTool(cwd, { intentController: fileMutationIntents })],\n\t]);\n\tif (executionPolicy) {\n\t\tfactories.set(PROCESS_LANE_TOOL_NAME, () =>\n\t\t\tcreateRunProcessTool(cwd, { policy: executionPolicy, maxWallClockMs: processMaxWallClockMs }),\n\t\t);\n\t}\n\tif (readMemory) {\n\t\tfactories.set(MEMORY_LANE_TOOL_NAME, () => ({\n\t\t\tname: MEMORY_LANE_TOOL_NAME,\n\t\t\tlabel: \"Read Memory\",\n\t\t\tdescription:\n\t\t\t\t\"Retrieve bounded, source-labeled standing memory relevant to this delegated task. Read-only: no memory writes or lifecycle actions are available.\",\n\t\t\tparameters: laneMemorySchema,\n\t\t\texecute: async (_toolCallId, params) => {\n\t\t\t\tconst query = (params as LaneMemoryParams).query?.trim();\n\t\t\t\tif (!query || query.length > MAX_LANE_MEMORY_QUERY_CHARS) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`memory_query_invalid: query must contain from 1 through ${MAX_LANE_MEMORY_QUERY_CHARS} characters.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\" as const, text: await readMemory(query) }],\n\t\t\t\t\tdetails: { readOnly: true },\n\t\t\t\t};\n\t\t\t},\n\t\t}));\n\t}\n\treturn names.flatMap((name) => {\n\t\tconst factory = factories.get(name);\n\t\treturn factory ? [wrapToolWithCredentialExposureGuard(factory(), cwd)] : [];\n\t});\n}\n\n/**\n * Materialize a fresh, fail-closed tool surface for one isolated lane.\n *\n * Profiles select only from classified built-ins. Opaque extension tools, shell, memory, goals,\n * and `delegate` are never candidates, so a wildcard cannot manufacture unknown authority or\n * recursively spawn more workers. Write/edit additionally require the explicit worker write switch\n * and a non-empty path scope; research therefore stays read-only regardless of profile contents.\n */\nexport function createLaneToolSurface(options: LaneToolSurfaceOptions): LaneToolSurface {\n\tconst fileMutationIntents = new FileMutationIntentController();\n\tconst writeCapable = options.writeEnabled === true && (options.writePaths?.length ?? 0) > 0;\n\tconst candidateNames = [\n\t\t...READ_ONLY_LANE_TOOL_NAMES,\n\t\t...(options.readMemory ? [MEMORY_LANE_TOOL_NAME] : []),\n\t\t...(writeCapable ? WRITE_LANE_TOOL_NAMES : []),\n\t\t...(options.executionPolicy ? [PROCESS_LANE_TOOL_NAME] : []),\n\t];\n\tconst patterns = strictLaneProfilePatterns(options.profile);\n\tconst compiledToolNames = new Set(options.grant?.allowedTools ?? []);\n\tconst deniedTools = candidateNames.filter((name) =>\n\t\toptions.grant ? !compiledToolNames.has(name) : matchesResourceProfilePattern(name, patterns.block),\n\t);\n\tconst unboundAllowPatterns = options.grant\n\t\t? []\n\t\t: patterns.allow.filter(\n\t\t\t\t(pattern) => !candidateNames.some((name) => matchesResourceProfilePattern(name, [pattern])),\n\t\t\t);\n\tconst allowedTools = options.grant\n\t\t? candidateNames.filter((name) => compiledToolNames.has(name))\n\t\t: candidateNames.filter(\n\t\t\t\t(name) =>\n\t\t\t\t\t(patterns.allow.length === 0 || matchesResourceProfilePattern(name, patterns.allow)) &&\n\t\t\t\t\t!matchesResourceProfilePattern(name, patterns.block),\n\t\t\t);\n\tconst allowedToolSet = new Set<string>(allowedTools);\n\tconst manifestsByName = new Map(options.toolManifests?.map((manifest) => [manifest.toolName, manifest]) ?? []);\n\tif (options.grant?.allowedTools.some((name) => !manifestsByName.has(name))) {\n\t\tthrow new Error(\"Compiled lane grant references a tool without a capability manifest.\");\n\t}\n\tconst gateway = options.grant\n\t\t? new CapabilityGateway({\n\t\t\t\tgrant: options.grant,\n\t\t\t\tcwd: options.cwd,\n\t\t\t\t...(options.initialUsage !== undefined ? { initialUsage: options.initialUsage } : {}),\n\t\t\t})\n\t\t: undefined;\n\tconst deniedPaths = options.deniedPaths?.map((entry) => path.resolve(entry));\n\tconst readEnvelope: CapabilityEnvelope = {\n\t\tid: \"isolated-lane-read-tools\",\n\t\tcapabilities: [\n\t\t\t\"filesystem.read\",\n\t\t\t...(allowedToolSet.has(MEMORY_LANE_TOOL_NAME) ? ([\"memory.query\"] as const) : []),\n\t\t\t...(allowedToolSet.has(PROCESS_LANE_TOOL_NAME) ? ([\"process.exec\"] as const) : []),\n\t\t],\n\t\tallowedTools,\n\t\tdeniedTools,\n\t\tallowedPaths: [path.resolve(options.cwd)],\n\t\t...(deniedPaths && deniedPaths.length > 0 ? { deniedPaths } : {}),\n\t};\n\tconst writeEnvelope: CapabilityEnvelope = {\n\t\tid: \"isolated-lane-write-tools\",\n\t\tcapabilities: [\"filesystem.write\"],\n\t\tallowedTools,\n\t\tdeniedTools,\n\t\tallowedPaths: resolveWriteRoots(options.cwd, options.writePaths ?? []),\n\t\t...(deniedPaths && deniedPaths.length > 0 ? { deniedPaths } : {}),\n\t};\n\n\treturn {\n\t\ttools: createLaneTools(\n\t\t\toptions.cwd,\n\t\t\tallowedTools,\n\t\t\tfileMutationIntents,\n\t\t\toptions.readMemory,\n\t\t\toptions.executionPolicy,\n\t\t\toptions.processMaxWallClockMs,\n\t\t),\n\t\tdispose: () => fileMutationIntents.dispose(),\n\t\tallowedTools,\n\t\tdeniedTools,\n\t\tunboundAllowPatterns,\n\t\tbeforeToolCall: async ({ toolCall, args }) => {\n\t\t\tif (!allowedToolSet.has(toolCall.name)) {\n\t\t\t\treturn { block: true, reason: `Lane tool '${toolCall.name}' is outside the materialized UAC surface.` };\n\t\t\t}\n\t\t\tif (gateway) {\n\t\t\t\tconst manifest = manifestsByName.get(toolCall.name);\n\t\t\t\tif (!manifest) {\n\t\t\t\t\treturn { block: true, reason: `Lane tool '${toolCall.name}' has no compiled capability manifest.` };\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\tgateway.authorizeToolCall(manifest, toolCall.name, args);\n\t\t\t\t\treturn undefined;\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (error instanceof CapabilityGatewayDeniedError) {\n\t\t\t\t\t\treturn { block: true, reason: `Lane tool blocked (${error.reasonCode}): ${error.message}` };\n\t\t\t\t\t}\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst outcome = evaluateToolGate({\n\t\t\t\ttoolName: toolCall.name,\n\t\t\t\targs,\n\t\t\t\tcwd: options.cwd,\n\t\t\t\tenvelope: WRITE_LANE_TOOL_NAME_SET.has(toolCall.name) ? writeEnvelope : readEnvelope,\n\t\t\t});\n\t\t\tif (outcome.outcome === \"allow\") return undefined;\n\t\t\treturn {\n\t\t\t\tblock: true,\n\t\t\t\treason: `Lane tool blocked (${outcome.reasonCode}): ${outcome.message ?? \"capability gate denied it\"}`,\n\t\t\t};\n\t\t},\n\t\t...(gateway ? { gateway } : {}),\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"lane-tool-surface.js","sourceRoot":"","sources":["../../../src/core/autonomy/lane-tool-surface.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EACN,iBAAiB,EACjB,4BAA4B,GAG5B,MAAM,wCAAwC,CAAC;AAOhD,OAAO,EAAE,mCAAmC,EAAE,MAAM,yCAAyC,CAAC;AAC9F,OAAO,EAAE,6BAA6B,EAAE,MAAM,wBAAwB,CAAC;AACvE,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,4BAA4B,EAAE,MAAM,kCAAkC,CAAC;AAChF,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,kBA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,GAAG,EAAE,OAAO,CAAC,GAAG;gBAChB,QAAQ,EAAE,wBAAwB,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,YAAY;aACpF,CAAC,CAAC;YACH,IAAI,OAAO,CAAC,OAAO,KAAK,OAAO;gBAAE,OAAO,SAAS,CAAC;YAClD,OAAO;gBACN,KAAK,EAAE,IAAI;gBACX,MAAM,EAAE,sBAAsB,OAAO,CAAC,UAAU,MAAM,OAAO,CAAC,OAAO,IAAI,2BAA2B,EAAE;aACtG,CAAC;QACH,CAAC;QACD,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC/B,CAAC;AACH,CAAC","sourcesContent":["import path from \"node:path\";\nimport type { AgentLoopConfig, AgentTool } from \"@caupulican/pi-agent-core\";\nimport { type Static, Type } from \"typebox\";\nimport { STABLE_SHELL_TOOL_NAME } from \"../default-tool-surface.ts\";\nimport {\n\tCapabilityGateway,\n\tCapabilityGatewayDeniedError,\n\ttype GatewayInitialUsage,\n\ttype SharedCapabilityBudget,\n} from \"../orchestration/capability-gateway.ts\";\nimport type {\n\tExecutionGrant,\n\tOrchestrationExecutionPolicy,\n\tToolCapabilityManifest,\n} from \"../orchestration/contracts.ts\";\nimport type { NormalizedProfile } from \"../profile-registry.ts\";\nimport { wrapToolWithCredentialExposureGuard } from \"../secrets/credential-exposure-guard.ts\";\nimport { matchesResourceProfilePattern } from \"../settings-manager.ts\";\nimport { createBashTool } from \"../tools/bash.ts\";\nimport { createEditTool } from \"../tools/edit.ts\";\nimport { FileMutationIntentController } from \"../tools/file-mutation-intent.ts\";\nimport { createFindTool } from \"../tools/find.ts\";\nimport { createGrepTool } from \"../tools/grep.ts\";\nimport { createLsTool } from \"../tools/ls.ts\";\nimport { createReadTool } from \"../tools/read.ts\";\nimport { createRunProcessTool } from \"../tools/run-process.ts\";\nimport { createWriteTool } from \"../tools/write.ts\";\nimport type { CapabilityEnvelope } from \"./contracts.ts\";\nimport { evaluateToolGate } from \"./gates.ts\";\n\nconst READ_ONLY_LANE_TOOL_NAMES = [\"read\", \"grep\", \"find\", \"ls\"] as const;\nconst MEMORY_LANE_TOOL_NAME = \"memory\" as const;\nconst WRITE_LANE_TOOL_NAMES = [\"write\", \"edit\"] as const;\nconst PROCESS_LANE_TOOL_NAME = \"run_process\" as const;\nconst MAX_LANE_MEMORY_QUERY_CHARS = 4_096;\nconst laneMemorySchema = Type.Object({\n\tquery: Type.String({\n\t\tmaxLength: MAX_LANE_MEMORY_QUERY_CHARS,\n\t\tdescription: \"What relevant standing memory or prior evidence to retrieve\",\n\t}),\n});\ntype LaneMemoryParams = Static<typeof laneMemorySchema>;\nconst WRITE_LANE_TOOL_NAME_SET = new Set<string>(WRITE_LANE_TOOL_NAMES);\n\nexport interface LaneToolSurface {\n\t/** Fresh tools owned by this lane only; no foreground tool instances or extension state leak in. */\n\ttools: AgentTool[];\n\t/** Release exact mutation payload leases owned by this isolated lane. */\n\tdispose(): Promise<void>;\n\t/** Exact names after profile globs are expanded. Safe to persist in a capability envelope. */\n\tallowedTools: string[];\n\t/** Exact safe-candidate names denied by the profile's block patterns. */\n\tdeniedTools: string[];\n\t/** Explicit grants that bind to no classified lane candidate (opaque tools stay fail-closed). */\n\tunboundAllowPatterns: string[];\n\t/** Per-call path and capability gate for the isolated child loop. */\n\tbeforeToolCall: NonNullable<AgentLoopConfig[\"beforeToolCall\"]>;\n\t/** Canonical cumulative authority/budget meter for a compiled worker grant. */\n\tgateway?: CapabilityGateway;\n}\n\nexport interface LaneToolSurfaceOptions {\n\tcwd: string;\n\tprofile?: NormalizedProfile;\n\t/** Private harness state that generic file tools must never traverse. */\n\tdeniedPaths?: readonly string[];\n\t/** Orchestrator-requested, policy-filtered read-only memory retrieval. Omitted means no memory tool. */\n\treadMemory?: (query: string) => Promise<string>;\n\t/** Research never sets this. Workers require both this flag and at least one write path. */\n\twriteEnabled?: boolean;\n\twritePaths?: readonly string[];\n\t/** Present only for process-capable owner profiles; absent means no process tool is materialized. */\n\texecutionPolicy?: OrchestrationExecutionPolicy;\n\tprocessMaxWallClockMs?: number;\n\t/** Stable per-agent shell identity. Omitted when the compiled plan does not grant a host shell. */\n\tshellSessionKey?: string;\n\t/** Compiled policy path. When present, it is the only authorization source for this surface. */\n\tgrant?: ExecutionGrant;\n\ttoolManifests?: readonly ToolCapabilityManifest[];\n\t/** Runtime-owned classified tools composed specifically for this lane (for example delegation control). */\n\tadditionalTools?: readonly AgentTool[];\n\t/** Durable cumulative active usage to seed the compiled grant's gateway on resume. */\n\tinitialUsage?: GatewayInitialUsage;\n\t/** Root-tree aggregate meter shared by this attempt and every descendant. */\n\tsharedBudget?: SharedCapabilityBudget;\n}\n\nfunction strictLaneProfilePatterns(profile: NormalizedProfile | undefined): {\n\tallow: string[];\n\tblock: string[];\n} {\n\tif (!profile) return { allow: [], block: [] };\n\tconst filter = profile.resources.tools;\n\tconst allow = [...(filter?.allow ?? [])];\n\tconst block = [...(filter?.block ?? [])];\n\t// Strict UAC: a shipped profile is the complete authority grant. Grant-all must be explicit.\n\tif (allow.length === 0 && block.length === 0) return { allow: [], block: [\"*\"] };\n\treturn { allow, block };\n}\n\nfunction resolveWriteRoots(cwd: string, writePaths: readonly string[]): string[] {\n\treturn writePaths.map((entry) => (path.isAbsolute(entry) ? path.resolve(entry) : path.resolve(cwd, entry)));\n}\n\nfunction createLaneTools(\n\tcwd: string,\n\tnames: readonly string[],\n\tfileMutationIntents: FileMutationIntentController,\n\tadditionalTools: ReadonlyMap<string, AgentTool>,\n\treadMemory?: (query: string) => Promise<string>,\n\texecutionPolicy?: OrchestrationExecutionPolicy,\n\tprocessMaxWallClockMs = 0,\n\tshellSessionKey?: string,\n): AgentTool[] {\n\tconst factories = new Map<string, () => AgentTool>([\n\t\t[\"read\", () => createReadTool(cwd)],\n\t\t[\"grep\", () => createGrepTool(cwd)],\n\t\t[\"find\", () => createFindTool(cwd)],\n\t\t[\"ls\", () => createLsTool(cwd)],\n\t\t[\"write\", () => createWriteTool(cwd, { intentController: fileMutationIntents })],\n\t\t[\"edit\", () => createEditTool(cwd, { intentController: fileMutationIntents })],\n\t]);\n\tif (executionPolicy) {\n\t\tfactories.set(PROCESS_LANE_TOOL_NAME, () =>\n\t\t\tcreateRunProcessTool(cwd, { policy: executionPolicy, maxWallClockMs: processMaxWallClockMs }),\n\t\t);\n\t}\n\tif (shellSessionKey) {\n\t\tfactories.set(STABLE_SHELL_TOOL_NAME, () => createBashTool(cwd, { sessionKey: shellSessionKey }));\n\t}\n\tif (readMemory) {\n\t\tfactories.set(MEMORY_LANE_TOOL_NAME, () => ({\n\t\t\tname: MEMORY_LANE_TOOL_NAME,\n\t\t\tlabel: \"Read Memory\",\n\t\t\tdescription:\n\t\t\t\t\"Retrieve bounded, source-labeled standing memory relevant to this delegated task. Read-only: no memory writes or lifecycle actions are available.\",\n\t\t\tparameters: laneMemorySchema,\n\t\t\texecute: async (_toolCallId, params) => {\n\t\t\t\tconst query = (params as LaneMemoryParams).query?.trim();\n\t\t\t\tif (!query || query.length > MAX_LANE_MEMORY_QUERY_CHARS) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`memory_query_invalid: query must contain from 1 through ${MAX_LANE_MEMORY_QUERY_CHARS} characters.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\" as const, text: await readMemory(query) }],\n\t\t\t\t\tdetails: { readOnly: true },\n\t\t\t\t};\n\t\t\t},\n\t\t}));\n\t}\n\treturn names.flatMap((name) => {\n\t\tconst additional = additionalTools.get(name);\n\t\tif (additional) return [additional];\n\t\tconst factory = factories.get(name);\n\t\treturn factory ? [wrapToolWithCredentialExposureGuard(factory(), cwd)] : [];\n\t});\n}\n\n/**\n * Materialize a fresh, fail-closed tool surface for one isolated lane.\n *\n * Admission selects classified built-ins plus runtime-owned injected controls. A compiled grant is\n * the only authority source for worker lanes; host shell and recursive delegation are materialized\n * when named by that grant. Write/edit additionally require the global write switch and a positive\n * path scope.\n */\nexport function createLaneToolSurface(options: LaneToolSurfaceOptions): LaneToolSurface {\n\tconst fileMutationIntents = new FileMutationIntentController();\n\tconst additionalTools = new Map<string, AgentTool>();\n\tfor (const tool of options.additionalTools ?? []) {\n\t\tif (!tool.name.trim()) throw new Error(\"An injected lane tool must have a name.\");\n\t\tif (additionalTools.has(tool.name)) throw new Error(`Injected lane tool '${tool.name}' is duplicated.`);\n\t\tadditionalTools.set(tool.name, tool);\n\t}\n\tconst writeCapable = options.writeEnabled === true && (options.writePaths?.length ?? 0) > 0;\n\tconst builtInCandidateNames = [\n\t\t...READ_ONLY_LANE_TOOL_NAMES,\n\t\t...(options.readMemory ? [MEMORY_LANE_TOOL_NAME] : []),\n\t\t...(writeCapable ? WRITE_LANE_TOOL_NAMES : []),\n\t\t...(options.executionPolicy ? [PROCESS_LANE_TOOL_NAME] : []),\n\t\t...(options.shellSessionKey ? [STABLE_SHELL_TOOL_NAME] : []),\n\t];\n\tfor (const name of additionalTools.keys()) {\n\t\tif (builtInCandidateNames.includes(name as (typeof builtInCandidateNames)[number])) {\n\t\t\tthrow new Error(`Injected lane tool '${name}' conflicts with a built-in lane tool.`);\n\t\t}\n\t}\n\tconst candidateNames = [...builtInCandidateNames, ...additionalTools.keys()];\n\tconst patterns = strictLaneProfilePatterns(options.profile);\n\tconst compiledToolNames = new Set(options.grant?.allowedTools ?? []);\n\tconst deniedTools = candidateNames.filter((name) =>\n\t\toptions.grant ? !compiledToolNames.has(name) : matchesResourceProfilePattern(name, patterns.block),\n\t);\n\tconst unboundAllowPatterns = options.grant\n\t\t? []\n\t\t: patterns.allow.filter(\n\t\t\t\t(pattern) => !candidateNames.some((name) => matchesResourceProfilePattern(name, [pattern])),\n\t\t\t);\n\tconst allowedTools = options.grant\n\t\t? candidateNames.filter((name) => compiledToolNames.has(name))\n\t\t: candidateNames.filter(\n\t\t\t\t(name) =>\n\t\t\t\t\t(patterns.allow.length === 0 || matchesResourceProfilePattern(name, patterns.allow)) &&\n\t\t\t\t\t!matchesResourceProfilePattern(name, patterns.block),\n\t\t\t);\n\tconst allowedToolSet = new Set<string>(allowedTools);\n\tconst manifestsByName = new Map(options.toolManifests?.map((manifest) => [manifest.toolName, manifest]) ?? []);\n\tif (options.grant?.allowedTools.some((name) => !manifestsByName.has(name))) {\n\t\tthrow new Error(\"Compiled lane grant references a tool without a capability manifest.\");\n\t}\n\tconst gateway = options.grant\n\t\t? new CapabilityGateway({\n\t\t\t\tgrant: options.grant,\n\t\t\t\tcwd: options.cwd,\n\t\t\t\t...(options.initialUsage !== undefined ? { initialUsage: options.initialUsage } : {}),\n\t\t\t\t...(options.sharedBudget ? { sharedBudget: options.sharedBudget } : {}),\n\t\t\t})\n\t\t: undefined;\n\tconst deniedPaths = options.deniedPaths?.map((entry) => path.resolve(entry));\n\tconst readEnvelope: CapabilityEnvelope = {\n\t\tid: \"isolated-lane-read-tools\",\n\t\tcapabilities: [\n\t\t\t\"filesystem.read\",\n\t\t\t...(allowedToolSet.has(MEMORY_LANE_TOOL_NAME) ? ([\"memory.query\"] as const) : []),\n\t\t\t...(allowedToolSet.has(PROCESS_LANE_TOOL_NAME) || allowedToolSet.has(STABLE_SHELL_TOOL_NAME)\n\t\t\t\t? ([\"process.exec\"] as const)\n\t\t\t\t: []),\n\t\t],\n\t\tallowedTools,\n\t\tdeniedTools,\n\t\tallowedPaths: [path.resolve(options.cwd)],\n\t\t...(deniedPaths && deniedPaths.length > 0 ? { deniedPaths } : {}),\n\t};\n\tconst writeEnvelope: CapabilityEnvelope = {\n\t\tid: \"isolated-lane-write-tools\",\n\t\tcapabilities: [\"filesystem.write\"],\n\t\tallowedTools,\n\t\tdeniedTools,\n\t\tallowedPaths: resolveWriteRoots(options.cwd, options.writePaths ?? []),\n\t\t...(deniedPaths && deniedPaths.length > 0 ? { deniedPaths } : {}),\n\t};\n\n\treturn {\n\t\ttools: createLaneTools(\n\t\t\toptions.cwd,\n\t\t\tallowedTools,\n\t\t\tfileMutationIntents,\n\t\t\tadditionalTools,\n\t\t\toptions.readMemory,\n\t\t\toptions.executionPolicy,\n\t\t\toptions.processMaxWallClockMs,\n\t\t\toptions.shellSessionKey,\n\t\t),\n\t\tdispose: () => fileMutationIntents.dispose(),\n\t\tallowedTools,\n\t\tdeniedTools,\n\t\tunboundAllowPatterns,\n\t\tbeforeToolCall: async ({ toolCall, args }) => {\n\t\t\tif (!allowedToolSet.has(toolCall.name)) {\n\t\t\t\treturn { block: true, reason: `Lane tool '${toolCall.name}' is outside the materialized UAC surface.` };\n\t\t\t}\n\t\t\tif (gateway) {\n\t\t\t\tconst manifest = manifestsByName.get(toolCall.name);\n\t\t\t\tif (!manifest) {\n\t\t\t\t\treturn { block: true, reason: `Lane tool '${toolCall.name}' has no compiled capability manifest.` };\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\tgateway.authorizeToolCall(manifest, toolCall.name, args);\n\t\t\t\t\treturn undefined;\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (error instanceof CapabilityGatewayDeniedError) {\n\t\t\t\t\t\treturn { block: true, reason: `Lane tool blocked (${error.reasonCode}): ${error.message}` };\n\t\t\t\t\t}\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst outcome = evaluateToolGate({\n\t\t\t\ttoolName: toolCall.name,\n\t\t\t\targs,\n\t\t\t\tcwd: options.cwd,\n\t\t\t\tenvelope: WRITE_LANE_TOOL_NAME_SET.has(toolCall.name) ? writeEnvelope : readEnvelope,\n\t\t\t});\n\t\t\tif (outcome.outcome === \"allow\") return undefined;\n\t\t\treturn {\n\t\t\t\tblock: true,\n\t\t\t\treason: `Lane tool blocked (${outcome.reasonCode}): ${outcome.message ?? \"capability gate denied it\"}`,\n\t\t\t};\n\t\t},\n\t\t...(gateway ? { gateway } : {}),\n\t};\n}\n"]}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Agent system-prompt composition with an irreducible execution-contract core.
|
|
3
3
|
*
|
|
4
4
|
* The core is the "ultimate level-0 default": ~80 tokens of non-negotiable rules that survive ANY
|
|
5
5
|
* customization. Everything above it — the lane's role prompt and a shipped profile's soul — is a
|
|
6
6
|
* replaceable layer: settings, a lane profile, or the calling model (delegate tool) can erase and
|
|
7
7
|
* replace it entirely. This keeps shipped subagents maximally efficient on small open models (a
|
|
8
|
-
* caller can hand a tiny model a purpose-built minimal prompt)
|
|
9
|
-
*
|
|
8
|
+
* caller can hand a tiny model a purpose-built minimal prompt) while the kernel remains the sole
|
|
9
|
+
* authority and budget owner. Keep the core UNDER 300 tokens; it is deliberately terse.
|
|
10
10
|
*/
|
|
11
11
|
export declare const SUBAGENT_CORE_SYSTEM_PROMPT: string;
|
|
12
12
|
export interface SubagentPromptParts {
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Agent system-prompt composition with an irreducible execution-contract core.
|
|
3
3
|
*
|
|
4
4
|
* The core is the "ultimate level-0 default": ~80 tokens of non-negotiable rules that survive ANY
|
|
5
5
|
* customization. Everything above it — the lane's role prompt and a shipped profile's soul — is a
|
|
6
6
|
* replaceable layer: settings, a lane profile, or the calling model (delegate tool) can erase and
|
|
7
7
|
* replace it entirely. This keeps shipped subagents maximally efficient on small open models (a
|
|
8
|
-
* caller can hand a tiny model a purpose-built minimal prompt)
|
|
9
|
-
*
|
|
8
|
+
* caller can hand a tiny model a purpose-built minimal prompt) while the kernel remains the sole
|
|
9
|
+
* authority and budget owner. Keep the core UNDER 300 tokens; it is deliberately terse.
|
|
10
10
|
*/
|
|
11
11
|
export const SUBAGENT_CORE_SYSTEM_PROMPT = [
|
|
12
|
-
"You are
|
|
13
|
-
"1.
|
|
14
|
-
"2. You
|
|
15
|
-
"3.
|
|
16
|
-
"4.
|
|
17
|
-
"5. Follow the requested output
|
|
12
|
+
"You are an autonomous agent in a coding-agent orchestration tree. Execution contract:",
|
|
13
|
+
"1. Use the maximum useful capability exposed by your tool surface; the kernel enforces the exact inherited authority.",
|
|
14
|
+
"2. You may delegate recursively, inspect exact peer transcripts, and exchange threaded messages when those tools are present.",
|
|
15
|
+
"3. Concurrency, cumulative budgets, leases, cycle detection, cancellation, and irreversible user-authority boundaries are kernel-owned.",
|
|
16
|
+
"4. Never invent facts, file paths, APIs, or command results; state uncertainty directly.",
|
|
17
|
+
"5. Follow the requested output contract exactly; your result remains evidence that other agents may independently verify.",
|
|
18
18
|
].join("\n");
|
|
19
19
|
export function composeSubagentSystemPrompt(parts) {
|
|
20
20
|
const override = parts.override?.trim();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subagent-prompt.js","sourceRoot":"","sources":["../../../src/core/autonomy/subagent-prompt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG;IAC1C,
|
|
1
|
+
{"version":3,"file":"subagent-prompt.js","sourceRoot":"","sources":["../../../src/core/autonomy/subagent-prompt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG;IAC1C,uFAAuF;IACvF,uHAAuH;IACvH,+HAA+H;IAC/H,yIAAyI;IACzI,0FAA0F;IAC1F,2HAA2H;CAC3H,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAWb,MAAM,UAAU,2BAA2B,CAAC,KAA0B;IACrE,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC;IACxC,MAAM,KAAK,GACV,QAAQ,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC;QAC9B,CAAC,CAAC,QAAQ;QACV,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,KAAK,CAAC,UAAU,CAAC;aACrC,MAAM,CAAC,CAAC,IAAI,EAAkB,EAAE,CAAC,OAAO,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;aAClE,IAAI,CAAC,MAAM,CAAC,CAAC;IAClB,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,2BAA2B,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,2BAA2B,CAAC;AACtG,CAAC","sourcesContent":["/**\n * Agent system-prompt composition with an irreducible execution-contract core.\n *\n * The core is the \"ultimate level-0 default\": ~80 tokens of non-negotiable rules that survive ANY\n * customization. Everything above it — the lane's role prompt and a shipped profile's soul — is a\n * replaceable layer: settings, a lane profile, or the calling model (delegate tool) can erase and\n * replace it entirely. This keeps shipped subagents maximally efficient on small open models (a\n * caller can hand a tiny model a purpose-built minimal prompt) while the kernel remains the sole\n * authority and budget owner. Keep the core UNDER 300 tokens; it is deliberately terse.\n */\nexport const SUBAGENT_CORE_SYSTEM_PROMPT = [\n\t\"You are an autonomous agent in a coding-agent orchestration tree. Execution contract:\",\n\t\"1. Use the maximum useful capability exposed by your tool surface; the kernel enforces the exact inherited authority.\",\n\t\"2. You may delegate recursively, inspect exact peer transcripts, and exchange threaded messages when those tools are present.\",\n\t\"3. Concurrency, cumulative budgets, leases, cycle detection, cancellation, and irreversible user-authority boundaries are kernel-owned.\",\n\t\"4. Never invent facts, file paths, APIs, or command results; state uncertainty directly.\",\n\t\"5. Follow the requested output contract exactly; your result remains evidence that other agents may independently verify.\",\n].join(\"\\n\");\n\nexport interface SubagentPromptParts {\n\t/** Situational identity from the shipped profile (replaceable layer). */\n\tsoul?: string;\n\t/** The lane's default role prompt (replaceable layer). */\n\trolePrompt: string;\n\t/** User- or model-provided replacement for every layer above level 0. */\n\toverride?: string;\n}\n\nexport function composeSubagentSystemPrompt(parts: SubagentPromptParts): string {\n\tconst override = parts.override?.trim();\n\tconst above =\n\t\toverride && override.length > 0\n\t\t\t? override\n\t\t\t: [parts.soul?.trim(), parts.rolePrompt]\n\t\t\t\t\t.filter((part): part is string => Boolean(part && part.length > 0))\n\t\t\t\t\t.join(\"\\n\\n\");\n\treturn above.length > 0 ? `${SUBAGENT_CORE_SYSTEM_PROMPT}\\n\\n${above}` : SUBAGENT_CORE_SYSTEM_PROMPT;\n}\n"]}
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
import type { Api, Model } from "@caupulican/pi-ai";
|
|
17
17
|
import type { GoalContinuationLoopOptions, GoalContinuationLoopResult, PromptOptions, ResearchLaneRunOutcome, WorkerDelegationRunOutcome } from "./agent-session-contracts.ts";
|
|
18
18
|
import { type LaneRecord } from "./autonomy/lane-tracker.ts";
|
|
19
|
-
import type { WorkerAgentControlPort } from "./delegation/worker-agent-control.ts";
|
|
19
|
+
import type { WorkerAgentControlPort, WorkerAgentControlScope, WorkerAgentMessageOptions, WorkerAgentTranscriptOptions } from "./delegation/worker-agent-control.ts";
|
|
20
20
|
import { type WorkerDelegationControllerDeps } from "./delegation/worker-delegation-controller.ts";
|
|
21
21
|
import type { WorkerDelegationRequest } from "./delegation/worker-delegation-request.ts";
|
|
22
22
|
import type { ManagedLaneEvent } from "./extensions/types.ts";
|
|
@@ -141,7 +141,7 @@ export declare class BackgroundLaneController implements WorkerAgentControlPort
|
|
|
141
141
|
context?: string;
|
|
142
142
|
goalId?: string;
|
|
143
143
|
}): Promise<ResearchLaneRunOutcome>;
|
|
144
|
-
/** Start a durable,
|
|
144
|
+
/** Start a durable recursive agent with inherited, preset, or model-selected authority. */
|
|
145
145
|
startWorkerDelegation(request: WorkerDelegationRequest): {
|
|
146
146
|
started: false;
|
|
147
147
|
skipReason: string;
|
|
@@ -150,28 +150,30 @@ export declare class BackgroundLaneController implements WorkerAgentControlPort
|
|
|
150
150
|
record: LaneRecord;
|
|
151
151
|
};
|
|
152
152
|
/** Durable logical-worker controls. Each checks UAC before materializing worker state. */
|
|
153
|
-
|
|
153
|
+
listWorkerAgents(scope?: WorkerAgentControlScope): ReturnType<WorkerAgentControlPort["listWorkerAgents"]>;
|
|
154
|
+
readWorkerAgentTranscript(agentId: string, options?: WorkerAgentTranscriptOptions): ReturnType<WorkerAgentControlPort["readWorkerAgentTranscript"]>;
|
|
155
|
+
sendWorkerAgentMessage(agentId: string, message: string, options?: WorkerAgentMessageOptions): {
|
|
154
156
|
messageId: string;
|
|
155
157
|
queued: true;
|
|
156
158
|
};
|
|
157
|
-
followUpWorkerAgent(agentId: string, message: string): {
|
|
159
|
+
followUpWorkerAgent(agentId: string, message: string, options?: WorkerAgentMessageOptions): {
|
|
158
160
|
started: boolean;
|
|
159
161
|
steering: boolean;
|
|
160
162
|
messageId: string;
|
|
161
163
|
record?: LaneRecord;
|
|
162
164
|
skipReason?: string;
|
|
163
165
|
};
|
|
164
|
-
interruptWorkerAgent(agentId: string): {
|
|
166
|
+
interruptWorkerAgent(agentId: string, scope?: WorkerAgentControlScope): {
|
|
165
167
|
interrupted: boolean;
|
|
166
168
|
reason?: string;
|
|
167
169
|
};
|
|
168
|
-
resumeWorkerAgent(agentId: string): {
|
|
170
|
+
resumeWorkerAgent(agentId: string, scope?: WorkerAgentControlScope): {
|
|
169
171
|
started: boolean;
|
|
170
172
|
record?: LaneRecord;
|
|
171
173
|
skipReason?: string;
|
|
172
174
|
};
|
|
173
|
-
cancelWorkerAgent(agentId: string, reasonCode?: string): LaneRecord | undefined;
|
|
174
|
-
waitForWorkerAgent(agentId: string, timeoutMs?: number): Promise<{
|
|
175
|
+
cancelWorkerAgent(agentId: string, reasonCode?: string, scope?: WorkerAgentControlScope): LaneRecord | undefined;
|
|
176
|
+
waitForWorkerAgent(agentId: string, timeoutMs?: number, scope?: WorkerAgentControlScope): Promise<{
|
|
175
177
|
status: "active" | "suspended" | "idle" | "unknown";
|
|
176
178
|
}>;
|
|
177
179
|
/** Run one worker immediately; used by focused integrations and tests. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"background-lane-controller.d.ts","sourceRoot":"","sources":["../../src/core/background-lane-controller.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EACX,2BAA2B,EAC3B,0BAA0B,EAC1B,aAAa,EACb,sBAAsB,EACtB,0BAA0B,EAC1B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,KAAK,UAAU,EAAe,MAAM,4BAA4B,CAAC;AAG1E,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"background-lane-controller.d.ts","sourceRoot":"","sources":["../../src/core/background-lane-controller.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EACX,2BAA2B,EAC3B,0BAA0B,EAC1B,aAAa,EACb,sBAAsB,EACtB,0BAA0B,EAC1B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,KAAK,UAAU,EAAe,MAAM,4BAA4B,CAAC;AAG1E,OAAO,KAAK,EACX,sBAAsB,EACtB,uBAAuB,EACvB,yBAAyB,EACzB,4BAA4B,EAC5B,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAEN,KAAK,8BAA8B,EACnC,MAAM,8CAA8C,CAAC;AACtD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,2CAA2C,CAAC;AAGzF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,OAAO,KAAK,EAAE,mBAAmB,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AACzG,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,KAAK,EACX,sBAAsB,EACtB,uBA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AM,CAAC;QACd,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,6FAA6F;QAC7F,UAAU,CAAC,EAAE,MAAM,CAAC;KACpB,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,IAAI,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,kBAAkB,CAAA;KAAE,GAAG;QAAE,OAAO,EAAE,KAAK,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC,CAEjH;IAED,mGAAmG;IACnG,4BAA4B,IAAI,IAAI,CAEnC;IAED,mGAAmG;IACnG,uBAAuB,IAAI,mBAAmB,EAAE,CAE/C;CACD"}
|
|
@@ -236,40 +236,50 @@ export class BackgroundLaneController {
|
|
|
236
236
|
async runResearchLaneOnce(request) {
|
|
237
237
|
return this._research.runOnce(request);
|
|
238
238
|
}
|
|
239
|
-
/** Start a durable,
|
|
239
|
+
/** Start a durable recursive agent with inherited, preset, or model-selected authority. */
|
|
240
240
|
startWorkerDelegation(request) {
|
|
241
241
|
return this._getWorkerController().start(request);
|
|
242
242
|
}
|
|
243
243
|
/** Durable logical-worker controls. Each checks UAC before materializing worker state. */
|
|
244
|
-
|
|
244
|
+
listWorkerAgents(scope) {
|
|
245
245
|
if (!this.deps.isDelegateToolActive())
|
|
246
246
|
throw new Error("Worker delegation control is unavailable in this UAC surface.");
|
|
247
|
-
return this._getWorkerController().getAgentControl().
|
|
247
|
+
return this._getWorkerController().getAgentControl().listWorkerAgents(scope);
|
|
248
248
|
}
|
|
249
|
-
|
|
249
|
+
readWorkerAgentTranscript(agentId, options) {
|
|
250
250
|
if (!this.deps.isDelegateToolActive())
|
|
251
251
|
throw new Error("Worker delegation control is unavailable in this UAC surface.");
|
|
252
|
-
return this._getWorkerController().getAgentControl().
|
|
252
|
+
return this._getWorkerController().getAgentControl().readWorkerAgentTranscript(agentId, options);
|
|
253
253
|
}
|
|
254
|
-
|
|
254
|
+
sendWorkerAgentMessage(agentId, message, options) {
|
|
255
255
|
if (!this.deps.isDelegateToolActive())
|
|
256
256
|
throw new Error("Worker delegation control is unavailable in this UAC surface.");
|
|
257
|
-
return this._getWorkerController().getAgentControl().
|
|
257
|
+
return this._getWorkerController().getAgentControl().sendWorkerAgentMessage(agentId, message, options);
|
|
258
258
|
}
|
|
259
|
-
|
|
259
|
+
followUpWorkerAgent(agentId, message, options) {
|
|
260
260
|
if (!this.deps.isDelegateToolActive())
|
|
261
261
|
throw new Error("Worker delegation control is unavailable in this UAC surface.");
|
|
262
|
-
return this._getWorkerController().getAgentControl().
|
|
262
|
+
return this._getWorkerController().getAgentControl().followUpWorkerAgent(agentId, message, options);
|
|
263
263
|
}
|
|
264
|
-
|
|
264
|
+
interruptWorkerAgent(agentId, scope) {
|
|
265
265
|
if (!this.deps.isDelegateToolActive())
|
|
266
266
|
throw new Error("Worker delegation control is unavailable in this UAC surface.");
|
|
267
|
-
return this._getWorkerController().getAgentControl().
|
|
267
|
+
return this._getWorkerController().getAgentControl().interruptWorkerAgent(agentId, scope);
|
|
268
268
|
}
|
|
269
|
-
|
|
269
|
+
resumeWorkerAgent(agentId, scope) {
|
|
270
270
|
if (!this.deps.isDelegateToolActive())
|
|
271
271
|
throw new Error("Worker delegation control is unavailable in this UAC surface.");
|
|
272
|
-
return this._getWorkerController().getAgentControl().
|
|
272
|
+
return this._getWorkerController().getAgentControl().resumeWorkerAgent(agentId, scope);
|
|
273
|
+
}
|
|
274
|
+
cancelWorkerAgent(agentId, reasonCode, scope) {
|
|
275
|
+
if (!this.deps.isDelegateToolActive())
|
|
276
|
+
throw new Error("Worker delegation control is unavailable in this UAC surface.");
|
|
277
|
+
return this._getWorkerController().getAgentControl().cancelWorkerAgent(agentId, reasonCode, scope);
|
|
278
|
+
}
|
|
279
|
+
waitForWorkerAgent(agentId, timeoutMs, scope) {
|
|
280
|
+
if (!this.deps.isDelegateToolActive())
|
|
281
|
+
throw new Error("Worker delegation control is unavailable in this UAC surface.");
|
|
282
|
+
return this._getWorkerController().getAgentControl().waitForWorkerAgent(agentId, timeoutMs, scope);
|
|
273
283
|
}
|
|
274
284
|
/** Run one worker immediately; used by focused integrations and tests. */
|
|
275
285
|
async runWorkerDelegationOnce(request, onStarted, existingRecord) {
|