@tea-agent/loop-agent 0.13.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +157 -157
- package/CHANGELOG.md +73 -301
- package/README.md +338 -334
- package/bin/agent-worker.js +22 -22
- package/bin/loop-agent.js +21 -21
- package/dist/commands/cursor-prompt.js +6 -6
- package/dist/commands/init.js +505 -505
- package/dist/commands/loop-benchmark.js +11 -11
- package/dist/commands/pi-reuse-benchmark.js +16 -16
- package/dist/executors/pi-event-serializer.js +33 -11
- package/dist/sidecars/cursor-prompt/executor.js +1 -1
- package/dist/task/runtime.js +27 -27
- package/dist/worker/observe/spec-evidence.js +19 -10
- package/dist/worker/observe/static/api.js +46 -46
- package/dist/worker/observe/static/app.js +151 -150
- package/dist/worker/observe/static/constants.js +156 -148
- package/dist/worker/observe/static/copy.js +67 -67
- package/dist/worker/observe/static/dag-helpers.js +201 -172
- package/dist/worker/observe/static/dag-layout.d.ts +31 -31
- package/dist/worker/observe/static/dag-layout.js +83 -83
- package/dist/worker/observe/static/dag-model.js +72 -72
- package/dist/worker/observe/static/dom.js +122 -122
- package/dist/worker/observe/static/format-pool.d.ts +71 -0
- package/dist/worker/observe/static/format-pool.js +134 -67
- package/dist/worker/observe/static/format.js +317 -292
- package/dist/worker/observe/static/index.html +350 -308
- package/dist/worker/observe/static/kpi.js +100 -94
- package/dist/worker/observe/static/markdown-render.js +124 -0
- package/dist/worker/observe/static/relations.js +133 -133
- package/dist/worker/observe/static/router.js +93 -93
- package/dist/worker/observe/static/run-processing.js +148 -148
- package/dist/worker/observe/static/shell-chrome.js +74 -68
- package/dist/worker/observe/static/state.js +273 -267
- package/dist/worker/observe/static/styles.css +2504 -1902
- package/dist/worker/observe/static/views/batch.js +227 -227
- package/dist/worker/observe/static/views/dag-graph.js +172 -172
- package/dist/worker/observe/static/views/dag-inspector.js +530 -627
- package/dist/worker/observe/static/views/dag.js +371 -371
- package/dist/worker/observe/static/views/dashboard.js +86 -100
- package/dist/worker/observe/static/views/failures.js +143 -143
- package/dist/worker/observe/static/views/feature.js +492 -492
- package/dist/worker/observe/static/views/pool.js +708 -350
- package/dist/worker/observe/static/views/run.js +453 -453
- package/dist/worker/observe/static/views/session-timeline.js +771 -219
- package/dist/worker/observe/static/views/shell.js +7 -7
- package/dist/worker/observe/static/views/task.js +314 -314
- package/dist/worker/observe/static/views/timeline.js +163 -163
- package/dist/workflows/dag/canvas-observer.js +275 -275
- package/docs/README.md +105 -104
- package/docs/agent-dag-recovery-playbook.md +195 -195
- package/docs/agent-dag-runner.md +67 -67
- package/docs/architecture/README.md +26 -26
- package/docs/architecture/dag-execution.md +140 -140
- package/docs/architecture/evolution.md +54 -54
- package/docs/architecture/facts-and-state.md +71 -71
- package/docs/architecture/runtime-boundaries.md +191 -191
- package/docs/architecture/system-overview.md +93 -93
- package/docs/architecture/worker-and-feature.md +85 -85
- package/docs/cursor-prompt-sidecar.md +36 -36
- package/docs/decisions/README.md +18 -18
- package/docs/design/README.md +167 -167
- package/docs/development-principles.md +73 -73
- package/docs/exec-plans/README.md +6 -6
- package/docs/exec-plans/active/README.md +2 -1
- package/docs/exec-plans/completed/README.md +105 -104
- package/docs/feature-workflow.md +414 -414
- package/docs/harness-methodology-debugging.md +153 -153
- package/docs/harness-methodology-tdd.md +130 -130
- package/docs/harness-methodology-verification.md +27 -27
- package/docs/init-surface.manifest.json +307 -307
- package/docs/loop-agent-harness.md +142 -142
- package/docs/production-readiness.md +96 -96
- package/docs/progress/README.md +59 -58
- package/docs/reports/README.md +123 -119
- package/docs/skills/README.md +7 -7
- package/docs/skills/vetted-skill-registry.md +29 -29
- package/docs/templates/adr.md +60 -60
- package/docs/templates/agent-dag-authority-surface-audit.prompt.md +94 -94
- package/docs/templates/agent-dag-decision-envelope.schema.json +213 -213
- package/docs/templates/agent-dag-decision-gate-dogfood-report.md +117 -117
- package/docs/templates/agent-dag-decision-gate.prompt.md +246 -246
- package/docs/templates/agent-dag-process-supervisor.prompt.md +98 -98
- package/docs/templates/agent-dag-report.schema.json +473 -473
- package/docs/templates/agent-dag-review-verdict.prompt.md +68 -68
- package/docs/templates/agent-dag.base.json +190 -190
- package/docs/templates/agent-dag.final-verification.json +185 -185
- package/docs/templates/agent-dag.schema.json +411 -411
- package/docs/templates/agent-dag.supervised-implementation.json +620 -620
- package/docs/templates/backend-test-analysis.schema.json +44 -44
- package/docs/templates/backend-test-case-manifest.schema.json +190 -190
- package/docs/templates/backend-test-dag.classify.prompt.md +75 -75
- package/docs/templates/backend-test-dag.generate-pytest.prompt.md +204 -204
- package/docs/templates/backend-test-dag.json +559 -559
- package/docs/templates/backend-test-dag.retrospect.prompt.md +139 -139
- package/docs/templates/backend-test-dag.review-cases.prompt.md +83 -83
- package/docs/templates/backend-test-execution.schema.json +133 -133
- package/docs/templates/backend-test-result.schema.json +99 -99
- package/docs/templates/exec-plan.md +64 -64
- package/docs/templates/feature-spec.md +53 -53
- package/docs/templates/frontend-design-contract.md +42 -42
- package/docs/templates/frontend-eval/fixtures/failures/01-type-build-error.md +17 -17
- package/docs/templates/frontend-eval/fixtures/failures/02-unit-component-test-fail.md +16 -16
- package/docs/templates/frontend-eval/fixtures/failures/03-fixture-schema-drift.md +16 -16
- package/docs/templates/frontend-eval/fixtures/failures/04-missing-loading-empty-error-state.md +16 -16
- package/docs/templates/frontend-eval/fixtures/failures/05-forbidden-write-writeset-expansion.md +16 -16
- package/docs/templates/frontend-eval/fixtures/failures/06-unapproved-dependency-add.md +16 -16
- package/docs/templates/frontend-eval/fixtures/failures/07-mock-production-on.md +21 -21
- package/docs/templates/frontend-eval/fixtures/functional/01-simple-component-style.md +29 -29
- package/docs/templates/frontend-eval/fixtures/functional/02-form-validation.md +28 -28
- package/docs/templates/frontend-eval/fixtures/functional/03-list-detail-page.md +28 -28
- package/docs/templates/frontend-eval/fixtures/functional/04-api-mock.md +29 -29
- package/docs/templates/frontend-eval/fixtures/functional/05-permission-auth-gated-ui.md +27 -27
- package/docs/templates/frontend-eval/fixtures/functional/06-ssr-server-client-boundary.md +28 -28
- package/docs/templates/frontend-eval/fixtures/functional/07-shared-public-component-api.md +28 -28
- package/docs/templates/frontend-eval/fixtures/functional/08-pure-local-no-remote.md +27 -27
- package/docs/templates/frontend-eval/metrics.md +138 -138
- package/docs/templates/frontend-eval/smoke-targets.md +53 -53
- package/docs/templates/frontend-implementation-contract.schema.json +27 -27
- package/docs/templates/frontend-task-constraints.md +35 -35
- package/docs/templates/frontend-task-requirement.md +70 -70
- package/docs/templates/frontend-test-dag.generate-cases.prompt.md +5 -5
- package/docs/templates/frontend-test-dag.json +23 -23
- package/docs/templates/frontend-test-dag.retrieve-context.prompt.md +3 -3
- package/docs/templates/frontend-test-dag.retrospect.prompt.md +3 -3
- package/docs/templates/frontend-test-dag.review-cases.prompt.md +3 -3
- package/docs/templates/frontend-test-dag.review-execution.prompt.md +3 -3
- package/docs/templates/harness.schema.json +221 -221
- package/docs/templates/hybrid-dag.json +188 -188
- package/docs/templates/init-evolution-review.md +35 -35
- package/docs/templates/interactive-ui-round2-experiment.md +66 -66
- package/docs/templates/knowledge-graph-bootstrap-dag.json +118 -118
- package/docs/templates/knowledge-sync-dag.json +178 -178
- package/docs/templates/knowledge-sync-draft.schema.json +71 -71
- package/docs/templates/product-line/AGENTS.md +8 -8
- package/docs/templates/product-line/README.md +9 -9
- package/docs/templates/product-line/acceptance.yaml +14 -14
- package/docs/templates/product-line/closeout.yaml +9 -9
- package/docs/templates/product-line/design.md +13 -13
- package/docs/templates/product-line/links.md +10 -10
- package/docs/templates/product-line/requirement.md +17 -17
- package/docs/templates/product-line/task-graph.yaml +15 -15
- package/docs/templates/product-line/task.yaml +64 -64
- package/docs/templates/product-line/test-plan.md +7 -7
- package/docs/templates/production-readiness-checklist.md +57 -57
- package/docs/templates/progress-log.md +17 -17
- package/docs/templates/project-start-checklist.md +9 -9
- package/docs/templates/qa-report.md +48 -48
- package/docs/templates/sprint-contract.md +29 -29
- package/docs/templates/worker-dogfood-evidence.md +80 -80
- package/docs/templates/worker-dogfood-setup.md +68 -68
- package/docs/verification-matrix.md +70 -70
- package/examples/decision-gate-agent-dag.json +173 -173
- package/examples/example-dag.json +46 -46
- package/examples/hybrid-loop-agent-dag.json +188 -188
- package/harness.json +66 -66
- package/package.json +88 -52
- package/scripts/check-product-line-docs.sh +29 -29
- package/scripts/check-task-pool-root.sh +32 -32
- package/scripts/kb-bootstrap-init-skeleton.sh +240 -240
- package/scripts/kb-graph-incremental-prepare.mjs +386 -386
- package/scripts/kb-graph-incremental-prepare.sh +5 -5
- package/scripts/kb-graph-materialize.mjs +105 -105
- package/scripts/kb-graph-materialize.sh +4 -4
- package/scripts/kb-graph-promote.mjs +164 -164
- package/scripts/kb-graph-promote.sh +4 -4
- package/scripts/kb-query.mjs +554 -554
- package/scripts/kb-query.sh +5 -5
- package/skills/agent-worker/SKILL.md +39 -39
- package/skills/agent-worker/references/agent-worker-operator.md +60 -60
- package/skills/ai-engineering-context/SKILL.md +48 -48
- package/skills/analyze-product-dependencies/SKILL.md +67 -67
- package/skills/analyze-product-dependencies/agents/openai.yaml +4 -4
- package/skills/analyze-product-dependencies/references/api-documentation-schema.md +30 -30
- package/skills/analyze-product-dependencies/references/dependency-analysis-schema.md +28 -28
- package/skills/analyze-product-dependencies/references/example.md +76 -76
- package/skills/analyze-product-dependencies/references/forward-test-cases.md +35 -35
- package/skills/analyze-product-dependencies/references/input-contract.md +11 -11
- package/skills/analyze-product-dependencies/references/scouting-rules.md +61 -61
- package/skills/analyze-product-dependencies/scripts/test-validators.mjs +267 -267
- package/skills/analyze-product-dependencies/scripts/validate-api-documentation.mjs +101 -101
- package/skills/analyze-product-dependencies/scripts/validate-dependency-analysis.mjs +142 -142
- package/skills/analyze-product-dependencies/scripts/validate-product-requirement-input.mjs +76 -76
- package/skills/analyze-product-dependencies/scripts/validation-helpers.mjs +146 -146
- package/skills/analyze-product-requirements/SKILL.md +90 -90
- package/skills/analyze-product-requirements/agents/openai.yaml +4 -4
- package/skills/analyze-product-requirements/references/acceptance-criteria.md +91 -91
- package/skills/analyze-product-requirements/references/clarification-and-knowledge.md +56 -56
- package/skills/analyze-product-requirements/references/example.md +86 -86
- package/skills/analyze-product-requirements/references/forward-test-cases.md +66 -66
- package/skills/analyze-product-requirements/references/product-analysis-schema.md +32 -32
- package/skills/analyze-product-requirements/references/product-requirement-schema.md +33 -33
- package/skills/analyze-product-requirements/references/requirement-clarification-schema.md +35 -35
- package/skills/analyze-product-requirements/scripts/test-validators.mjs +193 -193
- package/skills/analyze-product-requirements/scripts/validate-product-analysis.mjs +69 -69
- package/skills/analyze-product-requirements/scripts/validate-product-requirement.mjs +97 -97
- package/skills/analyze-product-requirements/scripts/validate-requirement-clarification.mjs +98 -98
- package/skills/analyze-product-requirements/scripts/validation-helpers.mjs +156 -156
- package/skills/browser-tools/SKILL.md +196 -196
- package/skills/browser-tools/browser-content.js +103 -103
- package/skills/browser-tools/browser-cookies.js +35 -35
- package/skills/browser-tools/browser-eval.js +53 -53
- package/skills/browser-tools/browser-hn-scraper.js +108 -108
- package/skills/browser-tools/browser-nav.js +44 -44
- package/skills/browser-tools/browser-pick.js +162 -162
- package/skills/browser-tools/browser-screenshot.js +34 -34
- package/skills/browser-tools/browser-start.js +86 -86
- package/skills/browser-tools/package-lock.json +2556 -2556
- package/skills/browser-tools/package.json +19 -19
- package/skills/code-review-core/SKILL.md +20 -20
- package/skills/codebase-scout/SKILL.md +19 -19
- package/skills/frontend-design-review/SKILL.md +66 -66
- package/skills/frontend-design-review/references/review-checklist.md +58 -58
- package/skills/frontend-implementation/SKILL.md +49 -49
- package/skills/frontend-implementation/references/code-standards.md +32 -32
- package/skills/frontend-implementation/references/design-spec.md +46 -46
- package/skills/frontend-implementation/references/node-contracts.md +27 -27
- package/skills/frontend-review/SKILL.md +59 -59
- package/skills/frontend-review/references/review-findings.md +47 -47
- package/skills/frontend-verification/SKILL.md +53 -53
- package/skills/frontend-verification/references/verification-checklist.md +68 -68
- package/skills/grill-me/SKILL.md +10 -10
- package/skills/grill-with-docs/SKILL.md +88 -88
- package/skills/grill-with-docs/adr-format.md +47 -47
- package/skills/grill-with-docs/context-format.md +60 -60
- package/skills/init-capability-evolution/SKILL.md +70 -70
- package/skills/loop-agent/SKILL.md +151 -151
- package/skills/loop-agent/references/README.md +67 -67
- package/skills/loop-agent/references/command-reference.md +527 -527
- package/skills/loop-agent/references/docs-converge.md +126 -126
- package/skills/loop-agent/references/harness-policy.md +263 -263
- package/skills/loop-agent/references/hybrid-dag.md +243 -243
- package/skills/loop-agent/references/learned/README.md +21 -21
- package/skills/loop-agent/references/long-running-loop.md +57 -57
- package/skills/loop-agent/references/model-routing.md +36 -36
- package/skills/loop-agent/references/multi-worktree.md +54 -54
- package/skills/loop-agent/references/one-shot-runs.md +85 -85
- package/skills/loop-agent/references/orchestrator-and-interventions.md +169 -169
- package/skills/loop-agent/references/pi-prompt.md +23 -23
- package/skills/loop-agent/references/pi-subagent-assisted-mode.md +84 -84
- package/skills/loop-agent/references/post-implementation-and-patterns.md +44 -44
- package/skills/loop-agent/references/task-workflow.md +89 -89
- package/skills/loop-agent/references/verification-and-failure-handling.md +141 -141
- package/skills/playwright-cli/SKILL.md +420 -420
- package/skills/playwright-cli/references/element-attributes.md +23 -23
- package/skills/playwright-cli/references/playwright-tests.md +39 -39
- package/skills/playwright-cli/references/request-mocking.md +87 -87
- package/skills/playwright-cli/references/running-code.md +241 -241
- package/skills/playwright-cli/references/session-management.md +225 -225
- package/skills/playwright-cli/references/storage-state.md +275 -275
- package/skills/playwright-cli/references/test-generation.md +433 -433
- package/skills/playwright-cli/references/tracing.md +139 -139
- package/skills/playwright-cli/references/video-recording.md +143 -143
- package/skills/playwright-cli-case-generator/SKILL.md +74 -74
- package/skills/requesting-code-review/SKILL.md +101 -101
- package/skills/requesting-code-review/code-reviewer.md +168 -168
- package/skills/systematic-debugging/CREATION-LOG.md +119 -119
- package/skills/systematic-debugging/SKILL.md +296 -296
- package/skills/systematic-debugging/condition-based-waiting-example.ts +158 -158
- package/skills/systematic-debugging/condition-based-waiting.md +115 -115
- package/skills/systematic-debugging/defense-in-depth.md +122 -122
- package/skills/systematic-debugging/find-polluter.sh +63 -63
- package/skills/systematic-debugging/root-cause-tracing.md +169 -169
- package/skills/systematic-debugging/test-academic.md +14 -14
- package/skills/systematic-debugging/test-pressure-1.md +58 -58
- package/skills/systematic-debugging/test-pressure-2.md +68 -68
- package/skills/systematic-debugging/test-pressure-3.md +69 -69
- package/skills/test-driven-development/SKILL.md +20 -20
- package/skills/using-git-worktrees/SKILL.md +215 -215
- package/skills/verification-before-completion/SKILL.md +154 -154
- package/skills/webapp-testing/SKILL.md +19 -19
|
@@ -1,627 +1,530 @@
|
|
|
1
|
-
/** DAG node inspector panel (Observe UI R5). */
|
|
2
|
-
import {
|
|
3
|
-
DAG_INSPECTOR_DEFAULT_WIDTH,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
//
|
|
30
|
-
//
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
uiState.
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
event.
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
)
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
);
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
if (
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
(
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
)
|
|
405
|
-
);
|
|
406
|
-
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
)
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
if (
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
const
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
uiState.
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
dagRunId,
|
|
532
|
-
node.nodeId,
|
|
533
|
-
uiState.dagInspectorTab,
|
|
534
|
-
node.outputPreview ?? "",
|
|
535
|
-
node.errorPreview ?? "",
|
|
536
|
-
uiState.dagInspectorTab === "timeline" ? uiState.sessionEventOffset : null,
|
|
537
|
-
]);
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
export function renderDagInspector(dagRunId, node, initial = true) {
|
|
541
|
-
// Record the current selection before any early-return so tab handlers
|
|
542
|
-
// (which reference the mutable inspectorSelection slot) always re-render
|
|
543
|
-
// the currently selected node, never a stale build-time closure.
|
|
544
|
-
inspectorSelection.dagRunId = dagRunId;
|
|
545
|
-
inspectorSelection.node = node;
|
|
546
|
-
const panel = document.getElementById("dag-inspector");
|
|
547
|
-
if (!panel) return;
|
|
548
|
-
captureDagTimelineViewportState(panel);
|
|
549
|
-
if (!uiState.dagInspectorOpen || !node) {
|
|
550
|
-
panel.classList.remove("is-open");
|
|
551
|
-
panel.setAttribute("aria-hidden", "true");
|
|
552
|
-
return;
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
// Defer tearing down the inspector shell while the user is actively
|
|
556
|
-
// dragging the resize handle (or the graph) so the pointer-capture target
|
|
557
|
-
// is not destroyed mid-gesture; the next poll refreshes the content.
|
|
558
|
-
if (isInteractiveGestureActive(document.body.classList)) {
|
|
559
|
-
return;
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
const existingContent = panel.querySelector(".dag-inspector-content") ?? null;
|
|
563
|
-
const reuseShell = !initial && Boolean(existingContent);
|
|
564
|
-
const nextContentSignature = dagInspectorSignature(dagRunId, node);
|
|
565
|
-
|
|
566
|
-
if (reuseShell && existingContent) {
|
|
567
|
-
panel.classList.add("is-open");
|
|
568
|
-
panel.setAttribute("aria-hidden", "false");
|
|
569
|
-
syncDagInspectorHeader(panel, dagRunId, node);
|
|
570
|
-
if (panel.dataset.contentSignature === nextContentSignature) return;
|
|
571
|
-
const previousNode = existingContent.dataset.dagNodeId ?? "";
|
|
572
|
-
const nodeChanged = previousNode !== String(node.nodeId ?? "");
|
|
573
|
-
const followLatest =
|
|
574
|
-
nodeChanged ||
|
|
575
|
-
computeFollowLatest(
|
|
576
|
-
existingContent.scrollTop,
|
|
577
|
-
existingContent.scrollHeight,
|
|
578
|
-
existingContent.clientHeight,
|
|
579
|
-
);
|
|
580
|
-
const regionKey = `dag:${dagRunId}:${node.nodeId}:output`;
|
|
581
|
-
uiState.dagNodeOutputViewportState = updateDagOutputViewportState(
|
|
582
|
-
uiState.dagNodeOutputViewportState,
|
|
583
|
-
regionKey,
|
|
584
|
-
existingContent.scrollLeft,
|
|
585
|
-
existingContent.scrollTop,
|
|
586
|
-
followLatest,
|
|
587
|
-
);
|
|
588
|
-
const nestedViewportState = [
|
|
589
|
-
...existingContent.querySelectorAll("pre"),
|
|
590
|
-
].map((pre) => ({
|
|
591
|
-
scrollLeft: pre.scrollLeft,
|
|
592
|
-
scrollTop: pre.scrollTop,
|
|
593
|
-
}));
|
|
594
|
-
clearNode(existingContent);
|
|
595
|
-
fillDagInspectorContent(existingContent, dagRunId, node);
|
|
596
|
-
if (followLatest) {
|
|
597
|
-
existingContent.scrollTop = existingContent.scrollHeight;
|
|
598
|
-
} else {
|
|
599
|
-
existingContent.scrollTop = uiState.dagNodeOutputViewportState.scrollTop;
|
|
600
|
-
}
|
|
601
|
-
for (const [index, pre] of [
|
|
602
|
-
...existingContent.querySelectorAll("pre"),
|
|
603
|
-
].entries()) {
|
|
604
|
-
const previous = nestedViewportState[index];
|
|
605
|
-
if (!previous) continue;
|
|
606
|
-
pre.scrollLeft = previous.scrollLeft;
|
|
607
|
-
pre.scrollTop = previous.scrollTop;
|
|
608
|
-
}
|
|
609
|
-
panel.dataset.contentSignature = nextContentSignature;
|
|
610
|
-
return;
|
|
611
|
-
}
|
|
612
|
-
|
|
613
|
-
clearNode(panel);
|
|
614
|
-
panel.classList.add("is-open");
|
|
615
|
-
panel.setAttribute("aria-hidden", "false");
|
|
616
|
-
panel.appendChild(createDagInspectorResizeHandle(panel));
|
|
617
|
-
panel.appendChild(buildDagInspectorHeader(dagRunId, node));
|
|
618
|
-
|
|
619
|
-
const content = el("div", "dag-inspector-content");
|
|
620
|
-
fillDagInspectorContent(content, dagRunId, node);
|
|
621
|
-
panel.appendChild(content);
|
|
622
|
-
panel.dataset.contentSignature = nextContentSignature;
|
|
623
|
-
}
|
|
624
|
-
|
|
625
|
-
/**
|
|
626
|
-
* Bounded event history UI. Uses opaque `cursor`/`nextCursor` (not SSE/run `after` offsets).
|
|
627
|
-
*/
|
|
1
|
+
/** DAG node inspector panel (Observe UI R5). */
|
|
2
|
+
import {
|
|
3
|
+
DAG_INSPECTOR_DEFAULT_WIDTH,
|
|
4
|
+
DAG_INSPECTOR_DEFAULT_WIDTH_RATIO,
|
|
5
|
+
DAG_INSPECTOR_MIN_WIDTH,
|
|
6
|
+
DAG_INSPECTOR_MAX_WIDTH,
|
|
7
|
+
DAG_INSPECTOR_RIGHT_OFFSET,
|
|
8
|
+
DAG_INSPECTOR_VIEWPORT_MARGIN,
|
|
9
|
+
DAG_INSPECTOR_KEYBOARD_STEP,
|
|
10
|
+
UI_TEXT,
|
|
11
|
+
} from "../constants.js";
|
|
12
|
+
import { clearNode, el } from "../dom.js";
|
|
13
|
+
import { fetchJson } from "../api.js";
|
|
14
|
+
import { badge } from "../format.js";
|
|
15
|
+
import { renderMarkdown } from "../markdown-render.js";
|
|
16
|
+
import {
|
|
17
|
+
uiState,
|
|
18
|
+
makeSessionEventIdentity,
|
|
19
|
+
updateDagTimelineViewportState,
|
|
20
|
+
updateDagOutputViewportState,
|
|
21
|
+
computeFollowLatest,
|
|
22
|
+
isInteractiveGestureActive,
|
|
23
|
+
} from "../state.js";
|
|
24
|
+
import {
|
|
25
|
+
formatSessionEventTime,
|
|
26
|
+
renderSessionTimeline,
|
|
27
|
+
} from "./session-timeline.js";
|
|
28
|
+
|
|
29
|
+
// Current inspector selection. Tab handlers reference this mutable slot so a
|
|
30
|
+
// reused inspector shell never keeps stale node closures: every render writes
|
|
31
|
+
// the latest {dagRunId, node} here and tab clicks re-render from the same
|
|
32
|
+
// reference, always resolving the currently selected node identity.
|
|
33
|
+
const inspectorSelection = { dagRunId: null, node: null };
|
|
34
|
+
|
|
35
|
+
function renderDagInspectorForCurrent() {
|
|
36
|
+
if (!inspectorSelection.dagRunId || !inspectorSelection.node) return;
|
|
37
|
+
renderDagInspector(inspectorSelection.dagRunId, inspectorSelection.node, false);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function selectDagNode(dagRunId, nodeId) {
|
|
41
|
+
const nodeChanged = uiState.selectedDagNodeId !== nodeId;
|
|
42
|
+
uiState.selectedDagNodeId = nodeId;
|
|
43
|
+
uiState.dagInspectorOpen = true;
|
|
44
|
+
if (nodeChanged) {
|
|
45
|
+
uiState.sessionEventOffset = 0;
|
|
46
|
+
uiState.sessionEvents = [];
|
|
47
|
+
// Bump the session-event identity token so any in-flight response for the
|
|
48
|
+
// previous node is rejected before it can mutate the current node cache.
|
|
49
|
+
uiState.sessionEventIdentity = makeSessionEventIdentity(dagRunId, nodeId);
|
|
50
|
+
}
|
|
51
|
+
void import("./dag.js").then((m) => m.renderDagDetail(dagRunId, false));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function closeDagInspector() {
|
|
55
|
+
uiState.dagInspectorOpen = false;
|
|
56
|
+
const panel = document.getElementById("dag-inspector");
|
|
57
|
+
if (panel) {
|
|
58
|
+
panel.classList.remove("is-open");
|
|
59
|
+
panel.setAttribute("aria-hidden", "true");
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function closeDagInspectorOnOutsideClick(event) {
|
|
64
|
+
if (!uiState.dagInspectorOpen || !(event.target instanceof Element)) return;
|
|
65
|
+
if (
|
|
66
|
+
event.target.closest(
|
|
67
|
+
"#dag-inspector, .dag-node-table tbody tr, button, a, input, select, textarea, [role='button'], [role='tab']",
|
|
68
|
+
)
|
|
69
|
+
) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
closeDagInspector();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function dagInspectorMaximumWidth() {
|
|
76
|
+
return Math.max(
|
|
77
|
+
DAG_INSPECTOR_MIN_WIDTH,
|
|
78
|
+
Math.min(
|
|
79
|
+
DAG_INSPECTOR_MAX_WIDTH,
|
|
80
|
+
window.innerWidth - DAG_INSPECTOR_VIEWPORT_MARGIN,
|
|
81
|
+
),
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** Default open width: half the viewport, clamped to min/max. */
|
|
86
|
+
export function dagInspectorDefaultWidth() {
|
|
87
|
+
const half = Math.round(
|
|
88
|
+
window.innerWidth * DAG_INSPECTOR_DEFAULT_WIDTH_RATIO,
|
|
89
|
+
);
|
|
90
|
+
return Math.min(
|
|
91
|
+
dagInspectorMaximumWidth(),
|
|
92
|
+
Math.max(DAG_INSPECTOR_MIN_WIDTH, half || DAG_INSPECTOR_DEFAULT_WIDTH),
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export function setDagInspectorWidth(panel, requestedWidth) {
|
|
97
|
+
const maximum = dagInspectorMaximumWidth();
|
|
98
|
+
uiState.dagInspectorWidth = Math.min(
|
|
99
|
+
maximum,
|
|
100
|
+
Math.max(DAG_INSPECTOR_MIN_WIDTH, Math.round(requestedWidth)),
|
|
101
|
+
);
|
|
102
|
+
panel.style.setProperty(
|
|
103
|
+
"--dag-inspector-width",
|
|
104
|
+
`${uiState.dagInspectorWidth}px`,
|
|
105
|
+
);
|
|
106
|
+
return {
|
|
107
|
+
minimum: DAG_INSPECTOR_MIN_WIDTH,
|
|
108
|
+
maximum,
|
|
109
|
+
value: uiState.dagInspectorWidth,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export function createDagInspectorResizeHandle(panel) {
|
|
114
|
+
const handle = el("div", "dag-inspector-resize-handle");
|
|
115
|
+
handle.tabIndex = 0;
|
|
116
|
+
handle.setAttribute("role", "separator");
|
|
117
|
+
handle.setAttribute("aria-orientation", "vertical");
|
|
118
|
+
handle.setAttribute("aria-label", "调整节点检查器宽度");
|
|
119
|
+
handle.title = "拖动调整节点检查器宽度";
|
|
120
|
+
|
|
121
|
+
const updateRange = (requestedWidth) => {
|
|
122
|
+
const range = setDagInspectorWidth(
|
|
123
|
+
panel,
|
|
124
|
+
requestedWidth ??
|
|
125
|
+
uiState.dagInspectorWidth ??
|
|
126
|
+
dagInspectorDefaultWidth(),
|
|
127
|
+
);
|
|
128
|
+
handle.setAttribute("aria-valuemin", String(range.minimum));
|
|
129
|
+
handle.setAttribute("aria-valuemax", String(range.maximum));
|
|
130
|
+
handle.setAttribute("aria-valuenow", String(range.value));
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
updateRange();
|
|
134
|
+
handle.addEventListener("pointerdown", (event) => {
|
|
135
|
+
if (event.button !== 0) return;
|
|
136
|
+
event.preventDefault();
|
|
137
|
+
handle.setPointerCapture(event.pointerId);
|
|
138
|
+
document.body.classList.add("is-resizing-dag-inspector");
|
|
139
|
+
});
|
|
140
|
+
handle.addEventListener("pointermove", (event) => {
|
|
141
|
+
if (!handle.hasPointerCapture(event.pointerId)) return;
|
|
142
|
+
updateRange(window.innerWidth - event.clientX - DAG_INSPECTOR_RIGHT_OFFSET);
|
|
143
|
+
});
|
|
144
|
+
const stopResizing = (event) => {
|
|
145
|
+
if (handle.hasPointerCapture(event.pointerId)) {
|
|
146
|
+
handle.releasePointerCapture(event.pointerId);
|
|
147
|
+
}
|
|
148
|
+
document.body.classList.remove("is-resizing-dag-inspector");
|
|
149
|
+
};
|
|
150
|
+
handle.addEventListener("pointerup", stopResizing);
|
|
151
|
+
handle.addEventListener("pointercancel", stopResizing);
|
|
152
|
+
handle.addEventListener("keydown", (event) => {
|
|
153
|
+
const currentWidth =
|
|
154
|
+
uiState.dagInspectorWidth ?? dagInspectorDefaultWidth();
|
|
155
|
+
if (event.key === "ArrowLeft") {
|
|
156
|
+
event.preventDefault();
|
|
157
|
+
updateRange(currentWidth + DAG_INSPECTOR_KEYBOARD_STEP);
|
|
158
|
+
} else if (event.key === "ArrowRight") {
|
|
159
|
+
event.preventDefault();
|
|
160
|
+
updateRange(currentWidth - DAG_INSPECTOR_KEYBOARD_STEP);
|
|
161
|
+
} else if (event.key === "Home") {
|
|
162
|
+
event.preventDefault();
|
|
163
|
+
updateRange(DAG_INSPECTOR_MIN_WIDTH);
|
|
164
|
+
} else if (event.key === "End") {
|
|
165
|
+
event.preventDefault();
|
|
166
|
+
updateRange(dagInspectorMaximumWidth());
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
return handle;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export function captureDagTimelineViewportState(panel) {
|
|
173
|
+
const scrollEl = panel.querySelector(".process-timeline-scroll");
|
|
174
|
+
if (scrollEl?.dataset.dagRunId && scrollEl.dataset.nodeId) {
|
|
175
|
+
const followLatest = computeFollowLatest(
|
|
176
|
+
scrollEl.scrollTop,
|
|
177
|
+
scrollEl.scrollHeight,
|
|
178
|
+
scrollEl.clientHeight,
|
|
179
|
+
);
|
|
180
|
+
uiState.dagTimelineViewportState = updateDagTimelineViewportState(
|
|
181
|
+
uiState.dagTimelineViewportState,
|
|
182
|
+
scrollEl.dataset.dagRunId,
|
|
183
|
+
scrollEl.dataset.nodeId,
|
|
184
|
+
scrollEl.scrollLeft,
|
|
185
|
+
scrollEl.scrollTop,
|
|
186
|
+
followLatest,
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
async function renderSpecEvidence(content, dagRunId, nodeId) {
|
|
192
|
+
const evidence = await fetchJson(
|
|
193
|
+
`/api/dag-runs/${encodeURIComponent(dagRunId)}/nodes/${encodeURIComponent(nodeId)}/spec-evidence`,
|
|
194
|
+
);
|
|
195
|
+
if (!content.isConnected || content.dataset.dagNodeId !== String(nodeId)) return;
|
|
196
|
+
if (!evidence) {
|
|
197
|
+
content.appendChild(el("p", "empty", "无法加载规范证据。"));
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
const statusLabels = {
|
|
202
|
+
"spec-read": "已读取规范",
|
|
203
|
+
"source-bound": "已绑定任务源",
|
|
204
|
+
"spec-injected": "仅注入 skill",
|
|
205
|
+
"search-only": "仅执行检索",
|
|
206
|
+
"kb-queried": "已观察知识库查询",
|
|
207
|
+
"no-evidence": "未观察到读取",
|
|
208
|
+
};
|
|
209
|
+
const statusSection = el("div", "spec-evidence-section");
|
|
210
|
+
statusSection.appendChild(el("h4", null, "证据状态"));
|
|
211
|
+
statusSection.appendChild(
|
|
212
|
+
el(
|
|
213
|
+
"span",
|
|
214
|
+
`badge badge-${evidence.status === "spec-read" ? "succeeded" : evidence.status === "no-evidence" ? "failed" : "pending"}`,
|
|
215
|
+
statusLabels[evidence.status] ?? evidence.status,
|
|
216
|
+
),
|
|
217
|
+
);
|
|
218
|
+
if (evidence.summary) {
|
|
219
|
+
statusSection.appendChild(
|
|
220
|
+
el("p", "spec-evidence-summary", evidence.summary),
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
content.appendChild(statusSection);
|
|
224
|
+
|
|
225
|
+
const appendListSection = (title, entries, renderEntry) => {
|
|
226
|
+
if (!entries?.length) return;
|
|
227
|
+
const section = el("div", "spec-evidence-section");
|
|
228
|
+
section.appendChild(el("h4", null, title));
|
|
229
|
+
const list = el("ul", "spec-evidence-list");
|
|
230
|
+
for (const entry of entries) list.appendChild(renderEntry(entry));
|
|
231
|
+
section.appendChild(list);
|
|
232
|
+
content.appendChild(section);
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
appendListSection("注入的 Skill", evidence.skillInjection?.skills, (skill) => {
|
|
236
|
+
const item = el("li", null);
|
|
237
|
+
const icon = el("i", "ri-bookmark-line");
|
|
238
|
+
icon.setAttribute("aria-hidden", "true");
|
|
239
|
+
item.append(icon, document.createTextNode(` ${skill}`));
|
|
240
|
+
return item;
|
|
241
|
+
});
|
|
242
|
+
appendListSection("已绑定任务源", evidence.sourceBinding?.sources, (source) => {
|
|
243
|
+
const item = el("li", null);
|
|
244
|
+
const icon = el("i", "ri-links-line");
|
|
245
|
+
icon.setAttribute("aria-hidden", "true");
|
|
246
|
+
item.append(icon, document.createTextNode(` ${source.kind}: `), el("code", null, source.path), document.createTextNode(` · sha256 ${source.sha256.slice(0, 12)}…`));
|
|
247
|
+
return item;
|
|
248
|
+
});
|
|
249
|
+
appendListSection("显式需求编号", evidence.sourceBinding?.requirementIds, (id) => el("li", null, id));
|
|
250
|
+
appendListSection(
|
|
251
|
+
`已读取规范文件(${evidence.specReads?.length ?? 0})`,
|
|
252
|
+
evidence.specReads,
|
|
253
|
+
(read) => {
|
|
254
|
+
const item = el("li", null);
|
|
255
|
+
const icon = el("i", "ri-file-text-line");
|
|
256
|
+
icon.setAttribute("aria-hidden", "true");
|
|
257
|
+
item.append(icon, el("code", null, read.path));
|
|
258
|
+
if (read.timestamp) {
|
|
259
|
+
item.appendChild(
|
|
260
|
+
el(
|
|
261
|
+
"span",
|
|
262
|
+
"spec-evidence-time",
|
|
263
|
+
formatSessionEventTime({ timestamp: read.timestamp }),
|
|
264
|
+
),
|
|
265
|
+
);
|
|
266
|
+
}
|
|
267
|
+
return item;
|
|
268
|
+
},
|
|
269
|
+
);
|
|
270
|
+
appendListSection(
|
|
271
|
+
`检索操作(${evidence.specSearches?.length ?? 0})`,
|
|
272
|
+
evidence.specSearches,
|
|
273
|
+
(search) => {
|
|
274
|
+
const item = el("li", null);
|
|
275
|
+
const icon = el("i", "ri-search-line");
|
|
276
|
+
icon.setAttribute("aria-hidden", "true");
|
|
277
|
+
item.append(icon, document.createTextNode(` ${search.tool}: ${search.query}`));
|
|
278
|
+
return item;
|
|
279
|
+
},
|
|
280
|
+
);
|
|
281
|
+
appendListSection(
|
|
282
|
+
`知识库查询(${evidence.knowledgeBaseQueries?.length ?? 0})`,
|
|
283
|
+
evidence.knowledgeBaseQueries,
|
|
284
|
+
(query) => {
|
|
285
|
+
const item = el("li", null);
|
|
286
|
+
const icon = el("i", "ri-database-2-line");
|
|
287
|
+
icon.setAttribute("aria-hidden", "true");
|
|
288
|
+
item.append(icon, document.createTextNode(` ${query.connector}`));
|
|
289
|
+
return item;
|
|
290
|
+
},
|
|
291
|
+
);
|
|
292
|
+
|
|
293
|
+
if (evidence.status === "source-bound" || evidence.status === "spec-injected" || evidence.status === "no-evidence") {
|
|
294
|
+
const warning = el("div", "spec-evidence-warning");
|
|
295
|
+
const icon = el("i", "ri-alert-line");
|
|
296
|
+
icon.setAttribute("aria-hidden", "true");
|
|
297
|
+
warning.append(
|
|
298
|
+
icon,
|
|
299
|
+
document.createTextNode(
|
|
300
|
+
evidence.status === "source-bound"
|
|
301
|
+
? "DAG 已绑定权威任务源及内容哈希,但尚未观察到成功的 read 工具调用;绑定证明上下文来源,read 事件才证明节点读取了完整文件。"
|
|
302
|
+
: evidence.status === "no-evidence"
|
|
303
|
+
? "未观察到规范读取。只有 session event 中成功配对的 read 工具调用才算已读取,模型总结或文件名命中不能作为证明。"
|
|
304
|
+
: "规范 skill 已注入,但未观察到规范读取或知识库查询;grep/find/ls 只能证明检索,不能替代 read。",
|
|
305
|
+
),
|
|
306
|
+
);
|
|
307
|
+
content.appendChild(warning);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
function fillDagInspectorContent(content, dagRunId, node) {
|
|
312
|
+
const activeTab = ["timeline", "spec-evidence"].includes(
|
|
313
|
+
uiState.dagInspectorTab,
|
|
314
|
+
)
|
|
315
|
+
? uiState.dagInspectorTab
|
|
316
|
+
: "output";
|
|
317
|
+
content.id = `dag-inspector-panel-${activeTab}`;
|
|
318
|
+
content.setAttribute("role", "tabpanel");
|
|
319
|
+
content.setAttribute("aria-labelledby", `dag-inspector-tab-${activeTab}`);
|
|
320
|
+
content.dataset.dagNodeId = String(node.nodeId ?? "");
|
|
321
|
+
// Drop timeline-only classes when switching tabs so output layout stays clean.
|
|
322
|
+
content.className = "dag-inspector-content";
|
|
323
|
+
if (activeTab === "spec-evidence") {
|
|
324
|
+
void renderSpecEvidence(content, dagRunId, node.nodeId);
|
|
325
|
+
} else if (activeTab === "timeline") {
|
|
326
|
+
renderSessionTimeline(content, node.nodeId);
|
|
327
|
+
} else if (!node.outputPreview && !node.errorPreview) {
|
|
328
|
+
content.appendChild(el("p", "empty", UI_TEXT.noOutput));
|
|
329
|
+
} else {
|
|
330
|
+
if (node.outputPreview)
|
|
331
|
+
content.appendChild(renderMarkdown(node.outputPreview));
|
|
332
|
+
if (node.errorPreview) {
|
|
333
|
+
const error = el("section", "markdown-error");
|
|
334
|
+
error.appendChild(el("p", "markdown-error-title", "错误输出"));
|
|
335
|
+
error.appendChild(renderMarkdown(node.errorPreview));
|
|
336
|
+
content.appendChild(error);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
function buildDagInspectorHeader(dagRunId, node) {
|
|
342
|
+
const header = el("div", "dag-inspector-header");
|
|
343
|
+
header.dataset.dagRunId = String(dagRunId ?? "");
|
|
344
|
+
header.dataset.dagNodeId = String(node.nodeId ?? "");
|
|
345
|
+
const title = el("div", "dag-inspector-title");
|
|
346
|
+
title.appendChild(el("h3", null, "节点检查器"));
|
|
347
|
+
title.appendChild(el("div", "dag-inspector-node", node.nodeId));
|
|
348
|
+
header.appendChild(title);
|
|
349
|
+
const controls = el("div", "dag-inspector-controls");
|
|
350
|
+
const status = badge(node.status ?? "unknown");
|
|
351
|
+
status.classList.add("dag-inspector-status");
|
|
352
|
+
controls.appendChild(status);
|
|
353
|
+
const close = document.createElement("button");
|
|
354
|
+
close.type = "button";
|
|
355
|
+
close.className = "dag-inspector-close";
|
|
356
|
+
close.setAttribute("aria-label", "关闭节点检查器");
|
|
357
|
+
const closeIcon = el("i", "ri-close-line");
|
|
358
|
+
closeIcon.setAttribute("aria-hidden", "true");
|
|
359
|
+
close.appendChild(closeIcon);
|
|
360
|
+
close.addEventListener("click", closeDagInspector);
|
|
361
|
+
controls.appendChild(close);
|
|
362
|
+
header.appendChild(controls);
|
|
363
|
+
|
|
364
|
+
const tabDefs = [
|
|
365
|
+
["output", "节点输出", "ri-file-text-line"],
|
|
366
|
+
["timeline", "执行过程", "ri-route-line"],
|
|
367
|
+
["spec-evidence", "规范证据", "ri-book-open-line"],
|
|
368
|
+
];
|
|
369
|
+
const tabs = el("div", "dag-inspector-tabs");
|
|
370
|
+
tabs.setAttribute("role", "tablist");
|
|
371
|
+
tabs.setAttribute("aria-label", "节点检查器面板");
|
|
372
|
+
for (const [tab, label, icon] of tabDefs) {
|
|
373
|
+
const selected = uiState.dagInspectorTab === tab;
|
|
374
|
+
const button = document.createElement("button");
|
|
375
|
+
button.type = "button";
|
|
376
|
+
button.id = `dag-inspector-tab-${tab}`;
|
|
377
|
+
button.className = "dag-inspector-tab";
|
|
378
|
+
button.setAttribute("role", "tab");
|
|
379
|
+
button.setAttribute("aria-controls", `dag-inspector-panel-${tab}`);
|
|
380
|
+
button.setAttribute("aria-selected", String(selected));
|
|
381
|
+
button.tabIndex = selected ? 0 : -1;
|
|
382
|
+
button.dataset.tab = tab;
|
|
383
|
+
const tabIcon = el("i", icon);
|
|
384
|
+
tabIcon.setAttribute("aria-hidden", "true");
|
|
385
|
+
button.appendChild(tabIcon);
|
|
386
|
+
button.appendChild(document.createTextNode(` ${label}`));
|
|
387
|
+
button.addEventListener("click", () => {
|
|
388
|
+
uiState.dagInspectorTab = tab;
|
|
389
|
+
renderDagInspectorForCurrent();
|
|
390
|
+
const next = document.getElementById(`dag-inspector-tab-${tab}`);
|
|
391
|
+
next?.focus();
|
|
392
|
+
});
|
|
393
|
+
button.addEventListener("keydown", (event) => {
|
|
394
|
+
if (event.key !== "ArrowLeft" && event.key !== "ArrowRight") return;
|
|
395
|
+
event.preventDefault();
|
|
396
|
+
event.stopPropagation();
|
|
397
|
+
const order = tabDefs.map(([id]) => id);
|
|
398
|
+
const idx = order.indexOf(tab);
|
|
399
|
+
if (idx < 0) return;
|
|
400
|
+
const delta = event.key === "ArrowRight" ? 1 : -1;
|
|
401
|
+
const nextTab = order[(idx + delta + order.length) % order.length];
|
|
402
|
+
uiState.dagInspectorTab = nextTab;
|
|
403
|
+
renderDagInspectorForCurrent();
|
|
404
|
+
document.getElementById(`dag-inspector-tab-${nextTab}`)?.focus();
|
|
405
|
+
});
|
|
406
|
+
tabs.appendChild(button);
|
|
407
|
+
}
|
|
408
|
+
header.appendChild(tabs);
|
|
409
|
+
return header;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
function syncDagInspectorHeader(panel, dagRunId, node) {
|
|
413
|
+
const header = panel.querySelector(".dag-inspector-header");
|
|
414
|
+
if (!header) return;
|
|
415
|
+
header.dataset.dagRunId = String(dagRunId ?? "");
|
|
416
|
+
header.dataset.dagNodeId = String(node.nodeId ?? "");
|
|
417
|
+
const nodeLabel = header.querySelector(".dag-inspector-node");
|
|
418
|
+
if (nodeLabel) nodeLabel.textContent = node.nodeId;
|
|
419
|
+
const status = header.querySelector(".dag-inspector-status");
|
|
420
|
+
if (status) {
|
|
421
|
+
const next = badge(node.status ?? "unknown");
|
|
422
|
+
next.classList.add("dag-inspector-status");
|
|
423
|
+
status.replaceWith(next);
|
|
424
|
+
}
|
|
425
|
+
for (const button of header.querySelectorAll(".dag-inspector-tab")) {
|
|
426
|
+
const selected = button.dataset.tab === uiState.dagInspectorTab;
|
|
427
|
+
button.setAttribute("aria-selected", String(selected));
|
|
428
|
+
button.tabIndex = selected ? 0 : -1;
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
function dagInspectorSignature(dagRunId, node) {
|
|
433
|
+
return JSON.stringify([
|
|
434
|
+
dagRunId,
|
|
435
|
+
node.nodeId,
|
|
436
|
+
uiState.dagInspectorTab,
|
|
437
|
+
node.outputPreview ?? "",
|
|
438
|
+
node.errorPreview ?? "",
|
|
439
|
+
uiState.dagInspectorTab === "timeline" ? uiState.sessionEventOffset : null,
|
|
440
|
+
]);
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
export function renderDagInspector(dagRunId, node, initial = true) {
|
|
444
|
+
// Record the current selection before any early-return so tab handlers
|
|
445
|
+
// (which reference the mutable inspectorSelection slot) always re-render
|
|
446
|
+
// the currently selected node, never a stale build-time closure.
|
|
447
|
+
inspectorSelection.dagRunId = dagRunId;
|
|
448
|
+
inspectorSelection.node = node;
|
|
449
|
+
const panel = document.getElementById("dag-inspector");
|
|
450
|
+
if (!panel) return;
|
|
451
|
+
captureDagTimelineViewportState(panel);
|
|
452
|
+
if (!uiState.dagInspectorOpen || !node) {
|
|
453
|
+
panel.classList.remove("is-open");
|
|
454
|
+
panel.setAttribute("aria-hidden", "true");
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
// Defer tearing down the inspector shell while the user is actively
|
|
459
|
+
// dragging the resize handle (or the graph) so the pointer-capture target
|
|
460
|
+
// is not destroyed mid-gesture; the next poll refreshes the content.
|
|
461
|
+
if (isInteractiveGestureActive(document.body.classList)) {
|
|
462
|
+
return;
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
const existingContent = panel.querySelector(".dag-inspector-content") ?? null;
|
|
466
|
+
const reuseShell = !initial && Boolean(existingContent);
|
|
467
|
+
const nextContentSignature = dagInspectorSignature(dagRunId, node);
|
|
468
|
+
|
|
469
|
+
if (reuseShell && existingContent) {
|
|
470
|
+
panel.classList.add("is-open");
|
|
471
|
+
panel.setAttribute("aria-hidden", "false");
|
|
472
|
+
syncDagInspectorHeader(panel, dagRunId, node);
|
|
473
|
+
if (panel.dataset.contentSignature === nextContentSignature) return;
|
|
474
|
+
const previousNode = existingContent.dataset.dagNodeId ?? "";
|
|
475
|
+
const nodeChanged = previousNode !== String(node.nodeId ?? "");
|
|
476
|
+
const followLatest =
|
|
477
|
+
nodeChanged ||
|
|
478
|
+
computeFollowLatest(
|
|
479
|
+
existingContent.scrollTop,
|
|
480
|
+
existingContent.scrollHeight,
|
|
481
|
+
existingContent.clientHeight,
|
|
482
|
+
);
|
|
483
|
+
const regionKey = `dag:${dagRunId}:${node.nodeId}:output`;
|
|
484
|
+
uiState.dagNodeOutputViewportState = updateDagOutputViewportState(
|
|
485
|
+
uiState.dagNodeOutputViewportState,
|
|
486
|
+
regionKey,
|
|
487
|
+
existingContent.scrollLeft,
|
|
488
|
+
existingContent.scrollTop,
|
|
489
|
+
followLatest,
|
|
490
|
+
);
|
|
491
|
+
const nestedViewportState = [
|
|
492
|
+
...existingContent.querySelectorAll("pre"),
|
|
493
|
+
].map((pre) => ({
|
|
494
|
+
scrollLeft: pre.scrollLeft,
|
|
495
|
+
scrollTop: pre.scrollTop,
|
|
496
|
+
}));
|
|
497
|
+
clearNode(existingContent);
|
|
498
|
+
fillDagInspectorContent(existingContent, dagRunId, node);
|
|
499
|
+
if (followLatest) {
|
|
500
|
+
existingContent.scrollTop = existingContent.scrollHeight;
|
|
501
|
+
} else {
|
|
502
|
+
existingContent.scrollTop = uiState.dagNodeOutputViewportState.scrollTop;
|
|
503
|
+
}
|
|
504
|
+
for (const [index, pre] of [
|
|
505
|
+
...existingContent.querySelectorAll("pre"),
|
|
506
|
+
].entries()) {
|
|
507
|
+
const previous = nestedViewportState[index];
|
|
508
|
+
if (!previous) continue;
|
|
509
|
+
pre.scrollLeft = previous.scrollLeft;
|
|
510
|
+
pre.scrollTop = previous.scrollTop;
|
|
511
|
+
}
|
|
512
|
+
panel.dataset.contentSignature = nextContentSignature;
|
|
513
|
+
return;
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
clearNode(panel);
|
|
517
|
+
panel.classList.add("is-open");
|
|
518
|
+
panel.setAttribute("aria-hidden", "false");
|
|
519
|
+
panel.appendChild(createDagInspectorResizeHandle(panel));
|
|
520
|
+
panel.appendChild(buildDagInspectorHeader(dagRunId, node));
|
|
521
|
+
|
|
522
|
+
const content = el("div", "dag-inspector-content");
|
|
523
|
+
fillDagInspectorContent(content, dagRunId, node);
|
|
524
|
+
panel.appendChild(content);
|
|
525
|
+
panel.dataset.contentSignature = nextContentSignature;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
/**
|
|
529
|
+
* Bounded event history UI. Uses opaque `cursor`/`nextCursor` (not SSE/run `after` offsets).
|
|
530
|
+
*/
|