@tea-agent/loop-agent 0.40.0-next.1 → 0.40.0-next.10
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 +106 -109
- package/README.md +2 -2
- package/dist/application/task-lifecycle/advance.js +12 -0
- package/dist/build-stamp.json +3 -3
- package/dist/cli/update/runtime-activity.js +1 -29
- package/dist/commands/dag-rerun.js +1 -1
- package/dist/executors/dag-pi-executor.js +69 -7
- package/dist/executors/pi-executor.js +4 -2
- package/dist/executors/pi-sdk-executor.js +46 -1
- package/dist/executors/pi-writer-tool-policy.js +57 -1
- package/dist/executors/shell-executor.js +43 -3
- package/dist/executors/workspace-write-snapshot.js +68 -0
- package/dist/infrastructure/harness/atomic-write.js +23 -0
- package/dist/shared/dag-prompt-override.js +4 -5
- package/dist/shared/update/npm-client.js +33 -11
- package/dist/task/config-types.js +10 -0
- package/dist/task/contract/apply.js +11 -1
- package/dist/task/contract/constants.js +2 -0
- package/dist/task/contract/hash.js +3 -0
- package/dist/task/contract/observe.js +25 -4
- package/dist/task/contract/paths.js +2 -1
- package/dist/task/contract/project.js +15 -1
- package/dist/task/contract/schema.js +2 -0
- package/dist/task/contract/transaction.js +12 -0
- package/dist/task/source-prepare/completeness.js +188 -0
- package/dist/task/source-prepare/fragment-inventory.js +474 -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/prepare.js +262 -1
- package/dist/task/source-prepare/semantic-intake.js +19 -3
- package/dist/task/source-prepare/source-fidelity-pi.js +384 -0
- package/dist/task/source-prepare/types.js +22 -0
- package/dist/worker/cli.js +12 -26
- package/dist/worker/console/chat/chat-event-store.js +75 -5
- package/dist/worker/console/chat/context-panel.js +7 -0
- package/dist/worker/console/chat/deferred-turn.js +12 -0
- package/dist/worker/console/chat/pi-runtime.js +331 -18
- package/dist/worker/console/chat/provider-error.js +98 -0
- package/dist/worker/console/chat/routes.js +389 -56
- package/dist/worker/console/chat/session-stats.js +179 -0
- package/dist/worker/console/chat/session-store.js +93 -63
- package/dist/worker/console/chat/todos.js +115 -0
- package/dist/worker/console/chat/tool-preview.js +42 -0
- package/dist/worker/console/chat/turn-process.js +20 -55
- package/dist/worker/console/chat/user-questions.js +266 -0
- package/dist/worker/console/chat/workspace-landing.js +79 -0
- package/dist/worker/console/console-handoff.js +82 -0
- package/dist/worker/console/console-update-and-init.js +115 -0
- package/dist/worker/console/console-update-runtime.js +84 -0
- package/dist/worker/console/draft-store.js +49 -0
- package/dist/worker/console/native-directory-picker.js +13 -0
- package/dist/worker/console/operation-store.js +1 -1
- package/dist/worker/console/operator-actions.js +129 -4
- package/dist/worker/console/operator-surface-health.js +1 -0
- package/dist/worker/console/prd-intake-bridge.js +13 -0
- package/dist/worker/console/routes.js +312 -1
- package/dist/worker/console/security.js +4 -4
- package/dist/worker/console/server.js +583 -172
- package/dist/worker/console/static/assets/{abnfDiagram-N423BO3Z-Br92EGb7.js → abnfDiagram-N423BO3Z-Bs-CDAXM.js} +1 -1
- package/dist/worker/console/static/assets/{arc-oulImtQq.js → arc-CAkA3We3.js} +1 -1
- package/dist/worker/console/static/assets/{architectureDiagram-T3A2C74G-tyHc6aqO.js → architectureDiagram-T3A2C74G-DEmI_zqr.js} +1 -1
- package/dist/worker/console/static/assets/{blockDiagram-VBNYF7ZC-CY86BSpT.js → blockDiagram-VBNYF7ZC-uDHANebE.js} +1 -1
- package/dist/worker/console/static/assets/{c4Diagram-5PPSVZJV-BKKsDmNs.js → c4Diagram-5PPSVZJV-Bv97b4_B.js} +1 -1
- package/dist/worker/console/static/assets/channel-amxUpk7o.js +1 -0
- package/dist/worker/console/static/assets/{chunk-2GRJ4B5K-CXZdjl3B.js → chunk-2GRJ4B5K-shmQKsFz.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-2Q5K7J3B-B-aIFDQ5.js → chunk-2Q5K7J3B-BAraNvcN.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-5RXB4S5H-BDgAW_B2.js → chunk-5RXB4S5H-BirhxUop.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-5VM5RSS4-DABa4UPR.js → chunk-5VM5RSS4-C9LgUJpR.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-6Q2QTUOP-aGbysVOx.js → chunk-6Q2QTUOP-DrU-s-t7.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-GF5L2VYU-B8MSZDVs.js → chunk-GF5L2VYU-Tx-H_FA2.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-JWPE2WC7-CpelV73g.js → chunk-JWPE2WC7-BjLtNFrR.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-KBJHAD2P-BE04ty3z.js → chunk-KBJHAD2P-UNLVwSsy.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-RYQCIY6F-BUxTkaaR.js → chunk-RYQCIY6F-CBEUX8XD.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-XXDRQBXY-CYYBVKfX.js → chunk-XXDRQBXY-WTL7IZOq.js} +1 -1
- package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-bejwBVIz.js +1 -0
- package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-bejwBVIz.js +1 -0
- package/dist/worker/console/static/assets/{cose-bilkent-JH36ORCC-CEQF_xmQ.js → cose-bilkent-JH36ORCC-CkHG6W3s.js} +1 -1
- package/dist/worker/console/static/assets/{cynefin-VYW2F7L2-CqpxN5IT.js → cynefin-VYW2F7L2-BRzFqTaL.js} +1 -1
- package/dist/worker/console/static/assets/{cynefinDiagram-MW4NZA55-B3PzanVi.js → cynefinDiagram-MW4NZA55-2_CFp_i7.js} +1 -1
- package/dist/worker/console/static/assets/{dagre-VZM6K2ZE-BSUGCNx1.js → dagre-VZM6K2ZE-BJtsmdkE.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-7IWD3JNH-CdLevU5T.js → diagram-7IWD3JNH-DNEFFo6w.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-B4RE2ZJO-BjpF_Kok.js → diagram-B4RE2ZJO-B_IWV7eo.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-LBJQPF4R-C4I6NJny.js → diagram-LBJQPF4R-DvvRx2dz.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-Q27KOJAE-C8hecCr5.js → diagram-Q27KOJAE-CsibsWLg.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-UB23O5K3-Daod6tOS.js → diagram-UB23O5K3-les_djBQ.js} +1 -1
- package/dist/worker/console/static/assets/{ebnfDiagram-BXEA7PRR-BvvmazGv.js → ebnfDiagram-BXEA7PRR-BEm2n7qJ.js} +1 -1
- package/dist/worker/console/static/assets/{erDiagram-JOGREHBK-DeN_vfV4.js → erDiagram-JOGREHBK-BI7vHHVm.js} +1 -1
- package/dist/worker/console/static/assets/{flowDiagram-UKHOOZJN-D6dq1t9z.js → flowDiagram-UKHOOZJN-CUFCERrB.js} +1 -1
- package/dist/worker/console/static/assets/{ganttDiagram-PKOTCBZU-DziIdNY4.js → ganttDiagram-PKOTCBZU-wxyLiGWt.js} +1 -1
- package/dist/worker/console/static/assets/{gitGraphDiagram-DS77QQ5N-Dy4s5CXr.js → gitGraphDiagram-DS77QQ5N-Bt897K8Z.js} +1 -1
- package/dist/worker/console/static/assets/index-BHhUOTri.css +1 -0
- package/dist/worker/console/static/assets/index-DqJbO3-p.js +407 -0
- package/dist/worker/console/static/assets/{infoDiagram-6WML65LV-Czv5eYx2.js → infoDiagram-6WML65LV-DYNx_IPv.js} +1 -1
- package/dist/worker/console/static/assets/{ishikawaDiagram-WSZJBQD7-Bsk3nFRT.js → ishikawaDiagram-WSZJBQD7-CzpLNEu6.js} +1 -1
- package/dist/worker/console/static/assets/{journeyDiagram-NVQOT4AX-DxGmNj5K.js → journeyDiagram-NVQOT4AX-97f9owNU.js} +1 -1
- package/dist/worker/console/static/assets/{kanban-definition-27J2QSJJ-CYCFqkO_.js → kanban-definition-27J2QSJJ-BxM9hyBn.js} +1 -1
- package/dist/worker/console/static/assets/{linear-B0YzRwrd.js → linear-ByuxcHvp.js} +1 -1
- package/dist/worker/console/static/assets/{mermaid.core-t3EZtIGh.js → mermaid.core-DwPGvpCv.js} +5 -5
- package/dist/worker/console/static/assets/{mindmap-definition-FAOFIHXS-BTXpTv0T.js → mindmap-definition-FAOFIHXS-DCoqG9RT.js} +1 -1
- package/dist/worker/console/static/assets/{pegDiagram-VL7TDLO6-DU8UkKqA.js → pegDiagram-VL7TDLO6-BLSBmBMx.js} +1 -1
- package/dist/worker/console/static/assets/{pieDiagram-7S7Q4E2Y-DP4y8ohp.js → pieDiagram-7S7Q4E2Y-B0t_0oJW.js} +1 -1
- package/dist/worker/console/static/assets/{quadrantDiagram-CIZ2JOQS-B07vNaYR.js → quadrantDiagram-CIZ2JOQS-sTzDk7Nt.js} +1 -1
- package/dist/worker/console/static/assets/{railroadDiagram-AXF67PYL-xDWktb2i.js → railroadDiagram-AXF67PYL-B3jRdATC.js} +1 -1
- package/dist/worker/console/static/assets/{requirementDiagram-LRYGKXZP-BLNMKqeS.js → requirementDiagram-LRYGKXZP-D-cTtXEN.js} +1 -1
- package/dist/worker/console/static/assets/{sankeyDiagram-W5VNT64P-n0adalxH.js → sankeyDiagram-W5VNT64P-B25igJRE.js} +1 -1
- package/dist/worker/console/static/assets/{sequenceDiagram-SI44F4Z6-BbnS-2DL.js → sequenceDiagram-SI44F4Z6-jW_lM1_D.js} +1 -1
- package/dist/worker/console/static/assets/{sizeCapture-X5ZJPWSS-B4uPpCLu.js → sizeCapture-X5ZJPWSS-CrzTgsHE.js} +1 -1
- package/dist/worker/console/static/assets/{stateDiagram-OKZ733FA--MMbB0fX.js → stateDiagram-OKZ733FA-B01MvlqE.js} +1 -1
- package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-BvFKEtm2.js +1 -0
- package/dist/worker/console/static/assets/{swimlanes-SLNWSIFB-BXUgp2QY.js → swimlanes-SLNWSIFB-YcF12FiU.js} +2 -2
- package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-DIB2eVg-.js +8 -0
- package/dist/worker/console/static/assets/{timeline-definition-Z64GVDOM-CsaMxki7.js → timeline-definition-Z64GVDOM-ClnRcg2s.js} +1 -1
- package/dist/worker/console/static/assets/{vennDiagram-T6HMQDX7-C2IuG9iH.js → vennDiagram-T6HMQDX7-B6gr_z-q.js} +1 -1
- package/dist/worker/console/static/assets/{wardleyDiagram-T6FBY63Y-CmEWOXCW.js → wardleyDiagram-T6FBY63Y-CvSgguGH.js} +1 -1
- package/dist/worker/console/static/assets/{xychartDiagram-ELKLHX3M-D_9LE0MG.js → xychartDiagram-ELKLHX3M-23OtSZCb.js} +1 -1
- package/dist/worker/console/static/index.html +2 -2
- package/dist/worker/console/static-src/app/console-types.js +68 -4
- package/dist/worker/console/static-src/app/useConsoleShell.js +30 -12
- package/dist/worker/console/static-src/app/useOperatorActions.js +41 -6
- package/dist/worker/console/static-src/app/useRecoveryConsole.js +10 -11
- package/dist/worker/console/static-src/app/useRunProgress.js +2 -1
- 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/chat-sse-events.js +141 -8
- package/dist/worker/console/static-src/operator-chat/compaction-message.js +79 -0
- package/dist/worker/console/static-src/operator-chat/details-dag-actions.js +122 -0
- package/dist/worker/console/static-src/operator-chat/refs.js +3 -0
- package/dist/worker/console/static-src/operator-chat/runtime-selection-labels.js +27 -0
- package/dist/worker/console/static-src/operator-chat/spatial-overlay.js +1 -2
- package/dist/worker/console/static-src/operator-chat/turn-stream-controller.js +25 -0
- package/dist/worker/console/static-src/operator-chat/turn-submission.js +3 -2
- package/dist/worker/console/static-src/operator-chat/useChatSessions.js +181 -87
- package/dist/worker/console/static-src/operator-chat/useChatStream.js +159 -44
- package/dist/worker/console/static-src/operator-chat/useChatThread.js +177 -8
- package/dist/worker/console/static-src/operator-chat/useRepoBrowser.js +63 -9
- package/dist/worker/console/static-src/operator-chat/useWorkspaceBrowserGate.js +4 -0
- package/dist/worker/console/static-src/operator-chat/workspace-layout-mode.js +3 -3
- package/dist/worker/console/static-src/shell/useWorkspaces.js +299 -0
- package/dist/worker/console/static-src/shell/workspace-route.js +339 -0
- package/dist/worker/console/workspace-context.js +234 -0
- package/dist/worker/console/workspace-registry.js +214 -0
- package/dist/worker/observability/init-runtime-activity.js +26 -0
- package/dist/worker/observe/node-input.js +88 -2
- package/dist/worker/observe/routes.js +188 -0
- package/dist/worker/observe/server.js +4 -0
- package/dist/worker/observe/static/api.js +29 -9
- package/dist/worker/observe/static/app.js +18 -70
- package/dist/worker/observe/static/dag-node-purpose.d.ts +6 -0
- package/dist/worker/observe/static/dag-node-purpose.js +203 -0
- package/dist/worker/observe/static/format.js +37 -0
- package/dist/worker/observe/static/index.html +6 -1
- package/dist/worker/observe/static/inspect-workspace.js +307 -0
- package/dist/worker/observe/static/operator-chrome.css +145 -20
- package/dist/worker/observe/static/operator-chrome.d.ts +20 -3
- package/dist/worker/observe/static/operator-chrome.js +330 -100
- package/dist/worker/observe/static/prompt-restart-candidates.d.ts +18 -0
- package/dist/worker/observe/static/prompt-restart-candidates.js +36 -0
- package/dist/worker/observe/static/router.d.ts +46 -0
- package/dist/worker/observe/static/router.js +25 -1
- package/dist/worker/observe/static/state.d.ts +50 -0
- package/dist/worker/observe/static/state.js +174 -2
- package/dist/worker/observe/static/styles.css +357 -35
- package/dist/worker/observe/static/views/dag-graph.js +4 -2
- package/dist/worker/observe/static/views/dag-inspector.js +533 -79
- package/dist/worker/observe/static/views/dag.d.ts +13 -0
- package/dist/worker/observe/static/views/dag.js +6 -4
- package/dist/worker/observe/static/views/dashboard.js +6 -4
- package/dist/worker/observe/static/views/night.js +2 -2
- package/dist/worker/observe/static/views/pool.js +1 -0
- package/dist/worker/observe/static/views/run.js +3 -1
- package/dist/worker/observe/static/views/task.js +56 -1
- package/dist/workflows/dag/backend-test-case-coverage-analysis.js +29 -1
- package/dist/workflows/dag/backend-test-markdown-workflow.js +176 -1
- package/dist/workflows/dag/backend-test-pytest-collection.js +98 -14
- package/dist/workflows/dag/backend-test-writer-completeness.js +17 -17
- package/dist/workflows/dag/dynamic-runtime/map.js +1 -0
- package/dist/workflows/dag/frontend-implementation-contract.js +88 -2
- package/dist/workflows/dag/frontend-plan-render.js +24 -0
- package/dist/workflows/dag/frontend-prewrite-gate.js +197 -0
- package/dist/workflows/dag/frontend-review-context.js +92 -10
- package/dist/workflows/dag/init-hybrid.js +238 -51
- package/dist/workflows/dag/interrupt-request.js +3 -3
- package/dist/workflows/dag/lifecycle.js +3 -3
- package/dist/workflows/dag/node-execution.js +45 -0
- package/dist/workflows/dag/types.js +62 -12
- package/docs/README.md +2 -0
- package/docs/architecture/evolution.md +45 -0
- package/docs/init-surface.manifest.json +1 -0
- package/docs/operations/local-development-environment.md +21 -0
- package/docs/templates/README.md +1 -1
- package/docs/templates/agent-dag.schema.json +18 -0
- package/docs/templates/backend-test-dag.json +265 -237
- package/docs/templates/frontend-implementation-contract.schema.json +681 -24
- package/harness.json +3 -3
- package/package.json +3 -1
- package/skills/loop-agent/references/hybrid-dag.md +7 -0
- package/dist/worker/console/static/assets/channel-TY36zt-i.js +0 -1
- package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-Dk7QCChM.js +0 -1
- package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-Dk7QCChM.js +0 -1
- package/dist/worker/console/static/assets/index-C3GgHg-g.css +0 -1
- package/dist/worker/console/static/assets/index-Ci8ksvBm.js +0 -406
- package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-BqOigMQ4.js +0 -1
- package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-Caxz9UA2.js +0 -8
- package/dist/worker/console/static-src/operator-chat/activity-rail-presentation.js +0 -73
- package/dist/worker/console/static-src/operator-chat/useActivityRailTransition.js +0 -59
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/** 与 router.js 对应的类型声明(供 vitest/TS 侧导入契约测试)。 */
|
|
2
|
+
|
|
3
|
+
export type InspectHashRoute = {
|
|
4
|
+
view: string;
|
|
5
|
+
batchRunId?: string;
|
|
6
|
+
workerRunId?: string;
|
|
7
|
+
dagRunId?: string;
|
|
8
|
+
featureId?: string;
|
|
9
|
+
taskId?: string;
|
|
10
|
+
scheduleId?: string;
|
|
11
|
+
page?: number;
|
|
12
|
+
pageSize?: number;
|
|
13
|
+
filters?: { status?: string; q?: string };
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export function parseHashRoute(hashValue: string): InspectHashRoute;
|
|
17
|
+
export function parseRoute(): InspectHashRoute;
|
|
18
|
+
export function setNavigateHandler(
|
|
19
|
+
handler: ((href: string) => void) | null,
|
|
20
|
+
): void;
|
|
21
|
+
export function inspectPathToCanonicalHref(path: string): string;
|
|
22
|
+
export function navigate(path: string): void;
|
|
23
|
+
|
|
24
|
+
export const DAG_HISTORY_DEFAULT_PAGE: number;
|
|
25
|
+
export const DAG_HISTORY_DEFAULT_PAGE_SIZE: number;
|
|
26
|
+
export const DAG_HISTORY_ALLOWED_PAGE_SIZES: readonly number[];
|
|
27
|
+
|
|
28
|
+
export function clampDagHistoryPageSize(value: unknown): number;
|
|
29
|
+
export function clampDagHistoryPage(
|
|
30
|
+
value: unknown,
|
|
31
|
+
totalPages?: number,
|
|
32
|
+
): number;
|
|
33
|
+
export function parseDagHistoryQuery(hashValue: string): {
|
|
34
|
+
page: number;
|
|
35
|
+
pageSize: number;
|
|
36
|
+
};
|
|
37
|
+
export function buildDagHistoryHash(page: unknown, pageSize: unknown): string;
|
|
38
|
+
export function parseHashFilters(hashValue: string): {
|
|
39
|
+
status?: string;
|
|
40
|
+
q?: string;
|
|
41
|
+
};
|
|
42
|
+
export function parseHashRouteWithFilters(hashValue: string): InspectHashRoute;
|
|
43
|
+
export function buildHashPath(
|
|
44
|
+
path: string,
|
|
45
|
+
filters?: Record<string, unknown>,
|
|
46
|
+
): string;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
/** Hash routing for Observe UI (R5). */
|
|
2
2
|
|
|
3
3
|
export function parseHashRoute(hashValue) {
|
|
4
|
-
|
|
4
|
+
let hash = (hashValue.replace(/^#/, "") || "/").split("?")[0] || "/";
|
|
5
|
+
if (!hash.startsWith("/")) hash = `/${hash}`;
|
|
6
|
+
if (hash === "/inspect") hash = "/";
|
|
7
|
+
else if (hash.startsWith("/inspect/")) hash = hash.slice("/inspect".length) || "/";
|
|
5
8
|
const batchMatch = /^\/batch\/([^/]+)$/.exec(hash);
|
|
6
9
|
if (batchMatch) {
|
|
7
10
|
return { view: "batch", batchRunId: decodeURIComponent(batchMatch[1]) };
|
|
@@ -61,7 +64,28 @@ export function parseRoute() {
|
|
|
61
64
|
return parseHashRouteWithFilters(location.hash);
|
|
62
65
|
}
|
|
63
66
|
|
|
67
|
+
let navigateHandler = null;
|
|
68
|
+
|
|
69
|
+
export function setNavigateHandler(handler) {
|
|
70
|
+
navigateHandler = typeof handler === "function" ? handler : null;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export function inspectPathToCanonicalHref(path) {
|
|
74
|
+
const raw = String(path ?? "");
|
|
75
|
+
if (raw.startsWith("/#/inspect")) return raw;
|
|
76
|
+
if (raw.startsWith("#/inspect")) return `/${raw}`;
|
|
77
|
+
const stripped = raw.replace(/^#/, "");
|
|
78
|
+
const withSlash = stripped.startsWith("/") ? stripped : `/${stripped}`;
|
|
79
|
+
if (withSlash === "/inspect" || withSlash === "/") return "/#/inspect";
|
|
80
|
+
if (withSlash.startsWith("/inspect/")) return `/#${withSlash}`;
|
|
81
|
+
return `/#/inspect${withSlash}`;
|
|
82
|
+
}
|
|
83
|
+
|
|
64
84
|
export function navigate(path) {
|
|
85
|
+
if (navigateHandler) {
|
|
86
|
+
navigateHandler(inspectPathToCanonicalHref(path));
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
65
89
|
location.hash = path.startsWith("#") ? path.slice(1) : path;
|
|
66
90
|
}
|
|
67
91
|
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/** 与 state.js 对应的类型声明(供 vitest/TS 侧导入契约测试)。 */
|
|
2
|
+
|
|
3
|
+
export type ViewStateKind = "loading" | "empty" | "degraded" | "error";
|
|
4
|
+
|
|
5
|
+
export type ViewStateDescriptor = {
|
|
6
|
+
kind: ViewStateKind;
|
|
7
|
+
className: string;
|
|
8
|
+
role: string | null;
|
|
9
|
+
ariaLive: string | null;
|
|
10
|
+
message: string;
|
|
11
|
+
detail: string | null;
|
|
12
|
+
messageClass: string | null;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const uiState: {
|
|
16
|
+
lastSnapshot: unknown;
|
|
17
|
+
specEvidenceDetail: {
|
|
18
|
+
source: string;
|
|
19
|
+
path: string;
|
|
20
|
+
loading: boolean;
|
|
21
|
+
error: string | null;
|
|
22
|
+
data: unknown;
|
|
23
|
+
triggerId: string | null;
|
|
24
|
+
} | null;
|
|
25
|
+
dagNodeExecutionOutputCache: Map<string, unknown> | null;
|
|
26
|
+
[key: string]: unknown;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export function setWorkspaceScope(workspaceId: string | null): void;
|
|
30
|
+
export function workspaceScope(): string | null;
|
|
31
|
+
export function scopedApiUrl(url: string): string;
|
|
32
|
+
export function workspaceRequestSignal(): AbortSignal | undefined;
|
|
33
|
+
export function fetchWithWorkspaceScope(
|
|
34
|
+
url: string,
|
|
35
|
+
init?: RequestInit,
|
|
36
|
+
): Promise<Response>;
|
|
37
|
+
export function abortWorkspaceRequests(): void;
|
|
38
|
+
export function setWorkspaceActive(active: boolean): void;
|
|
39
|
+
export function stopTimers(): void;
|
|
40
|
+
export function pauseForegroundTimers(): void;
|
|
41
|
+
|
|
42
|
+
/** Multi-workspace atomic scope switch (2026-08-26, AC-006). */
|
|
43
|
+
export function applyWorkspaceScopeSwitch(
|
|
44
|
+
nextWorkspaceId: string | null,
|
|
45
|
+
routeValue?: (() => void) | string,
|
|
46
|
+
options?: {
|
|
47
|
+
route?: (hashValue: string) => void;
|
|
48
|
+
onTrace?: (trace: string[]) => void;
|
|
49
|
+
},
|
|
50
|
+
): string[];
|
|
@@ -82,8 +82,8 @@ export const uiState = {
|
|
|
82
82
|
dagNodeExecutionOutputLoading: false,
|
|
83
83
|
dagNodeExecutionOutputError: null,
|
|
84
84
|
dagNodeExecutionOutputKey: null,
|
|
85
|
-
/** When true,「执行过程」展开 message_start/end
|
|
86
|
-
sessionTimelineShowProtocol:
|
|
85
|
+
/** When true,「执行过程」展开 message_start/end 原始协议事件。默认隐藏,用户可点选展开。 */
|
|
86
|
+
sessionTimelineShowProtocol: false,
|
|
87
87
|
/** Open <details> keys restored across timeline re-renders. */
|
|
88
88
|
sessionTimelineOpenDetails: null,
|
|
89
89
|
lastSnapshot: null,
|
|
@@ -116,6 +116,8 @@ export const uiState = {
|
|
|
116
116
|
/** Last-rendered spec-evidence list, used to restore the list synchronously. */
|
|
117
117
|
specEvidenceListEvidence: null,
|
|
118
118
|
pollingGeneration: 0,
|
|
119
|
+
/** Hosted Inspect workspace is foreground. Standalone defaults to active. */
|
|
120
|
+
workspaceActive: true,
|
|
119
121
|
};
|
|
120
122
|
|
|
121
123
|
/** Per-dagRunId graph viewport restore map (stable Map instance). */
|
|
@@ -279,16 +281,186 @@ export function isPageVisible() {
|
|
|
279
281
|
);
|
|
280
282
|
}
|
|
281
283
|
|
|
284
|
+
export function isWorkspaceActive() {
|
|
285
|
+
return uiState.workspaceActive !== false;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
export function setWorkspaceActive(active) {
|
|
289
|
+
uiState.workspaceActive = Boolean(active);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Multi-workspace scope (2026-08-23): every Observe GET must carry the
|
|
294
|
+
* current workspaceId (AC-002/AC-003). The scope is synced from the parent
|
|
295
|
+
* Console shell hash (`?workspaceId=`) or via postMessage for hosted mode;
|
|
296
|
+
* standalone pages default to null and all workspace-scoped routes fail closed
|
|
297
|
+
* until the host or hash publishes an explicit workspace id.
|
|
298
|
+
*/
|
|
299
|
+
let currentWorkspaceScope = null;
|
|
300
|
+
let currentWorkspaceRequestController =
|
|
301
|
+
typeof AbortController === "undefined" ? null : new AbortController();
|
|
302
|
+
|
|
303
|
+
export function setWorkspaceScope(workspaceId) {
|
|
304
|
+
currentWorkspaceScope =
|
|
305
|
+
typeof workspaceId === "string" && workspaceId.trim()
|
|
306
|
+
? workspaceId.trim()
|
|
307
|
+
: null;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
export function workspaceScope() {
|
|
311
|
+
return currentWorkspaceScope;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/** Signal shared by every workspace-scoped Observe request in the active scope. */
|
|
315
|
+
export function workspaceRequestSignal() {
|
|
316
|
+
if (
|
|
317
|
+
typeof AbortController !== "undefined" &&
|
|
318
|
+
(!currentWorkspaceRequestController ||
|
|
319
|
+
currentWorkspaceRequestController.signal.aborted)
|
|
320
|
+
) {
|
|
321
|
+
currentWorkspaceRequestController = new AbortController();
|
|
322
|
+
}
|
|
323
|
+
return currentWorkspaceRequestController?.signal;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
function combinedRequestSignal(scopeSignal, requestSignal) {
|
|
327
|
+
const signals = [scopeSignal, requestSignal].filter(Boolean);
|
|
328
|
+
if (signals.length <= 1) return { signal: signals[0], cleanup: () => {} };
|
|
329
|
+
const controller = new AbortController();
|
|
330
|
+
const abort = () => controller.abort();
|
|
331
|
+
for (const signal of signals) {
|
|
332
|
+
if (signal.aborted) abort();
|
|
333
|
+
else signal.addEventListener("abort", abort, { once: true });
|
|
334
|
+
}
|
|
335
|
+
return {
|
|
336
|
+
signal: controller.signal,
|
|
337
|
+
cleanup: () => {
|
|
338
|
+
for (const signal of signals) signal.removeEventListener("abort", abort);
|
|
339
|
+
},
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/** Fetch through the current workspace boundary and abort on any scope swap. */
|
|
344
|
+
export async function fetchWithWorkspaceScope(url, init = {}) {
|
|
345
|
+
const { signal: requestSignal, ...rest } = init;
|
|
346
|
+
const combined = combinedRequestSignal(
|
|
347
|
+
workspaceRequestSignal(),
|
|
348
|
+
requestSignal,
|
|
349
|
+
);
|
|
350
|
+
try {
|
|
351
|
+
return await fetch(scopedApiUrl(url), {
|
|
352
|
+
...rest,
|
|
353
|
+
...(combined.signal ? { signal: combined.signal } : {}),
|
|
354
|
+
});
|
|
355
|
+
} finally {
|
|
356
|
+
combined.cleanup();
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
/** Abort every old-scope request and invalidate request identity guards. */
|
|
361
|
+
export function abortWorkspaceRequests() {
|
|
362
|
+
currentWorkspaceRequestController?.abort();
|
|
363
|
+
currentWorkspaceRequestController =
|
|
364
|
+
typeof AbortController === "undefined" ? null : new AbortController();
|
|
365
|
+
uiState.dagHistoryAbortController?.abort?.();
|
|
366
|
+
uiState.dagHistoryAbortController = null;
|
|
367
|
+
uiState.dagHistoryRequestSeq += 1;
|
|
368
|
+
uiState.dagHistoryPrefetchGeneration += 1;
|
|
369
|
+
uiState.dagNodeInputRequestSeq += 1;
|
|
370
|
+
uiState.dagNodeProcessRequestSeq += 1;
|
|
371
|
+
uiState.dagNodeExecutionOutputRequestSeq += 1;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/** Multi-workspace atomic scope switch (2026-08-26, AC-006).
|
|
375
|
+
*
|
|
376
|
+
* Contract order — strictly sequential, no interleaving:
|
|
377
|
+
* 1. abort old — stop every poll/SSE so no late request can race the swap;
|
|
378
|
+
* 2. clear old — drop cached run/task/selection state of the old scope;
|
|
379
|
+
* 3. set scope — publish the new workspaceId for scopedApiUrl;
|
|
380
|
+
* 4. reload new — re-route/re-render with the new scope active.
|
|
381
|
+
*
|
|
382
|
+
* Observability: each stage appends to the returned trace so tests (and
|
|
383
|
+
* diagnostics) can assert the exact ordering; there is no window in which a
|
|
384
|
+
* new route is requested with the old scope or vice versa.
|
|
385
|
+
*/
|
|
386
|
+
export function applyWorkspaceScopeSwitch(
|
|
387
|
+
nextWorkspaceId,
|
|
388
|
+
routeValue,
|
|
389
|
+
options = {},
|
|
390
|
+
) {
|
|
391
|
+
const trace = [];
|
|
392
|
+
// 1. abort old
|
|
393
|
+
abortWorkspaceRequests();
|
|
394
|
+
stopTimers();
|
|
395
|
+
pauseForegroundTimers();
|
|
396
|
+
trace.push("abort-old");
|
|
397
|
+
// 2. clear old
|
|
398
|
+
uiState.lastSnapshot = null;
|
|
399
|
+
uiState.specEvidenceDetail = null;
|
|
400
|
+
uiState.specEvidenceListEvidence = null;
|
|
401
|
+
clearDagNodeExecutionOutputCache();
|
|
402
|
+
trace.push("clear-old");
|
|
403
|
+
// 3. set scope
|
|
404
|
+
setWorkspaceScope(nextWorkspaceId);
|
|
405
|
+
trace.push(`set-scope:${workspaceScope() ?? ""}`);
|
|
406
|
+
// 4. route/reload new
|
|
407
|
+
if (typeof routeValue === "function") routeValue();
|
|
408
|
+
else if (typeof routeValue === "string") options.route?.(routeValue);
|
|
409
|
+
trace.push("route-new");
|
|
410
|
+
if (options.onTrace) options.onTrace(trace);
|
|
411
|
+
return trace;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
/** Append ?workspaceId= to an observe API URL (real request path kept). */
|
|
415
|
+
export function scopedApiUrl(url) {
|
|
416
|
+
const raw = String(url ?? "");
|
|
417
|
+
if (!currentWorkspaceScope || !raw.startsWith("/api/")) return raw;
|
|
418
|
+
const qIndex = raw.indexOf("?");
|
|
419
|
+
if (qIndex >= 0) {
|
|
420
|
+
const params = new URLSearchParams(raw.slice(qIndex + 1));
|
|
421
|
+
if (params.has("workspaceId")) return raw;
|
|
422
|
+
params.set("workspaceId", currentWorkspaceScope);
|
|
423
|
+
return `${raw.slice(0, qIndex)}?${params.toString()}`;
|
|
424
|
+
}
|
|
425
|
+
return `${raw}?workspaceId=${encodeURIComponent(currentWorkspaceScope)}`;
|
|
426
|
+
}
|
|
427
|
+
|
|
282
428
|
export function detailPollDelay(status, isVisible) {
|
|
283
429
|
const normalizedStatus = (status ?? "").toLowerCase().replace(/-/g, "_");
|
|
284
430
|
if (TERMINAL_RUN_STATUSES.has(normalizedStatus)) return null;
|
|
431
|
+
if (!isWorkspaceActive()) return null;
|
|
285
432
|
return isVisible ? ACTIVE_DETAIL_POLL_MS : HIDDEN_POLL_MS;
|
|
286
433
|
}
|
|
287
434
|
|
|
288
435
|
export function dashboardPollDelay() {
|
|
436
|
+
if (!isWorkspaceActive()) return null;
|
|
289
437
|
return isPageVisible() ? DASHBOARD_POLL_MS : HIDDEN_POLL_MS;
|
|
290
438
|
}
|
|
291
439
|
|
|
440
|
+
/** Stop pausable timers without destroying route/selection/scroll. */
|
|
441
|
+
export function pauseForegroundTimers() {
|
|
442
|
+
if (uiState.dashboardTimer) {
|
|
443
|
+
clearTimeout(uiState.dashboardTimer);
|
|
444
|
+
uiState.dashboardTimer = null;
|
|
445
|
+
}
|
|
446
|
+
if (uiState.runPollTimer) {
|
|
447
|
+
clearTimeout(uiState.runPollTimer);
|
|
448
|
+
uiState.runPollTimer = null;
|
|
449
|
+
}
|
|
450
|
+
if (uiState.dagPollTimer) {
|
|
451
|
+
clearTimeout(uiState.dagPollTimer);
|
|
452
|
+
uiState.dagPollTimer = null;
|
|
453
|
+
}
|
|
454
|
+
if (uiState.poolTimer) {
|
|
455
|
+
clearTimeout(uiState.poolTimer);
|
|
456
|
+
uiState.poolTimer = null;
|
|
457
|
+
}
|
|
458
|
+
if (uiState.taskPollTimer) {
|
|
459
|
+
clearTimeout(uiState.taskPollTimer);
|
|
460
|
+
uiState.taskPollTimer = null;
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
|
|
292
464
|
export function updateDagGraphViewportState(
|
|
293
465
|
_previous,
|
|
294
466
|
dagRunId,
|