@tea-agent/loop-agent 0.1.0-fe-test.5 → 0.1.0-fe-test.6
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 +1 -1
- package/CHANGELOG.md +441 -2525
- package/README.md +19 -12
- package/dist/adapters/loop-agent.js +34 -0
- package/dist/application/dag/args.js +8 -0
- package/dist/application/dag/run-dag.js +5 -0
- package/dist/application/evaluation/budget.js +40 -1
- package/dist/application/evaluation/corpus-hash.js +10 -15
- package/dist/application/evaluation/corpus.js +2 -1
- package/dist/application/evaluation/frontend-browser-acceptance.js +77 -0
- package/dist/application/evaluation/frontend-corpus-browser-acceptance.js +175 -0
- package/dist/application/evaluation/frontend-gateway-evidence.js +226 -0
- package/dist/application/evaluation/frontend-pair-registration.js +143 -0
- package/dist/application/evaluation/frontend-paired-summary.js +150 -0
- package/dist/application/evaluation/frontend-run-observation.js +144 -0
- package/dist/application/evaluation/frontend-shared-evidence.js +105 -0
- package/dist/application/evaluation/types.js +45 -12
- package/dist/application/task-lifecycle/advance.js +64 -15
- package/dist/application/task-lifecycle/observe.js +69 -30
- package/dist/application/task-lifecycle/plan-transitions.js +5 -4
- package/dist/build-stamp.json +3 -3
- package/dist/cli/command-definitions.js +18 -5
- package/dist/cli/program.js +8 -5
- package/dist/cli/update/init-surface-notifier.js +2 -0
- package/dist/cli/update/policy.js +2 -0
- package/dist/commands/client-recovery.js +20 -55
- package/dist/commands/cursor-prompt.js +2 -0
- package/dist/commands/dag-approve.js +2 -0
- package/dist/commands/dag-final-verification.js +2 -0
- package/dist/commands/dag-init-hybrid.js +2 -0
- package/dist/commands/dag-reconcile-tasks.js +2 -0
- package/dist/commands/dag-reject.js +2 -0
- package/dist/commands/dag-report.js +2 -0
- package/dist/commands/dag-rerun.js +2 -0
- package/dist/commands/dag-resume.js +2 -0
- package/dist/commands/dag-workflow-compile.js +2 -0
- package/dist/commands/dag-workflow-plan.js +2 -0
- package/dist/commands/dag-workflow-validate.js +2 -0
- package/dist/commands/delegate.js +2 -0
- package/dist/commands/examples.js +2 -0
- package/dist/commands/import-prd.js +2 -0
- package/dist/commands/init-legacy-audit.js +330 -0
- package/dist/commands/init-model-catalog.js +2 -0
- package/dist/commands/init-upgrade.js +644 -104
- package/dist/commands/init.js +700 -338
- package/dist/commands/instructions.js +2 -0
- package/dist/commands/knowledge.js +2 -0
- package/dist/commands/loop-benchmark.js +2 -0
- package/dist/commands/operator-guide.js +99 -0
- package/dist/commands/operator.js +16 -3
- package/dist/commands/pi-prompt.js +2 -0
- package/dist/commands/pi-reuse-benchmark.js +2 -0
- package/dist/commands/promote-run.js +2 -0
- package/dist/commands/stats.js +1 -1
- package/dist/commands/study-init.js +2 -0
- package/dist/commands/task-advance.js +32 -0
- package/dist/commands/task-source-prepare.js +18 -2
- package/dist/commands/worktree-create.js +2 -0
- package/dist/commands/worktree-remove.js +2 -0
- package/dist/executors/dag-pi/guards.js +4 -0
- package/dist/executors/dag-pi/model-config.js +30 -0
- package/dist/executors/dag-pi/plan/fact-adoption.js +55 -0
- package/dist/executors/dag-pi/plan/facts.js +180 -0
- package/dist/executors/dag-pi/plan/finalize-tools.js +259 -0
- package/dist/executors/dag-pi/plan/ledger-contract.js +55 -0
- package/dist/executors/dag-pi/plan/record-tools.js +861 -0
- package/dist/executors/dag-pi/plan/schema.js +129 -0
- package/dist/executors/dag-pi/plan/tool-helpers.js +16 -0
- package/dist/executors/dag-pi/sessions/index.js +6 -0
- package/dist/executors/dag-pi/sessions/plan-batches.js +280 -0
- package/dist/executors/dag-pi/sessions/plan-prompts.js +367 -0
- package/dist/executors/dag-pi/sessions/scout-parallel.js +197 -0
- package/dist/executors/dag-pi/sessions/segmented-plan.js +1184 -0
- package/dist/executors/dag-pi/sessions/writer-evidence.js +60 -0
- package/dist/executors/dag-pi/tools/contract-tools.js +515 -0
- package/dist/executors/dag-pi/tools/design-terminal-tools.js +159 -0
- package/dist/executors/dag-pi/tools/plan-decision-tools.js +529 -0
- package/dist/executors/dag-pi/tools/review-terminal-tools.js +159 -0
- package/dist/executors/dag-pi/tools/scout-evidence-tools.js +270 -0
- package/dist/executors/dag-pi-executor.js +1516 -3181
- package/dist/executors/pi-executor.js +112 -4
- package/dist/executors/pi-sdk-executor.js +258 -44
- package/dist/executors/pi-writer-tool-policy.js +60 -4
- package/dist/executors/playwright-cli-launcher.js +31 -45
- package/dist/executors/shell-executor.js +313 -48
- package/dist/executors/shell-presets.js +1 -1
- package/dist/executors/shell-verification.js +3 -0
- package/dist/executors/shell-write-guard.js +77 -102
- package/dist/governance/exec-plans.js +16 -4
- package/dist/governance/harness.js +2 -7
- package/dist/governance/manifest-types.js +28 -9
- package/dist/governance/project-capability-scanner.js +263 -0
- package/dist/governance/project-config.js +96 -0
- package/dist/governance/resource-catalog.js +151 -0
- package/dist/infrastructure/console/app-data.js +12 -2
- package/dist/infrastructure/console/operation-store.js +48 -14
- package/dist/infrastructure/evaluation/corpus-store.js +37 -12
- package/dist/shared/artifacts-core.js +2 -0
- package/dist/shared/backend-dogfood-preflight.js +47 -0
- package/dist/shared/dag-failure-category.js +9 -0
- package/dist/shared/file-identity.js +23 -0
- package/dist/shared/frontend-execution-policy.js +23 -0
- package/dist/shared/git-progress.js +2 -0
- package/dist/shared/git-workspace-status.js +482 -0
- package/dist/shared/one-shot-prompt-args.js +2 -0
- package/dist/shared/operator/capabilities.js +185 -0
- package/dist/shared/package-metadata.js +29 -11
- package/dist/shared/path-safety.js +2 -2
- package/dist/shared/pi-context-pressure/extension.js +49 -16
- package/dist/shared/pi-context-pressure/index.js +1 -0
- package/dist/shared/pi-context-pressure/sift-bridge.js +1 -1
- package/dist/shared/pi-context-pressure/telemetry.js +4 -0
- package/dist/shared/pi-context-pressure/tool-result-pruner.js +98 -0
- package/dist/shared/pi-provider-recovery.js +182 -0
- package/dist/shared/pi-retry-settings.js +40 -0
- package/dist/shared/reference-context.js +2 -0
- package/dist/shared/update/npm-client.js +49 -1
- package/dist/shared/wizard-local-telemetry.js +51 -0
- package/dist/task/config-types.js +51 -2
- package/dist/task/contract/apply.js +36 -2
- package/dist/task/contract/project.js +22 -0
- package/dist/task/contract/recover.js +6 -0
- package/dist/task/contract/schema.js +12 -0
- package/dist/task/frontend-preflight.js +1 -1
- package/dist/task/source-prepare/artifact-meta.js +9 -2
- package/dist/task/source-prepare/build-draft.js +61 -0
- package/dist/task/source-prepare/fragment-inventory.js +4 -1
- package/dist/task/source-prepare/ledger-reconciliation.js +2 -2
- package/dist/task/source-prepare/ledger-review.js +6 -9
- package/dist/task/source-prepare/parse-intent.js +165 -14
- package/dist/task/source-prepare/path-policy.js +17 -7
- package/dist/task/source-prepare/prepare.js +6 -1
- package/dist/task/source-prepare/semantic-intake.js +33 -28
- package/dist/task/source-prepare/source-execution.js +65 -0
- package/dist/task/source-prepare/source-fidelity-pi.js +49 -17
- package/dist/task/source-prepare/source-provider-budget.js +290 -0
- package/dist/task/source-references.js +48 -23
- package/dist/task/task-demand-routing.js +5 -2
- package/dist/worker/cli.js +3 -5
- package/dist/worker/console/chat/assistant-content.js +5 -13
- package/dist/worker/console/chat/browser-automation.js +937 -0
- package/dist/worker/console/chat/browser-content.js +74 -0
- package/dist/worker/console/chat/browser-diagnostics.js +250 -0
- package/dist/worker/console/chat/browser-evaluation.js +58 -0
- package/dist/worker/console/chat/browser-operation-queue.js +19 -0
- package/dist/worker/console/chat/browser-pick.js +113 -0
- package/dist/worker/console/chat/browser-policy.js +113 -0
- package/dist/worker/console/chat/browser-routes.js +329 -0
- package/dist/worker/console/chat/browser-screenshot-result.js +47 -0
- package/dist/worker/console/chat/browser-storage.js +89 -0
- package/dist/worker/console/chat/chat-event-store.js +73 -18
- package/dist/worker/console/chat/context-insights.js +788 -0
- package/dist/worker/console/chat/conversation-nodes.js +383 -0
- package/dist/worker/console/chat/db-connections.js +854 -0
- package/dist/worker/console/chat/explore-tools.js +18 -2
- package/dist/worker/console/chat/pet/pet-affinity.js +169 -0
- package/dist/worker/console/chat/pet/pet-persist.js +109 -0
- package/dist/worker/console/chat/pet/pet-registry.js +142 -0
- package/dist/worker/console/chat/pet/pet-remarks.js +48 -0
- package/dist/worker/console/chat/pet/pet-routes.js +125 -0
- package/dist/worker/console/chat/pet/pet-service.js +262 -0
- package/dist/worker/console/chat/pet/pet-state.js +99 -0
- package/dist/worker/console/chat/pi-mode-loop-isolation.js +170 -0
- package/dist/worker/console/chat/pi-runtime/custom-tools/ask-user-question.js +44 -0
- package/dist/worker/console/chat/pi-runtime/custom-tools/browser-tools.js +135 -0
- package/dist/worker/console/chat/pi-runtime/custom-tools/explore-tools.js +202 -0
- package/dist/worker/console/chat/pi-runtime/custom-tools/goal-tools.js +79 -0
- package/dist/worker/console/chat/pi-runtime/custom-tools/operator-tools.js +94 -0
- package/dist/worker/console/chat/pi-runtime/custom-tools/scheduled-goal-tools.js +22 -0
- package/dist/worker/console/chat/pi-runtime/custom-tools/sql-tools.js +670 -0
- package/dist/worker/console/chat/pi-runtime/custom-tools/todo-write.js +38 -0
- package/dist/worker/console/chat/pi-runtime/inspection-types.js +28 -0
- package/dist/worker/console/chat/pi-runtime/inspection.js +439 -0
- package/dist/worker/console/chat/pi-runtime/progressive-tools.js +195 -0
- package/dist/worker/console/chat/pi-runtime/sdk-bindings.js +153 -0
- package/dist/worker/console/chat/pi-runtime/sdk-session.js +5 -0
- package/dist/worker/console/chat/pi-runtime.js +793 -1230
- package/dist/worker/console/chat/provider-error.js +0 -12
- package/dist/worker/console/chat/repo-browser.js +132 -6
- package/dist/worker/console/chat/repo-preview-kind.js +155 -0
- package/dist/worker/console/chat/resource-loader.js +4 -1
- package/dist/worker/console/chat/routes.js +861 -148
- package/dist/worker/console/chat/scheduled-goal-booking.js +59 -0
- package/dist/worker/console/chat/scheduled-goal-delivery.js +27 -0
- package/dist/worker/console/chat/scheduled-goal-request.js +198 -0
- package/dist/worker/console/chat/scm-routes.js +217 -0
- package/dist/worker/console/chat/scm-service.js +283 -0
- package/dist/worker/console/chat/scm-tools.js +111 -0
- package/dist/worker/console/chat/sdd-data-alignment.js +85 -41
- package/dist/worker/console/chat/session-catalog.js +32 -0
- package/dist/worker/console/chat/session-mode-view.js +49 -0
- package/dist/worker/console/chat/session-mode.js +224 -0
- package/dist/worker/console/chat/session-store.js +232 -32
- package/dist/worker/console/chat/shortcuts.js +13 -0
- package/dist/worker/console/chat/subagents/agent-tool.js +62 -0
- package/dist/worker/console/chat/subagents/explore-agent.js +169 -0
- package/dist/worker/console/chat/subagents/index.js +5 -0
- package/dist/worker/console/chat/subagents/orchestrator.js +273 -0
- package/dist/worker/console/chat/subagents/tool-policy.js +53 -0
- package/dist/worker/console/chat/subagents/types.js +13 -0
- package/dist/worker/console/chat/terminal-routes.js +216 -0
- package/dist/worker/console/chat/terminal-sessions.js +348 -0
- package/dist/worker/console/chat/terminal-tools.js +211 -0
- package/dist/worker/console/chat/timeline-message-order.js +22 -0
- package/dist/worker/console/chat/tool-preview.js +136 -0
- package/dist/worker/console/chat/tools.js +69 -1
- package/dist/worker/console/chat/turn-order.js +13 -0
- package/dist/worker/console/chat/turn-process.js +210 -36
- package/dist/worker/console/chat/user-turn-outline.js +19 -0
- package/dist/worker/console/console-shutdown.js +34 -0
- package/dist/worker/console/console-update-and-init.js +1 -19
- package/dist/worker/console/console-update-runtime.js +7 -22
- package/dist/worker/console/dag-confirmation.js +3 -0
- package/dist/worker/console/dag-execution-receipt.js +3 -0
- package/dist/worker/console/interview/tools.js +1 -0
- package/dist/worker/console/operator-actions.js +95 -4
- package/dist/worker/console/operator-user-error.js +28 -1
- package/dist/worker/console/pi-readiness.js +4 -4
- package/dist/worker/console/prd-intake-bridge.js +47 -1
- package/dist/worker/console/recovery-cta.js +14 -14
- package/dist/worker/console/routes.js +13 -0
- package/dist/worker/console/scheduled-goal-host.js +98 -0
- package/dist/worker/console/scheduled-goal-operation-adapter.js +127 -0
- package/dist/worker/console/server.js +33 -31
- package/dist/worker/console/static/app-icon.svg +39 -0
- package/dist/worker/console/static/assets/{abnfDiagram-N423BO3Z-BZogYNl1.js → abnfDiagram-N423BO3Z-DASc69AM.js} +1 -1
- package/dist/worker/console/static/assets/{arc-DcJTLe2v.js → arc-h09p-LAc.js} +1 -1
- package/dist/worker/console/static/assets/{architectureDiagram-T3A2C74G-B39EQQ9n.js → architectureDiagram-T3A2C74G-CZ3dtLkh.js} +1 -1
- package/dist/worker/console/static/assets/{blockDiagram-VBNYF7ZC-CitCGV56.js → blockDiagram-VBNYF7ZC-DMrRhMXG.js} +1 -1
- package/dist/worker/console/static/assets/{c4Diagram-5PPSVZJV-rvWuOHLG.js → c4Diagram-5PPSVZJV-DQxisHV6.js} +1 -1
- package/dist/worker/console/static/assets/channel-D1zgKZfg.js +1 -0
- package/dist/worker/console/static/assets/{chunk-2GRJ4B5K-DGXplIJs.js → chunk-2GRJ4B5K-CefVN9zh.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-2Q5K7J3B-ur9OqjPn.js → chunk-2Q5K7J3B-DmR1Koq2.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-5RXB4S5H-D1KqU_Vi.js → chunk-5RXB4S5H-NlzrSW7L.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-5VM5RSS4-BlVZrbtM.js → chunk-5VM5RSS4-DfelJv-0.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-6Q2QTUOP-BAzz3nQy.js → chunk-6Q2QTUOP-BK6RFy58.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-GF5L2VYU-CP_nYuCV.js → chunk-GF5L2VYU-BAeh9lz4.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-JWPE2WC7-CWvKQ80X.js → chunk-JWPE2WC7-ChPS5WzG.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-KBJHAD2P-CyUki8wp.js → chunk-KBJHAD2P-BoVe5IM6.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-RYQCIY6F-5NYzNKfY.js → chunk-RYQCIY6F-C4q_0Lw9.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-XXDRQBXY-DHdUgjS-.js → chunk-XXDRQBXY-Bb9TvjeY.js} +1 -1
- package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-CXNNsY2M.js +1 -0
- package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-CXNNsY2M.js +1 -0
- package/dist/worker/console/static/assets/{cose-bilkent-JH36ORCC-ANQ5g_t6.js → cose-bilkent-JH36ORCC-DmNnL8Ff.js} +1 -1
- package/dist/worker/console/static/assets/{cynefin-VYW2F7L2-CruT_4-0.js → cynefin-VYW2F7L2-Contvx58.js} +1 -1
- package/dist/worker/console/static/assets/{cynefinDiagram-MW4NZA55-rbFo77ID.js → cynefinDiagram-MW4NZA55-Cigq7cjk.js} +1 -1
- package/dist/worker/console/static/assets/{dagre-VZM6K2ZE-asstxBQs.js → dagre-VZM6K2ZE-dEbC0nxb.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-7IWD3JNH-DzTyBZwI.js → diagram-7IWD3JNH-CzIztESV.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-B4RE2ZJO-gw8ccH3B.js → diagram-B4RE2ZJO-Bo14zbaY.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-LBJQPF4R-B8RpZzOf.js → diagram-LBJQPF4R-C4xUyil6.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-Q27KOJAE-B1zJkCS9.js → diagram-Q27KOJAE-CaBY_uYa.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-UB23O5K3-B6JLWZmO.js → diagram-UB23O5K3-ClUXUeiu.js} +1 -1
- package/dist/worker/console/static/assets/{ebnfDiagram-BXEA7PRR-q2iZP-Ps.js → ebnfDiagram-BXEA7PRR-BbGCgjC6.js} +1 -1
- package/dist/worker/console/static/assets/{erDiagram-JOGREHBK-B3dbbktQ.js → erDiagram-JOGREHBK-Dr-AcwSl.js} +1 -1
- package/dist/worker/console/static/assets/{flowDiagram-UKHOOZJN-C-zc6-kB.js → flowDiagram-UKHOOZJN-BG8Gcfyc.js} +1 -1
- package/dist/worker/console/static/assets/{ganttDiagram-PKOTCBZU-BSolnot9.js → ganttDiagram-PKOTCBZU-CFVaPs5r.js} +1 -1
- package/dist/worker/console/static/assets/{gitGraphDiagram-DS77QQ5N-Bo8jGxTk.js → gitGraphDiagram-DS77QQ5N-ChJ8pm-O.js} +1 -1
- package/dist/worker/console/static/assets/index-B_5GhVIO.js +488 -0
- package/dist/worker/console/static/assets/index-C7YMBluX.css +1 -0
- package/dist/worker/console/static/assets/{infoDiagram-6WML65LV-DQaZqJOH.js → infoDiagram-6WML65LV-C5J9-uCZ.js} +1 -1
- package/dist/worker/console/static/assets/{ishikawaDiagram-WSZJBQD7-DsdX1WnE.js → ishikawaDiagram-WSZJBQD7-BcfjqzDv.js} +1 -1
- package/dist/worker/console/static/assets/{journeyDiagram-NVQOT4AX-CP5EYDZL.js → journeyDiagram-NVQOT4AX-BzzCO-rD.js} +1 -1
- package/dist/worker/console/static/assets/{kanban-definition-27J2QSJJ-DAm14Dr8.js → kanban-definition-27J2QSJJ-NCHUZ46h.js} +1 -1
- package/dist/worker/console/static/assets/{linear-gZECoLc5.js → linear-BKZlWCUU.js} +1 -1
- package/dist/worker/console/static/assets/{mermaid.core-BRJNIM6p.js → mermaid.core-DbTaQjFE.js} +5 -5
- package/dist/worker/console/static/assets/{mindmap-definition-FAOFIHXS-Cja3kLkR.js → mindmap-definition-FAOFIHXS-CroYl5xQ.js} +1 -1
- package/dist/worker/console/static/assets/{pegDiagram-VL7TDLO6-22ZGFisL.js → pegDiagram-VL7TDLO6-DgMBx-9k.js} +1 -1
- package/dist/worker/console/static/assets/{pieDiagram-7S7Q4E2Y-BXin0Y1o.js → pieDiagram-7S7Q4E2Y-CyWDmbq1.js} +1 -1
- package/dist/worker/console/static/assets/{quadrantDiagram-CIZ2JOQS-Cw6T69Yt.js → quadrantDiagram-CIZ2JOQS-BgGEOqSP.js} +1 -1
- package/dist/worker/console/static/assets/{railroadDiagram-AXF67PYL-C1-gTieN.js → railroadDiagram-AXF67PYL-BMZ7oeeV.js} +1 -1
- package/dist/worker/console/static/assets/{requirementDiagram-LRYGKXZP--H5N2iI1.js → requirementDiagram-LRYGKXZP-DxqyGhcc.js} +1 -1
- package/dist/worker/console/static/assets/{sankeyDiagram-W5VNT64P-CgWAPeRz.js → sankeyDiagram-W5VNT64P-DnSvNCG8.js} +1 -1
- package/dist/worker/console/static/assets/{sequenceDiagram-SI44F4Z6-CrKqzGvt.js → sequenceDiagram-SI44F4Z6-BiZh6f-R.js} +1 -1
- package/dist/worker/console/static/assets/{sizeCapture-X5ZJPWSS-BB3wG06K.js → sizeCapture-X5ZJPWSS-BKXSI8WB.js} +1 -1
- package/dist/worker/console/static/assets/{stateDiagram-OKZ733FA-DjsGgdgY.js → stateDiagram-OKZ733FA-CfSgoYFm.js} +1 -1
- package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-DgHi3vjb.js +1 -0
- package/dist/worker/console/static/assets/{swimlanes-SLNWSIFB-DYKEbvAR.js → swimlanes-SLNWSIFB-CyGADcHe.js} +2 -2
- package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-Bgvdt1Y0.js +8 -0
- package/dist/worker/console/static/assets/{timeline-definition-Z64GVDOM-eQOb5k9Y.js → timeline-definition-Z64GVDOM-HmPaSPOK.js} +1 -1
- package/dist/worker/console/static/assets/{vennDiagram-T6HMQDX7-B2-l9FIu.js → vennDiagram-T6HMQDX7-VA2VBbez.js} +1 -1
- package/dist/worker/console/static/assets/{wardleyDiagram-T6FBY63Y-BX2Cda3l.js → wardleyDiagram-T6FBY63Y-BxjiBPZa.js} +1 -1
- package/dist/worker/console/static/assets/{xychartDiagram-ELKLHX3M-D9S892ph.js → xychartDiagram-ELKLHX3M--hUY-qFj.js} +1 -1
- package/dist/worker/console/static/index.html +5 -2
- package/dist/worker/console/static/manifest.webmanifest +19 -0
- package/dist/worker/console/static/pets/ember/pet.json +167 -0
- package/dist/worker/console/static/pets/ember/spritesheet.png +0 -0
- package/dist/worker/console/static-src/app/console-types.js +9 -1
- package/dist/worker/console/static-src/chat-view-types.js +1 -1
- package/dist/worker/console/static-src/operator-chat/active-turn-tail.js +10 -0
- package/dist/worker/console/static-src/operator-chat/animation-frame-batcher.js +38 -0
- package/dist/worker/console/static-src/operator-chat/chat-link.js +114 -0
- package/dist/worker/console/static-src/operator-chat/chat-scroll-position.js +24 -0
- package/dist/worker/console/static-src/operator-chat/chat-sse-events.js +360 -14
- package/dist/worker/console/static-src/operator-chat/chat-stream-continuity.js +101 -0
- package/dist/worker/console/static-src/operator-chat/compaction-message.js +10 -2
- package/dist/worker/console/static-src/operator-chat/composer-session-ledger.js +192 -0
- package/dist/worker/console/static-src/operator-chat/context-insights-store.js +64 -0
- package/dist/worker/console/static-src/operator-chat/details-rail-surfaces.js +99 -0
- package/dist/worker/console/static-src/operator-chat/file-palette-nav.js +81 -0
- package/dist/worker/console/static-src/operator-chat/open-preview-in-browser.js +57 -9
- package/dist/worker/console/static-src/operator-chat/pending-user-message.js +66 -0
- package/dist/worker/console/static-src/operator-chat/process-label.js +63 -0
- package/dist/worker/console/static-src/operator-chat/slash-palette-nav.js +15 -5
- package/dist/worker/console/static-src/operator-chat/timeline-merge.js +29 -0
- package/dist/worker/console/static-src/operator-chat/tools-catalog.js +36 -8
- package/dist/worker/console/static-src/operator-chat/transcript-mode.js +21 -0
- package/dist/worker/console/static-src/operator-chat/turn-group-equality.js +16 -0
- package/dist/worker/console/static-src/operator-chat/turn-process-disclosure.js +18 -0
- package/dist/worker/console/static-src/operator-chat/turn-state-projection.js +166 -0
- package/dist/worker/console/static-src/operator-chat/turn-stream-controller.js +58 -2
- package/dist/worker/console/static-src/operator-chat/use-searchable-hidden.js +51 -0
- package/dist/worker/console/static-src/operator-chat/use-stat-dialog.js +95 -0
- package/dist/worker/console/static-src/operator-chat/useChatSessions.js +338 -93
- package/dist/worker/console/static-src/operator-chat/useChatStream.js +310 -106
- package/dist/worker/console/static-src/operator-chat/useChatThread.js +179 -75
- package/dist/worker/console/static-src/operator-chat/useComposer.js +281 -79
- package/dist/worker/console/static-src/operator-chat/useRepoBrowser.js +21 -3
- package/dist/worker/console/static-src/operator-chat/useRuntimeControls.js +36 -17
- package/dist/worker/console/static-src/operator-chat/useRuntimeSnapshot.js +18 -0
- package/dist/worker/console/static-src/operator-chat/useWorkspaceBrowserGate.js +4 -0
- package/dist/worker/console/static-src/operator-chat/user-turn-anchor-equality.js +21 -0
- package/dist/worker/console/static-src/prd-file-import.js +3 -1
- package/dist/worker/console/static-src/shell/console-update-reload.js +1 -1
- package/dist/worker/console/workspace-context.js +54 -1
- package/dist/worker/console/workspace-initialization.js +218 -0
- package/dist/worker/delivery/git-transaction.js +2 -0
- package/dist/worker/delivery/package.js +4 -1
- package/dist/worker/feature/fullstack-validate.js +2 -0
- package/dist/worker/loop-agent/loop-agent-client.js +8 -2
- package/dist/worker/materialize/harness-task-lineage.js +4 -2
- package/dist/worker/materialize/harness-task-materializer.js +4 -1
- package/dist/worker/metrics/projector.js +1 -1
- package/dist/worker/observability/event-store.js +4 -1
- package/dist/worker/observability/read-model.js +27 -3
- package/dist/worker/observe/node-context-insights.js +479 -0
- package/dist/worker/observe/node-transparency.js +103 -72
- package/dist/worker/observe/routes.js +24 -1
- package/dist/worker/observe/static/console-theme.css +178 -0
- package/dist/worker/observe/static/console-theme.js +74 -0
- package/dist/worker/observe/static/dag-inspector-humanize.js +3 -0
- package/dist/worker/observe/static/dom.js +20 -1
- package/dist/worker/observe/static/format-pool.d.ts +2 -0
- package/dist/worker/observe/static/format-pool.js +6 -0
- package/dist/worker/observe/static/format.js +7 -0
- package/dist/worker/observe/static/inspect-workspace.js +34 -7
- package/dist/worker/observe/static/inspector-submission.js +32 -0
- package/dist/worker/observe/static/kpi.js +1 -0
- package/dist/worker/observe/static/operator-chrome.css +85 -0
- package/dist/worker/observe/static/operator-chrome.js +13 -1
- package/dist/worker/observe/static/relations.js +2 -0
- package/dist/worker/observe/static/router.js +13 -0
- package/dist/worker/observe/static/run-processing.js +2 -0
- package/dist/worker/observe/static/shell-chrome.js +36 -3
- package/dist/worker/observe/static/state.js +35 -2
- package/dist/worker/observe/static/styles.css +263 -39
- package/dist/worker/observe/static/task-failure-labels.d.ts +4 -0
- package/dist/worker/observe/static/task-failure-labels.js +67 -0
- package/dist/worker/observe/static/task-history.js +12 -0
- package/dist/worker/observe/static/views/batch.js +6 -13
- package/dist/worker/observe/static/views/dag-graph.js +50 -3
- package/dist/worker/observe/static/views/dag-inspector.js +742 -268
- package/dist/worker/observe/static/views/dag-trajectory.js +3 -0
- package/dist/worker/observe/static/views/dag.d.ts +6 -0
- package/dist/worker/observe/static/views/dag.js +49 -11
- package/dist/worker/observe/static/views/dags.js +2 -0
- package/dist/worker/observe/static/views/dashboard.js +21 -12
- package/dist/worker/observe/static/views/failures.js +21 -11
- package/dist/worker/observe/static/views/feature.js +11 -29
- package/dist/worker/observe/static/views/pool.js +37 -28
- package/dist/worker/observe/static/views/run.js +48 -5
- package/dist/worker/observe/static/views/session-timeline.js +189 -240
- package/dist/worker/observe/static/views/task.js +81 -62
- package/dist/worker/outcomes/declared-artifacts.js +2 -0
- package/dist/worker/preflight.js +3 -0
- package/dist/worker/scheduler/scheduled-goal-dispatch.js +118 -0
- package/dist/worker/scheduler/scheduled-goal-evidence.js +230 -0
- package/dist/worker/scheduler/scheduled-goal-recovery.js +62 -0
- package/dist/worker/scheduler/scheduled-goal-store.js +709 -0
- package/dist/worker/scheduler/scheduled-goal-supervisor.js +132 -0
- package/dist/worker/scheduler/scheduled-goal-time.js +102 -0
- package/dist/worker/scheduler/scheduled-goal-types.js +95 -0
- package/dist/worker/task-spec/validate.js +4 -1
- package/dist/workflows/dag/backend-test-case-coverage-analysis.js +3 -1
- package/dist/workflows/dag/backend-test-layout.js +27 -7
- package/dist/workflows/dag/backend-test-markdown-workflow.js +9 -25
- package/dist/workflows/dag/backend-test-plan-protocol.js +82 -5
- package/dist/workflows/dag/backend-test-pytest-collection.js +4 -1
- package/dist/workflows/dag/budget-enforcement.js +82 -3
- package/dist/workflows/dag/checkpoint.js +686 -0
- package/dist/workflows/dag/dag-retry-schema.js +14 -0
- package/dist/workflows/dag/decision-envelope.js +2 -0
- package/dist/workflows/dag/dynamic-runtime/shared.js +2 -2
- package/dist/workflows/dag/final-verification.js +45 -10
- package/dist/workflows/dag/frontend-capacity.js +9 -0
- package/dist/workflows/dag/frontend-closeout.js +5 -1
- package/dist/workflows/dag/frontend-committed-facts.js +461 -0
- package/dist/workflows/dag/frontend-contract-facts.js +133 -0
- package/dist/workflows/dag/frontend-design-policy.js +107 -21
- package/dist/workflows/dag/frontend-durable-tools.js +225 -0
- package/dist/workflows/dag/frontend-execution-groups.js +24 -0
- package/dist/workflows/dag/frontend-implementation-contract.js +554 -26
- package/dist/workflows/dag/frontend-input-projection.js +76 -0
- package/dist/workflows/dag/frontend-plan-canary.js +103 -0
- package/dist/workflows/dag/frontend-plan-decision-contract.js +795 -0
- package/dist/workflows/dag/frontend-plan-progress.js +92 -0
- package/dist/workflows/dag/frontend-plan-recovery-policy.js +18 -0
- package/dist/workflows/dag/frontend-plan-render.js +21 -5
- package/dist/workflows/dag/frontend-provider-capability-matrix.js +8 -61
- package/dist/workflows/dag/frontend-recovery-controller.js +7 -7
- package/dist/workflows/dag/frontend-recovery-lineage.js +13 -0
- package/dist/workflows/dag/frontend-recovery-plan.js +10 -5
- package/dist/workflows/dag/frontend-recovery-run.js +148 -47
- package/dist/workflows/dag/frontend-repair-assertions.js +36 -0
- package/dist/workflows/dag/frontend-repair.js +79 -76
- package/dist/workflows/dag/frontend-review-context.js +71 -69
- package/dist/workflows/dag/frontend-review-scopes.js +237 -0
- package/dist/workflows/dag/frontend-risk.js +101 -12
- package/dist/workflows/dag/frontend-root-observation.js +261 -0
- package/dist/workflows/dag/frontend-session-budget.js +376 -0
- package/dist/workflows/dag/frontend-session-context.js +10 -0
- package/dist/workflows/dag/frontend-shape-facts.js +12 -2
- package/dist/workflows/dag/frontend-shape.js +27 -32
- package/dist/workflows/dag/frontend-test-case-checklist.js +12 -3
- package/dist/workflows/dag/frontend-test-case-generation-assessment.js +21 -2
- package/dist/workflows/dag/frontend-test-case-quality.js +3 -3
- package/dist/workflows/dag/frontend-test-environment-probe.js +0 -2
- package/dist/workflows/dag/frontend-test-execution-evidence.js +328 -0
- package/dist/workflows/dag/frontend-test-framework-adapters.js +309 -0
- package/dist/workflows/dag/frontend-test-layout.js +41 -12
- package/dist/workflows/dag/frontend-typed-event-store.js +57 -26
- package/dist/workflows/dag/frontend-verification-trace.js +65 -48
- package/dist/workflows/dag/frontend-writer-admission.js +6 -48
- package/dist/workflows/dag/frontend-writer-status.js +0 -23
- package/dist/workflows/dag/hybrid/sources.js +1831 -0
- package/dist/workflows/dag/hybrid/templates/backend-test.js +1822 -0
- package/dist/workflows/dag/hybrid/templates/frontend-test.js +807 -0
- package/dist/workflows/dag/hybrid/templates/frontend.js +1529 -0
- package/dist/workflows/dag/hybrid/templates/index.js +8 -0
- package/dist/workflows/dag/hybrid/templates/kg-bootstrap.js +449 -0
- package/dist/workflows/dag/hybrid/templates/knowledge-sync.js +495 -0
- package/dist/workflows/dag/hybrid/templates/shared.js +101 -0
- package/dist/workflows/dag/hybrid/templates/standard.js +265 -0
- package/dist/workflows/dag/hybrid/types.js +32 -0
- package/dist/workflows/dag/init-hybrid.js +57 -7167
- package/dist/workflows/dag/interrupt-request.js +2 -0
- package/dist/workflows/dag/lifecycle.js +11 -2
- package/dist/workflows/dag/node-execution.js +257 -247
- package/dist/workflows/dag/output-protocol.js +1 -0
- package/dist/workflows/dag/prompt.js +4 -0
- package/dist/workflows/dag/reconcile-run.js +2 -0
- package/dist/workflows/dag/repair-artifact.js +3 -1
- package/dist/workflows/dag/report.js +2 -0
- package/dist/workflows/dag/rerun-feedback.js +36 -4
- package/dist/workflows/dag/rerun-plan.js +106 -4
- package/dist/workflows/dag/rerun-run.js +7 -0
- package/dist/workflows/dag/rerun-task.js +75 -1
- package/dist/workflows/dag/retry-policy.js +34 -10
- package/dist/workflows/dag/runner-exit-diagnostics.js +125 -0
- package/dist/workflows/dag/runner.js +38 -1074
- package/dist/workflows/dag/scheduler.js +2 -4
- package/dist/workflows/dag/skill-instructions.js +102 -32
- package/dist/workflows/dag/skill-snapshot.js +3 -0
- package/dist/workflows/dag/skills.js +7 -7
- package/dist/workflows/dag/structured-output-repair.js +4 -1
- package/dist/workflows/dag/terminal-status.js +502 -0
- package/dist/workflows/dag/test-artifact-namespace.js +73 -0
- package/dist/workflows/dag/types.js +58 -7
- package/dist/workflows/dag/validate.js +38 -13
- package/dist/workflows/dag/workspace-checkpoint.js +79 -1
- package/dist/workflows/loop/benchmark.js +11 -8
- package/docs/README.md +2 -1
- package/docs/architecture/dag-execution.md +4 -4
- package/docs/architecture/runtime-boundaries.md +29 -23
- package/docs/governance/README.md +1 -0
- package/docs/governance/harness-methodology-verification.md +11 -0
- package/docs/init-surface.manifest.json +44 -295
- package/docs/operations/README.md +4 -0
- package/docs/templates/README.md +5 -5
- package/docs/templates/agent-dag.base.json +9 -9
- package/docs/templates/agent-dag.final-verification.json +6 -6
- package/docs/templates/agent-dag.schema.json +2 -2
- package/docs/templates/agent-dag.supervised-implementation.json +12 -12
- package/docs/templates/backend-test-dag.generate-pytest.prompt.md +3 -3
- package/docs/templates/backend-test-dag.json +708 -703
- package/docs/templates/backend-test-dag.review-cases.prompt.md +3 -3
- package/docs/templates/frontend-design-contract.md +4 -4
- package/docs/templates/frontend-implementation-contract.schema.json +99 -22
- package/docs/templates/frontend-implementation-dag.json +7 -7
- package/docs/templates/frontend-test-case-checklist.md +2 -2
- package/docs/templates/frontend-test-case.example.md +2 -0
- package/docs/templates/frontend-test-dag.generate-cases.prompt.md +1 -1
- package/docs/templates/frontend-test-dag.json +46 -37
- package/docs/templates/frontend-test-dag.retrieve-context.prompt.md +2 -2
- package/docs/templates/frontend-test-dag.retrospect.prompt.md +1 -1
- package/docs/templates/frontend-test-dag.review-cases.prompt.md +1 -1
- package/docs/templates/hybrid-dag.json +9 -9
- package/docs/templates/knowledge-sync-dag.json +8 -8
- package/harness.json +1 -1
- package/package.json +27 -8
- package/resource-catalog.v1.json +1981 -0
- package/resources/agent-bridge/loop-agent/SKILL.md +40 -0
- package/resources/init-history/legacy-surface.v1.json +33 -0
- package/skills/fe-test-ui-scout/SKILL.md +4 -4
- package/skills/fe-test-ui-scout/references/ledger-schema.md +1 -1
- package/skills/frontend-bounded-implement/references/code-standards.md +3 -3
- package/skills/frontend-contract/SKILL.md +2 -1
- package/skills/frontend-contract/references/contract-protocol.md +22 -4
- package/skills/frontend-design-review/SKILL.md +16 -18
- package/skills/frontend-design-review/references/review-checklist.md +3 -4
- package/skills/frontend-plan/SKILL.md +25 -3
- package/skills/frontend-plan/references/decision-contract.md +117 -8
- package/skills/frontend-plan/references/design-decisions.md +32 -0
- package/skills/frontend-review/SKILL.md +29 -36
- package/skills/frontend-review/references/review-findings.md +8 -3
- package/skills/frontend-scout/references/scout-evidence.md +4 -0
- package/skills/init-update/SKILL.md +34 -0
- package/skills/init-update/agents/openai.yaml +6 -0
- package/skills/loop-agent/references/command-reference.md +8 -0
- package/skills/loop-agent/references/hybrid-dag.md +1 -1
- package/skills/playwright-cli/SKILL.md +1 -1
- package/skills/playwright-cli-case-generator/SKILL.md +7 -5
- package/dist/commands/new-task.js +0 -5
- package/dist/commands/status.js +0 -57
- package/dist/commands/task-contract.js +0 -269
- package/dist/shared/prompts.js +0 -26
- package/dist/task/config.js +0 -2
- package/dist/task/contract/validate-draft.js +0 -106
- package/dist/task/goal.js +0 -3
- package/dist/task/index.js +0 -12
- package/dist/task/lifecycle.js +0 -1
- package/dist/task/operator/capabilities.js +0 -6
- package/dist/task/operator/envelope.js +0 -2
- package/dist/task/operator/index.js +0 -5
- package/dist/task/operator/registry.js +0 -2
- package/dist/task/paths.js +0 -1
- package/dist/task/source-state.js +0 -1
- package/dist/task/subagent-guidance.js +0 -1
- package/dist/worker/console/chat/sift-bridge.js +0 -1
- package/dist/worker/console/index.js +0 -20
- package/dist/worker/console/static/assets/channel-CXqdP5pW.js +0 -1
- package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-D9C3agF7.js +0 -1
- package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-D9C3agF7.js +0 -1
- package/dist/worker/console/static/assets/index-CAZ2fC_X.css +0 -1
- package/dist/worker/console/static/assets/index-DhfjOafu.js +0 -449
- package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-Tp7V0U4q.js +0 -1
- package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-DUZWZWi8.js +0 -8
- package/dist/worker/scheduler/index.js +0 -25
- package/dist/workflows/dag/facts.js +0 -4
- package/dist/workflows/dag/frontend-shadow-dual-write.js +0 -941
- package/dist/workflows/dag/index.js +0 -6
- package/dist/workflows/dynamic/index.js +0 -7
- /package/dist/{task/operator/types.js → executors/dag-pi/plan/session.js} +0 -0
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { isSafeMarkdownHref } from "../chat-markdown-security.js";
|
|
2
|
+
import { buildInspectHref, rewriteInspectHrefToCanonical, splitHash } from "../shell/workspace-route.js";
|
|
3
|
+
/** Recognize Markdown links that point at a workspace-relative file. */
|
|
4
|
+
export function parseRepoFileLink(href) {
|
|
5
|
+
if (!href || /^(?:[a-z][a-z0-9+.-]*:|#|\/\/|\/api\/|\/#\/|\/inspect(?:\/|$))/i.test(href))
|
|
6
|
+
return undefined;
|
|
7
|
+
let decoded;
|
|
8
|
+
try {
|
|
9
|
+
decoded = decodeURIComponent(href).replace(/^\.\//, "");
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
const lineMatch = /(?:#L|:)(\d+)(?:-L?\d+)?$/.exec(decoded);
|
|
15
|
+
const path = (lineMatch ? decoded.slice(0, lineMatch.index) : decoded)
|
|
16
|
+
.replace(/\\/g, "/")
|
|
17
|
+
.replace(/^\//, "");
|
|
18
|
+
if (!path || path.split("/").includes("..") || !/(?:\/|\.[a-z0-9_-]{1,12}$)/i.test(path))
|
|
19
|
+
return undefined;
|
|
20
|
+
const line = lineMatch ? Number(lineMatch[1]) : undefined;
|
|
21
|
+
return { path, ...(line && Number.isSafeInteger(line) ? { line } : {}) };
|
|
22
|
+
}
|
|
23
|
+
/** Normalize only this Console's navigation. Never infer ownership from the
|
|
24
|
+
* currently selected shell workspace: old messages belong to their session. */
|
|
25
|
+
export function resolveChatHref(href, scope, target = {}) {
|
|
26
|
+
if (!isSafeMarkdownHref(href))
|
|
27
|
+
return { error: "链接地址不可用。" };
|
|
28
|
+
const base = scope.origin || (typeof location === "undefined" ? "http://local.invalid" : location.origin);
|
|
29
|
+
let url;
|
|
30
|
+
try {
|
|
31
|
+
url = new URL(href, base);
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return { href };
|
|
35
|
+
}
|
|
36
|
+
if (url.origin !== new URL(base).origin)
|
|
37
|
+
return { href };
|
|
38
|
+
const documentPath = url.pathname.replace(/\/$/, "") || "/";
|
|
39
|
+
const directInspect = /^\/inspect\/(dag|task|run|feature|batch|night|pool|failures|dags)(\/|$)/.test(documentPath);
|
|
40
|
+
const inspectDocument = documentPath === "/inspect";
|
|
41
|
+
const hashPath = splitHash(url.hash).path;
|
|
42
|
+
const consoleHash = /^\/(inspect|operate|chat)(\/|$)/.test(hashPath);
|
|
43
|
+
const oldInspectHash = /^\/(dag|task|run|feature|batch|night|pool|failures|dags)(\/|$)/.test(hashPath);
|
|
44
|
+
if (!directInspect && !inspectDocument && !(documentPath === "/" && (consoleHash || oldInspectHash)))
|
|
45
|
+
return { href };
|
|
46
|
+
const canonical = directInspect ? buildInspectHref(documentPath, url.searchParams) : rewriteInspectHrefToCanonical(href, base);
|
|
47
|
+
let { path, query } = splitHash(canonical.slice(2));
|
|
48
|
+
if (path === "/chat")
|
|
49
|
+
return { href: canonical };
|
|
50
|
+
const owner = scope.workspaceId?.trim();
|
|
51
|
+
if (!owner)
|
|
52
|
+
return { error: "无法确认这条消息所属的工作区,请重新打开会话。" };
|
|
53
|
+
const explicit = query.get("workspaceId")?.trim();
|
|
54
|
+
if (explicit && explicit !== owner)
|
|
55
|
+
return { error: "链接工作区与这条消息所属的工作区不一致,请核对链接。" };
|
|
56
|
+
if (path === "/inspect" || path === "/inspect/") {
|
|
57
|
+
const runId = target.dagRunId || query.get("dagRunId")?.trim();
|
|
58
|
+
const taskId = target.taskId || query.get("taskId")?.trim();
|
|
59
|
+
if (runId)
|
|
60
|
+
path = `/inspect/dag/${encodeURIComponent(runId)}`;
|
|
61
|
+
else if (taskId) {
|
|
62
|
+
const featureId = query.get("featureId")?.trim();
|
|
63
|
+
path = featureId ? `/inspect/feature/${encodeURIComponent(featureId)}/task/${encodeURIComponent(taskId)}` : `/inspect/task/${encodeURIComponent(taskId)}`;
|
|
64
|
+
}
|
|
65
|
+
else if (query.has("operationId")) {
|
|
66
|
+
return { operationId: query.get("operationId")?.trim(), error: "需要查询这条执行记录对应的任务或运行。" };
|
|
67
|
+
}
|
|
68
|
+
if (runId || taskId) {
|
|
69
|
+
for (const key of ["dagRunId", "taskId", "featureId", "operationId"])
|
|
70
|
+
query.delete(key);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (path.startsWith("/inspect")) {
|
|
74
|
+
// These are the object/collection routes consumed by Observe's router.
|
|
75
|
+
const inspectPath = path.slice("/inspect".length);
|
|
76
|
+
const known = /^(?:\/?|\/(?:pool|failures|night|dags)|\/(?:dag|task|run|feature|batch|night)\/[^/]+|\/feature\/[^/]+\/task\/[^/]+)$/.test(inspectPath);
|
|
77
|
+
try {
|
|
78
|
+
decodeURIComponent(inspectPath);
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
return { error: "链接中的位置编码无效。" };
|
|
82
|
+
}
|
|
83
|
+
if (!known)
|
|
84
|
+
return { error: "无法识别这条记录链接的页面位置。" };
|
|
85
|
+
}
|
|
86
|
+
query.set("workspaceId", owner);
|
|
87
|
+
return { href: path.startsWith("/inspect") ? buildInspectHref(path, query) : `/#${path}?${query}` };
|
|
88
|
+
}
|
|
89
|
+
/** Read an operation only in the message's workspace, never search other repos. */
|
|
90
|
+
export async function resolveChatOperationHref(operationId, scope, request = (url) => fetch(url, { credentials: "include", signal: AbortSignal.timeout(10_000) })) {
|
|
91
|
+
const owner = scope.workspaceId?.trim();
|
|
92
|
+
if (!owner)
|
|
93
|
+
return { error: "无法确认这条消息所属的工作区。" };
|
|
94
|
+
try {
|
|
95
|
+
const response = await request(`${scope.origin ?? ""}/api/operator/v1/operations/${encodeURIComponent(operationId)}?workspaceId=${encodeURIComponent(owner)}`);
|
|
96
|
+
if (!response.ok)
|
|
97
|
+
return { error: response.status === 404 ? "当前会话工作区中找不到这条执行记录。" : `读取执行记录失败(HTTP ${response.status})。` };
|
|
98
|
+
const data = await response.json();
|
|
99
|
+
if (data.workspaceId !== owner)
|
|
100
|
+
return { error: "执行记录的工作区与当前会话不一致。" };
|
|
101
|
+
const op = data.operation;
|
|
102
|
+
const id = (value) => typeof value === "string" && value.trim() ? value.trim() : undefined;
|
|
103
|
+
const target = {
|
|
104
|
+
dagRunId: id(op?.dagRunId) ?? id(op?.actionParams?.dagRunId) ?? id(op?.actionParams?.runId),
|
|
105
|
+
taskId: id(op?.taskId) ?? id(op?.actionParams?.taskId),
|
|
106
|
+
};
|
|
107
|
+
if (!target.dagRunId && !target.taskId)
|
|
108
|
+
return { error: "这条执行记录尚未关联可查看的任务或运行。" };
|
|
109
|
+
return resolveChatHref("/#/inspect", scope, target);
|
|
110
|
+
}
|
|
111
|
+
catch {
|
|
112
|
+
return { error: "读取执行记录失败,请稍后重试。" };
|
|
113
|
+
}
|
|
114
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** Capture immediately before prepending history, after network waits finish. */
|
|
2
|
+
export function captureChatScrollPosition(container) {
|
|
3
|
+
const top = container.getBoundingClientRect().top;
|
|
4
|
+
const anchor = [...container.querySelectorAll(".oc-turn-group")]
|
|
5
|
+
.find((row) => row.getBoundingClientRect().bottom > top);
|
|
6
|
+
return {
|
|
7
|
+
container,
|
|
8
|
+
anchor,
|
|
9
|
+
anchorTop: anchor?.getBoundingClientRect().top,
|
|
10
|
+
scrollTop: container.scrollTop,
|
|
11
|
+
scrollHeight: container.scrollHeight,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
/** DOM anchoring may already have moved the viewport; compensate only the
|
|
15
|
+
* remaining displacement, before paint, rather than adding height twice. */
|
|
16
|
+
export function restoreChatScrollPosition(position) {
|
|
17
|
+
const { container, anchor, anchorTop } = position;
|
|
18
|
+
if (anchor && anchorTop !== undefined && container.contains(anchor)) {
|
|
19
|
+
container.scrollTop += anchor.getBoundingClientRect().top - anchorTop;
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
container.scrollTop = position.scrollTop + container.scrollHeight - position.scrollHeight;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -2,8 +2,11 @@ import { artifactFromEventPayload, mergeArtifactCardState, } from "../../chat/ar
|
|
|
2
2
|
import { humanGateCardFromEventPayload, mergeHumanGateCardState, } from "../../chat/human-gate-card.js";
|
|
3
3
|
import { mergeOperationCardState, operationFromEventPayload, } from "../../chat/operation-card.js";
|
|
4
4
|
import { requestId } from "./format.js";
|
|
5
|
-
import { parseAssistantContent } from "../../chat/assistant-content.js";
|
|
5
|
+
import { parseAssistantContent, } from "../../chat/assistant-content.js";
|
|
6
6
|
import { sortChatTimelineMessages, upsertCompactionMessage, } from "./compaction-message.js";
|
|
7
|
+
import { replacePendingUserMessage } from "./pending-user-message.js";
|
|
8
|
+
import { conversationNodeFromEvent, upsertConversationNode, } from "../../chat/conversation-nodes.js";
|
|
9
|
+
import { createAnimationFrameBatcher } from "./animation-frame-batcher.js";
|
|
7
10
|
/** Shared handler for a single parsed Chat SSE event (M1 reconnect).
|
|
8
11
|
*
|
|
9
12
|
* Used by BOTH the inline prompt POST SSE and the background reconnect
|
|
@@ -11,16 +14,132 @@ import { sortChatTimelineMessages, upsertCompactionMessage, } from "./compaction
|
|
|
11
14
|
* original request would have. `assistantId` is the in-flight assistant
|
|
12
15
|
* message id to patch for streaming text; reconnect creates one if none. */
|
|
13
16
|
export function createChatSseEventApplier(deps) {
|
|
14
|
-
const { refs, onReconcile, setError, setInterview, setHumanGateCards, setArtifactCards, setStreaming, setTurnPhase = () => undefined, setDeferredTurn = () => undefined, setDeferredTurns = () => undefined, setStreamingAssistantId, setUnread, setOperationCards, setUsage, onTelemetryRefresh, setMessages, setToolCalls, setPendingQuestion = () => undefined, setTodos = () => undefined, setGoal = () => undefined, } = deps;
|
|
17
|
+
const { refs, onReconcile, setError, setInterview, setHumanGateCards, setArtifactCards, setStreaming, setTurnPhase = () => undefined, setDeferredTurn = () => undefined, setDeferredTurns = () => undefined, setStreamingAssistantId, setUnread, setOperationCards, setUsage, onTelemetryRefresh, setMessages, setToolCalls, setPendingQuestion = () => undefined, setTodos = () => undefined, setGoal = () => undefined, setOperatorActions = () => undefined, setSddSessionIdentity = () => undefined, setConversationNodes = () => undefined, setTurnState = () => undefined, getMessages, } = deps;
|
|
15
18
|
let queueOwner;
|
|
16
19
|
let queueRevision = -1;
|
|
20
|
+
/** Retained-replay text per turn. Pi `message_update.text` is the cumulative
|
|
21
|
+
* full text of the current assistant step, so only the newest frame per
|
|
22
|
+
* turn matters and buffering cannot lose content. Flushed on `stream_ready`
|
|
23
|
+
* onto the turn's newest assistant row (2026-09-08). */
|
|
24
|
+
const replayTextByTurn = new Map();
|
|
25
|
+
const messageUpdateBatcher = createAnimationFrameBatcher({
|
|
26
|
+
schedule: (callback) => {
|
|
27
|
+
if (typeof window !== "undefined" && window.requestAnimationFrame) {
|
|
28
|
+
return window.requestAnimationFrame(callback);
|
|
29
|
+
}
|
|
30
|
+
return globalThis.setTimeout(callback, 16);
|
|
31
|
+
},
|
|
32
|
+
cancel: (handle) => {
|
|
33
|
+
if (typeof window !== "undefined" && window.cancelAnimationFrame) {
|
|
34
|
+
window.cancelAnimationFrame(handle);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
globalThis.clearTimeout(handle);
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
publish: (values) => {
|
|
41
|
+
const sessionId = refs.sessionRef.current?.sessionId;
|
|
42
|
+
const generation = refs.sessionGenerationRef.current;
|
|
43
|
+
setMessages((messages) => {
|
|
44
|
+
let next = messages;
|
|
45
|
+
for (const item of values.values()) {
|
|
46
|
+
if (item.sessionId !== sessionId || item.generation !== generation)
|
|
47
|
+
continue;
|
|
48
|
+
next = item.apply(next);
|
|
49
|
+
}
|
|
50
|
+
return next;
|
|
51
|
+
});
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
const useFrameBatching = typeof window !== "undefined" && typeof window.requestAnimationFrame === "function";
|
|
55
|
+
const flushReplayText = () => {
|
|
56
|
+
if (replayTextByTurn.size === 0)
|
|
57
|
+
return;
|
|
58
|
+
const entries = [...replayTextByTurn.entries()];
|
|
59
|
+
replayTextByTurn.clear();
|
|
60
|
+
const currentSessionId = refs.sessionRef.current?.sessionId;
|
|
61
|
+
const snapshot = getMessages?.() ?? [];
|
|
62
|
+
for (const [turnId, entry] of entries) {
|
|
63
|
+
if (entry.sessionId === undefined || entry.sessionId !== currentSessionId)
|
|
64
|
+
continue;
|
|
65
|
+
if (!entry.text.trim() && !(entry.content && entry.content.length > 0))
|
|
66
|
+
continue;
|
|
67
|
+
const mapped = refs.turnAssistantIdsRef.current.get(turnId);
|
|
68
|
+
const mappedRow = mapped
|
|
69
|
+
? snapshot.find((message) => message.id === mapped)
|
|
70
|
+
: undefined;
|
|
71
|
+
const lastSameTurn = [...snapshot]
|
|
72
|
+
.reverse()
|
|
73
|
+
.find((message) => message.role === "assistant" && message.turnId === turnId);
|
|
74
|
+
// Prefer the server-approved durable id: it is the id the restore
|
|
75
|
+
// projection and a future page will use, so live and restore stay
|
|
76
|
+
// aligned (2026-09-13).
|
|
77
|
+
const targetId = entry.messageId ??
|
|
78
|
+
mappedRow?.id ??
|
|
79
|
+
lastSameTurn?.id ??
|
|
80
|
+
mapped ??
|
|
81
|
+
`assistant-replay-${turnId}`;
|
|
82
|
+
// Bind synchronously: the next live frame in the same reader loop reads
|
|
83
|
+
// this map before React runs the updater below.
|
|
84
|
+
refs.turnAssistantIdsRef.current.set(turnId, targetId);
|
|
85
|
+
if (entry.sealed)
|
|
86
|
+
refs.sealedAssistantIdsRef.current.add(targetId);
|
|
87
|
+
setMessages((messages) => {
|
|
88
|
+
const existing = messages.find((message) => message.id === targetId);
|
|
89
|
+
if (!existing) {
|
|
90
|
+
return sortChatTimelineMessages([
|
|
91
|
+
...messages,
|
|
92
|
+
{
|
|
93
|
+
id: targetId,
|
|
94
|
+
role: "assistant",
|
|
95
|
+
text: entry.text,
|
|
96
|
+
createdAt: entry.at,
|
|
97
|
+
...(entry.eventSeq === undefined
|
|
98
|
+
? {}
|
|
99
|
+
: { eventSeq: entry.eventSeq, updatedSeq: entry.eventSeq }),
|
|
100
|
+
...(entry.content ? { content: entry.content } : {}),
|
|
101
|
+
turnId,
|
|
102
|
+
},
|
|
103
|
+
]);
|
|
104
|
+
}
|
|
105
|
+
// A stale buffer must never rewind a row that already carries newer
|
|
106
|
+
// text (cross-connection leftovers, or live frames that arrived first).
|
|
107
|
+
const currentSeq = existing.updatedSeq ?? existing.eventSeq;
|
|
108
|
+
if (entry.eventSeq !== undefined &&
|
|
109
|
+
currentSeq !== undefined &&
|
|
110
|
+
entry.eventSeq < currentSeq)
|
|
111
|
+
return messages;
|
|
112
|
+
return messages.map((message) => message.id !== targetId
|
|
113
|
+
? message
|
|
114
|
+
: {
|
|
115
|
+
...message,
|
|
116
|
+
text: entry.text,
|
|
117
|
+
...(entry.content ? { content: entry.content } : {}),
|
|
118
|
+
...(entry.eventSeq === undefined
|
|
119
|
+
? {}
|
|
120
|
+
: { updatedSeq: entry.eventSeq }),
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
};
|
|
17
125
|
return (eventName, data, assistantId, options) => {
|
|
18
126
|
if (options?.generation !== undefined &&
|
|
19
127
|
refs.sessionGenerationRef.current !== options.generation)
|
|
20
128
|
return;
|
|
129
|
+
if (typeof data.sessionId === "string" &&
|
|
130
|
+
data.sessionId !== refs.sessionRef.current?.sessionId)
|
|
131
|
+
return;
|
|
21
132
|
const replay = options?.replay === true;
|
|
22
|
-
if (eventName === "stream_ready")
|
|
133
|
+
if (eventName === "stream_ready") {
|
|
134
|
+
// The retained replay is fully buffered: publish it now so a reconnect
|
|
135
|
+
// that landed after the turn settled still shows the answer.
|
|
136
|
+
flushReplayText();
|
|
23
137
|
return;
|
|
138
|
+
}
|
|
139
|
+
// Structural events define visible boundaries in the DSH timeline. Publish
|
|
140
|
+
// any coalesced text before applying them so rows never appear out of order.
|
|
141
|
+
if (eventName !== "message_update" || replay)
|
|
142
|
+
messageUpdateBatcher.flush();
|
|
24
143
|
if (eventName === "reconcile") {
|
|
25
144
|
// Cursor aged out of the server ring (or the turn changed under us):
|
|
26
145
|
// retained history may be incomplete. Surface recovery via the callback
|
|
@@ -93,6 +212,64 @@ export function createChatSseEventApplier(deps) {
|
|
|
93
212
|
const eventAt = typeof data.at === "string" && Number.isFinite(Date.parse(data.at))
|
|
94
213
|
? Date.parse(data.at)
|
|
95
214
|
: Date.now();
|
|
215
|
+
const nodeKinds = new Set([
|
|
216
|
+
"step_start",
|
|
217
|
+
"step_end",
|
|
218
|
+
"model_retry",
|
|
219
|
+
"turn_error",
|
|
220
|
+
"turn_max_tokens",
|
|
221
|
+
"request_context",
|
|
222
|
+
"command",
|
|
223
|
+
"unknown",
|
|
224
|
+
]);
|
|
225
|
+
if (nodeKinds.has(eventName) &&
|
|
226
|
+
turnId &&
|
|
227
|
+
eventSeq !== undefined &&
|
|
228
|
+
typeof data.eventId === "string") {
|
|
229
|
+
const node = conversationNodeFromEvent({
|
|
230
|
+
eventId: data.eventId,
|
|
231
|
+
kind: eventName,
|
|
232
|
+
seq: eventSeq,
|
|
233
|
+
turnId,
|
|
234
|
+
at: new Date(eventAt).toISOString(),
|
|
235
|
+
data: payload,
|
|
236
|
+
});
|
|
237
|
+
if (node)
|
|
238
|
+
setConversationNodes((current) => upsertConversationNode(current, node));
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
if (eventName === "operator-action") {
|
|
242
|
+
const eventId = typeof data.eventId === "string" ? data.eventId : undefined;
|
|
243
|
+
if (!eventId ||
|
|
244
|
+
eventSeq === undefined ||
|
|
245
|
+
data.sessionId !== refs.sessionRef.current?.sessionId ||
|
|
246
|
+
payload.action !== "sdd-bingo" ||
|
|
247
|
+
typeof payload.skillName !== "string" ||
|
|
248
|
+
!payload.skillName.trim() ||
|
|
249
|
+
typeof payload.telemetrySessionId !== "string" ||
|
|
250
|
+
!payload.telemetrySessionId.trim())
|
|
251
|
+
return;
|
|
252
|
+
const action = {
|
|
253
|
+
eventId,
|
|
254
|
+
seq: eventSeq,
|
|
255
|
+
at: eventAt,
|
|
256
|
+
...(turnId ? { turnId } : {}),
|
|
257
|
+
action: "sdd-bingo",
|
|
258
|
+
skillName: payload.skillName.trim(),
|
|
259
|
+
telemetrySessionId: payload.telemetrySessionId.trim(),
|
|
260
|
+
};
|
|
261
|
+
setOperatorActions((current) => {
|
|
262
|
+
const existing = current.findIndex((item) => item.eventId === eventId);
|
|
263
|
+
const next = existing < 0
|
|
264
|
+
? [...current, action]
|
|
265
|
+
: current.map((item, index) => (index === existing ? action : item));
|
|
266
|
+
return next.sort((left, right) => left.seq - right.seq || left.at - right.at);
|
|
267
|
+
});
|
|
268
|
+
setSddSessionIdentity({
|
|
269
|
+
telemetrySessionId: action.telemetrySessionId,
|
|
270
|
+
});
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
96
273
|
if (eventName === "queue_update") {
|
|
97
274
|
const revision = typeof payload.revision === "number" ? payload.revision : -1;
|
|
98
275
|
const owner = refs.sessionRef.current?.sessionId;
|
|
@@ -138,11 +315,35 @@ export function createChatSseEventApplier(deps) {
|
|
|
138
315
|
? Date.parse(message.at)
|
|
139
316
|
: Date.now();
|
|
140
317
|
setMessages((messages) => {
|
|
318
|
+
const durableMessage = {
|
|
319
|
+
id: message.id,
|
|
320
|
+
role: "user",
|
|
321
|
+
text: message.text,
|
|
322
|
+
createdAt,
|
|
323
|
+
...(acceptedClientRequestId
|
|
324
|
+
? { clientRequestId: acceptedClientRequestId }
|
|
325
|
+
: {}),
|
|
326
|
+
...(eventSeq === undefined ? {} : { eventSeq }),
|
|
327
|
+
...(turnId ? { turnId } : {}),
|
|
328
|
+
...(Array.isArray(message.attachments)
|
|
329
|
+
? { attachments: message.attachments }
|
|
330
|
+
: {}),
|
|
331
|
+
};
|
|
332
|
+
// Any frame carrying the clientRequestId replaces the optimistic
|
|
333
|
+
// row in place — even after a /state reconcile already released
|
|
334
|
+
// the pending lease. Otherwise the optimistic row survives and
|
|
335
|
+
// the durable row is appended next to it (2026-09-08).
|
|
336
|
+
if (acceptedClientRequestId) {
|
|
337
|
+
return replacePendingUserMessage(messages, acceptedClientRequestId, durableMessage);
|
|
338
|
+
}
|
|
141
339
|
const existing = messages.some((item) => item.id === message.id);
|
|
142
340
|
const next = existing
|
|
143
341
|
? messages.map((item) => item.id === message.id
|
|
144
342
|
? {
|
|
145
343
|
...item,
|
|
344
|
+
...(acceptedClientRequestId
|
|
345
|
+
? { clientRequestId: acceptedClientRequestId }
|
|
346
|
+
: {}),
|
|
146
347
|
...(eventSeq === undefined ? {} : { eventSeq }),
|
|
147
348
|
...(turnId ? { turnId } : {}),
|
|
148
349
|
}
|
|
@@ -154,6 +355,9 @@ export function createChatSseEventApplier(deps) {
|
|
|
154
355
|
role: "user",
|
|
155
356
|
text: message.text,
|
|
156
357
|
createdAt,
|
|
358
|
+
...(acceptedClientRequestId
|
|
359
|
+
? { clientRequestId: acceptedClientRequestId }
|
|
360
|
+
: {}),
|
|
157
361
|
...(eventSeq === undefined ? {} : { eventSeq }),
|
|
158
362
|
...(turnId ? { turnId } : {}),
|
|
159
363
|
},
|
|
@@ -193,6 +397,12 @@ export function createChatSseEventApplier(deps) {
|
|
|
193
397
|
refs.sealedAssistantIdsRef.current.add(previousId);
|
|
194
398
|
refs.turnAssistantIdsRef.current.set(turnId, continuationId);
|
|
195
399
|
setStreamingAssistantId(continuationId);
|
|
400
|
+
// Overflow recovery makes the model regenerate the whole reply from
|
|
401
|
+
// the compacted context. Keeping the interrupted bubble beside the
|
|
402
|
+
// regenerated one rendered the same answer twice, so drop the
|
|
403
|
+
// superseded row (2026-09-08). Compaction itself stays visible as
|
|
404
|
+
// its own timeline row.
|
|
405
|
+
setMessages((messages) => messages.filter((message) => message.id !== previousId || message.role !== "assistant"));
|
|
196
406
|
}
|
|
197
407
|
return;
|
|
198
408
|
}
|
|
@@ -297,6 +507,8 @@ export function createChatSseEventApplier(deps) {
|
|
|
297
507
|
if (turnId) {
|
|
298
508
|
refs.settledTurnIdsRef.current.delete(turnId);
|
|
299
509
|
refs.activeTurnIdRef.current = turnId;
|
|
510
|
+
if (!replay)
|
|
511
|
+
setTurnState(turnId, "running");
|
|
300
512
|
}
|
|
301
513
|
if (refs.stopRequestedRef.current &&
|
|
302
514
|
(!turnId ||
|
|
@@ -315,13 +527,17 @@ export function createChatSseEventApplier(deps) {
|
|
|
315
527
|
return;
|
|
316
528
|
}
|
|
317
529
|
if (eventName === "agent_settled" || eventName === "agent_end") {
|
|
318
|
-
if (turnId)
|
|
319
|
-
refs.settledTurnIdsRef.current.add(turnId);
|
|
320
530
|
// `agent_end` means the SDK run ended, but the Console keeps the only
|
|
321
531
|
// GET stream through an idle grace for agent_settled/state reconciliation
|
|
322
532
|
// (M4.4). It must not prematurely close the visible turn.
|
|
323
533
|
if (eventName === "agent_end")
|
|
324
534
|
return;
|
|
535
|
+
if (turnId) {
|
|
536
|
+
refs.settledTurnIdsRef.current.add(turnId);
|
|
537
|
+
// Settlement proves closure but not its outcome. The stream owner starts
|
|
538
|
+
// an authoritative /state reconcile; do not guess settled here because
|
|
539
|
+
// abort/error closeout persists the exact state just after this event.
|
|
540
|
+
}
|
|
325
541
|
const pending = refs.pendingSubmissionRef.current;
|
|
326
542
|
if (pending && turnId && pending.acceptedTurnId === turnId) {
|
|
327
543
|
refs.releasedClientRequestIdsRef.current.add(pending.clientRequestId);
|
|
@@ -355,7 +571,7 @@ export function createChatSseEventApplier(deps) {
|
|
|
355
571
|
return prev.map((t) => t.status === "running" &&
|
|
356
572
|
((turnId !== undefined && t.turnId === turnId) ||
|
|
357
573
|
t.assistantMessageId === resolvedAssistantId)
|
|
358
|
-
? { ...t, status: "error", finishedAt: Date.now() }
|
|
574
|
+
? { ...t, status: "error", interrupted: true, finishedAt: Date.now() }
|
|
359
575
|
: t);
|
|
360
576
|
});
|
|
361
577
|
// Drop only a true placeholder. An empty bubble that still owns tools
|
|
@@ -465,9 +681,39 @@ export function createChatSseEventApplier(deps) {
|
|
|
465
681
|
}
|
|
466
682
|
if (eventName === "message_update" || eventName === "message_end") {
|
|
467
683
|
if (replay) {
|
|
468
|
-
//
|
|
469
|
-
//
|
|
470
|
-
//
|
|
684
|
+
// Buffer instead of dropping: dropping lost the answer whenever a
|
|
685
|
+
// reconnect landed after the turn settled — the session store may not
|
|
686
|
+
// have the row yet and nothing else reloads messages afterwards. Only
|
|
687
|
+
// the newest frame per turn is kept because Pi text is cumulative.
|
|
688
|
+
// The durable messageId (2026-09-13) is buffered so the flushed row
|
|
689
|
+
// adopts the same id the restore projection will use.
|
|
690
|
+
const bufferSessionId = refs.sessionRef.current?.sessionId;
|
|
691
|
+
if (turnId && bufferSessionId) {
|
|
692
|
+
const previous = replayTextByTurn.get(turnId);
|
|
693
|
+
const content = parseAssistantContent(payload.content);
|
|
694
|
+
const durableMessageId = typeof payload.messageId === "string" && payload.messageId
|
|
695
|
+
? payload.messageId
|
|
696
|
+
: previous?.messageId;
|
|
697
|
+
replayTextByTurn.set(turnId, {
|
|
698
|
+
text: typeof payload.text === "string"
|
|
699
|
+
? payload.text
|
|
700
|
+
: (previous?.text ?? ""),
|
|
701
|
+
...(content
|
|
702
|
+
? { content }
|
|
703
|
+
: previous?.content
|
|
704
|
+
? { content: previous.content }
|
|
705
|
+
: {}),
|
|
706
|
+
...(eventSeq !== undefined
|
|
707
|
+
? { eventSeq }
|
|
708
|
+
: previous?.eventSeq !== undefined
|
|
709
|
+
? { eventSeq: previous.eventSeq }
|
|
710
|
+
: {}),
|
|
711
|
+
...(durableMessageId ? { messageId: durableMessageId } : {}),
|
|
712
|
+
at: previous?.at ?? eventAt,
|
|
713
|
+
sealed: eventName === "message_end" ? true : (previous?.sealed ?? false),
|
|
714
|
+
sessionId: previous?.sessionId ?? bufferSessionId,
|
|
715
|
+
});
|
|
716
|
+
}
|
|
471
717
|
return;
|
|
472
718
|
}
|
|
473
719
|
const sealedIds = refs.sealedAssistantIdsRef.current;
|
|
@@ -484,11 +730,36 @@ export function createChatSseEventApplier(deps) {
|
|
|
484
730
|
}
|
|
485
731
|
const text = typeof payload.text === "string" ? payload.text : "";
|
|
486
732
|
const content = parseAssistantContent(payload.content);
|
|
733
|
+
// Server-approved durable assistant message id (2026-09-13). When the
|
|
734
|
+
// frame carries one (message_end persists before SSE is written), the
|
|
735
|
+
// bubble adopts it so live ↔ restore ids match; the old locally
|
|
736
|
+
// generated id is retired from the turn map.
|
|
737
|
+
const durableMessageId = typeof payload.messageId === "string" && payload.messageId
|
|
738
|
+
? payload.messageId
|
|
739
|
+
: undefined;
|
|
740
|
+
const previousResolved = resolvedAssistantId;
|
|
741
|
+
if (durableMessageId && resolvedAssistantId !== durableMessageId) {
|
|
742
|
+
resolvedAssistantId = durableMessageId;
|
|
743
|
+
if (turnId)
|
|
744
|
+
refs.turnAssistantIdsRef.current.set(turnId, durableMessageId);
|
|
745
|
+
}
|
|
746
|
+
if (durableMessageId &&
|
|
747
|
+
refs.sealedAssistantIdsRef.current.has(previousResolved)) {
|
|
748
|
+
refs.sealedAssistantIdsRef.current.delete(previousResolved);
|
|
749
|
+
refs.sealedAssistantIdsRef.current.add(durableMessageId);
|
|
750
|
+
}
|
|
487
751
|
const assistantIdForEvent = resolvedAssistantId;
|
|
488
|
-
|
|
489
|
-
|
|
752
|
+
const applyMessageUpdate = (m) => {
|
|
753
|
+
// Rename a locally-generated row to the durable id in place so we
|
|
754
|
+
// never render a twin bubble for the same persistence.
|
|
755
|
+
const rows = durableMessageId
|
|
756
|
+
? m.map((msg) => msg.id === previousResolved && msg.role === "assistant"
|
|
757
|
+
? { ...msg, id: durableMessageId }
|
|
758
|
+
: msg)
|
|
759
|
+
: m;
|
|
760
|
+
const exists = rows.some((msg) => msg.id === assistantIdForEvent);
|
|
490
761
|
if (exists) {
|
|
491
|
-
return sortChatTimelineMessages(
|
|
762
|
+
return sortChatTimelineMessages(rows.map((msg) => {
|
|
492
763
|
if (msg.id !== assistantIdForEvent)
|
|
493
764
|
return msg;
|
|
494
765
|
return {
|
|
@@ -508,7 +779,7 @@ export function createChatSseEventApplier(deps) {
|
|
|
508
779
|
// Reconnect path: the assistant message may not exist yet
|
|
509
780
|
// (e.g. only tool_call events arrived). Append a placeholder.
|
|
510
781
|
return sortChatTimelineMessages([
|
|
511
|
-
...
|
|
782
|
+
...rows,
|
|
512
783
|
{
|
|
513
784
|
id: assistantIdForEvent,
|
|
514
785
|
role: "assistant",
|
|
@@ -521,7 +792,20 @@ export function createChatSseEventApplier(deps) {
|
|
|
521
792
|
...(content ? { content } : {}),
|
|
522
793
|
},
|
|
523
794
|
]);
|
|
524
|
-
}
|
|
795
|
+
};
|
|
796
|
+
if (eventName === "message_update" && useFrameBatching) {
|
|
797
|
+
const sessionId = refs.sessionRef.current?.sessionId;
|
|
798
|
+
if (sessionId) {
|
|
799
|
+
messageUpdateBatcher.enqueue(`${sessionId}:${assistantIdForEvent}`, {
|
|
800
|
+
sessionId,
|
|
801
|
+
generation: refs.sessionGenerationRef.current,
|
|
802
|
+
apply: applyMessageUpdate,
|
|
803
|
+
});
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
else {
|
|
807
|
+
setMessages(applyMessageUpdate);
|
|
808
|
+
}
|
|
525
809
|
if (eventName === "message_end")
|
|
526
810
|
sealedIds.add(assistantIdForEvent);
|
|
527
811
|
}
|
|
@@ -531,6 +815,10 @@ export function createChatSseEventApplier(deps) {
|
|
|
531
815
|
: requestId("t");
|
|
532
816
|
const toolName = typeof payload.toolName === "string" ? payload.toolName : "tool";
|
|
533
817
|
const argsPreview = typeof payload.argsPreview === "string" ? payload.argsPreview : "{}";
|
|
818
|
+
const toolStep = typeof payload.step === "number" ? payload.step : undefined;
|
|
819
|
+
const parentToolCallId = typeof payload.parentToolCallId === "string" && payload.parentToolCallId
|
|
820
|
+
? payload.parentToolCallId
|
|
821
|
+
: undefined;
|
|
534
822
|
setToolCalls((prev) => {
|
|
535
823
|
if (prev.some((t) => t.id === id)) {
|
|
536
824
|
return prev.map((t) => {
|
|
@@ -542,6 +830,8 @@ export function createChatSseEventApplier(deps) {
|
|
|
542
830
|
status: "running",
|
|
543
831
|
turnId: turnId ?? t.turnId,
|
|
544
832
|
assistantMessageId: resolvedAssistantId,
|
|
833
|
+
...(toolStep === undefined ? {} : { step: toolStep }),
|
|
834
|
+
...(parentToolCallId ? { parentToolCallId } : {}),
|
|
545
835
|
...(eventSeq === undefined ? {} : { eventSeq }),
|
|
546
836
|
};
|
|
547
837
|
});
|
|
@@ -557,6 +847,54 @@ export function createChatSseEventApplier(deps) {
|
|
|
557
847
|
...(eventSeq === undefined ? {} : { eventSeq }),
|
|
558
848
|
turnId,
|
|
559
849
|
assistantMessageId: resolvedAssistantId,
|
|
850
|
+
...(toolStep === undefined ? {} : { step: toolStep }),
|
|
851
|
+
...(parentToolCallId ? { parentToolCallId } : {}),
|
|
852
|
+
},
|
|
853
|
+
];
|
|
854
|
+
});
|
|
855
|
+
}
|
|
856
|
+
else if (eventName === "tool_update") {
|
|
857
|
+
const id = typeof payload.toolCallId === "string"
|
|
858
|
+
? payload.toolCallId
|
|
859
|
+
: requestId("u");
|
|
860
|
+
const toolName = typeof payload.toolName === "string" ? payload.toolName : "tool";
|
|
861
|
+
const resultText = typeof payload.resultPreview === "string"
|
|
862
|
+
? payload.resultPreview
|
|
863
|
+
: "";
|
|
864
|
+
const toolStep = typeof payload.step === "number" ? payload.step : undefined;
|
|
865
|
+
const parentToolCallId = typeof payload.parentToolCallId === "string" && payload.parentToolCallId
|
|
866
|
+
? payload.parentToolCallId
|
|
867
|
+
: undefined;
|
|
868
|
+
setToolCalls((prev) => {
|
|
869
|
+
const exists = prev.some((tool) => tool.id === id);
|
|
870
|
+
if (exists) {
|
|
871
|
+
return prev.map((tool) => tool.id !== id
|
|
872
|
+
? tool
|
|
873
|
+
: {
|
|
874
|
+
...tool,
|
|
875
|
+
result: resultText,
|
|
876
|
+
resultText,
|
|
877
|
+
status: "running",
|
|
878
|
+
turnId: turnId ?? tool.turnId,
|
|
879
|
+
assistantMessageId: tool.assistantMessageId ?? resolvedAssistantId,
|
|
880
|
+
...(toolStep === undefined ? {} : { step: toolStep }),
|
|
881
|
+
...(parentToolCallId ? { parentToolCallId } : {}),
|
|
882
|
+
});
|
|
883
|
+
}
|
|
884
|
+
return [
|
|
885
|
+
...prev,
|
|
886
|
+
{
|
|
887
|
+
id,
|
|
888
|
+
toolName,
|
|
889
|
+
result: resultText,
|
|
890
|
+
resultText,
|
|
891
|
+
status: "running",
|
|
892
|
+
createdAt: eventAt,
|
|
893
|
+
...(eventSeq === undefined ? {} : { eventSeq }),
|
|
894
|
+
turnId,
|
|
895
|
+
assistantMessageId: resolvedAssistantId,
|
|
896
|
+
...(toolStep === undefined ? {} : { step: toolStep }),
|
|
897
|
+
...(parentToolCallId ? { parentToolCallId } : {}),
|
|
560
898
|
},
|
|
561
899
|
];
|
|
562
900
|
});
|
|
@@ -570,6 +908,10 @@ export function createChatSseEventApplier(deps) {
|
|
|
570
908
|
const resultText = typeof payload.resultPreview === "string"
|
|
571
909
|
? payload.resultPreview
|
|
572
910
|
: "{}";
|
|
911
|
+
const toolStep = typeof payload.step === "number" ? payload.step : undefined;
|
|
912
|
+
const parentToolCallId = typeof payload.parentToolCallId === "string" && payload.parentToolCallId
|
|
913
|
+
? payload.parentToolCallId
|
|
914
|
+
: undefined;
|
|
573
915
|
// Plan A (2026-08-16): the server carries the accepted-operation link on
|
|
574
916
|
// the frame; persist it on the tool entry so the semantic event resolves
|
|
575
917
|
// an operation:<id> ref (mirrors the hydrated path backfill).
|
|
@@ -591,6 +933,8 @@ export function createChatSseEventApplier(deps) {
|
|
|
591
933
|
...(eventSeq === undefined ? {} : { finishedSeq: eventSeq }),
|
|
592
934
|
turnId: turnId ?? t.turnId,
|
|
593
935
|
assistantMessageId: t.assistantMessageId ?? resolvedAssistantId,
|
|
936
|
+
...(toolStep === undefined ? {} : { step: toolStep }),
|
|
937
|
+
...(parentToolCallId ? { parentToolCallId } : {}),
|
|
594
938
|
...(resultOperationId
|
|
595
939
|
? { operationId: resultOperationId }
|
|
596
940
|
: t.operationId
|
|
@@ -614,6 +958,8 @@ export function createChatSseEventApplier(deps) {
|
|
|
614
958
|
: { eventSeq, finishedSeq: eventSeq }),
|
|
615
959
|
turnId,
|
|
616
960
|
assistantMessageId: resolvedAssistantId,
|
|
961
|
+
...(toolStep === undefined ? {} : { step: toolStep }),
|
|
962
|
+
...(parentToolCallId ? { parentToolCallId } : {}),
|
|
617
963
|
...(resultOperationId ? { operationId: resultOperationId } : {}),
|
|
618
964
|
},
|
|
619
965
|
];
|