@tea-agent/loop-agent 0.1.0-fe-test.2 → 0.1.0-fe-test.4
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/AGENTS.md +6 -3
- package/CHANGELOG.md +607 -93
- package/README.md +11 -5
- package/bin/loop-agent.js +7 -3
- package/dist/adapters/context-transfer/optional-pi-handoff.js +31 -0
- package/dist/adapters/context-transfer/pi-session.js +61 -0
- package/dist/application/dag/generate-task-dag.js +90 -21
- package/dist/application/dag/run-dag.js +41 -0
- package/dist/application/task-lifecycle/advance.js +40 -5
- package/dist/application/task-lifecycle/observe.js +171 -17
- package/dist/application/task-lifecycle/plan-transitions.js +42 -7
- package/dist/application/task-lifecycle/recommendations.js +13 -2
- package/dist/build-stamp.json +3 -3
- package/dist/cli/command-definitions.js +44 -10
- package/dist/cli/program.js +82 -6
- package/dist/cli/update/notifier.js +2 -2
- package/dist/cli/update/runtime-activity.js +1 -29
- package/dist/cli.js +2 -1
- package/dist/commands/client-recovery.js +11 -36
- package/dist/commands/dag-artifact.js +284 -0
- package/dist/commands/dag-context.js +184 -0
- package/dist/commands/dag-follow-up.js +138 -0
- package/dist/commands/dag-rerun-task.js +2 -0
- package/dist/commands/dag-rerun.js +261 -2
- package/dist/commands/init-model-catalog.js +486 -0
- package/dist/commands/init-upgrade.js +265 -97
- package/dist/commands/init.js +455 -28
- package/dist/commands/inspect-next.js +8 -0
- package/dist/commands/task-advance.js +73 -1
- package/dist/commands/task-source-prepare.js +5 -0
- package/dist/commands/task-status.js +1 -0
- package/dist/executors/dag-pi-executor.js +4321 -231
- package/dist/executors/pi-event-serializer.js +42 -1
- package/dist/executors/pi-executor.js +70 -6
- package/dist/executors/pi-extension-resolver.js +245 -0
- package/dist/executors/pi-playwright-cli-tool.js +74 -28
- package/dist/executors/pi-read-budget-policy.js +239 -0
- package/dist/executors/pi-sdk-executor.js +263 -59
- package/dist/executors/pi-writer-tool-policy.js +57 -1
- package/dist/executors/shell-executor.js +1443 -240
- package/dist/executors/shell-write-guard.js +14 -0
- package/dist/executors/workspace-write-snapshot.js +68 -0
- package/dist/governance/checks.js +1 -0
- package/dist/{worker → infrastructure}/console/app-data.js +4 -0
- package/dist/infrastructure/console/artifact-revision-store.js +430 -0
- package/dist/infrastructure/console/context-export-store.js +160 -0
- package/dist/infrastructure/console/dir-lock.js +132 -0
- package/dist/infrastructure/console/operation-store.js +417 -0
- package/dist/infrastructure/harness/artifact-store.js +10 -1
- package/dist/infrastructure/harness/atomic-write.js +35 -2
- package/dist/shared/context-transfer/artifact-revision.js +172 -0
- package/dist/shared/context-transfer.js +418 -0
- package/dist/shared/dag-failure-category.js +150 -0
- package/dist/shared/dag-prompt-override.js +27 -0
- package/dist/shared/openspec-spec.js +70 -4
- package/dist/shared/operator/capabilities.js +65 -4
- package/dist/shared/operator/safe-run-summary.js +1 -0
- package/dist/shared/path-safety.js +93 -0
- package/dist/shared/pi-context-pressure/checkpoint.js +116 -0
- package/dist/shared/pi-context-pressure/compaction-policy.js +151 -0
- package/dist/shared/pi-context-pressure/env.js +58 -0
- package/dist/shared/pi-context-pressure/extension.js +100 -0
- package/dist/shared/pi-context-pressure/index.js +7 -0
- package/dist/shared/pi-context-pressure/overflow.js +252 -0
- package/dist/shared/pi-context-pressure/sift-bridge.js +386 -0
- package/dist/shared/pi-context-pressure/telemetry.js +51 -0
- package/dist/shared/playwright-cli-command-policy.js +15 -0
- package/dist/shared/preview.js +28 -4
- package/dist/shared/update/console-notifier.js +100 -0
- package/dist/{cli → shared}/update/npm-client.js +70 -15
- package/dist/{cli → shared}/update/state.js +41 -13
- package/dist/task/config-types.js +125 -6
- package/dist/task/contract/adopt.js +4 -0
- package/dist/task/contract/apply.js +11 -1
- package/dist/task/contract/constants.js +3 -0
- package/dist/task/contract/diff.js +26 -0
- package/dist/task/contract/hash.js +3 -0
- package/dist/task/contract/import-revision.js +4 -0
- package/dist/task/contract/observe.js +25 -4
- package/dist/task/contract/paths.js +2 -1
- package/dist/task/contract/project.js +23 -1
- package/dist/task/contract/schema.js +9 -1
- package/dist/task/contract/transaction.js +12 -0
- package/dist/task/frontend-project-capability.js +203 -20
- package/dist/task/runtime.js +5 -2
- package/dist/task/source-prepare/build-draft.js +18 -3
- package/dist/task/source-prepare/completeness.js +188 -0
- package/dist/task/source-prepare/fragment-inventory.js +513 -0
- package/dist/task/source-prepare/index.js +3 -0
- package/dist/task/source-prepare/ledger-reconciliation.js +127 -0
- package/dist/task/source-prepare/ledger-review.js +214 -0
- package/dist/task/source-prepare/ledger.js +545 -0
- package/dist/task/source-prepare/parse-intent.js +24 -4
- package/dist/task/source-prepare/prepare.js +368 -2
- package/dist/task/source-prepare/semantic-intake.js +25 -5
- package/dist/task/source-prepare/source-fidelity-pi.js +384 -0
- package/dist/task/source-prepare/types.js +22 -0
- package/dist/task/source-references.js +22 -1
- package/dist/task/task-demand-routing.js +3 -0
- package/dist/worker/cli.js +18 -2
- package/dist/worker/console/chat/assistant-content.js +7 -0
- package/dist/worker/console/chat/chat-event-store.js +159 -18
- package/dist/worker/console/chat/chat-ui-policy.js +4 -2
- package/dist/worker/console/chat/context-panel.js +7 -0
- package/dist/worker/console/chat/deferred-turn.js +103 -0
- package/dist/worker/console/chat/goal-round-driver.js +72 -0
- package/dist/worker/console/chat/goals.js +300 -0
- package/dist/worker/console/chat/model-resolver.js +7 -4
- package/dist/worker/console/chat/operation-card.js +8 -1
- package/dist/worker/console/chat/pi-console-config.js +81 -10
- package/dist/worker/console/chat/pi-runtime.js +868 -30
- package/dist/worker/console/chat/provider-error.js +99 -0
- package/dist/worker/console/chat/repo-browser.js +101 -12
- package/dist/worker/console/chat/resource-preferences-store.js +1 -1
- package/dist/worker/console/chat/routes.js +1451 -145
- package/dist/worker/console/chat/sdd-data-alignment.js +222 -0
- package/dist/worker/console/chat/semantic-activity.js +25 -24
- package/dist/worker/console/chat/session-catalog.js +50 -0
- package/dist/worker/console/chat/session-stats.js +275 -0
- package/dist/worker/console/chat/session-store.js +348 -76
- package/dist/worker/console/chat/shortcuts.js +26 -3
- package/dist/worker/console/chat/sift-bridge.js +1 -0
- package/dist/worker/console/chat/todos.js +115 -0
- package/dist/worker/console/chat/tool-preview.js +42 -0
- package/dist/worker/console/chat/turn-process.js +185 -112
- package/dist/worker/console/chat/user-questions.js +266 -0
- package/dist/worker/console/chat/workspace-landing.js +79 -0
- package/dist/worker/console/console-handoff.js +82 -0
- package/dist/worker/console/console-update-and-init.js +115 -0
- package/dist/worker/console/console-update-runtime.js +84 -0
- package/dist/worker/console/context-transfer-diagnostics.js +198 -0
- package/dist/worker/console/dag-confirmation.js +1 -1
- package/dist/worker/console/dag-execution-receipt.js +54 -3
- package/dist/worker/console/doctor.js +1 -1
- package/dist/worker/console/draft-store.js +50 -1
- package/dist/worker/console/frontend-human-decision-adapter.js +19 -0
- package/dist/worker/console/frontend-split-operation-adapter.js +20 -0
- package/dist/worker/console/human-gate-token.js +1 -1
- package/dist/worker/console/index.js +6 -3
- package/dist/worker/console/inspect-split.js +18 -0
- package/dist/worker/console/interview/assessment.js +1 -1
- package/dist/worker/console/interview/session.js +1 -1
- package/dist/worker/console/native-directory-picker.js +13 -0
- package/dist/worker/console/operation-run-facts.js +19 -3
- package/dist/worker/console/operation-runner.js +45 -4
- package/dist/worker/console/operation-sse.js +1 -1
- package/dist/worker/console/operation-wait.js +1 -1
- package/dist/worker/console/operator-actions.js +534 -15
- package/dist/worker/console/operator-selection.js +6 -2
- package/dist/worker/console/operator-surface-health.js +2 -1
- package/dist/worker/console/operator-user-error.js +171 -2
- package/dist/worker/console/pi-plugins.catalog.json +73658 -0
- package/dist/worker/console/pi-plugins.js +238 -0
- package/dist/worker/console/pi-readiness.js +7 -6
- package/dist/worker/console/prd-intake-bridge.js +13 -0
- package/dist/worker/console/recovery-cta.js +4 -4
- package/dist/worker/console/recovery-error-copy.js +4 -4
- package/dist/worker/console/routes.js +1231 -10
- package/dist/worker/console/security.js +102 -13
- package/dist/worker/console/server.js +762 -159
- package/dist/worker/console/static/assets/{abnfDiagram-N423BO3Z-BmOEx0gA.js → abnfDiagram-N423BO3Z-BZogYNl1.js} +1 -1
- package/dist/worker/console/static/assets/{arc-BGiVVe8b.js → arc-DcJTLe2v.js} +1 -1
- package/dist/worker/console/static/assets/{architectureDiagram-T3A2C74G-nDdu4rgJ.js → architectureDiagram-T3A2C74G-B39EQQ9n.js} +1 -1
- package/dist/worker/console/static/assets/{blockDiagram-VBNYF7ZC-Bb5u0BWf.js → blockDiagram-VBNYF7ZC-CitCGV56.js} +1 -1
- package/dist/worker/console/static/assets/{c4Diagram-5PPSVZJV-BlhC0j94.js → c4Diagram-5PPSVZJV-rvWuOHLG.js} +1 -1
- package/dist/worker/console/static/assets/channel-CXqdP5pW.js +1 -0
- package/dist/worker/console/static/assets/{chunk-2GRJ4B5K-Ai8_qQXI.js → chunk-2GRJ4B5K-DGXplIJs.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-2Q5K7J3B-B9gyCjqX.js → chunk-2Q5K7J3B-ur9OqjPn.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-5RXB4S5H-Bzbj3zGH.js → chunk-5RXB4S5H-D1KqU_Vi.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-5VM5RSS4-BT415PvT.js → chunk-5VM5RSS4-BlVZrbtM.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-6Q2QTUOP-D_A5_5QL.js → chunk-6Q2QTUOP-BAzz3nQy.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-GF5L2VYU-srJkaP3f.js → chunk-GF5L2VYU-CP_nYuCV.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-JWPE2WC7-UYGvEP4l.js → chunk-JWPE2WC7-CWvKQ80X.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-KBJHAD2P-B8luBrrz.js → chunk-KBJHAD2P-CyUki8wp.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-RYQCIY6F-DN7wXZSq.js → chunk-RYQCIY6F-5NYzNKfY.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-XXDRQBXY-DXKyMuKS.js → chunk-XXDRQBXY-DHdUgjS-.js} +1 -1
- package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-D9C3agF7.js +1 -0
- package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-D9C3agF7.js +1 -0
- package/dist/worker/console/static/assets/{cose-bilkent-JH36ORCC-dqvoynXj.js → cose-bilkent-JH36ORCC-ANQ5g_t6.js} +1 -1
- package/dist/worker/console/static/assets/{cynefin-VYW2F7L2--PcyL34A.js → cynefin-VYW2F7L2-CruT_4-0.js} +1 -1
- package/dist/worker/console/static/assets/{cynefinDiagram-MW4NZA55-DvWs_hTY.js → cynefinDiagram-MW4NZA55-rbFo77ID.js} +1 -1
- package/dist/worker/console/static/assets/{dagre-VZM6K2ZE-DxeIxbyO.js → dagre-VZM6K2ZE-asstxBQs.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-7IWD3JNH-DPCG61Of.js → diagram-7IWD3JNH-DzTyBZwI.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-B4RE2ZJO-CmuU50-U.js → diagram-B4RE2ZJO-gw8ccH3B.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-LBJQPF4R-B61XLD_v.js → diagram-LBJQPF4R-B8RpZzOf.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-Q27KOJAE-BB7HTRRY.js → diagram-Q27KOJAE-B1zJkCS9.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-UB23O5K3-DvkboAIp.js → diagram-UB23O5K3-B6JLWZmO.js} +1 -1
- package/dist/worker/console/static/assets/{ebnfDiagram-BXEA7PRR-BdJ_y1fL.js → ebnfDiagram-BXEA7PRR-q2iZP-Ps.js} +1 -1
- package/dist/worker/console/static/assets/{erDiagram-JOGREHBK-9bUBZTRi.js → erDiagram-JOGREHBK-B3dbbktQ.js} +1 -1
- package/dist/worker/console/static/assets/{flowDiagram-UKHOOZJN-Dw4L4RBa.js → flowDiagram-UKHOOZJN-C-zc6-kB.js} +1 -1
- package/dist/worker/console/static/assets/{ganttDiagram-PKOTCBZU-Jr82N_QP.js → ganttDiagram-PKOTCBZU-BSolnot9.js} +1 -1
- package/dist/worker/console/static/assets/{gitGraphDiagram-DS77QQ5N-DAz9wFLr.js → gitGraphDiagram-DS77QQ5N-Bo8jGxTk.js} +1 -1
- package/dist/worker/console/static/assets/index-CAZ2fC_X.css +1 -0
- package/dist/worker/console/static/assets/index-DhfjOafu.js +449 -0
- package/dist/worker/console/static/assets/{infoDiagram-6WML65LV-CBB5Np7y.js → infoDiagram-6WML65LV-DQaZqJOH.js} +1 -1
- package/dist/worker/console/static/assets/{ishikawaDiagram-WSZJBQD7-D8IOp94y.js → ishikawaDiagram-WSZJBQD7-DsdX1WnE.js} +1 -1
- package/dist/worker/console/static/assets/{journeyDiagram-NVQOT4AX-Dgd3AHGG.js → journeyDiagram-NVQOT4AX-CP5EYDZL.js} +1 -1
- package/dist/worker/console/static/assets/{kanban-definition-27J2QSJJ-BmYOxLE9.js → kanban-definition-27J2QSJJ-DAm14Dr8.js} +1 -1
- package/dist/worker/console/static/assets/{linear-DfYTEF6J.js → linear-gZECoLc5.js} +1 -1
- package/dist/worker/console/static/assets/{mermaid.core-BjuFPRqa.js → mermaid.core-BRJNIM6p.js} +5 -5
- package/dist/worker/console/static/assets/{mindmap-definition-FAOFIHXS-CLyUViGd.js → mindmap-definition-FAOFIHXS-Cja3kLkR.js} +1 -1
- package/dist/worker/console/static/assets/{pegDiagram-VL7TDLO6-BvX2Di4-.js → pegDiagram-VL7TDLO6-22ZGFisL.js} +1 -1
- package/dist/worker/console/static/assets/{pieDiagram-7S7Q4E2Y-BFj0_OLv.js → pieDiagram-7S7Q4E2Y-BXin0Y1o.js} +1 -1
- package/dist/worker/console/static/assets/{quadrantDiagram-CIZ2JOQS-BIUrD_hx.js → quadrantDiagram-CIZ2JOQS-Cw6T69Yt.js} +1 -1
- package/dist/worker/console/static/assets/{railroadDiagram-AXF67PYL-CHBB48fj.js → railroadDiagram-AXF67PYL-C1-gTieN.js} +1 -1
- package/dist/worker/console/static/assets/{requirementDiagram-LRYGKXZP-sJrYw2Sf.js → requirementDiagram-LRYGKXZP--H5N2iI1.js} +1 -1
- package/dist/worker/console/static/assets/{sankeyDiagram-W5VNT64P-BzHH6fPR.js → sankeyDiagram-W5VNT64P-CgWAPeRz.js} +1 -1
- package/dist/worker/console/static/assets/{sequenceDiagram-SI44F4Z6-7QCnelCt.js → sequenceDiagram-SI44F4Z6-CrKqzGvt.js} +1 -1
- package/dist/worker/console/static/assets/{sizeCapture-X5ZJPWSS-sDYSxn72.js → sizeCapture-X5ZJPWSS-BB3wG06K.js} +1 -1
- package/dist/worker/console/static/assets/{stateDiagram-OKZ733FA-XpiUdwzm.js → stateDiagram-OKZ733FA-DjsGgdgY.js} +1 -1
- package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-Tp7V0U4q.js +1 -0
- package/dist/worker/console/static/assets/{swimlanes-SLNWSIFB-DvqgNPzD.js → swimlanes-SLNWSIFB-DYKEbvAR.js} +2 -2
- package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-DUZWZWi8.js +8 -0
- package/dist/worker/console/static/assets/{timeline-definition-Z64GVDOM-2TyOYNx0.js → timeline-definition-Z64GVDOM-eQOb5k9Y.js} +1 -1
- package/dist/worker/console/static/assets/{vennDiagram-T6HMQDX7-B-nM6wM2.js → vennDiagram-T6HMQDX7-B2-l9FIu.js} +1 -1
- package/dist/worker/console/static/assets/{wardleyDiagram-T6FBY63Y-B86wPdbr.js → wardleyDiagram-T6FBY63Y-BX2Cda3l.js} +1 -1
- package/dist/worker/console/static/assets/{xychartDiagram-ELKLHX3M-Dr1C4AQz.js → xychartDiagram-ELKLHX3M-D9S892ph.js} +1 -1
- package/dist/worker/console/static/index.html +7 -2
- package/dist/worker/console/static-src/active-run-badge.js +17 -0
- package/dist/worker/console/static-src/app/console-types.js +68 -4
- package/dist/worker/console/static-src/app/useConsoleShell.js +30 -12
- package/dist/worker/console/static-src/app/useOperatorActions.js +43 -7
- package/dist/worker/console/static-src/app/useRecoveryActions.js +2 -2
- package/dist/worker/console/static-src/app/useRecoveryConsole.js +45 -10
- package/dist/worker/console/static-src/app/useRunProgress.js +54 -0
- package/dist/worker/console/static-src/app/useTaskWizard.js +74 -2
- package/dist/worker/console/static-src/night/useNightBoard.js +8 -5
- package/dist/worker/console/static-src/operator-chat/cards/failure-category-advice.js +25 -0
- package/dist/worker/console/static-src/operator-chat/chat-sse-events.js +264 -13
- package/dist/worker/console/static-src/operator-chat/compaction-message.js +113 -0
- package/dist/worker/console/static-src/operator-chat/dag-progress-link.js +22 -0
- package/dist/worker/console/static-src/operator-chat/details-dag-actions.js +122 -0
- package/dist/worker/console/static-src/operator-chat/input-history.js +78 -0
- package/dist/worker/console/static-src/operator-chat/mutation-gate.js +1 -1
- package/dist/worker/console/static-src/operator-chat/open-preview-in-browser.js +338 -0
- package/dist/worker/console/static-src/operator-chat/refs.js +3 -0
- package/dist/worker/console/static-src/operator-chat/runtime-selection-labels.js +27 -0
- package/dist/worker/console/static-src/operator-chat/runtime-snapshot-store.js +10 -0
- package/dist/worker/console/static-src/operator-chat/spatial-overlay.js +1 -2
- package/dist/worker/console/static-src/operator-chat/turn-stream-controller.js +33 -1
- package/dist/worker/console/static-src/operator-chat/turn-submission.js +55 -0
- package/dist/worker/console/static-src/operator-chat/useChatSessions.js +448 -109
- package/dist/worker/console/static-src/operator-chat/useChatStream.js +344 -27
- package/dist/worker/console/static-src/operator-chat/useChatThread.js +323 -11
- package/dist/worker/console/static-src/operator-chat/useComposer.js +45 -4
- package/dist/worker/console/static-src/operator-chat/useRepoBrowser.js +97 -13
- package/dist/worker/console/static-src/operator-chat/useRuntimeControls.js +57 -9
- package/dist/worker/console/static-src/operator-chat/useRuntimeSnapshot.js +8 -2
- package/dist/worker/console/static-src/operator-chat/useWorkspaceBrowserGate.js +4 -0
- package/dist/worker/console/static-src/operator-chat/workspace-layout-mode.js +3 -3
- package/dist/worker/console/static-src/operator-chat/workspace-reorder.js +18 -0
- package/dist/worker/console/static-src/pages/tasks/run-id-resolution.js +79 -0
- package/dist/worker/console/static-src/pages/tasks/run-ownership-verify.js +23 -0
- package/dist/worker/console/static-src/pages/tasks/run-panel-progress.js +216 -0
- package/dist/worker/console/static-src/shell/console-update-reload.js +52 -0
- package/dist/worker/console/static-src/shell/useWorkspaces.js +415 -0
- package/dist/worker/console/static-src/shell/workspace-route.js +356 -0
- package/dist/worker/console/workspace-context.js +399 -0
- package/dist/worker/console/workspace-registry.js +487 -0
- package/dist/worker/continuation/worker-continuation.js +278 -0
- package/dist/worker/loop-agent/loop-agent-client.js +7 -3
- package/dist/worker/materialize/frontend-split-task-materializer.js +72 -0
- package/dist/worker/materialize/harness-task-lineage.js +5 -2
- package/dist/worker/observability/init-runtime-activity.js +26 -0
- package/dist/worker/observability/read-model.js +26 -0
- package/dist/worker/observe/health.js +1 -1
- package/dist/worker/observe/node-input.js +160 -3
- package/dist/worker/observe/node-process.js +377 -0
- package/dist/worker/observe/node-transparency.js +572 -0
- package/dist/worker/observe/routes.js +278 -3
- package/dist/worker/observe/server.js +4 -0
- package/dist/worker/observe/shell-handler-keys.js +34 -0
- package/dist/worker/observe/static/api.js +154 -4
- package/dist/worker/observe/static/app.js +18 -70
- package/dist/worker/observe/static/constants.js +26 -19
- package/dist/worker/observe/static/dag-context-reason-labels.d.ts +9 -0
- package/dist/worker/observe/static/dag-context-reason-labels.js +139 -0
- package/dist/worker/observe/static/dag-helpers.js +4 -2
- package/dist/worker/observe/static/dag-history-labels.js +5 -0
- package/dist/worker/observe/static/dag-inspector-humanize.d.ts +16 -0
- package/dist/worker/observe/static/dag-inspector-humanize.js +339 -0
- package/dist/worker/observe/static/dag-node-purpose.d.ts +6 -0
- package/dist/worker/observe/static/dag-node-purpose.js +208 -0
- package/dist/worker/observe/static/format.js +60 -0
- package/dist/worker/observe/static/index.html +10 -5
- package/dist/worker/observe/static/inspect-bootstrap.d.ts +8 -0
- package/dist/worker/observe/static/inspect-bootstrap.js +57 -0
- package/dist/worker/observe/static/inspect-workspace.js +374 -0
- package/dist/worker/observe/static/kpi.js +2 -2
- package/dist/worker/observe/static/markdown-render.js +20 -1
- package/dist/worker/observe/static/operator-chrome.css +168 -24
- package/dist/worker/observe/static/operator-chrome.d.ts +30 -5
- package/dist/worker/observe/static/operator-chrome.js +354 -101
- package/dist/worker/observe/static/prompt-restart-candidates.d.ts +18 -0
- package/dist/worker/observe/static/prompt-restart-candidates.js +38 -0
- package/dist/worker/observe/static/relations.js +7 -7
- package/dist/worker/observe/static/router.d.ts +57 -0
- package/dist/worker/observe/static/router.js +67 -1
- package/dist/worker/observe/static/run-processing.js +4 -2
- package/dist/worker/observe/static/shell-chrome.js +2 -2
- package/dist/worker/observe/static/state.d.ts +50 -0
- package/dist/worker/observe/static/state.js +191 -1
- package/dist/worker/observe/static/styles.css +1720 -86
- package/dist/worker/observe/static/views/dag-graph.js +5 -3
- package/dist/worker/observe/static/views/dag-inspector.js +2601 -188
- package/dist/worker/observe/static/views/dag.d.ts +13 -0
- package/dist/worker/observe/static/views/dag.js +39 -18
- package/dist/worker/observe/static/views/dags.js +10 -6
- package/dist/worker/observe/static/views/dashboard.js +18 -8
- package/dist/worker/observe/static/views/failures.js +5 -2
- package/dist/worker/observe/static/views/night.js +2 -2
- package/dist/worker/observe/static/views/pool.js +8 -2
- package/dist/worker/observe/static/views/run.js +15 -4
- package/dist/worker/observe/static/views/session-timeline.js +386 -25
- package/dist/worker/observe/static/views/task.js +63 -3
- package/dist/worker/outcomes/adapters.js +19 -0
- package/dist/worker/outcomes/types.js +1 -0
- package/dist/worker/pool/attempt-lease.js +97 -66
- package/dist/worker/pool/begin-attempt-with-lease.js +1 -0
- package/dist/worker/pool/reconcile.js +46 -1
- package/dist/worker/pool/run-store.js +2 -0
- package/dist/worker/pool/state-projection.js +2 -0
- package/dist/worker/task-spec/workflow-routing.js +8 -3
- package/dist/workflows/dag/artifact-bindings.js +149 -0
- package/dist/workflows/dag/artifact-revision-schema-registry.js +31 -0
- package/dist/workflows/dag/backend-test-case-coverage-analysis.js +470 -31
- package/dist/workflows/dag/backend-test-markdown-workflow.js +189 -2
- package/dist/workflows/dag/backend-test-plan-protocol.js +210 -0
- package/dist/workflows/dag/backend-test-pytest-collection.js +168 -16
- package/dist/workflows/dag/backend-test-result-contract.js +5 -1
- package/dist/workflows/dag/backend-test-scenario-param.js +506 -73
- package/dist/workflows/dag/backend-test-scenario-partitions.js +135 -2
- package/dist/workflows/dag/backend-test-writer-completeness.js +131 -28
- package/dist/workflows/dag/budget-enforcement.js +10 -0
- package/dist/workflows/dag/context-receipt.js +305 -0
- package/dist/workflows/dag/context-transfer/context-bundle.js +423 -0
- package/dist/workflows/dag/context-transfer/operator-actions.js +61 -0
- package/dist/workflows/dag/context-transfer/renderers.js +93 -0
- package/dist/workflows/dag/contract-output-registry.js +15 -0
- package/dist/workflows/dag/contract-validator-registrations.js +1 -2
- package/dist/workflows/dag/convergence/controller.js +141 -0
- package/dist/workflows/dag/dag-retry-schema.js +138 -0
- package/dist/workflows/dag/dynamic-runtime/loop-until.js +1 -1
- package/dist/workflows/dag/dynamic-runtime/map.js +2 -1
- package/dist/workflows/dag/failure-category.js +7 -116
- package/dist/workflows/dag/frontend-closeout.js +221 -0
- package/dist/workflows/dag/frontend-design-policy.js +400 -0
- package/dist/workflows/dag/frontend-human-decision.js +182 -0
- package/dist/workflows/dag/frontend-implementation-contract.js +1377 -141
- package/dist/workflows/dag/frontend-plan-render.js +26 -1
- package/dist/workflows/dag/frontend-prewrite-gate.js +376 -318
- package/dist/workflows/dag/frontend-provider-capability-matrix.js +159 -0
- package/dist/workflows/dag/frontend-recovery-capsule.js +455 -0
- package/dist/workflows/dag/frontend-recovery-controller.js +226 -0
- package/dist/workflows/dag/frontend-recovery-lineage.js +178 -0
- package/dist/workflows/dag/frontend-recovery-plan.js +21 -10
- package/dist/workflows/dag/frontend-recovery-run.js +166 -34
- package/dist/workflows/dag/frontend-repair.js +7 -424
- package/dist/workflows/dag/frontend-review-context.js +348 -20
- package/dist/workflows/dag/frontend-review-findings.js +270 -0
- package/dist/workflows/dag/frontend-risk.js +15 -2
- package/dist/workflows/dag/frontend-shadow-dual-write.js +941 -0
- package/dist/workflows/dag/frontend-shape-capsule-store.js +191 -0
- package/dist/workflows/dag/frontend-shape-facts.js +419 -0
- package/dist/workflows/dag/frontend-shape.js +435 -0
- package/dist/workflows/dag/frontend-source-fidelity-ledger.js +108 -0
- package/dist/workflows/dag/frontend-split-application-service.js +203 -0
- package/dist/workflows/dag/frontend-split-orchestrator.js +899 -0
- package/dist/workflows/dag/frontend-test-case-checklist.js +53 -5
- package/dist/workflows/dag/frontend-test-case-manifest.js +11 -4
- package/dist/workflows/dag/frontend-test-case-quality.js +11 -16
- package/dist/workflows/dag/frontend-test-environment-probe.js +230 -0
- package/dist/workflows/dag/frontend-test-html-report.js +3 -1
- package/dist/workflows/dag/frontend-test-l5-report.js +3 -1
- package/dist/workflows/dag/frontend-test-layout.js +159 -0
- package/dist/workflows/dag/frontend-test-markdown.js +61 -0
- package/dist/workflows/dag/frontend-test-rerun-candidates.js +103 -0
- package/dist/workflows/dag/frontend-test-result-contract.js +188 -42
- package/dist/workflows/dag/frontend-test-standard-scenarios.js +70 -0
- package/dist/workflows/dag/frontend-typed-event-store.js +452 -0
- package/dist/workflows/dag/frontend-typed-event-transaction.js +180 -0
- package/dist/workflows/dag/frontend-verification-trace.js +281 -29
- package/dist/workflows/dag/frontend-worktree-diff.js +250 -17
- package/dist/workflows/dag/frontend-writer-admission.js +319 -0
- package/dist/workflows/dag/frontend-writer-rollback.js +32 -0
- package/dist/workflows/dag/frontend-writer-status.js +256 -0
- package/dist/workflows/dag/init-hybrid.js +1675 -721
- package/dist/workflows/dag/interrupt-request.js +10 -3
- package/dist/workflows/dag/lifecycle.js +3 -3
- package/dist/workflows/dag/node-execution.js +1141 -32
- package/dist/workflows/dag/path-safety.js +1 -0
- package/dist/workflows/dag/prompt.js +158 -7
- package/dist/workflows/dag/recovery-lease.js +170 -0
- package/dist/workflows/dag/report.js +37 -1
- package/dist/workflows/dag/rerun-feedback.js +526 -0
- package/dist/workflows/dag/rerun-plan.js +790 -28
- package/dist/workflows/dag/rerun-run.js +700 -21
- package/dist/workflows/dag/rerun-task.js +311 -14
- package/dist/workflows/dag/retry-policy.js +336 -101
- package/dist/workflows/dag/runner.js +596 -121
- package/dist/workflows/dag/scheduler.js +133 -20
- package/dist/workflows/dag/skill-snapshot.js +17 -0
- package/dist/workflows/dag/structured-output-repair.js +712 -0
- package/dist/workflows/dag/types.js +585 -31
- package/dist/workflows/dag/validate.js +93 -32
- package/docs/README.md +2 -0
- package/docs/architecture/evolution.md +45 -0
- package/docs/architecture/runtime-boundaries.md +8 -7
- package/docs/architecture/worker-and-feature.md +1 -1
- package/docs/examples/README.md +5 -0
- package/docs/init-surface.manifest.json +36 -12
- package/docs/operations/README.md +1 -1
- package/docs/operations/local-development-environment.md +22 -5
- package/docs/skills/vetted-skill-registry.md +16 -0
- package/docs/templates/README.md +4 -2
- package/docs/templates/agent-dag-report.schema.json +8 -2
- package/docs/templates/agent-dag.schema.json +95 -1
- package/docs/templates/backend-test-dag.json +278 -244
- package/docs/templates/frontend-implementation-contract.schema.json +684 -24
- package/docs/templates/frontend-implementation-dag.json +89 -0
- package/docs/templates/frontend-test-case-checklist.md +2 -2
- package/docs/templates/frontend-test-dag.json +8 -10
- package/docs/templates/frontend-test-dag.retrieve-context.prompt.md +1 -1
- package/docs/templates/init-managed-agents.md +13 -3
- package/docs/templates/product-line/task.yaml +1 -1
- package/docs/templates/spec-registry.schema.json +45 -0
- package/harness.json +2 -2
- package/package.json +19 -5
- package/scripts/next-info.mjs +356 -0
- package/scripts/next-publish-gate.mjs +238 -0
- package/scripts/release-source-binding.mjs +251 -0
- package/skills/analyze-product-requirements/SKILL.md +8 -5
- package/skills/analyze-product-requirements/references/acceptance-criteria.md +1 -1
- package/skills/analyze-product-requirements/references/clarification-and-knowledge.md +10 -6
- package/skills/analyze-product-requirements/references/example.md +50 -0
- package/skills/analyze-product-requirements/references/forward-test-cases.md +11 -7
- package/skills/analyze-product-requirements/references/kb-integration.md +5 -5
- package/skills/analyze-product-requirements/references/product-analysis-schema.md +8 -4
- package/skills/analyze-product-requirements/references/product-requirement-schema.md +2 -2
- package/skills/analyze-product-requirements/references/requirement-clarification-schema.md +1 -1
- package/skills/analyze-product-requirements/scripts/test-validators.mjs +11 -1
- package/skills/analyze-product-requirements/scripts/validate-product-analysis.mjs +20 -1
- package/skills/analyze-product-requirements/scripts/validate-requirement-clarification.mjs +9 -0
- package/skills/codebase-scout/SKILL.md +1 -1
- package/skills/fe-test-ui-scout/SKILL.md +65 -0
- package/skills/fe-test-ui-scout/references/ledger-schema.md +62 -0
- package/skills/fe-test-ui-scout/references/recon-protocol.md +54 -0
- package/skills/frontend-bounded-implement/SKILL.md +15 -14
- package/skills/frontend-bounded-implement/references/code-standards.md +19 -0
- package/skills/frontend-contract/SKILL.md +23 -0
- package/skills/frontend-contract/references/contract-protocol.md +34 -0
- package/skills/frontend-design-review/SKILL.md +22 -41
- package/skills/frontend-plan/SKILL.md +26 -0
- package/skills/frontend-plan/references/decision-contract.md +37 -0
- package/skills/frontend-plan/references/design-decisions.md +17 -0
- package/skills/frontend-review/SKILL.md +20 -15
- package/skills/frontend-review/references/review-findings.md +6 -7
- package/skills/frontend-scout/SKILL.md +25 -0
- package/skills/frontend-scout/references/design-evidence.md +16 -0
- package/skills/frontend-scout/references/scout-evidence.md +23 -0
- package/skills/frontend-verification/SKILL.md +1 -1
- package/skills/improve-codebase-architecture/SKILL.md +81 -0
- package/skills/improve-codebase-architecture/deepening.md +37 -0
- package/skills/improve-codebase-architecture/html-report.md +123 -0
- package/skills/improve-codebase-architecture/interface-design.md +44 -0
- package/skills/improve-codebase-architecture/language.md +53 -0
- package/skills/loop-agent/references/command-reference.md +32 -4
- package/skills/loop-agent/references/hybrid-dag.md +9 -2
- package/skills/playwright-cli/SKILL.md +23 -1
- package/skills/playwright-cli-case-generator/SKILL.md +50 -13
- package/dist/worker/console/operation-store.js +0 -169
- package/dist/worker/console/static/assets/channel-Tl-FkUqr.js +0 -1
- package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-BaehtRk4.js +0 -1
- package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-BaehtRk4.js +0 -1
- package/dist/worker/console/static/assets/index-B7Y-0g3J.css +0 -1
- package/dist/worker/console/static/assets/index-DkCrqaYg.js +0 -325
- package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-eEhq2A8Y.js +0 -1
- package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-la8AC7fo.js +0 -8
- package/dist/worker/console/static-src/operator-chat/activity-rail-presentation.js +0 -73
- package/dist/worker/console/static-src/operator-chat/useActivityRailTransition.js +0 -59
- package/skills/frontend-implementation/SKILL.md +0 -52
- package/skills/frontend-implementation/references/code-standards.md +0 -33
- package/skills/frontend-implementation/references/design-spec.md +0 -56
- package/skills/frontend-implementation/references/node-contracts.md +0 -31
- /package/dist/{worker → infrastructure}/console/repo-fingerprint.js +0 -0
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure DAG failure-category classification shared by the workflows kernel and
|
|
3
|
+
* the Operator Console projection (console sources may not import
|
|
4
|
+
* src/workflows — security-and-tools boundary test).
|
|
5
|
+
*
|
|
6
|
+
* No runtime imports: this module is a leaf safe for both the CLI kernel and
|
|
7
|
+
* the browser bundle.
|
|
8
|
+
*/
|
|
9
|
+
export const DAG_NORMALIZED_FAILURE_CATEGORY_VALUES = [
|
|
10
|
+
"success",
|
|
11
|
+
"validation",
|
|
12
|
+
"executor",
|
|
13
|
+
"write-guard",
|
|
14
|
+
"timeout",
|
|
15
|
+
"auth",
|
|
16
|
+
"human-required",
|
|
17
|
+
"human-rejected",
|
|
18
|
+
"shell-command",
|
|
19
|
+
"static-error",
|
|
20
|
+
"decision-envelope",
|
|
21
|
+
"skipped",
|
|
22
|
+
"unknown",
|
|
23
|
+
];
|
|
24
|
+
const RAW_TO_NORMALIZED = {
|
|
25
|
+
success: "success",
|
|
26
|
+
"write-guard": "write-guard",
|
|
27
|
+
timeout: "timeout",
|
|
28
|
+
// Clean implementer stall with zero writes — still a timeout class for report,
|
|
29
|
+
// but retryable under WRITER_TRANSPORT_RETRY_POLICY.
|
|
30
|
+
"writer-clean-timeout": "timeout",
|
|
31
|
+
"missing-api-key": "auth",
|
|
32
|
+
auth: "auth",
|
|
33
|
+
"human-rejected": "human-rejected",
|
|
34
|
+
"human-required": "human-required",
|
|
35
|
+
"decision-envelope-invalid": "decision-envelope",
|
|
36
|
+
"nonzero-exit": "shell-command",
|
|
37
|
+
"spawn-error": "shell-command",
|
|
38
|
+
"test-timeout": "timeout",
|
|
39
|
+
"static-error": "static-error",
|
|
40
|
+
"invalid-output": "validation",
|
|
41
|
+
"structured-output-truncated": "validation",
|
|
42
|
+
"output-too-large": "validation",
|
|
43
|
+
"structured-repair-exhausted": "validation",
|
|
44
|
+
"governance-blocked": "validation",
|
|
45
|
+
"path-violation": "validation",
|
|
46
|
+
"empty-output": "validation",
|
|
47
|
+
"verify-failure": "validation",
|
|
48
|
+
"test-failure": "validation",
|
|
49
|
+
"verification-plan-stale": "validation",
|
|
50
|
+
"read-burst": "validation",
|
|
51
|
+
// Writer persisted real file changes but the final provider call hit a
|
|
52
|
+
// context overflow; verification never ran. Distinct from empty-output so
|
|
53
|
+
// the report shows partial success instead of a spec issue.
|
|
54
|
+
"partial-success-with-context-overflow": "validation",
|
|
55
|
+
// Writer burned an excessive token budget (unconverged read-edit-test loop)
|
|
56
|
+
// and still failed; distinct from empty-output for accurate reporting.
|
|
57
|
+
"writer-budget-exhausted": "validation",
|
|
58
|
+
network: "executor",
|
|
59
|
+
quota: "executor",
|
|
60
|
+
"rate-limit": "executor",
|
|
61
|
+
unavailable: "executor",
|
|
62
|
+
// Context window overflow (400 request-too-large): the session needs
|
|
63
|
+
// compaction / fresh context before retrying — an executor-side
|
|
64
|
+
// environment condition, not a plan-quality defect.
|
|
65
|
+
"context-overflow": "executor",
|
|
66
|
+
// Deterministic capability/policy refusal: missing verified launcher JS
|
|
67
|
+
// entry, capability allowlist rejection, or missing bounded write tool
|
|
68
|
+
// profile. These are environment/config defects the operator repairs
|
|
69
|
+
// before rerunning; classify as executor so recovery recommends
|
|
70
|
+
// rerun-after-fix WITHOUT forcing a human-decision gate on
|
|
71
|
+
// standaloneTaskRerun (run-failed same-task rerun).
|
|
72
|
+
"tool-policy": "executor",
|
|
73
|
+
unknown: "unknown",
|
|
74
|
+
};
|
|
75
|
+
/** Status inputs are deliberately `string`: projection layers pass bounded
|
|
76
|
+
* text from CLI JSON; unmatched values simply fall through to unknown. */
|
|
77
|
+
function isFinishedStatus(status) {
|
|
78
|
+
return status === "FINISHED" || status === "finished";
|
|
79
|
+
}
|
|
80
|
+
function isInProgressStatus(status) {
|
|
81
|
+
return (status === "PENDING" ||
|
|
82
|
+
status === "RUNNING" ||
|
|
83
|
+
status === "pending" ||
|
|
84
|
+
status === "running");
|
|
85
|
+
}
|
|
86
|
+
function isFailureStatus(status) {
|
|
87
|
+
return (status === "ERROR" ||
|
|
88
|
+
status === "failed" ||
|
|
89
|
+
status === "partial_failed");
|
|
90
|
+
}
|
|
91
|
+
function mapRawCategory(raw) {
|
|
92
|
+
const direct = RAW_TO_NORMALIZED[raw];
|
|
93
|
+
if (direct)
|
|
94
|
+
return direct;
|
|
95
|
+
const lower = raw.toLowerCase();
|
|
96
|
+
if (lower.includes("timeout"))
|
|
97
|
+
return "timeout";
|
|
98
|
+
if (lower.includes("validation") ||
|
|
99
|
+
lower.includes("invalid") ||
|
|
100
|
+
lower.includes("verification-plan-stale") ||
|
|
101
|
+
lower.includes("plan-stale"))
|
|
102
|
+
return "validation";
|
|
103
|
+
if (lower.includes("auth") || lower.includes("api-key"))
|
|
104
|
+
return "auth";
|
|
105
|
+
if (lower.includes("write-guard") || lower.includes("write_guard"))
|
|
106
|
+
return "write-guard";
|
|
107
|
+
if (lower.includes("decision-envelope") || lower.includes("decision_envelope"))
|
|
108
|
+
return "decision-envelope";
|
|
109
|
+
if (lower.includes("human-rejected"))
|
|
110
|
+
return "human-rejected";
|
|
111
|
+
if (lower.includes("human-required"))
|
|
112
|
+
return "human-required";
|
|
113
|
+
if (lower.includes("static-error"))
|
|
114
|
+
return "static-error";
|
|
115
|
+
if (lower.includes("nonzero-exit") ||
|
|
116
|
+
lower.includes("spawn-error") ||
|
|
117
|
+
lower.includes("shell"))
|
|
118
|
+
return "shell-command";
|
|
119
|
+
return undefined;
|
|
120
|
+
}
|
|
121
|
+
export function isDagFailureCategory(value) {
|
|
122
|
+
return DAG_NORMALIZED_FAILURE_CATEGORY_VALUES.includes(value);
|
|
123
|
+
}
|
|
124
|
+
export function normalizeDagFailureCategory(raw, status) {
|
|
125
|
+
if (status === "SKIPPED") {
|
|
126
|
+
return "skipped";
|
|
127
|
+
}
|
|
128
|
+
if (raw !== undefined) {
|
|
129
|
+
const mapped = mapRawCategory(raw);
|
|
130
|
+
if (mapped) {
|
|
131
|
+
if (mapped === "success") {
|
|
132
|
+
return isFinishedStatus(status) ? "success" : "unknown";
|
|
133
|
+
}
|
|
134
|
+
return mapped;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
if (raw === undefined && isFinishedStatus(status)) {
|
|
138
|
+
return "success";
|
|
139
|
+
}
|
|
140
|
+
if (isInProgressStatus(status)) {
|
|
141
|
+
return "unknown";
|
|
142
|
+
}
|
|
143
|
+
if (isFailureStatus(status)) {
|
|
144
|
+
return "unknown";
|
|
145
|
+
}
|
|
146
|
+
if (raw === "success" && isFinishedStatus(status)) {
|
|
147
|
+
return "success";
|
|
148
|
+
}
|
|
149
|
+
return "unknown";
|
|
150
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal switch for the experimental "rerun failed node with an edited
|
|
3
|
+
* prompt" capability. The feature is enabled by default; the environment
|
|
4
|
+
* variable remains as an emergency kill switch while the feature is internal.
|
|
5
|
+
*/
|
|
6
|
+
export const DAG_RERUN_PROMPT_OVERRIDE_ENV = "HARNESS_DAG_RERUN_PROMPT_OVERRIDE";
|
|
7
|
+
/** Upper bound for an override input body (characters). */
|
|
8
|
+
export const MAX_DAG_RERUN_PROMPT_OVERRIDE_CHARS = 65_536;
|
|
9
|
+
export function isDagRerunPromptOverrideEnabled(env = process.env) {
|
|
10
|
+
const value = env[DAG_RERUN_PROMPT_OVERRIDE_ENV]?.trim().toLowerCase();
|
|
11
|
+
return value !== "0" && value !== "false" && value !== "off";
|
|
12
|
+
}
|
|
13
|
+
export const DAG_RERUN_PROMPT_ADDENDUM_TAG = "operator_addendum";
|
|
14
|
+
/**
|
|
15
|
+
* Compose the final subtask_prompt for a rerun override.
|
|
16
|
+
* - "replace": the operator text becomes the whole prompt (advanced mode).
|
|
17
|
+
* - "append" (recommended): the frozen base prompt is kept verbatim and the
|
|
18
|
+
* operator addendum is appended in a clearly marked block, mirroring the
|
|
19
|
+
* rerunFeedback / retry_instruction augmentation semantics — small diffs,
|
|
20
|
+
* no risk of dropping template scaffolding.
|
|
21
|
+
*/
|
|
22
|
+
export function composeDagPromptOverridePrompt(input) {
|
|
23
|
+
if (input.mode === "replace") {
|
|
24
|
+
return input.text;
|
|
25
|
+
}
|
|
26
|
+
return `${input.basePrompt}\n\n<${DAG_RERUN_PROMPT_ADDENDUM_TAG}>\n${input.text.trim()}\n</${DAG_RERUN_PROMPT_ADDENDUM_TAG}>\n`;
|
|
27
|
+
}
|
|
@@ -12,6 +12,19 @@ export const OPENSPEC_SPEC_DIRS = [
|
|
|
12
12
|
"openspec/project-specs",
|
|
13
13
|
"ai_workspace",
|
|
14
14
|
];
|
|
15
|
+
/** Default roots used when a frontend task does not declare specRoots. */
|
|
16
|
+
export const DEFAULT_FRONTEND_SPEC_ROOTS = OPENSPEC_SPEC_DIRS;
|
|
17
|
+
/** A task-owned spec root must be a normalized, repo-relative POSIX directory. */
|
|
18
|
+
export function isValidFrontendSpecRoot(value) {
|
|
19
|
+
return (Boolean(value) &&
|
|
20
|
+
!value.includes("\\") &&
|
|
21
|
+
!value.startsWith("/") &&
|
|
22
|
+
!value.includes("//") &&
|
|
23
|
+
!value.split("/").some((segment) => !segment ||
|
|
24
|
+
segment === "." ||
|
|
25
|
+
segment === ".." ||
|
|
26
|
+
/\s/.test(segment)));
|
|
27
|
+
}
|
|
15
28
|
/** Allowed spec file extensions (case-insensitive). */
|
|
16
29
|
export const OPENSPEC_SPEC_EXT_RE = /\.(md|mdx|json|yaml|yml)$/i;
|
|
17
30
|
/**
|
|
@@ -43,14 +56,17 @@ export function isGovernanceSubtreePath(filePath, governanceRoot) {
|
|
|
43
56
|
* directories. `filePath` must be a repo-relative POSIX path (backslashes are
|
|
44
57
|
* normalised internally). Directory names are case-sensitive.
|
|
45
58
|
*/
|
|
46
|
-
export function
|
|
59
|
+
export function isFrontendSpecPath(filePath, specRoots = DEFAULT_FRONTEND_SPEC_ROOTS) {
|
|
47
60
|
const normalized = filePath.replaceAll("\\", "/");
|
|
48
|
-
for (const dir of
|
|
61
|
+
for (const dir of specRoots) {
|
|
49
62
|
if (normalized === dir || normalized.startsWith(dir + "/"))
|
|
50
63
|
return true;
|
|
51
64
|
}
|
|
52
65
|
return false;
|
|
53
66
|
}
|
|
67
|
+
export function isOpenspecSpecPath(filePath) {
|
|
68
|
+
return isFrontendSpecPath(filePath);
|
|
69
|
+
}
|
|
54
70
|
/**
|
|
55
71
|
* Returns `true` when `filename` (the basename only, not a full path) has an
|
|
56
72
|
* allowed frontend specification extension.
|
|
@@ -59,10 +75,13 @@ export function isValidOpenspecExtension(filename) {
|
|
|
59
75
|
return OPENSPEC_SPEC_EXT_RE.test(filename);
|
|
60
76
|
}
|
|
61
77
|
/** Returns `true` for a supported file inside a canonical openspec spec dir. */
|
|
62
|
-
export function
|
|
63
|
-
return (
|
|
78
|
+
export function isFrontendSpecFilePath(filePath, specRoots = DEFAULT_FRONTEND_SPEC_ROOTS) {
|
|
79
|
+
return (isFrontendSpecPath(filePath, specRoots) &&
|
|
64
80
|
isValidOpenspecExtension(filePath.replaceAll("\\", "/")));
|
|
65
81
|
}
|
|
82
|
+
export function isOpenspecSpecFilePath(filePath) {
|
|
83
|
+
return isFrontendSpecFilePath(filePath);
|
|
84
|
+
}
|
|
66
85
|
/**
|
|
67
86
|
* Returns `true` when free-form search input references a canonical frontend
|
|
68
87
|
* specification directory with exact lowercase directory names.
|
|
@@ -123,3 +142,50 @@ export function extractTaskSourceOpenspecPaths(markdown, governanceRoot = DEFAUL
|
|
|
123
142
|
!isGovernanceSubtreePath(token, governanceRoot))
|
|
124
143
|
.sort();
|
|
125
144
|
}
|
|
145
|
+
/**
|
|
146
|
+
* Extract explicit specification-file citations for a task's frozen spec roots.
|
|
147
|
+
* This is intentionally path-only: source preparation decides which roots are
|
|
148
|
+
* normative, while DAG execution only consumes that frozen configuration.
|
|
149
|
+
*/
|
|
150
|
+
export function extractTaskSourceFrontendSpecPaths(markdown, specRoots, governanceRoot = DEFAULT_OPENSPEC_GOVERNANCE_ROOT) {
|
|
151
|
+
if (!markdown)
|
|
152
|
+
return [];
|
|
153
|
+
const raw = new Set();
|
|
154
|
+
const collect = (token) => {
|
|
155
|
+
const normalized = normalizeCitationToken(token);
|
|
156
|
+
if (normalized)
|
|
157
|
+
raw.add(normalized);
|
|
158
|
+
};
|
|
159
|
+
for (const match of markdown.matchAll(/`([^`\n]+)`/g))
|
|
160
|
+
collect(match[1] ?? "");
|
|
161
|
+
for (const match of markdown.matchAll(/\[[^\]]*\]\(([^)\s]+)\)/g))
|
|
162
|
+
collect(match[1] ?? "");
|
|
163
|
+
for (const root of specRoots) {
|
|
164
|
+
const escaped = root.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
165
|
+
for (const match of markdown.matchAll(new RegExp(`(?:^|[\\s\"'([>])(${escaped}/[A-Za-z0-9._/-]+)`, "g"))) {
|
|
166
|
+
collect(match[1] ?? "");
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return [...raw]
|
|
170
|
+
.filter((token) => isFrontendSpecFilePath(token, specRoots) && !isGovernanceSubtreePath(token, governanceRoot))
|
|
171
|
+
.sort();
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Source-preparation helper for explicitly named normative directories. A root
|
|
175
|
+
* is inferred only on a line that declares a spec/规范/design-system intent;
|
|
176
|
+
* arbitrary Markdown links never silently broaden task configuration.
|
|
177
|
+
*/
|
|
178
|
+
export function extractDeclaredFrontendSpecRoots(markdown) {
|
|
179
|
+
const roots = new Set();
|
|
180
|
+
for (const line of markdown.split(/\r?\n/)) {
|
|
181
|
+
if (!/(?:规范|规约|标准|设计系统|\bspec(?:ification)?\b|\bdesign[ -]?system\b|\bguidelines?\b|\brules?\b)/i.test(line))
|
|
182
|
+
continue;
|
|
183
|
+
for (const match of line.matchAll(/`([^`]+)`|\[[^\]]+\]\(([^)\s]+)\)/g)) {
|
|
184
|
+
const raw = (match[1] ?? match[2] ?? "").replaceAll("\\", "/").replace(/\/+$/, "");
|
|
185
|
+
if (!raw || !isValidFrontendSpecRoot(raw))
|
|
186
|
+
continue;
|
|
187
|
+
roots.add(isValidOpenspecExtension(raw) ? raw.split("/").slice(0, -1).join("/") : raw);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return [...roots].filter(isValidFrontendSpecRoot).sort();
|
|
191
|
+
}
|
|
@@ -51,6 +51,8 @@ const OFFICIAL_ACTION_DESCRIPTIONS = {
|
|
|
51
51
|
workerSchedulerStatus: "Night-scheduler status overview (agent-worker). Use to check whether overnight jobs are healthy.",
|
|
52
52
|
workerSchedulerLedger: "Night-scheduler harvest ledger (agent-worker). Use to audit what overnight runs produced.",
|
|
53
53
|
workerSchedulerDoctor: "Diagnose night-scheduler health (agent-worker). Use when overnight jobs fail to fire or harvest.",
|
|
54
|
+
dagResume: "Unpause a run paused at a human decision checkpoint. Orphaned runs (dead runner, liveness=orphaned) are NOT continuable — do not resume them: use dagReconcileRun --action supersede to archive and then advance/rerun the task fresh.",
|
|
55
|
+
dagReconcileRun: "Reconcile an orphaned run (dead runner, liveness=orphaned). These are NOT continuable: supersede archives the run for a fresh same-task advance/rerun; abandon discards it. resume only unpauses human-decision checkpoints — never for orphaned runs.",
|
|
54
56
|
};
|
|
55
57
|
const officialAction = (action, cli, kind, coverage) => ({
|
|
56
58
|
action,
|
|
@@ -817,7 +819,7 @@ export function buildOperatorCapabilitiesDocument() {
|
|
|
817
819
|
"BINDING_DRIFT",
|
|
818
820
|
"HUMAN_CONFIRMATION_REQUIRED",
|
|
819
821
|
],
|
|
820
|
-
description: "
|
|
822
|
+
description: "Returns SYNCHRONOUSLY (not an operation): it immediately yields a session-bound single-use executionId + receipt, which you then pass to runDag to actually execute. It is a server-side G2 assessment (bounded writeSet ⊆ allowedPaths, no forbidden overlap, no broad/destructive risk, structured verification). The model never passes a raw DAG path.",
|
|
821
823
|
inputParams: [
|
|
822
824
|
{
|
|
823
825
|
name: "taskId",
|
|
@@ -1067,6 +1069,12 @@ export function buildOperatorCapabilitiesDocument() {
|
|
|
1067
1069
|
required: false,
|
|
1068
1070
|
description: "verification entries as label:command strings",
|
|
1069
1071
|
},
|
|
1072
|
+
{
|
|
1073
|
+
name: "approveGate",
|
|
1074
|
+
type: "string",
|
|
1075
|
+
required: false,
|
|
1076
|
+
description: "optional write-set gate approval token `<gate-id>:sha256:<64-hex>` exactly as reported by task status gate.approveCommand; forwards as --approve-gate and executes the approved DAG as this background operation (preferred over a foreground terminal)",
|
|
1077
|
+
},
|
|
1070
1078
|
],
|
|
1071
1079
|
modelCallable: "always",
|
|
1072
1080
|
humanConfirmation: "none",
|
|
@@ -1155,6 +1163,19 @@ export function buildOperatorCapabilitiesDocument() {
|
|
|
1155
1163
|
modelCallable: "always",
|
|
1156
1164
|
humanConfirmation: "none",
|
|
1157
1165
|
},
|
|
1166
|
+
{
|
|
1167
|
+
action: "dagPromptOverrideConfig",
|
|
1168
|
+
cli: "console dag-prompt-override-config",
|
|
1169
|
+
kind: "read",
|
|
1170
|
+
inputSchemaVersion: 1,
|
|
1171
|
+
resultSchemaVersion: 1,
|
|
1172
|
+
envelopeSchemaVersion: 1,
|
|
1173
|
+
requiredErrorCodes: [],
|
|
1174
|
+
description: "Read-only probe of the experimental prompt-override rerun switch (env-gated, default off). The browser Recovery UI hides the failed-node prompt editor unless this returns enabled=true. Never mutates.",
|
|
1175
|
+
inputParams: [],
|
|
1176
|
+
modelCallable: "always",
|
|
1177
|
+
humanConfirmation: "none",
|
|
1178
|
+
},
|
|
1158
1179
|
{
|
|
1159
1180
|
action: "dagRerunPlan",
|
|
1160
1181
|
cli: "loop-agent dag rerun --run-id <id> --from-node <node> --plan --json",
|
|
@@ -1163,7 +1184,7 @@ export function buildOperatorCapabilitiesDocument() {
|
|
|
1163
1184
|
resultSchemaVersion: 1,
|
|
1164
1185
|
envelopeSchemaVersion: 1,
|
|
1165
1186
|
requiredErrorCodes: ["INVALID_INPUT", "NOT_FOUND"],
|
|
1166
|
-
description: "Read-only check
|
|
1187
|
+
description: "Read-only check for failed-node recovery; it does not execute. Call after dagReport with primaryFailure.nodeId. eligible=true returns the exact planHash required by dagRerun. eligible=false covers writer/decision/fingerprint, unsafe shell, Worker ownership, or workspace/controller drift: use workerTaskRetry for Worker/Task Pool failures, or standaloneTaskRerun after any required contract adopt for standalone runs. Do not force dagRerun or invent a new task.",
|
|
1167
1188
|
inputParams: [
|
|
1168
1189
|
{
|
|
1169
1190
|
name: "runId",
|
|
@@ -1177,6 +1198,12 @@ export function buildOperatorCapabilitiesDocument() {
|
|
|
1177
1198
|
required: true,
|
|
1178
1199
|
description: "node id to rerun from (prefer failed/attention node from dagReport primaryFailure.nodeId)",
|
|
1179
1200
|
},
|
|
1201
|
+
{
|
|
1202
|
+
name: "promptOverrides",
|
|
1203
|
+
type: "array",
|
|
1204
|
+
required: false,
|
|
1205
|
+
description: "experimental (switch off by default): [{nodeId, prompt, mode?}] — mode append (recommended) keeps the frozen base prompt and appends the text as a marked addendum block, replace swaps the whole subtask_prompt; only FAILED nodes inside the reset closure are admitted and the planHash binds the composed change",
|
|
1206
|
+
},
|
|
1180
1207
|
],
|
|
1181
1208
|
modelCallable: "always",
|
|
1182
1209
|
humanConfirmation: "none",
|
|
@@ -1193,7 +1220,7 @@ export function buildOperatorCapabilitiesDocument() {
|
|
|
1193
1220
|
"BINDING_DRIFT",
|
|
1194
1221
|
"INVALID_INPUT",
|
|
1195
1222
|
],
|
|
1196
|
-
description: "Continue the same DAG from
|
|
1223
|
+
description: "Continue the same DAG from the effective failed node by creating a continuation run. Requires a fresh eligible dagRerunPlan and its exact planHash. Prefer this for provider, network, rate-limit, timeout, and other safe downstream failures. Not a full task regenerate: use standaloneTaskRerun for that. Server rejects stale planHash, binding, or fingerprint drift.",
|
|
1197
1224
|
inputParams: [
|
|
1198
1225
|
{
|
|
1199
1226
|
name: "runId",
|
|
@@ -1219,6 +1246,12 @@ export function buildOperatorCapabilitiesDocument() {
|
|
|
1219
1246
|
required: true,
|
|
1220
1247
|
description: "why continue from this node (e.g. provider flake; resume from review-pi)",
|
|
1221
1248
|
},
|
|
1249
|
+
{
|
|
1250
|
+
name: "promptOverrides",
|
|
1251
|
+
type: "array",
|
|
1252
|
+
required: false,
|
|
1253
|
+
description: "experimental (switch off by default): must match the dagRerunPlan promptOverrides exactly (same mode/text); the planHash already binds them, any drift is rejected",
|
|
1254
|
+
},
|
|
1222
1255
|
],
|
|
1223
1256
|
// always: fresh eligible dagRerun plans are model-callable (2026-08-11).
|
|
1224
1257
|
// The CLI keeps enforcing parent lifecycle, fromNode, planHash,
|
|
@@ -1559,7 +1592,7 @@ export function buildOperatorCapabilitiesDocument() {
|
|
|
1559
1592
|
"INVALID_INPUT",
|
|
1560
1593
|
"HUMAN_CONFIRMATION_REQUIRED",
|
|
1561
1594
|
],
|
|
1562
|
-
description: "Regenerate the whole standalone DAG from the CURRENT contract, then validate and execute a new run
|
|
1595
|
+
description: "Regenerate the whole standalone DAG from the CURRENT contract, then validate and execute a new run with parent lineage and the latest unresolved verify/review feedback when available. This is NOT continue-from-failed-node (use dagRerun for that). Server rejects the call when dagRerunPlan is eligible, primaryRecovery.humanRequired=true, or run facts do not recommend rerun-task. Feedback is recovery context, not a contract rewrite; adopt required contract changes before calling or the new DAG repeats the same failure.",
|
|
1563
1596
|
inputParams: [
|
|
1564
1597
|
{
|
|
1565
1598
|
name: "runId",
|
|
@@ -1822,6 +1855,13 @@ export const OPERATOR_COMMAND_COVERAGE = Object.freeze([
|
|
|
1822
1855
|
source: "loop-agent",
|
|
1823
1856
|
exclusionReason: "Not exposed to Operator Chat in M5.",
|
|
1824
1857
|
},
|
|
1858
|
+
{
|
|
1859
|
+
command: "loop-agent init model-catalog",
|
|
1860
|
+
coverage: "excluded",
|
|
1861
|
+
action: null,
|
|
1862
|
+
source: "loop-agent",
|
|
1863
|
+
exclusionReason: "Not exposed to Operator Chat in M5.",
|
|
1864
|
+
},
|
|
1825
1865
|
{
|
|
1826
1866
|
command: "loop-agent init doctor",
|
|
1827
1867
|
coverage: "excluded",
|
|
@@ -2200,6 +2240,13 @@ export const OPERATOR_COMMAND_COVERAGE = Object.freeze([
|
|
|
2200
2240
|
source: "loop-agent",
|
|
2201
2241
|
note: "server-side read-only run-facts check (ineligible plan / explicit rerun-task recommendation) replaces the browser Human Gate (2026-08-11).",
|
|
2202
2242
|
},
|
|
2243
|
+
{
|
|
2244
|
+
command: "loop-agent dag follow-up",
|
|
2245
|
+
coverage: "excluded",
|
|
2246
|
+
action: null,
|
|
2247
|
+
source: "loop-agent",
|
|
2248
|
+
exclusionReason: "Frontend review recovery helper is a direct advanced CLI composition (create/import task and optional advance), not an Operator action endpoint.",
|
|
2249
|
+
},
|
|
2203
2250
|
{
|
|
2204
2251
|
command: "loop-agent dag reconcile-tasks",
|
|
2205
2252
|
coverage: "human-gated-required",
|
|
@@ -2212,6 +2259,20 @@ export const OPERATOR_COMMAND_COVERAGE = Object.freeze([
|
|
|
2212
2259
|
action: "dagFinalVerification",
|
|
2213
2260
|
source: "loop-agent",
|
|
2214
2261
|
},
|
|
2262
|
+
{
|
|
2263
|
+
command: "loop-agent dag context",
|
|
2264
|
+
coverage: "excluded",
|
|
2265
|
+
action: null,
|
|
2266
|
+
source: "loop-agent",
|
|
2267
|
+
exclusionReason: "Context export can disclose raw execution bytes and requires a human-selected output path; Console uses dedicated gated actions instead of the generic CLI wrapper.",
|
|
2268
|
+
},
|
|
2269
|
+
{
|
|
2270
|
+
command: "loop-agent dag artifact",
|
|
2271
|
+
coverage: "excluded",
|
|
2272
|
+
action: null,
|
|
2273
|
+
source: "loop-agent",
|
|
2274
|
+
exclusionReason: "Artifact revision staging consumes a human-selected local file and remains on dedicated Console/CLI mutation gates.",
|
|
2275
|
+
},
|
|
2215
2276
|
{
|
|
2216
2277
|
command: "loop-agent workflow list",
|
|
2217
2278
|
coverage: "advanced",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { constants as fsConstants } from "node:fs";
|
|
2
|
+
import { lstat, open, realpath } from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
function assertContained(root, target, label) {
|
|
5
|
+
if (target === root || !target.startsWith(`${root}${path.sep}`)) {
|
|
6
|
+
throw new Error(`${label}: path escapes boundary: ${target}`);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Reject any symlink on the path between `boundaryRoot` and `targetPath`.
|
|
11
|
+
* This is the lexical/path-walk phase; callers that consume file bytes must
|
|
12
|
+
* still use readFileBoundarySafe so the checked object is the opened object.
|
|
13
|
+
*/
|
|
14
|
+
export async function assertRealPathInsideBoundary(input) {
|
|
15
|
+
const root = path.resolve(input.boundaryRoot);
|
|
16
|
+
const target = path.resolve(input.targetPath);
|
|
17
|
+
assertContained(root, target, input.label);
|
|
18
|
+
const rootStat = await lstat(root).catch(() => undefined);
|
|
19
|
+
if (!rootStat) {
|
|
20
|
+
throw new Error(`${input.label}: boundary root is not a real directory`);
|
|
21
|
+
}
|
|
22
|
+
if (rootStat.isSymbolicLink()) {
|
|
23
|
+
throw new Error(`${input.label}: boundary root must not be a symlink`);
|
|
24
|
+
}
|
|
25
|
+
if (!rootStat.isDirectory()) {
|
|
26
|
+
throw new Error(`${input.label}: boundary root is not a real directory`);
|
|
27
|
+
}
|
|
28
|
+
const segments = path.relative(root, target).split(path.sep).filter(Boolean);
|
|
29
|
+
let current = root;
|
|
30
|
+
for (let index = 0; index < segments.length; index += 1) {
|
|
31
|
+
current = path.join(current, segments[index]);
|
|
32
|
+
const stat = await lstat(current).catch(() => undefined);
|
|
33
|
+
if (!stat) {
|
|
34
|
+
throw new Error(`${input.label}: path component missing: ${segments[index]}`);
|
|
35
|
+
}
|
|
36
|
+
if (stat.isSymbolicLink()) {
|
|
37
|
+
throw new Error(`${input.label}: symlink is forbidden on path: ${segments[index]}`);
|
|
38
|
+
}
|
|
39
|
+
if (index < segments.length - 1 && !stat.isDirectory()) {
|
|
40
|
+
throw new Error(`${input.label}: path ancestor is not a directory: ${segments[index]}`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return target;
|
|
44
|
+
}
|
|
45
|
+
/** Reject a non-regular, symlinked, or hardlinked final entry before opening. */
|
|
46
|
+
export async function assertReadableRegularFile(input) {
|
|
47
|
+
const target = await assertRealPathInsideBoundary(input);
|
|
48
|
+
const stat = await lstat(target).catch(() => undefined);
|
|
49
|
+
if (!stat)
|
|
50
|
+
throw new Error(`${input.label}: path component missing`);
|
|
51
|
+
if (!stat.isFile() || stat.isSymbolicLink() || stat.nlink !== 1) {
|
|
52
|
+
throw new Error(`${input.label}: path must be a regular single-link file`);
|
|
53
|
+
}
|
|
54
|
+
return target;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Read one owned regular file without reopening an unchecked pathname.
|
|
58
|
+
*
|
|
59
|
+
* The preflight rejects normal FIFO/device/hardlink cases without opening
|
|
60
|
+
* them. O_NOFOLLOW rejects a final symlink introduced after preflight and
|
|
61
|
+
* O_NONBLOCK prevents a swapped FIFO from blocking. The post-open identity and
|
|
62
|
+
* realpath checks make an ancestor swap detectable before bytes are consumed.
|
|
63
|
+
*/
|
|
64
|
+
export async function readFileBoundarySafe(input) {
|
|
65
|
+
const target = await assertReadableRegularFile(input);
|
|
66
|
+
const flags = fsConstants.O_RDONLY |
|
|
67
|
+
(fsConstants.O_NOFOLLOW ?? 0) |
|
|
68
|
+
(fsConstants.O_NONBLOCK ?? 0);
|
|
69
|
+
const handle = await open(target, flags);
|
|
70
|
+
try {
|
|
71
|
+
const opened = await handle.stat();
|
|
72
|
+
if (!opened.isFile() || opened.nlink !== 1) {
|
|
73
|
+
throw new Error(`${input.label}: path must be a regular single-link file`);
|
|
74
|
+
}
|
|
75
|
+
const [resolvedRoot, resolvedTarget, current] = await Promise.all([
|
|
76
|
+
realpath(path.resolve(input.boundaryRoot)),
|
|
77
|
+
realpath(target),
|
|
78
|
+
lstat(target),
|
|
79
|
+
]);
|
|
80
|
+
assertContained(resolvedRoot, resolvedTarget, input.label);
|
|
81
|
+
if (current.isSymbolicLink() ||
|
|
82
|
+
!current.isFile() ||
|
|
83
|
+
current.nlink !== 1 ||
|
|
84
|
+
current.dev !== opened.dev ||
|
|
85
|
+
current.ino !== opened.ino) {
|
|
86
|
+
throw new Error(`${input.label}: path changed while opening`);
|
|
87
|
+
}
|
|
88
|
+
return await handle.readFile();
|
|
89
|
+
}
|
|
90
|
+
finally {
|
|
91
|
+
await handle.close().catch(() => { });
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
const CHECKPOINT_MAX_BYTES = 12 * 1024;
|
|
2
|
+
function boundText(value, maxChars) {
|
|
3
|
+
if (typeof value !== "string" || !value.trim())
|
|
4
|
+
return "";
|
|
5
|
+
return value.length <= maxChars ? value : `${value.slice(0, maxChars - 1)}…`;
|
|
6
|
+
}
|
|
7
|
+
function asRecord(value) {
|
|
8
|
+
return value !== null && typeof value === "object" && !Array.isArray(value)
|
|
9
|
+
? value
|
|
10
|
+
: undefined;
|
|
11
|
+
}
|
|
12
|
+
function extractLastUserGoal(messages) {
|
|
13
|
+
if (!Array.isArray(messages))
|
|
14
|
+
return "";
|
|
15
|
+
for (let index = messages.length - 1; index >= 0; index -= 1) {
|
|
16
|
+
const message = asRecord(messages[index]);
|
|
17
|
+
if (!message || message.role !== "user")
|
|
18
|
+
continue;
|
|
19
|
+
const content = message.content;
|
|
20
|
+
if (typeof content === "string")
|
|
21
|
+
return boundText(content, 800);
|
|
22
|
+
if (Array.isArray(content)) {
|
|
23
|
+
const texts = content
|
|
24
|
+
.map((block) => {
|
|
25
|
+
const rec = asRecord(block);
|
|
26
|
+
return typeof rec?.text === "string" ? rec.text : "";
|
|
27
|
+
})
|
|
28
|
+
.filter(Boolean);
|
|
29
|
+
if (texts.length > 0)
|
|
30
|
+
return boundText(texts.join("\n"), 800);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return "";
|
|
34
|
+
}
|
|
35
|
+
function extractTodos(details) {
|
|
36
|
+
const record = asRecord(details);
|
|
37
|
+
const todos = record?.todos ?? record?.items;
|
|
38
|
+
if (!Array.isArray(todos))
|
|
39
|
+
return "";
|
|
40
|
+
const lines = todos
|
|
41
|
+
.slice(0, 24)
|
|
42
|
+
.map((item) => {
|
|
43
|
+
const rec = asRecord(item);
|
|
44
|
+
const status = typeof rec?.status === "string" ? rec.status : "pending";
|
|
45
|
+
const content = typeof rec?.content === "string"
|
|
46
|
+
? rec.content
|
|
47
|
+
: typeof rec?.title === "string"
|
|
48
|
+
? rec.title
|
|
49
|
+
: "";
|
|
50
|
+
return content ? `- [${status}] ${content}` : "";
|
|
51
|
+
})
|
|
52
|
+
.filter(Boolean);
|
|
53
|
+
return boundText(lines.join("\n"), 1200);
|
|
54
|
+
}
|
|
55
|
+
function extractFileOps(fileOps) {
|
|
56
|
+
const record = asRecord(fileOps);
|
|
57
|
+
if (!record)
|
|
58
|
+
return "";
|
|
59
|
+
const parts = [];
|
|
60
|
+
for (const key of ["edited", "written", "read", "deleted", "ops"]) {
|
|
61
|
+
const value = record[key];
|
|
62
|
+
if (Array.isArray(value)) {
|
|
63
|
+
parts.push(`${key}: ${value
|
|
64
|
+
.slice(0, 20)
|
|
65
|
+
.map((item) => (typeof item === "string" ? item : JSON.stringify(item)))
|
|
66
|
+
.join(", ")}`);
|
|
67
|
+
}
|
|
68
|
+
else if (typeof value === "string" && value) {
|
|
69
|
+
parts.push(`${key}: ${value}`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (parts.length === 0) {
|
|
73
|
+
try {
|
|
74
|
+
return boundText(JSON.stringify(fileOps), 800);
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
return "";
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return boundText(parts.join("\n"), 800);
|
|
81
|
+
}
|
|
82
|
+
export function buildOverflowCheckpoint(input) {
|
|
83
|
+
const preparation = input.preparation;
|
|
84
|
+
const firstKeptEntryId = typeof preparation?.firstKeptEntryId === "string" &&
|
|
85
|
+
preparation.firstKeptEntryId
|
|
86
|
+
? preparation.firstKeptEntryId
|
|
87
|
+
: undefined;
|
|
88
|
+
const tokensBefore = typeof preparation?.tokensBefore === "number" &&
|
|
89
|
+
Number.isFinite(preparation.tokensBefore)
|
|
90
|
+
? preparation.tokensBefore
|
|
91
|
+
: undefined;
|
|
92
|
+
if (!firstKeptEntryId || tokensBefore === undefined)
|
|
93
|
+
return undefined;
|
|
94
|
+
const sections = [
|
|
95
|
+
"Deterministic overflow checkpoint (no extra summary request).",
|
|
96
|
+
boundText(preparation?.previousSummary, 2000)
|
|
97
|
+
? `Previous summary:\n${boundText(preparation?.previousSummary, 2000)}`
|
|
98
|
+
: "",
|
|
99
|
+
extractLastUserGoal(preparation?.messagesToSummarize)
|
|
100
|
+
? `Latest user goal:\n${extractLastUserGoal(preparation?.messagesToSummarize)}`
|
|
101
|
+
: "",
|
|
102
|
+
extractTodos(input.todos) ? `Open todos:\n${extractTodos(input.todos)}` : "",
|
|
103
|
+
extractFileOps(preparation?.fileOps)
|
|
104
|
+
? `File ops:\n${extractFileOps(preparation?.fileOps)}`
|
|
105
|
+
: "",
|
|
106
|
+
typeof input.lastError === "string" && input.lastError
|
|
107
|
+
? `Latest error:\n${boundText(input.lastError, 400)}`
|
|
108
|
+
: "",
|
|
109
|
+
"Next step: continue the interrupted turn from the kept recent messages. Do not repeat completed file writes.",
|
|
110
|
+
].filter(Boolean);
|
|
111
|
+
let summary = sections.join("\n\n");
|
|
112
|
+
if (Buffer.byteLength(summary, "utf8") > CHECKPOINT_MAX_BYTES) {
|
|
113
|
+
summary = `${summary.slice(0, CHECKPOINT_MAX_BYTES - 1)}…`;
|
|
114
|
+
}
|
|
115
|
+
return { summary, firstKeptEntryId, tokensBefore };
|
|
116
|
+
}
|