@tea-agent/loop-agent 0.1.0-fe-test.4 → 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 +442 -2524
- 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 +1517 -3180
- 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 +358 -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/map.js +15 -2
- 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 +14 -3
- package/dist/workflows/dag/frontend-test-case-generation-assessment.js +88 -0
- package/dist/workflows/dag/frontend-test-case-manifest.js +6 -1
- 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-test-result-contract.js +15 -1
- 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 -7077
- 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 +79 -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 +48 -39
- 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,66 @@
|
|
|
1
|
+
/** Insert the optimistic user bubble and assistant slot exactly once.
|
|
2
|
+
*
|
|
3
|
+
* The optimistic user row is the ONLY row carrying `pending: true`. Every
|
|
4
|
+
* rollback path deletes pending rows by clientRequestId; a durable row that
|
|
5
|
+
* already replaced it must survive (2026-09-08). */
|
|
6
|
+
export function appendPendingSubmission(messages, pending) {
|
|
7
|
+
if (messages.some((message) => message.clientRequestId === pending.clientRequestId))
|
|
8
|
+
return [...messages];
|
|
9
|
+
return [
|
|
10
|
+
...messages,
|
|
11
|
+
{ ...pending.user, pending: true },
|
|
12
|
+
{ ...pending.assistant, clientRequestId: pending.clientRequestId },
|
|
13
|
+
];
|
|
14
|
+
}
|
|
15
|
+
/** Merge a durable user message into its optimistic or snapshot row in place.
|
|
16
|
+
*
|
|
17
|
+
* The replacement drops the `pending` marker: the row is server truth from now
|
|
18
|
+
* on, so a later adopt/rejected/connect rollback for the same clientRequestId
|
|
19
|
+
* must not delete it. Matching the durable id also dedupes retained SSE replay
|
|
20
|
+
* against a session snapshot whose stored row predates clientRequestId. */
|
|
21
|
+
export function replacePendingUserMessage(messages, clientRequestId, durable) {
|
|
22
|
+
let replaced = false;
|
|
23
|
+
const next = [];
|
|
24
|
+
for (const message of messages) {
|
|
25
|
+
const matches = message.role === "user" &&
|
|
26
|
+
(message.clientRequestId === clientRequestId || message.id === durable.id);
|
|
27
|
+
if (!matches) {
|
|
28
|
+
next.push(message);
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
if (replaced)
|
|
32
|
+
continue;
|
|
33
|
+
replaced = true;
|
|
34
|
+
const { pending: _pending, ...rest } = message;
|
|
35
|
+
next.push({
|
|
36
|
+
...rest,
|
|
37
|
+
...durable,
|
|
38
|
+
// Durable reconciliation replaces values in the established optimistic
|
|
39
|
+
// seat. A later server timestamp must not move the user below the empty
|
|
40
|
+
// active assistant cursor when turn groups sort by display time.
|
|
41
|
+
createdAt: Math.min(message.createdAt, durable.createdAt),
|
|
42
|
+
clientRequestId,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
if (replaced)
|
|
46
|
+
return next;
|
|
47
|
+
const assistantIndex = next.findIndex((message) => message.role === "assistant" && message.clientRequestId === clientRequestId);
|
|
48
|
+
if (assistantIndex < 0)
|
|
49
|
+
return [...next, durable];
|
|
50
|
+
return [
|
|
51
|
+
...next.slice(0, assistantIndex),
|
|
52
|
+
durable,
|
|
53
|
+
...next.slice(assistantIndex),
|
|
54
|
+
];
|
|
55
|
+
}
|
|
56
|
+
/** Keep an unconfirmed optimistic bubble when a recovery snapshot lacks it. */
|
|
57
|
+
export function mergePendingSubmissionOnHydration(canonical, pending) {
|
|
58
|
+
if (!pending || canonical.some((message) => message.clientRequestId === pending.clientRequestId))
|
|
59
|
+
return [...canonical];
|
|
60
|
+
return appendPendingSubmission(canonical, pending);
|
|
61
|
+
}
|
|
62
|
+
/** Drop only the unconfirmed optimistic rows for a submission. A durable row
|
|
63
|
+
* that already replaced the optimistic one is left untouched. */
|
|
64
|
+
export function removePendingSubmission(messages, clientRequestId) {
|
|
65
|
+
return messages.filter((message) => message.clientRequestId !== clientRequestId || message.pending !== true);
|
|
66
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { isSubagentTool } from "../../chat/tool-preview.js";
|
|
2
|
+
/**
|
|
3
|
+
* Count the collapsed-turn disclosure buckets exactly like DSH
|
|
4
|
+
* `TurnProcessNodeView`: tool calls, durable assistant replies and subagents,
|
|
5
|
+
* in that order. Built-in subagent delegations (`Agent` tool) count as
|
|
6
|
+
* subagents, not as ordinary tool calls (2026-09-08 alignment).
|
|
7
|
+
*
|
|
8
|
+
* @param items - ordered process nodes of one turn.
|
|
9
|
+
* @returns the three bucket counts.
|
|
10
|
+
*/
|
|
11
|
+
export function countTurnProcessItems(items) {
|
|
12
|
+
return countEntries(items.map((item) => ({ source: "process", item })));
|
|
13
|
+
}
|
|
14
|
+
function countEntries(entries) {
|
|
15
|
+
let toolCalls = 0;
|
|
16
|
+
let messages = 0;
|
|
17
|
+
let subagents = 0;
|
|
18
|
+
const assistantMessageIds = new Set();
|
|
19
|
+
for (const entry of entries) {
|
|
20
|
+
if (entry.source !== "process")
|
|
21
|
+
continue;
|
|
22
|
+
const item = entry.item;
|
|
23
|
+
if (item.kind === "tool") {
|
|
24
|
+
if (isSubagentTool(item.tool.toolName))
|
|
25
|
+
subagents += 1;
|
|
26
|
+
else
|
|
27
|
+
toolCalls += 1;
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
if (item.kind === "activity" || item.kind === "dag-progress") {
|
|
31
|
+
toolCalls += item.toolCallCount ?? 0;
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
if (item.kind !== "text" || item.text.trim() === "")
|
|
35
|
+
continue;
|
|
36
|
+
if (item.assistantMessageId)
|
|
37
|
+
assistantMessageIds.add(item.assistantMessageId);
|
|
38
|
+
else
|
|
39
|
+
messages += 1;
|
|
40
|
+
}
|
|
41
|
+
messages += assistantMessageIds.size;
|
|
42
|
+
return { toolCalls, messages, subagents };
|
|
43
|
+
}
|
|
44
|
+
/** Count only the ordered process window; prelude/post-answer nodes are kept
|
|
45
|
+
* visible but do not inflate the DSH compact disclosure summary. */
|
|
46
|
+
export function countTurnFlowItems(entries) {
|
|
47
|
+
return countEntries(entries);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Summary label for a completed turn's process disclosure.
|
|
51
|
+
*
|
|
52
|
+
* @param counts - bucket counts from {@link countTurnProcessItems}.
|
|
53
|
+
* @returns `N 次工具调用 · M 条消息 · K 个 subagent`, or「已思考」when empty.
|
|
54
|
+
*/
|
|
55
|
+
export function buildTurnProcessLabel(counts) {
|
|
56
|
+
return ([
|
|
57
|
+
counts.toolCalls > 0 ? `${counts.toolCalls} 次工具调用` : "",
|
|
58
|
+
counts.messages > 0 ? `${counts.messages} 条消息` : "",
|
|
59
|
+
counts.subagents > 0 ? `${counts.subagents} 个 subagent` : "",
|
|
60
|
+
]
|
|
61
|
+
.filter(Boolean)
|
|
62
|
+
.join(" · ") || "已思考");
|
|
63
|
+
}
|
|
@@ -27,8 +27,11 @@ export function buildPaletteModel(entries) {
|
|
|
27
27
|
for (const source of SLASH_GROUP_DISPLAY_ORDER) {
|
|
28
28
|
const items = [];
|
|
29
29
|
for (let i = 0; i < entries.length; i += 1) {
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
const entry = entries[i];
|
|
31
|
+
if (!entry)
|
|
32
|
+
continue;
|
|
33
|
+
if (entry.source === source) {
|
|
34
|
+
items.push({ entry, globalIndex: i });
|
|
32
35
|
}
|
|
33
36
|
}
|
|
34
37
|
if (items.length === 0)
|
|
@@ -69,6 +72,8 @@ export function movePaletteIndex(currentIndex, model, columns, direction) {
|
|
|
69
72
|
if (groupPos < 0)
|
|
70
73
|
return currentIndex;
|
|
71
74
|
const group = model[groupPos];
|
|
75
|
+
if (!group)
|
|
76
|
+
return currentIndex;
|
|
72
77
|
const offset = group.items.findIndex((card) => card.globalIndex === currentIndex);
|
|
73
78
|
if (offset < 0)
|
|
74
79
|
return currentIndex;
|
|
@@ -84,25 +89,30 @@ export function movePaletteIndex(currentIndex, model, columns, direction) {
|
|
|
84
89
|
}
|
|
85
90
|
if (Math.floor(targetOffset / columns) !== row)
|
|
86
91
|
return currentIndex;
|
|
87
|
-
|
|
92
|
+
const targetCard = group.items[targetOffset];
|
|
93
|
+
return targetCard ? targetCard.globalIndex : currentIndex;
|
|
88
94
|
}
|
|
89
95
|
const delta = direction === "up" ? -1 : 1;
|
|
90
96
|
const targetOffset = offset + delta * columns;
|
|
91
97
|
if (targetOffset >= 0 && targetOffset < group.items.length) {
|
|
92
|
-
|
|
98
|
+
const targetCard = group.items[targetOffset];
|
|
99
|
+
return targetCard ? targetCard.globalIndex : currentIndex;
|
|
93
100
|
}
|
|
94
101
|
// Cross-group: walk to the previous/next non-empty group and target the
|
|
95
102
|
// same column on its last (up) / first (down) row; stick when that column
|
|
96
103
|
// does not exist in the partial edge row.
|
|
97
104
|
for (let cursor = groupPos + delta; cursor >= 0 && cursor < model.length; cursor += delta) {
|
|
98
105
|
const candidate = model[cursor];
|
|
106
|
+
if (!candidate)
|
|
107
|
+
continue;
|
|
99
108
|
if (candidate.items.length === 0)
|
|
100
109
|
continue;
|
|
101
110
|
const lastRowStart = Math.floor((candidate.items.length - 1) / columns) * columns;
|
|
102
111
|
const target = direction === "up" ? lastRowStart + col : col;
|
|
103
112
|
if (target >= candidate.items.length)
|
|
104
113
|
return currentIndex;
|
|
105
|
-
|
|
114
|
+
const targetCard = candidate.items[target];
|
|
115
|
+
return targetCard ? targetCard.globalIndex : currentIndex;
|
|
106
116
|
}
|
|
107
117
|
return currentIndex;
|
|
108
118
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
function anchorAt(group) {
|
|
2
|
+
return group.user?.createdAt ?? group.assistants[0]?.createdAt ?? 0;
|
|
3
|
+
}
|
|
4
|
+
function pendingAt(item) {
|
|
5
|
+
const at = Date.parse(item.updatedAt);
|
|
6
|
+
return Number.isFinite(at) ? at : Number.MAX_SAFE_INTEGER;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Merge pending (dispatching/queued) user steering into the message timeline
|
|
10
|
+
* by timestamp instead of always rendering at the very end. A pending message
|
|
11
|
+
* whose `updatedAt` precedes an already-rendered turn keeps its real slot; a
|
|
12
|
+
* stable sort preserves current group order for equal anchors (turns first).
|
|
13
|
+
*/
|
|
14
|
+
export function mergePendingIntoTimeline(input) {
|
|
15
|
+
const entries = [];
|
|
16
|
+
for (const group of input.turnGroups) {
|
|
17
|
+
entries.push({ kind: "group", group });
|
|
18
|
+
}
|
|
19
|
+
for (const item of input.pendingSteering) {
|
|
20
|
+
if (item.state !== "dispatching")
|
|
21
|
+
continue;
|
|
22
|
+
entries.push({ kind: "pending", item });
|
|
23
|
+
}
|
|
24
|
+
return entries.sort((a, b) => {
|
|
25
|
+
const atA = a.kind === "group" ? anchorAt(a.group) : pendingAt(a.item);
|
|
26
|
+
const atB = b.kind === "group" ? anchorAt(b.group) : pendingAt(b.item);
|
|
27
|
+
return atA - atB;
|
|
28
|
+
});
|
|
29
|
+
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* ADR 0011: full Pi tools + optional safe-* explore surface.
|
|
3
|
+
* The `Agent` (Explore) entry is injected from capabilities.builtinSubagents
|
|
4
|
+
* (ADR 0022 server truth); the static entry below is only a fallback for
|
|
5
|
+
* older backends that do not send the field yet.
|
|
3
6
|
*/
|
|
4
|
-
const
|
|
7
|
+
const STATIC_EXPLORE_TOOLS = [
|
|
5
8
|
{
|
|
6
9
|
toolId: "read",
|
|
7
10
|
kind: "explore",
|
|
@@ -58,17 +61,42 @@ const EXPLORE_TOOLS = [
|
|
|
58
61
|
description: "固定参数查看 git diff;敏感路径不可查看且结果自动脱敏。",
|
|
59
62
|
},
|
|
60
63
|
];
|
|
64
|
+
/** Fallback when the backend does not advertise builtinSubagents yet. */
|
|
65
|
+
const FALLBACK_AGENT_ENTRY = {
|
|
66
|
+
toolId: "Agent",
|
|
67
|
+
kind: "explore",
|
|
68
|
+
description: "启动内置只读 Explore 子 Agent,执行代码库搜索、符号查找和调用链追踪。",
|
|
69
|
+
};
|
|
61
70
|
export function buildToolCatalog(capabilities) {
|
|
62
71
|
if (!capabilities)
|
|
63
72
|
return null;
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
73
|
+
const operatorToolsById = new Map();
|
|
74
|
+
for (const tool of [
|
|
75
|
+
...(capabilities.tools ?? []),
|
|
76
|
+
...(capabilities.builtinCustomTools ?? []),
|
|
77
|
+
]) {
|
|
78
|
+
if (operatorToolsById.has(tool.toolId))
|
|
79
|
+
continue;
|
|
80
|
+
operatorToolsById.set(tool.toolId, {
|
|
81
|
+
toolId: tool.toolId,
|
|
82
|
+
action: tool.action,
|
|
83
|
+
description: tool.description,
|
|
84
|
+
kind: tool.kind ?? "read",
|
|
85
|
+
cli: tool.cli,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
const operatorTools = [...operatorToolsById.values()];
|
|
89
|
+
// ADR 0022: subagents come from the server's builtinSubagents field;
|
|
90
|
+
// static entries never duplicate a server-advertised toolId.
|
|
91
|
+
const subagentTools = (capabilities.builtinSubagents ?? []).map((s) => ({
|
|
92
|
+
toolId: s.toolId,
|
|
93
|
+
description: s.description,
|
|
94
|
+
kind: "explore",
|
|
70
95
|
}));
|
|
71
|
-
const
|
|
96
|
+
const staticTools = subagentTools.length > 0
|
|
97
|
+
? STATIC_EXPLORE_TOOLS
|
|
98
|
+
: [...STATIC_EXPLORE_TOOLS, FALLBACK_AGENT_ENTRY];
|
|
99
|
+
const explore = [...staticTools, ...subagentTools];
|
|
72
100
|
return {
|
|
73
101
|
explore,
|
|
74
102
|
operator: operatorTools,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export const TRANSCRIPT_MODE_STORAGE_KEY = "loop-console.operator-chat.transcript-mode.v1";
|
|
2
|
+
export function parseTranscriptMode(value) {
|
|
3
|
+
return value === "compact" || value === "full" ? value : null;
|
|
4
|
+
}
|
|
5
|
+
export function loadTranscriptMode(storage) {
|
|
6
|
+
try {
|
|
7
|
+
return parseTranscriptMode(storage?.getItem(TRANSCRIPT_MODE_STORAGE_KEY)) ?? "compact";
|
|
8
|
+
}
|
|
9
|
+
catch {
|
|
10
|
+
return "compact";
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export function saveTranscriptMode(mode, storage) {
|
|
14
|
+
try {
|
|
15
|
+
storage?.setItem(TRANSCRIPT_MODE_STORAGE_KEY, mode);
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
// Preference storage is optional.
|
|
19
|
+
}
|
|
20
|
+
return mode;
|
|
21
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
function sameReferences(previous, next) {
|
|
2
|
+
return (previous.length === next.length &&
|
|
3
|
+
previous.every((value, index) => value === next[index]));
|
|
4
|
+
}
|
|
5
|
+
/** A completed group's rendered projection is reusable only while every source
|
|
6
|
+
* object that feeds grouping and process-item derivation remains unchanged. */
|
|
7
|
+
export function sameTurnGroupInputs(previous, next) {
|
|
8
|
+
return (previous.key === next.key &&
|
|
9
|
+
previous.user === next.user &&
|
|
10
|
+
previous.turnState === next.turnState &&
|
|
11
|
+
previous.turnClosed === next.turnClosed &&
|
|
12
|
+
previous.live === next.live &&
|
|
13
|
+
sameReferences(previous.assistants, next.assistants) &&
|
|
14
|
+
sameReferences(previous.tools, next.tools) &&
|
|
15
|
+
sameReferences(previous.conversationItems ?? [], next.conversationItems ?? []));
|
|
16
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export function turnProcessDisclosureKey(groupKey, answerId) {
|
|
2
|
+
return `${groupKey}:generation-${answerId ?? "none"}`;
|
|
3
|
+
}
|
|
4
|
+
export function isTurnProcessCompact(input) {
|
|
5
|
+
const eligible = !input.historyHasMore &&
|
|
6
|
+
input.turnClosed &&
|
|
7
|
+
input.hasFinalAnswer &&
|
|
8
|
+
input.processItemCount > 0;
|
|
9
|
+
if (!eligible)
|
|
10
|
+
return false;
|
|
11
|
+
if (input.manualOpen)
|
|
12
|
+
return false;
|
|
13
|
+
if (input.manualClosed)
|
|
14
|
+
return true;
|
|
15
|
+
if (input.mode === "full")
|
|
16
|
+
return false;
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
export const TURN_STATE_RECONCILE_DELAYS_MS = [0, 75, 200, 500];
|
|
2
|
+
export const TURN_STATE_QUEUE_RETRY_DELAYS_MS = [0, 75, 200, 500, 2_000];
|
|
3
|
+
const MAX_TURN_STATE_QUERY_BATCH = 8;
|
|
4
|
+
/** Normalize server turn facts. Queued is externally still an open/running Turn. */
|
|
5
|
+
export function normalizeDurableTurnState(state) {
|
|
6
|
+
if (state === "queued" || state === "running")
|
|
7
|
+
return "running";
|
|
8
|
+
if (state === "settled" || state === "aborted" || state === "failed") {
|
|
9
|
+
return state;
|
|
10
|
+
}
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
/** Merge authoritative summaries without deleting older paginated Turn facts. */
|
|
14
|
+
export function mergeTurnStateSummaries(current, summaries) {
|
|
15
|
+
if (!summaries?.length)
|
|
16
|
+
return current;
|
|
17
|
+
let next;
|
|
18
|
+
for (const summary of summaries) {
|
|
19
|
+
if (typeof summary.turnId !== "string" || !summary.turnId)
|
|
20
|
+
continue;
|
|
21
|
+
const state = normalizeDurableTurnState(summary.state);
|
|
22
|
+
const previous = next?.[summary.turnId] ?? current[summary.turnId];
|
|
23
|
+
const merged = mergeDurableTurnState(previous, state);
|
|
24
|
+
if (!merged || previous === merged)
|
|
25
|
+
continue;
|
|
26
|
+
next ??= { ...current };
|
|
27
|
+
next[summary.turnId] = merged;
|
|
28
|
+
}
|
|
29
|
+
return next ?? current;
|
|
30
|
+
}
|
|
31
|
+
export function setProjectedTurnState(current, turnId, state) {
|
|
32
|
+
if (!turnId)
|
|
33
|
+
return current;
|
|
34
|
+
const normalized = normalizeDurableTurnState(state);
|
|
35
|
+
const merged = mergeDurableTurnState(current[turnId], normalized);
|
|
36
|
+
if (!merged || current[turnId] === merged) {
|
|
37
|
+
return current;
|
|
38
|
+
}
|
|
39
|
+
return { ...current, [turnId]: merged };
|
|
40
|
+
}
|
|
41
|
+
function mergeDurableTurnState(current, incoming) {
|
|
42
|
+
if (!incoming)
|
|
43
|
+
return current;
|
|
44
|
+
if (!current)
|
|
45
|
+
return incoming;
|
|
46
|
+
if (current === "failed" || current === "aborted")
|
|
47
|
+
return current;
|
|
48
|
+
if (current === "settled" && incoming === "running")
|
|
49
|
+
return current;
|
|
50
|
+
return incoming;
|
|
51
|
+
}
|
|
52
|
+
export function turnStateReconcileTrigger(replay, eventName) {
|
|
53
|
+
if (eventName !== "agent_settled")
|
|
54
|
+
return undefined;
|
|
55
|
+
return replay ? "after-replay" : "immediate";
|
|
56
|
+
}
|
|
57
|
+
export async function reconcileTurnStateWithBackoff(input) {
|
|
58
|
+
const delays = input.delaysMs ?? TURN_STATE_RECONCILE_DELAYS_MS;
|
|
59
|
+
const wait = input.wait ??
|
|
60
|
+
((delayMs) => new Promise((resolve) => globalThis.setTimeout(resolve, delayMs)));
|
|
61
|
+
for (const delayMs of delays) {
|
|
62
|
+
if (delayMs > 0)
|
|
63
|
+
await wait(delayMs);
|
|
64
|
+
if (input.isCancelled?.())
|
|
65
|
+
return "cancelled";
|
|
66
|
+
let snapshot = null;
|
|
67
|
+
try {
|
|
68
|
+
snapshot = await input.read();
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
// A transport failure consumes one bounded attempt; later attempts or an
|
|
72
|
+
// SSE reconnect retain ownership of the pending reconciliation.
|
|
73
|
+
}
|
|
74
|
+
if (input.isCancelled?.())
|
|
75
|
+
return "cancelled";
|
|
76
|
+
if (!snapshot?.turnStates)
|
|
77
|
+
continue;
|
|
78
|
+
input.apply(snapshot.turnStates);
|
|
79
|
+
const state = snapshot.turnStates
|
|
80
|
+
.filter((summary) => summary.turnId === input.turnId)
|
|
81
|
+
.map((summary) => normalizeDurableTurnState(summary.state))
|
|
82
|
+
.find((candidate) => candidate !== undefined);
|
|
83
|
+
if (state && state !== "running")
|
|
84
|
+
return "terminal";
|
|
85
|
+
}
|
|
86
|
+
return "pending";
|
|
87
|
+
}
|
|
88
|
+
/** Serialize targeted Turn-state reads, batching replay work and retaining
|
|
89
|
+
* unresolved Turns until durable terminal truth arrives or the owner ends. */
|
|
90
|
+
export function createTurnStateReconcileQueue(input) {
|
|
91
|
+
const pending = new Set();
|
|
92
|
+
const wait = input.wait ??
|
|
93
|
+
((delayMs) => new Promise((resolve) => globalThis.setTimeout(resolve, delayMs)));
|
|
94
|
+
const retryDelays = input.retryDelaysMs?.length
|
|
95
|
+
? input.retryDelaysMs
|
|
96
|
+
: TURN_STATE_QUEUE_RETRY_DELAYS_MS;
|
|
97
|
+
let worker = null;
|
|
98
|
+
const run = async () => {
|
|
99
|
+
let retryIndex = 0;
|
|
100
|
+
while (pending.size > 0 && !input.isCancelled?.()) {
|
|
101
|
+
const delayMs = retryDelays[Math.min(retryIndex, retryDelays.length - 1)] ?? 0;
|
|
102
|
+
if (delayMs > 0) {
|
|
103
|
+
try {
|
|
104
|
+
await wait(delayMs);
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
if (input.isCancelled?.())
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
if (input.isCancelled?.())
|
|
112
|
+
return;
|
|
113
|
+
const batch = [...pending].slice(0, MAX_TURN_STATE_QUERY_BATCH);
|
|
114
|
+
let snapshot = null;
|
|
115
|
+
try {
|
|
116
|
+
snapshot = await input.read(batch);
|
|
117
|
+
}
|
|
118
|
+
catch {
|
|
119
|
+
// The queue owns retry cadence; a transient read failure keeps the batch pending.
|
|
120
|
+
}
|
|
121
|
+
if (input.isCancelled?.())
|
|
122
|
+
return;
|
|
123
|
+
const summaries = snapshot?.turnStates;
|
|
124
|
+
if (summaries?.length)
|
|
125
|
+
input.apply(summaries);
|
|
126
|
+
let completed = 0;
|
|
127
|
+
for (const turnId of batch) {
|
|
128
|
+
const state = summaries
|
|
129
|
+
?.filter((summary) => summary.turnId === turnId)
|
|
130
|
+
.map((summary) => normalizeDurableTurnState(summary.state))
|
|
131
|
+
.find((candidate) => candidate !== undefined);
|
|
132
|
+
if (state && state !== "running") {
|
|
133
|
+
pending.delete(turnId);
|
|
134
|
+
completed += 1;
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
// Rotate unresolved ids so batches larger than the server query cap cannot starve.
|
|
138
|
+
pending.delete(turnId);
|
|
139
|
+
pending.add(turnId);
|
|
140
|
+
}
|
|
141
|
+
retryIndex = completed > 0 ? 0 : retryIndex + 1;
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
const start = () => {
|
|
145
|
+
if (worker)
|
|
146
|
+
return worker;
|
|
147
|
+
if (pending.size === 0 || input.isCancelled?.())
|
|
148
|
+
return Promise.resolve();
|
|
149
|
+
worker = run().finally(() => {
|
|
150
|
+
worker = null;
|
|
151
|
+
if (pending.size > 0 && !input.isCancelled?.())
|
|
152
|
+
void start();
|
|
153
|
+
});
|
|
154
|
+
return worker;
|
|
155
|
+
};
|
|
156
|
+
return {
|
|
157
|
+
enqueue: (turnId, options) => {
|
|
158
|
+
if (!turnId || input.isCancelled?.())
|
|
159
|
+
return;
|
|
160
|
+
pending.add(turnId);
|
|
161
|
+
if (!options?.defer)
|
|
162
|
+
void start();
|
|
163
|
+
},
|
|
164
|
+
start,
|
|
165
|
+
};
|
|
166
|
+
}
|
|
@@ -19,11 +19,65 @@ export const OPERATOR_CHAT_REAL_PATHS = {
|
|
|
19
19
|
events: "/api/operator/v1/chat/sessions/:sessionId/events",
|
|
20
20
|
abort: "/api/operator/v1/chat/sessions/:sessionId/turns/:turnId/abort",
|
|
21
21
|
};
|
|
22
|
+
const MAX_STATE_TURN_IDS = 8;
|
|
23
|
+
const MAX_STATE_TURN_ID_CHARS = 240;
|
|
24
|
+
function boundedStateTurnIds(turnIds) {
|
|
25
|
+
const result = [];
|
|
26
|
+
const seen = new Set();
|
|
27
|
+
for (const raw of turnIds ?? []) {
|
|
28
|
+
const turnId = raw.trim();
|
|
29
|
+
if (!turnId ||
|
|
30
|
+
turnId.length > MAX_STATE_TURN_ID_CHARS ||
|
|
31
|
+
seen.has(turnId)) {
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
seen.add(turnId);
|
|
35
|
+
result.push(turnId);
|
|
36
|
+
if (result.length >= MAX_STATE_TURN_IDS)
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
return result;
|
|
40
|
+
}
|
|
22
41
|
export function operatorChatTurnsUrl(origin, sessionId) {
|
|
23
42
|
return `${origin}/api/operator/v1/chat/sessions/${encodeURIComponent(sessionId)}/turns`;
|
|
24
43
|
}
|
|
25
|
-
export function operatorChatStateUrl(origin, sessionId) {
|
|
26
|
-
|
|
44
|
+
export function operatorChatStateUrl(origin, sessionId, turnIds) {
|
|
45
|
+
const base = `${origin}/api/operator/v1/chat/sessions/${encodeURIComponent(sessionId)}/state`;
|
|
46
|
+
const bounded = boundedStateTurnIds(turnIds);
|
|
47
|
+
if (bounded.length === 0)
|
|
48
|
+
return base;
|
|
49
|
+
const query = new URLSearchParams();
|
|
50
|
+
for (const turnId of bounded)
|
|
51
|
+
query.append("turnId", turnId);
|
|
52
|
+
return `${base}?${query.toString()}`;
|
|
53
|
+
}
|
|
54
|
+
/** Compose session ownership with a short request timeout and explicit cleanup. */
|
|
55
|
+
export function createBoundedOwnerSignal(input) {
|
|
56
|
+
const controller = new AbortController();
|
|
57
|
+
const abortFromOwner = () => controller.abort(input.ownerSignal?.reason);
|
|
58
|
+
if (input.ownerSignal?.aborted)
|
|
59
|
+
abortFromOwner();
|
|
60
|
+
else
|
|
61
|
+
input.ownerSignal?.addEventListener("abort", abortFromOwner, { once: true });
|
|
62
|
+
const schedule = input.schedule ??
|
|
63
|
+
((callback, delayMs) => globalThis.setTimeout(callback, delayMs));
|
|
64
|
+
const cancel = input.cancel ??
|
|
65
|
+
((handle) => globalThis.clearTimeout(handle));
|
|
66
|
+
const timer = controller.signal.aborted
|
|
67
|
+
? undefined
|
|
68
|
+
: schedule(() => controller.abort(new Error("Operator Chat state request timed out")), input.timeoutMs);
|
|
69
|
+
let disposed = false;
|
|
70
|
+
return {
|
|
71
|
+
signal: controller.signal,
|
|
72
|
+
dispose: () => {
|
|
73
|
+
if (disposed)
|
|
74
|
+
return;
|
|
75
|
+
disposed = true;
|
|
76
|
+
if (timer !== undefined)
|
|
77
|
+
cancel(timer);
|
|
78
|
+
input.ownerSignal?.removeEventListener("abort", abortFromOwner);
|
|
79
|
+
},
|
|
80
|
+
};
|
|
27
81
|
}
|
|
28
82
|
export function operatorChatEventsUrl(origin, sessionId) {
|
|
29
83
|
return `${origin}/api/operator/v1/chat/sessions/${encodeURIComponent(sessionId)}/events`;
|
|
@@ -224,6 +278,7 @@ export function applyAdoptActiveOwnership(bag, input) {
|
|
|
224
278
|
releaseSubmitOwnership(bag, input.pending.clientRequestId);
|
|
225
279
|
if (!input.current)
|
|
226
280
|
return;
|
|
281
|
+
input.ui?.removePendingMessage?.(input.pending.clientRequestId);
|
|
227
282
|
input.ui?.clearEmptyAssistant(input.assistantId);
|
|
228
283
|
input.ui?.setInput(input.text);
|
|
229
284
|
input.ui?.setPendingImages(input.images);
|
|
@@ -253,6 +308,7 @@ export function applyRejectedOwnership(bag, input) {
|
|
|
253
308
|
input.ui?.setStreaming(false);
|
|
254
309
|
input.ui?.setStreamingAssistantId(null);
|
|
255
310
|
input.ui?.clearEmptyAssistant(input.assistantId);
|
|
311
|
+
input.ui?.removePendingMessage?.(input.pending.clientRequestId);
|
|
256
312
|
input.ui?.setInput(input.text);
|
|
257
313
|
input.ui?.setPendingImages(input.images);
|
|
258
314
|
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { useEffect, useLayoutEffect, useRef } from "react";
|
|
2
|
+
/** Whether this browser can reveal `hidden="until-found"` content through
|
|
3
|
+
* `beforematch` (Chrome 102+, Firefox 148+, Safari: not supported at all).
|
|
4
|
+
* `content-visibility` support does NOT imply this — Safari 18+ and
|
|
5
|
+
* Firefox 125–147 have the former without the latter. */
|
|
6
|
+
function supportsUntilFound() {
|
|
7
|
+
return typeof document !== "undefined" && "onbeforematch" in document.body;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Collapse content without removing it from the document: the element gets
|
|
11
|
+
* `hidden="until-found"` so browser find-in-page can still reach the text, and
|
|
12
|
+
* a match fires `beforematch`, which reveals (expands) the disclosure again.
|
|
13
|
+
*
|
|
14
|
+
* Mirrors DSH `useSearchableHidden` (2026-09-08 alignment). Browsers without
|
|
15
|
+
* `until-found` support get a plain `hidden=""` element, which keeps the
|
|
16
|
+
* pre-alignment behavior (collapsed and not searchable).
|
|
17
|
+
*
|
|
18
|
+
* @param hidden - whether the content is collapsed.
|
|
19
|
+
* @param reveal - expand callback invoked on `beforematch` and when the
|
|
20
|
+
* collapsed subtree already owns focus.
|
|
21
|
+
* @returns ref for the collapsible container.
|
|
22
|
+
*/
|
|
23
|
+
export function useSearchableHidden(hidden, reveal) {
|
|
24
|
+
const ref = useRef(null);
|
|
25
|
+
useLayoutEffect(() => {
|
|
26
|
+
const element = ref.current;
|
|
27
|
+
if (element === null)
|
|
28
|
+
return;
|
|
29
|
+
// Focus would otherwise be lost inside a hidden subtree.
|
|
30
|
+
if (hidden && element.contains(element.ownerDocument.activeElement)) {
|
|
31
|
+
reveal();
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (hidden) {
|
|
35
|
+
element.setAttribute("hidden", supportsUntilFound() ? "until-found" : "");
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
element.removeAttribute("hidden");
|
|
39
|
+
}
|
|
40
|
+
}, [hidden, reveal]);
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
const element = ref.current;
|
|
43
|
+
if (element === null)
|
|
44
|
+
return;
|
|
45
|
+
element.addEventListener("beforematch", reveal);
|
|
46
|
+
return () => {
|
|
47
|
+
element.removeEventListener("beforematch", reveal);
|
|
48
|
+
};
|
|
49
|
+
}, [reveal]);
|
|
50
|
+
return ref;
|
|
51
|
+
}
|