@tea-agent/loop-agent 0.1.0-fe-test.0
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 +114 -0
- package/CHANGELOG.md +2283 -0
- package/README.md +177 -0
- package/bin/agent-worker.js +22 -0
- package/bin/loop-agent.js +57 -0
- package/dist/adapters/aimax.js +91 -0
- package/dist/adapters/context.js +32 -0
- package/dist/adapters/index.js +29 -0
- package/dist/adapters/loop-agent.js +192 -0
- package/dist/adapters/types.js +1 -0
- package/dist/application/context-usage/skill-resolution-stats.js +263 -0
- package/dist/application/dag/args.js +486 -0
- package/dist/application/dag/generate-task-dag.js +408 -0
- package/dist/application/dag/report-dag.js +14 -0
- package/dist/application/dag/run-dag.js +109 -0
- package/dist/application/dag/validate-dag.js +166 -0
- package/dist/application/evaluation/alias.js +184 -0
- package/dist/application/evaluation/budget.js +192 -0
- package/dist/application/evaluation/campaign-hash.js +47 -0
- package/dist/application/evaluation/campaign-matrix.js +372 -0
- package/dist/application/evaluation/campaign-scorecard.js +135 -0
- package/dist/application/evaluation/campaign.js +370 -0
- package/dist/application/evaluation/candidate-hash.js +75 -0
- package/dist/application/evaluation/candidate.js +69 -0
- package/dist/application/evaluation/corpus-hash.js +38 -0
- package/dist/application/evaluation/corpus.js +56 -0
- package/dist/application/evaluation/experiment.js +294 -0
- package/dist/application/evaluation/ignition.js +198 -0
- package/dist/application/evaluation/integrity-audit.js +162 -0
- package/dist/application/evaluation/outer-loop.js +132 -0
- package/dist/application/evaluation/pi-cell-executor.js +39 -0
- package/dist/application/evaluation/private-verifier.js +46 -0
- package/dist/application/evaluation/promotion-policy.js +151 -0
- package/dist/application/evaluation/proposer.js +98 -0
- package/dist/application/evaluation/replay.js +289 -0
- package/dist/application/evaluation/types.js +652 -0
- package/dist/application/loop/run-action.js +19 -0
- package/dist/application/task-lifecycle/advance.js +1204 -0
- package/dist/application/task-lifecycle/gates.js +130 -0
- package/dist/application/task-lifecycle/index.js +7 -0
- package/dist/application/task-lifecycle/observe.js +424 -0
- package/dist/application/task-lifecycle/plan-transitions.js +251 -0
- package/dist/application/task-lifecycle/recommendations.js +180 -0
- package/dist/application/task-lifecycle/record.js +73 -0
- package/dist/application/task-lifecycle/types.js +1 -0
- package/dist/build-stamp.json +6 -0
- package/dist/cli/catalog.js +24 -0
- package/dist/cli/command-definitions.js +659 -0
- package/dist/cli/help.js +56 -0
- package/dist/cli/index.js +5 -0
- package/dist/cli/program.js +647 -0
- package/dist/cli/router.js +13 -0
- package/dist/cli/update/init-surface-notifier.js +167 -0
- package/dist/cli/update/notifier.js +117 -0
- package/dist/cli/update/npm-client.js +151 -0
- package/dist/cli/update/policy.js +92 -0
- package/dist/cli/update/runtime-activity.js +29 -0
- package/dist/cli/update/state.js +68 -0
- package/dist/cli-governance/active-residue-check.js +38 -0
- package/dist/cli.js +57 -0
- package/dist/commands/client-recovery.js +1373 -0
- package/dist/commands/closeout.js +13 -0
- package/dist/commands/coverage-audit.js +14 -0
- package/dist/commands/coverage-report.js +50 -0
- package/dist/commands/cursor-prompt.js +182 -0
- package/dist/commands/dag-approve.js +142 -0
- package/dist/commands/dag-final-verification.js +76 -0
- package/dist/commands/dag-init-hybrid.js +57 -0
- package/dist/commands/dag-reconcile-run.js +5 -0
- package/dist/commands/dag-reconcile-tasks.js +51 -0
- package/dist/commands/dag-reject.js +91 -0
- package/dist/commands/dag-report.js +76 -0
- package/dist/commands/dag-request-interrupt.js +20 -0
- package/dist/commands/dag-rerun-task.js +19 -0
- package/dist/commands/dag-rerun.js +111 -0
- package/dist/commands/dag-resume.js +35 -0
- package/dist/commands/dag-run-task.js +12 -0
- package/dist/commands/dag-validate.js +20 -0
- package/dist/commands/dag-workflow-compile.js +91 -0
- package/dist/commands/dag-workflow-plan.js +130 -0
- package/dist/commands/dag-workflow-validate.js +66 -0
- package/dist/commands/delegate.js +130 -0
- package/dist/commands/docs-archive.js +5 -0
- package/dist/commands/docs-audit.js +6 -0
- package/dist/commands/doctor.js +283 -0
- package/dist/commands/eval.js +1398 -0
- package/dist/commands/examples.js +90 -0
- package/dist/commands/goal.js +92 -0
- package/dist/commands/handoff-check.js +5 -0
- package/dist/commands/harvest.js +44 -0
- package/dist/commands/import-prd.js +81 -0
- package/dist/commands/init-upgrade.js +3085 -0
- package/dist/commands/init.js +3630 -0
- package/dist/commands/inspect.js +11 -0
- package/dist/commands/instructions.js +223 -0
- package/dist/commands/knowledge.js +162 -0
- package/dist/commands/loop-benchmark.js +72 -0
- package/dist/commands/loop.js +251 -0
- package/dist/commands/new-task.js +5 -0
- package/dist/commands/operator.js +44 -0
- package/dist/commands/pi-prompt.js +174 -0
- package/dist/commands/pi-reuse-benchmark.js +153 -0
- package/dist/commands/plan-list.js +5 -0
- package/dist/commands/plan.js +50 -0
- package/dist/commands/promote-run.js +29 -0
- package/dist/commands/reference-index.js +16 -0
- package/dist/commands/run-dag-progress.js +123 -0
- package/dist/commands/run-dag.js +22 -0
- package/dist/commands/spine.js +38 -0
- package/dist/commands/stats.js +113 -0
- package/dist/commands/status.js +57 -0
- package/dist/commands/study-init.js +192 -0
- package/dist/commands/task-advance.js +366 -0
- package/dist/commands/task-contract.js +269 -0
- package/dist/commands/task-source-prepare.js +479 -0
- package/dist/commands/task-status.js +133 -0
- package/dist/commands/workflow.js +259 -0
- package/dist/commands/worktree-create.js +31 -0
- package/dist/commands/worktree-list.js +5 -0
- package/dist/commands/worktree-remove.js +26 -0
- package/dist/executors/config-core.js +5 -0
- package/dist/executors/config.js +2 -0
- package/dist/executors/dag-pi-executor.js +1277 -0
- package/dist/executors/dag-static-executor.js +42 -0
- package/dist/executors/dag.js +3 -0
- package/dist/executors/index.js +6 -0
- package/dist/executors/model-routing.js +71 -0
- package/dist/executors/pi-defaults.js +9 -0
- package/dist/executors/pi-event-serializer.js +65 -0
- package/dist/executors/pi-executor.js +981 -0
- package/dist/executors/pi-playwright-cli-tool.js +1006 -0
- package/dist/executors/pi-prompt-transport.js +198 -0
- package/dist/executors/pi-reuse-benchmark.js +316 -0
- package/dist/executors/pi-runtime-reuse.js +29 -0
- package/dist/executors/pi-sdk-executor.js +722 -0
- package/dist/executors/pi-sdk.js +1 -0
- package/dist/executors/pi-writer-tool-policy.js +266 -0
- package/dist/executors/pi.js +3 -0
- package/dist/executors/playwright-cli-launcher.js +63 -0
- package/dist/executors/process-tree.js +33 -0
- package/dist/executors/shell-executor.js +3055 -0
- package/dist/executors/shell-presets.js +99 -0
- package/dist/executors/shell-verification.js +262 -0
- package/dist/executors/shell-write-guard.js +543 -0
- package/dist/executors/shell.js +3 -0
- package/dist/executors/static.js +1 -0
- package/dist/governance/checks.js +437 -0
- package/dist/governance/document-index-closure.js +164 -0
- package/dist/governance/exec-plans.js +549 -0
- package/dist/governance/harness.js +9 -0
- package/dist/governance/index.js +3 -0
- package/dist/governance/manifest-types.js +254 -0
- package/dist/governance/manifest.js +2 -0
- package/dist/governance/path-guard.js +69 -0
- package/dist/governance/path-guards.js +2 -0
- package/dist/governance/profiles.js +3 -0
- package/dist/governance/requirement-coverage.js +425 -0
- package/dist/governance/skill-safety.js +135 -0
- package/dist/governance/spine-audit.js +155 -0
- package/dist/infrastructure/evaluation/alias-store.js +199 -0
- package/dist/infrastructure/evaluation/campaign-store.js +154 -0
- package/dist/infrastructure/evaluation/candidate-store.js +439 -0
- package/dist/infrastructure/evaluation/corpus-store.js +181 -0
- package/dist/infrastructure/evaluation/experiment-store.js +124 -0
- package/dist/infrastructure/evaluation/ignition-store.js +82 -0
- package/dist/infrastructure/evaluation/private-verifier-store.js +145 -0
- package/dist/infrastructure/evaluation/proposer-store.js +78 -0
- package/dist/infrastructure/evaluation/store.js +40 -0
- package/dist/infrastructure/harness/active-residue-policy.js +73 -0
- package/dist/infrastructure/harness/artifact-store.js +72 -0
- package/dist/infrastructure/harness/atomic-write.js +50 -0
- package/dist/infrastructure/harness/completed-facts-guard.js +40 -0
- package/dist/infrastructure/harness/loop-action-store.js +20 -0
- package/dist/infrastructure/harness/loop-store.js +41 -0
- package/dist/infrastructure/harness/one-shot-run-store.js +94 -0
- package/dist/infrastructure/harness/task-store.js +108 -0
- package/dist/records/closeout.js +2 -0
- package/dist/records/harvest.js +215 -0
- package/dist/records/index.js +3 -0
- package/dist/records/one-shot-runs.js +386 -0
- package/dist/records/promotion.js +200 -0
- package/dist/shared/artifacts-core.js +107 -0
- package/dist/shared/artifacts.js +2 -0
- package/dist/shared/context-files.js +32 -0
- package/dist/shared/context.js +2 -0
- package/dist/shared/copy-dir.js +17 -0
- package/dist/shared/git-progress.js +172 -0
- package/dist/shared/index.js +5 -0
- package/dist/shared/logger.js +17 -0
- package/dist/shared/one-shot-prompt-args.js +98 -0
- package/dist/shared/openspec-spec.js +125 -0
- package/dist/shared/operator/capabilities.js +2659 -0
- package/dist/shared/operator/command-lifecycle.js +94 -0
- package/dist/shared/operator/envelope.js +59 -0
- package/dist/shared/operator/index.js +5 -0
- package/dist/shared/operator/registry.js +38 -0
- package/dist/shared/operator/types.js +5 -0
- package/dist/shared/output-truncation.js +37 -0
- package/dist/shared/package-metadata.js +530 -0
- package/dist/shared/path-refs.js +31 -0
- package/dist/shared/pi-retry-settings.js +23 -0
- package/dist/shared/playwright-cli-command-policy.js +41 -0
- package/dist/shared/preview.js +39 -0
- package/dist/shared/prompts.js +26 -0
- package/dist/shared/reference-context.js +264 -0
- package/dist/shared/resilient-git.js +133 -0
- package/dist/shared/runtime-activity.js +6 -0
- package/dist/shared/timeout-policy.js +24 -0
- package/dist/shared/timeout.js +1 -0
- package/dist/shared/types.js +5 -0
- package/dist/sidecars/cursor-prompt/executor.js +428 -0
- package/dist/sidecars/cursor-prompt/index.js +3 -0
- package/dist/sidecars/cursor-prompt/stream.js +121 -0
- package/dist/task/config-types.js +235 -0
- package/dist/task/config.js +2 -0
- package/dist/task/contract/adopt.js +166 -0
- package/dist/task/contract/apply.js +326 -0
- package/dist/task/contract/canonicalize.js +60 -0
- package/dist/task/contract/constants.js +30 -0
- package/dist/task/contract/diff.js +177 -0
- package/dist/task/contract/hash.js +42 -0
- package/dist/task/contract/import-revision.js +96 -0
- package/dist/task/contract/index.js +17 -0
- package/dist/task/contract/journal.js +155 -0
- package/dist/task/contract/lock.js +153 -0
- package/dist/task/contract/observe.js +296 -0
- package/dist/task/contract/paths.js +19 -0
- package/dist/task/contract/project.js +185 -0
- package/dist/task/contract/recover.js +312 -0
- package/dist/task/contract/request-ledger.js +37 -0
- package/dist/task/contract/schema.js +153 -0
- package/dist/task/contract/transaction.js +160 -0
- package/dist/task/contract/types.js +1 -0
- package/dist/task/contract/validate-draft.js +106 -0
- package/dist/task/dag-source-paths.js +50 -0
- package/dist/task/delegate.js +208 -0
- package/dist/task/frontend-preflight.js +131 -0
- package/dist/task/frontend-project-capability.js +570 -0
- package/dist/task/goal-audit.js +51 -0
- package/dist/task/goal-policy.js +8 -0
- package/dist/task/goal.js +3 -0
- package/dist/task/ids.js +1 -0
- package/dist/task/index.js +12 -0
- package/dist/task/lifecycle.js +1 -0
- package/dist/task/operator/capabilities.js +6 -0
- package/dist/task/operator/envelope.js +2 -0
- package/dist/task/operator/index.js +5 -0
- package/dist/task/operator/registry.js +2 -0
- package/dist/task/operator/types.js +1 -0
- package/dist/task/paths.js +1 -0
- package/dist/task/read-model.js +140 -0
- package/dist/task/runtime.js +708 -0
- package/dist/task/source-prepare/artifact-meta.js +137 -0
- package/dist/task/source-prepare/build-draft.js +232 -0
- package/dist/task/source-prepare/completeness.js +248 -0
- package/dist/task/source-prepare/index.js +10 -0
- package/dist/task/source-prepare/parse-intent.js +496 -0
- package/dist/task/source-prepare/path-policy.js +197 -0
- package/dist/task/source-prepare/placeholder-paths.js +77 -0
- package/dist/task/source-prepare/prepare.js +920 -0
- package/dist/task/source-prepare/reference-integrity.js +290 -0
- package/dist/task/source-prepare/semantic-intake.js +717 -0
- package/dist/task/source-prepare/types.js +7 -0
- package/dist/task/source-references.js +228 -0
- package/dist/task/source-state.js +1 -0
- package/dist/task/state.js +41 -0
- package/dist/task/subagent-guidance.js +1 -0
- package/dist/task/task-demand-routing.js +443 -0
- package/dist/task/workflow-state-types.js +92 -0
- package/dist/task/worktree-cleanup.js +140 -0
- package/dist/task/worktree.js +388 -0
- package/dist/verification/maven/cache.js +142 -0
- package/dist/verification/maven/index.js +120 -0
- package/dist/verification/maven/plan-commands.js +421 -0
- package/dist/verification/maven/pom-static.js +136 -0
- package/dist/verification/maven/scope-resolve.js +153 -0
- package/dist/verification/maven/stale.js +130 -0
- package/dist/verification/maven/types.js +23 -0
- package/dist/verification/maven/workspace-graph.js +322 -0
- package/dist/worker/cli.js +957 -0
- package/dist/worker/closeout/apply.js +73 -0
- package/dist/worker/closeout/preview.js +30 -0
- package/dist/worker/console/app-data.js +316 -0
- package/dist/worker/console/chat/artifact-card.js +30 -0
- package/dist/worker/console/chat/assistant-content.js +121 -0
- package/dist/worker/console/chat/chat-event-store.js +981 -0
- package/dist/worker/console/chat/chat-ui-policy.js +25 -0
- package/dist/worker/console/chat/compaction-errors.js +64 -0
- package/dist/worker/console/chat/composer-draft-store.js +45 -0
- package/dist/worker/console/chat/context-panel.js +54 -0
- package/dist/worker/console/chat/contract-apply-receipt-store.js +174 -0
- package/dist/worker/console/chat/explore-tools.js +299 -0
- package/dist/worker/console/chat/human-gate-card.js +45 -0
- package/dist/worker/console/chat/interview-adapter.js +149 -0
- package/dist/worker/console/chat/mcp-inventory.js +221 -0
- package/dist/worker/console/chat/model-resolver.js +215 -0
- package/dist/worker/console/chat/operation-card.js +92 -0
- package/dist/worker/console/chat/pi-console-config.js +376 -0
- package/dist/worker/console/chat/pi-runtime.js +2446 -0
- package/dist/worker/console/chat/repo-browser.js +140 -0
- package/dist/worker/console/chat/repo-walk.js +125 -0
- package/dist/worker/console/chat/resource-loader.js +59 -0
- package/dist/worker/console/chat/resource-preferences-store.js +152 -0
- package/dist/worker/console/chat/routes.js +3137 -0
- package/dist/worker/console/chat/runtime-context.js +102 -0
- package/dist/worker/console/chat/runtime-selection.js +96 -0
- package/dist/worker/console/chat/semantic-activity.js +489 -0
- package/dist/worker/console/chat/session-store.js +484 -0
- package/dist/worker/console/chat/shortcuts.js +217 -0
- package/dist/worker/console/chat/tool-adapter.js +131 -0
- package/dist/worker/console/chat/tool-preview.js +247 -0
- package/dist/worker/console/chat/tools.js +212 -0
- package/dist/worker/console/chat/turn-execution-registry.js +82 -0
- package/dist/worker/console/chat/turn-process.js +346 -0
- package/dist/worker/console/chat/usage.js +165 -0
- package/dist/worker/console/chat/workspace-landing.js +103 -0
- package/dist/worker/console/dag-confirmation.js +347 -0
- package/dist/worker/console/dag-execution-receipt.js +393 -0
- package/dist/worker/console/doctor.js +230 -0
- package/dist/worker/console/draft-store.js +158 -0
- package/dist/worker/console/harness-pi-model-matrix.js +137 -0
- package/dist/worker/console/human-gate-token.js +130 -0
- package/dist/worker/console/index.js +17 -0
- package/dist/worker/console/inspect-split.js +82 -0
- package/dist/worker/console/interview/assessment.js +67 -0
- package/dist/worker/console/interview/grill-me.js +277 -0
- package/dist/worker/console/interview/session.js +100 -0
- package/dist/worker/console/interview/tools.js +109 -0
- package/dist/worker/console/loopback.js +16 -0
- package/dist/worker/console/mutation-gate-receipt-store.js +184 -0
- package/dist/worker/console/night-aux-ticker.js +146 -0
- package/dist/worker/console/observe-health-match.js +179 -0
- package/dist/worker/console/observe-link.js +42 -0
- package/dist/worker/console/open-browser.js +134 -0
- package/dist/worker/console/operation-run-facts.js +190 -0
- package/dist/worker/console/operation-runner.js +353 -0
- package/dist/worker/console/operation-sse.js +184 -0
- package/dist/worker/console/operation-store.js +169 -0
- package/dist/worker/console/operation-wait.js +355 -0
- package/dist/worker/console/operator-actions.js +3768 -0
- package/dist/worker/console/operator-selection.js +105 -0
- package/dist/worker/console/operator-surface-health.js +24 -0
- package/dist/worker/console/operator-user-error.js +45 -0
- package/dist/worker/console/pi-readiness.js +288 -0
- package/dist/worker/console/prd-identity.js +102 -0
- package/dist/worker/console/prd-intake-bridge.js +441 -0
- package/dist/worker/console/prd-reference-discovery.js +124 -0
- package/dist/worker/console/recovery-cta.js +320 -0
- package/dist/worker/console/recovery-error-copy.js +198 -0
- package/dist/worker/console/recovery-selection.js +107 -0
- package/dist/worker/console/repo-fingerprint.js +35 -0
- package/dist/worker/console/resolve-dag-run-for-task.js +115 -0
- package/dist/worker/console/resource-loader.js +95 -0
- package/dist/worker/console/routes.js +475 -0
- package/dist/worker/console/security.js +170 -0
- package/dist/worker/console/server.js +357 -0
- package/dist/worker/console/sibling-controller.js +33 -0
- package/dist/worker/console/static/assets/abnfDiagram-N423BO3Z-BmOEx0gA.js +1 -0
- package/dist/worker/console/static/assets/arc-BGiVVe8b.js +1 -0
- package/dist/worker/console/static/assets/architectureDiagram-T3A2C74G-nDdu4rgJ.js +36 -0
- package/dist/worker/console/static/assets/blockDiagram-VBNYF7ZC-Bb5u0BWf.js +132 -0
- package/dist/worker/console/static/assets/c4Diagram-5PPSVZJV-BlhC0j94.js +10 -0
- package/dist/worker/console/static/assets/channel-Tl-FkUqr.js +1 -0
- package/dist/worker/console/static/assets/chunk-2GRJ4B5K-Ai8_qQXI.js +1 -0
- package/dist/worker/console/static/assets/chunk-2Q5K7J3B-B9gyCjqX.js +1 -0
- package/dist/worker/console/static/assets/chunk-5RXB4S5H-Bzbj3zGH.js +231 -0
- package/dist/worker/console/static/assets/chunk-5VM5RSS4-BT415PvT.js +15 -0
- package/dist/worker/console/static/assets/chunk-6Q2QTUOP-D_A5_5QL.js +88 -0
- package/dist/worker/console/static/assets/chunk-GF5L2VYU-srJkaP3f.js +206 -0
- package/dist/worker/console/static/assets/chunk-JWPE2WC7-UYGvEP4l.js +1 -0
- package/dist/worker/console/static/assets/chunk-KBJHAD2P-B8luBrrz.js +1 -0
- package/dist/worker/console/static/assets/chunk-RYQCIY6F-DN7wXZSq.js +1 -0
- package/dist/worker/console/static/assets/chunk-XXDRQBXY-DXKyMuKS.js +1 -0
- package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-BaehtRk4.js +1 -0
- package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-BaehtRk4.js +1 -0
- package/dist/worker/console/static/assets/cose-bilkent-JH36ORCC-dqvoynXj.js +1 -0
- package/dist/worker/console/static/assets/cynefin-VYW2F7L2--PcyL34A.js +166 -0
- package/dist/worker/console/static/assets/cynefinDiagram-MW4NZA55-DvWs_hTY.js +62 -0
- package/dist/worker/console/static/assets/cytoscape.esm-yzknjiTM.js +321 -0
- package/dist/worker/console/static/assets/dagre-VZM6K2ZE-DxeIxbyO.js +4 -0
- package/dist/worker/console/static/assets/defaultLocale-DX6XiGOO.js +1 -0
- package/dist/worker/console/static/assets/diagram-7IWD3JNH-DPCG61Of.js +30 -0
- package/dist/worker/console/static/assets/diagram-B4RE2ZJO-CmuU50-U.js +3 -0
- package/dist/worker/console/static/assets/diagram-LBJQPF4R-B61XLD_v.js +24 -0
- package/dist/worker/console/static/assets/diagram-Q27KOJAE-BB7HTRRY.js +24 -0
- package/dist/worker/console/static/assets/diagram-UB23O5K3-DvkboAIp.js +41 -0
- package/dist/worker/console/static/assets/ebnfDiagram-BXEA7PRR-BdJ_y1fL.js +1 -0
- package/dist/worker/console/static/assets/erDiagram-JOGREHBK-9bUBZTRi.js +85 -0
- package/dist/worker/console/static/assets/flowDiagram-UKHOOZJN-Dw4L4RBa.js +156 -0
- package/dist/worker/console/static/assets/ganttDiagram-PKOTCBZU-Jr82N_QP.js +292 -0
- package/dist/worker/console/static/assets/gitGraphDiagram-DS77QQ5N-DAz9wFLr.js +106 -0
- package/dist/worker/console/static/assets/graph-DOmOIIwC.js +1 -0
- package/dist/worker/console/static/assets/index-B7Y-0g3J.css +1 -0
- package/dist/worker/console/static/assets/index-DkCrqaYg.js +325 -0
- package/dist/worker/console/static/assets/infoDiagram-6WML65LV-CBB5Np7y.js +2 -0
- package/dist/worker/console/static/assets/init-Gi6I4Gst.js +1 -0
- package/dist/worker/console/static/assets/ishikawaDiagram-WSZJBQD7-D8IOp94y.js +70 -0
- package/dist/worker/console/static/assets/journeyDiagram-NVQOT4AX-Dgd3AHGG.js +139 -0
- package/dist/worker/console/static/assets/kanban-definition-27J2QSJJ-BmYOxLE9.js +89 -0
- package/dist/worker/console/static/assets/layout-D-LzfAck.js +1 -0
- package/dist/worker/console/static/assets/linear-DfYTEF6J.js +1 -0
- package/dist/worker/console/static/assets/map-DxJ2ADlA.js +1 -0
- package/dist/worker/console/static/assets/mermaid.core-BjuFPRqa.js +308 -0
- package/dist/worker/console/static/assets/mindmap-definition-FAOFIHXS-CLyUViGd.js +96 -0
- package/dist/worker/console/static/assets/ordinal-Cboi1Yqb.js +1 -0
- package/dist/worker/console/static/assets/pegDiagram-VL7TDLO6-BvX2Di4-.js +1 -0
- package/dist/worker/console/static/assets/pieDiagram-7S7Q4E2Y-BFj0_OLv.js +39 -0
- package/dist/worker/console/static/assets/quadrantDiagram-CIZ2JOQS-BIUrD_hx.js +7 -0
- package/dist/worker/console/static/assets/railroadDiagram-AXF67PYL-CHBB48fj.js +1 -0
- package/dist/worker/console/static/assets/requirementDiagram-LRYGKXZP-sJrYw2Sf.js +84 -0
- package/dist/worker/console/static/assets/sankeyDiagram-W5VNT64P-BzHH6fPR.js +40 -0
- package/dist/worker/console/static/assets/sequenceDiagram-SI44F4Z6-7QCnelCt.js +162 -0
- package/dist/worker/console/static/assets/sizeCapture-X5ZJPWSS-sDYSxn72.js +1 -0
- package/dist/worker/console/static/assets/stateDiagram-OKZ733FA-XpiUdwzm.js +1 -0
- package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-eEhq2A8Y.js +1 -0
- package/dist/worker/console/static/assets/swimlanes-SLNWSIFB-DvqgNPzD.js +2 -0
- package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-la8AC7fo.js +8 -0
- package/dist/worker/console/static/assets/timeline-definition-Z64GVDOM-2TyOYNx0.js +120 -0
- package/dist/worker/console/static/assets/vennDiagram-T6HMQDX7-B-nM6wM2.js +34 -0
- package/dist/worker/console/static/assets/wardleyDiagram-T6FBY63Y-B86wPdbr.js +78 -0
- package/dist/worker/console/static/assets/xychartDiagram-ELKLHX3M-Dr1C4AQz.js +7 -0
- package/dist/worker/console/static/favicon.svg +37 -0
- package/dist/worker/console/static/fonts/katex/KaTeX_AMS-Regular.woff2 +0 -0
- package/dist/worker/console/static/fonts/katex/KaTeX_Caligraphic-Bold.woff2 +0 -0
- package/dist/worker/console/static/fonts/katex/KaTeX_Caligraphic-Regular.woff2 +0 -0
- package/dist/worker/console/static/fonts/katex/KaTeX_Fraktur-Bold.woff2 +0 -0
- package/dist/worker/console/static/fonts/katex/KaTeX_Fraktur-Regular.woff2 +0 -0
- package/dist/worker/console/static/fonts/katex/KaTeX_Main-Bold.woff2 +0 -0
- package/dist/worker/console/static/fonts/katex/KaTeX_Main-BoldItalic.woff2 +0 -0
- package/dist/worker/console/static/fonts/katex/KaTeX_Main-Italic.woff2 +0 -0
- package/dist/worker/console/static/fonts/katex/KaTeX_Main-Regular.woff2 +0 -0
- package/dist/worker/console/static/fonts/katex/KaTeX_Math-BoldItalic.woff2 +0 -0
- package/dist/worker/console/static/fonts/katex/KaTeX_Math-Italic.woff2 +0 -0
- package/dist/worker/console/static/fonts/katex/KaTeX_SansSerif-Bold.woff2 +0 -0
- package/dist/worker/console/static/fonts/katex/KaTeX_SansSerif-Italic.woff2 +0 -0
- package/dist/worker/console/static/fonts/katex/KaTeX_SansSerif-Regular.woff2 +0 -0
- package/dist/worker/console/static/fonts/katex/KaTeX_Script-Regular.woff2 +0 -0
- package/dist/worker/console/static/fonts/katex/KaTeX_Size1-Regular.woff2 +0 -0
- package/dist/worker/console/static/fonts/katex/KaTeX_Size2-Regular.woff2 +0 -0
- package/dist/worker/console/static/fonts/katex/KaTeX_Size3-Regular.woff2 +0 -0
- package/dist/worker/console/static/fonts/katex/KaTeX_Size4-Regular.woff2 +0 -0
- package/dist/worker/console/static/fonts/katex/KaTeX_Typewriter-Regular.woff2 +0 -0
- package/dist/worker/console/static/index.html +15 -0
- package/dist/worker/console/static-src/app/console-types.js +184 -0
- package/dist/worker/console/static-src/app/useConsoleShell.js +101 -0
- package/dist/worker/console/static-src/app/useOperatorActions.js +324 -0
- package/dist/worker/console/static-src/app/usePrdImport.js +172 -0
- package/dist/worker/console/static-src/app/useRecoveryActions.js +289 -0
- package/dist/worker/console/static-src/app/useRecoveryConsole.js +425 -0
- package/dist/worker/console/static-src/app/useTaskWizard.js +296 -0
- package/dist/worker/console/static-src/chat-markdown-security.js +38 -0
- package/dist/worker/console/static-src/chat-view-types.js +2 -0
- package/dist/worker/console/static-src/night/night-types.js +24 -0
- package/dist/worker/console/static-src/night/useNightBoard.js +94 -0
- package/dist/worker/console/static-src/night/useNightWizard.js +171 -0
- package/dist/worker/console/static-src/night-prepare-result.js +118 -0
- package/dist/worker/console/static-src/operator-chat/activity-journey.js +125 -0
- package/dist/worker/console/static-src/operator-chat/activity-rail-presentation.js +73 -0
- package/dist/worker/console/static-src/operator-chat/activity-references.js +20 -0
- package/dist/worker/console/static-src/operator-chat/chat-sse-events.js +420 -0
- package/dist/worker/console/static-src/operator-chat/format.js +71 -0
- package/dist/worker/console/static-src/operator-chat/landing-density.js +23 -0
- package/dist/worker/console/static-src/operator-chat/mutation-gate.js +45 -0
- package/dist/worker/console/static-src/operator-chat/refs.js +86 -0
- package/dist/worker/console/static-src/operator-chat/resource-auto-invocation.js +91 -0
- package/dist/worker/console/static-src/operator-chat/resource-diagnostics.js +204 -0
- package/dist/worker/console/static-src/operator-chat/runtime-snapshot-store.js +257 -0
- package/dist/worker/console/static-src/operator-chat/session-title-watcher.js +128 -0
- package/dist/worker/console/static-src/operator-chat/sidebar-split.js +90 -0
- package/dist/worker/console/static-src/operator-chat/slash-palette-layout.js +24 -0
- package/dist/worker/console/static-src/operator-chat/slash-palette-nav.js +141 -0
- package/dist/worker/console/static-src/operator-chat/spatial-overlay.js +38 -0
- package/dist/worker/console/static-src/operator-chat/tools-catalog.js +77 -0
- package/dist/worker/console/static-src/operator-chat/turn-stream-controller.js +690 -0
- package/dist/worker/console/static-src/operator-chat/turn-submission.js +158 -0
- package/dist/worker/console/static-src/operator-chat/types.js +1 -0
- package/dist/worker/console/static-src/operator-chat/useActivityRailTransition.js +59 -0
- package/dist/worker/console/static-src/operator-chat/useChatSessions.js +495 -0
- package/dist/worker/console/static-src/operator-chat/useChatStream.js +780 -0
- package/dist/worker/console/static-src/operator-chat/useChatThread.js +280 -0
- package/dist/worker/console/static-src/operator-chat/useComposer.js +257 -0
- package/dist/worker/console/static-src/operator-chat/useInterview.js +108 -0
- package/dist/worker/console/static-src/operator-chat/useOverlayFocus.js +84 -0
- package/dist/worker/console/static-src/operator-chat/useRepoBrowser.js +148 -0
- package/dist/worker/console/static-src/operator-chat/useRuntimeControls.js +358 -0
- package/dist/worker/console/static-src/operator-chat/useRuntimeSnapshot.js +196 -0
- package/dist/worker/console/static-src/operator-chat/useWorkspaceLayout.js +58 -0
- package/dist/worker/console/static-src/operator-chat/workspace-layout-mode.js +35 -0
- package/dist/worker/console/static-src/prd-file-import.js +218 -0
- package/dist/worker/console/vite.config.js +27 -0
- package/dist/worker/console/workflow-kinds.js +46 -0
- package/dist/worker/delivery/final-verification.js +302 -0
- package/dist/worker/delivery/git-transaction.js +497 -0
- package/dist/worker/delivery/package.js +537 -0
- package/dist/worker/delivery/verification-bundle.js +544 -0
- package/dist/worker/feature/acceptance-policy.js +227 -0
- package/dist/worker/feature/advance.js +301 -0
- package/dist/worker/feature/decision-loader.js +99 -0
- package/dist/worker/feature/discover.js +14 -0
- package/dist/worker/feature/doctor.js +223 -0
- package/dist/worker/feature/fullstack-validate.js +337 -0
- package/dist/worker/feature/next-action.js +140 -0
- package/dist/worker/feature/profile-schema.js +47 -0
- package/dist/worker/feature/ready-plan-projection.js +82 -0
- package/dist/worker/feature/reducer.js +137 -0
- package/dist/worker/feature/review.js +678 -0
- package/dist/worker/feature/run.js +390 -0
- package/dist/worker/feature/scaffold.js +812 -0
- package/dist/worker/feature/types.js +1 -0
- package/dist/worker/follow-up/approve.js +273 -0
- package/dist/worker/follow-up/factory.js +234 -0
- package/dist/worker/follow-up/paths.js +25 -0
- package/dist/worker/follow-up/policy.js +26 -0
- package/dist/worker/follow-up/schema.js +93 -0
- package/dist/worker/follow-up/store.js +96 -0
- package/dist/worker/loop-agent/command-result.js +1 -0
- package/dist/worker/loop-agent/controller-protocol.js +143 -0
- package/dist/worker/loop-agent/loop-agent-client.js +489 -0
- package/dist/worker/loop-agent/parse-json.js +14 -0
- package/dist/worker/materialize/harness-task-lifecycle-probe.js +126 -0
- package/dist/worker/materialize/harness-task-lineage.js +220 -0
- package/dist/worker/materialize/harness-task-materializer.js +648 -0
- package/dist/worker/metrics/projector.js +139 -0
- package/dist/worker/observability/dag-execution-trajectory.js +591 -0
- package/dist/worker/observability/event-history.js +216 -0
- package/dist/worker/observability/event-store.js +83 -0
- package/dist/worker/observability/events.js +79 -0
- package/dist/worker/observability/interrupt-eligibility.js +264 -0
- package/dist/worker/observability/progress-composite.js +34 -0
- package/dist/worker/observability/read-model.js +2499 -0
- package/dist/worker/observability/snapshot-store.js +43 -0
- package/dist/worker/observability/types.js +1 -0
- package/dist/worker/observe/dag-node-execution-output.js +180 -0
- package/dist/worker/observe/dag-run-artifacts.js +90 -0
- package/dist/worker/observe/health.js +58 -0
- package/dist/worker/observe/night-jobs.js +104 -0
- package/dist/worker/observe/node-input.js +441 -0
- package/dist/worker/observe/paths.js +174 -0
- package/dist/worker/observe/routes.js +1077 -0
- package/dist/worker/observe/server.js +117 -0
- package/dist/worker/observe/spec-evidence.js +398 -0
- package/dist/worker/observe/static/api.js +117 -0
- package/dist/worker/observe/static/app.js +169 -0
- package/dist/worker/observe/static/constants.js +182 -0
- package/dist/worker/observe/static/copy.js +67 -0
- package/dist/worker/observe/static/custom-select.js +567 -0
- package/dist/worker/observe/static/dag-edge-routing.js +368 -0
- package/dist/worker/observe/static/dag-helpers.js +161 -0
- package/dist/worker/observe/static/dag-history-labels.js +95 -0
- package/dist/worker/observe/static/dag-layout.d.ts +36 -0
- package/dist/worker/observe/static/dag-layout.js +163 -0
- package/dist/worker/observe/static/dag-model.js +145 -0
- package/dist/worker/observe/static/dom.js +220 -0
- package/dist/worker/observe/static/favicon.svg +37 -0
- package/dist/worker/observe/static/format-pool.d.ts +71 -0
- package/dist/worker/observe/static/format-pool.js +153 -0
- package/dist/worker/observe/static/format.js +347 -0
- package/dist/worker/observe/static/index.html +409 -0
- package/dist/worker/observe/static/kpi.js +78 -0
- package/dist/worker/observe/static/markdown-render.js +124 -0
- package/dist/worker/observe/static/operator-chrome.css +517 -0
- package/dist/worker/observe/static/operator-chrome.d.ts +83 -0
- package/dist/worker/observe/static/operator-chrome.js +623 -0
- package/dist/worker/observe/static/relations.js +133 -0
- package/dist/worker/observe/static/router.js +156 -0
- package/dist/worker/observe/static/run-processing.js +148 -0
- package/dist/worker/observe/static/shell-chrome.js +65 -0
- package/dist/worker/observe/static/state.js +496 -0
- package/dist/worker/observe/static/styles.css +3567 -0
- package/dist/worker/observe/static/views/batch.js +227 -0
- package/dist/worker/observe/static/views/dag-graph.js +508 -0
- package/dist/worker/observe/static/views/dag-inspector.js +1722 -0
- package/dist/worker/observe/static/views/dag-trajectory.js +313 -0
- package/dist/worker/observe/static/views/dag.js +483 -0
- package/dist/worker/observe/static/views/dags.js +877 -0
- package/dist/worker/observe/static/views/dashboard.js +747 -0
- package/dist/worker/observe/static/views/failures.js +143 -0
- package/dist/worker/observe/static/views/feature.js +492 -0
- package/dist/worker/observe/static/views/night.js +201 -0
- package/dist/worker/observe/static/views/pool.js +708 -0
- package/dist/worker/observe/static/views/run.js +453 -0
- package/dist/worker/observe/static/views/session-timeline.js +771 -0
- package/dist/worker/observe/static/views/shell.js +7 -0
- package/dist/worker/observe/static/views/task.js +315 -0
- package/dist/worker/observe/static/views/timeline.js +163 -0
- package/dist/worker/outcomes/adapters.js +153 -0
- package/dist/worker/outcomes/declared-artifacts.js +103 -0
- package/dist/worker/outcomes/evidence-tokens.js +29 -0
- package/dist/worker/outcomes/gate.js +40 -0
- package/dist/worker/outcomes/projector.js +227 -0
- package/dist/worker/outcomes/registry.js +1 -0
- package/dist/worker/outcomes/store.js +131 -0
- package/dist/worker/outcomes/types.js +79 -0
- package/dist/worker/pool/attempt-identity.js +41 -0
- package/dist/worker/pool/attempt-lease.js +184 -0
- package/dist/worker/pool/attempt-transition.js +210 -0
- package/dist/worker/pool/begin-attempt-with-lease.js +26 -0
- package/dist/worker/pool/begin-attempt.js +35 -0
- package/dist/worker/pool/doctor.js +165 -0
- package/dist/worker/pool/failure-routing.js +182 -0
- package/dist/worker/pool/migrate-state.js +303 -0
- package/dist/worker/pool/reconcile.js +285 -0
- package/dist/worker/pool/recovery-decision.js +163 -0
- package/dist/worker/pool/run-owner-store.js +126 -0
- package/dist/worker/pool/run-store.js +360 -0
- package/dist/worker/pool/runtime-reconcile-inventory.js +127 -0
- package/dist/worker/pool/state-projection.js +57 -0
- package/dist/worker/pool/types.js +17 -0
- package/dist/worker/pool/validation.js +144 -0
- package/dist/worker/preflight.js +157 -0
- package/dist/worker/profile-mapping.js +76 -0
- package/dist/worker/progress-reporter.js +63 -0
- package/dist/worker/report/morning-report.js +155 -0
- package/dist/worker/repos/repo-resolver.js +23 -0
- package/dist/worker/run-task/execute-prepared-task.js +178 -0
- package/dist/worker/run-task/run-task.js +912 -0
- package/dist/worker/runner/run-ready.js +561 -0
- package/dist/worker/runner/single-task-attempt.js +176 -0
- package/dist/worker/scheduler/admission.js +547 -0
- package/dist/worker/scheduler/auto-followup.js +99 -0
- package/dist/worker/scheduler/cli.js +644 -0
- package/dist/worker/scheduler/clock-install/darwin-launchd.js +238 -0
- package/dist/worker/scheduler/clock-install/linux-systemd-user.js +224 -0
- package/dist/worker/scheduler/clock-install/types.js +1 -0
- package/dist/worker/scheduler/clock-install/win32-schtasks.js +227 -0
- package/dist/worker/scheduler/clock-install.js +284 -0
- package/dist/worker/scheduler/clock.js +420 -0
- package/dist/worker/scheduler/dispatcher.js +503 -0
- package/dist/worker/scheduler/doctor.js +431 -0
- package/dist/worker/scheduler/evidence.js +170 -0
- package/dist/worker/scheduler/git-base.js +90 -0
- package/dist/worker/scheduler/index.js +25 -0
- package/dist/worker/scheduler/lease.js +114 -0
- package/dist/worker/scheduler/lifecycle.js +348 -0
- package/dist/worker/scheduler/lock.js +80 -0
- package/dist/worker/scheduler/morning-window.js +191 -0
- package/dist/worker/scheduler/night-git-finalizer.js +114 -0
- package/dist/worker/scheduler/night-harvest.js +412 -0
- package/dist/worker/scheduler/paths.js +92 -0
- package/dist/worker/scheduler/prepared-attempt-recovery.js +471 -0
- package/dist/worker/scheduler/recovery.js +277 -0
- package/dist/worker/scheduler/reservation.js +146 -0
- package/dist/worker/scheduler/retry.js +199 -0
- package/dist/worker/scheduler/scheduler-loop.js +272 -0
- package/dist/worker/scheduler/store.js +275 -0
- package/dist/worker/scheduler/traceability.js +54 -0
- package/dist/worker/scheduler/trigger.js +258 -0
- package/dist/worker/scheduler/types.js +369 -0
- package/dist/worker/scheduler/workspace-adapter.js +128 -0
- package/dist/worker/task-graph/acceptance-schema.js +40 -0
- package/dist/worker/task-graph/ready-planner.js +267 -0
- package/dist/worker/task-graph/ready-queue.js +23 -0
- package/dist/worker/task-graph/task-graph-schema.js +59 -0
- package/dist/worker/task-graph/types.js +1 -0
- package/dist/worker/task-graph/validate.js +293 -0
- package/dist/worker/task-spec/complexity-mapping.js +8 -0
- package/dist/worker/task-spec/schema.js +125 -0
- package/dist/worker/task-spec/types.js +1 -0
- package/dist/worker/task-spec/validate.js +391 -0
- package/dist/worker/task-spec/workflow-routing.js +149 -0
- package/dist/workflows/dag/authoring.js +8 -0
- package/dist/workflows/dag/authority-surface.js +138 -0
- package/dist/workflows/dag/backend-test-analysis-contract.js +507 -0
- package/dist/workflows/dag/backend-test-case-coverage-analysis.js +1985 -0
- package/dist/workflows/dag/backend-test-case-manifest.js +638 -0
- package/dist/workflows/dag/backend-test-classification-contract.js +38 -0
- package/dist/workflows/dag/backend-test-contract-envelope.js +205 -0
- package/dist/workflows/dag/backend-test-coverage-contract.js +202 -0
- package/dist/workflows/dag/backend-test-execution-contract.js +715 -0
- package/dist/workflows/dag/backend-test-gap-fill.js +205 -0
- package/dist/workflows/dag/backend-test-intake-context.js +178 -0
- package/dist/workflows/dag/backend-test-layout.js +133 -0
- package/dist/workflows/dag/backend-test-markdown-workflow.js +1984 -0
- package/dist/workflows/dag/backend-test-module-stem.js +26 -0
- package/dist/workflows/dag/backend-test-pytest-collection.js +859 -0
- package/dist/workflows/dag/backend-test-result-contract.js +1030 -0
- package/dist/workflows/dag/backend-test-scenario-param.js +1670 -0
- package/dist/workflows/dag/backend-test-scenario-partitions.js +249 -0
- package/dist/workflows/dag/backend-test-semantic-review-contract.js +36 -0
- package/dist/workflows/dag/backend-test-stability-contract.js +57 -0
- package/dist/workflows/dag/backend-test-writer-completeness.js +1058 -0
- package/dist/workflows/dag/budget-enforcement.js +67 -0
- package/dist/workflows/dag/canvas-observer.js +474 -0
- package/dist/workflows/dag/context-policy.js +137 -0
- package/dist/workflows/dag/contract-output-registry.js +14 -0
- package/dist/workflows/dag/contract-validator-registrations.js +10 -0
- package/dist/workflows/dag/controller-identity.js +104 -0
- package/dist/workflows/dag/convergence/controller.js +596 -0
- package/dist/workflows/dag/decision-envelope.js +557 -0
- package/dist/workflows/dag/decision-evidence.js +153 -0
- package/dist/workflows/dag/decision-gates.js +1 -0
- package/dist/workflows/dag/dynamic-runtime/condition.js +48 -0
- package/dist/workflows/dag/dynamic-runtime/loop-until.js +161 -0
- package/dist/workflows/dag/dynamic-runtime/map.js +435 -0
- package/dist/workflows/dag/dynamic-runtime/reduction.js +72 -0
- package/dist/workflows/dag/dynamic-runtime/shared.js +203 -0
- package/dist/workflows/dag/event-observer.js +132 -0
- package/dist/workflows/dag/executor-registry.js +23 -0
- package/dist/workflows/dag/facts.js +4 -0
- package/dist/workflows/dag/failure-category.js +118 -0
- package/dist/workflows/dag/failure-routing.js +105 -0
- package/dist/workflows/dag/final-verification.js +180 -0
- package/dist/workflows/dag/frontend-implementation-contract.js +1911 -0
- package/dist/workflows/dag/frontend-lint-baseline.js +474 -0
- package/dist/workflows/dag/frontend-plan-render.js +90 -0
- package/dist/workflows/dag/frontend-prewrite-gate.js +1011 -0
- package/dist/workflows/dag/frontend-project-capability.js +1 -0
- package/dist/workflows/dag/frontend-recovery-plan.js +73 -0
- package/dist/workflows/dag/frontend-recovery-root-manifest.js +123 -0
- package/dist/workflows/dag/frontend-recovery-run.js +539 -0
- package/dist/workflows/dag/frontend-repair.js +541 -0
- package/dist/workflows/dag/frontend-review-context.js +116 -0
- package/dist/workflows/dag/frontend-risk.js +161 -0
- package/dist/workflows/dag/frontend-test-case-checklist.js +343 -0
- package/dist/workflows/dag/frontend-test-case-manifest.js +104 -0
- package/dist/workflows/dag/frontend-test-case-quality.js +105 -0
- package/dist/workflows/dag/frontend-test-html-report.js +174 -0
- package/dist/workflows/dag/frontend-test-l5-report.js +177 -0
- package/dist/workflows/dag/frontend-test-result-contract.js +487 -0
- package/dist/workflows/dag/frontend-verification-trace.js +275 -0
- package/dist/workflows/dag/frontend-worktree-diff.js +201 -0
- package/dist/workflows/dag/frontend-writer-recovery.js +106 -0
- package/dist/workflows/dag/frontend-writer-rollback.js +821 -0
- package/dist/workflows/dag/governance-constants.js +5 -0
- package/dist/workflows/dag/governance-profile.js +413 -0
- package/dist/workflows/dag/index.js +6 -0
- package/dist/workflows/dag/init-hybrid.js +7345 -0
- package/dist/workflows/dag/interrupt-request.js +559 -0
- package/dist/workflows/dag/knowledge-curator.js +165 -0
- package/dist/workflows/dag/l5-report-metrics.js +33 -0
- package/dist/workflows/dag/lifecycle.js +855 -0
- package/dist/workflows/dag/liveness-policy.js +251 -0
- package/dist/workflows/dag/node-execution.js +1081 -0
- package/dist/workflows/dag/observer-compose.js +52 -0
- package/dist/workflows/dag/output-protocol.js +356 -0
- package/dist/workflows/dag/project-governance-context.js +514 -0
- package/dist/workflows/dag/prompt-source.js +88 -0
- package/dist/workflows/dag/prompt.js +348 -0
- package/dist/workflows/dag/reconcile-run.js +145 -0
- package/dist/workflows/dag/reconcile-tasks.js +404 -0
- package/dist/workflows/dag/recovery-recommendation.js +329 -0
- package/dist/workflows/dag/repair-artifact.js +363 -0
- package/dist/workflows/dag/report.js +1229 -0
- package/dist/workflows/dag/rerun-plan.js +614 -0
- package/dist/workflows/dag/rerun-run.js +556 -0
- package/dist/workflows/dag/rerun-task.js +370 -0
- package/dist/workflows/dag/retry-policy.js +263 -0
- package/dist/workflows/dag/run-store.js +41 -0
- package/dist/workflows/dag/runner.js +1069 -0
- package/dist/workflows/dag/runtime-contract.js +87 -0
- package/dist/workflows/dag/runtime.js +5 -0
- package/dist/workflows/dag/scheduler.js +497 -0
- package/dist/workflows/dag/sdd-embedded.js +128 -0
- package/dist/workflows/dag/skill-instructions.js +478 -0
- package/dist/workflows/dag/skill-snapshot.js +553 -0
- package/dist/workflows/dag/skills.js +41 -0
- package/dist/workflows/dag/spec.js +3 -0
- package/dist/workflows/dag/task-contract-binding.js +138 -0
- package/dist/workflows/dag/task-demand-routing.js +1 -0
- package/dist/workflows/dag/topo.js +30 -0
- package/dist/workflows/dag/types.js +1145 -0
- package/dist/workflows/dag/upstream-artifacts.js +98 -0
- package/dist/workflows/dag/validate.js +998 -0
- package/dist/workflows/dag/workspace-checkpoint.js +186 -0
- package/dist/workflows/dynamic/artifacts.js +65 -0
- package/dist/workflows/dynamic/compile.js +371 -0
- package/dist/workflows/dynamic/compileTypes.js +1 -0
- package/dist/workflows/dynamic/errors.js +5 -0
- package/dist/workflows/dynamic/index.js +7 -0
- package/dist/workflows/dynamic/profiles.js +156 -0
- package/dist/workflows/dynamic/spec.js +115 -0
- package/dist/workflows/dynamic/validate.js +275 -0
- package/dist/workflows/loop/actions/dag-action.js +129 -0
- package/dist/workflows/loop/actions/pi-review.js +267 -0
- package/dist/workflows/loop/actions/shared.js +157 -0
- package/dist/workflows/loop/actions/shell-verify.js +82 -0
- package/dist/workflows/loop/actions/types.js +1 -0
- package/dist/workflows/loop/actions/workflow-action.js +255 -0
- package/dist/workflows/loop/actions.js +160 -0
- package/dist/workflows/loop/benchmark.js +510 -0
- package/dist/workflows/loop/closeout.js +135 -0
- package/dist/workflows/loop/context.js +47 -0
- package/dist/workflows/loop/events.js +26 -0
- package/dist/workflows/loop/hash.js +32 -0
- package/dist/workflows/loop/index.js +8 -0
- package/dist/workflows/loop/paths.js +17 -0
- package/dist/workflows/loop/policy/auto-policy.js +112 -0
- package/dist/workflows/loop/policy/path-patterns.js +13 -0
- package/dist/workflows/loop/rounds.js +81 -0
- package/dist/workflows/loop/signals.js +52 -0
- package/dist/workflows/loop/state.js +116 -0
- package/dist/workflows/loop/templates.js +54 -0
- package/dist/workflows/loop/types.js +28 -0
- package/docs/README.md +82 -0
- package/docs/architecture/README.md +35 -0
- package/docs/architecture/dag-execution.md +165 -0
- package/docs/architecture/evolution.md +108 -0
- package/docs/architecture/facts-and-state.md +74 -0
- package/docs/architecture/runtime-boundaries.md +226 -0
- package/docs/architecture/system-overview.md +100 -0
- package/docs/architecture/worker-and-feature.md +122 -0
- package/docs/governance/README.md +18 -0
- package/docs/governance/harness-methodology-debugging.md +177 -0
- package/docs/governance/harness-methodology-tdd.md +130 -0
- package/docs/governance/harness-methodology-verification.md +27 -0
- package/docs/init-surface.manifest.json +358 -0
- package/docs/operations/README.md +15 -0
- package/docs/operations/local-development-environment.md +77 -0
- package/docs/skills/README.md +7 -0
- package/docs/skills/vetted-skill-registry.md +49 -0
- package/docs/templates/README.md +67 -0
- package/docs/templates/adr.md +60 -0
- package/docs/templates/agent-dag-authority-surface-audit.prompt.md +94 -0
- package/docs/templates/agent-dag-decision-envelope.schema.json +213 -0
- package/docs/templates/agent-dag-decision-gate-dogfood-report.md +117 -0
- package/docs/templates/agent-dag-decision-gate.prompt.md +246 -0
- package/docs/templates/agent-dag-process-supervisor.prompt.md +98 -0
- package/docs/templates/agent-dag-report.schema.json +473 -0
- package/docs/templates/agent-dag-review-verdict.prompt.md +68 -0
- package/docs/templates/agent-dag.base.json +190 -0
- package/docs/templates/agent-dag.final-verification.json +185 -0
- package/docs/templates/agent-dag.schema.json +590 -0
- package/docs/templates/agent-dag.supervised-implementation.json +640 -0
- package/docs/templates/agent-worker-production-readiness-checklist.md +47 -0
- package/docs/templates/backend-test-analysis.schema.json +37 -0
- package/docs/templates/backend-test-case-manifest.schema.json +223 -0
- package/docs/templates/backend-test-dag.classify.prompt.md +75 -0
- package/docs/templates/backend-test-dag.generate-pytest.prompt.md +41 -0
- package/docs/templates/backend-test-dag.json +671 -0
- package/docs/templates/backend-test-dag.retrospect.prompt.md +165 -0
- package/docs/templates/backend-test-dag.review-cases.prompt.md +36 -0
- package/docs/templates/backend-test-execution.schema.json +138 -0
- package/docs/templates/backend-test-result.schema.json +99 -0
- package/docs/templates/branch-merge-report.md +115 -0
- package/docs/templates/evaluation/agents-map-slim-v1.candidate.json +9 -0
- package/docs/templates/evaluation/agents-map-slim-v1.md +87 -0
- package/docs/templates/evaluation/agents-map-verbose-v0.candidate.json +9 -0
- package/docs/templates/evaluation/agents-map-verbose-v0.md +153 -0
- package/docs/templates/evaluation/campaign-budget-v1.json +12 -0
- package/docs/templates/evaluation/campaign-dogfood-v0.json +24 -0
- package/docs/templates/evaluation/campaign-evidence-v1.json +44 -0
- package/docs/templates/evaluation/context-policy-baseline-v1.json +17 -0
- package/docs/templates/evaluation/context-policy-role-specialized-v1.json +28 -0
- package/docs/templates/evaluation/corpus-dogfood-v0.manifest.json +118 -0
- package/docs/templates/evaluation/matrix-dag-dry-run-v1.json +21 -0
- package/docs/templates/evaluation/matrix-fixture-v1.json +10 -0
- package/docs/templates/evaluation/private-verifier-dogfood-v0.json +16 -0
- package/docs/templates/exec-plan.md +66 -0
- package/docs/templates/feature-spec.md +53 -0
- package/docs/templates/frontend-design-contract.md +68 -0
- package/docs/templates/frontend-eval/fixtures/failures/01-type-build-error.md +17 -0
- package/docs/templates/frontend-eval/fixtures/failures/02-unit-component-test-fail.md +16 -0
- package/docs/templates/frontend-eval/fixtures/failures/03-fixture-schema-drift.md +16 -0
- package/docs/templates/frontend-eval/fixtures/failures/04-missing-loading-empty-error-state.md +16 -0
- package/docs/templates/frontend-eval/fixtures/failures/05-forbidden-write-writeset-expansion.md +16 -0
- package/docs/templates/frontend-eval/fixtures/failures/06-unapproved-dependency-add.md +16 -0
- package/docs/templates/frontend-eval/fixtures/failures/07-mock-production-on.md +21 -0
- package/docs/templates/frontend-eval/fixtures/functional/01-simple-component-style.md +29 -0
- package/docs/templates/frontend-eval/fixtures/functional/02-form-validation.md +28 -0
- package/docs/templates/frontend-eval/fixtures/functional/03-list-detail-page.md +28 -0
- package/docs/templates/frontend-eval/fixtures/functional/04-api-mock.md +29 -0
- package/docs/templates/frontend-eval/fixtures/functional/05-permission-auth-gated-ui.md +27 -0
- package/docs/templates/frontend-eval/fixtures/functional/06-ssr-server-client-boundary.md +28 -0
- package/docs/templates/frontend-eval/fixtures/functional/07-shared-public-component-api.md +28 -0
- package/docs/templates/frontend-eval/fixtures/functional/08-pure-local-no-remote.md +27 -0
- package/docs/templates/frontend-eval/metrics.md +138 -0
- package/docs/templates/frontend-eval/smoke-targets.md +53 -0
- package/docs/templates/frontend-implementation-contract.schema.json +35 -0
- package/docs/templates/frontend-task-constraints.md +62 -0
- package/docs/templates/frontend-task-requirement.md +104 -0
- package/docs/templates/frontend-test-case-checklist.md +44 -0
- package/docs/templates/frontend-test-case.example.md +143 -0
- package/docs/templates/frontend-test-dag.generate-cases.prompt.md +63 -0
- package/docs/templates/frontend-test-dag.json +409 -0
- package/docs/templates/frontend-test-dag.retrieve-context.prompt.md +21 -0
- package/docs/templates/frontend-test-dag.retrospect.prompt.md +5 -0
- package/docs/templates/frontend-test-dag.review-cases.prompt.md +5 -0
- package/docs/templates/frontend-test-dag.review-execution.prompt.md +3 -0
- package/docs/templates/frontend-test-standard-scenarios.v1.json +159 -0
- package/docs/templates/harness.schema.json +351 -0
- package/docs/templates/hybrid-dag.json +188 -0
- package/docs/templates/init-evolution-review.md +35 -0
- package/docs/templates/init-managed-agents.md +157 -0
- package/docs/templates/interactive-ui-round2-experiment.md +66 -0
- package/docs/templates/knowledge-graph-bootstrap-dag.json +118 -0
- package/docs/templates/knowledge-sync-dag.json +178 -0
- package/docs/templates/knowledge-sync-draft.schema.json +71 -0
- package/docs/templates/product-line/AGENTS.md +9 -0
- package/docs/templates/product-line/README.md +42 -0
- package/docs/templates/product-line/acceptance.yaml +23 -0
- package/docs/templates/product-line/closeout.yaml +9 -0
- package/docs/templates/product-line/design.md +13 -0
- package/docs/templates/product-line/feature-scaffold-batch.example.yaml +31 -0
- package/docs/templates/product-line/feature.yaml +11 -0
- package/docs/templates/product-line/links.md +10 -0
- package/docs/templates/product-line/requirement.md +17 -0
- package/docs/templates/product-line/scaffold-samples/README.md +36 -0
- package/docs/templates/product-line/scaffold-samples/backend-only/acceptance.yaml +16 -0
- package/docs/templates/product-line/scaffold-samples/backend-only/design.md +14 -0
- package/docs/templates/product-line/scaffold-samples/backend-only/feature.yaml +14 -0
- package/docs/templates/product-line/scaffold-samples/backend-only/requirement.md +6 -0
- package/docs/templates/product-line/scaffold-samples/backend-only/tasks/BE-IMPL-001.yaml +83 -0
- package/docs/templates/product-line/scaffold-samples/backend-only/tasks/task-graph.yaml +14 -0
- package/docs/templates/product-line/scaffold-samples/fe-with-api/acceptance.yaml +18 -0
- package/docs/templates/product-line/scaffold-samples/fe-with-api/design.md +18 -0
- package/docs/templates/product-line/scaffold-samples/fe-with-api/feature.yaml +14 -0
- package/docs/templates/product-line/scaffold-samples/fe-with-api/requirement.md +6 -0
- package/docs/templates/product-line/scaffold-samples/fe-with-api/tasks/BE-IMPL-001.yaml +84 -0
- package/docs/templates/product-line/scaffold-samples/fe-with-api/tasks/CONTRACT-001.yaml +84 -0
- package/docs/templates/product-line/scaffold-samples/fe-with-api/tasks/FE-IMPL-001.yaml +86 -0
- package/docs/templates/product-line/scaffold-samples/fe-with-api/tasks/task-graph.yaml +40 -0
- package/docs/templates/product-line/scaffold-samples/frontend-only/acceptance.yaml +16 -0
- package/docs/templates/product-line/scaffold-samples/frontend-only/design.md +14 -0
- package/docs/templates/product-line/scaffold-samples/frontend-only/feature.yaml +14 -0
- package/docs/templates/product-line/scaffold-samples/frontend-only/requirement.md +6 -0
- package/docs/templates/product-line/scaffold-samples/frontend-only/tasks/FE-IMPL-001.yaml +85 -0
- package/docs/templates/product-line/scaffold-samples/frontend-only/tasks/task-graph.yaml +14 -0
- package/docs/templates/product-line/task-graph.yaml +23 -0
- package/docs/templates/product-line/task.yaml +68 -0
- package/docs/templates/product-line/test-plan.md +7 -0
- package/docs/templates/production-readiness-checklist.md +57 -0
- package/docs/templates/progress-log.md +27 -0
- package/docs/templates/project-start-checklist.md +9 -0
- package/docs/templates/qa-report.md +48 -0
- package/docs/templates/sprint-contract.md +29 -0
- package/docs/templates/worker-dogfood-evidence.md +80 -0
- package/docs/templates/worker-dogfood-setup.md +68 -0
- package/examples/decision-gate-agent-dag.json +177 -0
- package/examples/example-dag.json +46 -0
- package/examples/hybrid-loop-agent-dag.json +189 -0
- package/examples/l5-report-coms-process-definition.html +322 -0
- package/examples/l5-report-demo.html +79 -0
- package/harness.json +90 -0
- package/package.json +98 -0
- package/scripts/kb-bootstrap-init-skeleton.sh +241 -0
- package/scripts/kb-graph-incremental-prepare.mjs +386 -0
- package/scripts/kb-graph-materialize.mjs +105 -0
- package/scripts/kb-graph-promote.mjs +164 -0
- package/scripts/kb-query.mjs +554 -0
- package/skills/agent-worker/SKILL.md +48 -0
- package/skills/agent-worker/references/agent-worker-operator.md +159 -0
- package/skills/ai-engineering-context/SKILL.md +48 -0
- package/skills/analyze-product-dependencies/SKILL.md +108 -0
- package/skills/analyze-product-dependencies/references/api-documentation-schema.md +35 -0
- package/skills/analyze-product-dependencies/references/dependency-analysis-schema.md +38 -0
- package/skills/analyze-product-dependencies/references/example.md +76 -0
- package/skills/analyze-product-dependencies/references/forward-test-cases.md +110 -0
- package/skills/analyze-product-dependencies/references/input-contract.md +34 -0
- package/skills/analyze-product-dependencies/references/kb-integration.md +64 -0
- package/skills/analyze-product-dependencies/references/scouting-rules.md +76 -0
- package/skills/analyze-product-dependencies/scripts/test-validators.mjs +460 -0
- package/skills/analyze-product-dependencies/scripts/validate-api-documentation.mjs +194 -0
- package/skills/analyze-product-dependencies/scripts/validate-dependency-analysis.mjs +200 -0
- package/skills/analyze-product-dependencies/scripts/validate-product-requirement-input.mjs +90 -0
- package/skills/analyze-product-dependencies/scripts/validation-helpers.mjs +138 -0
- package/skills/analyze-product-requirements/SKILL.md +145 -0
- package/skills/analyze-product-requirements/references/acceptance-criteria.md +87 -0
- package/skills/analyze-product-requirements/references/clarification-and-knowledge.md +70 -0
- package/skills/analyze-product-requirements/references/example.md +104 -0
- package/skills/analyze-product-requirements/references/forward-test-cases.md +144 -0
- package/skills/analyze-product-requirements/references/kb-integration.md +56 -0
- package/skills/analyze-product-requirements/references/product-analysis-schema.md +41 -0
- package/skills/analyze-product-requirements/references/product-requirement-schema.md +42 -0
- package/skills/analyze-product-requirements/references/requirement-clarification-schema.md +66 -0
- package/skills/analyze-product-requirements/scripts/compute-source-identity.mjs +35 -0
- package/skills/analyze-product-requirements/scripts/test-validators.mjs +501 -0
- package/skills/analyze-product-requirements/scripts/validate-product-analysis.mjs +100 -0
- package/skills/analyze-product-requirements/scripts/validate-product-requirement.mjs +109 -0
- package/skills/analyze-product-requirements/scripts/validate-requirement-clarification.mjs +109 -0
- package/skills/analyze-product-requirements/scripts/validation-helpers.mjs +175 -0
- package/skills/browser-tools/SKILL.md +196 -0
- package/skills/browser-tools/browser-content.js +103 -0
- package/skills/browser-tools/browser-cookies.js +35 -0
- package/skills/browser-tools/browser-eval.js +53 -0
- package/skills/browser-tools/browser-hn-scraper.js +108 -0
- package/skills/browser-tools/browser-nav.js +44 -0
- package/skills/browser-tools/browser-pick.js +162 -0
- package/skills/browser-tools/browser-screenshot.js +34 -0
- package/skills/browser-tools/browser-start.js +86 -0
- package/skills/browser-tools/package-lock.json +2556 -0
- package/skills/browser-tools/package.json +19 -0
- package/skills/code-review-core/SKILL.md +20 -0
- package/skills/codebase-scout/SKILL.md +19 -0
- package/skills/frontend-bounded-implement/SKILL.md +53 -0
- package/skills/frontend-design-review/SKILL.md +79 -0
- package/skills/frontend-design-review/references/review-checklist.md +43 -0
- package/skills/frontend-implementation/SKILL.md +52 -0
- package/skills/frontend-implementation/references/code-standards.md +33 -0
- package/skills/frontend-implementation/references/design-spec.md +56 -0
- package/skills/frontend-implementation/references/node-contracts.md +31 -0
- package/skills/frontend-review/SKILL.md +55 -0
- package/skills/frontend-review/references/review-findings.md +50 -0
- package/skills/frontend-verification/SKILL.md +61 -0
- package/skills/frontend-verification/references/verification-checklist.md +48 -0
- package/skills/grill-me/SKILL.md +10 -0
- package/skills/grill-with-docs/SKILL.md +80 -0
- package/skills/grill-with-docs/adr-format.md +58 -0
- package/skills/grill-with-docs/context-format.md +52 -0
- package/skills/init-capability-evolution/SKILL.md +70 -0
- package/skills/local-jacoco-coverage/SKILL.md +281 -0
- package/skills/local-jacoco-coverage/references/requirement-to-source-mapping.md +85 -0
- package/skills/local-jacoco-coverage/references/runtime-alignment.md +106 -0
- package/skills/local-jacoco-coverage/scripts/run-coverage-analysis.sh +148 -0
- package/skills/local-jacoco-coverage/scripts/start-jacoco-agent.sh +110 -0
- package/skills/loop-agent/SKILL.md +68 -0
- package/skills/loop-agent/references/README.md +67 -0
- package/skills/loop-agent/references/command-reference.md +645 -0
- package/skills/loop-agent/references/docs-converge.md +126 -0
- package/skills/loop-agent/references/harness-policy.md +289 -0
- package/skills/loop-agent/references/hybrid-dag.md +245 -0
- package/skills/loop-agent/references/learned/README.md +21 -0
- package/skills/loop-agent/references/long-running-loop.md +57 -0
- package/skills/loop-agent/references/model-routing.md +45 -0
- package/skills/loop-agent/references/multi-worktree.md +54 -0
- package/skills/loop-agent/references/one-shot-runs.md +84 -0
- package/skills/loop-agent/references/orchestrator-and-interventions.md +175 -0
- package/skills/loop-agent/references/pi-prompt.md +23 -0
- package/skills/loop-agent/references/pi-subagent-assisted-mode.md +84 -0
- package/skills/loop-agent/references/post-implementation-and-patterns.md +54 -0
- package/skills/loop-agent/references/source-and-plan-practice.md +169 -0
- package/skills/loop-agent/references/task-workflow.md +104 -0
- package/skills/loop-agent/references/verification-and-failure-handling.md +148 -0
- package/skills/playwright-cli/SKILL.md +93 -0
- package/skills/playwright-cli/references/element-attributes.md +23 -0
- package/skills/playwright-cli/references/playwright-tests.md +39 -0
- package/skills/playwright-cli/references/request-mocking.md +87 -0
- package/skills/playwright-cli/references/running-code.md +241 -0
- package/skills/playwright-cli/references/session-management.md +225 -0
- package/skills/playwright-cli/references/storage-state.md +275 -0
- package/skills/playwright-cli/references/test-generation.md +433 -0
- package/skills/playwright-cli/references/tracing.md +5 -0
- package/skills/playwright-cli/references/video-recording.md +5 -0
- package/skills/playwright-cli-case-generator/SKILL.md +108 -0
- package/skills/requesting-code-review/SKILL.md +101 -0
- package/skills/requesting-code-review/code-reviewer.md +168 -0
- package/skills/systematic-debugging/CREATION-LOG.md +119 -0
- package/skills/systematic-debugging/SKILL.md +312 -0
- package/skills/systematic-debugging/condition-based-waiting-example.ts +158 -0
- package/skills/systematic-debugging/condition-based-waiting.md +115 -0
- package/skills/systematic-debugging/defense-in-depth.md +122 -0
- package/skills/systematic-debugging/find-polluter.sh +63 -0
- package/skills/systematic-debugging/root-cause-tracing.md +169 -0
- package/skills/systematic-debugging/test-academic.md +14 -0
- package/skills/systematic-debugging/test-pressure-1.md +58 -0
- package/skills/systematic-debugging/test-pressure-2.md +68 -0
- package/skills/systematic-debugging/test-pressure-3.md +69 -0
- package/skills/test-driven-development/SKILL.md +27 -0
- package/skills/using-git-worktrees/SKILL.md +215 -0
- package/skills/verification-before-completion/SKILL.md +154 -0
- package/skills/webapp-testing/SKILL.md +19 -0
|
@@ -0,0 +1,1077 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
import { open as openFile, readFile, stat } from "node:fs/promises";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
import { redactSecrets, truncateUtf8Preview } from "../../shared/preview.js";
|
|
7
|
+
import { parseWorkerEventLine } from "../observability/events.js";
|
|
8
|
+
import { isSafeObservabilityIdentifier } from "../observability/event-store.js";
|
|
9
|
+
import { clampEventHistoryLimit, listBatchEventHistory, listPoolEventHistory, } from "../observability/event-history.js";
|
|
10
|
+
import { buildGlobalSnapshot, clampDagRunHistoryPageSize, clampTaskRunHistoryLimit, listDagRunHistoryFromSnapshot, listTaskRunHistory, resolveLegacyTask, } from "../observability/read-model.js";
|
|
11
|
+
import { loadDagRunExecutionTrajectory } from "../observability/dag-execution-trajectory.js";
|
|
12
|
+
import { resolveDagTaskSourcePath } from "../../task/dag-source-paths.js";
|
|
13
|
+
import { dagSourceBindingSchema } from "../../workflows/dag/types.js";
|
|
14
|
+
import { getTaskPoolRoot } from "../pool/run-store.js";
|
|
15
|
+
import { isAllowedArtifactTextPath, resolveArtifactPath, resolveRepoFilePreview, toRepoRelativeArtifactPath, } from "./paths.js";
|
|
16
|
+
import { extractSpecEvidence, extractSpecReadContent, } from "./spec-evidence.js";
|
|
17
|
+
import { buildDagNodeInput } from "./node-input.js";
|
|
18
|
+
import { loadDagNodeExecutionOutput } from "./dag-node-execution-output.js";
|
|
19
|
+
import { buildObserveHealthV1 } from "./health.js";
|
|
20
|
+
import { buildNightJobDetail, buildNightJobsDoctor, buildNightJobsList, buildNightJobsMorning, } from "./night-jobs.js";
|
|
21
|
+
const ARTIFACT_PREVIEW_MAX_BYTES = 64 * 1024;
|
|
22
|
+
export function createObserveSnapshotCache() {
|
|
23
|
+
return { expiresAt: 0 };
|
|
24
|
+
}
|
|
25
|
+
export function defaultObserveStaticDir(fromFileUrl = import.meta.url) {
|
|
26
|
+
return path.join(path.dirname(fileURLToPath(fromFileUrl)), "static");
|
|
27
|
+
}
|
|
28
|
+
export function createObserveRouteContext(repoRoot, options = {}) {
|
|
29
|
+
return {
|
|
30
|
+
repoRoot: path.resolve(repoRoot),
|
|
31
|
+
pollIntervalMs: options.pollIntervalMs ?? 1000,
|
|
32
|
+
staticDir: options.staticDir ?? defaultObserveStaticDir(),
|
|
33
|
+
snapshotCache: options.snapshotCache ?? createObserveSnapshotCache(),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export const ROUTES = [
|
|
37
|
+
{ method: "GET", pattern: /^\/api\/health$/, handler: handleHealth },
|
|
38
|
+
{ method: "GET", pattern: /^\/api\/snapshot$/, handler: handleSnapshot },
|
|
39
|
+
{ method: "GET", pattern: /^\/api\/batches$/, handler: handleBatches },
|
|
40
|
+
{
|
|
41
|
+
method: "GET",
|
|
42
|
+
pattern: /^\/api\/batches\/([^/]+)\/events$/,
|
|
43
|
+
handler: handleBatchEvents,
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
method: "GET",
|
|
47
|
+
pattern: /^\/api\/batches\/([^/]+)$/,
|
|
48
|
+
handler: handleBatchById,
|
|
49
|
+
},
|
|
50
|
+
/**
|
|
51
|
+
* Pool bounded event history (cursor/limit). Distinct from SSE `/api/events/stream`
|
|
52
|
+
* and from run/session `?after=<line-offset>` integer offsets.
|
|
53
|
+
*/
|
|
54
|
+
{ method: "GET", pattern: /^\/api\/events$/, handler: handlePoolEvents },
|
|
55
|
+
{ method: "GET", pattern: /^\/api\/tasks$/, handler: handleTasks },
|
|
56
|
+
// Canonical feature-scoped task routes (must precede legacy /api/tasks/:id).
|
|
57
|
+
{
|
|
58
|
+
method: "GET",
|
|
59
|
+
pattern: /^\/api\/features\/([^/]+)\/tasks\/([^/]+)\/runs$/,
|
|
60
|
+
handler: handleFeatureTaskRuns,
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
method: "GET",
|
|
64
|
+
pattern: /^\/api\/features\/([^/]+)\/tasks\/([^/]+)$/,
|
|
65
|
+
handler: handleFeatureTaskById,
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
method: "GET",
|
|
69
|
+
pattern: /^\/api\/tasks\/([^/]+)\/runs$/,
|
|
70
|
+
handler: handleTaskRuns,
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
method: "GET",
|
|
74
|
+
pattern: /^\/api\/tasks\/([^/]+)$/,
|
|
75
|
+
handler: handleTaskById,
|
|
76
|
+
},
|
|
77
|
+
{ method: "GET", pattern: /^\/api\/runs\/([^/]+)$/, handler: handleRunById },
|
|
78
|
+
{
|
|
79
|
+
method: "GET",
|
|
80
|
+
pattern: /^\/api\/runs\/([^/]+)\/events$/,
|
|
81
|
+
handler: handleRunEvents,
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
method: "GET",
|
|
85
|
+
pattern: /^\/api\/runs\/([^/]+)\/artifacts$/,
|
|
86
|
+
handler: handleRunArtifacts,
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
method: "GET",
|
|
90
|
+
pattern: /^\/api\/dag-runs\/([^/]+)\/nodes\/([^/]+)\/session-events$/,
|
|
91
|
+
handler: handleDagNodeSessionEvents,
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
method: "GET",
|
|
95
|
+
pattern: /^\/api\/dag-runs\/([^/]+)\/nodes\/([^/]+)\/input$/,
|
|
96
|
+
handler: handleDagNodeInput,
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
method: "GET",
|
|
100
|
+
pattern: /^\/api\/dag-runs\/([^/]+)\/nodes\/([^/]+)\/execution-output$/,
|
|
101
|
+
handler: handleDagNodeExecutionOutput,
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
method: "GET",
|
|
105
|
+
pattern: /^\/api\/dag-runs\/([^/]+)\/nodes\/([^/]+)\/spec-evidence$/,
|
|
106
|
+
handler: handleDagNodeSpecEvidence,
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
method: "GET",
|
|
110
|
+
pattern: /^\/api\/dag-runs\/([^/]+)\/nodes\/([^/]+)\/spec-evidence\/file$/,
|
|
111
|
+
handler: handleDagNodeSpecEvidenceFile,
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
method: "GET",
|
|
115
|
+
pattern: /^\/api\/dag-runs\/([^/]+)$/,
|
|
116
|
+
handler: handleDagRunById,
|
|
117
|
+
},
|
|
118
|
+
// List route must be registered after /api/dag-runs/:id so detail keeps priority;
|
|
119
|
+
// matchObserveGetRoute scans in order and this path has no capture group.
|
|
120
|
+
{
|
|
121
|
+
method: "GET",
|
|
122
|
+
pattern: /^\/api\/dag-runs$/,
|
|
123
|
+
handler: handleDagRuns,
|
|
124
|
+
},
|
|
125
|
+
{ method: "GET", pattern: /^\/api\/artifacts$/, handler: handleArtifactRead },
|
|
126
|
+
{
|
|
127
|
+
method: "GET",
|
|
128
|
+
pattern: /^\/api\/events\/stream$/,
|
|
129
|
+
handler: handleEventStream,
|
|
130
|
+
},
|
|
131
|
+
// Night Scheduler Inspect (Phase 5) — read-only projections over scheduler facts.
|
|
132
|
+
{ method: "GET", pattern: /^\/api\/night-jobs$/, handler: handleNightJobs },
|
|
133
|
+
{
|
|
134
|
+
method: "GET",
|
|
135
|
+
pattern: /^\/api\/night-jobs\/morning$/,
|
|
136
|
+
handler: handleNightJobsMorning,
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
method: "GET",
|
|
140
|
+
pattern: /^\/api\/night-jobs\/doctor$/,
|
|
141
|
+
handler: handleNightJobsDoctor,
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
method: "GET",
|
|
145
|
+
pattern: /^\/api\/night-jobs\/([^/]+)$/,
|
|
146
|
+
handler: handleNightJobById,
|
|
147
|
+
},
|
|
148
|
+
];
|
|
149
|
+
export function matchObserveGetRoute(pathname) {
|
|
150
|
+
for (const route of ROUTES) {
|
|
151
|
+
if (route.method !== "GET")
|
|
152
|
+
continue;
|
|
153
|
+
const match = route.pattern.exec(pathname);
|
|
154
|
+
if (!match)
|
|
155
|
+
continue;
|
|
156
|
+
const params = {};
|
|
157
|
+
if (match[1])
|
|
158
|
+
params.id = match[1];
|
|
159
|
+
if (match[2])
|
|
160
|
+
params.sub = match[2];
|
|
161
|
+
return { params, query: new URLSearchParams(), handler: route.handler };
|
|
162
|
+
}
|
|
163
|
+
return null;
|
|
164
|
+
}
|
|
165
|
+
export async function handleMatchedObserveRoute(req, res, match, ctx) {
|
|
166
|
+
try {
|
|
167
|
+
const url = new URL(req.url ?? "/", "http://localhost");
|
|
168
|
+
await match.handler(req, res, { ...match, query: url.searchParams }, ctx);
|
|
169
|
+
}
|
|
170
|
+
catch (error) {
|
|
171
|
+
if (!res.headersSent) {
|
|
172
|
+
sendJson(res, 500, {
|
|
173
|
+
error: error instanceof Error ? error.message : String(error),
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
export async function handleRequest(req, res, ctx) {
|
|
179
|
+
const method = req.method ?? "GET";
|
|
180
|
+
const url = new URL(req.url ?? "/", "http://localhost");
|
|
181
|
+
const pathname = decodeURIComponent(url.pathname);
|
|
182
|
+
if (method !== "GET") {
|
|
183
|
+
sendJson(res, 405, { error: "Method not allowed" });
|
|
184
|
+
return true;
|
|
185
|
+
}
|
|
186
|
+
const match = matchObserveGetRoute(pathname);
|
|
187
|
+
if (match) {
|
|
188
|
+
await handleMatchedObserveRoute(req, res, match, ctx);
|
|
189
|
+
return true;
|
|
190
|
+
}
|
|
191
|
+
if (pathname.startsWith("/api/")) {
|
|
192
|
+
sendJson(res, 404, { error: "Not found" });
|
|
193
|
+
return true;
|
|
194
|
+
}
|
|
195
|
+
return false;
|
|
196
|
+
}
|
|
197
|
+
export async function serveStatic(req, res, staticDir) {
|
|
198
|
+
await serveObserveStatic(req, res, staticDir);
|
|
199
|
+
}
|
|
200
|
+
export async function serveObserveStatic(req, res, staticDir, options = {}) {
|
|
201
|
+
const url = new URL(req.url ?? "/", "http://localhost");
|
|
202
|
+
let pathname = decodeURIComponent(url.pathname);
|
|
203
|
+
const urlPrefix = options.urlPrefix?.replace(/\/$/, "");
|
|
204
|
+
const withinPrefix = Boolean(urlPrefix) &&
|
|
205
|
+
(pathname === urlPrefix || pathname.startsWith(`${urlPrefix}/`));
|
|
206
|
+
if (urlPrefix && withinPrefix) {
|
|
207
|
+
pathname = pathname.slice(urlPrefix.length) || "/";
|
|
208
|
+
}
|
|
209
|
+
if (pathname === "/") {
|
|
210
|
+
pathname = "/index.html";
|
|
211
|
+
}
|
|
212
|
+
const filePath = path.join(staticDir, pathname);
|
|
213
|
+
const resolvedStatic = path.resolve(staticDir);
|
|
214
|
+
const resolvedFile = path.resolve(filePath);
|
|
215
|
+
if (!resolvedFile.startsWith(resolvedStatic + path.sep) &&
|
|
216
|
+
resolvedFile !== resolvedStatic) {
|
|
217
|
+
sendJson(res, 404, { error: "Not found" });
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
if (!existsSync(resolvedFile)) {
|
|
221
|
+
sendJson(res, 404, { error: "Not found" });
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
const content = await readFile(resolvedFile);
|
|
225
|
+
const contentType = contentTypeFor(pathname);
|
|
226
|
+
res.writeHead(200, {
|
|
227
|
+
"Content-Type": contentType,
|
|
228
|
+
"Content-Length": content.byteLength,
|
|
229
|
+
"X-Content-Type-Options": "nosniff",
|
|
230
|
+
"X-Frame-Options": "SAMEORIGIN",
|
|
231
|
+
});
|
|
232
|
+
res.end(content);
|
|
233
|
+
}
|
|
234
|
+
async function handleHealth(_req, res, _match, ctx) {
|
|
235
|
+
sendJson(res, 200, buildObserveHealthV1({
|
|
236
|
+
repoRoot: ctx.repoRoot,
|
|
237
|
+
routes: ROUTES,
|
|
238
|
+
}));
|
|
239
|
+
}
|
|
240
|
+
async function getSnapshot(ctx) {
|
|
241
|
+
const now = Date.now();
|
|
242
|
+
if (ctx.snapshotCache.snapshot && now < ctx.snapshotCache.expiresAt) {
|
|
243
|
+
return ctx.snapshotCache.snapshot;
|
|
244
|
+
}
|
|
245
|
+
if (ctx.snapshotCache.inFlight) {
|
|
246
|
+
return ctx.snapshotCache.inFlight;
|
|
247
|
+
}
|
|
248
|
+
const inFlight = buildGlobalSnapshot({ repoRoot: ctx.repoRoot });
|
|
249
|
+
ctx.snapshotCache.inFlight = inFlight;
|
|
250
|
+
try {
|
|
251
|
+
const snapshot = await inFlight;
|
|
252
|
+
ctx.snapshotCache.snapshot = snapshot;
|
|
253
|
+
ctx.snapshotCache.expiresAt = Date.now() + ctx.pollIntervalMs;
|
|
254
|
+
return snapshot;
|
|
255
|
+
}
|
|
256
|
+
finally {
|
|
257
|
+
if (ctx.snapshotCache.inFlight === inFlight) {
|
|
258
|
+
ctx.snapshotCache.inFlight = undefined;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
async function handleSnapshot(_req, res, _match, ctx) {
|
|
263
|
+
const snapshot = await getSnapshot(ctx);
|
|
264
|
+
sendJson(res, 200, snapshot);
|
|
265
|
+
}
|
|
266
|
+
async function handleNightJobs(_req, res, _match, ctx) {
|
|
267
|
+
const body = await buildNightJobsList(ctx.repoRoot);
|
|
268
|
+
sendJson(res, 200, body);
|
|
269
|
+
}
|
|
270
|
+
async function handleNightJobsMorning(_req, res, match, ctx) {
|
|
271
|
+
const date = match.query.get("date") ?? undefined;
|
|
272
|
+
const timezone = match.query.get("timezone") ?? match.query.get("tz") ?? undefined;
|
|
273
|
+
const body = await buildNightJobsMorning(ctx.repoRoot, {
|
|
274
|
+
...(date ? { date } : {}),
|
|
275
|
+
...(timezone ? { timezone } : {}),
|
|
276
|
+
});
|
|
277
|
+
sendJson(res, 200, body);
|
|
278
|
+
}
|
|
279
|
+
async function handleNightJobsDoctor(_req, res, _match, ctx) {
|
|
280
|
+
const body = await buildNightJobsDoctor(ctx.repoRoot);
|
|
281
|
+
sendJson(res, 200, body);
|
|
282
|
+
}
|
|
283
|
+
async function handleNightJobById(_req, res, match, ctx) {
|
|
284
|
+
const scheduleId = match.params.id;
|
|
285
|
+
if (!scheduleId) {
|
|
286
|
+
sendJson(res, 400, { error: "schedule id required" });
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
const body = await buildNightJobDetail(ctx.repoRoot, scheduleId);
|
|
290
|
+
if (!body) {
|
|
291
|
+
sendJson(res, 404, { error: "Night schedule not found" });
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
sendJson(res, 200, body);
|
|
295
|
+
}
|
|
296
|
+
async function handleBatches(_req, res, _match, ctx) {
|
|
297
|
+
const snapshot = await getSnapshot(ctx);
|
|
298
|
+
sendJson(res, 200, snapshot.batches);
|
|
299
|
+
}
|
|
300
|
+
async function handleBatchById(_req, res, match, ctx) {
|
|
301
|
+
const snapshot = await getSnapshot(ctx);
|
|
302
|
+
const batch = snapshot.batches.find((b) => b.batchRunId === match.params.id);
|
|
303
|
+
if (!batch) {
|
|
304
|
+
sendJson(res, 404, { error: "Batch not found" });
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
sendJson(res, 200, batch);
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Bounded batch event history. Query: `limit` (default 50, max 200), `cursor`
|
|
311
|
+
* (opaque history cursor). Not the same as run/SSE `after` line offsets.
|
|
312
|
+
*/
|
|
313
|
+
async function handleBatchEvents(_req, res, match, ctx) {
|
|
314
|
+
const batchRunId = match.params.id;
|
|
315
|
+
if (!isSafeObservabilityIdentifier(batchRunId)) {
|
|
316
|
+
sendJson(res, 404, { error: "Batch not found" });
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
const limit = clampEventHistoryLimit(parsePositiveInt(match.query.get("limit"), NaN));
|
|
320
|
+
const cursor = match.query.get("cursor") ?? undefined;
|
|
321
|
+
const page = await listBatchEventHistory(ctx.repoRoot, batchRunId, {
|
|
322
|
+
limit,
|
|
323
|
+
cursor,
|
|
324
|
+
});
|
|
325
|
+
sendJson(res, 200, page);
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Bounded pool-wide event history. Path is `/api/events` (JSON page), not
|
|
329
|
+
* `/api/events/stream` (SSE). Uses `cursor`/`limit`, not integer `after`.
|
|
330
|
+
*/
|
|
331
|
+
async function handlePoolEvents(_req, res, match, ctx) {
|
|
332
|
+
const limit = clampEventHistoryLimit(parsePositiveInt(match.query.get("limit"), NaN));
|
|
333
|
+
const cursor = match.query.get("cursor") ?? undefined;
|
|
334
|
+
const page = await listPoolEventHistory(ctx.repoRoot, { limit, cursor });
|
|
335
|
+
sendJson(res, 200, page);
|
|
336
|
+
}
|
|
337
|
+
async function handleTasks(_req, res, _match, ctx) {
|
|
338
|
+
const snapshot = await getSnapshot(ctx);
|
|
339
|
+
sendJson(res, 200, snapshot.tasks);
|
|
340
|
+
}
|
|
341
|
+
async function handleFeatureTaskById(_req, res, match, ctx) {
|
|
342
|
+
const resolved = resolveFeatureTaskParams(match);
|
|
343
|
+
if (!resolved) {
|
|
344
|
+
sendJson(res, 400, { error: "Invalid task identifier" });
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
if (!isSafeObservabilityIdentifier(resolved.featureId) ||
|
|
348
|
+
!isSafeObservabilityIdentifier(resolved.taskId)) {
|
|
349
|
+
sendJson(res, 400, { error: "Invalid task identifier" });
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
const snapshot = await getSnapshot(ctx);
|
|
353
|
+
const task = snapshot.tasks.find((t) => t.featureId === resolved.featureId && t.taskId === resolved.taskId);
|
|
354
|
+
if (!task) {
|
|
355
|
+
sendJson(res, 404, { error: "Task not found" });
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
sendJson(res, 200, task);
|
|
359
|
+
}
|
|
360
|
+
async function handleFeatureTaskRuns(_req, res, match, ctx) {
|
|
361
|
+
const resolved = resolveFeatureTaskParams(match);
|
|
362
|
+
if (!resolved) {
|
|
363
|
+
sendJson(res, 400, { error: "Invalid task identifier" });
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
366
|
+
if (!isSafeObservabilityIdentifier(resolved.featureId) ||
|
|
367
|
+
!isSafeObservabilityIdentifier(resolved.taskId)) {
|
|
368
|
+
sendJson(res, 400, { error: "Invalid task identifier" });
|
|
369
|
+
return;
|
|
370
|
+
}
|
|
371
|
+
const limit = clampTaskRunHistoryLimit(parsePositiveInt(match.query.get("limit"), 0) || undefined);
|
|
372
|
+
const before = match.query.get("before");
|
|
373
|
+
const page = await listTaskRunHistory(ctx.repoRoot, resolved.featureId, resolved.taskId, {
|
|
374
|
+
limit,
|
|
375
|
+
before: before && before.length > 0 ? before : null,
|
|
376
|
+
});
|
|
377
|
+
// 404 only when neither snapshot row nor ledger history exists for this composite id.
|
|
378
|
+
if (page.runs.length === 0) {
|
|
379
|
+
const snapshot = await getSnapshot(ctx);
|
|
380
|
+
const known = snapshot.tasks.some((t) => t.featureId === resolved.featureId && t.taskId === resolved.taskId);
|
|
381
|
+
if (!known) {
|
|
382
|
+
sendJson(res, 404, { error: "Task not found" });
|
|
383
|
+
return;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
sendJson(res, 200, page);
|
|
387
|
+
}
|
|
388
|
+
async function handleTaskById(_req, res, match, ctx) {
|
|
389
|
+
const taskId = match.params.id;
|
|
390
|
+
if (!isSafeObservabilityIdentifier(taskId)) {
|
|
391
|
+
sendJson(res, 400, { error: "Invalid task identifier" });
|
|
392
|
+
return;
|
|
393
|
+
}
|
|
394
|
+
const snapshot = await getSnapshot(ctx);
|
|
395
|
+
const resolved = resolveLegacyTask(snapshot.tasks, taskId);
|
|
396
|
+
if (resolved.kind === "missing") {
|
|
397
|
+
sendJson(res, 404, { error: "Task not found" });
|
|
398
|
+
return;
|
|
399
|
+
}
|
|
400
|
+
if (resolved.kind === "ambiguous") {
|
|
401
|
+
sendJson(res, 409, ambiguousTaskBody(taskId, resolved.candidates));
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
404
|
+
sendJson(res, 200, resolved.task);
|
|
405
|
+
}
|
|
406
|
+
async function handleTaskRuns(_req, res, match, ctx) {
|
|
407
|
+
const taskId = match.params.id;
|
|
408
|
+
if (!isSafeObservabilityIdentifier(taskId)) {
|
|
409
|
+
sendJson(res, 400, { error: "Invalid task identifier" });
|
|
410
|
+
return;
|
|
411
|
+
}
|
|
412
|
+
const snapshot = await getSnapshot(ctx);
|
|
413
|
+
const resolved = resolveLegacyTask(snapshot.tasks, taskId);
|
|
414
|
+
if (resolved.kind === "ambiguous") {
|
|
415
|
+
sendJson(res, 409, ambiguousTaskBody(taskId, resolved.candidates));
|
|
416
|
+
return;
|
|
417
|
+
}
|
|
418
|
+
if (resolved.kind === "missing") {
|
|
419
|
+
// No snapshot row: do not guess featureId for history.
|
|
420
|
+
sendJson(res, 404, { error: "Task not found" });
|
|
421
|
+
return;
|
|
422
|
+
}
|
|
423
|
+
const featureId = resolved.task.featureId;
|
|
424
|
+
if (!featureId) {
|
|
425
|
+
sendJson(res, 404, { error: "Task not found" });
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
428
|
+
const limit = clampTaskRunHistoryLimit(parsePositiveInt(match.query.get("limit"), 0) || undefined);
|
|
429
|
+
const before = match.query.get("before");
|
|
430
|
+
const page = await listTaskRunHistory(ctx.repoRoot, featureId, taskId, {
|
|
431
|
+
limit,
|
|
432
|
+
before: before && before.length > 0 ? before : null,
|
|
433
|
+
});
|
|
434
|
+
sendJson(res, 200, page);
|
|
435
|
+
}
|
|
436
|
+
function ambiguousTaskBody(taskId, candidates) {
|
|
437
|
+
return {
|
|
438
|
+
error: "Task identity ambiguous",
|
|
439
|
+
taskId,
|
|
440
|
+
candidates,
|
|
441
|
+
};
|
|
442
|
+
}
|
|
443
|
+
/** Extract featureId/taskId from /api/features/:featureId/tasks/:taskId[...]. */
|
|
444
|
+
function resolveFeatureTaskParams(match) {
|
|
445
|
+
// handleRequest maps capture groups to params.id (group 1) and params.sub (group 2).
|
|
446
|
+
const featureId = match.params.featureId ?? match.params.id;
|
|
447
|
+
const taskId = match.params.taskId ?? match.params.sub;
|
|
448
|
+
if (!featureId || !taskId)
|
|
449
|
+
return null;
|
|
450
|
+
return { featureId, taskId };
|
|
451
|
+
}
|
|
452
|
+
async function handleRunById(_req, res, match, ctx) {
|
|
453
|
+
if (!isSafeObservabilityIdentifier(match.params.id)) {
|
|
454
|
+
sendJson(res, 400, { error: "Invalid run identifier" });
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
const snapshot = await getSnapshot(ctx);
|
|
458
|
+
const task = findRunByWorkerRunId(snapshot.tasks, snapshot.batches, match.params.id);
|
|
459
|
+
if (!task) {
|
|
460
|
+
sendJson(res, 404, { error: "Run not found" });
|
|
461
|
+
return;
|
|
462
|
+
}
|
|
463
|
+
sendJson(res, 200, task);
|
|
464
|
+
}
|
|
465
|
+
async function handleRunEvents(_req, res, match, ctx) {
|
|
466
|
+
const workerRunId = match.params.id;
|
|
467
|
+
if (!isSafeObservabilityIdentifier(workerRunId)) {
|
|
468
|
+
sendJson(res, 400, { error: "Invalid run identifier" });
|
|
469
|
+
return;
|
|
470
|
+
}
|
|
471
|
+
const after = parseNonNegativeInt(match.query.get("after"), 0);
|
|
472
|
+
const eventsPath = path.join(getTaskPoolRoot(ctx.repoRoot), "observability", "runs", workerRunId, "events.jsonl");
|
|
473
|
+
const events = (await readJsonlLines(eventsPath, after)).map((event) => normalizeEventArtifactRefs(ctx.repoRoot, event));
|
|
474
|
+
sendJson(res, 200, { events });
|
|
475
|
+
}
|
|
476
|
+
async function handleRunArtifacts(_req, res, match, ctx) {
|
|
477
|
+
const workerRunId = match.params.id;
|
|
478
|
+
if (!isSafeObservabilityIdentifier(workerRunId)) {
|
|
479
|
+
sendJson(res, 400, { error: "Invalid run identifier" });
|
|
480
|
+
return;
|
|
481
|
+
}
|
|
482
|
+
const snapshot = await getSnapshot(ctx);
|
|
483
|
+
const task = findRunByWorkerRunId(snapshot.tasks, snapshot.batches, workerRunId);
|
|
484
|
+
const artifacts = [];
|
|
485
|
+
const seen = new Set();
|
|
486
|
+
if (task?.artifactRefs) {
|
|
487
|
+
for (const [label, artifactPath] of Object.entries(task.artifactRefs)) {
|
|
488
|
+
if (!artifactPath || seen.has(artifactPath))
|
|
489
|
+
continue;
|
|
490
|
+
seen.add(artifactPath);
|
|
491
|
+
artifacts.push({ path: artifactPath, label });
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
const eventsPath = path.join(getTaskPoolRoot(ctx.repoRoot), "observability", "runs", workerRunId, "events.jsonl");
|
|
495
|
+
const runEvents = await readJsonlLines(eventsPath, 0);
|
|
496
|
+
for (const event of runEvents) {
|
|
497
|
+
const parsed = event;
|
|
498
|
+
if (parsed.workerRunId && parsed.workerRunId !== workerRunId)
|
|
499
|
+
continue;
|
|
500
|
+
if (!parsed.artifactRefs)
|
|
501
|
+
continue;
|
|
502
|
+
for (const [label, artifactPath] of Object.entries(parsed.artifactRefs)) {
|
|
503
|
+
const relativePath = toRepoRelativeArtifactPath(ctx.repoRoot, artifactPath);
|
|
504
|
+
if (!relativePath || seen.has(relativePath))
|
|
505
|
+
continue;
|
|
506
|
+
seen.add(relativePath);
|
|
507
|
+
artifacts.push({ path: relativePath, label });
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
sendJson(res, 200, { artifacts });
|
|
511
|
+
}
|
|
512
|
+
/**
|
|
513
|
+
* GET /api/dag-runs?page=&pageSize=
|
|
514
|
+
* Lightweight formal DAG history page (schemaVersion 1).
|
|
515
|
+
*/
|
|
516
|
+
async function handleDagRuns(_req, res, match, ctx) {
|
|
517
|
+
const snapshot = await getSnapshot(ctx);
|
|
518
|
+
const page = parsePositiveInt(match.query.get("page"), 1);
|
|
519
|
+
const pageSize = clampDagRunHistoryPageSize(parsePositiveInt(match.query.get("pageSize"), 0) || undefined);
|
|
520
|
+
const body = listDagRunHistoryFromSnapshot(snapshot, { page, pageSize });
|
|
521
|
+
sendJson(res, 200, body);
|
|
522
|
+
}
|
|
523
|
+
export async function handleDagRunById(_req, res, match, ctx) {
|
|
524
|
+
const snapshot = await getSnapshot(ctx);
|
|
525
|
+
const dagRun = snapshot.dagRuns.find((d) => d.dagRunId === match.params.id);
|
|
526
|
+
if (!dagRun) {
|
|
527
|
+
sendJson(res, 404, { error: "DAG run not found" });
|
|
528
|
+
return;
|
|
529
|
+
}
|
|
530
|
+
const payload = { ...dagRun };
|
|
531
|
+
// P1 契约:在 detail 响应中内嵌有界 executionTrajectory(不新增端点、
|
|
532
|
+
// 不接收客户端 artifact path)。仅当存在真实执行证据/警告/投影异常时附加;
|
|
533
|
+
// legacy 或纯事件 run 省略该字段,前端据此显示「本次运行没有可展开的执行轨迹」。
|
|
534
|
+
const trajectory = await loadDagRunExecutionTrajectory(ctx.repoRoot, dagRun.dagRunId);
|
|
535
|
+
if (trajectory &&
|
|
536
|
+
(trajectory.occurrences.length > 0 ||
|
|
537
|
+
trajectory.projectionError === true ||
|
|
538
|
+
trajectory.warnings.length > 0)) {
|
|
539
|
+
payload.executionTrajectory = trajectory;
|
|
540
|
+
}
|
|
541
|
+
sendJson(res, 200, payload);
|
|
542
|
+
}
|
|
543
|
+
async function handleDagNodeInput(_req, res, match, ctx) {
|
|
544
|
+
const dagRunId = match.params.id;
|
|
545
|
+
const nodeId = match.params.sub;
|
|
546
|
+
if (!isSafeObservabilityIdentifier(dagRunId) ||
|
|
547
|
+
!isSafeObservabilityIdentifier(nodeId)) {
|
|
548
|
+
sendJson(res, 400, { error: "Invalid dag run or node identifier" });
|
|
549
|
+
return;
|
|
550
|
+
}
|
|
551
|
+
const result = await buildDagNodeInput(ctx.repoRoot, dagRunId, nodeId);
|
|
552
|
+
sendJson(res, result.status, result.body);
|
|
553
|
+
}
|
|
554
|
+
/**
|
|
555
|
+
* Read-only execution body by attempt-N / pass-N key only.
|
|
556
|
+
* Clients must never submit artifact paths; server maps key → run-dir segments.
|
|
557
|
+
*/
|
|
558
|
+
async function handleDagNodeExecutionOutput(_req, res, match, ctx) {
|
|
559
|
+
const dagRunId = match.params.id;
|
|
560
|
+
const nodeId = match.params.sub;
|
|
561
|
+
const key = match.query.get("key");
|
|
562
|
+
// Reject path-shaped inputs even if smuggled via key/query aliases.
|
|
563
|
+
if (match.query.has("path") || match.query.has("artifactPath")) {
|
|
564
|
+
sendJson(res, 400, {
|
|
565
|
+
error: "Artifact path is not accepted; use key=attempt-N|pass-N",
|
|
566
|
+
reason: "path-not-allowed",
|
|
567
|
+
});
|
|
568
|
+
return;
|
|
569
|
+
}
|
|
570
|
+
const result = await loadDagNodeExecutionOutput(ctx.repoRoot, dagRunId, nodeId, key);
|
|
571
|
+
sendJson(res, result.status, result.body);
|
|
572
|
+
}
|
|
573
|
+
async function handleDagNodeSessionEvents(_req, res, match, ctx) {
|
|
574
|
+
const dagRunId = match.params.id;
|
|
575
|
+
const nodeId = match.params.sub;
|
|
576
|
+
if (!isSafeObservabilityIdentifier(dagRunId) ||
|
|
577
|
+
!isSafeObservabilityIdentifier(nodeId)) {
|
|
578
|
+
sendJson(res, 400, { error: "Invalid dag run or node identifier" });
|
|
579
|
+
return;
|
|
580
|
+
}
|
|
581
|
+
const after = parseNonNegativeInt(match.query.get("after"), 0);
|
|
582
|
+
const snapshot = await getSnapshot(ctx);
|
|
583
|
+
const dagRun = snapshot.dagRuns.find((d) => d.dagRunId === dagRunId);
|
|
584
|
+
const eventsPath = resolveSessionEventsPath(ctx.repoRoot, dagRunId, nodeId, dagRun?.dagPath);
|
|
585
|
+
if (!eventsPath) {
|
|
586
|
+
sendJson(res, 400, { error: "Invalid session events path" });
|
|
587
|
+
return;
|
|
588
|
+
}
|
|
589
|
+
if (!existsSync(eventsPath)) {
|
|
590
|
+
sendJson(res, 200, { events: [], nextOffset: 0 });
|
|
591
|
+
return;
|
|
592
|
+
}
|
|
593
|
+
const page = await readJsonlPage(eventsPath, after);
|
|
594
|
+
sendJson(res, 200, page);
|
|
595
|
+
}
|
|
596
|
+
async function handleArtifactRead(_req, res, match, ctx) {
|
|
597
|
+
const relativePath = match.query.get("path") ?? "";
|
|
598
|
+
const resolved = resolveArtifactPath(ctx.repoRoot, relativePath);
|
|
599
|
+
if (!resolved || !isAllowedArtifactTextPath(relativePath)) {
|
|
600
|
+
sendJson(res, 400, { error: "Invalid artifact path" });
|
|
601
|
+
return;
|
|
602
|
+
}
|
|
603
|
+
if (!existsSync(resolved)) {
|
|
604
|
+
sendJson(res, 404, { error: "Artifact not found" });
|
|
605
|
+
return;
|
|
606
|
+
}
|
|
607
|
+
const artifactStat = await stat(resolved);
|
|
608
|
+
if (!artifactStat.isFile()) {
|
|
609
|
+
sendJson(res, 400, { error: "Artifact is not a readable text file" });
|
|
610
|
+
return;
|
|
611
|
+
}
|
|
612
|
+
const sourceBytes = artifactStat.size;
|
|
613
|
+
const start = Math.max(0, sourceBytes - ARTIFACT_PREVIEW_MAX_BYTES);
|
|
614
|
+
const length = Math.min(sourceBytes, ARTIFACT_PREVIEW_MAX_BYTES);
|
|
615
|
+
const buffer = Buffer.alloc(length);
|
|
616
|
+
const handle = await openFile(resolved, "r");
|
|
617
|
+
let bytesRead = 0;
|
|
618
|
+
try {
|
|
619
|
+
({ bytesRead } = await handle.read(buffer, 0, length, start));
|
|
620
|
+
}
|
|
621
|
+
finally {
|
|
622
|
+
await handle.close();
|
|
623
|
+
}
|
|
624
|
+
let raw = buffer.subarray(0, bytesRead).toString("utf-8");
|
|
625
|
+
let truncated = start > 0;
|
|
626
|
+
if (truncated) {
|
|
627
|
+
const firstCompleteLine = raw.indexOf("\n");
|
|
628
|
+
raw = firstCompleteLine >= 0 ? raw.slice(firstCompleteLine + 1) : "";
|
|
629
|
+
}
|
|
630
|
+
const tail = match.query.get("tail");
|
|
631
|
+
if (tail !== null) {
|
|
632
|
+
const tailLines = parsePositiveInt(tail, 0);
|
|
633
|
+
if (tailLines > 0) {
|
|
634
|
+
const lines = raw.replace(/\n$/, "").split("\n");
|
|
635
|
+
truncated = truncated || lines.length > tailLines;
|
|
636
|
+
raw = lines.slice(-tailLines).join("\n");
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
const redacted = redactSecrets(raw);
|
|
640
|
+
const content = truncateUtf8Preview(redacted, ARTIFACT_PREVIEW_MAX_BYTES);
|
|
641
|
+
truncated = truncated || content !== redacted;
|
|
642
|
+
sendJson(res, 200, {
|
|
643
|
+
content,
|
|
644
|
+
truncated,
|
|
645
|
+
sourceBytes,
|
|
646
|
+
maxBytes: ARTIFACT_PREVIEW_MAX_BYTES,
|
|
647
|
+
});
|
|
648
|
+
}
|
|
649
|
+
async function handleEventStream(req, res, match, ctx) {
|
|
650
|
+
const batchRunId = match.query.get("batchRunId");
|
|
651
|
+
if (!batchRunId) {
|
|
652
|
+
sendJson(res, 400, { error: "batchRunId is required" });
|
|
653
|
+
return;
|
|
654
|
+
}
|
|
655
|
+
res.writeHead(200, {
|
|
656
|
+
"Content-Type": "text/event-stream",
|
|
657
|
+
"Cache-Control": "no-cache, no-transform",
|
|
658
|
+
Connection: "keep-alive",
|
|
659
|
+
// Disable proxy buffering (nginx) so heartbeats reach the client.
|
|
660
|
+
"X-Accel-Buffering": "no",
|
|
661
|
+
});
|
|
662
|
+
// Flush headers immediately for proxies that wait on first body byte.
|
|
663
|
+
if (typeof res.flushHeaders === "function") {
|
|
664
|
+
res.flushHeaders();
|
|
665
|
+
}
|
|
666
|
+
const observabilityRoot = path.join(getTaskPoolRoot(ctx.repoRoot), "observability");
|
|
667
|
+
const eventsPath = path.join(observabilityRoot, "events.jsonl");
|
|
668
|
+
let offset = 0;
|
|
669
|
+
let knownFileSize;
|
|
670
|
+
let timer;
|
|
671
|
+
let closed = false;
|
|
672
|
+
let lastHeartbeatAt = 0;
|
|
673
|
+
const heartbeatEveryMs = Math.max(15_000, ctx.pollIntervalMs * 10);
|
|
674
|
+
const writeHeartbeat = () => {
|
|
675
|
+
if (closed || res.writableEnded)
|
|
676
|
+
return;
|
|
677
|
+
const now = Date.now();
|
|
678
|
+
if (now - lastHeartbeatAt < heartbeatEveryMs)
|
|
679
|
+
return;
|
|
680
|
+
lastHeartbeatAt = now;
|
|
681
|
+
res.write(`: keepalive ${new Date(now).toISOString()}\n\n`);
|
|
682
|
+
};
|
|
683
|
+
const sendMatchingEvents = async (initial) => {
|
|
684
|
+
writeHeartbeat();
|
|
685
|
+
let currentFileSize;
|
|
686
|
+
try {
|
|
687
|
+
currentFileSize = (await stat(eventsPath)).size;
|
|
688
|
+
}
|
|
689
|
+
catch {
|
|
690
|
+
knownFileSize = undefined;
|
|
691
|
+
offset = 0;
|
|
692
|
+
return;
|
|
693
|
+
}
|
|
694
|
+
if (!shouldReadSseEventFile(knownFileSize, currentFileSize))
|
|
695
|
+
return;
|
|
696
|
+
if (knownFileSize !== undefined && currentFileSize < knownFileSize) {
|
|
697
|
+
offset = 0;
|
|
698
|
+
}
|
|
699
|
+
const page = await readFilteredEvents(eventsPath, offset, batchRunId, ctx.repoRoot);
|
|
700
|
+
if (!page.ok)
|
|
701
|
+
return;
|
|
702
|
+
offset = page.nextOffset;
|
|
703
|
+
knownFileSize = currentFileSize;
|
|
704
|
+
for (const event of page.events) {
|
|
705
|
+
if (initial || !res.writableEnded) {
|
|
706
|
+
res.write(`data: ${JSON.stringify(event)}\n\n`);
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
};
|
|
710
|
+
await sendMatchingEvents(true);
|
|
711
|
+
const scheduleNextPoll = () => {
|
|
712
|
+
if (closed)
|
|
713
|
+
return;
|
|
714
|
+
timer = setTimeout(() => {
|
|
715
|
+
timer = undefined;
|
|
716
|
+
void sendMatchingEvents(false)
|
|
717
|
+
.then(scheduleNextPoll)
|
|
718
|
+
.catch(() => {
|
|
719
|
+
closed = true;
|
|
720
|
+
if (!res.writableEnded)
|
|
721
|
+
res.end();
|
|
722
|
+
});
|
|
723
|
+
}, ctx.pollIntervalMs);
|
|
724
|
+
};
|
|
725
|
+
scheduleNextPoll();
|
|
726
|
+
req.on("close", () => {
|
|
727
|
+
closed = true;
|
|
728
|
+
if (timer)
|
|
729
|
+
clearTimeout(timer);
|
|
730
|
+
if (!res.writableEnded)
|
|
731
|
+
res.end();
|
|
732
|
+
});
|
|
733
|
+
}
|
|
734
|
+
function findRunByWorkerRunId(tasks, batches, workerRunId) {
|
|
735
|
+
return (tasks.find((task) => task.workerRunId === workerRunId) ??
|
|
736
|
+
batches
|
|
737
|
+
.flatMap((batch) => batch.tasks)
|
|
738
|
+
.find((task) => task.workerRunId === workerRunId));
|
|
739
|
+
}
|
|
740
|
+
async function readJsonlLines(filePath, after) {
|
|
741
|
+
const page = await readJsonlPage(filePath, after);
|
|
742
|
+
return page.events;
|
|
743
|
+
}
|
|
744
|
+
async function readJsonlPage(filePath, after) {
|
|
745
|
+
try {
|
|
746
|
+
const raw = await readFile(filePath, "utf-8");
|
|
747
|
+
const lines = raw
|
|
748
|
+
.split("\n")
|
|
749
|
+
.map((line) => line.trim())
|
|
750
|
+
.filter(Boolean);
|
|
751
|
+
const events = lines
|
|
752
|
+
.slice(after)
|
|
753
|
+
.map((line) => {
|
|
754
|
+
try {
|
|
755
|
+
return JSON.parse(line);
|
|
756
|
+
}
|
|
757
|
+
catch {
|
|
758
|
+
return undefined;
|
|
759
|
+
}
|
|
760
|
+
})
|
|
761
|
+
.filter((line) => line !== undefined);
|
|
762
|
+
return { events, nextOffset: lines.length };
|
|
763
|
+
}
|
|
764
|
+
catch {
|
|
765
|
+
return { events: [], nextOffset: after };
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
const DAG_RUN_LIFECYCLE_DIRS = ["active", "completed", "paused"];
|
|
769
|
+
function resolveSessionEventsPath(repoRoot, dagRunId, nodeId, dagRunDir) {
|
|
770
|
+
if (!isSafeObservabilityIdentifier(dagRunId) ||
|
|
771
|
+
!isSafeObservabilityIdentifier(nodeId)) {
|
|
772
|
+
return null;
|
|
773
|
+
}
|
|
774
|
+
const dagRunsRoot = path.resolve(repoRoot, ".harness", "dag-runs");
|
|
775
|
+
const candidates = [];
|
|
776
|
+
if (dagRunDir) {
|
|
777
|
+
candidates.push(path.join(dagRunDir, nodeId, "session-events.jsonl"));
|
|
778
|
+
}
|
|
779
|
+
for (const lifecycle of DAG_RUN_LIFECYCLE_DIRS) {
|
|
780
|
+
candidates.push(path.join(dagRunsRoot, lifecycle, dagRunId, nodeId, "session-events.jsonl"));
|
|
781
|
+
}
|
|
782
|
+
for (const candidate of candidates) {
|
|
783
|
+
const resolved = path.resolve(candidate);
|
|
784
|
+
if (!isPathInside(dagRunsRoot, resolved))
|
|
785
|
+
continue;
|
|
786
|
+
if (!isExpectedSessionEventsRelativePath(dagRunsRoot, resolved, dagRunId, nodeId)) {
|
|
787
|
+
continue;
|
|
788
|
+
}
|
|
789
|
+
if (existsSync(resolved))
|
|
790
|
+
return resolved;
|
|
791
|
+
}
|
|
792
|
+
const fallback = path.resolve(dagRunsRoot, "active", dagRunId, nodeId, "session-events.jsonl");
|
|
793
|
+
if (isPathInside(dagRunsRoot, fallback) &&
|
|
794
|
+
isExpectedSessionEventsRelativePath(dagRunsRoot, fallback, dagRunId, nodeId)) {
|
|
795
|
+
return fallback;
|
|
796
|
+
}
|
|
797
|
+
return null;
|
|
798
|
+
}
|
|
799
|
+
function isExpectedSessionEventsRelativePath(dagRunsRoot, resolvedPath, dagRunId, nodeId) {
|
|
800
|
+
const relative = path.relative(dagRunsRoot, resolvedPath);
|
|
801
|
+
const parts = relative.split(path.sep).filter(Boolean);
|
|
802
|
+
return (parts.length === 4 &&
|
|
803
|
+
DAG_RUN_LIFECYCLE_DIRS.includes(parts[0]) &&
|
|
804
|
+
parts[1] === dagRunId &&
|
|
805
|
+
parts[2] === nodeId &&
|
|
806
|
+
parts[3] === "session-events.jsonl");
|
|
807
|
+
}
|
|
808
|
+
function isPathInside(root, target) {
|
|
809
|
+
const normalizedRoot = root.endsWith(path.sep) ? root : `${root}${path.sep}`;
|
|
810
|
+
const normalizedTarget = path.normalize(target);
|
|
811
|
+
return (normalizedTarget === root || normalizedTarget.startsWith(normalizedRoot));
|
|
812
|
+
}
|
|
813
|
+
async function readFilteredEvents(filePath, offset, batchRunId, repoRoot) {
|
|
814
|
+
try {
|
|
815
|
+
const raw = await readFile(filePath, "utf-8");
|
|
816
|
+
const lines = raw
|
|
817
|
+
.split("\n")
|
|
818
|
+
.map((line) => line.trim())
|
|
819
|
+
.filter(Boolean);
|
|
820
|
+
const events = [];
|
|
821
|
+
for (let i = offset; i < lines.length; i++) {
|
|
822
|
+
const event = parseWorkerEventLine(lines[i]);
|
|
823
|
+
if (event && event.batchRunId === batchRunId) {
|
|
824
|
+
events.push(normalizeEventArtifactRefs(repoRoot, event));
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
return { events, nextOffset: lines.length, ok: true };
|
|
828
|
+
}
|
|
829
|
+
catch {
|
|
830
|
+
return { events: [], nextOffset: offset, ok: false };
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
export function shouldReadSseEventFile(previousSize, currentSize) {
|
|
834
|
+
return previousSize !== currentSize;
|
|
835
|
+
}
|
|
836
|
+
function normalizeEventArtifactRefs(repoRoot, value) {
|
|
837
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
838
|
+
return value;
|
|
839
|
+
const event = value;
|
|
840
|
+
if (!event.artifactRefs)
|
|
841
|
+
return event;
|
|
842
|
+
const artifactRefs = {};
|
|
843
|
+
for (const [key, artifactPath] of Object.entries(event.artifactRefs)) {
|
|
844
|
+
const relativePath = toRepoRelativeArtifactPath(repoRoot, artifactPath);
|
|
845
|
+
if (relativePath)
|
|
846
|
+
artifactRefs[key] = relativePath;
|
|
847
|
+
}
|
|
848
|
+
return {
|
|
849
|
+
...event,
|
|
850
|
+
artifactRefs,
|
|
851
|
+
};
|
|
852
|
+
}
|
|
853
|
+
function parseNonNegativeInt(value, fallback) {
|
|
854
|
+
if (value === null)
|
|
855
|
+
return fallback;
|
|
856
|
+
const parsed = Number.parseInt(value, 10);
|
|
857
|
+
return Number.isFinite(parsed) && parsed >= 0 ? parsed : fallback;
|
|
858
|
+
}
|
|
859
|
+
function parsePositiveInt(value, fallback) {
|
|
860
|
+
if (value === null)
|
|
861
|
+
return fallback;
|
|
862
|
+
const parsed = Number.parseInt(value, 10);
|
|
863
|
+
return Number.isFinite(parsed) && parsed > 0 ? parsed : fallback;
|
|
864
|
+
}
|
|
865
|
+
function sendJson(res, status, body) {
|
|
866
|
+
const payload = JSON.stringify(body);
|
|
867
|
+
res.writeHead(status, {
|
|
868
|
+
"Content-Type": "application/json",
|
|
869
|
+
"Content-Length": Buffer.byteLength(payload),
|
|
870
|
+
});
|
|
871
|
+
res.end(payload);
|
|
872
|
+
}
|
|
873
|
+
async function loadDagRunSourceBinding(repoRoot, dagRunId) {
|
|
874
|
+
const dagRunsRoot = path.resolve(repoRoot, ".harness", "dag-runs");
|
|
875
|
+
for (const lifecycle of ["active", "completed", "paused"]) {
|
|
876
|
+
const runJsonPath = path.join(dagRunsRoot, lifecycle, dagRunId, "run.json");
|
|
877
|
+
try {
|
|
878
|
+
const runRaw = await readFile(runJsonPath, "utf-8");
|
|
879
|
+
const runSpec = JSON.parse(runRaw);
|
|
880
|
+
const parsed = dagSourceBindingSchema.safeParse(runSpec.sourceBinding);
|
|
881
|
+
if (parsed.success)
|
|
882
|
+
return parsed.data;
|
|
883
|
+
return undefined;
|
|
884
|
+
}
|
|
885
|
+
catch {
|
|
886
|
+
// run.json may not exist; continue to next lifecycle
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
return undefined;
|
|
890
|
+
}
|
|
891
|
+
/**
|
|
892
|
+
* Read-only spec-evidence file preview (AC-001..AC-005). Re-validates evidence
|
|
893
|
+
* membership server-side: binding paths must be in sourceBinding.sources, read
|
|
894
|
+
* paths must have a successful paired read in session events. Enforces AC-003
|
|
895
|
+
* path safety and AC-004 truncation + redaction.
|
|
896
|
+
*/
|
|
897
|
+
async function handleDagNodeSpecEvidenceFile(_req, res, match, ctx) {
|
|
898
|
+
const dagRunId = match.params.id;
|
|
899
|
+
const nodeId = match.params.sub;
|
|
900
|
+
if (!isSafeObservabilityIdentifier(dagRunId) ||
|
|
901
|
+
!isSafeObservabilityIdentifier(nodeId)) {
|
|
902
|
+
sendJson(res, 400, { error: "Invalid dag run or node identifier" });
|
|
903
|
+
return;
|
|
904
|
+
}
|
|
905
|
+
const source = match.query.get("source");
|
|
906
|
+
const rawPath = match.query.get("path");
|
|
907
|
+
if (source !== "binding" && source !== "read") {
|
|
908
|
+
sendJson(res, 400, { error: "Invalid source" });
|
|
909
|
+
return;
|
|
910
|
+
}
|
|
911
|
+
if (!rawPath) {
|
|
912
|
+
sendJson(res, 400, { error: "path is required" });
|
|
913
|
+
return;
|
|
914
|
+
}
|
|
915
|
+
const maxBytes = ARTIFACT_PREVIEW_MAX_BYTES;
|
|
916
|
+
if (source === "binding") {
|
|
917
|
+
const sourceBinding = await loadDagRunSourceBinding(ctx.repoRoot, dagRunId);
|
|
918
|
+
const member = sourceBinding?.sources?.find((s) => s.path === rawPath);
|
|
919
|
+
if (!sourceBinding || !member) {
|
|
920
|
+
sendJson(res, 404, { error: "Path is not a bound source" });
|
|
921
|
+
return;
|
|
922
|
+
}
|
|
923
|
+
if (!isSafeObservabilityIdentifier(sourceBinding.taskId)) {
|
|
924
|
+
sendJson(res, 400, { error: "Invalid or unsafe path" });
|
|
925
|
+
return;
|
|
926
|
+
}
|
|
927
|
+
let resolved;
|
|
928
|
+
try {
|
|
929
|
+
const sourcePath = resolveDagTaskSourcePath({
|
|
930
|
+
workspaceRoot: ctx.repoRoot,
|
|
931
|
+
taskId: sourceBinding.taskId,
|
|
932
|
+
sourcePath: member.path,
|
|
933
|
+
});
|
|
934
|
+
const repoRelativePath = path.relative(ctx.repoRoot, sourcePath);
|
|
935
|
+
resolved = await resolveRepoFilePreview(ctx.repoRoot, repoRelativePath);
|
|
936
|
+
}
|
|
937
|
+
catch {
|
|
938
|
+
sendJson(res, 400, { error: "Invalid or unsafe path" });
|
|
939
|
+
return;
|
|
940
|
+
}
|
|
941
|
+
let raw;
|
|
942
|
+
try {
|
|
943
|
+
raw = await readFile(resolved.absPath, "utf-8");
|
|
944
|
+
}
|
|
945
|
+
catch {
|
|
946
|
+
sendJson(res, 404, { error: "File not found" });
|
|
947
|
+
return;
|
|
948
|
+
}
|
|
949
|
+
const redacted = redactSecrets(raw);
|
|
950
|
+
const content = truncateUtf8Preview(redacted, maxBytes);
|
|
951
|
+
const truncated = content !== redacted;
|
|
952
|
+
const currentSha256 = createHash("sha256")
|
|
953
|
+
.update(raw, "utf-8")
|
|
954
|
+
.digest("hex");
|
|
955
|
+
sendJson(res, 200, {
|
|
956
|
+
source: "binding",
|
|
957
|
+
path: rawPath,
|
|
958
|
+
sha256: member.sha256,
|
|
959
|
+
currentSha256,
|
|
960
|
+
hashMatch: currentSha256 === member.sha256,
|
|
961
|
+
content,
|
|
962
|
+
truncated,
|
|
963
|
+
contentBytes: Buffer.byteLength(content, "utf-8"),
|
|
964
|
+
maxBytes,
|
|
965
|
+
});
|
|
966
|
+
return;
|
|
967
|
+
}
|
|
968
|
+
// source === "read"
|
|
969
|
+
const record = await extractSpecReadContent(ctx.repoRoot, dagRunId, nodeId, rawPath);
|
|
970
|
+
if (!record) {
|
|
971
|
+
sendJson(res, 404, { error: "Path was not successfully read" });
|
|
972
|
+
return;
|
|
973
|
+
}
|
|
974
|
+
const redacted = redactSecrets(record.content);
|
|
975
|
+
const content = truncateUtf8Preview(redacted, maxBytes);
|
|
976
|
+
const truncated = content !== redacted;
|
|
977
|
+
sendJson(res, 200, {
|
|
978
|
+
source: "read",
|
|
979
|
+
path: rawPath,
|
|
980
|
+
content,
|
|
981
|
+
truncated,
|
|
982
|
+
contentBytes: Buffer.byteLength(content, "utf-8"),
|
|
983
|
+
maxBytes,
|
|
984
|
+
readAt: record.timestamp ?? null,
|
|
985
|
+
});
|
|
986
|
+
}
|
|
987
|
+
async function handleDagNodeSpecEvidence(_req, res, match, ctx) {
|
|
988
|
+
const dagRunId = match.params.id;
|
|
989
|
+
const nodeId = match.params.sub;
|
|
990
|
+
if (!isSafeObservabilityIdentifier(dagRunId) ||
|
|
991
|
+
!isSafeObservabilityIdentifier(nodeId)) {
|
|
992
|
+
sendJson(res, 400, { error: "Invalid dag run or node identifier" });
|
|
993
|
+
return;
|
|
994
|
+
}
|
|
995
|
+
// Extract skill injection info from the DAG run spec (run.json)
|
|
996
|
+
const skillInjection = {
|
|
997
|
+
skills: [],
|
|
998
|
+
references: [],
|
|
999
|
+
};
|
|
1000
|
+
const sourceBinding = await loadDagRunSourceBinding(ctx.repoRoot, dagRunId);
|
|
1001
|
+
{
|
|
1002
|
+
const dagRunsRoot = path.resolve(ctx.repoRoot, ".harness", "dag-runs");
|
|
1003
|
+
for (const lifecycle of ["active", "completed", "paused"]) {
|
|
1004
|
+
const runJsonPath = path.join(dagRunsRoot, lifecycle, dagRunId, "run.json");
|
|
1005
|
+
try {
|
|
1006
|
+
const runRaw = await readFile(runJsonPath, "utf-8");
|
|
1007
|
+
const runSpec = JSON.parse(runRaw);
|
|
1008
|
+
const task = runSpec.tasks?.find((t) => t.id === nodeId);
|
|
1009
|
+
if (task?.skills && Array.isArray(task.skills)) {
|
|
1010
|
+
skillInjection.skills = task.skills;
|
|
1011
|
+
}
|
|
1012
|
+
break;
|
|
1013
|
+
}
|
|
1014
|
+
catch {
|
|
1015
|
+
// run.json may not exist; continue to next lifecycle
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
const evidence = await extractSpecEvidence(ctx.repoRoot, dagRunId, nodeId);
|
|
1020
|
+
if (!evidence) {
|
|
1021
|
+
const hasSourceBinding = Boolean(sourceBinding);
|
|
1022
|
+
sendJson(res, 200, {
|
|
1023
|
+
dagRunId,
|
|
1024
|
+
nodeId,
|
|
1025
|
+
status: hasSourceBinding ? "source-bound" : "no-evidence",
|
|
1026
|
+
skillInjection,
|
|
1027
|
+
sourceBinding,
|
|
1028
|
+
specReads: [],
|
|
1029
|
+
specSearches: [],
|
|
1030
|
+
knowledgeBaseQueries: [],
|
|
1031
|
+
summary: hasSourceBinding
|
|
1032
|
+
? `已绑定 ${sourceBinding.sources.length} 个任务源文件和 ${sourceBinding.requirementIds.length} 个显式需求编号;未观察到 read 工具调用。`
|
|
1033
|
+
: "未找到该节点的 session events 记录。",
|
|
1034
|
+
});
|
|
1035
|
+
return;
|
|
1036
|
+
}
|
|
1037
|
+
evidence.skillInjection = skillInjection;
|
|
1038
|
+
evidence.sourceBinding = sourceBinding;
|
|
1039
|
+
// Recompute status considering skill injection
|
|
1040
|
+
if (evidence.specReads.length === 0 &&
|
|
1041
|
+
evidence.knowledgeBaseQueries.length === 0) {
|
|
1042
|
+
if (evidence.specSearches.length > 0) {
|
|
1043
|
+
evidence.status = "search-only";
|
|
1044
|
+
}
|
|
1045
|
+
else if (sourceBinding) {
|
|
1046
|
+
evidence.status = "source-bound";
|
|
1047
|
+
evidence.summary = `已绑定 ${sourceBinding.sources.length} 个任务源文件和 ${sourceBinding.requirementIds.length} 个显式需求编号;未观察到 read 工具调用。`;
|
|
1048
|
+
}
|
|
1049
|
+
else if (skillInjection.skills.length > 0) {
|
|
1050
|
+
evidence.status = "spec-injected";
|
|
1051
|
+
evidence.summary =
|
|
1052
|
+
"规范 skill 已注入但未观察到规范文件读取或知识库查询。";
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
sendJson(res, 200, evidence);
|
|
1056
|
+
}
|
|
1057
|
+
function contentTypeFor(pathname) {
|
|
1058
|
+
const lower = pathname.toLowerCase();
|
|
1059
|
+
if (lower.endsWith(".html"))
|
|
1060
|
+
return "text/html; charset=utf-8";
|
|
1061
|
+
if (lower.endsWith(".js") || lower.endsWith(".mjs")) {
|
|
1062
|
+
return "text/javascript; charset=utf-8";
|
|
1063
|
+
}
|
|
1064
|
+
if (lower.endsWith(".css"))
|
|
1065
|
+
return "text/css; charset=utf-8";
|
|
1066
|
+
if (lower.endsWith(".json"))
|
|
1067
|
+
return "application/json; charset=utf-8";
|
|
1068
|
+
if (lower.endsWith(".svg"))
|
|
1069
|
+
return "image/svg+xml";
|
|
1070
|
+
if (lower.endsWith(".png"))
|
|
1071
|
+
return "image/png";
|
|
1072
|
+
if (lower.endsWith(".ico"))
|
|
1073
|
+
return "image/x-icon";
|
|
1074
|
+
if (lower.endsWith(".woff2"))
|
|
1075
|
+
return "font/woff2";
|
|
1076
|
+
return "application/octet-stream";
|
|
1077
|
+
}
|