@caupulican/pi-adaptative 0.81.38 → 0.81.40
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 +131 -0
- package/README.md +2 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/README.md +18 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.d.ts +133 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.d.ts.map +1 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.js +198 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.js.map +1 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.ts +311 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.d.ts +31 -2
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.d.ts.map +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.js +823 -79
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.js.map +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.ts +1043 -86
- package/dist/bundled-resources/runtimes/pi-shell-engine/commands/__init__.py +43 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/commands/fs.py +270 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/commands/search.py +252 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/commands/strings.py +399 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/commands/text.py +575 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/context.py +52 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/errors.py +49 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/exec.py +734 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/expand.py +238 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/main.py +132 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/nodes.py +116 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/parser.py +287 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/proc.py +137 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/state.py +100 -0
- package/dist/bundled-resources/runtimes/pi-shell-engine/tokens.py +579 -0
- package/dist/bundled-resources/skills/tool-call-repair/SKILL.md +19 -9
- package/dist/bundled-resources/skills/tool-call-repair/references/failure-grammar.md +22 -5
- package/dist/bundled-resources/skills/tool-call-repair/references/repair-catalogue.md +7 -7
- package/dist/bundled-resources/skills/tool-call-repair/references/text-protocol-grammar.md +28 -7
- package/dist/cli/args.d.ts +5 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +24 -0
- package/dist/cli/args.js.map +1 -1
- package/dist/core/agent-directory-layout.d.ts +15 -0
- package/dist/core/agent-directory-layout.d.ts.map +1 -0
- package/dist/core/agent-directory-layout.js +72 -0
- package/dist/core/agent-directory-layout.js.map +1 -0
- package/dist/core/agent-paths.d.ts +66 -0
- package/dist/core/agent-paths.d.ts.map +1 -0
- package/dist/core/agent-paths.js +170 -0
- package/dist/core/agent-paths.js.map +1 -0
- package/dist/core/agent-session-runtime.d.ts +52 -8
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +397 -79
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-services.d.ts +1 -0
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +4 -3
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session.d.ts +255 -103
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +754 -1173
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/autonomy/approval-gate.d.ts +3 -2
- package/dist/core/autonomy/approval-gate.d.ts.map +1 -1
- package/dist/core/autonomy/approval-gate.js +6 -28
- package/dist/core/autonomy/approval-gate.js.map +1 -1
- package/dist/core/autonomy/bounded-completion.d.ts +1 -1
- package/dist/core/autonomy/bounded-completion.d.ts.map +1 -1
- package/dist/core/autonomy/bounded-completion.js +1 -1
- package/dist/core/autonomy/bounded-completion.js.map +1 -1
- package/dist/core/autonomy/contracts.d.ts +26 -9
- package/dist/core/autonomy/contracts.d.ts.map +1 -1
- package/dist/core/autonomy/contracts.js.map +1 -1
- package/dist/core/autonomy/foreground-envelope.d.ts +8 -2
- package/dist/core/autonomy/foreground-envelope.d.ts.map +1 -1
- package/dist/core/autonomy/foreground-envelope.js +8 -25
- package/dist/core/autonomy/foreground-envelope.js.map +1 -1
- package/dist/core/autonomy/gates.d.ts.map +1 -1
- package/dist/core/autonomy/gates.js +8 -10
- package/dist/core/autonomy/gates.js.map +1 -1
- package/dist/core/autonomy/lane-private-paths.d.ts +2 -0
- package/dist/core/autonomy/lane-private-paths.d.ts.map +1 -0
- package/dist/core/autonomy/lane-private-paths.js +16 -0
- package/dist/core/autonomy/lane-private-paths.js.map +1 -0
- package/dist/core/autonomy/lane-tool-surface.d.ts +10 -0
- package/dist/core/autonomy/lane-tool-surface.d.ts.map +1 -1
- package/dist/core/autonomy/lane-tool-surface.js +46 -8
- package/dist/core/autonomy/lane-tool-surface.js.map +1 -1
- package/dist/core/autonomy/lane-tracker.d.ts +24 -1
- package/dist/core/autonomy/lane-tracker.d.ts.map +1 -1
- package/dist/core/autonomy/lane-tracker.js +43 -1
- package/dist/core/autonomy/lane-tracker.js.map +1 -1
- package/dist/core/autonomy/risk-assessment.d.ts +1 -2
- package/dist/core/autonomy/risk-assessment.d.ts.map +1 -1
- package/dist/core/autonomy/risk-assessment.js +1 -123
- package/dist/core/autonomy/risk-assessment.js.map +1 -1
- package/dist/core/autonomy/session-lane-record.d.ts +4 -4
- package/dist/core/autonomy/session-lane-record.d.ts.map +1 -1
- package/dist/core/autonomy/session-lane-record.js +16 -29
- package/dist/core/autonomy/session-lane-record.js.map +1 -1
- package/dist/core/autonomy/telemetry-events.d.ts +1 -1
- package/dist/core/autonomy/telemetry-events.d.ts.map +1 -1
- package/dist/core/autonomy/telemetry-events.js +1 -1
- package/dist/core/autonomy/telemetry-events.js.map +1 -1
- package/dist/core/autonomy-telemetry.d.ts +7 -7
- package/dist/core/autonomy-telemetry.d.ts.map +1 -1
- package/dist/core/autonomy-telemetry.js +9 -9
- package/dist/core/autonomy-telemetry.js.map +1 -1
- package/dist/core/background-lane-controller.d.ts +90 -156
- package/dist/core/background-lane-controller.d.ts.map +1 -1
- package/dist/core/background-lane-controller.js +192 -968
- package/dist/core/background-lane-controller.js.map +1 -1
- package/dist/core/bash-execution-controller.d.ts +4 -0
- package/dist/core/bash-execution-controller.d.ts.map +1 -1
- package/dist/core/bash-execution-controller.js +7 -1
- package/dist/core/bash-execution-controller.js.map +1 -1
- package/dist/core/capability-contract.d.ts +4 -0
- package/dist/core/capability-contract.d.ts.map +1 -0
- package/dist/core/capability-contract.js +28 -0
- package/dist/core/capability-contract.js.map +1 -0
- package/dist/core/compaction-controller.d.ts +90 -0
- package/dist/core/compaction-controller.d.ts.map +1 -0
- package/dist/core/compaction-controller.js +452 -0
- package/dist/core/compaction-controller.js.map +1 -0
- package/dist/core/compaction-support.d.ts +24 -13
- package/dist/core/compaction-support.d.ts.map +1 -1
- package/dist/core/compaction-support.js +43 -7
- package/dist/core/compaction-support.js.map +1 -1
- package/dist/core/context/context-artifacts.d.ts +6 -2
- package/dist/core/context/context-artifacts.d.ts.map +1 -1
- package/dist/core/context/context-artifacts.js +34 -2
- package/dist/core/context/context-artifacts.js.map +1 -1
- package/dist/core/context/context-audit.d.ts +33 -1
- package/dist/core/context/context-audit.d.ts.map +1 -1
- package/dist/core/context/context-audit.js +31 -5
- package/dist/core/context/context-audit.js.map +1 -1
- package/dist/core/context/context-store-retention.d.ts +8 -2
- package/dist/core/context/context-store-retention.d.ts.map +1 -1
- package/dist/core/context/context-store-retention.js +158 -35
- package/dist/core/context/context-store-retention.js.map +1 -1
- package/dist/core/context/okf-memory.d.ts.map +1 -1
- package/dist/core/context/okf-memory.js +9 -11
- package/dist/core/context/okf-memory.js.map +1 -1
- package/dist/core/context/sqlite-runtime-index.d.ts.map +1 -1
- package/dist/core/context/sqlite-runtime-index.js +6 -8
- package/dist/core/context/sqlite-runtime-index.js.map +1 -1
- package/dist/core/context-gc.d.ts +3 -0
- package/dist/core/context-gc.d.ts.map +1 -1
- package/dist/core/context-gc.js +26 -6
- package/dist/core/context-gc.js.map +1 -1
- package/dist/core/context-pipeline.d.ts +26 -4
- package/dist/core/context-pipeline.d.ts.map +1 -1
- package/dist/core/context-pipeline.js +146 -18
- package/dist/core/context-pipeline.js.map +1 -1
- package/dist/core/cost-guard.d.ts +19 -3
- package/dist/core/cost-guard.d.ts.map +1 -1
- package/dist/core/cost-guard.js +18 -3
- 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/delegation/managed-lane-controller.d.ts +34 -0
- package/dist/core/delegation/managed-lane-controller.d.ts.map +1 -0
- package/dist/core/delegation/managed-lane-controller.js +217 -0
- package/dist/core/delegation/managed-lane-controller.js.map +1 -0
- package/dist/core/delegation/session-worker-claim.d.ts +44 -0
- package/dist/core/delegation/session-worker-claim.d.ts.map +1 -0
- package/dist/core/delegation/session-worker-claim.js +98 -0
- package/dist/core/delegation/session-worker-claim.js.map +1 -0
- package/dist/core/delegation/worker-actions.d.ts +7 -5
- package/dist/core/delegation/worker-actions.d.ts.map +1 -1
- package/dist/core/delegation/worker-actions.js +20 -4
- package/dist/core/delegation/worker-actions.js.map +1 -1
- package/dist/core/delegation/worker-claim.d.ts +56 -0
- package/dist/core/delegation/worker-claim.d.ts.map +1 -0
- package/dist/core/delegation/worker-claim.js +239 -0
- package/dist/core/delegation/worker-claim.js.map +1 -0
- package/dist/core/delegation/worker-delegation-controller.d.ts +110 -0
- package/dist/core/delegation/worker-delegation-controller.d.ts.map +1 -0
- package/dist/core/delegation/worker-delegation-controller.js +861 -0
- package/dist/core/delegation/worker-delegation-controller.js.map +1 -0
- package/dist/core/delegation/worker-delegation-request.d.ts +11 -0
- package/dist/core/delegation/worker-delegation-request.d.ts.map +1 -0
- package/dist/core/delegation/worker-delegation-request.js +2 -0
- package/dist/core/delegation/worker-delegation-request.js.map +1 -0
- package/dist/core/delegation/worker-dispatch-scheduler.d.ts +40 -0
- package/dist/core/delegation/worker-dispatch-scheduler.d.ts.map +1 -0
- package/dist/core/delegation/worker-dispatch-scheduler.js +93 -0
- package/dist/core/delegation/worker-dispatch-scheduler.js.map +1 -0
- package/dist/core/delegation/worker-execution-policy.d.ts +62 -0
- package/dist/core/delegation/worker-execution-policy.d.ts.map +1 -0
- package/dist/core/delegation/worker-execution-policy.js +160 -0
- package/dist/core/delegation/worker-execution-policy.js.map +1 -0
- package/dist/core/delegation/worker-lane-projection.d.ts +14 -0
- package/dist/core/delegation/worker-lane-projection.d.ts.map +1 -0
- package/dist/core/delegation/worker-lane-projection.js +100 -0
- package/dist/core/delegation/worker-lane-projection.js.map +1 -0
- package/dist/core/delegation/worker-lifecycle.d.ts +97 -0
- package/dist/core/delegation/worker-lifecycle.d.ts.map +1 -0
- package/dist/core/delegation/worker-lifecycle.js +339 -0
- package/dist/core/delegation/worker-lifecycle.js.map +1 -0
- package/dist/core/delegation/worker-notification-coordinator.d.ts +36 -0
- package/dist/core/delegation/worker-notification-coordinator.d.ts.map +1 -0
- package/dist/core/delegation/worker-notification-coordinator.js +90 -0
- package/dist/core/delegation/worker-notification-coordinator.js.map +1 -0
- package/dist/core/delegation/worker-profile-resolver.d.ts +55 -0
- package/dist/core/delegation/worker-profile-resolver.d.ts.map +1 -0
- package/dist/core/delegation/worker-profile-resolver.js +113 -0
- package/dist/core/delegation/worker-profile-resolver.js.map +1 -0
- package/dist/core/delegation/worker-runner.d.ts +25 -14
- package/dist/core/delegation/worker-runner.d.ts.map +1 -1
- package/dist/core/delegation/worker-runner.js +122 -53
- package/dist/core/delegation/worker-runner.js.map +1 -1
- package/dist/core/delegation/worker-task-label.d.ts +3 -0
- package/dist/core/delegation/worker-task-label.d.ts.map +1 -0
- package/dist/core/delegation/worker-task-label.js +11 -0
- package/dist/core/delegation/worker-task-label.js.map +1 -0
- package/dist/core/doctor.d.ts +8 -0
- package/dist/core/doctor.d.ts.map +1 -1
- package/dist/core/doctor.js +32 -1
- package/dist/core/doctor.js.map +1 -1
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/loader.d.ts +5 -1
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +68 -13
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +7 -0
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/storage.d.ts +8 -0
- package/dist/core/extensions/storage.d.ts.map +1 -0
- package/dist/core/extensions/storage.js +28 -0
- package/dist/core/extensions/storage.js.map +1 -0
- package/dist/core/extensions/types.d.ts +101 -1
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/failure-corpus.d.ts +1 -15
- package/dist/core/failure-corpus.d.ts.map +1 -1
- package/dist/core/failure-corpus.js +9 -37
- package/dist/core/failure-corpus.js.map +1 -1
- package/dist/core/foreground-recovery-controller.d.ts +52 -0
- package/dist/core/foreground-recovery-controller.d.ts.map +1 -0
- package/dist/core/foreground-recovery-controller.js +111 -0
- package/dist/core/foreground-recovery-controller.js.map +1 -0
- package/dist/core/gateways/channel-provider.d.ts +3 -0
- package/dist/core/gateways/channel-provider.d.ts.map +1 -1
- package/dist/core/gateways/channel-provider.js +31 -6
- package/dist/core/gateways/channel-provider.js.map +1 -1
- package/dist/core/goal-loop-controller.d.ts +17 -1
- package/dist/core/goal-loop-controller.d.ts.map +1 -1
- package/dist/core/goal-loop-controller.js +79 -11
- package/dist/core/goal-loop-controller.js.map +1 -1
- package/dist/core/goals/goal-acceptance.d.ts +11 -0
- package/dist/core/goals/goal-acceptance.d.ts.map +1 -0
- package/dist/core/goals/goal-acceptance.js +25 -0
- package/dist/core/goals/goal-acceptance.js.map +1 -0
- package/dist/core/goals/goal-auto-continue-controller.d.ts +27 -0
- package/dist/core/goals/goal-auto-continue-controller.d.ts.map +1 -0
- package/dist/core/goals/goal-auto-continue-controller.js +93 -0
- package/dist/core/goals/goal-auto-continue-controller.js.map +1 -0
- package/dist/core/goals/goal-continuation-controller.d.ts +48 -2
- package/dist/core/goals/goal-continuation-controller.d.ts.map +1 -1
- package/dist/core/goals/goal-continuation-controller.js +87 -0
- package/dist/core/goals/goal-continuation-controller.js.map +1 -1
- package/dist/core/goals/goal-continuation-defaults.d.ts +39 -0
- package/dist/core/goals/goal-continuation-defaults.d.ts.map +1 -1
- package/dist/core/goals/goal-continuation-defaults.js +42 -0
- package/dist/core/goals/goal-continuation-defaults.js.map +1 -1
- package/dist/core/goals/goal-continuation-prompt.d.ts +5 -1
- package/dist/core/goals/goal-continuation-prompt.d.ts.map +1 -1
- package/dist/core/goals/goal-continuation-prompt.js +56 -15
- package/dist/core/goals/goal-continuation-prompt.js.map +1 -1
- package/dist/core/goals/goal-lifecycle.d.ts +20 -0
- package/dist/core/goals/goal-lifecycle.d.ts.map +1 -0
- package/dist/core/goals/goal-lifecycle.js +17 -0
- package/dist/core/goals/goal-lifecycle.js.map +1 -0
- package/dist/core/goals/goal-runtime-snapshot.d.ts +105 -4
- package/dist/core/goals/goal-runtime-snapshot.d.ts.map +1 -1
- package/dist/core/goals/goal-runtime-snapshot.js +91 -6
- package/dist/core/goals/goal-runtime-snapshot.js.map +1 -1
- package/dist/core/goals/goal-state.d.ts +90 -1
- package/dist/core/goals/goal-state.d.ts.map +1 -1
- package/dist/core/goals/goal-state.js +78 -15
- package/dist/core/goals/goal-state.js.map +1 -1
- package/dist/core/goals/goal-tool-core.d.ts +58 -2
- package/dist/core/goals/goal-tool-core.d.ts.map +1 -1
- package/dist/core/goals/goal-tool-core.js +82 -6
- package/dist/core/goals/goal-tool-core.js.map +1 -1
- package/dist/core/goals/session-goal-state.d.ts +13 -6
- package/dist/core/goals/session-goal-state.d.ts.map +1 -1
- package/dist/core/goals/session-goal-state.js +20 -28
- package/dist/core/goals/session-goal-state.js.map +1 -1
- package/dist/core/human-input.d.ts +100 -0
- package/dist/core/human-input.d.ts.map +1 -0
- package/dist/core/human-input.js +362 -0
- package/dist/core/human-input.js.map +1 -0
- package/dist/core/index.d.ts +9 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +9 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/{telemetry.d.ts → install-telemetry.d.ts} +1 -1
- package/dist/core/install-telemetry.d.ts.map +1 -0
- package/dist/core/{telemetry.js → install-telemetry.js} +1 -1
- package/dist/core/install-telemetry.js.map +1 -0
- package/dist/core/keybindings.d.ts +27 -1
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +34 -8
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/learning/learning-audit.d.ts +2 -4
- package/dist/core/learning/learning-audit.d.ts.map +1 -1
- package/dist/core/learning/learning-audit.js +9 -29
- package/dist/core/learning/learning-audit.js.map +1 -1
- package/dist/core/learning/learning-gate.d.ts.map +1 -1
- package/dist/core/learning/learning-gate.js +1 -6
- package/dist/core/learning/learning-gate.js.map +1 -1
- package/dist/core/learning/observation-store.d.ts +12 -3
- package/dist/core/learning/observation-store.d.ts.map +1 -1
- package/dist/core/learning/observation-store.js +30 -15
- package/dist/core/learning/observation-store.js.map +1 -1
- package/dist/core/learning/session-learning-decision.d.ts +2 -4
- package/dist/core/learning/session-learning-decision.d.ts.map +1 -1
- package/dist/core/learning/session-learning-decision.js +9 -29
- package/dist/core/learning/session-learning-decision.js.map +1 -1
- package/dist/core/learning/skill-curator.d.ts +5 -1
- package/dist/core/learning/skill-curator.d.ts.map +1 -1
- package/dist/core/learning/skill-curator.js +21 -19
- package/dist/core/learning/skill-curator.js.map +1 -1
- package/dist/core/local-runtime-controller.d.ts +65 -3
- package/dist/core/local-runtime-controller.d.ts.map +1 -1
- package/dist/core/local-runtime-controller.js +186 -26
- package/dist/core/local-runtime-controller.js.map +1 -1
- package/dist/core/memory/providers/file-store.d.ts +1 -1
- package/dist/core/memory/providers/file-store.d.ts.map +1 -1
- package/dist/core/memory/providers/file-store.js +6 -6
- package/dist/core/memory/providers/file-store.js.map +1 -1
- package/dist/core/memory-controller.d.ts.map +1 -1
- package/dist/core/memory-controller.js +4 -4
- package/dist/core/memory-controller.js.map +1 -1
- package/dist/core/model-capability.d.ts +34 -0
- package/dist/core/model-capability.d.ts.map +1 -1
- package/dist/core/model-capability.js +43 -1
- package/dist/core/model-capability.js.map +1 -1
- package/dist/core/model-resolver.d.ts +1 -1
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +6 -9
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/model-router/intent-classifier.d.ts +1 -4
- package/dist/core/model-router/intent-classifier.d.ts.map +1 -1
- package/dist/core/model-router/intent-classifier.js +1 -156
- package/dist/core/model-router/intent-classifier.js.map +1 -1
- package/dist/core/model-router/tool-escalation.d.ts +15 -0
- package/dist/core/model-router/tool-escalation.d.ts.map +1 -1
- package/dist/core/model-router/tool-escalation.js +23 -1
- package/dist/core/model-router/tool-escalation.js.map +1 -1
- package/dist/core/model-router-controller.d.ts +34 -7
- package/dist/core/model-router-controller.d.ts.map +1 -1
- package/dist/core/model-router-controller.js +95 -16
- package/dist/core/model-router-controller.js.map +1 -1
- package/dist/core/model-selection-controller.d.ts +4 -4
- package/dist/core/model-selection-controller.d.ts.map +1 -1
- package/dist/core/model-selection-controller.js.map +1 -1
- package/dist/core/model-tool-protocol.d.ts +23 -0
- package/dist/core/model-tool-protocol.d.ts.map +1 -0
- package/dist/core/model-tool-protocol.js +43 -0
- package/dist/core/model-tool-protocol.js.map +1 -0
- package/dist/core/models/adaptation-store.d.ts +10 -5
- package/dist/core/models/adaptation-store.d.ts.map +1 -1
- package/dist/core/models/adaptation-store.js +129 -81
- package/dist/core/models/adaptation-store.js.map +1 -1
- package/dist/core/models/default-model-suggestions.d.ts.map +1 -1
- package/dist/core/models/default-model-suggestions.js +17 -0
- package/dist/core/models/default-model-suggestions.js.map +1 -1
- package/dist/core/models/fitness-store.d.ts +4 -11
- package/dist/core/models/fitness-store.d.ts.map +1 -1
- package/dist/core/models/fitness-store.js +87 -51
- package/dist/core/models/fitness-store.js.map +1 -1
- package/dist/core/models/host-state-store.d.ts +34 -0
- package/dist/core/models/host-state-store.d.ts.map +1 -0
- package/dist/core/models/host-state-store.js +86 -0
- package/dist/core/models/host-state-store.js.map +1 -0
- package/dist/core/models/llamacpp-runtime.d.ts +180 -0
- package/dist/core/models/llamacpp-runtime.d.ts.map +1 -0
- package/dist/core/models/llamacpp-runtime.js +475 -0
- package/dist/core/models/llamacpp-runtime.js.map +1 -0
- package/dist/core/models/local-registration.d.ts +40 -0
- package/dist/core/models/local-registration.d.ts.map +1 -1
- package/dist/core/models/local-registration.js +94 -5
- package/dist/core/models/local-registration.js.map +1 -1
- package/dist/core/models/local-runtime.d.ts.map +1 -1
- package/dist/core/models/local-runtime.js +6 -5
- package/dist/core/models/local-runtime.js.map +1 -1
- package/dist/core/models/model-ref.d.ts +7 -0
- package/dist/core/models/model-ref.d.ts.map +1 -1
- package/dist/core/models/model-ref.js +26 -0
- package/dist/core/models/model-ref.js.map +1 -1
- package/dist/core/models/needle-runtime.d.ts +257 -0
- package/dist/core/models/needle-runtime.d.ts.map +1 -0
- package/dist/core/models/needle-runtime.js +519 -0
- package/dist/core/models/needle-runtime.js.map +1 -0
- package/dist/core/models/prism-llamacpp-lifecycle.d.ts +89 -0
- package/dist/core/models/prism-llamacpp-lifecycle.d.ts.map +1 -0
- package/dist/core/models/prism-llamacpp-lifecycle.js +121 -0
- package/dist/core/models/prism-llamacpp-lifecycle.js.map +1 -0
- package/dist/core/orchestration/agent-resume.d.ts +24 -0
- package/dist/core/orchestration/agent-resume.d.ts.map +1 -0
- package/dist/core/orchestration/agent-resume.js +90 -0
- package/dist/core/orchestration/agent-resume.js.map +1 -0
- package/dist/core/orchestration/capability-gateway.d.ts +61 -0
- package/dist/core/orchestration/capability-gateway.d.ts.map +1 -0
- package/dist/core/orchestration/capability-gateway.js +152 -0
- package/dist/core/orchestration/capability-gateway.js.map +1 -0
- package/dist/core/orchestration/contracts.d.ts +343 -0
- package/dist/core/orchestration/contracts.d.ts.map +1 -0
- package/dist/core/orchestration/contracts.js +135 -0
- package/dist/core/orchestration/contracts.js.map +1 -0
- package/dist/core/orchestration/delegation-ledger.d.ts +56 -0
- package/dist/core/orchestration/delegation-ledger.d.ts.map +1 -0
- package/dist/core/orchestration/delegation-ledger.js +197 -0
- package/dist/core/orchestration/delegation-ledger.js.map +1 -0
- package/dist/core/orchestration/event-store.d.ts +83 -0
- package/dist/core/orchestration/event-store.d.ts.map +1 -0
- package/dist/core/orchestration/event-store.js +560 -0
- package/dist/core/orchestration/event-store.js.map +1 -0
- package/dist/core/orchestration/lane-tool-manifests.d.ts +9 -0
- package/dist/core/orchestration/lane-tool-manifests.d.ts.map +1 -0
- package/dist/core/orchestration/lane-tool-manifests.js +37 -0
- package/dist/core/orchestration/lane-tool-manifests.js.map +1 -0
- package/dist/core/orchestration/model-binding.d.ts +15 -0
- package/dist/core/orchestration/model-binding.d.ts.map +1 -0
- package/dist/core/orchestration/model-binding.js +29 -0
- package/dist/core/orchestration/model-binding.js.map +1 -0
- package/dist/core/orchestration/policy-compiler.d.ts +49 -0
- package/dist/core/orchestration/policy-compiler.d.ts.map +1 -0
- package/dist/core/orchestration/policy-compiler.js +191 -0
- package/dist/core/orchestration/policy-compiler.js.map +1 -0
- package/dist/core/orchestration/policy-gate.d.ts +18 -0
- package/dist/core/orchestration/policy-gate.d.ts.map +1 -0
- package/dist/core/orchestration/policy-gate.js +24 -0
- package/dist/core/orchestration/policy-gate.js.map +1 -0
- package/dist/core/orchestration/profile-registry.d.ts +51 -0
- package/dist/core/orchestration/profile-registry.d.ts.map +1 -0
- package/dist/core/orchestration/profile-registry.js +393 -0
- package/dist/core/orchestration/profile-registry.js.map +1 -0
- package/dist/core/orchestration/profile-store.d.ts +31 -0
- package/dist/core/orchestration/profile-store.d.ts.map +1 -0
- package/dist/core/orchestration/profile-store.js +136 -0
- package/dist/core/orchestration/profile-store.js.map +1 -0
- package/dist/core/orchestration/risk-budget.d.ts +9 -0
- package/dist/core/orchestration/risk-budget.d.ts.map +1 -0
- package/dist/core/orchestration/risk-budget.js +48 -0
- package/dist/core/orchestration/risk-budget.js.map +1 -0
- package/dist/core/orchestration/task-runtime.d.ts +168 -0
- package/dist/core/orchestration/task-runtime.d.ts.map +1 -0
- package/dist/core/orchestration/task-runtime.js +1600 -0
- package/dist/core/orchestration/task-runtime.js.map +1 -0
- package/dist/core/orchestration/work-state-projection.d.ts +32 -0
- package/dist/core/orchestration/work-state-projection.d.ts.map +1 -0
- package/dist/core/orchestration/work-state-projection.js +116 -0
- package/dist/core/orchestration/work-state-projection.js.map +1 -0
- package/dist/core/orchestration/worker-execution-contract.d.ts +21 -0
- package/dist/core/orchestration/worker-execution-contract.d.ts.map +1 -0
- package/dist/core/orchestration/worker-execution-contract.js +179 -0
- package/dist/core/orchestration/worker-execution-contract.js.map +1 -0
- package/dist/core/orchestration/worker-result-adapter.d.ts +21 -0
- package/dist/core/orchestration/worker-result-adapter.d.ts.map +1 -0
- package/dist/core/orchestration/worker-result-adapter.js +109 -0
- package/dist/core/orchestration/worker-result-adapter.js.map +1 -0
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +11 -10
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/process-identity.d.ts +11 -0
- package/dist/core/process-identity.d.ts.map +1 -0
- package/dist/core/process-identity.js +26 -0
- package/dist/core/process-identity.js.map +1 -0
- package/dist/core/process-matrix/codes.d.ts +83 -0
- package/dist/core/process-matrix/codes.d.ts.map +1 -0
- package/dist/core/process-matrix/codes.js +15 -0
- package/dist/core/process-matrix/codes.js.map +1 -0
- package/dist/core/process-matrix/resume-launcher.d.ts +26 -0
- package/dist/core/process-matrix/resume-launcher.d.ts.map +1 -0
- package/dist/core/process-matrix/resume-launcher.js +62 -0
- package/dist/core/process-matrix/resume-launcher.js.map +1 -0
- package/dist/core/process-matrix/runtime.d.ts +78 -0
- package/dist/core/process-matrix/runtime.d.ts.map +1 -0
- package/dist/core/process-matrix/runtime.js +633 -0
- package/dist/core/process-matrix/runtime.js.map +1 -0
- package/dist/core/process-matrix/store.d.ts +25 -0
- package/dist/core/process-matrix/store.d.ts.map +1 -0
- package/dist/core/process-matrix/store.js +189 -0
- package/dist/core/process-matrix/store.js.map +1 -0
- package/dist/core/process-matrix/supervisor.d.ts +75 -0
- package/dist/core/process-matrix/supervisor.d.ts.map +1 -0
- package/dist/core/process-matrix/supervisor.js +161 -0
- package/dist/core/process-matrix/supervisor.js.map +1 -0
- package/dist/core/profile-registry.d.ts +7 -0
- package/dist/core/profile-registry.d.ts.map +1 -1
- package/dist/core/profile-registry.js +25 -7
- package/dist/core/profile-registry.js.map +1 -1
- package/dist/core/python-runtime.d.ts.map +1 -1
- package/dist/core/python-runtime.js +3 -3
- package/dist/core/python-runtime.js.map +1 -1
- package/dist/core/reflection-controller.d.ts +33 -9
- package/dist/core/reflection-controller.d.ts.map +1 -1
- package/dist/core/reflection-controller.js +217 -127
- package/dist/core/reflection-controller.js.map +1 -1
- package/dist/core/reload-blockers.d.ts +36 -0
- package/dist/core/reload-blockers.d.ts.map +1 -1
- package/dist/core/reload-blockers.js +50 -8
- package/dist/core/reload-blockers.js.map +1 -1
- package/dist/core/research/evidence-bundle.d.ts.map +1 -1
- package/dist/core/research/evidence-bundle.js +1 -6
- package/dist/core/research/evidence-bundle.js.map +1 -1
- package/dist/core/research/lane-model-resolver.d.ts +33 -0
- package/dist/core/research/lane-model-resolver.d.ts.map +1 -0
- package/dist/core/research/lane-model-resolver.js +65 -0
- package/dist/core/research/lane-model-resolver.js.map +1 -0
- package/dist/core/research/model-fitness-controller.d.ts +38 -0
- package/dist/core/research/model-fitness-controller.d.ts.map +1 -0
- package/dist/core/research/model-fitness-controller.js +106 -0
- package/dist/core/research/model-fitness-controller.js.map +1 -0
- package/dist/core/research/model-fitness.d.ts +1 -1
- package/dist/core/research/model-fitness.d.ts.map +1 -1
- package/dist/core/research/model-fitness.js +4 -4
- package/dist/core/research/model-fitness.js.map +1 -1
- package/dist/core/research/research-gate.d.ts.map +1 -1
- package/dist/core/research/research-gate.js +7 -7
- package/dist/core/research/research-gate.js.map +1 -1
- package/dist/core/research/research-lane-controller.d.ts +62 -0
- package/dist/core/research/research-lane-controller.d.ts.map +1 -0
- package/dist/core/research/research-lane-controller.js +292 -0
- package/dist/core/research/research-lane-controller.js.map +1 -0
- package/dist/core/research/session-evidence-bundle.d.ts +2 -4
- package/dist/core/research/session-evidence-bundle.d.ts.map +1 -1
- package/dist/core/research/session-evidence-bundle.js +10 -46
- package/dist/core/research/session-evidence-bundle.js.map +1 -1
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +15 -9
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/risk-classifier.d.ts +6 -0
- package/dist/core/risk-classifier.d.ts.map +1 -0
- package/dist/core/risk-classifier.js +225 -0
- package/dist/core/risk-classifier.js.map +1 -0
- package/dist/core/runtime-builder.d.ts +76 -17
- package/dist/core/runtime-builder.d.ts.map +1 -1
- package/dist/core/runtime-builder.js +367 -124
- package/dist/core/runtime-builder.js.map +1 -1
- package/dist/core/scout-controller.d.ts +6 -0
- package/dist/core/scout-controller.d.ts.map +1 -1
- package/dist/core/scout-controller.js +66 -52
- package/dist/core/scout-controller.js.map +1 -1
- package/dist/core/sdk.d.ts +6 -3
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +64 -27
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-analytics.d.ts.map +1 -1
- package/dist/core/session-analytics.js +28 -1
- package/dist/core/session-analytics.js.map +1 -1
- package/dist/core/session-image-store.d.ts +33 -0
- package/dist/core/session-image-store.d.ts.map +1 -0
- package/dist/core/session-image-store.js +283 -0
- package/dist/core/session-image-store.js.map +1 -0
- package/dist/core/session-role.d.ts +33 -0
- package/dist/core/session-role.d.ts.map +1 -0
- package/dist/core/session-role.js +58 -0
- package/dist/core/session-role.js.map +1 -0
- package/dist/core/session-snapshot.d.ts +34 -0
- package/dist/core/session-snapshot.d.ts.map +1 -0
- package/dist/core/session-snapshot.js +68 -0
- package/dist/core/session-snapshot.js.map +1 -0
- package/dist/core/session-supervision-runtime.d.ts +31 -0
- package/dist/core/session-supervision-runtime.d.ts.map +1 -0
- package/dist/core/session-supervision-runtime.js +97 -0
- package/dist/core/session-supervision-runtime.js.map +1 -0
- package/dist/core/settings-manager.d.ts +51 -7
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +168 -82
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/system-prompt-builder.d.ts +12 -0
- package/dist/core/system-prompt-builder.d.ts.map +1 -1
- package/dist/core/system-prompt-builder.js +6 -0
- package/dist/core/system-prompt-builder.js.map +1 -1
- package/dist/core/system-prompt.d.ts +14 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +20 -3
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tasks/session-task-state.d.ts +13 -6
- package/dist/core/tasks/session-task-state.d.ts.map +1 -1
- package/dist/core/tasks/session-task-state.js +20 -22
- package/dist/core/tasks/session-task-state.js.map +1 -1
- package/dist/core/tasks/task-contract-monitor.d.ts +45 -0
- package/dist/core/tasks/task-contract-monitor.d.ts.map +1 -0
- package/dist/core/tasks/task-contract-monitor.js +56 -0
- package/dist/core/tasks/task-contract-monitor.js.map +1 -0
- package/dist/core/tasks/task-projection.d.ts +20 -0
- package/dist/core/tasks/task-projection.d.ts.map +1 -0
- package/dist/core/tasks/task-projection.js +47 -0
- package/dist/core/tasks/task-projection.js.map +1 -0
- package/dist/core/tasks/task-state.d.ts +12 -0
- package/dist/core/tasks/task-state.d.ts.map +1 -1
- package/dist/core/tasks/task-state.js +56 -12
- package/dist/core/tasks/task-state.js.map +1 -1
- package/dist/core/tool-capability-policy.d.ts +13 -0
- package/dist/core/tool-capability-policy.d.ts.map +1 -0
- package/dist/core/tool-capability-policy.js +85 -0
- package/dist/core/tool-capability-policy.js.map +1 -0
- package/dist/core/tool-gate-controller.d.ts.map +1 -1
- package/dist/core/tool-gate-controller.js +5 -0
- package/dist/core/tool-gate-controller.js.map +1 -1
- package/dist/core/tool-protocol-controller.d.ts +91 -0
- package/dist/core/tool-protocol-controller.d.ts.map +1 -0
- package/dist/core/tool-protocol-controller.js +512 -0
- package/dist/core/tool-protocol-controller.js.map +1 -0
- package/dist/core/tool-recovery-log-records.d.ts +6 -0
- package/dist/core/tool-recovery-log-records.d.ts.map +1 -1
- package/dist/core/tool-recovery-log-records.js +13 -31
- package/dist/core/tool-recovery-log-records.js.map +1 -1
- package/dist/core/tool-selection/promotion.d.ts +54 -0
- package/dist/core/tool-selection/promotion.d.ts.map +1 -0
- package/dist/core/tool-selection/promotion.js +81 -0
- package/dist/core/tool-selection/promotion.js.map +1 -0
- package/dist/core/tool-selection/tool-performance-store.d.ts +39 -6
- package/dist/core/tool-selection/tool-performance-store.d.ts.map +1 -1
- package/dist/core/tool-selection/tool-performance-store.js +153 -110
- package/dist/core/tool-selection/tool-performance-store.js.map +1 -1
- package/dist/core/tool-selection/tool-selection-controller.d.ts +45 -0
- package/dist/core/tool-selection/tool-selection-controller.d.ts.map +1 -1
- package/dist/core/tool-selection/tool-selection-controller.js +96 -0
- package/dist/core/tool-selection/tool-selection-controller.js.map +1 -1
- package/dist/core/tools/ask-question.d.ts +124 -0
- package/dist/core/tools/ask-question.d.ts.map +1 -0
- package/dist/core/tools/ask-question.js +693 -0
- package/dist/core/tools/ask-question.js.map +1 -0
- package/dist/core/tools/bash.d.ts +18 -0
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +95 -16
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/delegate-status.d.ts +44 -2
- package/dist/core/tools/delegate-status.d.ts.map +1 -1
- package/dist/core/tools/delegate-status.js +214 -19
- package/dist/core/tools/delegate-status.js.map +1 -1
- package/dist/core/tools/delegate.d.ts +15 -13
- package/dist/core/tools/delegate.d.ts.map +1 -1
- package/dist/core/tools/delegate.js +124 -22
- package/dist/core/tools/delegate.js.map +1 -1
- package/dist/core/tools/extensionify.d.ts.map +1 -1
- package/dist/core/tools/extensionify.js +1 -0
- package/dist/core/tools/extensionify.js.map +1 -1
- package/dist/core/tools/goal.d.ts +94 -3
- package/dist/core/tools/goal.d.ts.map +1 -1
- package/dist/core/tools/goal.js +165 -15
- package/dist/core/tools/goal.js.map +1 -1
- package/dist/core/tools/model-fitness.d.ts +7 -0
- package/dist/core/tools/model-fitness.d.ts.map +1 -1
- package/dist/core/tools/model-fitness.js +4 -4
- package/dist/core/tools/model-fitness.js.map +1 -1
- package/dist/core/tools/orchestration-panel.d.ts +43 -0
- package/dist/core/tools/orchestration-panel.d.ts.map +1 -0
- package/dist/core/tools/orchestration-panel.js +168 -0
- package/dist/core/tools/orchestration-panel.js.map +1 -0
- package/dist/core/tools/run-process.d.ts +26 -0
- package/dist/core/tools/run-process.d.ts.map +1 -0
- package/dist/core/tools/run-process.js +138 -0
- package/dist/core/tools/run-process.js.map +1 -0
- package/dist/core/tools/shell-contract-router.d.ts +6 -1
- package/dist/core/tools/shell-contract-router.d.ts.map +1 -1
- package/dist/core/tools/shell-contract-router.js +23 -2
- package/dist/core/tools/shell-contract-router.js.map +1 -1
- package/dist/core/tools/shell-session.d.ts +89 -0
- package/dist/core/tools/shell-session.d.ts.map +1 -0
- package/dist/core/tools/shell-session.js +432 -0
- package/dist/core/tools/shell-session.js.map +1 -0
- package/dist/core/tools/task-steps.d.ts +6 -0
- package/dist/core/tools/task-steps.d.ts.map +1 -1
- package/dist/core/tools/task-steps.js +165 -8
- package/dist/core/tools/task-steps.js.map +1 -1
- package/dist/core/tools/tmux-dispatch.d.ts +84 -0
- package/dist/core/tools/tmux-dispatch.d.ts.map +1 -0
- package/dist/core/tools/tmux-dispatch.js +91 -0
- package/dist/core/tools/tmux-dispatch.js.map +1 -0
- package/dist/core/tools/windows-shell-engine.d.ts +42 -0
- package/dist/core/tools/windows-shell-engine.d.ts.map +1 -0
- package/dist/core/tools/windows-shell-engine.js +151 -0
- package/dist/core/tools/windows-shell-engine.js.map +1 -0
- package/dist/core/tools/windows-shell-state.d.ts +40 -0
- package/dist/core/tools/windows-shell-state.d.ts.map +1 -0
- package/dist/core/tools/windows-shell-state.js +59 -0
- package/dist/core/tools/windows-shell-state.js.map +1 -0
- package/dist/core/tools/worktree-sync.d.ts +24 -0
- package/dist/core/tools/worktree-sync.d.ts.map +1 -0
- package/dist/core/tools/worktree-sync.js +338 -0
- package/dist/core/tools/worktree-sync.js.map +1 -0
- package/dist/core/trust-manager.d.ts +4 -1
- package/dist/core/trust-manager.d.ts.map +1 -1
- package/dist/core/trust-manager.js +20 -2
- package/dist/core/trust-manager.js.map +1 -1
- package/dist/core/util/atomic-file.d.ts +55 -0
- package/dist/core/util/atomic-file.d.ts.map +1 -0
- package/dist/core/util/atomic-file.js +255 -0
- package/dist/core/util/atomic-file.js.map +1 -0
- package/dist/core/util/bounded-jsonl.d.ts +10 -0
- package/dist/core/util/bounded-jsonl.d.ts.map +1 -0
- package/dist/core/util/bounded-jsonl.js +75 -0
- package/dist/core/util/bounded-jsonl.js.map +1 -0
- package/dist/core/util/minimatch-cache.d.ts +33 -0
- package/dist/core/util/minimatch-cache.d.ts.map +1 -0
- package/dist/core/util/minimatch-cache.js +0 -0
- package/dist/core/util/minimatch-cache.js.map +1 -0
- package/dist/core/util/value-guards.d.ts +5 -0
- package/dist/core/util/value-guards.d.ts.map +1 -0
- package/dist/core/util/value-guards.js +12 -0
- package/dist/core/util/value-guards.js.map +1 -0
- package/dist/core/worktree-sync/codes.d.ts +227 -0
- package/dist/core/worktree-sync/codes.d.ts.map +1 -0
- package/dist/core/worktree-sync/codes.js +14 -0
- package/dist/core/worktree-sync/codes.js.map +1 -0
- package/dist/core/worktree-sync/git-engine.d.ts +156 -0
- package/dist/core/worktree-sync/git-engine.d.ts.map +1 -0
- package/dist/core/worktree-sync/git-engine.js +1191 -0
- package/dist/core/worktree-sync/git-engine.js.map +1 -0
- package/dist/core/worktree-sync/lane-gate.d.ts +75 -0
- package/dist/core/worktree-sync/lane-gate.d.ts.map +1 -0
- package/dist/core/worktree-sync/lane-gate.js +360 -0
- package/dist/core/worktree-sync/lane-gate.js.map +1 -0
- package/dist/core/worktree-sync/runtime.d.ts +47 -0
- package/dist/core/worktree-sync/runtime.d.ts.map +1 -0
- package/dist/core/worktree-sync/runtime.js +96 -0
- package/dist/core/worktree-sync/runtime.js.map +1 -0
- package/dist/core/worktree-sync/store.d.ts +69 -0
- package/dist/core/worktree-sync/store.d.ts.map +1 -0
- package/dist/core/worktree-sync/store.js +252 -0
- package/dist/core/worktree-sync/store.js.map +1 -0
- package/dist/core/worktree-sync/watcher.d.ts +29 -0
- package/dist/core/worktree-sync/watcher.d.ts.map +1 -0
- package/dist/core/worktree-sync/watcher.js +93 -0
- package/dist/core/worktree-sync/watcher.js.map +1 -0
- package/dist/index.d.ts +13 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -2
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +179 -1
- package/dist/main.js.map +1 -1
- package/dist/migrations.d.ts +7 -0
- package/dist/migrations.d.ts.map +1 -1
- package/dist/migrations.js +197 -1
- package/dist/migrations.js.map +1 -1
- package/dist/modes/interactive/auto-learn-controller.d.ts +16 -1
- package/dist/modes/interactive/auto-learn-controller.d.ts.map +1 -1
- package/dist/modes/interactive/auto-learn-controller.js +50 -8
- package/dist/modes/interactive/auto-learn-controller.js.map +1 -1
- package/dist/modes/interactive/clipboard-input.d.ts +7 -1
- package/dist/modes/interactive/clipboard-input.d.ts.map +1 -1
- package/dist/modes/interactive/clipboard-input.js +44 -6
- package/dist/modes/interactive/clipboard-input.js.map +1 -1
- package/dist/modes/interactive/components/profile-resource-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/profile-resource-editor.js +23 -1
- package/dist/modes/interactive/components/profile-resource-editor.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +2 -2
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/config-backup.d.ts.map +1 -1
- package/dist/modes/interactive/config-backup.js +5 -4
- package/dist/modes/interactive/config-backup.js.map +1 -1
- package/dist/modes/interactive/extension-ui-host.d.ts +14 -0
- package/dist/modes/interactive/extension-ui-host.d.ts.map +1 -1
- package/dist/modes/interactive/extension-ui-host.js +76 -15
- package/dist/modes/interactive/extension-ui-host.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +4 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +67 -1
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/key-handlers.d.ts.map +1 -1
- package/dist/modes/interactive/key-handlers.js +1 -1
- package/dist/modes/interactive/key-handlers.js.map +1 -1
- package/dist/modes/interactive/local-model-commands.d.ts +43 -0
- package/dist/modes/interactive/local-model-commands.d.ts.map +1 -1
- package/dist/modes/interactive/local-model-commands.js +290 -3
- package/dist/modes/interactive/local-model-commands.js.map +1 -1
- package/dist/modes/interactive/profile-menu-controller.d.ts.map +1 -1
- package/dist/modes/interactive/profile-menu-controller.js +7 -7
- package/dist/modes/interactive/profile-menu-controller.js.map +1 -1
- package/dist/modes/interactive/report-commands.d.ts.map +1 -1
- package/dist/modes/interactive/report-commands.js +21 -0
- package/dist/modes/interactive/report-commands.js.map +1 -1
- package/dist/modes/interactive/session-flow-commands.d.ts +17 -2
- package/dist/modes/interactive/session-flow-commands.d.ts.map +1 -1
- package/dist/modes/interactive/session-flow-commands.js +74 -21
- package/dist/modes/interactive/session-flow-commands.js.map +1 -1
- package/dist/modes/interactive/session-io-commands.d.ts.map +1 -1
- package/dist/modes/interactive/session-io-commands.js +16 -6
- package/dist/modes/interactive/session-io-commands.js.map +1 -1
- package/dist/modes/interactive/session-replacement-errors.d.ts +7 -0
- package/dist/modes/interactive/session-replacement-errors.d.ts.map +1 -0
- package/dist/modes/interactive/session-replacement-errors.js +15 -0
- package/dist/modes/interactive/session-replacement-errors.js.map +1 -0
- package/dist/modes/interactive/startup-checks.d.ts.map +1 -1
- package/dist/modes/interactive/startup-checks.js +1 -1
- package/dist/modes/interactive/startup-checks.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +82 -23
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +15 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js +138 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/utils/clipboard-image.d.ts.map +1 -1
- package/dist/utils/clipboard-image.js +2 -13
- package/dist/utils/clipboard-image.js.map +1 -1
- package/dist/utils/clipboard-native.d.ts +1 -0
- package/dist/utils/clipboard-native.d.ts.map +1 -1
- package/dist/utils/clipboard-native.js.map +1 -1
- package/dist/utils/clipboard.d.ts +1 -0
- package/dist/utils/clipboard.d.ts.map +1 -1
- package/dist/utils/clipboard.js +52 -1
- package/dist/utils/clipboard.js.map +1 -1
- package/dist/utils/fs-watch.d.ts +11 -0
- package/dist/utils/fs-watch.d.ts.map +1 -1
- package/dist/utils/fs-watch.js +20 -2
- package/dist/utils/fs-watch.js.map +1 -1
- package/dist/utils/highlight-js-languages.d.ts +4 -0
- package/dist/utils/highlight-js-languages.d.ts.map +1 -0
- package/dist/utils/highlight-js-languages.js +573 -0
- package/dist/utils/highlight-js-languages.js.map +1 -0
- package/dist/utils/platform.d.ts +3 -0
- package/dist/utils/platform.d.ts.map +1 -0
- package/dist/utils/platform.js +8 -0
- package/dist/utils/platform.js.map +1 -0
- package/dist/utils/shell.d.ts +7 -1
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +21 -6
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/syntax-highlight.d.ts.map +1 -1
- package/dist/utils/syntax-highlight.js +53 -5
- 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 +112 -1
- package/dist/utils/tools-manager.js.map +1 -1
- package/dist/utils/work-directory.d.ts +11 -0
- package/dist/utils/work-directory.d.ts.map +1 -1
- package/dist/utils/work-directory.js +30 -9
- package/dist/utils/work-directory.js.map +1 -1
- package/docs/UI_POLISH_ORCHESTRATION.md +44 -0
- package/docs/UI_QUALITY_ORCHESTRATION.md +30 -0
- package/docs/docs.json +4 -0
- package/docs/extensions.md +62 -2
- package/docs/harness-architecture.md +156 -0
- package/docs/keybindings.md +11 -1
- package/docs/process-matrix.md +153 -0
- package/docs/rpc.md +45 -2
- package/docs/sessions.md +15 -0
- package/docs/settings.md +128 -11
- package/docs/task-steps.md +8 -0
- package/docs/telemetry.md +19 -0
- package/docs/tmux-agent-manager.md +92 -2
- package/docs/ui-reference/README.md +9 -0
- package/docs/ui-reference/orchestration-after.txt +7 -0
- package/docs/ui-reference/orchestration-before.txt +7 -0
- package/docs/ui-reference/orchestration-reference.txt +6 -0
- package/docs/usage.md +14 -2
- package/docs/windows.md +52 -3
- package/docs/work-directory.md +42 -2
- package/docs/worktree-sync.md +250 -0
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/question.ts +34 -245
- package/examples/extensions/questionnaire.ts +41 -407
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +12 -12
- package/package.json +10 -4
- package/dist/core/delegation/session-worker-result.d.ts +0 -16
- package/dist/core/delegation/session-worker-result.d.ts.map +0 -1
- package/dist/core/delegation/session-worker-result.js +0 -53
- package/dist/core/delegation/session-worker-result.js.map +0 -1
- package/dist/core/delegation/worker-result.d.ts +0 -15
- package/dist/core/delegation/worker-result.d.ts.map +0 -1
- package/dist/core/delegation/worker-result.js +0 -161
- package/dist/core/delegation/worker-result.js.map +0 -1
- package/dist/core/telemetry.d.ts.map +0 -1
- package/dist/core/telemetry.js.map +0 -1
- package/docs/integration-sweep-builder-blueprint-2026-07-09.md +0 -365
- package/docs/integration-sweep-resume-2026-07-09.md +0 -407
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-task-state.js","sourceRoot":"","sources":["../../../src/core/tasks/session-task-state.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAuB,MAAM,iBAAiB,CAAC;AAE7F,MAAM,CAAC,MAAM,4BAA4B,GAAG,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"session-task-state.js","sourceRoot":"","sources":["../../../src/core/tasks/session-task-state.ts"],"names":[],"mappings":"AACA,OAAO,EACN,qBAAqB,EACrB,4BAA4B,EAC5B,gCAAgC,GAGhC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAuB,MAAM,iBAAiB,CAAC;AAE7F,MAAM,CAAC,MAAM,4BAA4B,GAAG,kBAAkB,CAAC;AAI/D,MAAM,+BAA+B,GAAkD;IACtF,UAAU,EAAE,4BAA4B;IACxC,QAAQ,EAAE,OAAO;IACjB,OAAO,EAAE,gBAAgB;IACzB,KAAK,EAAE,mBAAmB;CAC1B,CAAC;AAEF,MAAM,UAAU,4BAA4B,CAC3C,cAAyD,EACzD,KAAqB,EACZ;IACT,OAAO,qBAAqB,CAAC,cAAc,EAAE,+BAA+B,EAAE,KAAK,CAAC,CAAC;AAAA,CACrF;AAED;sFACsF;AACtF,MAAM,UAAU,mCAAmC,CAAC,IAAa,EAA8B;IAC9F,OAAO,4BAA4B,CAAC,IAAI,EAAE,+BAA+B,CAAC,CAAC;AAAA,CAC3E;AAED;;;;;GAKG;AACH,MAAM,UAAU,+BAA+B,CAC9C,cAAoE,EACvC;IAC7B,OAAO,gCAAgC,CAAC,cAAc,EAAE,+BAA+B,CAAC,CAAC;AAAA,CACzF","sourcesContent":["import type { SessionManager } from \"@caupulican/pi-agent-core/node\";\nimport {\n\tappendSessionSnapshot,\n\tdecodeSessionSnapshotPayload,\n\tgetLatestSessionSnapshotOnBranch,\n\ttype SessionSnapshotCodec,\n\ttype SessionSnapshotPayload,\n} from \"../session-snapshot.ts\";\nimport { cloneTaskStepsState, isTaskStepsState, type TaskStepsState } from \"./task-state.ts\";\n\nexport const TASK_STEPS_STATE_CUSTOM_TYPE = \"task_steps_state\";\n\nexport type TaskStepsStateSnapshotPayload = SessionSnapshotPayload<\"state\", TaskStepsState>;\n\nconst TASK_STEPS_STATE_SNAPSHOT_CODEC: SessionSnapshotCodec<TaskStepsState, \"state\"> = {\n\tcustomType: TASK_STEPS_STATE_CUSTOM_TYPE,\n\tvalueKey: \"state\",\n\tisValue: isTaskStepsState,\n\tclone: cloneTaskStepsState,\n};\n\nexport function appendTaskStepsStateSnapshot(\n\tsessionManager: Pick<SessionManager, \"appendCustomEntry\">,\n\tstate: TaskStepsState,\n): string {\n\treturn appendSessionSnapshot(sessionManager, TASK_STEPS_STATE_SNAPSHOT_CODEC, state);\n}\n\n/** Pure payload decode: validates + clones a task-steps snapshot payload. No SessionManager access,\n * so unit tests can exercise decoding directly against a constructed `data` value. */\nexport function decodeTaskStepsStateSnapshotPayload(data: unknown): TaskStepsState | undefined {\n\treturn decodeSessionSnapshotPayload(data, TASK_STEPS_STATE_SNAPSHOT_CODEC);\n}\n\n/**\n * Most recent VALID task-steps snapshot on the active branch. Walks leaf→root ancestry via\n * `getLatestCustomEntryOnBranch`, skipping entries whose payload fails to decode and resuming\n * the search from that entry's parent, so an older valid snapshot still wins over a newer\n * malformed one (matches the pre-branch-scoping flat-list resolution semantics).\n */\nexport function getLatestTaskStepsStateSnapshot(\n\tsessionManager: Pick<SessionManager, \"getLatestCustomEntryOnBranch\">,\n): TaskStepsState | undefined {\n\treturn getLatestSessionSnapshotOnBranch(sessionManager, TASK_STEPS_STATE_SNAPSHOT_CODEC);\n}\n"]}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turn-boundary task_steps contract monitor.
|
|
3
|
+
*
|
|
4
|
+
* Pure logic only: given the current task_steps state and the prior consecutive-violation streak,
|
|
5
|
+
* decides whether the workflow contract described in the task_steps tool's `promptGuidelines`
|
|
6
|
+
* (`tools/task-steps.ts`) — at most one in_progress step, and an in_progress step whenever open
|
|
7
|
+
* steps remain — has been broken for N consecutive turns, and if so returns a ONE-LINE harness
|
|
8
|
+
* note. No model calls, no I/O, no session access: the caller (`AutoLearnController`) owns reading
|
|
9
|
+
* the task_steps state, persisting the returned streak across turns, and delivering the note
|
|
10
|
+
* through the session's existing next-turn message surface. This is an advisory nudge, not an
|
|
11
|
+
* enforcement gate.
|
|
12
|
+
*/
|
|
13
|
+
import type { TaskStepsState } from "./task-state.ts";
|
|
14
|
+
/** Consecutive violating turns required before a harness note fires. */
|
|
15
|
+
export declare const TASK_CONTRACT_VIOLATION_THRESHOLD = 3;
|
|
16
|
+
export interface TaskContractStreak {
|
|
17
|
+
/** Number of consecutive turns the contract has been violated; reset to 0 on a compliant turn. */
|
|
18
|
+
consecutiveViolations: number;
|
|
19
|
+
/**
|
|
20
|
+
* Whether a note has already fired for the CURRENT streak. Re-arms to false only when the streak
|
|
21
|
+
* resets to 0 via a compliant turn, so a sustained violation emits exactly one note instead of
|
|
22
|
+
* repeating every turn past the threshold.
|
|
23
|
+
*/
|
|
24
|
+
noteFired: boolean;
|
|
25
|
+
}
|
|
26
|
+
export declare const INITIAL_TASK_CONTRACT_STREAK: TaskContractStreak;
|
|
27
|
+
export interface TaskContractCheckResult {
|
|
28
|
+
streak: TaskContractStreak;
|
|
29
|
+
/** Present only on the turn the streak first reaches the threshold. */
|
|
30
|
+
note?: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* True when the task_steps contract is broken: more than one step is in_progress, or open
|
|
34
|
+
* (non-terminal) steps remain with none in_progress. An absent state (no task list ever created)
|
|
35
|
+
* is never a violation — there is nothing to enforce.
|
|
36
|
+
*/
|
|
37
|
+
export declare function isTaskStepsContractViolation(state: TaskStepsState | undefined): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Advance the streak by one turn. Pure: takes the current task_steps state and the prior streak,
|
|
40
|
+
* returns the next streak plus, only on the exact turn the streak first reaches `threshold`, a
|
|
41
|
+
* ONE-LINE note. Callers must persist the returned streak and feed it back in as `priorStreak` on
|
|
42
|
+
* the next turn.
|
|
43
|
+
*/
|
|
44
|
+
export declare function checkTaskStepsContract(state: TaskStepsState | undefined, priorStreak: TaskContractStreak, threshold?: number): TaskContractCheckResult;
|
|
45
|
+
//# sourceMappingURL=task-contract-monitor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task-contract-monitor.d.ts","sourceRoot":"","sources":["../../../src/core/tasks/task-contract-monitor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEtD,wEAAwE;AACxE,eAAO,MAAM,iCAAiC,IAAI,CAAC;AAEnD,MAAM,WAAW,kBAAkB;IAClC,kGAAkG;IAClG,qBAAqB,EAAE,MAAM,CAAC;IAC9B;;;;OAIG;IACH,SAAS,EAAE,OAAO,CAAC;CACnB;AAED,eAAO,MAAM,4BAA4B,EAAE,kBAAmE,CAAC;AAE/G,MAAM,WAAW,uBAAuB;IACvC,MAAM,EAAE,kBAAkB,CAAC;IAC3B,uEAAuE;IACvE,IAAI,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;;;GAIG;AACH,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,cAAc,GAAG,SAAS,GAAG,OAAO,CAMvF;AAWD;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACrC,KAAK,EAAE,cAAc,GAAG,SAAS,EACjC,WAAW,EAAE,kBAAkB,EAC/B,SAAS,GAAE,MAA0C,GACnD,uBAAuB,CAYzB","sourcesContent":["/**\n * Turn-boundary task_steps contract monitor.\n *\n * Pure logic only: given the current task_steps state and the prior consecutive-violation streak,\n * decides whether the workflow contract described in the task_steps tool's `promptGuidelines`\n * (`tools/task-steps.ts`) — at most one in_progress step, and an in_progress step whenever open\n * steps remain — has been broken for N consecutive turns, and if so returns a ONE-LINE harness\n * note. No model calls, no I/O, no session access: the caller (`AutoLearnController`) owns reading\n * the task_steps state, persisting the returned streak across turns, and delivering the note\n * through the session's existing next-turn message surface. This is an advisory nudge, not an\n * enforcement gate.\n */\n\nimport type { TaskStepsState } from \"./task-state.ts\";\n\n/** Consecutive violating turns required before a harness note fires. */\nexport const TASK_CONTRACT_VIOLATION_THRESHOLD = 3;\n\nexport interface TaskContractStreak {\n\t/** Number of consecutive turns the contract has been violated; reset to 0 on a compliant turn. */\n\tconsecutiveViolations: number;\n\t/**\n\t * Whether a note has already fired for the CURRENT streak. Re-arms to false only when the streak\n\t * resets to 0 via a compliant turn, so a sustained violation emits exactly one note instead of\n\t * repeating every turn past the threshold.\n\t */\n\tnoteFired: boolean;\n}\n\nexport const INITIAL_TASK_CONTRACT_STREAK: TaskContractStreak = { consecutiveViolations: 0, noteFired: false };\n\nexport interface TaskContractCheckResult {\n\tstreak: TaskContractStreak;\n\t/** Present only on the turn the streak first reaches the threshold. */\n\tnote?: string;\n}\n\n/**\n * True when the task_steps contract is broken: more than one step is in_progress, or open\n * (non-terminal) steps remain with none in_progress. An absent state (no task list ever created)\n * is never a violation — there is nothing to enforce.\n */\nexport function isTaskStepsContractViolation(state: TaskStepsState | undefined): boolean {\n\tif (!state) return false;\n\tconst inProgressCount = state.steps.filter((step) => step.status === \"in_progress\").length;\n\tif (inProgressCount > 1) return true;\n\tconst openCount = state.steps.filter((step) => step.status !== \"completed\" && step.status !== \"cancelled\").length;\n\treturn openCount > 0 && inProgressCount === 0;\n}\n\nfunction buildTaskContractNote(state: TaskStepsState | undefined, consecutiveViolations: number): string {\n\tconst inProgressCount = state?.steps.filter((step) => step.status === \"in_progress\").length ?? 0;\n\tconst reason =\n\t\tinProgressCount > 1\n\t\t\t? `${inProgressCount} steps are in_progress at once`\n\t\t\t: \"open task_steps have none in_progress\";\n\treturn `Harness note: task_steps contract violated for ${consecutiveViolations} consecutive turns (${reason}) — set exactly one open step to in_progress before continuing.`;\n}\n\n/**\n * Advance the streak by one turn. Pure: takes the current task_steps state and the prior streak,\n * returns the next streak plus, only on the exact turn the streak first reaches `threshold`, a\n * ONE-LINE note. Callers must persist the returned streak and feed it back in as `priorStreak` on\n * the next turn.\n */\nexport function checkTaskStepsContract(\n\tstate: TaskStepsState | undefined,\n\tpriorStreak: TaskContractStreak,\n\tthreshold: number = TASK_CONTRACT_VIOLATION_THRESHOLD,\n): TaskContractCheckResult {\n\tif (!isTaskStepsContractViolation(state)) {\n\t\treturn { streak: { consecutiveViolations: 0, noteFired: false } };\n\t}\n\tconst consecutiveViolations = priorStreak.consecutiveViolations + 1;\n\tif (consecutiveViolations >= threshold && !priorStreak.noteFired) {\n\t\treturn {\n\t\t\tstreak: { consecutiveViolations, noteFired: true },\n\t\t\tnote: buildTaskContractNote(state, consecutiveViolations),\n\t\t};\n\t}\n\treturn { streak: { consecutiveViolations, noteFired: priorStreak.noteFired } };\n}\n"]}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turn-boundary task_steps contract monitor.
|
|
3
|
+
*
|
|
4
|
+
* Pure logic only: given the current task_steps state and the prior consecutive-violation streak,
|
|
5
|
+
* decides whether the workflow contract described in the task_steps tool's `promptGuidelines`
|
|
6
|
+
* (`tools/task-steps.ts`) — at most one in_progress step, and an in_progress step whenever open
|
|
7
|
+
* steps remain — has been broken for N consecutive turns, and if so returns a ONE-LINE harness
|
|
8
|
+
* note. No model calls, no I/O, no session access: the caller (`AutoLearnController`) owns reading
|
|
9
|
+
* the task_steps state, persisting the returned streak across turns, and delivering the note
|
|
10
|
+
* through the session's existing next-turn message surface. This is an advisory nudge, not an
|
|
11
|
+
* enforcement gate.
|
|
12
|
+
*/
|
|
13
|
+
/** Consecutive violating turns required before a harness note fires. */
|
|
14
|
+
export const TASK_CONTRACT_VIOLATION_THRESHOLD = 3;
|
|
15
|
+
export const INITIAL_TASK_CONTRACT_STREAK = { consecutiveViolations: 0, noteFired: false };
|
|
16
|
+
/**
|
|
17
|
+
* True when the task_steps contract is broken: more than one step is in_progress, or open
|
|
18
|
+
* (non-terminal) steps remain with none in_progress. An absent state (no task list ever created)
|
|
19
|
+
* is never a violation — there is nothing to enforce.
|
|
20
|
+
*/
|
|
21
|
+
export function isTaskStepsContractViolation(state) {
|
|
22
|
+
if (!state)
|
|
23
|
+
return false;
|
|
24
|
+
const inProgressCount = state.steps.filter((step) => step.status === "in_progress").length;
|
|
25
|
+
if (inProgressCount > 1)
|
|
26
|
+
return true;
|
|
27
|
+
const openCount = state.steps.filter((step) => step.status !== "completed" && step.status !== "cancelled").length;
|
|
28
|
+
return openCount > 0 && inProgressCount === 0;
|
|
29
|
+
}
|
|
30
|
+
function buildTaskContractNote(state, consecutiveViolations) {
|
|
31
|
+
const inProgressCount = state?.steps.filter((step) => step.status === "in_progress").length ?? 0;
|
|
32
|
+
const reason = inProgressCount > 1
|
|
33
|
+
? `${inProgressCount} steps are in_progress at once`
|
|
34
|
+
: "open task_steps have none in_progress";
|
|
35
|
+
return `Harness note: task_steps contract violated for ${consecutiveViolations} consecutive turns (${reason}) — set exactly one open step to in_progress before continuing.`;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Advance the streak by one turn. Pure: takes the current task_steps state and the prior streak,
|
|
39
|
+
* returns the next streak plus, only on the exact turn the streak first reaches `threshold`, a
|
|
40
|
+
* ONE-LINE note. Callers must persist the returned streak and feed it back in as `priorStreak` on
|
|
41
|
+
* the next turn.
|
|
42
|
+
*/
|
|
43
|
+
export function checkTaskStepsContract(state, priorStreak, threshold = TASK_CONTRACT_VIOLATION_THRESHOLD) {
|
|
44
|
+
if (!isTaskStepsContractViolation(state)) {
|
|
45
|
+
return { streak: { consecutiveViolations: 0, noteFired: false } };
|
|
46
|
+
}
|
|
47
|
+
const consecutiveViolations = priorStreak.consecutiveViolations + 1;
|
|
48
|
+
if (consecutiveViolations >= threshold && !priorStreak.noteFired) {
|
|
49
|
+
return {
|
|
50
|
+
streak: { consecutiveViolations, noteFired: true },
|
|
51
|
+
note: buildTaskContractNote(state, consecutiveViolations),
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
return { streak: { consecutiveViolations, noteFired: priorStreak.noteFired } };
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=task-contract-monitor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task-contract-monitor.js","sourceRoot":"","sources":["../../../src/core/tasks/task-contract-monitor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,wEAAwE;AACxE,MAAM,CAAC,MAAM,iCAAiC,GAAG,CAAC,CAAC;AAanD,MAAM,CAAC,MAAM,4BAA4B,GAAuB,EAAE,qBAAqB,EAAE,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;AAQ/G;;;;GAIG;AACH,MAAM,UAAU,4BAA4B,CAAC,KAAiC,EAAW;IACxF,IAAI,CAAC,KAAK;QAAE,OAAO,KAAK,CAAC;IACzB,MAAM,eAAe,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,KAAK,aAAa,CAAC,CAAC,MAAM,CAAC;IAC3F,IAAI,eAAe,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IACrC,MAAM,SAAS,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,KAAK,WAAW,IAAI,IAAI,CAAC,MAAM,KAAK,WAAW,CAAC,CAAC,MAAM,CAAC;IAClH,OAAO,SAAS,GAAG,CAAC,IAAI,eAAe,KAAK,CAAC,CAAC;AAAA,CAC9C;AAED,SAAS,qBAAqB,CAAC,KAAiC,EAAE,qBAA6B,EAAU;IACxG,MAAM,eAAe,GAAG,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,KAAK,aAAa,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC;IACjG,MAAM,MAAM,GACX,eAAe,GAAG,CAAC;QAClB,CAAC,CAAC,GAAG,eAAe,gCAAgC;QACpD,CAAC,CAAC,uCAAuC,CAAC;IAC5C,OAAO,kDAAkD,qBAAqB,uBAAuB,MAAM,mEAAiE,CAAC;AAAA,CAC7K;AAED;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CACrC,KAAiC,EACjC,WAA+B,EAC/B,SAAS,GAAW,iCAAiC,EAC3B;IAC1B,IAAI,CAAC,4BAA4B,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1C,OAAO,EAAE,MAAM,EAAE,EAAE,qBAAqB,EAAE,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,CAAC;IACnE,CAAC;IACD,MAAM,qBAAqB,GAAG,WAAW,CAAC,qBAAqB,GAAG,CAAC,CAAC;IACpE,IAAI,qBAAqB,IAAI,SAAS,IAAI,CAAC,WAAW,CAAC,SAAS,EAAE,CAAC;QAClE,OAAO;YACN,MAAM,EAAE,EAAE,qBAAqB,EAAE,SAAS,EAAE,IAAI,EAAE;YAClD,IAAI,EAAE,qBAAqB,CAAC,KAAK,EAAE,qBAAqB,CAAC;SACzD,CAAC;IACH,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,EAAE,qBAAqB,EAAE,SAAS,EAAE,WAAW,CAAC,SAAS,EAAE,EAAE,CAAC;AAAA,CAC/E","sourcesContent":["/**\n * Turn-boundary task_steps contract monitor.\n *\n * Pure logic only: given the current task_steps state and the prior consecutive-violation streak,\n * decides whether the workflow contract described in the task_steps tool's `promptGuidelines`\n * (`tools/task-steps.ts`) — at most one in_progress step, and an in_progress step whenever open\n * steps remain — has been broken for N consecutive turns, and if so returns a ONE-LINE harness\n * note. No model calls, no I/O, no session access: the caller (`AutoLearnController`) owns reading\n * the task_steps state, persisting the returned streak across turns, and delivering the note\n * through the session's existing next-turn message surface. This is an advisory nudge, not an\n * enforcement gate.\n */\n\nimport type { TaskStepsState } from \"./task-state.ts\";\n\n/** Consecutive violating turns required before a harness note fires. */\nexport const TASK_CONTRACT_VIOLATION_THRESHOLD = 3;\n\nexport interface TaskContractStreak {\n\t/** Number of consecutive turns the contract has been violated; reset to 0 on a compliant turn. */\n\tconsecutiveViolations: number;\n\t/**\n\t * Whether a note has already fired for the CURRENT streak. Re-arms to false only when the streak\n\t * resets to 0 via a compliant turn, so a sustained violation emits exactly one note instead of\n\t * repeating every turn past the threshold.\n\t */\n\tnoteFired: boolean;\n}\n\nexport const INITIAL_TASK_CONTRACT_STREAK: TaskContractStreak = { consecutiveViolations: 0, noteFired: false };\n\nexport interface TaskContractCheckResult {\n\tstreak: TaskContractStreak;\n\t/** Present only on the turn the streak first reaches the threshold. */\n\tnote?: string;\n}\n\n/**\n * True when the task_steps contract is broken: more than one step is in_progress, or open\n * (non-terminal) steps remain with none in_progress. An absent state (no task list ever created)\n * is never a violation — there is nothing to enforce.\n */\nexport function isTaskStepsContractViolation(state: TaskStepsState | undefined): boolean {\n\tif (!state) return false;\n\tconst inProgressCount = state.steps.filter((step) => step.status === \"in_progress\").length;\n\tif (inProgressCount > 1) return true;\n\tconst openCount = state.steps.filter((step) => step.status !== \"completed\" && step.status !== \"cancelled\").length;\n\treturn openCount > 0 && inProgressCount === 0;\n}\n\nfunction buildTaskContractNote(state: TaskStepsState | undefined, consecutiveViolations: number): string {\n\tconst inProgressCount = state?.steps.filter((step) => step.status === \"in_progress\").length ?? 0;\n\tconst reason =\n\t\tinProgressCount > 1\n\t\t\t? `${inProgressCount} steps are in_progress at once`\n\t\t\t: \"open task_steps have none in_progress\";\n\treturn `Harness note: task_steps contract violated for ${consecutiveViolations} consecutive turns (${reason}) — set exactly one open step to in_progress before continuing.`;\n}\n\n/**\n * Advance the streak by one turn. Pure: takes the current task_steps state and the prior streak,\n * returns the next streak plus, only on the exact turn the streak first reaches `threshold`, a\n * ONE-LINE note. Callers must persist the returned streak and feed it back in as `priorStreak` on\n * the next turn.\n */\nexport function checkTaskStepsContract(\n\tstate: TaskStepsState | undefined,\n\tpriorStreak: TaskContractStreak,\n\tthreshold: number = TASK_CONTRACT_VIOLATION_THRESHOLD,\n): TaskContractCheckResult {\n\tif (!isTaskStepsContractViolation(state)) {\n\t\treturn { streak: { consecutiveViolations: 0, noteFired: false } };\n\t}\n\tconst consecutiveViolations = priorStreak.consecutiveViolations + 1;\n\tif (consecutiveViolations >= threshold && !priorStreak.noteFired) {\n\t\treturn {\n\t\t\tstreak: { consecutiveViolations, noteFired: true },\n\t\t\tnote: buildTaskContractNote(state, consecutiveViolations),\n\t\t};\n\t}\n\treturn { streak: { consecutiveViolations, noteFired: priorStreak.noteFired } };\n}\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { TaskStepStatus, TaskStepsState } from "./task-state.ts";
|
|
2
|
+
export interface OpenTaskStepProjection {
|
|
3
|
+
id: string;
|
|
4
|
+
status: TaskStepStatus;
|
|
5
|
+
content: string;
|
|
6
|
+
/** Always populated by projectOpenTaskSteps; optional for hand-built/legacy projections. */
|
|
7
|
+
requirementIds?: readonly string[];
|
|
8
|
+
}
|
|
9
|
+
export interface TaskRequirementReference {
|
|
10
|
+
id: string;
|
|
11
|
+
text: string;
|
|
12
|
+
}
|
|
13
|
+
/** Conservative fallback used only for task steps persisted before explicit requirement links existed. */
|
|
14
|
+
export declare function taskStepReferencesRequirement(step: Pick<OpenTaskStepProjection, "content" | "requirementIds">, requirement: TaskRequirementReference): boolean;
|
|
15
|
+
export declare function projectOpenTaskSteps(state: TaskStepsState | undefined): OpenTaskStepProjection[];
|
|
16
|
+
export declare function resolveTaskStepRequirementIds(step: Pick<OpenTaskStepProjection, "content" | "requirementIds">, requirements: readonly TaskRequirementReference[]): {
|
|
17
|
+
matchedIds: readonly string[];
|
|
18
|
+
unknownIds: readonly string[];
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=task-projection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task-projection.d.ts","sourceRoot":"","sources":["../../../src/core/tasks/task-projection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEtE,MAAM,WAAW,sBAAsB;IACtC,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,cAAc,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,4FAA4F;IAC5F,cAAc,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACnC;AAED,MAAM,WAAW,wBAAwB;IACxC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACb;AAMD,0GAA0G;AAC1G,wBAAgB,6BAA6B,CAC5C,IAAI,EAAE,IAAI,CAAC,sBAAsB,EAAE,SAAS,GAAG,gBAAgB,CAAC,EAChE,WAAW,EAAE,wBAAwB,GACnC,OAAO,CAST;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,cAAc,GAAG,SAAS,GAAG,sBAAsB,EAAE,CAShG;AAED,wBAAgB,6BAA6B,CAC5C,IAAI,EAAE,IAAI,CAAC,sBAAsB,EAAE,SAAS,GAAG,gBAAgB,CAAC,EAChE,YAAY,EAAE,SAAS,wBAAwB,EAAE,GAC/C;IAAE,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;IAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAmBlE","sourcesContent":["import type { TaskStepStatus, TaskStepsState } from \"./task-state.ts\";\n\nexport interface OpenTaskStepProjection {\n\tid: string;\n\tstatus: TaskStepStatus;\n\tcontent: string;\n\t/** Always populated by projectOpenTaskSteps; optional for hand-built/legacy projections. */\n\trequirementIds?: readonly string[];\n}\n\nexport interface TaskRequirementReference {\n\tid: string;\n\ttext: string;\n}\n\nfunction escapeRegExp(text: string): string {\n\treturn text.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n\n/** Conservative fallback used only for task steps persisted before explicit requirement links existed. */\nexport function taskStepReferencesRequirement(\n\tstep: Pick<OpenTaskStepProjection, \"content\" | \"requirementIds\">,\n\trequirement: TaskRequirementReference,\n): boolean {\n\tif ((step.requirementIds?.length ?? 0) > 0) return step.requirementIds?.includes(requirement.id) ?? false;\n\tconst idToken = requirement.id.trim();\n\tif (idToken.length >= 2) {\n\t\tconst idPattern = new RegExp(`(^|[^a-z0-9])${escapeRegExp(idToken.toLocaleLowerCase())}([^a-z0-9]|$)`, \"i\");\n\t\tif (idPattern.test(step.content)) return true;\n\t}\n\tconst text = requirement.text.trim();\n\treturn text.length >= 8 && step.content.toLocaleLowerCase().includes(text.toLocaleLowerCase());\n}\n\nexport function projectOpenTaskSteps(state: TaskStepsState | undefined): OpenTaskStepProjection[] {\n\treturn (state?.steps ?? [])\n\t\t.filter((step) => step.status !== \"completed\" && step.status !== \"cancelled\")\n\t\t.map((step) => ({\n\t\t\tid: step.id,\n\t\t\tstatus: step.status,\n\t\t\tcontent: step.activeForm || step.content,\n\t\t\trequirementIds: [...(step.requirementIds ?? [])],\n\t\t}));\n}\n\nexport function resolveTaskStepRequirementIds(\n\tstep: Pick<OpenTaskStepProjection, \"content\" | \"requirementIds\">,\n\trequirements: readonly TaskRequirementReference[],\n): { matchedIds: readonly string[]; unknownIds: readonly string[] } {\n\tconst explicitIds = [...new Set(step.requirementIds ?? [])];\n\tif (explicitIds.length > 0) {\n\t\tconst knownIds = new Set(requirements.map((requirement) => requirement.id));\n\t\treturn {\n\t\t\tmatchedIds: explicitIds.filter((id) => knownIds.has(id)),\n\t\t\tunknownIds: explicitIds.filter((id) => !knownIds.has(id)),\n\t\t};\n\t}\n\tconst projected = {\n\t\tcontent: step.content,\n\t\trequirementIds: explicitIds,\n\t};\n\treturn {\n\t\tmatchedIds: requirements\n\t\t\t.filter((requirement) => taskStepReferencesRequirement(projected, requirement))\n\t\t\t.map((requirement) => requirement.id),\n\t\tunknownIds: [],\n\t};\n}\n"]}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
function escapeRegExp(text) {
|
|
2
|
+
return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
3
|
+
}
|
|
4
|
+
/** Conservative fallback used only for task steps persisted before explicit requirement links existed. */
|
|
5
|
+
export function taskStepReferencesRequirement(step, requirement) {
|
|
6
|
+
if ((step.requirementIds?.length ?? 0) > 0)
|
|
7
|
+
return step.requirementIds?.includes(requirement.id) ?? false;
|
|
8
|
+
const idToken = requirement.id.trim();
|
|
9
|
+
if (idToken.length >= 2) {
|
|
10
|
+
const idPattern = new RegExp(`(^|[^a-z0-9])${escapeRegExp(idToken.toLocaleLowerCase())}([^a-z0-9]|$)`, "i");
|
|
11
|
+
if (idPattern.test(step.content))
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
const text = requirement.text.trim();
|
|
15
|
+
return text.length >= 8 && step.content.toLocaleLowerCase().includes(text.toLocaleLowerCase());
|
|
16
|
+
}
|
|
17
|
+
export function projectOpenTaskSteps(state) {
|
|
18
|
+
return (state?.steps ?? [])
|
|
19
|
+
.filter((step) => step.status !== "completed" && step.status !== "cancelled")
|
|
20
|
+
.map((step) => ({
|
|
21
|
+
id: step.id,
|
|
22
|
+
status: step.status,
|
|
23
|
+
content: step.activeForm || step.content,
|
|
24
|
+
requirementIds: [...(step.requirementIds ?? [])],
|
|
25
|
+
}));
|
|
26
|
+
}
|
|
27
|
+
export function resolveTaskStepRequirementIds(step, requirements) {
|
|
28
|
+
const explicitIds = [...new Set(step.requirementIds ?? [])];
|
|
29
|
+
if (explicitIds.length > 0) {
|
|
30
|
+
const knownIds = new Set(requirements.map((requirement) => requirement.id));
|
|
31
|
+
return {
|
|
32
|
+
matchedIds: explicitIds.filter((id) => knownIds.has(id)),
|
|
33
|
+
unknownIds: explicitIds.filter((id) => !knownIds.has(id)),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
const projected = {
|
|
37
|
+
content: step.content,
|
|
38
|
+
requirementIds: explicitIds,
|
|
39
|
+
};
|
|
40
|
+
return {
|
|
41
|
+
matchedIds: requirements
|
|
42
|
+
.filter((requirement) => taskStepReferencesRequirement(projected, requirement))
|
|
43
|
+
.map((requirement) => requirement.id),
|
|
44
|
+
unknownIds: [],
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=task-projection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task-projection.js","sourceRoot":"","sources":["../../../src/core/tasks/task-projection.ts"],"names":[],"mappings":"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","sourcesContent":["import type { TaskStepStatus, TaskStepsState } from \"./task-state.ts\";\n\nexport interface OpenTaskStepProjection {\n\tid: string;\n\tstatus: TaskStepStatus;\n\tcontent: string;\n\t/** Always populated by projectOpenTaskSteps; optional for hand-built/legacy projections. */\n\trequirementIds?: readonly string[];\n}\n\nexport interface TaskRequirementReference {\n\tid: string;\n\ttext: string;\n}\n\nfunction escapeRegExp(text: string): string {\n\treturn text.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n\n/** Conservative fallback used only for task steps persisted before explicit requirement links existed. */\nexport function taskStepReferencesRequirement(\n\tstep: Pick<OpenTaskStepProjection, \"content\" | \"requirementIds\">,\n\trequirement: TaskRequirementReference,\n): boolean {\n\tif ((step.requirementIds?.length ?? 0) > 0) return step.requirementIds?.includes(requirement.id) ?? false;\n\tconst idToken = requirement.id.trim();\n\tif (idToken.length >= 2) {\n\t\tconst idPattern = new RegExp(`(^|[^a-z0-9])${escapeRegExp(idToken.toLocaleLowerCase())}([^a-z0-9]|$)`, \"i\");\n\t\tif (idPattern.test(step.content)) return true;\n\t}\n\tconst text = requirement.text.trim();\n\treturn text.length >= 8 && step.content.toLocaleLowerCase().includes(text.toLocaleLowerCase());\n}\n\nexport function projectOpenTaskSteps(state: TaskStepsState | undefined): OpenTaskStepProjection[] {\n\treturn (state?.steps ?? [])\n\t\t.filter((step) => step.status !== \"completed\" && step.status !== \"cancelled\")\n\t\t.map((step) => ({\n\t\t\tid: step.id,\n\t\t\tstatus: step.status,\n\t\t\tcontent: step.activeForm || step.content,\n\t\t\trequirementIds: [...(step.requirementIds ?? [])],\n\t\t}));\n}\n\nexport function resolveTaskStepRequirementIds(\n\tstep: Pick<OpenTaskStepProjection, \"content\" | \"requirementIds\">,\n\trequirements: readonly TaskRequirementReference[],\n): { matchedIds: readonly string[]; unknownIds: readonly string[] } {\n\tconst explicitIds = [...new Set(step.requirementIds ?? [])];\n\tif (explicitIds.length > 0) {\n\t\tconst knownIds = new Set(requirements.map((requirement) => requirement.id));\n\t\treturn {\n\t\t\tmatchedIds: explicitIds.filter((id) => knownIds.has(id)),\n\t\t\tunknownIds: explicitIds.filter((id) => !knownIds.has(id)),\n\t\t};\n\t}\n\tconst projected = {\n\t\tcontent: step.content,\n\t\trequirementIds: explicitIds,\n\t};\n\treturn {\n\t\tmatchedIds: requirements\n\t\t\t.filter((requirement) => taskStepReferencesRequirement(projected, requirement))\n\t\t\t.map((requirement) => requirement.id),\n\t\tunknownIds: [],\n\t};\n}\n"]}
|
|
@@ -10,6 +10,7 @@ export interface TaskStepInput {
|
|
|
10
10
|
status?: TaskStepStatus;
|
|
11
11
|
priority?: TaskStepPriority;
|
|
12
12
|
owner?: string;
|
|
13
|
+
requirementIds?: readonly string[];
|
|
13
14
|
note?: string;
|
|
14
15
|
notes?: readonly string[];
|
|
15
16
|
evidence?: readonly string[];
|
|
@@ -21,6 +22,8 @@ export interface TaskStep {
|
|
|
21
22
|
status: TaskStepStatus;
|
|
22
23
|
priority?: TaskStepPriority;
|
|
23
24
|
owner?: string;
|
|
25
|
+
/** Goal requirements this foreground step advances. Optional only for snapshots from older sessions. */
|
|
26
|
+
requirementIds?: readonly string[];
|
|
24
27
|
notes: readonly string[];
|
|
25
28
|
evidence: readonly string[];
|
|
26
29
|
createdAt: string;
|
|
@@ -46,6 +49,7 @@ export interface TaskStepUpdate {
|
|
|
46
49
|
status?: TaskStepStatus;
|
|
47
50
|
priority?: TaskStepPriority;
|
|
48
51
|
owner?: string;
|
|
52
|
+
requirementIds?: readonly string[];
|
|
49
53
|
note?: string;
|
|
50
54
|
evidence?: readonly string[];
|
|
51
55
|
}
|
|
@@ -55,6 +59,14 @@ export declare class TaskStepsError extends Error {
|
|
|
55
59
|
export declare function isTaskStepsState(value: unknown): value is TaskStepsState;
|
|
56
60
|
export declare function cloneTaskStepsState(state: TaskStepsState): TaskStepsState;
|
|
57
61
|
export declare function createTaskStepsState(now: string): TaskStepsState;
|
|
62
|
+
/**
|
|
63
|
+
* Find an OPEN (non-terminal) step whose content matches `content` case-insensitively.
|
|
64
|
+
* Terminal steps (completed/cancelled) are deliberately excluded so a legitimate re-add of
|
|
65
|
+
* previously finished work still creates a new step.
|
|
66
|
+
*/
|
|
67
|
+
export declare function findOpenDuplicateStep(steps: readonly TaskStep[], content: string): TaskStep | undefined;
|
|
68
|
+
/** True when a completed step has no evidence attached (a verification nudge candidate). */
|
|
69
|
+
export declare function hasUnverifiedCompletedStep(state: TaskStepsState): boolean;
|
|
58
70
|
export declare function setTaskSteps(state: TaskStepsState, inputs: readonly TaskStepInput[], now: string): TaskStepsState;
|
|
59
71
|
export declare function addTaskStep(state: TaskStepsState, input: TaskStepInput, now: string): TaskStepsState;
|
|
60
72
|
export declare function resolveTaskStepSelector(steps: readonly TaskStep[], selector: string): TaskStep;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task-state.d.ts","sourceRoot":"","sources":["../../../src/core/tasks/task-state.ts"],"names":[],"mappings":"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","sourcesContent":["export const TASK_STEP_STATUSES = [\"pending\", \"in_progress\", \"completed\", \"blocked\", \"cancelled\"] as const;\nexport type TaskStepStatus = (typeof TASK_STEP_STATUSES)[number];\n\nexport const TASK_STEP_PRIORITIES = [\"low\", \"normal\", \"high\"] as const;\nexport type TaskStepPriority = (typeof TASK_STEP_PRIORITIES)[number];\n\nexport const MAX_TASK_STEPS = 100;\nexport const MAX_TASK_STEP_CONTENT_LENGTH = 2_000;\nconst MAX_TASK_STEP_NOTE_LENGTH = 4_000;\nconst MAX_TASK_STEP_OWNER_LENGTH = 200;\nconst MAX_TASK_STEP_EVIDENCE = 32;\nconst MAX_TASK_STEP_EVIDENCE_LENGTH = 2_000;\n\nexport interface TaskStepInput {\n\tcontent: string;\n\tactiveForm?: string;\n\tstatus?: TaskStepStatus;\n\tpriority?: TaskStepPriority;\n\towner?: string;\n\tnote?: string;\n\tnotes?: readonly string[];\n\tevidence?: readonly string[];\n}\n\nexport interface TaskStep {\n\tid: string;\n\tcontent: string;\n\tactiveForm?: string;\n\tstatus: TaskStepStatus;\n\tpriority?: TaskStepPriority;\n\towner?: string;\n\tnotes: readonly string[];\n\tevidence: readonly string[];\n\tcreatedAt: string;\n\tupdatedAt: string;\n}\n\nexport interface TaskStepsArchive {\n\tcompleted: number;\n\tcancelled: number;\n\tcompactedAt?: string;\n}\n\nexport interface TaskStepsState {\n\tversion: 1;\n\trevision: number;\n\tnextStepNumber: number;\n\tsteps: readonly TaskStep[];\n\tarchive: TaskStepsArchive;\n\tcreatedAt: string;\n\tupdatedAt: string;\n}\n\nexport interface TaskStepUpdate {\n\tcontent?: string;\n\tactiveForm?: string;\n\tstatus?: TaskStepStatus;\n\tpriority?: TaskStepPriority;\n\towner?: string;\n\tnote?: string;\n\tevidence?: readonly string[];\n}\n\nexport class TaskStepsError extends Error {\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"TaskStepsError\";\n\t}\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\tif (!value || typeof value !== \"object\" || Array.isArray(value)) return false;\n\tconst prototype = Object.getPrototypeOf(value);\n\treturn prototype === Object.prototype || prototype === null;\n}\n\nfunction isTaskStepStatus(value: unknown): value is TaskStepStatus {\n\treturn TASK_STEP_STATUSES.some((status) => status === value);\n}\n\nfunction isTaskStepPriority(value: unknown): value is TaskStepPriority {\n\treturn TASK_STEP_PRIORITIES.some((priority) => priority === value);\n}\n\nfunction hasOptionalString(record: Record<string, unknown>, key: string, maxLength: number): boolean {\n\tconst value = record[key];\n\treturn value === undefined || (typeof value === \"string\" && value.length <= maxLength);\n}\n\nfunction isBoundedStringArray(value: unknown, maxItems: number, maxLength: number): value is readonly string[] {\n\treturn (\n\t\tArray.isArray(value) &&\n\t\tvalue.length <= maxItems &&\n\t\tvalue.every((item) => typeof item === \"string\" && item.length > 0 && item.length <= maxLength)\n\t);\n}\n\nfunction isTaskStep(value: unknown): value is TaskStep {\n\tif (!isRecord(value)) return false;\n\treturn (\n\t\ttypeof value.id === \"string\" &&\n\t\t/^step-[1-9]\\d*$/.test(value.id) &&\n\t\ttypeof value.content === \"string\" &&\n\t\tvalue.content.length > 0 &&\n\t\tvalue.content.length <= MAX_TASK_STEP_CONTENT_LENGTH &&\n\t\thasOptionalString(value, \"activeForm\", MAX_TASK_STEP_CONTENT_LENGTH) &&\n\t\tisTaskStepStatus(value.status) &&\n\t\t(value.priority === undefined || isTaskStepPriority(value.priority)) &&\n\t\thasOptionalString(value, \"owner\", MAX_TASK_STEP_OWNER_LENGTH) &&\n\t\tisBoundedStringArray(value.notes, MAX_TASK_STEP_EVIDENCE, MAX_TASK_STEP_NOTE_LENGTH) &&\n\t\tisBoundedStringArray(value.evidence, MAX_TASK_STEP_EVIDENCE, MAX_TASK_STEP_EVIDENCE_LENGTH) &&\n\t\ttypeof value.createdAt === \"string\" &&\n\t\ttypeof value.updatedAt === \"string\"\n\t);\n}\n\nfunction isTaskStepsArchive(value: unknown): value is TaskStepsArchive {\n\tif (!isRecord(value)) return false;\n\treturn (\n\t\tNumber.isInteger(value.completed) &&\n\t\tNumber(value.completed) >= 0 &&\n\t\tNumber.isInteger(value.cancelled) &&\n\t\tNumber(value.cancelled) >= 0 &&\n\t\thasOptionalString(value, \"compactedAt\", 100)\n\t);\n}\n\nexport function isTaskStepsState(value: unknown): value is TaskStepsState {\n\tif (!isRecord(value)) return false;\n\tif (\n\t\tvalue.version !== 1 ||\n\t\t!Number.isInteger(value.revision) ||\n\t\tNumber(value.revision) < 0 ||\n\t\t!Number.isInteger(value.nextStepNumber) ||\n\t\tNumber(value.nextStepNumber) < 1 ||\n\t\t!Array.isArray(value.steps) ||\n\t\tvalue.steps.length > MAX_TASK_STEPS ||\n\t\t!value.steps.every(isTaskStep) ||\n\t\t!isTaskStepsArchive(value.archive) ||\n\t\ttypeof value.createdAt !== \"string\" ||\n\t\ttypeof value.updatedAt !== \"string\"\n\t) {\n\t\treturn false;\n\t}\n\tconst ids = new Set(value.steps.map((step) => step.id));\n\treturn ids.size === value.steps.length && value.steps.filter((step) => step.status === \"in_progress\").length <= 1;\n}\n\nfunction cloneTaskStep(step: TaskStep): TaskStep {\n\treturn { ...step, notes: [...step.notes], evidence: [...step.evidence] };\n}\n\nexport function cloneTaskStepsState(state: TaskStepsState): TaskStepsState {\n\treturn {\n\t\t...state,\n\t\tsteps: state.steps.map(cloneTaskStep),\n\t\tarchive: { ...state.archive },\n\t};\n}\n\nexport function createTaskStepsState(now: string): TaskStepsState {\n\treturn {\n\t\tversion: 1,\n\t\trevision: 0,\n\t\tnextStepNumber: 1,\n\t\tsteps: [],\n\t\tarchive: { completed: 0, cancelled: 0 },\n\t\tcreatedAt: now,\n\t\tupdatedAt: now,\n\t};\n}\n\nfunction requireBoundedText(value: string, label: string, maxLength: number): string {\n\tconst normalized = value.trim();\n\tif (!normalized) throw new TaskStepsError(`${label} is required.`);\n\tif (normalized.length > maxLength) throw new TaskStepsError(`${label} must be at most ${maxLength} characters.`);\n\treturn normalized;\n}\n\nfunction optionalBoundedText(value: string | undefined, label: string, maxLength: number): string | undefined {\n\tif (value === undefined) return undefined;\n\tconst normalized = value.trim();\n\tif (!normalized) return undefined;\n\tif (normalized.length > maxLength) throw new TaskStepsError(`${label} must be at most ${maxLength} characters.`);\n\treturn normalized;\n}\n\nfunction normalizeStrings(values: readonly string[] | undefined, label: string, maxLength: number): string[] {\n\tif (!values) return [];\n\tconst normalized: string[] = [];\n\tfor (const value of values) {\n\t\tconst item = requireBoundedText(value, label, maxLength);\n\t\tif (!normalized.includes(item)) normalized.push(item);\n\t}\n\tif (normalized.length > MAX_TASK_STEP_EVIDENCE) {\n\t\tthrow new TaskStepsError(`${label} supports at most ${MAX_TASK_STEP_EVIDENCE} entries.`);\n\t}\n\treturn normalized;\n}\n\nfunction appendUniqueStrings(\n\tcurrent: readonly string[],\n\tvalues: readonly string[] | undefined,\n\tlabel: string,\n\tmaxLength: number,\n): string[] {\n\tconst appended = [...current];\n\tfor (const value of normalizeStrings(values, label, maxLength)) {\n\t\tif (!appended.includes(value)) appended.push(value);\n\t}\n\tif (appended.length > MAX_TASK_STEP_EVIDENCE) {\n\t\tthrow new TaskStepsError(`${label} supports at most ${MAX_TASK_STEP_EVIDENCE} entries.`);\n\t}\n\treturn appended;\n}\n\nfunction normalizeInputNotes(input: TaskStepInput): string[] {\n\tconst notes = normalizeStrings(input.notes, \"Task step note\", MAX_TASK_STEP_NOTE_LENGTH);\n\tconst note = optionalBoundedText(input.note, \"Task step note\", MAX_TASK_STEP_NOTE_LENGTH);\n\tif (note && !notes.includes(note)) notes.push(note);\n\treturn notes;\n}\n\nfunction demoteOtherActiveSteps(steps: TaskStep[], activeIndex: number): void {\n\tfor (let index = 0; index < steps.length; index++) {\n\t\tif (index !== activeIndex && steps[index].status === \"in_progress\") {\n\t\t\tsteps[index] = { ...steps[index], status: \"pending\" };\n\t\t}\n\t}\n}\n\nfunction nextState(state: TaskStepsState, steps: readonly TaskStep[], now: string): TaskStepsState {\n\treturn {\n\t\t...state,\n\t\trevision: state.revision + 1,\n\t\tsteps: steps.map(cloneTaskStep),\n\t\tarchive: { ...state.archive },\n\t\tupdatedAt: now,\n\t};\n}\n\nfunction createStep(args: {\n\tinput: TaskStepInput;\n\tid: string;\n\tcreatedAt: string;\n\tupdatedAt: string;\n\texisting?: TaskStep;\n}): TaskStep {\n\tconst existing = args.existing;\n\tconst notes =\n\t\targs.input.note === undefined && args.input.notes === undefined\n\t\t\t? [...(existing?.notes ?? [])]\n\t\t\t: normalizeInputNotes(args.input);\n\tconst evidence =\n\t\targs.input.evidence === undefined\n\t\t\t? [...(existing?.evidence ?? [])]\n\t\t\t: normalizeStrings(args.input.evidence, \"Task step evidence\", MAX_TASK_STEP_EVIDENCE_LENGTH);\n\treturn {\n\t\tid: args.id,\n\t\tcontent: requireBoundedText(args.input.content, \"Task step content\", MAX_TASK_STEP_CONTENT_LENGTH),\n\t\tactiveForm:\n\t\t\targs.input.activeForm === undefined\n\t\t\t\t? existing?.activeForm\n\t\t\t\t: optionalBoundedText(args.input.activeForm, \"Task step active form\", MAX_TASK_STEP_CONTENT_LENGTH),\n\t\tstatus: args.input.status ?? existing?.status ?? \"pending\",\n\t\tpriority: args.input.priority ?? existing?.priority,\n\t\towner:\n\t\t\targs.input.owner === undefined\n\t\t\t\t? existing?.owner\n\t\t\t\t: optionalBoundedText(args.input.owner, \"Task step owner\", MAX_TASK_STEP_OWNER_LENGTH),\n\t\tnotes,\n\t\tevidence,\n\t\tcreatedAt: args.createdAt,\n\t\tupdatedAt: args.updatedAt,\n\t};\n}\n\nexport function setTaskSteps(state: TaskStepsState, inputs: readonly TaskStepInput[], now: string): TaskStepsState {\n\tif (inputs.length > MAX_TASK_STEPS) {\n\t\tthrow new TaskStepsError(`Task steps supports at most ${MAX_TASK_STEPS} steps.`);\n\t}\n\tconst existingByContent = new Map<string, TaskStep[]>();\n\tfor (const step of state.steps) {\n\t\tconst key = step.content.toLocaleLowerCase();\n\t\tconst matches = existingByContent.get(key) ?? [];\n\t\tmatches.push(step);\n\t\texistingByContent.set(key, matches);\n\t}\n\n\tlet nextStepNumber = state.nextStepNumber;\n\tconst steps = inputs.map((input) => {\n\t\tconst content = requireBoundedText(input.content, \"Task step content\", MAX_TASK_STEP_CONTENT_LENGTH);\n\t\tconst matches = existingByContent.get(content.toLocaleLowerCase());\n\t\tconst existing = matches?.shift();\n\t\tconst id = existing?.id ?? `step-${nextStepNumber++}`;\n\t\treturn createStep({\n\t\t\tinput: { ...input, content },\n\t\t\tid,\n\t\t\tcreatedAt: existing?.createdAt ?? now,\n\t\t\tupdatedAt: now,\n\t\t\texisting,\n\t\t});\n\t});\n\tconst activeIndex = steps.findLastIndex((step) => step.status === \"in_progress\");\n\tif (activeIndex >= 0) demoteOtherActiveSteps(steps, activeIndex);\n\treturn { ...nextState(state, steps, now), nextStepNumber };\n}\n\nexport function addTaskStep(state: TaskStepsState, input: TaskStepInput, now: string): TaskStepsState {\n\tif (state.steps.length >= MAX_TASK_STEPS) {\n\t\tthrow new TaskStepsError(`Task steps already has the maximum ${MAX_TASK_STEPS} steps.`);\n\t}\n\tconst step = createStep({ input, id: `step-${state.nextStepNumber}`, createdAt: now, updatedAt: now });\n\tconst steps = [...state.steps.map(cloneTaskStep), step];\n\tif (step.status === \"in_progress\") demoteOtherActiveSteps(steps, steps.length - 1);\n\treturn { ...nextState(state, steps, now), nextStepNumber: state.nextStepNumber + 1 };\n}\n\nexport function resolveTaskStepSelector(steps: readonly TaskStep[], selector: string): TaskStep {\n\tconst normalized = selector.trim().toLocaleLowerCase();\n\tif (!normalized) throw new TaskStepsError(\"Task step selector is required.\");\n\tif (normalized === \"current\" || normalized === \"active\") {\n\t\tconst active = steps.find((step) => step.status === \"in_progress\");\n\t\tif (!active) throw new TaskStepsError(\"No in_progress task step was found.\");\n\t\treturn active;\n\t}\n\n\tconst exactId = steps.find((step) => step.id.toLocaleLowerCase() === normalized);\n\tif (exactId) return exactId;\n\tconst idPrefix = steps.filter((step) => step.id.toLocaleLowerCase().startsWith(normalized));\n\tif (idPrefix.length === 1) return idPrefix[0];\n\tif (idPrefix.length > 1) {\n\t\tthrow new TaskStepsError(`Task step selector is ambiguous: ${idPrefix.map((step) => step.id).join(\", \")}.`);\n\t}\n\n\tconst exactContent = steps.filter((step) => step.content.toLocaleLowerCase() === normalized);\n\tif (exactContent.length === 1) return exactContent[0];\n\tconst contentMatches = steps.filter((step) => step.content.toLocaleLowerCase().includes(normalized));\n\tif (contentMatches.length === 1) return contentMatches[0];\n\tif (exactContent.length > 1 || contentMatches.length > 1) {\n\t\tconst matches = exactContent.length > 1 ? exactContent : contentMatches;\n\t\tthrow new TaskStepsError(`Task step selector is ambiguous: ${matches.map((step) => step.id).join(\", \")}.`);\n\t}\n\tthrow new TaskStepsError(`Task step not found for selector: ${selector}.`);\n}\n\nexport function updateTaskStep(\n\tstate: TaskStepsState,\n\tselector: string,\n\tupdate: TaskStepUpdate,\n\tnow: string,\n): TaskStepsState {\n\tconst selected = resolveTaskStepSelector(state.steps, selector);\n\tconst selectedIndex = state.steps.findIndex((step) => step.id === selected.id);\n\tconst steps = state.steps.map(cloneTaskStep);\n\tconst current = steps[selectedIndex];\n\tconst note = optionalBoundedText(update.note, \"Task step note\", MAX_TASK_STEP_NOTE_LENGTH);\n\tconst notes = note\n\t\t? appendUniqueStrings(current.notes, [note], \"Task step note\", MAX_TASK_STEP_NOTE_LENGTH)\n\t\t: [...current.notes];\n\tconst evidence = appendUniqueStrings(\n\t\tcurrent.evidence,\n\t\tupdate.evidence,\n\t\t\"Task step evidence\",\n\t\tMAX_TASK_STEP_EVIDENCE_LENGTH,\n\t);\n\tsteps[selectedIndex] = {\n\t\t...current,\n\t\tcontent:\n\t\t\tupdate.content === undefined\n\t\t\t\t? current.content\n\t\t\t\t: requireBoundedText(update.content, \"Task step content\", MAX_TASK_STEP_CONTENT_LENGTH),\n\t\tactiveForm:\n\t\t\tupdate.activeForm === undefined\n\t\t\t\t? current.activeForm\n\t\t\t\t: optionalBoundedText(update.activeForm, \"Task step active form\", MAX_TASK_STEP_CONTENT_LENGTH),\n\t\tstatus: update.status ?? current.status,\n\t\tpriority: update.priority ?? current.priority,\n\t\towner:\n\t\t\tupdate.owner === undefined\n\t\t\t\t? current.owner\n\t\t\t\t: optionalBoundedText(update.owner, \"Task step owner\", MAX_TASK_STEP_OWNER_LENGTH),\n\t\tnotes,\n\t\tevidence,\n\t\tupdatedAt: now,\n\t};\n\tif (steps[selectedIndex].status === \"in_progress\") demoteOtherActiveSteps(steps, selectedIndex);\n\treturn nextState(state, steps, now);\n}\n\nexport function clearTaskSteps(state: TaskStepsState, now: string): TaskStepsState {\n\treturn {\n\t\t...nextState(state, [], now),\n\t\tarchive: { completed: 0, cancelled: 0 },\n\t};\n}\n\nexport function compactTaskSteps(state: TaskStepsState, now: string): TaskStepsState {\n\tconst completed = state.steps.filter((step) => step.status === \"completed\").length;\n\tconst cancelled = state.steps.filter((step) => step.status === \"cancelled\").length;\n\tconst open = state.steps.filter((step) => step.status !== \"completed\" && step.status !== \"cancelled\");\n\treturn {\n\t\t...nextState(state, open, now),\n\t\tarchive: {\n\t\t\tcompleted: state.archive.completed + completed,\n\t\t\tcancelled: state.archive.cancelled + cancelled,\n\t\t\tcompactedAt: now,\n\t\t},\n\t};\n}\n\nexport function formatTaskSteps(\n\tstate: TaskStepsState,\n\toptions: { includeTerminal?: boolean; maxItems?: number } = {},\n): string {\n\tconst visible = options.includeTerminal\n\t\t? state.steps\n\t\t: state.steps.filter((step) => step.status !== \"completed\" && step.status !== \"cancelled\");\n\tconst maxItems = Math.max(1, Math.min(MAX_TASK_STEPS, Math.floor(options.maxItems ?? 20)));\n\tconst statusMarker: Record<TaskStepStatus, string> = {\n\t\tpending: \" \",\n\t\tin_progress: \">\",\n\t\tcompleted: \"x\",\n\t\tblocked: \"!\",\n\t\tcancelled: \"-\",\n\t};\n\tconst lines = [`Task steps (${visible.length} visible, ${state.steps.length} tracked):`];\n\tfor (const step of visible.slice(0, maxItems)) {\n\t\tconst details = [step.priority, step.owner].filter(Boolean).join(\", \");\n\t\tlines.push(\n\t\t\t`- [${statusMarker[step.status]}] ${step.id} ${step.activeForm || step.content}${details ? ` (${details})` : \"\"}`,\n\t\t);\n\t\tfor (const note of step.notes.slice(-2)) lines.push(` note: ${note}`);\n\t\tfor (const evidence of step.evidence.slice(-2)) lines.push(` evidence: ${evidence}`);\n\t}\n\tif (visible.length > maxItems) lines.push(`- … ${visible.length - maxItems} more`);\n\tif (state.archive.completed || state.archive.cancelled) {\n\t\tlines.push(\n\t\t\t`Archived terminal steps: ${state.archive.completed} completed, ${state.archive.cancelled} cancelled.`,\n\t\t);\n\t}\n\treturn lines.join(\"\\n\");\n}\n\nexport function formatTaskStepsContext(state: TaskStepsState, maxItems = 12): string | undefined {\n\tconst open = state.steps.filter((step) => step.status !== \"completed\" && step.status !== \"cancelled\");\n\tif (open.length === 0) return undefined;\n\tconst limit = Math.max(1, Math.min(MAX_TASK_STEPS, Math.floor(maxItems)));\n\tconst lines = [\n\t\t\"Current native task_steps context for this session:\",\n\t\t\"Open task_steps:\",\n\t\t...open.slice(0, limit).map((step) => `- [${step.status}] ${step.activeForm || step.content}`),\n\t];\n\tif (open.length > limit) lines.push(`- … ${open.length - limit} more open step(s)`);\n\tconst active = open.find((step) => step.status === \"in_progress\");\n\tlines.push(\n\t\t\"\",\n\t\tactive\n\t\t\t? `Continue the in_progress step first: ${active.activeForm || active.content}. Update it completed, blocked, or cancelled as soon as evidence is known.`\n\t\t\t: `No step is in_progress. Start the first open step before unrelated work: ${open[0].activeForm || open[0].content}.`,\n\t\t\"Use task_steps to keep this checklist current and leave no stale in_progress step before the final response.\",\n\t);\n\treturn lines.join(\"\\n\");\n}\n\nexport function serializeTaskStepsState(state: TaskStepsState): string {\n\treturn JSON.stringify(cloneTaskStepsState(state), null, 2);\n}\n\nexport function parseTaskStepsState(text: string): TaskStepsState | undefined {\n\ttry {\n\t\tconst parsed: unknown = JSON.parse(text);\n\t\treturn isTaskStepsState(parsed) ? cloneTaskStepsState(parsed) : undefined;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"task-state.d.ts","sourceRoot":"","sources":["../../../src/core/tasks/task-state.ts"],"names":[],"mappings":"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","sourcesContent":["import { isPlainRecord } from \"../util/value-guards.ts\";\n\nexport const TASK_STEP_STATUSES = [\"pending\", \"in_progress\", \"completed\", \"blocked\", \"cancelled\"] as const;\nexport type TaskStepStatus = (typeof TASK_STEP_STATUSES)[number];\n\nexport const TASK_STEP_PRIORITIES = [\"low\", \"normal\", \"high\"] as const;\nexport type TaskStepPriority = (typeof TASK_STEP_PRIORITIES)[number];\n\nexport const MAX_TASK_STEPS = 100;\nexport const MAX_TASK_STEP_CONTENT_LENGTH = 2_000;\nconst MAX_TASK_STEP_NOTE_LENGTH = 4_000;\nconst MAX_TASK_STEP_OWNER_LENGTH = 200;\nconst MAX_TASK_STEP_EVIDENCE = 32;\nconst MAX_TASK_STEP_EVIDENCE_LENGTH = 2_000;\nconst MAX_TASK_STEP_REQUIREMENTS = 32;\nconst MAX_TASK_STEP_REQUIREMENT_ID_LENGTH = 200;\n\nexport interface TaskStepInput {\n\tcontent: string;\n\tactiveForm?: string;\n\tstatus?: TaskStepStatus;\n\tpriority?: TaskStepPriority;\n\towner?: string;\n\trequirementIds?: readonly string[];\n\tnote?: string;\n\tnotes?: readonly string[];\n\tevidence?: readonly string[];\n}\n\nexport interface TaskStep {\n\tid: string;\n\tcontent: string;\n\tactiveForm?: string;\n\tstatus: TaskStepStatus;\n\tpriority?: TaskStepPriority;\n\towner?: string;\n\t/** Goal requirements this foreground step advances. Optional only for snapshots from older sessions. */\n\trequirementIds?: readonly string[];\n\tnotes: readonly string[];\n\tevidence: readonly string[];\n\tcreatedAt: string;\n\tupdatedAt: string;\n}\n\nexport interface TaskStepsArchive {\n\tcompleted: number;\n\tcancelled: number;\n\tcompactedAt?: string;\n}\n\nexport interface TaskStepsState {\n\tversion: 1;\n\trevision: number;\n\tnextStepNumber: number;\n\tsteps: readonly TaskStep[];\n\tarchive: TaskStepsArchive;\n\tcreatedAt: string;\n\tupdatedAt: string;\n}\n\nexport interface TaskStepUpdate {\n\tcontent?: string;\n\tactiveForm?: string;\n\tstatus?: TaskStepStatus;\n\tpriority?: TaskStepPriority;\n\towner?: string;\n\trequirementIds?: readonly string[];\n\tnote?: string;\n\tevidence?: readonly string[];\n}\n\nexport class TaskStepsError extends Error {\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"TaskStepsError\";\n\t}\n}\n\nfunction isTaskStepStatus(value: unknown): value is TaskStepStatus {\n\treturn TASK_STEP_STATUSES.some((status) => status === value);\n}\n\nfunction isTaskStepPriority(value: unknown): value is TaskStepPriority {\n\treturn TASK_STEP_PRIORITIES.some((priority) => priority === value);\n}\n\nfunction hasOptionalString(record: Record<string, unknown>, key: string, maxLength: number): boolean {\n\tconst value = record[key];\n\treturn value === undefined || (typeof value === \"string\" && value.length <= maxLength);\n}\n\nfunction isBoundedStringArray(value: unknown, maxItems: number, maxLength: number): value is readonly string[] {\n\treturn (\n\t\tArray.isArray(value) &&\n\t\tvalue.length <= maxItems &&\n\t\tvalue.every((item) => typeof item === \"string\" && item.length > 0 && item.length <= maxLength)\n\t);\n}\n\nfunction isTaskStep(value: unknown): value is TaskStep {\n\tif (!isPlainRecord(value)) return false;\n\treturn (\n\t\ttypeof value.id === \"string\" &&\n\t\t/^step-[1-9]\\d*$/.test(value.id) &&\n\t\ttypeof value.content === \"string\" &&\n\t\tvalue.content.length > 0 &&\n\t\tvalue.content.length <= MAX_TASK_STEP_CONTENT_LENGTH &&\n\t\thasOptionalString(value, \"activeForm\", MAX_TASK_STEP_CONTENT_LENGTH) &&\n\t\tisTaskStepStatus(value.status) &&\n\t\t(value.priority === undefined || isTaskStepPriority(value.priority)) &&\n\t\thasOptionalString(value, \"owner\", MAX_TASK_STEP_OWNER_LENGTH) &&\n\t\t(value.requirementIds === undefined ||\n\t\t\tisBoundedStringArray(value.requirementIds, MAX_TASK_STEP_REQUIREMENTS, MAX_TASK_STEP_REQUIREMENT_ID_LENGTH)) &&\n\t\tisBoundedStringArray(value.notes, MAX_TASK_STEP_EVIDENCE, MAX_TASK_STEP_NOTE_LENGTH) &&\n\t\tisBoundedStringArray(value.evidence, MAX_TASK_STEP_EVIDENCE, MAX_TASK_STEP_EVIDENCE_LENGTH) &&\n\t\ttypeof value.createdAt === \"string\" &&\n\t\ttypeof value.updatedAt === \"string\"\n\t);\n}\n\nfunction isTaskStepsArchive(value: unknown): value is TaskStepsArchive {\n\tif (!isPlainRecord(value)) return false;\n\treturn (\n\t\tNumber.isInteger(value.completed) &&\n\t\tNumber(value.completed) >= 0 &&\n\t\tNumber.isInteger(value.cancelled) &&\n\t\tNumber(value.cancelled) >= 0 &&\n\t\thasOptionalString(value, \"compactedAt\", 100)\n\t);\n}\n\nexport function isTaskStepsState(value: unknown): value is TaskStepsState {\n\tif (!isPlainRecord(value)) return false;\n\tif (\n\t\tvalue.version !== 1 ||\n\t\t!Number.isInteger(value.revision) ||\n\t\tNumber(value.revision) < 0 ||\n\t\t!Number.isInteger(value.nextStepNumber) ||\n\t\tNumber(value.nextStepNumber) < 1 ||\n\t\t!Array.isArray(value.steps) ||\n\t\tvalue.steps.length > MAX_TASK_STEPS ||\n\t\t!value.steps.every(isTaskStep) ||\n\t\t!isTaskStepsArchive(value.archive) ||\n\t\ttypeof value.createdAt !== \"string\" ||\n\t\ttypeof value.updatedAt !== \"string\"\n\t) {\n\t\treturn false;\n\t}\n\tconst ids = new Set(value.steps.map((step) => step.id));\n\treturn ids.size === value.steps.length && value.steps.filter((step) => step.status === \"in_progress\").length <= 1;\n}\n\nfunction cloneTaskStep(step: TaskStep): TaskStep {\n\treturn {\n\t\t...step,\n\t\trequirementIds: [...(step.requirementIds ?? [])],\n\t\tnotes: [...step.notes],\n\t\tevidence: [...step.evidence],\n\t};\n}\n\nexport function cloneTaskStepsState(state: TaskStepsState): TaskStepsState {\n\treturn {\n\t\t...state,\n\t\tsteps: state.steps.map(cloneTaskStep),\n\t\tarchive: { ...state.archive },\n\t};\n}\n\nexport function createTaskStepsState(now: string): TaskStepsState {\n\treturn {\n\t\tversion: 1,\n\t\trevision: 0,\n\t\tnextStepNumber: 1,\n\t\tsteps: [],\n\t\tarchive: { completed: 0, cancelled: 0 },\n\t\tcreatedAt: now,\n\t\tupdatedAt: now,\n\t};\n}\n\nfunction requireBoundedText(value: string, label: string, maxLength: number): string {\n\tconst normalized = value.trim();\n\tif (!normalized) throw new TaskStepsError(`${label} is required.`);\n\tif (normalized.length > maxLength) throw new TaskStepsError(`${label} must be at most ${maxLength} characters.`);\n\treturn normalized;\n}\n\nfunction optionalBoundedText(value: string | undefined, label: string, maxLength: number): string | undefined {\n\tif (value === undefined) return undefined;\n\tconst normalized = value.trim();\n\tif (!normalized) return undefined;\n\tif (normalized.length > maxLength) throw new TaskStepsError(`${label} must be at most ${maxLength} characters.`);\n\treturn normalized;\n}\n\nfunction normalizeStrings(values: readonly string[] | undefined, label: string, maxLength: number): string[] {\n\tif (!values) return [];\n\tconst normalized: string[] = [];\n\tfor (const value of values) {\n\t\tconst item = requireBoundedText(value, label, maxLength);\n\t\tif (!normalized.includes(item)) normalized.push(item);\n\t}\n\tif (normalized.length > MAX_TASK_STEP_EVIDENCE) {\n\t\tthrow new TaskStepsError(`${label} supports at most ${MAX_TASK_STEP_EVIDENCE} entries.`);\n\t}\n\treturn normalized;\n}\n\nfunction appendUniqueStrings(\n\tcurrent: readonly string[],\n\tvalues: readonly string[] | undefined,\n\tlabel: string,\n\tmaxLength: number,\n): string[] {\n\tconst appended = [...current];\n\tfor (const value of normalizeStrings(values, label, maxLength)) {\n\t\tif (!appended.includes(value)) appended.push(value);\n\t}\n\tif (appended.length > MAX_TASK_STEP_EVIDENCE) {\n\t\tthrow new TaskStepsError(`${label} supports at most ${MAX_TASK_STEP_EVIDENCE} entries.`);\n\t}\n\treturn appended;\n}\n\nfunction normalizeInputNotes(input: TaskStepInput): string[] {\n\tconst notes = normalizeStrings(input.notes, \"Task step note\", MAX_TASK_STEP_NOTE_LENGTH);\n\tconst note = optionalBoundedText(input.note, \"Task step note\", MAX_TASK_STEP_NOTE_LENGTH);\n\tif (note && !notes.includes(note)) notes.push(note);\n\treturn notes;\n}\n\n/**\n * Find an OPEN (non-terminal) step whose content matches `content` case-insensitively.\n * Terminal steps (completed/cancelled) are deliberately excluded so a legitimate re-add of\n * previously finished work still creates a new step.\n */\nexport function findOpenDuplicateStep(steps: readonly TaskStep[], content: string): TaskStep | undefined {\n\tconst normalized = content.trim().toLocaleLowerCase();\n\tif (!normalized) return undefined;\n\treturn steps.find(\n\t\t(step) =>\n\t\t\tstep.status !== \"completed\" && step.status !== \"cancelled\" && step.content.toLocaleLowerCase() === normalized,\n\t);\n}\n\n/** True when a completed step has no evidence attached (a verification nudge candidate). */\nexport function hasUnverifiedCompletedStep(state: TaskStepsState): boolean {\n\treturn state.steps.some((step) => step.status === \"completed\" && step.evidence.length === 0);\n}\n\nfunction demoteOtherActiveSteps(steps: TaskStep[], activeIndex: number): void {\n\tfor (let index = 0; index < steps.length; index++) {\n\t\tif (index !== activeIndex && steps[index].status === \"in_progress\") {\n\t\t\tsteps[index] = { ...steps[index], status: \"pending\" };\n\t\t}\n\t}\n}\n\nfunction nextState(state: TaskStepsState, steps: readonly TaskStep[], now: string): TaskStepsState {\n\treturn {\n\t\t...state,\n\t\trevision: state.revision + 1,\n\t\tsteps: steps.map(cloneTaskStep),\n\t\tarchive: { ...state.archive },\n\t\tupdatedAt: now,\n\t};\n}\n\nfunction createStep(args: {\n\tinput: TaskStepInput;\n\tid: string;\n\tcreatedAt: string;\n\tupdatedAt: string;\n\texisting?: TaskStep;\n}): TaskStep {\n\tconst existing = args.existing;\n\tconst notes =\n\t\targs.input.note === undefined && args.input.notes === undefined\n\t\t\t? [...(existing?.notes ?? [])]\n\t\t\t: normalizeInputNotes(args.input);\n\tconst evidence =\n\t\targs.input.evidence === undefined\n\t\t\t? [...(existing?.evidence ?? [])]\n\t\t\t: normalizeStrings(args.input.evidence, \"Task step evidence\", MAX_TASK_STEP_EVIDENCE_LENGTH);\n\tconst requirementIds =\n\t\targs.input.requirementIds === undefined\n\t\t\t? [...(existing?.requirementIds ?? [])]\n\t\t\t: normalizeStrings(args.input.requirementIds, \"Task step requirement id\", MAX_TASK_STEP_REQUIREMENT_ID_LENGTH);\n\treturn {\n\t\tid: args.id,\n\t\tcontent: requireBoundedText(args.input.content, \"Task step content\", MAX_TASK_STEP_CONTENT_LENGTH),\n\t\tactiveForm:\n\t\t\targs.input.activeForm === undefined\n\t\t\t\t? existing?.activeForm\n\t\t\t\t: optionalBoundedText(args.input.activeForm, \"Task step active form\", MAX_TASK_STEP_CONTENT_LENGTH),\n\t\tstatus: args.input.status ?? existing?.status ?? \"pending\",\n\t\tpriority: args.input.priority ?? existing?.priority,\n\t\towner:\n\t\t\targs.input.owner === undefined\n\t\t\t\t? existing?.owner\n\t\t\t\t: optionalBoundedText(args.input.owner, \"Task step owner\", MAX_TASK_STEP_OWNER_LENGTH),\n\t\trequirementIds,\n\t\tnotes,\n\t\tevidence,\n\t\tcreatedAt: args.createdAt,\n\t\tupdatedAt: args.updatedAt,\n\t};\n}\n\nexport function setTaskSteps(state: TaskStepsState, inputs: readonly TaskStepInput[], now: string): TaskStepsState {\n\tif (inputs.length > MAX_TASK_STEPS) {\n\t\tthrow new TaskStepsError(`Task steps supports at most ${MAX_TASK_STEPS} steps.`);\n\t}\n\tconst existingByContent = new Map<string, TaskStep[]>();\n\tfor (const step of state.steps) {\n\t\tconst key = step.content.toLocaleLowerCase();\n\t\tconst matches = existingByContent.get(key) ?? [];\n\t\tmatches.push(step);\n\t\texistingByContent.set(key, matches);\n\t}\n\n\tlet nextStepNumber = state.nextStepNumber;\n\tconst steps = inputs.map((input) => {\n\t\tconst content = requireBoundedText(input.content, \"Task step content\", MAX_TASK_STEP_CONTENT_LENGTH);\n\t\tconst matches = existingByContent.get(content.toLocaleLowerCase());\n\t\tconst existing = matches?.shift();\n\t\tconst id = existing?.id ?? `step-${nextStepNumber++}`;\n\t\treturn createStep({\n\t\t\tinput: { ...input, content },\n\t\t\tid,\n\t\t\tcreatedAt: existing?.createdAt ?? now,\n\t\t\tupdatedAt: now,\n\t\t\texisting,\n\t\t});\n\t});\n\tconst activeIndex = steps.findLastIndex((step) => step.status === \"in_progress\");\n\tif (activeIndex >= 0) demoteOtherActiveSteps(steps, activeIndex);\n\treturn { ...nextState(state, steps, now), nextStepNumber };\n}\n\nexport function addTaskStep(state: TaskStepsState, input: TaskStepInput, now: string): TaskStepsState {\n\t// Dedupe against OPEN steps only, before the capacity check: a duplicate re-add of an\n\t// already-open step is a no-op regardless of whether the list happens to be full. Terminal\n\t// (completed/cancelled) matches are excluded so a legitimate re-add still creates a step.\n\tif (findOpenDuplicateStep(state.steps, input.content)) return state;\n\tif (state.steps.length >= MAX_TASK_STEPS) {\n\t\tthrow new TaskStepsError(`Task steps already has the maximum ${MAX_TASK_STEPS} steps.`);\n\t}\n\tconst step = createStep({ input, id: `step-${state.nextStepNumber}`, createdAt: now, updatedAt: now });\n\tconst steps = [...state.steps.map(cloneTaskStep), step];\n\tif (step.status === \"in_progress\") demoteOtherActiveSteps(steps, steps.length - 1);\n\treturn { ...nextState(state, steps, now), nextStepNumber: state.nextStepNumber + 1 };\n}\n\nexport function resolveTaskStepSelector(steps: readonly TaskStep[], selector: string): TaskStep {\n\tconst normalized = selector.trim().toLocaleLowerCase();\n\tif (!normalized) throw new TaskStepsError(\"Task step selector is required.\");\n\tif (normalized === \"current\" || normalized === \"active\") {\n\t\tconst active = steps.find((step) => step.status === \"in_progress\");\n\t\tif (!active) throw new TaskStepsError(\"No in_progress task step was found.\");\n\t\treturn active;\n\t}\n\n\tconst exactId = steps.find((step) => step.id.toLocaleLowerCase() === normalized);\n\tif (exactId) return exactId;\n\tconst idPrefix = steps.filter((step) => step.id.toLocaleLowerCase().startsWith(normalized));\n\tif (idPrefix.length === 1) return idPrefix[0];\n\tif (idPrefix.length > 1) {\n\t\tthrow new TaskStepsError(`Task step selector is ambiguous: ${idPrefix.map((step) => step.id).join(\", \")}.`);\n\t}\n\n\tconst exactContent = steps.filter((step) => step.content.toLocaleLowerCase() === normalized);\n\tif (exactContent.length === 1) return exactContent[0];\n\tconst contentMatches = steps.filter((step) => step.content.toLocaleLowerCase().includes(normalized));\n\tif (contentMatches.length === 1) return contentMatches[0];\n\tif (exactContent.length > 1 || contentMatches.length > 1) {\n\t\tconst matches = exactContent.length > 1 ? exactContent : contentMatches;\n\t\tthrow new TaskStepsError(`Task step selector is ambiguous: ${matches.map((step) => step.id).join(\", \")}.`);\n\t}\n\tthrow new TaskStepsError(`Task step not found for selector: ${selector}.`);\n}\n\nexport function updateTaskStep(\n\tstate: TaskStepsState,\n\tselector: string,\n\tupdate: TaskStepUpdate,\n\tnow: string,\n): TaskStepsState {\n\tconst selected = resolveTaskStepSelector(state.steps, selector);\n\tconst selectedIndex = state.steps.findIndex((step) => step.id === selected.id);\n\tconst steps = state.steps.map(cloneTaskStep);\n\tconst current = steps[selectedIndex];\n\tconst note = optionalBoundedText(update.note, \"Task step note\", MAX_TASK_STEP_NOTE_LENGTH);\n\tconst notes = note\n\t\t? appendUniqueStrings(current.notes, [note], \"Task step note\", MAX_TASK_STEP_NOTE_LENGTH)\n\t\t: [...current.notes];\n\tconst evidence = appendUniqueStrings(\n\t\tcurrent.evidence,\n\t\tupdate.evidence,\n\t\t\"Task step evidence\",\n\t\tMAX_TASK_STEP_EVIDENCE_LENGTH,\n\t);\n\tsteps[selectedIndex] = {\n\t\t...current,\n\t\tcontent:\n\t\t\tupdate.content === undefined\n\t\t\t\t? current.content\n\t\t\t\t: requireBoundedText(update.content, \"Task step content\", MAX_TASK_STEP_CONTENT_LENGTH),\n\t\tactiveForm:\n\t\t\tupdate.activeForm === undefined\n\t\t\t\t? current.activeForm\n\t\t\t\t: optionalBoundedText(update.activeForm, \"Task step active form\", MAX_TASK_STEP_CONTENT_LENGTH),\n\t\tstatus: update.status ?? current.status,\n\t\tpriority: update.priority ?? current.priority,\n\t\towner:\n\t\t\tupdate.owner === undefined\n\t\t\t\t? current.owner\n\t\t\t\t: optionalBoundedText(update.owner, \"Task step owner\", MAX_TASK_STEP_OWNER_LENGTH),\n\t\trequirementIds:\n\t\t\tupdate.requirementIds === undefined\n\t\t\t\t? [...(current.requirementIds ?? [])]\n\t\t\t\t: normalizeStrings(update.requirementIds, \"Task step requirement id\", MAX_TASK_STEP_REQUIREMENT_ID_LENGTH),\n\t\tnotes,\n\t\tevidence,\n\t\tupdatedAt: now,\n\t};\n\tif (steps[selectedIndex].status === \"in_progress\") demoteOtherActiveSteps(steps, selectedIndex);\n\treturn nextState(state, steps, now);\n}\n\nexport function clearTaskSteps(state: TaskStepsState, now: string): TaskStepsState {\n\treturn {\n\t\t...nextState(state, [], now),\n\t\tarchive: { completed: 0, cancelled: 0 },\n\t};\n}\n\nexport function compactTaskSteps(state: TaskStepsState, now: string): TaskStepsState {\n\tconst completed = state.steps.filter((step) => step.status === \"completed\").length;\n\tconst cancelled = state.steps.filter((step) => step.status === \"cancelled\").length;\n\tconst open = state.steps.filter((step) => step.status !== \"completed\" && step.status !== \"cancelled\");\n\treturn {\n\t\t...nextState(state, open, now),\n\t\tarchive: {\n\t\t\tcompleted: state.archive.completed + completed,\n\t\t\tcancelled: state.archive.cancelled + cancelled,\n\t\t\tcompactedAt: now,\n\t\t},\n\t};\n}\n\nexport function formatTaskSteps(\n\tstate: TaskStepsState,\n\toptions: { includeTerminal?: boolean; maxItems?: number } = {},\n): string {\n\tconst visible = options.includeTerminal\n\t\t? state.steps\n\t\t: state.steps.filter((step) => step.status !== \"completed\" && step.status !== \"cancelled\");\n\tconst maxItems = Math.max(1, Math.min(MAX_TASK_STEPS, Math.floor(options.maxItems ?? 20)));\n\tconst statusMarker: Record<TaskStepStatus, string> = {\n\t\tpending: \" \",\n\t\tin_progress: \">\",\n\t\tcompleted: \"x\",\n\t\tblocked: \"!\",\n\t\tcancelled: \"-\",\n\t};\n\tconst lines = [`Task steps (${visible.length} visible, ${state.steps.length} tracked):`];\n\tfor (const step of visible.slice(0, maxItems)) {\n\t\tconst details = [\n\t\t\tstep.priority,\n\t\t\tstep.owner,\n\t\t\tstep.requirementIds?.length ? `requirements: ${step.requirementIds.join(\", \")}` : undefined,\n\t\t]\n\t\t\t.filter(Boolean)\n\t\t\t.join(\", \");\n\t\tlines.push(\n\t\t\t`- [${statusMarker[step.status]}] ${step.id} ${step.activeForm || step.content}${details ? ` (${details})` : \"\"}`,\n\t\t);\n\t\tfor (const note of step.notes.slice(-2)) lines.push(` note: ${note}`);\n\t\tfor (const evidence of step.evidence.slice(-2)) lines.push(` evidence: ${evidence}`);\n\t}\n\tif (visible.length > maxItems) lines.push(`- … ${visible.length - maxItems} more`);\n\tif (state.archive.completed || state.archive.cancelled) {\n\t\tlines.push(\n\t\t\t`Archived terminal steps: ${state.archive.completed} completed, ${state.archive.cancelled} cancelled.`,\n\t\t);\n\t}\n\treturn lines.join(\"\\n\");\n}\n\nexport function formatTaskStepsContext(state: TaskStepsState, maxItems = 12): string | undefined {\n\tconst open = state.steps.filter((step) => step.status !== \"completed\" && step.status !== \"cancelled\");\n\tif (open.length === 0) return undefined;\n\tconst limit = Math.max(1, Math.min(MAX_TASK_STEPS, Math.floor(maxItems)));\n\tconst lines = [\n\t\t\"Current native task_steps context for this session:\",\n\t\t\"Open task_steps:\",\n\t\t...open.slice(0, limit).map((step) => `- [${step.status}] ${step.activeForm || step.content}`),\n\t];\n\tif (open.length > limit) lines.push(`- … ${open.length - limit} more open step(s)`);\n\tconst active = open.find((step) => step.status === \"in_progress\");\n\tlines.push(\n\t\t\"\",\n\t\tactive\n\t\t\t? `Continue the in_progress step first: ${active.activeForm || active.content}. Update it completed, blocked, or cancelled as soon as evidence is known.`\n\t\t\t: `No step is in_progress. Start the first open step before unrelated work: ${open[0].activeForm || open[0].content}.`,\n\t\t\"Use task_steps to keep this checklist current and leave no stale in_progress step before the final response.\",\n\t);\n\tif (hasUnverifiedCompletedStep(state)) {\n\t\tlines.push(\n\t\t\t\"A completed step has no evidence attached; attach evidence via task_steps update before treating it as verified.\",\n\t\t);\n\t}\n\t// Wrapped in a marker (mirrors the <memory_context> precedent) so context-gc's\n\t// semantic-memory packer can recognize this as a deterministic, re-derivable context page and\n\t// pack stale copies down to the most recent one instead of letting a full page accumulate every\n\t// turn. The revision (monotonic per mutation) lets a reader tell which page is current.\n\treturn `<task_steps_context revision=${state.revision}>\\n${lines.join(\"\\n\")}\\n</task_steps_context>`;\n}\n\nexport function serializeTaskStepsState(state: TaskStepsState): string {\n\treturn JSON.stringify(cloneTaskStepsState(state), null, 2);\n}\n\nexport function parseTaskStepsState(text: string): TaskStepsState | undefined {\n\ttry {\n\t\tconst parsed: unknown = JSON.parse(text);\n\t\treturn isTaskStepsState(parsed) ? cloneTaskStepsState(parsed) : undefined;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isPlainRecord } from "../util/value-guards.js";
|
|
1
2
|
export const TASK_STEP_STATUSES = ["pending", "in_progress", "completed", "blocked", "cancelled"];
|
|
2
3
|
export const TASK_STEP_PRIORITIES = ["low", "normal", "high"];
|
|
3
4
|
export const MAX_TASK_STEPS = 100;
|
|
@@ -6,18 +7,14 @@ const MAX_TASK_STEP_NOTE_LENGTH = 4_000;
|
|
|
6
7
|
const MAX_TASK_STEP_OWNER_LENGTH = 200;
|
|
7
8
|
const MAX_TASK_STEP_EVIDENCE = 32;
|
|
8
9
|
const MAX_TASK_STEP_EVIDENCE_LENGTH = 2_000;
|
|
10
|
+
const MAX_TASK_STEP_REQUIREMENTS = 32;
|
|
11
|
+
const MAX_TASK_STEP_REQUIREMENT_ID_LENGTH = 200;
|
|
9
12
|
export class TaskStepsError extends Error {
|
|
10
13
|
constructor(message) {
|
|
11
14
|
super(message);
|
|
12
15
|
this.name = "TaskStepsError";
|
|
13
16
|
}
|
|
14
17
|
}
|
|
15
|
-
function isRecord(value) {
|
|
16
|
-
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
17
|
-
return false;
|
|
18
|
-
const prototype = Object.getPrototypeOf(value);
|
|
19
|
-
return prototype === Object.prototype || prototype === null;
|
|
20
|
-
}
|
|
21
18
|
function isTaskStepStatus(value) {
|
|
22
19
|
return TASK_STEP_STATUSES.some((status) => status === value);
|
|
23
20
|
}
|
|
@@ -34,7 +31,7 @@ function isBoundedStringArray(value, maxItems, maxLength) {
|
|
|
34
31
|
value.every((item) => typeof item === "string" && item.length > 0 && item.length <= maxLength));
|
|
35
32
|
}
|
|
36
33
|
function isTaskStep(value) {
|
|
37
|
-
if (!
|
|
34
|
+
if (!isPlainRecord(value))
|
|
38
35
|
return false;
|
|
39
36
|
return (typeof value.id === "string" &&
|
|
40
37
|
/^step-[1-9]\d*$/.test(value.id) &&
|
|
@@ -45,13 +42,15 @@ function isTaskStep(value) {
|
|
|
45
42
|
isTaskStepStatus(value.status) &&
|
|
46
43
|
(value.priority === undefined || isTaskStepPriority(value.priority)) &&
|
|
47
44
|
hasOptionalString(value, "owner", MAX_TASK_STEP_OWNER_LENGTH) &&
|
|
45
|
+
(value.requirementIds === undefined ||
|
|
46
|
+
isBoundedStringArray(value.requirementIds, MAX_TASK_STEP_REQUIREMENTS, MAX_TASK_STEP_REQUIREMENT_ID_LENGTH)) &&
|
|
48
47
|
isBoundedStringArray(value.notes, MAX_TASK_STEP_EVIDENCE, MAX_TASK_STEP_NOTE_LENGTH) &&
|
|
49
48
|
isBoundedStringArray(value.evidence, MAX_TASK_STEP_EVIDENCE, MAX_TASK_STEP_EVIDENCE_LENGTH) &&
|
|
50
49
|
typeof value.createdAt === "string" &&
|
|
51
50
|
typeof value.updatedAt === "string");
|
|
52
51
|
}
|
|
53
52
|
function isTaskStepsArchive(value) {
|
|
54
|
-
if (!
|
|
53
|
+
if (!isPlainRecord(value))
|
|
55
54
|
return false;
|
|
56
55
|
return (Number.isInteger(value.completed) &&
|
|
57
56
|
Number(value.completed) >= 0 &&
|
|
@@ -60,7 +59,7 @@ function isTaskStepsArchive(value) {
|
|
|
60
59
|
hasOptionalString(value, "compactedAt", 100));
|
|
61
60
|
}
|
|
62
61
|
export function isTaskStepsState(value) {
|
|
63
|
-
if (!
|
|
62
|
+
if (!isPlainRecord(value))
|
|
64
63
|
return false;
|
|
65
64
|
if (value.version !== 1 ||
|
|
66
65
|
!Number.isInteger(value.revision) ||
|
|
@@ -79,7 +78,12 @@ export function isTaskStepsState(value) {
|
|
|
79
78
|
return ids.size === value.steps.length && value.steps.filter((step) => step.status === "in_progress").length <= 1;
|
|
80
79
|
}
|
|
81
80
|
function cloneTaskStep(step) {
|
|
82
|
-
return {
|
|
81
|
+
return {
|
|
82
|
+
...step,
|
|
83
|
+
requirementIds: [...(step.requirementIds ?? [])],
|
|
84
|
+
notes: [...step.notes],
|
|
85
|
+
evidence: [...step.evidence],
|
|
86
|
+
};
|
|
83
87
|
}
|
|
84
88
|
export function cloneTaskStepsState(state) {
|
|
85
89
|
return {
|
|
@@ -149,6 +153,21 @@ function normalizeInputNotes(input) {
|
|
|
149
153
|
notes.push(note);
|
|
150
154
|
return notes;
|
|
151
155
|
}
|
|
156
|
+
/**
|
|
157
|
+
* Find an OPEN (non-terminal) step whose content matches `content` case-insensitively.
|
|
158
|
+
* Terminal steps (completed/cancelled) are deliberately excluded so a legitimate re-add of
|
|
159
|
+
* previously finished work still creates a new step.
|
|
160
|
+
*/
|
|
161
|
+
export function findOpenDuplicateStep(steps, content) {
|
|
162
|
+
const normalized = content.trim().toLocaleLowerCase();
|
|
163
|
+
if (!normalized)
|
|
164
|
+
return undefined;
|
|
165
|
+
return steps.find((step) => step.status !== "completed" && step.status !== "cancelled" && step.content.toLocaleLowerCase() === normalized);
|
|
166
|
+
}
|
|
167
|
+
/** True when a completed step has no evidence attached (a verification nudge candidate). */
|
|
168
|
+
export function hasUnverifiedCompletedStep(state) {
|
|
169
|
+
return state.steps.some((step) => step.status === "completed" && step.evidence.length === 0);
|
|
170
|
+
}
|
|
152
171
|
function demoteOtherActiveSteps(steps, activeIndex) {
|
|
153
172
|
for (let index = 0; index < steps.length; index++) {
|
|
154
173
|
if (index !== activeIndex && steps[index].status === "in_progress") {
|
|
@@ -173,6 +192,9 @@ function createStep(args) {
|
|
|
173
192
|
const evidence = args.input.evidence === undefined
|
|
174
193
|
? [...(existing?.evidence ?? [])]
|
|
175
194
|
: normalizeStrings(args.input.evidence, "Task step evidence", MAX_TASK_STEP_EVIDENCE_LENGTH);
|
|
195
|
+
const requirementIds = args.input.requirementIds === undefined
|
|
196
|
+
? [...(existing?.requirementIds ?? [])]
|
|
197
|
+
: normalizeStrings(args.input.requirementIds, "Task step requirement id", MAX_TASK_STEP_REQUIREMENT_ID_LENGTH);
|
|
176
198
|
return {
|
|
177
199
|
id: args.id,
|
|
178
200
|
content: requireBoundedText(args.input.content, "Task step content", MAX_TASK_STEP_CONTENT_LENGTH),
|
|
@@ -184,6 +206,7 @@ function createStep(args) {
|
|
|
184
206
|
owner: args.input.owner === undefined
|
|
185
207
|
? existing?.owner
|
|
186
208
|
: optionalBoundedText(args.input.owner, "Task step owner", MAX_TASK_STEP_OWNER_LENGTH),
|
|
209
|
+
requirementIds,
|
|
187
210
|
notes,
|
|
188
211
|
evidence,
|
|
189
212
|
createdAt: args.createdAt,
|
|
@@ -221,6 +244,11 @@ export function setTaskSteps(state, inputs, now) {
|
|
|
221
244
|
return { ...nextState(state, steps, now), nextStepNumber };
|
|
222
245
|
}
|
|
223
246
|
export function addTaskStep(state, input, now) {
|
|
247
|
+
// Dedupe against OPEN steps only, before the capacity check: a duplicate re-add of an
|
|
248
|
+
// already-open step is a no-op regardless of whether the list happens to be full. Terminal
|
|
249
|
+
// (completed/cancelled) matches are excluded so a legitimate re-add still creates a step.
|
|
250
|
+
if (findOpenDuplicateStep(state.steps, input.content))
|
|
251
|
+
return state;
|
|
224
252
|
if (state.steps.length >= MAX_TASK_STEPS) {
|
|
225
253
|
throw new TaskStepsError(`Task steps already has the maximum ${MAX_TASK_STEPS} steps.`);
|
|
226
254
|
}
|
|
@@ -284,6 +312,9 @@ export function updateTaskStep(state, selector, update, now) {
|
|
|
284
312
|
owner: update.owner === undefined
|
|
285
313
|
? current.owner
|
|
286
314
|
: optionalBoundedText(update.owner, "Task step owner", MAX_TASK_STEP_OWNER_LENGTH),
|
|
315
|
+
requirementIds: update.requirementIds === undefined
|
|
316
|
+
? [...(current.requirementIds ?? [])]
|
|
317
|
+
: normalizeStrings(update.requirementIds, "Task step requirement id", MAX_TASK_STEP_REQUIREMENT_ID_LENGTH),
|
|
287
318
|
notes,
|
|
288
319
|
evidence,
|
|
289
320
|
updatedAt: now,
|
|
@@ -325,7 +356,13 @@ export function formatTaskSteps(state, options = {}) {
|
|
|
325
356
|
};
|
|
326
357
|
const lines = [`Task steps (${visible.length} visible, ${state.steps.length} tracked):`];
|
|
327
358
|
for (const step of visible.slice(0, maxItems)) {
|
|
328
|
-
const details = [
|
|
359
|
+
const details = [
|
|
360
|
+
step.priority,
|
|
361
|
+
step.owner,
|
|
362
|
+
step.requirementIds?.length ? `requirements: ${step.requirementIds.join(", ")}` : undefined,
|
|
363
|
+
]
|
|
364
|
+
.filter(Boolean)
|
|
365
|
+
.join(", ");
|
|
329
366
|
lines.push(`- [${statusMarker[step.status]}] ${step.id} ${step.activeForm || step.content}${details ? ` (${details})` : ""}`);
|
|
330
367
|
for (const note of step.notes.slice(-2))
|
|
331
368
|
lines.push(` note: ${note}`);
|
|
@@ -355,7 +392,14 @@ export function formatTaskStepsContext(state, maxItems = 12) {
|
|
|
355
392
|
lines.push("", active
|
|
356
393
|
? `Continue the in_progress step first: ${active.activeForm || active.content}. Update it completed, blocked, or cancelled as soon as evidence is known.`
|
|
357
394
|
: `No step is in_progress. Start the first open step before unrelated work: ${open[0].activeForm || open[0].content}.`, "Use task_steps to keep this checklist current and leave no stale in_progress step before the final response.");
|
|
358
|
-
|
|
395
|
+
if (hasUnverifiedCompletedStep(state)) {
|
|
396
|
+
lines.push("A completed step has no evidence attached; attach evidence via task_steps update before treating it as verified.");
|
|
397
|
+
}
|
|
398
|
+
// Wrapped in a marker (mirrors the <memory_context> precedent) so context-gc's
|
|
399
|
+
// semantic-memory packer can recognize this as a deterministic, re-derivable context page and
|
|
400
|
+
// pack stale copies down to the most recent one instead of letting a full page accumulate every
|
|
401
|
+
// turn. The revision (monotonic per mutation) lets a reader tell which page is current.
|
|
402
|
+
return `<task_steps_context revision=${state.revision}>\n${lines.join("\n")}\n</task_steps_context>`;
|
|
359
403
|
}
|
|
360
404
|
export function serializeTaskStepsState(state) {
|
|
361
405
|
return JSON.stringify(cloneTaskStepsState(state), null, 2);
|