@tea-agent/loop-agent 0.39.0-beta.1 → 0.39.0-beta.11
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 +4 -1
- package/CHANGELOG.md +349 -97
- package/README.md +9 -5
- package/bin/loop-agent.js +7 -3
- package/dist/application/task-lifecycle/advance.js +12 -0
- package/dist/application/task-lifecycle/recommendations.js +13 -2
- package/dist/build-stamp.json +3 -3
- package/dist/cli/command-definitions.js +23 -5
- package/dist/cli/program.js +21 -2
- 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 +3 -0
- package/dist/commands/dag-follow-up.js +138 -0
- package/dist/commands/dag-rerun.js +55 -1
- package/dist/commands/init-model-catalog.js +464 -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 +19 -0
- package/dist/executors/dag-pi-executor.js +2370 -64
- package/dist/executors/pi-executor.js +11 -2
- package/dist/executors/pi-extension-resolver.js +233 -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 +225 -33
- package/dist/executors/pi-writer-tool-policy.js +57 -1
- package/dist/executors/shell-executor.js +1258 -224
- package/dist/executors/shell-write-guard.js +14 -0
- package/dist/executors/workspace-write-snapshot.js +68 -0
- package/dist/infrastructure/harness/atomic-write.js +23 -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 +39 -0
- package/dist/shared/playwright-cli-command-policy.js +15 -0
- 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 +50 -5
- package/dist/task/contract/apply.js +11 -1
- package/dist/task/contract/constants.js +2 -0
- package/dist/task/contract/hash.js +3 -0
- package/dist/task/contract/observe.js +25 -4
- package/dist/task/contract/paths.js +2 -1
- package/dist/task/contract/project.js +18 -1
- package/dist/task/contract/schema.js +4 -1
- package/dist/task/contract/transaction.js +12 -0
- package/dist/task/frontend-project-capability.js +199 -18
- package/dist/task/source-prepare/completeness.js +188 -0
- package/dist/task/source-prepare/fragment-inventory.js +477 -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 +298 -1
- 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/worker/cli.js +18 -2
- package/dist/worker/console/chat/chat-event-store.js +75 -5
- package/dist/worker/console/chat/context-panel.js +7 -0
- package/dist/worker/console/chat/deferred-turn.js +12 -0
- 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 +331 -18
- package/dist/worker/console/chat/provider-error.js +98 -0
- package/dist/worker/console/chat/routes.js +395 -59
- package/dist/worker/console/chat/session-stats.js +179 -0
- package/dist/worker/console/chat/session-store.js +93 -63
- 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 +20 -55
- 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/dag-execution-receipt.js +33 -0
- package/dist/worker/console/draft-store.js +49 -0
- 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/index.js +3 -0
- package/dist/worker/console/inspect-split.js +18 -0
- 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-store.js +227 -7
- package/dist/worker/console/operator-actions.js +388 -0
- package/dist/worker/console/operator-surface-health.js +1 -0
- package/dist/worker/console/operator-user-error.js +2 -2
- package/dist/worker/console/prd-intake-bridge.js +13 -0
- package/dist/worker/console/routes.js +355 -3
- package/dist/worker/console/security.js +67 -13
- package/dist/worker/console/server.js +609 -164
- package/dist/worker/console/static/assets/{abnfDiagram-N423BO3Z-C4kVYweA.js → abnfDiagram-N423BO3Z-CXj_GnSb.js} +1 -1
- package/dist/worker/console/static/assets/{arc-Bj2M8iO5.js → arc-BZp6JAp7.js} +1 -1
- package/dist/worker/console/static/assets/{architectureDiagram-T3A2C74G-CLlXe4-6.js → architectureDiagram-T3A2C74G-DfpcEuYU.js} +1 -1
- package/dist/worker/console/static/assets/{blockDiagram-VBNYF7ZC-psEp5xH0.js → blockDiagram-VBNYF7ZC-_Gf0xadb.js} +1 -1
- package/dist/worker/console/static/assets/{c4Diagram-5PPSVZJV-DeKcOCGJ.js → c4Diagram-5PPSVZJV-Ct2QPCmv.js} +1 -1
- package/dist/worker/console/static/assets/channel-3TxJgYaH.js +1 -0
- package/dist/worker/console/static/assets/{chunk-2GRJ4B5K-K0C744p1.js → chunk-2GRJ4B5K-BfklkzKl.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-2Q5K7J3B-xbNw4J9-.js → chunk-2Q5K7J3B-Dy25vZJV.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-5RXB4S5H-DjLaSDUO.js → chunk-5RXB4S5H-BFlCRZep.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-5VM5RSS4-CtiPlKel.js → chunk-5VM5RSS4-op3oVxIE.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-6Q2QTUOP-DZtolir7.js → chunk-6Q2QTUOP-C0R7rzF2.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-GF5L2VYU-CPcdNeew.js → chunk-GF5L2VYU-Bt44TCGy.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-JWPE2WC7-NgHc6V37.js → chunk-JWPE2WC7-_uEE_XFx.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-KBJHAD2P-DQ_T-hg8.js → chunk-KBJHAD2P-C3TOYGZ9.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-RYQCIY6F-DgLsxcVP.js → chunk-RYQCIY6F-Cz60oBPV.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-XXDRQBXY-UrVoM9z1.js → chunk-XXDRQBXY-8Bik0qis.js} +1 -1
- package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-BHIkXpp3.js +1 -0
- package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-BHIkXpp3.js +1 -0
- package/dist/worker/console/static/assets/{cose-bilkent-JH36ORCC-CLkYvTb3.js → cose-bilkent-JH36ORCC-C2QIOA4a.js} +1 -1
- package/dist/worker/console/static/assets/{cynefin-VYW2F7L2-BwT_xKrE.js → cynefin-VYW2F7L2-CSH_yUUd.js} +1 -1
- package/dist/worker/console/static/assets/{cynefinDiagram-MW4NZA55-Bi9tuzif.js → cynefinDiagram-MW4NZA55-BDLw2XFM.js} +1 -1
- package/dist/worker/console/static/assets/{dagre-VZM6K2ZE-BCIqkWBV.js → dagre-VZM6K2ZE-CcD9ZtF4.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-7IWD3JNH-Dip6l9_Z.js → diagram-7IWD3JNH-DqwtkBsI.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-B4RE2ZJO-B-xkh_wK.js → diagram-B4RE2ZJO-BWVEcqsC.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-LBJQPF4R-DZO0kTt_.js → diagram-LBJQPF4R-M-WAbtQi.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-Q27KOJAE-D6ZplNbZ.js → diagram-Q27KOJAE-DKW7SixP.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-UB23O5K3-BPekbhoS.js → diagram-UB23O5K3-PHHPPtrj.js} +1 -1
- package/dist/worker/console/static/assets/{ebnfDiagram-BXEA7PRR-BtmaJpK5.js → ebnfDiagram-BXEA7PRR-BQD-B4RX.js} +1 -1
- package/dist/worker/console/static/assets/{erDiagram-JOGREHBK-6DS0Xc44.js → erDiagram-JOGREHBK-BFvULb51.js} +1 -1
- package/dist/worker/console/static/assets/{flowDiagram-UKHOOZJN-CihnROSm.js → flowDiagram-UKHOOZJN-Bw-aXTCb.js} +1 -1
- package/dist/worker/console/static/assets/{ganttDiagram-PKOTCBZU-CZC4zOE2.js → ganttDiagram-PKOTCBZU-BGKw04Qx.js} +1 -1
- package/dist/worker/console/static/assets/{gitGraphDiagram-DS77QQ5N-Dq1fhzGN.js → gitGraphDiagram-DS77QQ5N-RqKaPR-I.js} +1 -1
- package/dist/worker/console/static/assets/index-B_D8rbWc.js +407 -0
- package/dist/worker/console/static/assets/index-BdNx6fj0.css +1 -0
- package/dist/worker/console/static/assets/{infoDiagram-6WML65LV-DlSl4BGx.js → infoDiagram-6WML65LV-YO5dnzrJ.js} +1 -1
- package/dist/worker/console/static/assets/{ishikawaDiagram-WSZJBQD7-snnzFl_U.js → ishikawaDiagram-WSZJBQD7-Bi1VZHMq.js} +1 -1
- package/dist/worker/console/static/assets/{journeyDiagram-NVQOT4AX-BDE7qpMx.js → journeyDiagram-NVQOT4AX-Bszls1DD.js} +1 -1
- package/dist/worker/console/static/assets/{kanban-definition-27J2QSJJ-CD2Ci04G.js → kanban-definition-27J2QSJJ-PhzeaZ09.js} +1 -1
- package/dist/worker/console/static/assets/{linear-DdnapKIH.js → linear-BsjbDoXi.js} +1 -1
- package/dist/worker/console/static/assets/{mermaid.core-BVjAT9b8.js → mermaid.core-0B7NnWKk.js} +5 -5
- package/dist/worker/console/static/assets/{mindmap-definition-FAOFIHXS-D0yJk-zA.js → mindmap-definition-FAOFIHXS-BJr4Fj-q.js} +1 -1
- package/dist/worker/console/static/assets/{pegDiagram-VL7TDLO6-BVo9tFP-.js → pegDiagram-VL7TDLO6-moC4fpGB.js} +1 -1
- package/dist/worker/console/static/assets/{pieDiagram-7S7Q4E2Y-DnOV-mZ_.js → pieDiagram-7S7Q4E2Y-BEw37-2c.js} +1 -1
- package/dist/worker/console/static/assets/{quadrantDiagram-CIZ2JOQS-CzUJo58i.js → quadrantDiagram-CIZ2JOQS-Cq6LyasU.js} +1 -1
- package/dist/worker/console/static/assets/{railroadDiagram-AXF67PYL-Bvikrolh.js → railroadDiagram-AXF67PYL-DUCMcK0D.js} +1 -1
- package/dist/worker/console/static/assets/{requirementDiagram-LRYGKXZP-DtaSVCap.js → requirementDiagram-LRYGKXZP-C3upTZm7.js} +1 -1
- package/dist/worker/console/static/assets/{sankeyDiagram-W5VNT64P-C2c9A0wW.js → sankeyDiagram-W5VNT64P-BI_gMsCW.js} +1 -1
- package/dist/worker/console/static/assets/{sequenceDiagram-SI44F4Z6-DmXJcU7r.js → sequenceDiagram-SI44F4Z6-YFOIRzfN.js} +1 -1
- package/dist/worker/console/static/assets/{sizeCapture-X5ZJPWSS-B4GUFW92.js → sizeCapture-X5ZJPWSS-dOnB7UDD.js} +1 -1
- package/dist/worker/console/static/assets/{stateDiagram-OKZ733FA-Dsad2MXf.js → stateDiagram-OKZ733FA-BXUniaIh.js} +1 -1
- package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-Cdi6UhLa.js +1 -0
- package/dist/worker/console/static/assets/{swimlanes-SLNWSIFB-DGq48Fbi.js → swimlanes-SLNWSIFB-2tA4wTNu.js} +2 -2
- package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-D-RJBbb0.js +8 -0
- package/dist/worker/console/static/assets/{timeline-definition-Z64GVDOM-CSSi6OFf.js → timeline-definition-Z64GVDOM-DO0HkJXC.js} +1 -1
- package/dist/worker/console/static/assets/{vennDiagram-T6HMQDX7-BqyzPrWv.js → vennDiagram-T6HMQDX7-DvIOzixv.js} +1 -1
- package/dist/worker/console/static/assets/{wardleyDiagram-T6FBY63Y-DlznVb6S.js → wardleyDiagram-T6FBY63Y-DXDZ0cTj.js} +1 -1
- package/dist/worker/console/static/assets/{xychartDiagram-ELKLHX3M-CfBcgJ_K.js → xychartDiagram-ELKLHX3M-B32Ark0D.js} +1 -1
- package/dist/worker/console/static/index.html +2 -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 +41 -6
- package/dist/worker/console/static-src/app/useRecoveryConsole.js +45 -10
- package/dist/worker/console/static-src/app/useRunProgress.js +47 -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 +141 -8
- package/dist/worker/console/static-src/operator-chat/compaction-message.js +79 -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 +76 -0
- package/dist/worker/console/static-src/operator-chat/mutation-gate.js +1 -1
- 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/spatial-overlay.js +1 -2
- package/dist/worker/console/static-src/operator-chat/turn-stream-controller.js +25 -0
- package/dist/worker/console/static-src/operator-chat/turn-submission.js +16 -3
- package/dist/worker/console/static-src/operator-chat/useChatSessions.js +181 -87
- package/dist/worker/console/static-src/operator-chat/useChatStream.js +183 -48
- package/dist/worker/console/static-src/operator-chat/useChatThread.js +177 -8
- package/dist/worker/console/static-src/operator-chat/useComposer.js +32 -0
- package/dist/worker/console/static-src/operator-chat/useRepoBrowser.js +63 -9
- 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/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 +110 -0
- package/dist/worker/console/static-src/shell/useWorkspaces.js +299 -0
- package/dist/worker/console/static-src/shell/workspace-route.js +339 -0
- package/dist/worker/console/workspace-context.js +344 -0
- package/dist/worker/console/workspace-registry.js +214 -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 +22 -0
- package/dist/worker/observe/node-input.js +160 -3
- package/dist/worker/observe/node-process.js +377 -0
- package/dist/worker/observe/routes.js +224 -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 +90 -4
- package/dist/worker/observe/static/app.js +18 -70
- package/dist/worker/observe/static/constants.js +8 -1
- package/dist/worker/observe/static/dag-history-labels.js +4 -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 +6 -1
- package/dist/worker/observe/static/inspect-workspace.js +307 -0
- package/dist/worker/observe/static/markdown-render.js +20 -1
- package/dist/worker/observe/static/operator-chrome.css +145 -20
- package/dist/worker/observe/static/operator-chrome.d.ts +20 -3
- package/dist/worker/observe/static/operator-chrome.js +330 -96
- package/dist/worker/observe/static/prompt-restart-candidates.d.ts +18 -0
- package/dist/worker/observe/static/prompt-restart-candidates.js +36 -0
- package/dist/worker/observe/static/router.d.ts +46 -0
- package/dist/worker/observe/static/router.js +25 -1
- package/dist/worker/observe/static/state.d.ts +50 -0
- package/dist/worker/observe/static/state.js +184 -1
- package/dist/worker/observe/static/styles.css +395 -0
- package/dist/worker/observe/static/views/dag-graph.js +4 -2
- package/dist/worker/observe/static/views/dag-inspector.js +1067 -9
- package/dist/worker/observe/static/views/dag.d.ts +13 -0
- package/dist/worker/observe/static/views/dag.js +14 -5
- package/dist/worker/observe/static/views/dashboard.js +6 -4
- 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 +1 -0
- package/dist/worker/observe/static/views/run.js +3 -1
- package/dist/worker/observe/static/views/session-timeline.js +78 -9
- package/dist/worker/observe/static/views/task.js +56 -1
- package/dist/workflows/dag/backend-test-case-coverage-analysis.js +49 -3
- package/dist/workflows/dag/backend-test-markdown-workflow.js +176 -1
- package/dist/workflows/dag/backend-test-pytest-collection.js +98 -14
- package/dist/workflows/dag/backend-test-writer-completeness.js +17 -17
- package/dist/workflows/dag/contract-output-registry.js +15 -0
- package/dist/workflows/dag/contract-validator-registrations.js +1 -2
- 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 +538 -166
- package/dist/workflows/dag/frontend-plan-render.js +24 -0
- package/dist/workflows/dag/frontend-prewrite-gate.js +388 -392
- 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 +202 -0
- package/dist/workflows/dag/frontend-recovery-lineage.js +178 -0
- package/dist/workflows/dag/frontend-recovery-plan.js +17 -10
- package/dist/workflows/dag/frontend-recovery-run.js +33 -20
- package/dist/workflows/dag/frontend-repair.js +7 -424
- package/dist/workflows/dag/frontend-review-context.js +288 -14
- 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 +814 -0
- package/dist/workflows/dag/frontend-shape-capsule-store.js +191 -0
- package/dist/workflows/dag/frontend-shape-facts.js +409 -0
- package/dist/workflows/dag/frontend-shape.js +427 -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 +30 -4
- 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-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 +52 -17
- package/dist/workflows/dag/frontend-worktree-diff.js +250 -17
- package/dist/workflows/dag/frontend-writer-admission.js +272 -0
- package/dist/workflows/dag/frontend-writer-status.js +244 -0
- package/dist/workflows/dag/init-hybrid.js +1072 -660
- package/dist/workflows/dag/interrupt-request.js +10 -3
- package/dist/workflows/dag/lifecycle.js +3 -3
- package/dist/workflows/dag/node-execution.js +552 -58
- package/dist/workflows/dag/prompt.js +44 -19
- package/dist/workflows/dag/recovery-lease.js +80 -0
- package/dist/workflows/dag/report.js +37 -1
- package/dist/workflows/dag/rerun-feedback.js +124 -1
- package/dist/workflows/dag/rerun-plan.js +144 -5
- package/dist/workflows/dag/rerun-run.js +81 -6
- package/dist/workflows/dag/rerun-task.js +29 -0
- package/dist/workflows/dag/retry-policy.js +318 -8
- package/dist/workflows/dag/runner.js +429 -122
- package/dist/workflows/dag/scheduler.js +114 -16
- package/dist/workflows/dag/structured-output-repair.js +712 -0
- package/dist/workflows/dag/types.js +338 -31
- package/dist/workflows/dag/upstream-artifacts.js +0 -4
- package/dist/workflows/dag/validate.js +92 -32
- package/docs/README.md +2 -0
- package/docs/architecture/evolution.md +45 -0
- package/docs/init-surface.manifest.json +9 -0
- package/docs/operations/README.md +1 -1
- package/docs/operations/local-development-environment.md +21 -0
- package/docs/templates/README.md +2 -1
- package/docs/templates/agent-dag-report.schema.json +8 -2
- package/docs/templates/agent-dag.schema.json +63 -1
- package/docs/templates/backend-test-dag.json +265 -237
- package/docs/templates/frontend-implementation-contract.schema.json +684 -24
- 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/spec-registry.schema.json +45 -0
- package/harness.json +1 -1
- package/package.json +7 -1
- 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/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 +8 -14
- package/skills/frontend-design-review/SKILL.md +20 -41
- package/skills/frontend-implementation/SKILL.md +3 -4
- package/skills/frontend-implementation/references/design-spec.md +15 -10
- package/skills/frontend-implementation/references/node-contracts.md +23 -13
- package/skills/frontend-review/SKILL.md +22 -14
- package/skills/frontend-review/references/review-findings.md +6 -7
- package/skills/loop-agent/references/command-reference.md +12 -4
- package/skills/loop-agent/references/hybrid-dag.md +8 -1
- package/skills/playwright-cli/SKILL.md +23 -1
- package/skills/playwright-cli-case-generator/SKILL.md +29 -8
- package/dist/worker/console/static/assets/channel-CPF4N7pf.js +0 -1
- package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-C2DwA_Y1.js +0 -1
- package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-C2DwA_Y1.js +0 -1
- package/dist/worker/console/static/assets/index-DTZOKgAn.js +0 -404
- package/dist/worker/console/static/assets/index-Ya5FE7cD.css +0 -1
- package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-B8FB_cNk.js +0 -1
- package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-CrZYaWfx.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
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { redactSecrets, truncateUtf8Preview } from "../../shared/preview.js";
|
|
3
|
+
import { isSafeObservabilityIdentifier } from "../observability/event-store.js";
|
|
4
|
+
import { parseExecutionOutputKey, } from "./dag-node-execution-output.js";
|
|
5
|
+
import { resolveDagRunArtifact, resolveDagRunJson, } from "./dag-run-artifacts.js";
|
|
6
|
+
import { namedShellHandlers } from "./shell-handler-keys.js";
|
|
7
|
+
export const NODE_PROCESS_SCHEMA_VERSION = 1;
|
|
8
|
+
export const NODE_PROCESS_FIELD_MAX_BYTES = 16 * 1024;
|
|
9
|
+
function boundField(value) {
|
|
10
|
+
if (value == null || value === "")
|
|
11
|
+
return { text: null, truncated: false };
|
|
12
|
+
const redacted = redactSecrets(value);
|
|
13
|
+
const truncated = truncateUtf8Preview(redacted, NODE_PROCESS_FIELD_MAX_BYTES);
|
|
14
|
+
return {
|
|
15
|
+
text: truncated,
|
|
16
|
+
truncated: truncated !== redacted,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
function asRecord(value) {
|
|
20
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
21
|
+
return null;
|
|
22
|
+
return value;
|
|
23
|
+
}
|
|
24
|
+
function asString(value) {
|
|
25
|
+
return typeof value === "string" && value.trim() ? value : null;
|
|
26
|
+
}
|
|
27
|
+
function asNumber(value) {
|
|
28
|
+
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
29
|
+
}
|
|
30
|
+
function asBoolean(value) {
|
|
31
|
+
return value === true;
|
|
32
|
+
}
|
|
33
|
+
async function readJsonArtifact(repoRoot, dagRunId, segments) {
|
|
34
|
+
const resolved = resolveDagRunArtifact(repoRoot, dagRunId, segments);
|
|
35
|
+
if (!resolved.ok)
|
|
36
|
+
return null;
|
|
37
|
+
try {
|
|
38
|
+
const raw = await readFile(resolved.result.absolutePath, "utf8");
|
|
39
|
+
const parsed = JSON.parse(raw);
|
|
40
|
+
return asRecord(parsed);
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
async function readTextArtifact(repoRoot, dagRunId, segments) {
|
|
47
|
+
const resolved = resolveDagRunArtifact(repoRoot, dagRunId, segments);
|
|
48
|
+
if (!resolved.ok)
|
|
49
|
+
return { text: null, truncated: false };
|
|
50
|
+
try {
|
|
51
|
+
const raw = await readFile(resolved.result.absolutePath, "utf8");
|
|
52
|
+
return boundField(raw);
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
return { text: null, truncated: false };
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function emptyBody(dagRunId, nodeId, kind, emptyReason, extras = {}) {
|
|
59
|
+
return {
|
|
60
|
+
schemaVersion: NODE_PROCESS_SCHEMA_VERSION,
|
|
61
|
+
dagRunId,
|
|
62
|
+
nodeId,
|
|
63
|
+
kind,
|
|
64
|
+
executor: extras.executor ?? null,
|
|
65
|
+
handler: extras.handler ?? null,
|
|
66
|
+
emptyReason,
|
|
67
|
+
key: extras.key ?? null,
|
|
68
|
+
commands: extras.commands ?? [],
|
|
69
|
+
steps: extras.steps ?? [],
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
function classifyKind(task) {
|
|
73
|
+
const executor = asString(task.executor);
|
|
74
|
+
const shell = asRecord(task.shell);
|
|
75
|
+
const handlers = namedShellHandlers(shell);
|
|
76
|
+
const handler = handlers[0] ?? null;
|
|
77
|
+
const commands = shell?.commands;
|
|
78
|
+
const commandsDeclared = Array.isArray(commands) &&
|
|
79
|
+
commands.some((item) => typeof item === "string" && item.trim());
|
|
80
|
+
if (executor === "static" || task.static) {
|
|
81
|
+
return { kind: "static", executor: executor ?? "static", handler, commandsDeclared };
|
|
82
|
+
}
|
|
83
|
+
if (executor === "shell" || shell) {
|
|
84
|
+
if (commandsDeclared) {
|
|
85
|
+
return { kind: "shell-commands", executor: executor ?? "shell", handler, commandsDeclared };
|
|
86
|
+
}
|
|
87
|
+
if (handler) {
|
|
88
|
+
return { kind: "shell-preset", executor: executor ?? "shell", handler, commandsDeclared };
|
|
89
|
+
}
|
|
90
|
+
return { kind: "shell-commands", executor: executor ?? "shell", handler, commandsDeclared };
|
|
91
|
+
}
|
|
92
|
+
return {
|
|
93
|
+
kind: "pi-session",
|
|
94
|
+
executor: executor ?? "pi",
|
|
95
|
+
handler,
|
|
96
|
+
commandsDeclared,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
function receiptAttemptSegments(nodeId, parsed) {
|
|
100
|
+
if (parsed?.kind === "attempt") {
|
|
101
|
+
return [nodeId, `attempt-${parsed.index}`, "shell-command-receipt.json"];
|
|
102
|
+
}
|
|
103
|
+
return [nodeId, "shell-command-receipt.json"];
|
|
104
|
+
}
|
|
105
|
+
async function loadShellCommands(repoRoot, dagRunId, nodeId, parsed) {
|
|
106
|
+
const preferred = await readJsonArtifact(repoRoot, dagRunId, receiptAttemptSegments(nodeId, parsed));
|
|
107
|
+
const receipt = preferred ??
|
|
108
|
+
(parsed
|
|
109
|
+
? await readJsonArtifact(repoRoot, dagRunId, [
|
|
110
|
+
nodeId,
|
|
111
|
+
"shell-command-receipt.json",
|
|
112
|
+
])
|
|
113
|
+
: null);
|
|
114
|
+
if (!receipt)
|
|
115
|
+
return null;
|
|
116
|
+
const rawCommands = Array.isArray(receipt.commands) ? receipt.commands : [];
|
|
117
|
+
const commands = [];
|
|
118
|
+
for (let i = 0; i < rawCommands.length; i += 1) {
|
|
119
|
+
const entry = asRecord(rawCommands[i]) ?? {};
|
|
120
|
+
const stdout = await readTextArtifact(repoRoot, dagRunId, [
|
|
121
|
+
nodeId,
|
|
122
|
+
"commands",
|
|
123
|
+
`${i + 1}.stdout.txt`,
|
|
124
|
+
]);
|
|
125
|
+
const stderr = await readTextArtifact(repoRoot, dagRunId, [
|
|
126
|
+
nodeId,
|
|
127
|
+
"commands",
|
|
128
|
+
`${i + 1}.stderr.txt`,
|
|
129
|
+
]);
|
|
130
|
+
const commandBound = boundField(asString(entry.command) ?? "");
|
|
131
|
+
commands.push({
|
|
132
|
+
index: i + 1,
|
|
133
|
+
command: commandBound.text ?? "(command)",
|
|
134
|
+
ok: asBoolean(entry.ok),
|
|
135
|
+
exitCode: asNumber(entry.exitCode),
|
|
136
|
+
failureCategory: asString(entry.failureCategory),
|
|
137
|
+
startedAt: asString(entry.startedAt),
|
|
138
|
+
finishedAt: asString(entry.finishedAt),
|
|
139
|
+
durationMs: asNumber(entry.wallDurationMs) ??
|
|
140
|
+
asNumber(entry.executionDurationMs) ??
|
|
141
|
+
null,
|
|
142
|
+
reused: asBoolean(entry.reused),
|
|
143
|
+
stdout: stdout.text,
|
|
144
|
+
stderr: stderr.text,
|
|
145
|
+
truncated: commandBound.truncated || stdout.truncated || stderr.truncated,
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
return commands;
|
|
149
|
+
}
|
|
150
|
+
function handlerLabel(handler) {
|
|
151
|
+
if (handler === "frontendBrowserToolPreflight")
|
|
152
|
+
return "浏览器工具能力探测";
|
|
153
|
+
if (handler === "frontendTestStandardScenarios")
|
|
154
|
+
return "标准场景物化";
|
|
155
|
+
if (handler === "frontendTestEnvironmentProbe")
|
|
156
|
+
return "前端环境探测";
|
|
157
|
+
if (handler === "frontendTestCaseChecklist")
|
|
158
|
+
return "用例清单校验";
|
|
159
|
+
if (handler === "frontendTestCaseManifest")
|
|
160
|
+
return "用例清单物化";
|
|
161
|
+
if (handler === "frontendTestEvidenceValidation")
|
|
162
|
+
return "证据校验";
|
|
163
|
+
if (handler === "frontendTestResultFinalize")
|
|
164
|
+
return "结果定稿";
|
|
165
|
+
if (handler === "frontendTestReports" || handler === "frontendTestL5Report" || handler === "frontendTestHtmlReport") {
|
|
166
|
+
return "测试报告";
|
|
167
|
+
}
|
|
168
|
+
if (handler === "frontendPrewriteGate")
|
|
169
|
+
return "前端预写门禁";
|
|
170
|
+
if (handler === "finalWriteSetApprovalGate")
|
|
171
|
+
return "writeSet 终态批准";
|
|
172
|
+
return handler;
|
|
173
|
+
}
|
|
174
|
+
async function loadPresetSteps(repoRoot, dagRunId, nodeId, handler, parsed) {
|
|
175
|
+
const written = await readJsonArtifact(repoRoot, dagRunId, [
|
|
176
|
+
nodeId,
|
|
177
|
+
"process-receipt.json",
|
|
178
|
+
]);
|
|
179
|
+
if (written && Array.isArray(written.steps)) {
|
|
180
|
+
return written.steps.flatMap((item, index) => {
|
|
181
|
+
const step = asRecord(item);
|
|
182
|
+
if (!step)
|
|
183
|
+
return [];
|
|
184
|
+
const detail = boundField(asString(step.detail));
|
|
185
|
+
return [
|
|
186
|
+
{
|
|
187
|
+
id: asString(step.id) ?? `step-${index + 1}`,
|
|
188
|
+
label: asString(step.label) ?? handlerLabel(handler ?? "preset"),
|
|
189
|
+
ok: asBoolean(step.ok),
|
|
190
|
+
detail: detail.text,
|
|
191
|
+
durationMs: asNumber(step.durationMs),
|
|
192
|
+
truncated: detail.truncated,
|
|
193
|
+
},
|
|
194
|
+
];
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
const capability = await readJsonArtifact(repoRoot, dagRunId, [
|
|
198
|
+
nodeId,
|
|
199
|
+
"frontend-browser-capability.json",
|
|
200
|
+
]);
|
|
201
|
+
if (capability && handler === "frontendBrowserToolPreflight") {
|
|
202
|
+
const detail = boundField(JSON.stringify(capability, null, 2));
|
|
203
|
+
return [
|
|
204
|
+
{
|
|
205
|
+
id: "capability",
|
|
206
|
+
label: handlerLabel(handler),
|
|
207
|
+
ok: asString(capability.status) !== "failed",
|
|
208
|
+
detail: detail.text,
|
|
209
|
+
durationMs: null,
|
|
210
|
+
truncated: detail.truncated,
|
|
211
|
+
},
|
|
212
|
+
];
|
|
213
|
+
}
|
|
214
|
+
const attemptIndex = parsed?.kind === "attempt" ? parsed.index : 1;
|
|
215
|
+
const attempt = await readJsonArtifact(repoRoot, dagRunId, [
|
|
216
|
+
nodeId,
|
|
217
|
+
`attempt-${attemptIndex}.json`,
|
|
218
|
+
]);
|
|
219
|
+
if (attempt) {
|
|
220
|
+
const ok = asBoolean(attempt.ok);
|
|
221
|
+
const detail = boundField(ok
|
|
222
|
+
? (asString(attempt.stdout) ?? asString(attempt.assistantText))
|
|
223
|
+
: (asString(attempt.stderr) ?? asString(attempt.stdout)));
|
|
224
|
+
return [
|
|
225
|
+
{
|
|
226
|
+
id: "run",
|
|
227
|
+
label: handlerLabel(handler ?? "preset"),
|
|
228
|
+
ok,
|
|
229
|
+
detail: detail.text,
|
|
230
|
+
durationMs: asNumber(attempt.durationMs),
|
|
231
|
+
truncated: detail.truncated,
|
|
232
|
+
},
|
|
233
|
+
];
|
|
234
|
+
}
|
|
235
|
+
return [];
|
|
236
|
+
}
|
|
237
|
+
export async function loadDagNodeProcess(repoRoot, dagRunId, nodeId, rawKey) {
|
|
238
|
+
if (!isSafeObservabilityIdentifier(dagRunId) ||
|
|
239
|
+
!isSafeObservabilityIdentifier(nodeId)) {
|
|
240
|
+
return {
|
|
241
|
+
status: 400,
|
|
242
|
+
body: { error: "Invalid dag run or node identifier", reason: "invalid-id" },
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
let parsedKey = null;
|
|
246
|
+
if (rawKey != null && String(rawKey).trim() !== "") {
|
|
247
|
+
const parsed = parseExecutionOutputKey(rawKey);
|
|
248
|
+
if (!parsed.ok) {
|
|
249
|
+
return {
|
|
250
|
+
status: 400,
|
|
251
|
+
body: {
|
|
252
|
+
error: "Invalid execution key (expected attempt-N or pass-N)",
|
|
253
|
+
reason: "invalid-key",
|
|
254
|
+
},
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
parsedKey = parsed;
|
|
258
|
+
}
|
|
259
|
+
const runResolved = resolveDagRunJson(repoRoot, dagRunId);
|
|
260
|
+
if (!runResolved.ok) {
|
|
261
|
+
if (runResolved.reason === "invalid-id") {
|
|
262
|
+
return {
|
|
263
|
+
status: 400,
|
|
264
|
+
body: { error: "Invalid dag run or node identifier", reason: "invalid-id" },
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
if (runResolved.reason === "ambiguous") {
|
|
268
|
+
return {
|
|
269
|
+
status: 409,
|
|
270
|
+
body: { error: "Ambiguous dag run lifecycle", reason: "ambiguous" },
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
return {
|
|
274
|
+
status: 404,
|
|
275
|
+
body: { error: "DAG run not found", reason: "not-found" },
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
let spec = {};
|
|
279
|
+
try {
|
|
280
|
+
const raw = JSON.parse(await readFile(runResolved.result.absolutePath, "utf8"));
|
|
281
|
+
spec = asRecord(raw) ?? {};
|
|
282
|
+
}
|
|
283
|
+
catch {
|
|
284
|
+
return {
|
|
285
|
+
status: 404,
|
|
286
|
+
body: { error: "run.json is unreadable", reason: "not-found" },
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
const tasks = Array.isArray(spec.tasks) ? spec.tasks : [];
|
|
290
|
+
const task = tasks
|
|
291
|
+
.map((item) => asRecord(item))
|
|
292
|
+
.find((item) => item && asString(item.id) === nodeId);
|
|
293
|
+
if (!task) {
|
|
294
|
+
return {
|
|
295
|
+
status: 200,
|
|
296
|
+
body: emptyBody(dagRunId, nodeId, "none", "not-executed"),
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
const classified = classifyKind(task);
|
|
300
|
+
const key = parsedKey?.key ?? null;
|
|
301
|
+
if (classified.kind === "pi-session") {
|
|
302
|
+
return {
|
|
303
|
+
status: 200,
|
|
304
|
+
body: emptyBody(dagRunId, nodeId, "pi-session", "pi-session", {
|
|
305
|
+
executor: classified.executor,
|
|
306
|
+
key,
|
|
307
|
+
}),
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
if (classified.kind === "static") {
|
|
311
|
+
return {
|
|
312
|
+
status: 200,
|
|
313
|
+
body: emptyBody(dagRunId, nodeId, "static", "static-no-process", {
|
|
314
|
+
executor: classified.executor,
|
|
315
|
+
key,
|
|
316
|
+
}),
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
if (classified.kind === "shell-commands" || classified.kind === "shell-preset") {
|
|
320
|
+
const commands = await loadShellCommands(repoRoot, dagRunId, nodeId, parsedKey);
|
|
321
|
+
if (commands && commands.length > 0) {
|
|
322
|
+
return {
|
|
323
|
+
status: 200,
|
|
324
|
+
body: {
|
|
325
|
+
schemaVersion: NODE_PROCESS_SCHEMA_VERSION,
|
|
326
|
+
dagRunId,
|
|
327
|
+
nodeId,
|
|
328
|
+
kind: "shell-commands",
|
|
329
|
+
executor: classified.executor,
|
|
330
|
+
handler: classified.handler,
|
|
331
|
+
emptyReason: null,
|
|
332
|
+
key,
|
|
333
|
+
commands,
|
|
334
|
+
steps: [],
|
|
335
|
+
},
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
if (classified.handler || classified.kind === "shell-preset") {
|
|
339
|
+
const steps = await loadPresetSteps(repoRoot, dagRunId, nodeId, classified.handler, parsedKey);
|
|
340
|
+
if (steps.length > 0) {
|
|
341
|
+
return {
|
|
342
|
+
status: 200,
|
|
343
|
+
body: {
|
|
344
|
+
schemaVersion: NODE_PROCESS_SCHEMA_VERSION,
|
|
345
|
+
dagRunId,
|
|
346
|
+
nodeId,
|
|
347
|
+
kind: "shell-preset",
|
|
348
|
+
executor: classified.executor,
|
|
349
|
+
handler: classified.handler,
|
|
350
|
+
emptyReason: null,
|
|
351
|
+
key,
|
|
352
|
+
commands: [],
|
|
353
|
+
steps,
|
|
354
|
+
},
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
return {
|
|
359
|
+
status: 200,
|
|
360
|
+
body: emptyBody(dagRunId, nodeId, classified.kind, classified.kind === "shell-preset"
|
|
361
|
+
? "shell-preset-pending"
|
|
362
|
+
: "shell-receipt-missing", {
|
|
363
|
+
executor: classified.executor,
|
|
364
|
+
handler: classified.handler,
|
|
365
|
+
key,
|
|
366
|
+
}),
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
return {
|
|
370
|
+
status: 200,
|
|
371
|
+
body: emptyBody(dagRunId, nodeId, "none", "not-executed", {
|
|
372
|
+
executor: classified.executor,
|
|
373
|
+
handler: classified.handler,
|
|
374
|
+
key,
|
|
375
|
+
}),
|
|
376
|
+
};
|
|
377
|
+
}
|
|
@@ -11,11 +11,16 @@ import { buildGlobalSnapshot, clampDagRunHistoryPageSize, clampTaskRunHistoryLim
|
|
|
11
11
|
import { loadDagRunExecutionTrajectory } from "../observability/dag-execution-trajectory.js";
|
|
12
12
|
import { resolveDagTaskSourcePath } from "../../task/dag-source-paths.js";
|
|
13
13
|
import { dagSourceBindingSchema } from "../../workflows/dag/types.js";
|
|
14
|
+
import { getTaskPaths } from "../../task/runtime.js";
|
|
15
|
+
import { classifyLedgerGate, computeLedgerInputDigest, LedgerParseError, parseLedgerJson, recoverLedgerInputContract, summarizeLedger, } from "../../task/source-prepare/ledger.js";
|
|
14
16
|
import { getTaskPoolRoot } from "../pool/run-store.js";
|
|
17
|
+
import { resolveDagRunArtifact, } from "./dag-run-artifacts.js";
|
|
18
|
+
import { frontendPrewriteResultV1Schema } from "../../workflows/dag/frontend-prewrite-gate.js";
|
|
15
19
|
import { isAllowedArtifactTextPath, resolveArtifactPath, resolveRepoFilePreview, toRepoRelativeArtifactPath, } from "./paths.js";
|
|
16
20
|
import { extractSpecEvidence, extractSpecReadContent, } from "./spec-evidence.js";
|
|
17
21
|
import { buildDagNodeInput } from "./node-input.js";
|
|
18
22
|
import { loadDagNodeExecutionOutput } from "./dag-node-execution-output.js";
|
|
23
|
+
import { loadDagNodeProcess } from "./node-process.js";
|
|
19
24
|
import { buildObserveHealthV1 } from "./health.js";
|
|
20
25
|
import { buildNightJobDetail, buildNightJobsDoctor, buildNightJobsList, buildNightJobsMorning, } from "./night-jobs.js";
|
|
21
26
|
const ARTIFACT_PREVIEW_MAX_BYTES = 64 * 1024;
|
|
@@ -69,6 +74,15 @@ export const ROUTES = [
|
|
|
69
74
|
pattern: /^\/api\/tasks\/([^/]+)\/runs$/,
|
|
70
75
|
handler: handleTaskRuns,
|
|
71
76
|
},
|
|
77
|
+
/**
|
|
78
|
+
* Read-only source fidelity ledger safe summary (AC-009 / AC-FIDELITY-009):
|
|
79
|
+
* 只返回计数/状态/failure code,不泄漏敏感原文。
|
|
80
|
+
*/
|
|
81
|
+
{
|
|
82
|
+
method: "GET",
|
|
83
|
+
pattern: /^\/api\/tasks\/([^/]+)\/ledger$/,
|
|
84
|
+
handler: handleTaskLedger,
|
|
85
|
+
},
|
|
72
86
|
{
|
|
73
87
|
method: "GET",
|
|
74
88
|
pattern: /^\/api\/tasks\/([^/]+)$/,
|
|
@@ -100,6 +114,11 @@ export const ROUTES = [
|
|
|
100
114
|
pattern: /^\/api\/dag-runs\/([^/]+)\/nodes\/([^/]+)\/execution-output$/,
|
|
101
115
|
handler: handleDagNodeExecutionOutput,
|
|
102
116
|
},
|
|
117
|
+
{
|
|
118
|
+
method: "GET",
|
|
119
|
+
pattern: /^\/api\/dag-runs\/([^/]+)\/nodes\/([^/]+)\/process$/,
|
|
120
|
+
handler: handleDagNodeProcess,
|
|
121
|
+
},
|
|
103
122
|
{
|
|
104
123
|
method: "GET",
|
|
105
124
|
pattern: /^\/api\/dag-runs\/([^/]+)\/nodes\/([^/]+)\/spec-evidence$/,
|
|
@@ -110,6 +129,16 @@ export const ROUTES = [
|
|
|
110
129
|
pattern: /^\/api\/dag-runs\/([^/]+)\/nodes\/([^/]+)\/spec-evidence\/file$/,
|
|
111
130
|
handler: handleDagNodeSpecEvidenceFile,
|
|
112
131
|
},
|
|
132
|
+
// DAG run 专属只读 prewrite 结果(AC-006 / AC-BLOCK-006):唯一读路径为
|
|
133
|
+
// run-owned contracts/frontend-prewrite-result.json(resolveDagRunArtifact 四类
|
|
134
|
+
// fail-closed),不扩大 isAllowedArtifactTextPath 通用 allowlist;响应以
|
|
135
|
+
// frontendPrewriteResultV1Schema(.strict())解析,Inspector 不再做
|
|
136
|
+
// /api/artifacts 预览 → JSON.stringify → JSON.parse 双编码。
|
|
137
|
+
{
|
|
138
|
+
method: "GET",
|
|
139
|
+
pattern: /^\/api\/dag-runs\/([^/]+)\/prewrite-result$/,
|
|
140
|
+
handler: handleDagRunPrewriteResult,
|
|
141
|
+
},
|
|
113
142
|
{
|
|
114
143
|
method: "GET",
|
|
115
144
|
pattern: /^\/api\/dag-runs\/([^/]+)$/,
|
|
@@ -221,14 +250,23 @@ export async function serveObserveStatic(req, res, staticDir, options = {}) {
|
|
|
221
250
|
sendJson(res, 404, { error: "Not found" });
|
|
222
251
|
return;
|
|
223
252
|
}
|
|
224
|
-
|
|
253
|
+
let content = await readFile(resolvedFile);
|
|
225
254
|
const contentType = contentTypeFor(pathname);
|
|
226
|
-
|
|
255
|
+
const headers = {
|
|
227
256
|
"Content-Type": contentType,
|
|
228
257
|
"Content-Length": content.byteLength,
|
|
229
258
|
"X-Content-Type-Options": "nosniff",
|
|
230
259
|
"X-Frame-Options": "SAMEORIGIN",
|
|
231
|
-
}
|
|
260
|
+
};
|
|
261
|
+
if (contentType.startsWith("text/html") && options.htmlEnhancer) {
|
|
262
|
+
const enhanced = options.htmlEnhancer(Buffer.from(content));
|
|
263
|
+
content = enhanced.content;
|
|
264
|
+
headers["Content-Length"] = content.byteLength;
|
|
265
|
+
if (enhanced.setCookie) {
|
|
266
|
+
headers["Set-Cookie"] = enhanced.setCookie;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
res.writeHead(200, headers);
|
|
232
270
|
res.end(content);
|
|
233
271
|
}
|
|
234
272
|
async function handleHealth(_req, res, _match, ctx) {
|
|
@@ -433,6 +471,117 @@ async function handleTaskRuns(_req, res, match, ctx) {
|
|
|
433
471
|
});
|
|
434
472
|
sendJson(res, 200, page);
|
|
435
473
|
}
|
|
474
|
+
/**
|
|
475
|
+
* GET /api/tasks/:id/ledger — 只读 ledger 安全摘要。任务存在但无 ledger 时返回
|
|
476
|
+
* `{ present: false }`(空态,不伪造计数);任务不存在返回 404;ledger 解析失败
|
|
477
|
+
* 返回带稳定 SOURCE_FIDELITY_* 错误码的 `{ present: false }`(AC-HARD-003:与
|
|
478
|
+
* parseLedgerJson 同一稳定码,不泄漏原文)。binding v2 标记 + ledgerSha256 +
|
|
479
|
+
* inputDigest 仅在真实 v2 绑定(非空 canonical requirement 集)时展示(AC-HARD-004:
|
|
480
|
+
* v1+optional 冒充 v2 不标记);inputDigest 与当前权威源输入不一致时置 stale。
|
|
481
|
+
*/
|
|
482
|
+
async function handleTaskLedger(_req, res, match, ctx) {
|
|
483
|
+
const taskId = match.params.id;
|
|
484
|
+
if (!isSafeObservabilityIdentifier(taskId)) {
|
|
485
|
+
sendJson(res, 400, { error: "Invalid task identifier" });
|
|
486
|
+
return;
|
|
487
|
+
}
|
|
488
|
+
const taskPaths = getTaskPaths(ctx.repoRoot, taskId);
|
|
489
|
+
try {
|
|
490
|
+
await stat(taskPaths.taskDir);
|
|
491
|
+
}
|
|
492
|
+
catch {
|
|
493
|
+
sendJson(res, 404, { error: "Task not found" });
|
|
494
|
+
return;
|
|
495
|
+
}
|
|
496
|
+
const ledgerPath = path.join(taskPaths.sourceDir, "requirement-ledger.json");
|
|
497
|
+
let raw;
|
|
498
|
+
try {
|
|
499
|
+
raw = await readFile(ledgerPath, "utf8");
|
|
500
|
+
}
|
|
501
|
+
catch (error) {
|
|
502
|
+
if (error.code === "ENOENT") {
|
|
503
|
+
sendJson(res, 200, { present: false, taskId });
|
|
504
|
+
return;
|
|
505
|
+
}
|
|
506
|
+
sendJson(res, 200, {
|
|
507
|
+
present: false,
|
|
508
|
+
taskId,
|
|
509
|
+
error: "ledger-unreadable",
|
|
510
|
+
});
|
|
511
|
+
return;
|
|
512
|
+
}
|
|
513
|
+
let ledger;
|
|
514
|
+
try {
|
|
515
|
+
ledger = parseLedgerJson(raw);
|
|
516
|
+
}
|
|
517
|
+
catch (error) {
|
|
518
|
+
// AC-HARD-003:解析失败分支使用与 parseLedgerJson 相同的稳定 SOURCE_FIDELITY_*
|
|
519
|
+
// 错误码(结构化可消费),而非裸字符串/裸 Error。
|
|
520
|
+
const code = error instanceof LedgerParseError
|
|
521
|
+
? error.code
|
|
522
|
+
: "SOURCE_FIDELITY_LEDGER_STALE";
|
|
523
|
+
sendJson(res, 200, {
|
|
524
|
+
present: false,
|
|
525
|
+
taskId,
|
|
526
|
+
error: code,
|
|
527
|
+
});
|
|
528
|
+
return;
|
|
529
|
+
}
|
|
530
|
+
const classification = classifyLedgerGate(ledger);
|
|
531
|
+
const summary = summarizeLedger(ledger, {
|
|
532
|
+
gateStatus: classification.ok ? "pass" : "fail",
|
|
533
|
+
failureCode: classification.ok ? null : classification.code,
|
|
534
|
+
});
|
|
535
|
+
// v2 binding 语义(AC-HARD-004):仅在真实 v2 绑定(canonical requirement 非空,
|
|
536
|
+
// 具备 requirement→fragment 映射证据)时标记 bindingSchemaVersion=2 并透传
|
|
537
|
+
// ledgerSha256/inputDigest;空 canonical 的 ledger 是退化/伪造 v2,不标记。
|
|
538
|
+
const contract = recoverLedgerInputContract(ledger);
|
|
539
|
+
const realV2Binding = contract.canonicalRequirements.length > 0;
|
|
540
|
+
let stale = false;
|
|
541
|
+
if (realV2Binding) {
|
|
542
|
+
// 当前权威源输入:ledger.sourcePaths(repo-root relative POSIX)→ 当前字节;
|
|
543
|
+
// 缺失/清空的权威源视为 stale(fail-closed,与 init-hybrid 语义一致)。
|
|
544
|
+
const currentByPath = new Map();
|
|
545
|
+
for (const sourcePath of contract.sourcePaths) {
|
|
546
|
+
try {
|
|
547
|
+
currentByPath.set(sourcePath, await readFile(path.resolve(ctx.repoRoot, sourcePath), "utf8"));
|
|
548
|
+
}
|
|
549
|
+
catch {
|
|
550
|
+
// 权威源缺失:保持缺失,expectedInputDigest 不一致 → stale。
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
const expectedDigest = computeLedgerInputDigest({
|
|
554
|
+
sourceDocuments: contract.sourcePaths.map((sourcePath) => ({
|
|
555
|
+
path: sourcePath,
|
|
556
|
+
content: currentByPath.get(sourcePath) ?? "",
|
|
557
|
+
})),
|
|
558
|
+
canonicalRequirements: contract.canonicalRequirements,
|
|
559
|
+
});
|
|
560
|
+
stale = ledger.inputDigest !== expectedDigest;
|
|
561
|
+
}
|
|
562
|
+
const ledgerSha256 = createHash("sha256").update(raw).digest("hex");
|
|
563
|
+
sendJson(res, 200, {
|
|
564
|
+
present: true,
|
|
565
|
+
taskId,
|
|
566
|
+
...(realV2Binding
|
|
567
|
+
? {
|
|
568
|
+
bindingSchemaVersion: 2,
|
|
569
|
+
ledgerSha256,
|
|
570
|
+
inputDigest: ledger.inputDigest,
|
|
571
|
+
stale,
|
|
572
|
+
}
|
|
573
|
+
: {}),
|
|
574
|
+
fragmentCount: summary.fragmentCount,
|
|
575
|
+
canonicalRequirementCount: summary.canonicalRequirementCount,
|
|
576
|
+
contextOnlyCount: summary.contextOnlyCount,
|
|
577
|
+
duplicateCount: summary.duplicateCount,
|
|
578
|
+
unresolvedCount: summary.unresolvedCount,
|
|
579
|
+
conflictCount: summary.conflictCount,
|
|
580
|
+
gateStatus: summary.gateStatus,
|
|
581
|
+
failureCode: summary.failureCode,
|
|
582
|
+
exclusions: summary.exclusions,
|
|
583
|
+
});
|
|
584
|
+
}
|
|
436
585
|
function ambiguousTaskBody(taskId, candidates) {
|
|
437
586
|
return {
|
|
438
587
|
error: "Task identity ambiguous",
|
|
@@ -520,6 +669,60 @@ async function handleDagRuns(_req, res, match, ctx) {
|
|
|
520
669
|
const body = listDagRunHistoryFromSnapshot(snapshot, { page, pageSize });
|
|
521
670
|
sendJson(res, 200, body);
|
|
522
671
|
}
|
|
672
|
+
/**
|
|
673
|
+
* GET /api/dag-runs/:dagRunId/prewrite-result(AC-006 / AC-BLOCK-006)
|
|
674
|
+
* 只读 run-owned contracts/frontend-prewrite-result.json:resolveDagRunArtifact 是
|
|
675
|
+
* 唯一读路径(active/paused/completed 生命周期;invalid-id / unsafe-path /
|
|
676
|
+
* not-found / ambiguous 四类 fail-closed)。响应以 frontendPrewriteResultV1Schema
|
|
677
|
+
* (.strict())解析,拒绝 envelope 之外的字段;不扩大通用 artifact allowlist。
|
|
678
|
+
*/
|
|
679
|
+
async function handleDagRunPrewriteResult(_req, res, match, ctx) {
|
|
680
|
+
const dagRunId = match.params.id;
|
|
681
|
+
const resolved = resolveDagRunArtifact(ctx.repoRoot, dagRunId, [
|
|
682
|
+
"contracts",
|
|
683
|
+
"frontend-prewrite-result.json",
|
|
684
|
+
]);
|
|
685
|
+
if (!resolved.ok) {
|
|
686
|
+
if (resolved.reason === "invalid-id") {
|
|
687
|
+
sendJson(res, 400, { error: "Invalid dag run identifier" });
|
|
688
|
+
return;
|
|
689
|
+
}
|
|
690
|
+
if (resolved.reason === "ambiguous") {
|
|
691
|
+
sendJson(res, 409, { error: "DAG run identity ambiguous" });
|
|
692
|
+
return;
|
|
693
|
+
}
|
|
694
|
+
sendJson(res, 404, { error: "Prewrite result not found" });
|
|
695
|
+
return;
|
|
696
|
+
}
|
|
697
|
+
let raw;
|
|
698
|
+
try {
|
|
699
|
+
raw = await readFile(resolved.result.absolutePath, "utf8");
|
|
700
|
+
}
|
|
701
|
+
catch {
|
|
702
|
+
sendJson(res, 404, { error: "Prewrite result not found" });
|
|
703
|
+
return;
|
|
704
|
+
}
|
|
705
|
+
let parsed;
|
|
706
|
+
try {
|
|
707
|
+
parsed = JSON.parse(raw);
|
|
708
|
+
}
|
|
709
|
+
catch {
|
|
710
|
+
sendJson(res, 500, {
|
|
711
|
+
error: "Prewrite result is not valid JSON",
|
|
712
|
+
reason: "prewrite-result-unparseable",
|
|
713
|
+
});
|
|
714
|
+
return;
|
|
715
|
+
}
|
|
716
|
+
const envelope = frontendPrewriteResultV1Schema.safeParse(parsed);
|
|
717
|
+
if (!envelope.success) {
|
|
718
|
+
sendJson(res, 500, {
|
|
719
|
+
error: "Prewrite result is not a valid frontend-prewrite-result-v1 envelope",
|
|
720
|
+
reason: "prewrite-result-schema-invalid",
|
|
721
|
+
});
|
|
722
|
+
return;
|
|
723
|
+
}
|
|
724
|
+
sendJson(res, 200, envelope.data);
|
|
725
|
+
}
|
|
523
726
|
export async function handleDagRunById(_req, res, match, ctx) {
|
|
524
727
|
const snapshot = await getSnapshot(ctx);
|
|
525
728
|
const dagRun = snapshot.dagRuns.find((d) => d.dagRunId === match.params.id);
|
|
@@ -570,6 +773,24 @@ async function handleDagNodeExecutionOutput(_req, res, match, ctx) {
|
|
|
570
773
|
const result = await loadDagNodeExecutionOutput(ctx.repoRoot, dagRunId, nodeId, key);
|
|
571
774
|
sendJson(res, result.status, result.body);
|
|
572
775
|
}
|
|
776
|
+
async function handleDagNodeProcess(_req, res, match, ctx) {
|
|
777
|
+
const dagRunId = match.params.id;
|
|
778
|
+
const nodeId = match.params.sub;
|
|
779
|
+
if (!isSafeObservabilityIdentifier(dagRunId) ||
|
|
780
|
+
!isSafeObservabilityIdentifier(nodeId)) {
|
|
781
|
+
sendJson(res, 400, { error: "Invalid dag run or node identifier" });
|
|
782
|
+
return;
|
|
783
|
+
}
|
|
784
|
+
if (match.query.has("path") || match.query.has("artifactPath")) {
|
|
785
|
+
sendJson(res, 400, {
|
|
786
|
+
error: "Artifact path is not accepted; use optional key=attempt-N|pass-N",
|
|
787
|
+
reason: "path-not-allowed",
|
|
788
|
+
});
|
|
789
|
+
return;
|
|
790
|
+
}
|
|
791
|
+
const result = await loadDagNodeProcess(ctx.repoRoot, dagRunId, nodeId, match.query.get("key"));
|
|
792
|
+
sendJson(res, result.status, result.body);
|
|
793
|
+
}
|
|
573
794
|
async function handleDagNodeSessionEvents(_req, res, match, ctx) {
|
|
574
795
|
const dagRunId = match.params.id;
|
|
575
796
|
const nodeId = match.params.sub;
|
|
@@ -83,6 +83,10 @@ export function createObserveServer(options) {
|
|
|
83
83
|
url: `http://${host}:${addr.port}`,
|
|
84
84
|
close: () => new Promise((closeResolve, closeReject) => {
|
|
85
85
|
server.close((err) => (err ? closeReject(err) : closeResolve()));
|
|
86
|
+
// Explicit shutdown must not wait for the 65s keep-alive window.
|
|
87
|
+
// This also closes active SSE clients so process/test teardown is
|
|
88
|
+
// deterministic instead of timing out behind pooled connections.
|
|
89
|
+
server.closeAllConnections();
|
|
86
90
|
}),
|
|
87
91
|
});
|
|
88
92
|
});
|