@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
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
* tool's worker scoping, and the read-only store options threaded through the persistence layer).
|
|
6
6
|
*
|
|
7
7
|
* A session is a worker iff EITHER:
|
|
8
|
-
* - `PI_SESSION_ROLE=worker` is set (an explicit launcher declaration),
|
|
8
|
+
* - `PI_SESSION_ROLE=worker` is set (an explicit launcher declaration),
|
|
9
|
+
* - a valid `PI_PARENT_PID` declares this process as a managed child, or
|
|
9
10
|
* - it is bound to a worktree-sync lane (`PI_WORKTREE_LANE`; see worktree-sync/runtime.ts) — a
|
|
10
11
|
* lane-bound session is a worker by construction, regardless of how it was launched.
|
|
11
12
|
*
|
|
@@ -14,15 +15,21 @@
|
|
|
14
15
|
* var is additive evidence for "worker", never a downgrade signal.
|
|
15
16
|
*/
|
|
16
17
|
export type SessionRole = "main" | "worker";
|
|
18
|
+
export type TerminalSessionMode = "user" | "worker";
|
|
19
|
+
export declare const PI_SESSION_ROLE_ENV = "PI_SESSION_ROLE";
|
|
20
|
+
export declare function isTerminalSessionMode(value: string): value is TerminalSessionMode;
|
|
21
|
+
/** Apply the terminal audience declaration without bypassing worker inference or UAC ceilings. */
|
|
22
|
+
export declare function setTerminalSessionMode(mode: TerminalSessionMode, env?: NodeJS.ProcessEnv): void;
|
|
17
23
|
/** Derive this process's session role from the environment (env-injectable for tests). */
|
|
18
24
|
export declare function getSessionRole(env?: NodeJS.ProcessEnv): SessionRole;
|
|
19
25
|
/** True iff this process is a worker session (lane-bound or explicitly declared). */
|
|
20
26
|
export declare function isWorkerSession(env?: NodeJS.ProcessEnv): boolean;
|
|
21
27
|
/**
|
|
22
28
|
* Tools a worker session may never activate: the orchestration/self-adaptation surface that would
|
|
23
|
-
* let a worker spawn its own sub-orchestration,
|
|
24
|
-
* shell out to the unbounded `python` execution contract.
|
|
25
|
-
* zero-footprint guarantee (it can write anywhere the interpreter
|
|
29
|
+
* let a worker spawn its own sub-orchestration, bypass its parent to request owner input, mutate
|
|
30
|
+
* settings-driven learning/model state, or shell out to the unbounded `python` execution contract.
|
|
31
|
+
* `python` is load-bearing for the zero-footprint guarantee (it can write anywhere the interpreter
|
|
32
|
+
* can reach); `context_scout` is
|
|
26
33
|
* sub-orchestration (spawns its own isolated agent loop). `bash` is deliberately NOT included: it
|
|
27
34
|
* stays available as the documented cooperative boundary (see docs/worktree-sync.md) — the same
|
|
28
35
|
* trust model the lane gate already applies to foreign CLIs it cannot structurally contain.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-role.d.ts","sourceRoot":"","sources":["../../src/core/session-role.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"session-role.d.ts","sourceRoot":"","sources":["../../src/core/session-role.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAKH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,QAAQ,CAAC;AAC5C,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,QAAQ,CAAC;AAEpD,eAAO,MAAM,mBAAmB,oBAAoB,CAAC;AAErD,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,mBAAmB,CAEjF;AAED,kGAAkG;AAClG,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,mBAAmB,EAAE,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,IAAI,CAM5G;AAED,0FAA0F;AAC1F,wBAAgB,cAAc,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,WAAW,CAKhF;AAED,qFAAqF;AACrF,wBAAgB,eAAe,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,OAAO,CAE7E;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,sBAAsB,EAAE,WAAW,CAAC,MAAM,CAcrD,CAAC","sourcesContent":["/**\n * Session-role identity: distinguishes a MAIN session (an interactive/direct `pi` session) from a\n * WORKER session (lane-bound or explicitly dispatched) — the seam every worker-scoped UAC ceiling\n * and zero-footprint store gates on (see runtime-builder.ts's `isAllowedTool`, the worktree_sync\n * tool's worker scoping, and the read-only store options threaded through the persistence layer).\n *\n * A session is a worker iff EITHER:\n * - `PI_SESSION_ROLE=worker` is set (an explicit launcher declaration),\n * - a valid `PI_PARENT_PID` declares this process as a managed child, or\n * - it is bound to a worktree-sync lane (`PI_WORKTREE_LANE`; see worktree-sync/runtime.ts) — a\n * lane-bound session is a worker by construction, regardless of how it was launched.\n *\n * `PI_SESSION_ROLE=main` is deliberately NOT an escalation: it can never override a bound lane.\n * There is no environment value a lane-bound process can set to shed the worker ceiling — the env\n * var is additive evidence for \"worker\", never a downgrade signal.\n */\n\nimport { getParentPid } from \"./process-identity.ts\";\nimport { getBoundWorktreeLaneKey } from \"./worktree-sync/runtime.ts\";\n\nexport type SessionRole = \"main\" | \"worker\";\nexport type TerminalSessionMode = \"user\" | \"worker\";\n\nexport const PI_SESSION_ROLE_ENV = \"PI_SESSION_ROLE\";\n\nexport function isTerminalSessionMode(value: string): value is TerminalSessionMode {\n\treturn value === \"user\" || value === \"worker\";\n}\n\n/** Apply the terminal audience declaration without bypassing worker inference or UAC ceilings. */\nexport function setTerminalSessionMode(mode: TerminalSessionMode, env: NodeJS.ProcessEnv = process.env): void {\n\tif (mode === \"worker\") {\n\t\tenv[PI_SESSION_ROLE_ENV] = \"worker\";\n\t} else if (env[PI_SESSION_ROLE_ENV] !== \"worker\") {\n\t\tenv[PI_SESSION_ROLE_ENV] = \"main\";\n\t}\n}\n\n/** Derive this process's session role from the environment (env-injectable for tests). */\nexport function getSessionRole(env: NodeJS.ProcessEnv = process.env): SessionRole {\n\tif (env[PI_SESSION_ROLE_ENV] === \"worker\") return \"worker\";\n\tif (getParentPid(env) !== undefined) return \"worker\";\n\tif (getBoundWorktreeLaneKey(env) !== undefined) return \"worker\";\n\treturn \"main\";\n}\n\n/** True iff this process is a worker session (lane-bound or explicitly declared). */\nexport function isWorkerSession(env: NodeJS.ProcessEnv = process.env): boolean {\n\treturn getSessionRole(env) === \"worker\";\n}\n\n/**\n * Tools a worker session may never activate: the orchestration/self-adaptation surface that would\n * let a worker spawn its own sub-orchestration, bypass its parent to request owner input, mutate\n * settings-driven learning/model state, or shell out to the unbounded `python` execution contract.\n * `python` is load-bearing for the zero-footprint guarantee (it can write anywhere the interpreter\n * can reach); `context_scout` is\n * sub-orchestration (spawns its own isolated agent loop). `bash` is deliberately NOT included: it\n * stays available as the documented cooperative boundary (see docs/worktree-sync.md) — the same\n * trust model the lane gate already applies to foreign CLIs it cannot structurally contain.\n */\nexport const WORKER_FORBIDDEN_TOOLS: ReadonlySet<string> = new Set([\n\t\"goal\",\n\t\"ask_question\",\n\t\"secret_store\",\n\t\"delegate\",\n\t\"delegate_status\",\n\t\"improvement_loop\",\n\t\"extensionify\",\n\t\"skillify\",\n\t\"run_toolkit_script\",\n\t\"model_fitness\",\n\t\"tmux_agent_manager\",\n\t\"context_scout\",\n\t\"python\",\n]);\n"]}
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
* tool's worker scoping, and the read-only store options threaded through the persistence layer).
|
|
6
6
|
*
|
|
7
7
|
* A session is a worker iff EITHER:
|
|
8
|
-
* - `PI_SESSION_ROLE=worker` is set (an explicit launcher declaration),
|
|
8
|
+
* - `PI_SESSION_ROLE=worker` is set (an explicit launcher declaration),
|
|
9
|
+
* - a valid `PI_PARENT_PID` declares this process as a managed child, or
|
|
9
10
|
* - it is bound to a worktree-sync lane (`PI_WORKTREE_LANE`; see worktree-sync/runtime.ts) — a
|
|
10
11
|
* lane-bound session is a worker by construction, regardless of how it was launched.
|
|
11
12
|
*
|
|
@@ -13,12 +14,27 @@
|
|
|
13
14
|
* There is no environment value a lane-bound process can set to shed the worker ceiling — the env
|
|
14
15
|
* var is additive evidence for "worker", never a downgrade signal.
|
|
15
16
|
*/
|
|
17
|
+
import { getParentPid } from "./process-identity.js";
|
|
16
18
|
import { getBoundWorktreeLaneKey } from "./worktree-sync/runtime.js";
|
|
17
|
-
const PI_SESSION_ROLE_ENV = "PI_SESSION_ROLE";
|
|
19
|
+
export const PI_SESSION_ROLE_ENV = "PI_SESSION_ROLE";
|
|
20
|
+
export function isTerminalSessionMode(value) {
|
|
21
|
+
return value === "user" || value === "worker";
|
|
22
|
+
}
|
|
23
|
+
/** Apply the terminal audience declaration without bypassing worker inference or UAC ceilings. */
|
|
24
|
+
export function setTerminalSessionMode(mode, env = process.env) {
|
|
25
|
+
if (mode === "worker") {
|
|
26
|
+
env[PI_SESSION_ROLE_ENV] = "worker";
|
|
27
|
+
}
|
|
28
|
+
else if (env[PI_SESSION_ROLE_ENV] !== "worker") {
|
|
29
|
+
env[PI_SESSION_ROLE_ENV] = "main";
|
|
30
|
+
}
|
|
31
|
+
}
|
|
18
32
|
/** Derive this process's session role from the environment (env-injectable for tests). */
|
|
19
33
|
export function getSessionRole(env = process.env) {
|
|
20
34
|
if (env[PI_SESSION_ROLE_ENV] === "worker")
|
|
21
35
|
return "worker";
|
|
36
|
+
if (getParentPid(env) !== undefined)
|
|
37
|
+
return "worker";
|
|
22
38
|
if (getBoundWorktreeLaneKey(env) !== undefined)
|
|
23
39
|
return "worker";
|
|
24
40
|
return "main";
|
|
@@ -29,15 +45,18 @@ export function isWorkerSession(env = process.env) {
|
|
|
29
45
|
}
|
|
30
46
|
/**
|
|
31
47
|
* Tools a worker session may never activate: the orchestration/self-adaptation surface that would
|
|
32
|
-
* let a worker spawn its own sub-orchestration,
|
|
33
|
-
* shell out to the unbounded `python` execution contract.
|
|
34
|
-
* zero-footprint guarantee (it can write anywhere the interpreter
|
|
48
|
+
* let a worker spawn its own sub-orchestration, bypass its parent to request owner input, mutate
|
|
49
|
+
* settings-driven learning/model state, or shell out to the unbounded `python` execution contract.
|
|
50
|
+
* `python` is load-bearing for the zero-footprint guarantee (it can write anywhere the interpreter
|
|
51
|
+
* can reach); `context_scout` is
|
|
35
52
|
* sub-orchestration (spawns its own isolated agent loop). `bash` is deliberately NOT included: it
|
|
36
53
|
* stays available as the documented cooperative boundary (see docs/worktree-sync.md) — the same
|
|
37
54
|
* trust model the lane gate already applies to foreign CLIs it cannot structurally contain.
|
|
38
55
|
*/
|
|
39
56
|
export const WORKER_FORBIDDEN_TOOLS = new Set([
|
|
40
57
|
"goal",
|
|
58
|
+
"ask_question",
|
|
59
|
+
"secret_store",
|
|
41
60
|
"delegate",
|
|
42
61
|
"delegate_status",
|
|
43
62
|
"improvement_loop",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-role.js","sourceRoot":"","sources":["../../src/core/session-role.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"session-role.js","sourceRoot":"","sources":["../../src/core/session-role.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAKrE,MAAM,CAAC,MAAM,mBAAmB,GAAG,iBAAiB,CAAC;AAErD,MAAM,UAAU,qBAAqB,CAAC,KAAa,EAAgC;IAClF,OAAO,KAAK,KAAK,MAAM,IAAI,KAAK,KAAK,QAAQ,CAAC;AAAA,CAC9C;AAED,kGAAkG;AAClG,MAAM,UAAU,sBAAsB,CAAC,IAAyB,EAAE,GAAG,GAAsB,OAAO,CAAC,GAAG,EAAQ;IAC7G,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;QACvB,GAAG,CAAC,mBAAmB,CAAC,GAAG,QAAQ,CAAC;IACrC,CAAC;SAAM,IAAI,GAAG,CAAC,mBAAmB,CAAC,KAAK,QAAQ,EAAE,CAAC;QAClD,GAAG,CAAC,mBAAmB,CAAC,GAAG,MAAM,CAAC;IACnC,CAAC;AAAA,CACD;AAED,0FAA0F;AAC1F,MAAM,UAAU,cAAc,CAAC,GAAG,GAAsB,OAAO,CAAC,GAAG,EAAe;IACjF,IAAI,GAAG,CAAC,mBAAmB,CAAC,KAAK,QAAQ;QAAE,OAAO,QAAQ,CAAC;IAC3D,IAAI,YAAY,CAAC,GAAG,CAAC,KAAK,SAAS;QAAE,OAAO,QAAQ,CAAC;IACrD,IAAI,uBAAuB,CAAC,GAAG,CAAC,KAAK,SAAS;QAAE,OAAO,QAAQ,CAAC;IAChE,OAAO,MAAM,CAAC;AAAA,CACd;AAED,qFAAqF;AACrF,MAAM,UAAU,eAAe,CAAC,GAAG,GAAsB,OAAO,CAAC,GAAG,EAAW;IAC9E,OAAO,cAAc,CAAC,GAAG,CAAC,KAAK,QAAQ,CAAC;AAAA,CACxC;AAED;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAwB,IAAI,GAAG,CAAC;IAClE,MAAM;IACN,cAAc;IACd,cAAc;IACd,UAAU;IACV,iBAAiB;IACjB,kBAAkB;IAClB,cAAc;IACd,UAAU;IACV,oBAAoB;IACpB,eAAe;IACf,oBAAoB;IACpB,eAAe;IACf,QAAQ;CACR,CAAC,CAAC","sourcesContent":["/**\n * Session-role identity: distinguishes a MAIN session (an interactive/direct `pi` session) from a\n * WORKER session (lane-bound or explicitly dispatched) — the seam every worker-scoped UAC ceiling\n * and zero-footprint store gates on (see runtime-builder.ts's `isAllowedTool`, the worktree_sync\n * tool's worker scoping, and the read-only store options threaded through the persistence layer).\n *\n * A session is a worker iff EITHER:\n * - `PI_SESSION_ROLE=worker` is set (an explicit launcher declaration),\n * - a valid `PI_PARENT_PID` declares this process as a managed child, or\n * - it is bound to a worktree-sync lane (`PI_WORKTREE_LANE`; see worktree-sync/runtime.ts) — a\n * lane-bound session is a worker by construction, regardless of how it was launched.\n *\n * `PI_SESSION_ROLE=main` is deliberately NOT an escalation: it can never override a bound lane.\n * There is no environment value a lane-bound process can set to shed the worker ceiling — the env\n * var is additive evidence for \"worker\", never a downgrade signal.\n */\n\nimport { getParentPid } from \"./process-identity.ts\";\nimport { getBoundWorktreeLaneKey } from \"./worktree-sync/runtime.ts\";\n\nexport type SessionRole = \"main\" | \"worker\";\nexport type TerminalSessionMode = \"user\" | \"worker\";\n\nexport const PI_SESSION_ROLE_ENV = \"PI_SESSION_ROLE\";\n\nexport function isTerminalSessionMode(value: string): value is TerminalSessionMode {\n\treturn value === \"user\" || value === \"worker\";\n}\n\n/** Apply the terminal audience declaration without bypassing worker inference or UAC ceilings. */\nexport function setTerminalSessionMode(mode: TerminalSessionMode, env: NodeJS.ProcessEnv = process.env): void {\n\tif (mode === \"worker\") {\n\t\tenv[PI_SESSION_ROLE_ENV] = \"worker\";\n\t} else if (env[PI_SESSION_ROLE_ENV] !== \"worker\") {\n\t\tenv[PI_SESSION_ROLE_ENV] = \"main\";\n\t}\n}\n\n/** Derive this process's session role from the environment (env-injectable for tests). */\nexport function getSessionRole(env: NodeJS.ProcessEnv = process.env): SessionRole {\n\tif (env[PI_SESSION_ROLE_ENV] === \"worker\") return \"worker\";\n\tif (getParentPid(env) !== undefined) return \"worker\";\n\tif (getBoundWorktreeLaneKey(env) !== undefined) return \"worker\";\n\treturn \"main\";\n}\n\n/** True iff this process is a worker session (lane-bound or explicitly declared). */\nexport function isWorkerSession(env: NodeJS.ProcessEnv = process.env): boolean {\n\treturn getSessionRole(env) === \"worker\";\n}\n\n/**\n * Tools a worker session may never activate: the orchestration/self-adaptation surface that would\n * let a worker spawn its own sub-orchestration, bypass its parent to request owner input, mutate\n * settings-driven learning/model state, or shell out to the unbounded `python` execution contract.\n * `python` is load-bearing for the zero-footprint guarantee (it can write anywhere the interpreter\n * can reach); `context_scout` is\n * sub-orchestration (spawns its own isolated agent loop). `bash` is deliberately NOT included: it\n * stays available as the documented cooperative boundary (see docs/worktree-sync.md) — the same\n * trust model the lane gate already applies to foreign CLIs it cannot structurally contain.\n */\nexport const WORKER_FORBIDDEN_TOOLS: ReadonlySet<string> = new Set([\n\t\"goal\",\n\t\"ask_question\",\n\t\"secret_store\",\n\t\"delegate\",\n\t\"delegate_status\",\n\t\"improvement_loop\",\n\t\"extensionify\",\n\t\"skillify\",\n\t\"run_toolkit_script\",\n\t\"model_fitness\",\n\t\"tmux_agent_manager\",\n\t\"context_scout\",\n\t\"python\",\n]);\n"]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { SessionEntry, SessionManager } from "@caupulican/pi-agent-core/node";
|
|
2
|
+
export type SessionSnapshotPayload<ValueKey extends string, Value extends object> = {
|
|
3
|
+
version: 1;
|
|
4
|
+
} & {
|
|
5
|
+
[Key in ValueKey]: Value;
|
|
6
|
+
};
|
|
7
|
+
export interface SessionSnapshotCodec<Value extends object, ValueKey extends string> {
|
|
8
|
+
customType: string;
|
|
9
|
+
valueKey: ValueKey;
|
|
10
|
+
isValue(value: unknown): value is Value;
|
|
11
|
+
clone(value: Value): Value;
|
|
12
|
+
}
|
|
13
|
+
export interface SessionBranchEntrySource {
|
|
14
|
+
getBranch?: () => readonly SessionEntry[];
|
|
15
|
+
getEntries?: () => readonly SessionEntry[];
|
|
16
|
+
}
|
|
17
|
+
type VersionOneSnapshotPayload = Record<string, unknown> & {
|
|
18
|
+
version: 1;
|
|
19
|
+
};
|
|
20
|
+
/** Active branch when available; linear entry history only for narrow stores that expose no branch API. */
|
|
21
|
+
export declare function getActiveSessionBranchEntries(source: SessionBranchEntrySource): readonly SessionEntry[];
|
|
22
|
+
export declare function isVersionOneSessionSnapshotPayload(data: unknown): data is VersionOneSnapshotPayload;
|
|
23
|
+
export declare function createSessionSnapshotPayload<Value extends object, ValueKey extends string>(codec: SessionSnapshotCodec<Value, ValueKey>, value: Value): SessionSnapshotPayload<ValueKey, Value>;
|
|
24
|
+
export declare function appendSessionSnapshot<Value extends object, ValueKey extends string>(sessionManager: Pick<SessionManager, "appendCustomEntry">, codec: SessionSnapshotCodec<Value, ValueKey>, value: Value): string;
|
|
25
|
+
export declare function decodeSessionSnapshotPayload<Value extends object, ValueKey extends string>(data: unknown, codec: SessionSnapshotCodec<Value, ValueKey>): Value | undefined;
|
|
26
|
+
export declare function getSessionSnapshots<Value extends object, ValueKey extends string>(entries: readonly SessionEntry[], codec: SessionSnapshotCodec<Value, ValueKey>): Value[];
|
|
27
|
+
export declare function getLatestSessionSnapshot<Value extends object, ValueKey extends string>(entries: readonly SessionEntry[], codec: SessionSnapshotCodec<Value, ValueKey>): Value | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* Resolves the newest valid snapshot on the active branch. Malformed entries are skipped while
|
|
30
|
+
* walking leaf to root so they cannot hide an older valid checkpoint.
|
|
31
|
+
*/
|
|
32
|
+
export declare function getLatestSessionSnapshotOnBranch<Value extends object, ValueKey extends string>(sessionManager: Pick<SessionManager, "getLatestCustomEntryOnBranch">, codec: SessionSnapshotCodec<Value, ValueKey>): Value | undefined;
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=session-snapshot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-snapshot.d.ts","sourceRoot":"","sources":["../../src/core/session-snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAGnF,MAAM,MAAM,sBAAsB,CAAC,QAAQ,SAAS,MAAM,EAAE,KAAK,SAAS,MAAM,IAAI;IACnF,OAAO,EAAE,CAAC,CAAC;CACX,GAAG;KACF,GAAG,IAAI,QAAQ,GAAG,KAAK;CACxB,CAAC;AAEF,MAAM,WAAW,oBAAoB,CAAC,KAAK,SAAS,MAAM,EAAE,QAAQ,SAAS,MAAM;IAClF,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,QAAQ,CAAC;IACnB,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,KAAK,CAAC;IACxC,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,CAAC;CAC3B;AAED,MAAM,WAAW,wBAAwB;IACxC,SAAS,CAAC,EAAE,MAAM,SAAS,YAAY,EAAE,CAAC;IAC1C,UAAU,CAAC,EAAE,MAAM,SAAS,YAAY,EAAE,CAAC;CAC3C;AAED,KAAK,yBAAyB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IAAE,OAAO,EAAE,CAAC,CAAA;CAAE,CAAC;AAE1E,2GAA2G;AAC3G,wBAAgB,6BAA6B,CAAC,MAAM,EAAE,wBAAwB,GAAG,SAAS,YAAY,EAAE,CAIvG;AAED,wBAAgB,kCAAkC,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,yBAAyB,CAEnG;AAED,wBAAgB,4BAA4B,CAAC,KAAK,SAAS,MAAM,EAAE,QAAQ,SAAS,MAAM,EACzF,KAAK,EAAE,oBAAoB,CAAC,KAAK,EAAE,QAAQ,CAAC,EAC5C,KAAK,EAAE,KAAK,GACV,sBAAsB,CAAC,QAAQ,EAAE,KAAK,CAAC,CAKzC;AAED,wBAAgB,qBAAqB,CAAC,KAAK,SAAS,MAAM,EAAE,QAAQ,SAAS,MAAM,EAClF,cAAc,EAAE,IAAI,CAAC,cAAc,EAAE,mBAAmB,CAAC,EACzD,KAAK,EAAE,oBAAoB,CAAC,KAAK,EAAE,QAAQ,CAAC,EAC5C,KAAK,EAAE,KAAK,GACV,MAAM,CAER;AAED,wBAAgB,4BAA4B,CAAC,KAAK,SAAS,MAAM,EAAE,QAAQ,SAAS,MAAM,EACzF,IAAI,EAAE,OAAO,EACb,KAAK,EAAE,oBAAoB,CAAC,KAAK,EAAE,QAAQ,CAAC,GAC1C,KAAK,GAAG,SAAS,CAInB;AAED,wBAAgB,mBAAmB,CAAC,KAAK,SAAS,MAAM,EAAE,QAAQ,SAAS,MAAM,EAChF,OAAO,EAAE,SAAS,YAAY,EAAE,EAChC,KAAK,EAAE,oBAAoB,CAAC,KAAK,EAAE,QAAQ,CAAC,GAC1C,KAAK,EAAE,CAQT;AAED,wBAAgB,wBAAwB,CAAC,KAAK,SAAS,MAAM,EAAE,QAAQ,SAAS,MAAM,EACrF,OAAO,EAAE,SAAS,YAAY,EAAE,EAChC,KAAK,EAAE,oBAAoB,CAAC,KAAK,EAAE,QAAQ,CAAC,GAC1C,KAAK,GAAG,SAAS,CAQnB;AAED;;;GAGG;AACH,wBAAgB,gCAAgC,CAAC,KAAK,SAAS,MAAM,EAAE,QAAQ,SAAS,MAAM,EAC7F,cAAc,EAAE,IAAI,CAAC,cAAc,EAAE,8BAA8B,CAAC,EACpE,KAAK,EAAE,oBAAoB,CAAC,KAAK,EAAE,QAAQ,CAAC,GAC1C,KAAK,GAAG,SAAS,CAUnB","sourcesContent":["import type { SessionEntry, SessionManager } from \"@caupulican/pi-agent-core/node\";\nimport { isPlainRecord } from \"./util/value-guards.ts\";\n\nexport type SessionSnapshotPayload<ValueKey extends string, Value extends object> = {\n\tversion: 1;\n} & {\n\t[Key in ValueKey]: Value;\n};\n\nexport interface SessionSnapshotCodec<Value extends object, ValueKey extends string> {\n\tcustomType: string;\n\tvalueKey: ValueKey;\n\tisValue(value: unknown): value is Value;\n\tclone(value: Value): Value;\n}\n\nexport interface SessionBranchEntrySource {\n\tgetBranch?: () => readonly SessionEntry[];\n\tgetEntries?: () => readonly SessionEntry[];\n}\n\ntype VersionOneSnapshotPayload = Record<string, unknown> & { version: 1 };\n\n/** Active branch when available; linear entry history only for narrow stores that expose no branch API. */\nexport function getActiveSessionBranchEntries(source: SessionBranchEntrySource): readonly SessionEntry[] {\n\tif (typeof source.getBranch === \"function\") return source.getBranch();\n\tif (typeof source.getEntries === \"function\") return source.getEntries();\n\tthrow new TypeError(\"Session branch entry source exposes neither getBranch nor getEntries\");\n}\n\nexport function isVersionOneSessionSnapshotPayload(data: unknown): data is VersionOneSnapshotPayload {\n\treturn isPlainRecord(data) && data.version === 1;\n}\n\nexport function createSessionSnapshotPayload<Value extends object, ValueKey extends string>(\n\tcodec: SessionSnapshotCodec<Value, ValueKey>,\n\tvalue: Value,\n): SessionSnapshotPayload<ValueKey, Value> {\n\treturn {\n\t\tversion: 1,\n\t\t[codec.valueKey]: codec.clone(value),\n\t} as SessionSnapshotPayload<ValueKey, Value>;\n}\n\nexport function appendSessionSnapshot<Value extends object, ValueKey extends string>(\n\tsessionManager: Pick<SessionManager, \"appendCustomEntry\">,\n\tcodec: SessionSnapshotCodec<Value, ValueKey>,\n\tvalue: Value,\n): string {\n\treturn sessionManager.appendCustomEntry(codec.customType, createSessionSnapshotPayload(codec, value));\n}\n\nexport function decodeSessionSnapshotPayload<Value extends object, ValueKey extends string>(\n\tdata: unknown,\n\tcodec: SessionSnapshotCodec<Value, ValueKey>,\n): Value | undefined {\n\tif (!isVersionOneSessionSnapshotPayload(data)) return undefined;\n\tconst value = data[codec.valueKey];\n\treturn codec.isValue(value) ? codec.clone(value) : undefined;\n}\n\nexport function getSessionSnapshots<Value extends object, ValueKey extends string>(\n\tentries: readonly SessionEntry[],\n\tcodec: SessionSnapshotCodec<Value, ValueKey>,\n): Value[] {\n\tconst snapshots: Value[] = [];\n\tfor (const entry of entries) {\n\t\tif (entry.type !== \"custom\" || entry.customType !== codec.customType) continue;\n\t\tconst snapshot = decodeSessionSnapshotPayload(entry.data, codec);\n\t\tif (snapshot !== undefined) snapshots.push(snapshot);\n\t}\n\treturn snapshots;\n}\n\nexport function getLatestSessionSnapshot<Value extends object, ValueKey extends string>(\n\tentries: readonly SessionEntry[],\n\tcodec: SessionSnapshotCodec<Value, ValueKey>,\n): Value | undefined {\n\tfor (let index = entries.length - 1; index >= 0; index--) {\n\t\tconst entry = entries[index];\n\t\tif (entry.type !== \"custom\" || entry.customType !== codec.customType) continue;\n\t\tconst snapshot = decodeSessionSnapshotPayload(entry.data, codec);\n\t\tif (snapshot !== undefined) return snapshot;\n\t}\n\treturn undefined;\n}\n\n/**\n * Resolves the newest valid snapshot on the active branch. Malformed entries are skipped while\n * walking leaf to root so they cannot hide an older valid checkpoint.\n */\nexport function getLatestSessionSnapshotOnBranch<Value extends object, ValueKey extends string>(\n\tsessionManager: Pick<SessionManager, \"getLatestCustomEntryOnBranch\">,\n\tcodec: SessionSnapshotCodec<Value, ValueKey>,\n): Value | undefined {\n\tlet fromId: string | undefined;\n\tfor (;;) {\n\t\tconst entry = sessionManager.getLatestCustomEntryOnBranch(codec.customType, fromId);\n\t\tif (!entry) return undefined;\n\t\tconst snapshot = decodeSessionSnapshotPayload(entry.data, codec);\n\t\tif (snapshot !== undefined) return snapshot;\n\t\tif (entry.parentId === null) return undefined;\n\t\tfromId = entry.parentId;\n\t}\n}\n"]}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { isPlainRecord } from "./util/value-guards.js";
|
|
2
|
+
/** Active branch when available; linear entry history only for narrow stores that expose no branch API. */
|
|
3
|
+
export function getActiveSessionBranchEntries(source) {
|
|
4
|
+
if (typeof source.getBranch === "function")
|
|
5
|
+
return source.getBranch();
|
|
6
|
+
if (typeof source.getEntries === "function")
|
|
7
|
+
return source.getEntries();
|
|
8
|
+
throw new TypeError("Session branch entry source exposes neither getBranch nor getEntries");
|
|
9
|
+
}
|
|
10
|
+
export function isVersionOneSessionSnapshotPayload(data) {
|
|
11
|
+
return isPlainRecord(data) && data.version === 1;
|
|
12
|
+
}
|
|
13
|
+
export function createSessionSnapshotPayload(codec, value) {
|
|
14
|
+
return {
|
|
15
|
+
version: 1,
|
|
16
|
+
[codec.valueKey]: codec.clone(value),
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export function appendSessionSnapshot(sessionManager, codec, value) {
|
|
20
|
+
return sessionManager.appendCustomEntry(codec.customType, createSessionSnapshotPayload(codec, value));
|
|
21
|
+
}
|
|
22
|
+
export function decodeSessionSnapshotPayload(data, codec) {
|
|
23
|
+
if (!isVersionOneSessionSnapshotPayload(data))
|
|
24
|
+
return undefined;
|
|
25
|
+
const value = data[codec.valueKey];
|
|
26
|
+
return codec.isValue(value) ? codec.clone(value) : undefined;
|
|
27
|
+
}
|
|
28
|
+
export function getSessionSnapshots(entries, codec) {
|
|
29
|
+
const snapshots = [];
|
|
30
|
+
for (const entry of entries) {
|
|
31
|
+
if (entry.type !== "custom" || entry.customType !== codec.customType)
|
|
32
|
+
continue;
|
|
33
|
+
const snapshot = decodeSessionSnapshotPayload(entry.data, codec);
|
|
34
|
+
if (snapshot !== undefined)
|
|
35
|
+
snapshots.push(snapshot);
|
|
36
|
+
}
|
|
37
|
+
return snapshots;
|
|
38
|
+
}
|
|
39
|
+
export function getLatestSessionSnapshot(entries, codec) {
|
|
40
|
+
for (let index = entries.length - 1; index >= 0; index--) {
|
|
41
|
+
const entry = entries[index];
|
|
42
|
+
if (entry.type !== "custom" || entry.customType !== codec.customType)
|
|
43
|
+
continue;
|
|
44
|
+
const snapshot = decodeSessionSnapshotPayload(entry.data, codec);
|
|
45
|
+
if (snapshot !== undefined)
|
|
46
|
+
return snapshot;
|
|
47
|
+
}
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Resolves the newest valid snapshot on the active branch. Malformed entries are skipped while
|
|
52
|
+
* walking leaf to root so they cannot hide an older valid checkpoint.
|
|
53
|
+
*/
|
|
54
|
+
export function getLatestSessionSnapshotOnBranch(sessionManager, codec) {
|
|
55
|
+
let fromId;
|
|
56
|
+
for (;;) {
|
|
57
|
+
const entry = sessionManager.getLatestCustomEntryOnBranch(codec.customType, fromId);
|
|
58
|
+
if (!entry)
|
|
59
|
+
return undefined;
|
|
60
|
+
const snapshot = decodeSessionSnapshotPayload(entry.data, codec);
|
|
61
|
+
if (snapshot !== undefined)
|
|
62
|
+
return snapshot;
|
|
63
|
+
if (entry.parentId === null)
|
|
64
|
+
return undefined;
|
|
65
|
+
fromId = entry.parentId;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=session-snapshot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-snapshot.js","sourceRoot":"","sources":["../../src/core/session-snapshot.ts"],"names":[],"mappings":"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","sourcesContent":["import type { SessionEntry, SessionManager } from \"@caupulican/pi-agent-core/node\";\nimport { isPlainRecord } from \"./util/value-guards.ts\";\n\nexport type SessionSnapshotPayload<ValueKey extends string, Value extends object> = {\n\tversion: 1;\n} & {\n\t[Key in ValueKey]: Value;\n};\n\nexport interface SessionSnapshotCodec<Value extends object, ValueKey extends string> {\n\tcustomType: string;\n\tvalueKey: ValueKey;\n\tisValue(value: unknown): value is Value;\n\tclone(value: Value): Value;\n}\n\nexport interface SessionBranchEntrySource {\n\tgetBranch?: () => readonly SessionEntry[];\n\tgetEntries?: () => readonly SessionEntry[];\n}\n\ntype VersionOneSnapshotPayload = Record<string, unknown> & { version: 1 };\n\n/** Active branch when available; linear entry history only for narrow stores that expose no branch API. */\nexport function getActiveSessionBranchEntries(source: SessionBranchEntrySource): readonly SessionEntry[] {\n\tif (typeof source.getBranch === \"function\") return source.getBranch();\n\tif (typeof source.getEntries === \"function\") return source.getEntries();\n\tthrow new TypeError(\"Session branch entry source exposes neither getBranch nor getEntries\");\n}\n\nexport function isVersionOneSessionSnapshotPayload(data: unknown): data is VersionOneSnapshotPayload {\n\treturn isPlainRecord(data) && data.version === 1;\n}\n\nexport function createSessionSnapshotPayload<Value extends object, ValueKey extends string>(\n\tcodec: SessionSnapshotCodec<Value, ValueKey>,\n\tvalue: Value,\n): SessionSnapshotPayload<ValueKey, Value> {\n\treturn {\n\t\tversion: 1,\n\t\t[codec.valueKey]: codec.clone(value),\n\t} as SessionSnapshotPayload<ValueKey, Value>;\n}\n\nexport function appendSessionSnapshot<Value extends object, ValueKey extends string>(\n\tsessionManager: Pick<SessionManager, \"appendCustomEntry\">,\n\tcodec: SessionSnapshotCodec<Value, ValueKey>,\n\tvalue: Value,\n): string {\n\treturn sessionManager.appendCustomEntry(codec.customType, createSessionSnapshotPayload(codec, value));\n}\n\nexport function decodeSessionSnapshotPayload<Value extends object, ValueKey extends string>(\n\tdata: unknown,\n\tcodec: SessionSnapshotCodec<Value, ValueKey>,\n): Value | undefined {\n\tif (!isVersionOneSessionSnapshotPayload(data)) return undefined;\n\tconst value = data[codec.valueKey];\n\treturn codec.isValue(value) ? codec.clone(value) : undefined;\n}\n\nexport function getSessionSnapshots<Value extends object, ValueKey extends string>(\n\tentries: readonly SessionEntry[],\n\tcodec: SessionSnapshotCodec<Value, ValueKey>,\n): Value[] {\n\tconst snapshots: Value[] = [];\n\tfor (const entry of entries) {\n\t\tif (entry.type !== \"custom\" || entry.customType !== codec.customType) continue;\n\t\tconst snapshot = decodeSessionSnapshotPayload(entry.data, codec);\n\t\tif (snapshot !== undefined) snapshots.push(snapshot);\n\t}\n\treturn snapshots;\n}\n\nexport function getLatestSessionSnapshot<Value extends object, ValueKey extends string>(\n\tentries: readonly SessionEntry[],\n\tcodec: SessionSnapshotCodec<Value, ValueKey>,\n): Value | undefined {\n\tfor (let index = entries.length - 1; index >= 0; index--) {\n\t\tconst entry = entries[index];\n\t\tif (entry.type !== \"custom\" || entry.customType !== codec.customType) continue;\n\t\tconst snapshot = decodeSessionSnapshotPayload(entry.data, codec);\n\t\tif (snapshot !== undefined) return snapshot;\n\t}\n\treturn undefined;\n}\n\n/**\n * Resolves the newest valid snapshot on the active branch. Malformed entries are skipped while\n * walking leaf to root so they cannot hide an older valid checkpoint.\n */\nexport function getLatestSessionSnapshotOnBranch<Value extends object, ValueKey extends string>(\n\tsessionManager: Pick<SessionManager, \"getLatestCustomEntryOnBranch\">,\n\tcodec: SessionSnapshotCodec<Value, ValueKey>,\n): Value | undefined {\n\tlet fromId: string | undefined;\n\tfor (;;) {\n\t\tconst entry = sessionManager.getLatestCustomEntryOnBranch(codec.customType, fromId);\n\t\tif (!entry) return undefined;\n\t\tconst snapshot = decodeSessionSnapshotPayload(entry.data, codec);\n\t\tif (snapshot !== undefined) return snapshot;\n\t\tif (entry.parentId === null) return undefined;\n\t\tfromId = entry.parentId;\n\t}\n}\n"]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { AgentSession } from "./agent-session.ts";
|
|
2
|
+
import type { AgentSessionRuntimeResource } from "./agent-session-runtime.ts";
|
|
3
|
+
import type { ResumablePayload } from "./process-matrix/codes.ts";
|
|
4
|
+
import { type ResumeWorkerLaunchOutcome } from "./process-matrix/runtime.ts";
|
|
5
|
+
export interface SessionSupervisionRuntimeOptions {
|
|
6
|
+
agentDir: string;
|
|
7
|
+
hasUI: boolean;
|
|
8
|
+
orchestrationProfileId?: string;
|
|
9
|
+
isProcessAlive: (pid: number) => boolean;
|
|
10
|
+
promptConfirm: (message: string) => Promise<boolean>;
|
|
11
|
+
resumeWorker: (payload: ResumablePayload, parentSessionId: string) => Promise<ResumeWorkerLaunchOutcome>;
|
|
12
|
+
onDiagnostic: (message: string) => void;
|
|
13
|
+
requestExit: (session: AgentSession) => void;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Owns the process-matrix and worktree-sync handles for the currently active session.
|
|
17
|
+
* Replacement stops the old generation before a new one is started, so no watcher can retain a
|
|
18
|
+
* disposed session or deliver a notice across a `/new`, `/resume`, or `/fork` boundary.
|
|
19
|
+
*/
|
|
20
|
+
export declare class SessionSupervisionRuntime implements AgentSessionRuntimeResource {
|
|
21
|
+
private readonly options;
|
|
22
|
+
private generation;
|
|
23
|
+
private processMatrix?;
|
|
24
|
+
private worktreeSync?;
|
|
25
|
+
constructor(options: SessionSupervisionRuntimeOptions);
|
|
26
|
+
start(session: AgentSession): Promise<void>;
|
|
27
|
+
stop(): Promise<void>;
|
|
28
|
+
private stopHandles;
|
|
29
|
+
private notify;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=session-supervision-runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-supervision-runtime.d.ts","sourceRoot":"","sources":["../../src/core/session-supervision-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AAE9E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAIN,KAAK,yBAAyB,EAE9B,MAAM,6BAA6B,CAAC;AAIrC,MAAM,WAAW,gCAAgC;IAChD,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;IACf,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,cAAc,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;IACzC,aAAa,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACrD,YAAY,EAAE,CAAC,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,KAAK,OAAO,CAAC,yBAAyB,CAAC,CAAC;IACzG,YAAY,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,WAAW,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,IAAI,CAAC;CAC7C;AAED;;;;GAIG;AACH,qBAAa,yBAA0B,YAAW,2BAA2B;IAC5E,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAmC;IAC3D,OAAO,CAAC,UAAU,CAAK;IACvB,OAAO,CAAC,aAAa,CAAC,CAA6B;IACnD,OAAO,CAAC,YAAY,CAAC,CAA4B;IAEjD,YAAY,OAAO,EAAE,gCAAgC,EAEpD;IAEK,KAAK,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CA4DhD;IAEK,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAG1B;YAEa,WAAW;YAQX,MAAM;CAYpB","sourcesContent":["import type { AgentSession } from \"./agent-session.ts\";\nimport type { AgentSessionRuntimeResource } from \"./agent-session-runtime.ts\";\nimport { createAgentIdentity } from \"./orchestration/agent-resume.ts\";\nimport type { ResumablePayload } from \"./process-matrix/codes.ts\";\nimport {\n\tgetOrchestrationAgentId,\n\tgetProcessTaskRef,\n\ttype ProcessMatrixRuntimeHandle,\n\ttype ResumeWorkerLaunchOutcome,\n\tstartProcessMatrixRuntime,\n} from \"./process-matrix/runtime.ts\";\nimport type { WorktreeSyncRuntimeHandle } from \"./worktree-sync/runtime.ts\";\nimport { getBoundWorktreeLaneKey, startWorktreeSyncRuntime } from \"./worktree-sync/runtime.ts\";\n\nexport interface SessionSupervisionRuntimeOptions {\n\tagentDir: string;\n\thasUI: boolean;\n\torchestrationProfileId?: string;\n\tisProcessAlive: (pid: number) => boolean;\n\tpromptConfirm: (message: string) => Promise<boolean>;\n\tresumeWorker: (payload: ResumablePayload, parentSessionId: string) => Promise<ResumeWorkerLaunchOutcome>;\n\tonDiagnostic: (message: string) => void;\n\trequestExit: (session: AgentSession) => void;\n}\n\n/**\n * Owns the process-matrix and worktree-sync handles for the currently active session.\n * Replacement stops the old generation before a new one is started, so no watcher can retain a\n * disposed session or deliver a notice across a `/new`, `/resume`, or `/fork` boundary.\n */\nexport class SessionSupervisionRuntime implements AgentSessionRuntimeResource {\n\tprivate readonly options: SessionSupervisionRuntimeOptions;\n\tprivate generation = 0;\n\tprivate processMatrix?: ProcessMatrixRuntimeHandle;\n\tprivate worktreeSync?: WorktreeSyncRuntimeHandle;\n\n\tconstructor(options: SessionSupervisionRuntimeOptions) {\n\t\tthis.options = options;\n\t}\n\n\tasync start(session: AgentSession): Promise<void> {\n\t\tconst generation = ++this.generation;\n\t\tawait this.stopHandles();\n\t\tconst sessionManager = session.sessionManager;\n\t\tconst sessionId = sessionManager.getSessionId();\n\t\tconst boundWorktreeLaneKey = getBoundWorktreeLaneKey();\n\t\tconst orchestrationProfileId =\n\t\t\tthis.options.orchestrationProfileId ??\n\t\t\tsession.capabilityEnvelope?.profileId ??\n\t\t\tsession.settingsManager.getActiveOrchestrationProfile();\n\t\tconst sessionFile = sessionManager.getSessionFile();\n\t\tconst goal = session.getGoalStateSnapshot();\n\t\tconst taskRef = getProcessTaskRef() ?? goal?.goalId;\n\t\tconst agent = createAgentIdentity(getOrchestrationAgentId() ?? sessionId, {\n\t\t\tprovider: \"pi\",\n\t\t\tsessionId,\n\t\t\tsessionDir: sessionManager.getSessionDir(),\n\t\t\t...(sessionFile ? { sessionFile } : {}),\n\t\t\tcwd: sessionManager.getCwd(),\n\t\t\t...(boundWorktreeLaneKey ? { worktreeLaneKey: boundWorktreeLaneKey } : {}),\n\t\t\t...(orchestrationProfileId ? { orchestrationProfileId } : {}),\n\t\t\tresourceProfileNames: session.settingsManager.getActiveResourceProfileNames(),\n\t\t\t...(session.model ? { modelRef: `${session.model.provider}/${session.model.id}` } : {}),\n\t\t\tcontextPointers: [],\n\t\t});\n\n\t\tconst [worktreeSync, processMatrix] = await Promise.all([\n\t\t\tstartWorktreeSyncRuntime({\n\t\t\t\tcwd: sessionManager.getCwd(),\n\t\t\t\tagentDir: this.options.agentDir,\n\t\t\t\tsettingsManager: session.settingsManager,\n\t\t\t\tsessionId,\n\t\t\t\tnotify: (text) => {\n\t\t\t\t\tvoid this.notify(session, \"worktree-sync-notice\", text).catch(() => {});\n\t\t\t\t},\n\t\t\t\tonDiagnostic: this.options.onDiagnostic,\n\t\t\t}),\n\t\t\tstartProcessMatrixRuntime({\n\t\t\t\tagentDir: this.options.agentDir,\n\t\t\t\tagent,\n\t\t\t\t...(taskRef ? { taskRef } : {}),\n\t\t\t\ttaskSummary: goal?.userGoal,\n\t\t\t\tallowAutomaticRecovery: goal === undefined || goal.status === \"active\",\n\t\t\t\tresumeWorker: (payload) => this.options.resumeWorker(payload, sessionId),\n\t\t\t\thasUI: this.options.hasUI,\n\t\t\t\tsettings: session.settingsManager.getProcessMatrixSettings(),\n\t\t\t\tisProcessAlive: this.options.isProcessAlive,\n\t\t\t\tpromptConfirm: this.options.promptConfirm,\n\t\t\t\tnotify: (text) => this.notify(session, \"process-matrix-notice\", text),\n\t\t\t\tonDiagnostic: this.options.onDiagnostic,\n\t\t\t\trequestExit: () => this.options.requestExit(session),\n\t\t\t}),\n\t\t]);\n\n\t\tif (generation !== this.generation) {\n\t\t\tawait Promise.all([worktreeSync.stop(), processMatrix.stop()]);\n\t\t\treturn;\n\t\t}\n\t\tthis.worktreeSync = worktreeSync;\n\t\tthis.processMatrix = processMatrix;\n\t}\n\n\tasync stop(): Promise<void> {\n\t\tthis.generation++;\n\t\tawait this.stopHandles();\n\t}\n\n\tprivate async stopHandles(): Promise<void> {\n\t\tconst worktreeSync = this.worktreeSync;\n\t\tconst processMatrix = this.processMatrix;\n\t\tthis.worktreeSync = undefined;\n\t\tthis.processMatrix = undefined;\n\t\tawait Promise.all([worktreeSync?.stop(), processMatrix?.stop()]);\n\t}\n\n\tprivate async notify(session: AgentSession, customType: string, text: string): Promise<void> {\n\t\ttry {\n\t\t\tawait session.sendCustomMessage(\n\t\t\t\t{ customType, content: text, display: true },\n\t\t\t\t{ triggerTurn: true, deliverAs: \"steer\" },\n\t\t\t);\n\t\t} catch (error) {\n\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\tthis.options.onDiagnostic(`${customType}: failed to notify session: ${message}`);\n\t\t\tthrow error;\n\t\t}\n\t}\n}\n"]}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { createAgentIdentity } from "./orchestration/agent-resume.js";
|
|
2
|
+
import { getOrchestrationAgentId, getProcessTaskRef, startProcessMatrixRuntime, } from "./process-matrix/runtime.js";
|
|
3
|
+
import { getBoundWorktreeLaneKey, startWorktreeSyncRuntime } from "./worktree-sync/runtime.js";
|
|
4
|
+
/**
|
|
5
|
+
* Owns the process-matrix and worktree-sync handles for the currently active session.
|
|
6
|
+
* Replacement stops the old generation before a new one is started, so no watcher can retain a
|
|
7
|
+
* disposed session or deliver a notice across a `/new`, `/resume`, or `/fork` boundary.
|
|
8
|
+
*/
|
|
9
|
+
export class SessionSupervisionRuntime {
|
|
10
|
+
options;
|
|
11
|
+
generation = 0;
|
|
12
|
+
processMatrix;
|
|
13
|
+
worktreeSync;
|
|
14
|
+
constructor(options) {
|
|
15
|
+
this.options = options;
|
|
16
|
+
}
|
|
17
|
+
async start(session) {
|
|
18
|
+
const generation = ++this.generation;
|
|
19
|
+
await this.stopHandles();
|
|
20
|
+
const sessionManager = session.sessionManager;
|
|
21
|
+
const sessionId = sessionManager.getSessionId();
|
|
22
|
+
const boundWorktreeLaneKey = getBoundWorktreeLaneKey();
|
|
23
|
+
const orchestrationProfileId = this.options.orchestrationProfileId ??
|
|
24
|
+
session.capabilityEnvelope?.profileId ??
|
|
25
|
+
session.settingsManager.getActiveOrchestrationProfile();
|
|
26
|
+
const sessionFile = sessionManager.getSessionFile();
|
|
27
|
+
const goal = session.getGoalStateSnapshot();
|
|
28
|
+
const taskRef = getProcessTaskRef() ?? goal?.goalId;
|
|
29
|
+
const agent = createAgentIdentity(getOrchestrationAgentId() ?? sessionId, {
|
|
30
|
+
provider: "pi",
|
|
31
|
+
sessionId,
|
|
32
|
+
sessionDir: sessionManager.getSessionDir(),
|
|
33
|
+
...(sessionFile ? { sessionFile } : {}),
|
|
34
|
+
cwd: sessionManager.getCwd(),
|
|
35
|
+
...(boundWorktreeLaneKey ? { worktreeLaneKey: boundWorktreeLaneKey } : {}),
|
|
36
|
+
...(orchestrationProfileId ? { orchestrationProfileId } : {}),
|
|
37
|
+
resourceProfileNames: session.settingsManager.getActiveResourceProfileNames(),
|
|
38
|
+
...(session.model ? { modelRef: `${session.model.provider}/${session.model.id}` } : {}),
|
|
39
|
+
contextPointers: [],
|
|
40
|
+
});
|
|
41
|
+
const [worktreeSync, processMatrix] = await Promise.all([
|
|
42
|
+
startWorktreeSyncRuntime({
|
|
43
|
+
cwd: sessionManager.getCwd(),
|
|
44
|
+
agentDir: this.options.agentDir,
|
|
45
|
+
settingsManager: session.settingsManager,
|
|
46
|
+
sessionId,
|
|
47
|
+
notify: (text) => {
|
|
48
|
+
void this.notify(session, "worktree-sync-notice", text).catch(() => { });
|
|
49
|
+
},
|
|
50
|
+
onDiagnostic: this.options.onDiagnostic,
|
|
51
|
+
}),
|
|
52
|
+
startProcessMatrixRuntime({
|
|
53
|
+
agentDir: this.options.agentDir,
|
|
54
|
+
agent,
|
|
55
|
+
...(taskRef ? { taskRef } : {}),
|
|
56
|
+
taskSummary: goal?.userGoal,
|
|
57
|
+
allowAutomaticRecovery: goal === undefined || goal.status === "active",
|
|
58
|
+
resumeWorker: (payload) => this.options.resumeWorker(payload, sessionId),
|
|
59
|
+
hasUI: this.options.hasUI,
|
|
60
|
+
settings: session.settingsManager.getProcessMatrixSettings(),
|
|
61
|
+
isProcessAlive: this.options.isProcessAlive,
|
|
62
|
+
promptConfirm: this.options.promptConfirm,
|
|
63
|
+
notify: (text) => this.notify(session, "process-matrix-notice", text),
|
|
64
|
+
onDiagnostic: this.options.onDiagnostic,
|
|
65
|
+
requestExit: () => this.options.requestExit(session),
|
|
66
|
+
}),
|
|
67
|
+
]);
|
|
68
|
+
if (generation !== this.generation) {
|
|
69
|
+
await Promise.all([worktreeSync.stop(), processMatrix.stop()]);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
this.worktreeSync = worktreeSync;
|
|
73
|
+
this.processMatrix = processMatrix;
|
|
74
|
+
}
|
|
75
|
+
async stop() {
|
|
76
|
+
this.generation++;
|
|
77
|
+
await this.stopHandles();
|
|
78
|
+
}
|
|
79
|
+
async stopHandles() {
|
|
80
|
+
const worktreeSync = this.worktreeSync;
|
|
81
|
+
const processMatrix = this.processMatrix;
|
|
82
|
+
this.worktreeSync = undefined;
|
|
83
|
+
this.processMatrix = undefined;
|
|
84
|
+
await Promise.all([worktreeSync?.stop(), processMatrix?.stop()]);
|
|
85
|
+
}
|
|
86
|
+
async notify(session, customType, text) {
|
|
87
|
+
try {
|
|
88
|
+
await session.sendCustomMessage({ customType, content: text, display: true }, { triggerTurn: true, deliverAs: "steer" });
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
92
|
+
this.options.onDiagnostic(`${customType}: failed to notify session: ${message}`);
|
|
93
|
+
throw error;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=session-supervision-runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-supervision-runtime.js","sourceRoot":"","sources":["../../src/core/session-supervision-runtime.ts"],"names":[],"mappings":"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","sourcesContent":["import type { AgentSession } from \"./agent-session.ts\";\nimport type { AgentSessionRuntimeResource } from \"./agent-session-runtime.ts\";\nimport { createAgentIdentity } from \"./orchestration/agent-resume.ts\";\nimport type { ResumablePayload } from \"./process-matrix/codes.ts\";\nimport {\n\tgetOrchestrationAgentId,\n\tgetProcessTaskRef,\n\ttype ProcessMatrixRuntimeHandle,\n\ttype ResumeWorkerLaunchOutcome,\n\tstartProcessMatrixRuntime,\n} from \"./process-matrix/runtime.ts\";\nimport type { WorktreeSyncRuntimeHandle } from \"./worktree-sync/runtime.ts\";\nimport { getBoundWorktreeLaneKey, startWorktreeSyncRuntime } from \"./worktree-sync/runtime.ts\";\n\nexport interface SessionSupervisionRuntimeOptions {\n\tagentDir: string;\n\thasUI: boolean;\n\torchestrationProfileId?: string;\n\tisProcessAlive: (pid: number) => boolean;\n\tpromptConfirm: (message: string) => Promise<boolean>;\n\tresumeWorker: (payload: ResumablePayload, parentSessionId: string) => Promise<ResumeWorkerLaunchOutcome>;\n\tonDiagnostic: (message: string) => void;\n\trequestExit: (session: AgentSession) => void;\n}\n\n/**\n * Owns the process-matrix and worktree-sync handles for the currently active session.\n * Replacement stops the old generation before a new one is started, so no watcher can retain a\n * disposed session or deliver a notice across a `/new`, `/resume`, or `/fork` boundary.\n */\nexport class SessionSupervisionRuntime implements AgentSessionRuntimeResource {\n\tprivate readonly options: SessionSupervisionRuntimeOptions;\n\tprivate generation = 0;\n\tprivate processMatrix?: ProcessMatrixRuntimeHandle;\n\tprivate worktreeSync?: WorktreeSyncRuntimeHandle;\n\n\tconstructor(options: SessionSupervisionRuntimeOptions) {\n\t\tthis.options = options;\n\t}\n\n\tasync start(session: AgentSession): Promise<void> {\n\t\tconst generation = ++this.generation;\n\t\tawait this.stopHandles();\n\t\tconst sessionManager = session.sessionManager;\n\t\tconst sessionId = sessionManager.getSessionId();\n\t\tconst boundWorktreeLaneKey = getBoundWorktreeLaneKey();\n\t\tconst orchestrationProfileId =\n\t\t\tthis.options.orchestrationProfileId ??\n\t\t\tsession.capabilityEnvelope?.profileId ??\n\t\t\tsession.settingsManager.getActiveOrchestrationProfile();\n\t\tconst sessionFile = sessionManager.getSessionFile();\n\t\tconst goal = session.getGoalStateSnapshot();\n\t\tconst taskRef = getProcessTaskRef() ?? goal?.goalId;\n\t\tconst agent = createAgentIdentity(getOrchestrationAgentId() ?? sessionId, {\n\t\t\tprovider: \"pi\",\n\t\t\tsessionId,\n\t\t\tsessionDir: sessionManager.getSessionDir(),\n\t\t\t...(sessionFile ? { sessionFile } : {}),\n\t\t\tcwd: sessionManager.getCwd(),\n\t\t\t...(boundWorktreeLaneKey ? { worktreeLaneKey: boundWorktreeLaneKey } : {}),\n\t\t\t...(orchestrationProfileId ? { orchestrationProfileId } : {}),\n\t\t\tresourceProfileNames: session.settingsManager.getActiveResourceProfileNames(),\n\t\t\t...(session.model ? { modelRef: `${session.model.provider}/${session.model.id}` } : {}),\n\t\t\tcontextPointers: [],\n\t\t});\n\n\t\tconst [worktreeSync, processMatrix] = await Promise.all([\n\t\t\tstartWorktreeSyncRuntime({\n\t\t\t\tcwd: sessionManager.getCwd(),\n\t\t\t\tagentDir: this.options.agentDir,\n\t\t\t\tsettingsManager: session.settingsManager,\n\t\t\t\tsessionId,\n\t\t\t\tnotify: (text) => {\n\t\t\t\t\tvoid this.notify(session, \"worktree-sync-notice\", text).catch(() => {});\n\t\t\t\t},\n\t\t\t\tonDiagnostic: this.options.onDiagnostic,\n\t\t\t}),\n\t\t\tstartProcessMatrixRuntime({\n\t\t\t\tagentDir: this.options.agentDir,\n\t\t\t\tagent,\n\t\t\t\t...(taskRef ? { taskRef } : {}),\n\t\t\t\ttaskSummary: goal?.userGoal,\n\t\t\t\tallowAutomaticRecovery: goal === undefined || goal.status === \"active\",\n\t\t\t\tresumeWorker: (payload) => this.options.resumeWorker(payload, sessionId),\n\t\t\t\thasUI: this.options.hasUI,\n\t\t\t\tsettings: session.settingsManager.getProcessMatrixSettings(),\n\t\t\t\tisProcessAlive: this.options.isProcessAlive,\n\t\t\t\tpromptConfirm: this.options.promptConfirm,\n\t\t\t\tnotify: (text) => this.notify(session, \"process-matrix-notice\", text),\n\t\t\t\tonDiagnostic: this.options.onDiagnostic,\n\t\t\t\trequestExit: () => this.options.requestExit(session),\n\t\t\t}),\n\t\t]);\n\n\t\tif (generation !== this.generation) {\n\t\t\tawait Promise.all([worktreeSync.stop(), processMatrix.stop()]);\n\t\t\treturn;\n\t\t}\n\t\tthis.worktreeSync = worktreeSync;\n\t\tthis.processMatrix = processMatrix;\n\t}\n\n\tasync stop(): Promise<void> {\n\t\tthis.generation++;\n\t\tawait this.stopHandles();\n\t}\n\n\tprivate async stopHandles(): Promise<void> {\n\t\tconst worktreeSync = this.worktreeSync;\n\t\tconst processMatrix = this.processMatrix;\n\t\tthis.worktreeSync = undefined;\n\t\tthis.processMatrix = undefined;\n\t\tawait Promise.all([worktreeSync?.stop(), processMatrix?.stop()]);\n\t}\n\n\tprivate async notify(session: AgentSession, customType: string, text: string): Promise<void> {\n\t\ttry {\n\t\t\tawait session.sendCustomMessage(\n\t\t\t\t{ customType, content: text, display: true },\n\t\t\t\t{ triggerTurn: true, deliverAs: \"steer\" },\n\t\t\t);\n\t\t} catch (error) {\n\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\tthis.options.onDiagnostic(`${customType}: failed to notify session: ${message}`);\n\t\t\tthrow error;\n\t\t}\n\t}\n}\n"]}
|
|
@@ -9,21 +9,19 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import type { Agent } from "@caupulican/pi-agent-core";
|
|
11
11
|
import { type BranchSummaryEntry, type SessionManager } from "@caupulican/pi-agent-core/node";
|
|
12
|
-
import type { Model } from "@caupulican/pi-ai";
|
|
12
|
+
import type { Api, Model } from "@caupulican/pi-ai";
|
|
13
13
|
import type { ExtensionRunner } from "./extensions/index.ts";
|
|
14
|
+
import type { RequestAuth } from "./request-auth.ts";
|
|
14
15
|
import type { SettingsManager } from "./settings-manager.ts";
|
|
15
16
|
export interface SessionTreeNavigatorDeps {
|
|
16
17
|
/** Session log — leaf/branch reads and writes go through this. */
|
|
17
18
|
getSessionManager(): SessionManager;
|
|
18
19
|
/** Current model — required to run the default branch summarizer. */
|
|
19
|
-
getModel(): Model<
|
|
20
|
+
getModel(): Model<Api> | undefined;
|
|
20
21
|
/** Extension runner — `session_before_tree`/`session_tree` hooks fire here. */
|
|
21
22
|
getExtensionRunner(): ExtensionRunner;
|
|
22
23
|
/** Resolve request auth for the summarizer call (session-owned, also used by compaction). */
|
|
23
|
-
getRequiredRequestAuth(model: Model<
|
|
24
|
-
apiKey: string;
|
|
25
|
-
headers?: Record<string, string>;
|
|
26
|
-
}>;
|
|
24
|
+
getRequiredRequestAuth(model: Model<Api>): Promise<RequestAuth>;
|
|
27
25
|
/** Settings — branch-summary reserve tokens. */
|
|
28
26
|
getSettingsManager(): SettingsManager;
|
|
29
27
|
/** The underlying agent — the rebuilt message view is assigned to `agent.state.messages`. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-tree-navigator.d.ts","sourceRoot":"","sources":["../../src/core/session-tree-navigator.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EACN,KAAK,kBAAkB,EAGvB,KAAK,cAAc,EACnB,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,KAAK,EAAE,eAAe,EAA4C,MAAM,uBAAuB,CAAC;AACvG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,MAAM,WAAW,wBAAwB;IACxC,oEAAkE;IAClE,iBAAiB,IAAI,cAAc,CAAC;IACpC,uEAAqE;IACrE,QAAQ,IAAI,KAAK,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC;IACnC,iFAA+E;IAC/E,kBAAkB,IAAI,eAAe,CAAC;IACtC,6FAA6F;IAC7F,sBAAsB,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,CAAC,CAAC;IACzG,kDAAgD;IAChD,kBAAkB,IAAI,eAAe,CAAC;IACtC,+FAA6F;IAC7F,QAAQ,IAAI,KAAK,CAAC;IAClB,uGAAuG;IACvG,qBAAqB,CAAC,UAAU,EAAE,eAAe,GAAG,SAAS,GAAG,IAAI,CAAC;CACrE;AAED,qBAAa,oBAAoB;IAChC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAA2B;IAEhD,YAAY,IAAI,EAAE,wBAAwB,EAEzC;IAED;;;;;;;;;;OAUG;IACG,YAAY,CACjB,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE;QAAE,SAAS,CAAC,EAAE,OAAO,CAAC;QAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC;QAAC,mBAAmB,CAAC,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAO,GAC/G,OAAO,CAAC;QAAE,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,OAAO,CAAC;QAAC,OAAO,CAAC,EAAE,OAAO,CAAC;QAAC,YAAY,CAAC,EAAE,kBAAkB,CAAA;KAAE,CAAC,CAoL5G;IAED;;OAEG;IACH,yBAAyB,IAAI,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAepE;IAED,OAAO,CAAC,uBAAuB;CAU/B","sourcesContent":["/**\n * Session-tree navigation (in-file branch switching + fork-selector reads).\n *\n * Extracted verbatim from agent-session.ts (god-file decomposition). `navigateTree` moves the leaf\n * to another node in the SAME session file (unlike fork(), which creates a new file), optionally\n * summarizing the abandoned branch via the model or an extension override. It owns no state: the\n * branch-summary abort controller stays on the session (also read by `isCompacting`) and is set/cleared\n * here through a dep so the session's abort/compacting surface is untouched.\n */\n\nimport type { Agent } from \"@caupulican/pi-agent-core\";\nimport {\n\ttype BranchSummaryEntry,\n\tcollectEntriesForBranchSummary,\n\tgenerateBranchSummary,\n\ttype SessionManager,\n} from \"@caupulican/pi-agent-core/node\";\nimport type { Model } from \"@caupulican/pi-ai\";\nimport type { ExtensionRunner, SessionBeforeTreeResult, TreePreparation } from \"./extensions/index.ts\";\nimport type { SettingsManager } from \"./settings-manager.ts\";\n\nexport interface SessionTreeNavigatorDeps {\n\t/** Session log — leaf/branch reads and writes go through this. */\n\tgetSessionManager(): SessionManager;\n\t/** Current model — required to run the default branch summarizer. */\n\tgetModel(): Model<any> | undefined;\n\t/** Extension runner — `session_before_tree`/`session_tree` hooks fire here. */\n\tgetExtensionRunner(): ExtensionRunner;\n\t/** Resolve request auth for the summarizer call (session-owned, also used by compaction). */\n\tgetRequiredRequestAuth(model: Model<any>): Promise<{ apiKey: string; headers?: Record<string, string> }>;\n\t/** Settings — branch-summary reserve tokens. */\n\tgetSettingsManager(): SettingsManager;\n\t/** The underlying agent — the rebuilt message view is assigned to `agent.state.messages`. */\n\tgetAgent(): Agent;\n\t/** Store/clear the in-flight branch-summary abort controller on the session (read by isCompacting). */\n\tsetBranchSummaryAbort(controller: AbortController | undefined): void;\n}\n\nexport class SessionTreeNavigator {\n\tprivate readonly deps: SessionTreeNavigatorDeps;\n\n\tconstructor(deps: SessionTreeNavigatorDeps) {\n\t\tthis.deps = deps;\n\t}\n\n\t/**\n\t * Navigate to a different node in the session tree.\n\t * Unlike fork() which creates a new session file, this stays in the same file.\n\t *\n\t * @param targetId The entry ID to navigate to\n\t * @param options.summarize Whether user wants to summarize abandoned branch\n\t * @param options.customInstructions Custom instructions for summarizer\n\t * @param options.replaceInstructions If true, customInstructions replaces the default prompt\n\t * @param options.label Label to attach to the branch summary entry\n\t * @returns Result with editorText (if user message) and cancelled status\n\t */\n\tasync navigateTree(\n\t\ttargetId: string,\n\t\toptions: { summarize?: boolean; customInstructions?: string; replaceInstructions?: boolean; label?: string } = {},\n\t): Promise<{ editorText?: string; cancelled: boolean; aborted?: boolean; summaryEntry?: BranchSummaryEntry }> {\n\t\tconst sessionManager = this.deps.getSessionManager();\n\t\tconst extensionRunner = this.deps.getExtensionRunner();\n\t\tconst oldLeafId = sessionManager.getLeafId();\n\n\t\t// No-op if already at target\n\t\tif (targetId === oldLeafId) {\n\t\t\treturn { cancelled: false };\n\t\t}\n\n\t\t// Model required for summarization\n\t\tif (options.summarize && !this.deps.getModel()) {\n\t\t\tthrow new Error(\"No model available for summarization\");\n\t\t}\n\n\t\tconst targetEntry = sessionManager.getEntry(targetId);\n\t\tif (!targetEntry) {\n\t\t\tthrow new Error(`Entry ${targetId} not found`);\n\t\t}\n\n\t\t// Collect entries to summarize (from old leaf to common ancestor)\n\t\tconst { entries: entriesToSummarize, commonAncestorId } = collectEntriesForBranchSummary(\n\t\t\tsessionManager,\n\t\t\toldLeafId,\n\t\t\ttargetId,\n\t\t);\n\n\t\t// Prepare event data - mutable so extensions can override\n\t\tlet customInstructions = options.customInstructions;\n\t\tlet replaceInstructions = options.replaceInstructions;\n\t\tlet label = options.label;\n\n\t\tconst preparation: TreePreparation = {\n\t\t\ttargetId,\n\t\t\toldLeafId,\n\t\t\tcommonAncestorId,\n\t\t\tentriesToSummarize,\n\t\t\tuserWantsSummary: options.summarize ?? false,\n\t\t\tcustomInstructions,\n\t\t\treplaceInstructions,\n\t\t\tlabel,\n\t\t};\n\n\t\t// Set up abort controller for summarization\n\t\tconst branchSummaryAbort = new AbortController();\n\t\tthis.deps.setBranchSummaryAbort(branchSummaryAbort);\n\n\t\ttry {\n\t\t\tlet extensionSummary: { summary: string; details?: unknown } | undefined;\n\t\t\tlet fromExtension = false;\n\n\t\t\t// Emit session_before_tree event\n\t\t\tif (extensionRunner.hasHandlers(\"session_before_tree\")) {\n\t\t\t\tconst result = (await extensionRunner.emit({\n\t\t\t\t\ttype: \"session_before_tree\",\n\t\t\t\t\tpreparation,\n\t\t\t\t\tsignal: branchSummaryAbort.signal,\n\t\t\t\t})) as SessionBeforeTreeResult | undefined;\n\n\t\t\t\tif (result?.cancel) {\n\t\t\t\t\treturn { cancelled: true };\n\t\t\t\t}\n\n\t\t\t\tif (result?.summary && options.summarize) {\n\t\t\t\t\textensionSummary = result.summary;\n\t\t\t\t\tfromExtension = true;\n\t\t\t\t}\n\n\t\t\t\t// Allow extensions to override instructions and label\n\t\t\t\tif (result?.customInstructions !== undefined) {\n\t\t\t\t\tcustomInstructions = result.customInstructions;\n\t\t\t\t}\n\t\t\t\tif (result?.replaceInstructions !== undefined) {\n\t\t\t\t\treplaceInstructions = result.replaceInstructions;\n\t\t\t\t}\n\t\t\t\tif (result?.label !== undefined) {\n\t\t\t\t\tlabel = result.label;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Run default summarizer if needed\n\t\t\tlet summaryText: string | undefined;\n\t\t\tlet summaryDetails: unknown;\n\t\t\tif (options.summarize && entriesToSummarize.length > 0 && !extensionSummary) {\n\t\t\t\tconst model = this.deps.getModel()!;\n\t\t\t\tconst { apiKey, headers } = await this.deps.getRequiredRequestAuth(model);\n\t\t\t\tconst branchSummarySettings = this.deps.getSettingsManager().getBranchSummarySettings();\n\t\t\t\tconst result = await generateBranchSummary(entriesToSummarize, {\n\t\t\t\t\tmodel,\n\t\t\t\t\tapiKey,\n\t\t\t\t\theaders,\n\t\t\t\t\tsignal: branchSummaryAbort.signal,\n\t\t\t\t\tcustomInstructions,\n\t\t\t\t\treplaceInstructions,\n\t\t\t\t\treserveTokens: branchSummarySettings.reserveTokens,\n\t\t\t\t\tstreamFn: this.deps.getAgent().streamFn,\n\t\t\t\t});\n\t\t\t\tif (result.aborted) {\n\t\t\t\t\treturn { cancelled: true, aborted: true };\n\t\t\t\t}\n\t\t\t\tif (result.error) {\n\t\t\t\t\tthrow new Error(result.error);\n\t\t\t\t}\n\t\t\t\tsummaryText = result.summary;\n\t\t\t\tsummaryDetails = {\n\t\t\t\t\treadFiles: result.readFiles || [],\n\t\t\t\t\tmodifiedFiles: result.modifiedFiles || [],\n\t\t\t\t};\n\t\t\t} else if (extensionSummary) {\n\t\t\t\tsummaryText = extensionSummary.summary;\n\t\t\t\tsummaryDetails = extensionSummary.details;\n\t\t\t}\n\n\t\t\t// Determine the new leaf position based on target type\n\t\t\tlet newLeafId: string | null;\n\t\t\tlet editorText: string | undefined;\n\n\t\t\tif (targetEntry.type === \"message\" && targetEntry.message.role === \"user\") {\n\t\t\t\t// User message: leaf = parent (null if root), text goes to editor\n\t\t\t\tnewLeafId = targetEntry.parentId;\n\t\t\t\teditorText = this._extractUserMessageText(targetEntry.message.content);\n\t\t\t} else if (targetEntry.type === \"custom_message\") {\n\t\t\t\t// Custom message: leaf = parent (null if root), text goes to editor\n\t\t\t\tnewLeafId = targetEntry.parentId;\n\t\t\t\teditorText =\n\t\t\t\t\ttypeof targetEntry.content === \"string\"\n\t\t\t\t\t\t? targetEntry.content\n\t\t\t\t\t\t: targetEntry.content\n\t\t\t\t\t\t\t\t.filter((c): c is { type: \"text\"; text: string } => c.type === \"text\")\n\t\t\t\t\t\t\t\t.map((c) => c.text)\n\t\t\t\t\t\t\t\t.join(\"\");\n\t\t\t} else {\n\t\t\t\t// Non-user message: leaf = selected node\n\t\t\t\tnewLeafId = targetId;\n\t\t\t}\n\n\t\t\t// Switch leaf (with or without summary)\n\t\t\t// Summary is attached at the navigation target position (newLeafId), not the old branch\n\t\t\tlet summaryEntry: BranchSummaryEntry | undefined;\n\t\t\tif (summaryText) {\n\t\t\t\t// Create summary at target position (can be null for root)\n\t\t\t\tconst summaryId = sessionManager.branchWithSummary(newLeafId, summaryText, summaryDetails, fromExtension);\n\t\t\t\tsummaryEntry = sessionManager.getEntry(summaryId) as BranchSummaryEntry;\n\n\t\t\t\t// Attach label to the summary entry\n\t\t\t\tif (label) {\n\t\t\t\t\tsessionManager.appendLabelChange(summaryId, label);\n\t\t\t\t}\n\t\t\t} else if (newLeafId === null) {\n\t\t\t\t// No summary, navigating to root - reset leaf\n\t\t\t\tsessionManager.resetLeaf();\n\t\t\t} else {\n\t\t\t\t// No summary, navigating to non-root\n\t\t\t\tsessionManager.branch(newLeafId);\n\t\t\t}\n\n\t\t\t// Attach label to target entry when not summarizing (no summary entry to label)\n\t\t\tif (label && !summaryText) {\n\t\t\t\tsessionManager.appendLabelChange(targetId, label);\n\t\t\t}\n\n\t\t\t// Update agent state\n\t\t\tconst sessionContext = sessionManager.buildSessionContext();\n\t\t\tthis.deps.getAgent().state.messages = sessionContext.messages;\n\n\t\t\t// Emit session_tree event\n\t\t\tawait extensionRunner.emit({\n\t\t\t\ttype: \"session_tree\",\n\t\t\t\tnewLeafId: sessionManager.getLeafId(),\n\t\t\t\toldLeafId,\n\t\t\t\tsummaryEntry,\n\t\t\t\tfromExtension: summaryText ? fromExtension : undefined,\n\t\t\t});\n\n\t\t\t// Emit to custom tools\n\n\t\t\treturn { editorText, cancelled: false, summaryEntry };\n\t\t} finally {\n\t\t\tthis.deps.setBranchSummaryAbort(undefined);\n\t\t}\n\t}\n\n\t/**\n\t * Get all user messages from session for fork selector.\n\t */\n\tgetUserMessagesForForking(): Array<{ entryId: string; text: string }> {\n\t\tconst entries = this.deps.getSessionManager().getEntries();\n\t\tconst result: Array<{ entryId: string; text: string }> = [];\n\n\t\tfor (const entry of entries) {\n\t\t\tif (entry.type !== \"message\") continue;\n\t\t\tif (entry.message.role !== \"user\") continue;\n\n\t\t\tconst text = this._extractUserMessageText(entry.message.content);\n\t\t\tif (text) {\n\t\t\t\tresult.push({ entryId: entry.id, text });\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tprivate _extractUserMessageText(content: string | Array<{ type: string; text?: string }>): string {\n\t\tif (typeof content === \"string\") return content;\n\t\tif (Array.isArray(content)) {\n\t\t\treturn content\n\t\t\t\t.filter((c): c is { type: \"text\"; text: string } => c.type === \"text\")\n\t\t\t\t.map((c) => c.text)\n\t\t\t\t.join(\"\");\n\t\t}\n\t\treturn \"\";\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"session-tree-navigator.d.ts","sourceRoot":"","sources":["../../src/core/session-tree-navigator.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EACN,KAAK,kBAAkB,EAGvB,KAAK,cAAc,EACnB,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,EAAE,GAAG,EAAE,KAAK,EAAS,MAAM,mBAAmB,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAA4C,MAAM,uBAAuB,CAAC;AACvG,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,MAAM,WAAW,wBAAwB;IACxC,oEAAkE;IAClE,iBAAiB,IAAI,cAAc,CAAC;IACpC,uEAAqE;IACrE,QAAQ,IAAI,KAAK,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC;IACnC,iFAA+E;IAC/E,kBAAkB,IAAI,eAAe,CAAC;IACtC,6FAA6F;IAC7F,sBAAsB,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IAChE,kDAAgD;IAChD,kBAAkB,IAAI,eAAe,CAAC;IACtC,+FAA6F;IAC7F,QAAQ,IAAI,KAAK,CAAC;IAClB,uGAAuG;IACvG,qBAAqB,CAAC,UAAU,EAAE,eAAe,GAAG,SAAS,GAAG,IAAI,CAAC;CACrE;AAED,qBAAa,oBAAoB;IAChC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAA2B;IAEhD,YAAY,IAAI,EAAE,wBAAwB,EAEzC;IAED;;;;;;;;;;OAUG;IACG,YAAY,CACjB,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE;QAAE,SAAS,CAAC,EAAE,OAAO,CAAC;QAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC;QAAC,mBAAmB,CAAC,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAO,GAC/G,OAAO,CAAC;QAAE,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,OAAO,CAAC;QAAC,OAAO,CAAC,EAAE,OAAO,CAAC;QAAC,YAAY,CAAC,EAAE,kBAAkB,CAAA;KAAE,CAAC,CA6L5G;IAED;;OAEG;IACH,yBAAyB,IAAI,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAepE;IAED,OAAO,CAAC,uBAAuB;CAU/B","sourcesContent":["/**\n * Session-tree navigation (in-file branch switching + fork-selector reads).\n *\n * Extracted verbatim from agent-session.ts (god-file decomposition). `navigateTree` moves the leaf\n * to another node in the SAME session file (unlike fork(), which creates a new file), optionally\n * summarizing the abandoned branch via the model or an extension override. It owns no state: the\n * branch-summary abort controller stays on the session (also read by `isCompacting`) and is set/cleared\n * here through a dep so the session's abort/compacting surface is untouched.\n */\n\nimport type { Agent } from \"@caupulican/pi-agent-core\";\nimport {\n\ttype BranchSummaryEntry,\n\tcollectEntriesForBranchSummary,\n\tgenerateBranchSummary,\n\ttype SessionManager,\n} from \"@caupulican/pi-agent-core/node\";\nimport type { Api, Model, Usage } from \"@caupulican/pi-ai\";\nimport type { ExtensionRunner, SessionBeforeTreeResult, TreePreparation } from \"./extensions/index.ts\";\nimport type { RequestAuth } from \"./request-auth.ts\";\nimport type { SettingsManager } from \"./settings-manager.ts\";\n\nexport interface SessionTreeNavigatorDeps {\n\t/** Session log — leaf/branch reads and writes go through this. */\n\tgetSessionManager(): SessionManager;\n\t/** Current model — required to run the default branch summarizer. */\n\tgetModel(): Model<Api> | undefined;\n\t/** Extension runner — `session_before_tree`/`session_tree` hooks fire here. */\n\tgetExtensionRunner(): ExtensionRunner;\n\t/** Resolve request auth for the summarizer call (session-owned, also used by compaction). */\n\tgetRequiredRequestAuth(model: Model<Api>): Promise<RequestAuth>;\n\t/** Settings — branch-summary reserve tokens. */\n\tgetSettingsManager(): SettingsManager;\n\t/** The underlying agent — the rebuilt message view is assigned to `agent.state.messages`. */\n\tgetAgent(): Agent;\n\t/** Store/clear the in-flight branch-summary abort controller on the session (read by isCompacting). */\n\tsetBranchSummaryAbort(controller: AbortController | undefined): void;\n}\n\nexport class SessionTreeNavigator {\n\tprivate readonly deps: SessionTreeNavigatorDeps;\n\n\tconstructor(deps: SessionTreeNavigatorDeps) {\n\t\tthis.deps = deps;\n\t}\n\n\t/**\n\t * Navigate to a different node in the session tree.\n\t * Unlike fork() which creates a new session file, this stays in the same file.\n\t *\n\t * @param targetId The entry ID to navigate to\n\t * @param options.summarize Whether user wants to summarize abandoned branch\n\t * @param options.customInstructions Custom instructions for summarizer\n\t * @param options.replaceInstructions If true, customInstructions replaces the default prompt\n\t * @param options.label Label to attach to the branch summary entry\n\t * @returns Result with editorText (if user message) and cancelled status\n\t */\n\tasync navigateTree(\n\t\ttargetId: string,\n\t\toptions: { summarize?: boolean; customInstructions?: string; replaceInstructions?: boolean; label?: string } = {},\n\t): Promise<{ editorText?: string; cancelled: boolean; aborted?: boolean; summaryEntry?: BranchSummaryEntry }> {\n\t\tconst sessionManager = this.deps.getSessionManager();\n\t\tconst extensionRunner = this.deps.getExtensionRunner();\n\t\tconst oldLeafId = sessionManager.getLeafId();\n\n\t\t// No-op if already at target\n\t\tif (targetId === oldLeafId) {\n\t\t\treturn { cancelled: false };\n\t\t}\n\n\t\t// Model required for summarization\n\t\tif (options.summarize && !this.deps.getModel()) {\n\t\t\tthrow new Error(\"No model available for summarization\");\n\t\t}\n\n\t\tconst targetEntry = sessionManager.getEntry(targetId);\n\t\tif (!targetEntry) {\n\t\t\tthrow new Error(`Entry ${targetId} not found`);\n\t\t}\n\n\t\t// Collect entries to summarize (from old leaf to common ancestor)\n\t\tconst { entries: entriesToSummarize, commonAncestorId } = collectEntriesForBranchSummary(\n\t\t\tsessionManager,\n\t\t\toldLeafId,\n\t\t\ttargetId,\n\t\t);\n\n\t\t// Prepare event data - mutable so extensions can override\n\t\tlet customInstructions = options.customInstructions;\n\t\tlet replaceInstructions = options.replaceInstructions;\n\t\tlet label = options.label;\n\n\t\tconst preparation: TreePreparation = {\n\t\t\ttargetId,\n\t\t\toldLeafId,\n\t\t\tcommonAncestorId,\n\t\t\tentriesToSummarize,\n\t\t\tuserWantsSummary: options.summarize ?? false,\n\t\t\tcustomInstructions,\n\t\t\treplaceInstructions,\n\t\t\tlabel,\n\t\t};\n\n\t\t// Set up abort controller for summarization\n\t\tconst branchSummaryAbort = new AbortController();\n\t\tthis.deps.setBranchSummaryAbort(branchSummaryAbort);\n\n\t\ttry {\n\t\t\tlet extensionSummary: { summary: string; details?: unknown; usage?: Usage } | undefined;\n\t\t\tlet fromExtension = false;\n\n\t\t\t// Emit session_before_tree event\n\t\t\tif (extensionRunner.hasHandlers(\"session_before_tree\")) {\n\t\t\t\tconst result = (await extensionRunner.emit({\n\t\t\t\t\ttype: \"session_before_tree\",\n\t\t\t\t\tpreparation,\n\t\t\t\t\tsignal: branchSummaryAbort.signal,\n\t\t\t\t})) as SessionBeforeTreeResult | undefined;\n\n\t\t\t\tif (result?.cancel) {\n\t\t\t\t\treturn { cancelled: true };\n\t\t\t\t}\n\n\t\t\t\tif (result?.summary && options.summarize) {\n\t\t\t\t\textensionSummary = result.summary;\n\t\t\t\t\tfromExtension = true;\n\t\t\t\t}\n\n\t\t\t\t// Allow extensions to override instructions and label\n\t\t\t\tif (result?.customInstructions !== undefined) {\n\t\t\t\t\tcustomInstructions = result.customInstructions;\n\t\t\t\t}\n\t\t\t\tif (result?.replaceInstructions !== undefined) {\n\t\t\t\t\treplaceInstructions = result.replaceInstructions;\n\t\t\t\t}\n\t\t\t\tif (result?.label !== undefined) {\n\t\t\t\t\tlabel = result.label;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Run default summarizer if needed\n\t\t\tlet summaryText: string | undefined;\n\t\t\tlet summaryDetails: unknown;\n\t\t\tlet summaryUsage: Usage | undefined;\n\t\t\tif (options.summarize && entriesToSummarize.length > 0 && !extensionSummary) {\n\t\t\t\tconst model = this.deps.getModel()!;\n\t\t\t\tconst { apiKey, headers } = await this.deps.getRequiredRequestAuth(model);\n\t\t\t\tconst branchSummarySettings = this.deps.getSettingsManager().getBranchSummarySettings();\n\t\t\t\tconst result = await generateBranchSummary(entriesToSummarize, {\n\t\t\t\t\tmodel,\n\t\t\t\t\tapiKey,\n\t\t\t\t\theaders,\n\t\t\t\t\tsignal: branchSummaryAbort.signal,\n\t\t\t\t\tcustomInstructions,\n\t\t\t\t\treplaceInstructions,\n\t\t\t\t\treserveTokens: branchSummarySettings.reserveTokens,\n\t\t\t\t\tstreamFn: this.deps.getAgent().streamFn,\n\t\t\t\t});\n\t\t\t\tif (result.aborted) {\n\t\t\t\t\treturn { cancelled: true, aborted: true };\n\t\t\t\t}\n\t\t\t\tif (result.error) {\n\t\t\t\t\tthrow new Error(result.error);\n\t\t\t\t}\n\t\t\t\tsummaryText = result.summary;\n\t\t\t\tsummaryUsage = result.usage;\n\t\t\t\tsummaryDetails = {\n\t\t\t\t\treadFiles: result.readFiles || [],\n\t\t\t\t\tmodifiedFiles: result.modifiedFiles || [],\n\t\t\t\t};\n\t\t\t} else if (extensionSummary) {\n\t\t\t\tsummaryText = extensionSummary.summary;\n\t\t\t\tsummaryDetails = extensionSummary.details;\n\t\t\t\tsummaryUsage = extensionSummary.usage;\n\t\t\t}\n\n\t\t\t// Determine the new leaf position based on target type\n\t\t\tlet newLeafId: string | null;\n\t\t\tlet editorText: string | undefined;\n\n\t\t\tif (targetEntry.type === \"message\" && targetEntry.message.role === \"user\") {\n\t\t\t\t// User message: leaf = parent (null if root), text goes to editor\n\t\t\t\tnewLeafId = targetEntry.parentId;\n\t\t\t\teditorText = this._extractUserMessageText(targetEntry.message.content);\n\t\t\t} else if (targetEntry.type === \"custom_message\") {\n\t\t\t\t// Custom message: leaf = parent (null if root), text goes to editor\n\t\t\t\tnewLeafId = targetEntry.parentId;\n\t\t\t\teditorText =\n\t\t\t\t\ttypeof targetEntry.content === \"string\"\n\t\t\t\t\t\t? targetEntry.content\n\t\t\t\t\t\t: targetEntry.content\n\t\t\t\t\t\t\t\t.filter((c): c is { type: \"text\"; text: string } => c.type === \"text\")\n\t\t\t\t\t\t\t\t.map((c) => c.text)\n\t\t\t\t\t\t\t\t.join(\"\");\n\t\t\t} else {\n\t\t\t\t// Non-user message: leaf = selected node\n\t\t\t\tnewLeafId = targetId;\n\t\t\t}\n\n\t\t\t// Switch leaf (with or without summary)\n\t\t\t// Summary is attached at the navigation target position (newLeafId), not the old branch\n\t\t\tlet summaryEntry: BranchSummaryEntry | undefined;\n\t\t\tif (summaryText) {\n\t\t\t\t// Create summary at target position (can be null for root)\n\t\t\t\tconst summaryId = sessionManager.branchWithSummary(\n\t\t\t\t\tnewLeafId,\n\t\t\t\t\tsummaryText,\n\t\t\t\t\tsummaryDetails,\n\t\t\t\t\tfromExtension,\n\t\t\t\t\tsummaryUsage,\n\t\t\t\t);\n\t\t\t\tsummaryEntry = sessionManager.getEntry(summaryId) as BranchSummaryEntry;\n\n\t\t\t\t// Attach label to the summary entry\n\t\t\t\tif (label) {\n\t\t\t\t\tsessionManager.appendLabelChange(summaryId, label);\n\t\t\t\t}\n\t\t\t} else if (newLeafId === null) {\n\t\t\t\t// No summary, navigating to root - reset leaf\n\t\t\t\tsessionManager.resetLeaf();\n\t\t\t} else {\n\t\t\t\t// No summary, navigating to non-root\n\t\t\t\tsessionManager.branch(newLeafId);\n\t\t\t}\n\n\t\t\t// Attach label to target entry when not summarizing (no summary entry to label)\n\t\t\tif (label && !summaryText) {\n\t\t\t\tsessionManager.appendLabelChange(targetId, label);\n\t\t\t}\n\n\t\t\t// Update agent state\n\t\t\tconst sessionContext = sessionManager.buildSessionContext();\n\t\t\tthis.deps.getAgent().state.messages = sessionContext.messages;\n\n\t\t\t// Emit session_tree event\n\t\t\tawait extensionRunner.emit({\n\t\t\t\ttype: \"session_tree\",\n\t\t\t\tnewLeafId: sessionManager.getLeafId(),\n\t\t\t\toldLeafId,\n\t\t\t\tsummaryEntry,\n\t\t\t\tfromExtension: summaryText ? fromExtension : undefined,\n\t\t\t});\n\n\t\t\t// Emit to custom tools\n\n\t\t\treturn { editorText, cancelled: false, summaryEntry };\n\t\t} finally {\n\t\t\tthis.deps.setBranchSummaryAbort(undefined);\n\t\t}\n\t}\n\n\t/**\n\t * Get all user messages from session for fork selector.\n\t */\n\tgetUserMessagesForForking(): Array<{ entryId: string; text: string }> {\n\t\tconst entries = this.deps.getSessionManager().getEntries();\n\t\tconst result: Array<{ entryId: string; text: string }> = [];\n\n\t\tfor (const entry of entries) {\n\t\t\tif (entry.type !== \"message\") continue;\n\t\t\tif (entry.message.role !== \"user\") continue;\n\n\t\t\tconst text = this._extractUserMessageText(entry.message.content);\n\t\t\tif (text) {\n\t\t\t\tresult.push({ entryId: entry.id, text });\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tprivate _extractUserMessageText(content: string | Array<{ type: string; text?: string }>): string {\n\t\tif (typeof content === \"string\") return content;\n\t\tif (Array.isArray(content)) {\n\t\t\treturn content\n\t\t\t\t.filter((c): c is { type: \"text\"; text: string } => c.type === \"text\")\n\t\t\t\t.map((c) => c.text)\n\t\t\t\t.join(\"\");\n\t\t}\n\t\treturn \"\";\n\t}\n}\n"]}
|
|
@@ -90,6 +90,7 @@ export class SessionTreeNavigator {
|
|
|
90
90
|
// Run default summarizer if needed
|
|
91
91
|
let summaryText;
|
|
92
92
|
let summaryDetails;
|
|
93
|
+
let summaryUsage;
|
|
93
94
|
if (options.summarize && entriesToSummarize.length > 0 && !extensionSummary) {
|
|
94
95
|
const model = this.deps.getModel();
|
|
95
96
|
const { apiKey, headers } = await this.deps.getRequiredRequestAuth(model);
|
|
@@ -111,6 +112,7 @@ export class SessionTreeNavigator {
|
|
|
111
112
|
throw new Error(result.error);
|
|
112
113
|
}
|
|
113
114
|
summaryText = result.summary;
|
|
115
|
+
summaryUsage = result.usage;
|
|
114
116
|
summaryDetails = {
|
|
115
117
|
readFiles: result.readFiles || [],
|
|
116
118
|
modifiedFiles: result.modifiedFiles || [],
|
|
@@ -119,6 +121,7 @@ export class SessionTreeNavigator {
|
|
|
119
121
|
else if (extensionSummary) {
|
|
120
122
|
summaryText = extensionSummary.summary;
|
|
121
123
|
summaryDetails = extensionSummary.details;
|
|
124
|
+
summaryUsage = extensionSummary.usage;
|
|
122
125
|
}
|
|
123
126
|
// Determine the new leaf position based on target type
|
|
124
127
|
let newLeafId;
|
|
@@ -148,7 +151,7 @@ export class SessionTreeNavigator {
|
|
|
148
151
|
let summaryEntry;
|
|
149
152
|
if (summaryText) {
|
|
150
153
|
// Create summary at target position (can be null for root)
|
|
151
|
-
const summaryId = sessionManager.branchWithSummary(newLeafId, summaryText, summaryDetails, fromExtension);
|
|
154
|
+
const summaryId = sessionManager.branchWithSummary(newLeafId, summaryText, summaryDetails, fromExtension, summaryUsage);
|
|
152
155
|
summaryEntry = sessionManager.getEntry(summaryId);
|
|
153
156
|
// Attach label to the summary entry
|
|
154
157
|
if (label) {
|