@tea-agent/loop-agent 0.1.0-fe-test.2 → 0.1.0-fe-test.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +6 -3
- package/CHANGELOG.md +607 -93
- package/README.md +11 -5
- package/bin/loop-agent.js +7 -3
- package/dist/adapters/context-transfer/optional-pi-handoff.js +31 -0
- package/dist/adapters/context-transfer/pi-session.js +61 -0
- package/dist/application/dag/generate-task-dag.js +90 -21
- package/dist/application/dag/run-dag.js +41 -0
- package/dist/application/task-lifecycle/advance.js +40 -5
- package/dist/application/task-lifecycle/observe.js +171 -17
- package/dist/application/task-lifecycle/plan-transitions.js +42 -7
- package/dist/application/task-lifecycle/recommendations.js +13 -2
- package/dist/build-stamp.json +3 -3
- package/dist/cli/command-definitions.js +44 -10
- package/dist/cli/program.js +82 -6
- package/dist/cli/update/notifier.js +2 -2
- package/dist/cli/update/runtime-activity.js +1 -29
- package/dist/cli.js +2 -1
- package/dist/commands/client-recovery.js +11 -36
- package/dist/commands/dag-artifact.js +284 -0
- package/dist/commands/dag-context.js +184 -0
- package/dist/commands/dag-follow-up.js +138 -0
- package/dist/commands/dag-rerun-task.js +2 -0
- package/dist/commands/dag-rerun.js +261 -2
- package/dist/commands/init-model-catalog.js +486 -0
- package/dist/commands/init-upgrade.js +265 -97
- package/dist/commands/init.js +455 -28
- package/dist/commands/inspect-next.js +8 -0
- package/dist/commands/task-advance.js +73 -1
- package/dist/commands/task-source-prepare.js +5 -0
- package/dist/commands/task-status.js +1 -0
- package/dist/executors/dag-pi-executor.js +4321 -231
- package/dist/executors/pi-event-serializer.js +42 -1
- package/dist/executors/pi-executor.js +70 -6
- package/dist/executors/pi-extension-resolver.js +245 -0
- package/dist/executors/pi-playwright-cli-tool.js +74 -28
- package/dist/executors/pi-read-budget-policy.js +239 -0
- package/dist/executors/pi-sdk-executor.js +263 -59
- package/dist/executors/pi-writer-tool-policy.js +57 -1
- package/dist/executors/shell-executor.js +1443 -240
- package/dist/executors/shell-write-guard.js +14 -0
- package/dist/executors/workspace-write-snapshot.js +68 -0
- package/dist/governance/checks.js +1 -0
- package/dist/{worker → infrastructure}/console/app-data.js +4 -0
- package/dist/infrastructure/console/artifact-revision-store.js +430 -0
- package/dist/infrastructure/console/context-export-store.js +160 -0
- package/dist/infrastructure/console/dir-lock.js +132 -0
- package/dist/infrastructure/console/operation-store.js +417 -0
- package/dist/infrastructure/harness/artifact-store.js +10 -1
- package/dist/infrastructure/harness/atomic-write.js +35 -2
- package/dist/shared/context-transfer/artifact-revision.js +172 -0
- package/dist/shared/context-transfer.js +418 -0
- package/dist/shared/dag-failure-category.js +150 -0
- package/dist/shared/dag-prompt-override.js +27 -0
- package/dist/shared/openspec-spec.js +70 -4
- package/dist/shared/operator/capabilities.js +65 -4
- package/dist/shared/operator/safe-run-summary.js +1 -0
- package/dist/shared/path-safety.js +93 -0
- package/dist/shared/pi-context-pressure/checkpoint.js +116 -0
- package/dist/shared/pi-context-pressure/compaction-policy.js +151 -0
- package/dist/shared/pi-context-pressure/env.js +58 -0
- package/dist/shared/pi-context-pressure/extension.js +100 -0
- package/dist/shared/pi-context-pressure/index.js +7 -0
- package/dist/shared/pi-context-pressure/overflow.js +252 -0
- package/dist/shared/pi-context-pressure/sift-bridge.js +386 -0
- package/dist/shared/pi-context-pressure/telemetry.js +51 -0
- package/dist/shared/playwright-cli-command-policy.js +15 -0
- package/dist/shared/preview.js +28 -4
- package/dist/shared/update/console-notifier.js +100 -0
- package/dist/{cli → shared}/update/npm-client.js +70 -15
- package/dist/{cli → shared}/update/state.js +41 -13
- package/dist/task/config-types.js +125 -6
- package/dist/task/contract/adopt.js +4 -0
- package/dist/task/contract/apply.js +11 -1
- package/dist/task/contract/constants.js +3 -0
- package/dist/task/contract/diff.js +26 -0
- package/dist/task/contract/hash.js +3 -0
- package/dist/task/contract/import-revision.js +4 -0
- package/dist/task/contract/observe.js +25 -4
- package/dist/task/contract/paths.js +2 -1
- package/dist/task/contract/project.js +23 -1
- package/dist/task/contract/schema.js +9 -1
- package/dist/task/contract/transaction.js +12 -0
- package/dist/task/frontend-project-capability.js +203 -20
- package/dist/task/runtime.js +5 -2
- package/dist/task/source-prepare/build-draft.js +18 -3
- package/dist/task/source-prepare/completeness.js +188 -0
- package/dist/task/source-prepare/fragment-inventory.js +513 -0
- package/dist/task/source-prepare/index.js +3 -0
- package/dist/task/source-prepare/ledger-reconciliation.js +127 -0
- package/dist/task/source-prepare/ledger-review.js +214 -0
- package/dist/task/source-prepare/ledger.js +545 -0
- package/dist/task/source-prepare/parse-intent.js +24 -4
- package/dist/task/source-prepare/prepare.js +368 -2
- package/dist/task/source-prepare/semantic-intake.js +25 -5
- package/dist/task/source-prepare/source-fidelity-pi.js +384 -0
- package/dist/task/source-prepare/types.js +22 -0
- package/dist/task/source-references.js +22 -1
- package/dist/task/task-demand-routing.js +3 -0
- package/dist/worker/cli.js +18 -2
- package/dist/worker/console/chat/assistant-content.js +7 -0
- package/dist/worker/console/chat/chat-event-store.js +159 -18
- package/dist/worker/console/chat/chat-ui-policy.js +4 -2
- package/dist/worker/console/chat/context-panel.js +7 -0
- package/dist/worker/console/chat/deferred-turn.js +103 -0
- package/dist/worker/console/chat/goal-round-driver.js +72 -0
- package/dist/worker/console/chat/goals.js +300 -0
- package/dist/worker/console/chat/model-resolver.js +7 -4
- package/dist/worker/console/chat/operation-card.js +8 -1
- package/dist/worker/console/chat/pi-console-config.js +81 -10
- package/dist/worker/console/chat/pi-runtime.js +868 -30
- package/dist/worker/console/chat/provider-error.js +99 -0
- package/dist/worker/console/chat/repo-browser.js +101 -12
- package/dist/worker/console/chat/resource-preferences-store.js +1 -1
- package/dist/worker/console/chat/routes.js +1451 -145
- package/dist/worker/console/chat/sdd-data-alignment.js +222 -0
- package/dist/worker/console/chat/semantic-activity.js +25 -24
- package/dist/worker/console/chat/session-catalog.js +50 -0
- package/dist/worker/console/chat/session-stats.js +275 -0
- package/dist/worker/console/chat/session-store.js +348 -76
- package/dist/worker/console/chat/shortcuts.js +26 -3
- package/dist/worker/console/chat/sift-bridge.js +1 -0
- package/dist/worker/console/chat/todos.js +115 -0
- package/dist/worker/console/chat/tool-preview.js +42 -0
- package/dist/worker/console/chat/turn-process.js +185 -112
- package/dist/worker/console/chat/user-questions.js +266 -0
- package/dist/worker/console/chat/workspace-landing.js +79 -0
- package/dist/worker/console/console-handoff.js +82 -0
- package/dist/worker/console/console-update-and-init.js +115 -0
- package/dist/worker/console/console-update-runtime.js +84 -0
- package/dist/worker/console/context-transfer-diagnostics.js +198 -0
- package/dist/worker/console/dag-confirmation.js +1 -1
- package/dist/worker/console/dag-execution-receipt.js +54 -3
- package/dist/worker/console/doctor.js +1 -1
- package/dist/worker/console/draft-store.js +50 -1
- package/dist/worker/console/frontend-human-decision-adapter.js +19 -0
- package/dist/worker/console/frontend-split-operation-adapter.js +20 -0
- package/dist/worker/console/human-gate-token.js +1 -1
- package/dist/worker/console/index.js +6 -3
- package/dist/worker/console/inspect-split.js +18 -0
- package/dist/worker/console/interview/assessment.js +1 -1
- package/dist/worker/console/interview/session.js +1 -1
- package/dist/worker/console/native-directory-picker.js +13 -0
- package/dist/worker/console/operation-run-facts.js +19 -3
- package/dist/worker/console/operation-runner.js +45 -4
- package/dist/worker/console/operation-sse.js +1 -1
- package/dist/worker/console/operation-wait.js +1 -1
- package/dist/worker/console/operator-actions.js +534 -15
- package/dist/worker/console/operator-selection.js +6 -2
- package/dist/worker/console/operator-surface-health.js +2 -1
- package/dist/worker/console/operator-user-error.js +171 -2
- package/dist/worker/console/pi-plugins.catalog.json +73658 -0
- package/dist/worker/console/pi-plugins.js +238 -0
- package/dist/worker/console/pi-readiness.js +7 -6
- package/dist/worker/console/prd-intake-bridge.js +13 -0
- package/dist/worker/console/recovery-cta.js +4 -4
- package/dist/worker/console/recovery-error-copy.js +4 -4
- package/dist/worker/console/routes.js +1231 -10
- package/dist/worker/console/security.js +102 -13
- package/dist/worker/console/server.js +762 -159
- package/dist/worker/console/static/assets/{abnfDiagram-N423BO3Z-BmOEx0gA.js → abnfDiagram-N423BO3Z-BZogYNl1.js} +1 -1
- package/dist/worker/console/static/assets/{arc-BGiVVe8b.js → arc-DcJTLe2v.js} +1 -1
- package/dist/worker/console/static/assets/{architectureDiagram-T3A2C74G-nDdu4rgJ.js → architectureDiagram-T3A2C74G-B39EQQ9n.js} +1 -1
- package/dist/worker/console/static/assets/{blockDiagram-VBNYF7ZC-Bb5u0BWf.js → blockDiagram-VBNYF7ZC-CitCGV56.js} +1 -1
- package/dist/worker/console/static/assets/{c4Diagram-5PPSVZJV-BlhC0j94.js → c4Diagram-5PPSVZJV-rvWuOHLG.js} +1 -1
- package/dist/worker/console/static/assets/channel-CXqdP5pW.js +1 -0
- package/dist/worker/console/static/assets/{chunk-2GRJ4B5K-Ai8_qQXI.js → chunk-2GRJ4B5K-DGXplIJs.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-2Q5K7J3B-B9gyCjqX.js → chunk-2Q5K7J3B-ur9OqjPn.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-5RXB4S5H-Bzbj3zGH.js → chunk-5RXB4S5H-D1KqU_Vi.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-5VM5RSS4-BT415PvT.js → chunk-5VM5RSS4-BlVZrbtM.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-6Q2QTUOP-D_A5_5QL.js → chunk-6Q2QTUOP-BAzz3nQy.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-GF5L2VYU-srJkaP3f.js → chunk-GF5L2VYU-CP_nYuCV.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-JWPE2WC7-UYGvEP4l.js → chunk-JWPE2WC7-CWvKQ80X.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-KBJHAD2P-B8luBrrz.js → chunk-KBJHAD2P-CyUki8wp.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-RYQCIY6F-DN7wXZSq.js → chunk-RYQCIY6F-5NYzNKfY.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-XXDRQBXY-DXKyMuKS.js → chunk-XXDRQBXY-DHdUgjS-.js} +1 -1
- package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-D9C3agF7.js +1 -0
- package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-D9C3agF7.js +1 -0
- package/dist/worker/console/static/assets/{cose-bilkent-JH36ORCC-dqvoynXj.js → cose-bilkent-JH36ORCC-ANQ5g_t6.js} +1 -1
- package/dist/worker/console/static/assets/{cynefin-VYW2F7L2--PcyL34A.js → cynefin-VYW2F7L2-CruT_4-0.js} +1 -1
- package/dist/worker/console/static/assets/{cynefinDiagram-MW4NZA55-DvWs_hTY.js → cynefinDiagram-MW4NZA55-rbFo77ID.js} +1 -1
- package/dist/worker/console/static/assets/{dagre-VZM6K2ZE-DxeIxbyO.js → dagre-VZM6K2ZE-asstxBQs.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-7IWD3JNH-DPCG61Of.js → diagram-7IWD3JNH-DzTyBZwI.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-B4RE2ZJO-CmuU50-U.js → diagram-B4RE2ZJO-gw8ccH3B.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-LBJQPF4R-B61XLD_v.js → diagram-LBJQPF4R-B8RpZzOf.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-Q27KOJAE-BB7HTRRY.js → diagram-Q27KOJAE-B1zJkCS9.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-UB23O5K3-DvkboAIp.js → diagram-UB23O5K3-B6JLWZmO.js} +1 -1
- package/dist/worker/console/static/assets/{ebnfDiagram-BXEA7PRR-BdJ_y1fL.js → ebnfDiagram-BXEA7PRR-q2iZP-Ps.js} +1 -1
- package/dist/worker/console/static/assets/{erDiagram-JOGREHBK-9bUBZTRi.js → erDiagram-JOGREHBK-B3dbbktQ.js} +1 -1
- package/dist/worker/console/static/assets/{flowDiagram-UKHOOZJN-Dw4L4RBa.js → flowDiagram-UKHOOZJN-C-zc6-kB.js} +1 -1
- package/dist/worker/console/static/assets/{ganttDiagram-PKOTCBZU-Jr82N_QP.js → ganttDiagram-PKOTCBZU-BSolnot9.js} +1 -1
- package/dist/worker/console/static/assets/{gitGraphDiagram-DS77QQ5N-DAz9wFLr.js → gitGraphDiagram-DS77QQ5N-Bo8jGxTk.js} +1 -1
- package/dist/worker/console/static/assets/index-CAZ2fC_X.css +1 -0
- package/dist/worker/console/static/assets/index-DhfjOafu.js +449 -0
- package/dist/worker/console/static/assets/{infoDiagram-6WML65LV-CBB5Np7y.js → infoDiagram-6WML65LV-DQaZqJOH.js} +1 -1
- package/dist/worker/console/static/assets/{ishikawaDiagram-WSZJBQD7-D8IOp94y.js → ishikawaDiagram-WSZJBQD7-DsdX1WnE.js} +1 -1
- package/dist/worker/console/static/assets/{journeyDiagram-NVQOT4AX-Dgd3AHGG.js → journeyDiagram-NVQOT4AX-CP5EYDZL.js} +1 -1
- package/dist/worker/console/static/assets/{kanban-definition-27J2QSJJ-BmYOxLE9.js → kanban-definition-27J2QSJJ-DAm14Dr8.js} +1 -1
- package/dist/worker/console/static/assets/{linear-DfYTEF6J.js → linear-gZECoLc5.js} +1 -1
- package/dist/worker/console/static/assets/{mermaid.core-BjuFPRqa.js → mermaid.core-BRJNIM6p.js} +5 -5
- package/dist/worker/console/static/assets/{mindmap-definition-FAOFIHXS-CLyUViGd.js → mindmap-definition-FAOFIHXS-Cja3kLkR.js} +1 -1
- package/dist/worker/console/static/assets/{pegDiagram-VL7TDLO6-BvX2Di4-.js → pegDiagram-VL7TDLO6-22ZGFisL.js} +1 -1
- package/dist/worker/console/static/assets/{pieDiagram-7S7Q4E2Y-BFj0_OLv.js → pieDiagram-7S7Q4E2Y-BXin0Y1o.js} +1 -1
- package/dist/worker/console/static/assets/{quadrantDiagram-CIZ2JOQS-BIUrD_hx.js → quadrantDiagram-CIZ2JOQS-Cw6T69Yt.js} +1 -1
- package/dist/worker/console/static/assets/{railroadDiagram-AXF67PYL-CHBB48fj.js → railroadDiagram-AXF67PYL-C1-gTieN.js} +1 -1
- package/dist/worker/console/static/assets/{requirementDiagram-LRYGKXZP-sJrYw2Sf.js → requirementDiagram-LRYGKXZP--H5N2iI1.js} +1 -1
- package/dist/worker/console/static/assets/{sankeyDiagram-W5VNT64P-BzHH6fPR.js → sankeyDiagram-W5VNT64P-CgWAPeRz.js} +1 -1
- package/dist/worker/console/static/assets/{sequenceDiagram-SI44F4Z6-7QCnelCt.js → sequenceDiagram-SI44F4Z6-CrKqzGvt.js} +1 -1
- package/dist/worker/console/static/assets/{sizeCapture-X5ZJPWSS-sDYSxn72.js → sizeCapture-X5ZJPWSS-BB3wG06K.js} +1 -1
- package/dist/worker/console/static/assets/{stateDiagram-OKZ733FA-XpiUdwzm.js → stateDiagram-OKZ733FA-DjsGgdgY.js} +1 -1
- package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-Tp7V0U4q.js +1 -0
- package/dist/worker/console/static/assets/{swimlanes-SLNWSIFB-DvqgNPzD.js → swimlanes-SLNWSIFB-DYKEbvAR.js} +2 -2
- package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-DUZWZWi8.js +8 -0
- package/dist/worker/console/static/assets/{timeline-definition-Z64GVDOM-2TyOYNx0.js → timeline-definition-Z64GVDOM-eQOb5k9Y.js} +1 -1
- package/dist/worker/console/static/assets/{vennDiagram-T6HMQDX7-B-nM6wM2.js → vennDiagram-T6HMQDX7-B2-l9FIu.js} +1 -1
- package/dist/worker/console/static/assets/{wardleyDiagram-T6FBY63Y-B86wPdbr.js → wardleyDiagram-T6FBY63Y-BX2Cda3l.js} +1 -1
- package/dist/worker/console/static/assets/{xychartDiagram-ELKLHX3M-Dr1C4AQz.js → xychartDiagram-ELKLHX3M-D9S892ph.js} +1 -1
- package/dist/worker/console/static/index.html +7 -2
- package/dist/worker/console/static-src/active-run-badge.js +17 -0
- package/dist/worker/console/static-src/app/console-types.js +68 -4
- package/dist/worker/console/static-src/app/useConsoleShell.js +30 -12
- package/dist/worker/console/static-src/app/useOperatorActions.js +43 -7
- package/dist/worker/console/static-src/app/useRecoveryActions.js +2 -2
- package/dist/worker/console/static-src/app/useRecoveryConsole.js +45 -10
- package/dist/worker/console/static-src/app/useRunProgress.js +54 -0
- package/dist/worker/console/static-src/app/useTaskWizard.js +74 -2
- package/dist/worker/console/static-src/night/useNightBoard.js +8 -5
- package/dist/worker/console/static-src/operator-chat/cards/failure-category-advice.js +25 -0
- package/dist/worker/console/static-src/operator-chat/chat-sse-events.js +264 -13
- package/dist/worker/console/static-src/operator-chat/compaction-message.js +113 -0
- package/dist/worker/console/static-src/operator-chat/dag-progress-link.js +22 -0
- package/dist/worker/console/static-src/operator-chat/details-dag-actions.js +122 -0
- package/dist/worker/console/static-src/operator-chat/input-history.js +78 -0
- package/dist/worker/console/static-src/operator-chat/mutation-gate.js +1 -1
- package/dist/worker/console/static-src/operator-chat/open-preview-in-browser.js +338 -0
- package/dist/worker/console/static-src/operator-chat/refs.js +3 -0
- package/dist/worker/console/static-src/operator-chat/runtime-selection-labels.js +27 -0
- package/dist/worker/console/static-src/operator-chat/runtime-snapshot-store.js +10 -0
- package/dist/worker/console/static-src/operator-chat/spatial-overlay.js +1 -2
- package/dist/worker/console/static-src/operator-chat/turn-stream-controller.js +33 -1
- package/dist/worker/console/static-src/operator-chat/turn-submission.js +55 -0
- package/dist/worker/console/static-src/operator-chat/useChatSessions.js +448 -109
- package/dist/worker/console/static-src/operator-chat/useChatStream.js +344 -27
- package/dist/worker/console/static-src/operator-chat/useChatThread.js +323 -11
- package/dist/worker/console/static-src/operator-chat/useComposer.js +45 -4
- package/dist/worker/console/static-src/operator-chat/useRepoBrowser.js +97 -13
- package/dist/worker/console/static-src/operator-chat/useRuntimeControls.js +57 -9
- package/dist/worker/console/static-src/operator-chat/useRuntimeSnapshot.js +8 -2
- package/dist/worker/console/static-src/operator-chat/useWorkspaceBrowserGate.js +4 -0
- package/dist/worker/console/static-src/operator-chat/workspace-layout-mode.js +3 -3
- package/dist/worker/console/static-src/operator-chat/workspace-reorder.js +18 -0
- package/dist/worker/console/static-src/pages/tasks/run-id-resolution.js +79 -0
- package/dist/worker/console/static-src/pages/tasks/run-ownership-verify.js +23 -0
- package/dist/worker/console/static-src/pages/tasks/run-panel-progress.js +216 -0
- package/dist/worker/console/static-src/shell/console-update-reload.js +52 -0
- package/dist/worker/console/static-src/shell/useWorkspaces.js +415 -0
- package/dist/worker/console/static-src/shell/workspace-route.js +356 -0
- package/dist/worker/console/workspace-context.js +399 -0
- package/dist/worker/console/workspace-registry.js +487 -0
- package/dist/worker/continuation/worker-continuation.js +278 -0
- package/dist/worker/loop-agent/loop-agent-client.js +7 -3
- package/dist/worker/materialize/frontend-split-task-materializer.js +72 -0
- package/dist/worker/materialize/harness-task-lineage.js +5 -2
- package/dist/worker/observability/init-runtime-activity.js +26 -0
- package/dist/worker/observability/read-model.js +26 -0
- package/dist/worker/observe/health.js +1 -1
- package/dist/worker/observe/node-input.js +160 -3
- package/dist/worker/observe/node-process.js +377 -0
- package/dist/worker/observe/node-transparency.js +572 -0
- package/dist/worker/observe/routes.js +278 -3
- package/dist/worker/observe/server.js +4 -0
- package/dist/worker/observe/shell-handler-keys.js +34 -0
- package/dist/worker/observe/static/api.js +154 -4
- package/dist/worker/observe/static/app.js +18 -70
- package/dist/worker/observe/static/constants.js +26 -19
- package/dist/worker/observe/static/dag-context-reason-labels.d.ts +9 -0
- package/dist/worker/observe/static/dag-context-reason-labels.js +139 -0
- package/dist/worker/observe/static/dag-helpers.js +4 -2
- package/dist/worker/observe/static/dag-history-labels.js +5 -0
- package/dist/worker/observe/static/dag-inspector-humanize.d.ts +16 -0
- package/dist/worker/observe/static/dag-inspector-humanize.js +339 -0
- package/dist/worker/observe/static/dag-node-purpose.d.ts +6 -0
- package/dist/worker/observe/static/dag-node-purpose.js +208 -0
- package/dist/worker/observe/static/format.js +60 -0
- package/dist/worker/observe/static/index.html +10 -5
- package/dist/worker/observe/static/inspect-bootstrap.d.ts +8 -0
- package/dist/worker/observe/static/inspect-bootstrap.js +57 -0
- package/dist/worker/observe/static/inspect-workspace.js +374 -0
- package/dist/worker/observe/static/kpi.js +2 -2
- package/dist/worker/observe/static/markdown-render.js +20 -1
- package/dist/worker/observe/static/operator-chrome.css +168 -24
- package/dist/worker/observe/static/operator-chrome.d.ts +30 -5
- package/dist/worker/observe/static/operator-chrome.js +354 -101
- package/dist/worker/observe/static/prompt-restart-candidates.d.ts +18 -0
- package/dist/worker/observe/static/prompt-restart-candidates.js +38 -0
- package/dist/worker/observe/static/relations.js +7 -7
- package/dist/worker/observe/static/router.d.ts +57 -0
- package/dist/worker/observe/static/router.js +67 -1
- package/dist/worker/observe/static/run-processing.js +4 -2
- package/dist/worker/observe/static/shell-chrome.js +2 -2
- package/dist/worker/observe/static/state.d.ts +50 -0
- package/dist/worker/observe/static/state.js +191 -1
- package/dist/worker/observe/static/styles.css +1720 -86
- package/dist/worker/observe/static/views/dag-graph.js +5 -3
- package/dist/worker/observe/static/views/dag-inspector.js +2601 -188
- package/dist/worker/observe/static/views/dag.d.ts +13 -0
- package/dist/worker/observe/static/views/dag.js +39 -18
- package/dist/worker/observe/static/views/dags.js +10 -6
- package/dist/worker/observe/static/views/dashboard.js +18 -8
- package/dist/worker/observe/static/views/failures.js +5 -2
- package/dist/worker/observe/static/views/night.js +2 -2
- package/dist/worker/observe/static/views/pool.js +8 -2
- package/dist/worker/observe/static/views/run.js +15 -4
- package/dist/worker/observe/static/views/session-timeline.js +386 -25
- package/dist/worker/observe/static/views/task.js +63 -3
- package/dist/worker/outcomes/adapters.js +19 -0
- package/dist/worker/outcomes/types.js +1 -0
- package/dist/worker/pool/attempt-lease.js +97 -66
- package/dist/worker/pool/begin-attempt-with-lease.js +1 -0
- package/dist/worker/pool/reconcile.js +46 -1
- package/dist/worker/pool/run-store.js +2 -0
- package/dist/worker/pool/state-projection.js +2 -0
- package/dist/worker/task-spec/workflow-routing.js +8 -3
- package/dist/workflows/dag/artifact-bindings.js +149 -0
- package/dist/workflows/dag/artifact-revision-schema-registry.js +31 -0
- package/dist/workflows/dag/backend-test-case-coverage-analysis.js +470 -31
- package/dist/workflows/dag/backend-test-markdown-workflow.js +189 -2
- package/dist/workflows/dag/backend-test-plan-protocol.js +210 -0
- package/dist/workflows/dag/backend-test-pytest-collection.js +168 -16
- package/dist/workflows/dag/backend-test-result-contract.js +5 -1
- package/dist/workflows/dag/backend-test-scenario-param.js +506 -73
- package/dist/workflows/dag/backend-test-scenario-partitions.js +135 -2
- package/dist/workflows/dag/backend-test-writer-completeness.js +131 -28
- package/dist/workflows/dag/budget-enforcement.js +10 -0
- package/dist/workflows/dag/context-receipt.js +305 -0
- package/dist/workflows/dag/context-transfer/context-bundle.js +423 -0
- package/dist/workflows/dag/context-transfer/operator-actions.js +61 -0
- package/dist/workflows/dag/context-transfer/renderers.js +93 -0
- package/dist/workflows/dag/contract-output-registry.js +15 -0
- package/dist/workflows/dag/contract-validator-registrations.js +1 -2
- package/dist/workflows/dag/convergence/controller.js +141 -0
- package/dist/workflows/dag/dag-retry-schema.js +138 -0
- package/dist/workflows/dag/dynamic-runtime/loop-until.js +1 -1
- package/dist/workflows/dag/dynamic-runtime/map.js +2 -1
- package/dist/workflows/dag/failure-category.js +7 -116
- package/dist/workflows/dag/frontend-closeout.js +221 -0
- package/dist/workflows/dag/frontend-design-policy.js +400 -0
- package/dist/workflows/dag/frontend-human-decision.js +182 -0
- package/dist/workflows/dag/frontend-implementation-contract.js +1377 -141
- package/dist/workflows/dag/frontend-plan-render.js +26 -1
- package/dist/workflows/dag/frontend-prewrite-gate.js +376 -318
- package/dist/workflows/dag/frontend-provider-capability-matrix.js +159 -0
- package/dist/workflows/dag/frontend-recovery-capsule.js +455 -0
- package/dist/workflows/dag/frontend-recovery-controller.js +226 -0
- package/dist/workflows/dag/frontend-recovery-lineage.js +178 -0
- package/dist/workflows/dag/frontend-recovery-plan.js +21 -10
- package/dist/workflows/dag/frontend-recovery-run.js +166 -34
- package/dist/workflows/dag/frontend-repair.js +7 -424
- package/dist/workflows/dag/frontend-review-context.js +348 -20
- package/dist/workflows/dag/frontend-review-findings.js +270 -0
- package/dist/workflows/dag/frontend-risk.js +15 -2
- package/dist/workflows/dag/frontend-shadow-dual-write.js +941 -0
- package/dist/workflows/dag/frontend-shape-capsule-store.js +191 -0
- package/dist/workflows/dag/frontend-shape-facts.js +419 -0
- package/dist/workflows/dag/frontend-shape.js +435 -0
- package/dist/workflows/dag/frontend-source-fidelity-ledger.js +108 -0
- package/dist/workflows/dag/frontend-split-application-service.js +203 -0
- package/dist/workflows/dag/frontend-split-orchestrator.js +899 -0
- package/dist/workflows/dag/frontend-test-case-checklist.js +53 -5
- package/dist/workflows/dag/frontend-test-case-manifest.js +11 -4
- package/dist/workflows/dag/frontend-test-case-quality.js +11 -16
- package/dist/workflows/dag/frontend-test-environment-probe.js +230 -0
- package/dist/workflows/dag/frontend-test-html-report.js +3 -1
- package/dist/workflows/dag/frontend-test-l5-report.js +3 -1
- package/dist/workflows/dag/frontend-test-layout.js +159 -0
- package/dist/workflows/dag/frontend-test-markdown.js +61 -0
- package/dist/workflows/dag/frontend-test-rerun-candidates.js +103 -0
- package/dist/workflows/dag/frontend-test-result-contract.js +188 -42
- package/dist/workflows/dag/frontend-test-standard-scenarios.js +70 -0
- package/dist/workflows/dag/frontend-typed-event-store.js +452 -0
- package/dist/workflows/dag/frontend-typed-event-transaction.js +180 -0
- package/dist/workflows/dag/frontend-verification-trace.js +281 -29
- package/dist/workflows/dag/frontend-worktree-diff.js +250 -17
- package/dist/workflows/dag/frontend-writer-admission.js +319 -0
- package/dist/workflows/dag/frontend-writer-rollback.js +32 -0
- package/dist/workflows/dag/frontend-writer-status.js +256 -0
- package/dist/workflows/dag/init-hybrid.js +1675 -721
- package/dist/workflows/dag/interrupt-request.js +10 -3
- package/dist/workflows/dag/lifecycle.js +3 -3
- package/dist/workflows/dag/node-execution.js +1141 -32
- package/dist/workflows/dag/path-safety.js +1 -0
- package/dist/workflows/dag/prompt.js +158 -7
- package/dist/workflows/dag/recovery-lease.js +170 -0
- package/dist/workflows/dag/report.js +37 -1
- package/dist/workflows/dag/rerun-feedback.js +526 -0
- package/dist/workflows/dag/rerun-plan.js +790 -28
- package/dist/workflows/dag/rerun-run.js +700 -21
- package/dist/workflows/dag/rerun-task.js +311 -14
- package/dist/workflows/dag/retry-policy.js +336 -101
- package/dist/workflows/dag/runner.js +596 -121
- package/dist/workflows/dag/scheduler.js +133 -20
- package/dist/workflows/dag/skill-snapshot.js +17 -0
- package/dist/workflows/dag/structured-output-repair.js +712 -0
- package/dist/workflows/dag/types.js +585 -31
- package/dist/workflows/dag/validate.js +93 -32
- package/docs/README.md +2 -0
- package/docs/architecture/evolution.md +45 -0
- package/docs/architecture/runtime-boundaries.md +8 -7
- package/docs/architecture/worker-and-feature.md +1 -1
- package/docs/examples/README.md +5 -0
- package/docs/init-surface.manifest.json +36 -12
- package/docs/operations/README.md +1 -1
- package/docs/operations/local-development-environment.md +22 -5
- package/docs/skills/vetted-skill-registry.md +16 -0
- package/docs/templates/README.md +4 -2
- package/docs/templates/agent-dag-report.schema.json +8 -2
- package/docs/templates/agent-dag.schema.json +95 -1
- package/docs/templates/backend-test-dag.json +278 -244
- package/docs/templates/frontend-implementation-contract.schema.json +684 -24
- package/docs/templates/frontend-implementation-dag.json +89 -0
- package/docs/templates/frontend-test-case-checklist.md +2 -2
- package/docs/templates/frontend-test-dag.json +8 -10
- package/docs/templates/frontend-test-dag.retrieve-context.prompt.md +1 -1
- package/docs/templates/init-managed-agents.md +13 -3
- package/docs/templates/product-line/task.yaml +1 -1
- package/docs/templates/spec-registry.schema.json +45 -0
- package/harness.json +2 -2
- package/package.json +19 -5
- package/scripts/next-info.mjs +356 -0
- package/scripts/next-publish-gate.mjs +238 -0
- package/scripts/release-source-binding.mjs +251 -0
- package/skills/analyze-product-requirements/SKILL.md +8 -5
- package/skills/analyze-product-requirements/references/acceptance-criteria.md +1 -1
- package/skills/analyze-product-requirements/references/clarification-and-knowledge.md +10 -6
- package/skills/analyze-product-requirements/references/example.md +50 -0
- package/skills/analyze-product-requirements/references/forward-test-cases.md +11 -7
- package/skills/analyze-product-requirements/references/kb-integration.md +5 -5
- package/skills/analyze-product-requirements/references/product-analysis-schema.md +8 -4
- package/skills/analyze-product-requirements/references/product-requirement-schema.md +2 -2
- package/skills/analyze-product-requirements/references/requirement-clarification-schema.md +1 -1
- package/skills/analyze-product-requirements/scripts/test-validators.mjs +11 -1
- package/skills/analyze-product-requirements/scripts/validate-product-analysis.mjs +20 -1
- package/skills/analyze-product-requirements/scripts/validate-requirement-clarification.mjs +9 -0
- package/skills/codebase-scout/SKILL.md +1 -1
- package/skills/fe-test-ui-scout/SKILL.md +65 -0
- package/skills/fe-test-ui-scout/references/ledger-schema.md +62 -0
- package/skills/fe-test-ui-scout/references/recon-protocol.md +54 -0
- package/skills/frontend-bounded-implement/SKILL.md +15 -14
- package/skills/frontend-bounded-implement/references/code-standards.md +19 -0
- package/skills/frontend-contract/SKILL.md +23 -0
- package/skills/frontend-contract/references/contract-protocol.md +34 -0
- package/skills/frontend-design-review/SKILL.md +22 -41
- package/skills/frontend-plan/SKILL.md +26 -0
- package/skills/frontend-plan/references/decision-contract.md +37 -0
- package/skills/frontend-plan/references/design-decisions.md +17 -0
- package/skills/frontend-review/SKILL.md +20 -15
- package/skills/frontend-review/references/review-findings.md +6 -7
- package/skills/frontend-scout/SKILL.md +25 -0
- package/skills/frontend-scout/references/design-evidence.md +16 -0
- package/skills/frontend-scout/references/scout-evidence.md +23 -0
- package/skills/frontend-verification/SKILL.md +1 -1
- package/skills/improve-codebase-architecture/SKILL.md +81 -0
- package/skills/improve-codebase-architecture/deepening.md +37 -0
- package/skills/improve-codebase-architecture/html-report.md +123 -0
- package/skills/improve-codebase-architecture/interface-design.md +44 -0
- package/skills/improve-codebase-architecture/language.md +53 -0
- package/skills/loop-agent/references/command-reference.md +32 -4
- package/skills/loop-agent/references/hybrid-dag.md +9 -2
- package/skills/playwright-cli/SKILL.md +23 -1
- package/skills/playwright-cli-case-generator/SKILL.md +50 -13
- package/dist/worker/console/operation-store.js +0 -169
- package/dist/worker/console/static/assets/channel-Tl-FkUqr.js +0 -1
- package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-BaehtRk4.js +0 -1
- package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-BaehtRk4.js +0 -1
- package/dist/worker/console/static/assets/index-B7Y-0g3J.css +0 -1
- package/dist/worker/console/static/assets/index-DkCrqaYg.js +0 -325
- package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-eEhq2A8Y.js +0 -1
- package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-la8AC7fo.js +0 -8
- package/dist/worker/console/static-src/operator-chat/activity-rail-presentation.js +0 -73
- package/dist/worker/console/static-src/operator-chat/useActivityRailTransition.js +0 -59
- package/skills/frontend-implementation/SKILL.md +0 -52
- package/skills/frontend-implementation/references/code-standards.md +0 -33
- package/skills/frontend-implementation/references/design-spec.md +0 -56
- package/skills/frontend-implementation/references/node-contracts.md +0 -31
- /package/dist/{worker → infrastructure}/console/repo-fingerprint.js +0 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure composer input-history state machine for Operator Chat.
|
|
3
|
+
*
|
|
4
|
+
* Extracted so ArrowUp/ArrowUp recall, unsent-draft retention and history
|
|
5
|
+
* recording can be unit-tested without mounting the React composer.
|
|
6
|
+
*/
|
|
7
|
+
export const INPUT_HISTORY_LIMIT = 100;
|
|
8
|
+
export function createInputHistoryState() {
|
|
9
|
+
return { entries: [], index: -1, draft: "" };
|
|
10
|
+
}
|
|
11
|
+
/** Record one sent text and reset browsing back to the present draft. */
|
|
12
|
+
export function recordInputHistoryEntry(state, text) {
|
|
13
|
+
if (!text.trim())
|
|
14
|
+
return state;
|
|
15
|
+
if (state.entries[state.entries.length - 1] === text) {
|
|
16
|
+
return state.index === -1 ? state : { ...state, index: -1, draft: "" };
|
|
17
|
+
}
|
|
18
|
+
const entries = [...state.entries, text].slice(-INPUT_HISTORY_LIMIT);
|
|
19
|
+
return { entries, index: -1, draft: "" };
|
|
20
|
+
}
|
|
21
|
+
/** Leave browse mode (manual typing edits the recalled text in place). */
|
|
22
|
+
export function resetInputHistoryBrowsing(state) {
|
|
23
|
+
return state.index === -1 ? state : { ...state, index: -1 };
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Recall an earlier input with the arrow keys (terminal-style).
|
|
27
|
+
*
|
|
28
|
+
* History recall is only active at the absolute text boundary: Up before the
|
|
29
|
+
* first character and Down after the final character. This keeps native
|
|
30
|
+
* textarea caret movement intact everywhere inside a multi-line draft. The
|
|
31
|
+
* unsent draft is stashed when browsing leaves the present position and
|
|
32
|
+
* restored when Down walks past the newest entry.
|
|
33
|
+
*/
|
|
34
|
+
export function navigateInputHistory(state, direction, context) {
|
|
35
|
+
const { text, caretStart, caretEnd } = context;
|
|
36
|
+
if (state.entries.length === 0)
|
|
37
|
+
return { handled: false };
|
|
38
|
+
if (direction === "up") {
|
|
39
|
+
if (caretStart !== 0 || caretEnd !== 0)
|
|
40
|
+
return { handled: false };
|
|
41
|
+
if (state.index === -1) {
|
|
42
|
+
const index = state.entries.length - 1;
|
|
43
|
+
return {
|
|
44
|
+
handled: true,
|
|
45
|
+
state: { ...state, index, draft: text },
|
|
46
|
+
text: state.entries[index],
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
if (state.index === 0) {
|
|
50
|
+
// Already at the oldest entry: stay there (terminal behaviour).
|
|
51
|
+
return { handled: true, state, text: state.entries[0] };
|
|
52
|
+
}
|
|
53
|
+
const index = state.index - 1;
|
|
54
|
+
return {
|
|
55
|
+
handled: true,
|
|
56
|
+
state: { ...state, index },
|
|
57
|
+
text: state.entries[index],
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
if (state.index === -1)
|
|
61
|
+
return { handled: false };
|
|
62
|
+
if (caretStart !== text.length || caretEnd !== text.length) {
|
|
63
|
+
return { handled: false };
|
|
64
|
+
}
|
|
65
|
+
if (state.index >= state.entries.length - 1) {
|
|
66
|
+
return {
|
|
67
|
+
handled: true,
|
|
68
|
+
state: { ...state, index: -1 },
|
|
69
|
+
text: state.draft,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
const index = state.index + 1;
|
|
73
|
+
return {
|
|
74
|
+
handled: true,
|
|
75
|
+
state: { ...state, index },
|
|
76
|
+
text: state.entries[index],
|
|
77
|
+
};
|
|
78
|
+
}
|
|
@@ -30,7 +30,7 @@ export function isStaleTokenFailure(code) {
|
|
|
30
30
|
/** Chinese, actionable copy for mutation-gate rejections. */
|
|
31
31
|
export function describeMutationGateFailure(code) {
|
|
32
32
|
if (isStaleTokenFailure(code)) {
|
|
33
|
-
return "
|
|
33
|
+
return "页面凭证已失效(控制台可能已重启),请刷新页面(F5)后重试。";
|
|
34
34
|
}
|
|
35
35
|
if (code === "host-not-loopback") {
|
|
36
36
|
return "请求主机校验失败:非回环绑定时要求 Host 头,请刷新页面或检查访问地址。";
|
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
import { HTML_PREVIEW_SANDBOX } from "../../chat/chat-ui-policy.js";
|
|
2
|
+
/** Shown near the preview header when window.open is blocked or Blob/URL creation fails. */
|
|
3
|
+
export const PREVIEW_OPEN_POPUP_BLOCKED = "无法在浏览器中打开:弹窗被拦截";
|
|
4
|
+
export const PREVIEW_TRUNCATION_NOTICE = "内容已截断,以下为已加载片段。";
|
|
5
|
+
/** Window features that force a real OS window instead of a browser tab.
|
|
6
|
+
* Do not include `noopener` here: browsers then return null even on success. */
|
|
7
|
+
export function previewOpenWindowFeatures(input) {
|
|
8
|
+
const availWidth = input?.availWidth ?? 1440;
|
|
9
|
+
const availHeight = input?.availHeight ?? 900;
|
|
10
|
+
const width = Math.min(1280, Math.max(880, Math.floor(availWidth * 0.82)));
|
|
11
|
+
const height = Math.min(960, Math.max(640, Math.floor(availHeight * 0.88)));
|
|
12
|
+
return [
|
|
13
|
+
"popup=yes",
|
|
14
|
+
`width=${width}`,
|
|
15
|
+
`height=${height}`,
|
|
16
|
+
"left=72",
|
|
17
|
+
"top=36",
|
|
18
|
+
"menubar=yes",
|
|
19
|
+
"toolbar=yes",
|
|
20
|
+
"location=yes",
|
|
21
|
+
"status=yes",
|
|
22
|
+
"resizable=yes",
|
|
23
|
+
"scrollbars=yes",
|
|
24
|
+
].join(",");
|
|
25
|
+
}
|
|
26
|
+
export function escapeHtml(text) {
|
|
27
|
+
return text
|
|
28
|
+
.replaceAll("&", "&")
|
|
29
|
+
.replaceAll("<", "<")
|
|
30
|
+
.replaceAll(">", ">")
|
|
31
|
+
.replaceAll('"', """)
|
|
32
|
+
.replaceAll("'", "'");
|
|
33
|
+
}
|
|
34
|
+
function normalizedLanguage(language) {
|
|
35
|
+
return language.trim().toLowerCase();
|
|
36
|
+
}
|
|
37
|
+
export function isHtmlPreviewLanguage(language) {
|
|
38
|
+
const lang = normalizedLanguage(language);
|
|
39
|
+
return lang === "html" || lang === "htm";
|
|
40
|
+
}
|
|
41
|
+
export function isMarkdownPreviewLanguage(language) {
|
|
42
|
+
const lang = normalizedLanguage(language);
|
|
43
|
+
return lang === "md" || lang === "markdown";
|
|
44
|
+
}
|
|
45
|
+
function formatTextBody(preview) {
|
|
46
|
+
if (normalizedLanguage(preview.language) !== "json")
|
|
47
|
+
return preview.content;
|
|
48
|
+
try {
|
|
49
|
+
return JSON.stringify(JSON.parse(preview.content), null, 2);
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
return preview.content;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function isSafeHttpHref(href) {
|
|
56
|
+
return /^https?:\/\//i.test(href.trim());
|
|
57
|
+
}
|
|
58
|
+
function renderMarkdownInline(text) {
|
|
59
|
+
const withCode = [];
|
|
60
|
+
const coded = text.replace(/`([^`]+)`/g, (_all, code) => {
|
|
61
|
+
withCode.push(`<code>${code}</code>`);
|
|
62
|
+
return `\u0000${withCode.length - 1}\u0000`;
|
|
63
|
+
});
|
|
64
|
+
const linked = coded.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g, (_all, label, href) => {
|
|
65
|
+
if (!isSafeHttpHref(href))
|
|
66
|
+
return label;
|
|
67
|
+
return `<a href="${href}" rel="noopener noreferrer" target="_blank">${label}</a>`;
|
|
68
|
+
});
|
|
69
|
+
const emphasized = linked
|
|
70
|
+
.replace(/\*\*([^*]+)\*\*/g, "<strong>$1</strong>")
|
|
71
|
+
.replace(/__([^_]+)__/g, "<strong>$1</strong>")
|
|
72
|
+
.replace(/\*([^*]+)\*/g, "<em>$1</em>");
|
|
73
|
+
return emphasized.replace(/\u0000(\d+)\u0000/g, (_all, idx) => {
|
|
74
|
+
return withCode[Number(idx)] ?? "";
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
function flushParagraph(lines) {
|
|
78
|
+
if (!lines.length)
|
|
79
|
+
return "";
|
|
80
|
+
return `<p>${renderMarkdownInline(lines.join(" "))}</p>`;
|
|
81
|
+
}
|
|
82
|
+
function renderMarkdownBlocks(escaped) {
|
|
83
|
+
const lines = escaped.replaceAll("\r\n", "\n").split("\n");
|
|
84
|
+
const out = [];
|
|
85
|
+
let paragraph = [];
|
|
86
|
+
let listKind = null;
|
|
87
|
+
const closeList = () => {
|
|
88
|
+
if (listKind) {
|
|
89
|
+
out.push(listKind === "ul" ? "</ul>" : "</ol>");
|
|
90
|
+
listKind = null;
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
const closeParagraph = () => {
|
|
94
|
+
if (paragraph.length) {
|
|
95
|
+
out.push(flushParagraph(paragraph));
|
|
96
|
+
paragraph = [];
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
for (const line of lines) {
|
|
100
|
+
const heading = /^(#{1,6})\s+(.+)$/.exec(line);
|
|
101
|
+
if (heading) {
|
|
102
|
+
closeParagraph();
|
|
103
|
+
closeList();
|
|
104
|
+
const level = heading[1].length;
|
|
105
|
+
out.push(`<h${level}>${renderMarkdownInline(heading[2])}</h${level}>`);
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
if (/^---+$/.test(line.trim()) || /^\*\*\*+$/.test(line.trim())) {
|
|
109
|
+
closeParagraph();
|
|
110
|
+
closeList();
|
|
111
|
+
out.push("<hr>");
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
const quote = /^>\s?(.*)$/.exec(line);
|
|
115
|
+
if (quote) {
|
|
116
|
+
closeParagraph();
|
|
117
|
+
closeList();
|
|
118
|
+
out.push(`<blockquote><p>${renderMarkdownInline(quote[1] ?? "")}</p></blockquote>`);
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
const ul = /^[-*]\s+(.+)$/.exec(line);
|
|
122
|
+
if (ul) {
|
|
123
|
+
closeParagraph();
|
|
124
|
+
if (listKind !== "ul") {
|
|
125
|
+
closeList();
|
|
126
|
+
out.push("<ul>");
|
|
127
|
+
listKind = "ul";
|
|
128
|
+
}
|
|
129
|
+
out.push(`<li>${renderMarkdownInline(ul[1])}</li>`);
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
const ol = /^\d+\.\s+(.+)$/.exec(line);
|
|
133
|
+
if (ol) {
|
|
134
|
+
closeParagraph();
|
|
135
|
+
if (listKind !== "ol") {
|
|
136
|
+
closeList();
|
|
137
|
+
out.push("<ol>");
|
|
138
|
+
listKind = "ol";
|
|
139
|
+
}
|
|
140
|
+
out.push(`<li>${renderMarkdownInline(ol[1])}</li>`);
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
if (line.trim() === "") {
|
|
144
|
+
closeParagraph();
|
|
145
|
+
closeList();
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
closeList();
|
|
149
|
+
paragraph.push(line);
|
|
150
|
+
}
|
|
151
|
+
closeParagraph();
|
|
152
|
+
closeList();
|
|
153
|
+
return out.join("\n");
|
|
154
|
+
}
|
|
155
|
+
/** Conservative Markdown → HTML for the detached reading tab. Input is escaped first. */
|
|
156
|
+
export function renderMarkdownLite(source) {
|
|
157
|
+
const escaped = escapeHtml(source);
|
|
158
|
+
const chunks = [];
|
|
159
|
+
const fence = /```([^\n`]*)\n([\s\S]*?)```/g;
|
|
160
|
+
let last = 0;
|
|
161
|
+
let match;
|
|
162
|
+
while ((match = fence.exec(escaped))) {
|
|
163
|
+
if (match.index > last) {
|
|
164
|
+
chunks.push(renderMarkdownBlocks(escaped.slice(last, match.index)));
|
|
165
|
+
}
|
|
166
|
+
chunks.push(`<pre class="md-code"><code>${match[2] ?? ""}</code></pre>`);
|
|
167
|
+
last = match.index + match[0].length;
|
|
168
|
+
}
|
|
169
|
+
if (last < escaped.length) {
|
|
170
|
+
chunks.push(renderMarkdownBlocks(escaped.slice(last)));
|
|
171
|
+
}
|
|
172
|
+
return chunks.filter(Boolean).join("\n");
|
|
173
|
+
}
|
|
174
|
+
function readingPageCss() {
|
|
175
|
+
return `
|
|
176
|
+
:root { color-scheme: light dark; }
|
|
177
|
+
html, body { margin: 0; min-height: 100%; background: #f7f5f0; color: #1f1b16; }
|
|
178
|
+
body { font: 16px/1.65 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; }
|
|
179
|
+
.bar { position: sticky; top: 0; z-index: 1; display: flex; gap: 12px; align-items: center; padding: 10px 16px 10px 20px; border-bottom: 1px solid #e4ddd2; background: #fffdf8; }
|
|
180
|
+
.bar .meta { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 2px; }
|
|
181
|
+
.bar strong { font-size: 13px; font-weight: 650; word-break: break-all; }
|
|
182
|
+
.bar .kind { color: #6b6258; font-size: 12px; }
|
|
183
|
+
.modes { display: inline-flex; gap: 2px; padding: 2px; border: 1px solid #e4ddd2; border-radius: 8px; background: #f3eee6; }
|
|
184
|
+
.modes button { appearance: none; border: 0; background: transparent; color: #6b6258; font: 12px/1.2 inherit; padding: 5px 10px; border-radius: 6px; cursor: pointer; }
|
|
185
|
+
.modes button:hover { color: #1f1b16; }
|
|
186
|
+
.modes button.is-active { background: #fff; color: #1f1b16; font-weight: 600; box-shadow: 0 1px 2px rgb(0 0 0 / 8%); }
|
|
187
|
+
.notice { margin: 0; padding: 8px 20px; background: #fff6d8; color: #5c4b00; font-size: 13px; }
|
|
188
|
+
.pane { display: none; }
|
|
189
|
+
.pane.is-active { display: block; }
|
|
190
|
+
.doc { max-width: 52rem; margin: 0 auto; padding: 32px 24px 96px; }
|
|
191
|
+
.doc.md h1, .doc.md h2, .doc.md h3, .doc.md h4 { line-height: 1.25; margin: 1.4em 0 0.5em; }
|
|
192
|
+
.doc.md h1 { font-size: 2rem; }
|
|
193
|
+
.doc.md h2 { font-size: 1.45rem; }
|
|
194
|
+
.doc.md p { margin: 0.8em 0; }
|
|
195
|
+
.doc.md ul, .doc.md ol { margin: 0.6em 0; padding-left: 1.4em; }
|
|
196
|
+
.doc.md blockquote { margin: 0.8em 0; padding: 0.2em 0.9em; border-left: 3px solid #d9cfc0; color: #4a433c; }
|
|
197
|
+
.doc.md hr { border: 0; border-top: 1px solid #e4ddd2; margin: 1.6em 0; }
|
|
198
|
+
.doc.md a { color: #0b57d0; }
|
|
199
|
+
.doc.md code, .md-code, .source { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.92em; }
|
|
200
|
+
.doc.md :not(pre) > code { padding: 0.1em 0.35em; border-radius: 4px; background: #efe8dc; }
|
|
201
|
+
.md-code, .source { margin: 1em 0; padding: 14px 16px; overflow: auto; white-space: pre-wrap; background: #fff; border: 1px solid #e4ddd2; border-radius: 8px; }
|
|
202
|
+
.frame { margin: 0; padding: 0; }
|
|
203
|
+
iframe.page { display: block; width: 100%; height: calc(100vh - 53px); border: 0; background: #fff; }
|
|
204
|
+
`.trim();
|
|
205
|
+
}
|
|
206
|
+
function formattedSource(preview) {
|
|
207
|
+
return escapeHtml(formatTextBody(preview));
|
|
208
|
+
}
|
|
209
|
+
function previewPane(preview) {
|
|
210
|
+
if (isHtmlPreviewLanguage(preview.language)) {
|
|
211
|
+
return preview.htmlPreviewUrl
|
|
212
|
+
? `<div class="frame"><iframe class="page" sandbox="${HTML_PREVIEW_SANDBOX}" referrerpolicy="no-referrer" src="${escapeHtml(preview.htmlPreviewUrl)}"></iframe></div>`
|
|
213
|
+
: `<div class="frame"><iframe class="page" sandbox="${HTML_PREVIEW_SANDBOX}" srcdoc="${escapeHtml(preview.content)}"></iframe></div>`;
|
|
214
|
+
}
|
|
215
|
+
if (isMarkdownPreviewLanguage(preview.language)) {
|
|
216
|
+
return `<article class="doc md">${renderMarkdownLite(preview.content)}</article>`;
|
|
217
|
+
}
|
|
218
|
+
return `<article class="doc"><pre class="source">${formattedSource(preview)}</pre></article>`;
|
|
219
|
+
}
|
|
220
|
+
function sourcePane(preview) {
|
|
221
|
+
return `<article class="doc"><pre class="source">${formattedSource(preview)}</pre></article>`;
|
|
222
|
+
}
|
|
223
|
+
function readingPageScript() {
|
|
224
|
+
return `<script>
|
|
225
|
+
(function () {
|
|
226
|
+
var previewBtn = document.getElementById("view-preview");
|
|
227
|
+
var sourceBtn = document.getElementById("view-source");
|
|
228
|
+
var previewPane = document.getElementById("pane-preview");
|
|
229
|
+
var sourcePane = document.getElementById("pane-source");
|
|
230
|
+
if (!previewBtn || !sourceBtn || !previewPane || !sourcePane) return;
|
|
231
|
+
function show(mode) {
|
|
232
|
+
var source = mode === "source";
|
|
233
|
+
previewBtn.classList.toggle("is-active", !source);
|
|
234
|
+
sourceBtn.classList.toggle("is-active", source);
|
|
235
|
+
previewBtn.setAttribute("aria-pressed", String(!source));
|
|
236
|
+
sourceBtn.setAttribute("aria-pressed", String(source));
|
|
237
|
+
previewPane.classList.toggle("is-active", !source);
|
|
238
|
+
sourcePane.classList.toggle("is-active", source);
|
|
239
|
+
}
|
|
240
|
+
previewBtn.addEventListener("click", function () { show("preview"); });
|
|
241
|
+
sourceBtn.addEventListener("click", function () { show("source"); });
|
|
242
|
+
})();
|
|
243
|
+
</script>`;
|
|
244
|
+
}
|
|
245
|
+
/** Build the Blob document HTML from the already-loaded preview snapshot. */
|
|
246
|
+
export function buildPreviewBrowserDocument(preview) {
|
|
247
|
+
const title = escapeHtml(preview.path);
|
|
248
|
+
const notice = preview.truncated
|
|
249
|
+
? `<p class="notice">${escapeHtml(PREVIEW_TRUNCATION_NOTICE)}</p>`
|
|
250
|
+
: "";
|
|
251
|
+
const lang = normalizedLanguage(preview.language);
|
|
252
|
+
return `<!doctype html>
|
|
253
|
+
<html lang="zh-CN">
|
|
254
|
+
<head>
|
|
255
|
+
<meta charset="utf-8">
|
|
256
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
257
|
+
<title>${title}</title>
|
|
258
|
+
<style>
|
|
259
|
+
${readingPageCss()}
|
|
260
|
+
</style>
|
|
261
|
+
</head>
|
|
262
|
+
<body>
|
|
263
|
+
<header class="bar">
|
|
264
|
+
<div class="meta">
|
|
265
|
+
<strong>${title}</strong>
|
|
266
|
+
<span class="kind">${escapeHtml(lang || "text")}${preview.truncated ? " · 已截断" : ""}</span>
|
|
267
|
+
</div>
|
|
268
|
+
<div class="modes" role="group" aria-label="查看模式">
|
|
269
|
+
<button type="button" id="view-preview" class="is-active" aria-pressed="true">预览</button>
|
|
270
|
+
<button type="button" id="view-source" aria-pressed="false">查看原文</button>
|
|
271
|
+
</div>
|
|
272
|
+
</header>
|
|
273
|
+
${notice}
|
|
274
|
+
<div id="pane-preview" class="pane is-active">${previewPane(preview)}</div>
|
|
275
|
+
<div id="pane-source" class="pane">${sourcePane(preview)}</div>
|
|
276
|
+
${readingPageScript()}
|
|
277
|
+
</body>
|
|
278
|
+
</html>`;
|
|
279
|
+
}
|
|
280
|
+
function screenAvail() {
|
|
281
|
+
const screen = globalThis.screen;
|
|
282
|
+
return {
|
|
283
|
+
availWidth: screen?.availWidth,
|
|
284
|
+
availHeight: screen?.availHeight,
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
function defaultHost() {
|
|
288
|
+
const g = globalThis;
|
|
289
|
+
if (typeof g.open !== "function") {
|
|
290
|
+
throw new Error("window.open is unavailable");
|
|
291
|
+
}
|
|
292
|
+
return {
|
|
293
|
+
open: g.open.bind(g),
|
|
294
|
+
createObjectURL: g.URL.createObjectURL.bind(g.URL),
|
|
295
|
+
revokeObjectURL: g.URL.revokeObjectURL.bind(g.URL),
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Open the current preview in a new OS window from already-loaded
|
|
300
|
+
* path/content/language/truncated. Does not fetch the repo file API again.
|
|
301
|
+
*
|
|
302
|
+
* Width/height window features ask the browser for a real window, not a tab.
|
|
303
|
+
* Do not pass `noopener` as a feature: browsers then return null even on
|
|
304
|
+
* success. Detach via `opener = null` after a real handle is obtained. Keep
|
|
305
|
+
* the Blob URL alive — revoking immediately blanks the page.
|
|
306
|
+
*/
|
|
307
|
+
export function openPreviewInBrowser(preview, host = defaultHost(), features = previewOpenWindowFeatures(screenAvail())) {
|
|
308
|
+
let objectUrl;
|
|
309
|
+
try {
|
|
310
|
+
let targetUrl = isHtmlPreviewLanguage(preview.language) && preview.htmlPreviewUrl
|
|
311
|
+
? preview.htmlPreviewUrl
|
|
312
|
+
: undefined;
|
|
313
|
+
if (!targetUrl) {
|
|
314
|
+
const documentHtml = buildPreviewBrowserDocument(preview);
|
|
315
|
+
const blob = new Blob([documentHtml], { type: "text/html;charset=utf-8" });
|
|
316
|
+
objectUrl = host.createObjectURL(blob);
|
|
317
|
+
targetUrl = objectUrl;
|
|
318
|
+
}
|
|
319
|
+
const opened = host.open(targetUrl, "_blank", features);
|
|
320
|
+
if (!opened) {
|
|
321
|
+
if (objectUrl)
|
|
322
|
+
host.revokeObjectURL(objectUrl);
|
|
323
|
+
return { ok: false, error: PREVIEW_OPEN_POPUP_BLOCKED };
|
|
324
|
+
}
|
|
325
|
+
try {
|
|
326
|
+
opened.opener = null;
|
|
327
|
+
}
|
|
328
|
+
catch {
|
|
329
|
+
// Some hosts expose a frozen handle; the window is still open.
|
|
330
|
+
}
|
|
331
|
+
return { ok: true };
|
|
332
|
+
}
|
|
333
|
+
catch {
|
|
334
|
+
if (objectUrl)
|
|
335
|
+
host.revokeObjectURL(objectUrl);
|
|
336
|
+
return { ok: false, error: PREVIEW_OPEN_POPUP_BLOCKED };
|
|
337
|
+
}
|
|
338
|
+
}
|
|
@@ -24,6 +24,7 @@ export function useChatRefs() {
|
|
|
24
24
|
const abortPostedTurnIdsRef = useRef(new Set());
|
|
25
25
|
const releasedClientRequestIdsRef = useRef(new Set());
|
|
26
26
|
const usageResponseKeysRef = useRef(new Set());
|
|
27
|
+
const unlinkedOperationIdsRef = useRef(new Map());
|
|
27
28
|
const isComposingRef = useRef(false);
|
|
28
29
|
const compositionEndedAtRef = useRef(0);
|
|
29
30
|
// Keep the bag identity stable: individual refs never change, so domain
|
|
@@ -53,6 +54,7 @@ export function useChatRefs() {
|
|
|
53
54
|
abortPostedTurnIdsRef,
|
|
54
55
|
releasedClientRequestIdsRef,
|
|
55
56
|
usageResponseKeysRef,
|
|
57
|
+
unlinkedOperationIdsRef,
|
|
56
58
|
isComposingRef,
|
|
57
59
|
compositionEndedAtRef,
|
|
58
60
|
}), [
|
|
@@ -80,6 +82,7 @@ export function useChatRefs() {
|
|
|
80
82
|
abortPostedTurnIdsRef,
|
|
81
83
|
releasedClientRequestIdsRef,
|
|
82
84
|
usageResponseKeysRef,
|
|
85
|
+
unlinkedOperationIdsRef,
|
|
83
86
|
isComposingRef,
|
|
84
87
|
compositionEndedAtRef,
|
|
85
88
|
]);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { formatModelRef } from "../../chat/runtime-selection.js";
|
|
2
|
+
const THINKING_SHORT_LABELS = {
|
|
3
|
+
auto: "Auto",
|
|
4
|
+
off: "Off",
|
|
5
|
+
minimal: "Minimal",
|
|
6
|
+
low: "Low",
|
|
7
|
+
medium: "Medium",
|
|
8
|
+
high: "High",
|
|
9
|
+
xhigh: "XHigh",
|
|
10
|
+
max: "Max",
|
|
11
|
+
};
|
|
12
|
+
export function formatThinkingSelectionLabel(selection, effective) {
|
|
13
|
+
const normalized = selection || "auto";
|
|
14
|
+
const label = THINKING_SHORT_LABELS[normalized] ?? normalized;
|
|
15
|
+
if (normalized !== "auto" || !effective)
|
|
16
|
+
return label;
|
|
17
|
+
return `${label} · ${THINKING_SHORT_LABELS[effective] ?? effective}`;
|
|
18
|
+
}
|
|
19
|
+
export function resolveModelDisplayName(models, activeModelRef) {
|
|
20
|
+
if (!activeModelRef)
|
|
21
|
+
return "选择模型";
|
|
22
|
+
const current = models.find((model) => formatModelRef(model.provider, model.id) === activeModelRef);
|
|
23
|
+
if (current)
|
|
24
|
+
return current.name?.trim() || current.id;
|
|
25
|
+
const slash = activeModelRef.indexOf("/");
|
|
26
|
+
return slash === -1 ? activeModelRef : activeModelRef.slice(slash + 1);
|
|
27
|
+
}
|
|
@@ -20,6 +20,16 @@ export const runtimeSnapshotInitialState = {
|
|
|
20
20
|
mutationBusy: false,
|
|
21
21
|
mutationToken: null,
|
|
22
22
|
};
|
|
23
|
+
/** True when the session cannot be reopened and the client should forget it. */
|
|
24
|
+
export function isLostChatSessionError(error) {
|
|
25
|
+
if (!error)
|
|
26
|
+
return false;
|
|
27
|
+
const code = error.code ?? "";
|
|
28
|
+
if (code === "PI_SESSION_NOT_FOUND" || code === "NOT_FOUND")
|
|
29
|
+
return true;
|
|
30
|
+
return (code === "PI_RUNTIME_UNAVAILABLE" &&
|
|
31
|
+
/session file missing or not openable|no persisted Pi session file/i.test(error.message ?? ""));
|
|
32
|
+
}
|
|
23
33
|
/** Parse a failed HTTP body into a structured snapshot error (never empty). */
|
|
24
34
|
export function parseRuntimeSnapshotError(body) {
|
|
25
35
|
if (!body || typeof body !== "object") {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Mutual-exclusion state for large spatial overlays in Operator Chat.
|
|
3
|
-
* At most one of: sidebar drawer, process, runtime context, tools
|
|
3
|
+
* At most one of: sidebar drawer, process, runtime context, tools.
|
|
4
4
|
* Small composer menus (model/thinking) are out of scope.
|
|
5
5
|
*/
|
|
6
6
|
export function createSpatialOverlayState(active = "none") {
|
|
@@ -33,6 +33,5 @@ export function spatialOverlayFlags(state) {
|
|
|
33
33
|
processOpen: state.active === "process",
|
|
34
34
|
runtimeContextOpen: state.active === "runtime-context",
|
|
35
35
|
toolsOpen: state.active === "tools",
|
|
36
|
-
activityOpen: state.active === "activity",
|
|
37
36
|
};
|
|
38
37
|
}
|
|
@@ -31,6 +31,22 @@ export function operatorChatEventsUrl(origin, sessionId) {
|
|
|
31
31
|
export function operatorChatAbortUrl(origin, sessionId, turnId) {
|
|
32
32
|
return `${origin}/api/operator/v1/chat/sessions/${encodeURIComponent(sessionId)}/turns/${encodeURIComponent(turnId)}/abort`;
|
|
33
33
|
}
|
|
34
|
+
export function turnPhaseFromOwnership(bag) {
|
|
35
|
+
if (bag.stoppingTurnId || bag.stopRequested)
|
|
36
|
+
return "stopping";
|
|
37
|
+
if (bag.activeTurnId || bag.streaming || bag.submitInFlight || bag.pendingSubmission)
|
|
38
|
+
return "running";
|
|
39
|
+
return "idle";
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* DSH-style visual projection: Stop immediately releases the composer while
|
|
43
|
+
* the ownership projection remains `stopping` for deferred-send routing and
|
|
44
|
+
* duplicate-Turn prevention.
|
|
45
|
+
*/
|
|
46
|
+
export function visualTurnPhaseFromOwnership(bag) {
|
|
47
|
+
const phase = turnPhaseFromOwnership(bag);
|
|
48
|
+
return phase === "stopping" ? "idle" : phase;
|
|
49
|
+
}
|
|
34
50
|
export function createTurnOwnershipBag(seed) {
|
|
35
51
|
return {
|
|
36
52
|
submitInFlight: false,
|
|
@@ -53,7 +69,7 @@ export function createTurnOwnershipBag(seed) {
|
|
|
53
69
|
}
|
|
54
70
|
/** Whether a second concurrent send is blocked by ownership / busy. */
|
|
55
71
|
export function isSubmitOwnershipBusy(bag) {
|
|
56
|
-
return bag
|
|
72
|
+
return turnPhaseFromOwnership(bag) !== "idle";
|
|
57
73
|
}
|
|
58
74
|
/**
|
|
59
75
|
* Release submit ownership. Optionally scoped to a clientRequestId so a stale
|
|
@@ -387,6 +403,9 @@ export function classifyAbortResponse(input) {
|
|
|
387
403
|
isTerminalTurnState(terminalState)) {
|
|
388
404
|
return { action: "terminal-idle", turnId: input.turnId };
|
|
389
405
|
}
|
|
406
|
+
if (input.httpOk && input.body.accepted === true) {
|
|
407
|
+
return { action: "abort-accepted-background" };
|
|
408
|
+
}
|
|
390
409
|
if (input.body.error?.code === "TURN_ABORT_PENDING") {
|
|
391
410
|
return { action: "abort-pending-notice" };
|
|
392
411
|
}
|
|
@@ -409,6 +428,10 @@ export function applyAbortDecision(bag, decision, notice, opts) {
|
|
|
409
428
|
if (!current)
|
|
410
429
|
return;
|
|
411
430
|
bag.settledTurnIds.add(decision.turnId);
|
|
431
|
+
if (bag.pendingSubmission) {
|
|
432
|
+
releaseSubmitOwnership(bag, bag.pendingSubmission.clientRequestId);
|
|
433
|
+
}
|
|
434
|
+
clearStopRequested(bag);
|
|
412
435
|
bag.streaming = false;
|
|
413
436
|
bag.activeTurnId = null;
|
|
414
437
|
bag.assistantId = null;
|
|
@@ -416,6 +439,11 @@ export function applyAbortDecision(bag, decision, notice, opts) {
|
|
|
416
439
|
opts?.markIdle?.();
|
|
417
440
|
return;
|
|
418
441
|
}
|
|
442
|
+
if (decision.action === "abort-accepted-background") {
|
|
443
|
+
// Visual idle is projected by the caller. Hidden ownership deliberately
|
|
444
|
+
// remains stopping until terminal SSE or /state evidence releases it.
|
|
445
|
+
return;
|
|
446
|
+
}
|
|
419
447
|
if (decision.action === "abort-pending-notice") {
|
|
420
448
|
// Non-fatal; keep busy.
|
|
421
449
|
notice.showNotice(ABORT_PENDING_NOTICE);
|
|
@@ -429,6 +457,10 @@ export function applyAbortDecision(bag, decision, notice, opts) {
|
|
|
429
457
|
bag.settledTurnIds.add(bag.stoppingTurnId);
|
|
430
458
|
}
|
|
431
459
|
bag.streaming = false;
|
|
460
|
+
if (bag.pendingSubmission) {
|
|
461
|
+
releaseSubmitOwnership(bag, bag.pendingSubmission.clientRequestId);
|
|
462
|
+
}
|
|
463
|
+
clearStopRequested(bag);
|
|
432
464
|
bag.activeTurnId = null;
|
|
433
465
|
bag.assistantId = null;
|
|
434
466
|
bag.stoppingTurnId = null;
|
|
@@ -3,6 +3,61 @@
|
|
|
3
3
|
* Extracted so double-submit, TURN_ACTIVE adoption, transport ambiguity, and
|
|
4
4
|
* generation fences can be unit-tested without mounting the full React tree.
|
|
5
5
|
*/
|
|
6
|
+
/**
|
|
7
|
+
* Choose the submission path from the mutable ownership facts, never from a
|
|
8
|
+
* possibly stale React render. A stopping intent without a bound Turn must
|
|
9
|
+
* remain held until reconciliation binds or releases that ownership.
|
|
10
|
+
*
|
|
11
|
+
* Since 2026-08-23 a running Turn also accepts a queued follow-up: Enter
|
|
12
|
+
* mid-turn binds the message to the active Turn (blockedByTurnId) and the
|
|
13
|
+
* server auto-dispatches it when the Turn settles or aborts.
|
|
14
|
+
*/
|
|
15
|
+
export function decideSubmissionRoute(input) {
|
|
16
|
+
if (input.turnPhase === "stopping") {
|
|
17
|
+
return input.blockedByTurnId
|
|
18
|
+
? {
|
|
19
|
+
action: "queue-deferred",
|
|
20
|
+
blockedByTurnId: input.blockedByTurnId,
|
|
21
|
+
}
|
|
22
|
+
: { action: "hold" };
|
|
23
|
+
}
|
|
24
|
+
if (input.turnPhase === "running") {
|
|
25
|
+
return input.blockedByTurnId
|
|
26
|
+
? {
|
|
27
|
+
action: "queue-deferred",
|
|
28
|
+
blockedByTurnId: input.blockedByTurnId,
|
|
29
|
+
}
|
|
30
|
+
: { action: "hold" };
|
|
31
|
+
}
|
|
32
|
+
return { action: "send-now" };
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Reconcile a deferred PUT that raced with Stop completion. The same
|
|
36
|
+
* clientRequestId may move to the normal POST path only after authoritative
|
|
37
|
+
* state proves that no Turn/runtime remains busy.
|
|
38
|
+
*/
|
|
39
|
+
export function reconcileDeferredSubmissionFromState(input) {
|
|
40
|
+
const { clientRequestId, blockedByTurnId, state } = input;
|
|
41
|
+
if (!state)
|
|
42
|
+
return { action: "hold" };
|
|
43
|
+
const queued = state.deferredTurns?.find((item) => item.clientRequestId === clientRequestId) ?? (state.deferredTurn?.clientRequestId === clientRequestId ? state.deferredTurn : undefined);
|
|
44
|
+
if (queued) {
|
|
45
|
+
return { action: "deferred", deferredTurn: queued };
|
|
46
|
+
}
|
|
47
|
+
if (state.activeTurn?.clientRequestId === clientRequestId) {
|
|
48
|
+
return { action: "accepted", turn: state.activeTurn };
|
|
49
|
+
}
|
|
50
|
+
if (state.latestTurn?.clientRequestId === clientRequestId) {
|
|
51
|
+
return { action: "accepted", turn: state.latestTurn };
|
|
52
|
+
}
|
|
53
|
+
const activeTurnId = state.activeTurn?.turnId ?? state.activeTurnId ?? null;
|
|
54
|
+
if (state.turnPhase === "stopping" && activeTurnId === blockedByTurnId) {
|
|
55
|
+
return { action: "retry-deferred" };
|
|
56
|
+
}
|
|
57
|
+
if (!isRuntimeBusyUnion(state))
|
|
58
|
+
return { action: "send-now" };
|
|
59
|
+
return { action: "hold" };
|
|
60
|
+
}
|
|
6
61
|
export function createPendingSubmission(input) {
|
|
7
62
|
let resolveOutcome;
|
|
8
63
|
const outcomePromise = new Promise((resolve) => {
|