@caupulican/pi-adaptative 0.81.42 → 0.81.43
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 +37 -0
- package/dist/bun/cli.d.ts.map +1 -1
- package/dist/bun/cli.js.map +1 -1
- package/dist/bun/register-bedrock.d.ts.map +1 -1
- package/dist/bun/restore-sandbox-env.d.ts.map +1 -1
- package/dist/bun/restore-sandbox-env.js.map +1 -1
- 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.map +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.d.ts.map +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.js +52 -49
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.js.map +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.ts +62 -57
- package/dist/bundled-resources/prompts/skillify.md +1 -1
- package/dist/bundled-resources/runtimes/pi-shell-engine/commands/fs.py +16 -19
- package/dist/bundled-resources/runtimes/pi-shell-engine/commands/search.py +12 -26
- package/dist/bundled-resources/runtimes/pi-shell-engine/commands/strings.py +15 -121
- package/dist/bundled-resources/runtimes/pi-shell-engine/commands/text.py +52 -79
- package/dist/bundled-resources/runtimes/pi-shell-engine/escapes.py +70 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/exec.py +110 -61
- package/dist/bundled-resources/runtimes/pi-shell-engine/main.py +106 -23
- package/dist/bundled-resources/runtimes/pi-shell-engine/paths.py +10 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/proc.py +12 -4
- package/dist/bundled-resources/runtimes/pi-shell-engine/shell_args.py +22 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/state.py +9 -2
- package/dist/bundled-resources/runtimes/pi-shell-engine/tokens.py +129 -259
- package/dist/bundled-resources/skills/authorized-web-security-audit/SKILL.md +187 -0
- package/dist/bundled-resources/skills/authorized-web-security-audit/references/assessment-contract.md +92 -0
- package/dist/bundled-resources/skills/deduplicate-by-evidence/SKILL.md +134 -0
- package/dist/bundled-resources/skills/evidence-gated-tdd/SKILL.md +93 -0
- package/dist/bundled-resources/skills/evidence-gated-tdd/references/evidence-model.md +27 -0
- package/dist/bundled-resources/skills/evidence-gated-tdd/references/security-scanners.md +24 -0
- package/dist/bundled-resources/skills/harness-self-adaptation/SKILL.md +4 -2
- package/dist/bundled-resources/skills/secure-agent-tool-surfaces/SKILL.md +217 -0
- package/dist/bundled-resources/skills/secure-agent-tool-surfaces/references/defensive-exploit-catalogue.md +175 -0
- package/dist/bundled-resources/skills/secure-agent-tool-surfaces/references/tool-boundary-checklist.md +87 -0
- package/dist/bundled-resources/skills/skill-architect/SKILL.md +2 -2
- package/dist/bundled-resources/skills/skill-creator/SKILL.md +188 -0
- package/dist/bundled-resources/skills/skill-creator/references/pi-skill-contract.md +73 -0
- package/dist/bundled-resources/skills/skill-creator/scripts/init-skill.mjs +142 -0
- package/dist/bundled-resources/skills/skill-creator/scripts/validate-skill.mjs +122 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/config-selector.d.ts.map +1 -1
- package/dist/cli/config-selector.js.map +1 -1
- package/dist/cli/file-processor.d.ts.map +1 -1
- package/dist/cli/file-processor.js +8 -8
- package/dist/cli/file-processor.js.map +1 -1
- package/dist/cli/initial-message.d.ts +1 -1
- package/dist/cli/initial-message.d.ts.map +1 -1
- package/dist/cli/initial-message.js.map +1 -1
- package/dist/cli/list-models.d.ts.map +1 -1
- package/dist/cli/list-models.js.map +1 -1
- package/dist/cli/piped-stdin.d.ts +4 -0
- package/dist/cli/piped-stdin.d.ts.map +1 -0
- package/dist/cli/piped-stdin.js +13 -0
- package/dist/cli/piped-stdin.js.map +1 -0
- package/dist/cli/session-picker.d.ts.map +1 -1
- package/dist/cli/session-picker.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +9 -14
- package/dist/config.js.map +1 -1
- package/dist/core/agent-directory-layout.d.ts.map +1 -1
- package/dist/core/agent-directory-layout.js.map +1 -1
- package/dist/core/agent-paths.d.ts.map +1 -1
- package/dist/core/agent-paths.js.map +1 -1
- package/dist/core/agent-session-contracts.d.ts +5 -9
- package/dist/core/agent-session-contracts.d.ts.map +1 -1
- package/dist/core/agent-session-contracts.js +1 -12
- package/dist/core/agent-session-contracts.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +10 -25
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session.d.ts +24 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +210 -237
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-guidance.d.ts.map +1 -1
- package/dist/core/auth-guidance.js.map +1 -1
- package/dist/core/auth-storage.d.ts +4 -1
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +13 -39
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/autonomy/approval-gate.d.ts.map +1 -1
- package/dist/core/autonomy/approval-gate.js.map +1 -1
- package/dist/core/autonomy/bounded-completion.d.ts.map +1 -1
- package/dist/core/autonomy/bounded-completion.js.map +1 -1
- package/dist/core/autonomy/contracts.d.ts.map +1 -1
- package/dist/core/autonomy/envelope-enforcement.d.ts.map +1 -1
- package/dist/core/autonomy/envelope-enforcement.js.map +1 -1
- package/dist/core/autonomy/evidence-finding-projection.d.ts +11 -0
- package/dist/core/autonomy/evidence-finding-projection.d.ts.map +1 -0
- package/dist/core/autonomy/evidence-finding-projection.js +37 -0
- package/dist/core/autonomy/evidence-finding-projection.js.map +1 -0
- package/dist/core/autonomy/foreground-envelope.d.ts.map +1 -1
- 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.map +1 -1
- package/dist/core/autonomy/lane-private-paths.d.ts.map +1 -1
- package/dist/core/autonomy/lane-private-paths.js.map +1 -1
- package/dist/core/autonomy/lane-tool-surface.d.ts.map +1 -1
- package/dist/core/autonomy/lane-tool-surface.js.map +1 -1
- package/dist/core/autonomy/lane-tracker.d.ts.map +1 -1
- package/dist/core/autonomy/lane-tracker.js +2 -3
- package/dist/core/autonomy/lane-tracker.js.map +1 -1
- package/dist/core/autonomy/path-scope.d.ts.map +1 -1
- package/dist/core/autonomy/path-scope.js.map +1 -1
- package/dist/core/autonomy/risk-assessment.d.ts.map +1 -1
- package/dist/core/autonomy/session-lane-record.d.ts.map +1 -1
- package/dist/core/autonomy/session-lane-record.js.map +1 -1
- package/dist/core/autonomy/status.d.ts.map +1 -1
- package/dist/core/autonomy/status.js.map +1 -1
- package/dist/core/autonomy/subagent-prompt.d.ts.map +1 -1
- package/dist/core/autonomy/subagent-prompt.js.map +1 -1
- package/dist/core/autonomy/telemetry-events.d.ts.map +1 -1
- package/dist/core/autonomy/telemetry-events.js.map +1 -1
- package/dist/core/autonomy-telemetry.d.ts.map +1 -1
- package/dist/core/autonomy-telemetry.js +2 -4
- package/dist/core/autonomy-telemetry.js.map +1 -1
- package/dist/core/background-lane-controller.d.ts.map +1 -1
- package/dist/core/background-lane-controller.js +2 -15
- package/dist/core/background-lane-controller.js.map +1 -1
- package/dist/core/background-tool-task-controller.d.ts +88 -0
- package/dist/core/background-tool-task-controller.d.ts.map +1 -0
- package/dist/core/background-tool-task-controller.js +470 -0
- package/dist/core/background-tool-task-controller.js.map +1 -0
- package/dist/core/bash-execution-controller.d.ts +1 -0
- package/dist/core/bash-execution-controller.d.ts.map +1 -1
- package/dist/core/bash-execution-controller.js +5 -4
- package/dist/core/bash-execution-controller.js.map +1 -1
- package/dist/core/bash-executor.d.ts.map +1 -1
- package/dist/core/bash-executor.js.map +1 -1
- package/dist/core/bedrock-sso-login.d.ts.map +1 -1
- package/dist/core/bedrock-sso-login.js.map +1 -1
- package/dist/core/billing-failover-controller.d.ts.map +1 -1
- package/dist/core/billing-failover-controller.js +3 -3
- package/dist/core/billing-failover-controller.js.map +1 -1
- package/dist/core/billing-failover.d.ts.map +1 -1
- package/dist/core/billing-failover.js.map +1 -1
- package/dist/core/capability-contract.d.ts.map +1 -1
- package/dist/core/catalog-manager.d.ts.map +1 -1
- package/dist/core/catalog-manager.js +0 -0
- package/dist/core/catalog-manager.js.map +1 -1
- package/dist/core/compaction-controller.d.ts +2 -0
- package/dist/core/compaction-controller.d.ts.map +1 -1
- package/dist/core/compaction-controller.js +21 -8
- package/dist/core/compaction-controller.js.map +1 -1
- package/dist/core/compaction-support.d.ts +8 -0
- package/dist/core/compaction-support.d.ts.map +1 -1
- package/dist/core/compaction-support.js +0 -2
- package/dist/core/compaction-support.js.map +1 -1
- package/dist/core/context/artifact-retrieval.d.ts.map +1 -1
- package/dist/core/context/artifact-retrieval.js.map +1 -1
- package/dist/core/context/brain-curator.d.ts.map +1 -1
- package/dist/core/context/brain-curator.js +14 -33
- package/dist/core/context/brain-curator.js.map +1 -1
- package/dist/core/context/context-artifacts.d.ts.map +1 -1
- package/dist/core/context/context-artifacts.js +16 -24
- package/dist/core/context/context-artifacts.js.map +1 -1
- package/dist/core/context/context-audit.d.ts.map +1 -1
- package/dist/core/context/context-audit.js +3 -17
- package/dist/core/context/context-audit.js.map +1 -1
- package/dist/core/context/context-composition.d.ts.map +1 -1
- package/dist/core/context/context-composition.js.map +1 -1
- package/dist/core/context/context-item.d.ts.map +1 -1
- package/dist/core/context/context-item.js.map +1 -1
- package/dist/core/context/context-prompt-enforcement.d.ts.map +1 -1
- package/dist/core/context/context-prompt-enforcement.js +3 -16
- package/dist/core/context/context-prompt-enforcement.js.map +1 -1
- package/dist/core/context/context-prompt-policy.d.ts.map +1 -1
- package/dist/core/context/context-prompt-policy.js.map +1 -1
- package/dist/core/context/context-retention.d.ts.map +1 -1
- package/dist/core/context/context-retention.js.map +1 -1
- package/dist/core/context/context-store-retention.d.ts.map +1 -1
- package/dist/core/context/context-store-retention.js.map +1 -1
- package/dist/core/context/context-store.d.ts.map +1 -1
- package/dist/core/context/context-store.js.map +1 -1
- package/dist/core/context/context-tool-result.d.ts +4 -0
- package/dist/core/context/context-tool-result.d.ts.map +1 -0
- package/dist/core/context/context-tool-result.js +15 -0
- package/dist/core/context/context-tool-result.js.map +1 -0
- package/dist/core/context/current-work-memory.d.ts.map +1 -1
- package/dist/core/context/current-work-memory.js.map +1 -1
- package/dist/core/context/file-store-memory-provider.d.ts.map +1 -1
- package/dist/core/context/file-store-memory-provider.js +7 -28
- package/dist/core/context/file-store-memory-provider.js.map +1 -1
- package/dist/core/context/local-memory-search.d.ts +11 -0
- package/dist/core/context/local-memory-search.d.ts.map +1 -0
- package/dist/core/context/local-memory-search.js +37 -0
- package/dist/core/context/local-memory-search.js.map +1 -0
- package/dist/core/context/long-term-memory-trigger.d.ts.map +1 -1
- package/dist/core/context/long-term-memory-trigger.js.map +1 -1
- package/dist/core/context/memory-diagnostics.d.ts.map +1 -1
- package/dist/core/context/memory-diagnostics.js.map +1 -1
- package/dist/core/context/memory-index-store.d.ts.map +1 -1
- package/dist/core/context/memory-index-store.js.map +1 -1
- package/dist/core/context/memory-prompt-block.d.ts.map +1 -1
- package/dist/core/context/memory-prompt-block.js.map +1 -1
- package/dist/core/context/memory-prompt-budget.d.ts.map +1 -1
- package/dist/core/context/memory-prompt-budget.js.map +1 -1
- package/dist/core/context/memory-provider-contract.d.ts.map +1 -1
- package/dist/core/context/memory-provider-contract.js.map +1 -1
- package/dist/core/context/memory-retrieval.d.ts.map +1 -1
- package/dist/core/context/memory-retrieval.js.map +1 -1
- package/dist/core/context/memory-tier-composer.d.ts.map +1 -1
- package/dist/core/context/memory-tier-composer.js.map +1 -1
- package/dist/core/context/message-text.d.ts +7 -0
- package/dist/core/context/message-text.d.ts.map +1 -0
- package/dist/core/context/message-text.js +68 -0
- package/dist/core/context/message-text.js.map +1 -0
- package/dist/core/context/okf-memory-provider.d.ts.map +1 -1
- package/dist/core/context/okf-memory-provider.js +4 -30
- package/dist/core/context/okf-memory-provider.js.map +1 -1
- package/dist/core/context/okf-memory.d.ts.map +1 -1
- package/dist/core/context/okf-memory.js.map +1 -1
- package/dist/core/context/policy-engine.d.ts.map +1 -1
- package/dist/core/context/policy-engine.js.map +1 -1
- package/dist/core/context/policy-types.d.ts.map +1 -1
- package/dist/core/context/sqlite-runtime-index.d.ts.map +1 -1
- package/dist/core/context/sqlite-runtime-index.js.map +1 -1
- package/dist/core/context/storage-authority.d.ts.map +1 -1
- package/dist/core/context/tool-output-packer.d.ts.map +1 -1
- package/dist/core/context/tool-output-packer.js.map +1 -1
- package/dist/core/context-gc.d.ts.map +1 -1
- package/dist/core/context-gc.js +14 -21
- package/dist/core/context-gc.js.map +1 -1
- package/dist/core/context-pipeline.d.ts +1 -3
- package/dist/core/context-pipeline.d.ts.map +1 -1
- package/dist/core/context-pipeline.js +64 -145
- 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.map +1 -1
- package/dist/core/cost/daily-usage.d.ts.map +1 -1
- package/dist/core/cost/daily-usage.js.map +1 -1
- package/dist/core/cost/session-usage.d.ts.map +1 -1
- package/dist/core/cost/session-usage.js.map +1 -1
- package/dist/core/cost-guard.d.ts.map +1 -1
- package/dist/core/cost-guard.js.map +1 -1
- package/dist/core/default-tool-surface.d.ts.map +1 -1
- package/dist/core/default-tool-surface.js +1 -0
- package/dist/core/default-tool-surface.js.map +1 -1
- package/dist/core/defaults.d.ts.map +1 -1
- package/dist/core/delegation/managed-lane-controller.d.ts.map +1 -1
- package/dist/core/delegation/managed-lane-controller.js +2 -6
- package/dist/core/delegation/managed-lane-controller.js.map +1 -1
- package/dist/core/delegation/session-worker-claim.d.ts.map +1 -1
- package/dist/core/delegation/session-worker-claim.js.map +1 -1
- package/dist/core/delegation/worker-action-journal.d.ts.map +1 -1
- package/dist/core/delegation/worker-action-journal.js +0 -4
- package/dist/core/delegation/worker-action-journal.js.map +1 -1
- package/dist/core/delegation/worker-actions.d.ts.map +1 -1
- package/dist/core/delegation/worker-actions.js.map +1 -1
- package/dist/core/delegation/worker-agent-control-coordinator.d.ts +1 -0
- package/dist/core/delegation/worker-agent-control-coordinator.d.ts.map +1 -1
- package/dist/core/delegation/worker-agent-control-coordinator.js +13 -15
- package/dist/core/delegation/worker-agent-control-coordinator.js.map +1 -1
- package/dist/core/delegation/worker-agent-control.d.ts.map +1 -1
- package/dist/core/delegation/worker-agent-control.js +1 -4
- package/dist/core/delegation/worker-agent-control.js.map +1 -1
- package/dist/core/delegation/worker-attempt-executor.d.ts.map +1 -1
- package/dist/core/delegation/worker-attempt-executor.js.map +1 -1
- package/dist/core/delegation/worker-claim.d.ts.map +1 -1
- package/dist/core/delegation/worker-claim.js.map +1 -1
- package/dist/core/delegation/worker-conversation-store.d.ts.map +1 -1
- package/dist/core/delegation/worker-conversation-store.js +0 -2
- package/dist/core/delegation/worker-conversation-store.js.map +1 -1
- package/dist/core/delegation/worker-delegation-controller.d.ts.map +1 -1
- package/dist/core/delegation/worker-delegation-controller.js +5 -14
- package/dist/core/delegation/worker-delegation-controller.js.map +1 -1
- package/dist/core/delegation/worker-delegation-request.d.ts.map +1 -1
- package/dist/core/delegation/worker-dispatch-scheduler.d.ts.map +1 -1
- package/dist/core/delegation/worker-dispatch-scheduler.js +5 -6
- package/dist/core/delegation/worker-dispatch-scheduler.js.map +1 -1
- package/dist/core/delegation/worker-execution-policy.d.ts.map +1 -1
- package/dist/core/delegation/worker-execution-policy.js.map +1 -1
- package/dist/core/delegation/worker-lane-projection.d.ts.map +1 -1
- package/dist/core/delegation/worker-lane-projection.js.map +1 -1
- package/dist/core/delegation/worker-lifecycle.d.ts.map +1 -1
- package/dist/core/delegation/worker-lifecycle.js +0 -3
- package/dist/core/delegation/worker-lifecycle.js.map +1 -1
- package/dist/core/delegation/worker-notification-coordinator.d.ts.map +1 -1
- package/dist/core/delegation/worker-notification-coordinator.js +4 -5
- package/dist/core/delegation/worker-notification-coordinator.js.map +1 -1
- package/dist/core/delegation/worker-process-owner.d.ts.map +1 -1
- package/dist/core/delegation/worker-process-owner.js.map +1 -1
- package/dist/core/delegation/worker-profile-resolver.d.ts.map +1 -1
- package/dist/core/delegation/worker-profile-resolver.js +1 -2
- package/dist/core/delegation/worker-profile-resolver.js.map +1 -1
- package/dist/core/delegation/worker-recovery-coordinator.d.ts.map +1 -1
- package/dist/core/delegation/worker-recovery-coordinator.js +3 -4
- package/dist/core/delegation/worker-recovery-coordinator.js.map +1 -1
- package/dist/core/delegation/worker-resource-catalog.d.ts.map +1 -1
- package/dist/core/delegation/worker-resource-catalog.js.map +1 -1
- package/dist/core/delegation/worker-resource-materializer.d.ts.map +1 -1
- package/dist/core/delegation/worker-resource-materializer.js +1 -4
- package/dist/core/delegation/worker-resource-materializer.js.map +1 -1
- package/dist/core/delegation/worker-runner.d.ts +2 -4
- package/dist/core/delegation/worker-runner.d.ts.map +1 -1
- package/dist/core/delegation/worker-runner.js +6 -18
- package/dist/core/delegation/worker-runner.js.map +1 -1
- package/dist/core/delegation/worker-task-label.d.ts.map +1 -1
- package/dist/core/delegation/worker-task-label.js.map +1 -1
- package/dist/core/delegation/worker-terminal-finalizer.d.ts.map +1 -1
- package/dist/core/delegation/worker-terminal-finalizer.js.map +1 -1
- package/dist/core/delegation/worker-write-reservation-coordinator.d.ts.map +1 -1
- package/dist/core/delegation/worker-write-reservation-coordinator.js +1 -4
- package/dist/core/delegation/worker-write-reservation-coordinator.js.map +1 -1
- package/dist/core/delegation/worker-write-reservation.d.ts.map +1 -1
- package/dist/core/delegation/worker-write-reservation.js +0 -2
- package/dist/core/delegation/worker-write-reservation.js.map +1 -1
- package/dist/core/diagnostics.d.ts.map +1 -1
- package/dist/core/doctor.d.ts.map +1 -1
- package/dist/core/doctor.js.map +1 -1
- package/dist/core/event-bus.d.ts.map +1 -1
- package/dist/core/event-bus.js.map +1 -1
- package/dist/core/exec.d.ts.map +1 -1
- package/dist/core/exec.js +26 -7
- package/dist/core/exec.js.map +1 -1
- package/dist/core/export-html/ansi-to-html.d.ts.map +1 -1
- package/dist/core/export-html/ansi-to-html.js +21 -74
- package/dist/core/export-html/ansi-to-html.js.map +1 -1
- package/dist/core/export-html/index.d.ts.map +1 -1
- package/dist/core/export-html/index.js +4 -0
- package/dist/core/export-html/index.js.map +1 -1
- package/dist/core/export-html/session-tree-foundations.d.mts +67 -0
- package/dist/core/export-html/session-tree-foundations.mjs +313 -0
- package/dist/core/export-html/template.css +14 -41
- package/dist/core/export-html/template.html +3 -1
- package/dist/core/export-html/template.js +26 -435
- package/dist/core/export-html/tool-renderer.d.ts.map +1 -1
- package/dist/core/export-html/tool-renderer.js.map +1 -1
- package/dist/core/extension-import-authority.d.ts.map +1 -1
- package/dist/core/extension-import-authority.js.map +1 -1
- package/dist/core/extension-metadata.d.ts.map +1 -1
- package/dist/core/extension-metadata.js.map +1 -1
- package/dist/core/extensions/builtin.d.ts +17 -0
- package/dist/core/extensions/builtin.d.ts.map +1 -1
- package/dist/core/extensions/builtin.js +18 -54
- package/dist/core/extensions/builtin.js.map +1 -1
- package/dist/core/extensions/entry-resolution.d.ts +3 -0
- package/dist/core/extensions/entry-resolution.d.ts.map +1 -0
- package/dist/core/extensions/entry-resolution.js +17 -0
- package/dist/core/extensions/entry-resolution.js.map +1 -0
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +76 -21
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +2 -0
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +41 -112
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/stale-context.d.ts.map +1 -1
- package/dist/core/extensions/storage.d.ts.map +1 -1
- package/dist/core/extensions/storage.js.map +1 -1
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/extensions/wrapper.d.ts.map +1 -1
- package/dist/core/extensions/wrapper.js.map +1 -1
- package/dist/core/failure-corpus.d.ts.map +1 -1
- package/dist/core/failure-corpus.js +2 -5
- package/dist/core/failure-corpus.js.map +1 -1
- package/dist/core/footer-data-provider.d.ts.map +1 -1
- package/dist/core/footer-data-provider.js +27 -33
- package/dist/core/footer-data-provider.js.map +1 -1
- package/dist/core/foreground-recovery-controller.d.ts.map +1 -1
- package/dist/core/foreground-recovery-controller.js +0 -4
- package/dist/core/foreground-recovery-controller.js.map +1 -1
- package/dist/core/gateways/channel-provider.d.ts.map +1 -1
- package/dist/core/gateways/channel-provider.js +7 -5
- package/dist/core/gateways/channel-provider.js.map +1 -1
- package/dist/core/goal-loop-controller.d.ts.map +1 -1
- package/dist/core/goal-loop-controller.js +0 -1
- package/dist/core/goal-loop-controller.js.map +1 -1
- package/dist/core/goals/compact-goal-context.d.ts.map +1 -1
- package/dist/core/goals/compact-goal-context.js +2 -4
- package/dist/core/goals/compact-goal-context.js.map +1 -1
- package/dist/core/goals/goal-acceptance.d.ts.map +1 -1
- package/dist/core/goals/goal-acceptance.js.map +1 -1
- package/dist/core/goals/goal-auto-continue-controller.d.ts.map +1 -1
- package/dist/core/goals/goal-auto-continue-controller.js +1 -3
- package/dist/core/goals/goal-auto-continue-controller.js.map +1 -1
- package/dist/core/goals/goal-continuation-controller.d.ts.map +1 -1
- package/dist/core/goals/goal-continuation-controller.js.map +1 -1
- package/dist/core/goals/goal-continuation-defaults.d.ts.map +1 -1
- package/dist/core/goals/goal-continuation-prompt.d.ts.map +1 -1
- package/dist/core/goals/goal-continuation-prompt.js.map +1 -1
- package/dist/core/goals/goal-lifecycle.d.ts.map +1 -1
- package/dist/core/goals/goal-lifecycle.js.map +1 -1
- package/dist/core/goals/goal-record.d.ts.map +1 -1
- package/dist/core/goals/goal-record.js.map +1 -1
- package/dist/core/goals/goal-runtime-snapshot.d.ts.map +1 -1
- package/dist/core/goals/goal-runtime-snapshot.js.map +1 -1
- package/dist/core/goals/goal-session-controller.d.ts +15 -0
- package/dist/core/goals/goal-session-controller.d.ts.map +1 -1
- package/dist/core/goals/goal-session-controller.js +27 -3
- package/dist/core/goals/goal-session-controller.js.map +1 -1
- package/dist/core/goals/goal-state.d.ts.map +1 -1
- package/dist/core/goals/goal-state.js +35 -51
- package/dist/core/goals/goal-state.js.map +1 -1
- package/dist/core/goals/goal-tool-core.d.ts.map +1 -1
- package/dist/core/goals/goal-tool-core.js.map +1 -1
- package/dist/core/goals/natural-language-goal.d.ts +9 -0
- package/dist/core/goals/natural-language-goal.d.ts.map +1 -0
- package/dist/core/goals/natural-language-goal.js +23 -0
- package/dist/core/goals/natural-language-goal.js.map +1 -0
- package/dist/core/goals/session-goal-state.d.ts.map +1 -1
- package/dist/core/goals/session-goal-state.js.map +1 -1
- package/dist/core/http-dispatcher.d.ts.map +1 -1
- package/dist/core/http-dispatcher.js.map +1 -1
- package/dist/core/human-input-controller.d.ts.map +1 -1
- package/dist/core/human-input-controller.js +2 -3
- package/dist/core/human-input-controller.js.map +1 -1
- package/dist/core/human-input.d.ts.map +1 -1
- package/dist/core/human-input.js.map +1 -1
- package/dist/core/improvement-loop.d.ts.map +1 -1
- package/dist/core/improvement-loop.js +11 -11
- package/dist/core/improvement-loop.js.map +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/install-telemetry.d.ts.map +1 -1
- package/dist/core/install-telemetry.js.map +1 -1
- package/dist/core/isolated-text-completion.d.ts +17 -0
- package/dist/core/isolated-text-completion.d.ts.map +1 -0
- package/dist/core/isolated-text-completion.js +15 -0
- package/dist/core/isolated-text-completion.js.map +1 -0
- package/dist/core/keybindings.d.ts +47 -2
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +12 -1
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/learning/learning-audit.d.ts.map +1 -1
- 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.map +1 -1
- package/dist/core/learning/observation-store.d.ts.map +1 -1
- package/dist/core/learning/observation-store.js +0 -2
- package/dist/core/learning/observation-store.js.map +1 -1
- package/dist/core/learning/reflection-engine.d.ts +1 -1
- package/dist/core/learning/reflection-engine.d.ts.map +1 -1
- package/dist/core/learning/reflection-engine.js +3 -0
- package/dist/core/learning/reflection-engine.js.map +1 -1
- package/dist/core/learning/reflection-turn-analysis.d.ts +20 -0
- package/dist/core/learning/reflection-turn-analysis.d.ts.map +1 -0
- package/dist/core/learning/reflection-turn-analysis.js +136 -0
- package/dist/core/learning/reflection-turn-analysis.js.map +1 -0
- package/dist/core/learning/session-learning-decision.d.ts.map +1 -1
- package/dist/core/learning/session-learning-decision.js.map +1 -1
- package/dist/core/learning/skill-curator.d.ts.map +1 -1
- package/dist/core/learning/skill-curator.js +0 -3
- package/dist/core/learning/skill-curator.js.map +1 -1
- package/dist/core/local-runtime-controller.d.ts +39 -0
- package/dist/core/local-runtime-controller.d.ts.map +1 -1
- package/dist/core/local-runtime-controller.js +41 -62
- package/dist/core/local-runtime-controller.js.map +1 -1
- package/dist/core/memory/effectiveness-tracker.d.ts.map +1 -1
- package/dist/core/memory/effectiveness-tracker.js +4 -2
- package/dist/core/memory/effectiveness-tracker.js.map +1 -1
- package/dist/core/memory/memory-manager.d.ts.map +1 -1
- package/dist/core/memory/memory-manager.js +7 -7
- package/dist/core/memory/memory-manager.js.map +1 -1
- package/dist/core/memory/memory-provider.d.ts.map +1 -1
- package/dist/core/memory/providers/file-store.d.ts +7 -0
- package/dist/core/memory/providers/file-store.d.ts.map +1 -1
- package/dist/core/memory/providers/file-store.js +48 -13
- package/dist/core/memory/providers/file-store.js.map +1 -1
- package/dist/core/memory/providers/transcript-recall-worker-protocol.d.ts +47 -0
- package/dist/core/memory/providers/transcript-recall-worker-protocol.d.ts.map +1 -0
- package/dist/core/memory/providers/transcript-recall-worker-protocol.js +50 -0
- package/dist/core/memory/providers/transcript-recall-worker-protocol.js.map +1 -0
- package/dist/core/memory/providers/transcript-recall-worker.d.ts +2 -0
- package/dist/core/memory/providers/transcript-recall-worker.d.ts.map +1 -0
- package/dist/core/memory/providers/transcript-recall-worker.js +143 -0
- package/dist/core/memory/providers/transcript-recall-worker.js.map +1 -0
- package/dist/core/memory/providers/transcript-recall.d.ts +24 -13
- package/dist/core/memory/providers/transcript-recall.d.ts.map +1 -1
- package/dist/core/memory/providers/transcript-recall.js +143 -141
- package/dist/core/memory/providers/transcript-recall.js.map +1 -1
- package/dist/core/memory/providers/user-memory-archive.d.ts +39 -0
- package/dist/core/memory/providers/user-memory-archive.d.ts.map +1 -0
- package/dist/core/memory/providers/user-memory-archive.js +258 -0
- package/dist/core/memory/providers/user-memory-archive.js.map +1 -0
- package/dist/core/memory/transcript-index.d.ts.map +1 -1
- package/dist/core/memory/transcript-index.js +1 -1
- package/dist/core/memory/transcript-index.js.map +1 -1
- package/dist/core/memory-controller.d.ts +9 -0
- package/dist/core/memory-controller.d.ts.map +1 -1
- package/dist/core/memory-controller.js +57 -16
- package/dist/core/memory-controller.js.map +1 -1
- package/dist/core/model-capability.d.ts.map +1 -1
- package/dist/core/model-capability.js.map +1 -1
- package/dist/core/model-output-json.d.ts +10 -0
- package/dist/core/model-output-json.d.ts.map +1 -0
- package/dist/core/model-output-json.js +43 -0
- package/dist/core/model-output-json.js.map +1 -0
- package/dist/core/model-registry.d.ts +8 -8
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +29 -52
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +1 -1
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/model-router/config-diagnostics.d.ts.map +1 -1
- package/dist/core/model-router/config-diagnostics.js.map +1 -1
- package/dist/core/model-router/executor-route.d.ts.map +1 -1
- package/dist/core/model-router/executor-route.js.map +1 -1
- package/dist/core/model-router/fitness-gate.d.ts.map +1 -1
- package/dist/core/model-router/fitness-gate.js.map +1 -1
- package/dist/core/model-router/intent-classifier.d.ts.map +1 -1
- package/dist/core/model-router/route-judge.d.ts.map +1 -1
- package/dist/core/model-router/route-judge.js +18 -36
- package/dist/core/model-router/route-judge.js.map +1 -1
- package/dist/core/model-router/session-buffer.d.ts.map +1 -1
- package/dist/core/model-router/session-buffer.js.map +1 -1
- package/dist/core/model-router/status.d.ts.map +1 -1
- package/dist/core/model-router/status.js.map +1 -1
- package/dist/core/model-router/tool-escalation.d.ts.map +1 -1
- package/dist/core/model-router/tool-escalation.js.map +1 -1
- package/dist/core/model-router-controller.d.ts +1 -0
- package/dist/core/model-router-controller.d.ts.map +1 -1
- package/dist/core/model-router-controller.js +25 -56
- package/dist/core/model-router-controller.js.map +1 -1
- package/dist/core/model-selection-controller.d.ts +10 -0
- package/dist/core/model-selection-controller.d.ts.map +1 -1
- package/dist/core/model-selection-controller.js +0 -1
- package/dist/core/model-selection-controller.js.map +1 -1
- package/dist/core/model-tool-protocol.d.ts.map +1 -1
- package/dist/core/model-tool-protocol.js.map +1 -1
- package/dist/core/models/adaptation-store.d.ts.map +1 -1
- package/dist/core/models/adaptation-store.js +0 -1
- package/dist/core/models/adaptation-store.js.map +1 -1
- package/dist/core/models/context-sizing.d.ts.map +1 -1
- package/dist/core/models/context-sizing.js.map +1 -1
- package/dist/core/models/default-model-suggestions.d.ts.map +1 -1
- package/dist/core/models/default-model-suggestions.js.map +1 -1
- package/dist/core/models/fitness-store.d.ts.map +1 -1
- package/dist/core/models/fitness-store.js +0 -1
- package/dist/core/models/fitness-store.js.map +1 -1
- package/dist/core/models/host-state-store.d.ts.map +1 -1
- package/dist/core/models/host-state-store.js +1 -6
- package/dist/core/models/host-state-store.js.map +1 -1
- package/dist/core/models/llamacpp-runtime.d.ts +4 -19
- package/dist/core/models/llamacpp-runtime.d.ts.map +1 -1
- package/dist/core/models/llamacpp-runtime.js +32 -136
- package/dist/core/models/llamacpp-runtime.js.map +1 -1
- package/dist/core/models/local-registration.d.ts.map +1 -1
- package/dist/core/models/local-registration.js +82 -115
- package/dist/core/models/local-registration.js.map +1 -1
- package/dist/core/models/local-runtime.d.ts +12 -18
- package/dist/core/models/local-runtime.d.ts.map +1 -1
- package/dist/core/models/local-runtime.js +60 -204
- package/dist/core/models/local-runtime.js.map +1 -1
- package/dist/core/models/model-endpoint.d.ts.map +1 -1
- package/dist/core/models/model-endpoint.js.map +1 -1
- package/dist/core/models/model-ref.d.ts.map +1 -1
- package/dist/core/models/model-ref.js.map +1 -1
- package/dist/core/models/needle-runtime.d.ts +7 -3
- package/dist/core/models/needle-runtime.d.ts.map +1 -1
- package/dist/core/models/needle-runtime.js +16 -92
- package/dist/core/models/needle-runtime.js.map +1 -1
- package/dist/core/models/perf-profile.d.ts +1 -1
- package/dist/core/models/perf-profile.d.ts.map +1 -1
- package/dist/core/models/perf-profile.js +6 -13
- package/dist/core/models/perf-profile.js.map +1 -1
- package/dist/core/models/prism-llamacpp-lifecycle.d.ts.map +1 -1
- package/dist/core/models/prism-llamacpp-lifecycle.js.map +1 -1
- package/dist/core/models/runtime-arbiter.d.ts.map +1 -1
- package/dist/core/models/runtime-arbiter.js +3 -15
- package/dist/core/models/runtime-arbiter.js.map +1 -1
- package/dist/core/models/runtime-process.d.ts +100 -0
- package/dist/core/models/runtime-process.d.ts.map +1 -0
- package/dist/core/models/runtime-process.js +183 -0
- package/dist/core/models/runtime-process.js.map +1 -0
- package/dist/core/orchestration/agent-resume.d.ts.map +1 -1
- package/dist/core/orchestration/agent-resume.js.map +1 -1
- package/dist/core/orchestration/attempt-usage.d.ts.map +1 -1
- package/dist/core/orchestration/attempt-usage.js.map +1 -1
- package/dist/core/orchestration/capability-gateway.d.ts.map +1 -1
- package/dist/core/orchestration/capability-gateway.js +0 -14
- package/dist/core/orchestration/capability-gateway.js.map +1 -1
- package/dist/core/orchestration/contracts.d.ts.map +1 -1
- package/dist/core/orchestration/contracts.js.map +1 -1
- package/dist/core/orchestration/delegation-ledger.d.ts.map +1 -1
- package/dist/core/orchestration/delegation-ledger.js +0 -2
- package/dist/core/orchestration/delegation-ledger.js.map +1 -1
- package/dist/core/orchestration/event-store.d.ts.map +1 -1
- package/dist/core/orchestration/event-store.js +1 -14
- package/dist/core/orchestration/event-store.js.map +1 -1
- package/dist/core/orchestration/lane-tool-manifests.d.ts.map +1 -1
- package/dist/core/orchestration/lane-tool-manifests.js.map +1 -1
- package/dist/core/orchestration/model-binding.d.ts.map +1 -1
- package/dist/core/orchestration/model-binding.js.map +1 -1
- package/dist/core/orchestration/policy-compiler.d.ts.map +1 -1
- package/dist/core/orchestration/policy-compiler.js +0 -3
- package/dist/core/orchestration/policy-compiler.js.map +1 -1
- package/dist/core/orchestration/policy-gate.d.ts.map +1 -1
- package/dist/core/orchestration/policy-gate.js +0 -2
- package/dist/core/orchestration/policy-gate.js.map +1 -1
- package/dist/core/orchestration/profile-registry.d.ts.map +1 -1
- package/dist/core/orchestration/profile-registry.js +1 -1
- package/dist/core/orchestration/profile-registry.js.map +1 -1
- package/dist/core/orchestration/profile-store.d.ts.map +1 -1
- package/dist/core/orchestration/profile-store.js +0 -3
- package/dist/core/orchestration/profile-store.js.map +1 -1
- package/dist/core/orchestration/risk-budget.d.ts.map +1 -1
- package/dist/core/orchestration/risk-budget.js.map +1 -1
- package/dist/core/orchestration/task-runtime.d.ts +1 -0
- package/dist/core/orchestration/task-runtime.d.ts.map +1 -1
- package/dist/core/orchestration/task-runtime.js +27 -42
- package/dist/core/orchestration/task-runtime.js.map +1 -1
- package/dist/core/orchestration/work-state-projection.d.ts.map +1 -1
- package/dist/core/orchestration/work-state-projection.js.map +1 -1
- package/dist/core/orchestration/worker-execution-contract.d.ts.map +1 -1
- package/dist/core/orchestration/worker-execution-contract.js.map +1 -1
- package/dist/core/orchestration/worker-result-adapter.d.ts.map +1 -1
- package/dist/core/orchestration/worker-result-adapter.js.map +1 -1
- package/dist/core/output-guard.d.ts.map +1 -1
- package/dist/core/output-guard.js.map +1 -1
- package/dist/core/package-manager.d.ts +3 -0
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +88 -353
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/process-identity.d.ts.map +1 -1
- package/dist/core/process-identity.js.map +1 -1
- package/dist/core/process-liveness.d.ts +3 -0
- package/dist/core/process-liveness.d.ts.map +1 -0
- package/dist/core/process-liveness.js +17 -0
- package/dist/core/process-liveness.js.map +1 -0
- package/dist/core/process-matrix/codes.d.ts.map +1 -1
- package/dist/core/process-matrix/resume-launcher.d.ts.map +1 -1
- package/dist/core/process-matrix/resume-launcher.js.map +1 -1
- package/dist/core/process-matrix/runtime.d.ts.map +1 -1
- package/dist/core/process-matrix/runtime.js.map +1 -1
- package/dist/core/process-matrix/store.d.ts.map +1 -1
- package/dist/core/process-matrix/store.js.map +1 -1
- package/dist/core/process-matrix/supervisor.d.ts.map +1 -1
- package/dist/core/process-matrix/supervisor.js.map +1 -1
- package/dist/core/profile-filter-controller.d.ts.map +1 -1
- package/dist/core/profile-filter-controller.js +7 -8
- 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 +1 -2
- package/dist/core/profile-registry.js.map +1 -1
- package/dist/core/profile-resource-selection.d.ts.map +1 -1
- package/dist/core/profile-resource-selection.js +18 -59
- package/dist/core/profile-resource-selection.js.map +1 -1
- package/dist/core/prompt-markup.d.ts +3 -0
- package/dist/core/prompt-markup.d.ts.map +1 -0
- package/dist/core/prompt-markup.js +7 -0
- package/dist/core/prompt-markup.js.map +1 -0
- package/dist/core/prompt-templates.d.ts.map +1 -1
- package/dist/core/prompt-templates.js +13 -39
- package/dist/core/prompt-templates.js.map +1 -1
- package/dist/core/provider-display-names.d.ts.map +1 -1
- package/dist/core/python-runtime.d.ts.map +1 -1
- package/dist/core/python-runtime.js.map +1 -1
- package/dist/core/reflection-controller.d.ts +22 -1
- package/dist/core/reflection-controller.d.ts.map +1 -1
- package/dist/core/reflection-controller.js +143 -25
- package/dist/core/reflection-controller.js.map +1 -1
- package/dist/core/reload-blockers.d.ts +2 -1
- package/dist/core/reload-blockers.d.ts.map +1 -1
- package/dist/core/reload-blockers.js +4 -14
- package/dist/core/reload-blockers.js.map +1 -1
- package/dist/core/request-auth.d.ts.map +1 -1
- package/dist/core/request-auth.js.map +1 -1
- package/dist/core/research/automata-provider.d.ts.map +1 -1
- package/dist/core/research/automata-provider.js.map +1 -1
- package/dist/core/research/evidence-bundle.d.ts.map +1 -1
- package/dist/core/research/evidence-bundle.js.map +1 -1
- package/dist/core/research/lane-model-resolver.d.ts.map +1 -1
- package/dist/core/research/lane-model-resolver.js +0 -1
- package/dist/core/research/lane-model-resolver.js.map +1 -1
- package/dist/core/research/model-fitness-controller.d.ts.map +1 -1
- package/dist/core/research/model-fitness-controller.js +17 -33
- package/dist/core/research/model-fitness-controller.js.map +1 -1
- package/dist/core/research/model-fitness.d.ts.map +1 -1
- package/dist/core/research/model-fitness.js +4 -25
- 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.map +1 -1
- package/dist/core/research/research-lane-controller.d.ts.map +1 -1
- package/dist/core/research/research-lane-controller.js +5 -10
- package/dist/core/research/research-lane-controller.js.map +1 -1
- package/dist/core/research/research-runner.d.ts +2 -4
- package/dist/core/research/research-runner.d.ts.map +1 -1
- package/dist/core/research/research-runner.js +17 -48
- package/dist/core/research/research-runner.js.map +1 -1
- package/dist/core/research/session-evidence-bundle.d.ts.map +1 -1
- package/dist/core/research/session-evidence-bundle.js.map +1 -1
- package/dist/core/research/workspace-collector.d.ts.map +1 -1
- package/dist/core/research/workspace-collector.js.map +1 -1
- package/dist/core/resolve-config-value.d.ts.map +1 -1
- package/dist/core/resolve-config-value.js.map +1 -1
- package/dist/core/resource-ignore.d.ts +6 -0
- package/dist/core/resource-ignore.d.ts.map +1 -0
- package/dist/core/resource-ignore.js +44 -0
- package/dist/core/resource-ignore.js.map +1 -0
- package/dist/core/resource-loader.d.ts +0 -1
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +52 -187
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/resource-profile-blocks.d.ts +3 -1
- package/dist/core/resource-profile-blocks.d.ts.map +1 -1
- package/dist/core/resource-profile-blocks.js +8 -5
- package/dist/core/resource-profile-blocks.js.map +1 -1
- package/dist/core/resource-profile-equality.d.ts.map +1 -1
- package/dist/core/resource-profile-equality.js.map +1 -1
- package/dist/core/resource-traversal.d.ts +43 -0
- package/dist/core/resource-traversal.d.ts.map +1 -0
- package/dist/core/resource-traversal.js +84 -0
- package/dist/core/resource-traversal.js.map +1 -0
- package/dist/core/risk-classifier.d.ts.map +1 -1
- package/dist/core/risk-classifier.js.map +1 -1
- package/dist/core/runtime-builder.d.ts +4 -1
- package/dist/core/runtime-builder.d.ts.map +1 -1
- package/dist/core/runtime-builder.js +25 -50
- package/dist/core/runtime-builder.js.map +1 -1
- package/dist/core/scout-controller.d.ts.map +1 -1
- package/dist/core/scout-controller.js +0 -1
- package/dist/core/scout-controller.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/secrets/credential-exposure-guard.d.ts.map +1 -1
- package/dist/core/secrets/credential-exposure-guard.js +70 -44
- package/dist/core/secrets/credential-exposure-guard.js.map +1 -1
- package/dist/core/secrets/secret-dotenv.d.ts.map +1 -1
- package/dist/core/secrets/secret-dotenv.js +0 -1
- package/dist/core/secrets/secret-dotenv.js.map +1 -1
- package/dist/core/secrets/secret-vault-format.d.ts.map +1 -1
- package/dist/core/secrets/secret-vault-format.js +0 -1
- package/dist/core/secrets/secret-vault-format.js.map +1 -1
- package/dist/core/secrets/secret-vault.d.ts.map +1 -1
- package/dist/core/secrets/secret-vault.js +2 -10
- package/dist/core/secrets/secret-vault.js.map +1 -1
- package/dist/core/security/secret-text.d.ts.map +1 -1
- package/dist/core/security/secret-text.js.map +1 -1
- package/dist/core/security/untrusted-boundary.d.ts.map +1 -1
- package/dist/core/security/untrusted-boundary.js.map +1 -1
- package/dist/core/session-analytics.d.ts.map +1 -1
- package/dist/core/session-analytics.js +18 -50
- package/dist/core/session-analytics.js.map +1 -1
- package/dist/core/session-artifact-bundle.d.ts.map +1 -1
- package/dist/core/session-artifact-bundle.js.map +1 -1
- package/dist/core/session-cwd.d.ts.map +1 -1
- package/dist/core/session-cwd.js +0 -1
- package/dist/core/session-cwd.js.map +1 -1
- package/dist/core/session-entry-index.d.ts +8 -0
- package/dist/core/session-entry-index.d.ts.map +1 -0
- package/dist/core/session-entry-index.js +16 -0
- package/dist/core/session-entry-index.js.map +1 -0
- package/dist/core/session-image-store.d.ts.map +1 -1
- package/dist/core/session-image-store.js +0 -3
- package/dist/core/session-image-store.js.map +1 -1
- package/dist/core/session-jsonl-writer.d.ts +3 -0
- package/dist/core/session-jsonl-writer.d.ts.map +1 -0
- package/dist/core/session-jsonl-writer.js +38 -0
- package/dist/core/session-jsonl-writer.js.map +1 -0
- package/dist/core/session-manager-factory.d.ts.map +1 -1
- package/dist/core/session-manager-factory.js.map +1 -1
- package/dist/core/session-role.d.ts.map +1 -1
- package/dist/core/session-role.js.map +1 -1
- package/dist/core/session-snapshot.d.ts.map +1 -1
- package/dist/core/session-snapshot.js.map +1 -1
- package/dist/core/session-supervision-runtime.d.ts.map +1 -1
- package/dist/core/session-supervision-runtime.js +1 -4
- package/dist/core/session-supervision-runtime.js.map +1 -1
- package/dist/core/session-tree-navigator.d.ts.map +1 -1
- package/dist/core/session-tree-navigator.js +0 -1
- package/dist/core/session-tree-navigator.js.map +1 -1
- package/dist/core/settings-manager.d.ts +2 -1
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +64 -162
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/skill-block.d.mts +8 -0
- package/dist/core/skill-block.mjs +52 -0
- package/dist/core/skill-discovery.d.ts +5 -0
- package/dist/core/skill-discovery.d.ts.map +1 -0
- package/dist/core/skill-discovery.js +34 -0
- package/dist/core/skill-discovery.js.map +1 -0
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +23 -159
- package/dist/core/skills.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/source-info.d.ts.map +1 -1
- package/dist/core/source-info.js.map +1 -1
- package/dist/core/spawned-usage.d.ts +21 -0
- package/dist/core/spawned-usage.d.ts.map +1 -0
- package/dist/core/spawned-usage.js +29 -0
- package/dist/core/spawned-usage.js.map +1 -0
- package/dist/core/system-prompt-builder.d.ts +4 -0
- package/dist/core/system-prompt-builder.d.ts.map +1 -1
- package/dist/core/system-prompt-builder.js +15 -8
- package/dist/core/system-prompt-builder.js.map +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +52 -35
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tasks/session-task-state.d.ts.map +1 -1
- package/dist/core/tasks/session-task-state.js.map +1 -1
- package/dist/core/tasks/task-command.d.ts.map +1 -1
- package/dist/core/tasks/task-command.js.map +1 -1
- package/dist/core/tasks/task-contract-monitor.d.ts.map +1 -1
- package/dist/core/tasks/task-contract-monitor.js.map +1 -1
- package/dist/core/tasks/task-projection.d.ts.map +1 -1
- package/dist/core/tasks/task-projection.js.map +1 -1
- package/dist/core/tasks/task-state.d.ts.map +1 -1
- package/dist/core/tasks/task-state.js.map +1 -1
- package/dist/core/text-preview.d.ts +4 -0
- package/dist/core/text-preview.d.ts.map +1 -0
- package/dist/core/text-preview.js +33 -0
- package/dist/core/text-preview.js.map +1 -0
- package/dist/core/timings.d.ts.map +1 -1
- package/dist/core/timings.js.map +1 -1
- package/dist/core/tool-capability-policy.d.ts.map +1 -1
- package/dist/core/tool-capability-policy.js.map +1 -1
- package/dist/core/tool-gate-controller.d.ts.map +1 -1
- package/dist/core/tool-gate-controller.js +86 -87
- package/dist/core/tool-gate-controller.js.map +1 -1
- package/dist/core/tool-protocol-controller.d.ts +4 -1
- package/dist/core/tool-protocol-controller.d.ts.map +1 -1
- package/dist/core/tool-protocol-controller.js +19 -23
- package/dist/core/tool-protocol-controller.js.map +1 -1
- package/dist/core/tool-recovery-log-records.d.ts.map +1 -1
- package/dist/core/tool-recovery-log-records.js.map +1 -1
- package/dist/core/tool-recovery-log-worker.d.ts.map +1 -1
- package/dist/core/tool-recovery-log-worker.js.map +1 -1
- package/dist/core/tool-recovery-logger.d.ts.map +1 -1
- package/dist/core/tool-recovery-logger.js +12 -24
- package/dist/core/tool-recovery-logger.js.map +1 -1
- package/dist/core/tool-recovery-stats.d.ts.map +1 -1
- package/dist/core/tool-recovery-stats.js +16 -22
- package/dist/core/tool-recovery-stats.js.map +1 -1
- package/dist/core/tool-repair-health.d.ts.map +1 -1
- package/dist/core/tool-repair-health.js.map +1 -1
- package/dist/core/tool-repair-settings.d.ts.map +1 -1
- package/dist/core/tool-repair-settings.js.map +1 -1
- package/dist/core/tool-selection/expected-utility.d.ts.map +1 -1
- package/dist/core/tool-selection/expected-utility.js.map +1 -1
- package/dist/core/tool-selection/promotion.d.ts.map +1 -1
- package/dist/core/tool-selection/promotion.js.map +1 -1
- package/dist/core/tool-selection/tool-performance-store.d.ts +2 -0
- package/dist/core/tool-selection/tool-performance-store.d.ts.map +1 -1
- package/dist/core/tool-selection/tool-performance-store.js +49 -7
- package/dist/core/tool-selection/tool-performance-store.js.map +1 -1
- package/dist/core/tool-selection/tool-phase-timing.d.ts +19 -0
- package/dist/core/tool-selection/tool-phase-timing.d.ts.map +1 -0
- package/dist/core/tool-selection/tool-phase-timing.js +63 -0
- package/dist/core/tool-selection/tool-phase-timing.js.map +1 -0
- package/dist/core/tool-selection/tool-selection-controller.d.ts +2 -5
- package/dist/core/tool-selection/tool-selection-controller.d.ts.map +1 -1
- package/dist/core/tool-selection/tool-selection-controller.js +50 -30
- package/dist/core/tool-selection/tool-selection-controller.js.map +1 -1
- package/dist/core/toolkit/reflex-interpreter.d.ts +16 -0
- package/dist/core/toolkit/reflex-interpreter.d.ts.map +1 -1
- package/dist/core/toolkit/reflex-interpreter.js +21 -0
- package/dist/core/toolkit/reflex-interpreter.js.map +1 -1
- package/dist/core/toolkit/script-registry.d.ts.map +1 -1
- package/dist/core/toolkit/script-registry.js.map +1 -1
- package/dist/core/toolkit/script-runner.d.ts.map +1 -1
- package/dist/core/toolkit/script-runner.js.map +1 -1
- package/dist/core/tools/artifact-retrieve.d.ts.map +1 -1
- package/dist/core/tools/artifact-retrieve.js.map +1 -1
- package/dist/core/tools/ask-question.d.ts +2 -3
- package/dist/core/tools/ask-question.d.ts.map +1 -1
- package/dist/core/tools/ask-question.js +14 -40
- package/dist/core/tools/ask-question.js.map +1 -1
- package/dist/core/tools/bash.d.ts +2 -0
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +83 -30
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/context-scout.d.ts.map +1 -1
- package/dist/core/tools/context-scout.js.map +1 -1
- package/dist/core/tools/delegate-status.d.ts.map +1 -1
- package/dist/core/tools/delegate-status.js +9 -7
- package/dist/core/tools/delegate-status.js.map +1 -1
- package/dist/core/tools/delegate.d.ts.map +1 -1
- package/dist/core/tools/delegate.js +6 -6
- package/dist/core/tools/delegate.js.map +1 -1
- package/dist/core/tools/edit-diff.d.ts.map +1 -1
- package/dist/core/tools/edit-diff.js.map +1 -1
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/extensionify.d.ts.map +1 -1
- package/dist/core/tools/extensionify.js.map +1 -1
- package/dist/core/tools/fff-search-backend.d.ts +19 -0
- package/dist/core/tools/fff-search-backend.d.ts.map +1 -1
- package/dist/core/tools/fff-search-backend.js +28 -2
- package/dist/core/tools/fff-search-backend.js.map +1 -1
- package/dist/core/tools/file-encoding-policy.d.ts.map +1 -1
- package/dist/core/tools/file-encoding-policy.js.map +1 -1
- package/dist/core/tools/file-mutation-queue.d.ts.map +1 -1
- package/dist/core/tools/file-mutation-queue.js.map +1 -1
- package/dist/core/tools/find.d.ts +1 -1
- package/dist/core/tools/find.d.ts.map +1 -1
- package/dist/core/tools/find.js +44 -108
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/git-filter.d.ts.map +1 -1
- package/dist/core/tools/git-filter.js.map +1 -1
- package/dist/core/tools/goal.d.ts.map +1 -1
- package/dist/core/tools/goal.js +7 -7
- package/dist/core/tools/goal.js.map +1 -1
- package/dist/core/tools/grep.d.ts +1 -1
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/grep.js +42 -102
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/ls.d.ts.map +1 -1
- package/dist/core/tools/ls.js +20 -36
- package/dist/core/tools/ls.js.map +1 -1
- package/dist/core/tools/model-fitness.d.ts.map +1 -1
- package/dist/core/tools/model-fitness.js.map +1 -1
- package/dist/core/tools/orchestration-panel.d.ts +5 -0
- package/dist/core/tools/orchestration-panel.d.ts.map +1 -1
- package/dist/core/tools/orchestration-panel.js +5 -5
- package/dist/core/tools/orchestration-panel.js.map +1 -1
- package/dist/core/tools/output-accumulator.d.ts +2 -0
- package/dist/core/tools/output-accumulator.d.ts.map +1 -1
- package/dist/core/tools/output-accumulator.js +24 -36
- package/dist/core/tools/output-accumulator.js.map +1 -1
- package/dist/core/tools/path-utils.d.ts.map +1 -1
- package/dist/core/tools/path-utils.js.map +1 -1
- package/dist/core/tools/persistent-process-coordinator.d.ts +31 -0
- package/dist/core/tools/persistent-process-coordinator.d.ts.map +1 -0
- package/dist/core/tools/persistent-process-coordinator.js +123 -0
- package/dist/core/tools/persistent-process-coordinator.js.map +1 -0
- package/dist/core/tools/python.d.ts.map +1 -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 +14 -13
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/render-utils.d.ts +29 -0
- package/dist/core/tools/render-utils.d.ts.map +1 -1
- package/dist/core/tools/render-utils.js +31 -1
- package/dist/core/tools/render-utils.js.map +1 -1
- package/dist/core/tools/run-process.d.ts.map +1 -1
- package/dist/core/tools/run-process.js.map +1 -1
- package/dist/core/tools/run-toolkit-script.d.ts.map +1 -1
- package/dist/core/tools/run-toolkit-script.js.map +1 -1
- package/dist/core/tools/search-command-guard.d.ts +10 -0
- package/dist/core/tools/search-command-guard.d.ts.map +1 -1
- package/dist/core/tools/search-command-guard.js +118 -31
- package/dist/core/tools/search-command-guard.js.map +1 -1
- package/dist/core/tools/search-router.d.ts.map +1 -1
- package/dist/core/tools/search-router.js.map +1 -1
- package/dist/core/tools/search-tool-runtime.d.ts +19 -0
- package/dist/core/tools/search-tool-runtime.d.ts.map +1 -0
- package/dist/core/tools/search-tool-runtime.js +12 -0
- package/dist/core/tools/search-tool-runtime.js.map +1 -0
- package/dist/core/tools/secret-store.d.ts.map +1 -1
- package/dist/core/tools/secret-store.js.map +1 -1
- package/dist/core/tools/shell-command-parser.d.ts.map +1 -1
- package/dist/core/tools/shell-command-parser.js.map +1 -1
- package/dist/core/tools/shell-contract-router.d.ts.map +1 -1
- package/dist/core/tools/shell-contract-router.js +4 -1
- package/dist/core/tools/shell-contract-router.js.map +1 -1
- package/dist/core/tools/shell-execution-session.d.ts +4 -0
- package/dist/core/tools/shell-execution-session.d.ts.map +1 -0
- package/dist/core/tools/shell-execution-session.js +11 -0
- package/dist/core/tools/shell-execution-session.js.map +1 -0
- package/dist/core/tools/shell-output-projection.d.ts +49 -0
- package/dist/core/tools/shell-output-projection.d.ts.map +1 -0
- package/dist/core/tools/shell-output-projection.js +381 -0
- package/dist/core/tools/shell-output-projection.js.map +1 -0
- package/dist/core/tools/shell-session.d.ts +2 -13
- package/dist/core/tools/shell-session.d.ts.map +1 -1
- package/dist/core/tools/shell-session.js +36 -136
- package/dist/core/tools/shell-session.js.map +1 -1
- package/dist/core/tools/skill-audit.d.ts.map +1 -1
- package/dist/core/tools/skill-audit.js.map +1 -1
- package/dist/core/tools/skillify.d.ts.map +1 -1
- package/dist/core/tools/skillify.js.map +1 -1
- package/dist/core/tools/task-steps.d.ts +8 -8
- package/dist/core/tools/task-steps.d.ts.map +1 -1
- package/dist/core/tools/task-steps.js +17 -18
- package/dist/core/tools/task-steps.js.map +1 -1
- package/dist/core/tools/tmux-dispatch.d.ts.map +1 -1
- package/dist/core/tools/tmux-dispatch.js.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
- package/dist/core/tools/tool-task.d.ts +23 -0
- package/dist/core/tools/tool-task.d.ts.map +1 -0
- package/dist/core/tools/tool-task.js +93 -0
- package/dist/core/tools/tool-task.js.map +1 -0
- package/dist/core/tools/windows-shell-engine.d.ts +17 -11
- package/dist/core/tools/windows-shell-engine.d.ts.map +1 -1
- package/dist/core/tools/windows-shell-engine.js +339 -117
- package/dist/core/tools/windows-shell-engine.js.map +1 -1
- package/dist/core/tools/windows-shell-state.d.ts.map +1 -1
- package/dist/core/tools/windows-shell-state.js.map +1 -1
- package/dist/core/tools/worktree-sync.d.ts.map +1 -1
- package/dist/core/tools/worktree-sync.js +8 -12
- package/dist/core/tools/worktree-sync.js.map +1 -1
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js +0 -1
- package/dist/core/tools/write.js.map +1 -1
- package/dist/core/trust-manager.d.ts.map +1 -1
- package/dist/core/trust-manager.js +7 -40
- package/dist/core/trust-manager.js.map +1 -1
- package/dist/core/util/atomic-file.d.ts +19 -0
- package/dist/core/util/atomic-file.d.ts.map +1 -1
- package/dist/core/util/atomic-file.js +50 -15
- package/dist/core/util/atomic-file.js.map +1 -1
- package/dist/core/util/bounded-file.d.ts.map +1 -1
- package/dist/core/util/bounded-file.js.map +1 -1
- package/dist/core/util/bounded-jsonl.d.ts.map +1 -1
- package/dist/core/util/bounded-jsonl.js +2 -9
- package/dist/core/util/bounded-jsonl.js.map +1 -1
- package/dist/core/util/bounded-value.d.ts.map +1 -1
- package/dist/core/util/bounded-value.js.map +1 -1
- package/dist/core/util/json-size.d.ts +3 -0
- package/dist/core/util/json-size.d.ts.map +1 -0
- package/dist/core/util/json-size.js +95 -0
- package/dist/core/util/json-size.js.map +1 -0
- package/dist/core/util/minimatch-cache.d.ts.map +1 -1
- package/dist/core/util/minimatch-cache.js.map +1 -1
- package/dist/core/util/value-guards.d.ts.map +1 -1
- package/dist/core/util/value-guards.js.map +1 -1
- package/dist/core/worktree-sync/codes.d.ts.map +1 -1
- package/dist/core/worktree-sync/git-engine.d.ts.map +1 -1
- package/dist/core/worktree-sync/git-engine.js +20 -36
- package/dist/core/worktree-sync/git-engine.js.map +1 -1
- package/dist/core/worktree-sync/lane-gate.d.ts.map +1 -1
- package/dist/core/worktree-sync/lane-gate.js +1 -4
- package/dist/core/worktree-sync/lane-gate.js.map +1 -1
- package/dist/core/worktree-sync/runtime.d.ts.map +1 -1
- package/dist/core/worktree-sync/runtime.js.map +1 -1
- package/dist/core/worktree-sync/store.d.ts.map +1 -1
- package/dist/core/worktree-sync/store.js.map +1 -1
- package/dist/core/worktree-sync/watcher.d.ts.map +1 -1
- package/dist/core/worktree-sync/watcher.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +10 -32
- package/dist/main.js.map +1 -1
- package/dist/migrations.d.ts.map +1 -1
- package/dist/migrations.js +6 -19
- package/dist/migrations.js.map +1 -1
- package/dist/modes/index.d.ts.map +1 -1
- package/dist/modes/interactive/auth-dialogs-controller.d.ts +3 -0
- package/dist/modes/interactive/auth-dialogs-controller.d.ts.map +1 -1
- package/dist/modes/interactive/auth-dialogs-controller.js +96 -132
- package/dist/modes/interactive/auth-dialogs-controller.js.map +1 -1
- package/dist/modes/interactive/auto-learn-controller.d.ts +1 -31
- package/dist/modes/interactive/auto-learn-controller.d.ts.map +1 -1
- package/dist/modes/interactive/auto-learn-controller.js +86 -307
- package/dist/modes/interactive/auto-learn-controller.js.map +1 -1
- package/dist/modes/interactive/autocomplete-provider.d.ts.map +1 -1
- package/dist/modes/interactive/autocomplete-provider.js.map +1 -1
- package/dist/modes/interactive/autonomy-commands.d.ts.map +1 -1
- package/dist/modes/interactive/autonomy-commands.js +2 -8
- package/dist/modes/interactive/autonomy-commands.js.map +1 -1
- package/dist/modes/interactive/clipboard-input.d.ts +5 -1
- package/dist/modes/interactive/clipboard-input.d.ts.map +1 -1
- package/dist/modes/interactive/clipboard-input.js +17 -0
- package/dist/modes/interactive/clipboard-input.js.map +1 -1
- package/dist/modes/interactive/compaction-queue.d.ts.map +1 -1
- package/dist/modes/interactive/compaction-queue.js +13 -18
- package/dist/modes/interactive/compaction-queue.js.map +1 -1
- package/dist/modes/interactive/components/activity-lane.d.ts.map +1 -1
- package/dist/modes/interactive/components/activity-lane.js +6 -10
- package/dist/modes/interactive/components/activity-lane.js.map +1 -1
- package/dist/modes/interactive/components/armin.d.ts +1 -0
- package/dist/modes/interactive/components/armin.d.ts.map +1 -1
- package/dist/modes/interactive/components/armin.js +10 -21
- package/dist/modes/interactive/components/armin.js.map +1 -1
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +1 -6
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/bash-execution.js +4 -9
- package/dist/modes/interactive/components/bash-execution.js.map +1 -1
- package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -1
- package/dist/modes/interactive/components/bordered-loader.js +0 -3
- package/dist/modes/interactive/components/bordered-loader.js.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.d.ts +3 -8
- package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.js +13 -35
- package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.d.ts +3 -8
- package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.js +14 -36
- package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/config-selector.d.ts +1 -0
- package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/config-selector.js +20 -43
- package/dist/modes/interactive/components/config-selector.js.map +1 -1
- package/dist/modes/interactive/components/countdown-timer.d.ts.map +1 -1
- package/dist/modes/interactive/components/countdown-timer.js +0 -5
- package/dist/modes/interactive/components/countdown-timer.js.map +1 -1
- package/dist/modes/interactive/components/custom-editor.d.ts +2 -0
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-editor.js +4 -8
- package/dist/modes/interactive/components/custom-editor.js.map +1 -1
- package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-message.js +1 -6
- package/dist/modes/interactive/components/custom-message.js.map +1 -1
- package/dist/modes/interactive/components/daxnuts.d.ts.map +1 -1
- package/dist/modes/interactive/components/daxnuts.js +6 -8
- package/dist/modes/interactive/components/daxnuts.js.map +1 -1
- package/dist/modes/interactive/components/diff.d.ts.map +1 -1
- package/dist/modes/interactive/components/diff.js.map +1 -1
- package/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -1
- package/dist/modes/interactive/components/dynamic-border.js +0 -1
- package/dist/modes/interactive/components/dynamic-border.js.map +1 -1
- package/dist/modes/interactive/components/earendil-announcement.d.ts.map +1 -1
- package/dist/modes/interactive/components/earendil-announcement.js.map +1 -1
- package/dist/modes/interactive/components/expandable-markdown-message.d.ts +21 -0
- package/dist/modes/interactive/components/expandable-markdown-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/expandable-markdown-message.js +48 -0
- package/dist/modes/interactive/components/expandable-markdown-message.js.map +1 -0
- package/dist/modes/interactive/components/expandable-text.d.ts.map +1 -1
- package/dist/modes/interactive/components/expandable-text.js +0 -2
- package/dist/modes/interactive/components/expandable-text.js.map +1 -1
- package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-editor.js +1 -9
- package/dist/modes/interactive/components/extension-editor.js.map +1 -1
- package/dist/modes/interactive/components/extension-input.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-input.js +2 -8
- package/dist/modes/interactive/components/extension-input.js.map +1 -1
- package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-selector.js +5 -20
- package/dist/modes/interactive/components/extension-selector.js.map +1 -1
- package/dist/modes/interactive/components/fitness-role-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/fitness-role-selector.js +0 -1
- package/dist/modes/interactive/components/fitness-role-selector.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +1 -5
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/index.d.ts.map +1 -1
- package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -1
- package/dist/modes/interactive/components/keybinding-hints.js.map +1 -1
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
- package/dist/modes/interactive/components/login-dialog.js +4 -10
- package/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts +2 -2
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +21 -44
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/model-suggestion-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-suggestion-selector.js +0 -1
- package/dist/modes/interactive/components/model-suggestion-selector.js.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.d.ts +1 -1
- package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.js +16 -32
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
- package/dist/modes/interactive/components/profile-resource-editor.d.ts +3 -4
- package/dist/modes/interactive/components/profile-resource-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/profile-resource-editor.js +34 -93
- package/dist/modes/interactive/components/profile-resource-editor.js.map +1 -1
- package/dist/modes/interactive/components/profile-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/profile-selector.js +0 -1
- package/dist/modes/interactive/components/profile-selector.js.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.d.ts +3 -4
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.js +34 -79
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
- package/dist/modes/interactive/components/selector-list.d.ts +63 -0
- package/dist/modes/interactive/components/selector-list.d.ts.map +1 -0
- package/dist/modes/interactive/components/selector-list.js +186 -0
- package/dist/modes/interactive/components/selector-list.js.map +1 -0
- package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector-search.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +34 -59
- package/dist/modes/interactive/components/session-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 +40 -138
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/show-images-selector.d.ts +2 -4
- package/dist/modes/interactive/components/show-images-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/show-images-selector.js +9 -28
- package/dist/modes/interactive/components/show-images-selector.js.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.d.ts +3 -8
- package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.js +12 -40
- package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
- package/dist/modes/interactive/components/theme-selector.d.ts +2 -5
- package/dist/modes/interactive/components/theme-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/theme-selector.js +11 -37
- package/dist/modes/interactive/components/theme-selector.js.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.d.ts +2 -4
- package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.js +9 -31
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +9 -28
- 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 +2 -3
- package/dist/modes/interactive/components/tool-group.js.map +1 -1
- package/dist/modes/interactive/components/tool-panel-registry.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-panel-registry.js +5 -3
- package/dist/modes/interactive/components/tool-panel-registry.js.map +1 -1
- package/dist/modes/interactive/components/tool-title.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-title.js +0 -4
- package/dist/modes/interactive/components/tool-title.js.map +1 -1
- package/dist/modes/interactive/components/transcript-pager.d.ts +26 -0
- package/dist/modes/interactive/components/transcript-pager.d.ts.map +1 -0
- package/dist/modes/interactive/components/transcript-pager.js +81 -0
- package/dist/modes/interactive/components/transcript-pager.js.map +1 -0
- package/dist/modes/interactive/components/tree-selector.d.ts +1 -12
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector.js +42 -402
- package/dist/modes/interactive/components/tree-selector.js.map +1 -1
- package/dist/modes/interactive/components/trust-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/trust-selector.js +4 -16
- package/dist/modes/interactive/components/trust-selector.js.map +1 -1
- package/dist/modes/interactive/components/usage-action-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/usage-action-selector.js +2 -10
- package/dist/modes/interactive/components/usage-action-selector.js.map +1 -1
- package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message-selector.js +3 -6
- package/dist/modes/interactive/components/user-message-selector.js.map +1 -1
- package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message.js +0 -1
- package/dist/modes/interactive/components/user-message.js.map +1 -1
- package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -1
- package/dist/modes/interactive/components/visual-truncate.js.map +1 -1
- package/dist/modes/interactive/config-backup.d.ts.map +1 -1
- package/dist/modes/interactive/config-backup.js.map +1 -1
- package/dist/modes/interactive/editor-overlay-host.d.ts.map +1 -1
- package/dist/modes/interactive/editor-overlay-host.js +0 -3
- package/dist/modes/interactive/editor-overlay-host.js.map +1 -1
- package/dist/modes/interactive/extension-ui-host.d.ts +2 -0
- package/dist/modes/interactive/extension-ui-host.d.ts.map +1 -1
- package/dist/modes/interactive/extension-ui-host.js +51 -72
- package/dist/modes/interactive/extension-ui-host.js.map +1 -1
- package/dist/modes/interactive/external-editor.d.ts.map +1 -1
- package/dist/modes/interactive/external-editor.js +2 -15
- package/dist/modes/interactive/external-editor.js.map +1 -1
- package/dist/modes/interactive/history-reload-math.d.ts.map +1 -1
- package/dist/modes/interactive/history-reload-math.js.map +1 -1
- package/dist/modes/interactive/interactive-event-controller.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-event-controller.js +23 -16
- package/dist/modes/interactive/interactive-event-controller.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +13 -4
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +123 -204
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/interactive-selection-prompts.d.ts +20 -0
- package/dist/modes/interactive/interactive-selection-prompts.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-selection-prompts.js +43 -0
- package/dist/modes/interactive/interactive-selection-prompts.js.map +1 -0
- package/dist/modes/interactive/key-handlers.d.ts +2 -1
- package/dist/modes/interactive/key-handlers.d.ts.map +1 -1
- package/dist/modes/interactive/key-handlers.js +4 -2
- package/dist/modes/interactive/key-handlers.js.map +1 -1
- package/dist/modes/interactive/loaded-resources-view.d.ts.map +1 -1
- package/dist/modes/interactive/loaded-resources-view.js.map +1 -1
- package/dist/modes/interactive/local-model-commands.d.ts.map +1 -1
- package/dist/modes/interactive/local-model-commands.js +4 -9
- package/dist/modes/interactive/local-model-commands.js.map +1 -1
- package/dist/modes/interactive/model-fitness-presentation.d.ts +21 -0
- package/dist/modes/interactive/model-fitness-presentation.d.ts.map +1 -0
- package/dist/modes/interactive/model-fitness-presentation.js +13 -0
- package/dist/modes/interactive/model-fitness-presentation.js.map +1 -0
- package/dist/modes/interactive/profile-menu-controller.d.ts +2 -0
- package/dist/modes/interactive/profile-menu-controller.d.ts.map +1 -1
- package/dist/modes/interactive/profile-menu-controller.js +79 -171
- package/dist/modes/interactive/profile-menu-controller.js.map +1 -1
- package/dist/modes/interactive/report-commands.d.ts +2 -0
- package/dist/modes/interactive/report-commands.d.ts.map +1 -1
- package/dist/modes/interactive/report-commands.js +12 -6
- 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.map +1 -1
- package/dist/modes/interactive/resource-shell-commands.d.ts.map +1 -1
- package/dist/modes/interactive/resource-shell-commands.js +6 -23
- package/dist/modes/interactive/resource-shell-commands.js.map +1 -1
- package/dist/modes/interactive/session-flow-commands.d.ts.map +1 -1
- package/dist/modes/interactive/session-flow-commands.js +21 -25
- 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.map +1 -1
- package/dist/modes/interactive/session-replacement-errors.d.ts.map +1 -1
- package/dist/modes/interactive/session-replacement-errors.js.map +1 -1
- package/dist/modes/interactive/settings-selector-flow.d.ts.map +1 -1
- package/dist/modes/interactive/settings-selector-flow.js.map +1 -1
- package/dist/modes/interactive/signal-lifecycle.d.ts.map +1 -1
- package/dist/modes/interactive/signal-lifecycle.js.map +1 -1
- package/dist/modes/interactive/startup-checks.d.ts.map +1 -1
- package/dist/modes/interactive/startup-checks.js +12 -8
- package/dist/modes/interactive/startup-checks.js.map +1 -1
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +10 -76
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/modes/interactive/usage-commands.d.ts.map +1 -1
- package/dist/modes/interactive/usage-commands.js.map +1 -1
- package/dist/modes/print-mode.d.ts.map +1 -1
- package/dist/modes/print-mode.js +5 -22
- package/dist/modes/print-mode.js.map +1 -1
- package/dist/modes/rpc/jsonl.d.ts.map +1 -1
- package/dist/modes/rpc/jsonl.js +1 -1
- package/dist/modes/rpc/jsonl.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +7 -8
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +5 -20
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/modes/termination-signals.d.ts +4 -0
- package/dist/modes/termination-signals.d.ts.map +1 -0
- package/dist/modes/termination-signals.js +21 -0
- package/dist/modes/termination-signals.js.map +1 -0
- package/dist/package-manager-cli.d.ts.map +1 -1
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/utils/ansi-colors.d.ts +5 -0
- package/dist/utils/ansi-colors.d.ts.map +1 -0
- package/dist/utils/ansi-colors.js +38 -0
- package/dist/utils/ansi-colors.js.map +1 -0
- package/dist/utils/ansi.d.ts.map +1 -1
- package/dist/utils/ansi.js.map +1 -1
- package/dist/utils/changelog.d.ts.map +1 -1
- package/dist/utils/changelog.js.map +1 -1
- package/dist/utils/child-process.d.ts.map +1 -1
- package/dist/utils/child-process.js.map +1 -1
- package/dist/utils/clipboard-image.d.ts.map +1 -1
- package/dist/utils/clipboard-image.js.map +1 -1
- 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.map +1 -1
- package/dist/utils/clipboard.js.map +1 -1
- package/dist/utils/deprecation.d.ts.map +1 -1
- package/dist/utils/deprecation.js.map +1 -1
- package/dist/utils/exif-orientation.d.ts.map +1 -1
- package/dist/utils/exif-orientation.js.map +1 -1
- package/dist/utils/external-editor-command.d.ts.map +1 -1
- package/dist/utils/external-editor-command.js.map +1 -1
- package/dist/utils/frontmatter.d.ts.map +1 -1
- package/dist/utils/frontmatter.js.map +1 -1
- package/dist/utils/fs-watch.d.ts.map +1 -1
- package/dist/utils/fs-watch.js.map +1 -1
- package/dist/utils/git.d.ts.map +1 -1
- package/dist/utils/git.js +20 -28
- package/dist/utils/git.js.map +1 -1
- package/dist/utils/highlight-js-languages.d.ts.map +1 -1
- package/dist/utils/html.d.ts.map +1 -1
- package/dist/utils/html.js.map +1 -1
- package/dist/utils/image-convert.d.ts.map +1 -1
- package/dist/utils/image-convert.js.map +1 -1
- package/dist/utils/image-resize-core.d.ts.map +1 -1
- package/dist/utils/image-resize-core.js.map +1 -1
- package/dist/utils/image-resize-worker.d.ts.map +1 -1
- package/dist/utils/image-resize-worker.js.map +1 -1
- package/dist/utils/image-resize.d.ts.map +1 -1
- package/dist/utils/image-resize.js.map +1 -1
- package/dist/utils/json.d.ts.map +1 -1
- package/dist/utils/json.js.map +1 -1
- package/dist/utils/mime.d.ts.map +1 -1
- package/dist/utils/mime.js.map +1 -1
- package/dist/utils/open-browser.d.ts.map +1 -1
- package/dist/utils/open-browser.js.map +1 -1
- package/dist/utils/paths.d.ts.map +1 -1
- package/dist/utils/paths.js.map +1 -1
- package/dist/utils/photon.d.ts.map +1 -1
- package/dist/utils/photon.js.map +1 -1
- package/dist/utils/pi-user-agent.d.ts.map +1 -1
- package/dist/utils/pi-user-agent.js.map +1 -1
- package/dist/utils/platform.d.ts.map +1 -1
- package/dist/utils/platform.js.map +1 -1
- package/dist/utils/process-memory.d.ts.map +1 -1
- package/dist/utils/process-memory.js.map +1 -1
- package/dist/utils/safe-write-stream.d.ts.map +1 -1
- package/dist/utils/safe-write-stream.js.map +1 -1
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/sleep.d.ts.map +1 -1
- package/dist/utils/sleep.js +2 -15
- package/dist/utils/sleep.js.map +1 -1
- package/dist/utils/stdin-events.d.ts +8 -0
- package/dist/utils/stdin-events.d.ts.map +1 -0
- package/dist/utils/stdin-events.js +19 -0
- package/dist/utils/stdin-events.js.map +1 -0
- package/dist/utils/syntax-highlight.d.ts.map +1 -1
- package/dist/utils/syntax-highlight.js +20 -13
- package/dist/utils/syntax-highlight.js.map +1 -1
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/tools-manager.js.map +1 -1
- package/dist/utils/version-check.d.ts.map +1 -1
- package/dist/utils/version-check.js.map +1 -1
- package/dist/utils/windows-self-update.d.ts.map +1 -1
- package/dist/utils/windows-self-update.js.map +1 -1
- package/dist/utils/work-directory.d.ts.map +1 -1
- package/dist/utils/work-directory.js.map +1 -1
- package/docs/compaction.md +11 -3
- package/docs/sessions.md +6 -0
- package/docs/settings.md +1 -1
- package/docs/windows.md +26 -1
- package/docs/work-directory.md +9 -1
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +16 -16
- package/package.json +10 -10
- package/dist/utils/streaming-lines.d.ts +0 -20
- package/dist/utils/streaming-lines.d.ts.map +0 -1
- package/dist/utils/streaming-lines.js +0 -79
- package/dist/utils/streaming-lines.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"goal-continuation-controller.d.ts","sourceRoot":"","sources":["../../../src/core/goals/goal-continuation-controller.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,MAAM,MAAM,sBAAsB,GAAG,UAAU,GAAG,UAAU,GAAG,UAAU,GAAG,MAAM,GAAG,SAAS,CAAC;AAC/F,MAAM,MAAM,0BAA0B,GACnC,aAAa,GACb,gBAAgB,GAChB,aAAa,GACb,cAAc,GACd,oBAAoB,GACpB,qBAAqB,GACrB,gBAAgB,GAChB,qBAAqB,GACrB,0BAA0B,GAC1B,8BAA8B,GAC9B,8BAA8B,GAC9B,oBAAoB,GACpB,kBAAkB,GAClB,qBAAqB,GACrB,oBAAoB,GACpB,oBAAoB,CAAC;AAExB,MAAM,WAAW,wBAAwB;IACxC,MAAM,EAAE,sBAAsB,CAAC;IAC/B,UAAU,EAAE,0BAA0B,CAAC;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,kBAAkB,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,qBAAqB,EAAE,SAAS,MAAM,EAAE,CAAC;IACzC,uBAAuB,EAAE,SAAS,MAAM,EAAE,CAAC;CAC3C;AAED,MAAM,WAAW,wBAAwB;IACxC,aAAa,EAAE,MAAM,CAAC;CACtB;AAED,wBAAgB,wBAAwB,CAAC,IAAI,EAAE;IAC9C,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,QAAQ,EAAE,wBAAwB,CAAC;IACnC;;;;;;;OAOG;IACH,mBAAmB,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC1C;;;;;OAKG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;;;;;OAOG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;;;;;;;OAUG;IACH,wBAAwB,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC/C;;;;;;;OAOG;IACH,oBAAoB,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CAC3C,GAAG,wBAAwB,CAkO3B","sourcesContent":["import { getUnprovenGoalRequirementIds } from \"./goal-acceptance.ts\";\nimport type { GoalState } from \"./goal-state.ts\";\n\nexport type GoalContinuationAction = \"continue\" | \"ask-user\" | \"finalize\" | \"stop\" | \"waiting\";\nexport type GoalContinuationReasonCode =\n\t| \"goal_active\"\n\t| \"goal_completed\"\n\t| \"goal_paused\"\n\t| \"goal_blocked\"\n\t| \"goal_usage_limited\"\n\t| \"goal_budget_limited\"\n\t| \"goal_cancelled\"\n\t| \"stall_limit_reached\"\n\t| \"goal_completion_required\"\n\t| \"acceptance_evidence_required\"\n\t| \"blocked_requirements_present\"\n\t| \"missing_goal_state\"\n\t| \"worker_in_flight\"\n\t| \"worker_wait_timeout\"\n\t| \"lane_sync_conflict\"\n\t| \"lane_sync_required\";\n\nexport interface GoalContinuationDecision {\n\taction: GoalContinuationAction;\n\treasonCode: GoalContinuationReasonCode;\n\tmessage: string;\n\tgoalId?: string;\n\tstallTurns?: number;\n\tmaxStallTurns?: number;\n\topenRequirementIds: readonly string[];\n\tblockedRequirementIds: readonly string[];\n\tsatisfiedRequirementIds: readonly string[];\n}\n\nexport interface GoalContinuationSettings {\n\tmaxStallTurns: number;\n}\n\nexport function evaluateGoalContinuation(args: {\n\tstate?: GoalState;\n\tsettings: GoalContinuationSettings;\n\t/**\n\t * LaneIds currently queued/running AND tagged with THIS goal's id (see `LaneRecord.goalId`).\n\t * When an open requirement is bound (`Requirement.boundLaneId`) to one of these lanes, the\n\t * goal is WAITING on that worker rather than stalled or ready for another pass: the loop must not\n\t * submit a hollow continuation prompt (which would waste a turn while no parent work can advance),\n\t * and the idle scheduler must not race a re-dispatch against the same open requirement. Optional\n\t * so every pre-existing (in-flight-unaware) caller keeps compiling and behaving unchanged.\n\t */\n\tinFlightGoalLaneIds?: ReadonlySet<string>;\n\t/**\n\t * Current time as an ISO string, paired with `maxWorkerWaitMs` to detect a bound in-flight\n\t * requirement that has hung past its deadline (see below). Optional so every pre-existing\n\t * caller that omits it keeps behaving byte-identically -- the goal waits indefinitely, exactly\n\t * as before this field existed.\n\t */\n\tnow?: string;\n\t/**\n\t * Maximum milliseconds a bound in-flight requirement (`Requirement.boundAt`) may wait before\n\t * this escalates to `action:\"ask-user\"`/`reasonCode:\"worker_wait_timeout\"` instead of\n\t * `\"waiting\"` -- a worker that is alive-but-hung past its deadline must not wait forever. Only\n\t * takes effect when BOTH `now` and this are supplied; escalation fires only once EVERY\n\t * bound-in-flight open requirement has individually passed `boundAt + maxWorkerWaitMs`, so a\n\t * goal with a mix of fresh and stale bindings keeps waiting on the fresh one.\n\t */\n\tmaxWorkerWaitMs?: number;\n\t/**\n\t * Bound lanes (`Requirement.boundLaneId` -- SAME id-space as `inFlightGoalLaneIds`, not the raw\n\t * worktree-sync `laneKey`) whose worktree-sync lane has a rebase stopped on conflicts\n\t * (`LaneFacts.rebaseInProgress`). The caller (`goal-runtime-snapshot.ts`) is responsible for\n\t * translating live per-worktree-lane status into this id-space by matching each status entry's\n\t * own `boundLaneId` against the requirement -- this function stays pure and never resolves a\n\t * worktree laneKey itself, exactly like `inFlightGoalLaneIds` never resolves a tmux job id.\n\t * Checked BEFORE the waiting branch (see `lane_sync_conflict` below): a stalled-but-conflicted\n\t * worker must get the resolve directive, not silently wait forever. Optional so every\n\t * pre-existing caller keeps compiling and behaving byte-identically when omitted or empty.\n\t */\n\tlaneSyncConflictLaneKeys?: ReadonlySet<string>;\n\t/**\n\t * Bound lanes (`Requirement.boundLaneId`, same id-space note as {@link laneSyncConflictLaneKeys})\n\t * whose worktree-sync lane is stale and must sync with current main before further work\n\t * (`sync_required`, i.e. NOT already covered by `laneSyncConflictLaneKeys` -- a lane with a\n\t * rebase in progress is reported as a conflict, never double-counted here). Checked BEFORE the\n\t * waiting branch, same precedence rationale as above. Optional so every pre-existing caller keeps\n\t * compiling and behaving byte-identically when omitted or empty.\n\t */\n\tsyncRequiredLaneKeys?: ReadonlySet<string>;\n}): GoalContinuationDecision {\n\tif (!args.state) {\n\t\treturn {\n\t\t\taction: \"ask-user\",\n\t\t\treasonCode: \"missing_goal_state\",\n\t\t\tmessage: \"No goal state is present.\",\n\t\t\topenRequirementIds: [],\n\t\t\tblockedRequirementIds: [],\n\t\t\tsatisfiedRequirementIds: [],\n\t\t};\n\t}\n\n\tconst state = args.state;\n\tconst openRequirementIds: string[] = [];\n\tconst blockedRequirementIds: string[] = [];\n\tconst satisfiedRequirementIds: string[] = [];\n\n\tfor (const req of state.requirements) {\n\t\tif (req.status === \"open\") openRequirementIds.push(req.id);\n\t\telse if (req.status === \"blocked\") blockedRequirementIds.push(req.id);\n\t\telse if (req.status === \"satisfied\") satisfiedRequirementIds.push(req.id);\n\t}\n\n\tconst baseDecision = {\n\t\tgoalId: state.goalId,\n\t\tstallTurns: state.stallTurns,\n\t\tmaxStallTurns: args.settings.maxStallTurns,\n\t\topenRequirementIds,\n\t\tblockedRequirementIds,\n\t\tsatisfiedRequirementIds,\n\t};\n\n\tif (state.status === \"completed\") {\n\t\treturn {\n\t\t\t...baseDecision,\n\t\t\taction: \"finalize\",\n\t\t\treasonCode: \"goal_completed\",\n\t\t\tmessage: \"The goal is marked as completed.\",\n\t\t};\n\t}\n\n\tif (state.status === \"paused\") {\n\t\treturn {\n\t\t\t...baseDecision,\n\t\t\taction: \"stop\",\n\t\t\treasonCode: \"goal_paused\",\n\t\t\tmessage: \"The goal is paused by the owner.\",\n\t\t};\n\t}\n\n\tif (state.status === \"blocked\") {\n\t\treturn {\n\t\t\t...baseDecision,\n\t\t\taction: \"ask-user\",\n\t\t\treasonCode: \"goal_blocked\",\n\t\t\tmessage: \"The goal is explicitly blocked.\",\n\t\t};\n\t}\n\n\tif (state.status === \"usage_limited\") {\n\t\treturn {\n\t\t\t...baseDecision,\n\t\t\taction: \"ask-user\",\n\t\t\treasonCode: \"goal_usage_limited\",\n\t\t\tmessage: \"The goal stopped after the active provider reached a usage limit.\",\n\t\t};\n\t}\n\n\tif (state.status === \"budget_limited\") {\n\t\treturn {\n\t\t\t...baseDecision,\n\t\t\taction: \"stop\",\n\t\t\treasonCode: \"goal_budget_limited\",\n\t\t\tmessage: \"The goal exhausted its configured budget.\",\n\t\t};\n\t}\n\n\tif (state.status === \"cancelled\") {\n\t\treturn {\n\t\t\t...baseDecision,\n\t\t\taction: \"stop\",\n\t\t\treasonCode: \"goal_cancelled\",\n\t\t\tmessage: \"The goal has been cancelled.\",\n\t\t};\n\t}\n\n\tif (openRequirementIds.length === 0) {\n\t\tif (blockedRequirementIds.length > 0) {\n\t\t\treturn {\n\t\t\t\t...baseDecision,\n\t\t\t\taction: \"ask-user\",\n\t\t\t\treasonCode: \"blocked_requirements_present\",\n\t\t\t\tmessage: \"All remaining legacy goal requirements are blocked.\",\n\t\t\t};\n\t\t}\n\t\tif (state.requirements.length === 0) {\n\t\t\treturn {\n\t\t\t\t...baseDecision,\n\t\t\t\taction: \"continue\",\n\t\t\t\treasonCode: \"goal_active\",\n\t\t\t\tmessage: \"The compact goal record is active.\",\n\t\t\t};\n\t\t}\n\t\tconst unprovenRequirementIds = getUnprovenGoalRequirementIds(state);\n\t\tif (unprovenRequirementIds.length > 0) {\n\t\t\treturn {\n\t\t\t\t...baseDecision,\n\t\t\t\taction: \"continue\",\n\t\t\t\treasonCode: \"acceptance_evidence_required\",\n\t\t\t\tmessage: `Requirement(s) ${unprovenRequirementIds.join(\", \")} still need trusted acceptance evidence.`,\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t...baseDecision,\n\t\t\taction: \"continue\",\n\t\t\treasonCode: \"goal_completion_required\",\n\t\t\tmessage: \"All requirements are proven. Mark the goal complete only after confirming no required work remains.\",\n\t\t};\n\t}\n\n\t// Worktree-sync directives take precedence over the \"waiting\" branch below: a worker whose bound\n\t// lane is conflicted or stale is NOT merely in-flight-and-quiet -- it needs an explicit directive\n\t// (resolve conflicts, or sync) delivered through the continuation prompt, and a stalled-but-stale\n\t// worker must never be left waiting indefinitely for a sync it was never told to run. Conflict is\n\t// checked first: a lane with a rebase already stopped on conflicts cannot usefully be told to\n\t// \"sync\" again (that lane's `sync_required` flag is never set while `rebaseInProgress` is true --\n\t// see `goal-runtime-snapshot.ts` -- so the two sets below are disjoint by construction, not by a\n\t// priority check here).\n\tconst laneSyncConflictLaneKeys = args.laneSyncConflictLaneKeys;\n\tconst conflictedRequirements = laneSyncConflictLaneKeys\n\t\t? state.requirements.filter(\n\t\t\t\t(requirement) =>\n\t\t\t\t\trequirement.status === \"open\" &&\n\t\t\t\t\trequirement.boundLaneId !== undefined &&\n\t\t\t\t\tlaneSyncConflictLaneKeys.has(requirement.boundLaneId),\n\t\t\t)\n\t\t: [];\n\tif (conflictedRequirements.length > 0) {\n\t\treturn {\n\t\t\t...baseDecision,\n\t\t\taction: \"continue\",\n\t\t\treasonCode: \"lane_sync_conflict\",\n\t\t\tmessage: `Requirement(s) ${conflictedRequirements.map((requirement) => requirement.id).join(\", \")} are bound to a worktree-sync lane with a rebase stopped on conflicts; resolve via worktree_sync action:\"continue\" (or \"abort_sync\") before this goal can progress further.`,\n\t\t};\n\t}\n\n\tconst syncRequiredLaneKeys = args.syncRequiredLaneKeys;\n\tconst syncRequiredRequirements = syncRequiredLaneKeys\n\t\t? state.requirements.filter(\n\t\t\t\t(requirement) =>\n\t\t\t\t\trequirement.status === \"open\" &&\n\t\t\t\t\trequirement.boundLaneId !== undefined &&\n\t\t\t\t\tsyncRequiredLaneKeys.has(requirement.boundLaneId),\n\t\t\t)\n\t\t: [];\n\tif (syncRequiredRequirements.length > 0) {\n\t\treturn {\n\t\t\t...baseDecision,\n\t\t\taction: \"continue\",\n\t\t\treasonCode: \"lane_sync_required\",\n\t\t\tmessage: `Requirement(s) ${syncRequiredRequirements.map((requirement) => requirement.id).join(\", \")} are bound to a worktree-sync lane that must rebase current main before further work; deliver worktree_sync action:\"sync\" to the bound worker, or run it directly for an idle lane.`,\n\t\t};\n\t}\n\n\t// A worker is dispatched (queued/running) against an open requirement this goal owns — wait\n\t// for it rather than submit a hollow pass or let the stall counter judge the goal unproductive.\n\t// Checked BEFORE the stall check so an in-flight worker always wins over an accumulated stall\n\t// count: the goal isn't stalled, it's actively being worked by something other than this loop.\n\tconst inFlightGoalLaneIds = args.inFlightGoalLaneIds;\n\tconst boundInFlightRequirements = inFlightGoalLaneIds\n\t\t? state.requirements.filter(\n\t\t\t\t(requirement) =>\n\t\t\t\t\trequirement.status === \"open\" &&\n\t\t\t\t\trequirement.boundLaneId !== undefined &&\n\t\t\t\t\tinFlightGoalLaneIds.has(requirement.boundLaneId),\n\t\t\t)\n\t\t: [];\n\n\tif (boundInFlightRequirements.length > 0) {\n\t\t// Never-hang backstop: a worker alive-but-hung past its deadline must escalate to the owner\n\t\t// instead of waiting forever. Only evaluated when the caller supplies BOTH a clock reading and\n\t\t// a deadline; escalates only once EVERY bound-in-flight requirement has individually timed out,\n\t\t// so one fresh binding keeps the goal legitimately waiting.\n\t\tif (args.now !== undefined && args.maxWorkerWaitMs !== undefined) {\n\t\t\tconst nowMs = Date.parse(args.now);\n\t\t\tconst maxWorkerWaitMs = args.maxWorkerWaitMs;\n\t\t\tconst allTimedOut =\n\t\t\t\tNumber.isFinite(nowMs) &&\n\t\t\t\tboundInFlightRequirements.every((requirement) => {\n\t\t\t\t\tif (requirement.boundAt === undefined) return false;\n\t\t\t\t\tconst boundAtMs = Date.parse(requirement.boundAt);\n\t\t\t\t\treturn Number.isFinite(boundAtMs) && boundAtMs + maxWorkerWaitMs <= nowMs;\n\t\t\t\t});\n\t\t\tif (allTimedOut) {\n\t\t\t\treturn {\n\t\t\t\t\t...baseDecision,\n\t\t\t\t\taction: \"ask-user\",\n\t\t\t\t\treasonCode: \"worker_wait_timeout\",\n\t\t\t\t\tmessage: `A dispatched worker has not completed within the maximum wait of ${maxWorkerWaitMs}ms; escalating to the owner instead of waiting indefinitely.`,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\t...baseDecision,\n\t\t\taction: \"waiting\",\n\t\t\treasonCode: \"worker_in_flight\",\n\t\t\tmessage: \"A worker is dispatched against an open requirement; waiting for it to finish before continuing.\",\n\t\t};\n\t}\n\n\tif (args.settings.maxStallTurns > 0 && state.stallTurns >= args.settings.maxStallTurns) {\n\t\treturn {\n\t\t\t...baseDecision,\n\t\t\taction: \"ask-user\",\n\t\t\treasonCode: \"stall_limit_reached\",\n\t\t\tmessage: `The goal has reached the maximum stall limit of ${args.settings.maxStallTurns} turns.`,\n\t\t};\n\t}\n\n\treturn {\n\t\t...baseDecision,\n\t\taction: \"continue\",\n\t\treasonCode: \"goal_active\",\n\t\tmessage: \"The goal is active and making progress.\",\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"goal-continuation-controller.d.ts","sourceRoot":"","sources":["../../../src/core/goals/goal-continuation-controller.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,MAAM,MAAM,sBAAsB,GAAG,UAAU,GAAG,UAAU,GAAG,UAAU,GAAG,MAAM,GAAG,SAAS,CAAC;AAC/F,MAAM,MAAM,0BAA0B,GACnC,aAAa,GACb,gBAAgB,GAChB,aAAa,GACb,cAAc,GACd,oBAAoB,GACpB,qBAAqB,GACrB,gBAAgB,GAChB,qBAAqB,GACrB,0BAA0B,GAC1B,8BAA8B,GAC9B,8BAA8B,GAC9B,oBAAoB,GACpB,kBAAkB,GAClB,qBAAqB,GACrB,oBAAoB,GACpB,oBAAoB,CAAC;AAExB,MAAM,WAAW,wBAAwB;IACxC,MAAM,EAAE,sBAAsB,CAAC;IAC/B,UAAU,EAAE,0BAA0B,CAAC;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,kBAAkB,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,qBAAqB,EAAE,SAAS,MAAM,EAAE,CAAC;IACzC,uBAAuB,EAAE,SAAS,MAAM,EAAE,CAAC;CAC3C;AAED,MAAM,WAAW,wBAAwB;IACxC,aAAa,EAAE,MAAM,CAAC;CACtB;AAED,wBAAgB,wBAAwB,CAAC,IAAI,EAAE;IAC9C,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,QAAQ,EAAE,wBAAwB,CAAC;IACnC;;;;;;;OAOG;IACH,mBAAmB,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC1C;;;;;OAKG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;;;;;OAOG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;;;;;;;OAUG;IACH,wBAAwB,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC/C;;;;;;;OAOG;IACH,oBAAoB,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CAC3C,GAAG,wBAAwB,CAkO3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"goal-continuation-controller.js","sourceRoot":"","sources":["../../../src/core/goals/goal-continuation-controller.ts"],"names":[],"mappings":"AAA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;IAED,OAAO;QACN,GAAG,YAAY;QACf,MAAM,EAAE,UAAU;QAClB,UAAU,EAAE,aAAa;QACzB,OAAO,EAAE,yCAAyC;KAClD,CAAC;AAAA,CACF","sourcesContent":["import { getUnprovenGoalRequirementIds } from \"./goal-acceptance.ts\";\nimport type { GoalState } from \"./goal-state.ts\";\n\nexport type GoalContinuationAction = \"continue\" | \"ask-user\" | \"finalize\" | \"stop\" | \"waiting\";\nexport type GoalContinuationReasonCode =\n\t| \"goal_active\"\n\t| \"goal_completed\"\n\t| \"goal_paused\"\n\t| \"goal_blocked\"\n\t| \"goal_usage_limited\"\n\t| \"goal_budget_limited\"\n\t| \"goal_cancelled\"\n\t| \"stall_limit_reached\"\n\t| \"goal_completion_required\"\n\t| \"acceptance_evidence_required\"\n\t| \"blocked_requirements_present\"\n\t| \"missing_goal_state\"\n\t| \"worker_in_flight\"\n\t| \"worker_wait_timeout\"\n\t| \"lane_sync_conflict\"\n\t| \"lane_sync_required\";\n\nexport interface GoalContinuationDecision {\n\taction: GoalContinuationAction;\n\treasonCode: GoalContinuationReasonCode;\n\tmessage: string;\n\tgoalId?: string;\n\tstallTurns?: number;\n\tmaxStallTurns?: number;\n\topenRequirementIds: readonly string[];\n\tblockedRequirementIds: readonly string[];\n\tsatisfiedRequirementIds: readonly string[];\n}\n\nexport interface GoalContinuationSettings {\n\tmaxStallTurns: number;\n}\n\nexport function evaluateGoalContinuation(args: {\n\tstate?: GoalState;\n\tsettings: GoalContinuationSettings;\n\t/**\n\t * LaneIds currently queued/running AND tagged with THIS goal's id (see `LaneRecord.goalId`).\n\t * When an open requirement is bound (`Requirement.boundLaneId`) to one of these lanes, the\n\t * goal is WAITING on that worker rather than stalled or ready for another pass: the loop must not\n\t * submit a hollow continuation prompt (which would waste a turn while no parent work can advance),\n\t * and the idle scheduler must not race a re-dispatch against the same open requirement. Optional\n\t * so every pre-existing (in-flight-unaware) caller keeps compiling and behaving unchanged.\n\t */\n\tinFlightGoalLaneIds?: ReadonlySet<string>;\n\t/**\n\t * Current time as an ISO string, paired with `maxWorkerWaitMs` to detect a bound in-flight\n\t * requirement that has hung past its deadline (see below). Optional so every pre-existing\n\t * caller that omits it keeps behaving byte-identically -- the goal waits indefinitely, exactly\n\t * as before this field existed.\n\t */\n\tnow?: string;\n\t/**\n\t * Maximum milliseconds a bound in-flight requirement (`Requirement.boundAt`) may wait before\n\t * this escalates to `action:\"ask-user\"`/`reasonCode:\"worker_wait_timeout\"` instead of\n\t * `\"waiting\"` -- a worker that is alive-but-hung past its deadline must not wait forever. Only\n\t * takes effect when BOTH `now` and this are supplied; escalation fires only once EVERY\n\t * bound-in-flight open requirement has individually passed `boundAt + maxWorkerWaitMs`, so a\n\t * goal with a mix of fresh and stale bindings keeps waiting on the fresh one.\n\t */\n\tmaxWorkerWaitMs?: number;\n\t/**\n\t * Bound lanes (`Requirement.boundLaneId` -- SAME id-space as `inFlightGoalLaneIds`, not the raw\n\t * worktree-sync `laneKey`) whose worktree-sync lane has a rebase stopped on conflicts\n\t * (`LaneFacts.rebaseInProgress`). The caller (`goal-runtime-snapshot.ts`) is responsible for\n\t * translating live per-worktree-lane status into this id-space by matching each status entry's\n\t * own `boundLaneId` against the requirement -- this function stays pure and never resolves a\n\t * worktree laneKey itself, exactly like `inFlightGoalLaneIds` never resolves a tmux job id.\n\t * Checked BEFORE the waiting branch (see `lane_sync_conflict` below): a stalled-but-conflicted\n\t * worker must get the resolve directive, not silently wait forever. Optional so every\n\t * pre-existing caller keeps compiling and behaving byte-identically when omitted or empty.\n\t */\n\tlaneSyncConflictLaneKeys?: ReadonlySet<string>;\n\t/**\n\t * Bound lanes (`Requirement.boundLaneId`, same id-space note as {@link laneSyncConflictLaneKeys})\n\t * whose worktree-sync lane is stale and must sync with current main before further work\n\t * (`sync_required`, i.e. NOT already covered by `laneSyncConflictLaneKeys` -- a lane with a\n\t * rebase in progress is reported as a conflict, never double-counted here). Checked BEFORE the\n\t * waiting branch, same precedence rationale as above. Optional so every pre-existing caller keeps\n\t * compiling and behaving byte-identically when omitted or empty.\n\t */\n\tsyncRequiredLaneKeys?: ReadonlySet<string>;\n}): GoalContinuationDecision {\n\tif (!args.state) {\n\t\treturn {\n\t\t\taction: \"ask-user\",\n\t\t\treasonCode: \"missing_goal_state\",\n\t\t\tmessage: \"No goal state is present.\",\n\t\t\topenRequirementIds: [],\n\t\t\tblockedRequirementIds: [],\n\t\t\tsatisfiedRequirementIds: [],\n\t\t};\n\t}\n\n\tconst state = args.state;\n\tconst openRequirementIds: string[] = [];\n\tconst blockedRequirementIds: string[] = [];\n\tconst satisfiedRequirementIds: string[] = [];\n\n\tfor (const req of state.requirements) {\n\t\tif (req.status === \"open\") openRequirementIds.push(req.id);\n\t\telse if (req.status === \"blocked\") blockedRequirementIds.push(req.id);\n\t\telse if (req.status === \"satisfied\") satisfiedRequirementIds.push(req.id);\n\t}\n\n\tconst baseDecision = {\n\t\tgoalId: state.goalId,\n\t\tstallTurns: state.stallTurns,\n\t\tmaxStallTurns: args.settings.maxStallTurns,\n\t\topenRequirementIds,\n\t\tblockedRequirementIds,\n\t\tsatisfiedRequirementIds,\n\t};\n\n\tif (state.status === \"completed\") {\n\t\treturn {\n\t\t\t...baseDecision,\n\t\t\taction: \"finalize\",\n\t\t\treasonCode: \"goal_completed\",\n\t\t\tmessage: \"The goal is marked as completed.\",\n\t\t};\n\t}\n\n\tif (state.status === \"paused\") {\n\t\treturn {\n\t\t\t...baseDecision,\n\t\t\taction: \"stop\",\n\t\t\treasonCode: \"goal_paused\",\n\t\t\tmessage: \"The goal is paused by the owner.\",\n\t\t};\n\t}\n\n\tif (state.status === \"blocked\") {\n\t\treturn {\n\t\t\t...baseDecision,\n\t\t\taction: \"ask-user\",\n\t\t\treasonCode: \"goal_blocked\",\n\t\t\tmessage: \"The goal is explicitly blocked.\",\n\t\t};\n\t}\n\n\tif (state.status === \"usage_limited\") {\n\t\treturn {\n\t\t\t...baseDecision,\n\t\t\taction: \"ask-user\",\n\t\t\treasonCode: \"goal_usage_limited\",\n\t\t\tmessage: \"The goal stopped after the active provider reached a usage limit.\",\n\t\t};\n\t}\n\n\tif (state.status === \"budget_limited\") {\n\t\treturn {\n\t\t\t...baseDecision,\n\t\t\taction: \"stop\",\n\t\t\treasonCode: \"goal_budget_limited\",\n\t\t\tmessage: \"The goal exhausted its configured budget.\",\n\t\t};\n\t}\n\n\tif (state.status === \"cancelled\") {\n\t\treturn {\n\t\t\t...baseDecision,\n\t\t\taction: \"stop\",\n\t\t\treasonCode: \"goal_cancelled\",\n\t\t\tmessage: \"The goal has been cancelled.\",\n\t\t};\n\t}\n\n\tif (openRequirementIds.length === 0) {\n\t\tif (blockedRequirementIds.length > 0) {\n\t\t\treturn {\n\t\t\t\t...baseDecision,\n\t\t\t\taction: \"ask-user\",\n\t\t\t\treasonCode: \"blocked_requirements_present\",\n\t\t\t\tmessage: \"All remaining legacy goal requirements are blocked.\",\n\t\t\t};\n\t\t}\n\t\tif (state.requirements.length === 0) {\n\t\t\treturn {\n\t\t\t\t...baseDecision,\n\t\t\t\taction: \"continue\",\n\t\t\t\treasonCode: \"goal_active\",\n\t\t\t\tmessage: \"The compact goal record is active.\",\n\t\t\t};\n\t\t}\n\t\tconst unprovenRequirementIds = getUnprovenGoalRequirementIds(state);\n\t\tif (unprovenRequirementIds.length > 0) {\n\t\t\treturn {\n\t\t\t\t...baseDecision,\n\t\t\t\taction: \"continue\",\n\t\t\t\treasonCode: \"acceptance_evidence_required\",\n\t\t\t\tmessage: `Requirement(s) ${unprovenRequirementIds.join(\", \")} still need trusted acceptance evidence.`,\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t...baseDecision,\n\t\t\taction: \"continue\",\n\t\t\treasonCode: \"goal_completion_required\",\n\t\t\tmessage: \"All requirements are proven. Mark the goal complete only after confirming no required work remains.\",\n\t\t};\n\t}\n\n\t// Worktree-sync directives take precedence over the \"waiting\" branch below: a worker whose bound\n\t// lane is conflicted or stale is NOT merely in-flight-and-quiet -- it needs an explicit directive\n\t// (resolve conflicts, or sync) delivered through the continuation prompt, and a stalled-but-stale\n\t// worker must never be left waiting indefinitely for a sync it was never told to run. Conflict is\n\t// checked first: a lane with a rebase already stopped on conflicts cannot usefully be told to\n\t// \"sync\" again (that lane's `sync_required` flag is never set while `rebaseInProgress` is true --\n\t// see `goal-runtime-snapshot.ts` -- so the two sets below are disjoint by construction, not by a\n\t// priority check here).\n\tconst laneSyncConflictLaneKeys = args.laneSyncConflictLaneKeys;\n\tconst conflictedRequirements = laneSyncConflictLaneKeys\n\t\t? state.requirements.filter(\n\t\t\t\t(requirement) =>\n\t\t\t\t\trequirement.status === \"open\" &&\n\t\t\t\t\trequirement.boundLaneId !== undefined &&\n\t\t\t\t\tlaneSyncConflictLaneKeys.has(requirement.boundLaneId),\n\t\t\t)\n\t\t: [];\n\tif (conflictedRequirements.length > 0) {\n\t\treturn {\n\t\t\t...baseDecision,\n\t\t\taction: \"continue\",\n\t\t\treasonCode: \"lane_sync_conflict\",\n\t\t\tmessage: `Requirement(s) ${conflictedRequirements.map((requirement) => requirement.id).join(\", \")} are bound to a worktree-sync lane with a rebase stopped on conflicts; resolve via worktree_sync action:\"continue\" (or \"abort_sync\") before this goal can progress further.`,\n\t\t};\n\t}\n\n\tconst syncRequiredLaneKeys = args.syncRequiredLaneKeys;\n\tconst syncRequiredRequirements = syncRequiredLaneKeys\n\t\t? state.requirements.filter(\n\t\t\t\t(requirement) =>\n\t\t\t\t\trequirement.status === \"open\" &&\n\t\t\t\t\trequirement.boundLaneId !== undefined &&\n\t\t\t\t\tsyncRequiredLaneKeys.has(requirement.boundLaneId),\n\t\t\t)\n\t\t: [];\n\tif (syncRequiredRequirements.length > 0) {\n\t\treturn {\n\t\t\t...baseDecision,\n\t\t\taction: \"continue\",\n\t\t\treasonCode: \"lane_sync_required\",\n\t\t\tmessage: `Requirement(s) ${syncRequiredRequirements.map((requirement) => requirement.id).join(\", \")} are bound to a worktree-sync lane that must rebase current main before further work; deliver worktree_sync action:\"sync\" to the bound worker, or run it directly for an idle lane.`,\n\t\t};\n\t}\n\n\t// A worker is dispatched (queued/running) against an open requirement this goal owns — wait\n\t// for it rather than submit a hollow pass or let the stall counter judge the goal unproductive.\n\t// Checked BEFORE the stall check so an in-flight worker always wins over an accumulated stall\n\t// count: the goal isn't stalled, it's actively being worked by something other than this loop.\n\tconst inFlightGoalLaneIds = args.inFlightGoalLaneIds;\n\tconst boundInFlightRequirements = inFlightGoalLaneIds\n\t\t? state.requirements.filter(\n\t\t\t\t(requirement) =>\n\t\t\t\t\trequirement.status === \"open\" &&\n\t\t\t\t\trequirement.boundLaneId !== undefined &&\n\t\t\t\t\tinFlightGoalLaneIds.has(requirement.boundLaneId),\n\t\t\t)\n\t\t: [];\n\n\tif (boundInFlightRequirements.length > 0) {\n\t\t// Never-hang backstop: a worker alive-but-hung past its deadline must escalate to the owner\n\t\t// instead of waiting forever. Only evaluated when the caller supplies BOTH a clock reading and\n\t\t// a deadline; escalates only once EVERY bound-in-flight requirement has individually timed out,\n\t\t// so one fresh binding keeps the goal legitimately waiting.\n\t\tif (args.now !== undefined && args.maxWorkerWaitMs !== undefined) {\n\t\t\tconst nowMs = Date.parse(args.now);\n\t\t\tconst maxWorkerWaitMs = args.maxWorkerWaitMs;\n\t\t\tconst allTimedOut =\n\t\t\t\tNumber.isFinite(nowMs) &&\n\t\t\t\tboundInFlightRequirements.every((requirement) => {\n\t\t\t\t\tif (requirement.boundAt === undefined) return false;\n\t\t\t\t\tconst boundAtMs = Date.parse(requirement.boundAt);\n\t\t\t\t\treturn Number.isFinite(boundAtMs) && boundAtMs + maxWorkerWaitMs <= nowMs;\n\t\t\t\t});\n\t\t\tif (allTimedOut) {\n\t\t\t\treturn {\n\t\t\t\t\t...baseDecision,\n\t\t\t\t\taction: \"ask-user\",\n\t\t\t\t\treasonCode: \"worker_wait_timeout\",\n\t\t\t\t\tmessage: `A dispatched worker has not completed within the maximum wait of ${maxWorkerWaitMs}ms; escalating to the owner instead of waiting indefinitely.`,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\t...baseDecision,\n\t\t\taction: \"waiting\",\n\t\t\treasonCode: \"worker_in_flight\",\n\t\t\tmessage: \"A worker is dispatched against an open requirement; waiting for it to finish before continuing.\",\n\t\t};\n\t}\n\n\tif (args.settings.maxStallTurns > 0 && state.stallTurns >= args.settings.maxStallTurns) {\n\t\treturn {\n\t\t\t...baseDecision,\n\t\t\taction: \"ask-user\",\n\t\t\treasonCode: \"stall_limit_reached\",\n\t\t\tmessage: `The goal has reached the maximum stall limit of ${args.settings.maxStallTurns} turns.`,\n\t\t};\n\t}\n\n\treturn {\n\t\t...baseDecision,\n\t\taction: \"continue\",\n\t\treasonCode: \"goal_active\",\n\t\tmessage: \"The goal is active and making progress.\",\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"goal-continuation-controller.js","sourceRoot":"","sources":["../../../src/core/goals/goal-continuation-controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,MAAM,sBAAsB,CAAC;AAsCrE,MAAM,UAAU,wBAAwB,CAAC,IAiDxC;IACA,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;QACjB,OAAO;YACN,MAAM,EAAE,UAAU;YAClB,UAAU,EAAE,oBAAoB;YAChC,OAAO,EAAE,2BAA2B;YACpC,kBAAkB,EAAE,EAAE;YACtB,qBAAqB,EAAE,EAAE;YACzB,uBAAuB,EAAE,EAAE;SAC3B,CAAC;IACH,CAAC;IAED,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;IACzB,MAAM,kBAAkB,GAAa,EAAE,CAAC;IACxC,MAAM,qBAAqB,GAAa,EAAE,CAAC;IAC3C,MAAM,uBAAuB,GAAa,EAAE,CAAC;IAE7C,KAAK,MAAM,GAAG,IAAI,KAAK,CAAC,YAAY,EAAE,CAAC;QACtC,IAAI,GAAG,CAAC,MAAM,KAAK,MAAM;YAAE,kBAAkB,CAAC,IAAI,CAA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E,CAAC;gBACjB,OAAO;oBACN,GAAG,YAAY;oBACf,MAAM,EAAE,UAAU;oBAClB,UAAU,EAAE,qBAAqB;oBACjC,OAAO,EAAE,oEAAoE,eAAe,8DAA8D;iBAC1J,CAAC;YACH,CAAC;QACF,CAAC;QAED,OAAO;YACN,GAAG,YAAY;YACf,MAAM,EAAE,SAAS;YACjB,UAAU,EAAE,kBAAkB;YAC9B,OAAO,EAAE,iGAAiG;SAC1G,CAAC;IACH,CAAC;IAED,IAAI,IAAI,CAAC,QAAQ,CAAC,aAAa,GAAG,CAAC,IAAI,KAAK,CAAC,UAAU,IAAI,IAAI,CAAC,QAAQ,CAAC,aAAa,EAAE,CAAC;QACxF,OAAO;YACN,GAAG,YAAY;YACf,MAAM,EAAE,UAAU;YAClB,UAAU,EAAE,qBAAqB;YACjC,OAAO,EAAE,mDAAmD,IAAI,CAAC,QAAQ,CAAC,aAAa,SAAS;SAChG,CAAC;IACH,CAAC;IAED,OAAO;QACN,GAAG,YAAY;QACf,MAAM,EAAE,UAAU;QAClB,UAAU,EAAE,aAAa;QACzB,OAAO,EAAE,yCAAyC;KAClD,CAAC;AACH,CAAC","sourcesContent":["import { getUnprovenGoalRequirementIds } from \"./goal-acceptance.ts\";\nimport type { GoalState } from \"./goal-state.ts\";\n\nexport type GoalContinuationAction = \"continue\" | \"ask-user\" | \"finalize\" | \"stop\" | \"waiting\";\nexport type GoalContinuationReasonCode =\n\t| \"goal_active\"\n\t| \"goal_completed\"\n\t| \"goal_paused\"\n\t| \"goal_blocked\"\n\t| \"goal_usage_limited\"\n\t| \"goal_budget_limited\"\n\t| \"goal_cancelled\"\n\t| \"stall_limit_reached\"\n\t| \"goal_completion_required\"\n\t| \"acceptance_evidence_required\"\n\t| \"blocked_requirements_present\"\n\t| \"missing_goal_state\"\n\t| \"worker_in_flight\"\n\t| \"worker_wait_timeout\"\n\t| \"lane_sync_conflict\"\n\t| \"lane_sync_required\";\n\nexport interface GoalContinuationDecision {\n\taction: GoalContinuationAction;\n\treasonCode: GoalContinuationReasonCode;\n\tmessage: string;\n\tgoalId?: string;\n\tstallTurns?: number;\n\tmaxStallTurns?: number;\n\topenRequirementIds: readonly string[];\n\tblockedRequirementIds: readonly string[];\n\tsatisfiedRequirementIds: readonly string[];\n}\n\nexport interface GoalContinuationSettings {\n\tmaxStallTurns: number;\n}\n\nexport function evaluateGoalContinuation(args: {\n\tstate?: GoalState;\n\tsettings: GoalContinuationSettings;\n\t/**\n\t * LaneIds currently queued/running AND tagged with THIS goal's id (see `LaneRecord.goalId`).\n\t * When an open requirement is bound (`Requirement.boundLaneId`) to one of these lanes, the\n\t * goal is WAITING on that worker rather than stalled or ready for another pass: the loop must not\n\t * submit a hollow continuation prompt (which would waste a turn while no parent work can advance),\n\t * and the idle scheduler must not race a re-dispatch against the same open requirement. Optional\n\t * so every pre-existing (in-flight-unaware) caller keeps compiling and behaving unchanged.\n\t */\n\tinFlightGoalLaneIds?: ReadonlySet<string>;\n\t/**\n\t * Current time as an ISO string, paired with `maxWorkerWaitMs` to detect a bound in-flight\n\t * requirement that has hung past its deadline (see below). Optional so every pre-existing\n\t * caller that omits it keeps behaving byte-identically -- the goal waits indefinitely, exactly\n\t * as before this field existed.\n\t */\n\tnow?: string;\n\t/**\n\t * Maximum milliseconds a bound in-flight requirement (`Requirement.boundAt`) may wait before\n\t * this escalates to `action:\"ask-user\"`/`reasonCode:\"worker_wait_timeout\"` instead of\n\t * `\"waiting\"` -- a worker that is alive-but-hung past its deadline must not wait forever. Only\n\t * takes effect when BOTH `now` and this are supplied; escalation fires only once EVERY\n\t * bound-in-flight open requirement has individually passed `boundAt + maxWorkerWaitMs`, so a\n\t * goal with a mix of fresh and stale bindings keeps waiting on the fresh one.\n\t */\n\tmaxWorkerWaitMs?: number;\n\t/**\n\t * Bound lanes (`Requirement.boundLaneId` -- SAME id-space as `inFlightGoalLaneIds`, not the raw\n\t * worktree-sync `laneKey`) whose worktree-sync lane has a rebase stopped on conflicts\n\t * (`LaneFacts.rebaseInProgress`). The caller (`goal-runtime-snapshot.ts`) is responsible for\n\t * translating live per-worktree-lane status into this id-space by matching each status entry's\n\t * own `boundLaneId` against the requirement -- this function stays pure and never resolves a\n\t * worktree laneKey itself, exactly like `inFlightGoalLaneIds` never resolves a tmux job id.\n\t * Checked BEFORE the waiting branch (see `lane_sync_conflict` below): a stalled-but-conflicted\n\t * worker must get the resolve directive, not silently wait forever. Optional so every\n\t * pre-existing caller keeps compiling and behaving byte-identically when omitted or empty.\n\t */\n\tlaneSyncConflictLaneKeys?: ReadonlySet<string>;\n\t/**\n\t * Bound lanes (`Requirement.boundLaneId`, same id-space note as {@link laneSyncConflictLaneKeys})\n\t * whose worktree-sync lane is stale and must sync with current main before further work\n\t * (`sync_required`, i.e. NOT already covered by `laneSyncConflictLaneKeys` -- a lane with a\n\t * rebase in progress is reported as a conflict, never double-counted here). Checked BEFORE the\n\t * waiting branch, same precedence rationale as above. Optional so every pre-existing caller keeps\n\t * compiling and behaving byte-identically when omitted or empty.\n\t */\n\tsyncRequiredLaneKeys?: ReadonlySet<string>;\n}): GoalContinuationDecision {\n\tif (!args.state) {\n\t\treturn {\n\t\t\taction: \"ask-user\",\n\t\t\treasonCode: \"missing_goal_state\",\n\t\t\tmessage: \"No goal state is present.\",\n\t\t\topenRequirementIds: [],\n\t\t\tblockedRequirementIds: [],\n\t\t\tsatisfiedRequirementIds: [],\n\t\t};\n\t}\n\n\tconst state = args.state;\n\tconst openRequirementIds: string[] = [];\n\tconst blockedRequirementIds: string[] = [];\n\tconst satisfiedRequirementIds: string[] = [];\n\n\tfor (const req of state.requirements) {\n\t\tif (req.status === \"open\") openRequirementIds.push(req.id);\n\t\telse if (req.status === \"blocked\") blockedRequirementIds.push(req.id);\n\t\telse if (req.status === \"satisfied\") satisfiedRequirementIds.push(req.id);\n\t}\n\n\tconst baseDecision = {\n\t\tgoalId: state.goalId,\n\t\tstallTurns: state.stallTurns,\n\t\tmaxStallTurns: args.settings.maxStallTurns,\n\t\topenRequirementIds,\n\t\tblockedRequirementIds,\n\t\tsatisfiedRequirementIds,\n\t};\n\n\tif (state.status === \"completed\") {\n\t\treturn {\n\t\t\t...baseDecision,\n\t\t\taction: \"finalize\",\n\t\t\treasonCode: \"goal_completed\",\n\t\t\tmessage: \"The goal is marked as completed.\",\n\t\t};\n\t}\n\n\tif (state.status === \"paused\") {\n\t\treturn {\n\t\t\t...baseDecision,\n\t\t\taction: \"stop\",\n\t\t\treasonCode: \"goal_paused\",\n\t\t\tmessage: \"The goal is paused by the owner.\",\n\t\t};\n\t}\n\n\tif (state.status === \"blocked\") {\n\t\treturn {\n\t\t\t...baseDecision,\n\t\t\taction: \"ask-user\",\n\t\t\treasonCode: \"goal_blocked\",\n\t\t\tmessage: \"The goal is explicitly blocked.\",\n\t\t};\n\t}\n\n\tif (state.status === \"usage_limited\") {\n\t\treturn {\n\t\t\t...baseDecision,\n\t\t\taction: \"ask-user\",\n\t\t\treasonCode: \"goal_usage_limited\",\n\t\t\tmessage: \"The goal stopped after the active provider reached a usage limit.\",\n\t\t};\n\t}\n\n\tif (state.status === \"budget_limited\") {\n\t\treturn {\n\t\t\t...baseDecision,\n\t\t\taction: \"stop\",\n\t\t\treasonCode: \"goal_budget_limited\",\n\t\t\tmessage: \"The goal exhausted its configured budget.\",\n\t\t};\n\t}\n\n\tif (state.status === \"cancelled\") {\n\t\treturn {\n\t\t\t...baseDecision,\n\t\t\taction: \"stop\",\n\t\t\treasonCode: \"goal_cancelled\",\n\t\t\tmessage: \"The goal has been cancelled.\",\n\t\t};\n\t}\n\n\tif (openRequirementIds.length === 0) {\n\t\tif (blockedRequirementIds.length > 0) {\n\t\t\treturn {\n\t\t\t\t...baseDecision,\n\t\t\t\taction: \"ask-user\",\n\t\t\t\treasonCode: \"blocked_requirements_present\",\n\t\t\t\tmessage: \"All remaining legacy goal requirements are blocked.\",\n\t\t\t};\n\t\t}\n\t\tif (state.requirements.length === 0) {\n\t\t\treturn {\n\t\t\t\t...baseDecision,\n\t\t\t\taction: \"continue\",\n\t\t\t\treasonCode: \"goal_active\",\n\t\t\t\tmessage: \"The compact goal record is active.\",\n\t\t\t};\n\t\t}\n\t\tconst unprovenRequirementIds = getUnprovenGoalRequirementIds(state);\n\t\tif (unprovenRequirementIds.length > 0) {\n\t\t\treturn {\n\t\t\t\t...baseDecision,\n\t\t\t\taction: \"continue\",\n\t\t\t\treasonCode: \"acceptance_evidence_required\",\n\t\t\t\tmessage: `Requirement(s) ${unprovenRequirementIds.join(\", \")} still need trusted acceptance evidence.`,\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t...baseDecision,\n\t\t\taction: \"continue\",\n\t\t\treasonCode: \"goal_completion_required\",\n\t\t\tmessage: \"All requirements are proven. Mark the goal complete only after confirming no required work remains.\",\n\t\t};\n\t}\n\n\t// Worktree-sync directives take precedence over the \"waiting\" branch below: a worker whose bound\n\t// lane is conflicted or stale is NOT merely in-flight-and-quiet -- it needs an explicit directive\n\t// (resolve conflicts, or sync) delivered through the continuation prompt, and a stalled-but-stale\n\t// worker must never be left waiting indefinitely for a sync it was never told to run. Conflict is\n\t// checked first: a lane with a rebase already stopped on conflicts cannot usefully be told to\n\t// \"sync\" again (that lane's `sync_required` flag is never set while `rebaseInProgress` is true --\n\t// see `goal-runtime-snapshot.ts` -- so the two sets below are disjoint by construction, not by a\n\t// priority check here).\n\tconst laneSyncConflictLaneKeys = args.laneSyncConflictLaneKeys;\n\tconst conflictedRequirements = laneSyncConflictLaneKeys\n\t\t? state.requirements.filter(\n\t\t\t\t(requirement) =>\n\t\t\t\t\trequirement.status === \"open\" &&\n\t\t\t\t\trequirement.boundLaneId !== undefined &&\n\t\t\t\t\tlaneSyncConflictLaneKeys.has(requirement.boundLaneId),\n\t\t\t)\n\t\t: [];\n\tif (conflictedRequirements.length > 0) {\n\t\treturn {\n\t\t\t...baseDecision,\n\t\t\taction: \"continue\",\n\t\t\treasonCode: \"lane_sync_conflict\",\n\t\t\tmessage: `Requirement(s) ${conflictedRequirements.map((requirement) => requirement.id).join(\", \")} are bound to a worktree-sync lane with a rebase stopped on conflicts; resolve via worktree_sync action:\"continue\" (or \"abort_sync\") before this goal can progress further.`,\n\t\t};\n\t}\n\n\tconst syncRequiredLaneKeys = args.syncRequiredLaneKeys;\n\tconst syncRequiredRequirements = syncRequiredLaneKeys\n\t\t? state.requirements.filter(\n\t\t\t\t(requirement) =>\n\t\t\t\t\trequirement.status === \"open\" &&\n\t\t\t\t\trequirement.boundLaneId !== undefined &&\n\t\t\t\t\tsyncRequiredLaneKeys.has(requirement.boundLaneId),\n\t\t\t)\n\t\t: [];\n\tif (syncRequiredRequirements.length > 0) {\n\t\treturn {\n\t\t\t...baseDecision,\n\t\t\taction: \"continue\",\n\t\t\treasonCode: \"lane_sync_required\",\n\t\t\tmessage: `Requirement(s) ${syncRequiredRequirements.map((requirement) => requirement.id).join(\", \")} are bound to a worktree-sync lane that must rebase current main before further work; deliver worktree_sync action:\"sync\" to the bound worker, or run it directly for an idle lane.`,\n\t\t};\n\t}\n\n\t// A worker is dispatched (queued/running) against an open requirement this goal owns — wait\n\t// for it rather than submit a hollow pass or let the stall counter judge the goal unproductive.\n\t// Checked BEFORE the stall check so an in-flight worker always wins over an accumulated stall\n\t// count: the goal isn't stalled, it's actively being worked by something other than this loop.\n\tconst inFlightGoalLaneIds = args.inFlightGoalLaneIds;\n\tconst boundInFlightRequirements = inFlightGoalLaneIds\n\t\t? state.requirements.filter(\n\t\t\t\t(requirement) =>\n\t\t\t\t\trequirement.status === \"open\" &&\n\t\t\t\t\trequirement.boundLaneId !== undefined &&\n\t\t\t\t\tinFlightGoalLaneIds.has(requirement.boundLaneId),\n\t\t\t)\n\t\t: [];\n\n\tif (boundInFlightRequirements.length > 0) {\n\t\t// Never-hang backstop: a worker alive-but-hung past its deadline must escalate to the owner\n\t\t// instead of waiting forever. Only evaluated when the caller supplies BOTH a clock reading and\n\t\t// a deadline; escalates only once EVERY bound-in-flight requirement has individually timed out,\n\t\t// so one fresh binding keeps the goal legitimately waiting.\n\t\tif (args.now !== undefined && args.maxWorkerWaitMs !== undefined) {\n\t\t\tconst nowMs = Date.parse(args.now);\n\t\t\tconst maxWorkerWaitMs = args.maxWorkerWaitMs;\n\t\t\tconst allTimedOut =\n\t\t\t\tNumber.isFinite(nowMs) &&\n\t\t\t\tboundInFlightRequirements.every((requirement) => {\n\t\t\t\t\tif (requirement.boundAt === undefined) return false;\n\t\t\t\t\tconst boundAtMs = Date.parse(requirement.boundAt);\n\t\t\t\t\treturn Number.isFinite(boundAtMs) && boundAtMs + maxWorkerWaitMs <= nowMs;\n\t\t\t\t});\n\t\t\tif (allTimedOut) {\n\t\t\t\treturn {\n\t\t\t\t\t...baseDecision,\n\t\t\t\t\taction: \"ask-user\",\n\t\t\t\t\treasonCode: \"worker_wait_timeout\",\n\t\t\t\t\tmessage: `A dispatched worker has not completed within the maximum wait of ${maxWorkerWaitMs}ms; escalating to the owner instead of waiting indefinitely.`,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\t...baseDecision,\n\t\t\taction: \"waiting\",\n\t\t\treasonCode: \"worker_in_flight\",\n\t\t\tmessage: \"A worker is dispatched against an open requirement; waiting for it to finish before continuing.\",\n\t\t};\n\t}\n\n\tif (args.settings.maxStallTurns > 0 && state.stallTurns >= args.settings.maxStallTurns) {\n\t\treturn {\n\t\t\t...baseDecision,\n\t\t\taction: \"ask-user\",\n\t\t\treasonCode: \"stall_limit_reached\",\n\t\t\tmessage: `The goal has reached the maximum stall limit of ${args.settings.maxStallTurns} turns.`,\n\t\t};\n\t}\n\n\treturn {\n\t\t...baseDecision,\n\t\taction: \"continue\",\n\t\treasonCode: \"goal_active\",\n\t\tmessage: \"The goal is active and making progress.\",\n\t};\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"goal-continuation-defaults.d.ts","sourceRoot":"","sources":["../../../src/core/goals/goal-continuation-defaults.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAChG,eAAO,MAAM,+BAA+B,IAAI,CAAC;AACjD,eAAO,MAAM,qCAAqC,KAAK,CAAC;AACxD,eAAO,MAAM,4CAA4C,IAAI,CAAC;AAC9D,eAAO,MAAM,0BAA0B,OAAO,CAAC;AAC/C,eAAO,MAAM,mCAAmC,IAAI,CAAC;AAErD,qGAAqG;AACrG,eAAO,MAAM,2BAA2B,QAA0B,CAAC;AACnE,eAAO,MAAM,iCAAiC,MAAM,CAAC;AACrD,eAAO,MAAM,wCAAwC,QAAU,CAAC;AAChE,eAAO,MAAM,+BAA+B,QAAS,CAAC;AAEtD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,2BAA2B,UAAY,CAAC"
|
|
1
|
+
{"version":3,"file":"goal-continuation-defaults.d.ts","sourceRoot":"","sources":["../../../src/core/goals/goal-continuation-defaults.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAChG,eAAO,MAAM,+BAA+B,IAAI,CAAC;AACjD,eAAO,MAAM,qCAAqC,KAAK,CAAC;AACxD,eAAO,MAAM,4CAA4C,IAAI,CAAC;AAC9D,eAAO,MAAM,0BAA0B,OAAO,CAAC;AAC/C,eAAO,MAAM,mCAAmC,IAAI,CAAC;AAErD,qGAAqG;AACrG,eAAO,MAAM,2BAA2B,QAA0B,CAAC;AACnE,eAAO,MAAM,iCAAiC,MAAM,CAAC;AACrD,eAAO,MAAM,wCAAwC,QAAU,CAAC;AAChE,eAAO,MAAM,+BAA+B,QAAS,CAAC;AAEtD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,2BAA2B,UAAY,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"goal-continuation-prompt.d.ts","sourceRoot":"","sources":["../../../src/core/goals/goal-continuation-prompt.ts"],"names":[],"mappings":"AAAA,oGAAoG;AACpG,eAAO,MAAM,qCAAqC,8BAA8B,CAAC;AAEjF,MAAM,WAAW,sBAAsB;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,KAAK,CAAC;CACjB;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,IAAI,sBAAsB,CAKpE"
|
|
1
|
+
{"version":3,"file":"goal-continuation-prompt.d.ts","sourceRoot":"","sources":["../../../src/core/goals/goal-continuation-prompt.ts"],"names":[],"mappings":"AAAA,oGAAoG;AACpG,eAAO,MAAM,qCAAqC,8BAA8B,CAAC;AAEjF,MAAM,WAAW,sBAAsB;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,KAAK,CAAC;CACjB;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,IAAI,sBAAsB,CAKpE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"goal-continuation-prompt.js","sourceRoot":"","sources":["../../../src/core/goals/goal-continuation-prompt.ts"],"names":[],"mappings":"AAAA,oGAAoG;AACpG,MAAM,CAAC,MAAM,qCAAqC,GAAG,2BAA2B,CAAC;AAOjF;;;GAGG;AACH,MAAM,UAAU,2BAA2B
|
|
1
|
+
{"version":3,"file":"goal-continuation-prompt.js","sourceRoot":"","sources":["../../../src/core/goals/goal-continuation-prompt.ts"],"names":[],"mappings":"AAAA,oGAAoG;AACpG,MAAM,CAAC,MAAM,qCAAqC,GAAG,2BAA2B,CAAC;AAOjF;;;GAGG;AACH,MAAM,UAAU,2BAA2B;IAC1C,OAAO;QACN,IAAI,EAAE,0CAA0C;QAChD,SAAS,EAAE,KAAK;KAChB,CAAC;AACH,CAAC","sourcesContent":["/** Hidden turn trigger. The current goal record is injected ephemerally during context assembly. */\nexport const GOAL_CONTINUATION_TRIGGER_CUSTOM_TYPE = \"goal_continuation_trigger\";\n\nexport interface GoalContinuationPrompt {\n\ttext: string;\n\ttruncated: false;\n}\n\n/**\n * Keep the persisted trigger constant and tiny. Dynamic objective and usage fields belong to the\n * ephemeral compact projection, never to the append-only transcript.\n */\nexport function buildGoalContinuationPrompt(): GoalContinuationPrompt {\n\treturn {\n\t\ttext: \"Continue working toward the active goal.\",\n\t\ttruncated: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BAAkB,CACjC,IAA4B,EAC5B,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EACH;IAC3B,MAAM,OAAO,GAAG,IAAI,CAAC,oBAAoB,EAAE,CAAC;IAC5C,IAAI,CAAC,OAAO;QAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAClD,IAAI,CAAC,IAAI,CAAC,sBAAsB;QAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,+CAA+C,EAAE,CAAC;IAC/G,IAAI,CAAC,sBAAsB,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IAC1C,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAAA,CACnC","sourcesContent":["import {\n\tapplyGoalEvent,\n\ttype GoalState,\n\tisGoalResumableStatus,\n\tisGoalUnfinishedStatus,\n\tMAX_GOAL_OBJECTIVE_LENGTH,\n} from \"./goal-state.ts\";\nimport { applyGoalAction, type GoalActionFailure, type GoalActionResult } from \"./goal-tool-core.ts\";\n\nexport interface GoalStateRevision {\n\tgoalId: string;\n\trevision: number;\n}\n\nexport function getGoalStateRevision(state: GoalState): GoalStateRevision {\n\treturn { goalId: state.goalId, revision: state.revision ?? 0 };\n}\n\n/** Minimal durable seam shared by CLI, tools, and in-process session restoration. */\nexport interface PersistedGoalStateHost {\n\tgetGoalStateSnapshot(): GoalState | undefined;\n\tsaveGoalStateSnapshot(state: GoalState, expected?: GoalStateRevision): string;\n\tclearGoalStateSnapshot?(state: GoalState, now: string): string;\n}\n\nfunction missingGoal(action: string): GoalActionFailure {\n\treturn { ok: false, error: `No goal exists to ${action}.` };\n}\n\nfunction persistResult(\n\thost: PersistedGoalStateHost,\n\tcurrent: GoalState | undefined,\n\tresult: GoalActionResult,\n): GoalActionResult {\n\tif (!result.ok) return result;\n\thost.saveGoalStateSnapshot(result.state, current ? getGoalStateRevision(current) : undefined);\n\treturn result;\n}\n\nexport function pauseGoal(current: GoalState | undefined, now: string): GoalActionResult {\n\tif (!current) return missingGoal(\"pause\");\n\tif (current.status !== \"active\") {\n\t\treturn { ok: false, error: `Goal '${current.goalId}' is ${current.status}; only active goals can be paused.` };\n\t}\n\treturn { ok: true, state: applyGoalEvent(current, { type: \"pause_goal\", now }) };\n}\n\nexport function resumeGoal(current: GoalState | undefined, now: string): GoalActionResult {\n\tif (!current) return missingGoal(\"resume\");\n\tif (!isGoalResumableStatus(current.status)) {\n\t\treturn {\n\t\t\tok: false,\n\t\t\terror: `Goal '${current.goalId}' is ${current.status}; only paused, blocked, or usage-limited goals can be resumed.`,\n\t\t};\n\t}\n\treturn { ok: true, state: applyGoalEvent(current, { type: \"resume_goal\", now }) };\n}\n\nexport function editGoal(\n\tcurrent: GoalState | undefined,\n\targs: { userGoal: string; tokenBudget?: number },\n\tnow: string,\n): GoalActionResult {\n\tif (!current) return missingGoal(\"edit\");\n\tif (current.status === \"cancelled\") {\n\t\treturn { ok: false, error: `Goal '${current.goalId}' is cancelled; start a new goal instead.` };\n\t}\n\tconst userGoal = args.userGoal.trim();\n\tif (!userGoal) return { ok: false, error: \"Goal objective must not be empty.\" };\n\tif (userGoal.length > MAX_GOAL_OBJECTIVE_LENGTH) {\n\t\treturn { ok: false, error: `Goal objective must be at most ${MAX_GOAL_OBJECTIVE_LENGTH} characters.` };\n\t}\n\tif (args.tokenBudget !== undefined && (!Number.isSafeInteger(args.tokenBudget) || args.tokenBudget <= 0)) {\n\t\treturn { ok: false, error: \"Goal token budget must be a positive integer when provided.\" };\n\t}\n\treturn {\n\t\tok: true,\n\t\tstate: applyGoalEvent(current, { type: \"edit_goal\", userGoal, tokenBudget: args.tokenBudget, now }),\n\t};\n}\n\nexport function cancelGoal(current: GoalState | undefined, now: string): GoalActionResult {\n\tif (!current) return missingGoal(\"cancel\");\n\tif (!isGoalUnfinishedStatus(current.status)) {\n\t\treturn { ok: false, error: `Goal '${current.goalId}' is already ${current.status}.` };\n\t}\n\treturn { ok: true, state: applyGoalEvent(current, { type: \"cancel_goal\", now }) };\n}\n\n/** Explicit owner replacement. The old and new states cross one persistence boundary. */\nexport function replaceGoal(\n\targs: { goalId: string; userGoal: string; tokenBudget?: number },\n\tnow: string,\n): GoalActionResult {\n\treturn applyGoalAction(undefined, { action: \"start\", ...args }, now);\n}\n\nexport function stopGoalFromSystem(\n\tcurrent: GoalState | undefined,\n\targs: { status: \"blocked\" | \"usage_limited\" | \"budget_limited\"; reason: string },\n\tnow: string,\n): GoalActionResult {\n\tif (!current) return missingGoal(\"stop\");\n\tif (current.status !== \"active\") {\n\t\treturn { ok: false, error: `Goal '${current.goalId}' is ${current.status}; no system stop is needed.` };\n\t}\n\tconst reason = args.reason.trim();\n\tif (!reason) return { ok: false, error: \"System goal stop requires a reason.\" };\n\treturn { ok: true, state: applyGoalEvent(current, { type: \"system_stop_goal\", ...args, reason, now }) };\n}\n\nexport function pausePersistedGoal(host: PersistedGoalStateHost, now = new Date().toISOString()): GoalActionResult {\n\tconst current = host.getGoalStateSnapshot();\n\treturn persistResult(host, current, pauseGoal(current, now));\n}\n\nexport function resumePersistedGoal(host: PersistedGoalStateHost, now = new Date().toISOString()): GoalActionResult {\n\tconst current = host.getGoalStateSnapshot();\n\treturn persistResult(host, current, resumeGoal(current, now));\n}\n\nexport function editPersistedGoal(\n\thost: PersistedGoalStateHost,\n\targs: { userGoal: string; tokenBudget?: number },\n\tnow = new Date().toISOString(),\n): GoalActionResult {\n\tconst current = host.getGoalStateSnapshot();\n\treturn persistResult(host, current, editGoal(current, args, now));\n}\n\nexport function cancelPersistedGoal(host: PersistedGoalStateHost, now = new Date().toISOString()): GoalActionResult {\n\tconst current = host.getGoalStateSnapshot();\n\treturn persistResult(host, current, cancelGoal(current, now));\n}\n\nexport type ClearPersistedGoalResult = { ok: true; cleared: boolean } | GoalActionFailure;\n\nexport function clearPersistedGoal(\n\thost: PersistedGoalStateHost,\n\tnow = new Date().toISOString(),\n): ClearPersistedGoalResult {\n\tconst current = host.getGoalStateSnapshot();\n\tif (!current) return { ok: true, cleared: false };\n\tif (!host.clearGoalStateSnapshot) return { ok: false, error: \"This session does not support clearing goals.\" };\n\thost.clearGoalStateSnapshot(current, now);\n\treturn { ok: true, cleared: true };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"goal-lifecycle.js","sourceRoot":"","sources":["../../../src/core/goals/goal-lifecycle.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,cAAc,EAEd,qBAAqB,EACrB,sBAAsB,EACtB,yBAAyB,GACzB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,eAAe,EAAiD,MAAM,qBAAqB,CAAC;AAOrG,MAAM,UAAU,oBAAoB,CAAC,KAAgB;IACpD,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,IAAI,CAAC,EAAE,CAAC;AAChE,CAAC;AASD,SAAS,WAAW,CAAC,MAAc;IAClC,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,qBAAqB,MAAM,GAAG,EAAE,CAAC;AAC7D,CAAC;AAED,SAAS,aAAa,CACrB,IAA4B,EAC5B,OAA8B,EAC9B,MAAwB;IAExB,IAAI,CAAC,MAAM,CAAC,EAAE;QAAE,OAAO,MAAM,CAAC;IAC9B,IAAI,CAAC,qBAAqB,CAAC,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IAC9F,OAAO,MAAM,CAAC;AACf,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,OAA8B,EAAE,GAAW;IACpE,IAAI,CAAC,OAAO;QAAE,OAAO,WAAW,CAAC,OAAO,CAAC,CAAC;IAC1C,IAAI,OAAO,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;QACjC,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK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AAI,EAAE,CAAC,WAAW,EAAE;IAE9B,MAAM,OAAO,GAAG,IAAI,CAAC,oBAAoB,EAAE,CAAC;IAC5C,OAAO,aAAa,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC,OAAO,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;AACnE,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,IAA4B,EAAE,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;IAC/F,MAAM,OAAO,GAAG,IAAI,CAAC,oBAAoB,EAAE,CAAC;IAC5C,OAAO,aAAa,CAAC,IAAI,EAAE,OAAO,EAAE,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC;AAC/D,CAAC;AAID,MAAM,UAAU,kBAAkB,CACjC,IAA4B,EAC5B,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;IAE9B,MAAM,OAAO,GAAG,IAAI,CAAC,oBAAoB,EAAE,CAAC;IAC5C,IAAI,CAAC,OAAO;QAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAClD,IAAI,CAAC,IAAI,CAAC,sBAAsB;QAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,+CAA+C,EAAE,CAAC;IAC/G,IAAI,CAAC,sBAAsB,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IAC1C,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AACpC,CAAC","sourcesContent":["import {\n\tapplyGoalEvent,\n\ttype GoalState,\n\tisGoalResumableStatus,\n\tisGoalUnfinishedStatus,\n\tMAX_GOAL_OBJECTIVE_LENGTH,\n} from \"./goal-state.ts\";\nimport { applyGoalAction, type GoalActionFailure, type GoalActionResult } from \"./goal-tool-core.ts\";\n\nexport interface GoalStateRevision {\n\tgoalId: string;\n\trevision: number;\n}\n\nexport function getGoalStateRevision(state: GoalState): GoalStateRevision {\n\treturn { goalId: state.goalId, revision: state.revision ?? 0 };\n}\n\n/** Minimal durable seam shared by CLI, tools, and in-process session restoration. */\nexport interface PersistedGoalStateHost {\n\tgetGoalStateSnapshot(): GoalState | undefined;\n\tsaveGoalStateSnapshot(state: GoalState, expected?: GoalStateRevision): string;\n\tclearGoalStateSnapshot?(state: GoalState, now: string): string;\n}\n\nfunction missingGoal(action: string): GoalActionFailure {\n\treturn { ok: false, error: `No goal exists to ${action}.` };\n}\n\nfunction persistResult(\n\thost: PersistedGoalStateHost,\n\tcurrent: GoalState | undefined,\n\tresult: GoalActionResult,\n): GoalActionResult {\n\tif (!result.ok) return result;\n\thost.saveGoalStateSnapshot(result.state, current ? getGoalStateRevision(current) : undefined);\n\treturn result;\n}\n\nexport function pauseGoal(current: GoalState | undefined, now: string): GoalActionResult {\n\tif (!current) return missingGoal(\"pause\");\n\tif (current.status !== \"active\") {\n\t\treturn { ok: false, error: `Goal '${current.goalId}' is ${current.status}; only active goals can be paused.` };\n\t}\n\treturn { ok: true, state: applyGoalEvent(current, { type: \"pause_goal\", now }) };\n}\n\nexport function resumeGoal(current: GoalState | undefined, now: string): GoalActionResult {\n\tif (!current) return missingGoal(\"resume\");\n\tif (!isGoalResumableStatus(current.status)) {\n\t\treturn {\n\t\t\tok: false,\n\t\t\terror: `Goal '${current.goalId}' is ${current.status}; only paused, blocked, or usage-limited goals can be resumed.`,\n\t\t};\n\t}\n\treturn { ok: true, state: applyGoalEvent(current, { type: \"resume_goal\", now }) };\n}\n\nexport function editGoal(\n\tcurrent: GoalState | undefined,\n\targs: { userGoal: string; tokenBudget?: number },\n\tnow: string,\n): GoalActionResult {\n\tif (!current) return missingGoal(\"edit\");\n\tif (current.status === \"cancelled\") {\n\t\treturn { ok: false, error: `Goal '${current.goalId}' is cancelled; start a new goal instead.` };\n\t}\n\tconst userGoal = args.userGoal.trim();\n\tif (!userGoal) return { ok: false, error: \"Goal objective must not be empty.\" };\n\tif (userGoal.length > MAX_GOAL_OBJECTIVE_LENGTH) {\n\t\treturn { ok: false, error: `Goal objective must be at most ${MAX_GOAL_OBJECTIVE_LENGTH} characters.` };\n\t}\n\tif (args.tokenBudget !== undefined && (!Number.isSafeInteger(args.tokenBudget) || args.tokenBudget <= 0)) {\n\t\treturn { ok: false, error: \"Goal token budget must be a positive integer when provided.\" };\n\t}\n\treturn {\n\t\tok: true,\n\t\tstate: applyGoalEvent(current, { type: \"edit_goal\", userGoal, tokenBudget: args.tokenBudget, now }),\n\t};\n}\n\nexport function cancelGoal(current: GoalState | undefined, now: string): GoalActionResult {\n\tif (!current) return missingGoal(\"cancel\");\n\tif (!isGoalUnfinishedStatus(current.status)) {\n\t\treturn { ok: false, error: `Goal '${current.goalId}' is already ${current.status}.` };\n\t}\n\treturn { ok: true, state: applyGoalEvent(current, { type: \"cancel_goal\", now }) };\n}\n\n/** Explicit owner replacement. The old and new states cross one persistence boundary. */\nexport function replaceGoal(\n\targs: { goalId: string; userGoal: string; tokenBudget?: number },\n\tnow: string,\n): GoalActionResult {\n\treturn applyGoalAction(undefined, { action: \"start\", ...args }, now);\n}\n\nexport function stopGoalFromSystem(\n\tcurrent: GoalState | undefined,\n\targs: { status: \"blocked\" | \"usage_limited\" | \"budget_limited\"; reason: string },\n\tnow: string,\n): GoalActionResult {\n\tif (!current) return missingGoal(\"stop\");\n\tif (current.status !== \"active\") {\n\t\treturn { ok: false, error: `Goal '${current.goalId}' is ${current.status}; no system stop is needed.` };\n\t}\n\tconst reason = args.reason.trim();\n\tif (!reason) return { ok: false, error: \"System goal stop requires a reason.\" };\n\treturn { ok: true, state: applyGoalEvent(current, { type: \"system_stop_goal\", ...args, reason, now }) };\n}\n\nexport function pausePersistedGoal(host: PersistedGoalStateHost, now = new Date().toISOString()): GoalActionResult {\n\tconst current = host.getGoalStateSnapshot();\n\treturn persistResult(host, current, pauseGoal(current, now));\n}\n\nexport function resumePersistedGoal(host: PersistedGoalStateHost, now = new Date().toISOString()): GoalActionResult {\n\tconst current = host.getGoalStateSnapshot();\n\treturn persistResult(host, current, resumeGoal(current, now));\n}\n\nexport function editPersistedGoal(\n\thost: PersistedGoalStateHost,\n\targs: { userGoal: string; tokenBudget?: number },\n\tnow = new Date().toISOString(),\n): GoalActionResult {\n\tconst current = host.getGoalStateSnapshot();\n\treturn persistResult(host, current, editGoal(current, args, now));\n}\n\nexport function cancelPersistedGoal(host: PersistedGoalStateHost, now = new Date().toISOString()): GoalActionResult {\n\tconst current = host.getGoalStateSnapshot();\n\treturn persistResult(host, current, cancelGoal(current, now));\n}\n\nexport type ClearPersistedGoalResult = { ok: true; cleared: boolean } | GoalActionFailure;\n\nexport function clearPersistedGoal(\n\thost: PersistedGoalStateHost,\n\tnow = new Date().toISOString(),\n): ClearPersistedGoalResult {\n\tconst current = host.getGoalStateSnapshot();\n\tif (!current) return { ok: true, cleared: false };\n\tif (!host.clearGoalStateSnapshot) return { ok: false, error: \"This session does not support clearing goals.\" };\n\thost.clearGoalStateSnapshot(current, now);\n\treturn { ok: true, cleared: true };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"goal-record.d.ts","sourceRoot":"","sources":["../../../src/core/goals/goal-record.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7D,mGAAmG;AACnG,MAAM,WAAW,UAAU;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,UAAU,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CAClB;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,SAAS,GAAG,UAAU,CAkB9D;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAW3D"
|
|
1
|
+
{"version":3,"file":"goal-record.d.ts","sourceRoot":"","sources":["../../../src/core/goals/goal-record.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7D,mGAAmG;AACnG,MAAM,WAAW,UAAU;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,UAAU,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CAClB;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,SAAS,GAAG,UAAU,CAkB9D;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAW3D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"goal-record.js","sourceRoot":"","sources":["../../../src/core/goals/goal-record.ts"],"names":[],"mappings":"AAgBA,MAAM,UAAU,iBAAiB,CAAC,KAAgB
|
|
1
|
+
{"version":3,"file":"goal-record.js","sourceRoot":"","sources":["../../../src/core/goals/goal-record.ts"],"names":[],"mappings":"AAgBA,MAAM,UAAU,iBAAiB,CAAC,KAAgB;IACjD,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,IAAI,CAAC,CAAC,CAAC;IACtD,OAAO;QACN,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,SAAS,EAAE,KAAK,CAAC,QAAQ;QACzB,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,GAAG,CAAC,KAAK,CAAC,WAAW,KAAK,SAAS;YAClC,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC;gBACA,WAAW,EAAE,KAAK,CAAC,WAAW;gBAC9B,eAAe,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,WAAW,GAAG,UAAU,CAAC;aAC5D,CAAC;QACJ,UAAU;QACV,eAAe,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,uBAAuB,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;QACpF,aAAa,EAAE,KAAK,CAAC,aAAa;QAClC,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,SAAS,EAAE,KAAK,CAAC,SAAS;KAC1B,CAAC;AACH,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,MAAkB;IAClD,MAAM,MAAM,GACX,MAAM,CAAC,WAAW,KAAK,SAAS;QAC/B,CAAC,CAAC,GAAG,MAAM,CAAC,UAAU,qBAAqB;QAC3C,CAAC,CAAC,GAAG,MAAM,CAAC,UAAU,IAAI,MAAM,CAAC,WAAW,YAAY,MAAM,CAAC,eAAe,IAAI,CAAC,YAAY,CAAC;IAClG,OAAO;QACN,SAAS,MAAM,CAAC,MAAM,MAAM,MAAM,CAAC,MAAM,GAAG;QAC5C,cAAc,MAAM,CAAC,SAAS,EAAE;QAChC,UAAU,MAAM,KAAK,MAAM,CAAC,eAAe,gBAAgB;QAC3D,GAAG,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,WAAW,MAAM,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;KACpE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACd,CAAC","sourcesContent":["import type { GoalState, GoalStatus } from \"./goal-state.ts\";\n\n/** Compact model/user projection. Detailed planning and evidence remain in their owning stores. */\nexport interface GoalRecord {\n\tgoalId: string;\n\tobjective: string;\n\tstatus: GoalStatus;\n\ttokenBudget?: number;\n\ttokensUsed: number;\n\ttokensRemaining?: number;\n\ttimeUsedSeconds: number;\n\tblockedReason?: string;\n\tcreatedAt: string;\n\tupdatedAt: string;\n}\n\nexport function projectGoalRecord(state: GoalState): GoalRecord {\n\tconst tokensUsed = Math.max(0, state.tokensUsed ?? 0);\n\treturn {\n\t\tgoalId: state.goalId,\n\t\tobjective: state.userGoal,\n\t\tstatus: state.status,\n\t\t...(state.tokenBudget === undefined\n\t\t\t? {}\n\t\t\t: {\n\t\t\t\t\ttokenBudget: state.tokenBudget,\n\t\t\t\t\ttokensRemaining: Math.max(0, state.tokenBudget - tokensUsed),\n\t\t\t\t}),\n\t\ttokensUsed,\n\t\ttimeUsedSeconds: Math.max(0, Math.ceil((state.continuationWallClockMs ?? 0) / 1000)),\n\t\tblockedReason: state.blockedReason,\n\t\tcreatedAt: state.createdAt,\n\t\tupdatedAt: state.updatedAt,\n\t};\n}\n\nexport function formatGoalRecord(record: GoalRecord): string {\n\tconst budget =\n\t\trecord.tokenBudget === undefined\n\t\t\t? `${record.tokensUsed} tokens (unbounded)`\n\t\t\t: `${record.tokensUsed}/${record.tokenBudget} tokens; ${record.tokensRemaining ?? 0} remaining`;\n\treturn [\n\t\t`Goal '${record.goalId}' (${record.status})`,\n\t\t`Objective: ${record.objective}`,\n\t\t`Usage: ${budget}; ${record.timeUsedSeconds}s active time.`,\n\t\t...(record.blockedReason ? [`Reason: ${record.blockedReason}`] : []),\n\t].join(\"\\n\");\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"goal-runtime-snapshot.d.ts","sourceRoot":"","sources":["../../../src/core/goals/goal-runtime-snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,WAAW,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,CAAC,EAAE,SAAS,uBAAuB,EAAE,CAAC;IACnD,4FAA4F;IAC5F,SAAS,CAAC,EAAE,0BAA0B,CAAC;IACvC;;;;;;OAMG;IACH,yBAAyB,CAAC,EAAE,SAAS,mCAAmC,EAAE,CAAC;CAC3E;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE;IAC9C,cAAc,EAAE,IAAI,CAAC,cAAc,EAAE,8BAA8B,GAAG,WAAW,CAAC,CAAC;IACnF,QAAQ,EAAE,2BAA2B,CAAC;IACtC;;;;;;;;OAQG;IACH,WAAW,CAAC,EAAE,SAAS,UAAU,EAAE,CAAC;IACpC;;;;;OAKG;IACH,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IACnB;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;;;;;;OASG;IACH,kBAAkB,CAAC,EAAE,SAAS,6BAA6B,EAAE,CAAC;IAC9D,iGAAiG;IACjG,WAAW,CAAC,EAAE,qBAAqB,CAAC;CACpC,GAAG,mBAAmB,CA4FtB","sourcesContent":["import type { SessionManager } from \"@caupulican/pi-agent-core/node\";\nimport type { EvidenceBundle, LearningDecision, WorkerClaim } from \"../autonomy/contracts.ts\";\nimport type { LaneRecord } from \"../autonomy/lane-tracker.ts\";\nimport { getWorkerClaimSnapshots } from \"../delegation/session-worker-claim.ts\";\nimport { getLearningDecisionSnapshots } from \"../learning/session-learning-decision.ts\";\nimport type { TaskRuntimeProjection } from \"../orchestration/task-runtime.ts\";\nimport { projectSessionWorkState, type SessionWorkStateProjection } from \"../orchestration/work-state-projection.ts\";\nimport { getLatestEvidenceBundleSnapshot } from \"../research/session-evidence-bundle.ts\";\nimport { getActiveSessionBranchEntries } from \"../session-snapshot.ts\";\nimport { getLatestTaskStepsStateSnapshot } from \"../tasks/session-task-state.ts\";\nimport type { OpenTaskStepProjection } from \"../tasks/task-projection.ts\";\nimport { evaluateGoalContinuation, type GoalContinuationDecision } from \"./goal-continuation-controller.ts\";\nimport { DEFAULT_GOAL_WORKER_WAIT_MS } from \"./goal-continuation-defaults.ts\";\nimport type { GoalState } from \"./goal-state.ts\";\nimport { getLatestGoalStateSnapshot } from \"./session-goal-state.ts\";\n\nexport interface GoalRuntimeSnapshotSettings {\n\tmaxStallTurns: number;\n}\n\n/**\n * A read-only projection of one OPEN (non-terminal) task_steps step, included in the goal\n * runtime snapshot purely for cross-visibility. This is NOT a shared state machine: the goal\n * loop never writes back to task state through this snapshot, and the task store stays the\n * single source of truth for its own steps.\n */\nexport type GoalRuntimeOpenTaskStep = OpenTaskStepProjection;\n\n/**\n * Live, per-worktree-sync-lane status for one lane bound to a dispatched worker, as the caller\n * (runtime-builder / whatever host process has live git-engine access) derives it. `boundLaneId` is\n * the host `LaneRecord.laneId` the lane's registration was correlated to\n * (`LaneRegistration.boundLaneId`, same id-space as `Requirement.boundLaneId`) -- `undefined` for a\n * lane never bound to a dispatch. `fresh`/`stale` mirror `LaneFacts`; `syncRequired` is the\n * staleness-propagation verdict (`WorktreeSyncPolicy`-derived); `rebaseInProgress` marks a sync that\n * stopped on conflicts (a rebase left in progress) -- see `core/worktree-sync/git-engine.ts`.\n */\nexport interface GoalRuntimeWorktreeLaneStatus {\n\tlaneKey: string;\n\tboundLaneId?: string;\n\tfresh: boolean;\n\tstale: boolean;\n\tsyncRequired: boolean;\n\trebaseInProgress: boolean;\n}\n\n/**\n * Per-requirement projection of {@link GoalRuntimeWorktreeLaneStatus}, joined via\n * `requirement.boundLaneId === status.boundLaneId` -- read-only cross-visibility for snapshot\n * consumers (e.g. a future continuation-prompt render), mirroring `openTaskSteps`'s role. This is\n * NOT what feeds `evaluateGoalContinuation` (that reads the raw `boundLaneId`-keyed sets directly);\n * it exists purely so a requirement's worktree state is visible without re-deriving the join.\n */\nexport interface GoalRuntimeRequirementWorktreeState {\n\trequirementId: string;\n\tlaneKey: string;\n\tfresh: boolean;\n\tstale: boolean;\n\tsyncRequired: boolean;\n\trebaseInProgress: boolean;\n}\n\nexport interface GoalRuntimeSnapshot {\n\tgoalState?: GoalState;\n\tlatestEvidenceBundle?: EvidenceBundle;\n\tworkerClaims: readonly WorkerClaim[];\n\tlearningDecisions: readonly LearningDecision[];\n\tcontinuation: GoalContinuationDecision;\n\t/**\n\t * Open (non-terminal) task_steps steps on the active branch, latest-wins. Read-only.\n\t * Optional (like `goalState`/`latestEvidenceBundle`) so hand-built snapshots in existing\n\t * tests/call sites that predate this field keep compiling unchanged; `buildGoalRuntimeSnapshot`\n\t * itself always populates a concrete array (possibly empty).\n\t */\n\topenTaskSteps?: readonly GoalRuntimeOpenTaskStep[];\n\t/** Canonical read model joining requirements, foreground steps, and delegated DAG tasks. */\n\tworkState?: SessionWorkStateProjection;\n\t/**\n\t * Per-requirement worktree-sync state, present only for requirements whose `boundLaneId` matches\n\t * a `worktreeLaneStatus` entry supplied to the builder. Optional (like `openTaskSteps`) so every\n\t * pre-existing caller/test keeps compiling unchanged; omitted entirely (not an empty array) when\n\t * the builder was never given `worktreeLaneStatus`, since \"no data supplied\" and \"data supplied,\n\t * nothing bound\" are genuinely different states worth distinguishing.\n\t */\n\trequirementWorktreeStates?: readonly GoalRuntimeRequirementWorktreeState[];\n}\n\n/**\n * Branch-scoped: every resolver here reads from ONE source (the active branch), so the goal\n * state, evidence bundle, worker claims, learning decisions, and open task steps in the\n * returned snapshot are never a mix of the current branch and a sibling branch's history.\n */\nexport function buildGoalRuntimeSnapshot(args: {\n\tsessionManager: Pick<SessionManager, \"getLatestCustomEntryOnBranch\" | \"getBranch\">;\n\tsettings: GoalRuntimeSnapshotSettings;\n\t/**\n\t * Live lane records (queued/running/terminal), independent of branch scoping. Used ONLY to (a)\n\t * detect a worker in flight against the active goal's open requirement (\"waiting\" — see\n\t * `evaluateGoalContinuation`'s `inFlightGoalLaneIds`), and (b) surface this goal's cumulative\n\t * worker/subagent spend (advisory — see `GoalState.continuationWorkerSpendUsd`). Optional so\n\t * every pre-existing caller (hand-built snapshots, tests) that predates lane-awareness keeps\n\t * compiling and behaving byte-identically: omitting it disables both the \"waiting\" branch and the\n\t * worker-spend overlay, and never changes any OTHER continuation outcome.\n\t */\n\tlaneRecords?: readonly LaneRecord[];\n\t/**\n\t * Current time as an ISO-string factory, threaded into `evaluateGoalContinuation`'s never-hang\n\t * wait-timeout check (`now`/`maxWorkerWaitMs` — see there) alongside `maxWorkerWaitMs` below.\n\t * Defaults to the real wall clock. A factory (not a plain string) so a caller/test can inject a\n\t * fixed clock without freezing global `Date`.\n\t */\n\tnow?: () => string;\n\t/**\n\t * Maximum milliseconds a bound in-flight requirement may wait before the continuation escalates\n\t * to `worker_wait_timeout` instead of `\"waiting\"` forever (see `evaluateGoalContinuation`).\n\t * Defaults to `DEFAULT_GOAL_WORKER_WAIT_MS`.\n\t */\n\tmaxWorkerWaitMs?: number;\n\t/**\n\t * Live per-lane worktree-sync status, independent of branch scoping -- exactly like `laneRecords`,\n\t * this builder performs NO I/O of its own; the caller derives this array (e.g. from\n\t * `core/worktree-sync/git-engine.ts`'s live status) and supplies it ready-made. Used to (a) build\n\t * `requirementWorktreeStates` (per-requirement projection, matched via `boundLaneId`) and (b)\n\t * derive the `laneSyncConflictLaneKeys`/`syncRequiredLaneKeys` sets threaded into\n\t * `evaluateGoalContinuation`. Optional so every pre-existing caller (predating worktree-sync\n\t * awareness) keeps compiling and behaving byte-identically: omitting it disables both, and never\n\t * changes any OTHER continuation outcome.\n\t */\n\tworktreeLaneStatus?: readonly GoalRuntimeWorktreeLaneStatus[];\n\t/** Durable worker DAG projection, supplied only when the delegate capability has been loaded. */\n\ttaskRuntime?: TaskRuntimeProjection;\n}): GoalRuntimeSnapshot {\n\tconst branchEntries = getActiveSessionBranchEntries(args.sessionManager);\n\tlet goalState = getLatestGoalStateSnapshot(args.sessionManager);\n\tconst latestEvidenceBundle = getLatestEvidenceBundleSnapshot(branchEntries);\n\tconst workerClaims = getWorkerClaimSnapshots(branchEntries);\n\tconst learningDecisions = getLearningDecisionSnapshots(branchEntries);\n\n\t// Reuses the SAME branch-scoped primitive as goal-state resolution (getLatestCustomEntryOnBranch),\n\t// so the task-steps summary below can never leak a sibling branch's checklist either.\n\tconst taskStepsState = getLatestTaskStepsStateSnapshot(args.sessionManager);\n\tconst workState = projectSessionWorkState({ goalState, taskStepsState, taskRuntime: args.taskRuntime });\n\tconst openTaskSteps = workState.openTaskSteps;\n\n\tlet inFlightGoalLaneIds: ReadonlySet<string> | undefined;\n\tif (goalState && args.laneRecords) {\n\t\tconst goalId = goalState.goalId;\n\t\tconst inFlight = new Set<string>();\n\t\t// Live-derived, not durably persisted: the goal-state event log has no reducer branch that\n\t\t// writes `continuationWorkerSpendUsd` (see its doc comment on `GoalState`), so every read\n\t\t// re-sums THIS goal's own lane records instead of trusting a stale/zero persisted value.\n\t\t// `costUsd` is set today for in-process worker/research lane completions (LaneTracker.complete);\n\t\t// it is NOT yet set for tmux-worker completions (`ManagedLaneEvent` carries no cost claim), so\n\t\t// this sum is accurate for in-process lanes and a documented undercount for tmux workers until\n\t\t// `reportSpawnedUsage` threads a goalId/lane correlation through. Forward-compatible: the moment\n\t\t// tmux-worker costUsd is populated, this same sum picks it up with no further change here.\n\t\tlet workerSpendUsd = 0;\n\t\tfor (const record of args.laneRecords) {\n\t\t\tif (record.goalId !== goalId) continue;\n\t\t\tif (record.status === \"queued\" || record.status === \"running\") inFlight.add(record.laneId);\n\t\t\tworkerSpendUsd += record.costUsd ?? 0;\n\t\t}\n\t\tinFlightGoalLaneIds = inFlight;\n\t\tgoalState = { ...goalState, continuationWorkerSpendUsd: workerSpendUsd };\n\t}\n\n\t// Worktree-sync surfacing: (a) a per-requirement projection (matched via `boundLaneId`, purely for\n\t// snapshot consumers -- never read by `evaluateGoalContinuation` itself), and (b) the\n\t// `boundLaneId`-keyed sets `evaluateGoalContinuation` actually matches against\n\t// `Requirement.boundLaneId`, same id-space and matching pattern as `inFlightGoalLaneIds` above.\n\t// Disjoint by construction: a lane with `rebaseInProgress` feeds the conflict set only, never both.\n\tlet requirementWorktreeStates: GoalRuntimeRequirementWorktreeState[] | undefined;\n\tconst laneSyncConflictLaneKeys = new Set<string>();\n\tconst syncRequiredLaneKeys = new Set<string>();\n\tif (args.worktreeLaneStatus) {\n\t\tfor (const status of args.worktreeLaneStatus) {\n\t\t\tif (status.boundLaneId === undefined) continue;\n\t\t\tif (status.rebaseInProgress) laneSyncConflictLaneKeys.add(status.boundLaneId);\n\t\t\telse if (status.syncRequired) syncRequiredLaneKeys.add(status.boundLaneId);\n\t\t}\n\t\tif (goalState) {\n\t\t\tconst states: GoalRuntimeRequirementWorktreeState[] = [];\n\t\t\tfor (const requirement of goalState.requirements) {\n\t\t\t\tif (requirement.boundLaneId === undefined) continue;\n\t\t\t\tconst status = args.worktreeLaneStatus.find(\n\t\t\t\t\t(candidate) => candidate.boundLaneId === requirement.boundLaneId,\n\t\t\t\t);\n\t\t\t\tif (!status) continue;\n\t\t\t\tstates.push({\n\t\t\t\t\trequirementId: requirement.id,\n\t\t\t\t\tlaneKey: status.laneKey,\n\t\t\t\t\tfresh: status.fresh,\n\t\t\t\t\tstale: status.stale,\n\t\t\t\t\tsyncRequired: status.syncRequired,\n\t\t\t\t\trebaseInProgress: status.rebaseInProgress,\n\t\t\t\t});\n\t\t\t}\n\t\t\trequirementWorktreeStates = states;\n\t\t}\n\t}\n\n\tconst now = (args.now ?? (() => new Date().toISOString()))();\n\tconst maxWorkerWaitMs = args.maxWorkerWaitMs ?? DEFAULT_GOAL_WORKER_WAIT_MS;\n\tconst continuation = evaluateGoalContinuation({\n\t\tstate: goalState,\n\t\tsettings: { maxStallTurns: args.settings.maxStallTurns },\n\t\tinFlightGoalLaneIds,\n\t\tnow,\n\t\tmaxWorkerWaitMs,\n\t\tlaneSyncConflictLaneKeys: laneSyncConflictLaneKeys.size > 0 ? laneSyncConflictLaneKeys : undefined,\n\t\tsyncRequiredLaneKeys: syncRequiredLaneKeys.size > 0 ? syncRequiredLaneKeys : undefined,\n\t});\n\n\treturn {\n\t\tgoalState,\n\t\tlatestEvidenceBundle,\n\t\tworkerClaims,\n\t\tlearningDecisions,\n\t\tcontinuation,\n\t\topenTaskSteps,\n\t\tworkState,\n\t\t...(requirementWorktreeStates !== undefined ? { requirementWorktreeStates } : {}),\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"goal-runtime-snapshot.d.ts","sourceRoot":"","sources":["../../../src/core/goals/goal-runtime-snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC9F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAG9D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAC9E,OAAO,EAA2B,KAAK,0BAA0B,EAAE,MAAM,2CAA2C,CAAC;AAIrH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAC1E,OAAO,EAA4B,KAAK,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAE5G,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAGjD,MAAM,WAAW,2BAA2B;IAC3C,aAAa,EAAE,MAAM,CAAC;CACtB;AAED;;;;;GAKG;AACH,MAAM,MAAM,uBAAuB,GAAG,sBAAsB,CAAC;AAE7D;;;;;;;;GAQG;AACH,MAAM,WAAW,6BAA6B;IAC7C,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,EAAE,OAAO,CAAC;IACf,YAAY,EAAE,OAAO,CAAC;IACtB,gBAAgB,EAAE,OAAO,CAAC;CAC1B;AAED;;;;;;GAMG;AACH,MAAM,WAAW,mCAAmC;IACnD,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,M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B,CAAC,CAAC,CAAC,SAAS;KACtF,CAAC,CAAC;IAEH,OAAO;QACN,SAAS;QACT,oBAAoB;QACpB,YAAY;QACZ,iBAAiB;QACjB,YAAY;QACZ,aAAa;QACb,SAAS;QACT,GAAG,CAAC,yBAAyB,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,yBAAyB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACjF,CAAC;AAAA,CACF","sourcesContent":["import type { SessionManager } from \"@caupulican/pi-agent-core/node\";\nimport type { EvidenceBundle, LearningDecision, WorkerClaim } from \"../autonomy/contracts.ts\";\nimport type { LaneRecord } from \"../autonomy/lane-tracker.ts\";\nimport { getWorkerClaimSnapshots } from \"../delegation/session-worker-claim.ts\";\nimport { getLearningDecisionSnapshots } from \"../learning/session-learning-decision.ts\";\nimport type { TaskRuntimeProjection } from \"../orchestration/task-runtime.ts\";\nimport { projectSessionWorkState, type SessionWorkStateProjection } from \"../orchestration/work-state-projection.ts\";\nimport { getLatestEvidenceBundleSnapshot } from \"../research/session-evidence-bundle.ts\";\nimport { getActiveSessionBranchEntries } from \"../session-snapshot.ts\";\nimport { getLatestTaskStepsStateSnapshot } from \"../tasks/session-task-state.ts\";\nimport type { OpenTaskStepProjection } from \"../tasks/task-projection.ts\";\nimport { evaluateGoalContinuation, type GoalContinuationDecision } from \"./goal-continuation-controller.ts\";\nimport { DEFAULT_GOAL_WORKER_WAIT_MS } from \"./goal-continuation-defaults.ts\";\nimport type { GoalState } from \"./goal-state.ts\";\nimport { getLatestGoalStateSnapshot } from \"./session-goal-state.ts\";\n\nexport interface GoalRuntimeSnapshotSettings {\n\tmaxStallTurns: number;\n}\n\n/**\n * A read-only projection of one OPEN (non-terminal) task_steps step, included in the goal\n * runtime snapshot purely for cross-visibility. This is NOT a shared state machine: the goal\n * loop never writes back to task state through this snapshot, and the task store stays the\n * single source of truth for its own steps.\n */\nexport type GoalRuntimeOpenTaskStep = OpenTaskStepProjection;\n\n/**\n * Live, per-worktree-sync-lane status for one lane bound to a dispatched worker, as the caller\n * (runtime-builder / whatever host process has live git-engine access) derives it. `boundLaneId` is\n * the host `LaneRecord.laneId` the lane's registration was correlated to\n * (`LaneRegistration.boundLaneId`, same id-space as `Requirement.boundLaneId`) -- `undefined` for a\n * lane never bound to a dispatch. `fresh`/`stale` mirror `LaneFacts`; `syncRequired` is the\n * staleness-propagation verdict (`WorktreeSyncPolicy`-derived); `rebaseInProgress` marks a sync that\n * stopped on conflicts (a rebase left in progress) -- see `core/worktree-sync/git-engine.ts`.\n */\nexport interface GoalRuntimeWorktreeLaneStatus {\n\tlaneKey: string;\n\tboundLaneId?: string;\n\tfresh: boolean;\n\tstale: boolean;\n\tsyncRequired: boolean;\n\trebaseInProgress: boolean;\n}\n\n/**\n * Per-requirement projection of {@link GoalRuntimeWorktreeLaneStatus}, joined via\n * `requirement.boundLaneId === status.boundLaneId` -- read-only cross-visibility for snapshot\n * consumers (e.g. a future continuation-prompt render), mirroring `openTaskSteps`'s role. This is\n * NOT what feeds `evaluateGoalContinuation` (that reads the raw `boundLaneId`-keyed sets directly);\n * it exists purely so a requirement's worktree state is visible without re-deriving the join.\n */\nexport interface GoalRuntimeRequirementWorktreeState {\n\trequirementId: string;\n\tlaneKey: string;\n\tfresh: boolean;\n\tstale: boolean;\n\tsyncRequired: boolean;\n\trebaseInProgress: boolean;\n}\n\nexport interface GoalRuntimeSnapshot {\n\tgoalState?: GoalState;\n\tlatestEvidenceBundle?: EvidenceBundle;\n\tworkerClaims: readonly WorkerClaim[];\n\tlearningDecisions: readonly LearningDecision[];\n\tcontinuation: GoalContinuationDecision;\n\t/**\n\t * Open (non-terminal) task_steps steps on the active branch, latest-wins. Read-only.\n\t * Optional (like `goalState`/`latestEvidenceBundle`) so hand-built snapshots in existing\n\t * tests/call sites that predate this field keep compiling unchanged; `buildGoalRuntimeSnapshot`\n\t * itself always populates a concrete array (possibly empty).\n\t */\n\topenTaskSteps?: readonly GoalRuntimeOpenTaskStep[];\n\t/** Canonical read model joining requirements, foreground steps, and delegated DAG tasks. */\n\tworkState?: SessionWorkStateProjection;\n\t/**\n\t * Per-requirement worktree-sync state, present only for requirements whose `boundLaneId` matches\n\t * a `worktreeLaneStatus` entry supplied to the builder. Optional (like `openTaskSteps`) so every\n\t * pre-existing caller/test keeps compiling unchanged; omitted entirely (not an empty array) when\n\t * the builder was never given `worktreeLaneStatus`, since \"no data supplied\" and \"data supplied,\n\t * nothing bound\" are genuinely different states worth distinguishing.\n\t */\n\trequirementWorktreeStates?: readonly GoalRuntimeRequirementWorktreeState[];\n}\n\n/**\n * Branch-scoped: every resolver here reads from ONE source (the active branch), so the goal\n * state, evidence bundle, worker claims, learning decisions, and open task steps in the\n * returned snapshot are never a mix of the current branch and a sibling branch's history.\n */\nexport function buildGoalRuntimeSnapshot(args: {\n\tsessionManager: Pick<SessionManager, \"getLatestCustomEntryOnBranch\" | \"getBranch\">;\n\tsettings: GoalRuntimeSnapshotSettings;\n\t/**\n\t * Live lane records (queued/running/terminal), independent of branch scoping. Used ONLY to (a)\n\t * detect a worker in flight against the active goal's open requirement (\"waiting\" — see\n\t * `evaluateGoalContinuation`'s `inFlightGoalLaneIds`), and (b) surface this goal's cumulative\n\t * worker/subagent spend (advisory — see `GoalState.continuationWorkerSpendUsd`). Optional so\n\t * every pre-existing caller (hand-built snapshots, tests) that predates lane-awareness keeps\n\t * compiling and behaving byte-identically: omitting it disables both the \"waiting\" branch and the\n\t * worker-spend overlay, and never changes any OTHER continuation outcome.\n\t */\n\tlaneRecords?: readonly LaneRecord[];\n\t/**\n\t * Current time as an ISO-string factory, threaded into `evaluateGoalContinuation`'s never-hang\n\t * wait-timeout check (`now`/`maxWorkerWaitMs` — see there) alongside `maxWorkerWaitMs` below.\n\t * Defaults to the real wall clock. A factory (not a plain string) so a caller/test can inject a\n\t * fixed clock without freezing global `Date`.\n\t */\n\tnow?: () => string;\n\t/**\n\t * Maximum milliseconds a bound in-flight requirement may wait before the continuation escalates\n\t * to `worker_wait_timeout` instead of `\"waiting\"` forever (see `evaluateGoalContinuation`).\n\t * Defaults to `DEFAULT_GOAL_WORKER_WAIT_MS`.\n\t */\n\tmaxWorkerWaitMs?: number;\n\t/**\n\t * Live per-lane worktree-sync status, independent of branch scoping -- exactly like `laneRecords`,\n\t * this builder performs NO I/O of its own; the caller derives this array (e.g. from\n\t * `core/worktree-sync/git-engine.ts`'s live status) and supplies it ready-made. Used to (a) build\n\t * `requirementWorktreeStates` (per-requirement projection, matched via `boundLaneId`) and (b)\n\t * derive the `laneSyncConflictLaneKeys`/`syncRequiredLaneKeys` sets threaded into\n\t * `evaluateGoalContinuation`. Optional so every pre-existing caller (predating worktree-sync\n\t * awareness) keeps compiling and behaving byte-identically: omitting it disables both, and never\n\t * changes any OTHER continuation outcome.\n\t */\n\tworktreeLaneStatus?: readonly GoalRuntimeWorktreeLaneStatus[];\n\t/** Durable worker DAG projection, supplied only when the delegate capability has been loaded. */\n\ttaskRuntime?: TaskRuntimeProjection;\n}): GoalRuntimeSnapshot {\n\tconst branchEntries = getActiveSessionBranchEntries(args.sessionManager);\n\tlet goalState = getLatestGoalStateSnapshot(args.sessionManager);\n\tconst latestEvidenceBundle = getLatestEvidenceBundleSnapshot(branchEntries);\n\tconst workerClaims = getWorkerClaimSnapshots(branchEntries);\n\tconst learningDecisions = getLearningDecisionSnapshots(branchEntries);\n\n\t// Reuses the SAME branch-scoped primitive as goal-state resolution (getLatestCustomEntryOnBranch),\n\t// so the task-steps summary below can never leak a sibling branch's checklist either.\n\tconst taskStepsState = getLatestTaskStepsStateSnapshot(args.sessionManager);\n\tconst workState = projectSessionWorkState({ goalState, taskStepsState, taskRuntime: args.taskRuntime });\n\tconst openTaskSteps = workState.openTaskSteps;\n\n\tlet inFlightGoalLaneIds: ReadonlySet<string> | undefined;\n\tif (goalState && args.laneRecords) {\n\t\tconst goalId = goalState.goalId;\n\t\tconst inFlight = new Set<string>();\n\t\t// Live-derived, not durably persisted: the goal-state event log has no reducer branch that\n\t\t// writes `continuationWorkerSpendUsd` (see its doc comment on `GoalState`), so every read\n\t\t// re-sums THIS goal's own lane records instead of trusting a stale/zero persisted value.\n\t\t// `costUsd` is set today for in-process worker/research lane completions (LaneTracker.complete);\n\t\t// it is NOT yet set for tmux-worker completions (`ManagedLaneEvent` carries no cost claim), so\n\t\t// this sum is accurate for in-process lanes and a documented undercount for tmux workers until\n\t\t// `reportSpawnedUsage` threads a goalId/lane correlation through. Forward-compatible: the moment\n\t\t// tmux-worker costUsd is populated, this same sum picks it up with no further change here.\n\t\tlet workerSpendUsd = 0;\n\t\tfor (const record of args.laneRecords) {\n\t\t\tif (record.goalId !== goalId) continue;\n\t\t\tif (record.status === \"queued\" || record.status === \"running\") inFlight.add(record.laneId);\n\t\t\tworkerSpendUsd += record.costUsd ?? 0;\n\t\t}\n\t\tinFlightGoalLaneIds = inFlight;\n\t\tgoalState = { ...goalState, continuationWorkerSpendUsd: workerSpendUsd };\n\t}\n\n\t// Worktree-sync surfacing: (a) a per-requirement projection (matched via `boundLaneId`, purely for\n\t// snapshot consumers -- never read by `evaluateGoalContinuation` itself), and (b) the\n\t// `boundLaneId`-keyed sets `evaluateGoalContinuation` actually matches against\n\t// `Requirement.boundLaneId`, same id-space and matching pattern as `inFlightGoalLaneIds` above.\n\t// Disjoint by construction: a lane with `rebaseInProgress` feeds the conflict set only, never both.\n\tlet requirementWorktreeStates: GoalRuntimeRequirementWorktreeState[] | undefined;\n\tconst laneSyncConflictLaneKeys = new Set<string>();\n\tconst syncRequiredLaneKeys = new Set<string>();\n\tif (args.worktreeLaneStatus) {\n\t\tfor (const status of args.worktreeLaneStatus) {\n\t\t\tif (status.boundLaneId === undefined) continue;\n\t\t\tif (status.rebaseInProgress) laneSyncConflictLaneKeys.add(status.boundLaneId);\n\t\t\telse if (status.syncRequired) syncRequiredLaneKeys.add(status.boundLaneId);\n\t\t}\n\t\tif (goalState) {\n\t\t\tconst states: GoalRuntimeRequirementWorktreeState[] = [];\n\t\t\tfor (const requirement of goalState.requirements) {\n\t\t\t\tif (requirement.boundLaneId === undefined) continue;\n\t\t\t\tconst status = args.worktreeLaneStatus.find(\n\t\t\t\t\t(candidate) => candidate.boundLaneId === requirement.boundLaneId,\n\t\t\t\t);\n\t\t\t\tif (!status) continue;\n\t\t\t\tstates.push({\n\t\t\t\t\trequirementId: requirement.id,\n\t\t\t\t\tlaneKey: status.laneKey,\n\t\t\t\t\tfresh: status.fresh,\n\t\t\t\t\tstale: status.stale,\n\t\t\t\t\tsyncRequired: status.syncRequired,\n\t\t\t\t\trebaseInProgress: status.rebaseInProgress,\n\t\t\t\t});\n\t\t\t}\n\t\t\trequirementWorktreeStates = states;\n\t\t}\n\t}\n\n\tconst now = (args.now ?? (() => new Date().toISOString()))();\n\tconst maxWorkerWaitMs = args.maxWorkerWaitMs ?? DEFAULT_GOAL_WORKER_WAIT_MS;\n\tconst continuation = evaluateGoalContinuation({\n\t\tstate: goalState,\n\t\tsettings: { maxStallTurns: args.settings.maxStallTurns },\n\t\tinFlightGoalLaneIds,\n\t\tnow,\n\t\tmaxWorkerWaitMs,\n\t\tlaneSyncConflictLaneKeys: laneSyncConflictLaneKeys.size > 0 ? laneSyncConflictLaneKeys : undefined,\n\t\tsyncRequiredLaneKeys: syncRequiredLaneKeys.size > 0 ? syncRequiredLaneKeys : undefined,\n\t});\n\n\treturn {\n\t\tgoalState,\n\t\tlatestEvidenceBundle,\n\t\tworkerClaims,\n\t\tlearningDecisions,\n\t\tcontinuation,\n\t\topenTaskSteps,\n\t\tworkState,\n\t\t...(requirementWorktreeStates !== undefined ? { requirementWorktreeStates } : {}),\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"goal-runtime-snapshot.js","sourceRoot":"","sources":["../../../src/core/goals/goal-runtime-snapshot.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAChF,OAAO,EAAE,4BAA4B,EAAE,MAAM,0CAA0C,CAAC;AAExF,OAAO,EAAE,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B;QACpB,YAAY;QACZ,iBAAiB;QACjB,YAAY;QACZ,aAAa;QACb,SAAS;QACT,GAAG,CAAC,yBAAyB,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,yBAAyB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACjF,CAAC;AACH,CAAC","sourcesContent":["import type { SessionManager } from \"@caupulican/pi-agent-core/node\";\nimport type { EvidenceBundle, LearningDecision, WorkerClaim } from \"../autonomy/contracts.ts\";\nimport type { LaneRecord } from \"../autonomy/lane-tracker.ts\";\nimport { getWorkerClaimSnapshots } from \"../delegation/session-worker-claim.ts\";\nimport { getLearningDecisionSnapshots } from \"../learning/session-learning-decision.ts\";\nimport type { TaskRuntimeProjection } from \"../orchestration/task-runtime.ts\";\nimport { projectSessionWorkState, type SessionWorkStateProjection } from \"../orchestration/work-state-projection.ts\";\nimport { getLatestEvidenceBundleSnapshot } from \"../research/session-evidence-bundle.ts\";\nimport { getActiveSessionBranchEntries } from \"../session-snapshot.ts\";\nimport { getLatestTaskStepsStateSnapshot } from \"../tasks/session-task-state.ts\";\nimport type { OpenTaskStepProjection } from \"../tasks/task-projection.ts\";\nimport { evaluateGoalContinuation, type GoalContinuationDecision } from \"./goal-continuation-controller.ts\";\nimport { DEFAULT_GOAL_WORKER_WAIT_MS } from \"./goal-continuation-defaults.ts\";\nimport type { GoalState } from \"./goal-state.ts\";\nimport { getLatestGoalStateSnapshot } from \"./session-goal-state.ts\";\n\nexport interface GoalRuntimeSnapshotSettings {\n\tmaxStallTurns: number;\n}\n\n/**\n * A read-only projection of one OPEN (non-terminal) task_steps step, included in the goal\n * runtime snapshot purely for cross-visibility. This is NOT a shared state machine: the goal\n * loop never writes back to task state through this snapshot, and the task store stays the\n * single source of truth for its own steps.\n */\nexport type GoalRuntimeOpenTaskStep = OpenTaskStepProjection;\n\n/**\n * Live, per-worktree-sync-lane status for one lane bound to a dispatched worker, as the caller\n * (runtime-builder / whatever host process has live git-engine access) derives it. `boundLaneId` is\n * the host `LaneRecord.laneId` the lane's registration was correlated to\n * (`LaneRegistration.boundLaneId`, same id-space as `Requirement.boundLaneId`) -- `undefined` for a\n * lane never bound to a dispatch. `fresh`/`stale` mirror `LaneFacts`; `syncRequired` is the\n * staleness-propagation verdict (`WorktreeSyncPolicy`-derived); `rebaseInProgress` marks a sync that\n * stopped on conflicts (a rebase left in progress) -- see `core/worktree-sync/git-engine.ts`.\n */\nexport interface GoalRuntimeWorktreeLaneStatus {\n\tlaneKey: string;\n\tboundLaneId?: string;\n\tfresh: boolean;\n\tstale: boolean;\n\tsyncRequired: boolean;\n\trebaseInProgress: boolean;\n}\n\n/**\n * Per-requirement projection of {@link GoalRuntimeWorktreeLaneStatus}, joined via\n * `requirement.boundLaneId === status.boundLaneId` -- read-only cross-visibility for snapshot\n * consumers (e.g. a future continuation-prompt render), mirroring `openTaskSteps`'s role. This is\n * NOT what feeds `evaluateGoalContinuation` (that reads the raw `boundLaneId`-keyed sets directly);\n * it exists purely so a requirement's worktree state is visible without re-deriving the join.\n */\nexport interface GoalRuntimeRequirementWorktreeState {\n\trequirementId: string;\n\tlaneKey: string;\n\tfresh: boolean;\n\tstale: boolean;\n\tsyncRequired: boolean;\n\trebaseInProgress: boolean;\n}\n\nexport interface GoalRuntimeSnapshot {\n\tgoalState?: GoalState;\n\tlatestEvidenceBundle?: EvidenceBundle;\n\tworkerClaims: readonly WorkerClaim[];\n\tlearningDecisions: readonly LearningDecision[];\n\tcontinuation: GoalContinuationDecision;\n\t/**\n\t * Open (non-terminal) task_steps steps on the active branch, latest-wins. Read-only.\n\t * Optional (like `goalState`/`latestEvidenceBundle`) so hand-built snapshots in existing\n\t * tests/call sites that predate this field keep compiling unchanged; `buildGoalRuntimeSnapshot`\n\t * itself always populates a concrete array (possibly empty).\n\t */\n\topenTaskSteps?: readonly GoalRuntimeOpenTaskStep[];\n\t/** Canonical read model joining requirements, foreground steps, and delegated DAG tasks. */\n\tworkState?: SessionWorkStateProjection;\n\t/**\n\t * Per-requirement worktree-sync state, present only for requirements whose `boundLaneId` matches\n\t * a `worktreeLaneStatus` entry supplied to the builder. Optional (like `openTaskSteps`) so every\n\t * pre-existing caller/test keeps compiling unchanged; omitted entirely (not an empty array) when\n\t * the builder was never given `worktreeLaneStatus`, since \"no data supplied\" and \"data supplied,\n\t * nothing bound\" are genuinely different states worth distinguishing.\n\t */\n\trequirementWorktreeStates?: readonly GoalRuntimeRequirementWorktreeState[];\n}\n\n/**\n * Branch-scoped: every resolver here reads from ONE source (the active branch), so the goal\n * state, evidence bundle, worker claims, learning decisions, and open task steps in the\n * returned snapshot are never a mix of the current branch and a sibling branch's history.\n */\nexport function buildGoalRuntimeSnapshot(args: {\n\tsessionManager: Pick<SessionManager, \"getLatestCustomEntryOnBranch\" | \"getBranch\">;\n\tsettings: GoalRuntimeSnapshotSettings;\n\t/**\n\t * Live lane records (queued/running/terminal), independent of branch scoping. Used ONLY to (a)\n\t * detect a worker in flight against the active goal's open requirement (\"waiting\" — see\n\t * `evaluateGoalContinuation`'s `inFlightGoalLaneIds`), and (b) surface this goal's cumulative\n\t * worker/subagent spend (advisory — see `GoalState.continuationWorkerSpendUsd`). Optional so\n\t * every pre-existing caller (hand-built snapshots, tests) that predates lane-awareness keeps\n\t * compiling and behaving byte-identically: omitting it disables both the \"waiting\" branch and the\n\t * worker-spend overlay, and never changes any OTHER continuation outcome.\n\t */\n\tlaneRecords?: readonly LaneRecord[];\n\t/**\n\t * Current time as an ISO-string factory, threaded into `evaluateGoalContinuation`'s never-hang\n\t * wait-timeout check (`now`/`maxWorkerWaitMs` — see there) alongside `maxWorkerWaitMs` below.\n\t * Defaults to the real wall clock. A factory (not a plain string) so a caller/test can inject a\n\t * fixed clock without freezing global `Date`.\n\t */\n\tnow?: () => string;\n\t/**\n\t * Maximum milliseconds a bound in-flight requirement may wait before the continuation escalates\n\t * to `worker_wait_timeout` instead of `\"waiting\"` forever (see `evaluateGoalContinuation`).\n\t * Defaults to `DEFAULT_GOAL_WORKER_WAIT_MS`.\n\t */\n\tmaxWorkerWaitMs?: number;\n\t/**\n\t * Live per-lane worktree-sync status, independent of branch scoping -- exactly like `laneRecords`,\n\t * this builder performs NO I/O of its own; the caller derives this array (e.g. from\n\t * `core/worktree-sync/git-engine.ts`'s live status) and supplies it ready-made. Used to (a) build\n\t * `requirementWorktreeStates` (per-requirement projection, matched via `boundLaneId`) and (b)\n\t * derive the `laneSyncConflictLaneKeys`/`syncRequiredLaneKeys` sets threaded into\n\t * `evaluateGoalContinuation`. Optional so every pre-existing caller (predating worktree-sync\n\t * awareness) keeps compiling and behaving byte-identically: omitting it disables both, and never\n\t * changes any OTHER continuation outcome.\n\t */\n\tworktreeLaneStatus?: readonly GoalRuntimeWorktreeLaneStatus[];\n\t/** Durable worker DAG projection, supplied only when the delegate capability has been loaded. */\n\ttaskRuntime?: TaskRuntimeProjection;\n}): GoalRuntimeSnapshot {\n\tconst branchEntries = getActiveSessionBranchEntries(args.sessionManager);\n\tlet goalState = getLatestGoalStateSnapshot(args.sessionManager);\n\tconst latestEvidenceBundle = getLatestEvidenceBundleSnapshot(branchEntries);\n\tconst workerClaims = getWorkerClaimSnapshots(branchEntries);\n\tconst learningDecisions = getLearningDecisionSnapshots(branchEntries);\n\n\t// Reuses the SAME branch-scoped primitive as goal-state resolution (getLatestCustomEntryOnBranch),\n\t// so the task-steps summary below can never leak a sibling branch's checklist either.\n\tconst taskStepsState = getLatestTaskStepsStateSnapshot(args.sessionManager);\n\tconst workState = projectSessionWorkState({ goalState, taskStepsState, taskRuntime: args.taskRuntime });\n\tconst openTaskSteps = workState.openTaskSteps;\n\n\tlet inFlightGoalLaneIds: ReadonlySet<string> | undefined;\n\tif (goalState && args.laneRecords) {\n\t\tconst goalId = goalState.goalId;\n\t\tconst inFlight = new Set<string>();\n\t\t// Live-derived, not durably persisted: the goal-state event log has no reducer branch that\n\t\t// writes `continuationWorkerSpendUsd` (see its doc comment on `GoalState`), so every read\n\t\t// re-sums THIS goal's own lane records instead of trusting a stale/zero persisted value.\n\t\t// `costUsd` is set today for in-process worker/research lane completions (LaneTracker.complete);\n\t\t// it is NOT yet set for tmux-worker completions (`ManagedLaneEvent` carries no cost claim), so\n\t\t// this sum is accurate for in-process lanes and a documented undercount for tmux workers until\n\t\t// `reportSpawnedUsage` threads a goalId/lane correlation through. Forward-compatible: the moment\n\t\t// tmux-worker costUsd is populated, this same sum picks it up with no further change here.\n\t\tlet workerSpendUsd = 0;\n\t\tfor (const record of args.laneRecords) {\n\t\t\tif (record.goalId !== goalId) continue;\n\t\t\tif (record.status === \"queued\" || record.status === \"running\") inFlight.add(record.laneId);\n\t\t\tworkerSpendUsd += record.costUsd ?? 0;\n\t\t}\n\t\tinFlightGoalLaneIds = inFlight;\n\t\tgoalState = { ...goalState, continuationWorkerSpendUsd: workerSpendUsd };\n\t}\n\n\t// Worktree-sync surfacing: (a) a per-requirement projection (matched via `boundLaneId`, purely for\n\t// snapshot consumers -- never read by `evaluateGoalContinuation` itself), and (b) the\n\t// `boundLaneId`-keyed sets `evaluateGoalContinuation` actually matches against\n\t// `Requirement.boundLaneId`, same id-space and matching pattern as `inFlightGoalLaneIds` above.\n\t// Disjoint by construction: a lane with `rebaseInProgress` feeds the conflict set only, never both.\n\tlet requirementWorktreeStates: GoalRuntimeRequirementWorktreeState[] | undefined;\n\tconst laneSyncConflictLaneKeys = new Set<string>();\n\tconst syncRequiredLaneKeys = new Set<string>();\n\tif (args.worktreeLaneStatus) {\n\t\tfor (const status of args.worktreeLaneStatus) {\n\t\t\tif (status.boundLaneId === undefined) continue;\n\t\t\tif (status.rebaseInProgress) laneSyncConflictLaneKeys.add(status.boundLaneId);\n\t\t\telse if (status.syncRequired) syncRequiredLaneKeys.add(status.boundLaneId);\n\t\t}\n\t\tif (goalState) {\n\t\t\tconst states: GoalRuntimeRequirementWorktreeState[] = [];\n\t\t\tfor (const requirement of goalState.requirements) {\n\t\t\t\tif (requirement.boundLaneId === undefined) continue;\n\t\t\t\tconst status = args.worktreeLaneStatus.find(\n\t\t\t\t\t(candidate) => candidate.boundLaneId === requirement.boundLaneId,\n\t\t\t\t);\n\t\t\t\tif (!status) continue;\n\t\t\t\tstates.push({\n\t\t\t\t\trequirementId: requirement.id,\n\t\t\t\t\tlaneKey: status.laneKey,\n\t\t\t\t\tfresh: status.fresh,\n\t\t\t\t\tstale: status.stale,\n\t\t\t\t\tsyncRequired: status.syncRequired,\n\t\t\t\t\trebaseInProgress: status.rebaseInProgress,\n\t\t\t\t});\n\t\t\t}\n\t\t\trequirementWorktreeStates = states;\n\t\t}\n\t}\n\n\tconst now = (args.now ?? (() => new Date().toISOString()))();\n\tconst maxWorkerWaitMs = args.maxWorkerWaitMs ?? DEFAULT_GOAL_WORKER_WAIT_MS;\n\tconst continuation = evaluateGoalContinuation({\n\t\tstate: goalState,\n\t\tsettings: { maxStallTurns: args.settings.maxStallTurns },\n\t\tinFlightGoalLaneIds,\n\t\tnow,\n\t\tmaxWorkerWaitMs,\n\t\tlaneSyncConflictLaneKeys: laneSyncConflictLaneKeys.size > 0 ? laneSyncConflictLaneKeys : undefined,\n\t\tsyncRequiredLaneKeys: syncRequiredLaneKeys.size > 0 ? syncRequiredLaneKeys : undefined,\n\t});\n\n\treturn {\n\t\tgoalState,\n\t\tlatestEvidenceBundle,\n\t\tworkerClaims,\n\t\tlearningDecisions,\n\t\tcontinuation,\n\t\topenTaskSteps,\n\t\tworkState,\n\t\t...(requirementWorktreeStates !== undefined ? { requirementWorktreeStates } : {}),\n\t};\n}\n"]}
|
|
@@ -15,6 +15,15 @@ export interface GoalSessionControllerDeps {
|
|
|
15
15
|
prompt(text: string, options?: PromptOptions): Promise<void>;
|
|
16
16
|
emitWarning(message: string): void;
|
|
17
17
|
}
|
|
18
|
+
export type ChatGoalAdmission = {
|
|
19
|
+
status: "not_explicit";
|
|
20
|
+
} | {
|
|
21
|
+
status: "started";
|
|
22
|
+
state: GoalState;
|
|
23
|
+
} | {
|
|
24
|
+
status: "unfinished_goal_exists";
|
|
25
|
+
state: GoalState;
|
|
26
|
+
};
|
|
18
27
|
/**
|
|
19
28
|
* Owns durable goal state, exact continuation accounting, and the raw continuation loop. The
|
|
20
29
|
* AgentSession facade supplies process collaborators but no longer implements goal lifecycle rules.
|
|
@@ -26,6 +35,12 @@ export declare class GoalSessionController {
|
|
|
26
35
|
saveState(state: GoalState, expected?: GoalStateRevision): string;
|
|
27
36
|
clearState(state: GoalState, now: string): string;
|
|
28
37
|
getState(): GoalState | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Promote high-confidence natural-language persistence into the same durable state written by the
|
|
40
|
+
* goal tool. This is intentionally narrower than task detection: ordinary work never starts a
|
|
41
|
+
* goal, and an unfinished goal is never replaced implicitly.
|
|
42
|
+
*/
|
|
43
|
+
admitExplicitChatGoal(text: string, now?: string): ChatGoalAdmission;
|
|
29
44
|
recordContinuationPass(pass: {
|
|
30
45
|
turns: number;
|
|
31
46
|
wallClockMs: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"goal-session-controller.d.ts","sourceRoot":"","sources":["../../../src/core/goals/goal-session-controller.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"goal-session-controller.d.ts","sourceRoot":"","sources":["../../../src/core/goals/goal-session-controller.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAErE,OAAO,KAAK,EACX,2BAA2B,EAC3B,0BAA0B,EAC1B,2BAA2B,EAC3B,0BAA0B,EAC1B,aAAa,EACb,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAE9D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAC9E,OAAO,EAAE,KAAK,iBAAiB,EAA4C,MAAM,qBAAqB,CAAC;AACvG,OAAO,EAEN,KAAK,mBAAmB,EACxB,KAAK,2BAA2B,EAChC,MAAM,4BAA4B,CAAC;AACpC,OAAO,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AAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,GAAG,IAAI,CA6BrG;IAED,mBAAmB,IAAI,IAAI,CAW1B;IAED,kBAAkB,CAAC,QAAQ,EAAE,2BAA2B,GAAG,mBAAmB,CAO7E;IAED,YAAY,CAAC,OAAO,EAAE,2BAA2B,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAEtF;IAED,YAAY,CAAC,OAAO,EAAE,2BAA2B,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAEtF;IAED,kBAAkB,IAAI,IAAI,CAEzB;IAED,OAAO,CAAC,yBAAyB;IAcjC,OAAO,CAAC,iBAAiB;CAKzB"}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
1
2
|
import { classifyFailure } from "@caupulican/pi-agent-core";
|
|
2
3
|
import { GoalLoopController } from "../goal-loop-controller.js";
|
|
3
4
|
import { getGoalStateRevision, stopGoalFromSystem } from "./goal-lifecycle.js";
|
|
4
5
|
import { buildGoalRuntimeSnapshot, } from "./goal-runtime-snapshot.js";
|
|
5
|
-
import { applyGoalEvent } from "./goal-state.js";
|
|
6
|
+
import { applyGoalEvent, isGoalUnfinishedStatus } from "./goal-state.js";
|
|
7
|
+
import { applyGoalAction } from "./goal-tool-core.js";
|
|
8
|
+
import { parseExplicitChatGoal } from "./natural-language-goal.js";
|
|
6
9
|
import { appendGoalClearedSnapshot, appendGoalStateSnapshot, getLatestGoalStateSnapshot, } from "./session-goal-state.js";
|
|
7
10
|
/**
|
|
8
11
|
* Owns durable goal state, exact continuation accounting, and the raw continuation loop. The
|
|
9
12
|
* AgentSession facade supplies process collaborators but no longer implements goal lifecycle rules.
|
|
10
13
|
*/
|
|
11
14
|
export class GoalSessionController {
|
|
12
|
-
deps;
|
|
13
|
-
loop;
|
|
14
15
|
constructor(deps) {
|
|
15
16
|
this.deps = deps;
|
|
16
17
|
this.loop = new GoalLoopController({
|
|
@@ -51,6 +52,29 @@ export class GoalSessionController {
|
|
|
51
52
|
getState() {
|
|
52
53
|
return getLatestGoalStateSnapshot(this.deps.getSessionManager());
|
|
53
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* Promote high-confidence natural-language persistence into the same durable state written by the
|
|
57
|
+
* goal tool. This is intentionally narrower than task detection: ordinary work never starts a
|
|
58
|
+
* goal, and an unfinished goal is never replaced implicitly.
|
|
59
|
+
*/
|
|
60
|
+
admitExplicitChatGoal(text, now = new Date().toISOString()) {
|
|
61
|
+
const parsed = parseExplicitChatGoal(text);
|
|
62
|
+
if (!parsed)
|
|
63
|
+
return { status: "not_explicit" };
|
|
64
|
+
const current = this.getState();
|
|
65
|
+
if (current && isGoalUnfinishedStatus(current.status)) {
|
|
66
|
+
return { status: "unfinished_goal_exists", state: current };
|
|
67
|
+
}
|
|
68
|
+
const digest = createHash("sha256")
|
|
69
|
+
.update(`${now}\0${current?.goalId ?? "none"}\0${parsed.objective}`)
|
|
70
|
+
.digest("hex")
|
|
71
|
+
.slice(0, 20);
|
|
72
|
+
const result = applyGoalAction(current, { action: "start", goalId: `chat-${digest}`, userGoal: parsed.objective }, now);
|
|
73
|
+
if (!result.ok)
|
|
74
|
+
throw new Error(result.error);
|
|
75
|
+
this.saveState(result.state, current ? getGoalStateRevision(current) : undefined);
|
|
76
|
+
return { status: "started", state: result.state };
|
|
77
|
+
}
|
|
54
78
|
recordContinuationPass(pass) {
|
|
55
79
|
const state = this.getState();
|
|
56
80
|
if (!state)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"goal-session-controller.js","sourceRoot":"","sources":["../../../src/core/goals/goal-session-controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAW5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAEhE,OAAO,EAA0B,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,qBAA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AAC,CAAC,CAAC;IAAA,CAC3E;IAEO,iBAAiB,CAAC,MAAc,EAAQ;QAC/C,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;QAC9B,MAAM,OAAO,GAAG,kBAAkB,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC;QAC1G,IAAI,OAAO,CAAC,EAAE,IAAI,KAAK;YAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,EAAE,oBAAoB,CAAC,KAAK,CAAC,CAAC,CAAC;IAAA,CACpF;CACD","sourcesContent":["import { classifyFailure } from \"@caupulican/pi-agent-core\";\nimport type { SessionManager } from \"@caupulican/pi-agent-core/node\";\nimport type { AssistantMessage } from \"@caupulican/pi-ai\";\nimport type {\n\tGoalContinuationLoopOptions,\n\tGoalContinuationLoopResult,\n\tGoalContinuationOnceOptions,\n\tGoalContinuationOnceResult,\n\tPromptOptions,\n} from \"../agent-session-contracts.ts\";\nimport type { LaneRecord } from \"../autonomy/lane-tracker.ts\";\nimport { GoalLoopController } from \"../goal-loop-controller.ts\";\nimport type { TaskRuntimeProjection } from \"../orchestration/task-runtime.ts\";\nimport { type GoalStateRevision, getGoalStateRevision, stopGoalFromSystem } from \"./goal-lifecycle.ts\";\nimport {\n\tbuildGoalRuntimeSnapshot,\n\ttype GoalRuntimeSnapshot,\n\ttype GoalRuntimeSnapshotSettings,\n} from \"./goal-runtime-snapshot.ts\";\nimport { applyGoalEvent, type GoalState } from \"./goal-state.ts\";\nimport {\n\tappendGoalClearedSnapshot,\n\tappendGoalStateSnapshot,\n\tgetLatestGoalStateSnapshot,\n} from \"./session-goal-state.ts\";\n\nexport interface GoalSessionControllerDeps {\n\tgetSessionManager(): SessionManager;\n\tgetModelProvider(): string | undefined;\n\tgetLaneRecords(): readonly LaneRecord[];\n\tgetTaskRuntimeSnapshot(): TaskRuntimeProjection | undefined;\n\tsynchronizeGoalState(state: GoalState): void;\n\tscheduleGoalAutoContinueFromIdle(): void;\n\tprompt(text: string, options?: PromptOptions): Promise<void>;\n\temitWarning(message: string): void;\n}\n\n/**\n * Owns durable goal state, exact continuation accounting, and the raw continuation loop. The\n * AgentSession facade supplies process collaborators but no longer implements goal lifecycle rules.\n */\nexport class GoalSessionController {\n\tprivate readonly deps: GoalSessionControllerDeps;\n\tprivate readonly loop: GoalLoopController;\n\n\tconstructor(deps: GoalSessionControllerDeps) {\n\t\tthis.deps = deps;\n\t\tthis.loop = new GoalLoopController({\n\t\t\tgetGoalRuntimeSnapshot: (settings) => this.getRuntimeSnapshot(settings),\n\t\t\tprompt: (text, options) => this.deps.prompt(text, options),\n\t\t\tcaptureUsageCursor: () => this.deps.getSessionManager().getLeafId(),\n\t\t\trecordGoalContinuationPass: (pass) => this.recordContinuationPass(pass),\n\t\t\trecordGoalContinuationFailure: (error) => this.recordContinuationFailure(error),\n\t\t\tmarkGoalBudgetLimited: (reason) => this.markBudgetLimited(reason),\n\t\t});\n\t}\n\n\tsaveState(state: GoalState, expected?: GoalStateRevision): string {\n\t\tconst current = this.getState();\n\t\tif (\n\t\t\texpected &&\n\t\t\t(!current || current.goalId !== expected.goalId || (current.revision ?? 0) !== expected.revision)\n\t\t) {\n\t\t\tthrow new Error(\n\t\t\t\t`Goal state changed concurrently; expected ${expected.goalId}@${expected.revision}, found ${current ? `${current.goalId}@${current.revision ?? 0}` : \"none\"}. Retry against the latest state.`,\n\t\t\t);\n\t\t}\n\t\tconst entryId = appendGoalStateSnapshot(this.deps.getSessionManager(), state, current);\n\t\ttry {\n\t\t\tthis.deps.synchronizeGoalState(state);\n\t\t} catch (error) {\n\t\t\tthis.deps.emitWarning(\n\t\t\t\t`Goal state persisted but durable worker reconciliation failed: ${error instanceof Error ? error.message : String(error)}`,\n\t\t\t);\n\t\t}\n\t\treturn entryId;\n\t}\n\n\tclearState(state: GoalState, now: string): string {\n\t\tconst current = this.getState();\n\t\tconst expected = getGoalStateRevision(state);\n\t\tif (!current || current.goalId !== expected.goalId || (current.revision ?? 0) !== expected.revision) {\n\t\t\tthrow new Error(\"Goal state changed concurrently; retry clear against the latest state.\");\n\t\t}\n\t\tif (state.status !== \"completed\" && state.status !== \"cancelled\") {\n\t\t\tthis.deps.synchronizeGoalState(applyGoalEvent(state, { type: \"cancel_goal\", now }));\n\t\t}\n\t\treturn appendGoalClearedSnapshot(this.deps.getSessionManager(), state, now);\n\t}\n\n\tgetState(): GoalState | undefined {\n\t\treturn getLatestGoalStateSnapshot(this.deps.getSessionManager());\n\t}\n\n\trecordContinuationPass(pass: { turns: number; wallClockMs: number; usageCursor: string | null }): void {\n\t\tconst state = this.getState();\n\t\tif (!state) return;\n\t\tconst branch = this.deps.getSessionManager().getBranch();\n\t\tconst cursorIndex = pass.usageCursor === null ? -1 : branch.findIndex((entry) => entry.id === pass.usageCursor);\n\t\tif (pass.usageCursor !== null && cursorIndex < 0) {\n\t\t\tthis.deps.emitWarning(\n\t\t\t\t\"Goal usage cursor is no longer on the active branch; stopping instead of guessing usage.\",\n\t\t\t);\n\t\t\tthis.recordContinuationFailure(new Error(\"goal_usage_cursor_lost\"));\n\t\t\treturn;\n\t\t}\n\t\tlet tokens = 0;\n\t\tlet spendUsd = 0;\n\t\tfor (const entry of branch.slice(cursorIndex + 1)) {\n\t\t\tif (entry.type !== \"message\" || entry.message.role !== \"assistant\") continue;\n\t\t\tconst usage = (entry.message as AssistantMessage).usage;\n\t\t\ttokens += Math.max(0, usage.input) + Math.max(0, usage.output);\n\t\t\tspendUsd += Math.max(0, usage.cost.total);\n\t\t}\n\t\tconst updated = applyGoalEvent(state, {\n\t\t\ttype: \"record_continuation_budget\",\n\t\t\tturns: pass.turns,\n\t\t\twallClockMs: pass.wallClockMs,\n\t\t\ttokens,\n\t\t\tspendUsd,\n\t\t\tnow: new Date().toISOString(),\n\t\t});\n\t\tthis.saveState(updated, getGoalStateRevision(state));\n\t}\n\n\tmarkToolUnavailable(): void {\n\t\tconst state = this.getState();\n\t\tconst stopped = stopGoalFromSystem(\n\t\t\tstate,\n\t\t\t{\n\t\t\t\tstatus: \"blocked\",\n\t\t\t\treason: \"goal_tool_unavailable: the active capability surface cannot update durable goal state\",\n\t\t\t},\n\t\t\tnew Date().toISOString(),\n\t\t);\n\t\tif (stopped.ok && state) this.saveState(stopped.state, getGoalStateRevision(state));\n\t}\n\n\tgetRuntimeSnapshot(settings: GoalRuntimeSnapshotSettings): GoalRuntimeSnapshot {\n\t\treturn buildGoalRuntimeSnapshot({\n\t\t\tsessionManager: this.deps.getSessionManager(),\n\t\t\tsettings,\n\t\t\tlaneRecords: this.deps.getLaneRecords(),\n\t\t\ttaskRuntime: this.deps.getTaskRuntimeSnapshot(),\n\t\t});\n\t}\n\n\tcontinueOnce(options: GoalContinuationOnceOptions): Promise<GoalContinuationOnceResult> {\n\t\treturn this.loop.continueGoalOnce(options);\n\t}\n\n\tcontinueLoop(options: GoalContinuationLoopOptions): Promise<GoalContinuationLoopResult> {\n\t\treturn this.loop.continueGoalLoop(options);\n\t}\n\n\trestoreAfterResume(): void {\n\t\tthis.deps.scheduleGoalAutoContinueFromIdle();\n\t}\n\n\tprivate recordContinuationFailure(error: unknown): void {\n\t\tconst state = this.getState();\n\t\tif (!state || state.status !== \"active\") return;\n\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\tconst classified = classifyFailure({ message, provider: this.deps.getModelProvider() });\n\t\tconst status = classified.reason === \"billing_or_quota\" ? \"usage_limited\" : \"blocked\";\n\t\tconst stopped = stopGoalFromSystem(\n\t\t\tstate,\n\t\t\t{ status, reason: `${classified.reason}: ${message}` },\n\t\t\tnew Date().toISOString(),\n\t\t);\n\t\tif (stopped.ok) this.saveState(stopped.state, getGoalStateRevision(state));\n\t}\n\n\tprivate markBudgetLimited(reason: string): void {\n\t\tconst state = this.getState();\n\t\tconst stopped = stopGoalFromSystem(state, { status: \"budget_limited\", reason }, new Date().toISOString());\n\t\tif (stopped.ok && state) this.saveState(stopped.state, getGoalStateRevision(state));\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"goal-session-controller.js","sourceRoot":"","sources":["../../../src/core/goals/goal-session-controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAW5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAEhE,OAAO,EAA0B,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACvG,OAAO,EACN,wBAAwB,GAGxB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,cAAc,EAAkB,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzF,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EACN,yBAAyB,EACzB,uBAAuB,EACvB,0BAA0B,GAC1B,MAAM,yBAAyB,CAAC;AAkBjC;;;GAGG;AACH,MAAM,OAAO,qBAAqB;IAIjC,YAAY,IAA+B;QAC1C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,kBAAkB,CAAC;YAClC,sBAAsB,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC;YACvE,MAAM,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC;YAC1D,kBAAkB,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,CAAC,SAAS,EAAE;YACnE,0BAA0B,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC;YACv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CAAC,CAAC,CAAC,SAAS,CAAC;QACtF,MAAM,OAAO,GAAG,kBAAkB,CACjC,KAAK,EACL,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,MAAM,KAAK,OAAO,EAAE,EAAE,EACtD,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CACxB,CAAC;QACF,IAAI,OAAO,CAAC,EAAE;YAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,EAAE,oBAAoB,CAAC,KAAK,CAAC,CAAC,CAAC;IAC5E,CAAC;IAEO,iBAAiB,CAAC,MAAc;QACvC,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;QAC9B,MAAM,OAAO,GAAG,kBAAkB,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC;QAC1G,IAAI,OAAO,CAAC,EAAE,IAAI,KAAK;YAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,EAAE,oBAAoB,CAAC,KAAK,CAAC,CAAC,CAAC;IACrF,CAAC;CACD","sourcesContent":["import { createHash } from \"node:crypto\";\nimport { classifyFailure } from \"@caupulican/pi-agent-core\";\nimport type { SessionManager } from \"@caupulican/pi-agent-core/node\";\nimport type { AssistantMessage } from \"@caupulican/pi-ai\";\nimport type {\n\tGoalContinuationLoopOptions,\n\tGoalContinuationLoopResult,\n\tGoalContinuationOnceOptions,\n\tGoalContinuationOnceResult,\n\tPromptOptions,\n} from \"../agent-session-contracts.ts\";\nimport type { LaneRecord } from \"../autonomy/lane-tracker.ts\";\nimport { GoalLoopController } from \"../goal-loop-controller.ts\";\nimport type { TaskRuntimeProjection } from \"../orchestration/task-runtime.ts\";\nimport { type GoalStateRevision, getGoalStateRevision, stopGoalFromSystem } from \"./goal-lifecycle.ts\";\nimport {\n\tbuildGoalRuntimeSnapshot,\n\ttype GoalRuntimeSnapshot,\n\ttype GoalRuntimeSnapshotSettings,\n} from \"./goal-runtime-snapshot.ts\";\nimport { applyGoalEvent, type GoalState, isGoalUnfinishedStatus } from \"./goal-state.ts\";\nimport { applyGoalAction } from \"./goal-tool-core.ts\";\nimport { parseExplicitChatGoal } from \"./natural-language-goal.ts\";\nimport {\n\tappendGoalClearedSnapshot,\n\tappendGoalStateSnapshot,\n\tgetLatestGoalStateSnapshot,\n} from \"./session-goal-state.ts\";\n\nexport interface GoalSessionControllerDeps {\n\tgetSessionManager(): SessionManager;\n\tgetModelProvider(): string | undefined;\n\tgetLaneRecords(): readonly LaneRecord[];\n\tgetTaskRuntimeSnapshot(): TaskRuntimeProjection | undefined;\n\tsynchronizeGoalState(state: GoalState): void;\n\tscheduleGoalAutoContinueFromIdle(): void;\n\tprompt(text: string, options?: PromptOptions): Promise<void>;\n\temitWarning(message: string): void;\n}\n\nexport type ChatGoalAdmission =\n\t| { status: \"not_explicit\" }\n\t| { status: \"started\"; state: GoalState }\n\t| { status: \"unfinished_goal_exists\"; state: GoalState };\n\n/**\n * Owns durable goal state, exact continuation accounting, and the raw continuation loop. The\n * AgentSession facade supplies process collaborators but no longer implements goal lifecycle rules.\n */\nexport class GoalSessionController {\n\tprivate readonly deps: GoalSessionControllerDeps;\n\tprivate readonly loop: GoalLoopController;\n\n\tconstructor(deps: GoalSessionControllerDeps) {\n\t\tthis.deps = deps;\n\t\tthis.loop = new GoalLoopController({\n\t\t\tgetGoalRuntimeSnapshot: (settings) => this.getRuntimeSnapshot(settings),\n\t\t\tprompt: (text, options) => this.deps.prompt(text, options),\n\t\t\tcaptureUsageCursor: () => this.deps.getSessionManager().getLeafId(),\n\t\t\trecordGoalContinuationPass: (pass) => this.recordContinuationPass(pass),\n\t\t\trecordGoalContinuationFailure: (error) => this.recordContinuationFailure(error),\n\t\t\tmarkGoalBudgetLimited: (reason) => this.markBudgetLimited(reason),\n\t\t});\n\t}\n\n\tsaveState(state: GoalState, expected?: GoalStateRevision): string {\n\t\tconst current = this.getState();\n\t\tif (\n\t\t\texpected &&\n\t\t\t(!current || current.goalId !== expected.goalId || (current.revision ?? 0) !== expected.revision)\n\t\t) {\n\t\t\tthrow new Error(\n\t\t\t\t`Goal state changed concurrently; expected ${expected.goalId}@${expected.revision}, found ${current ? `${current.goalId}@${current.revision ?? 0}` : \"none\"}. Retry against the latest state.`,\n\t\t\t);\n\t\t}\n\t\tconst entryId = appendGoalStateSnapshot(this.deps.getSessionManager(), state, current);\n\t\ttry {\n\t\t\tthis.deps.synchronizeGoalState(state);\n\t\t} catch (error) {\n\t\t\tthis.deps.emitWarning(\n\t\t\t\t`Goal state persisted but durable worker reconciliation failed: ${error instanceof Error ? error.message : String(error)}`,\n\t\t\t);\n\t\t}\n\t\treturn entryId;\n\t}\n\n\tclearState(state: GoalState, now: string): string {\n\t\tconst current = this.getState();\n\t\tconst expected = getGoalStateRevision(state);\n\t\tif (!current || current.goalId !== expected.goalId || (current.revision ?? 0) !== expected.revision) {\n\t\t\tthrow new Error(\"Goal state changed concurrently; retry clear against the latest state.\");\n\t\t}\n\t\tif (state.status !== \"completed\" && state.status !== \"cancelled\") {\n\t\t\tthis.deps.synchronizeGoalState(applyGoalEvent(state, { type: \"cancel_goal\", now }));\n\t\t}\n\t\treturn appendGoalClearedSnapshot(this.deps.getSessionManager(), state, now);\n\t}\n\n\tgetState(): GoalState | undefined {\n\t\treturn getLatestGoalStateSnapshot(this.deps.getSessionManager());\n\t}\n\n\t/**\n\t * Promote high-confidence natural-language persistence into the same durable state written by the\n\t * goal tool. This is intentionally narrower than task detection: ordinary work never starts a\n\t * goal, and an unfinished goal is never replaced implicitly.\n\t */\n\tadmitExplicitChatGoal(text: string, now = new Date().toISOString()): ChatGoalAdmission {\n\t\tconst parsed = parseExplicitChatGoal(text);\n\t\tif (!parsed) return { status: \"not_explicit\" };\n\t\tconst current = this.getState();\n\t\tif (current && isGoalUnfinishedStatus(current.status)) {\n\t\t\treturn { status: \"unfinished_goal_exists\", state: current };\n\t\t}\n\t\tconst digest = createHash(\"sha256\")\n\t\t\t.update(`${now}\\0${current?.goalId ?? \"none\"}\\0${parsed.objective}`)\n\t\t\t.digest(\"hex\")\n\t\t\t.slice(0, 20);\n\t\tconst result = applyGoalAction(\n\t\t\tcurrent,\n\t\t\t{ action: \"start\", goalId: `chat-${digest}`, userGoal: parsed.objective },\n\t\t\tnow,\n\t\t);\n\t\tif (!result.ok) throw new Error(result.error);\n\t\tthis.saveState(result.state, current ? getGoalStateRevision(current) : undefined);\n\t\treturn { status: \"started\", state: result.state };\n\t}\n\n\trecordContinuationPass(pass: { turns: number; wallClockMs: number; usageCursor: string | null }): void {\n\t\tconst state = this.getState();\n\t\tif (!state) return;\n\t\tconst branch = this.deps.getSessionManager().getBranch();\n\t\tconst cursorIndex = pass.usageCursor === null ? -1 : branch.findIndex((entry) => entry.id === pass.usageCursor);\n\t\tif (pass.usageCursor !== null && cursorIndex < 0) {\n\t\t\tthis.deps.emitWarning(\n\t\t\t\t\"Goal usage cursor is no longer on the active branch; stopping instead of guessing usage.\",\n\t\t\t);\n\t\t\tthis.recordContinuationFailure(new Error(\"goal_usage_cursor_lost\"));\n\t\t\treturn;\n\t\t}\n\t\tlet tokens = 0;\n\t\tlet spendUsd = 0;\n\t\tfor (const entry of branch.slice(cursorIndex + 1)) {\n\t\t\tif (entry.type !== \"message\" || entry.message.role !== \"assistant\") continue;\n\t\t\tconst usage = (entry.message as AssistantMessage).usage;\n\t\t\ttokens += Math.max(0, usage.input) + Math.max(0, usage.output);\n\t\t\tspendUsd += Math.max(0, usage.cost.total);\n\t\t}\n\t\tconst updated = applyGoalEvent(state, {\n\t\t\ttype: \"record_continuation_budget\",\n\t\t\tturns: pass.turns,\n\t\t\twallClockMs: pass.wallClockMs,\n\t\t\ttokens,\n\t\t\tspendUsd,\n\t\t\tnow: new Date().toISOString(),\n\t\t});\n\t\tthis.saveState(updated, getGoalStateRevision(state));\n\t}\n\n\tmarkToolUnavailable(): void {\n\t\tconst state = this.getState();\n\t\tconst stopped = stopGoalFromSystem(\n\t\t\tstate,\n\t\t\t{\n\t\t\t\tstatus: \"blocked\",\n\t\t\t\treason: \"goal_tool_unavailable: the active capability surface cannot update durable goal state\",\n\t\t\t},\n\t\t\tnew Date().toISOString(),\n\t\t);\n\t\tif (stopped.ok && state) this.saveState(stopped.state, getGoalStateRevision(state));\n\t}\n\n\tgetRuntimeSnapshot(settings: GoalRuntimeSnapshotSettings): GoalRuntimeSnapshot {\n\t\treturn buildGoalRuntimeSnapshot({\n\t\t\tsessionManager: this.deps.getSessionManager(),\n\t\t\tsettings,\n\t\t\tlaneRecords: this.deps.getLaneRecords(),\n\t\t\ttaskRuntime: this.deps.getTaskRuntimeSnapshot(),\n\t\t});\n\t}\n\n\tcontinueOnce(options: GoalContinuationOnceOptions): Promise<GoalContinuationOnceResult> {\n\t\treturn this.loop.continueGoalOnce(options);\n\t}\n\n\tcontinueLoop(options: GoalContinuationLoopOptions): Promise<GoalContinuationLoopResult> {\n\t\treturn this.loop.continueGoalLoop(options);\n\t}\n\n\trestoreAfterResume(): void {\n\t\tthis.deps.scheduleGoalAutoContinueFromIdle();\n\t}\n\n\tprivate recordContinuationFailure(error: unknown): void {\n\t\tconst state = this.getState();\n\t\tif (!state || state.status !== \"active\") return;\n\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\tconst classified = classifyFailure({ message, provider: this.deps.getModelProvider() });\n\t\tconst status = classified.reason === \"billing_or_quota\" ? \"usage_limited\" : \"blocked\";\n\t\tconst stopped = stopGoalFromSystem(\n\t\t\tstate,\n\t\t\t{ status, reason: `${classified.reason}: ${message}` },\n\t\t\tnew Date().toISOString(),\n\t\t);\n\t\tif (stopped.ok) this.saveState(stopped.state, getGoalStateRevision(state));\n\t}\n\n\tprivate markBudgetLimited(reason: string): void {\n\t\tconst state = this.getState();\n\t\tconst stopped = stopGoalFromSystem(state, { status: \"budget_limited\", reason }, new Date().toISOString());\n\t\tif (stopped.ok && state) this.saveState(stopped.state, getGoalStateRevision(state));\n\t}\n}\n"]}
|