@caupulican/pi-adaptative 0.81.39 → 0.81.41
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 +77 -0
- package/README.md +2 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.d.ts +2 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.d.ts.map +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.js +3 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.js.map +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.ts +4 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.d.ts +9 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.d.ts.map +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.js +290 -107
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.js.map +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.ts +357 -122
- package/dist/bundled-resources/skills/tool-call-repair/references/repair-catalogue.md +2 -2
- package/dist/cli/args.d.ts +4 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +31 -1
- package/dist/cli/args.js.map +1 -1
- package/dist/core/agent-directory-layout.d.ts +15 -0
- package/dist/core/agent-directory-layout.d.ts.map +1 -0
- package/dist/core/agent-directory-layout.js +72 -0
- package/dist/core/agent-directory-layout.js.map +1 -0
- package/dist/core/agent-paths.d.ts +25 -2
- package/dist/core/agent-paths.d.ts.map +1 -1
- package/dist/core/agent-paths.js +79 -4
- package/dist/core/agent-paths.js.map +1 -1
- package/dist/core/agent-session-contracts.d.ts +293 -0
- package/dist/core/agent-session-contracts.d.ts.map +1 -0
- package/dist/core/agent-session-contracts.js +26 -0
- package/dist/core/agent-session-contracts.js.map +1 -0
- package/dist/core/agent-session-runtime.d.ts +52 -8
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +400 -79
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-services.d.ts +1 -0
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +1 -0
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session.d.ts +74 -518
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +370 -1432
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +3 -1
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/autonomy/approval-gate.d.ts +3 -2
- package/dist/core/autonomy/approval-gate.d.ts.map +1 -1
- package/dist/core/autonomy/approval-gate.js +6 -28
- package/dist/core/autonomy/approval-gate.js.map +1 -1
- package/dist/core/autonomy/bounded-completion.d.ts +1 -1
- package/dist/core/autonomy/bounded-completion.d.ts.map +1 -1
- package/dist/core/autonomy/bounded-completion.js +1 -1
- package/dist/core/autonomy/bounded-completion.js.map +1 -1
- package/dist/core/autonomy/contracts.d.ts +20 -12
- package/dist/core/autonomy/contracts.d.ts.map +1 -1
- package/dist/core/autonomy/contracts.js.map +1 -1
- package/dist/core/autonomy/foreground-envelope.d.ts +8 -2
- package/dist/core/autonomy/foreground-envelope.d.ts.map +1 -1
- package/dist/core/autonomy/foreground-envelope.js +8 -25
- package/dist/core/autonomy/foreground-envelope.js.map +1 -1
- package/dist/core/autonomy/gates.d.ts.map +1 -1
- package/dist/core/autonomy/gates.js +8 -10
- package/dist/core/autonomy/gates.js.map +1 -1
- package/dist/core/autonomy/lane-private-paths.d.ts +2 -0
- package/dist/core/autonomy/lane-private-paths.d.ts.map +1 -0
- package/dist/core/autonomy/lane-private-paths.js +16 -0
- package/dist/core/autonomy/lane-private-paths.js.map +1 -0
- package/dist/core/autonomy/lane-tool-surface.d.ts +10 -0
- package/dist/core/autonomy/lane-tool-surface.d.ts.map +1 -1
- package/dist/core/autonomy/lane-tool-surface.js +48 -9
- package/dist/core/autonomy/lane-tool-surface.js.map +1 -1
- package/dist/core/autonomy/lane-tracker.d.ts +14 -0
- package/dist/core/autonomy/lane-tracker.d.ts.map +1 -1
- package/dist/core/autonomy/lane-tracker.js +38 -0
- package/dist/core/autonomy/lane-tracker.js.map +1 -1
- package/dist/core/autonomy/risk-assessment.d.ts +1 -2
- package/dist/core/autonomy/risk-assessment.d.ts.map +1 -1
- package/dist/core/autonomy/risk-assessment.js +1 -123
- package/dist/core/autonomy/risk-assessment.js.map +1 -1
- package/dist/core/autonomy/session-lane-record.d.ts +4 -4
- package/dist/core/autonomy/session-lane-record.d.ts.map +1 -1
- package/dist/core/autonomy/session-lane-record.js +16 -29
- package/dist/core/autonomy/session-lane-record.js.map +1 -1
- package/dist/core/autonomy/telemetry-events.d.ts +1 -1
- package/dist/core/autonomy/telemetry-events.d.ts.map +1 -1
- package/dist/core/autonomy/telemetry-events.js +1 -1
- package/dist/core/autonomy/telemetry-events.js.map +1 -1
- package/dist/core/autonomy-telemetry.d.ts +7 -7
- package/dist/core/autonomy-telemetry.d.ts.map +1 -1
- package/dist/core/autonomy-telemetry.js +9 -9
- package/dist/core/autonomy-telemetry.js.map +1 -1
- package/dist/core/background-lane-controller.d.ts +56 -236
- package/dist/core/background-lane-controller.d.ts.map +1 -1
- package/dist/core/background-lane-controller.js +141 -1273
- package/dist/core/background-lane-controller.js.map +1 -1
- package/dist/core/bedrock-sso-login.d.ts +16 -0
- package/dist/core/bedrock-sso-login.d.ts.map +1 -0
- package/dist/core/bedrock-sso-login.js +98 -0
- package/dist/core/bedrock-sso-login.js.map +1 -0
- package/dist/core/capability-contract.d.ts +4 -0
- package/dist/core/capability-contract.d.ts.map +1 -0
- package/dist/core/capability-contract.js +28 -0
- package/dist/core/capability-contract.js.map +1 -0
- package/dist/core/compaction-controller.d.ts +90 -0
- package/dist/core/compaction-controller.d.ts.map +1 -0
- package/dist/core/compaction-controller.js +452 -0
- package/dist/core/compaction-controller.js.map +1 -0
- package/dist/core/compaction-support.d.ts +13 -17
- package/dist/core/compaction-support.d.ts.map +1 -1
- package/dist/core/compaction-support.js +3 -3
- package/dist/core/compaction-support.js.map +1 -1
- package/dist/core/context/context-artifacts.d.ts +6 -2
- package/dist/core/context/context-artifacts.d.ts.map +1 -1
- package/dist/core/context/context-artifacts.js +34 -2
- package/dist/core/context/context-artifacts.js.map +1 -1
- package/dist/core/context/context-store-retention.d.ts +8 -2
- package/dist/core/context/context-store-retention.d.ts.map +1 -1
- package/dist/core/context/context-store-retention.js +158 -35
- package/dist/core/context/context-store-retention.js.map +1 -1
- package/dist/core/context/okf-memory.d.ts.map +1 -1
- package/dist/core/context/okf-memory.js +9 -11
- package/dist/core/context/okf-memory.js.map +1 -1
- package/dist/core/context/sqlite-runtime-index.d.ts.map +1 -1
- package/dist/core/context/sqlite-runtime-index.js +6 -8
- package/dist/core/context/sqlite-runtime-index.js.map +1 -1
- package/dist/core/context-gc.d.ts +3 -0
- package/dist/core/context-gc.d.ts.map +1 -1
- package/dist/core/context-gc.js +10 -5
- package/dist/core/context-gc.js.map +1 -1
- package/dist/core/context-pipeline.d.ts +1 -1
- package/dist/core/context-pipeline.d.ts.map +1 -1
- package/dist/core/context-pipeline.js +16 -37
- package/dist/core/context-pipeline.js.map +1 -1
- package/dist/core/cost/cost-summary.d.ts.map +1 -1
- package/dist/core/cost/cost-summary.js +5 -3
- package/dist/core/cost/cost-summary.js.map +1 -1
- package/dist/core/cost/daily-usage.d.ts.map +1 -1
- package/dist/core/cost/daily-usage.js +4 -5
- package/dist/core/cost/daily-usage.js.map +1 -1
- package/dist/core/default-tool-surface.d.ts.map +1 -1
- package/dist/core/default-tool-surface.js +2 -0
- package/dist/core/default-tool-surface.js.map +1 -1
- package/dist/core/delegation/managed-lane-controller.d.ts +34 -0
- package/dist/core/delegation/managed-lane-controller.d.ts.map +1 -0
- package/dist/core/delegation/managed-lane-controller.js +217 -0
- package/dist/core/delegation/managed-lane-controller.js.map +1 -0
- package/dist/core/delegation/session-worker-claim.d.ts +44 -0
- package/dist/core/delegation/session-worker-claim.d.ts.map +1 -0
- package/dist/core/delegation/session-worker-claim.js +98 -0
- package/dist/core/delegation/session-worker-claim.js.map +1 -0
- package/dist/core/delegation/worker-actions.d.ts +7 -5
- package/dist/core/delegation/worker-actions.d.ts.map +1 -1
- package/dist/core/delegation/worker-actions.js +20 -4
- package/dist/core/delegation/worker-actions.js.map +1 -1
- package/dist/core/delegation/{worker-result.d.ts → worker-claim.d.ts} +13 -13
- package/dist/core/delegation/worker-claim.d.ts.map +1 -0
- package/dist/core/delegation/{worker-result.js → worker-claim.js} +61 -51
- package/dist/core/delegation/worker-claim.js.map +1 -0
- package/dist/core/delegation/worker-delegation-controller.d.ts +110 -0
- package/dist/core/delegation/worker-delegation-controller.d.ts.map +1 -0
- package/dist/core/delegation/worker-delegation-controller.js +861 -0
- package/dist/core/delegation/worker-delegation-controller.js.map +1 -0
- package/dist/core/delegation/worker-delegation-request.d.ts +11 -0
- package/dist/core/delegation/worker-delegation-request.d.ts.map +1 -0
- package/dist/core/delegation/worker-delegation-request.js +2 -0
- package/dist/core/delegation/worker-delegation-request.js.map +1 -0
- package/dist/core/delegation/worker-dispatch-scheduler.d.ts +40 -0
- package/dist/core/delegation/worker-dispatch-scheduler.d.ts.map +1 -0
- package/dist/core/delegation/worker-dispatch-scheduler.js +93 -0
- package/dist/core/delegation/worker-dispatch-scheduler.js.map +1 -0
- package/dist/core/delegation/worker-execution-policy.d.ts +62 -0
- package/dist/core/delegation/worker-execution-policy.d.ts.map +1 -0
- package/dist/core/delegation/worker-execution-policy.js +160 -0
- package/dist/core/delegation/worker-execution-policy.js.map +1 -0
- package/dist/core/delegation/worker-lane-projection.d.ts +14 -0
- package/dist/core/delegation/worker-lane-projection.d.ts.map +1 -0
- package/dist/core/delegation/worker-lane-projection.js +100 -0
- package/dist/core/delegation/worker-lane-projection.js.map +1 -0
- package/dist/core/delegation/worker-lifecycle.d.ts +97 -0
- package/dist/core/delegation/worker-lifecycle.d.ts.map +1 -0
- package/dist/core/delegation/worker-lifecycle.js +339 -0
- package/dist/core/delegation/worker-lifecycle.js.map +1 -0
- package/dist/core/delegation/worker-notification-coordinator.d.ts +36 -0
- package/dist/core/delegation/worker-notification-coordinator.d.ts.map +1 -0
- package/dist/core/delegation/worker-notification-coordinator.js +90 -0
- package/dist/core/delegation/worker-notification-coordinator.js.map +1 -0
- package/dist/core/delegation/worker-profile-resolver.d.ts +55 -0
- package/dist/core/delegation/worker-profile-resolver.d.ts.map +1 -0
- package/dist/core/delegation/worker-profile-resolver.js +113 -0
- package/dist/core/delegation/worker-profile-resolver.js.map +1 -0
- package/dist/core/delegation/worker-runner.d.ts +25 -14
- package/dist/core/delegation/worker-runner.d.ts.map +1 -1
- package/dist/core/delegation/worker-runner.js +122 -53
- package/dist/core/delegation/worker-runner.js.map +1 -1
- package/dist/core/delegation/worker-task-label.d.ts +3 -0
- package/dist/core/delegation/worker-task-label.d.ts.map +1 -0
- package/dist/core/delegation/worker-task-label.js +11 -0
- package/dist/core/delegation/worker-task-label.js.map +1 -0
- package/dist/core/doctor.d.ts +8 -0
- package/dist/core/doctor.d.ts.map +1 -1
- package/dist/core/doctor.js +32 -1
- package/dist/core/doctor.js.map +1 -1
- package/dist/core/extension-import-authority.d.ts +6 -0
- package/dist/core/extension-import-authority.d.ts.map +1 -0
- package/dist/core/extension-import-authority.js +10 -0
- package/dist/core/extension-import-authority.js.map +1 -0
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/loader.d.ts +5 -1
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +52 -18
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +3 -0
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +20 -5
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/stale-context.d.ts +2 -0
- package/dist/core/extensions/stale-context.d.ts.map +1 -0
- package/dist/core/extensions/stale-context.js +2 -0
- package/dist/core/extensions/stale-context.js.map +1 -0
- package/dist/core/extensions/storage.d.ts +8 -0
- package/dist/core/extensions/storage.d.ts.map +1 -0
- package/dist/core/extensions/storage.js +28 -0
- package/dist/core/extensions/storage.js.map +1 -0
- package/dist/core/extensions/types.d.ts +78 -21
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/failure-corpus.d.ts +1 -15
- package/dist/core/failure-corpus.d.ts.map +1 -1
- package/dist/core/failure-corpus.js +9 -37
- package/dist/core/failure-corpus.js.map +1 -1
- package/dist/core/foreground-recovery-controller.d.ts +53 -0
- package/dist/core/foreground-recovery-controller.d.ts.map +1 -0
- package/dist/core/foreground-recovery-controller.js +111 -0
- package/dist/core/foreground-recovery-controller.js.map +1 -0
- package/dist/core/gateways/channel-provider.d.ts +3 -0
- package/dist/core/gateways/channel-provider.d.ts.map +1 -1
- package/dist/core/gateways/channel-provider.js +31 -6
- package/dist/core/gateways/channel-provider.js.map +1 -1
- package/dist/core/goal-loop-controller.d.ts +14 -9
- package/dist/core/goal-loop-controller.d.ts.map +1 -1
- package/dist/core/goal-loop-controller.js +47 -75
- package/dist/core/goal-loop-controller.js.map +1 -1
- package/dist/core/goals/compact-goal-context.d.ts +11 -0
- package/dist/core/goals/compact-goal-context.d.ts.map +1 -0
- package/dist/core/goals/compact-goal-context.js +59 -0
- package/dist/core/goals/compact-goal-context.js.map +1 -0
- package/dist/core/goals/goal-acceptance.d.ts +11 -0
- package/dist/core/goals/goal-acceptance.d.ts.map +1 -0
- package/dist/core/goals/goal-acceptance.js +27 -0
- package/dist/core/goals/goal-acceptance.js.map +1 -0
- package/dist/core/goals/goal-auto-continue-controller.d.ts +28 -0
- package/dist/core/goals/goal-auto-continue-controller.d.ts.map +1 -0
- package/dist/core/goals/goal-auto-continue-controller.js +90 -0
- package/dist/core/goals/goal-auto-continue-controller.js.map +1 -0
- package/dist/core/goals/goal-continuation-controller.d.ts +2 -2
- package/dist/core/goals/goal-continuation-controller.d.ts.map +1 -1
- package/dist/core/goals/goal-continuation-controller.js +52 -11
- package/dist/core/goals/goal-continuation-controller.js.map +1 -1
- package/dist/core/goals/goal-continuation-defaults.d.ts +4 -29
- package/dist/core/goals/goal-continuation-defaults.d.ts.map +1 -1
- package/dist/core/goals/goal-continuation-defaults.js +4 -32
- package/dist/core/goals/goal-continuation-defaults.js.map +1 -1
- package/dist/core/goals/goal-continuation-prompt.d.ts +8 -18
- package/dist/core/goals/goal-continuation-prompt.d.ts.map +1 -1
- package/dist/core/goals/goal-continuation-prompt.js +9 -179
- package/dist/core/goals/goal-continuation-prompt.js.map +1 -1
- package/dist/core/goals/goal-lifecycle.d.ts +43 -0
- package/dist/core/goals/goal-lifecycle.d.ts.map +1 -0
- package/dist/core/goals/goal-lifecycle.js +102 -0
- package/dist/core/goals/goal-lifecycle.js.map +1 -0
- package/dist/core/goals/goal-record.d.ts +17 -0
- package/dist/core/goals/goal-record.d.ts.map +1 -0
- package/dist/core/goals/goal-record.js +31 -0
- package/dist/core/goals/goal-record.js.map +1 -0
- package/dist/core/goals/goal-runtime-snapshot.d.ts +11 -9
- package/dist/core/goals/goal-runtime-snapshot.d.ts.map +1 -1
- package/dist/core/goals/goal-runtime-snapshot.js +10 -8
- package/dist/core/goals/goal-runtime-snapshot.js.map +1 -1
- package/dist/core/goals/goal-session-controller.d.ts +42 -0
- package/dist/core/goals/goal-session-controller.d.ts.map +1 -0
- package/dist/core/goals/goal-session-controller.js +128 -0
- package/dist/core/goals/goal-session-controller.js.map +1 -0
- package/dist/core/goals/goal-state.d.ts +46 -25
- package/dist/core/goals/goal-state.d.ts.map +1 -1
- package/dist/core/goals/goal-state.js +91 -24
- package/dist/core/goals/goal-state.js.map +1 -1
- package/dist/core/goals/goal-tool-core.d.ts +9 -10
- package/dist/core/goals/goal-tool-core.d.ts.map +1 -1
- package/dist/core/goals/goal-tool-core.js +60 -75
- package/dist/core/goals/goal-tool-core.js.map +1 -1
- package/dist/core/goals/session-goal-state.d.ts +20 -12
- package/dist/core/goals/session-goal-state.d.ts.map +1 -1
- package/dist/core/goals/session-goal-state.js +133 -33
- package/dist/core/goals/session-goal-state.js.map +1 -1
- package/dist/core/human-input-controller.d.ts +47 -0
- package/dist/core/human-input-controller.d.ts.map +1 -0
- package/dist/core/human-input-controller.js +181 -0
- package/dist/core/human-input-controller.js.map +1 -0
- package/dist/core/human-input.d.ts +100 -0
- package/dist/core/human-input.d.ts.map +1 -0
- package/dist/core/human-input.js +362 -0
- package/dist/core/human-input.js.map +1 -0
- package/dist/core/index.d.ts +9 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +9 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/{telemetry.d.ts → install-telemetry.d.ts} +1 -1
- package/dist/core/install-telemetry.d.ts.map +1 -0
- package/dist/core/{telemetry.js → install-telemetry.js} +1 -1
- package/dist/core/install-telemetry.js.map +1 -0
- package/dist/core/keybindings.d.ts +17 -1
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +24 -6
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/learning/learning-audit.d.ts +2 -4
- package/dist/core/learning/learning-audit.d.ts.map +1 -1
- package/dist/core/learning/learning-audit.js +9 -29
- package/dist/core/learning/learning-audit.js.map +1 -1
- package/dist/core/learning/learning-gate.d.ts.map +1 -1
- package/dist/core/learning/learning-gate.js +1 -6
- package/dist/core/learning/learning-gate.js.map +1 -1
- package/dist/core/learning/session-learning-decision.d.ts +2 -4
- package/dist/core/learning/session-learning-decision.d.ts.map +1 -1
- package/dist/core/learning/session-learning-decision.js +9 -29
- package/dist/core/learning/session-learning-decision.js.map +1 -1
- package/dist/core/local-runtime-controller.d.ts +1 -1
- package/dist/core/local-runtime-controller.d.ts.map +1 -1
- package/dist/core/local-runtime-controller.js.map +1 -1
- package/dist/core/memory-controller.d.ts.map +1 -1
- package/dist/core/memory-controller.js +4 -4
- package/dist/core/memory-controller.js.map +1 -1
- package/dist/core/model-capability.d.ts +0 -19
- package/dist/core/model-capability.d.ts.map +1 -1
- package/dist/core/model-capability.js +1 -19
- package/dist/core/model-capability.js.map +1 -1
- package/dist/core/model-registry.d.ts +6 -1
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +13 -5
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver.d.ts +17 -2
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +38 -25
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/model-router/intent-classifier.d.ts +1 -4
- package/dist/core/model-router/intent-classifier.d.ts.map +1 -1
- package/dist/core/model-router/intent-classifier.js +1 -156
- package/dist/core/model-router/intent-classifier.js.map +1 -1
- package/dist/core/model-router-controller.d.ts +1 -1
- package/dist/core/model-router-controller.d.ts.map +1 -1
- package/dist/core/model-router-controller.js +2 -2
- package/dist/core/model-router-controller.js.map +1 -1
- package/dist/core/model-selection-controller.d.ts +5 -5
- package/dist/core/model-selection-controller.d.ts.map +1 -1
- package/dist/core/model-selection-controller.js.map +1 -1
- package/dist/core/model-tool-protocol.d.ts +23 -0
- package/dist/core/model-tool-protocol.d.ts.map +1 -0
- package/dist/core/model-tool-protocol.js +43 -0
- package/dist/core/model-tool-protocol.js.map +1 -0
- package/dist/core/models/adaptation-store.d.ts +4 -6
- package/dist/core/models/adaptation-store.d.ts.map +1 -1
- package/dist/core/models/adaptation-store.js +95 -83
- package/dist/core/models/adaptation-store.js.map +1 -1
- package/dist/core/models/fitness-store.d.ts +2 -12
- package/dist/core/models/fitness-store.d.ts.map +1 -1
- package/dist/core/models/fitness-store.js +84 -57
- package/dist/core/models/fitness-store.js.map +1 -1
- package/dist/core/models/host-state-store.d.ts +34 -0
- package/dist/core/models/host-state-store.d.ts.map +1 -0
- package/dist/core/models/host-state-store.js +86 -0
- package/dist/core/models/host-state-store.js.map +1 -0
- package/dist/core/orchestration/agent-resume.d.ts +24 -0
- package/dist/core/orchestration/agent-resume.d.ts.map +1 -0
- package/dist/core/orchestration/agent-resume.js +90 -0
- package/dist/core/orchestration/agent-resume.js.map +1 -0
- package/dist/core/orchestration/capability-gateway.d.ts +61 -0
- package/dist/core/orchestration/capability-gateway.d.ts.map +1 -0
- package/dist/core/orchestration/capability-gateway.js +152 -0
- package/dist/core/orchestration/capability-gateway.js.map +1 -0
- package/dist/core/orchestration/contracts.d.ts +343 -0
- package/dist/core/orchestration/contracts.d.ts.map +1 -0
- package/dist/core/orchestration/contracts.js +135 -0
- package/dist/core/orchestration/contracts.js.map +1 -0
- package/dist/core/orchestration/delegation-ledger.d.ts +56 -0
- package/dist/core/orchestration/delegation-ledger.d.ts.map +1 -0
- package/dist/core/orchestration/delegation-ledger.js +200 -0
- package/dist/core/orchestration/delegation-ledger.js.map +1 -0
- package/dist/core/orchestration/event-store.d.ts +83 -0
- package/dist/core/orchestration/event-store.d.ts.map +1 -0
- package/dist/core/orchestration/event-store.js +560 -0
- package/dist/core/orchestration/event-store.js.map +1 -0
- package/dist/core/orchestration/lane-tool-manifests.d.ts +9 -0
- package/dist/core/orchestration/lane-tool-manifests.d.ts.map +1 -0
- package/dist/core/orchestration/lane-tool-manifests.js +37 -0
- package/dist/core/orchestration/lane-tool-manifests.js.map +1 -0
- package/dist/core/orchestration/model-binding.d.ts +15 -0
- package/dist/core/orchestration/model-binding.d.ts.map +1 -0
- package/dist/core/orchestration/model-binding.js +29 -0
- package/dist/core/orchestration/model-binding.js.map +1 -0
- package/dist/core/orchestration/policy-compiler.d.ts +49 -0
- package/dist/core/orchestration/policy-compiler.d.ts.map +1 -0
- package/dist/core/orchestration/policy-compiler.js +191 -0
- package/dist/core/orchestration/policy-compiler.js.map +1 -0
- package/dist/core/orchestration/policy-gate.d.ts +18 -0
- package/dist/core/orchestration/policy-gate.d.ts.map +1 -0
- package/dist/core/orchestration/policy-gate.js +24 -0
- package/dist/core/orchestration/policy-gate.js.map +1 -0
- package/dist/core/orchestration/profile-registry.d.ts +51 -0
- package/dist/core/orchestration/profile-registry.d.ts.map +1 -0
- package/dist/core/orchestration/profile-registry.js +393 -0
- package/dist/core/orchestration/profile-registry.js.map +1 -0
- package/dist/core/orchestration/profile-store.d.ts +31 -0
- package/dist/core/orchestration/profile-store.d.ts.map +1 -0
- package/dist/core/orchestration/profile-store.js +136 -0
- package/dist/core/orchestration/profile-store.js.map +1 -0
- package/dist/core/orchestration/risk-budget.d.ts +9 -0
- package/dist/core/orchestration/risk-budget.d.ts.map +1 -0
- package/dist/core/orchestration/risk-budget.js +48 -0
- package/dist/core/orchestration/risk-budget.js.map +1 -0
- package/dist/core/orchestration/task-runtime.d.ts +168 -0
- package/dist/core/orchestration/task-runtime.d.ts.map +1 -0
- package/dist/core/orchestration/task-runtime.js +1600 -0
- package/dist/core/orchestration/task-runtime.js.map +1 -0
- package/dist/core/orchestration/work-state-projection.d.ts +32 -0
- package/dist/core/orchestration/work-state-projection.d.ts.map +1 -0
- package/dist/core/orchestration/work-state-projection.js +116 -0
- package/dist/core/orchestration/work-state-projection.js.map +1 -0
- package/dist/core/orchestration/worker-execution-contract.d.ts +21 -0
- package/dist/core/orchestration/worker-execution-contract.d.ts.map +1 -0
- package/dist/core/orchestration/worker-execution-contract.js +179 -0
- package/dist/core/orchestration/worker-execution-contract.js.map +1 -0
- package/dist/core/orchestration/worker-result-adapter.d.ts +21 -0
- package/dist/core/orchestration/worker-result-adapter.d.ts.map +1 -0
- package/dist/core/orchestration/worker-result-adapter.js +109 -0
- package/dist/core/orchestration/worker-result-adapter.js.map +1 -0
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +20 -3
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/process-identity.d.ts +11 -0
- package/dist/core/process-identity.d.ts.map +1 -0
- package/dist/core/process-identity.js +26 -0
- package/dist/core/process-identity.js.map +1 -0
- package/dist/core/process-matrix/codes.d.ts +14 -3
- package/dist/core/process-matrix/codes.d.ts.map +1 -1
- package/dist/core/process-matrix/codes.js.map +1 -1
- package/dist/core/process-matrix/resume-launcher.d.ts +26 -0
- package/dist/core/process-matrix/resume-launcher.d.ts.map +1 -0
- package/dist/core/process-matrix/resume-launcher.js +62 -0
- package/dist/core/process-matrix/resume-launcher.js.map +1 -0
- package/dist/core/process-matrix/runtime.d.ts +37 -22
- package/dist/core/process-matrix/runtime.d.ts.map +1 -1
- package/dist/core/process-matrix/runtime.js +399 -76
- package/dist/core/process-matrix/runtime.js.map +1 -1
- package/dist/core/process-matrix/store.d.ts +5 -2
- package/dist/core/process-matrix/store.d.ts.map +1 -1
- package/dist/core/process-matrix/store.js +123 -14
- package/dist/core/process-matrix/store.js.map +1 -1
- package/dist/core/process-matrix/supervisor.d.ts +10 -7
- package/dist/core/process-matrix/supervisor.d.ts.map +1 -1
- package/dist/core/process-matrix/supervisor.js +45 -14
- package/dist/core/process-matrix/supervisor.js.map +1 -1
- package/dist/core/profile-filter-controller.d.ts +8 -1
- package/dist/core/profile-filter-controller.d.ts.map +1 -1
- package/dist/core/profile-filter-controller.js +23 -5
- package/dist/core/profile-filter-controller.js.map +1 -1
- package/dist/core/profile-registry.d.ts.map +1 -1
- package/dist/core/profile-registry.js +6 -8
- package/dist/core/profile-registry.js.map +1 -1
- package/dist/core/prompt-templates.d.ts +1 -0
- package/dist/core/prompt-templates.d.ts.map +1 -1
- package/dist/core/prompt-templates.js +18 -29
- package/dist/core/prompt-templates.js.map +1 -1
- package/dist/core/reflection-controller.d.ts +5 -5
- package/dist/core/reflection-controller.d.ts.map +1 -1
- package/dist/core/reflection-controller.js +5 -2
- package/dist/core/reflection-controller.js.map +1 -1
- package/dist/core/reload-blockers.d.ts.map +1 -1
- package/dist/core/reload-blockers.js +6 -8
- package/dist/core/reload-blockers.js.map +1 -1
- package/dist/core/request-auth.d.ts +7 -0
- package/dist/core/request-auth.d.ts.map +1 -0
- package/dist/core/request-auth.js +8 -0
- package/dist/core/request-auth.js.map +1 -0
- package/dist/core/research/evidence-bundle.d.ts.map +1 -1
- package/dist/core/research/evidence-bundle.js +1 -6
- package/dist/core/research/evidence-bundle.js.map +1 -1
- package/dist/core/research/lane-model-resolver.d.ts +33 -0
- package/dist/core/research/lane-model-resolver.d.ts.map +1 -0
- package/dist/core/research/lane-model-resolver.js +65 -0
- package/dist/core/research/lane-model-resolver.js.map +1 -0
- package/dist/core/research/model-fitness-controller.d.ts +38 -0
- package/dist/core/research/model-fitness-controller.d.ts.map +1 -0
- package/dist/core/research/model-fitness-controller.js +106 -0
- package/dist/core/research/model-fitness-controller.js.map +1 -0
- package/dist/core/research/model-fitness.d.ts +1 -1
- package/dist/core/research/model-fitness.d.ts.map +1 -1
- package/dist/core/research/model-fitness.js +4 -4
- package/dist/core/research/model-fitness.js.map +1 -1
- package/dist/core/research/research-gate.d.ts.map +1 -1
- package/dist/core/research/research-gate.js +7 -7
- package/dist/core/research/research-gate.js.map +1 -1
- package/dist/core/research/research-lane-controller.d.ts +62 -0
- package/dist/core/research/research-lane-controller.d.ts.map +1 -0
- package/dist/core/research/research-lane-controller.js +292 -0
- package/dist/core/research/research-lane-controller.js.map +1 -0
- package/dist/core/research/session-evidence-bundle.d.ts +2 -4
- package/dist/core/research/session-evidence-bundle.d.ts.map +1 -1
- package/dist/core/research/session-evidence-bundle.js +10 -46
- package/dist/core/research/session-evidence-bundle.js.map +1 -1
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +23 -8
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/risk-classifier.d.ts +6 -0
- package/dist/core/risk-classifier.d.ts.map +1 -0
- package/dist/core/risk-classifier.js +233 -0
- package/dist/core/risk-classifier.js.map +1 -0
- package/dist/core/runtime-builder.d.ts +41 -23
- package/dist/core/runtime-builder.d.ts.map +1 -1
- package/dist/core/runtime-builder.js +365 -253
- package/dist/core/runtime-builder.js.map +1 -1
- package/dist/core/sdk.d.ts +6 -3
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +68 -25
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/secrets/credential-exposure-guard.d.ts +9 -0
- package/dist/core/secrets/credential-exposure-guard.d.ts.map +1 -0
- package/dist/core/secrets/credential-exposure-guard.js +241 -0
- package/dist/core/secrets/credential-exposure-guard.js.map +1 -0
- package/dist/core/secrets/secret-dotenv.d.ts +27 -0
- package/dist/core/secrets/secret-dotenv.d.ts.map +1 -0
- package/dist/core/secrets/secret-dotenv.js +183 -0
- package/dist/core/secrets/secret-dotenv.js.map +1 -0
- package/dist/core/secrets/secret-vault-format.d.ts +112 -0
- package/dist/core/secrets/secret-vault-format.d.ts.map +1 -0
- package/dist/core/secrets/secret-vault-format.js +397 -0
- package/dist/core/secrets/secret-vault-format.js.map +1 -0
- package/dist/core/secrets/secret-vault.d.ts +72 -0
- package/dist/core/secrets/secret-vault.d.ts.map +1 -0
- package/dist/core/secrets/secret-vault.js +671 -0
- package/dist/core/secrets/secret-vault.js.map +1 -0
- package/dist/core/session-analytics.d.ts +4 -23
- package/dist/core/session-analytics.d.ts.map +1 -1
- package/dist/core/session-analytics.js +67 -70
- package/dist/core/session-analytics.js.map +1 -1
- package/dist/core/session-image-store.d.ts +33 -0
- package/dist/core/session-image-store.d.ts.map +1 -0
- package/dist/core/session-image-store.js +283 -0
- package/dist/core/session-image-store.js.map +1 -0
- package/dist/core/session-role.d.ts +11 -4
- package/dist/core/session-role.d.ts.map +1 -1
- package/dist/core/session-role.js +24 -5
- package/dist/core/session-role.js.map +1 -1
- package/dist/core/session-snapshot.d.ts +34 -0
- package/dist/core/session-snapshot.d.ts.map +1 -0
- package/dist/core/session-snapshot.js +68 -0
- package/dist/core/session-snapshot.js.map +1 -0
- package/dist/core/session-supervision-runtime.d.ts +31 -0
- package/dist/core/session-supervision-runtime.d.ts.map +1 -0
- package/dist/core/session-supervision-runtime.js +97 -0
- package/dist/core/session-supervision-runtime.js.map +1 -0
- package/dist/core/session-tree-navigator.d.ts +4 -6
- package/dist/core/session-tree-navigator.d.ts.map +1 -1
- package/dist/core/session-tree-navigator.js +4 -1
- package/dist/core/session-tree-navigator.js.map +1 -1
- package/dist/core/settings-manager.d.ts +10 -5
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +81 -29
- 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 +2 -2
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/tasks/session-task-state.d.ts +2 -4
- package/dist/core/tasks/session-task-state.d.ts.map +1 -1
- package/dist/core/tasks/session-task-state.js +10 -28
- package/dist/core/tasks/session-task-state.js.map +1 -1
- package/dist/core/tasks/task-projection.d.ts +20 -0
- package/dist/core/tasks/task-projection.d.ts.map +1 -0
- package/dist/core/tasks/task-projection.js +47 -0
- package/dist/core/tasks/task-projection.js.map +1 -0
- package/dist/core/tasks/task-state.d.ts +4 -0
- package/dist/core/tasks/task-state.d.ts.map +1 -1
- package/dist/core/tasks/task-state.js +28 -11
- package/dist/core/tasks/task-state.js.map +1 -1
- package/dist/core/tool-capability-policy.d.ts +13 -0
- package/dist/core/tool-capability-policy.d.ts.map +1 -0
- package/dist/core/tool-capability-policy.js +86 -0
- package/dist/core/tool-capability-policy.js.map +1 -0
- package/dist/core/tool-gate-controller.d.ts.map +1 -1
- package/dist/core/tool-gate-controller.js +8 -2
- package/dist/core/tool-gate-controller.js.map +1 -1
- package/dist/core/tool-protocol-controller.d.ts +89 -0
- package/dist/core/tool-protocol-controller.d.ts.map +1 -0
- package/dist/core/tool-protocol-controller.js +512 -0
- package/dist/core/tool-protocol-controller.js.map +1 -0
- package/dist/core/tool-recovery-log-records.d.ts +2 -3
- package/dist/core/tool-recovery-log-records.d.ts.map +1 -1
- package/dist/core/tool-recovery-log-records.js +9 -35
- package/dist/core/tool-recovery-log-records.js.map +1 -1
- package/dist/core/tool-recovery-stats.d.ts +21 -1
- package/dist/core/tool-recovery-stats.d.ts.map +1 -1
- package/dist/core/tool-recovery-stats.js.map +1 -1
- package/dist/core/tool-selection/tool-performance-store.d.ts +3 -7
- package/dist/core/tool-selection/tool-performance-store.d.ts.map +1 -1
- package/dist/core/tool-selection/tool-performance-store.js +97 -138
- package/dist/core/tool-selection/tool-performance-store.js.map +1 -1
- package/dist/core/tools/ask-question.d.ts +124 -0
- package/dist/core/tools/ask-question.d.ts.map +1 -0
- package/dist/core/tools/ask-question.js +693 -0
- package/dist/core/tools/ask-question.js.map +1 -0
- package/dist/core/tools/bash.d.ts +5 -0
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +59 -5
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/delegate-status.d.ts +31 -3
- package/dist/core/tools/delegate-status.d.ts.map +1 -1
- package/dist/core/tools/delegate-status.js +148 -29
- package/dist/core/tools/delegate-status.js.map +1 -1
- package/dist/core/tools/delegate.d.ts +15 -13
- package/dist/core/tools/delegate.d.ts.map +1 -1
- package/dist/core/tools/delegate.js +106 -23
- package/dist/core/tools/delegate.js.map +1 -1
- package/dist/core/tools/extensionify.d.ts.map +1 -1
- package/dist/core/tools/extensionify.js +1 -0
- package/dist/core/tools/extensionify.js.map +1 -1
- package/dist/core/tools/git-filter.d.ts +1 -8
- package/dist/core/tools/git-filter.d.ts.map +1 -1
- package/dist/core/tools/git-filter.js +2 -63
- package/dist/core/tools/git-filter.js.map +1 -1
- package/dist/core/tools/goal.d.ts +10 -8
- package/dist/core/tools/goal.d.ts.map +1 -1
- package/dist/core/tools/goal.js +106 -28
- package/dist/core/tools/goal.js.map +1 -1
- package/dist/core/tools/index.d.ts +1 -0
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js +1 -0
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/model-fitness.d.ts.map +1 -1
- package/dist/core/tools/model-fitness.js +2 -2
- package/dist/core/tools/model-fitness.js.map +1 -1
- package/dist/core/tools/orchestration-panel.d.ts +40 -0
- package/dist/core/tools/orchestration-panel.d.ts.map +1 -0
- package/dist/core/tools/orchestration-panel.js +124 -0
- package/dist/core/tools/orchestration-panel.js.map +1 -0
- package/dist/core/tools/output-accumulator.d.ts +11 -0
- package/dist/core/tools/output-accumulator.d.ts.map +1 -1
- package/dist/core/tools/output-accumulator.js +36 -3
- package/dist/core/tools/output-accumulator.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 +3 -1
- package/dist/core/tools/python.js.map +1 -1
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +1 -1
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/run-process.d.ts +26 -0
- package/dist/core/tools/run-process.d.ts.map +1 -0
- package/dist/core/tools/run-process.js +138 -0
- package/dist/core/tools/run-process.js.map +1 -0
- package/dist/core/tools/search-command-guard.d.ts +14 -0
- package/dist/core/tools/search-command-guard.d.ts.map +1 -0
- package/dist/core/tools/search-command-guard.js +333 -0
- package/dist/core/tools/search-command-guard.js.map +1 -0
- package/dist/core/tools/secret-store.d.ts +38 -0
- package/dist/core/tools/secret-store.d.ts.map +1 -0
- package/dist/core/tools/secret-store.js +412 -0
- package/dist/core/tools/secret-store.js.map +1 -0
- package/dist/core/tools/shell-command-parser.d.ts +16 -0
- package/dist/core/tools/shell-command-parser.d.ts.map +1 -0
- package/dist/core/tools/shell-command-parser.js +113 -0
- package/dist/core/tools/shell-command-parser.js.map +1 -0
- package/dist/core/tools/task-steps.d.ts +2 -0
- package/dist/core/tools/task-steps.d.ts.map +1 -1
- package/dist/core/tools/task-steps.js +99 -0
- package/dist/core/tools/task-steps.js.map +1 -1
- package/dist/core/tools/tmux-dispatch.d.ts +3 -5
- package/dist/core/tools/tmux-dispatch.d.ts.map +1 -1
- package/dist/core/tools/tmux-dispatch.js +4 -4
- package/dist/core/tools/tmux-dispatch.js.map +1 -1
- package/dist/core/tools/windows-shell-engine.d.ts.map +1 -1
- package/dist/core/tools/windows-shell-engine.js +4 -6
- package/dist/core/tools/windows-shell-engine.js.map +1 -1
- package/dist/core/util/atomic-file.d.ts +6 -2
- package/dist/core/util/atomic-file.d.ts.map +1 -1
- package/dist/core/util/atomic-file.js +4 -4
- package/dist/core/util/atomic-file.js.map +1 -1
- package/dist/core/util/bounded-jsonl.d.ts +10 -0
- package/dist/core/util/bounded-jsonl.d.ts.map +1 -0
- package/dist/core/util/bounded-jsonl.js +75 -0
- package/dist/core/util/bounded-jsonl.js.map +1 -0
- package/dist/core/util/value-guards.d.ts +5 -0
- package/dist/core/util/value-guards.d.ts.map +1 -0
- package/dist/core/util/value-guards.js +12 -0
- package/dist/core/util/value-guards.js.map +1 -0
- package/dist/core/worktree-sync/store.d.ts +3 -3
- package/dist/core/worktree-sync/store.d.ts.map +1 -1
- package/dist/core/worktree-sync/store.js +10 -5
- package/dist/core/worktree-sync/store.js.map +1 -1
- package/dist/index.d.ts +15 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -3
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +149 -51
- package/dist/main.js.map +1 -1
- package/dist/migrations.d.ts +4 -6
- package/dist/migrations.d.ts.map +1 -1
- package/dist/migrations.js +186 -28
- package/dist/migrations.js.map +1 -1
- package/dist/modes/interactive/auth-dialogs-controller.d.ts +4 -0
- package/dist/modes/interactive/auth-dialogs-controller.d.ts.map +1 -1
- package/dist/modes/interactive/auth-dialogs-controller.js +60 -1
- package/dist/modes/interactive/auth-dialogs-controller.js.map +1 -1
- package/dist/modes/interactive/clipboard-input.d.ts +7 -1
- package/dist/modes/interactive/clipboard-input.d.ts.map +1 -1
- package/dist/modes/interactive/clipboard-input.js +44 -6
- package/dist/modes/interactive/clipboard-input.js.map +1 -1
- package/dist/modes/interactive/components/activity-lane.d.ts +55 -0
- package/dist/modes/interactive/components/activity-lane.d.ts.map +1 -0
- package/dist/modes/interactive/components/activity-lane.js +304 -0
- package/dist/modes/interactive/components/activity-lane.js.map +1 -0
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +19 -10
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/expandable-text.d.ts +12 -0
- package/dist/modes/interactive/components/expandable-text.d.ts.map +1 -0
- package/dist/modes/interactive/components/expandable-text.js +17 -0
- package/dist/modes/interactive/components/expandable-text.js.map +1 -0
- package/dist/modes/interactive/components/extension-editor.d.ts +15 -1
- package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-editor.js +30 -21
- package/dist/modes/interactive/components/extension-editor.js.map +1 -1
- package/dist/modes/interactive/components/extension-input.d.ts +1 -0
- package/dist/modes/interactive/components/extension-input.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-input.js +6 -1
- package/dist/modes/interactive/components/extension-input.js.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.d.ts +2 -2
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.js +23 -14
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +6 -6
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts +19 -11
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +53 -20
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/tool-group.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-group.js +3 -0
- package/dist/modes/interactive/components/tool-group.js.map +1 -1
- package/dist/modes/interactive/components/usage-action-selector.d.ts +16 -0
- package/dist/modes/interactive/components/usage-action-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/usage-action-selector.js +46 -0
- package/dist/modes/interactive/components/usage-action-selector.js.map +1 -0
- package/dist/modes/interactive/config-backup.d.ts.map +1 -1
- package/dist/modes/interactive/config-backup.js +5 -4
- package/dist/modes/interactive/config-backup.js.map +1 -1
- package/dist/modes/interactive/extension-ui-host.d.ts +14 -0
- package/dist/modes/interactive/extension-ui-host.d.ts.map +1 -1
- package/dist/modes/interactive/extension-ui-host.js +77 -15
- package/dist/modes/interactive/extension-ui-host.js.map +1 -1
- package/dist/modes/interactive/external-editor.d.ts +15 -0
- package/dist/modes/interactive/external-editor.d.ts.map +1 -1
- package/dist/modes/interactive/external-editor.js +27 -19
- package/dist/modes/interactive/external-editor.js.map +1 -1
- package/dist/modes/interactive/history-reload-math.d.ts +6 -2
- package/dist/modes/interactive/history-reload-math.d.ts.map +1 -1
- package/dist/modes/interactive/history-reload-math.js +10 -5
- package/dist/modes/interactive/history-reload-math.js.map +1 -1
- package/dist/modes/interactive/interactive-event-controller.d.ts +74 -0
- package/dist/modes/interactive/interactive-event-controller.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-event-controller.js +328 -0
- package/dist/modes/interactive/interactive-event-controller.js.map +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts +22 -24
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +245 -595
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/key-handlers.d.ts.map +1 -1
- package/dist/modes/interactive/key-handlers.js +1 -1
- package/dist/modes/interactive/key-handlers.js.map +1 -1
- package/dist/modes/interactive/loaded-resources-view.d.ts +20 -0
- package/dist/modes/interactive/loaded-resources-view.d.ts.map +1 -0
- package/dist/modes/interactive/loaded-resources-view.js +147 -0
- package/dist/modes/interactive/loaded-resources-view.js.map +1 -0
- package/dist/modes/interactive/profile-menu-controller.d.ts.map +1 -1
- package/dist/modes/interactive/profile-menu-controller.js +7 -7
- package/dist/modes/interactive/profile-menu-controller.js.map +1 -1
- package/dist/modes/interactive/report-commands.d.ts.map +1 -1
- package/dist/modes/interactive/report-commands.js +21 -0
- package/dist/modes/interactive/report-commands.js.map +1 -1
- package/dist/modes/interactive/resource-display.d.ts.map +1 -1
- package/dist/modes/interactive/resource-display.js +8 -2
- package/dist/modes/interactive/resource-display.js.map +1 -1
- package/dist/modes/interactive/resource-shell-commands.d.ts +1 -5
- package/dist/modes/interactive/resource-shell-commands.d.ts.map +1 -1
- package/dist/modes/interactive/resource-shell-commands.js +0 -5
- package/dist/modes/interactive/resource-shell-commands.js.map +1 -1
- package/dist/modes/interactive/session-flow-commands.d.ts +27 -8
- package/dist/modes/interactive/session-flow-commands.d.ts.map +1 -1
- package/dist/modes/interactive/session-flow-commands.js +150 -64
- package/dist/modes/interactive/session-flow-commands.js.map +1 -1
- package/dist/modes/interactive/session-io-commands.d.ts.map +1 -1
- package/dist/modes/interactive/session-io-commands.js +16 -6
- package/dist/modes/interactive/session-io-commands.js.map +1 -1
- package/dist/modes/interactive/session-replacement-errors.d.ts +7 -0
- package/dist/modes/interactive/session-replacement-errors.d.ts.map +1 -0
- package/dist/modes/interactive/session-replacement-errors.js +15 -0
- package/dist/modes/interactive/session-replacement-errors.js.map +1 -0
- package/dist/modes/interactive/startup-checks.d.ts.map +1 -1
- package/dist/modes/interactive/startup-checks.js +1 -1
- package/dist/modes/interactive/startup-checks.js.map +1 -1
- package/dist/modes/interactive/usage-commands.d.ts +34 -0
- package/dist/modes/interactive/usage-commands.d.ts.map +1 -0
- package/dist/modes/interactive/usage-commands.js +225 -0
- package/dist/modes/interactive/usage-commands.js.map +1 -0
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +82 -23
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +15 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js +138 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/utils/clipboard-image.d.ts.map +1 -1
- package/dist/utils/clipboard-image.js +2 -13
- package/dist/utils/clipboard-image.js.map +1 -1
- package/dist/utils/clipboard-native.d.ts +1 -0
- package/dist/utils/clipboard-native.d.ts.map +1 -1
- package/dist/utils/clipboard-native.js.map +1 -1
- package/dist/utils/clipboard.d.ts +1 -0
- package/dist/utils/clipboard.d.ts.map +1 -1
- package/dist/utils/clipboard.js +52 -1
- package/dist/utils/clipboard.js.map +1 -1
- package/dist/utils/platform.d.ts +3 -0
- package/dist/utils/platform.d.ts.map +1 -0
- package/dist/utils/platform.js +8 -0
- package/dist/utils/platform.js.map +1 -0
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +5 -3
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/version-check.d.ts.map +1 -1
- package/dist/utils/version-check.js +3 -1
- package/dist/utils/version-check.js.map +1 -1
- package/dist/utils/work-directory.d.ts +11 -0
- package/dist/utils/work-directory.d.ts.map +1 -1
- package/dist/utils/work-directory.js +30 -9
- package/dist/utils/work-directory.js.map +1 -1
- package/docs/UI_POLISH_ORCHESTRATION.md +38 -0
- package/docs/UI_QUALITY_ORCHESTRATION.md +28 -0
- package/docs/docs.json +4 -0
- package/docs/extensions.md +62 -2
- package/docs/harness-architecture.md +156 -0
- package/docs/keybindings.md +11 -1
- package/docs/process-matrix.md +59 -26
- package/docs/providers.md +9 -1
- package/docs/rpc.md +45 -2
- package/docs/sessions.md +15 -0
- package/docs/settings.md +125 -11
- package/docs/task-steps.md +8 -0
- package/docs/telemetry.md +19 -0
- package/docs/tmux-agent-manager.md +10 -3
- package/docs/ui-reference/README.md +9 -0
- package/docs/ui-reference/orchestration-after.txt +14 -0
- package/docs/ui-reference/orchestration-before.txt +13 -0
- package/docs/ui-reference/orchestration-reference.txt +16 -0
- package/docs/usage.md +22 -2
- package/docs/work-directory.md +19 -8
- 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/question.ts +34 -245
- package/examples/extensions/questionnaire.ts +41 -407
- 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 +13 -13
- package/package.json +4 -4
- package/dist/core/delegation/session-worker-result.d.ts +0 -46
- package/dist/core/delegation/session-worker-result.d.ts.map +0 -1
- package/dist/core/delegation/session-worker-result.js +0 -113
- package/dist/core/delegation/session-worker-result.js.map +0 -1
- package/dist/core/delegation/worker-result.d.ts.map +0 -1
- package/dist/core/delegation/worker-result.js.map +0 -1
- package/dist/core/telemetry.d.ts.map +0 -1
- package/dist/core/telemetry.js.map +0 -1
|
@@ -2,7 +2,8 @@ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
|
2
2
|
import { dirname, relative, resolve } from "node:path";
|
|
3
3
|
import { validateToolArguments } from "@caupulican/pi-ai";
|
|
4
4
|
import { Type } from "typebox";
|
|
5
|
-
import {
|
|
5
|
+
import { safeRealpathSync } from "../autonomy/path-scope.js";
|
|
6
|
+
import { CapabilityGatewayDeniedError } from "../orchestration/capability-gateway.js";
|
|
6
7
|
const MAX_ACTIONS = 20;
|
|
7
8
|
const MAX_CONTENT_CHARS = 512 * 1024;
|
|
8
9
|
const workerActionSchema = Type.Union([
|
|
@@ -64,12 +65,27 @@ export function parseWorkerActions(raw, validation) {
|
|
|
64
65
|
}
|
|
65
66
|
export function applyWorkerActions(args) {
|
|
66
67
|
const report = { changedFiles: [], refused: [], failed: [] };
|
|
68
|
+
const manifests = new Map(args.toolManifests.map((manifest) => [manifest.toolName, manifest]));
|
|
67
69
|
for (const action of args.actions) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
+
const manifest = manifests.get(action.op);
|
|
71
|
+
if (!manifest) {
|
|
72
|
+
report.refused.push({
|
|
73
|
+
path: action.path,
|
|
74
|
+
reason: `${action.op} is not present in the compiled tool manifest`,
|
|
75
|
+
});
|
|
70
76
|
continue;
|
|
71
77
|
}
|
|
72
|
-
|
|
78
|
+
try {
|
|
79
|
+
args.gateway.authorizeToolCall(manifest, action.op, { path: action.path });
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
if (error instanceof CapabilityGatewayDeniedError) {
|
|
83
|
+
report.refused.push({ path: action.path, reason: `${error.reasonCode}: ${error.message}` });
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
throw error;
|
|
87
|
+
}
|
|
88
|
+
const target = safeRealpathSync(resolve(args.cwd, action.path));
|
|
73
89
|
const relativePath = relative(args.cwd, target).replaceAll("\\", "/");
|
|
74
90
|
try {
|
|
75
91
|
if (action.op === "write") {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker-actions.js","sourceRoot":"","sources":["../../../src/core/delegation/worker-actions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE/B,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAsB3E,MAAM,WAAW,GAAG,EAAE,CAAC;AACvB,MAAM,iBAAiB,GAAG,GAAG,GAAG,IAAI,CAAC;AAErC,MAAM,kBAAkB,GAAG,IAAI,CAAC,KAAK,CAAC;IACrC,IAAI,CAAC,MAAM,CAAC;QACX,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;QACzB,IAAI,EAAE,IAA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import { dirname, relative, resolve } from \"node:path\";\nimport type { Tool, ToolArgumentValidationOptions } from \"@caupulican/pi-ai\";\nimport { validateToolArguments } from \"@caupulican/pi-ai\";\nimport { Type } from \"typebox\";\nimport type { CapabilityEnvelope } from \"../autonomy/contracts.ts\";\nimport { isPathWithinEnvelope } from \"../autonomy/envelope-enforcement.ts\";\n\n/**\n * Code-writing workers (G2): the worker MODEL never touches the filesystem — it emits strict-JSON\n * actions, and this RUNNER-side module applies them deterministically through the capability\n * envelope's path scope. That keeps the structural-contract philosophy (a local model without\n * tool-calling templates can still write code) and makes enforcement execution-time, not\n * validation-only: an out-of-scope action is REFUSED with a reason, never silently dropped, and\n * refusals surface as blockers on the result.\n */\n\nexport interface WorkerAction {\n\top: \"write\" | \"edit\";\n\tpath: string;\n\t/** write: full file content. */\n\tcontent?: string;\n\t/** edit: exact string to replace (must occur in the file). */\n\told?: string;\n\t/** edit: replacement text. */\n\tnew?: string;\n}\n\nconst MAX_ACTIONS = 20;\nconst MAX_CONTENT_CHARS = 512 * 1024;\n\nconst workerActionSchema = Type.Union([\n\tType.Object({\n\t\top: Type.Literal(\"write\"),\n\t\tpath: Type.String({ minLength: 1 }),\n\t\tcontent: Type.String({ maxLength: MAX_CONTENT_CHARS }),\n\t}),\n\tType.Object({\n\t\top: Type.Literal(\"edit\"),\n\t\tpath: Type.String({ minLength: 1 }),\n\t\told: Type.String({ minLength: 1 }),\n\t\tnew: Type.String({ maxLength: MAX_CONTENT_CHARS }),\n\t}),\n]);\n\nconst workerActionsTool: Tool = {\n\tname: \"worker_actions\",\n\tdescription: \"Worker filesystem action list\",\n\tparameters: Type.Object({ actions: Type.Array(workerActionSchema) }),\n};\n\nfunction validateWorkerActions(raw: unknown, validation?: ToolArgumentValidationOptions): unknown[] {\n\ttry {\n\t\tconst validated = validateToolArguments(\n\t\t\tworkerActionsTool,\n\t\t\t{ type: \"toolCall\", id: \"worker-actions\", name: \"worker_actions\", arguments: { actions: raw } },\n\t\t\tvalidation,\n\t\t).actions;\n\t\treturn Array.isArray(validated) ? validated : [];\n\t} catch {\n\t\treturn [];\n\t}\n}\n\nfunction sanitizeWorkerActions(raw: readonly unknown[]): WorkerAction[] {\n\tconst actions: WorkerAction[] = [];\n\tfor (const entry of raw.slice(0, MAX_ACTIONS)) {\n\t\tif (!entry || typeof entry !== \"object\") continue;\n\t\tconst record = entry as Record<string, unknown>;\n\t\tif (record.op !== \"write\" && record.op !== \"edit\") continue;\n\t\tif (typeof record.path !== \"string\" || record.path.length === 0) continue;\n\t\tif (record.op === \"write\") {\n\t\t\tif (typeof record.content !== \"string\" || record.content.length > MAX_CONTENT_CHARS) continue;\n\t\t\tactions.push({ op: \"write\", path: record.path, content: record.content });\n\t\t} else {\n\t\t\tif (typeof record.old !== \"string\" || record.old.length === 0) continue;\n\t\t\tif (typeof record.new !== \"string\" || record.new.length > MAX_CONTENT_CHARS) continue;\n\t\t\tactions.push({ op: \"edit\", path: record.path, old: record.old, new: record.new });\n\t\t}\n\t}\n\treturn actions;\n}\n\nexport function parseWorkerActions(raw: unknown, validation?: ToolArgumentValidationOptions): WorkerAction[] {\n\tif (Array.isArray(raw)) return sanitizeWorkerActions(validateWorkerActions(sanitizeWorkerActions(raw), validation));\n\treturn sanitizeWorkerActions(validateWorkerActions(raw, validation));\n}\n\nexport interface AppliedActionsReport {\n\t/** Repo-relative paths actually changed. */\n\tchangedFiles: string[];\n\t/** Envelope-scope refusals (execution-time enforcement) — surfaced, never silent. */\n\trefused: Array<{ path: string; reason: string }>;\n\t/** Actions that were in scope but could not be applied (missing file, old-text not found). */\n\tfailed: Array<{ path: string; reason: string }>;\n}\n\nexport function applyWorkerActions(args: {\n\tactions: readonly WorkerAction[];\n\tenvelope: CapabilityEnvelope;\n\tcwd: string;\n}): AppliedActionsReport {\n\tconst report: AppliedActionsReport = { changedFiles: [], refused: [], failed: [] };\n\tfor (const action of args.actions) {\n\t\tif (!isPathWithinEnvelope(args.envelope, action.path, args.cwd)) {\n\t\t\treport.refused.push({ path: action.path, reason: `outside envelope ${args.envelope.id} path scope` });\n\t\t\tcontinue;\n\t\t}\n\t\tconst target = resolve(args.cwd, action.path);\n\t\tconst relativePath = relative(args.cwd, target).replaceAll(\"\\\\\", \"/\");\n\t\ttry {\n\t\t\tif (action.op === \"write\") {\n\t\t\t\tmkdirSync(dirname(target), { recursive: true });\n\t\t\t\twriteFileSync(target, action.content ?? \"\", \"utf-8\");\n\t\t\t} else {\n\t\t\t\tif (!existsSync(target)) {\n\t\t\t\t\treport.failed.push({ path: action.path, reason: \"file does not exist\" });\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tconst current = readFileSync(target, \"utf-8\");\n\t\t\t\tif (!action.old || !current.includes(action.old)) {\n\t\t\t\t\treport.failed.push({ path: action.path, reason: \"edit old-text not found in file\" });\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\twriteFileSync(\n\t\t\t\t\ttarget,\n\t\t\t\t\tcurrent.replace(action.old, () => action.new ?? \"\"),\n\t\t\t\t\t\"utf-8\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (!report.changedFiles.includes(relativePath)) report.changedFiles.push(relativePath);\n\t\t} catch (error) {\n\t\t\treport.failed.push({ path: action.path, reason: error instanceof Error ? error.message : String(error) });\n\t\t}\n\t}\n\treturn report;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"worker-actions.js","sourceRoot":"","sources":["../../../src/core/delegation/worker-actions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AA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AM,EAAE,OAAO,CAAC,CAAC;gBAC9C,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;oBAClD,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,iCAAiC,EAAE,CAAC,CAAC;oBACrF,SAAS;gBACV,CAAC;gBACD,aAAa,CACZ,MAAM,EACN,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,GAAG,IAAI,EAAE,CAAC,EACnD,OAAO,CACP,CAAC;YACH,CAAC;YACD,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,YAAY,CAAC;gBAAE,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QACzF,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAC3G,CAAC;IACF,CAAC;IACD,OAAO,MAAM,CAAC;AAAA,CACd","sourcesContent":["import { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { dirname, relative, resolve } from \"node:path\";\nimport type { Tool, ToolArgumentValidationOptions } from \"@caupulican/pi-ai\";\nimport { validateToolArguments } from \"@caupulican/pi-ai\";\nimport { Type } from \"typebox\";\nimport { safeRealpathSync } from \"../autonomy/path-scope.ts\";\nimport { type CapabilityGateway, CapabilityGatewayDeniedError } from \"../orchestration/capability-gateway.ts\";\nimport type { ToolCapabilityManifest } from \"../orchestration/contracts.ts\";\n\n/**\n * Code-writing workers (G2): the worker MODEL never touches the filesystem — it emits strict-JSON\n * actions, and this RUNNER-side module applies them deterministically through the compiled\n * execution grant. That keeps the structural-contract philosophy (a local model without\n * tool-calling templates can still write code) and makes enforcement execution-time, not\n * validation-only: an out-of-scope action is REFUSED with a reason, never silently dropped, and\n * refusals surface as blockers on the result.\n */\n\nexport interface WorkerAction {\n\top: \"write\" | \"edit\";\n\tpath: string;\n\t/** write: full file content. */\n\tcontent?: string;\n\t/** edit: exact string to replace (must occur in the file). */\n\told?: string;\n\t/** edit: replacement text. */\n\tnew?: string;\n}\n\nconst MAX_ACTIONS = 20;\nconst MAX_CONTENT_CHARS = 512 * 1024;\n\nconst workerActionSchema = Type.Union([\n\tType.Object({\n\t\top: Type.Literal(\"write\"),\n\t\tpath: Type.String({ minLength: 1 }),\n\t\tcontent: Type.String({ maxLength: MAX_CONTENT_CHARS }),\n\t}),\n\tType.Object({\n\t\top: Type.Literal(\"edit\"),\n\t\tpath: Type.String({ minLength: 1 }),\n\t\told: Type.String({ minLength: 1 }),\n\t\tnew: Type.String({ maxLength: MAX_CONTENT_CHARS }),\n\t}),\n]);\n\nconst workerActionsTool: Tool = {\n\tname: \"worker_actions\",\n\tdescription: \"Worker filesystem action list\",\n\tparameters: Type.Object({ actions: Type.Array(workerActionSchema) }),\n};\n\nfunction validateWorkerActions(raw: unknown, validation?: ToolArgumentValidationOptions): unknown[] {\n\ttry {\n\t\tconst validated = validateToolArguments(\n\t\t\tworkerActionsTool,\n\t\t\t{ type: \"toolCall\", id: \"worker-actions\", name: \"worker_actions\", arguments: { actions: raw } },\n\t\t\tvalidation,\n\t\t).actions;\n\t\treturn Array.isArray(validated) ? validated : [];\n\t} catch {\n\t\treturn [];\n\t}\n}\n\nfunction sanitizeWorkerActions(raw: readonly unknown[]): WorkerAction[] {\n\tconst actions: WorkerAction[] = [];\n\tfor (const entry of raw.slice(0, MAX_ACTIONS)) {\n\t\tif (!entry || typeof entry !== \"object\") continue;\n\t\tconst record = entry as Record<string, unknown>;\n\t\tif (record.op !== \"write\" && record.op !== \"edit\") continue;\n\t\tif (typeof record.path !== \"string\" || record.path.length === 0) continue;\n\t\tif (record.op === \"write\") {\n\t\t\tif (typeof record.content !== \"string\" || record.content.length > MAX_CONTENT_CHARS) continue;\n\t\t\tactions.push({ op: \"write\", path: record.path, content: record.content });\n\t\t} else {\n\t\t\tif (typeof record.old !== \"string\" || record.old.length === 0) continue;\n\t\t\tif (typeof record.new !== \"string\" || record.new.length > MAX_CONTENT_CHARS) continue;\n\t\t\tactions.push({ op: \"edit\", path: record.path, old: record.old, new: record.new });\n\t\t}\n\t}\n\treturn actions;\n}\n\nexport function parseWorkerActions(raw: unknown, validation?: ToolArgumentValidationOptions): WorkerAction[] {\n\tif (Array.isArray(raw)) return sanitizeWorkerActions(validateWorkerActions(sanitizeWorkerActions(raw), validation));\n\treturn sanitizeWorkerActions(validateWorkerActions(raw, validation));\n}\n\nexport interface AppliedActionsReport {\n\t/** Repo-relative paths actually changed. */\n\tchangedFiles: string[];\n\t/** Grant refusals (execution-time enforcement) — surfaced, never silent. */\n\trefused: Array<{ path: string; reason: string }>;\n\t/** Actions that were in scope but could not be applied (missing file, old-text not found). */\n\tfailed: Array<{ path: string; reason: string }>;\n}\n\nexport function applyWorkerActions(args: {\n\tactions: readonly WorkerAction[];\n\tgateway: CapabilityGateway;\n\ttoolManifests: readonly ToolCapabilityManifest[];\n\tcwd: string;\n}): AppliedActionsReport {\n\tconst report: AppliedActionsReport = { changedFiles: [], refused: [], failed: [] };\n\tconst manifests = new Map(args.toolManifests.map((manifest) => [manifest.toolName, manifest]));\n\tfor (const action of args.actions) {\n\t\tconst manifest = manifests.get(action.op);\n\t\tif (!manifest) {\n\t\t\treport.refused.push({\n\t\t\t\tpath: action.path,\n\t\t\t\treason: `${action.op} is not present in the compiled tool manifest`,\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\ttry {\n\t\t\targs.gateway.authorizeToolCall(manifest, action.op, { path: action.path });\n\t\t} catch (error) {\n\t\t\tif (error instanceof CapabilityGatewayDeniedError) {\n\t\t\t\treport.refused.push({ path: action.path, reason: `${error.reasonCode}: ${error.message}` });\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t\tconst target = safeRealpathSync(resolve(args.cwd, action.path));\n\t\tconst relativePath = relative(args.cwd, target).replaceAll(\"\\\\\", \"/\");\n\t\ttry {\n\t\t\tif (action.op === \"write\") {\n\t\t\t\tmkdirSync(dirname(target), { recursive: true });\n\t\t\t\twriteFileSync(target, action.content ?? \"\", \"utf-8\");\n\t\t\t} else {\n\t\t\t\tif (!existsSync(target)) {\n\t\t\t\t\treport.failed.push({ path: action.path, reason: \"file does not exist\" });\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tconst current = readFileSync(target, \"utf-8\");\n\t\t\t\tif (!action.old || !current.includes(action.old)) {\n\t\t\t\t\treport.failed.push({ path: action.path, reason: \"edit old-text not found in file\" });\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\twriteFileSync(\n\t\t\t\t\ttarget,\n\t\t\t\t\tcurrent.replace(action.old, () => action.new ?? \"\"),\n\t\t\t\t\t\"utf-8\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (!report.changedFiles.includes(relativePath)) report.changedFiles.push(relativePath);\n\t\t} catch (error) {\n\t\t\treport.failed.push({ path: action.path, reason: error instanceof Error ? error.message : String(error) });\n\t\t}\n\t}\n\treturn report;\n}\n"]}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import type { CapabilityEnvelope, GateOutcome,
|
|
2
|
-
export declare function
|
|
3
|
-
export declare function
|
|
4
|
-
export declare function requiresParentReview(
|
|
1
|
+
import type { CapabilityEnvelope, GateOutcome, WorkerClaim, WorkerRequest } from "../autonomy/contracts.ts";
|
|
2
|
+
export declare function cloneWorkerClaimForStorage(claim: WorkerClaim): WorkerClaim;
|
|
3
|
+
export declare function isWorkerClaim(value: unknown): value is WorkerClaim;
|
|
4
|
+
export declare function requiresParentReview(claim: WorkerClaim): boolean;
|
|
5
5
|
/**
|
|
6
|
-
* True iff {@link
|
|
6
|
+
* True iff {@link validateWorkerClaim}'s gate would flag this claim "ask-user" /
|
|
7
7
|
* "parent_review_required" (the two branches at :110 and :178 below) — an otherwise-completed
|
|
8
|
-
*
|
|
9
|
-
* that passed path-scope validation. Reuses `
|
|
8
|
+
* claim the parent must explicitly look at because it reports blockers, or reports file mutations
|
|
9
|
+
* that passed path-scope validation. Reuses `validateWorkerClaim` itself rather than a
|
|
10
10
|
* separately-maintained heuristic, so a persisted review marker can never drift from the
|
|
11
11
|
* gate's actual verdict.
|
|
12
12
|
*/
|
|
13
13
|
export declare function isParentReviewRequired(args: {
|
|
14
14
|
request: WorkerRequest;
|
|
15
|
-
|
|
15
|
+
claim: WorkerClaim;
|
|
16
16
|
cwd?: string;
|
|
17
17
|
}): boolean;
|
|
18
|
-
export declare function
|
|
18
|
+
export declare function validateWorkerClaim(args: {
|
|
19
19
|
request: WorkerRequest;
|
|
20
|
-
|
|
20
|
+
claim: WorkerClaim;
|
|
21
21
|
/**
|
|
22
22
|
* Baseline for relative paths — BOTH the runner's cwd-relative `changedFiles` and the
|
|
23
23
|
* envelope's possibly-relative path scopes resolve against this. Defaults to process.cwd()
|
|
@@ -30,8 +30,8 @@ export declare function validateWorkerResult(args: {
|
|
|
30
30
|
* -- e.g. a tmux worker's own completion report, which (unlike an in-process worker's) never
|
|
31
31
|
* passed through this process's `applyWorkerActions` envelope enforcement before the write
|
|
32
32
|
* happened; the tmux worker's tool loop runs in a separate process this session does not gate.
|
|
33
|
-
* Reuses {@link
|
|
34
|
-
* reimplement path resolution: synthesizes a minimal, always-"completed" request/
|
|
33
|
+
* Reuses {@link validateWorkerClaim}'s exact symlink-safe scope check verbatim -- never
|
|
34
|
+
* reimplement path resolution: synthesizes a minimal, always-"completed" request/claim pair
|
|
35
35
|
* carrying only the reported `changedFiles` and the scope's `allowedPaths`/`deniedPaths`, so the
|
|
36
36
|
* ONLY thing that can vary the verdict is the path-scope branch.
|
|
37
37
|
*
|
|
@@ -53,4 +53,4 @@ export declare function reviewManagedLaneChangedFiles(args: {
|
|
|
53
53
|
reviewRequired: boolean;
|
|
54
54
|
reasonCode: string;
|
|
55
55
|
};
|
|
56
|
-
//# sourceMappingURL=worker-
|
|
56
|
+
//# sourceMappingURL=worker-claim.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker-claim.d.ts","sourceRoot":"","sources":["../../../src/core/delegation/worker-claim.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAK5G,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,WAAW,GAAG,WAAW,CAW1E;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW,CAyClE;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAWhE;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE;IAAE,OAAO,EAAE,aAAa,CAAC;IAAC,KAAK,EAAE,WAAW,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAGlH;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE;IACzC,OAAO,EAAE,aAAa,CAAC;IACvB,KAAK,EAAE,WAAW,CAAC;IACnB;;;;OAIG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;CACb,GAAG,WAAW,CAmHd;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,6BAA6B,CAAC,IAAI,EAAE;IACnD,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;IAChC;+FAC2F;IAC3F,QAAQ,EAAE,IAAI,CAAC,kBAAkB,EAAE,cAAc,GAAG,aAAa,CAAC,CAAC;IACnE,GAAG,CAAC,EAAE,MAAM,CAAC;CACb,GAAG;IAAE,cAAc,EAAE,OAAO,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAiClD","sourcesContent":["import path from \"node:path\";\nimport type { CapabilityEnvelope, GateOutcome, WorkerClaim, WorkerRequest } from \"../autonomy/contracts.ts\";\nimport { checkPathScope } from \"../autonomy/path-scope.ts\";\nimport { cloneEvidenceBundleForStorage, isEvidenceBundle } from \"../research/evidence-bundle.ts\";\nimport { isPlainRecord } from \"../util/value-guards.ts\";\n\nexport function cloneWorkerClaimForStorage(claim: WorkerClaim): WorkerClaim {\n\treturn {\n\t\t...claim,\n\t\t...(claim.outputFormat ? { outputFormat: claim.outputFormat } : {}),\n\t\tchangedFiles: [...claim.changedFiles],\n\t\tblockers: claim.blockers ? [...claim.blockers] : undefined,\n\t\tevidence: claim.evidence ? cloneEvidenceBundleForStorage(claim.evidence) : undefined,\n\t\tverification: claim.verification\n\t\t\t? { ...claim.verification, reasonCodes: [...claim.verification.reasonCodes] }\n\t\t\t: undefined,\n\t};\n}\n\nexport function isWorkerClaim(value: unknown): value is WorkerClaim {\n\tif (!isPlainRecord(value)) return false;\n\tconst obj = value as Record<string, unknown>;\n\n\tif (typeof obj.requestId !== \"string\") return false;\n\tif (typeof obj.status !== \"string\" || ![\"completed\", \"blocked\", \"failed\", \"cancelled\"].includes(obj.status)) {\n\t\treturn false;\n\t}\n\tif (typeof obj.summary !== \"string\") return false;\n\tif (obj.outputFormat !== undefined && obj.outputFormat !== \"structured\" && obj.outputFormat !== \"plain_text\")\n\t\treturn false;\n\n\tif (!Array.isArray(obj.changedFiles) || !obj.changedFiles.every((f) => typeof f === \"string\")) {\n\t\treturn false;\n\t}\n\n\tif (obj.blockers !== undefined) {\n\t\tif (!Array.isArray(obj.blockers) || !obj.blockers.every((b) => typeof b === \"string\")) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\tif (obj.usageReportId !== undefined && typeof obj.usageReportId !== \"string\") return false;\n\tif (obj.createdAt !== undefined && typeof obj.createdAt !== \"string\") return false;\n\tif (obj.parentReviewRequired !== undefined && typeof obj.parentReviewRequired !== \"boolean\") return false;\n\tif (obj.parentReviewedAt !== undefined && typeof obj.parentReviewedAt !== \"string\") return false;\n\tif (obj.verification !== undefined) {\n\t\tif (!isPlainRecord(obj.verification)) return false;\n\t\tif (typeof obj.verification.subjectTaskId !== \"string\" || !obj.verification.subjectTaskId) return false;\n\t\tif (obj.verification.verdict !== \"accepted\" && obj.verification.verdict !== \"rejected\") return false;\n\t\tif (\n\t\t\t!Array.isArray(obj.verification.reasonCodes) ||\n\t\t\t!obj.verification.reasonCodes.every((reasonCode) => typeof reasonCode === \"string\" && reasonCode.length > 0)\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\tif (obj.evidence !== undefined && !isEvidenceBundle(obj.evidence)) return false;\n\n\treturn true;\n}\n\nexport function requiresParentReview(claim: WorkerClaim): boolean {\n\tif (claim.status !== \"completed\") {\n\t\treturn true;\n\t}\n\tif (claim.blockers && claim.blockers.length > 0) {\n\t\treturn true;\n\t}\n\tif (claim.changedFiles.length > 0) {\n\t\treturn true;\n\t}\n\treturn false;\n}\n\n/**\n * True iff {@link validateWorkerClaim}'s gate would flag this claim \"ask-user\" /\n * \"parent_review_required\" (the two branches at :110 and :178 below) — an otherwise-completed\n * claim the parent must explicitly look at because it reports blockers, or reports file mutations\n * that passed path-scope validation. Reuses `validateWorkerClaim` itself rather than a\n * separately-maintained heuristic, so a persisted review marker can never drift from the\n * gate's actual verdict.\n */\nexport function isParentReviewRequired(args: { request: WorkerRequest; claim: WorkerClaim; cwd?: string }): boolean {\n\tconst acceptance = validateWorkerClaim(args);\n\treturn acceptance.outcome === \"ask-user\" && acceptance.reasonCode === \"parent_review_required\";\n}\n\nexport function validateWorkerClaim(args: {\n\trequest: WorkerRequest;\n\tclaim: WorkerClaim;\n\t/**\n\t * Baseline for relative paths — BOTH the runner's cwd-relative `changedFiles` and the\n\t * envelope's possibly-relative path scopes resolve against this. Defaults to process.cwd()\n\t * for callers whose session cwd is the process cwd.\n\t */\n\tcwd?: string;\n}): GateOutcome {\n\tconst { request, claim } = args;\n\tconst baseDir = args.cwd ?? process.cwd();\n\n\tif (claim.requestId !== request.id) {\n\t\treturn {\n\t\t\toutcome: \"block\",\n\t\t\tgate: \"worker_claim\",\n\t\t\treasonCode: \"request_id_mismatch\",\n\t\t\tmessage: `Claim requestId '${claim.requestId}' does not match request id '${request.id}'.`,\n\t\t};\n\t}\n\n\tif (claim.status !== \"completed\") {\n\t\treturn {\n\t\t\toutcome: \"block\",\n\t\t\tgate: \"worker_claim\",\n\t\t\treasonCode: \"worker_not_completed\",\n\t\t\tmessage: `Worker finished with status '${claim.status}'.`,\n\t\t\tdetails: claim.blockers && claim.blockers.length > 0 ? { blockers: [...claim.blockers] } : undefined,\n\t\t};\n\t}\n\n\tif (!claim.usageReportId) {\n\t\treturn {\n\t\t\toutcome: \"block\",\n\t\t\tgate: \"worker_claim\",\n\t\t\treasonCode: \"missing_usage_report\",\n\t\t\tmessage: \"Completed worker claim is missing usageReportId.\",\n\t\t};\n\t}\n\n\tif (claim.blockers && claim.blockers.length > 0) {\n\t\treturn {\n\t\t\toutcome: \"ask-user\",\n\t\t\tgate: \"worker_claim\",\n\t\t\treasonCode: \"parent_review_required\",\n\t\t\tmessage: \"Completed worker claim includes blockers and requires parent review.\",\n\t\t\tdetails: { blockers: [...claim.blockers] },\n\t\t};\n\t}\n\n\tif (claim.changedFiles.length > 0) {\n\t\tif (!request.envelope.allowedPaths || request.envelope.allowedPaths.length === 0) {\n\t\t\treturn {\n\t\t\t\toutcome: \"block\",\n\t\t\t\tgate: \"worker_claim\",\n\t\t\t\treasonCode: \"missing_path_scope\",\n\t\t\t\tmessage: \"Worker changed files but no allowedPaths are configured in the envelope.\",\n\t\t\t};\n\t\t}\n\n\t\t// The runner reports changed files relative to the session cwd — resolve file and scope\n\t\t// roots against the SAME baseline. Resolving per-root double-prefixed nested names and\n\t\t// let a denied subtree slip past the deny rule.\n\t\tconst resolvedAllowed = request.envelope.allowedPaths.map((p) => path.resolve(baseDir, p));\n\t\tconst resolvedDenied = request.envelope.deniedPaths?.map((p) => path.resolve(baseDir, p));\n\t\tfor (const changedFile of claim.changedFiles) {\n\t\t\tlet isInsideAny = false;\n\t\t\tlet isDenied = false;\n\n\t\t\tconst scopedChangedFile = path.resolve(baseDir, changedFile);\n\t\t\tfor (const root of resolvedAllowed) {\n\t\t\t\tconst decision = checkPathScope(\n\t\t\t\t\t{\n\t\t\t\t\t\troot,\n\t\t\t\t\t\tallowedPaths: resolvedAllowed,\n\t\t\t\t\t\tdeniedPaths: resolvedDenied,\n\t\t\t\t\t},\n\t\t\t\t\tscopedChangedFile,\n\t\t\t\t);\n\n\t\t\t\tif (decision.kind === \"denied\") {\n\t\t\t\t\tisDenied = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif (decision.kind === \"inside\") {\n\t\t\t\t\tisInsideAny = true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (isDenied) {\n\t\t\t\treturn {\n\t\t\t\t\toutcome: \"block\",\n\t\t\t\t\tgate: \"worker_claim\",\n\t\t\t\t\treasonCode: \"changed_file_denied\",\n\t\t\t\t\tmessage: `Worker changed file '${changedFile}' which matches a denied path.`,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif (!isInsideAny) {\n\t\t\t\treturn {\n\t\t\t\t\toutcome: \"block\",\n\t\t\t\t\tgate: \"worker_claim\",\n\t\t\t\t\treasonCode: \"changed_file_outside_scope\",\n\t\t\t\t\tmessage: `Worker changed file '${changedFile}' outside allowed scope.`,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\t// Files are inside scope, but worker output is untrusted\n\t\treturn {\n\t\t\toutcome: \"ask-user\",\n\t\t\tgate: \"worker_claim\",\n\t\t\treasonCode: \"parent_review_required\",\n\t\t\tmessage: \"Worker changed files require parent review.\",\n\t\t};\n\t}\n\n\treturn {\n\t\toutcome: \"allow\",\n\t\tgate: \"worker_claim\",\n\t\treasonCode: \"allowed\",\n\t\tmessage: \"Worker claim is read-only and allowed.\",\n\t};\n}\n\n/**\n * Path-scope-only re-review for a SELF-REPORTED (out-of-process) worker's claimed `changedFiles`\n * -- e.g. a tmux worker's own completion report, which (unlike an in-process worker's) never\n * passed through this process's `applyWorkerActions` envelope enforcement before the write\n * happened; the tmux worker's tool loop runs in a separate process this session does not gate.\n * Reuses {@link validateWorkerClaim}'s exact symlink-safe scope check verbatim -- never\n * reimplement path resolution: synthesizes a minimal, always-\"completed\" request/claim pair\n * carrying only the reported `changedFiles` and the scope's `allowedPaths`/`deniedPaths`, so the\n * ONLY thing that can vary the verdict is the path-scope branch.\n *\n * Deliberately broader than {@link isParentReviewRequired}: that helper only flags the gate's\n * \"ask-user\" branch, which is correct for an in-process worker (a write that would have been\n * \"block\"-worthy was already refused before it could happen, by the SAME envelope, via\n * `applyWorkerActions`). A self-reported claim has no such backstop -- an out-of-scope or denied\n * path already happened on the real filesystem whether or not this gate would allow it, so here\n * ANY non-\"allow\" verdict (in scope, out of scope, or no scope configured at all) means a human\n * must look, not \"the write didn't happen\".\n */\nexport function reviewManagedLaneChangedFiles(args: {\n\tchangedFiles: readonly string[];\n\t/** The scope to validate against -- e.g. the session's active `CapabilityEnvelope`, until a\n\t * per-launch tmux standing grant envelope lands in a later wave (documented follow-up). */\n\tenvelope: Pick<CapabilityEnvelope, \"allowedPaths\" | \"deniedPaths\">;\n\tcwd?: string;\n}): { reviewRequired: boolean; reasonCode: string } {\n\tif (args.changedFiles.length === 0) {\n\t\treturn { reviewRequired: false, reasonCode: \"no_changed_files\" };\n\t}\n\tconst syntheticId = \"managed-lane-review\";\n\tconst acceptance = validateWorkerClaim({\n\t\trequest: {\n\t\t\tid: syntheticId,\n\t\t\tinstructions: \"\",\n\t\t\troute: {\n\t\t\t\ttier: \"cheap\",\n\t\t\t\trisk: \"scoped-write\",\n\t\t\t\tconfidence: 1,\n\t\t\t\treasonCode: \"managed_lane_review\",\n\t\t\t\treasons: [],\n\t\t\t},\n\t\t\tenvelope: {\n\t\t\t\tid: syntheticId,\n\t\t\t\tcapabilities: [\"filesystem.write\"],\n\t\t\t\tallowedPaths: args.envelope.allowedPaths,\n\t\t\t\tdeniedPaths: args.envelope.deniedPaths,\n\t\t\t},\n\t\t},\n\t\tclaim: {\n\t\t\trequestId: syntheticId,\n\t\t\tstatus: \"completed\",\n\t\t\tsummary: \"\",\n\t\t\tchangedFiles: [...args.changedFiles],\n\t\t\tusageReportId: syntheticId,\n\t\t},\n\t\tcwd: args.cwd,\n\t});\n\treturn { reviewRequired: acceptance.outcome !== \"allow\", reasonCode: acceptance.reasonCode };\n}\n"]}
|
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { checkPathScope } from "../autonomy/path-scope.js";
|
|
3
3
|
import { cloneEvidenceBundleForStorage, isEvidenceBundle } from "../research/evidence-bundle.js";
|
|
4
|
-
|
|
4
|
+
import { isPlainRecord } from "../util/value-guards.js";
|
|
5
|
+
export function cloneWorkerClaimForStorage(claim) {
|
|
5
6
|
return {
|
|
6
|
-
...
|
|
7
|
-
...(
|
|
8
|
-
changedFiles: [...
|
|
9
|
-
blockers:
|
|
10
|
-
evidence:
|
|
7
|
+
...claim,
|
|
8
|
+
...(claim.outputFormat ? { outputFormat: claim.outputFormat } : {}),
|
|
9
|
+
changedFiles: [...claim.changedFiles],
|
|
10
|
+
blockers: claim.blockers ? [...claim.blockers] : undefined,
|
|
11
|
+
evidence: claim.evidence ? cloneEvidenceBundleForStorage(claim.evidence) : undefined,
|
|
12
|
+
verification: claim.verification
|
|
13
|
+
? { ...claim.verification, reasonCodes: [...claim.verification.reasonCodes] }
|
|
14
|
+
: undefined,
|
|
11
15
|
};
|
|
12
16
|
}
|
|
13
|
-
function
|
|
14
|
-
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
15
|
-
return false;
|
|
16
|
-
const prototype = Object.getPrototypeOf(value);
|
|
17
|
-
return prototype === Object.prototype || prototype === null;
|
|
18
|
-
}
|
|
19
|
-
export function isWorkerResult(value) {
|
|
17
|
+
export function isWorkerClaim(value) {
|
|
20
18
|
if (!isPlainRecord(value))
|
|
21
19
|
return false;
|
|
22
20
|
const obj = value;
|
|
@@ -45,76 +43,88 @@ export function isWorkerResult(value) {
|
|
|
45
43
|
return false;
|
|
46
44
|
if (obj.parentReviewedAt !== undefined && typeof obj.parentReviewedAt !== "string")
|
|
47
45
|
return false;
|
|
46
|
+
if (obj.verification !== undefined) {
|
|
47
|
+
if (!isPlainRecord(obj.verification))
|
|
48
|
+
return false;
|
|
49
|
+
if (typeof obj.verification.subjectTaskId !== "string" || !obj.verification.subjectTaskId)
|
|
50
|
+
return false;
|
|
51
|
+
if (obj.verification.verdict !== "accepted" && obj.verification.verdict !== "rejected")
|
|
52
|
+
return false;
|
|
53
|
+
if (!Array.isArray(obj.verification.reasonCodes) ||
|
|
54
|
+
!obj.verification.reasonCodes.every((reasonCode) => typeof reasonCode === "string" && reasonCode.length > 0)) {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
48
58
|
if (obj.evidence !== undefined && !isEvidenceBundle(obj.evidence))
|
|
49
59
|
return false;
|
|
50
60
|
return true;
|
|
51
61
|
}
|
|
52
|
-
export function requiresParentReview(
|
|
53
|
-
if (
|
|
62
|
+
export function requiresParentReview(claim) {
|
|
63
|
+
if (claim.status !== "completed") {
|
|
54
64
|
return true;
|
|
55
65
|
}
|
|
56
|
-
if (
|
|
66
|
+
if (claim.blockers && claim.blockers.length > 0) {
|
|
57
67
|
return true;
|
|
58
68
|
}
|
|
59
|
-
if (
|
|
69
|
+
if (claim.changedFiles.length > 0) {
|
|
60
70
|
return true;
|
|
61
71
|
}
|
|
62
72
|
return false;
|
|
63
73
|
}
|
|
64
74
|
/**
|
|
65
|
-
* True iff {@link
|
|
75
|
+
* True iff {@link validateWorkerClaim}'s gate would flag this claim "ask-user" /
|
|
66
76
|
* "parent_review_required" (the two branches at :110 and :178 below) — an otherwise-completed
|
|
67
|
-
*
|
|
68
|
-
* that passed path-scope validation. Reuses `
|
|
77
|
+
* claim the parent must explicitly look at because it reports blockers, or reports file mutations
|
|
78
|
+
* that passed path-scope validation. Reuses `validateWorkerClaim` itself rather than a
|
|
69
79
|
* separately-maintained heuristic, so a persisted review marker can never drift from the
|
|
70
80
|
* gate's actual verdict.
|
|
71
81
|
*/
|
|
72
82
|
export function isParentReviewRequired(args) {
|
|
73
|
-
const acceptance =
|
|
83
|
+
const acceptance = validateWorkerClaim(args);
|
|
74
84
|
return acceptance.outcome === "ask-user" && acceptance.reasonCode === "parent_review_required";
|
|
75
85
|
}
|
|
76
|
-
export function
|
|
77
|
-
const { request,
|
|
86
|
+
export function validateWorkerClaim(args) {
|
|
87
|
+
const { request, claim } = args;
|
|
78
88
|
const baseDir = args.cwd ?? process.cwd();
|
|
79
|
-
if (
|
|
89
|
+
if (claim.requestId !== request.id) {
|
|
80
90
|
return {
|
|
81
91
|
outcome: "block",
|
|
82
|
-
gate: "
|
|
92
|
+
gate: "worker_claim",
|
|
83
93
|
reasonCode: "request_id_mismatch",
|
|
84
|
-
message: `
|
|
94
|
+
message: `Claim requestId '${claim.requestId}' does not match request id '${request.id}'.`,
|
|
85
95
|
};
|
|
86
96
|
}
|
|
87
|
-
if (
|
|
97
|
+
if (claim.status !== "completed") {
|
|
88
98
|
return {
|
|
89
99
|
outcome: "block",
|
|
90
|
-
gate: "
|
|
100
|
+
gate: "worker_claim",
|
|
91
101
|
reasonCode: "worker_not_completed",
|
|
92
|
-
message: `Worker finished with status '${
|
|
93
|
-
details:
|
|
102
|
+
message: `Worker finished with status '${claim.status}'.`,
|
|
103
|
+
details: claim.blockers && claim.blockers.length > 0 ? { blockers: [...claim.blockers] } : undefined,
|
|
94
104
|
};
|
|
95
105
|
}
|
|
96
|
-
if (!
|
|
106
|
+
if (!claim.usageReportId) {
|
|
97
107
|
return {
|
|
98
108
|
outcome: "block",
|
|
99
|
-
gate: "
|
|
109
|
+
gate: "worker_claim",
|
|
100
110
|
reasonCode: "missing_usage_report",
|
|
101
|
-
message: "Completed worker
|
|
111
|
+
message: "Completed worker claim is missing usageReportId.",
|
|
102
112
|
};
|
|
103
113
|
}
|
|
104
|
-
if (
|
|
114
|
+
if (claim.blockers && claim.blockers.length > 0) {
|
|
105
115
|
return {
|
|
106
116
|
outcome: "ask-user",
|
|
107
|
-
gate: "
|
|
117
|
+
gate: "worker_claim",
|
|
108
118
|
reasonCode: "parent_review_required",
|
|
109
|
-
message: "Completed worker
|
|
110
|
-
details: { blockers: [...
|
|
119
|
+
message: "Completed worker claim includes blockers and requires parent review.",
|
|
120
|
+
details: { blockers: [...claim.blockers] },
|
|
111
121
|
};
|
|
112
122
|
}
|
|
113
|
-
if (
|
|
123
|
+
if (claim.changedFiles.length > 0) {
|
|
114
124
|
if (!request.envelope.allowedPaths || request.envelope.allowedPaths.length === 0) {
|
|
115
125
|
return {
|
|
116
126
|
outcome: "block",
|
|
117
|
-
gate: "
|
|
127
|
+
gate: "worker_claim",
|
|
118
128
|
reasonCode: "missing_path_scope",
|
|
119
129
|
message: "Worker changed files but no allowedPaths are configured in the envelope.",
|
|
120
130
|
};
|
|
@@ -124,7 +134,7 @@ export function validateWorkerResult(args) {
|
|
|
124
134
|
// let a denied subtree slip past the deny rule.
|
|
125
135
|
const resolvedAllowed = request.envelope.allowedPaths.map((p) => path.resolve(baseDir, p));
|
|
126
136
|
const resolvedDenied = request.envelope.deniedPaths?.map((p) => path.resolve(baseDir, p));
|
|
127
|
-
for (const changedFile of
|
|
137
|
+
for (const changedFile of claim.changedFiles) {
|
|
128
138
|
let isInsideAny = false;
|
|
129
139
|
let isDenied = false;
|
|
130
140
|
const scopedChangedFile = path.resolve(baseDir, changedFile);
|
|
@@ -145,7 +155,7 @@ export function validateWorkerResult(args) {
|
|
|
145
155
|
if (isDenied) {
|
|
146
156
|
return {
|
|
147
157
|
outcome: "block",
|
|
148
|
-
gate: "
|
|
158
|
+
gate: "worker_claim",
|
|
149
159
|
reasonCode: "changed_file_denied",
|
|
150
160
|
message: `Worker changed file '${changedFile}' which matches a denied path.`,
|
|
151
161
|
};
|
|
@@ -153,7 +163,7 @@ export function validateWorkerResult(args) {
|
|
|
153
163
|
if (!isInsideAny) {
|
|
154
164
|
return {
|
|
155
165
|
outcome: "block",
|
|
156
|
-
gate: "
|
|
166
|
+
gate: "worker_claim",
|
|
157
167
|
reasonCode: "changed_file_outside_scope",
|
|
158
168
|
message: `Worker changed file '${changedFile}' outside allowed scope.`,
|
|
159
169
|
};
|
|
@@ -162,16 +172,16 @@ export function validateWorkerResult(args) {
|
|
|
162
172
|
// Files are inside scope, but worker output is untrusted
|
|
163
173
|
return {
|
|
164
174
|
outcome: "ask-user",
|
|
165
|
-
gate: "
|
|
175
|
+
gate: "worker_claim",
|
|
166
176
|
reasonCode: "parent_review_required",
|
|
167
177
|
message: "Worker changed files require parent review.",
|
|
168
178
|
};
|
|
169
179
|
}
|
|
170
180
|
return {
|
|
171
181
|
outcome: "allow",
|
|
172
|
-
gate: "
|
|
182
|
+
gate: "worker_claim",
|
|
173
183
|
reasonCode: "allowed",
|
|
174
|
-
message: "Worker
|
|
184
|
+
message: "Worker claim is read-only and allowed.",
|
|
175
185
|
};
|
|
176
186
|
}
|
|
177
187
|
/**
|
|
@@ -179,8 +189,8 @@ export function validateWorkerResult(args) {
|
|
|
179
189
|
* -- e.g. a tmux worker's own completion report, which (unlike an in-process worker's) never
|
|
180
190
|
* passed through this process's `applyWorkerActions` envelope enforcement before the write
|
|
181
191
|
* happened; the tmux worker's tool loop runs in a separate process this session does not gate.
|
|
182
|
-
* Reuses {@link
|
|
183
|
-
* reimplement path resolution: synthesizes a minimal, always-"completed" request/
|
|
192
|
+
* Reuses {@link validateWorkerClaim}'s exact symlink-safe scope check verbatim -- never
|
|
193
|
+
* reimplement path resolution: synthesizes a minimal, always-"completed" request/claim pair
|
|
184
194
|
* carrying only the reported `changedFiles` and the scope's `allowedPaths`/`deniedPaths`, so the
|
|
185
195
|
* ONLY thing that can vary the verdict is the path-scope branch.
|
|
186
196
|
*
|
|
@@ -197,7 +207,7 @@ export function reviewManagedLaneChangedFiles(args) {
|
|
|
197
207
|
return { reviewRequired: false, reasonCode: "no_changed_files" };
|
|
198
208
|
}
|
|
199
209
|
const syntheticId = "managed-lane-review";
|
|
200
|
-
const acceptance =
|
|
210
|
+
const acceptance = validateWorkerClaim({
|
|
201
211
|
request: {
|
|
202
212
|
id: syntheticId,
|
|
203
213
|
instructions: "",
|
|
@@ -210,12 +220,12 @@ export function reviewManagedLaneChangedFiles(args) {
|
|
|
210
220
|
},
|
|
211
221
|
envelope: {
|
|
212
222
|
id: syntheticId,
|
|
213
|
-
capabilities: ["
|
|
223
|
+
capabilities: ["filesystem.write"],
|
|
214
224
|
allowedPaths: args.envelope.allowedPaths,
|
|
215
225
|
deniedPaths: args.envelope.deniedPaths,
|
|
216
226
|
},
|
|
217
227
|
},
|
|
218
|
-
|
|
228
|
+
claim: {
|
|
219
229
|
requestId: syntheticId,
|
|
220
230
|
status: "completed",
|
|
221
231
|
summary: "",
|
|
@@ -226,4 +236,4 @@ export function reviewManagedLaneChangedFiles(args) {
|
|
|
226
236
|
});
|
|
227
237
|
return { reviewRequired: acceptance.outcome !== "allow", reasonCode: acceptance.reasonCode };
|
|
228
238
|
}
|
|
229
|
-
//# sourceMappingURL=worker-
|
|
239
|
+
//# sourceMappingURL=worker-claim.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker-claim.js","sourceRoot":"","sources":["../../../src/core/delegation/worker-claim.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,6BAA6B,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AACjG,OAAO,EAAE,aAAa,EAA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mBAAmB,CAAC;QACtC,OAAO,EAAE;YACR,EAAE,EAAE,WAAW;YACf,YAAY,EAAE,EAAE;YAChB,KAAK,EAAE;gBACN,IAAI,EAAE,OAAO;gBACb,IAAI,EAAE,cAAc;gBACpB,UAAU,EAAE,CAAC;gBACb,UAAU,EAAE,qBAAqB;gBACjC,OAAO,EAAE,EAAE;aACX;YACD,QAAQ,EAAE;gBACT,EAAE,EAAE,WAAW;gBACf,YAAY,EAAE,CAAC,kBAAkB,CAAC;gBAClC,YAAY,EAAE,IAAI,CAAC,QAAQ,CAAC,YAAY;gBACxC,WAAW,EAAE,IAAI,CAAC,QAAQ,CAAC,WAAW;aACtC;SACD;QACD,KAAK,EAAE;YACN,SAAS,EAAE,WAAW;YACtB,MAAM,EAAE,WAAW;YACnB,OAAO,EAAE,EAAE;YACX,YAAY,EAAE,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC;YACpC,aAAa,EAAE,WAAW;SAC1B;QACD,GAAG,EAAE,IAAI,CAAC,GAAG;KACb,CAAC,CAAC;IACH,OAAO,EAAE,cAAc,EAAE,UAAU,CAAC,OAAO,KAAK,OAAO,EAAE,UAAU,EAAE,UAAU,CAAC,UAAU,EAAE,CAAC;AAAA,CAC7F","sourcesContent":["import path from \"node:path\";\nimport type { CapabilityEnvelope, GateOutcome, WorkerClaim, WorkerRequest } from \"../autonomy/contracts.ts\";\nimport { checkPathScope } from \"../autonomy/path-scope.ts\";\nimport { cloneEvidenceBundleForStorage, isEvidenceBundle } from \"../research/evidence-bundle.ts\";\nimport { isPlainRecord } from \"../util/value-guards.ts\";\n\nexport function cloneWorkerClaimForStorage(claim: WorkerClaim): WorkerClaim {\n\treturn {\n\t\t...claim,\n\t\t...(claim.outputFormat ? { outputFormat: claim.outputFormat } : {}),\n\t\tchangedFiles: [...claim.changedFiles],\n\t\tblockers: claim.blockers ? [...claim.blockers] : undefined,\n\t\tevidence: claim.evidence ? cloneEvidenceBundleForStorage(claim.evidence) : undefined,\n\t\tverification: claim.verification\n\t\t\t? { ...claim.verification, reasonCodes: [...claim.verification.reasonCodes] }\n\t\t\t: undefined,\n\t};\n}\n\nexport function isWorkerClaim(value: unknown): value is WorkerClaim {\n\tif (!isPlainRecord(value)) return false;\n\tconst obj = value as Record<string, unknown>;\n\n\tif (typeof obj.requestId !== \"string\") return false;\n\tif (typeof obj.status !== \"string\" || ![\"completed\", \"blocked\", \"failed\", \"cancelled\"].includes(obj.status)) {\n\t\treturn false;\n\t}\n\tif (typeof obj.summary !== \"string\") return false;\n\tif (obj.outputFormat !== undefined && obj.outputFormat !== \"structured\" && obj.outputFormat !== \"plain_text\")\n\t\treturn false;\n\n\tif (!Array.isArray(obj.changedFiles) || !obj.changedFiles.every((f) => typeof f === \"string\")) {\n\t\treturn false;\n\t}\n\n\tif (obj.blockers !== undefined) {\n\t\tif (!Array.isArray(obj.blockers) || !obj.blockers.every((b) => typeof b === \"string\")) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\tif (obj.usageReportId !== undefined && typeof obj.usageReportId !== \"string\") return false;\n\tif (obj.createdAt !== undefined && typeof obj.createdAt !== \"string\") return false;\n\tif (obj.parentReviewRequired !== undefined && typeof obj.parentReviewRequired !== \"boolean\") return false;\n\tif (obj.parentReviewedAt !== undefined && typeof obj.parentReviewedAt !== \"string\") return false;\n\tif (obj.verification !== undefined) {\n\t\tif (!isPlainRecord(obj.verification)) return false;\n\t\tif (typeof obj.verification.subjectTaskId !== \"string\" || !obj.verification.subjectTaskId) return false;\n\t\tif (obj.verification.verdict !== \"accepted\" && obj.verification.verdict !== \"rejected\") return false;\n\t\tif (\n\t\t\t!Array.isArray(obj.verification.reasonCodes) ||\n\t\t\t!obj.verification.reasonCodes.every((reasonCode) => typeof reasonCode === \"string\" && reasonCode.length > 0)\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\tif (obj.evidence !== undefined && !isEvidenceBundle(obj.evidence)) return false;\n\n\treturn true;\n}\n\nexport function requiresParentReview(claim: WorkerClaim): boolean {\n\tif (claim.status !== \"completed\") {\n\t\treturn true;\n\t}\n\tif (claim.blockers && claim.blockers.length > 0) {\n\t\treturn true;\n\t}\n\tif (claim.changedFiles.length > 0) {\n\t\treturn true;\n\t}\n\treturn false;\n}\n\n/**\n * True iff {@link validateWorkerClaim}'s gate would flag this claim \"ask-user\" /\n * \"parent_review_required\" (the two branches at :110 and :178 below) — an otherwise-completed\n * claim the parent must explicitly look at because it reports blockers, or reports file mutations\n * that passed path-scope validation. Reuses `validateWorkerClaim` itself rather than a\n * separately-maintained heuristic, so a persisted review marker can never drift from the\n * gate's actual verdict.\n */\nexport function isParentReviewRequired(args: { request: WorkerRequest; claim: WorkerClaim; cwd?: string }): boolean {\n\tconst acceptance = validateWorkerClaim(args);\n\treturn acceptance.outcome === \"ask-user\" && acceptance.reasonCode === \"parent_review_required\";\n}\n\nexport function validateWorkerClaim(args: {\n\trequest: WorkerRequest;\n\tclaim: WorkerClaim;\n\t/**\n\t * Baseline for relative paths — BOTH the runner's cwd-relative `changedFiles` and the\n\t * envelope's possibly-relative path scopes resolve against this. Defaults to process.cwd()\n\t * for callers whose session cwd is the process cwd.\n\t */\n\tcwd?: string;\n}): GateOutcome {\n\tconst { request, claim } = args;\n\tconst baseDir = args.cwd ?? process.cwd();\n\n\tif (claim.requestId !== request.id) {\n\t\treturn {\n\t\t\toutcome: \"block\",\n\t\t\tgate: \"worker_claim\",\n\t\t\treasonCode: \"request_id_mismatch\",\n\t\t\tmessage: `Claim requestId '${claim.requestId}' does not match request id '${request.id}'.`,\n\t\t};\n\t}\n\n\tif (claim.status !== \"completed\") {\n\t\treturn {\n\t\t\toutcome: \"block\",\n\t\t\tgate: \"worker_claim\",\n\t\t\treasonCode: \"worker_not_completed\",\n\t\t\tmessage: `Worker finished with status '${claim.status}'.`,\n\t\t\tdetails: claim.blockers && claim.blockers.length > 0 ? { blockers: [...claim.blockers] } : undefined,\n\t\t};\n\t}\n\n\tif (!claim.usageReportId) {\n\t\treturn {\n\t\t\toutcome: \"block\",\n\t\t\tgate: \"worker_claim\",\n\t\t\treasonCode: \"missing_usage_report\",\n\t\t\tmessage: \"Completed worker claim is missing usageReportId.\",\n\t\t};\n\t}\n\n\tif (claim.blockers && claim.blockers.length > 0) {\n\t\treturn {\n\t\t\toutcome: \"ask-user\",\n\t\t\tgate: \"worker_claim\",\n\t\t\treasonCode: \"parent_review_required\",\n\t\t\tmessage: \"Completed worker claim includes blockers and requires parent review.\",\n\t\t\tdetails: { blockers: [...claim.blockers] },\n\t\t};\n\t}\n\n\tif (claim.changedFiles.length > 0) {\n\t\tif (!request.envelope.allowedPaths || request.envelope.allowedPaths.length === 0) {\n\t\t\treturn {\n\t\t\t\toutcome: \"block\",\n\t\t\t\tgate: \"worker_claim\",\n\t\t\t\treasonCode: \"missing_path_scope\",\n\t\t\t\tmessage: \"Worker changed files but no allowedPaths are configured in the envelope.\",\n\t\t\t};\n\t\t}\n\n\t\t// The runner reports changed files relative to the session cwd — resolve file and scope\n\t\t// roots against the SAME baseline. Resolving per-root double-prefixed nested names and\n\t\t// let a denied subtree slip past the deny rule.\n\t\tconst resolvedAllowed = request.envelope.allowedPaths.map((p) => path.resolve(baseDir, p));\n\t\tconst resolvedDenied = request.envelope.deniedPaths?.map((p) => path.resolve(baseDir, p));\n\t\tfor (const changedFile of claim.changedFiles) {\n\t\t\tlet isInsideAny = false;\n\t\t\tlet isDenied = false;\n\n\t\t\tconst scopedChangedFile = path.resolve(baseDir, changedFile);\n\t\t\tfor (const root of resolvedAllowed) {\n\t\t\t\tconst decision = checkPathScope(\n\t\t\t\t\t{\n\t\t\t\t\t\troot,\n\t\t\t\t\t\tallowedPaths: resolvedAllowed,\n\t\t\t\t\t\tdeniedPaths: resolvedDenied,\n\t\t\t\t\t},\n\t\t\t\t\tscopedChangedFile,\n\t\t\t\t);\n\n\t\t\t\tif (decision.kind === \"denied\") {\n\t\t\t\t\tisDenied = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif (decision.kind === \"inside\") {\n\t\t\t\t\tisInsideAny = true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (isDenied) {\n\t\t\t\treturn {\n\t\t\t\t\toutcome: \"block\",\n\t\t\t\t\tgate: \"worker_claim\",\n\t\t\t\t\treasonCode: \"changed_file_denied\",\n\t\t\t\t\tmessage: `Worker changed file '${changedFile}' which matches a denied path.`,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif (!isInsideAny) {\n\t\t\t\treturn {\n\t\t\t\t\toutcome: \"block\",\n\t\t\t\t\tgate: \"worker_claim\",\n\t\t\t\t\treasonCode: \"changed_file_outside_scope\",\n\t\t\t\t\tmessage: `Worker changed file '${changedFile}' outside allowed scope.`,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\t// Files are inside scope, but worker output is untrusted\n\t\treturn {\n\t\t\toutcome: \"ask-user\",\n\t\t\tgate: \"worker_claim\",\n\t\t\treasonCode: \"parent_review_required\",\n\t\t\tmessage: \"Worker changed files require parent review.\",\n\t\t};\n\t}\n\n\treturn {\n\t\toutcome: \"allow\",\n\t\tgate: \"worker_claim\",\n\t\treasonCode: \"allowed\",\n\t\tmessage: \"Worker claim is read-only and allowed.\",\n\t};\n}\n\n/**\n * Path-scope-only re-review for a SELF-REPORTED (out-of-process) worker's claimed `changedFiles`\n * -- e.g. a tmux worker's own completion report, which (unlike an in-process worker's) never\n * passed through this process's `applyWorkerActions` envelope enforcement before the write\n * happened; the tmux worker's tool loop runs in a separate process this session does not gate.\n * Reuses {@link validateWorkerClaim}'s exact symlink-safe scope check verbatim -- never\n * reimplement path resolution: synthesizes a minimal, always-\"completed\" request/claim pair\n * carrying only the reported `changedFiles` and the scope's `allowedPaths`/`deniedPaths`, so the\n * ONLY thing that can vary the verdict is the path-scope branch.\n *\n * Deliberately broader than {@link isParentReviewRequired}: that helper only flags the gate's\n * \"ask-user\" branch, which is correct for an in-process worker (a write that would have been\n * \"block\"-worthy was already refused before it could happen, by the SAME envelope, via\n * `applyWorkerActions`). A self-reported claim has no such backstop -- an out-of-scope or denied\n * path already happened on the real filesystem whether or not this gate would allow it, so here\n * ANY non-\"allow\" verdict (in scope, out of scope, or no scope configured at all) means a human\n * must look, not \"the write didn't happen\".\n */\nexport function reviewManagedLaneChangedFiles(args: {\n\tchangedFiles: readonly string[];\n\t/** The scope to validate against -- e.g. the session's active `CapabilityEnvelope`, until a\n\t * per-launch tmux standing grant envelope lands in a later wave (documented follow-up). */\n\tenvelope: Pick<CapabilityEnvelope, \"allowedPaths\" | \"deniedPaths\">;\n\tcwd?: string;\n}): { reviewRequired: boolean; reasonCode: string } {\n\tif (args.changedFiles.length === 0) {\n\t\treturn { reviewRequired: false, reasonCode: \"no_changed_files\" };\n\t}\n\tconst syntheticId = \"managed-lane-review\";\n\tconst acceptance = validateWorkerClaim({\n\t\trequest: {\n\t\t\tid: syntheticId,\n\t\t\tinstructions: \"\",\n\t\t\troute: {\n\t\t\t\ttier: \"cheap\",\n\t\t\t\trisk: \"scoped-write\",\n\t\t\t\tconfidence: 1,\n\t\t\t\treasonCode: \"managed_lane_review\",\n\t\t\t\treasons: [],\n\t\t\t},\n\t\t\tenvelope: {\n\t\t\t\tid: syntheticId,\n\t\t\t\tcapabilities: [\"filesystem.write\"],\n\t\t\t\tallowedPaths: args.envelope.allowedPaths,\n\t\t\t\tdeniedPaths: args.envelope.deniedPaths,\n\t\t\t},\n\t\t},\n\t\tclaim: {\n\t\t\trequestId: syntheticId,\n\t\t\tstatus: \"completed\",\n\t\t\tsummary: \"\",\n\t\t\tchangedFiles: [...args.changedFiles],\n\t\t\tusageReportId: syntheticId,\n\t\t},\n\t\tcwd: args.cwd,\n\t});\n\treturn { reviewRequired: acceptance.outcome !== \"allow\", reasonCode: acceptance.reasonCode };\n}\n"]}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import type { SessionManager } from "@caupulican/pi-agent-core/node";
|
|
2
|
+
import type { Api, Model, Usage } from "@caupulican/pi-ai";
|
|
3
|
+
import type { AgentSessionEvent, IsolatedCompletionOptions, IsolatedCompletionResult, WorkerDelegationRunOutcome } from "../agent-session.ts";
|
|
4
|
+
import type { CapabilityEnvelope, WorkerClaim, WorkerRequest } from "../autonomy/contracts.ts";
|
|
5
|
+
import type { LaneRecord, LaneTerminalStatus } from "../autonomy/lane-tracker.ts";
|
|
6
|
+
import { type AutonomyTelemetryEvent } from "../autonomy/telemetry-events.ts";
|
|
7
|
+
import type { GoalState } from "../goals/goal-state.ts";
|
|
8
|
+
import type { ModelRegistry } from "../model-registry.ts";
|
|
9
|
+
import type { OrchestrationProfile } from "../orchestration/contracts.ts";
|
|
10
|
+
import type { TaskRuntimeProjection } from "../orchestration/task-runtime.ts";
|
|
11
|
+
import type { SettingsManager } from "../settings-manager.ts";
|
|
12
|
+
import type { WorkerDelegationRequest } from "./worker-delegation-request.ts";
|
|
13
|
+
import type { WorkerLifecycle } from "./worker-lifecycle.ts";
|
|
14
|
+
import type { WorkerNotificationCoordinator } from "./worker-notification-coordinator.ts";
|
|
15
|
+
export declare function isLocalExecutionModel(model: Pick<Model<Api>, "provider" | "baseUrl">): boolean;
|
|
16
|
+
export interface WorkerDelegationControllerDeps {
|
|
17
|
+
isDisposed(): boolean;
|
|
18
|
+
getSessionId(): string;
|
|
19
|
+
getCwd(): string;
|
|
20
|
+
getAgentDir(): string;
|
|
21
|
+
getSessionManager(): SessionManager;
|
|
22
|
+
getSettingsManager(): SettingsManager;
|
|
23
|
+
getActiveOrchestrationProfile?(): OrchestrationProfile | undefined;
|
|
24
|
+
getModelRegistry(): ModelRegistry;
|
|
25
|
+
isModelExhausted(model: Model<Api>): boolean;
|
|
26
|
+
getModel(): Model<Api> | undefined;
|
|
27
|
+
isDelegateToolActive(): boolean;
|
|
28
|
+
getCapabilityEnvelope(): CapabilityEnvelope | undefined;
|
|
29
|
+
emit(event: AgentSessionEvent): void;
|
|
30
|
+
notifyWorkerTerminalHandoff(records: readonly {
|
|
31
|
+
laneId: string;
|
|
32
|
+
status: LaneTerminalStatus;
|
|
33
|
+
reasonCode?: string;
|
|
34
|
+
}[]): Promise<void>;
|
|
35
|
+
emitAutonomyTelemetry(event: AutonomyTelemetryEvent): void;
|
|
36
|
+
getGoalStateSnapshot(): GoalState | undefined;
|
|
37
|
+
saveWorkerClaimSnapshot(claim: WorkerClaim, request?: WorkerRequest): string;
|
|
38
|
+
queueWorkerHumanInput(request: {
|
|
39
|
+
workerRequestId: string;
|
|
40
|
+
message: string;
|
|
41
|
+
blockers: readonly string[];
|
|
42
|
+
}): void;
|
|
43
|
+
readMemoryForLane(query: string): Promise<string>;
|
|
44
|
+
addSpawnedUsage(usage: Usage, opts: {
|
|
45
|
+
label?: string;
|
|
46
|
+
sourceSessionId?: string;
|
|
47
|
+
reportId: string;
|
|
48
|
+
}): string | undefined;
|
|
49
|
+
runIsolatedCompletion(opts: IsolatedCompletionOptions): Promise<IsolatedCompletionResult>;
|
|
50
|
+
}
|
|
51
|
+
export declare class WorkerDelegationController {
|
|
52
|
+
private readonly deps;
|
|
53
|
+
private readonly workerAbort;
|
|
54
|
+
private readonly lifecycle;
|
|
55
|
+
private profileResolver;
|
|
56
|
+
private queueRecovered;
|
|
57
|
+
private recoveringDurableState;
|
|
58
|
+
private readonly verificationRecoveryFailures;
|
|
59
|
+
private readonly notifications;
|
|
60
|
+
private readonly scheduler;
|
|
61
|
+
private readonly laneAbortControllers;
|
|
62
|
+
private readonly publishedTerminalAttemptIds;
|
|
63
|
+
private readonly inFlightLedgers;
|
|
64
|
+
constructor(deps: WorkerDelegationControllerDeps, notifications: WorkerNotificationCoordinator, lifecycle: WorkerLifecycle);
|
|
65
|
+
private safeWarn;
|
|
66
|
+
recordTerminal(record: LaneRecord): void;
|
|
67
|
+
getRecords(): LaneRecord[];
|
|
68
|
+
/** Process-local worker records for the shared terminal notifier; never triggers durable recovery. */
|
|
69
|
+
getLoadedRecords(): LaneRecord[];
|
|
70
|
+
markNotificationsDelivered(notificationIds: readonly string[]): void;
|
|
71
|
+
abort(): void;
|
|
72
|
+
private getWorkerLifecycle;
|
|
73
|
+
private getWorkerProfileResolver;
|
|
74
|
+
/** Read-only durable worker projection. Undefined means the delegate capability never loaded. */
|
|
75
|
+
getTaskRuntimeSnapshot(): TaskRuntimeProjection | undefined;
|
|
76
|
+
/** Reconcile the session goal into an already-loaded worker runtime without defeating lazy UAC. */
|
|
77
|
+
synchronizeGoalState(goal: GoalState): void;
|
|
78
|
+
private publishGoalTerminalRecords;
|
|
79
|
+
private recoverDurableQueue;
|
|
80
|
+
private laneCapabilityProfile;
|
|
81
|
+
getProfileCatalog(): Array<{
|
|
82
|
+
profileId: string;
|
|
83
|
+
role: string;
|
|
84
|
+
description: string;
|
|
85
|
+
}>;
|
|
86
|
+
private resolveWorkerShipment;
|
|
87
|
+
private resolveRequiredVerifier;
|
|
88
|
+
/** Single admission contract shared by enqueue, scheduler revalidation, and execution. */
|
|
89
|
+
private resolveWorkerAdmission;
|
|
90
|
+
private buildVerifierRequest;
|
|
91
|
+
private publishTerminalRecord;
|
|
92
|
+
private hasWorkerCapacity;
|
|
93
|
+
private workerDispatchAdmission;
|
|
94
|
+
private buildWorkerExecutionPlan;
|
|
95
|
+
/** One durable preparation path for queued, immediate, and recovered execution. */
|
|
96
|
+
private prepareWorkerAttempt;
|
|
97
|
+
start(request: WorkerDelegationRequest): {
|
|
98
|
+
started: false;
|
|
99
|
+
skipReason: string;
|
|
100
|
+
} | {
|
|
101
|
+
started: true;
|
|
102
|
+
record: LaneRecord;
|
|
103
|
+
};
|
|
104
|
+
private startInternal;
|
|
105
|
+
runOnce(request: WorkerDelegationRequest, onStarted?: (record: LaneRecord) => void, existingRecord?: LaneRecord): Promise<WorkerDelegationRunOutcome>;
|
|
106
|
+
private runOnceWithAdmission;
|
|
107
|
+
/** Start every capacity-eligible queued worker at the owner session's foreground-idle boundary. */
|
|
108
|
+
drain(): void;
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=worker-delegation-controller.d.ts.map
|