@caupulican/pi-adaptative 0.94.0 → 0.95.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 +55 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/README.md +32 -13
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.d.ts +7 -4
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.d.ts.map +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.js +173 -293
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.js.map +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.ts +247 -392
- package/dist/bundled-resources/extensions/tmux-agent-manager/launch-profile.d.ts +52 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/launch-profile.d.ts.map +1 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/launch-profile.js +118 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/launch-profile.js.map +1 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/launch-profile.ts +169 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/templates/builder-validator.json +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/templates/provider-prompt-smoke.json +1 -1
- package/dist/bundled-resources/skills/pi-harness-learning/SKILL.md +13 -7
- package/dist/bundled-resources/skills/worker-profile-writer/SKILL.md +11 -11
- package/dist/core/agent-paths.d.ts +2 -0
- package/dist/core/agent-paths.d.ts.map +1 -1
- package/dist/core/agent-paths.js +7 -0
- package/dist/core/agent-paths.js.map +1 -1
- package/dist/core/agent-session.d.ts +11 -41
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +98 -161
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/autonomy/envelope-enforcement.d.ts +6 -1
- package/dist/core/autonomy/envelope-enforcement.d.ts.map +1 -1
- package/dist/core/autonomy/envelope-enforcement.js +26 -25
- package/dist/core/autonomy/envelope-enforcement.js.map +1 -1
- package/dist/core/autonomy/lane-private-paths.d.ts.map +1 -1
- package/dist/core/autonomy/lane-private-paths.js +2 -1
- package/dist/core/autonomy/lane-private-paths.js.map +1 -1
- package/dist/core/autonomy/lane-tool-surface.d.ts +8 -8
- package/dist/core/autonomy/lane-tool-surface.d.ts.map +1 -1
- package/dist/core/autonomy/lane-tool-surface.js +45 -30
- package/dist/core/autonomy/lane-tool-surface.js.map +1 -1
- package/dist/core/autonomy/worker-session-private-scope.d.ts +12 -0
- package/dist/core/autonomy/worker-session-private-scope.d.ts.map +1 -0
- package/dist/core/autonomy/worker-session-private-scope.js +42 -0
- package/dist/core/autonomy/worker-session-private-scope.js.map +1 -0
- package/dist/core/autonomy/worker-tool-adapter-registry.d.ts +65 -0
- package/dist/core/autonomy/worker-tool-adapter-registry.d.ts.map +1 -0
- package/dist/core/autonomy/worker-tool-adapter-registry.js +145 -0
- package/dist/core/autonomy/worker-tool-adapter-registry.js.map +1 -0
- package/dist/core/background-lane-controller.d.ts +9 -1
- package/dist/core/background-lane-controller.d.ts.map +1 -1
- package/dist/core/background-lane-controller.js +76 -6
- package/dist/core/background-lane-controller.js.map +1 -1
- package/dist/core/background-tool-task-controller.d.ts +23 -2
- package/dist/core/background-tool-task-controller.d.ts.map +1 -1
- package/dist/core/background-tool-task-controller.js +132 -17
- package/dist/core/background-tool-task-controller.js.map +1 -1
- package/dist/core/context/long-term-memory-trigger.d.ts +3 -1
- package/dist/core/context/long-term-memory-trigger.d.ts.map +1 -1
- package/dist/core/context/long-term-memory-trigger.js +1 -1
- package/dist/core/context/long-term-memory-trigger.js.map +1 -1
- package/dist/core/context/okf-memory-provider.d.ts +3 -0
- package/dist/core/context/okf-memory-provider.d.ts.map +1 -1
- package/dist/core/context/okf-memory-provider.js +66 -31
- package/dist/core/context/okf-memory-provider.js.map +1 -1
- package/dist/core/context/okf-memory.d.ts +18 -1
- package/dist/core/context/okf-memory.d.ts.map +1 -1
- package/dist/core/context/okf-memory.js +48 -0
- package/dist/core/context/okf-memory.js.map +1 -1
- package/dist/core/cost-guard-controller.d.ts +37 -0
- package/dist/core/cost-guard-controller.d.ts.map +1 -0
- package/dist/core/cost-guard-controller.js +71 -0
- package/dist/core/cost-guard-controller.js.map +1 -0
- package/dist/core/cost-guard.d.ts +9 -4
- package/dist/core/cost-guard.d.ts.map +1 -1
- package/dist/core/cost-guard.js +7 -3
- package/dist/core/cost-guard.js.map +1 -1
- package/dist/core/delegation/worker-agent-control.d.ts +4 -0
- package/dist/core/delegation/worker-agent-control.d.ts.map +1 -1
- package/dist/core/delegation/worker-agent-control.js.map +1 -1
- package/dist/core/delegation/worker-attempt-executor.d.ts +1 -1
- package/dist/core/delegation/worker-attempt-executor.d.ts.map +1 -1
- package/dist/core/delegation/worker-attempt-executor.js +0 -1
- package/dist/core/delegation/worker-attempt-executor.js.map +1 -1
- package/dist/core/delegation/worker-authority-resolver.d.ts +16 -3
- package/dist/core/delegation/worker-authority-resolver.d.ts.map +1 -1
- package/dist/core/delegation/worker-authority-resolver.js +114 -55
- package/dist/core/delegation/worker-authority-resolver.js.map +1 -1
- package/dist/core/delegation/worker-claim.d.ts +1 -2
- package/dist/core/delegation/worker-claim.d.ts.map +1 -1
- package/dist/core/delegation/worker-claim.js.map +1 -1
- package/dist/core/delegation/worker-delegation-controller.d.ts +19 -6
- package/dist/core/delegation/worker-delegation-controller.d.ts.map +1 -1
- package/dist/core/delegation/worker-delegation-controller.js +125 -40
- package/dist/core/delegation/worker-delegation-controller.js.map +1 -1
- package/dist/core/delegation/worker-delegation-request.d.ts +3 -3
- package/dist/core/delegation/worker-delegation-request.d.ts.map +1 -1
- package/dist/core/delegation/worker-delegation-request.js +13 -19
- package/dist/core/delegation/worker-delegation-request.js.map +1 -1
- package/dist/core/delegation/worker-execution-policy.d.ts +3 -2
- package/dist/core/delegation/worker-execution-policy.d.ts.map +1 -1
- package/dist/core/delegation/worker-execution-policy.js +54 -39
- package/dist/core/delegation/worker-execution-policy.js.map +1 -1
- package/dist/core/delegation/worker-fleet-limits.d.ts +3 -3
- package/dist/core/delegation/worker-fleet-limits.d.ts.map +1 -1
- package/dist/core/delegation/worker-fleet-limits.js +7 -7
- package/dist/core/delegation/worker-fleet-limits.js.map +1 -1
- package/dist/core/delegation/worker-machine-scope.d.ts +12 -0
- package/dist/core/delegation/worker-machine-scope.d.ts.map +1 -0
- package/dist/core/delegation/worker-machine-scope.js +38 -0
- package/dist/core/delegation/worker-machine-scope.js.map +1 -0
- package/dist/core/delegation/worker-notification-coordinator.d.ts +10 -0
- package/dist/core/delegation/worker-notification-coordinator.d.ts.map +1 -1
- package/dist/core/delegation/worker-notification-coordinator.js +69 -3
- package/dist/core/delegation/worker-notification-coordinator.js.map +1 -1
- package/dist/core/delegation/worker-recovery-coordinator.d.ts.map +1 -1
- package/dist/core/delegation/worker-recovery-coordinator.js +6 -1
- package/dist/core/delegation/worker-recovery-coordinator.js.map +1 -1
- package/dist/core/delegation/worker-runner.d.ts +5 -7
- package/dist/core/delegation/worker-runner.d.ts.map +1 -1
- package/dist/core/delegation/worker-runner.js +1 -4
- package/dist/core/delegation/worker-runner.js.map +1 -1
- package/dist/core/delegation/worker-write-reservation-coordinator.d.ts +3 -2
- package/dist/core/delegation/worker-write-reservation-coordinator.d.ts.map +1 -1
- package/dist/core/delegation/worker-write-reservation-coordinator.js +50 -25
- package/dist/core/delegation/worker-write-reservation-coordinator.js.map +1 -1
- package/dist/core/durable-custom-message-turn-controller.d.ts +6 -0
- package/dist/core/durable-custom-message-turn-controller.d.ts.map +1 -1
- package/dist/core/durable-custom-message-turn-controller.js +38 -15
- package/dist/core/durable-custom-message-turn-controller.js.map +1 -1
- package/dist/core/extension-binding-controller.d.ts +5 -1
- package/dist/core/extension-binding-controller.d.ts.map +1 -1
- package/dist/core/extension-binding-controller.js +15 -0
- package/dist/core/extension-binding-controller.js.map +1 -1
- package/dist/core/extensions/factory-runtime.d.ts.map +1 -1
- package/dist/core/extensions/factory-runtime.js +5 -0
- package/dist/core/extensions/factory-runtime.js.map +1 -1
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +1 -0
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +8 -4
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/foreground-terminal-handoff-controller.d.ts +31 -0
- package/dist/core/foreground-terminal-handoff-controller.d.ts.map +1 -1
- package/dist/core/foreground-terminal-handoff-controller.js +239 -55
- package/dist/core/foreground-terminal-handoff-controller.js.map +1 -1
- package/dist/core/goals/goal-session-controller.d.ts +2 -0
- package/dist/core/goals/goal-session-controller.d.ts.map +1 -1
- package/dist/core/goals/goal-session-controller.js +8 -0
- package/dist/core/goals/goal-session-controller.js.map +1 -1
- package/dist/core/goals/goal-tool-core.d.ts +5 -4
- package/dist/core/goals/goal-tool-core.d.ts.map +1 -1
- package/dist/core/goals/goal-tool-core.js +23 -19
- package/dist/core/goals/goal-tool-core.js.map +1 -1
- package/dist/core/learning/auto-learn-settings.d.ts +84 -0
- package/dist/core/learning/auto-learn-settings.d.ts.map +1 -0
- package/dist/core/learning/auto-learn-settings.js +66 -0
- package/dist/core/learning/auto-learn-settings.js.map +1 -0
- package/dist/core/learning/learning-audit.d.ts +5 -1
- package/dist/core/learning/learning-audit.d.ts.map +1 -1
- package/dist/core/learning/learning-audit.js +32 -1
- package/dist/core/learning/learning-audit.js.map +1 -1
- package/dist/core/learning/reflection-engine.d.ts +24 -0
- package/dist/core/learning/reflection-engine.d.ts.map +1 -1
- package/dist/core/learning/reflection-engine.js +104 -8
- package/dist/core/learning/reflection-engine.js.map +1 -1
- package/dist/core/local-prefix-warm-controller.d.ts +24 -0
- package/dist/core/local-prefix-warm-controller.d.ts.map +1 -0
- package/dist/core/local-prefix-warm-controller.js +79 -0
- package/dist/core/local-prefix-warm-controller.js.map +1 -0
- package/dist/core/memory/okf-project-memory-store.d.ts +28 -0
- package/dist/core/memory/okf-project-memory-store.d.ts.map +1 -0
- package/dist/core/memory/okf-project-memory-store.js +111 -0
- package/dist/core/memory/okf-project-memory-store.js.map +1 -0
- package/dist/core/memory/providers/file-store.d.ts +44 -1
- package/dist/core/memory/providers/file-store.d.ts.map +1 -1
- package/dist/core/memory/providers/file-store.js +341 -24
- package/dist/core/memory/providers/file-store.js.map +1 -1
- package/dist/core/memory/worker-memory-tools.d.ts +5 -0
- package/dist/core/memory/worker-memory-tools.d.ts.map +1 -0
- package/dist/core/memory/worker-memory-tools.js +5 -0
- package/dist/core/memory/worker-memory-tools.js.map +1 -0
- package/dist/core/memory-controller.d.ts +10 -1
- package/dist/core/memory-controller.d.ts.map +1 -1
- package/dist/core/memory-controller.js +72 -8
- package/dist/core/memory-controller.js.map +1 -1
- package/dist/core/model-capability.d.ts +7 -0
- package/dist/core/model-capability.d.ts.map +1 -1
- package/dist/core/model-capability.js +12 -0
- package/dist/core/model-capability.js.map +1 -1
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +2 -10
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-router-controller.d.ts +3 -2
- package/dist/core/model-router-controller.d.ts.map +1 -1
- package/dist/core/model-router-controller.js +3 -2
- package/dist/core/model-router-controller.js.map +1 -1
- package/dist/core/orchestration/contracts.d.ts +16 -12
- package/dist/core/orchestration/contracts.d.ts.map +1 -1
- package/dist/core/orchestration/contracts.js +2 -2
- package/dist/core/orchestration/contracts.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 +6 -1
- package/dist/core/orchestration/lane-tool-manifests.js.map +1 -1
- package/dist/core/orchestration/profile-registry.d.ts.map +1 -1
- package/dist/core/orchestration/profile-registry.js +14 -0
- package/dist/core/orchestration/profile-registry.js.map +1 -1
- package/dist/core/orchestration/task-profile-writer.d.ts +7 -4
- package/dist/core/orchestration/task-profile-writer.d.ts.map +1 -1
- package/dist/core/orchestration/task-profile-writer.js +71 -59
- package/dist/core/orchestration/task-profile-writer.js.map +1 -1
- package/dist/core/orchestration/thinking-level-schema.d.ts +7 -0
- package/dist/core/orchestration/thinking-level-schema.d.ts.map +1 -0
- package/dist/core/orchestration/thinking-level-schema.js +19 -0
- package/dist/core/orchestration/thinking-level-schema.js.map +1 -0
- package/dist/core/orchestration/worker-execution-contract.d.ts.map +1 -1
- package/dist/core/orchestration/worker-execution-contract.js +12 -5
- package/dist/core/orchestration/worker-execution-contract.js.map +1 -1
- package/dist/core/provider-prompt-contracts.d.ts +1 -4
- package/dist/core/provider-prompt-contracts.d.ts.map +1 -1
- package/dist/core/provider-prompt-contracts.js +13 -29
- package/dist/core/provider-prompt-contracts.js.map +1 -1
- package/dist/core/provider-request-context-controller.d.ts +2 -0
- package/dist/core/provider-request-context-controller.d.ts.map +1 -1
- package/dist/core/provider-request-context-controller.js +10 -3
- package/dist/core/provider-request-context-controller.js.map +1 -1
- package/dist/core/reflection-controller.d.ts +63 -27
- package/dist/core/reflection-controller.d.ts.map +1 -1
- package/dist/core/reflection-controller.js +300 -132
- package/dist/core/reflection-controller.js.map +1 -1
- package/dist/core/runtime-builder.d.ts +1 -0
- package/dist/core/runtime-builder.d.ts.map +1 -1
- package/dist/core/runtime-builder.js +25 -14
- package/dist/core/runtime-builder.js.map +1 -1
- package/dist/core/secrets/credential-exposure-guard.d.ts.map +1 -1
- package/dist/core/secrets/credential-exposure-guard.js +55 -10
- package/dist/core/secrets/credential-exposure-guard.js.map +1 -1
- package/dist/core/session-role.d.ts +6 -8
- package/dist/core/session-role.d.ts.map +1 -1
- package/dist/core/session-role.js +8 -18
- package/dist/core/session-role.js.map +1 -1
- package/dist/core/settings-manager.d.ts +13 -16
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +53 -50
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/skill-vault.d.ts +15 -0
- package/dist/core/skill-vault.d.ts.map +1 -1
- package/dist/core/skill-vault.js +79 -45
- package/dist/core/skill-vault.js.map +1 -1
- package/dist/core/skills.d.ts +3 -0
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +6 -6
- package/dist/core/skills.js.map +1 -1
- package/dist/core/system-prompt-builder.d.ts +2 -0
- package/dist/core/system-prompt-builder.d.ts.map +1 -1
- package/dist/core/system-prompt-builder.js +52 -12
- package/dist/core/system-prompt-builder.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.d.ts +3 -0
- package/dist/core/tool-capability-policy.d.ts.map +1 -1
- package/dist/core/tool-capability-policy.js +13 -2
- package/dist/core/tool-capability-policy.js.map +1 -1
- package/dist/core/toolkit/script-runner.d.ts +2 -1
- package/dist/core/toolkit/script-runner.d.ts.map +1 -1
- package/dist/core/toolkit/script-runner.js +10 -2
- package/dist/core/toolkit/script-runner.js.map +1 -1
- package/dist/core/tools/delegate-status.d.ts +3 -1
- package/dist/core/tools/delegate-status.d.ts.map +1 -1
- package/dist/core/tools/delegate-status.js +5 -1
- package/dist/core/tools/delegate-status.js.map +1 -1
- package/dist/core/tools/delegate.d.ts +4 -13
- package/dist/core/tools/delegate.d.ts.map +1 -1
- package/dist/core/tools/delegate.js +173 -73
- package/dist/core/tools/delegate.js.map +1 -1
- package/dist/core/tools/goal.d.ts +3 -4
- package/dist/core/tools/goal.d.ts.map +1 -1
- package/dist/core/tools/goal.js +24 -7
- package/dist/core/tools/goal.js.map +1 -1
- package/dist/core/tools/profile-writer.d.ts +2 -8
- package/dist/core/tools/profile-writer.d.ts.map +1 -1
- package/dist/core/tools/profile-writer.js +6 -18
- package/dist/core/tools/profile-writer.js.map +1 -1
- package/dist/core/tools/run-toolkit-script.d.ts +1 -1
- package/dist/core/tools/run-toolkit-script.d.ts.map +1 -1
- package/dist/core/tools/run-toolkit-script.js +2 -2
- package/dist/core/tools/run-toolkit-script.js.map +1 -1
- package/dist/core/tools/skill-audit.d.ts +28 -1
- package/dist/core/tools/skill-audit.d.ts.map +1 -1
- package/dist/core/tools/skill-audit.js +56 -12
- package/dist/core/tools/skill-audit.js.map +1 -1
- package/dist/core/tools/skill.d.ts +12 -1
- package/dist/core/tools/skill.d.ts.map +1 -1
- package/dist/core/tools/skill.js +52 -0
- package/dist/core/tools/skill.js.map +1 -1
- package/dist/core/tools/skillify.d.ts.map +1 -1
- package/dist/core/tools/skillify.js +16 -7
- package/dist/core/tools/skillify.js.map +1 -1
- package/dist/core/tools/task-steps.js +1 -1
- package/dist/core/tools/task-steps.js.map +1 -1
- package/dist/core/tools/tmux-dispatch.d.ts +4 -16
- package/dist/core/tools/tmux-dispatch.d.ts.map +1 -1
- package/dist/core/tools/tmux-dispatch.js +5 -20
- package/dist/core/tools/tmux-dispatch.js.map +1 -1
- package/dist/core/tools/tool-task.d.ts +1 -0
- package/dist/core/tools/tool-task.d.ts.map +1 -1
- package/dist/core/tools/tool-task.js +13 -8
- package/dist/core/tools/tool-task.js.map +1 -1
- package/dist/core/util/atomic-file.d.ts +2 -0
- package/dist/core/util/atomic-file.d.ts.map +1 -1
- package/dist/core/util/atomic-file.js +4 -0
- package/dist/core/util/atomic-file.js.map +1 -1
- package/dist/core/worktree-sync/codes.d.ts +1 -2
- package/dist/core/worktree-sync/codes.d.ts.map +1 -1
- package/dist/core/worktree-sync/codes.js +1 -2
- package/dist/core/worktree-sync/codes.js.map +1 -1
- package/dist/core/worktree-sync/lane-gate.d.ts +4 -8
- package/dist/core/worktree-sync/lane-gate.d.ts.map +1 -1
- package/dist/core/worktree-sync/lane-gate.js +5 -51
- package/dist/core/worktree-sync/lane-gate.js.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/modes/interactive/auto-learn-controller.d.ts +6 -7
- package/dist/modes/interactive/auto-learn-controller.d.ts.map +1 -1
- package/dist/modes/interactive/auto-learn-controller.js +32 -207
- package/dist/modes/interactive/auto-learn-controller.js.map +1 -1
- package/dist/modes/interactive/autonomy-commands.js +2 -2
- package/dist/modes/interactive/autonomy-commands.js.map +1 -1
- package/dist/modes/interactive/components/activity-lane.d.ts.map +1 -1
- package/dist/modes/interactive/components/activity-lane.js +12 -23
- package/dist/modes/interactive/components/activity-lane.js.map +1 -1
- package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-message.js +142 -1
- package/dist/modes/interactive/components/custom-message.js.map +1 -1
- package/dist/modes/interactive/components/fitness-role-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/fitness-role-selector.js +2 -2
- package/dist/modes/interactive/components/fitness-role-selector.js.map +1 -1
- package/dist/modes/interactive/components/footer.js +1 -1
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +4 -0
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +150 -73
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/report-commands.d.ts.map +1 -1
- package/dist/modes/interactive/report-commands.js +8 -4
- package/dist/modes/interactive/report-commands.js.map +1 -1
- package/dist/modes/interactive/settings-selector-flow.d.ts.map +1 -1
- package/dist/modes/interactive/settings-selector-flow.js +10 -0
- package/dist/modes/interactive/settings-selector-flow.js.map +1 -1
- package/docs/extensions.md +8 -0
- package/docs/harness-architecture.md +28 -32
- package/docs/index.md +1 -1
- package/docs/process-matrix.md +8 -6
- package/docs/resources.md +1 -1
- package/docs/settings.md +61 -51
- package/docs/tmux-agent-manager.md +47 -40
- package/docs/usage.md +1 -1
- package/docs/worker-profiles.md +8 -6
- package/docs/worktree-sync.md +26 -20
- 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/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.d.ts +0 -133
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.d.ts.map +0 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.js +0 -199
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.js.map +0 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.ts +0 -312
|
@@ -25,8 +25,8 @@ export interface WorkerDelegationAuthorityRequest {
|
|
|
25
25
|
thinkingLevel?: OrchestrationThinkingLevel;
|
|
26
26
|
capabilities?: readonly HarnessCapability[];
|
|
27
27
|
toolNames?: readonly string[];
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
/** One model-selectable workspace focus. The host derives cwd plus symmetric read/write scope. */
|
|
29
|
+
path?: string;
|
|
30
30
|
budget?: RiskBudget;
|
|
31
31
|
}
|
|
32
32
|
export declare class WorkerDelegationRequestError extends Error {
|
|
@@ -41,7 +41,7 @@ export interface WorkerDelegationRequest {
|
|
|
41
41
|
authority?: WorkerDelegationAuthorityRequest;
|
|
42
42
|
/** Tool-facing immutable birth-context selection for a newly admitted logical worker. */
|
|
43
43
|
forkTurns?: string;
|
|
44
|
-
/** Runtime-owned creator identity for
|
|
44
|
+
/** Runtime-owned creator identity retained for recovery of legacy durable records. */
|
|
45
45
|
parentAgentId?: string;
|
|
46
46
|
/** Runtime-owned correlation for an automatically dispatched verifier; never model-settable. */
|
|
47
47
|
verificationOfTaskId?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker-delegation-request.d.ts","sourceRoot":"","sources":["../../../src/core/delegation/worker-delegation-request.ts"],"names":[],"mappings":"AACA,OAAO,EACN,KAAK,iBAAiB,
|
|
1
|
+
{"version":3,"file":"worker-delegation-request.d.ts","sourceRoot":"","sources":["../../../src/core/delegation/worker-delegation-request.ts"],"names":[],"mappings":"AACA,OAAO,EACN,KAAK,iBAAiB,EAMtB,KAAK,0BAA0B,EAC/B,KAAK,UAAU,EAEf,KAAK,UAAU,EACf,MAAM,+BAA+B,CAAC;AAIvC,oGAAoG;AACpG,MAAM,WAAW,2BAA2B;IAC3C,cAAc,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,gBAAgB,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,sBAAsB,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1C;;;;OAIG;IACH,kBAAkB,EAAE,SAAS,MAAM,EAAE,CAAC;CACtC;AAED,MAAM,WAAW,4BAA4B;IAC5C,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,MAAM,WAAW,gCAAgC;IAChD,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,KAAK,CAAC,EAAE,4BAA4B,CAAC;IACrC,aAAa,CAAC,EAAE,0BAA0B,CAAC;IAC3C,YAAY,CAAC,EAAE,SAAS,iBAAiB,EAAE,CAAC;IAC5C,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC9B,kGAAkG;IAClG,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,UAAU,CAAC;CACpB;AAED,qBAAa,4BAA6B,SAAQ,KAAK;IACtD,YAAY,OAAO,EAAE,MAAM,EAG1B;CACD;AAYD,qFAAqF;AACrF,wBAAgB,qCAAqC,CAAC,KAAK,EAAE,OAAO,GAAG,gCAAgC,CAmEtG;AAED,wFAAwF;AACxF,MAAM,WAAW,uBAAuB;IACvC,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,gCAAgC,CAAC;IAC7C,yFAAyF;IACzF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sFAAsF;IACtF,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gGAAgG;IAChG,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,iGAAiG;IACjG,WAAW,CAAC,EAAE,2BAA2B,CAAC;CAC1C"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { parseBoundedStringArray } from "../orchestration/bounded-string-array.js";
|
|
2
|
-
import { isHarnessCapability, MAX_ORCHESTRATION_MODEL_ID_LENGTH, MAX_ORCHESTRATION_MODEL_PROVIDER_LENGTH, MAX_WORKER_AUTHORITY_PATH_LENGTH,
|
|
2
|
+
import { isHarnessCapability, MAX_ORCHESTRATION_MODEL_ID_LENGTH, MAX_ORCHESTRATION_MODEL_PROVIDER_LENGTH, MAX_WORKER_AUTHORITY_PATH_LENGTH, ORCHESTRATION_THINKING_LEVELS, WORKER_ROLES, } from "../orchestration/contracts.js";
|
|
3
3
|
import { parseRiskBudget } from "../orchestration/risk-budget.js";
|
|
4
4
|
import { hasOnlyKeys, isPlainRecord } from "../util/value-guards.js";
|
|
5
5
|
export class WorkerDelegationRequestError extends Error {
|
|
@@ -21,16 +21,7 @@ function uniqueStringArray(value, label, options = {}) {
|
|
|
21
21
|
export function parseWorkerDelegationAuthorityRequest(value) {
|
|
22
22
|
if (!isPlainRecord(value))
|
|
23
23
|
throw new WorkerDelegationRequestError("Delegation authority must be an object.");
|
|
24
|
-
if (!hasOnlyKeys(value, [
|
|
25
|
-
"role",
|
|
26
|
-
"model",
|
|
27
|
-
"thinkingLevel",
|
|
28
|
-
"capabilities",
|
|
29
|
-
"toolNames",
|
|
30
|
-
"readPaths",
|
|
31
|
-
"writePaths",
|
|
32
|
-
"budget",
|
|
33
|
-
])) {
|
|
24
|
+
if (!hasOnlyKeys(value, ["role", "model", "thinkingLevel", "capabilities", "toolNames", "path", "budget"])) {
|
|
34
25
|
throw new WorkerDelegationRequestError("Delegation authority contains an unsupported field.");
|
|
35
26
|
}
|
|
36
27
|
if (value.role !== undefined && !WORKER_ROLES.includes(value.role)) {
|
|
@@ -63,13 +54,17 @@ export function parseWorkerDelegationAuthorityRequest(value) {
|
|
|
63
54
|
capabilities = parsed;
|
|
64
55
|
}
|
|
65
56
|
const toolNames = value.toolNames === undefined ? undefined : uniqueStringArray(value.toolNames, "Delegation authority toolNames");
|
|
66
|
-
const
|
|
67
|
-
const readPaths = value.readPaths === undefined
|
|
57
|
+
const workspacePath = value.path === undefined
|
|
68
58
|
? undefined
|
|
69
|
-
:
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
59
|
+
: typeof value.path === "string" &&
|
|
60
|
+
value.path.trim() &&
|
|
61
|
+
!value.path.includes("\0") &&
|
|
62
|
+
value.path.length <= MAX_WORKER_AUTHORITY_PATH_LENGTH
|
|
63
|
+
? value.path.trim()
|
|
64
|
+
: undefined;
|
|
65
|
+
if (value.path !== undefined && workspacePath === undefined) {
|
|
66
|
+
throw new WorkerDelegationRequestError("Delegation authority path must be a bounded, non-empty string.");
|
|
67
|
+
}
|
|
73
68
|
let budget;
|
|
74
69
|
try {
|
|
75
70
|
budget = value.budget === undefined ? undefined : parseRiskBudget(value.budget, "Delegation authority budget");
|
|
@@ -83,8 +78,7 @@ export function parseWorkerDelegationAuthorityRequest(value) {
|
|
|
83
78
|
...(value.thinkingLevel ? { thinkingLevel: value.thinkingLevel } : {}),
|
|
84
79
|
...(capabilities ? { capabilities } : {}),
|
|
85
80
|
...(toolNames ? { toolNames } : {}),
|
|
86
|
-
...(
|
|
87
|
-
...(writePaths ? { writePaths } : {}),
|
|
81
|
+
...(workspacePath ? { path: workspacePath } : {}),
|
|
88
82
|
...(budget ? { budget } : {}),
|
|
89
83
|
};
|
|
90
84
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker-delegation-request.js","sourceRoot":"","sources":["../../../src/core/delegation/worker-delegation-request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MA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AAI,EAAE,KAAK,CAAC,IAAkB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACzD,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC3B,GAAG,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,KAAK,CAAC,aAA2C,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACpG,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACzC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACnC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACnC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACrC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC7B,CAAC;AACH,CAAC","sourcesContent":["import { parseBoundedStringArray } from \"../orchestration/bounded-string-array.ts\";\nimport {\n\ttype HarnessCapability,\n\tisHarnessCapability,\n\tMAX_ORCHESTRATION_MODEL_ID_LENGTH,\n\tMAX_ORCHESTRATION_MODEL_PROVIDER_LENGTH,\n\tMAX_WORKER_AUTHORITY_PATH_LENGTH,\n\tMAX_WORKER_AUTHORITY_PATHS,\n\tORCHESTRATION_THINKING_LEVELS,\n\ttype OrchestrationThinkingLevel,\n\ttype RiskBudget,\n\tWORKER_ROLES,\n\ttype WorkerRole,\n} from \"../orchestration/contracts.ts\";\nimport { parseRiskBudget } from \"../orchestration/risk-budget.ts\";\nimport { hasOnlyKeys, isPlainRecord } from \"../util/value-guards.ts\";\n\n/** Runtime-owned task correlation retained with a durable worker dispatch. Never model-settable. */\nexport interface WorkerDelegationTaskContext {\n\trequirementIds: readonly string[];\n\tdependsOnTaskIds: readonly string[];\n\tacceptanceCriterionIds: readonly string[];\n\t/**\n\t * Optional runtime narrowing of the owner-admitted profile resources. An empty list does not\n\t * suppress owner resources: admission expands it to the immutable profile pointer set and\n\t * persists that exact selection with the attempt.\n\t */\n\tresourcePointerIds: readonly string[];\n}\n\nexport interface WorkerDelegationModelRequest {\n\tprovider: string;\n\tmodelId: string;\n}\n\n/**\n * Trusted caller execution preferences compiled into an immutable, inherited runtime grant.\n * The model-facing `delegate` adapter intentionally exposes a budget-free subset.\n */\nexport interface WorkerDelegationAuthorityRequest {\n\trole?: WorkerRole;\n\tmodel?: WorkerDelegationModelRequest;\n\tthinkingLevel?: OrchestrationThinkingLevel;\n\tcapabilities?: readonly HarnessCapability[];\n\ttoolNames?: readonly string[];\n\treadPaths?: readonly string[];\n\twritePaths?: readonly string[];\n\tbudget?: RiskBudget;\n}\n\nexport class WorkerDelegationRequestError extends Error {\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"WorkerDelegationRequestError\";\n\t}\n}\n\nfunction uniqueStringArray(value: unknown, label: string, options: { maxEntries?: number; maxLength?: number } = {}) {\n\treturn parseBoundedStringArray(value, {\n\t\t...options,\n\t\ttrim: true,\n\t\tinvalidMessage: `${label} must contain bounded, non-empty strings.`,\n\t\tduplicateMessage: `${label} must contain unique strings.`,\n\t\tcreateError: (message) => new WorkerDelegationRequestError(message),\n\t});\n}\n\n/** Parse a caller authority request before it reaches admission or durable state. */\nexport function parseWorkerDelegationAuthorityRequest(value: unknown): WorkerDelegationAuthorityRequest {\n\tif (!isPlainRecord(value)) throw new WorkerDelegationRequestError(\"Delegation authority must be an object.\");\n\tif (\n\t\t!hasOnlyKeys(value, [\n\t\t\t\"role\",\n\t\t\t\"model\",\n\t\t\t\"thinkingLevel\",\n\t\t\t\"capabilities\",\n\t\t\t\"toolNames\",\n\t\t\t\"readPaths\",\n\t\t\t\"writePaths\",\n\t\t\t\"budget\",\n\t\t])\n\t) {\n\t\tthrow new WorkerDelegationRequestError(\"Delegation authority contains an unsupported field.\");\n\t}\n\tif (value.role !== undefined && !WORKER_ROLES.includes(value.role as WorkerRole)) {\n\t\tthrow new WorkerDelegationRequestError(\"Delegation authority role is invalid.\");\n\t}\n\tif (\n\t\tvalue.thinkingLevel !== undefined &&\n\t\t!ORCHESTRATION_THINKING_LEVELS.includes(value.thinkingLevel as OrchestrationThinkingLevel)\n\t) {\n\t\tthrow new WorkerDelegationRequestError(\"Delegation authority thinkingLevel is invalid.\");\n\t}\n\tlet model: WorkerDelegationModelRequest | undefined;\n\tif (value.model !== undefined) {\n\t\tif (\n\t\t\t!isPlainRecord(value.model) ||\n\t\t\t!hasOnlyKeys(value.model, [\"provider\", \"modelId\"]) ||\n\t\t\ttypeof value.model.provider !== \"string\" ||\n\t\t\t!value.model.provider.trim() ||\n\t\t\tvalue.model.provider.length > MAX_ORCHESTRATION_MODEL_PROVIDER_LENGTH ||\n\t\t\ttypeof value.model.modelId !== \"string\" ||\n\t\t\t!value.model.modelId.trim() ||\n\t\t\tvalue.model.modelId.length > MAX_ORCHESTRATION_MODEL_ID_LENGTH\n\t\t) {\n\t\t\tthrow new WorkerDelegationRequestError(\"Delegation authority model is invalid.\");\n\t\t}\n\t\tmodel = { provider: value.model.provider.trim(), modelId: value.model.modelId.trim() };\n\t}\n\tlet capabilities: HarnessCapability[] | undefined;\n\tif (value.capabilities !== undefined) {\n\t\tconst parsed = uniqueStringArray(value.capabilities, \"Delegation authority capabilities\");\n\t\tif (!parsed.every(isHarnessCapability)) {\n\t\t\tthrow new WorkerDelegationRequestError(\"Delegation authority contains an unknown capability.\");\n\t\t}\n\t\tcapabilities = parsed;\n\t}\n\tconst toolNames =\n\t\tvalue.toolNames === undefined ? undefined : uniqueStringArray(value.toolNames, \"Delegation authority toolNames\");\n\tconst pathOptions = { maxEntries: MAX_WORKER_AUTHORITY_PATHS, maxLength: MAX_WORKER_AUTHORITY_PATH_LENGTH };\n\tconst readPaths =\n\t\tvalue.readPaths === undefined\n\t\t\t? undefined\n\t\t\t: uniqueStringArray(value.readPaths, \"Delegation authority readPaths\", pathOptions);\n\tconst writePaths =\n\t\tvalue.writePaths === undefined\n\t\t\t? undefined\n\t\t\t: uniqueStringArray(value.writePaths, \"Delegation authority writePaths\", pathOptions);\n\tlet budget: RiskBudget | undefined;\n\ttry {\n\t\tbudget = value.budget === undefined ? undefined : parseRiskBudget(value.budget, \"Delegation authority budget\");\n\t} catch (error) {\n\t\tthrow new WorkerDelegationRequestError(error instanceof Error ? error.message : String(error));\n\t}\n\treturn {\n\t\t...(value.role ? { role: value.role as WorkerRole } : {}),\n\t\t...(model ? { model } : {}),\n\t\t...(value.thinkingLevel ? { thinkingLevel: value.thinkingLevel as OrchestrationThinkingLevel } : {}),\n\t\t...(capabilities ? { capabilities } : {}),\n\t\t...(toolNames ? { toolNames } : {}),\n\t\t...(readPaths ? { readPaths } : {}),\n\t\t...(writePaths ? { writePaths } : {}),\n\t\t...(budget ? { budget } : {}),\n\t};\n}\n\n/** A profile is an optional preset; authority is compiled and persisted by the host. */\nexport interface WorkerDelegationRequest {\n\tinstructions: string;\n\tprofileId?: string;\n\tauthority?: WorkerDelegationAuthorityRequest;\n\t/** Tool-facing immutable birth-context selection for a newly admitted logical worker. */\n\tforkTurns?: string;\n\t/** Runtime-owned creator identity for recursive delegation; never accepted from a model argument. */\n\tparentAgentId?: string;\n\t/** Runtime-owned correlation for an automatically dispatched verifier; never model-settable. */\n\tverificationOfTaskId?: string;\n\t/** Runtime-owned durable task correlation; the delegate tool schema intentionally omits this. */\n\ttaskContext?: WorkerDelegationTaskContext;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"worker-delegation-request.js","sourceRoot":"","sources":["../../../src/core/delegation/worker-delegation-request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,0CAA0C,CAAC;AACnF,O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AAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAkB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACzD,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC3B,GAAG,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,KAAK,CAAC,aAA2C,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACpG,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACzC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACnC,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACjD,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC7B,CAAC;AACH,CAAC","sourcesContent":["import { parseBoundedStringArray } from \"../orchestration/bounded-string-array.ts\";\nimport {\n\ttype HarnessCapability,\n\tisHarnessCapability,\n\tMAX_ORCHESTRATION_MODEL_ID_LENGTH,\n\tMAX_ORCHESTRATION_MODEL_PROVIDER_LENGTH,\n\tMAX_WORKER_AUTHORITY_PATH_LENGTH,\n\tORCHESTRATION_THINKING_LEVELS,\n\ttype OrchestrationThinkingLevel,\n\ttype RiskBudget,\n\tWORKER_ROLES,\n\ttype WorkerRole,\n} from \"../orchestration/contracts.ts\";\nimport { parseRiskBudget } from \"../orchestration/risk-budget.ts\";\nimport { hasOnlyKeys, isPlainRecord } from \"../util/value-guards.ts\";\n\n/** Runtime-owned task correlation retained with a durable worker dispatch. Never model-settable. */\nexport interface WorkerDelegationTaskContext {\n\trequirementIds: readonly string[];\n\tdependsOnTaskIds: readonly string[];\n\tacceptanceCriterionIds: readonly string[];\n\t/**\n\t * Optional runtime narrowing of the owner-admitted profile resources. An empty list does not\n\t * suppress owner resources: admission expands it to the immutable profile pointer set and\n\t * persists that exact selection with the attempt.\n\t */\n\tresourcePointerIds: readonly string[];\n}\n\nexport interface WorkerDelegationModelRequest {\n\tprovider: string;\n\tmodelId: string;\n}\n\n/**\n * Trusted caller execution preferences compiled into an immutable, inherited runtime grant.\n * The model-facing `delegate` adapter intentionally exposes a budget-free subset.\n */\nexport interface WorkerDelegationAuthorityRequest {\n\trole?: WorkerRole;\n\tmodel?: WorkerDelegationModelRequest;\n\tthinkingLevel?: OrchestrationThinkingLevel;\n\tcapabilities?: readonly HarnessCapability[];\n\ttoolNames?: readonly string[];\n\t/** One model-selectable workspace focus. The host derives cwd plus symmetric read/write scope. */\n\tpath?: string;\n\tbudget?: RiskBudget;\n}\n\nexport class WorkerDelegationRequestError extends Error {\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"WorkerDelegationRequestError\";\n\t}\n}\n\nfunction uniqueStringArray(value: unknown, label: string, options: { maxEntries?: number; maxLength?: number } = {}) {\n\treturn parseBoundedStringArray(value, {\n\t\t...options,\n\t\ttrim: true,\n\t\tinvalidMessage: `${label} must contain bounded, non-empty strings.`,\n\t\tduplicateMessage: `${label} must contain unique strings.`,\n\t\tcreateError: (message) => new WorkerDelegationRequestError(message),\n\t});\n}\n\n/** Parse a caller authority request before it reaches admission or durable state. */\nexport function parseWorkerDelegationAuthorityRequest(value: unknown): WorkerDelegationAuthorityRequest {\n\tif (!isPlainRecord(value)) throw new WorkerDelegationRequestError(\"Delegation authority must be an object.\");\n\tif (!hasOnlyKeys(value, [\"role\", \"model\", \"thinkingLevel\", \"capabilities\", \"toolNames\", \"path\", \"budget\"])) {\n\t\tthrow new WorkerDelegationRequestError(\"Delegation authority contains an unsupported field.\");\n\t}\n\tif (value.role !== undefined && !WORKER_ROLES.includes(value.role as WorkerRole)) {\n\t\tthrow new WorkerDelegationRequestError(\"Delegation authority role is invalid.\");\n\t}\n\tif (\n\t\tvalue.thinkingLevel !== undefined &&\n\t\t!ORCHESTRATION_THINKING_LEVELS.includes(value.thinkingLevel as OrchestrationThinkingLevel)\n\t) {\n\t\tthrow new WorkerDelegationRequestError(\"Delegation authority thinkingLevel is invalid.\");\n\t}\n\tlet model: WorkerDelegationModelRequest | undefined;\n\tif (value.model !== undefined) {\n\t\tif (\n\t\t\t!isPlainRecord(value.model) ||\n\t\t\t!hasOnlyKeys(value.model, [\"provider\", \"modelId\"]) ||\n\t\t\ttypeof value.model.provider !== \"string\" ||\n\t\t\t!value.model.provider.trim() ||\n\t\t\tvalue.model.provider.length > MAX_ORCHESTRATION_MODEL_PROVIDER_LENGTH ||\n\t\t\ttypeof value.model.modelId !== \"string\" ||\n\t\t\t!value.model.modelId.trim() ||\n\t\t\tvalue.model.modelId.length > MAX_ORCHESTRATION_MODEL_ID_LENGTH\n\t\t) {\n\t\t\tthrow new WorkerDelegationRequestError(\"Delegation authority model is invalid.\");\n\t\t}\n\t\tmodel = { provider: value.model.provider.trim(), modelId: value.model.modelId.trim() };\n\t}\n\tlet capabilities: HarnessCapability[] | undefined;\n\tif (value.capabilities !== undefined) {\n\t\tconst parsed = uniqueStringArray(value.capabilities, \"Delegation authority capabilities\");\n\t\tif (!parsed.every(isHarnessCapability)) {\n\t\t\tthrow new WorkerDelegationRequestError(\"Delegation authority contains an unknown capability.\");\n\t\t}\n\t\tcapabilities = parsed;\n\t}\n\tconst toolNames =\n\t\tvalue.toolNames === undefined ? undefined : uniqueStringArray(value.toolNames, \"Delegation authority toolNames\");\n\tconst workspacePath =\n\t\tvalue.path === undefined\n\t\t\t? undefined\n\t\t\t: typeof value.path === \"string\" &&\n\t\t\t\t\tvalue.path.trim() &&\n\t\t\t\t\t!value.path.includes(\"\\0\") &&\n\t\t\t\t\tvalue.path.length <= MAX_WORKER_AUTHORITY_PATH_LENGTH\n\t\t\t\t? value.path.trim()\n\t\t\t\t: undefined;\n\tif (value.path !== undefined && workspacePath === undefined) {\n\t\tthrow new WorkerDelegationRequestError(\"Delegation authority path must be a bounded, non-empty string.\");\n\t}\n\tlet budget: RiskBudget | undefined;\n\ttry {\n\t\tbudget = value.budget === undefined ? undefined : parseRiskBudget(value.budget, \"Delegation authority budget\");\n\t} catch (error) {\n\t\tthrow new WorkerDelegationRequestError(error instanceof Error ? error.message : String(error));\n\t}\n\treturn {\n\t\t...(value.role ? { role: value.role as WorkerRole } : {}),\n\t\t...(model ? { model } : {}),\n\t\t...(value.thinkingLevel ? { thinkingLevel: value.thinkingLevel as OrchestrationThinkingLevel } : {}),\n\t\t...(capabilities ? { capabilities } : {}),\n\t\t...(toolNames ? { toolNames } : {}),\n\t\t...(workspacePath ? { path: workspacePath } : {}),\n\t\t...(budget ? { budget } : {}),\n\t};\n}\n\n/** A profile is an optional preset; authority is compiled and persisted by the host. */\nexport interface WorkerDelegationRequest {\n\tinstructions: string;\n\tprofileId?: string;\n\tauthority?: WorkerDelegationAuthorityRequest;\n\t/** Tool-facing immutable birth-context selection for a newly admitted logical worker. */\n\tforkTurns?: string;\n\t/** Runtime-owned creator identity retained for recovery of legacy durable records. */\n\tparentAgentId?: string;\n\t/** Runtime-owned correlation for an automatically dispatched verifier; never model-settable. */\n\tverificationOfTaskId?: string;\n\t/** Runtime-owned durable task correlation; the delegate tool schema intentionally omits this. */\n\ttaskContext?: WorkerDelegationTaskContext;\n}\n"]}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { ExecutionGrant, HarnessCapability, OrchestrationProfile, ResourcePointer, RiskBudget, ToolCapabilityManifest, WorkerExecutionAuthorityContract, WorkerRole } from "../orchestration/contracts.ts";
|
|
2
2
|
import type { ResolvedWorkerDelegationSettings } from "../settings-manager.ts";
|
|
3
3
|
export interface WorkerExecutionPlan {
|
|
4
|
+
/** Actual process and relative-tool working directory fixed at admission. */
|
|
5
|
+
cwd: string;
|
|
4
6
|
toolManifests: readonly ToolCapabilityManifest[];
|
|
5
7
|
requiredCapabilities: readonly HarnessCapability[];
|
|
6
8
|
readPaths: readonly string[];
|
|
@@ -21,8 +23,7 @@ export declare function buildWorkerExecutionPlan(args: {
|
|
|
21
23
|
deniedPaths: readonly string[];
|
|
22
24
|
foregroundMaxCostUsd?: number;
|
|
23
25
|
memoryEnabled: boolean;
|
|
24
|
-
|
|
25
|
-
requestedWritePaths?: readonly string[];
|
|
26
|
+
workerToolAdapterNames?: readonly string[];
|
|
26
27
|
}): WorkerExecutionPlan;
|
|
27
28
|
export declare function compileWorkerExecutionGrant(args: {
|
|
28
29
|
target: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker-execution-policy.d.ts","sourceRoot":"","sources":["../../../src/core/delegation/worker-execution-policy.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"worker-execution-policy.d.ts","sourceRoot":"","sources":["../../../src/core/delegation/worker-execution-policy.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACX,cAAc,EACd,iBAAiB,EACjB,oBAAoB,EACpB,eAAe,EACf,UAAU,EACV,sBAAsB,EACtB,gCAAgC,EAChC,UAAU,EACV,MAAM,+BAA+B,CAAC;AAKvC,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,wBAAwB,CAAC;AAW/E,MAAM,WAAW,mBAAmB;IACnC,6EAA6E;IAC7E,GAAG,EAAE,MAAM,CAAC;IACZ,aAAa,EAAE,SAAS,sBAAsB,EAAE,CAAC;IACjD,oBAAoB,EAAE,SAAS,iBAAiB,EAAE,CAAC;IACnD,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;IAC7B,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;IAC9B,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/B,UAAU,EAAE,OAAO,CAAC;IACpB,YAAY,EAAE,OAAO,CAAC;IACtB,cAAc,EAAE,OAAO,CAAC;IACxB,MAA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EAAE,UAAU,CAAC;IACjB,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;IAChC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/B,MAAM,EAAE,UAAU,CAAC;CACnB,GAAG;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,cAAc,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAmDtF"}
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { join } from "node:path";
|
|
2
2
|
import { isPathWithinScope } from "../autonomy/path-scope.js";
|
|
3
3
|
import { mapToolNamesForPlatform, STABLE_SHELL_TOOL_NAME } from "../default-tool-surface.js";
|
|
4
|
+
import { WORKER_MEMORY_READ_TOOL_NAME, WORKER_ROOT_MEMORY_TOOL_NAMES } from "../memory/worker-memory-tools.js";
|
|
4
5
|
import { buildLaneToolManifests } from "../orchestration/lane-tool-manifests.js";
|
|
5
6
|
import { ExecutionPolicyCompiler } from "../orchestration/policy-compiler.js";
|
|
6
7
|
import { intersectRiskBudgets } from "../orchestration/risk-budget.js";
|
|
8
|
+
import { WORKER_FORBIDDEN_TOOLS } from "../session-role.js";
|
|
7
9
|
import { getToolCapabilityPolicy, requiredEnvelopeCapabilities } from "../tool-capability-policy.js";
|
|
10
|
+
import { resolveWorkerWorkspacePath, workerMachinePathRoots } from "./worker-machine-scope.js";
|
|
8
11
|
const READ_TOOL_NAMES = ["read", "grep", "find", "ls"];
|
|
9
12
|
const WRITE_TOOL_NAMES = ["write", "edit"];
|
|
10
13
|
function delegatedToolCapabilities(toolName) {
|
|
11
|
-
return
|
|
14
|
+
return requiredEnvelopeCapabilities(toolName);
|
|
12
15
|
}
|
|
13
16
|
function intersectPathScopes(admittedPaths, currentPaths) {
|
|
14
17
|
const intersections = admittedPaths.flatMap((admitted) => currentPaths.flatMap((current) => {
|
|
@@ -18,10 +21,11 @@ function intersectPathScopes(admittedPaths, currentPaths) {
|
|
|
18
21
|
return [admitted];
|
|
19
22
|
return [];
|
|
20
23
|
}));
|
|
21
|
-
return [...new Set(intersections.map((entry) =>
|
|
24
|
+
return [...new Set(intersections.map((entry) => resolveWorkerWorkspacePath(entry, entry)))];
|
|
22
25
|
}
|
|
23
26
|
export function workerExecutionAuthorityFromPlan(plan) {
|
|
24
27
|
return {
|
|
28
|
+
cwd: plan.cwd,
|
|
25
29
|
capabilities: [...plan.requiredCapabilities],
|
|
26
30
|
toolNames: plan.toolManifests.map((manifest) => manifest.toolName),
|
|
27
31
|
readPaths: [...plan.readPaths],
|
|
@@ -34,85 +38,88 @@ export function workerExecutionAuthorityFromPlan(plan) {
|
|
|
34
38
|
export function narrowWorkerExecutionPlan(admitted, current) {
|
|
35
39
|
const admittedTools = new Set(mapToolNamesForPlatform(admitted.toolNames));
|
|
36
40
|
const admittedCapabilities = new Set(admitted.capabilities);
|
|
37
|
-
const toolManifests = current.toolManifests.filter((manifest) =>
|
|
41
|
+
const toolManifests = current.toolManifests.filter((manifest) => !WORKER_ROOT_MEMORY_TOOL_NAMES.has(manifest.toolName) &&
|
|
42
|
+
admittedTools.has(manifest.toolName) &&
|
|
38
43
|
manifest.capabilities.every((capability) => admittedCapabilities.has(capability)));
|
|
39
44
|
const requiredCapabilities = [...new Set(toolManifests.flatMap((manifest) => manifest.capabilities))];
|
|
40
45
|
const grantedTools = new Set(toolManifests.map((manifest) => manifest.toolName));
|
|
41
46
|
const readEnabled = requiredCapabilities.some((capability) => capability === "filesystem.read" || capability === "worktree.read");
|
|
42
47
|
const writeEnabled = grantedTools.has("write") || grantedTools.has("edit");
|
|
43
48
|
return {
|
|
49
|
+
cwd: admitted.cwd ?? current.cwd,
|
|
44
50
|
toolManifests,
|
|
45
51
|
requiredCapabilities,
|
|
46
52
|
readPaths: readEnabled ? intersectPathScopes(admitted.readPaths, current.readPaths) : [],
|
|
47
53
|
writePaths: writeEnabled ? intersectPathScopes(admitted.writePaths, current.writePaths) : [],
|
|
48
|
-
deniedPaths: [
|
|
49
|
-
|
|
54
|
+
deniedPaths: [
|
|
55
|
+
...new Set([...admitted.deniedPaths, ...current.deniedPaths].map((entry) => resolveWorkerWorkspacePath(current.cwd, entry))),
|
|
56
|
+
],
|
|
57
|
+
readMemory: grantedTools.has(WORKER_MEMORY_READ_TOOL_NAME),
|
|
50
58
|
writeEnabled,
|
|
51
|
-
processEnabled: grantedTools.has("
|
|
59
|
+
processEnabled: grantedTools.has("python") ||
|
|
60
|
+
grantedTools.has("run_process") ||
|
|
61
|
+
grantedTools.has(STABLE_SHELL_TOOL_NAME) ||
|
|
62
|
+
grantedTools.has("run_toolkit_script"),
|
|
52
63
|
budget: intersectRiskBudgets(admitted.budget, current.budget),
|
|
53
64
|
};
|
|
54
65
|
}
|
|
55
66
|
export function buildWorkerExecutionPlan(args) {
|
|
56
|
-
const
|
|
67
|
+
const parentCwd = resolveWorkerWorkspacePath(args.cwd, args.cwd);
|
|
68
|
+
const cwd = args.profile.workspacePath
|
|
69
|
+
? resolveWorkerWorkspacePath(parentCwd, args.profile.workspacePath)
|
|
70
|
+
: parentCwd;
|
|
71
|
+
const pathScopes = args.profile.workspacePath ? [cwd] : workerMachinePathRoots(cwd);
|
|
72
|
+
const profileToolNames = new Set(mapToolNamesForPlatform(args.profile.toolNames).filter((name) => !WORKER_ROOT_MEMORY_TOOL_NAMES.has(name)));
|
|
57
73
|
const grantsRead = args.profile.capabilityCeiling.includes("filesystem.read") ||
|
|
58
74
|
args.profile.capabilityCeiling.includes("worktree.read");
|
|
59
75
|
const writeEligible = args.settings.writeEnabled &&
|
|
60
|
-
args.settings.writePaths.length > 0 &&
|
|
61
76
|
(args.profile.capabilityCeiling.includes("filesystem.write") ||
|
|
62
77
|
args.profile.capabilityCeiling.includes("worktree.mutate"));
|
|
63
|
-
const memoryEligible = args.memoryEnabled
|
|
78
|
+
const memoryEligible = args.memoryEnabled &&
|
|
79
|
+
profileToolNames.has(WORKER_MEMORY_READ_TOOL_NAME) &&
|
|
80
|
+
args.profile.capabilityCeiling.includes("memory.query");
|
|
64
81
|
const processEligible = args.profile.capabilityCeiling.includes("process.exec") ||
|
|
65
82
|
args.profile.capabilityCeiling.includes("tests.execute");
|
|
66
83
|
const enabledProcessToolNames = processEligible
|
|
67
84
|
? [
|
|
85
|
+
...(profileToolNames.has("python") ? ["python"] : []),
|
|
68
86
|
...(args.profile.executionPolicy && profileToolNames.has("run_process") ? ["run_process"] : []),
|
|
69
87
|
...(profileToolNames.has(STABLE_SHELL_TOOL_NAME) ? [STABLE_SHELL_TOOL_NAME] : []),
|
|
70
88
|
]
|
|
71
89
|
: [];
|
|
90
|
+
const enabledAdapterToolNames = (args.workerToolAdapterNames ?? []).filter((name) => profileToolNames.has(name));
|
|
72
91
|
const enabledToolNames = [
|
|
73
92
|
...(grantsRead ? READ_TOOL_NAMES : []),
|
|
74
93
|
...(writeEligible ? WRITE_TOOL_NAMES : []),
|
|
94
|
+
...(memoryEligible ? [WORKER_MEMORY_READ_TOOL_NAME] : []),
|
|
75
95
|
...enabledProcessToolNames,
|
|
76
|
-
...
|
|
77
|
-
? ["delegate"]
|
|
78
|
-
: []),
|
|
96
|
+
...enabledAdapterToolNames,
|
|
79
97
|
];
|
|
80
98
|
const toolManifests = buildLaneToolManifests(args.profile, enabledToolNames);
|
|
81
|
-
if (memoryEligible) {
|
|
82
|
-
toolManifests.push({
|
|
83
|
-
toolName: "memory",
|
|
84
|
-
moduleSpecifier: "../tools/memory.ts",
|
|
85
|
-
capabilities: delegatedToolCapabilities("memory"),
|
|
86
|
-
roles: [args.profile.role],
|
|
87
|
-
enforcements: ["memory-broker"],
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
99
|
const grantedTools = new Set(toolManifests.map((manifest) => manifest.toolName));
|
|
91
100
|
const readEnabled = toolManifests.some((manifest) => manifest.capabilities.some((capability) => capability === "filesystem.read" || capability === "worktree.read"));
|
|
92
101
|
const writeEnabled = grantedTools.has("write") || grantedTools.has("edit");
|
|
93
|
-
const
|
|
94
|
-
|
|
102
|
+
const processEnabled = grantedTools.has("python") ||
|
|
103
|
+
grantedTools.has("run_process") ||
|
|
104
|
+
grantedTools.has(STABLE_SHELL_TOOL_NAME) ||
|
|
105
|
+
grantedTools.has("run_toolkit_script");
|
|
95
106
|
const budget = intersectRiskBudgets(args.profile.budget, ...(args.settings.maxUsd > 0 ? [{ maxCostUsd: args.settings.maxUsd }] : []), ...(args.foregroundMaxCostUsd !== undefined ? [{ maxCostUsd: args.foregroundMaxCostUsd }] : []), ...(args.settings.maxWallClockMs > 0 ? [{ maxWallClockMs: args.settings.maxWallClockMs }] : []));
|
|
96
107
|
return {
|
|
108
|
+
cwd,
|
|
97
109
|
toolManifests,
|
|
98
110
|
requiredCapabilities: [...new Set(toolManifests.flatMap((manifest) => manifest.capabilities))],
|
|
99
|
-
readPaths: readEnabled
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
deniedPaths: args.deniedPaths.map((entry) => path.resolve(entry)),
|
|
106
|
-
readMemory,
|
|
111
|
+
readPaths: readEnabled ? pathScopes : [],
|
|
112
|
+
writePaths: writeEnabled ? pathScopes : [],
|
|
113
|
+
deniedPaths: [
|
|
114
|
+
...new Set([...args.deniedPaths, join(cwd, ".pi", "settings.json")].map((entry) => resolveWorkerWorkspacePath(cwd, entry))),
|
|
115
|
+
],
|
|
116
|
+
readMemory: memoryEligible && grantedTools.has(WORKER_MEMORY_READ_TOOL_NAME),
|
|
107
117
|
writeEnabled,
|
|
108
118
|
processEnabled,
|
|
109
119
|
budget,
|
|
110
120
|
};
|
|
111
121
|
}
|
|
112
122
|
export function compileWorkerExecutionGrant(args) {
|
|
113
|
-
const authorityCapabilities = args.plan.readMemory && !args.profile.capabilityCeiling.includes("memory.query")
|
|
114
|
-
? [...args.profile.capabilityCeiling, "memory.query"]
|
|
115
|
-
: args.profile.capabilityCeiling;
|
|
116
123
|
const compiled = new ExecutionPolicyCompiler().compile({
|
|
117
124
|
objectiveId: args.target.objectiveId,
|
|
118
125
|
taskId: args.target.taskId,
|
|
@@ -121,7 +128,7 @@ export function compileWorkerExecutionGrant(args) {
|
|
|
121
128
|
role: args.profile.role,
|
|
122
129
|
requiredCapabilities: args.plan.requiredCapabilities,
|
|
123
130
|
requestedCapabilities: args.plan.requiredCapabilities,
|
|
124
|
-
authorityCapabilities,
|
|
131
|
+
authorityCapabilities: args.profile.capabilityCeiling,
|
|
125
132
|
requestedTools: args.plan.toolManifests.map((manifest) => manifest.toolName),
|
|
126
133
|
toolManifests: args.plan.toolManifests,
|
|
127
134
|
resources: args.resources,
|
|
@@ -141,6 +148,10 @@ export function compileManagedProcessExecutionGrant(args) {
|
|
|
141
148
|
const manifests = [];
|
|
142
149
|
const unknownTools = [];
|
|
143
150
|
for (const toolName of [...new Set(args.allowedTools)]) {
|
|
151
|
+
if (WORKER_FORBIDDEN_TOOLS.has(toolName) || toolName === WORKER_MEMORY_READ_TOOL_NAME) {
|
|
152
|
+
unknownTools.push(toolName);
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
144
155
|
const policy = getToolCapabilityPolicy(toolName);
|
|
145
156
|
const capabilities = delegatedToolCapabilities(toolName);
|
|
146
157
|
if (!policy || capabilities.length === 0) {
|
|
@@ -159,6 +170,10 @@ export function compileManagedProcessExecutionGrant(args) {
|
|
|
159
170
|
return { ok: false, reasonCodes: unknownTools.map((name) => `unknown_tool:${name}`) };
|
|
160
171
|
const capabilities = [...new Set(manifests.flatMap((manifest) => manifest.capabilities))];
|
|
161
172
|
const readEnabled = capabilities.some((capability) => capability === "filesystem.read" || capability === "worktree.read");
|
|
173
|
+
const writeEnabled = capabilities.some((capability) => capability === "filesystem.write" || capability === "worktree.mutate");
|
|
174
|
+
const cwd = resolveWorkerWorkspacePath(args.cwd, args.cwd);
|
|
175
|
+
const explicitScopes = args.writePaths.map((entry) => resolveWorkerWorkspacePath(cwd, entry));
|
|
176
|
+
const pathScopes = explicitScopes.length > 0 ? explicitScopes : workerMachinePathRoots(cwd);
|
|
162
177
|
const compiled = new ExecutionPolicyCompiler().compile({
|
|
163
178
|
...args.target,
|
|
164
179
|
subjectId: `managed:${args.laneId}:${args.authorizationId}`,
|
|
@@ -168,9 +183,9 @@ export function compileManagedProcessExecutionGrant(args) {
|
|
|
168
183
|
authorityCapabilities: capabilities,
|
|
169
184
|
requestedTools: manifests.map((manifest) => manifest.toolName),
|
|
170
185
|
toolManifests: manifests,
|
|
171
|
-
readPaths: readEnabled ?
|
|
172
|
-
writePaths:
|
|
173
|
-
deniedPaths: args.deniedPaths.map((entry) =>
|
|
186
|
+
readPaths: readEnabled ? pathScopes : [],
|
|
187
|
+
writePaths: writeEnabled ? pathScopes : [],
|
|
188
|
+
deniedPaths: args.deniedPaths.map((entry) => resolveWorkerWorkspacePath(cwd, entry)),
|
|
174
189
|
requestedBudget: args.budget,
|
|
175
190
|
authorityBudget: args.budget,
|
|
176
191
|
policyVersion: "managed-process-v1",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker-execution-policy.js","sourceRoot":"","sources":["../../../src/core/delegation/worker-execution-policy.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAW7F,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AACjF,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAC9E,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAEvE,OAAO,EAAE,uBAAuB,EAAE,4BAA4B,EAAE,MAAM,8BAA8B,CAAC;AAErG,MAAM,eAAe,GAA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,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,CAC5E;QACD,WAAW,EAAE,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QACjE,eAAe,EAAE,IAAI,CAAC,MAAM;QAC5B,eAAe,EAAE,IAAI,CAAC,MAAM;QAC5B,aAAa,EAAE,oBAAoB;KACnC,CAAC,CAAC;IACH,IAAI,QAAQ,CAAC,OAAO,KAAK,OAAO;QAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,QAAQ,CAAC,WAAW,EAAE,CAAC;IAC1F,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,KAAK,EAAE,CAAC;AAC5C,CAAC","sourcesContent":["import path from \"node:path\";\nimport { isPathWithinScope } from \"../autonomy/path-scope.ts\";\nimport { mapToolNamesForPlatform, STABLE_SHELL_TOOL_NAME } from \"../default-tool-surface.ts\";\nimport type {\n\tExecutionGrant,\n\tHarnessCapability,\n\tOrchestrationProfile,\n\tResourcePointer,\n\tRiskBudget,\n\tToolCapabilityManifest,\n\tWorkerExecutionAuthorityContract,\n\tWorkerRole,\n} from \"../orchestration/contracts.ts\";\nimport { buildLaneToolManifests } from \"../orchestration/lane-tool-manifests.ts\";\nimport { ExecutionPolicyCompiler } from \"../orchestration/policy-compiler.ts\";\nimport { intersectRiskBudgets } from \"../orchestration/risk-budget.ts\";\nimport type { ResolvedWorkerDelegationSettings } from \"../settings-manager.ts\";\nimport { getToolCapabilityPolicy, requiredEnvelopeCapabilities } from \"../tool-capability-policy.ts\";\n\nconst READ_TOOL_NAMES = [\"read\", \"grep\", \"find\", \"ls\"] as const;\nconst WRITE_TOOL_NAMES = [\"write\", \"edit\"] as const;\n\nfunction delegatedToolCapabilities(toolName: string): readonly HarnessCapability[] {\n\treturn toolName === \"memory\" ? [\"memory.query\"] : requiredEnvelopeCapabilities(toolName);\n}\n\nexport interface WorkerExecutionPlan {\n\ttoolManifests: readonly ToolCapabilityManifest[];\n\trequiredCapabilities: readonly HarnessCapability[];\n\treadPaths: readonly string[];\n\twritePaths: readonly string[];\n\tdeniedPaths: readonly string[];\n\treadMemory: boolean;\n\twriteEnabled: boolean;\n\tprocessEnabled: boolean;\n\tbudget: RiskBudget;\n}\n\nfunction intersectPathScopes(admittedPaths: readonly string[], currentPaths: readonly string[]): string[] {\n\tconst intersections = admittedPaths.flatMap((admitted) =>\n\t\tcurrentPaths.flatMap((current) => {\n\t\t\tif (isPathWithinScope(current, admitted)) return [current];\n\t\t\tif (isPathWithinScope(admitted, current)) return [admitted];\n\t\t\treturn [];\n\t\t}),\n\t);\n\treturn [...new Set(intersections.map((entry) => path.resolve(entry)))];\n}\n\nexport function workerExecutionAuthorityFromPlan(plan: WorkerExecutionPlan): WorkerExecutionAuthorityContract {\n\treturn {\n\t\tcapabilities: [...plan.requiredCapabilities],\n\t\ttoolNames: plan.toolManifests.map((manifest) => manifest.toolName),\n\t\treadPaths: [...plan.readPaths],\n\t\twritePaths: [...plan.writePaths],\n\t\tdeniedPaths: [...plan.deniedPaths],\n\t\tbudget: { ...plan.budget },\n\t};\n}\n\n/** Apply live revocations to admitted authority without allowing later settings to widen it. */\nexport function narrowWorkerExecutionPlan(\n\tadmitted: WorkerExecutionAuthorityContract,\n\tcurrent: WorkerExecutionPlan,\n): WorkerExecutionPlan {\n\tconst admittedTools = new Set(mapToolNamesForPlatform(admitted.toolNames));\n\tconst admittedCapabilities = new Set(admitted.capabilities);\n\tconst toolManifests = current.toolManifests.filter(\n\t\t(manifest) =>\n\t\t\tadmittedTools.has(manifest.toolName) &&\n\t\t\tmanifest.capabilities.every((capability) => admittedCapabilities.has(capability)),\n\t);\n\tconst requiredCapabilities = [...new Set(toolManifests.flatMap((manifest) => manifest.capabilities))];\n\tconst grantedTools = new Set(toolManifests.map((manifest) => manifest.toolName));\n\tconst readEnabled = requiredCapabilities.some(\n\t\t(capability) => capability === \"filesystem.read\" || capability === \"worktree.read\",\n\t);\n\tconst writeEnabled = grantedTools.has(\"write\") || grantedTools.has(\"edit\");\n\treturn {\n\t\ttoolManifests,\n\t\trequiredCapabilities,\n\t\treadPaths: readEnabled ? intersectPathScopes(admitted.readPaths, current.readPaths) : [],\n\t\twritePaths: writeEnabled ? intersectPathScopes(admitted.writePaths, current.writePaths) : [],\n\t\tdeniedPaths: [...new Set([...admitted.deniedPaths, ...current.deniedPaths].map((entry) => path.resolve(entry)))],\n\t\treadMemory: grantedTools.has(\"memory\"),\n\t\twriteEnabled,\n\t\tprocessEnabled: grantedTools.has(\"run_process\") || grantedTools.has(STABLE_SHELL_TOOL_NAME),\n\t\tbudget: intersectRiskBudgets(admitted.budget, current.budget),\n\t};\n}\n\nexport function buildWorkerExecutionPlan(args: {\n\tprofile: OrchestrationProfile;\n\tsettings: ResolvedWorkerDelegationSettings;\n\tcwd: string;\n\tdeniedPaths: readonly string[];\n\tforegroundMaxCostUsd?: number;\n\tmemoryEnabled: boolean;\n\trequestedReadPaths?: readonly string[];\n\trequestedWritePaths?: readonly string[];\n}): WorkerExecutionPlan {\n\tconst profileToolNames = new Set(mapToolNamesForPlatform(args.profile.toolNames));\n\tconst grantsRead =\n\t\targs.profile.capabilityCeiling.includes(\"filesystem.read\") ||\n\t\targs.profile.capabilityCeiling.includes(\"worktree.read\");\n\tconst writeEligible =\n\t\targs.settings.writeEnabled &&\n\t\targs.settings.writePaths.length > 0 &&\n\t\t(args.profile.capabilityCeiling.includes(\"filesystem.write\") ||\n\t\t\targs.profile.capabilityCeiling.includes(\"worktree.mutate\"));\n\tconst memoryEligible = args.memoryEnabled;\n\tconst processEligible =\n\t\targs.profile.capabilityCeiling.includes(\"process.exec\") ||\n\t\targs.profile.capabilityCeiling.includes(\"tests.execute\");\n\tconst enabledProcessToolNames = processEligible\n\t\t? [\n\t\t\t\t...(args.profile.executionPolicy && profileToolNames.has(\"run_process\") ? ([\"run_process\"] as const) : []),\n\t\t\t\t...(profileToolNames.has(STABLE_SHELL_TOOL_NAME) ? [STABLE_SHELL_TOOL_NAME] : []),\n\t\t\t]\n\t\t: [];\n\tconst enabledToolNames = [\n\t\t...(grantsRead ? READ_TOOL_NAMES : []),\n\t\t...(writeEligible ? WRITE_TOOL_NAMES : []),\n\t\t...enabledProcessToolNames,\n\t\t...(profileToolNames.has(\"delegate\") && args.profile.capabilityCeiling.includes(\"workflow.delegate\")\n\t\t\t? ([\"delegate\"] as const)\n\t\t\t: []),\n\t];\n\tconst toolManifests = buildLaneToolManifests(args.profile, enabledToolNames);\n\tif (memoryEligible) {\n\t\ttoolManifests.push({\n\t\t\ttoolName: \"memory\",\n\t\t\tmoduleSpecifier: \"../tools/memory.ts\",\n\t\t\tcapabilities: delegatedToolCapabilities(\"memory\"),\n\t\t\troles: [args.profile.role],\n\t\t\tenforcements: [\"memory-broker\"],\n\t\t});\n\t}\n\tconst grantedTools = new Set(toolManifests.map((manifest) => manifest.toolName));\n\tconst readEnabled = toolManifests.some((manifest) =>\n\t\tmanifest.capabilities.some((capability) => capability === \"filesystem.read\" || capability === \"worktree.read\"),\n\t);\n\tconst writeEnabled = grantedTools.has(\"write\") || grantedTools.has(\"edit\");\n\tconst readMemory = grantedTools.has(\"memory\");\n\tconst processEnabled = grantedTools.has(\"run_process\") || grantedTools.has(STABLE_SHELL_TOOL_NAME);\n\tconst budget = intersectRiskBudgets(\n\t\targs.profile.budget,\n\t\t...(args.settings.maxUsd > 0 ? [{ maxCostUsd: args.settings.maxUsd }] : []),\n\t\t...(args.foregroundMaxCostUsd !== undefined ? [{ maxCostUsd: args.foregroundMaxCostUsd }] : []),\n\t\t...(args.settings.maxWallClockMs > 0 ? [{ maxWallClockMs: args.settings.maxWallClockMs }] : []),\n\t);\n\treturn {\n\t\ttoolManifests,\n\t\trequiredCapabilities: [...new Set(toolManifests.flatMap((manifest) => manifest.capabilities))],\n\t\treadPaths: readEnabled\n\t\t\t? (args.requestedReadPaths ?? [args.cwd]).map((entry) =>\n\t\t\t\t\tpath.isAbsolute(entry) ? path.resolve(entry) : path.resolve(args.cwd, entry),\n\t\t\t\t)\n\t\t\t: [],\n\t\twritePaths: writeEnabled\n\t\t\t? intersectPathScopes(\n\t\t\t\t\targs.settings.writePaths.map((entry) =>\n\t\t\t\t\t\tpath.isAbsolute(entry) ? path.resolve(entry) : path.resolve(args.cwd, entry),\n\t\t\t\t\t),\n\t\t\t\t\t(args.requestedWritePaths ?? args.settings.writePaths).map((entry) =>\n\t\t\t\t\t\tpath.isAbsolute(entry) ? path.resolve(entry) : path.resolve(args.cwd, entry),\n\t\t\t\t\t),\n\t\t\t\t)\n\t\t\t: [],\n\t\tdeniedPaths: args.deniedPaths.map((entry) => path.resolve(entry)),\n\t\treadMemory,\n\t\twriteEnabled,\n\t\tprocessEnabled,\n\t\tbudget,\n\t};\n}\n\nexport function compileWorkerExecutionGrant(args: {\n\ttarget: { objectiveId: string; taskId: string; attemptId: string };\n\tprofile: OrchestrationProfile;\n\tplan: WorkerExecutionPlan;\n\tresources: readonly ResourcePointer[];\n}): { ok: true; grant: ExecutionGrant } | { ok: false; reasonCodes: readonly string[] } {\n\tconst authorityCapabilities =\n\t\targs.plan.readMemory && !args.profile.capabilityCeiling.includes(\"memory.query\")\n\t\t\t? [...args.profile.capabilityCeiling, \"memory.query\" as const]\n\t\t\t: args.profile.capabilityCeiling;\n\tconst compiled = new ExecutionPolicyCompiler().compile({\n\t\tobjectiveId: args.target.objectiveId,\n\t\ttaskId: args.target.taskId,\n\t\tattemptId: args.target.attemptId,\n\t\tsubjectId: `in-process:${args.target.attemptId}`,\n\t\trole: args.profile.role,\n\t\trequiredCapabilities: args.plan.requiredCapabilities,\n\t\trequestedCapabilities: args.plan.requiredCapabilities,\n\t\tauthorityCapabilities,\n\t\trequestedTools: args.plan.toolManifests.map((manifest) => manifest.toolName),\n\t\ttoolManifests: args.plan.toolManifests,\n\t\tresources: args.resources,\n\t\treadPaths: args.plan.readPaths,\n\t\twritePaths: args.plan.writePaths,\n\t\tdeniedPaths: args.plan.deniedPaths,\n\t\trequestedBudget: args.plan.budget,\n\t\tauthorityBudget: args.plan.budget,\n\t\tpolicyVersion: \"worker-profile-v1\",\n\t});\n\tif (compiled.outcome !== \"allow\") return { ok: false, reasonCodes: compiled.reasonCodes };\n\treturn { ok: true, grant: compiled.grant };\n}\n\n/** Compile the host's durable authority record before an externally managed process is launched. */\nexport function compileManagedProcessExecutionGrant(args: {\n\ttarget: { objectiveId: string; taskId: string; attemptId: string };\n\tlaneId: string;\n\tauthorizationId: string;\n\trole: WorkerRole;\n\tallowedTools: readonly string[];\n\twritePaths: readonly string[];\n\tcwd: string;\n\tdeniedPaths: readonly string[];\n\tbudget: RiskBudget;\n}): { ok: true; grant: ExecutionGrant } | { ok: false; reasonCodes: readonly string[] } {\n\tconst manifests: ToolCapabilityManifest[] = [];\n\tconst unknownTools: string[] = [];\n\tfor (const toolName of [...new Set(args.allowedTools)]) {\n\t\tconst policy = getToolCapabilityPolicy(toolName);\n\t\tconst capabilities = delegatedToolCapabilities(toolName);\n\t\tif (!policy || capabilities.length === 0) {\n\t\t\tunknownTools.push(toolName);\n\t\t\tcontinue;\n\t\t}\n\t\tmanifests.push({\n\t\t\ttoolName,\n\t\t\tmoduleSpecifier: `managed-process:${toolName}`,\n\t\t\tcapabilities,\n\t\t\troles: [args.role],\n\t\t\tenforcements: policy.enforcements,\n\t\t});\n\t}\n\tif (unknownTools.length > 0) return { ok: false, reasonCodes: unknownTools.map((name) => `unknown_tool:${name}`) };\n\tconst capabilities = [...new Set(manifests.flatMap((manifest) => manifest.capabilities))];\n\tconst readEnabled = capabilities.some(\n\t\t(capability) => capability === \"filesystem.read\" || capability === \"worktree.read\",\n\t);\n\tconst compiled = new ExecutionPolicyCompiler().compile({\n\t\t...args.target,\n\t\tsubjectId: `managed:${args.laneId}:${args.authorizationId}`,\n\t\trole: args.role,\n\t\trequiredCapabilities: capabilities,\n\t\trequestedCapabilities: capabilities,\n\t\tauthorityCapabilities: capabilities,\n\t\trequestedTools: manifests.map((manifest) => manifest.toolName),\n\t\ttoolManifests: manifests,\n\t\treadPaths: readEnabled ? [path.resolve(args.cwd)] : [],\n\t\twritePaths: args.writePaths.map((entry) =>\n\t\t\tpath.isAbsolute(entry) ? path.resolve(entry) : path.resolve(args.cwd, entry),\n\t\t),\n\t\tdeniedPaths: args.deniedPaths.map((entry) => path.resolve(entry)),\n\t\trequestedBudget: args.budget,\n\t\tauthorityBudget: args.budget,\n\t\tpolicyVersion: \"managed-process-v1\",\n\t});\n\tif (compiled.outcome !== \"allow\") return { ok: false, reasonCodes: compiled.reasonCodes };\n\treturn { ok: true, grant: compiled.grant };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"worker-execution-policy.js","sourceRoot":"","sources":["../../../src/core/delegation/worker-execution-policy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAC7F,OAAO,EAAE,4BAA4B,EAAE,6BAA6B,EAAE,MAAM,kCAAkC,CAAC;AAW/G,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AACjF,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAC9E,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAE5D,OAAO,EAAE,uBAAuB,EAAE,4BAA4B,EAAE,MAAM,8BAA8B,CAAC;AACrG,OAAO,EAAE,0BAA0B,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAE/F,MAAM,eAAe,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,CAAU,CAAC;AAChE,MAA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,CAAC,QAAQ,CAAC,QAAQ,CAAC;QAC9D,aAAa,EAAE,SAAS;QACxB,SAAS,EAAE,WAAW,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE;QACxC,UAAU,EAAE,YAAY,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE;QAC1C,WAAW,EAAE,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,0BAA0B,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACpF,eAAe,EAAE,IAAI,CAAC,MAAM;QAC5B,eAAe,EAAE,IAAI,CAAC,MAAM;QAC5B,aAAa,EAAE,oBAAoB;KACnC,CAAC,CAAC;IACH,IAAI,QAAQ,CAAC,OAAO,KAAK,OAAO;QAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,QAAQ,CAAC,WAAW,EAAE,CAAC;IAC1F,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,KAAK,EAAE,CAAC;AAC5C,CAAC","sourcesContent":["import { join } from \"node:path\";\nimport { isPathWithinScope } from \"../autonomy/path-scope.ts\";\nimport { mapToolNamesForPlatform, STABLE_SHELL_TOOL_NAME } from \"../default-tool-surface.ts\";\nimport { WORKER_MEMORY_READ_TOOL_NAME, WORKER_ROOT_MEMORY_TOOL_NAMES } from \"../memory/worker-memory-tools.ts\";\nimport type {\n\tExecutionGrant,\n\tHarnessCapability,\n\tOrchestrationProfile,\n\tResourcePointer,\n\tRiskBudget,\n\tToolCapabilityManifest,\n\tWorkerExecutionAuthorityContract,\n\tWorkerRole,\n} from \"../orchestration/contracts.ts\";\nimport { buildLaneToolManifests } from \"../orchestration/lane-tool-manifests.ts\";\nimport { ExecutionPolicyCompiler } from \"../orchestration/policy-compiler.ts\";\nimport { intersectRiskBudgets } from \"../orchestration/risk-budget.ts\";\nimport { WORKER_FORBIDDEN_TOOLS } from \"../session-role.ts\";\nimport type { ResolvedWorkerDelegationSettings } from \"../settings-manager.ts\";\nimport { getToolCapabilityPolicy, requiredEnvelopeCapabilities } from \"../tool-capability-policy.ts\";\nimport { resolveWorkerWorkspacePath, workerMachinePathRoots } from \"./worker-machine-scope.ts\";\n\nconst READ_TOOL_NAMES = [\"read\", \"grep\", \"find\", \"ls\"] as const;\nconst WRITE_TOOL_NAMES = [\"write\", \"edit\"] as const;\n\nfunction delegatedToolCapabilities(toolName: string): readonly HarnessCapability[] {\n\treturn requiredEnvelopeCapabilities(toolName);\n}\n\nexport interface WorkerExecutionPlan {\n\t/** Actual process and relative-tool working directory fixed at admission. */\n\tcwd: string;\n\ttoolManifests: readonly ToolCapabilityManifest[];\n\trequiredCapabilities: readonly HarnessCapability[];\n\treadPaths: readonly string[];\n\twritePaths: readonly string[];\n\tdeniedPaths: readonly string[];\n\treadMemory: boolean;\n\twriteEnabled: boolean;\n\tprocessEnabled: boolean;\n\tbudget: RiskBudget;\n}\n\nfunction intersectPathScopes(admittedPaths: readonly string[], currentPaths: readonly string[]): string[] {\n\tconst intersections = admittedPaths.flatMap((admitted) =>\n\t\tcurrentPaths.flatMap((current) => {\n\t\t\tif (isPathWithinScope(current, admitted)) return [current];\n\t\t\tif (isPathWithinScope(admitted, current)) return [admitted];\n\t\t\treturn [];\n\t\t}),\n\t);\n\treturn [...new Set(intersections.map((entry) => resolveWorkerWorkspacePath(entry, entry)))];\n}\n\nexport function workerExecutionAuthorityFromPlan(plan: WorkerExecutionPlan): WorkerExecutionAuthorityContract {\n\treturn {\n\t\tcwd: plan.cwd,\n\t\tcapabilities: [...plan.requiredCapabilities],\n\t\ttoolNames: plan.toolManifests.map((manifest) => manifest.toolName),\n\t\treadPaths: [...plan.readPaths],\n\t\twritePaths: [...plan.writePaths],\n\t\tdeniedPaths: [...plan.deniedPaths],\n\t\tbudget: { ...plan.budget },\n\t};\n}\n\n/** Apply live revocations to admitted authority without allowing later settings to widen it. */\nexport function narrowWorkerExecutionPlan(\n\tadmitted: WorkerExecutionAuthorityContract,\n\tcurrent: WorkerExecutionPlan,\n): WorkerExecutionPlan {\n\tconst admittedTools = new Set(mapToolNamesForPlatform(admitted.toolNames));\n\tconst admittedCapabilities = new Set(admitted.capabilities);\n\tconst toolManifests = current.toolManifests.filter(\n\t\t(manifest) =>\n\t\t\t!WORKER_ROOT_MEMORY_TOOL_NAMES.has(manifest.toolName) &&\n\t\t\tadmittedTools.has(manifest.toolName) &&\n\t\t\tmanifest.capabilities.every((capability) => admittedCapabilities.has(capability)),\n\t);\n\tconst requiredCapabilities = [...new Set(toolManifests.flatMap((manifest) => manifest.capabilities))];\n\tconst grantedTools = new Set(toolManifests.map((manifest) => manifest.toolName));\n\tconst readEnabled = requiredCapabilities.some(\n\t\t(capability) => capability === \"filesystem.read\" || capability === \"worktree.read\",\n\t);\n\tconst writeEnabled = grantedTools.has(\"write\") || grantedTools.has(\"edit\");\n\treturn {\n\t\tcwd: admitted.cwd ?? current.cwd,\n\t\ttoolManifests,\n\t\trequiredCapabilities,\n\t\treadPaths: readEnabled ? intersectPathScopes(admitted.readPaths, current.readPaths) : [],\n\t\twritePaths: writeEnabled ? intersectPathScopes(admitted.writePaths, current.writePaths) : [],\n\t\tdeniedPaths: [\n\t\t\t...new Set(\n\t\t\t\t[...admitted.deniedPaths, ...current.deniedPaths].map((entry) =>\n\t\t\t\t\tresolveWorkerWorkspacePath(current.cwd, entry),\n\t\t\t\t),\n\t\t\t),\n\t\t],\n\t\treadMemory: grantedTools.has(WORKER_MEMORY_READ_TOOL_NAME),\n\t\twriteEnabled,\n\t\tprocessEnabled:\n\t\t\tgrantedTools.has(\"python\") ||\n\t\t\tgrantedTools.has(\"run_process\") ||\n\t\t\tgrantedTools.has(STABLE_SHELL_TOOL_NAME) ||\n\t\t\tgrantedTools.has(\"run_toolkit_script\"),\n\t\tbudget: intersectRiskBudgets(admitted.budget, current.budget),\n\t};\n}\n\nexport function buildWorkerExecutionPlan(args: {\n\tprofile: OrchestrationProfile;\n\tsettings: ResolvedWorkerDelegationSettings;\n\tcwd: string;\n\tdeniedPaths: readonly string[];\n\tforegroundMaxCostUsd?: number;\n\tmemoryEnabled: boolean;\n\tworkerToolAdapterNames?: readonly string[];\n}): WorkerExecutionPlan {\n\tconst parentCwd = resolveWorkerWorkspacePath(args.cwd, args.cwd);\n\tconst cwd = args.profile.workspacePath\n\t\t? resolveWorkerWorkspacePath(parentCwd, args.profile.workspacePath)\n\t\t: parentCwd;\n\tconst pathScopes = args.profile.workspacePath ? [cwd] : workerMachinePathRoots(cwd);\n\tconst profileToolNames = new Set(\n\t\tmapToolNamesForPlatform(args.profile.toolNames).filter((name) => !WORKER_ROOT_MEMORY_TOOL_NAMES.has(name)),\n\t);\n\tconst grantsRead =\n\t\targs.profile.capabilityCeiling.includes(\"filesystem.read\") ||\n\t\targs.profile.capabilityCeiling.includes(\"worktree.read\");\n\tconst writeEligible =\n\t\targs.settings.writeEnabled &&\n\t\t(args.profile.capabilityCeiling.includes(\"filesystem.write\") ||\n\t\t\targs.profile.capabilityCeiling.includes(\"worktree.mutate\"));\n\tconst memoryEligible =\n\t\targs.memoryEnabled &&\n\t\tprofileToolNames.has(WORKER_MEMORY_READ_TOOL_NAME) &&\n\t\targs.profile.capabilityCeiling.includes(\"memory.query\");\n\tconst processEligible =\n\t\targs.profile.capabilityCeiling.includes(\"process.exec\") ||\n\t\targs.profile.capabilityCeiling.includes(\"tests.execute\");\n\tconst enabledProcessToolNames = processEligible\n\t\t? [\n\t\t\t\t...(profileToolNames.has(\"python\") ? ([\"python\"] as const) : []),\n\t\t\t\t...(args.profile.executionPolicy && profileToolNames.has(\"run_process\") ? ([\"run_process\"] as const) : []),\n\t\t\t\t...(profileToolNames.has(STABLE_SHELL_TOOL_NAME) ? [STABLE_SHELL_TOOL_NAME] : []),\n\t\t\t]\n\t\t: [];\n\tconst enabledAdapterToolNames = (args.workerToolAdapterNames ?? []).filter((name) => profileToolNames.has(name));\n\tconst enabledToolNames = [\n\t\t...(grantsRead ? READ_TOOL_NAMES : []),\n\t\t...(writeEligible ? WRITE_TOOL_NAMES : []),\n\t\t...(memoryEligible ? [WORKER_MEMORY_READ_TOOL_NAME] : []),\n\t\t...enabledProcessToolNames,\n\t\t...enabledAdapterToolNames,\n\t];\n\tconst toolManifests = buildLaneToolManifests(args.profile, enabledToolNames);\n\tconst grantedTools = new Set(toolManifests.map((manifest) => manifest.toolName));\n\tconst readEnabled = toolManifests.some((manifest) =>\n\t\tmanifest.capabilities.some((capability) => capability === \"filesystem.read\" || capability === \"worktree.read\"),\n\t);\n\tconst writeEnabled = grantedTools.has(\"write\") || grantedTools.has(\"edit\");\n\tconst processEnabled =\n\t\tgrantedTools.has(\"python\") ||\n\t\tgrantedTools.has(\"run_process\") ||\n\t\tgrantedTools.has(STABLE_SHELL_TOOL_NAME) ||\n\t\tgrantedTools.has(\"run_toolkit_script\");\n\tconst budget = intersectRiskBudgets(\n\t\targs.profile.budget,\n\t\t...(args.settings.maxUsd > 0 ? [{ maxCostUsd: args.settings.maxUsd }] : []),\n\t\t...(args.foregroundMaxCostUsd !== undefined ? [{ maxCostUsd: args.foregroundMaxCostUsd }] : []),\n\t\t...(args.settings.maxWallClockMs > 0 ? [{ maxWallClockMs: args.settings.maxWallClockMs }] : []),\n\t);\n\treturn {\n\t\tcwd,\n\t\ttoolManifests,\n\t\trequiredCapabilities: [...new Set(toolManifests.flatMap((manifest) => manifest.capabilities))],\n\t\treadPaths: readEnabled ? pathScopes : [],\n\t\twritePaths: writeEnabled ? pathScopes : [],\n\t\tdeniedPaths: [\n\t\t\t...new Set(\n\t\t\t\t[...args.deniedPaths, join(cwd, \".pi\", \"settings.json\")].map((entry) =>\n\t\t\t\t\tresolveWorkerWorkspacePath(cwd, entry),\n\t\t\t\t),\n\t\t\t),\n\t\t],\n\t\treadMemory: memoryEligible && grantedTools.has(WORKER_MEMORY_READ_TOOL_NAME),\n\t\twriteEnabled,\n\t\tprocessEnabled,\n\t\tbudget,\n\t};\n}\n\nexport function compileWorkerExecutionGrant(args: {\n\ttarget: { objectiveId: string; taskId: string; attemptId: string };\n\tprofile: OrchestrationProfile;\n\tplan: WorkerExecutionPlan;\n\tresources: readonly ResourcePointer[];\n}): { ok: true; grant: ExecutionGrant } | { ok: false; reasonCodes: readonly string[] } {\n\tconst compiled = new ExecutionPolicyCompiler().compile({\n\t\tobjectiveId: args.target.objectiveId,\n\t\ttaskId: args.target.taskId,\n\t\tattemptId: args.target.attemptId,\n\t\tsubjectId: `in-process:${args.target.attemptId}`,\n\t\trole: args.profile.role,\n\t\trequiredCapabilities: args.plan.requiredCapabilities,\n\t\trequestedCapabilities: args.plan.requiredCapabilities,\n\t\tauthorityCapabilities: args.profile.capabilityCeiling,\n\t\trequestedTools: args.plan.toolManifests.map((manifest) => manifest.toolName),\n\t\ttoolManifests: args.plan.toolManifests,\n\t\tresources: args.resources,\n\t\treadPaths: args.plan.readPaths,\n\t\twritePaths: args.plan.writePaths,\n\t\tdeniedPaths: args.plan.deniedPaths,\n\t\trequestedBudget: args.plan.budget,\n\t\tauthorityBudget: args.plan.budget,\n\t\tpolicyVersion: \"worker-profile-v1\",\n\t});\n\tif (compiled.outcome !== \"allow\") return { ok: false, reasonCodes: compiled.reasonCodes };\n\treturn { ok: true, grant: compiled.grant };\n}\n\n/** Compile the host's durable authority record before an externally managed process is launched. */\nexport function compileManagedProcessExecutionGrant(args: {\n\ttarget: { objectiveId: string; taskId: string; attemptId: string };\n\tlaneId: string;\n\tauthorizationId: string;\n\trole: WorkerRole;\n\tallowedTools: readonly string[];\n\twritePaths: readonly string[];\n\tcwd: string;\n\tdeniedPaths: readonly string[];\n\tbudget: RiskBudget;\n}): { ok: true; grant: ExecutionGrant } | { ok: false; reasonCodes: readonly string[] } {\n\tconst manifests: ToolCapabilityManifest[] = [];\n\tconst unknownTools: string[] = [];\n\tfor (const toolName of [...new Set(args.allowedTools)]) {\n\t\tif (WORKER_FORBIDDEN_TOOLS.has(toolName) || toolName === WORKER_MEMORY_READ_TOOL_NAME) {\n\t\t\tunknownTools.push(toolName);\n\t\t\tcontinue;\n\t\t}\n\t\tconst policy = getToolCapabilityPolicy(toolName);\n\t\tconst capabilities = delegatedToolCapabilities(toolName);\n\t\tif (!policy || capabilities.length === 0) {\n\t\t\tunknownTools.push(toolName);\n\t\t\tcontinue;\n\t\t}\n\t\tmanifests.push({\n\t\t\ttoolName,\n\t\t\tmoduleSpecifier: `managed-process:${toolName}`,\n\t\t\tcapabilities,\n\t\t\troles: [args.role],\n\t\t\tenforcements: policy.enforcements,\n\t\t});\n\t}\n\tif (unknownTools.length > 0) return { ok: false, reasonCodes: unknownTools.map((name) => `unknown_tool:${name}`) };\n\tconst capabilities = [...new Set(manifests.flatMap((manifest) => manifest.capabilities))];\n\tconst readEnabled = capabilities.some(\n\t\t(capability) => capability === \"filesystem.read\" || capability === \"worktree.read\",\n\t);\n\tconst writeEnabled = capabilities.some(\n\t\t(capability) => capability === \"filesystem.write\" || capability === \"worktree.mutate\",\n\t);\n\tconst cwd = resolveWorkerWorkspacePath(args.cwd, args.cwd);\n\tconst explicitScopes = args.writePaths.map((entry) => resolveWorkerWorkspacePath(cwd, entry));\n\tconst pathScopes = explicitScopes.length > 0 ? explicitScopes : workerMachinePathRoots(cwd);\n\tconst compiled = new ExecutionPolicyCompiler().compile({\n\t\t...args.target,\n\t\tsubjectId: `managed:${args.laneId}:${args.authorizationId}`,\n\t\trole: args.role,\n\t\trequiredCapabilities: capabilities,\n\t\trequestedCapabilities: capabilities,\n\t\tauthorityCapabilities: capabilities,\n\t\trequestedTools: manifests.map((manifest) => manifest.toolName),\n\t\ttoolManifests: manifests,\n\t\treadPaths: readEnabled ? pathScopes : [],\n\t\twritePaths: writeEnabled ? pathScopes : [],\n\t\tdeniedPaths: args.deniedPaths.map((entry) => resolveWorkerWorkspacePath(cwd, entry)),\n\t\trequestedBudget: args.budget,\n\t\tauthorityBudget: args.budget,\n\t\tpolicyVersion: \"managed-process-v1\",\n\t});\n\tif (compiled.outcome !== \"allow\") return { ok: false, reasonCodes: compiled.reasonCodes };\n\treturn { ok: true, grant: compiled.grant };\n}\n"]}
|
|
@@ -12,11 +12,11 @@ export interface WorkerFleetLimits {
|
|
|
12
12
|
maxQueuedDispatches: number;
|
|
13
13
|
}
|
|
14
14
|
export declare const DEFAULT_WORKER_FLEET_LIMITS: Readonly<WorkerFleetLimits>;
|
|
15
|
-
/**
|
|
16
|
-
export declare const
|
|
15
|
+
/** Every newly compiled native worker is a leaf; legacy wider limits are narrowed to this contract. */
|
|
16
|
+
export declare const LEAF_WORKER_DELEGATION_LIMITS: Readonly<OrchestrationDelegationLimits>;
|
|
17
17
|
/** Materialize an optional profile limit inside the process-independent host safety ceiling. */
|
|
18
18
|
export declare function resolveWorkerFleetLimits(delegationLimits?: Readonly<OrchestrationDelegationLimits>): Readonly<WorkerFleetLimits>;
|
|
19
|
-
/**
|
|
19
|
+
/** Legacy recovery may preserve or narrow a persisted lineage boundary, never widen it. */
|
|
20
20
|
export declare function intersectWorkerDelegationLimits(requested?: Readonly<OrchestrationDelegationLimits>, boundary?: Readonly<OrchestrationDelegationLimits>): OrchestrationDelegationLimits | undefined;
|
|
21
21
|
export type NewWorkerAdmission = {
|
|
22
22
|
ok: true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker-fleet-limits.d.ts","sourceRoot":"","sources":["../../../src/core/delegation/worker-fleet-limits.ts"],"names":[],"mappings":"AACA,OAAO,EACN,KAAK,oBAAoB,EAIzB,KAAK,6BAA6B,EAClC,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAuB,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAEnG;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,yBAAyB,EAAE,MAAM,CAAC;IAClC,mBAAmB,EAAE,MAAM,CAAC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CACvC,CAAC;AAEL,MAAM,MAAM,+BAA+B,GACxC;IAAE,EAAE,EAAE,IAAI,CAAA;CAAE,GACZ;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,UAAU,EAAE,oCAAoC,CAAA;CAAE,CAAC;AAEnE,+EAA+E;AAC/E,wBAAgB,6BAA6B,CAC5C,QAAQ,EAAE,IAAI,CAAC,qBAAqB,EAAE,QAAQ,GAAG,OAAO,GAAG,UAAU,CAAC,GACpE,GAAG,CAAC,MAAM,CAAC,CA0Cb;AAgBD;;;GAGG;AACH,wBAAgB,mCAAmC,CAClD,QAAQ,EAAE,IAAI,CAAC,qBAAqB,EAAE,QAAQ,GAAG,OAAO,GAAG,UAAU,CAAC,EACtE,OAAO,EAAE,MAAM,EACf,MAAM,GAAE,QAAQ,CAAC,iBAAiB,CAA+B,GAC/D,+BAA+B,CAKjC;AAED,kGAAkG;AAClG,wBAAgB,0BAA0B,CACzC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC,EACtD,aAAa,CAAC,EAAE,MAAM,EACtB,MAAM,GAAE,QAAQ,CAAC,iBAAiB,CAA+B,EACjE,kBAAkB,SAAI,GACpB,kBAAkB,CA+BpB;AAED,+EAA+E;AAC/E,wBAAgB,sBAAsB,CACrC,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,OAAO,EACjB,MAAM,GAAE,QAAQ,CAAC,iBAAiB,CAA+B,GAC/D,OAAO,CAIT"}
|
|
@@ -7,11 +7,11 @@ export const DEFAULT_WORKER_FLEET_LIMITS = Object.freeze({
|
|
|
7
7
|
maxNestedAgentsPerSession: MAX_ORCHESTRATION_AGENT_BINDINGS,
|
|
8
8
|
maxQueuedDispatches: 256,
|
|
9
9
|
});
|
|
10
|
-
/**
|
|
11
|
-
export const
|
|
12
|
-
maxDepth:
|
|
13
|
-
maxChildrenPerAgent:
|
|
14
|
-
maxNestedAgentsPerSession:
|
|
10
|
+
/** Every newly compiled native worker is a leaf; legacy wider limits are narrowed to this contract. */
|
|
11
|
+
export const LEAF_WORKER_DELEGATION_LIMITS = Object.freeze({
|
|
12
|
+
maxDepth: 0,
|
|
13
|
+
maxChildrenPerAgent: 0,
|
|
14
|
+
maxNestedAgentsPerSession: 0,
|
|
15
15
|
});
|
|
16
16
|
/** Materialize an optional profile limit inside the process-independent host safety ceiling. */
|
|
17
17
|
export function resolveWorkerFleetLimits(delegationLimits) {
|
|
@@ -22,7 +22,7 @@ export function resolveWorkerFleetLimits(delegationLimits) {
|
|
|
22
22
|
maxNestedAgentsPerSession: Math.min(delegationLimits?.maxNestedAgentsPerSession ?? DEFAULT_WORKER_FLEET_LIMITS.maxNestedAgentsPerSession, MAX_ORCHESTRATION_AGENT_BINDINGS),
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
|
-
/**
|
|
25
|
+
/** Legacy recovery may preserve or narrow a persisted lineage boundary, never widen it. */
|
|
26
26
|
export function intersectWorkerDelegationLimits(requested, boundary) {
|
|
27
27
|
if (!requested && !boundary)
|
|
28
28
|
return undefined;
|
|
@@ -134,7 +134,7 @@ export function evaluateNewWorkerAdmission(agents, parentAgentId, limits = DEFAU
|
|
|
134
134
|
// A retired agent's durable identity slot is still reserved (evaluateWorkerIdentityHeadroom
|
|
135
135
|
// above already bounds total agent count), but it no longer occupies a live nested-fleet
|
|
136
136
|
// slot. Counting it here permanently blocks all future nested delegation once any nested
|
|
137
|
-
// child has ever finished
|
|
137
|
+
// child has ever finished when a recovered legacy contract retains a nested-session limit of one.
|
|
138
138
|
if (agent.parentAgentId && agent.status !== "retired")
|
|
139
139
|
nestedAgents += 1;
|
|
140
140
|
}
|