dsh-client-ui-weave 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +157 -2
- package/cordis.patch.yml +5 -0
- package/lib/client.js +1276 -0
- package/lib/index.js +2 -0
- package/package.json +51 -4
package/lib/client.js
ADDED
|
@@ -0,0 +1,1276 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({id:"dsh-client-ui-weave",factory:require=>{var module={exports:{}};var exports=module.exports;Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});
|
|
2
|
+
/**
|
|
3
|
+
* Weave data mapping: DSH client snapshots -> window.WEAVE_DATA schema.
|
|
4
|
+
* Pure, dependency-free; inlined into the client bundle by build.mjs.
|
|
5
|
+
*
|
|
6
|
+
* Timeline model:
|
|
7
|
+
* - The ribbon uses ACTIVITY time, not wall time. Blocks come from the main
|
|
8
|
+
* agent's turns plus every subagent work interval; any real gap longer than
|
|
9
|
+
* GAP_MERGE_SECONDS is compressed to GAP_KEEP_SECONDS. This keeps the
|
|
10
|
+
* main-agent scaffold as the basis and removes large idle blanks.
|
|
11
|
+
* - Task bars borrow their owner's mapped work window and are split into
|
|
12
|
+
* relative "small cells", so their length reads relative to the ribbon.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
const AGENT_PALETTE = ['#E7EFFA', '#64C4FF', '#FFB45C', '#B79CFF', '#5EE3B0', '#FF9FB2', '#9AA7FF', '#F2D06B']
|
|
16
|
+
// Circle seals follow the thirty-six Tiangang star characters; the label below
|
|
17
|
+
// the node keeps the agent's functional name/summary.
|
|
18
|
+
const GANG_SEALS = ['魁', '罡', '机', '闲', '勇', '雄', '猛', '威', '英', '贵', '富', '满', '孤', '伤', '立', '捷', '暗', '佑', '速', '异', '杀', '微', '究', '退', '寿', '剑', '平', '罪', '损', '败', '牢', '慧', '暴', '哭', '巧', '天']
|
|
19
|
+
const GAP_MERGE_SECONDS = 12
|
|
20
|
+
const GAP_KEEP_SECONDS = 3
|
|
21
|
+
const MIN_TIMELINE_SECONDS = 24
|
|
22
|
+
|
|
23
|
+
function computeRunStart(list, sessionId, now, weave) {
|
|
24
|
+
// SessionSummary has no createdAt; updatedAt is the last durable message time,
|
|
25
|
+
// so using it as the origin collapsed every earlier turn to t=0 and
|
|
26
|
+
// re-anchored the ribbon on each new prompt. Anchor on the earliest loaded
|
|
27
|
+
// turn/event instead, falling back to the summary only when nothing loaded.
|
|
28
|
+
let earliest = null
|
|
29
|
+
const note = (ms) => {
|
|
30
|
+
if (typeof ms !== 'number' || !Number.isFinite(ms) || ms <= 0 || ms > now) return
|
|
31
|
+
if (earliest === null || ms < earliest) earliest = ms
|
|
32
|
+
}
|
|
33
|
+
if (weave && Array.isArray(weave.turns)) for (const turn of weave.turns) note(turn && turn.startTime)
|
|
34
|
+
if (weave && Array.isArray(weave.events)) for (const event of weave.events) note(event && event.time)
|
|
35
|
+
if (earliest !== null) return earliest
|
|
36
|
+
try {
|
|
37
|
+
const summary = list && list.byId ? list.byId[sessionId] : undefined
|
|
38
|
+
const candidate = summary ? summary.updatedAt : undefined
|
|
39
|
+
if (typeof candidate === 'number' && candidate > 0 && candidate <= now) return candidate
|
|
40
|
+
} catch (error) { /* fall through */ }
|
|
41
|
+
return now
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function realSeconds(ms, start) {
|
|
45
|
+
return Math.max(0, (ms - start) / 1000)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function usageTotal(usage) {
|
|
49
|
+
if (usage === null || typeof usage !== 'object') return 0
|
|
50
|
+
let total = 0
|
|
51
|
+
for (const key of ['uncachedInputTokens', 'outputTokens', 'cacheReadTokens', 'cacheWriteTokens']) {
|
|
52
|
+
const value = usage[key]
|
|
53
|
+
if (typeof value === 'number' && Number.isFinite(value) && value > 0) total += value
|
|
54
|
+
}
|
|
55
|
+
if (total === 0 && typeof usage.totalTokens === 'number') total = usage.totalTokens
|
|
56
|
+
return total
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function displayNameOf(list, id) {
|
|
60
|
+
const summary = list && list.byId ? list.byId[id] : undefined
|
|
61
|
+
if (summary === undefined) return undefined
|
|
62
|
+
if (typeof summary.displayTitle === 'string' && summary.displayTitle !== '') return summary.displayTitle
|
|
63
|
+
if (typeof summary.title === 'string' && summary.title !== '') return summary.title
|
|
64
|
+
return undefined
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function clipName(value, max) {
|
|
68
|
+
const text = String(value == null ? '' : value).replace(/\s+/g, ' ').trim()
|
|
69
|
+
if (text.length <= max) return text
|
|
70
|
+
return text.slice(0, max - 1) + '…'
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Timeline values are whole SECONDS: the iframe's clock formatter does not
|
|
74
|
+
// round fractional seconds, and activity-block arithmetic produces artifacts
|
|
75
|
+
// like 183.59999999999999 when it is fed raw floats.
|
|
76
|
+
function round1(value) {
|
|
77
|
+
return Math.round(value)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** Normalize one work segment to an ordered, non-negative interval. */
|
|
81
|
+
function normalizeSegment(seg) {
|
|
82
|
+
const s = Math.max(0, typeof seg.s === 'number' && Number.isFinite(seg.s) ? seg.s : 0)
|
|
83
|
+
const e = Math.max(s + 0.2, typeof seg.e === 'number' && Number.isFinite(seg.e) ? seg.e : s + 1)
|
|
84
|
+
return { s: s, e: e, label: seg.label, activity: seg.activity, task: seg.task == null ? null : seg.task }
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** Merge intervals whose real gap is at most tolerance seconds. */
|
|
88
|
+
function mergeBlocks(intervals, tolerance) {
|
|
89
|
+
const sorted = intervals
|
|
90
|
+
.map(normalizeSegment)
|
|
91
|
+
.sort((a, b) => a.s - b.s)
|
|
92
|
+
const blocks = []
|
|
93
|
+
for (const interval of sorted) {
|
|
94
|
+
const last = blocks[blocks.length - 1]
|
|
95
|
+
if (last !== undefined && interval.s - last.e <= tolerance) {
|
|
96
|
+
if (interval.e > last.e) last.e = interval.e
|
|
97
|
+
} else {
|
|
98
|
+
blocks.push({ s: interval.s, e: interval.e })
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return blocks
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Build a real-seconds -> activity-seconds compressor. Each merged block keeps
|
|
106
|
+
* its duration; larger gaps shrink to gapKeep. Times inside a compressed gap
|
|
107
|
+
* snap to the boundary of the following block.
|
|
108
|
+
*/
|
|
109
|
+
function buildCompressor(intervals, tolerance, gapKeep) {
|
|
110
|
+
const blocks = mergeBlocks(intervals, tolerance)
|
|
111
|
+
const spans = []
|
|
112
|
+
let cursor = 0
|
|
113
|
+
for (const block of blocks) {
|
|
114
|
+
const length = Math.max(0.2, block.e - block.s)
|
|
115
|
+
const virtualStart = cursor
|
|
116
|
+
cursor += length
|
|
117
|
+
spans.push({ realStart: block.s, realEnd: block.e, virtualStart: virtualStart, virtualEnd: cursor })
|
|
118
|
+
cursor += gapKeep
|
|
119
|
+
}
|
|
120
|
+
const total = spans.length === 0 ? 0 : Math.max(0, cursor - gapKeep)
|
|
121
|
+
function map(time) {
|
|
122
|
+
if (spans.length === 0) return 0
|
|
123
|
+
if (time <= spans[0].realStart) return 0
|
|
124
|
+
for (let index = 0; index < spans.length; index += 1) {
|
|
125
|
+
const span = spans[index]
|
|
126
|
+
if (time <= span.realEnd) return span.virtualStart + (time - span.realStart)
|
|
127
|
+
const next = spans[index + 1]
|
|
128
|
+
if (next !== undefined && time < next.realStart) return Math.max(span.virtualEnd, next.virtualStart - 0.01)
|
|
129
|
+
}
|
|
130
|
+
return total
|
|
131
|
+
}
|
|
132
|
+
return { map: map, total: total, blockCount: spans.length }
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function clampSegment(seg, duration) {
|
|
136
|
+
const s = Math.min(Math.max(0, Math.round(seg.s)), duration)
|
|
137
|
+
const e = Math.min(Math.max(s + 1, Math.round(seg.e)), duration)
|
|
138
|
+
return { s: round1(s), e: round1(e), label: seg.label, activity: seg.activity, task: seg.task == null ? null : seg.task }
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function mapSegments(segments, compressor, scale, timeline) {
|
|
142
|
+
const mapped = []
|
|
143
|
+
for (const seg of segments) {
|
|
144
|
+
const s = compressor.map(seg.s) * scale
|
|
145
|
+
const e = compressor.map(seg.e) * scale
|
|
146
|
+
mapped.push(clampSegment({ s: s, e: e, label: seg.label, activity: seg.activity, task: seg.task }, timeline))
|
|
147
|
+
}
|
|
148
|
+
return mapped
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** Raw (uncompressed) work segments from one subagent's timing projection. */
|
|
152
|
+
function rawTimingSegments(timing, start, now, updatedAt, createdMs) {
|
|
153
|
+
if (timing === null || typeof timing !== 'object') return []
|
|
154
|
+
const segments = []
|
|
155
|
+
const nowReal = realSeconds(now, start)
|
|
156
|
+
const active = timing.active
|
|
157
|
+
if (active !== null && typeof active === 'object' && typeof active.since === 'number') {
|
|
158
|
+
const s = realSeconds(active.since, start)
|
|
159
|
+
const e = typeof active.through === 'number' ? realSeconds(active.through, start) : nowReal
|
|
160
|
+
segments.push({ s: s, e: Math.max(e, s + 1), label: '执行中', activity: '模型/工具执行', task: null })
|
|
161
|
+
}
|
|
162
|
+
if (typeof timing.settledMs === 'number' && timing.settledMs > 0) {
|
|
163
|
+
// settledMs is an accumulated DURATION that runs FORWARD from the subagent's
|
|
164
|
+
// creation, not backwards from its last update. Using updatedAt (≈ creation
|
|
165
|
+
// prompt time) pushed the band before the agent even existed.
|
|
166
|
+
const settledSec = timing.settledMs / 1000
|
|
167
|
+
const created = typeof createdMs === 'number' && createdMs > 0
|
|
168
|
+
? realSeconds(createdMs, start)
|
|
169
|
+
: (typeof updatedAt === 'number' && updatedAt > 0 ? realSeconds(updatedAt, start) : nowReal)
|
|
170
|
+
const begin = Math.max(0, created)
|
|
171
|
+
const end = begin + settledSec
|
|
172
|
+
segments.push({ s: begin, e: Math.max(end, begin + 0.5), label: '已结算', activity: '历史工作段(近似)', task: null })
|
|
173
|
+
}
|
|
174
|
+
return segments
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function eventLabelOf(event) {
|
|
178
|
+
if (event.kind === 'prompt') {
|
|
179
|
+
if (event.sourceKind === 'agent-message' || event.sourceKind === 'team-message') return { type: 'message', tag: event.sender || '消息' }
|
|
180
|
+
return { type: 'decision', tag: '目标' }
|
|
181
|
+
}
|
|
182
|
+
if (event.kind === 'call') return { type: event.failed ? 'alert' : 'tool', tag: event.name || 'tool' }
|
|
183
|
+
return { type: 'artifact', tag: '产出' }
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function eventTextOf(event) {
|
|
187
|
+
if (event.kind === 'prompt') {
|
|
188
|
+
const prefix = event.sender ? event.sender + ':' : ''
|
|
189
|
+
return prefix + (event.text || '')
|
|
190
|
+
}
|
|
191
|
+
if (event.kind === 'call') return event.name + (event.args ? '(' + event.args + ')' : '()')
|
|
192
|
+
return event.text || ''
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Map DSH client snapshots into the prototype's WEAVE_DATA schema.
|
|
197
|
+
* @param {{sessionId:string, list?:object, weave?:object, now?:number}} input
|
|
198
|
+
* @returns {object} WEAVE_DATA
|
|
199
|
+
*/
|
|
200
|
+
function buildWeaveData(input) {
|
|
201
|
+
const now = input !== null && input !== undefined && typeof input.now === 'number' ? input.now : Date.now()
|
|
202
|
+
const sessionId = input !== null && input !== undefined ? String(input.sessionId || '') : ''
|
|
203
|
+
const list = input !== null && input !== undefined ? input.list : undefined
|
|
204
|
+
const weave = input !== null && input !== undefined ? input.weave : undefined
|
|
205
|
+
const start = computeRunStart(list, sessionId, now, weave)
|
|
206
|
+
const projection = list && list.projectionsBySession ? list.projectionsBySession[sessionId] : undefined
|
|
207
|
+
const values = projection && projection.values ? projection.values : {}
|
|
208
|
+
const catalog = Array.isArray(values.subagentCatalog) ? values.subagentCatalog : []
|
|
209
|
+
const team = values.agentTeam
|
|
210
|
+
const fullMainName = displayNameOf(list, sessionId) || '会话主代理'
|
|
211
|
+
const mainName = clipName(fullMainName, 12) || '会话主代理'
|
|
212
|
+
const rootId = sessionId || 'root'
|
|
213
|
+
const snapshotTurns = weave && Array.isArray(weave.turns) ? weave.turns : []
|
|
214
|
+
const snapshotEvents = weave && Array.isArray(weave.events) ? weave.events : []
|
|
215
|
+
const rootSummary = list && list.byId ? list.byId[sessionId] : undefined
|
|
216
|
+
|
|
217
|
+
/* ---- main agent raw work (the ribbon's basis) ------------------------- */
|
|
218
|
+
const mainRaw = []
|
|
219
|
+
for (const turn of snapshotTurns) {
|
|
220
|
+
if (turn === null || typeof turn !== 'object') continue
|
|
221
|
+
const s = typeof turn.startTime === 'number' ? realSeconds(turn.startTime, start) : null
|
|
222
|
+
if (s === null) continue
|
|
223
|
+
const e = typeof turn.endTime === 'number' ? realSeconds(turn.endTime, start) : realSeconds(now, start)
|
|
224
|
+
mainRaw.push({ s: s, e: Math.max(e, s + 1), label: '第 ' + turn.turn + ' 轮', activity: '对话与工具执行', task: null })
|
|
225
|
+
}
|
|
226
|
+
if (mainRaw.length === 0) {
|
|
227
|
+
// No turns in the loaded window: fall back to the observed event span or a
|
|
228
|
+
// short placeholder block so the ribbon still has an honest skeleton.
|
|
229
|
+
let first = null
|
|
230
|
+
let last = null
|
|
231
|
+
for (const event of snapshotEvents) {
|
|
232
|
+
if (typeof event.time !== 'number') continue
|
|
233
|
+
const t = realSeconds(event.time, start)
|
|
234
|
+
if (first === null || t < first) first = t
|
|
235
|
+
if (last === null || t > last) last = t
|
|
236
|
+
}
|
|
237
|
+
if (first !== null && last !== null && last > first) {
|
|
238
|
+
mainRaw.push({ s: first, e: last, label: '会话活动', activity: '已读取的事件范围', task: null })
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/* ---- subagent raw work ------------------------------------------------ */
|
|
243
|
+
const catalogRaw = []
|
|
244
|
+
const catalogIds = new Set()
|
|
245
|
+
const agentRaw = new Map()
|
|
246
|
+
catalog.forEach((entry) => {
|
|
247
|
+
if (entry === null || typeof entry !== 'object') return
|
|
248
|
+
const id = String(entry.id || '')
|
|
249
|
+
if (id === '') return
|
|
250
|
+
catalogIds.add(id)
|
|
251
|
+
const summary = list && list.byId ? list.byId[id] : undefined
|
|
252
|
+
// Per-child projections live under projectionsBySession[id].values; the
|
|
253
|
+
// parent's projectionValues only holds its own timing/tokenUsage.
|
|
254
|
+
const childProjection = list && list.projectionsBySession ? list.projectionsBySession[id] : undefined
|
|
255
|
+
const childValues = childProjection && childProjection.values ? childProjection.values : {}
|
|
256
|
+
const timing = childValues.subagentTiming !== undefined
|
|
257
|
+
? childValues.subagentTiming
|
|
258
|
+
: (summary && summary.projectionValues ? summary.projectionValues.subagentTiming : undefined)
|
|
259
|
+
const usageProjection = childValues.tokenUsage !== undefined
|
|
260
|
+
? childValues.tokenUsage
|
|
261
|
+
: (summary && summary.projectionValues ? summary.projectionValues.tokenUsage : undefined)
|
|
262
|
+
const updatedAt = summary ? summary.updatedAt : undefined
|
|
263
|
+
const segments = rawTimingSegments(timing, start, now, updatedAt, entry.createdAt)
|
|
264
|
+
const running = (summary && summary.running === true) || (timing && timing.active !== null && timing.active !== undefined && timing.active !== false)
|
|
265
|
+
catalogRaw.push({ entry: entry, id: id, summary: summary, segments: segments, usageProjection: usageProjection, running: running })
|
|
266
|
+
agentRaw.set(id, segments)
|
|
267
|
+
})
|
|
268
|
+
|
|
269
|
+
/* ---- activity compression -------------------------------------------- */
|
|
270
|
+
const intervals = []
|
|
271
|
+
for (const segment of mainRaw) intervals.push(segment)
|
|
272
|
+
for (const row of catalogRaw) for (const segment of row.segments) intervals.push(segment)
|
|
273
|
+
let compressor = buildCompressor(intervals, GAP_MERGE_SECONDS, GAP_KEEP_SECONDS)
|
|
274
|
+
let scale = 1
|
|
275
|
+
if (compressor.total <= 0) {
|
|
276
|
+
const fallback = Math.max(MIN_TIMELINE_SECONDS, 1)
|
|
277
|
+
compressor = { map: function (time) { return Math.min(Math.max(0, time), fallback) }, total: fallback, blockCount: 0 }
|
|
278
|
+
scale = 1
|
|
279
|
+
} else if (compressor.total < MIN_TIMELINE_SECONDS) {
|
|
280
|
+
scale = MIN_TIMELINE_SECONDS / compressor.total
|
|
281
|
+
}
|
|
282
|
+
const timeline = Math.max(1, round1(compressor.total * scale))
|
|
283
|
+
|
|
284
|
+
function mapTimestamp(ms) {
|
|
285
|
+
const value = compressor.map(realSeconds(ms, start)) * scale
|
|
286
|
+
return round1(Math.min(Math.max(0, value), timeline))
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/* ---- agents ----------------------------------------------------------- */
|
|
290
|
+
const agents = []
|
|
291
|
+
const agentWork = new Map()
|
|
292
|
+
let mainWork = mapSegments(mainRaw, compressor, scale, timeline)
|
|
293
|
+
if (mainWork.length === 0) mainWork = [{ s: 0, e: timeline, label: '会话进行中', activity: '编排与协调', task: null }]
|
|
294
|
+
agentWork.set(rootId, mainWork)
|
|
295
|
+
agents.push({
|
|
296
|
+
id: rootId,
|
|
297
|
+
name: mainName,
|
|
298
|
+
roleCn: '编排者',
|
|
299
|
+
roleEn: 'LEAD',
|
|
300
|
+
icon: 'compass',
|
|
301
|
+
color: AGENT_PALETTE[0],
|
|
302
|
+
model: 'main agent',
|
|
303
|
+
parent: null,
|
|
304
|
+
seal: '编',
|
|
305
|
+
running: true,
|
|
306
|
+
work: mainWork,
|
|
307
|
+
})
|
|
308
|
+
|
|
309
|
+
const tokensByAgent = {}
|
|
310
|
+
catalogRaw.forEach((row, index) => {
|
|
311
|
+
const summary = row.summary
|
|
312
|
+
const usage = row.usageProjection
|
|
313
|
+
const total = usageTotal(usage)
|
|
314
|
+
if (total > 0) tokensByAgent[row.id] = total
|
|
315
|
+
let work = mapSegments(row.segments, compressor, scale, timeline)
|
|
316
|
+
if (work.length === 0) {
|
|
317
|
+
work = [clampSegment(row.running
|
|
318
|
+
? { s: 0, e: timeline, label: '执行中', activity: '子代理执行(近似)', task: null }
|
|
319
|
+
: { s: 0, e: Math.min(timeline, 6), label: '曾参与', activity: '子代理历史(近似)', task: null }, timeline)]
|
|
320
|
+
}
|
|
321
|
+
agentWork.set(row.id, work)
|
|
322
|
+
agents.push({
|
|
323
|
+
id: row.id,
|
|
324
|
+
name: clipName(row.entry.name || row.entry.label || (summary && summary.displayTitle) || row.id.slice(0, 8), 10),
|
|
325
|
+
seal: GANG_SEALS[index % GANG_SEALS.length],
|
|
326
|
+
running: row.running === true,
|
|
327
|
+
title: clipName(row.entry.name || row.entry.label || (summary && summary.displayTitle) || row.id.slice(0, 8), 24),
|
|
328
|
+
roleCn: row.entry.mode === 'one-shot' ? '子任务' : '子代理',
|
|
329
|
+
roleEn: row.entry.mode === 'one-shot' ? 'TASK' : 'SUBAGENT',
|
|
330
|
+
icon: row.running ? 'spark' : 'branch',
|
|
331
|
+
color: AGENT_PALETTE[(index + 1) % AGENT_PALETTE.length],
|
|
332
|
+
model: row.running ? 'subagent · running' : 'subagent',
|
|
333
|
+
// Raw lineage candidate; resolved to an agent id once the roster exists.
|
|
334
|
+
parentRaw: summary && typeof summary.parentSessionId === 'string' ? summary.parentSessionId : null,
|
|
335
|
+
work: work,
|
|
336
|
+
})
|
|
337
|
+
})
|
|
338
|
+
|
|
339
|
+
const agentIds = new Set()
|
|
340
|
+
const agentAliases = new Map()
|
|
341
|
+
for (const agent of agents) {
|
|
342
|
+
agentIds.add(agent.id)
|
|
343
|
+
if (typeof agent.name === 'string' && agent.name !== '') agentAliases.set(agent.name, agent.id)
|
|
344
|
+
}
|
|
345
|
+
for (const row of catalogRaw) {
|
|
346
|
+
const alias = row.entry.name || row.entry.label || (row.summary && row.summary.displayTitle)
|
|
347
|
+
if (typeof alias === 'string' && alias !== '' && agentIds.has(row.id)) agentAliases.set(alias, row.id)
|
|
348
|
+
}
|
|
349
|
+
// Resolve subagent lineage to real agent ids (root session id resolves to the
|
|
350
|
+
// lead). Unknown parents fall back to the lead so the tree never loses a node.
|
|
351
|
+
for (const agent of agents) {
|
|
352
|
+
if (agent.id === rootId) { agent.parent = null; continue }
|
|
353
|
+
agent.parent = agent.parentRaw ? resolveAgentId(String(agent.parentRaw)) : rootId
|
|
354
|
+
delete agent.parentRaw
|
|
355
|
+
}
|
|
356
|
+
const nameById = new Map(agents.map((agent) => [agent.id, agent.name]))
|
|
357
|
+
/** The Weave app reads agentById[owner].color: every reference must be a real agent id. */
|
|
358
|
+
function resolveAgentId(value) {
|
|
359
|
+
if (typeof value !== 'string' || value === '') return rootId
|
|
360
|
+
if (agentIds.has(value)) return value
|
|
361
|
+
if (agentAliases.has(value)) return agentAliases.get(value)
|
|
362
|
+
const lower = value.toLowerCase()
|
|
363
|
+
for (const pair of agentAliases) {
|
|
364
|
+
if (pair[0].toLowerCase() === lower) return pair[1]
|
|
365
|
+
}
|
|
366
|
+
return rootId
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
/* ---- tasks: owner-relative small cells ------------------------------- */
|
|
370
|
+
const rawTasks = team && Array.isArray(team.tasks) ? team.tasks : []
|
|
371
|
+
const ownerCounts = new Map()
|
|
372
|
+
for (const task of rawTasks) {
|
|
373
|
+
if (task === null || typeof task !== 'object') continue
|
|
374
|
+
// Count by the RESOLVED owner id: aliases/unknown names would otherwise
|
|
375
|
+
// split one owner's cells across two buckets.
|
|
376
|
+
const ownerId = resolveAgentId(task.ownerId !== null && task.ownerId !== undefined ? String(task.ownerId) : rootId)
|
|
377
|
+
ownerCounts.set(ownerId, (ownerCounts.get(ownerId) || 0) + 1)
|
|
378
|
+
}
|
|
379
|
+
const taskIndexById = new Map()
|
|
380
|
+
rawTasks.forEach((task, index) => {
|
|
381
|
+
if (task !== null && typeof task === 'object' && task.id !== undefined) taskIndexById.set(String(task.id), index + 1)
|
|
382
|
+
})
|
|
383
|
+
const ownerSeen = new Map()
|
|
384
|
+
const tasks = rawTasks.map((task, index) => {
|
|
385
|
+
if (task === null || typeof task !== 'object') return null
|
|
386
|
+
const ownerId = resolveAgentId(task.ownerId !== null && task.ownerId !== undefined ? String(task.ownerId) : rootId)
|
|
387
|
+
const work = agentWork.get(ownerId) || mainWork
|
|
388
|
+
let start = 0
|
|
389
|
+
let end = 0
|
|
390
|
+
if (work.length > 0) {
|
|
391
|
+
start = work[0].s
|
|
392
|
+
end = work[0].e
|
|
393
|
+
for (const segment of work) {
|
|
394
|
+
if (segment.s < start) start = segment.s
|
|
395
|
+
if (segment.e > end) end = segment.e
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
const count = ownerCounts.get(ownerId) || 1
|
|
399
|
+
const seen = ownerSeen.get(ownerId) || 0
|
|
400
|
+
ownerSeen.set(ownerId, seen + 1)
|
|
401
|
+
const cell = Math.max(0.8, (end - start) / count)
|
|
402
|
+
const taskStart = round1(Math.min(start + seen * cell, Math.max(0, timeline - 0.8)))
|
|
403
|
+
const taskEnd = round1(Math.min(timeline, Math.max(taskStart + 0.8, start + (seen + 1) * cell)))
|
|
404
|
+
return {
|
|
405
|
+
id: 'T' + (index + 1),
|
|
406
|
+
title: String(task.subject || task.description || task.id || ('任务 ' + (index + 1))),
|
|
407
|
+
owner: ownerId,
|
|
408
|
+
start: taskStart,
|
|
409
|
+
end: taskEnd,
|
|
410
|
+
deps: (Array.isArray(task.blockedBy) ? task.blockedBy : [])
|
|
411
|
+
.map((id) => taskIndexById.get(String(id)))
|
|
412
|
+
.filter((n) => typeof n === 'number')
|
|
413
|
+
.map((n) => 'T' + n),
|
|
414
|
+
status: typeof task.status === 'string' ? task.status : 'pending',
|
|
415
|
+
ready: task.ready !== false,
|
|
416
|
+
}
|
|
417
|
+
}).filter((task) => task !== null)
|
|
418
|
+
|
|
419
|
+
/* ---- events ----------------------------------------------------------- */
|
|
420
|
+
const events = []
|
|
421
|
+
for (const event of snapshotEvents) {
|
|
422
|
+
if (typeof event.time !== 'number') continue
|
|
423
|
+
if (event.kind === 'assistant') continue
|
|
424
|
+
if (event.kind === 'prompt' && event.sourceKind !== 'user' && event.sourceKind !== 'agent-message' && event.sourceKind !== 'team-message' && event.sourceKind !== 'subagent-settled' && event.sourceKind !== 'compact-checkpoint') continue
|
|
425
|
+
const actor = event.kind === 'prompt' && event.sender ? resolveAgentId(event.sender) : rootId
|
|
426
|
+
const actorName = nameById.get(actor) || actor
|
|
427
|
+
const displayEvent = event.kind === 'prompt' && event.sender ? { ...event, sender: actorName } : event
|
|
428
|
+
const label = eventLabelOf(displayEvent)
|
|
429
|
+
let text = eventTextOf(displayEvent)
|
|
430
|
+
if (text === '') {
|
|
431
|
+
if (event.kind !== 'prompt') continue
|
|
432
|
+
// A settled teammate notice can carry no body; keep it as a marker row.
|
|
433
|
+
text = (actorName || '子代理') + ':已完成'
|
|
434
|
+
}
|
|
435
|
+
events.push({
|
|
436
|
+
t: mapTimestamp(event.time),
|
|
437
|
+
type: label.type,
|
|
438
|
+
actor: actor,
|
|
439
|
+
text: String(text).slice(0, 180),
|
|
440
|
+
tag: label.tag,
|
|
441
|
+
})
|
|
442
|
+
}
|
|
443
|
+
// Bound the payload: long sessions accumulate thousands of rows and every
|
|
444
|
+
// update posts the whole snapshot into the sandboxed iframe.
|
|
445
|
+
const recentEvents = events.slice(-600)
|
|
446
|
+
|
|
447
|
+
const blocked = rawTasks.filter((task) => task !== null && typeof task === 'object' && task.status !== 'completed' && task.ready === false)
|
|
448
|
+
let blocker
|
|
449
|
+
if (blocked.length > 0) {
|
|
450
|
+
// Cover exactly the non-completed blocked tasks; never fall back to the
|
|
451
|
+
// whole board (that band was both wrong and misleading).
|
|
452
|
+
const blockedMapped = tasks.filter((task) => task !== null && task.status !== 'completed' && task.ready === false)
|
|
453
|
+
let from = timeline
|
|
454
|
+
let to = 0
|
|
455
|
+
for (const task of blockedMapped) {
|
|
456
|
+
if (task === null) continue
|
|
457
|
+
if (from > task.start) from = task.start
|
|
458
|
+
if (to < task.end) to = task.end
|
|
459
|
+
}
|
|
460
|
+
if (blockedMapped.length > 0) {
|
|
461
|
+
const deps = Array.isArray(blocked[0].blockedBy) ? blocked[0].blockedBy.map(String).join('、') : ''
|
|
462
|
+
blocker = {
|
|
463
|
+
from: round1(Math.min(from, timeline)),
|
|
464
|
+
to: round1(Math.max(to, 0.5)),
|
|
465
|
+
title: String(blocked[0].subject || '任务阻塞'),
|
|
466
|
+
detail: deps !== '' ? '等待依赖:' + deps : String(blocked[0].description || '依赖未就绪的任务'),
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
/* Collaboration messages: agent/team prompts are the only cross-agent
|
|
472
|
+
traffic visible in the root session window. Synthesize the edges so the
|
|
473
|
+
graph and dossier can show "who talked to whom" instead of 0 messages. */
|
|
474
|
+
const messages = []
|
|
475
|
+
for (const event of snapshotEvents) {
|
|
476
|
+
if (event.kind !== 'prompt') continue
|
|
477
|
+
if (event.sourceKind !== 'agent-message' && event.sourceKind !== 'team-message') continue
|
|
478
|
+
const sender = resolveAgentId(event.sender)
|
|
479
|
+
if (sender === rootId) continue
|
|
480
|
+
messages.push({ from: sender, to: rootId, t: mapTimestamp(event.time), travel: 3 })
|
|
481
|
+
}
|
|
482
|
+
const recentMessages = messages.slice(-80)
|
|
483
|
+
|
|
484
|
+
const tokenSegments = {}
|
|
485
|
+
for (const key of Object.keys(tokensByAgent)) tokenSegments[key] = [tokensByAgent[key]]
|
|
486
|
+
const mainTokens = usageTotal(values.tokenUsage)
|
|
487
|
+
if (mainTokens > 0) tokenSegments[rootId] = [mainTokens]
|
|
488
|
+
|
|
489
|
+
return {
|
|
490
|
+
meta: {
|
|
491
|
+
runId: (sessionId || 'session').replace(/^session-/, '').slice(0, 8).toUpperCase(),
|
|
492
|
+
project: (() => {
|
|
493
|
+
const cwd = rootSummary && typeof rootSummary.cwd === 'string' ? rootSummary.cwd : ''
|
|
494
|
+
const name = cwd.replace(/[\\/]+$/, '').split(/[\\/]/).pop()
|
|
495
|
+
return name || 'dsh-session'
|
|
496
|
+
})(),
|
|
497
|
+
branch: '',
|
|
498
|
+
goal: fullMainName,
|
|
499
|
+
shortGoal: mainName,
|
|
500
|
+
startedAt: new Date(start).toTimeString().slice(0, 5),
|
|
501
|
+
duration: timeline,
|
|
502
|
+
// 1x playback: game the speed controls against the compressed timeline,
|
|
503
|
+
// not a hardcoded 80s (43x fast-forward on long sessions).
|
|
504
|
+
playbackSeconds: Math.max(1, Math.round(timeline)),
|
|
505
|
+
simulated: false,
|
|
506
|
+
live: true,
|
|
507
|
+
activityCompressed: true,
|
|
508
|
+
realDurationSeconds: round1(realSeconds(now, start)),
|
|
509
|
+
tokens: {
|
|
510
|
+
segments: tokenSegments,
|
|
511
|
+
// True when at least one agent has no projection usage; the embed
|
|
512
|
+
// falls back to a simulated series for those and labels it as such.
|
|
513
|
+
simulated: catalogRaw.some((row) => usageTotal(row.usageProjection) <= 0),
|
|
514
|
+
},
|
|
515
|
+
},
|
|
516
|
+
agents: agents,
|
|
517
|
+
tasks: tasks,
|
|
518
|
+
events: recentEvents,
|
|
519
|
+
messages: recentMessages,
|
|
520
|
+
...(blocker === undefined ? {} : { blocker: blocker }),
|
|
521
|
+
tokens: { segments: tokenSegments },
|
|
522
|
+
source: { sessionId: sessionId, catalogCount: catalogIds.size, taskCount: tasks.length, eventCount: recentEvents.length, blocks: compressor.blockCount },
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
/**
|
|
527
|
+
* Weave conversation target: Definitions that project session events into a
|
|
528
|
+
* compact observatory log (turns, prompts, tool calls, assistant usage), plus
|
|
529
|
+
* the target Builder consumed by the weave view source.
|
|
530
|
+
* Pure module: inlined into the client bundle by build.mjs.
|
|
531
|
+
*/
|
|
532
|
+
|
|
533
|
+
const WEAVE_TARGET = 'weave'
|
|
534
|
+
|
|
535
|
+
function textOfContent(content) {
|
|
536
|
+
if (!Array.isArray(content)) return ''
|
|
537
|
+
const parts = []
|
|
538
|
+
for (const block of content) {
|
|
539
|
+
if (block !== null && typeof block === 'object' && block.type === 'text' && typeof block.text === 'string') parts.push(block.text)
|
|
540
|
+
}
|
|
541
|
+
return parts.join('\n')
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
function clipText(value, max) {
|
|
545
|
+
if (typeof value !== 'string') return ''
|
|
546
|
+
const text = value.trim().replace(/\s+/g, ' ')
|
|
547
|
+
return text.length <= max ? text : text.slice(0, max - 1) + '…'
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
function anchorOf(context) {
|
|
551
|
+
if (context.start !== undefined && context.start !== null) return context.start.event.seq
|
|
552
|
+
const matches = context.matches
|
|
553
|
+
if (Array.isArray(matches) && matches.length > 0) return matches[matches.length - 1].event.seq
|
|
554
|
+
return 0
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
function locationOf(context) {
|
|
558
|
+
if (context.start !== undefined && context.start !== null && context.start.location !== undefined) return context.start.location
|
|
559
|
+
const matches = context.matches
|
|
560
|
+
if (Array.isArray(matches) && matches.length > 0) {
|
|
561
|
+
const last = matches[matches.length - 1]
|
|
562
|
+
if (last !== undefined && last !== null && last.location !== undefined) return last.location
|
|
563
|
+
}
|
|
564
|
+
return { kind: 'unresolved' }
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
function weaveNode(context, data, anchorSeq) {
|
|
568
|
+
return {
|
|
569
|
+
key: context.key,
|
|
570
|
+
kind: context.kind,
|
|
571
|
+
id: context.id,
|
|
572
|
+
target: WEAVE_TARGET,
|
|
573
|
+
anchorSeq: typeof anchorSeq === 'number' ? anchorSeq : 0,
|
|
574
|
+
location: locationOf(context),
|
|
575
|
+
data: data,
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
function senderOfMessage(message) {
|
|
580
|
+
if (message === null || typeof message !== 'object') return null
|
|
581
|
+
const source = message.source
|
|
582
|
+
if (source === null || typeof source !== 'object') return null
|
|
583
|
+
const kind = source.kind
|
|
584
|
+
if (kind !== 'agent-message' && kind !== 'team-message') return null
|
|
585
|
+
const text = textOfContent(message.content)
|
|
586
|
+
const team = /^\s*\[team[^\]]*\]\s*([^\n::]+)[::]/.exec(text)
|
|
587
|
+
if (team !== null) return team[1].trim()
|
|
588
|
+
const agent = /^\s*\[agent[^\]]*\]\s*([^\n::]+)[::]/.exec(text)
|
|
589
|
+
if (agent !== null) return agent[1].trim()
|
|
590
|
+
// Real DSH relay messages identify the sender by session id, not by a
|
|
591
|
+
// "[agent ...]" text prefix (that legacy format never appears in session logs).
|
|
592
|
+
if (typeof source.senderSessionId === 'string' && source.senderSessionId !== '') return source.senderSessionId
|
|
593
|
+
if (typeof source.sender === 'string' && source.sender !== '') return source.sender
|
|
594
|
+
if (typeof source.from === 'string' && source.from !== '') return source.from
|
|
595
|
+
return null
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
function usageOf(usage) {
|
|
599
|
+
if (usage === null || typeof usage !== 'object') return null
|
|
600
|
+
const result = {}
|
|
601
|
+
let total = 0
|
|
602
|
+
// Assistant-message usage uses inputTokens; the tokenUsage projection uses
|
|
603
|
+
// uncachedInputTokens. Accept both without double-counting.
|
|
604
|
+
const input = typeof usage.inputTokens === 'number' && usage.inputTokens > 0
|
|
605
|
+
? usage.inputTokens
|
|
606
|
+
: (typeof usage.uncachedInputTokens === 'number' && usage.uncachedInputTokens > 0 ? usage.uncachedInputTokens : 0)
|
|
607
|
+
if (input > 0) { result.inputTokens = input; total += input }
|
|
608
|
+
for (const key of ['outputTokens', 'cacheReadTokens', 'cacheWriteTokens']) {
|
|
609
|
+
const value = usage[key]
|
|
610
|
+
if (typeof value === 'number' && Number.isFinite(value) && value > 0) { result[key] = value; total += value }
|
|
611
|
+
}
|
|
612
|
+
if (total === 0 && typeof usage.totalTokens === 'number' && usage.totalTokens > 0) total = usage.totalTokens
|
|
613
|
+
if (total === 0) return null
|
|
614
|
+
result.total = total
|
|
615
|
+
return result
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
/** One node per turn: start time and (when seen) end time. */
|
|
619
|
+
const turnDefinition = {
|
|
620
|
+
kind: 'weave-turn',
|
|
621
|
+
target: WEAVE_TARGET,
|
|
622
|
+
match: (event) => {
|
|
623
|
+
// Turn nodes only need their boundaries. Matching every step/start &
|
|
624
|
+
// step/end here re-upserted the same node ~350 times per session and drove
|
|
625
|
+
// a pointless target flush (and parent re-render) for each step.
|
|
626
|
+
if (event.type !== 'turn/start' && event.type !== 'turn/end') return null
|
|
627
|
+
const turn = event.data.turn
|
|
628
|
+
return { id: 'turn:' + String(turn), role: event.type === 'turn/start' ? 'start' : 'update' }
|
|
629
|
+
},
|
|
630
|
+
start: (_context, match) => ({ turn: match.event.data.turn, startTime: match.event.time, endTime: null }),
|
|
631
|
+
update: (context, match) => (match.event.type === 'turn/end'
|
|
632
|
+
? { turn: context.state.turn, startTime: context.state.startTime, endTime: match.event.time }
|
|
633
|
+
: context.state),
|
|
634
|
+
publication: () => 'immediate',
|
|
635
|
+
buildViewNode: (context) => {
|
|
636
|
+
const state = context.state
|
|
637
|
+
if (state === undefined || state === null) return null
|
|
638
|
+
return weaveNode(context, { kind: 'turn', turn: state.turn, startTime: state.startTime, endTime: state.endTime }, anchorOf(context))
|
|
639
|
+
},
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
/** One node per user prompt (the human or a teammate/agent trigger). */
|
|
643
|
+
const promptDefinition = {
|
|
644
|
+
kind: 'weave-prompt',
|
|
645
|
+
target: WEAVE_TARGET,
|
|
646
|
+
match: (event) => (event.type === 'user/message' ? { id: 'user:' + String(event.seq), role: 'start' } : null),
|
|
647
|
+
start: (_context, match) => {
|
|
648
|
+
const message = match.event.data
|
|
649
|
+
const sourceKind = message !== null && typeof message === 'object' && message.source !== null && typeof message.source === 'object' && typeof message.source.kind === 'string'
|
|
650
|
+
? message.source.kind
|
|
651
|
+
: 'user'
|
|
652
|
+
return {
|
|
653
|
+
time: match.event.time,
|
|
654
|
+
text: clipText(textOfContent(message !== null && message !== undefined ? message.content : undefined), 400),
|
|
655
|
+
sourceKind: sourceKind,
|
|
656
|
+
sender: senderOfMessage(message),
|
|
657
|
+
}
|
|
658
|
+
},
|
|
659
|
+
update: (context) => context.state,
|
|
660
|
+
publication: () => 'immediate',
|
|
661
|
+
buildViewNode: (context) => {
|
|
662
|
+
const state = context.state
|
|
663
|
+
if (state === undefined || state === null) return null
|
|
664
|
+
return weaveNode(context, { kind: 'prompt', time: state.time, text: state.text, sourceKind: state.sourceKind, sender: state.sender }, anchorOf(context))
|
|
665
|
+
},
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
/** One node per tool call, completed by its result. */
|
|
669
|
+
const callDefinition = {
|
|
670
|
+
kind: 'weave-call',
|
|
671
|
+
target: WEAVE_TARGET,
|
|
672
|
+
match: (event) => {
|
|
673
|
+
if (event.type === 'tool/call') return { id: 'call:' + String(event.data.callId), role: 'start' }
|
|
674
|
+
if (event.type === 'tool/result') {
|
|
675
|
+
const source = event.data.message !== null && typeof event.data.message === 'object' ? event.data.message.source : null
|
|
676
|
+
const callId = source !== null && typeof source === 'object' ? source.callId : null
|
|
677
|
+
if (callId === null || callId === undefined) return null
|
|
678
|
+
return { id: 'call:' + String(callId), role: 'update' }
|
|
679
|
+
}
|
|
680
|
+
return null
|
|
681
|
+
},
|
|
682
|
+
start: (_context, match) => {
|
|
683
|
+
const data = match.event.data
|
|
684
|
+
let args = ''
|
|
685
|
+
if (typeof data.arguments === 'string') args = data.arguments
|
|
686
|
+
else if (data.arguments !== null && data.arguments !== undefined) {
|
|
687
|
+
try { args = JSON.stringify(data.arguments) } catch (error) { args = '' }
|
|
688
|
+
}
|
|
689
|
+
return { callId: String(data.callId), name: typeof data.name === 'string' ? data.name : 'tool', time: match.event.time, endTime: null, failed: false, args: clipText(args, 120) }
|
|
690
|
+
},
|
|
691
|
+
update: (context, match) => {
|
|
692
|
+
const message = match.event.data.message
|
|
693
|
+
const failed = message !== null && typeof message === 'object' && message.isError === true
|
|
694
|
+
return { callId: context.state.callId, name: context.state.name, time: context.state.time, endTime: match.event.time, failed: failed, args: context.state.args }
|
|
695
|
+
},
|
|
696
|
+
publication: () => 'immediate',
|
|
697
|
+
buildViewNode: (context) => {
|
|
698
|
+
const state = context.state
|
|
699
|
+
if (state === undefined || state === null) return null
|
|
700
|
+
return weaveNode(context, { kind: 'call', callId: state.callId, name: state.name, time: state.time, endTime: state.endTime, failed: state.failed, args: state.args }, anchorOf(context))
|
|
701
|
+
},
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
/** One node per settled assistant message, carrying usage and a short answer. */
|
|
705
|
+
const assistantDefinition = {
|
|
706
|
+
kind: 'weave-assistant',
|
|
707
|
+
target: WEAVE_TARGET,
|
|
708
|
+
match: (event) => (event.type === 'assistant/message' ? { id: 'assistant:' + String(event.seq), role: 'start' } : null),
|
|
709
|
+
start: (_context, match) => {
|
|
710
|
+
const data = match.event.data
|
|
711
|
+
const message = data.message
|
|
712
|
+
return {
|
|
713
|
+
time: match.event.time,
|
|
714
|
+
turn: data.turn,
|
|
715
|
+
usage: usageOf(data.usage),
|
|
716
|
+
text: clipText(textOfContent(message !== null && message !== undefined ? message.content : undefined), 300),
|
|
717
|
+
}
|
|
718
|
+
},
|
|
719
|
+
update: (context) => context.state,
|
|
720
|
+
publication: () => 'immediate',
|
|
721
|
+
buildViewNode: (context) => {
|
|
722
|
+
const state = context.state
|
|
723
|
+
if (state === undefined || state === null) return null
|
|
724
|
+
return weaveNode(context, { kind: 'assistant', time: state.time, turn: state.turn, usage: state.usage, text: state.text }, anchorOf(context))
|
|
725
|
+
},
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
/** One node per nested PTC dispatch (the real tool work behind run_code). */
|
|
729
|
+
const ptcDefinition = {
|
|
730
|
+
kind: 'weave-ptc',
|
|
731
|
+
target: WEAVE_TARGET,
|
|
732
|
+
match: (event) => {
|
|
733
|
+
if (event.type === 'tool/ptc-dispatch-start') return { id: 'ptc:' + String(event.data.subCallId), role: 'start' }
|
|
734
|
+
if (event.type === 'tool/ptc-dispatch') return { id: 'ptc:' + String(event.data.subCallId), role: 'update' }
|
|
735
|
+
return null
|
|
736
|
+
},
|
|
737
|
+
start: (_context, match) => {
|
|
738
|
+
const data = match.event.data
|
|
739
|
+
let args = ''
|
|
740
|
+
if (data.arguments !== null && data.arguments !== undefined) {
|
|
741
|
+
try { args = JSON.stringify(data.arguments) } catch (error) { args = '' }
|
|
742
|
+
}
|
|
743
|
+
return {
|
|
744
|
+
callId: String(data.subCallId),
|
|
745
|
+
name: typeof data.name === 'string' ? data.name : 'tool',
|
|
746
|
+
time: match.event.time,
|
|
747
|
+
endTime: null,
|
|
748
|
+
failed: false,
|
|
749
|
+
args: clipText(args, 120),
|
|
750
|
+
}
|
|
751
|
+
},
|
|
752
|
+
update: (context, match) => ({
|
|
753
|
+
callId: context.state.callId,
|
|
754
|
+
name: context.state.name,
|
|
755
|
+
time: context.state.time,
|
|
756
|
+
endTime: match.event.time,
|
|
757
|
+
failed: match.event.data.isError === true,
|
|
758
|
+
args: context.state.args,
|
|
759
|
+
}),
|
|
760
|
+
publication: () => 'immediate',
|
|
761
|
+
buildViewNode: (context) => {
|
|
762
|
+
const state = context.state
|
|
763
|
+
if (state === undefined || state === null) return null
|
|
764
|
+
return weaveNode(context, { kind: 'call', callId: state.callId, name: state.name, time: state.time, endTime: state.endTime, failed: state.failed, args: state.args }, anchorOf(context))
|
|
765
|
+
},
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
/** Incremental Builder: project target nodes into the weave observatory snapshot. */
|
|
769
|
+
class WeaveSnapshotBuilder {
|
|
770
|
+
constructor() {
|
|
771
|
+
this.nodes = new Map()
|
|
772
|
+
this.empty = { events: [], turns: [], usage: null }
|
|
773
|
+
this.current = this.empty
|
|
774
|
+
}
|
|
775
|
+
replace(input) {
|
|
776
|
+
this.nodes.clear()
|
|
777
|
+
for (const node of input.nodes) this.nodes.set(node.key, node)
|
|
778
|
+
return this.snapshot()
|
|
779
|
+
}
|
|
780
|
+
apply(input) {
|
|
781
|
+
if (input.upserts.length === 0) return this.current
|
|
782
|
+
for (const node of input.upserts) this.nodes.set(node.key, node)
|
|
783
|
+
return this.snapshot()
|
|
784
|
+
}
|
|
785
|
+
snapshot() {
|
|
786
|
+
const events = []
|
|
787
|
+
const turns = []
|
|
788
|
+
let total = 0
|
|
789
|
+
for (const node of this.nodes.values()) {
|
|
790
|
+
const data = node.data
|
|
791
|
+
if (data === null || typeof data !== 'object') continue
|
|
792
|
+
if (data.kind === 'turn') {
|
|
793
|
+
turns.push({ turn: data.turn, startTime: data.startTime, endTime: data.endTime })
|
|
794
|
+
continue
|
|
795
|
+
}
|
|
796
|
+
const event = { seq: node.anchorSeq, kind: data.kind }
|
|
797
|
+
if (data.kind === 'prompt') {
|
|
798
|
+
event.time = data.time; event.text = data.text; event.sourceKind = data.sourceKind; event.sender = data.sender
|
|
799
|
+
} else if (data.kind === 'call') {
|
|
800
|
+
event.time = data.time; event.endTime = data.endTime; event.name = data.name; event.callId = data.callId; event.failed = data.failed; event.args = data.args
|
|
801
|
+
} else if (data.kind === 'assistant') {
|
|
802
|
+
event.time = data.time; event.turn = data.turn; event.text = data.text; event.usage = data.usage
|
|
803
|
+
if (data.usage !== null && typeof data.usage === 'object') total += data.usage.total
|
|
804
|
+
}
|
|
805
|
+
events.push(event)
|
|
806
|
+
}
|
|
807
|
+
events.sort((a, b) => a.seq - b.seq)
|
|
808
|
+
turns.sort((a, b) => a.turn - b.turn)
|
|
809
|
+
this.current = { events: events, turns: turns, usage: total > 0 ? { total: total } : null }
|
|
810
|
+
return this.current
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
/** Register the weave target builder (rides the caller's fiber effect). */
|
|
815
|
+
function registerWeaveTarget(ctx) {
|
|
816
|
+
ctx.uiConversation.views.register({ target: WEAVE_TARGET, create: () => new WeaveSnapshotBuilder() })
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
/** Register the weave event Definitions (rides the caller's fiber effect). */
|
|
820
|
+
function registerWeaveDefinitions(ctx) {
|
|
821
|
+
ctx.uiConversation.events.register(turnDefinition)
|
|
822
|
+
ctx.uiConversation.events.register(promptDefinition)
|
|
823
|
+
ctx.uiConversation.events.register(callDefinition)
|
|
824
|
+
ctx.uiConversation.events.register(ptcDefinition)
|
|
825
|
+
ctx.uiConversation.events.register(assistantDefinition)
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
/* client.template.js — Weave conversation view (build.mjs wraps this into a ModuleLoader bundle). */
|
|
829
|
+
const React = require('react')
|
|
830
|
+
const NS = 'weave'
|
|
831
|
+
const TARGET = 'weave'
|
|
832
|
+
|
|
833
|
+
const zh = {
|
|
834
|
+
'view.weave': '织造',
|
|
835
|
+
'view.weave.aria': 'Weave 多智能体协作观测台',
|
|
836
|
+
'empty.title': '还没有可观测的协作数据',
|
|
837
|
+
'empty.body': '开启团队协作或发起子代理后,这里会显示织造图、泳道与事件流。',
|
|
838
|
+
'loading': '正在织造…',
|
|
839
|
+
'error': 'Weave 视图加载失败',
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
const EMPTY_WEAVE_DATA = {
|
|
843
|
+
meta: { runId: '', goal: '', shortGoal: '', duration: 0, playbackSeconds: 80, simulated: false, live: true },
|
|
844
|
+
agents: [],
|
|
845
|
+
tasks: [],
|
|
846
|
+
events: [],
|
|
847
|
+
messages: [],
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
const WEAVE_HTML = "<!DOCTYPE html>\n<html lang=\"zh-CN\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<meta name=\"color-scheme\" content=\"light dark\">\n<title>Weave · 织造观测台</title>\n<meta name=\"description\" content=\"Weave Silk Edition — 多智能体协作的可观看、可回放、可品读的观测界面原型。\">\n<meta name=\"theme-color\" content=\"#f1ead9\" id=\"themeColor\">\n<script>\n /* [EMBED] 主题由父视图通过 weave:theme 控制;不读取 localStorage(sandbox 下不可用) */\n document.documentElement.setAttribute(\"data-theme\", \"light\");\n</script>\n<link rel=\"icon\" href=\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Crect width='32' height='32' rx='2' fill='%23f1ead9'/%3E%3Cpath d='M16 4.5 26.5 10.5v11L16 27.5 5.5 21.5v-11z' fill='none' stroke='%23b23a26' stroke-width='1.6'/%3E%3Ccircle cx='16' cy='16.4' r='2' fill='%23b23a26'/%3E%3C/svg%3E\">\n<style id=\"weave-inline-styles\">\n/* ---- v2/styles.css ---- */\n/* ==========================================================================\n Weave · Silk Edition 02\n Paper, ink, silk thread. An editorial observatory for multi-agent runs.\n ========================================================================== */\n\n:root {\n --paper: #f1ead9;\n --paper-2: #ebe2cf;\n --paper-3: #e3d8c1;\n --paper-light: #f7f2e7;\n --ink: #1c1914;\n --ink-2: #564f40;\n --ink-3: #6b6150;\n --rule: rgba(28, 25, 20, 0.16);\n --rule-soft: rgba(28, 25, 20, 0.09);\n --rule-strong: rgba(28, 25, 20, 0.3);\n --accent: #b23a26;\n --accent-deep: #8d2a1b;\n --accent-wash: rgba(178, 58, 38, 0.08);\n --olive: #5c6a34;\n --indigo: #33495c;\n --ochre: #a3762d;\n --teal: #2c6b70;\n --plum: #6b3d57;\n --sienna: #a65a2b;\n\n /* compatibility tokens consumed by ../app.js inline tones */\n --sky: #2c6b70;\n --amber: #a3762d;\n --lime: #59682f;\n --mint: #5c6a34;\n --violet: #6b3d57;\n --rose: #a32d20;\n\n --font-sans: \"Segoe UI\", \"SF Pro Text\", \"PingFang SC\", \"Hiragino Sans GB\", \"Microsoft YaHei\", sans-serif;\n --font-serif: \"Songti SC\", \"STSong\", \"SimSun\", \"Noto Serif CJK SC\", Georgia, serif;\n --font-display: Georgia, \"Times New Roman\", \"Songti SC\", \"SimSun\", serif;\n --font-mono: \"Cascadia Code\", \"JetBrains Mono\", \"SF Mono\", Consolas, \"Liberation Mono\", monospace;\n --ease: cubic-bezier(0.22, 0.61, 0.36, 1);\n}\n\n* { box-sizing: border-box; }\nhtml, body { height: 100%; }\n\nbody {\n margin: 0;\n color: var(--ink);\n font-family: var(--font-sans);\n font-size: 13px;\n line-height: 1.55;\n background:\n radial-gradient(1200px 900px at 50% 34%, rgba(255, 255, 255, 0.16), transparent 72%),\n radial-gradient(900px 700px at 90% 108%, rgba(178, 58, 38, 0.03), transparent 60%),\n var(--paper);\n overflow: hidden;\n -webkit-font-smoothing: antialiased;\n text-rendering: optimizeLegibility;\n}\n\nbody::before {\n content: \"\";\n position: fixed;\n inset: 0;\n z-index: 0;\n pointer-events: none;\n opacity: 0.55;\n mix-blend-mode: multiply;\n background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='.22'/%3E%3C/svg%3E\");\n}\n\nbutton, input { font: inherit; color: inherit; }\nbutton { cursor: pointer; }\nsvg { display: block; }\nol, ul, dl, dd, dt { margin: 0; padding: 0; }\n\n::selection { background: rgba(178, 58, 38, 0.18); color: var(--ink); }\n\n:focus-visible { outline: 1px solid var(--accent); outline-offset: 3px; }\n\n* { scrollbar-width: thin; scrollbar-color: rgba(28, 25, 20, 0.25) transparent; }\n::-webkit-scrollbar { width: 7px; height: 7px; }\n::-webkit-scrollbar-track { background: transparent; }\n::-webkit-scrollbar-thumb { background: rgba(28, 25, 20, 0.22); border-radius: 0; }\n\n.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }\n.icon { width: 15px; height: 15px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }\n.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }\n.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }\n\n/* --------------------------------------------------------------------------\n Shell\n -------------------------------------------------------------------------- */\n\n.app {\n position: relative;\n z-index: 1;\n display: flex;\n flex-direction: column;\n height: 100dvh;\n min-height: 640px;\n max-width: 1760px;\n margin: 0 auto;\n padding: 0 30px;\n}\n\n/* Masthead\n -------------------------------------------------------------------------- */\n\n.masthead {\n display: flex;\n align-items: center;\n gap: 22px;\n flex: none;\n padding: 16px 0 10px;\n border-bottom: 2px solid var(--ink);\n}\n\n.brand { display: flex; align-items: center; gap: 11px; flex: none; }\n.brand-mark { width: 30px; height: 30px; color: var(--accent); }\n.brand-text { display: flex; flex-direction: column; line-height: 1.05; }\n.brand-name {\n font-family: var(--font-display);\n font-size: 27px;\n font-weight: 400;\n letter-spacing: 0.02em;\n line-height: 1;\n}\n.brand-sub {\n margin-top: 5px;\n font-family: var(--font-mono);\n font-size: 7.5px;\n letter-spacing: 0.16em;\n color: var(--ink-3);\n}\n\n.mast-run { display: flex; align-items: center; gap: 10px; min-width: 0; }\n.docket {\n display: flex;\n align-items: baseline;\n gap: 6px;\n padding: 2px 7px 1px;\n border: 1px solid var(--rule-strong);\n background: var(--paper-light);\n}\n.docket-label { font-family: var(--font-mono); font-size: 6.5px; letter-spacing: 0.12em; color: var(--ink-3); }\n.docket-id { font-family: var(--font-display); font-size: 13px; letter-spacing: 0.06em; }\n\n.stamp {\n display: inline-flex;\n align-items: center;\n gap: 5px;\n padding: 2px 6px;\n border: 1px solid var(--rule-strong);\n font-family: var(--font-mono);\n font-size: 8px;\n letter-spacing: 0.1em;\n text-transform: uppercase;\n color: var(--ink-2);\n white-space: nowrap;\n}\n.stamp-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); animation: dotPulse 2.2s var(--ease) infinite; }\n.stamp--demo {\n color: var(--accent);\n border-color: var(--accent);\n border-style: dashed;\n transform: rotate(-1.5deg);\n background: rgba(178, 58, 38, 0.03);\n}\n.run-short {\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n font-family: var(--font-mono);\n font-size: 9px;\n color: var(--ink-3);\n}\n\n.transport { display: flex; align-items: center; gap: 10px; margin-left: auto; flex: none; }\n\n.icon-btn {\n width: 30px; height: 30px;\n display: grid;\n place-items: center;\n border: 1px solid var(--rule-strong);\n border-radius: 50%;\n background: transparent;\n color: var(--ink-2);\n transition: color 0.2s, border-color 0.2s, background 0.2s;\n}\n.icon-btn:hover { color: var(--accent); border-color: var(--accent); background: rgba(178, 58, 38, 0.04); }\n.icon-btn .icon { width: 14px; height: 14px; }\n\n.play-btn {\n position: relative;\n width: 42px; height: 42px;\n display: grid;\n place-items: center;\n border: 1px solid var(--accent-deep);\n border-radius: 50%;\n background: var(--accent);\n color: var(--paper-light);\n box-shadow: 0 0 0 3px var(--paper), 0 0 0 4px var(--rule);\n transition: transform 0.2s var(--ease), background 0.2s;\n}\n.play-btn:hover { transform: rotate(-6deg); background: var(--accent-deep); }\n.play-btn .icon { width: 14px; height: 14px; }\n.play-btn span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }\n\n.speed { display: flex; align-items: center; gap: 7px; }\n.speed-btn {\n border: 0;\n border-bottom: 1px solid transparent;\n background: none;\n padding: 2px 0;\n font-family: var(--font-mono);\n font-size: 8.5px;\n color: var(--ink-3);\n transition: color 0.2s, border-color 0.2s;\n}\n.speed-btn:hover { color: var(--ink); }\n.speed-btn[aria-pressed=\"true\"] { color: var(--accent); border-bottom-color: var(--accent); }\n\n.clock { display: flex; align-items: baseline; gap: 4px; }\n.clock-now { font-family: var(--font-display); font-size: 21px; letter-spacing: 0.02em; line-height: 1; }\n.clock-total { font-size: 8.5px; color: var(--ink-3); }\n\n/* Headline\n -------------------------------------------------------------------------- */\n\n.headline { flex: none; padding: 14px 0 14px; border-bottom: 1px solid var(--rule); }\n.headline-rule {\n display: flex;\n justify-content: space-between;\n align-items: baseline;\n font-family: var(--font-mono);\n font-size: 8px;\n letter-spacing: 0.18em;\n text-transform: uppercase;\n color: var(--ink-3);\n}\n.headline-started { letter-spacing: 0.08em; }\n#goalTitle {\n margin: 7px 0 8px;\n max-width: 1240px;\n font-family: var(--font-serif);\n font-size: clamp(25px, 2.55vw, 35px);\n font-weight: 500;\n line-height: 1.3;\n letter-spacing: 0.015em;\n}\n.headline-meta {\n display: flex;\n flex-wrap: wrap;\n align-items: baseline;\n gap: 3px 7px;\n font-family: var(--font-mono);\n font-size: 9px;\n color: var(--ink-3);\n}\n.headline-meta #goalProject { color: var(--ink); letter-spacing: 0.04em; white-space: nowrap; }\n.headline-meta #goalBranch { white-space: nowrap; }\n.meta-dot { color: var(--ink-3); }\n.headline-elapsed { margin-left: auto; font-size: 9px; color: var(--ink-2); }\n.headline-token {\n margin-left: 14px;\n white-space: nowrap;\n font-family: var(--font-mono);\n font-size: 9px;\n letter-spacing: 0.04em;\n color: var(--accent);\n}\n.headline-token b { font-weight: 600; }\n.headline-elapsed b { font-weight: 500; color: var(--ink); }\n.elapsed-sep { margin: 0 5px; color: var(--ink-3); }\n\n/* Workspace\n -------------------------------------------------------------------------- */\n\n.workspace {\n display: grid;\n grid-template-columns: 272px minmax(0, 1fr) 332px;\n flex: 1;\n min-height: 0;\n}\n\n.rail { display: flex; flex-direction: column; min-height: 0; }\n.rail-left { padding: 16px 22px 10px 0; border-right: 1px solid var(--rule); }\n.center { display: flex; flex-direction: column; gap: 18px; min-height: 0; padding: 16px 22px 10px; }\n.rail-right { padding: 16px 0 10px 22px; border-left: 1px solid var(--rule); }\n\n.sect-head {\n display: flex;\n align-items: baseline;\n gap: 7px;\n flex: none;\n margin-bottom: 10px;\n padding-bottom: 6px;\n border-bottom: 1px solid var(--ink);\n}\n.sect-no {\n font-family: var(--font-display);\n font-style: italic;\n font-size: 11px;\n color: var(--accent);\n}\n.sect-head h2 {\n margin: 0;\n font-family: var(--font-serif);\n font-size: 14.5px;\n font-weight: 600;\n letter-spacing: 0.05em;\n}\n.sect-en {\n font-family: var(--font-mono);\n font-size: 7px;\n letter-spacing: 0.16em;\n color: var(--ink-3);\n text-transform: uppercase;\n}\n.sect-meta { margin-left: auto; font-size: 8.5px; color: var(--ink-3); }\n\n/* Left rail — ledger\n -------------------------------------------------------------------------- */\n\n.ledger { flex: none; margin-bottom: 22px; }\n.ledger-progress {\n display: flex;\n align-items: center;\n gap: 10px;\n padding: 6px 0 12px;\n}\n.pct-block { display: flex; flex-direction: column; }\n.pct-num {\n font-family: var(--font-display);\n font-size: 62px;\n font-weight: 400;\n line-height: 0.86;\n letter-spacing: -0.035em;\n color: var(--ink);\n font-variant-numeric: tabular-nums;\n}\n.pct-sign { font-family: var(--font-display); font-size: 15px; color: var(--accent); margin-left: 2px; }\n.pct-cap {\n margin-top: 7px;\n font-family: var(--font-mono);\n font-size: 7.5px;\n letter-spacing: 0.18em;\n text-transform: uppercase;\n color: var(--ink-3);\n}\n.goal-ring { width: 84px; height: 84px; margin-left: auto; transform: rotate(-90deg); flex: none; }\n.ring-track { fill: none; stroke: rgba(28, 25, 20, 0.1); stroke-width: 2.4; }\n.ring-value {\n fill: none;\n stroke: var(--accent);\n stroke-width: 2.4;\n stroke-linecap: round;\n stroke-dasharray: 188.5;\n stroke-dashoffset: 188.5;\n transition: stroke-dashoffset 0.3s linear;\n}\n\n.ledger-list { display: flex; flex-direction: column; }\n.ledger-row {\n display: flex;\n align-items: baseline;\n justify-content: space-between;\n padding: 7px 0;\n border-bottom: 1px dotted var(--rule);\n}\n.ledger-row dt { font-size: 10.5px; color: var(--ink-2); letter-spacing: 0.02em; }\n.ledger-row dd { font-family: var(--font-display); font-size: 19px; line-height: 1; color: var(--ink); }\n.ledger-row dd i { font-family: var(--font-mono); font-style: normal; font-size: 8px; color: var(--ink-3); margin-left: 2px; }\n#statBlockedCell.is-danger dt { color: var(--accent); }\n#statBlockedCell.is-danger dd { color: var(--accent); }\n\n/* Left rail — task index\n -------------------------------------------------------------------------- */\n\n.index { flex: 1; min-height: 0; display: flex; flex-direction: column; }\n.task-list {\n list-style: none;\n flex: 1;\n min-height: 0;\n overflow-y: auto;\n counter-reset: task;\n padding-bottom: 6px;\n}\n.task-item {\n position: relative;\n display: grid;\n grid-template-columns: 22px minmax(0, 1fr) auto;\n gap: 8px;\n align-items: start;\n padding: 5px 0 4px;\n border-bottom: 1px dotted var(--rule);\n cursor: pointer;\n counter-increment: task;\n transition: background 0.18s;\n}\n.task-item:hover { background: rgba(28, 25, 20, 0.035); }\n.task-item::before {\n content: counter(task, decimal-leading-zero);\n font-family: var(--font-display);\n font-style: italic;\n font-size: 10px;\n line-height: 1.9;\n color: var(--ink-3);\n}\n.task-icon { display: none; }\n.task-main { display: flex; flex-direction: column; gap: 1px; min-width: 0; }\n.task-title {\n font-size: 12px;\n font-weight: 500;\n color: var(--ink);\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n.task-sub {\n display: flex;\n align-items: center;\n gap: 6px;\n font-family: var(--font-mono);\n font-size: 8px;\n letter-spacing: 0.03em;\n color: var(--ink-3);\n white-space: nowrap;\n overflow: hidden;\n}\n.task-owner { display: inline-flex; align-items: center; gap: 4px; color: var(--agent-color, var(--ink-2)); }\n.task-owner::before { content: \"\"; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }\n.task-deps { color: var(--ink-3); }\n.task-tail {\n min-width: 36px;\n text-align: right;\n padding-top: 1px;\n font-family: var(--font-mono);\n font-size: 8.5px;\n color: var(--ink-3);\n}\n.task-item.is-running::before,\n.task-item.is-running .task-title,\n.task-item.is-running .task-tail { color: var(--accent); }\n.task-item.is-done .task-title { color: var(--ink-2); }\n.task-item.is-done .task-tail { color: var(--olive); }\n.task-item.is-done::before { color: var(--olive); }\n.task-item.is-alert,\n.task-item.is-blocked { background: var(--accent-wash); }\n.task-item.is-alert::before,\n.task-item.is-alert .task-title,\n.task-item.is-alert .task-tail,\n.task-item.is-blocked::before,\n.task-item.is-blocked .task-title,\n.task-item.is-blocked .task-tail { color: var(--accent-deep); }\n.task-item.is-selected { background: rgba(28, 25, 20, 0.05); }\n.task-item.is-selected .task-title { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }\n\n/* Plates\n -------------------------------------------------------------------------- */\n\n.plate { position: relative; display: flex; flex-direction: column; min-height: 0; margin: 0; }\n.plate-graph { flex: 1; }\n.plate-weave { flex: none; }\n\n.plate-head {\n display: flex;\n align-items: baseline;\n gap: 10px;\n flex: none;\n padding-bottom: 6px;\n border-bottom: 1px solid var(--ink);\n}\n.plate-no {\n font-family: var(--font-display);\n font-style: italic;\n font-size: 10.5px;\n color: var(--accent);\n white-space: nowrap;\n}\n.plate-title { display: flex; flex-direction: column; gap: 1px; }\n.plate-title h2 { margin: 0; font-family: var(--font-serif); font-size: 15.5px; font-weight: 600; letter-spacing: 0.06em; }\n.plate-title span { font-family: var(--font-mono); font-size: 6.5px; letter-spacing: 0.18em; color: var(--ink-3); }\n.plate-actions { display: flex; align-items: center; gap: 12px; margin-left: auto; }\n.plate-hint { font-family: var(--font-mono); font-size: 7.5px; letter-spacing: 0.06em; color: var(--ink-3); }\n.lane-readout { font-family: var(--font-display); font-size: 18px; letter-spacing: 0.02em; }\n\n.legend { display: flex; align-items: center; gap: 9px; font-family: var(--font-mono); font-size: 7.5px; letter-spacing: 0.05em; color: var(--ink-3); }\n.legend span { display: inline-flex; align-items: center; gap: 4px; }\n.lg-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--ink-3); }\n.lg-active { background: var(--accent); }\n.lg-done { background: var(--olive); }\n\n.chip-btn {\n display: inline-flex;\n align-items: center;\n gap: 5px;\n padding: 3px 7px;\n border: 1px solid var(--rule-strong);\n background: transparent;\n color: var(--ink-2);\n font-family: var(--font-mono);\n font-size: 7.5px;\n letter-spacing: 0.08em;\n text-transform: uppercase;\n transition: color 0.2s, background 0.2s, border-color 0.2s;\n}\n.chip-btn:hover { color: var(--paper-light); background: var(--ink); border-color: var(--ink); }\n.chip-btn[aria-pressed=\"true\"] { color: var(--paper-light); background: var(--accent); border-color: var(--accent); }\n.chip-btn .icon { width: 11px; height: 11px; }\n\n/* Stage — the loom\n -------------------------------------------------------------------------- */\n\n.stage {\n position: relative;\n flex: 1;\n min-height: 0;\n overflow: hidden;\n isolation: isolate;\n border: 1px solid var(--rule);\n border-top: 0;\n background:\n repeating-linear-gradient(0deg, transparent 0 47px, rgba(28, 25, 20, 0.038) 47px 48px),\n repeating-linear-gradient(90deg, transparent 0 47px, rgba(28, 25, 20, 0.038) 47px 48px),\n var(--paper-light);\n}\n.stage::before {\n content: \"\";\n position: absolute;\n inset: 9px;\n border: 1px solid rgba(28, 25, 20, 0.06);\n pointer-events: none;\n z-index: 3;\n}\n.stage::after {\n content: \"织造\";\n position: absolute;\n right: 24px;\n bottom: 34px;\n z-index: 0;\n font-family: var(--font-serif);\n font-size: 176px;\n line-height: 0.86;\n letter-spacing: 0.01em;\n color: rgba(28, 25, 20, 0.032);\n pointer-events: none;\n user-select: none;\n}\n.stage-grid {\n position: absolute;\n inset: 0;\n pointer-events: none;\n opacity: 0.6;\n background-image: radial-gradient(circle, rgba(28, 25, 20, 0.12) 0.7px, transparent 0.8px);\n background-size: 24px 24px;\n -webkit-mask-image: radial-gradient(ellipse 70% 66% at 50% 46%, #000 10%, transparent 76%);\n mask-image: radial-gradient(ellipse 70% 66% at 50% 46%, #000 10%, transparent 76%);\n}\n.orbits { position: absolute; left: 50%; top: 44%; width: 0; height: 0; pointer-events: none; opacity: 0.8; transform: translateY(12px); }\n.orbits span {\n position: absolute;\n left: 50%; top: 50%;\n transform: translate(-50%, -50%);\n border-radius: 50%;\n border: 1px dashed rgba(28, 25, 20, 0.09);\n}\n.orbits span:nth-child(1) { width: 230px; height: 230px; }\n.orbits span:nth-child(2) { width: 410px; height: 410px; border-style: solid; border-color: rgba(28, 25, 20, 0.04); }\n.orbits span:nth-child(3) { width: 600px; height: 600px; }\n\n.edge-layer { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }\n.edge {\n fill: none;\n stroke: rgba(28, 25, 20, 0.2);\n stroke-width: 1;\n transition: stroke 0.3s, stroke-width 0.3s, opacity 0.3s;\n}\n.edge.is-link { stroke-dasharray: 2 5; stroke: rgba(28, 25, 20, 0.24); }\n.edge.is-connected { stroke: rgba(28, 25, 20, 0.34); }\n.edge.is-hot { stroke-width: 1.6; }\n.stage.has-focus .edge { opacity: 0.2; }\n.stage.has-focus .edge.is-connected { opacity: 1; }\n\n.msg-particle { pointer-events: none; }\n.msg-glow { opacity: 0.18; filter: blur(2px); }\n.msg-core {\n stroke: var(--paper-light);\n stroke-width: 1.4;\n transform: rotate(45deg);\n transform-box: fill-box;\n transform-origin: center;\n filter: drop-shadow(0 0 2px rgba(28, 25, 20, 0.25));\n}\n\n.node-layer { position: absolute; inset: 0; transform: translateY(12px); pointer-events: none; }\n.node { pointer-events: none; }\n.node-btn { pointer-events: auto; }\n.edge-layer { transform: translateY(12px); }\n.node {\n position: absolute;\n width: 150px;\n text-align: center;\n transform: translateX(-50%);\n z-index: 2;\n transition: opacity 0.32s var(--ease), filter 0.32s var(--ease);\n}\n.node-btn {\n position: relative;\n width: 68px;\n height: 68px;\n margin: 0 auto;\n display: grid;\n place-items: center;\n border: 1px solid var(--c);\n border-radius: 50%;\n background: var(--paper-light);\n color: var(--c);\n box-shadow:\n inset 0 0 0 3px var(--paper-light),\n inset 0 0 0 4px color-mix(in srgb, var(--c) 55%, transparent);\n transition: background 0.25s, box-shadow 0.25s;\n}\n.node-btn::before {\n content: attr(data-seal);\n font-family: var(--font-serif);\n font-size: 29px;\n line-height: 1;\n font-weight: 500;\n letter-spacing: 0;\n color: var(--c);\n}\n.node-btn:hover { background: #fffdf6; }\n.node-icon { display: none; }\n.node-ring {\n position: absolute;\n inset: -7px;\n width: calc(100% + 14px);\n height: calc(100% + 14px);\n transform: rotate(-90deg);\n pointer-events: none;\n opacity: 0;\n transition: opacity 0.3s;\n}\n.node-ring circle { fill: none; stroke-width: 1.4; }\n.node-ring .ring-track { stroke: rgba(28, 25, 20, 0.08); }\n.node-ring .ring-value { stroke: var(--c); stroke-linecap: round; stroke-dasharray: 226; stroke-dashoffset: 226; }\n.node.is-active .node-ring,\n.node.is-alert .node-ring { opacity: 1; }\n\n.node-badge {\n position: absolute;\n right: -2px;\n top: -2px;\n width: 16px;\n height: 16px;\n display: grid;\n place-items: center;\n border: 1px solid var(--rule-strong);\n border-radius: 50%;\n background: var(--paper-light);\n color: var(--ink-3);\n}\n.node-badge .icon { width: 8px; height: 8px; }\n.node.is-active .node-badge { color: var(--paper-light); background: var(--accent); border-color: var(--accent); }\n.node.is-done .node-badge { color: var(--paper-light); background: var(--olive); border-color: var(--olive); }\n.node.is-alert .node-badge { color: var(--paper-light); background: var(--accent-deep); border-color: var(--accent-deep); }\n\n.node-name { margin-top: 8px; font-family: var(--font-serif); font-size: 13.5px; font-weight: 600; letter-spacing: 0.05em; color: var(--ink); }\n.node-role { margin-top: 1px; font-family: var(--font-mono); font-size: 7px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-3); }\n.node-activity {\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 4px;\n height: 16px;\n margin-top: 4px;\n padding: 0 4px;\n font-family: var(--font-serif);\n font-size: 10.5px;\n color: var(--ink-2);\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n.node-activity .mini { width: 4px; height: 4px; border-radius: 50%; background: var(--accent); animation: dotPulse 1.8s var(--ease) infinite; }\n.node.is-waiting .node-activity,\n.node.is-queued .node-activity { color: var(--ink-3); font-style: italic; }\n\n.node.is-selected .node-btn {\n box-shadow:\n 0 0 0 2px var(--paper-light),\n 0 0 0 3px var(--accent),\n inset 0 0 0 3px var(--paper-light),\n inset 0 0 0 4px color-mix(in srgb, var(--c) 55%, transparent);\n}\n.node.is-selected::after {\n content: \"\";\n position: absolute;\n left: 50%;\n top: 34px;\n width: 86px;\n height: 86px;\n border: 1px dashed var(--accent);\n border-radius: 50%;\n transform: translate(-50%, -50%) rotate(3deg);\n pointer-events: none;\n animation: sealTurn 44s linear infinite;\n}\n.stage.has-focus .node { opacity: 0.26; filter: grayscale(0.35); }\n.stage.has-focus .node.is-connected,\n.stage.has-focus .node.is-selected { opacity: 1; filter: none; }\n\n.stage-now {\n position: absolute;\n left: 0; right: 0; bottom: 0;\n z-index: 5;\n height: 42px;\n display: flex;\n align-items: center;\n gap: 9px;\n padding: 0 12px;\n border-top: 1px solid var(--rule);\n background: linear-gradient(180deg, var(--paper-light), var(--paper));\n box-shadow: 0 -12px 20px -18px rgba(28, 25, 20, 0.5);\n font-size: 10.5px;\n min-width: 0;\n}\n.now-label { flex: none; font-family: var(--font-mono); font-size: 7.5px; letter-spacing: 0.18em; color: var(--accent); }\n.now-time { flex: none; font-family: var(--font-display); font-size: 12px; color: var(--ink); }\n.now-text { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--ink-2); }\n.now-text b { color: var(--ink); font-family: var(--font-serif); font-weight: 600; }\n.now-text .to { color: var(--ink-3); }\n.now-text .feed-tag {\n font-family: var(--font-mono);\n font-size: 7px;\n color: var(--ink-3);\n border-bottom: 1px solid var(--rule);\n margin-left: 4px;\n padding-bottom: 1px;\n}\n.now-hint { margin-left: auto; flex: none; font-family: var(--font-mono); font-size: 7px; letter-spacing: 0.06em; color: var(--ink-3); }\n\n.plate-foot {\n display: flex;\n justify-content: space-between;\n gap: 10px;\n flex: none;\n padding-top: 5px;\n border-top: 1px dotted var(--rule);\n margin-top: 0;\n font-family: var(--font-mono);\n font-size: 7px;\n letter-spacing: 0.08em;\n color: var(--ink-3);\n}\n\n/* Lane / weave\n -------------------------------------------------------------------------- */\n\n.lanes {\n position: relative;\n display: grid;\n grid-template-columns: 78px minmax(0, 1fr);\n gap: 0 12px;\n padding: 6px 0 2px;\n}\n.lane-labels { display: flex; flex-direction: column; gap: 3px; padding-top: 25px; }\n.lane-label {\n height: 23px;\n display: flex;\n align-items: center;\n gap: 6px;\n font-family: var(--font-serif);\n font-size: 10.5px;\n letter-spacing: 0.03em;\n color: var(--ink-2);\n}\n.lane-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--c); flex: none; }\n.lane-tracks { position: relative; min-width: 0; }\n.lane-ruler { position: relative; height: 20px; border-bottom: 1px solid var(--rule); }\n.ruler-tick {\n position: absolute;\n top: 2px;\n transform: translateX(-50%);\n font-family: var(--font-mono);\n font-size: 7.5px;\n letter-spacing: 0.04em;\n color: var(--ink-3);\n white-space: nowrap;\n}\n.ruler-tick:first-child { transform: translateX(0); }\n.ruler-tick:last-child { transform: translateX(-100%); }\n.lane-rows { position: relative; z-index: 1; display: flex; flex-direction: column; gap: 3px; padding-top: 5px; }\n.lane-row { position: relative; height: 23px; border-bottom: 1px dotted rgba(28, 25, 20, 0.1); }\n.seg {\n position: absolute;\n top: 1px;\n bottom: 1px;\n overflow: hidden;\n border-left: 2px solid var(--c);\n background: color-mix(in srgb, var(--c) 10%, transparent);\n cursor: pointer;\n transition: opacity 0.22s, background 0.22s, box-shadow 0.22s;\n}\n.seg-fill {\n position: absolute;\n inset: 0;\n width: 0;\n background: color-mix(in srgb, var(--c) 22%, transparent);\n transition: width 0.12s linear;\n}\n.seg-label {\n position: relative;\n z-index: 2;\n display: block;\n padding: 0 5px;\n font-family: var(--font-mono);\n font-size: 8px;\n line-height: 20px;\n color: var(--ink);\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n.seg.is-upcoming { opacity: 0.3; }\n.seg.is-running {\n border-left-color: var(--accent);\n background: color-mix(in srgb, var(--c) 15%, transparent);\n}\n.seg.is-running .seg-fill {\n background-image: repeating-linear-gradient(45deg, transparent 0 3px, color-mix(in srgb, var(--c) 20%, transparent) 3px 4px);\n}\n.seg.is-selected { border-left-color: var(--ink-2); box-shadow: inset 0 -1px 0 rgba(28, 25, 20, 0.32); }\n.seg.is-tiny .seg-label { display: none; }\n\n.lane-links { position: absolute; top: 0; left: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; z-index: 0; }\n.lane-link { fill: none; stroke: rgba(28, 25, 20, 0.15); stroke-width: 1; transition: stroke 0.3s; }\n.lane-link.is-recent { stroke: var(--accent); stroke-width: 1.1; }\n.lane-link-dot { fill: rgba(28, 25, 20, 0.35); }\n.lane-link-dot.is-recent { fill: var(--accent); }\n\n.blocker-band {\n position: absolute;\n top: 20px;\n bottom: 0;\n background: repeating-linear-gradient(45deg, rgba(178, 58, 38, 0.055) 0 4px, transparent 4px 8px);\n border-left: 1px dashed rgba(178, 58, 38, 0.5);\n border-right: 1px dashed rgba(178, 58, 38, 0.3);\n pointer-events: none;\n transition: width 0.15s linear;\n}\n.blocker-label {\n position: absolute;\n top: 2px;\n left: 4px;\n padding: 1px 4px;\n border: 1px solid rgba(178, 58, 38, 0.35);\n background: var(--paper);\n font-family: var(--font-mono);\n font-size: 7.5px;\n letter-spacing: 0.04em;\n color: var(--accent-deep);\n white-space: nowrap;\n}\n.playhead {\n position: absolute;\n top: 16px;\n bottom: 0;\n width: 2px;\n background: var(--accent);\n transform: translateX(-1px);\n z-index: 3;\n pointer-events: none;\n}\n.playhead-cap {\n position: absolute;\n top: -4px;\n left: 50%;\n width: 8px;\n height: 8px;\n background: var(--accent);\n transform: translate(-50%, 0) rotate(45deg);\n}\n\n/* Right rail — dossier\n -------------------------------------------------------------------------- */\n\n.dossier { flex: none; max-height: 58%; display: flex; flex-direction: column; min-height: 0; padding-bottom: 18px; }\n.dossier-token {\n flex: none;\n display: grid;\n grid-template-columns: 1fr auto;\n grid-template-areas: \"label value\" \"share bar\";\n gap: 3px 8px;\n margin-top: 8px;\n padding: 7px 0 8px;\n border-top: 1px solid var(--rule);\n border-bottom: 1px dotted var(--rule);\n}\n.dt-label { grid-area: label; font-family: var(--font-mono); font-size: 8.5px; letter-spacing: 0.1em; color: var(--ink-3); }\n.dt-value { grid-area: value; font-family: var(--font-display); font-size: 18px; line-height: 1; color: var(--ink); }\n.dt-share { grid-area: share; font-family: var(--font-mono); font-size: 8px; color: var(--ink-3); }\n.dt-bar { grid-area: bar; align-self: center; width: 100%; height: 2px; background: rgba(28, 25, 20, 0.1); }\n.dt-bar i { display: block; height: 100%; width: 0%; background: var(--accent); transition: width 0.2s linear; }\n.inspector { flex: 1; min-height: 0; overflow-y: auto; padding-top: 8px; }\n\n.insp-head { display: flex; align-items: flex-start; gap: 10px; }\n.insp-avatar {\n width: 42px;\n height: 42px;\n display: grid;\n place-items: center;\n flex: none;\n border: 1px solid var(--c);\n border-radius: 50%;\n background: var(--paper-light);\n color: var(--c);\n box-shadow: inset 0 0 0 3px var(--paper-light), inset 0 0 0 4px color-mix(in srgb, var(--c) 45%, transparent);\n}\n.insp-avatar .icon { display: none; }\n.insp-avatar::before { content: attr(data-seal); font-family: var(--font-serif); font-size: 22px; line-height: 1; color: var(--c); }\n.insp-id { flex: 1; min-width: 0; }\n.insp-name { display: flex; align-items: baseline; gap: 7px; font-family: var(--font-serif); font-size: 17px; font-weight: 600; letter-spacing: 0.04em; }\n.insp-name .role { font-family: var(--font-mono); font-size: 7px; font-weight: 400; letter-spacing: 0.12em; color: var(--ink-3); }\n.insp-sub { margin-top: 2px; display: flex; flex-wrap: wrap; gap: 8px; font-family: var(--font-mono); font-size: 8px; color: var(--ink-3); }\n.insp-status {\n flex: none;\n margin-left: auto;\n display: inline-flex;\n align-items: center;\n gap: 5px;\n padding: 2px 7px;\n border: 1px solid var(--rule-strong);\n font-family: var(--font-mono);\n font-size: 8px;\n letter-spacing: 0.08em;\n color: var(--ink-2);\n white-space: nowrap;\n}\n.insp-status i { width: 5px; height: 5px; border-radius: 50%; background: var(--ink-3); }\n.insp-status.is-active { color: var(--accent); border-color: var(--accent); }\n.insp-status.is-active i { background: var(--accent); animation: dotPulse 1.8s var(--ease) infinite; }\n.insp-status.is-alert { color: var(--paper-light); background: var(--accent); border-color: var(--accent); }\n.insp-status.is-alert i { background: var(--paper-light); }\n.insp-status.is-done { color: var(--olive); border-color: var(--olive); }\n.insp-status.is-done i { background: var(--olive); }\n\n.insp-stats { display: flex; gap: 14px; margin-top: 12px; border-top: 1px solid var(--rule); padding-top: 8px; }\n.insp-stat { flex: 1; min-width: 0; }\n.insp-stat b { display: block; font-family: var(--font-display); font-size: 19px; font-weight: 400; line-height: 1.1; }\n.insp-stat span { font-family: var(--font-mono); font-size: 7.5px; letter-spacing: 0.08em; color: var(--ink-3); }\n\n.insp-section { margin-top: 12px; }\n.insp-label {\n display: flex;\n justify-content: space-between;\n gap: 8px;\n margin-bottom: 6px;\n padding-bottom: 4px;\n border-bottom: 1px dotted var(--rule);\n font-family: var(--font-mono);\n font-size: 7.5px;\n letter-spacing: 0.14em;\n text-transform: uppercase;\n color: var(--ink-3);\n}\n.work-card { padding: 8px 9px; border: 1px dashed var(--rule-strong); background: var(--paper-light); }\n.work-title { display: flex; align-items: baseline; gap: 6px; font-family: var(--font-serif); font-size: 12.5px; font-weight: 600; }\n.work-title .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--c); align-self: center; }\n.work-meta { display: flex; justify-content: space-between; gap: 8px; margin-top: 4px; font-family: var(--font-mono); font-size: 8px; color: var(--ink-3); }\n.progress { height: 3px; margin-top: 7px; background: rgba(28, 25, 20, 0.08); overflow: hidden; }\n.progress-fill { height: 100%; background: var(--c); transition: width 0.12s linear; }\n.wait-card {\n padding: 2px 0 2px 9px;\n border-left: 2px solid var(--rule-strong);\n font-family: var(--font-serif);\n font-size: 10.5px;\n line-height: 1.7;\n color: var(--ink-2);\n}\n.wait-card b { font-weight: 600; color: var(--ink); }\n\n.insp-events { display: flex; flex-direction: column; }\n.insp-event {\n display: grid;\n grid-template-columns: 32px 12px minmax(0, 1fr);\n gap: 6px;\n padding: 4px 0;\n border-bottom: 1px dotted var(--rule-soft);\n font-size: 10.5px;\n line-height: 1.55;\n color: var(--ink-2);\n}\n.insp-event .t { padding-top: 1px; font-family: var(--font-display); font-style: italic; font-size: 9px; color: var(--ink-3); }\n.insp-event .icon { width: 10px; height: 10px; margin-top: 3px; color: var(--tone, var(--ink-3)); }\n\n.artifacts { display: flex; flex-direction: column; }\n.artifact {\n display: flex;\n align-items: baseline;\n gap: 6px;\n padding: 4px 0;\n border-bottom: 1px dotted var(--rule-soft);\n font-size: 10px;\n color: var(--ink-2);\n}\n.artifact .icon { width: 10px; height: 10px; color: var(--olive); align-self: center; }\n.artifact .t { margin-left: auto; font-family: var(--font-mono); font-size: 8px; color: var(--ink-3); }\n.empty-note { font-family: var(--font-serif); font-style: italic; font-size: 10px; color: var(--ink-3); }\n\n.switch {\n display: inline-flex;\n align-items: center;\n gap: 5px;\n margin-left: auto;\n border: 0;\n background: none;\n padding: 0;\n font-family: var(--font-mono);\n font-size: 7.5px;\n letter-spacing: 0.04em;\n color: var(--ink-3);\n}\n.switch-track {\n position: relative;\n width: 24px;\n height: 13px;\n border: 1px solid var(--rule-strong);\n border-radius: 999px;\n background: transparent;\n transition: background 0.2s, border-color 0.2s;\n}\n.switch-thumb {\n position: absolute;\n top: 1px;\n left: 1px;\n width: 9px;\n height: 9px;\n border-radius: 50%;\n background: var(--ink-3);\n transition: transform 0.2s var(--ease), background 0.2s;\n}\n.switch[aria-pressed=\"true\"] { color: var(--ink-2); }\n.switch[aria-pressed=\"true\"] .switch-track { border-color: var(--accent); background: rgba(178, 58, 38, 0.1); }\n.switch[aria-pressed=\"true\"] .switch-thumb { transform: translateX(11px); background: var(--accent); }\n\n/* Right rail — field notes\n -------------------------------------------------------------------------- */\n\n.notes { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }\n.feed-filters { display: flex; flex-wrap: wrap; gap: 2px 10px; flex: none; padding: 8px 0 7px; border-bottom: 1px solid var(--rule); }\n.filter-chip {\n border: 0;\n border-bottom: 1px solid transparent;\n background: none;\n padding: 1px 0;\n font-family: var(--font-mono);\n font-size: 8px;\n letter-spacing: 0.08em;\n color: var(--ink-3);\n transition: color 0.18s, border-color 0.18s;\n}\n.filter-chip:hover { color: var(--ink); }\n.filter-chip[aria-pressed=\"true\"] { color: var(--accent); border-bottom-color: var(--accent); }\n\n.feed-scroll {\n position: relative;\n flex: 1;\n min-height: 0;\n overflow-y: auto;\n padding: 2px 0 10px;\n -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 16px);\n mask-image: linear-gradient(180deg, transparent 0, #000 16px);\n}\n.feed-list { list-style: none; }\n.feed-item {\n display: grid;\n grid-template-columns: 34px 12px minmax(0, 1fr);\n gap: 7px;\n padding: 7px 1px 7px;\n border-bottom: 1px dotted var(--rule);\n cursor: pointer;\n animation: noteIn 0.26s var(--ease) both;\n transition: background 0.18s;\n}\n.feed-item:hover { background: rgba(28, 25, 20, 0.04); }\n.feed-item.no-anim { animation: none; }\n.feed-time { padding-top: 1px; font-family: var(--font-display); font-style: italic; font-size: 9.5px; color: var(--ink-3); }\n.feed-icon { padding-top: 2px; color: var(--tone, var(--ink-3)); }\n.feed-icon .icon { width: 10px; height: 10px; }\n.feed-text { min-width: 0; font-size: 10.8px; line-height: 1.62; color: var(--ink-2); }\n.feed-text b { color: var(--ink); font-family: var(--font-serif); font-weight: 600; font-size: 11.5px; letter-spacing: 0.02em; }\n.feed-text .to { color: var(--ink-3); }\n.feed-tag {\n display: inline-block;\n margin-left: 4px;\n padding-bottom: 1px;\n border-bottom: 1px solid var(--rule);\n font-family: var(--font-mono);\n font-size: 7px;\n color: var(--ink-3);\n vertical-align: 1px;\n}\n.feed-item.t-delegate { --tone: var(--teal); }\n.feed-item.t-message { --tone: var(--ink-3); }\n.feed-item.t-tool { --tone: var(--ochre); }\n.feed-item.t-decision { --tone: var(--olive); }\n.feed-item.t-artifact { --tone: var(--olive); }\n.feed-item.t-insight { --tone: var(--plum); }\n.feed-item.t-alert { --tone: var(--accent-deep); background: rgba(178, 58, 38, 0.045); }\n.feed-item.t-alert .feed-text { color: var(--ink); }\n.feed-item.t-alert .feed-time { color: var(--accent); }\n.feed-empty { padding: 22px 2px; font-family: var(--font-serif); font-style: italic; font-size: 10.5px; color: var(--ink-3); }\n.feed-jump {\n position: absolute;\n right: 0;\n bottom: 8px;\n z-index: 3;\n display: inline-flex;\n align-items: center;\n gap: 5px;\n height: 24px;\n padding: 0 8px;\n border: 1px solid var(--ink);\n background: var(--paper-light);\n box-shadow: 2px 2px 0 rgba(28, 25, 20, 0.15);\n font-family: var(--font-mono);\n font-size: 7.5px;\n letter-spacing: 0.06em;\n color: var(--ink);\n}\n.feed-jump[hidden] { display: none; }\n.feed-jump .icon { width: 10px; height: 10px; }\n\n/* Footer\n -------------------------------------------------------------------------- */\n\n.footer {\n display: flex;\n align-items: center;\n gap: 16px;\n flex: none;\n height: 26px;\n border-top: 1px solid var(--rule);\n font-family: var(--font-mono);\n font-size: 7px;\n letter-spacing: 0.06em;\n color: var(--ink-3);\n}\n.footer-left { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }\n.footer-keys { display: flex; align-items: center; gap: 5px; margin-left: auto; white-space: nowrap; }\n.footer-right { white-space: nowrap; }\nkbd {\n padding: 1px 3px;\n border: 1px solid var(--rule-strong);\n background: rgba(255, 255, 255, 0.35);\n font-family: var(--font-mono);\n font-size: 7px;\n color: var(--ink-2);\n line-height: 1.2;\n}\n\n/* Dialog & toast\n -------------------------------------------------------------------------- */\n\n.dialog {\n width: min(460px, 92vw);\n padding: 0;\n border: 1px solid var(--ink);\n border-radius: 0;\n background: var(--paper-light);\n color: var(--ink);\n box-shadow: 10px 10px 0 rgba(28, 25, 20, 0.14);\n}\n.dialog::backdrop { background: rgba(28, 25, 20, 0.5); backdrop-filter: blur(2px); }\n.dialog-head {\n display: flex;\n align-items: flex-start;\n justify-content: space-between;\n padding: 16px 18px 12px;\n border-bottom: 1px solid var(--ink);\n}\n.dialog-head h2 { margin: 4px 0 0; font-family: var(--font-serif); font-size: 18px; font-weight: 600; letter-spacing: 0.05em; }\n.dialog-body { max-height: 65vh; overflow-y: auto; padding: 12px 18px 18px; }\n.shortcut-list { display: flex; flex-direction: column; }\n.shortcut-list div { display: grid; grid-template-columns: 106px 1fr; gap: 12px; align-items: center; padding: 7px 0; border-bottom: 1px dotted var(--rule); }\n.shortcut-list dt { display: flex; gap: 4px; align-items: center; }\n.shortcut-list dd { margin: 0; font-size: 11px; color: var(--ink-2); }\n.dialog-note {\n margin: 14px 0 0;\n padding-left: 9px;\n border-left: 2px solid var(--rule-strong);\n font-family: var(--font-serif);\n font-size: 10px;\n line-height: 1.75;\n color: var(--ink-3);\n}\n.eyebrow { display: block; font-family: var(--font-mono); font-size: 7.5px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-3); }\n.dialog .icon-btn { border-color: var(--rule-strong); color: var(--ink-2); }\n\n.tip-toast {\n position: fixed;\n right: 22px;\n bottom: 38px;\n z-index: 30;\n padding: 7px 12px;\n border: 1px solid var(--ink);\n background: var(--paper-light);\n box-shadow: 4px 4px 0 rgba(28, 25, 20, 0.14);\n border-left: 3px solid var(--accent);\n font-family: var(--font-serif);\n font-size: 10.5px;\n color: var(--ink-2);\n opacity: 0;\n pointer-events: none;\n transform: translateY(8px);\n transition: opacity 0.3s, transform 0.3s;\n}\n.tip-toast.is-visible { opacity: 1; transform: none; }\n\n/* Animations\n -------------------------------------------------------------------------- */\n\n@keyframes dotPulse {\n 0%, 100% { opacity: 1; transform: scale(1); }\n 50% { opacity: 0.35; transform: scale(0.75); }\n}\n@keyframes sealTurn { to { transform: translate(-50%, -50%) rotate(363deg); } }\n@keyframes noteIn { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }\n@keyframes fadeUp { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }\n.reveal { animation: fadeUp 0.5s var(--ease) both; }\n\n.app.is-paused #runStamp { color: var(--ink-3); border-color: var(--rule-strong); }\n.app.is-paused #runStamp .stamp-dot { background: var(--ink-3); }\n.app.is-complete #runStamp { color: var(--olive); border-color: var(--olive); }\n.app.is-complete #runStamp .stamp-dot { background: var(--olive); }\n.app.is-paused .stamp-dot,\n.app.is-paused .node-activity .mini,\n.app.is-paused .insp-status.is-active i,\n.app.is-paused .node.is-selected::after { animation-play-state: paused; }\n\n/* Responsive\n -------------------------------------------------------------------------- */\n\n@media (max-width: 1440px) {\n .workspace { grid-template-columns: 250px minmax(0, 1fr) 308px; }\n .center { padding: 16px 18px 10px; }\n .rail-left { padding-right: 18px; }\n .rail-right { padding-left: 18px; }\n .brand-sub { display: none; }\n}\n\n@media (max-width: 1180px) {\n body { overflow-y: auto; overflow-x: hidden; }\n .app { height: auto; min-height: 100dvh; padding: 0 18px; }\n .masthead { flex-wrap: wrap; row-gap: 8px; }\n .mast-run { order: 3; flex: 1 1 100%; }\n .transport { margin-left: auto; }\n .headline { padding: 12px 0; }\n .workspace { display: flex; flex-direction: column; gap: 0; }\n .center { order: 1; padding: 14px 0 0; }\n .rail-left { order: 2; padding: 20px 0 0; border-right: 0; border-top: 1px solid var(--rule); }\n .rail-right { order: 3; padding: 20px 0 0; border-left: 0; border-top: 1px solid var(--rule); }\n .plate-graph { min-height: 430px; }\n .plate-weave { margin-top: 16px; }\n .rail-left { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 0 26px; }\n .ledger { margin-bottom: 0; }\n .index { min-height: 220px; }\n .rail-right { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 0 26px; }\n .dossier { max-height: none; padding-bottom: 0; }\n .notes { min-height: 340px; }\n .footer { display: none; }\n}\n\n@media (max-width: 820px) {\n .rail-left, .rail-right { display: flex; flex-direction: column; gap: 20px; }\n .index { min-height: 0; max-height: 330px; }\n .notes { min-height: 360px; }\n .headline-elapsed { margin-left: 0; flex-basis: 100%; }\n .legend { display: none; }\n .plate-hint { display: none; }\n .run-short { display: none; }\n #goalTitle { font-size: 24px; }\n}\n\n@media (max-width: 620px) {\n .app { padding: 0 12px; }\n .masthead { padding-top: 12px; }\n .brand-name { font-size: 22px; }\n .clock { display: none; }\n .transport { gap: 7px; }\n .plate-head { flex-wrap: wrap; row-gap: 4px; }\n .plate-actions { margin-left: 0; }\n .stage { min-height: 400px; }\n .now-hint { display: none; }\n .lanes { grid-template-columns: 62px minmax(0, 1fr); gap: 0 8px; }\n .seg-label { display: none; }\n .feed-item { grid-template-columns: 30px 11px minmax(0, 1fr); }\n .footer { display: none; }\n .tip-toast { right: 10px; bottom: 14px; }\n}\n\n@media (max-width: 430px) {\n #goalTitle { font-size: 21px; }\n .pct-num { font-size: 50px; }\n .goal-ring { width: 68px; height: 68px; }\n .stage { min-height: 380px; }\n .node { width: 108px; }\n .node-btn { width: 52px; height: 52px; }\n .node-btn::before { font-size: 22px; }\n .node-name { font-size: 12px; }\n .node-activity { display: none; }\n .speed { display: none; }\n}\n\n@media (prefers-reduced-motion: reduce) {\n *, *::before, *::after {\n animation-duration: 0.001ms !important;\n animation-iteration-count: 1 !important;\n transition-duration: 0.001ms !important;\n scroll-behavior: auto !important;\n }\n .reveal { animation: none; }\n}\n\n/* ==========================================================================\n Graph zoom / pan — local to Plate I\n ========================================================================== */\n\n.stage-zoom {\n position: absolute;\n inset: 0;\n z-index: 1;\n transform-origin: 0 0;\n}\n.stage.can-pan { cursor: grab; touch-action: none; }\n.stage.can-pan .node-btn { cursor: pointer; }\n.stage.is-panning { cursor: grabbing; user-select: none; }\n.stage.is-panning .node-btn,\n.stage.is-panning .edge-hit { cursor: grabbing; }\n\n.graph-zoom {\n display: inline-flex;\n align-items: center;\n height: 24px;\n border: 1px solid var(--rule-strong);\n background: var(--paper-light);\n}\n.graph-zoom .zoom-btn {\n width: 22px;\n height: 22px;\n border: 0;\n background: transparent;\n color: var(--ink-2);\n cursor: pointer;\n font-family: var(--font-mono);\n font-size: 13px;\n line-height: 1;\n}\n.graph-zoom .zoom-btn:hover { background: var(--ink); color: var(--paper-light); }\n.graph-zoom .zoom-btn:disabled { opacity: 0.3; background: transparent; color: var(--ink-3); cursor: default; }\n.zoom-pct {\n height: 22px;\n min-width: 44px;\n padding: 0 6px;\n border: 0;\n border-left: 1px solid var(--rule);\n border-right: 1px solid var(--rule);\n background: transparent;\n color: var(--ink-2);\n font-family: var(--font-mono);\n font-size: 8.5px;\n cursor: pointer;\n}\n.zoom-pct:hover { color: var(--accent); }\n\n@media (max-width: 620px) {\n .graph-zoom .zoom-btn { width: 20px; }\n .zoom-pct { min-width: 40px; padding: 0 4px; font-size: 8px; }\n}\n\n/* ==========================================================================\n Many agents — compact graph and weave\n ========================================================================== */\n\n.agents-many .stage .node { width: 122px; }\n.agents-many .stage .node-btn { width: 56px; height: 56px; }\n.agents-many .stage .node-btn::before { font-size: 24px; }\n.agents-many .stage .node-role,\n.agents-many .stage .node-activity { display: none; }\n.agents-many .stage .node-name { margin-top: 6px; font-size: 12.5px; }\n.agents-many .stage .node.is-selected::after { top: 28px; width: 70px; height: 70px; }\n.agents-crowded .stage .node { width: 110px; }\n.agents-crowded .stage .node-btn { width: 48px; height: 48px; }\n.agents-crowded .stage .node-btn::before { font-size: 20px; }\n.agents-crowded .stage .node-name { font-size: 12px; }\n.agents-crowded .stage .node.is-selected::after { top: 24px; width: 60px; height: 60px; }\n\n.agents-swarm .stage .node { width: 92px; }\n.agents-swarm .stage .node-btn { width: 38px; height: 38px; }\n.agents-swarm .stage .node-btn::before { font-size: 16px; }\n.agents-swarm .stage .node-name { font-size: 11px; }\n.agents-swarm .stage .node.is-selected::after { top: 19px; width: 46px; height: 46px; }\n\n.agents-hive .stage .node { width: 84px; }\n.agents-hive .stage .node-btn { width: 32px; height: 32px; }\n.agents-hive .stage .node-btn::before { font-size: 14px; }\n.agents-hive .stage .node-name { font-size: 10.5px; }\n.agents-hive .stage .node.is-selected::after { top: 16px; width: 40px; height: 40px; }\n\n/* 8+ 智能体时,展开态给泳道一个内部滚动上限,避免把协作图压扁 */\n.agents-crowded .plate-weave:not(.is-collapsed) .weave-body {\n max-height: 232px;\n overflow-y: auto;\n scrollbar-width: thin;\n scrollbar-color: rgba(28, 25, 20, 0.28) transparent;\n}\n.agents-crowded .plate-weave:not(.is-collapsed) .weave-body::-webkit-scrollbar { width: 6px; }\n.agents-crowded .plate-weave:not(.is-collapsed) .weave-body::-webkit-scrollbar-thumb {\n background: rgba(28, 25, 20, 0.28);\n}\n\n.agents-many .lane-row { height: 20px; }\n.agents-many .lane-label { height: 20px; }\n.agents-many .lane-labels { padding-top: 24px; gap: 3px; }\n.agents-many .lane-rows { gap: 3px; padding-top: 4px; }\n.agents-many .seg-label { font-size: 7.5px; line-height: 16px; }\n.agents-many .lane-edge-marks { top: 20px; }\n.agents-many .blocker-band { top: 20px; }\n\n/* 展开时间轴后主图变矮时:多智能体只保留朱印,悬停/选中再显示名字 */\n.agents-many .stage.is-tight .node-name {\n opacity: 0;\n transition: opacity 0.18s;\n}\n.agents-many .stage.is-tight .node:hover .node-name,\n.agents-many .stage.is-tight .node.is-selected .node-name { opacity: 1; }\n.agents-many .stage.is-tight .node.is-selected::after { top: 29px; }\n\n/* ==========================================================================\n Blockers — dedicated row / strip + details popover (Edition 02.5)\n ========================================================================== */\n\n#blockerBand { display: none !important; }\n\n.wc-blocker-wrap { position: relative; height: 18px; margin: 2px 0 6px; }\n.wc-blocker-wrap[hidden] { display: none; }\n.wc-blocker-band {\n position: absolute;\n top: 0;\n bottom: 0;\n left: 0;\n width: 0;\n display: flex;\n align-items: center;\n padding: 0 6px;\n overflow: hidden;\n border: 1px dashed rgba(178, 58, 38, 0.55);\n background: repeating-linear-gradient(45deg, rgba(178, 58, 38, 0.09) 0 4px, transparent 4px 8px);\n cursor: pointer;\n font: inherit;\n text-align: left;\n}\n.wc-blocker-band:hover { border-style: solid; border-color: var(--accent); }\n.wc-blocker-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: rgba(178, 58, 38, 0.18); }\n.wc-blocker-text {\n position: relative;\n z-index: 1;\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n font-family: var(--font-mono);\n font-size: 8.5px;\n letter-spacing: 0.02em;\n color: var(--accent-deep);\n}\n.wc-blocker-band.is-resolved { border-style: solid; }\n\n.lane-label[hidden],\n.lane-row[hidden] { display: none !important; }\n.lane-label--blocker {\n color: var(--accent-deep);\n cursor: pointer;\n font-family: var(--font-mono);\n font-size: 9px;\n letter-spacing: 0.08em;\n}\n.lane-label--blocker:hover { color: var(--accent); }\n.lane-blocker-dot {\n width: 6px;\n height: 6px;\n border: 1px solid var(--accent);\n background: rgba(178, 58, 38, 0.18);\n flex: none;\n}\n.lane-row--blocker {\n background: repeating-linear-gradient(45deg, rgba(178, 58, 38, 0.035) 0 5px, transparent 5px 10px);\n border-bottom: 1px dashed rgba(178, 58, 38, 0.28);\n}\n.lane-blocker-band {\n position: absolute;\n top: 1px;\n bottom: 1px;\n left: 0;\n width: 0;\n display: flex;\n align-items: center;\n padding: 0 6px;\n overflow: hidden;\n border: 1px dashed rgba(178, 58, 38, 0.5);\n background: rgba(178, 58, 38, 0.07);\n cursor: pointer;\n font: inherit;\n text-align: left;\n}\n.lane-blocker-band:hover { border-style: solid; border-color: var(--accent); }\n.lane-blocker-band[hidden] { display: none; }\n.lane-blocker-band.is-resolved { border-style: solid; }\n.lane-blocker-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: rgba(178, 58, 38, 0.16); }\n.lane-blocker-text {\n position: relative;\n z-index: 1;\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n font-family: var(--font-mono);\n font-size: 8px;\n color: var(--accent-deep);\n}\n\n.blocker-pop {\n position: fixed;\n z-index: 80;\n width: 322px;\n max-width: calc(100vw - 24px);\n padding: 14px 16px 14px;\n border: 1px solid var(--accent);\n background: var(--paper-light);\n box-shadow: 8px 8px 0 rgba(28, 25, 20, 0.14);\n color: var(--ink);\n}\n.blocker-pop[hidden] { display: none; }\n.bp-close {\n position: absolute;\n top: 8px;\n right: 8px;\n width: 24px;\n height: 24px;\n display: grid;\n place-items: center;\n border: 1px solid var(--rule-strong);\n background: transparent;\n color: var(--ink-2);\n cursor: pointer;\n}\n.bp-close:hover { border-color: var(--accent); color: var(--accent); }\n.bp-close .icon { width: 12px; height: 12px; }\n.bp-eyebrow {\n font-family: var(--font-mono);\n font-size: 8px;\n letter-spacing: 0.14em;\n text-transform: uppercase;\n color: var(--accent);\n}\n.blocker-pop h3 { margin: 4px 0 4px; font-family: var(--font-serif); font-size: 18px; font-weight: 600; letter-spacing: 0.04em; }\n.blocker-pop p { margin: 0 0 10px; font-size: 11px; line-height: 1.6; color: var(--ink-2); }\n.bp-meta { display: flex; flex-direction: column; border-top: 1px solid var(--rule); }\n.bp-meta div { display: grid; grid-template-columns: 52px 1fr; gap: 8px; padding: 4px 0; border-bottom: 1px dotted var(--rule); }\n.bp-meta dt { font-family: var(--font-mono); font-size: 8px; color: var(--ink-3); }\n.bp-meta dd { margin: 0; font-size: 10.5px; color: var(--ink-2); }\n.bp-actions { display: flex; gap: 8px; margin-top: 10px; }\n.bp-actions button {\n padding: 4px 8px;\n border: 1px solid var(--rule-strong);\n background: transparent;\n color: var(--ink-2);\n font-family: var(--font-mono);\n font-size: 8.5px;\n cursor: pointer;\n}\n.bp-actions button:hover { border-color: var(--accent); color: var(--accent); }\n.bp-actions button:first-child { border-color: var(--accent); background: var(--accent); color: var(--paper-light); }\n\n@media (max-width: 620px) {\n .blocker-pop { width: calc(100vw - 20px); padding: 13px 14px; }\n .wc-blocker-text { font-size: 8px; }\n .lane-blocker-text { font-size: 7.5px; }\n}\n\n\n/* ==========================================================================\n Edition 02.1 — 可读性 / 自适应密度 / 可折叠织带 / 可拖拽栏宽\n ========================================================================== */\n\nbody { font-size: 14px; }\n\n/* --- 可拖拽的三栏网格 ------------------------------------------------ */\n\n.workspace {\n --left-w: 272px;\n --right-w: 332px;\n display: grid;\n grid-template-columns: var(--left-w) 10px minmax(0, 1fr) 10px var(--right-w);\n gap: 0;\n flex: 1;\n min-height: 0;\n}\n.rail-left { padding: 16px 18px 10px 0; border-right: 0; }\n.center { padding: 16px 18px 10px; gap: 14px; }\n.rail-right { padding: 16px 0 10px 18px; border-left: 0; }\n\n.splitter {\n position: relative;\n z-index: 6;\n width: 10px;\n cursor: col-resize;\n touch-action: none;\n background: transparent;\n}\n.splitter::after {\n content: \"\";\n position: absolute;\n top: 0;\n bottom: 0;\n left: 50%;\n width: 1px;\n background: var(--rule);\n transform: translateX(-0.5px);\n transition: width 0.15s, background 0.15s;\n}\n.splitter:hover::after,\n.splitter:focus-visible::after,\n.splitter.is-active::after { width: 2px; background: var(--accent); }\n.splitter:focus-visible { outline: none; }\n.splitter::before {\n content: \"\";\n position: absolute;\n top: 50%;\n left: 50%;\n width: 3px;\n height: 16px;\n background: repeating-linear-gradient(180deg, var(--rule-strong) 0 1px, transparent 1px 4px);\n transform: translate(-50%, -50%);\n opacity: 0.35;\n transition: opacity 0.15s;\n}\n.splitter:hover::before,\n.splitter:focus-visible::before { opacity: 1; }\nbody.is-resizing { cursor: col-resize; user-select: none; }\nbody.is-resizing .node-activity,\nbody.is-resizing .feed-item { pointer-events: none; }\n\n/* --- 字号:抬高小字下限,减少装饰性英文 ------------------------------ */\n\n.brand-sub { font-size: 8.5px; }\n.docket-label { font-size: 7.5px; }\n.docket-id { font-size: 14px; }\n.stamp { font-size: 9px; }\n.run-short { font-size: 9.5px; }\n.clock-now { font-size: 22px; }\n.clock-total { font-size: 9px; }\n.speed-btn { font-size: 9px; }\n.icon-btn .icon { width: 15px; height: 15px; }\n.sect-head { gap: 8px; padding-bottom: 7px; margin-bottom: 10px; }\n.sect-no { font-size: 12px; }\n.sect-head h2 { font-size: 15.5px; }\n.sect-en { font-size: 8px; }\n.sect-meta { font-size: 9.5px; }\n.eyebrow { font-size: 8px; }\n.pct-num { font-size: 56px; }\n.pct-sign { font-size: 16px; }\n.pct-cap { font-size: 9px; letter-spacing: 0.14em; }\n.ledger-progress { padding: 4px 0 10px; }\n.ledger-row { padding: 6px 0; }\n.ledger-row dt { font-size: 12px; }\n.ledger-row dd { font-size: 20px; }\n.ledger-row dd i { font-size: 9px; }\n.task-item { padding: 6px 0 5px; }\n.task-item::before { font-size: 11px; }\n.task-title { font-size: 13px; }\n.task-sub { font-size: 9.5px; }\n.task-tail { font-size: 9.5px; }\n.node-name { font-size: 14.5px; }\n.node-role { font-size: 9px; letter-spacing: 0.1em; }\n.node-activity { height: 18px; margin-top: 5px; font-size: 11.5px; }\n.now-label { font-size: 9px; }\n.now-time { font-size: 13px; }\n.now-text { font-size: 11.5px; }\n.now-hint { font-size: 9px; }\n.plate-no { font-size: 11.5px; }\n.plate-title h2 { font-size: 16px; }\n.plate-title span { font-size: 7.5px; }\n.plate-hint { font-size: 8.5px; }\n.legend { font-size: 8.5px; }\n.chip-btn { padding: 4px 8px; font-size: 8.5px; }\n.weave-toggle {\n display: inline-flex;\n align-items: center;\n gap: 5px;\n padding: 4px 8px;\n border: 1px solid var(--rule-strong);\n background: transparent;\n color: var(--ink-2);\n font-family: var(--font-mono);\n font-size: 8.5px;\n letter-spacing: 0.06em;\n cursor: pointer;\n transition: color 0.2s, border-color 0.2s, background 0.2s;\n}\n.weave-toggle:hover { color: var(--accent); border-color: var(--accent); background: rgba(178, 58, 38, 0.04); }\n.weave-toggle .icon { width: 11px; height: 11px; transition: transform 0.2s var(--ease); }\n.plate-weave:not(.is-collapsed) .weave-toggle .icon { transform: rotate(180deg); }\n.lane-readout { font-size: 19px; }\n.lane-label { font-size: 12px; height: 24px; gap: 6px; }\n.lane-labels { gap: 4px; padding-top: 26px; }\n.lane-row { height: 24px; }\n.lane-rows { gap: 4px; padding-top: 5px; }\n.lane-ruler { height: 22px; }\n.ruler-tick { font-size: 9px; }\n.seg-label { font-size: 9px; line-height: 19px; }\n.blocker-band { top: 22px; }\n.playhead { top: 18px; }\n.plate-foot { font-size: 8px; }\n.insp-name { font-size: 18px; }\n.insp-name .role { font-size: 8.5px; }\n.insp-sub { font-size: 9.5px; }\n.insp-status { font-size: 9.5px; padding: 3px 8px; }\n.insp-stats { gap: 16px; margin-top: 10px; padding-top: 7px; }\n.insp-stat b { font-size: 21px; }\n.insp-stat span { font-size: 9px; }\n.insp-label { font-size: 9px; }\n.work-title { font-size: 13px; }\n.work-meta { font-size: 9.5px; }\n.wait-card { font-size: 11.5px; }\n.insp-event { font-size: 11.5px; }\n.insp-event .t { font-size: 10px; }\n.artifact { font-size: 11px; }\n.artifact .t { font-size: 9px; }\n.filter-chip { font-size: 9.5px; }\n.feed-item { grid-template-columns: 38px 13px minmax(0, 1fr); padding: 8px 1px; }\n.feed-time { font-size: 11px; }\n.feed-text { font-size: 12px; line-height: 1.65; }\n.feed-text b { font-size: 12.5px; }\n.feed-tag { font-size: 8.5px; }\n.feed-empty { font-size: 11px; }\n.footer { font-size: 8px; height: 26px; }\nkbd { font-size: 8px; }\n.tip-toast { font-size: 11.5px; }\n\n/* --- 折叠织带:一根进度条 ------------------------------------------- */\n\n.weave-body { display: block; }\n.weave-compact { display: none; padding: 9px 0 2px; }\n.plate-weave.is-collapsed .weave-body { display: none; }\n.plate-weave.is-collapsed .weave-compact { display: block; }\n.plate-weave.is-collapsed .plate-head { border-bottom-color: var(--ink); }\n.wc-top { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; }\n.wc-caption { font-family: var(--font-mono); font-size: 8px; letter-spacing: 0.14em; color: var(--ink-3); text-transform: uppercase; }\n.wc-time { margin-left: auto; font-family: var(--font-display); font-size: 19px; color: var(--ink); }\n.wc-token { font-family: var(--font-mono); font-size: 9px; color: var(--accent); }\n.wc-stat { font-family: var(--font-mono); font-size: 9px; color: var(--ink-3); }\n.wc-track {\n position: relative;\n height: 12px;\n border: 1px solid var(--rule-strong);\n background: var(--paper-light);\n cursor: pointer;\n}\n.wc-track:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }\n.wc-fill {\n position: absolute;\n left: 0; top: 0; bottom: 0;\n width: 0;\n background: linear-gradient(90deg, rgba(178, 58, 38, 0.46), rgba(178, 58, 38, 0.2));\n border-right: 1px solid var(--accent);\n}\n.wc-ticks { position: absolute; inset: 0; pointer-events: none; }\n.wc-ticks i { position: absolute; top: 0; bottom: 0; width: 2px; opacity: 0.55; background: var(--c, var(--ink-3)); }\n.wc-head {\n position: absolute;\n top: -4px; bottom: -4px;\n width: 2px;\n background: var(--accent);\n transform: translateX(-1px);\n pointer-events: none;\n}\n.wc-head::before {\n content: \"\";\n position: absolute;\n top: -3px; left: 50%;\n width: 7px; height: 7px;\n background: var(--accent);\n transform: translateX(-50%) rotate(45deg);\n}\n.wc-edge { position: absolute; inset: 0; pointer-events: none; }\n.wc-edge-span {\n position: absolute;\n top: 0; bottom: 0;\n background: rgba(178, 58, 38, 0.14);\n border-left: 1px dashed var(--accent);\n border-right: 1px dashed var(--accent);\n}\n.wc-edge-mark {\n position: absolute;\n top: -3px; bottom: -3px;\n width: 2px;\n background: var(--accent);\n}\n.plate-weave.is-edge-focus .wc-track { border-color: var(--accent); box-shadow: 0 0 0 1px rgba(178, 58, 38, 0.25); }\n.plate-weave.is-edge-focus .plate-head { border-bottom-color: var(--accent); }\n\n/* 丝线悬停联动 */\n.edge-hit { fill: none; stroke: transparent; stroke-width: 16; pointer-events: stroke; cursor: pointer; }\n.stage.has-edge-hover .edge { opacity: 0.32; }\n.edge.is-edge-hover { stroke: var(--accent) !important; stroke-width: 2.2 !important; opacity: 1 !important; }\n.lane-edge-marks { position: absolute; top: 22px; bottom: 0; left: 0; right: 0; z-index: 2; pointer-events: none; }\n.lane-edge-mark { position: absolute; top: 0; bottom: 0; width: 1px; border-left: 1px dashed rgba(178, 58, 38, 0.6); }\n.node.is-edge-hover .node-name { color: var(--accent); }\n.node.is-edge-hover .node-btn {\n outline: 2px solid var(--accent);\n outline-offset: 4px;\n box-shadow:\n 0 0 0 2px var(--paper-light),\n 0 0 0 3px var(--accent),\n inset 0 0 0 3px var(--paper-light),\n inset 0 0 0 4px color-mix(in srgb, var(--c) 55%, transparent);\n}\n.lane-label.is-edge-hover { color: var(--accent); font-weight: 600; }\n.lane-label.is-agent-selected { color: var(--accent); font-weight: 600; }\n.lane-label.is-weave-dim { opacity: 0.32; }\n.lane-link.is-edge-hover { stroke: var(--accent); stroke-width: 1.8; opacity: 1; }\n\n/* 工作段高亮:丝线悬停 / 选中智能体 / 聚焦 */\n.seg.is-edge-hover {\n border-left-color: var(--accent) !important;\n background: color-mix(in srgb, var(--c) 46%, transparent) !important;\n box-shadow:\n inset 0 0 0 1px var(--accent),\n inset 0 -2px 0 var(--accent),\n 0 0 10px -2px rgba(178, 58, 38, 0.55);\n opacity: 1 !important;\n filter: saturate(1.1);\n}\n.seg.is-selected {\n border-left-color: var(--accent);\n background: color-mix(in srgb, var(--c) 34%, transparent);\n box-shadow:\n inset 0 0 0 1px rgba(178, 58, 38, 0.6),\n inset 0 -2px 0 var(--accent);\n opacity: 1;\n}\n.seg.is-weave-dim { opacity: 0.18; }\n.plate-weave.is-edge-focus .seg:not(.is-edge-hover) { opacity: 0.26; }\n.plate-weave.is-edge-focus .lane-label:not(.is-edge-hover) { opacity: 0.45; }\n.plate-weave.is-edge-focus .lane-link:not(.is-edge-hover) { opacity: 0.25; }\n.plate-weave.is-edge-focus .lane-link-dot:not(.is-edge-hover) { opacity: 0.25; }\n.wc-selected { position: absolute; inset: 0; pointer-events: none; }\n.wc-selected-seg { position: absolute; bottom: 0; height: 2px; background: var(--c); opacity: 0.9; }\n.wc-edge-work { position: absolute; bottom: 0; height: 2.5px; background: var(--c); opacity: 0.95; }\n.lane-link-dot.is-edge-hover { fill: var(--accent); }\n\n/* --- 窄屏 / 矮屏:删掉装饰性小字,缩小栏宽 --------------------------- */\n\n@media (max-width: 1360px), (max-height: 860px) {\n .brand-sub,\n .docket-label,\n .run-short,\n .sect-en,\n .plate-title span,\n .plate-hint,\n .now-hint,\n .plate-foot,\n .footer-keys,\n .legend,\n .insp-name .role { display: none; }\n .app { padding: 0 20px; }\n .masthead { padding: 10px 0 7px; }\n .headline { padding: 9px 0 10px; }\n #goalTitle { margin: 6px 0 6px; font-size: clamp(22px, 2.2vw, 29px); }\n .headline-meta { font-size: 8.5px; }\n .ledger { margin-bottom: 12px; }\n .ledger-progress { padding: 2px 0 8px; }\n .pct-num { font-size: 48px; }\n .goal-ring { width: 64px; height: 64px; }\n .ledger-row { padding: 5px 0; }\n .ledger-row dt { font-size: 11.5px; }\n .ledger-row dd { font-size: 18px; }\n .task-item { padding: 4px 0 3px; }\n .task-title { font-size: 12.5px; }\n .task-sub { font-size: 9px; }\n .center { gap: 12px; padding-top: 12px; }\n .plate-head { padding-bottom: 5px; }\n .plate-title h2 { font-size: 15px; }\n .node-name { font-size: 13.5px; }\n .node-activity { font-size: 10.8px; height: 16px; }\n .dossier { max-height: 55%; }\n .footer { display: none; }\n .workspace { --left-w: 236px; --right-w: 288px; }\n .rail-left { padding-right: 14px; }\n .center { padding-left: 14px; padding-right: 14px; }\n .rail-right { padding-left: 14px; }\n}\n\n/* 矮屏 + 展开织带时,压矮展开态,避免主图被挤没 */\n@media (max-height: 880px) {\n .plate-weave:not(.is-collapsed) .lane-row { height: 20px; }\n .plate-weave:not(.is-collapsed) .lane-label { height: 20px; }\n .plate-weave:not(.is-collapsed) .lane-labels { padding-top: 24px; gap: 3px; }\n .plate-weave:not(.is-collapsed) .lane-rows { gap: 3px; padding-top: 4px; }\n .plate-weave:not(.is-collapsed) .seg-label { line-height: 16px; font-size: 8.5px; }\n .plate-weave:not(.is-collapsed) .lane-ruler { height: 20px; }\n .plate-weave:not(.is-collapsed) .blocker-band { top: 20px; }\n .plate-weave:not(.is-collapsed) .playhead { top: 16px; }\n .plate-weave:not(.is-collapsed) .wc-caption { display: none; }\n .tip-toast { bottom: 24px; }\n}\n\n/* 桌面三栏在 1180 以下改为纵向阅读流,隐藏拖拽柄 */\n.dossier { max-height: 63%; }\n@media (min-width: 1181px) and (max-height: 900px) {\n .insp-section--recent { display: none; }\n}\n.ledger-list { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }\n.ledger-row { padding: 6px 0; }\n.ledger-row:nth-child(odd) { border-right: 1px dotted var(--rule); padding-right: 12px; }\n.ledger-row:nth-child(even) { padding-left: 2px; }\n.ledger-row dd { text-align: right; }\n\n@media (max-width: 1180px) {\n .workspace { display: flex; flex-direction: column; }\n .splitter { display: none; }\n .rail-left, .center, .rail-right { padding-left: 0; padding-right: 0; }\n .center { order: 1; padding-top: 14px; }\n .rail-left { order: 2; border-top: 1px solid var(--rule); padding-top: 20px; }\n .rail-right { order: 3; border-top: 1px solid var(--rule); padding-top: 20px; }\n .plate-graph { min-height: 430px; }\n .dossier { max-height: none; }\n .index { min-height: 0; }\n}\n\n@media (max-width: 820px) {\n .rail-left, .rail-right { display: flex; flex-direction: column; gap: 20px; }\n .index { max-height: 360px; }\n .notes { min-height: 380px; }\n .headline-elapsed { margin-left: 0; flex-basis: 100%; }\n #goalTitle { font-size: 24px; }\n .weave-toggle span { display: none; }\n .wc-caption { display: none; }\n}\n\n@media (max-width: 620px) {\n .brand-name { font-size: 22px; }\n .clock { display: none; }\n .headline { padding: 8px 0 9px; }\n .stage { min-height: 400px; }\n .lanes { grid-template-columns: 62px minmax(0, 1fr); gap: 0 8px; }\n .seg-label { display: none; }\n .feed-item { grid-template-columns: 32px 12px minmax(0, 1fr); }\n .wc-top { flex-wrap: wrap; row-gap: 2px; }\n .wc-stat { margin-left: auto; }\n .tip-toast { right: 10px; bottom: 14px; }\n}\n\n@media (max-width: 430px) {\n .pct-num { font-size: 46px; }\n .goal-ring { width: 56px; height: 56px; }\n .stage { min-height: 380px; }\n .node { width: 108px; }\n .node-btn { width: 52px; height: 52px; }\n .node-btn::before { font-size: 22px; }\n .node-name { font-size: 12.5px; }\n .node-role { font-size: 8px; }\n .node-activity { display: none; }\n .speed { display: none; }\n}\n\n\n/* ---- v2/theme.css ---- */\n/* ==========================================================================\n Weave · Theme layer\n Paper 纸本 (default) / Night Silk 夜色\n Built on the same tokens as styles.css.\n ========================================================================== */\n\n/* --- sliding theme switch (click to toggle; knob slides) ------------------ */\n\n.theme-switch {\n display: inline-flex;\n align-items: center;\n gap: 7px;\n flex: none;\n padding: 0;\n border: 0;\n background: transparent;\n color: var(--ink-3);\n cursor: pointer;\n}\n.theme-rail {\n position: relative;\n width: 56px;\n height: 28px;\n flex: none;\n overflow: hidden;\n border: 1px solid var(--rule-strong);\n background: var(--paper-light);\n transition: border-color 0.2s;\n}\n.theme-switch:hover .theme-rail { border-color: var(--accent); }\n.theme-thumb {\n position: absolute;\n z-index: 1;\n top: 2px;\n left: 2px;\n width: 22px;\n height: 22px;\n background: var(--accent);\n transition: transform 0.42s var(--ease);\n}\n[data-theme=\"dark\"] .theme-thumb { transform: translateX(28px); }\n.theme-icon {\n position: absolute;\n z-index: 2;\n top: 50%;\n width: 14px;\n height: 14px;\n transform: translateY(-50%);\n color: var(--ink-3);\n pointer-events: none;\n transition: color 0.2s;\n}\n.theme-icon .icon { width: 14px; height: 14px; stroke-width: 1.7; }\n.theme-sun { left: 5px; }\n.theme-moon { right: 5px; }\n[data-theme=\"light\"] .theme-sun { color: var(--paper-light); }\n[data-theme=\"dark\"] .theme-moon { color: var(--paper-light); }\n\n/* --- theme transition timing ---------------------------------------------\n Chromium/Edge use a real cross-fade via the View Transitions API.\n Other browsers get a colour/border/shadow cross-fade for the same window. */\n\n::view-transition-old(root),\n::view-transition-new(root) {\n animation: none;\n mix-blend-mode: normal;\n}\n::view-transition-old(root) { opacity: 1; }\n::view-transition-new(root) {\n animation: theme-dissolve 1000ms cubic-bezier(0.33, 1, 0.68, 1) both;\n}\n::view-transition-group(root) { animation-duration: 1000ms; }\n@keyframes theme-dissolve {\n from { opacity: 0; }\n to { opacity: 1; }\n}\nhtml.theme-transition,\nhtml.theme-transition * {\n transition-property: color, background-color, border-color, box-shadow, fill, stroke !important;\n transition-duration: 1000ms !important;\n transition-timing-function: cubic-bezier(0.33, 1, 0.68, 1) !important;\n}\nhtml.theme-transition .theme-thumb {\n transition-property: transform, background-color !important;\n transition-duration: 420ms !important;\n}\n@media (prefers-reduced-motion: reduce) {\n ::view-transition-old(root),\n ::view-transition-new(root),\n ::view-transition-group(root) { animation-duration: 1ms !important; }\n html.theme-transition,\n html.theme-transition * { transition-duration: 1ms !important; }\n ::view-transition-new(root) { animation-duration: 1ms !important; }\n}\n\n/* --- Night Silk tokens ---------------------------------------------------- */\n\n[data-theme=\"light\"] { color-scheme: light; }\n\n[data-theme=\"dark\"] {\n color-scheme: dark;\n --paper: #14110d;\n --paper-2: #191510;\n --paper-3: #221c16;\n --paper-light: #1e1914;\n\n --ink: #eae1d1;\n --ink-2: #c4b7a3;\n --ink-3: #938672;\n\n --rule: rgba(234, 225, 209, 0.16);\n --rule-soft: rgba(234, 225, 209, 0.09);\n --rule-strong: rgba(234, 225, 209, 0.3);\n\n --accent: #df7359;\n --accent-deep: #f0937a;\n --accent-wash: rgba(223, 115, 89, 0.12);\n\n --olive: #c0ce8f;\n --indigo: #93b7d0;\n --ochre: #d8b36f;\n --teal: #74c0c0;\n --plum: #c194b2;\n --sienna: #d28f63;\n\n --sky: #74c0c0;\n --amber: #d8b36f;\n --lime: #b9cb87;\n --mint: #a9c59b;\n --violet: #c194b2;\n --rose: #e08a76;\n}\n\n[data-theme=\"dark\"] body {\n background:\n radial-gradient(1200px 900px at 50% 34%, rgba(239, 227, 205, 0.035), transparent 72%),\n radial-gradient(900px 700px at 90% 108%, rgba(223, 115, 89, 0.035), transparent 60%),\n var(--paper);\n}\n[data-theme=\"dark\"] body::before {\n mix-blend-mode: screen;\n opacity: 0.26;\n}\n[data-theme=\"dark\"] ::selection {\n background: rgba(223, 115, 89, 0.32);\n color: var(--ink);\n}\n[data-theme=\"dark\"] * {\n scrollbar-color: rgba(234, 225, 209, 0.24) transparent;\n}\n[data-theme=\"dark\"] ::-webkit-scrollbar-thumb {\n background: rgba(234, 225, 209, 0.24);\n}\n\n/* small warm-glass washes that were hardcoded in the paper theme */\n[data-theme=\"dark\"] .stamp--demo,\n[data-theme=\"dark\"] .icon-btn:hover,\n[data-theme=\"dark\"] .feed-item.t-alert,\n[data-theme=\"dark\"] .switch[aria-pressed=\"true\"] .switch-track {\n background: rgba(223, 115, 89, 0.09);\n}\n[data-theme=\"dark\"] .task-item:hover { background: rgba(234, 225, 209, 0.045); }\n[data-theme=\"dark\"] .task-item.is-selected { background: rgba(234, 225, 209, 0.065); }\n[data-theme=\"dark\"] .feed-item:hover { background: rgba(234, 225, 209, 0.05); }\n\n/* --- stage / loom -------------------------------------------------------- */\n\n[data-theme=\"dark\"] .stage {\n background:\n repeating-linear-gradient(0deg, transparent 0 47px, rgba(234, 225, 209, 0.045) 47px 48px),\n repeating-linear-gradient(90deg, transparent 0 47px, rgba(234, 225, 209, 0.045) 47px 48px),\n var(--paper-light);\n}\n[data-theme=\"dark\"] .stage::before { border-color: rgba(234, 225, 209, 0.09); }\n[data-theme=\"dark\"] .stage::after { color: rgba(234, 225, 209, 0.042); }\n[data-theme=\"dark\"] .stage-grid {\n background-image: radial-gradient(circle, rgba(234, 225, 209, 0.17) 0.7px, transparent 0.8px);\n}\n[data-theme=\"dark\"] .orbits span { border-color: rgba(234, 225, 209, 0.13); }\n[data-theme=\"dark\"] .orbits span:nth-child(2) { border-color: rgba(234, 225, 209, 0.07); }\n[data-theme=\"dark\"] .edge { stroke: rgba(234, 225, 209, 0.25); }\n[data-theme=\"dark\"] .edge.is-link { stroke: rgba(234, 225, 209, 0.3); }\n[data-theme=\"dark\"] .edge.is-connected { stroke: rgba(234, 225, 209, 0.45); }\n[data-theme=\"dark\"] .msg-core { stroke: var(--paper-light); }\n[data-theme=\"dark\"] .stage-now {\n box-shadow: 0 -12px 20px -16px rgba(0, 0, 0, 0.7);\n}\n\n/* --- agents: dark silk is lifted toward warm starlight ------------------ */\n\n[data-theme=\"dark\"] .node {\n --c-ink: color-mix(in srgb, var(--c) 55%, #f0e5d2);\n}\n[data-theme=\"dark\"] .node-btn {\n border-color: var(--c-ink);\n color: var(--c-ink);\n background: var(--paper-light);\n box-shadow:\n inset 0 0 0 3px var(--paper-light),\n inset 0 0 0 4px color-mix(in srgb, var(--c-ink) 50%, transparent);\n}\n[data-theme=\"dark\"] .node-btn::before { color: var(--c-ink); }\n[data-theme=\"dark\"] .node-btn:hover { background: #2a231b; }\n[data-theme=\"dark\"] .node-ring .ring-track { stroke: rgba(234, 225, 209, 0.12); }\n[data-theme=\"dark\"] .node-ring .ring-value { stroke: var(--c-ink); }\n[data-theme=\"dark\"] .node.is-selected .node-btn,\n[data-theme=\"dark\"] .node.is-edge-hover .node-btn {\n box-shadow:\n 0 0 0 2px var(--paper-light),\n 0 0 0 3px var(--accent),\n inset 0 0 0 3px var(--paper-light),\n inset 0 0 0 4px color-mix(in srgb, var(--c-ink) 50%, transparent);\n}\n[data-theme=\"dark\"] .node.is-edge-hover .node-name { color: var(--accent); }\n\n/* --- weave lanes / segments --------------------------------------------- */\n\n[data-theme=\"dark\"] .lane-row { border-bottom-color: rgba(234, 225, 209, 0.1); }\n[data-theme=\"dark\"] .lane-label { --c-ink: color-mix(in srgb, var(--c) 55%, #f0e5d2); }\n[data-theme=\"dark\"] .lane-dot { background: var(--c-ink); }\n[data-theme=\"dark\"] .seg {\n --c-ink: color-mix(in srgb, var(--c) 55%, #f0e5d2);\n border-left-color: var(--c-ink);\n background: color-mix(in srgb, var(--c-ink) 17%, transparent);\n}\n[data-theme=\"dark\"] .seg-fill {\n background: color-mix(in srgb, var(--c-ink) 32%, transparent);\n}\n[data-theme=\"dark\"] .seg.is-running {\n border-left-color: var(--accent);\n background: color-mix(in srgb, var(--c-ink) 22%, transparent);\n}\n[data-theme=\"dark\"] .seg.is-running .seg-fill {\n background-image: repeating-linear-gradient(45deg, transparent 0 3px, color-mix(in srgb, var(--c-ink) 28%, transparent) 3px 4px);\n}\n[data-theme=\"dark\"] .seg.is-selected {\n border-left-color: var(--accent);\n background: color-mix(in srgb, var(--c-ink) 30%, transparent);\n box-shadow:\n inset 0 0 0 1px rgba(223, 115, 89, 0.55),\n inset 0 -2px 0 var(--accent);\n}\n[data-theme=\"dark\"] .seg.is-edge-hover {\n border-left-color: var(--accent) !important;\n background: color-mix(in srgb, var(--c-ink) 45%, transparent) !important;\n box-shadow:\n inset 0 0 0 1px var(--accent),\n inset 0 -2px 0 var(--accent),\n 0 0 12px -2px rgba(223, 115, 89, 0.62);\n}\n[data-theme=\"dark\"] .seg.is-weave-dim { opacity: 0.18; }\n[data-theme=\"dark\"] .lane-link { stroke: rgba(234, 225, 209, 0.18); }\n[data-theme=\"dark\"] .lane-link-dot { fill: rgba(234, 225, 209, 0.38); }\n[data-theme=\"dark\"] .lane-edge-mark { border-left-color: rgba(223, 115, 89, 0.72); }\n[data-theme=\"dark\"] .blocker-band {\n background: repeating-linear-gradient(45deg, rgba(223, 115, 89, 0.08) 0 4px, transparent 4px 8px);\n border-left-color: rgba(223, 115, 89, 0.62);\n border-right-color: rgba(223, 115, 89, 0.38);\n}\n[data-theme=\"dark\"] .blocker-label {\n background: var(--paper-light);\n border-color: rgba(223, 115, 89, 0.45);\n color: var(--accent-deep);\n}\n[data-theme=\"dark\"] .lane-blocker-band,\n[data-theme=\"dark\"] .wc-blocker-band {\n border-color: rgba(223, 115, 89, 0.55);\n background: rgba(223, 115, 89, 0.08);\n}\n[data-theme=\"dark\"] .lane-blocker-fill,\n[data-theme=\"dark\"] .wc-blocker-fill { background: rgba(223, 115, 89, 0.22); }\n\n/* compact weave */\n[data-theme=\"dark\"] .wc-track { background: var(--paper-light); }\n[data-theme=\"dark\"] .wc-fill {\n background: linear-gradient(90deg, rgba(223, 115, 89, 0.55), rgba(223, 115, 89, 0.22));\n}\n[data-theme=\"dark\"] .wc-ticks i,\n[data-theme=\"dark\"] .wc-selected-seg,\n[data-theme=\"dark\"] .wc-edge-work {\n background: color-mix(in srgb, var(--c) 55%, #f0e5d2);\n}\n[data-theme=\"dark\"] .wc-edge-span { background: rgba(223, 115, 89, 0.16); }\n\n/* --- tasks / ledger ------------------------------------------------------ */\n\n[data-theme=\"dark\"] .ring-track { stroke: rgba(234, 225, 209, 0.12); }\n[data-theme=\"dark\"] .task-owner { color: color-mix(in srgb, var(--agent-color) 55%, #f0e5d2); }\n[data-theme=\"dark\"] .task-owner .dot { background: color-mix(in srgb, var(--agent-color) 55%, #f0e5d2); }\n[data-theme=\"dark\"] .task-progress,\n[data-theme=\"dark\"] .progress,\n[data-theme=\"dark\"] .dt-bar { background: rgba(234, 225, 209, 0.1); }\n[data-theme=\"dark\"] .task-progress i { background: color-mix(in srgb, var(--agent-color) 55%, #f0e5d2); }\n\n/* --- inspector ----------------------------------------------------------- */\n\n[data-theme=\"dark\"] .inspector { --c-ink: color-mix(in srgb, var(--c) 55%, #f0e5d2); }\n[data-theme=\"dark\"] .insp-avatar {\n border-color: var(--c-ink);\n background: var(--paper-light);\n color: var(--c-ink);\n box-shadow:\n inset 0 0 0 3px var(--paper-light),\n inset 0 0 0 4px color-mix(in srgb, var(--c-ink) 50%, transparent);\n}\n[data-theme=\"dark\"] .insp-avatar::before { color: var(--c-ink); }\n[data-theme=\"dark\"] .work-title .dot { background: var(--c-ink); }\n[data-theme=\"dark\"] .progress-fill { background: var(--c-ink); }\n[data-theme=\"dark\"] .work-card { background: var(--paper-light); }\n\n/* --- feed / notes -------------------------------------------------------- */\n\n[data-theme=\"dark\"] .feed-text b.actor-name,\n[data-theme=\"dark\"] .now-text b.actor-name {\n color: color-mix(in srgb, var(--actor, var(--ink)) 55%, #f0e5d2) !important;\n}\n[data-theme=\"dark\"] kbd { background: rgba(234, 225, 209, 0.08); }\n\n/* --- dialogs / popovers -------------------------------------------------- */\n\n[data-theme=\"dark\"] .dialog { box-shadow: 10px 10px 0 rgba(0, 0, 0, 0.46); }\n[data-theme=\"dark\"] .dialog::backdrop { background: rgba(0, 0, 0, 0.64); }\n[data-theme=\"dark\"] .blocker-pop { box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.46); }\n\n/* --- small screens ------------------------------------------------------- */\n\n@media (max-width: 820px) {\n .theme-switch { gap: 0; }\n}\n\n/* ---- v2/live.css ---- */\n/* ==========================================================================\n LIVE / REPLAY — simulated livestream timeshift (Edition 02.8)\n ========================================================================== */\n\n.mode-switch {\n display: inline-flex;\n align-items: center;\n height: 24px;\n flex: none;\n border: 1px solid var(--rule-strong);\n background: var(--paper-light);\n}\n.mode-btn {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: 4px;\n height: 22px;\n padding: 0 7px;\n border: 0;\n background: transparent;\n color: var(--ink-3);\n font-family: var(--font-mono);\n font-size: 9px;\n letter-spacing: 0.04em;\n cursor: pointer;\n transition: color 0.18s, background 0.18s;\n}\n.mode-btn + .mode-btn { border-left: 1px solid var(--rule); }\n.mode-btn:hover { color: var(--ink); }\n.mode-btn[aria-pressed=\"true\"] { color: var(--paper-light); background: var(--ink); }\n.mode-btn--live[aria-pressed=\"true\"] { color: var(--paper-light); background: var(--accent); }\n\n.live-dot {\n width: 5px;\n height: 5px;\n flex: none;\n border-radius: 50%;\n background: var(--accent);\n}\n.mode-btn--live[aria-pressed=\"true\"] .live-dot { background: var(--paper-light); }\n.app.is-live.is-live-following .mode-btn--live .live-dot { animation: dotPulse 1.8s var(--ease) infinite; }\n\n.live-jump {\n height: 24px;\n padding: 0 8px;\n border: 1px solid var(--accent);\n background: transparent;\n color: var(--accent);\n font-family: var(--font-mono);\n font-size: 8.5px;\n letter-spacing: 0.03em;\n cursor: pointer;\n white-space: nowrap;\n}\n.live-jump:hover { background: var(--accent); color: var(--paper-light); }\n.live-jump[hidden] { display: none; }\n\n.app.is-live .speed { opacity: 0.4; pointer-events: none; }\n\n/* the live edge is only visible when the playhead is behind it */\n.live-edge {\n position: absolute;\n z-index: 4;\n top: 20px;\n bottom: 0;\n width: 1px;\n background: var(--accent);\n opacity: 0.85;\n pointer-events: none;\n}\n.live-edge::before {\n content: \"\";\n position: absolute;\n top: -3px;\n left: 50%;\n width: 6px;\n height: 6px;\n border-radius: 50%;\n background: var(--accent);\n transform: translateX(-50%);\n box-shadow: 0 0 0 2px var(--paper-light);\n}\n.live-edge[hidden] { display: none; }\n.live-edge--compact { top: -4px; bottom: -4px; }\n.live-edge--compact::before { width: 5px; height: 5px; }\n\n@media (max-width: 760px) {\n .plate-weave .lane-readout { display: none; }\n .mode-btn { padding: 0 6px; }\n .live-jump { padding: 0 6px; font-size: 7.5px; }\n}\n\n/* ---- weave-embed/src/embed.css ---- */\n/* ==========================================================================\n * weave-embed/src/embed.css\n * 嵌入运行时专用覆盖层(build.mjs 内联到 dist/weave.html 的 v2 样式之后)。\n * 只在 iframe 运行时内生效:不修改 v2/ 原型。\n * ========================================================================== */\n\n/* --- 启动占位:首次 weave:init 之前只显示中性占位 ----------------------- */\nbody.weave-booting #app,\nbody.weave-booting #helpDialog,\nbody.weave-booting #tipToast,\nbody.weave-booting #blockerPop {\n visibility: hidden !important;\n}\nbody.weave-booting .weave-placeholder { display: flex; }\n\n.weave-placeholder {\n position: fixed;\n inset: 0;\n z-index: 9999;\n display: none;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n gap: 9px;\n background: var(--paper, #f1ead9);\n color: var(--ink-3, #6b6150);\n font-family: var(--font-mono, monospace);\n letter-spacing: 0.12em;\n user-select: none;\n}\n.weave-placeholder .wp-mark {\n width: 34px;\n height: 34px;\n border: 1px solid var(--rule-strong, rgba(28, 25, 20, 0.3));\n transform: rotate(45deg);\n position: relative;\n}\n.weave-placeholder .wp-mark::after {\n content: \"\";\n position: absolute;\n inset: 10px;\n border: 1px solid var(--accent, #b23a26);\n transform: rotate(45deg);\n}\n.weave-placeholder .wp-title {\n font-family: var(--font-display, Georgia, serif);\n font-size: 20px;\n letter-spacing: 0.18em;\n color: var(--ink, #1c1914);\n}\n.weave-placeholder .wp-sub { font-size: 11px; }\n@media (prefers-reduced-motion: no-preference) {\n .weave-placeholder .wp-mark::after { animation: weaveWpPulse 2.4s ease-in-out infinite; }\n @keyframes weaveWpPulse {\n 0%, 100% { opacity: 0.35; transform: rotate(45deg) scale(0.92); }\n 50% { opacity: 1; transform: rotate(45deg) scale(1.06); }\n }\n}\n\n/* --- 嵌入模式:隐藏原型自己的主题 / 直播开关与演示标识 ------------------ */\nbody.weave-embed .theme-switch,\nbody.weave-embed .mode-switch,\nbody.weave-embed .live-jump,\nbody.weave-embed .stamp--demo,\nbody.weave-embed .footer-left {\n display: none !important;\n}\n/* 主题由父视图控制;开关即便被脚本聚焦也不再响应 */\nbody.weave-theme-managed .theme-switch {\n pointer-events: none !important;\n}\n\n/* --- 直播跟随状态条(由 live-adapter 创建) ----------------------------- */\n.weave-livebar {\n position: fixed;\n right: 12px;\n bottom: 9px;\n z-index: 60;\n display: flex;\n align-items: center;\n gap: 6px;\n font-family: var(--font-mono, monospace);\n font-size: 10px;\n letter-spacing: 0.04em;\n}\n.weave-livebar[hidden] { display: none !important; }\n.weave-livebadge {\n display: inline-flex;\n align-items: center;\n gap: 5px;\n padding: 4px 7px;\n border: 1px solid var(--rule-strong, rgba(28, 25, 20, 0.3));\n background: var(--paper-light, #f7f2e7);\n color: var(--ink-3, #6b6150);\n}\n.weave-livedot {\n width: 6px;\n height: 6px;\n border-radius: 50%;\n background: var(--accent, #b23a26);\n}\n.weave-livebar.is-behind .weave-livebadge { color: var(--accent, #b23a26); border-color: var(--accent, #b23a26); }\n.weave-livebar:not(.is-behind) .weave-livedot { animation: weaveLivePulse 1.8s var(--ease, ease) infinite; }\n@keyframes weaveLivePulse {\n 0%, 100% { opacity: 1; transform: scale(1); }\n 50% { opacity: 0.35; transform: scale(0.72); }\n}\n.weave-livejump {\n height: 24px;\n padding: 0 8px;\n border: 1px solid var(--accent, #b23a26);\n background: var(--paper-light, #f7f2e7);\n color: var(--accent, #b23a26);\n font-family: inherit;\n font-size: 10px;\n letter-spacing: 0.04em;\n cursor: pointer;\n}\n.weave-livejump:hover { background: var(--accent, #b23a26); color: var(--paper-light, #f7f2e7); }\n.weave-livejump[hidden] { display: none !important; }\n\n/* --- 已释放态 ------------------------------------------------------------ */\nbody.weave-disposed #app { visibility: hidden !important; }\n\n/* --- 泳道标签:长名称单行省略,避免换行压到相邻泳道 ------------------- */\nbody.weave-embed .lane-label { min-width: 0; }\nbody.weave-embed .lane-label > span:last-child {\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n/* --- 占位页:读取本地历史数据按钮 -------------------------------------- */\n.weave-placeholder .wp-history {\n margin-top: 12px;\n padding: 7px 16px;\n border: 1px solid var(--accent, #b23a26);\n border-radius: 2px;\n background: transparent;\n color: var(--accent, #b23a26);\n font-family: var(--font-mono, monospace);\n font-size: 11px;\n letter-spacing: 0.08em;\n cursor: pointer;\n transition: background-color 0.15s, color 0.15s;\n}\n.weave-placeholder .wp-history:hover:not(:disabled) {\n background: var(--accent, #b23a26);\n color: var(--paper, #f1ead9);\n}\n.weave-placeholder .wp-history:disabled { opacity: 0.45; cursor: default; }\n.weave-placeholder .wp-history-status {\n max-width: 320px;\n font-size: 10.5px;\n letter-spacing: 0.04em;\n text-align: center;\n color: var(--ink-3, #6b6150);\n}\n.weave-placeholder .wp-history-status[hidden] { display: none; }\n\n\n/* --- 嵌入模式:禁用原型左右栏拖拽(保留 10px 网格轨道,避免布局错位) --- */\nbody.weave-embed .splitter { pointer-events: none !important; cursor: default !important; }\nbody.weave-embed .splitter::before { display: none !important; }\nbody.weave-embed .splitter:hover::after { width: 1px !important; background: var(--rule) !important; }\n\n\n/* --- 选中朱环定位:is-tight 规则原本只适配 5–7 位智能体,会覆盖高密度档 |\n .agents-many .stage.is-tight .node.is-selected::after { top: 29px; }\n 8+ 位(crowded/swarm/hive)按钮更小,需把环重新对中,否则选中环下移错位。 */\nbody.weave-embed .agents-many .stage.is-tight .node.is-selected::after { top: 28px; width: 70px; height: 70px; }\nbody.weave-embed .agents-crowded .stage.is-tight .node.is-selected::after { top: 24px; width: 60px; height: 60px; }\nbody.weave-embed .agents-swarm .stage.is-tight .node.is-selected::after { top: 19px; width: 46px; height: 46px; }\nbody.weave-embed .agents-hive .stage.is-tight .node.is-selected::after { top: 16px; width: 40px; height: 40px; }\n\n\n/* --- 高密度节点:徽标随按钮缩小,避免盖住印章;名字最多两行 ------------------ */\nbody.weave-embed .agents-crowded .stage .node-badge { width: 13px; height: 13px; right: -3px; top: -3px; }\nbody.weave-embed .agents-swarm .stage .node-badge { width: 11px; height: 11px; right: -3px; top: -3px; }\nbody.weave-embed .agents-hive .stage .node-badge { width: 10px; height: 10px; right: -2px; top: -2px; }\nbody.weave-embed .agents-crowded .stage .node-badge .icon,\nbody.weave-embed .agents-swarm .stage .node-badge .icon,\nbody.weave-embed .agents-hive .stage .node-badge .icon { width: 6px; height: 6px; }\nbody.weave-embed .agents-crowded .stage .node-name,\nbody.weave-embed .agents-swarm .stage .node-name,\nbody.weave-embed .agents-hive .stage .node-name {\n width: 100%;\n display: -webkit-box;\n -webkit-line-clamp: 2;\n -webkit-box-orient: vertical;\n overflow: hidden;\n overflow-wrap: anywhere;\n word-break: break-word;\n}\n\n\n/* --- 矮视口(DSH 停靠/分栏,如 932x353):一屏内完成主图 + 折叠织带 ---------- */\n@media (max-height: 560px) {\n body.weave-embed .app { height: 100dvh; min-height: 0; }\n body.weave-embed .headline { display: none; }\n body.weave-embed .workspace { flex: 1; min-height: 0; }\n body.weave-embed .center { flex: 1; min-height: 0; gap: 8px; padding: 8px 0 0; }\n body.weave-embed .plate-graph { flex: 1; min-height: 0; }\n body.weave-embed .plate-weave { margin-top: 0; }\n body.weave-embed .rail-left,\n body.weave-embed .rail-right { display: none; }\n body.weave-embed .footer,\n body.weave-embed .plate-foot { display: none; }\n}\n\n/* --- 嵌入态去掉与禁用能力冲突的提示/页脚 -------------------------------- */\nbody.weave-embed .tip-toast,\nbody.weave-embed .footer { display: none !important; }\n\n/* --- 选中朱环:按按钮尺寸留稳定间距,避免和进度环/光晕三环相撞 ----------- */\nbody.weave-embed .agents-many .stage .node.is-selected::after { top: 28px; width: 74px; height: 74px; }\nbody.weave-embed .agents-crowded .stage .node.is-selected::after { top: 24px; width: 66px; height: 66px; }\nbody.weave-embed .agents-swarm .stage .node.is-selected::after { top: 19px; width: 56px; height: 56px; }\nbody.weave-embed .agents-hive .stage .node.is-selected::after { top: 16px; width: 50px; height: 50px; }\nbody.weave-embed .agents-many .stage.is-tight .node.is-selected::after { top: 28px; width: 74px; height: 74px; }\nbody.weave-embed .agents-crowded .stage.is-tight .node.is-selected::after { top: 24px; width: 66px; height: 66px; }\nbody.weave-embed .agents-swarm .stage.is-tight .node.is-selected::after { top: 19px; width: 56px; height: 56px; }\nbody.weave-embed .agents-hive .stage.is-tight .node.is-selected::after { top: 16px; width: 50px; height: 50px; }\n\n/* --- 节点名字不向邻座渗出 ------------------------------------------------- */\nbody.weave-embed .stage .node-name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }\n\n\n/* --- 树状图:闲置子代理默认收起,+N 展开一层,− 收起 ---------------------- */\nbody.weave-embed .node.is-tree-hidden { display: none !important; }\nbody.weave-embed .node-toggle {\n position: absolute;\n z-index: 4;\n min-width: 15px;\n height: 15px;\n padding: 0 3px;\n border: 1px solid var(--rule-strong);\n border-radius: 8px;\n background: var(--paper-light);\n color: var(--ink-2);\n font: 9px/13px var(--font-mono);\n text-align: center;\n cursor: pointer;\n pointer-events: auto;\n transform: translateY(-50%);\n}\nbody.weave-embed .node-toggle:hover { color: var(--accent); border-color: var(--accent); }\nbody.weave-embed .node-toggle[hidden] { display: none !important; }\nbody.weave-embed .node-toggle { top: 34px; left: calc(50% + 44px); }\nbody.weave-embed .agents-many .node-toggle { top: 28px; left: calc(50% + 36px); }\nbody.weave-embed .agents-crowded .node-toggle { top: 24px; left: calc(50% + 32px); }\nbody.weave-embed .agents-swarm .node-toggle { top: 19px; left: calc(50% + 27px); }\nbody.weave-embed .agents-hive .node-toggle { top: 16px; left: calc(50% + 24px); }\n\n\n</style>\n</head>\n<body class=\"weave-booting\">\n<!-- [EMBED] 首次 weave:init 之前只显示中性占位 -->\n<div class=\"weave-placeholder\" id=\"weavePlaceholder\" role=\"status\" aria-live=\"polite\">\n <span class=\"wp-mark\" aria-hidden=\"true\"></span>\n <span class=\"wp-title\">Weave</span>\n <span class=\"wp-sub\">等待会话数据…</span>\n <button class=\"wp-history\" type=\"button\">读取本地历史数据</button>\n <span class=\"wp-history-status\" hidden></span>\n</div>\n<svg class=\"sprite\" aria-hidden=\"true\" focusable=\"false\">\n <defs>\n <symbol id=\"i-play\" viewBox=\"0 0 24 24\"><path d=\"M8 5.2v13.6a1 1 0 0 0 1.53.85l10.6-6.8a1 1 0 0 0 0-1.7L9.53 4.35A1 1 0 0 0 8 5.2z\" fill=\"currentColor\" stroke=\"none\"/></symbol>\n <symbol id=\"i-pause\" viewBox=\"0 0 24 24\"><rect x=\"6\" y=\"4.5\" width=\"4\" height=\"15\" rx=\"1.2\" fill=\"currentColor\" stroke=\"none\"/><rect x=\"14\" y=\"4.5\" width=\"4\" height=\"15\" rx=\"1.2\" fill=\"currentColor\" stroke=\"none\"/></symbol>\n <symbol id=\"i-restart\" viewBox=\"0 0 24 24\"><path d=\"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8\"/><path d=\"M3 3v5h5\"/></symbol>\n <symbol id=\"i-compass\" viewBox=\"0 0 24 24\"><circle cx=\"12\" cy=\"12\" r=\"9\"/><path d=\"m16.2 7.8-2.1 6.3-6.3 2.1 2.1-6.3 6.3-2.1z\"/></symbol>\n <symbol id=\"i-search\" viewBox=\"0 0 24 24\"><circle cx=\"11\" cy=\"11\" r=\"7.5\"/><path d=\"m20.5 20.5-4.2-4.2\"/></symbol>\n <symbol id=\"i-code\" viewBox=\"0 0 24 24\"><path d=\"m16 18 6-6-6-6\"/><path d=\"m8 6-6 6 6 6\"/></symbol>\n <symbol id=\"i-shield\" viewBox=\"0 0 24 24\"><path d=\"M12 22s8-3.5 8-10V5.5L12 2 4 5.5V12c0 6.5 8 10 8 10z\"/><path d=\"m9 12 2 2 4-4\"/></symbol>\n <symbol id=\"i-pen\" viewBox=\"0 0 24 24\"><path d=\"M12 20h9\"/><path d=\"M16.5 3.5a2.12 2.12 0 0 1 3 3L7.5 18.5 3 20l1.5-4.5z\"/></symbol>\n <symbol id=\"i-send\" viewBox=\"0 0 24 24\"><path d=\"m22 2-7 20-4-9-9-4 20-7z\"/><path d=\"M22 2 11 13\"/></symbol>\n <symbol id=\"i-message\" viewBox=\"0 0 24 24\"><path d=\"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z\"/></symbol>\n <symbol id=\"i-terminal\" viewBox=\"0 0 24 24\"><path d=\"m4 17 6-6-6-6\"/><path d=\"M12 19h8\"/></symbol>\n <symbol id=\"i-branch\" viewBox=\"0 0 24 24\"><circle cx=\"18\" cy=\"6\" r=\"3\"/><circle cx=\"6\" cy=\"18\" r=\"3\"/><path d=\"M6 15V3\"/><path d=\"M18 9a9 9 0 0 1-9 9\"/></symbol>\n <symbol id=\"i-file\" viewBox=\"0 0 24 24\"><path d=\"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z\"/><path d=\"M14 2v6h6\"/><path d=\"M8.5 13h7M8.5 17h4.5\"/></symbol>\n <symbol id=\"i-spark\" viewBox=\"0 0 24 24\"><path d=\"m12 3 1.9 5.1L19 10l-5.1 1.9L12 17l-1.9-5.1L5 10l5.1-1.9L12 3z\"/><path d=\"m19 15 .6 1.6 1.6.4-1.6.6L19 19.2l-.6-1.6-1.6-.6 1.6-.4z\"/></symbol>\n <symbol id=\"i-alert\" viewBox=\"0 0 24 24\"><path d=\"m10.3 3.9-8.4 14.5A1.9 1.9 0 0 0 3.6 21h16.8a1.9 1.9 0 0 0 1.7-2.6L13.7 3.9a1.9 1.9 0 0 0-3.4 0z\"/><path d=\"M12 9v4\"/><path d=\"M12 17h.01\"/></symbol>\n <symbol id=\"i-check\" viewBox=\"0 0 24 24\"><path d=\"m4.5 12.5 5 5 10-10.5\"/></symbol>\n <symbol id=\"i-clock\" viewBox=\"0 0 24 24\"><circle cx=\"12\" cy=\"12\" r=\"9\"/><path d=\"M12 7v5l3.5 2\"/></symbol>\n <symbol id=\"i-focus\" viewBox=\"0 0 24 24\"><circle cx=\"12\" cy=\"12\" r=\"3\"/><path d=\"M3 8V5a2 2 0 0 1 2-2h3\"/><path d=\"M16 3h3a2 2 0 0 1 2 2v3\"/><path d=\"M21 16v3a2 2 0 0 1-2 2h-3\"/><path d=\"M8 21H5a2 2 0 0 1-2-2v-3\"/></symbol>\n <symbol id=\"i-keyboard\" viewBox=\"0 0 24 24\"><rect x=\"2\" y=\"6\" width=\"20\" height=\"12\" rx=\"2\"/><path d=\"M6 10h.01M10 10h.01M14 10h.01M18 10h.01M6 14h.01M18 14h.01M9.5 14h5\"/></symbol>\n <symbol id=\"i-info\" viewBox=\"0 0 24 24\"><circle cx=\"12\" cy=\"12\" r=\"9\"/><path d=\"M12 11v5\"/><path d=\"M12 8h.01\"/></symbol>\n <symbol id=\"i-chevron-up\" viewBox=\"0 0 24 24\"><path d=\"m6 15 6-6 6 6\"/></symbol>\n <symbol id=\"i-arrow-right\" viewBox=\"0 0 24 24\"><path d=\"M4 12h15\"/><path d=\"m13 6 6 6-6 6\"/></symbol>\n <symbol id=\"i-users\" viewBox=\"0 0 24 24\"><path d=\"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2\"/><circle cx=\"9\" cy=\"7\" r=\"4\"/><path d=\"M22 21v-2a4 4 0 0 0-3-3.87\"/><path d=\"M16 3.13a4 4 0 0 1 0 7.75\"/></symbol>\n <symbol id=\"i-target\" viewBox=\"0 0 24 24\"><circle cx=\"12\" cy=\"12\" r=\"9\"/><circle cx=\"12\" cy=\"12\" r=\"4.5\"/><circle cx=\"12\" cy=\"12\" r=\"1\" fill=\"currentColor\" stroke=\"none\"/></symbol>\n <symbol id=\"i-activity\" viewBox=\"0 0 24 24\"><path d=\"M3 12h4l2.5-7 5 14 2.5-7h4\"/></symbol>\n <symbol id=\"i-x\" viewBox=\"0 0 24 24\"><path d=\"M6 6l12 12M18 6 6 18\"/></symbol>\n <symbol id=\"i-sun\" viewBox=\"0 0 24 24\"><circle cx=\"12\" cy=\"12\" r=\"4.2\"/><path d=\"M12 2.4v2.1M12 19.5v2.1M2.4 12h2.1M19.5 12h2.1M5.2 5.2l1.5 1.5M17.3 17.3l1.5 1.5M18.8 5.2l-1.5 1.5M6.7 17.3l-1.5 1.5\"/></symbol>\n <symbol id=\"i-moon\" viewBox=\"0 0 24 24\"><path d=\"M20.4 14.8A8.6 8.6 0 0 1 9.2 3.6 8.6 8.6 0 1 0 20.4 14.8z\"/></symbol>\n </defs>\n</svg>\n<div class=\"app\" id=\"app\">\n\n <header class=\"masthead\">\n <div class=\"brand\">\n <svg class=\"brand-mark\" viewBox=\"0 0 32 32\" aria-hidden=\"true\">\n <path d=\"M16 3.2 27.2 9.6v12.8L16 28.8 4.8 22.4V9.6z\" fill=\"none\" stroke=\"currentColor\" stroke-opacity=\".35\" stroke-width=\"1.1\"/>\n <path d=\"M16 10.2 21.8 13.5v6.8L16 23.6l-5.8-3.3v-6.8z\" fill=\"none\" stroke=\"currentColor\" stroke-opacity=\".7\" stroke-width=\"1.1\"/>\n <circle cx=\"16\" cy=\"16.6\" r=\"2.1\" fill=\"currentColor\"/>\n </svg>\n <div class=\"brand-text\">\n <span class=\"brand-name\">Weave</span>\n <span class=\"brand-sub\">织造观测台 · MULTI-AGENT OBSERVATORY</span>\n </div>\n </div>\n\n <div class=\"mast-run\">\n <span class=\"docket\"><span class=\"docket-label\">运行记录 / RUN</span><b class=\"docket-id mono\" id=\"runId\">A7F3</b></span>\n <span class=\"stamp\" id=\"runStamp\"><i class=\"stamp-dot\" aria-hidden=\"true\"></i><span id=\"runState\">回放中</span></span>\n <span class=\"stamp stamp--demo\" title=\"脚本化模拟场景,非实时遥测\">模拟运行</span>\n <span class=\"run-short\" id=\"runGoalShort\">支付网关 · 幂等层重构</span>\n </div>\n\n <div class=\"transport\" aria-label=\"回放控制\">\n <button class=\"icon-btn\" id=\"restartBtn\" type=\"button\" title=\"重新播放(R)\" aria-label=\"重新播放\">\n <svg class=\"icon\"><use href=\"#i-restart\"></use></svg>\n </button>\n <button class=\"play-btn\" id=\"playBtn\" type=\"button\" aria-label=\"暂停回放\">\n <svg class=\"icon play-icon\" id=\"playIcon\"><use href=\"#i-pause\" id=\"playIconUse\"></use></svg>\n <span id=\"playLabel\">暂停</span>\n </button>\n <div class=\"speed\" role=\"group\" aria-label=\"播放速度\">\n <button class=\"speed-btn\" type=\"button\" data-speed=\"1\" aria-pressed=\"true\">1×</button>\n <button class=\"speed-btn\" type=\"button\" data-speed=\"2\" aria-pressed=\"false\">2×</button>\n <button class=\"speed-btn\" type=\"button\" data-speed=\"4\" aria-pressed=\"false\">4×</button>\n </div>\n <div class=\"clock\" aria-label=\"回放时间\">\n <span class=\"clock-now mono\" id=\"timeNow\">00:00</span>\n <span class=\"clock-total mono\">/ <span id=\"timeTotal\">11:40</span></span>\n </div>\n <button class=\"theme-switch\" id=\"themeSwitch\" type=\"button\" role=\"switch\" aria-checked=\"false\" aria-label=\"明暗主题:纸本,切换到夜色\" title=\"明暗主题:纸本,切换到夜色\">\n <span class=\"theme-rail\" aria-hidden=\"true\">\n <span class=\"theme-thumb\"></span>\n <span class=\"theme-icon theme-sun\"><svg class=\"icon\"><use href=\"#i-sun\"></use></svg></span>\n <span class=\"theme-icon theme-moon\"><svg class=\"icon\"><use href=\"#i-moon\"></use></svg></span>\n </span>\n </button>\n <button class=\"icon-btn\" id=\"helpBtn\" type=\"button\" title=\"键盘快捷键(?)\" aria-label=\"键盘快捷键\">\n <svg class=\"icon\"><use href=\"#i-keyboard\"></use></svg>\n </button>\n </div>\n </header>\n\n <section class=\"headline\" aria-labelledby=\"goalTitle\">\n <div class=\"headline-rule\">\n <span class=\"headline-eyebrow\">目标 / OBJECTIVE</span>\n <span class=\"headline-started\" id=\"runStarted\">09:14 启动</span>\n </div>\n <h1 id=\"goalTitle\">重构支付网关幂等层,消除重复扣款</h1>\n <div class=\"headline-meta\">\n <span id=\"goalProject\">pay-gateway</span><span class=\"meta-dot\">·</span>\n <span id=\"goalBranch\" class=\"mono\">fix/idempotency-layer</span>\n <span class=\"headline-elapsed\">已用时 <b id=\"goalElapsed\" class=\"mono\">00:00</b><span class=\"elapsed-sep\">/</span>预计 <b id=\"goalEta\" class=\"mono\">11:40</b></span>\n <span class=\"headline-token\" title=\"累计 Token 消耗(模拟)\"><b class=\"mono\" id=\"tokenHead\">0</b> TOKENS</span>\n </div>\n </section>\n\n <main class=\"workspace\">\n <aside class=\"rail rail-left\" aria-label=\"运行簿与任务索引\">\n <section class=\"ledger reveal\">\n <div class=\"sect-head\">\n <span class=\"sect-no\">01</span>\n <h2>运行簿</h2>\n <span class=\"sect-en\">RUN LEDGER</span>\n </div>\n <div class=\"ledger-progress\">\n <div class=\"pct-block\">\n <span class=\"pct-num\" id=\"goalPct\">0<span class=\"pct-sign\">%</span></span>\n <span class=\"pct-cap\">整体进度</span>\n </div>\n <svg class=\"goal-ring\" viewBox=\"0 0 76 76\" aria-hidden=\"true\">\n <circle class=\"ring-track\" cx=\"38\" cy=\"38\" r=\"30\"/>\n <circle class=\"ring-value\" id=\"goalRing\" cx=\"38\" cy=\"38\" r=\"30\"/>\n </svg>\n </div>\n <dl class=\"ledger-list\">\n <div class=\"ledger-row\"><dt>并行智能体</dt><dd id=\"statActive\">0<i>/5</i></dd></div>\n <div class=\"ledger-row\"><dt>完成事项</dt><dd id=\"statDone\">0<i>/7</i></dd></div>\n <div class=\"ledger-row\"><dt>工具调用</dt><dd id=\"statCalls\">0</dd></div>\n <div class=\"ledger-row\" id=\"statBlockedCell\"><dt>阻塞</dt><dd id=\"statBlocked\">0</dd></div>\n </dl>\n </section>\n\n <section class=\"index reveal\">\n <div class=\"sect-head\">\n <span class=\"sect-no\">02</span>\n <h2>任务索引</h2>\n <span class=\"sect-en\">TASK INDEX</span>\n <span class=\"sect-meta mono\" id=\"taskCount\">0/7</span>\n </div>\n <ol class=\"task-list\" id=\"taskList\" aria-label=\"任务列表\"></ol>\n </section>\n </aside>\n\n <div class=\"splitter splitter-left\" id=\"splitLeft\" role=\"separator\" aria-orientation=\"vertical\" aria-label=\"拖动调整左栏宽度,双击复位\" title=\"拖动调整左栏宽度 / 双击复位\"></div>\n\n <section class=\"center\">\n <figure class=\"plate plate-graph reveal\">\n <figcaption class=\"plate-head\">\n <span class=\"plate-no\">图版 I</span>\n <div class=\"plate-title\">\n <h2>协作织造图</h2>\n <span>COLLABORATION LOOM</span>\n </div>\n <div class=\"plate-actions\">\n <div class=\"legend\" aria-hidden=\"true\">\n <span><i class=\"lg-dot lg-active\"></i>执行中</span>\n <span><i class=\"lg-dot lg-wait\"></i>等待</span>\n <span><i class=\"lg-dot lg-done\"></i>已完成</span>\n </div>\n <div class=\"graph-zoom\" role=\"group\" aria-label=\"协作图缩放\">\n <button class=\"zoom-btn\" id=\"zoomOut\" type=\"button\" title=\"缩小(-)\" aria-label=\"缩小\">−</button>\n <button class=\"zoom-pct\" id=\"zoomReset\" type=\"button\" title=\"恢复 100%(0 / 双击空白处)\"><span id=\"zoomPct\" aria-live=\"polite\">100%</span></button>\n <button class=\"zoom-btn\" id=\"zoomIn\" type=\"button\" title=\"放大(+)\" aria-label=\"放大\">+</button>\n </div>\n <button class=\"chip-btn\" id=\"focusBtn\" type=\"button\" aria-pressed=\"false\" title=\"只突出选中智能体的协作关系(F)\">\n <svg class=\"icon\"><use href=\"#i-focus\"></use></svg>\n <span>聚焦</span>\n </button>\n </div>\n </figcaption>\n <div class=\"stage\" id=\"stage\" role=\"group\" aria-label=\"多智能体协作织造图:丝线表示委派与协作关系,可用滚轮缩放、拖动平移\">\n <div class=\"stage-zoom\" id=\"stageZoom\">\n <div class=\"stage-grid\" aria-hidden=\"true\"></div>\n <div class=\"orbits\" aria-hidden=\"true\"><span></span><span></span><span></span></div>\n <svg class=\"edge-layer\" id=\"edgeLayer\" aria-hidden=\"true\"></svg>\n <div class=\"node-layer\" id=\"nodeLayer\"></div>\n </div>\n <div class=\"stage-now\">\n <span class=\"now-label\">此刻</span>\n <span class=\"now-time mono\" id=\"nowTime\">00:00</span>\n <span class=\"now-text\" id=\"nowText\">等待开始</span>\n <span class=\"now-hint\">拖动时间轴回看</span>\n </div>\n </div>\n <div class=\"plate-foot\">\n <span>丝线 = 协作关系 · 结 = 消息 · 朱印 = 状态</span>\n <span class=\"mono\">滚轮缩放 / 拖动平移 · PLATE I · FIG. 1</span>\n </div>\n </figure>\n\n <figure class=\"plate plate-weave reveal\">\n <figcaption class=\"plate-head\">\n <span class=\"plate-no\">图版 II</span>\n <div class=\"plate-title\">\n <h2>时间织带</h2>\n <span>THE WEAVE</span>\n </div>\n <div class=\"plate-actions\">\n <div class=\"mode-switch\" role=\"group\" aria-label=\"时间模式:回放 / 直播\">\n <button class=\"mode-btn\" id=\"replayMode\" type=\"button\" aria-pressed=\"true\" title=\"回放模式\">回放</button>\n <button class=\"mode-btn mode-btn--live\" id=\"liveMode\" type=\"button\" aria-pressed=\"false\" title=\"进入直播(演示为加速直播)\"><i class=\"live-dot\" aria-hidden=\"true\"></i>直播</button>\n </div>\n <button class=\"live-jump\" id=\"liveJump\" type=\"button\" hidden title=\"跳到最新直播画面\">回到直播</button>\n <span class=\"lane-readout mono\" id=\"laneTime\">00:00</span>\n <button class=\"weave-toggle\" id=\"weaveToggle\" type=\"button\" aria-expanded=\"true\" aria-controls=\"weaveBody\">\n <svg class=\"icon\"><use href=\"#i-chevron-up\"></use></svg>\n <span>收起织带</span>\n </button>\n </div>\n </figcaption>\n <div class=\"weave-body\" id=\"weaveBody\">\n <div class=\"lanes\" id=\"lanes\">\n <div class=\"lane-labels\" id=\"laneLabels\"></div>\n <div class=\"lane-tracks\" id=\"laneTracks\">\n <div class=\"lane-ruler\" id=\"laneRuler\"></div>\n <div class=\"lane-rows\" id=\"laneRows\"></div>\n <svg class=\"lane-links\" id=\"laneLinks\" aria-hidden=\"true\"></svg>\n <div class=\"live-edge\" id=\"liveEdgeLane\" aria-hidden=\"true\" hidden></div>\n <div class=\"blocker-band\" id=\"blockerBand\" hidden><span class=\"blocker-label\" id=\"blockerLabel\"></span></div>\n <div class=\"lane-edge-marks\" id=\"laneEdgeMarks\" aria-hidden=\"true\"></div>\n <div class=\"playhead\" id=\"playhead\" aria-hidden=\"true\"><span class=\"playhead-cap\"></span></div>\n </div>\n <input class=\"sr-only\" type=\"range\" id=\"scrubInput\" min=\"0\" max=\"700\" step=\"1\" value=\"0\" aria-label=\"回放时间轴\" aria-valuetext=\"00:00\">\n </div>\n </div>\n <div class=\"weave-compact\" id=\"weaveCompact\">\n <div class=\"wc-top\">\n <span class=\"wc-caption\">整体进度</span>\n <span class=\"wc-time mono\" id=\"wcTime\">00:00</span>\n <span class=\"wc-token mono\" id=\"wcToken\">0 TOK</span>\n <span class=\"wc-stat\" id=\"wcStat\">0 / 7 完成</span>\n </div>\n <div class=\"wc-blocker-wrap\" id=\"wcBlockerWrap\" hidden>\n <button class=\"wc-blocker-band\" id=\"wcBlockerBand\" type=\"button\" aria-haspopup=\"dialog\" aria-controls=\"blockerPop\">\n <span class=\"wc-blocker-fill\" id=\"wcBlockerFill\"></span>\n <span class=\"wc-blocker-text\" id=\"wcBlockerText\">阻塞</span>\n </button>\n </div>\n <div class=\"wc-track\" id=\"wcTrack\" role=\"slider\" tabindex=\"0\" aria-label=\"紧凑回放时间轴\" aria-valuemin=\"0\" aria-valuemax=\"700\" aria-valuenow=\"0\">\n <span class=\"wc-fill\" id=\"wcFill\"></span>\n <span class=\"wc-ticks\" id=\"wcTicks\"></span>\n <span class=\"wc-selected\" id=\"wcSelected\" aria-hidden=\"true\"></span>\n <span class=\"wc-edge\" id=\"wcEdge\" aria-hidden=\"true\"></span>\n <span class=\"live-edge live-edge--compact\" id=\"liveEdgeCompact\" aria-hidden=\"true\" hidden></span>\n <span class=\"wc-head\" id=\"wcHead\"></span>\n </div>\n </div>\n </figure>\n </section>\n\n <div class=\"splitter splitter-right\" id=\"splitRight\" role=\"separator\" aria-orientation=\"vertical\" aria-label=\"拖动调整右栏宽度,双击复位\" title=\"拖动调整右栏宽度 / 双击复位\"></div>\n\n <aside class=\"rail rail-right\" aria-label=\"档案与旁注\">\n <section class=\"dossier reveal\">\n <div class=\"sect-head\">\n <span class=\"sect-no\">03</span>\n <h2>档案</h2>\n <span class=\"sect-en\">DOSSIER</span>\n <button class=\"switch\" id=\"followBtn\" type=\"button\" aria-pressed=\"true\" title=\"自动跟随最新活跃智能体(G)\">\n <span class=\"switch-track\"><span class=\"switch-thumb\"></span></span>\n <span>自动跟随</span>\n </button>\n </div>\n <div class=\"dossier-token\" id=\"dossierToken\">\n <span class=\"dt-label\">丝线消耗 / TOKENS</span>\n <b class=\"dt-value mono\" id=\"agentToken\">0</b>\n <span class=\"dt-share\" id=\"agentTokenShare\">占全局 0%</span>\n <span class=\"dt-bar\"><i id=\"agentTokenBar\"></i></span>\n </div>\n <div class=\"inspector\" id=\"inspector\"></div>\n </section>\n\n <section class=\"notes reveal\">\n <div class=\"sect-head\">\n <span class=\"sect-no\">04</span>\n <h2>旁注</h2>\n <span class=\"sect-en\">FIELD NOTES</span>\n <span class=\"sect-meta mono\" id=\"feedCount\">0 / 0</span>\n </div>\n <div class=\"feed-filters\" id=\"feedFilters\" role=\"group\" aria-label=\"事件筛选\"></div>\n <div class=\"feed-scroll\" id=\"feedScroll\">\n <ol class=\"feed-list\" id=\"feedList\" role=\"log\" aria-live=\"off\"></ol>\n </div>\n <button class=\"feed-jump\" id=\"feedJump\" type=\"button\" hidden>\n <svg class=\"icon\"><use href=\"#i-chevron-up\"></use></svg>\n 回到最新\n </button>\n </section>\n </aside>\n </main>\n\n <div class=\"blocker-pop\" id=\"blockerPop\" role=\"dialog\" aria-modal=\"false\" aria-labelledby=\"blockerPopTitle\" hidden>\n <button class=\"bp-close\" id=\"blockerPopClose\" type=\"button\" aria-label=\"关闭阻塞详情\">\n <svg class=\"icon\"><use href=\"#i-x\"></use></svg>\n </button>\n <div class=\"bp-eyebrow\">阻塞记录 / BLOCKED</div>\n <h3 id=\"blockerPopTitle\">并发竞态阻塞</h3>\n <p id=\"blockerPopDetail\">Lens 发现幂等占位记录可被并发重试覆盖</p>\n <dl class=\"bp-meta\">\n <div><dt>窗口</dt><dd id=\"bpWindow\">07:10 – 09:38 · 02:28</dd></div>\n <div><dt>发现</dt><dd>Lens 确认并发重试可覆盖占位</dd></div>\n <div><dt>上报</dt><dd>Lens → Atlas</dd></div>\n <div><dt>解除</dt><dd>Lens 复核通过 · 风险降级</dd></div>\n <div><dt>影响</dt><dd>T4 安全与并发评审 · T5 竞态修复</dd></div>\n </dl>\n <div class=\"bp-actions\">\n <button id=\"bpJump\" type=\"button\">跳到阻塞开始</button>\n <button id=\"bpLens\" type=\"button\">查看 Lens</button>\n </div>\n </div>\n\n <footer class=\"footer\">\n <span class=\"footer-left\"><i class=\"stamp-dot\" aria-hidden=\"true\"></i>脚本化模拟回放 · 非实时遥测</span>\n <span class=\"footer-keys\" aria-hidden=\"true\">\n <kbd>Space</kbd> 播放 / 暂停\n <kbd>←</kbd><kbd>→</kbd> 跳转\n <kbd>R</kbd> 重播\n <kbd>F</kbd> 聚焦\n <kbd>?</kbd> 快捷键\n </span>\n <span class=\"footer-right mono\">WEAVE · SILK EDITION 02.8 / 2026</span>\n </footer>\n</div>\n\n<dialog class=\"dialog\" id=\"helpDialog\" aria-labelledby=\"helpTitle\">\n <header class=\"dialog-head\">\n <div>\n <span class=\"eyebrow\">SHORTCUTS · 操作指南</span>\n <h2 id=\"helpTitle\">键盘与交互</h2>\n </div>\n <button class=\"icon-btn\" type=\"button\" data-close aria-label=\"关闭\">\n <svg class=\"icon\"><use href=\"#i-x\"></use></svg>\n </button>\n </header>\n <div class=\"dialog-body\">\n <dl class=\"shortcut-list\">\n <div><dt><kbd>Space</kbd></dt><dd>播放 / 暂停回放</dd></div>\n <div><dt><kbd>←</kbd> <kbd>→</kbd></dt><dd>后退 / 前进 10 秒(按住 Shift 为 60 秒)</dd></div>\n <div><dt><kbd>1</kbd> <kbd>2</kbd> <kbd>4</kbd></dt><dd>切换播放速度</dd></div>\n <div><dt><kbd>R</kbd></dt><dd>从头重新播放</dd></div>\n <div><dt><kbd>F</kbd></dt><dd>聚焦当前选中的智能体</dd></div>\n <div><dt><kbd>G</kbd></dt><dd>开启 / 关闭自动跟随</dd></div>\n <div><dt><kbd>?</kbd></dt><dd>打开这份操作指南</dd></div>\n <div><dt>点击丝印</dt><dd>检视该智能体的当前工作、消息与产出</dd></div>\n <div><dt>点击织带</dt><dd>跳转到该时间点,暂停回放</dd></div>\n <div><dt>悬停丝线</dt><dd>在织带中标亮这两个智能体之间的协作时段</dd></div>\n <div><dt><kbd>T</kbd></dt><dd>展开 / 收起完整织带(收起时为一根进度条)</dd></div>\n <div><dt>拖动栏边</dt><dd>调整左右栏宽度(双击复位;聚焦后可用方向键微调)</dd></div>\n <div><dt>直播 / 回放</dt><dd>点「直播」进入跟随模式;点「回放」退出。直播中拖动进度条即可回看,按「回到直播」一键追平最新画面(演示为加速直播)。</dd></div>\n <div><dt>明暗主题</dt><dd>点击顶栏右侧的「日 / 月」滑动开关,在纸本与夜色之间切换;选择会自动记忆</dd></div>\n <div><dt>缩放 / 平移</dt><dd>滚轮缩放协作图,拖动空白处平移(放大后),双击空白处或点百分比复位;也可用 + / − / 0</dd></div>\n <div><dt>点击阻塞带</dt><dd>查看阻塞原因、时间窗与相关智能体,可跳转到阻塞起点</dd></div>\n </dl>\n <p class=\"dialog-note\">\n 这是 Silk Edition 视觉原型:运行内容为脚本化模拟数据,用于演示「如何让多智能体协作过程更可读」,\n 不连接真实遥测。所有状态、消息与产出均随回放时间推导。\n </p>\n </div>\n</dialog>\n\n<div class=\"tip-toast\" id=\"tipToast\" role=\"status\">空格播放 / 暂停 · 点击丝印检视 · 拖动织带回看</div>\n\n<script>\n/* [EMBED] 中性占位数据:真实 WEAVE_DATA 只在第一次 weave:init 时注入 */\nwindow.WEAVE_DATA = {\"meta\":{\"runId\":\"—\",\"project\":\"—\",\"branch\":\"—\",\"goal\":\"等待会话数据\",\"shortGoal\":\"等待会话数据\",\"startedAt\":\"--:--\",\"duration\":700,\"playbackSeconds\":80,\"simulated\":false},\"agents\":[],\"tasks\":[],\"events\":[],\"messages\":[],\"blocker\":null};\nwindow.WEAVE_EMBED_VERSION = \"1.0.0\";\nwindow.WEAVE_EMBED_BUILT_AT = \"2026-11-26T15:34:51.059Z\";\n</script>\n<script id=\"weave-app\">\n/* ---- weave-embed/src/weave-app.js(从根目录 app.js 生成) ---- */\n/* Weave · 多智能体协作观测台 — 回放引擎与渲染层\n * 纯前端、无依赖。基于虚拟时间的确定性回放:\n * 任意时间点的状态(谁在做什么、消息在途、事件流、泳道进度)都由 t 推导。\n *\n * ==========================================================================\n * [EMBED] weave-app.js —— 由 weave-embed/tools/make-weave-app.mjs 从根目录 app.js 生成。\n * 相对原版的差异集中在下面 5 处 [EMBED] 标注:\n * 1) 数据索引改为可重入 indexData(),setData 时整体重算并重建动态 DOM;\n * 2) 数据未就绪时不自动启动,由 WeaveLive.setData 首次注入后启动;\n * 3) 暴露 window.WeaveLive(setData / setTheme / setLive / seek / getState);\n * 4) 不再监听 DOMContentLoaded,启动由嵌入外壳控制;\n * 5) 主题跟随父视图,隐藏原型自己的主题开关。\n * 渲染、布局、回放与交互逻辑与原版保持一致。\n * ==========================================================================\n */\n(function () {\n \"use strict\";\n\n /* [EMBED] 运行时外壳:数据就绪后创建;setData 可重建 / 热重载运行时 */\n var runtime = null;\n var liveMode = false;\n\n function createRuntime(initialData) {\n return (function (DATA) {\n \"use strict\";\n\n /* [EMBED] 数据派生变量改为可变,由 indexData() 统一重算 */\n var META, END, RATE;\n var reduceMotion = window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n var NS = \"http://www.w3.org/2000/svg\";\n\n /* [EMBED] 防御:root 不是可查询节点时回退 document(缓存元素为空也不抛错) */\n var $ = function (sel, root) {\n var scope = (root && typeof root.querySelector === 'function') ? root : document;\n try { return scope.querySelector(sel); }\n catch (err) { window.__WEAVE_SCOPE_ERR__ = { fn: '$', sel: sel, rootType: typeof root, rootTag: root && root.tagName, stack: String(err && err.stack) }; throw err; }\n };\n var $$ = function (sel, root) {\n var scope = (root && typeof root.querySelectorAll === 'function') ? root : document;\n try { return Array.prototype.slice.call(scope.querySelectorAll(sel)); }\n catch (err) { window.__WEAVE_SCOPE_ERR__ = { fn: '$$', sel: sel, rootType: typeof root, rootTag: root && root.tagName, stack: String(err && err.stack) }; throw err; }\n };\n var clamp = function (v, a, b) { return Math.max(a, Math.min(b, v)); };\n var pad = function (n) { return n < 10 ? \"0\" + n : \"\" + n; };\n var fmt = function (sec) {\n sec = clamp(Math.round(sec), 0, END);\n return pad(Math.floor(sec / 60)) + \":\" + pad(sec % 60);\n };\n var pct = function (n) { return Math.round(clamp(n, 0, 1) * 100); };\n var icon = function (id) {\n return '<svg class=\"icon\" aria-hidden=\"true\"><use href=\"#' + id + '\"></use></svg>';\n };\n\n /* [EMBED] 这些派生变量由 indexData() 赋值 */\n var agents, agentById, EVENTS, MESSAGES, TASKS, BLOCKER;\n\n var STATUS_TEXT = { active: \"执行中\", waiting: \"等待中\", queued: \"待命\", done: \"已完成\" };\n var TYPE_ICON = {\n delegate: \"i-send\", message: \"i-message\", tool: \"i-terminal\",\n decision: \"i-branch\", artifact: \"i-file\", insight: \"i-spark\", alert: \"i-alert\"\n };\n var TYPE_TONE = {\n delegate: \"var(--sky)\", message: \"#8fa3bd\", tool: \"var(--amber)\",\n decision: \"var(--lime)\", artifact: \"var(--mint)\", insight: \"var(--violet)\", alert: \"var(--rose)\"\n };\n var FEED_TYPES = [\n { id: \"all\", label: \"全部\" }, { id: \"delegate\", label: \"委派\" },\n { id: \"message\", label: \"消息\" }, { id: \"tool\", label: \"工具\" },\n { id: \"decision\", label: \"决策\" }, { id: \"artifact\", label: \"产出\" },\n { id: \"insight\", label: \"发现\" }, { id: \"alert\", label: \"异常\" }\n ];\n var WAIT_NOTES = {\n atlas: \"等待上游结论与评审反馈\",\n scout: \"等待下一项任务分派\",\n forge: \"等待评审结论与修复指令\",\n lens: \"等待新的实现提交评审\",\n quill: \"等待其他智能体的结论同步\"\n };\n var WAIT_ACTIVITY = {\n atlas: \"研判评审反馈\",\n scout: \"待命 · 等待分派\",\n forge: \"等待评审结论\",\n lens: \"等待复核请求\",\n quill: \"等待结论合并\"\n };\n\n var LEAD = null; /* [EMBED] 由 indexData() 重算 */\n function edgeKey(a, b) { return a < b ? a + \"|\" + b : b + \"|\" + a; }\n\n /* 根据实际数据推导协作关系:主编排者到所有成员 + 消息里出现的横向关系 */\n function buildEdgeDefs() {\n var defs = [];\n var seen = {};\n if (LEAD) {\n agents.forEach(function (a) {\n if (a.id === LEAD.id) return;\n /* 谱系边优先:子代理连到它的父代理,而不是全部连主智能体 */\n var parent = a.parent && agentById[a.parent] ? a.parent : LEAD.id;\n var k = edgeKey(parent, a.id);\n if (seen[k]) return;\n seen[k] = true;\n defs.push({ a: parent, b: a.id, peer: false });\n });\n }\n MESSAGES.forEach(function (m) {\n if (!agentById[m.from] || !agentById[m.to]) return;\n var k = edgeKey(m.from, m.to);\n if (seen[k]) return;\n seen[k] = true;\n defs.push({ a: m.from, b: m.to, peer: true });\n });\n return defs;\n }\n var EDGE_DEFS = null;\n\n /* [EMBED] 数据索引:集中重算所有依赖 WEAVE_DATA 的派生状态。\n * setData 时整体重跑,因此不会残留旧 DATA 闭包。 */\n function indexData(nextData) {\n if (!nextData || !nextData.meta || typeof nextData.meta !== \"object\") {\n throw new Error(\"WeaveLive.setData: WEAVE_DATA.meta 缺失\");\n }\n DATA = nextData;\n META = DATA.meta;\n END = Number(META.duration) > 0 ? Number(META.duration) : 700;\n RATE = END / (Number(META.playbackSeconds) > 0 ? Number(META.playbackSeconds) : 80);\n agents = Array.isArray(DATA.agents) ? DATA.agents : [];\n agentById = {};\n agents.forEach(function (a) { agentById[a.id] = a; });\n EVENTS = (DATA.events || []).slice().sort(function (a, b) { return a.t - b.t; });\n MESSAGES = (DATA.messages || []).slice().sort(function (a, b) { return a.t - b.t; });\n TASKS = (DATA.tasks || []).slice().sort(function (a, b) {\n return parseInt(String(a.id).slice(1), 10) - parseInt(String(b.id).slice(1), 10);\n });\n BLOCKER = DATA.blocker || { from: Infinity, to: Infinity, title: \"\", detail: \"\" };\n LEAD = agentById[\"atlas\"] || agents[0] || null;\n EDGE_DEFS = buildEdgeDefs();\n if (typeof window !== \"undefined\") window.WEAVE_EDGES = EDGE_DEFS;\n if (!agentById[state.selected]) {\n state.selected = agents[0] ? agents[0].id : null;\n }\n }\n\n /* 闲置子代理默认收起(类似 DSH 侧边栏会话树):可见集 = 根 + 运行中的\n 代理及其祖先 + 被用户逐层展开的代理的直接子代理。 */\n function treeChildren() {\n var children = {};\n agents.forEach(function (a) {\n var parent = a.id !== (LEAD || agents[0]).id && a.parent && agentById[a.parent] ? a.parent : null;\n if (parent === null) return;\n (children[parent] = children[parent] || []).push(a);\n });\n return children;\n }\n\n function treeVisible() {\n var lead = LEAD || agents[0];\n var visible = {};\n var keep = {};\n if (!lead) return visible;\n var children = treeChildren();\n agents.forEach(function (a) {\n if (a.running !== true || a.id === lead.id) return;\n keep[a.id] = true;\n var parent = a.parent;\n while (parent && agentById[parent] && !keep[parent]) {\n keep[parent] = true;\n parent = agentById[parent].parent;\n }\n });\n visible[lead.id] = true;\n var queue = [lead];\n while (queue.length) {\n var node = queue.shift();\n (children[node.id] || []).forEach(function (child) {\n if (visible[child.id]) return;\n var show = child.running === true || keep[child.id] === true || (state.expanded && state.expanded[node.id] === true);\n if (!show) return;\n visible[child.id] = true;\n queue.push(child);\n });\n }\n return visible;\n }\n\n function refreshTreeVisibility() {\n var visible = treeVisible();\n var children = treeChildren();\n agents.forEach(function (a) {\n var rec = nodeEls[a.id];\n if (!rec) return;\n var show = visible[a.id] === true;\n rec.root.classList.toggle(\"is-tree-hidden\", !show);\n var toggle = rec.root.querySelector(\".node-toggle\");\n if (!toggle) return;\n var kids = children[a.id] || [];\n var hidden = kids.filter(function (child) { return visible[child.id] !== true });\n var hasIdle = kids.some(function (child) { return child.running !== true });\n if (!show || (!hasIdle && !(state.expanded && state.expanded[a.id] === true))) {\n toggle.hidden = true;\n return;\n }\n var open = state.expanded && state.expanded[a.id] === true;\n toggle.hidden = false;\n toggle.textContent = open ? \"−\" : \"+\" + (hidden.length || kids.length);\n toggle.setAttribute(\"aria-expanded\", open ? \"true\" : \"false\");\n toggle.title = open ? \"收起闲置子代理\" : \"展开闲置子代理(\" + (hidden.length || kids.length) + \")\";\n });\n layoutStage();\n edgeList.forEach(function (edge) {\n var showEdge = visible[edge.def.a] === true && visible[edge.def.b] === true;\n edge.path.style.display = showEdge ? \"\" : \"none\";\n });\n }\n\n function toggleTree(id) {\n if (!state.expanded) state.expanded = {};\n state.expanded[id] = state.expanded[id] === true ? false : true;\n refreshTreeVisibility();\n }\n\n /* 自适应节点位置:1 位编排者 + 最多 4 位成员沿用菱形,更多成员排成环形 */\n /* 有谱系数据时按 DSH 会话树排布;无谱系的演示数据沿用菱形/环形。 */\n function treePositions(compact, stageWidth, lead) {\n var positions = {};\n var visible = treeVisible();\n var treeAgents = agents.filter(function (a) { return visible[a.id] === true; });\n var children = {};\n treeAgents.forEach(function (a) {\n var parent = a.id !== lead.id && a.parent && agentById[a.parent] ? a.parent : null;\n if (parent === null) return;\n (children[parent] = children[parent] || []).push(a);\n });\n var levels = [[lead]];\n var seen = {};\n seen[lead.id] = true;\n while (true) {\n var prev = levels[levels.length - 1];\n var next = [];\n prev.forEach(function (node) {\n (children[node.id] || []).forEach(function (child) {\n if (seen[child.id]) return;\n seen[child.id] = true;\n next.push(child);\n });\n });\n if (!next.length) break;\n levels.push(next);\n }\n var orphans = treeAgents.filter(function (a) { return !seen[a.id]; });\n if (orphans.length) levels[1] = (levels[1] || []).concat(orphans);\n var width = stageWidth || 1200;\n var perRow = Math.max(compact ? 3 : 4, Math.min(12, Math.floor(width / (compact ? 88 : 96))));\n var rowGap = compact ? 0.3 : 0.235;\n var baseY = compact ? 0.16 : 0.14;\n var row = 0;\n levels.forEach(function (nodes, depth) {\n if (depth === 0) { positions[lead.id] = { x: 0.5, y: baseY }; return; }\n var rowCount = Math.max(1, Math.ceil(nodes.length / perRow));\n var per = Math.ceil(nodes.length / rowCount);\n for (var i = 0; i < nodes.length; i += per) {\n var part = nodes.slice(i, i + per);\n var y = Math.min(0.86, baseY + (++row) * rowGap);\n part.forEach(function (node, index) {\n positions[node.id] = { x: (index + 1) / (part.length + 1), y: y };\n });\n }\n });\n treeAgents.forEach(function (a) {\n if (!positions[a.id]) positions[a.id] = { x: 0.5, y: 0.86 };\n });\n return positions;\n }\n\n function stagePositions(compact, stageWidth) {\n var positions = {};\n if (!agents.length) return positions;\n var lead = LEAD || agents[0];\n var hasLineage = agents.some(function (a) { return a.id !== lead.id && a.parent && agentById[a.parent]; });\n if (hasLineage) return treePositions(compact, stageWidth, lead);\n var others = agents.filter(function (a) { return a.id !== lead.id; });\n positions[lead.id] = compact ? { x: 0.5, y: 0.5 } : { x: 0.5, y: 0.44 };\n var n = others.length;\n if (!n) return positions;\n if (n <= 4) {\n var slots;\n if (n === 1) {\n slots = compact ? [{ x: 0.76, y: 0.5 }] : [{ x: 0.77, y: 0.48 }];\n } else if (n === 2) {\n slots = compact\n ? [{ x: 0.24, y: 0.48 }, { x: 0.76, y: 0.48 }]\n : [{ x: 0.2, y: 0.48 }, { x: 0.8, y: 0.48 }];\n } else if (n === 3) {\n slots = compact\n ? [{ x: 0.25, y: 0.24 }, { x: 0.75, y: 0.24 }, { x: 0.5, y: 0.79 }]\n : [{ x: 0.23, y: 0.2 }, { x: 0.77, y: 0.2 }, { x: 0.5, y: 0.8 }];\n } else {\n slots = compact\n ? [{ x: 0.23, y: 0.24 }, { x: 0.77, y: 0.24 }, { x: 0.23, y: 0.78 }, { x: 0.77, y: 0.78 }]\n : [{ x: 0.155, y: 0.21 }, { x: 0.845, y: 0.21 }, { x: 0.155, y: 0.775 }, { x: 0.845, y: 0.775 }];\n }\n others.forEach(function (a, i) { positions[a.id] = slots[i] || slots[slots.length - 1]; });\n return positions;\n }\n var rx = compact ? 0.34 : 0.37;\n var ry = compact ? 0.32 : 0.35;\n others.forEach(function (a, i) {\n var angle = -Math.PI / 2 + (i * Math.PI * 2) / n;\n positions[a.id] = {\n x: Math.max(0.12, Math.min(0.88, 0.5 + Math.cos(angle) * rx)),\n y: Math.max(0.12, Math.min(0.88, 0.5 + Math.sin(angle) * ry))\n };\n });\n return positions;\n }\n\n var state = {\n t: 0, playing: !reduceMotion, speed: 1,\n /* [EMBED] 选中项由 indexData() 按新数据校正 */\n selected: null, follow: true, focus: false,\n filter: \"all\", completed: false, expanded: {}\n };\n\n /* [EMBED] 直播跟随标记:true 时每次 setData 自动追到最新并暂停 */\n var liveMode = false;\n\n var el = {};\n var nodeEls = {};\n var edgeList = [];\n var edgeByKey = {};\n var particleList = [];\n var segmentEls = [];\n var laneRowEls = {};\n var laneLinkEls = [];\n var taskEls = {};\n var renderedEvents = [];\n var stageW = 0;\n var stageH = 0;\n var lastHotSig = \"\";\n var lastNowIdx = -2;\n var lastUiStamp = 0;\n var lastInspectorStamp = 0;\n var lastPlaying = null;\n var lastCompleted = null;\n var forceInspector = true;\n var resizeQueued = false;\n var lastTimeText = \"\";\n\n /* ------------------------------------------------------------------ utils */\n function blockerActive(t) { return t >= BLOCKER.from && t < BLOCKER.to; }\n function workAt(agent, t) {\n for (var i = 0; i < agent.work.length; i++) {\n var w = agent.work[i];\n if (t >= w.s && t < w.e) return { work: w, index: i };\n }\n return null;\n }\n function agentStatus(agent, t) {\n var works = agent.work;\n if (t >= works[works.length - 1].e) return \"done\";\n if (workAt(agent, t)) return \"active\";\n if (t < works[0].s) return \"queued\";\n return \"waiting\";\n }\n function taskStatus(task, t) {\n if (t >= task.end) return \"done\";\n if (task.id === \"T5\" && blockerActive(t) && t < task.start) return \"blocked\";\n if (task.id === \"T4\" && blockerActive(t) && t >= task.start) return \"alert\";\n if (t < task.start) return \"queued\";\n return \"running\";\n }\n function activeTime(agent, t) {\n var sum = 0;\n agent.work.forEach(function (w) { sum += clamp(t - w.s, 0, w.e - w.s); });\n return sum;\n }\n function overallProgress(t) {\n var total = 0, done = 0;\n TASKS.forEach(function (task) {\n var dur = task.end - task.start;\n total += dur;\n done += clamp(t - task.start, 0, dur);\n });\n return total ? done / total : 0;\n }\n function latestEventIndex(t) {\n var idx = -1;\n for (var i = 0; i < EVENTS.length; i++) {\n if (EVENTS[i].t <= t + 0.001) idx = i; else break;\n }\n return idx;\n }\n function matchesFilter(ev) { return state.filter === \"all\" || ev.type === state.filter; }\n function currentVisibleEvents() {\n return EVENTS.filter(function (ev) { return ev.t <= state.t + 0.001 && matchesFilter(ev); });\n }\n function connectedSet() {\n var set = {};\n set[state.selected] = true;\n EDGE_DEFS.forEach(function (d) {\n if (d.a === state.selected) set[d.b] = true;\n if (d.b === state.selected) set[d.a] = true;\n });\n return set;\n }\n function agentName(id) {\n if (id === \"all\") return \"全员\";\n return agentById[id] ? agentById[id].name : id;\n }\n function spanMeta(ev) {\n var actor = agentById[ev.actor];\n var text = '<b class=\"actor-name\" style=\"color:' + actor.color + ';--actor:' + actor.color + '\">' + actor.name + \"</b> \" + ev.text;\n if (ev.target) text += ' <span class=\"to\">→ ' + agentName(ev.target) + \"</span>\";\n if (ev.tag) text += ' <span class=\"feed-tag\">' + ev.tag + \"</span>\";\n return text;\n }\n\n /* ------------------------------------------------------------------ build */\n function cacheEls() {\n el.app = $(\"#app\");\n el.runState = $(\"#runState\");\n el.runId = $(\"#runId\");\n el.runGoalShort = $(\"#runGoalShort\");\n el.runStarted = $(\"#runStarted\");\n el.playBtn = $(\"#playBtn\");\n el.playLabel = $(\"#playLabel\");\n el.playIconUse = $(\"#playIconUse\");\n el.restartBtn = $(\"#restartBtn\");\n el.helpBtn = $(\"#helpBtn\");\n el.timeNow = $(\"#timeNow\");\n el.timeTotal = $(\"#timeTotal\");\n el.goalTitle = $(\"#goalTitle\");\n el.goalProject = $(\"#goalProject\");\n el.goalBranch = $(\"#goalBranch\");\n el.goalRing = $(\"#goalRing\");\n el.goalPct = $(\"#goalPct\");\n el.goalElapsed = $(\"#goalElapsed\");\n el.goalEta = $(\"#goalEta\");\n el.statActive = $(\"#statActive\");\n el.statDone = $(\"#statDone\");\n el.statCalls = $(\"#statCalls\");\n el.statBlocked = $(\"#statBlocked\");\n el.statBlockedCell = $(\"#statBlockedCell\");\n el.taskCount = $(\"#taskCount\");\n el.taskList = $(\"#taskList\");\n el.focusBtn = $(\"#focusBtn\");\n el.stage = $(\"#stage\");\n el.orbits = $(\".orbits\", el.stage);\n el.edgeLayer = $(\"#edgeLayer\");\n el.nodeLayer = $(\"#nodeLayer\");\n el.nowTime = $(\"#nowTime\");\n el.nowText = $(\"#nowText\");\n el.laneLabels = $(\"#laneLabels\");\n el.laneTracks = $(\"#laneTracks\");\n el.laneRuler = $(\"#laneRuler\");\n el.laneRows = $(\"#laneRows\");\n el.laneLinks = $(\"#laneLinks\");\n el.blockerBand = $(\"#blockerBand\");\n el.blockerLabel = $(\"#blockerLabel\");\n el.playhead = $(\"#playhead\");\n el.laneTime = $(\"#laneTime\");\n el.scrubInput = $(\"#scrubInput\");\n el.inspector = $(\"#inspector\");\n el.followBtn = $(\"#followBtn\");\n el.feedFilters = $(\"#feedFilters\");\n el.feedCount = $(\"#feedCount\");\n el.feedScroll = $(\"#feedScroll\");\n el.feedList = $(\"#feedList\");\n el.feedJump = $(\"#feedJump\");\n el.helpDialog = $(\"#helpDialog\");\n el.tipToast = $(\"#tipToast\");\n }\n\n function buildNodes() {\n el.nodeLayer.innerHTML = \"\";\n agents.forEach(function (a) {\n var node = document.createElement(\"div\");\n node.className = \"node is-queued\";\n node.dataset.agent = a.id;\n node.style.setProperty(\"--c\", a.color);\n node.innerHTML =\n '<button class=\"node-btn\" type=\"button\" aria-pressed=\"false\">' +\n '<span class=\"node-icon\">' + icon(a.icon) + '</span>' +\n '<svg class=\"node-ring\" viewBox=\"0 0 78 78\" aria-hidden=\"true\">' +\n '<circle class=\"ring-track\" cx=\"39\" cy=\"39\" r=\"36\"></circle>' +\n '<circle class=\"ring-value\" cx=\"39\" cy=\"39\" r=\"36\"></circle>' +\n \"</svg>\" +\n '<span class=\"node-badge\" aria-hidden=\"true\"></span>' +\n \"</button>\" +\n '<div class=\"node-name\">' + a.name + \"</div>\" +\n '<div class=\"node-role\">' + a.roleEn + \" · \" + a.roleCn + \"</div>\" +\n '<div class=\"node-activity\"><span class=\"mini\" hidden></span><span class=\"node-activity-text\">待命</span></div>' +\n '<button class=\"node-toggle\" type=\"button\" hidden></button>';\n el.nodeLayer.appendChild(node);\n var btn = node.querySelector(\".node-btn\");\n btn.addEventListener(\"click\", function () { selectAgent(a.id, true); });\n var toggle = node.querySelector(\".node-toggle\");\n if (toggle) {\n toggle.addEventListener(\"click\", function (ev) {\n ev.preventDefault();\n ev.stopPropagation();\n toggleTree(a.id);\n });\n }\n nodeEls[a.id] = {\n root: node, btn: btn,\n badge: node.querySelector(\".node-badge\"),\n activityText: node.querySelector(\".node-activity-text\"),\n mini: node.querySelector(\".mini\"),\n ringValue: node.querySelector(\".ring-value\")\n };\n });\n }\n\n function buildEdges() {\n el.edgeLayer.innerHTML = \"\";\n edgeList = [];\n edgeByKey = {};\n EDGE_DEFS.forEach(function (def) {\n var path = document.createElementNS(NS, \"path\");\n path.setAttribute(\"class\", \"edge\" + (def.peer ? \" is-link\" : \"\"));\n el.edgeLayer.appendChild(path);\n var rec = { def: def, path: path, len: 0, key: edgeKey(def.a, def.b) };\n edgeList.push(rec);\n edgeByKey[rec.key] = rec;\n });\n }\n\n function buildParticles() {\n var old = el.edgeLayer.querySelectorAll(\".msg-particle\");\n Array.prototype.forEach.call(old, function (n) { n.parentNode.removeChild(n); });\n particleList = [];\n MESSAGES.forEach(function (m) {\n var from = agentById[m.from];\n var g = document.createElementNS(NS, \"g\");\n g.setAttribute(\"class\", \"msg-particle\");\n g.style.display = \"none\";\n var glow = document.createElementNS(NS, \"circle\");\n glow.setAttribute(\"r\", \"7\");\n glow.setAttribute(\"class\", \"msg-glow\");\n glow.setAttribute(\"fill\", from.color);\n var core = document.createElementNS(NS, \"circle\");\n core.setAttribute(\"r\", \"2.6\");\n core.setAttribute(\"class\", \"msg-core\");\n core.setAttribute(\"fill\", from.color);\n g.appendChild(glow);\n g.appendChild(core);\n el.edgeLayer.appendChild(g);\n particleList.push({ msg: m, g: g, visible: false });\n });\n }\n\n function buildLanes() {\n el.laneLabels.innerHTML = \"\";\n el.laneRows.innerHTML = \"\";\n segmentEls = [];\n laneRowEls = {};\n agents.forEach(function (a) {\n var label = document.createElement(\"div\");\n label.className = \"lane-label\";\n label.style.setProperty(\"--c\", a.color);\n label.innerHTML = '<span class=\"lane-dot\"></span><span>' + a.name + \"</span>\";\n el.laneLabels.appendChild(label);\n\n var row = document.createElement(\"div\");\n row.className = \"lane-row\";\n row.dataset.agent = a.id;\n a.work.forEach(function (w, i) {\n var seg = document.createElement(\"div\");\n seg.className = \"seg is-upcoming\";\n seg.style.setProperty(\"--c\", a.color);\n seg.style.left = (w.s / END * 100).toFixed(3) + \"%\";\n seg.style.width = ((w.e - w.s) / END * 100).toFixed(3) + \"%\";\n seg.dataset.agent = a.id;\n seg.dataset.index = i;\n seg.title = w.label + \" · \" + fmt(w.s) + \"–\" + fmt(w.e);\n seg.innerHTML = '<span class=\"seg-fill\"></span><span class=\"seg-label\">' + w.label + \"</span>\";\n row.appendChild(seg);\n segmentEls.push({\n el: seg, fill: seg.querySelector(\".seg-fill\"), agentId: a.id, work: w, cls: \"\",\n tiny: ((w.e - w.s) / END * 100) < 2.8\n });\n });\n el.laneRows.appendChild(row);\n laneRowEls[a.id] = row;\n });\n }\n\n function buildTasks() {\n el.taskList.innerHTML = \"\";\n taskEls = {};\n TASKS.forEach(function (task) {\n var owner = agentById[task.owner];\n var li = document.createElement(\"li\");\n li.className = \"task-item is-queued\";\n li.dataset.task = task.id;\n li.style.setProperty(\"--agent-color\", owner.color);\n li.style.setProperty(\"--task-c\", owner.color);\n li.innerHTML =\n '<span class=\"task-icon\"></span>' +\n '<span class=\"task-main\">' +\n '<span class=\"task-title\">' + task.title + \"</span>\" +\n '<span class=\"task-sub\"><span class=\"task-owner\">' + owner.name + \"</span><span>\" + task.id + \"</span>\" +\n (task.deps.length ? '<span class=\"task-deps\">← ' + task.deps.join(\" \") + \"</span>\" : \"\") +\n \"</span>\" +\n \"</span>\" +\n '<span class=\"task-tail mono\"></span>';\n li.tabIndex = 0;\n li.setAttribute(\"role\", \"button\");\n li.setAttribute(\"aria-label\", task.title + \",\" + owner.name + \",\" + task.id + \",跳转到开始时间\");\n li.addEventListener(\"click\", function () {\n pause();\n seek(task.start + 0.5);\n selectAgent(task.owner, true);\n });\n li.addEventListener(\"keydown\", function (e) {\n if (e.key === \"Enter\" || e.key === \" \") { e.preventDefault(); li.click(); }\n });\n el.taskList.appendChild(li);\n taskEls[task.id] = {\n root: li, icon: li.querySelector(\".task-icon\"),\n tail: li.querySelector(\".task-tail\"), cls: \"\", iconId: \"\", tailTxt: \"\"\n };\n });\n }\n\n function buildFilters() {\n el.feedFilters.innerHTML = \"\";\n FEED_TYPES.forEach(function (ft) {\n var b = document.createElement(\"button\");\n b.type = \"button\";\n b.className = \"filter-chip\";\n b.textContent = ft.label;\n b.dataset.filter = ft.id;\n b.setAttribute(\"aria-pressed\", ft.id === state.filter ? \"true\" : \"false\");\n b.addEventListener(\"click\", function () {\n state.filter = ft.id;\n $$(\".filter-chip\", el.feedFilters).forEach(function (x) {\n x.setAttribute(\"aria-pressed\", x === b ? \"true\" : \"false\");\n });\n rebuildFeed(currentVisibleEvents());\n });\n el.feedFilters.appendChild(b);\n });\n }\n\n /* ------------------------------------------------------------------ layout */\n function layoutStage() {\n stageW = el.stage.clientWidth;\n stageH = el.stage.clientHeight;\n if (!stageW || !stageH) return;\n // 42px 底部「此刻」条 + 约 70px 节点标签空间,避免节点文字压到时间轴\n var graphH = Math.max(140, stageH - 42 - 70);\n var pos = stagePositions(stageW < 560, stageW);\n el.edgeLayer.setAttribute(\"viewBox\", \"0 0 \" + stageW + \" \" + stageH);\n var pts = {};\n agents.forEach(function (a) {\n var p = pos[a.id];\n if (!p) return;\n var x = p.x * stageW;\n var y = 10 + p.y * graphH;\n var rec = nodeEls[a.id];\n var r = (rec.btn.offsetHeight || 62) / 2;\n pts[a.id] = { x: x, y: y, r: r };\n rec.root.style.left = x.toFixed(1) + \"px\";\n rec.root.style.top = (y - r).toFixed(1) + \"px\";\n });\n if (LEAD && pts[LEAD.id]) {\n el.orbits.style.left = pts[LEAD.id].x.toFixed(1) + \"px\";\n el.orbits.style.top = pts[LEAD.id].y.toFixed(1) + \"px\";\n }\n edgeList.forEach(function (edge) {\n var A = pts[edge.def.a];\n var B = pts[edge.def.b];\n if (!A || !B) return;\n var dx = B.x - A.x, dy = B.y - A.y;\n var len = Math.sqrt(dx * dx + dy * dy) || 1;\n var ux = dx / len, uy = dy / len;\n var padA = A.r + 10, padB = B.r + 10;\n var x1 = A.x + ux * padA, y1 = A.y + uy * padA;\n var x2 = B.x - ux * padB, y2 = B.y - uy * padB;\n var mx = (x1 + x2) / 2, my = (y1 + y2) / 2;\n var nx = -uy, ny = ux;\n var bow = edge.def.peer ? 0.2 : 0.085;\n var cx = mx + nx * len * bow * 0.5;\n var cy = my + ny * len * bow * 0.5;\n edge.path.setAttribute(\"d\",\n \"M \" + x1.toFixed(1) + \" \" + y1.toFixed(1) +\n \" Q \" + cx.toFixed(1) + \" \" + cy.toFixed(1) +\n \" \" + x2.toFixed(1) + \" \" + y2.toFixed(1));\n edge.len = edge.path.getTotalLength();\n });\n }\n\n function rebuildRuler() {\n var w = el.laneTracks.clientWidth;\n var step = w < 380 ? 240 : 120;\n el.laneRuler.innerHTML = \"\";\n var t = 0;\n while (t <= END) { addTick(t); t += step; }\n if (END % step !== 0) addTick(END);\n function addTick(time) {\n var d = document.createElement(\"span\");\n d.className = \"ruler-tick\";\n d.style.left = (time / END * 100).toFixed(3) + \"%\";\n d.textContent = fmt(time);\n el.laneRuler.appendChild(d);\n }\n }\n\n function rebuildLaneLinks() {\n var tracksBox = el.laneTracks.getBoundingClientRect();\n var w = tracksBox.width;\n var h = tracksBox.height;\n if (!w || !h) return;\n el.laneLinks.setAttribute(\"viewBox\", \"0 0 \" + w + \" \" + h);\n el.laneLinks.innerHTML = \"\";\n laneLinkEls = [];\n var rowY = {};\n agents.forEach(function (a) {\n var row = laneRowEls[a.id];\n if (!row) return;\n var box = row.getBoundingClientRect();\n rowY[a.id] = box.top + box.height / 2 - tracksBox.top;\n });\n MESSAGES.forEach(function (m) {\n var y1 = rowY[m.from], y2 = rowY[m.to];\n if (y1 == null || y2 == null) return;\n var x = m.t / END * w;\n var pathNode = document.createElementNS(NS, \"path\");\n pathNode.setAttribute(\"class\", \"lane-link\");\n pathNode.setAttribute(\"d\",\n \"M \" + x.toFixed(1) + \" \" + y1.toFixed(1) +\n \" C \" + (x + 14).toFixed(1) + \" \" + y1.toFixed(1) +\n \", \" + (x + 14).toFixed(1) + \" \" + y2.toFixed(1) +\n \", \" + (x + 3).toFixed(1) + \" \" + y2.toFixed(1));\n var dot = document.createElementNS(NS, \"circle\");\n dot.setAttribute(\"class\", \"lane-link-dot\");\n dot.setAttribute(\"cx\", (x + 3).toFixed(1));\n dot.setAttribute(\"cy\", y2.toFixed(1));\n dot.setAttribute(\"r\", \"1.8\");\n el.laneLinks.appendChild(pathNode);\n el.laneLinks.appendChild(dot);\n laneLinkEls.push({ msg: m, path: pathNode, dot: dot, visible: null, recent: null });\n });\n }\n\n function queueLayout() {\n if (resizeQueued) return;\n resizeQueued = true;\n requestAnimationFrame(function () {\n resizeQueued = false;\n layoutStage();\n rebuildRuler();\n rebuildLaneLinks();\n renderAll();\n if (state.playing || state.completed) scrollFeedToLatest();\n });\n }\n\n /* ------------------------------------------------------------------ selection */\n function selectAgent(id, userInitiated) {\n if (!agentById[id]) return;\n if (userInitiated) setFollow(false);\n if (state.selected === id) {\n forceInspector = true;\n return;\n }\n state.selected = id;\n forceInspector = true;\n updateSelectionClasses();\n renderStage();\n renderTasks();\n renderInspector(true);\n }\n\n function updateSelectionClasses() {\n el.stage.classList.toggle(\"has-focus\", !!state.focus);\n edgeList.forEach(function (edge) {\n edge.path.classList.toggle(\"is-connected\", edge.def.a === state.selected || edge.def.b === state.selected);\n });\n el.focusBtn.setAttribute(\"aria-pressed\", state.focus ? \"true\" : \"false\");\n }\n\n function setFollow(on) {\n state.follow = !!on;\n el.followBtn.setAttribute(\"aria-pressed\", state.follow ? \"true\" : \"false\");\n if (state.follow) {\n var idx = latestEventIndex(state.t);\n if (idx >= 0) selectAgent(EVENTS[idx].actor, false);\n }\n }\n\n function syncFollow() {\n if (!state.follow) return;\n var idx = latestEventIndex(state.t);\n if (idx < 0) return;\n var actor = EVENTS[idx].actor;\n if (agentById[actor] && actor !== state.selected) selectAgent(actor, false);\n }\n\n /* ------------------------------------------------------------------ playback */\n function applyPlayState() {\n var playing = state.playing;\n var completed = state.completed;\n if (lastPlaying !== playing || lastCompleted !== completed) {\n lastPlaying = playing;\n lastCompleted = completed;\n el.playIconUse.setAttribute(\"href\", playing ? \"#i-pause\" : \"#i-play\");\n el.playLabel.textContent = playing ? \"暂停\" : (completed ? \"重播\" : \"播放\");\n el.playBtn.setAttribute(\"aria-label\",\n playing ? \"暂停回放\" : (completed ? \"重新播放\" : \"播放回放\"));\n el.runState.textContent = completed ? \"已完成\" : (playing ? \"回放中\" : (state.t > 0 ? \"已暂停\" : \"待播放\"));\n el.app.classList.toggle(\"is-paused\", !playing);\n el.app.classList.toggle(\"is-complete\", !!completed);\n }\n }\n\n function setPlaying(play) {\n if (play && state.t >= END - 0.001) {\n state.t = 0;\n state.completed = false;\n }\n state.playing = !!play;\n if (!state.playing) state.completed = state.t >= END - 0.001;\n applyPlayState();\n }\n\n function pause() { setPlaying(false); }\n\n function togglePlay() {\n if (state.t >= END - 0.001) {\n state.t = 0;\n state.completed = false;\n state.playing = true;\n applyPlayState();\n return;\n }\n setPlaying(!state.playing);\n }\n\n function seek(t) {\n state.t = clamp(t, 0, END);\n if (state.t >= END - 0.001) {\n state.t = END;\n state.completed = true;\n state.playing = false;\n } else {\n state.completed = false;\n }\n forceInspector = true;\n applyPlayState();\n renderAll();\n }\n\n function seekFromClientX(clientX) {\n var box = el.laneTracks.getBoundingClientRect();\n var ratio = clamp((clientX - box.left) / box.width, 0, 1);\n seek(ratio * END);\n }\n\n /* ------------------------------------------------------------------ stage render */\n function renderStage() {\n var t = state.t;\n var connected = connectedSet();\n var alertAgent = blockerActive(t) ? \"lens\" : null;\n agents.forEach(function (a) {\n var rec = nodeEls[a.id];\n var st = agentStatus(a, t);\n var cur = workAt(a, t);\n var cls = \"node is-\" + st;\n if (alertAgent === a.id) cls += \" is-alert\";\n if (state.selected === a.id) cls += \" is-selected\";\n if (connected[a.id]) cls += \" is-connected\";\n if (rec.root.classList.contains(\"is-tree-hidden\")) cls += \" is-tree-hidden\";\n if (rec.root.className !== cls) rec.root.className = cls;\n\n var badgeId = st === \"active\" ? \"i-activity\" : (st === \"done\" ? \"i-check\" : \"i-clock\");\n if (alertAgent === a.id && st !== \"active\") badgeId = \"i-alert\";\n if (rec.badge.__id !== badgeId) {\n rec.badge.__id = badgeId;\n rec.badge.innerHTML = icon(badgeId);\n }\n\n var activity = cur ? cur.work.activity\n : (st === \"done\" ? \"工作已完成\"\n : (st === \"waiting\" ? (WAIT_ACTIVITY[a.id] || \"等待中\") : \"待命\"));\n if (rec.activityText.textContent !== activity) rec.activityText.textContent = activity;\n rec.mini.hidden = st !== \"active\";\n\n if (st === \"active\" && cur) {\n var p = clamp((t - cur.work.s) / (cur.work.e - cur.work.s), 0, 1);\n rec.ringValue.style.strokeDashoffset = (226 * (1 - p)).toFixed(1);\n }\n\n var press = state.selected === a.id ? \"true\" : \"false\";\n if (rec.btn.getAttribute(\"aria-pressed\") !== press) rec.btn.setAttribute(\"aria-pressed\", press);\n var label = a.name + \",\" + a.roleCn + \",\" + STATUS_TEXT[st] + (cur ? \",\" + cur.work.activity : \"\");\n if (rec.btn.getAttribute(\"aria-label\") !== label) {\n rec.btn.setAttribute(\"aria-label\", label);\n rec.btn.setAttribute(\"title\", label);\n }\n });\n updateHotEdges(t);\n updateParticles(t);\n }\n\n function updateHotEdges(t) {\n var hot = {};\n MESSAGES.forEach(function (m) {\n if (t >= m.t && t <= m.t + m.travel) {\n hot[edgeKey(m.from, m.to)] = agentById[m.from].color;\n }\n });\n var sig = JSON.stringify(hot);\n if (sig === lastHotSig) return;\n lastHotSig = sig;\n edgeList.forEach(function (edge) {\n var color = hot[edge.key];\n if (color) {\n edge.path.classList.add(\"is-hot\");\n edge.path.style.stroke = color;\n edge.path.style.opacity = \"0.72\";\n } else {\n edge.path.classList.remove(\"is-hot\");\n edge.path.style.stroke = \"\";\n edge.path.style.opacity = \"\";\n }\n });\n }\n\n function updateParticles(t) {\n particleList.forEach(function (p) {\n var m = p.msg;\n var show = t >= m.t && t <= m.t + m.travel;\n if (p.visible !== show) {\n p.visible = show;\n p.g.style.display = show ? \"\" : \"none\";\n }\n if (!show) return;\n var edge = edgeByKey[edgeKey(m.from, m.to)];\n if (!edge || !edge.len) return;\n var ratio = (t - m.t) / m.travel;\n var dist = (m.from === edge.def.a ? ratio : 1 - ratio) * edge.len;\n var pt;\n try { pt = edge.path.getPointAtLength(dist); } catch (err) { return; }\n p.g.setAttribute(\"transform\", \"translate(\" + pt.x.toFixed(2) + \" \" + pt.y.toFixed(2) + \")\");\n });\n }\n\n /* ------------------------------------------------------------------ lanes render */\n function renderLanes() {\n var t = state.t;\n segmentEls.forEach(function (seg) {\n var w = seg.work;\n var started = t >= w.s;\n var ended = t >= w.e;\n var p = started ? clamp((t - w.s) / (w.e - w.s), 0, 1) : 0;\n seg.fill.style.width = (p * 100).toFixed(2) + \"%\";\n var cls = \"seg\";\n if (seg.agentId === state.selected) cls += \" is-selected\";\n if (started && !ended) cls += \" is-running\";\n if (!started) cls += \" is-upcoming\";\n if (seg.tiny) cls += \" is-tiny\";\n if (seg.cls !== cls) { seg.cls = cls; seg.el.className = cls; }\n });\n\n var ratio = t / END;\n el.playhead.style.left = (ratio * 100).toFixed(3) + \"%\";\n\n var showBlock = t >= BLOCKER.from;\n if (el.blockerBand.hidden === showBlock) el.blockerBand.hidden = !showBlock;\n if (showBlock) {\n var endT = Math.min(t, BLOCKER.to);\n var left = BLOCKER.from / END * 100;\n var width = Math.max(0.4, (endT - BLOCKER.from) / END * 100);\n el.blockerBand.style.left = left.toFixed(3) + \"%\";\n el.blockerBand.style.width = width.toFixed(3) + \"%\";\n var label = t < BLOCKER.to\n ? \"阻塞 · \" + fmt(t - BLOCKER.from)\n : \"阻塞已解除 · \" + fmt(BLOCKER.to - BLOCKER.from);\n if (el.blockerLabel.textContent !== label) el.blockerLabel.textContent = label;\n }\n\n laneLinkEls.forEach(function (link) {\n var visible = t >= link.msg.t;\n if (link.visible !== visible) {\n link.visible = visible;\n link.path.style.display = visible ? \"\" : \"none\";\n link.dot.style.display = visible ? \"\" : \"none\";\n }\n if (!visible) return;\n var recent = (t - link.msg.t) <= 10;\n if (link.recent !== recent) {\n link.recent = recent;\n link.path.classList.toggle(\"is-recent\", recent);\n link.dot.classList.toggle(\"is-recent\", recent);\n }\n });\n }\n\n /* ------------------------------------------------------------------ feed */\n function isFeedNearBottom() {\n var node = el.feedScroll;\n return node.scrollHeight - node.scrollTop - node.clientHeight < 36;\n }\n\n function feedItemEl(ev, animate) {\n var li = document.createElement(\"li\");\n li.className = \"feed-item t-\" + ev.type;\n if (!animate) li.classList.add(\"no-anim\");\n li.innerHTML =\n '<span class=\"feed-time\">' + fmt(ev.t) + \"</span>\" +\n '<span class=\"feed-icon\">' + icon(TYPE_ICON[ev.type] || \"i-info\") + \"</span>\" +\n '<span class=\"feed-text\">' + spanMeta(ev) + \"</span>\";\n li.tabIndex = 0;\n li.setAttribute(\"role\", \"button\");\n li.setAttribute(\"aria-label\", fmt(ev.t) + \" \" + agentName(ev.actor) + \" \" + ev.text);\n li.addEventListener(\"click\", function () {\n pause();\n seek(ev.t);\n selectAgent(ev.actor, true);\n });\n li.addEventListener(\"keydown\", function (e) {\n if (e.key === \"Enter\" || e.key === \" \") { e.preventDefault(); li.click(); }\n });\n return li;\n }\n\n function rebuildFeed(visible) {\n el.feedList.innerHTML = \"\";\n renderedEvents = visible;\n if (!visible.length) {\n var empty = document.createElement(\"li\");\n empty.className = \"feed-empty\";\n empty.textContent = state.filter === \"all\" ? \"回放开始后,事件会在这里出现\" : \"该类型暂无事件\";\n el.feedList.appendChild(empty);\n } else {\n var frag = document.createDocumentFragment();\n visible.forEach(function (ev) { frag.appendChild(feedItemEl(ev, false)); });\n el.feedList.appendChild(frag);\n }\n updateFeedMeta(visible);\n el.feedScroll.scrollTop = el.feedScroll.scrollHeight;\n el.feedJump.hidden = true;\n requestAnimationFrame(function () {\n el.feedScroll.scrollTop = el.feedScroll.scrollHeight;\n el.feedJump.hidden = true;\n });\n }\n\n function appendFeed(items) {\n if (!items.length) return;\n var near = isFeedNearBottom();\n var frag = document.createDocumentFragment();\n items.forEach(function (ev) { frag.appendChild(feedItemEl(ev, true)); });\n var empty = el.feedList.querySelector(\".feed-empty\");\n if (empty) empty.parentNode.removeChild(empty);\n el.feedList.appendChild(frag);\n renderedEvents = renderedEvents.concat(items);\n updateFeedMeta(renderedEvents);\n if (near) {\n el.feedScroll.scrollTop = el.feedScroll.scrollHeight;\n el.feedJump.hidden = true;\n } else {\n el.feedJump.hidden = false;\n }\n }\n\n function updateFeedMeta(visible) {\n var total = EVENTS.filter(matchesFilter).length;\n var text = visible.length + \" / \" + total;\n if (el.feedCount.textContent !== text) el.feedCount.textContent = text;\n }\n\n function syncFeed() {\n var visible = currentVisibleEvents();\n var same = visible.length >= renderedEvents.length;\n if (same) {\n for (var i = 0; i < renderedEvents.length; i++) {\n if (visible[i] !== renderedEvents[i]) { same = false; break; }\n }\n }\n if (!same) { rebuildFeed(visible); return; }\n if (visible.length > renderedEvents.length) appendFeed(visible.slice(renderedEvents.length));\n else updateFeedMeta(visible);\n }\n\n function scrollFeedToLatest() {\n el.feedScroll.scrollTop = el.feedScroll.scrollHeight;\n el.feedJump.hidden = true;\n }\n\n /* ------------------------------------------------------------------ inspector */\n function renderInspector(force) {\n var now = performance.now();\n if (!force && now - lastInspectorStamp < 160) return;\n lastInspectorStamp = now;\n var t = state.t;\n var a = agentById[state.selected];\n if (!a) return;\n var st = agentStatus(a, t);\n var cur = workAt(a, t);\n var next = null;\n for (var i = 0; i < a.work.length; i++) {\n if (a.work[i].s > t) { next = a.work[i]; break; }\n }\n var involved = EVENTS.filter(function (ev) {\n return ev.t <= t + 0.001 && (ev.actor === a.id || ev.target === a.id);\n });\n var recent = involved.slice(-3).reverse();\n var tools = EVENTS.filter(function (ev) { return ev.type === \"tool\" && ev.actor === a.id && ev.t <= t + 0.001; });\n var artifacts = EVENTS.filter(function (ev) { return ev.type === \"artifact\" && ev.actor === a.id && ev.t <= t + 0.001; });\n var msgs = MESSAGES.filter(function (m) { return m.t <= t + 0.001 && (m.from === a.id || m.to === a.id); });\n var owned = TASKS.filter(function (task) { return task.owner === a.id; });\n var doneOwned = owned.filter(function (task) { return t >= task.end; }).length;\n var statusClass = st === \"done\" ? \"is-done\" : (st === \"active\" ? \"is-active\" : \"\");\n var statusLabel = STATUS_TEXT[st];\n if (blockerActive(t) && a.id === \"lens\") {\n statusClass = \"is-alert\";\n statusLabel = \"发现阻塞\";\n }\n\n var html = \"\";\n html += '<div class=\"insp-head\">';\n html += '<span class=\"insp-avatar\">' + icon(a.icon) + \"</span>\";\n html += '<div class=\"insp-id\"><div class=\"insp-name\">' + a.name +\n '<span class=\"role\">' + a.roleEn + \" · \" + a.roleCn + \"</span></div>\";\n html += '<div class=\"insp-sub\"><span>' + a.model + '</span><span>已活跃 ' + fmt(activeTime(a, t)) + \"</span></div></div>\";\n html += '<span class=\"insp-status ' + statusClass + '\"><i></i>' + statusLabel + \"</span>\";\n html += \"</div>\";\n\n html += '<div class=\"insp-stats\">';\n html += '<div class=\"insp-stat\"><b>' + tools.length + \"</b><span>工具调用</span></div>\";\n html += '<div class=\"insp-stat\"><b>' + msgs.length + \"</b><span>协作消息</span></div>\";\n html += '<div class=\"insp-stat\"><b>' + artifacts.length + \"</b><span>产出</span></div>\";\n html += \"</div>\";\n\n html += '<div class=\"insp-section\"><div class=\"insp-label\"><span>当前工作</span><span>' +\n (cur ? (cur.work.task || \"持续中\") : \"—\") + \"</span></div>\";\n if (cur) {\n var p = clamp((t - cur.work.s) / (cur.work.e - cur.work.s), 0, 1);\n html += '<div class=\"work-card\">';\n html += '<div class=\"work-title\"><span class=\"dot\"></span>' + cur.work.label + \"</div>\";\n html += '<div class=\"work-meta\"><span>已进行 ' + fmt(t - cur.work.s) + \"</span><span>段长 \" + fmt(cur.work.e - cur.work.s) + \"</span></div>\";\n html += '<div class=\"progress\"><span class=\"progress-fill\" style=\"width:' + (p * 100).toFixed(1) + '%\"></span></div>';\n html += \"</div>\";\n } else if (st === \"done\") {\n html += '<div class=\"wait-card\">全部工作已完成。<br>最后动作:<b>' +\n (recent[0] ? recent[0].text : \"—\") + \"</b></div>\";\n } else {\n html += '<div class=\"wait-card\">' + (WAIT_NOTES[a.id] || \"等待中\") +\n (next ? '。<br>下一项:<b>' + next.label + \"</b> · 预计 \" + fmt(next.s) + \" 开始\" : \"\") + \"</div>\";\n }\n html += \"</div>\";\n\n html += '<div class=\"insp-section\"><div class=\"insp-label\"><span>最近动作</span><span>' +\n (doneOwned + \"/\" + owned.length + \" 工作项\") + \"</span></div>\";\n if (recent.length) {\n html += '<div class=\"insp-events\">';\n recent.forEach(function (ev) {\n html += '<div class=\"insp-event\" style=\"--tone:' + (TYPE_TONE[ev.type] || \"var(--text-3)\") + '\">';\n html += '<span class=\"t\">' + fmt(ev.t) + \"</span>\";\n html += icon(TYPE_ICON[ev.type] || \"i-info\");\n html += \"<span>\" + ev.text + \"</span>\";\n html += \"</div>\";\n });\n html += \"</div>\";\n } else {\n html += '<div class=\"empty-note\">尚未产生可直接观察的动作。</div>';\n }\n html += \"</div>\";\n\n if (artifacts.length) {\n html += '<div class=\"insp-section\"><div class=\"insp-label\"><span>产出</span><span>' + artifacts.length + \"</span></div>\";\n html += '<div class=\"artifacts\">';\n artifacts.forEach(function (ev) {\n html += '<div class=\"artifact\">' + icon(\"i-file\") + \"<span>\" + ev.text + '</span><span class=\"t\">' + fmt(ev.t) + \"</span></div>\";\n });\n html += \"</div></div>\";\n }\n\n el.inspector.style.setProperty(\"--c\", a.color);\n var inspectorScroll = el.inspector.scrollTop;\n el.inspector.innerHTML = html;\n el.inspector.scrollTop = inspectorScroll;\n }\n\n /* ------------------------------------------------------------------ metrics */\n function renderMetrics() {\n var t = state.t;\n var progress = overallProgress(t);\n el.goalRing.style.strokeDashoffset = (188.5 * (1 - progress)).toFixed(1);\n var pctText = pct(progress);\n if (el.goalPct.__v !== pctText) {\n el.goalPct.__v = pctText;\n el.goalPct.innerHTML = pctText + '<span class=\"pct-sign\">%</span>';\n }\n el.goalElapsed.textContent = fmt(t);\n el.goalEta.textContent = fmt(END);\n\n var activeCount = agents.filter(function (a) { return agentStatus(a, t) === \"active\"; }).length;\n var doneCount = TASKS.filter(function (task) { return t >= task.end; }).length;\n var toolCount = EVENTS.filter(function (ev) { return ev.type === \"tool\" && ev.t <= t + 0.001; }).length;\n var blocked = blockerActive(t) ? 1 : 0;\n\n setHTML(el.statActive, activeCount + \"<i>/\" + agents.length + \"</i>\");\n setHTML(el.statDone, doneCount + \"<i>/\" + TASKS.length + \"</i>\");\n setText(el.statCalls, String(toolCount));\n setText(el.statBlocked, String(blocked));\n el.statBlockedCell.classList.toggle(\"is-danger\", !!blocked);\n setText(el.taskCount, doneCount + \"/\" + TASKS.length);\n\n if (lastTimeText !== fmt(t)) {\n lastTimeText = fmt(t);\n el.timeNow.textContent = lastTimeText;\n el.laneTime.textContent = lastTimeText;\n el.nowTime.textContent = lastTimeText;\n el.scrubInput.value = String(Math.round(t));\n el.scrubInput.setAttribute(\"aria-valuetext\", lastTimeText);\n }\n\n renderTasks();\n renderNow();\n }\n\n function renderTasks() {\n var t = state.t;\n TASKS.forEach(function (task) {\n var item = taskEls[task.id];\n if (!item) return;\n var st = taskStatus(task, t);\n var cls = \"task-item is-\" + st;\n if (task.owner === state.selected && st === \"running\") cls += \" is-selected\";\n if (item.cls !== cls) { item.cls = cls; item.root.className = cls; }\n var iconId = st === \"done\" ? \"i-check\"\n : st === \"running\" ? \"i-activity\"\n : (st === \"alert\" || st === \"blocked\") ? \"i-alert\" : \"i-clock\";\n if (item.iconId !== iconId) { item.iconId = iconId; item.icon.innerHTML = icon(iconId); }\n var tail;\n if (st === \"done\") tail = fmt(task.end - task.start);\n else if (st === \"running\") tail = pct((t - task.start) / (task.end - task.start)) + \"%\";\n else if (st === \"blocked\") tail = \"受阻\";\n else if (st === \"alert\") tail = \"发现问题\";\n else tail = \"等待\";\n if (item.tailTxt !== tail) { item.tailTxt = tail; item.tail.textContent = tail; }\n });\n }\n\n function renderNow() {\n var idx = latestEventIndex(state.t);\n if (idx === lastNowIdx) return;\n lastNowIdx = idx;\n if (idx < 0) {\n el.nowText.textContent = \"等待开始\";\n return;\n }\n var ev = EVENTS[idx];\n var temp = document.createElement(\"span\");\n temp.innerHTML = spanMeta(ev);\n el.nowText.innerHTML = temp.innerHTML;\n }\n\n function setText(node, text) { if (node.textContent !== text) node.textContent = text; }\n function setHTML(node, text) { if (node.__html !== text) { node.__html = text; node.innerHTML = text; } }\n\n function renderAll() {\n renderStage();\n renderLanes();\n syncFeed();\n renderMetrics();\n renderInspector(true);\n renderNow();\n }\n\n /* ------------------------------------------------------------------ loop */\n function frame(ts) {\n var dt = frame.last ? Math.min(0.06, (ts - frame.last) / 1000) : 0;\n frame.last = ts;\n if (state.playing) {\n state.t += dt * RATE * state.speed;\n if (state.t >= END) {\n state.t = END;\n state.playing = false;\n state.completed = true;\n applyPlayState();\n }\n }\n syncFollow();\n renderStage();\n renderLanes();\n syncFeed();\n if (ts - lastUiStamp > 100) {\n lastUiStamp = ts;\n renderMetrics();\n }\n if (forceInspector || ts - lastInspectorStamp > 160) {\n forceInspector = false;\n renderInspector(true);\n }\n requestAnimationFrame(frame);\n }\n\n /* ------------------------------------------------------------------ interactions */\n function bindControls() {\n el.playBtn.addEventListener(\"click\", togglePlay);\n el.restartBtn.addEventListener(\"click\", function () {\n seek(0);\n setPlaying(true);\n });\n el.helpBtn.addEventListener(\"click\", function () { openHelp(); });\n $$(\".speed-btn\").forEach(function (btn) {\n btn.addEventListener(\"click\", function () {\n state.speed = parseFloat(btn.dataset.speed) || 1;\n $$(\".speed-btn\").forEach(function (x) {\n x.setAttribute(\"aria-pressed\", x === btn ? \"true\" : \"false\");\n });\n });\n });\n el.focusBtn.addEventListener(\"click\", function () {\n state.focus = !state.focus;\n updateSelectionClasses();\n });\n el.followBtn.addEventListener(\"click\", function () { setFollow(!state.follow); });\n\n el.scrubInput.addEventListener(\"input\", function () {\n pause();\n seek(parseFloat(el.scrubInput.value) || 0);\n });\n\n var scrubbing = false;\n el.laneTracks.addEventListener(\"pointerdown\", function (e) {\n if (e.button !== 0) return;\n var seg = e.target.closest ? e.target.closest(\".seg\") : null;\n scrubbing = true;\n pause();\n try { el.laneTracks.setPointerCapture(e.pointerId); } catch (err) {}\n seekFromClientX(e.clientX);\n if (seg) selectAgent(seg.dataset.agent, true);\n e.preventDefault();\n });\n el.laneTracks.addEventListener(\"pointermove\", function (e) {\n if (!scrubbing) return;\n seekFromClientX(e.clientX);\n });\n el.laneTracks.addEventListener(\"pointerup\", function () { scrubbing = false; });\n el.laneTracks.addEventListener(\"pointercancel\", function () { scrubbing = false; });\n\n el.feedScroll.addEventListener(\"scroll\", function () {\n el.feedJump.hidden = isFeedNearBottom() || renderedEvents.length === 0;\n });\n el.feedJump.addEventListener(\"click\", scrollFeedToLatest);\n\n el.helpDialog.addEventListener(\"click\", function (e) {\n if (e.target === el.helpDialog) el.helpDialog.close();\n });\n $$(\"[data-close]\", el.helpDialog).forEach(function (btn) {\n btn.addEventListener(\"click\", function () { el.helpDialog.close(); });\n });\n\n document.addEventListener(\"keydown\", onKeydown);\n\n window.addEventListener(\"resize\", queueLayout);\n var ro = new ResizeObserver(queueLayout);\n ro.observe(el.stage);\n ro.observe(el.laneTracks);\n }\n\n function openHelp() {\n if (typeof el.helpDialog.showModal === \"function\") el.helpDialog.showModal();\n else el.helpDialog.setAttribute(\"open\", \"\");\n }\n\n function onKeydown(e) {\n var tag = (e.target.tagName || \"\").toLowerCase();\n if (tag === \"input\" || tag === \"textarea\" || tag === \"select\" || e.target.isContentEditable) return;\n if (el.helpDialog.open) {\n if (e.key === \"Escape\") el.helpDialog.close();\n return;\n }\n var key = e.key;\n if (key === \" \" || key === \"Spacebar\" || e.code === \"Space\") {\n e.preventDefault();\n togglePlay();\n } else if (key === \"ArrowLeft\" || key === \"ArrowRight\") {\n e.preventDefault();\n pause();\n var delta = (e.shiftKey ? 60 : 10) * (key === \"ArrowLeft\" ? -1 : 1);\n seek(state.t + delta);\n } else if (key === \"Home\") {\n e.preventDefault();\n pause();\n seek(0);\n } else if (key === \"End\") {\n e.preventDefault();\n pause();\n seek(END);\n } else if (key === \"r\" || key === \"R\") {\n seek(0);\n setPlaying(true);\n } else if (key === \"1\" || key === \"2\" || key === \"4\") {\n state.speed = parseFloat(key);\n $$(\".speed-btn\").forEach(function (x) {\n x.setAttribute(\"aria-pressed\", x.dataset.speed === key ? \"true\" : \"false\");\n });\n } else if (key === \"f\" || key === \"F\") {\n state.focus = !state.focus;\n updateSelectionClasses();\n } else if (key === \"g\" || key === \"G\") {\n setFollow(!state.follow);\n } else if (key === \"?\" || (key === \"/\" && e.shiftKey)) {\n openHelp();\n }\n }\n\n function scheduleTip() {\n el.tipToast.textContent = window.innerWidth < 760\n ? \"点击节点检视 · 拖动时间轴回看\"\n : \"空格播放 / 暂停 · 点击节点检视 · 拖动泳道回看\";\n window.setTimeout(function () {\n el.tipToast.classList.add(\"is-visible\");\n }, 1000);\n window.setTimeout(function () {\n el.tipToast.classList.remove(\"is-visible\");\n }, 8000);\n var hide = function () { el.tipToast.classList.remove(\"is-visible\"); };\n window.addEventListener(\"pointerdown\", hide, { once: true });\n }\n\n function hydrateStatic() {\n el.runId.textContent = META.runId;\n el.runGoalShort.textContent = META.shortGoal;\n el.runStarted.textContent = META.startedAt + \" 启动\";\n el.goalTitle.textContent = META.goal;\n el.goalProject.textContent = META.project;\n el.goalBranch.textContent = META.branch;\n el.timeTotal.textContent = fmt(END);\n el.goalEta.textContent = fmt(END);\n /* [EMBED] reload 保留 state.t,这里不归零,避免闪帧 */\n el.scrubInput.setAttribute(\"max\", String(END));\n el.scrubInput.setAttribute(\"aria-valuemax\", String(END));\n el.scrubInput.setAttribute(\"aria-valuenow\", \"0\");\n el.scrubInput.setAttribute(\"aria-valuetext\", \"00:00\");\n el.orbits.style.left = \"50%\";\n el.orbits.style.top = \"44%\";\n }\n\n /* [EMBED] 全量重载:重算索引 -> 重建全部动态 DOM -> 重渲染(保留回看位置与视图状态) */\n function reload(nextData) {\n var prevT = state.t;\n var wasFollow = state.follow;\n var prevFilter = state.filter;\n var feedEl = el.feedScroll;\n var wasPlaying = state.playing;\n var prevFeedTop = feedEl ? feedEl.scrollTop : 0;\n var prevFeedBottom = feedEl ? (feedEl.scrollHeight - feedEl.scrollTop - feedEl.clientHeight < 36) : true;\n var plateEl = document.querySelector('.plate-weave');\n var prevPlateCollapsed = plateEl ? plateEl.classList.contains('is-collapsed') : false;\n var inspEl = document.getElementById('inspector');\n var prevInspTop = inspEl ? inspEl.scrollTop : 0;\n indexData(nextData);\n state.t = clamp(prevT, 0, END);\n state.playing = false;\n state.completed = state.t >= END - 0.001;\n state.filter = prevFilter;\n renderedEvents = [];\n lastNowIdx = -2;\n lastTimeText = \"\";\n lastHotSig = \"\";\n lastInspectorStamp = 0;\n lastUiStamp = 0;\n lastPlaying = null;\n lastCompleted = null;\n forceInspector = true;\n cacheEls();\n hydrateStatic();\n applyAgentScaleClasses();\n buildNodes();\n buildEdges();\n buildParticles();\n buildLanes();\n buildTasks();\n buildFilters();\n rebuildFeed(currentVisibleEvents());\n layoutStage();\n refreshTreeVisibility();\n rebuildRuler();\n rebuildLaneLinks();\n updateSelectionClasses();\n setFollow(wasFollow);\n applyPlayState();\n renderAll();\n if (window.WEAVE_EDITION && window.WEAVE_EDITION.refresh) {\n window.WEAVE_EDITION.refresh();\n }\n if (plateEl) plateEl.classList.toggle('is-collapsed', prevPlateCollapsed);\n if (!liveMode && wasPlaying) { state.playing = true; applyPlayState(); }\n /* 滚动恢复排在本轮 rebuildFeed/renderInspector 的 rAF 之后,否则会被拉回底部 */\n requestAnimationFrame(function () {\n if (feedEl) feedEl.scrollTop = prevFeedBottom ? feedEl.scrollHeight : prevFeedTop;\n if (inspEl) inspEl.scrollTop = prevInspTop;\n });\n }\n\n /* [EMBED] 按智能体数量切换缩放类(原 init() 中的四行) */\n function applyAgentScaleClasses() {\n el.app.classList.toggle(\"agents-many\", agents.length > 5);\n el.app.classList.toggle(\"agents-crowded\", agents.length > 7);\n el.app.classList.toggle(\"agents-swarm\", agents.length > 9);\n el.app.classList.toggle(\"agents-hive\", agents.length > 11);\n }\n\n function init() {\n /* [EMBED] 首次启动时建立数据索引,并设置缩放类 */\n indexData(initialData);\n cacheEls();\n applyAgentScaleClasses();\n hydrateStatic();\n buildNodes();\n buildEdges();\n buildParticles();\n buildLanes();\n buildTasks();\n buildFilters();\n layoutStage();\n refreshTreeVisibility();\n rebuildRuler();\n rebuildLaneLinks();\n bindControls();\n updateSelectionClasses();\n setFollow(true);\n applyPlayState();\n renderAll();\n if (state.playing) applyPlayState();\n requestAnimationFrame(frame);\n scheduleTip();\n window.WEAVE_DEBUG = {\n state: state,\n seek: seek,\n play: function () { setPlaying(true); },\n pause: pause,\n data: DATA\n };\n }\n\n /* [EMBED] 运行时控制面:init 由外壳在首次 setData 后调用 */\n return {\n init: init,\n reload: reload,\n seek: function (seconds) { setPlaying(false); seek(seconds); },\n setLive: function (on) {\n liveMode = !!on;\n if (liveMode) { setPlaying(false); seek(END); }\n },\n getState: function () {\n return {\n t: state.t, playing: state.playing, completed: state.completed,\n selected: state.selected, follow: state.follow, live: liveMode,\n duration: END, agents: agents.length, events: EVENTS.length\n };\n }\n };\n })(initialData);\n }\n\n /* [EMBED] 把新数据原地合并进 window.WEAVE_DATA,让 v2/edition.js 的同一引用同步更新 */\n function adoptData(next) {\n if (!next || typeof next !== \"object\") {\n throw new Error(\"WeaveLive.setData: data 必须是对象\");\n }\n var target = window.WEAVE_DATA;\n if (target && typeof target === \"object\") {\n Object.keys(target).forEach(function (k) { delete target[k]; });\n Object.keys(next).forEach(function (k) { target[k] = next[k]; });\n return target;\n }\n window.WEAVE_DATA = next;\n return next;\n }\n\n window.WeaveLive = {\n version: (typeof window.WEAVE_EMBED_VERSION === \"string\" ? window.WEAVE_EMBED_VERSION : \"weave-embed/dev\"),\n setData: function (data) {\n var adopted = adoptData(data);\n if (!runtime) {\n runtime = createRuntime(adopted);\n runtime.init();\n if (window.WEAVE_EDITION && window.WEAVE_EDITION.boot) {\n window.WEAVE_EDITION.boot();\n }\n } else {\n runtime.reload(adopted);\n }\n if (liveMode) runtime.setLive(true);\n document.body.classList.add(\"weave-has-data\");\n return runtime.getState();\n },\n setTheme: function (theme) {\n var next = theme === \"dark\" ? \"dark\" : \"light\";\n document.documentElement.setAttribute(\"data-theme\", next);\n document.body.classList.add(\"weave-theme-managed\");\n var sw = document.getElementById(\"themeSwitch\");\n if (sw) {\n sw.setAttribute(\"aria-hidden\", \"true\");\n sw.setAttribute(\"tabindex\", \"-1\");\n }\n var meta = document.getElementById(\"themeColor\");\n if (meta) meta.setAttribute(\"content\", next === \"dark\" ? \"#14110d\" : \"#f1ead9\");\n },\n setLive: function (on) {\n liveMode = !!on;\n if (runtime) runtime.setLive(liveMode);\n },\n seek: function (seconds) { if (runtime) runtime.seek(seconds); },\n getState: function () {\n if (runtime) return runtime.getState();\n return { t: 0, playing: false, completed: false, selected: null, follow: true, live: liveMode, duration: 0, agents: 0, events: 0 };\n }\n };\n})();\n\n</script>\n<script id=\"weave-edition\">\n/* ---- weave-embed/src/edition.patched.js(v2/edition.js 的嵌入转换结果) ---- */\n/* Weave · Silk Edition — interaction chrome layered over ../app.js */\n(function () {\n \"use strict\";\n\n /* [EMBED] iframe sandbox 下 __WEAVE_STORE__ 不可用:用内存桩替代,禁止任何持久化 */\n var __WEAVE_STORE__ = {\n getItem: function () { return null; },\n setItem: function () {},\n removeItem: function () {}\n };\n\n var SEALS = { atlas: \"编\", scout: \"研\", forge: \"造\", lens: \"审\", quill: \"撰\" };\n var SEAL_POOL = [\"策\", \"纲\", \"测\", \"记\", \"译\", \"衡\", \"集\", \"验\", \"构\", \"勘\"];\n\n var sealAssignments = null;\n function ensureSeals() {\n /* [EMBED] 数据热更新:为新出现的成员补充朱印 */\n if (sealAssignments) {\n (DATA.agents || []).forEach(function (a) {\n if (sealAssignments[a.id]) return;\n var ch = a.seal || (a.roleCn ? a.roleCn.charAt(0) : \"\");\n if (!ch) ch = String.fromCharCode(0x4e00 + (((DATA.agents || []).length * 37) % 180));\n sealAssignments[a.id] = ch;\n });\n return;\n }\n sealAssignments = {};\n var used = {};\n (DATA.agents || []).forEach(function (a) {\n if (SEALS[a.id]) { sealAssignments[a.id] = SEALS[a.id]; used[SEALS[a.id]] = true; }\n });\n (DATA.agents || []).forEach(function (a, i) {\n if (sealAssignments[a.id]) return;\n var ch = a.seal || (a.roleCn ? a.roleCn.charAt(0) : \"\");\n /* 数据侧给的朱印优先(子代理用天罡三十六星字,主代理用「编」) */\n if (!ch || used[ch]) {\n ch = \"\";\n for (var j = 0; j < SEAL_POOL.length; j++) {\n if (!used[SEAL_POOL[j]]) { ch = SEAL_POOL[j]; break; }\n }\n }\n if (!ch) ch = String.fromCharCode(0x4e00 + ((i * 37) % 180));\n sealAssignments[a.id] = ch;\n used[ch] = true;\n });\n }\n function sealFor(agent, index) {\n ensureSeals();\n return agent && sealAssignments[agent.id] ? sealAssignments[agent.id] : \"\";\n }\n\n function agentById(id) {\n return (DATA.agents || []).filter(function (a) { return a.id === id; })[0] || null;\n }\n var DATA = window.WEAVE_DATA || { agents: [], tasks: [], meta: { duration: 700 } };\n function __weaveEnd() { return (DATA.meta && DATA.meta.duration) || 700; }\n\n /* 真实 token:优先使用 WEAVE_DATA.meta.tokens.segments(DSH 投影),\n 仅原型演示数据没有该字段时退回模拟模型。真实值按工作段时长分摊,\n 这样时间轴上的累计曲线仍然成立,但总量与来源真实。 */\n function realTokenTotal(agent) {\n var segs = DATA.meta && DATA.meta.tokens && DATA.meta.tokens.segments;\n if (!segs || typeof segs !== \"object\") return null;\n var arr = segs[agent.id];\n if (!Array.isArray(arr)) return null;\n var total = 0;\n for (var i = 0; i < arr.length; i++) {\n var value = Number(arr[i]);\n if (Number.isFinite(value) && value > 0) total += value;\n }\n return total;\n }\n\n /* 模拟的 token 消耗模型:与 agents[].work 的工作段一一对应 */\n var TOKEN_SEGMENTS = {\n atlas: [12400, 84000, 256000, 46000, 188000, 74000],\n scout: [146000, 62000, 28000],\n forge: [312000, 96000, 34000],\n lens: [118000, 52000],\n quill: [96000, 18000, 74000]\n };\n\n function fmtTok(n) {\n if (n >= 1000000) return (n / 1000000).toFixed(2) + \"M\";\n if (n >= 1000) return Math.round(n / 1000) + \"k\";\n return String(Math.round(n));\n }\n\n var generatedTokens = {};\n function tokenSegmentsFor(agent) {\n if (!agent) return [];\n var real = realTokenTotal(agent);\n if (real !== null) {\n var work = agent.work || [];\n if (!work.length) return [real];\n var weights = work.map(function (w) { return Math.max(1, w.e - w.s); });\n var weightSum = weights.reduce(function (a, b) { return a + b; }, 0) || 1;\n return weights.map(function (w) { return real * w / weightSum; });\n }\n if (TOKEN_SEGMENTS[agent.id] && TOKEN_SEGMENTS[agent.id].length === (agent.work || []).length) return TOKEN_SEGMENTS[agent.id];\n if (generatedTokens[agent.id]) return generatedTokens[agent.id];\n var hash = 0;\n String(agent.id).split(\"\").forEach(function (ch) { hash = (hash * 31 + ch.charCodeAt(0)) % 997; });\n var arr = (agent.work || []).map(function (w, i) {\n var rate = 620 + ((hash + i * 137) % 320);\n return Math.round((w.e - w.s) * rate);\n });\n generatedTokens[agent.id] = arr;\n return arr;\n }\n\n function tokenUsage(t) {\n var per = {};\n var total = 0;\n (DATA.agents || []).forEach(function (agent) {\n var arr = tokenSegmentsFor(agent);\n var sum = 0;\n (agent.work || []).forEach(function (w, i) {\n var tok = arr[i] || 0;\n if (t >= w.e) sum += tok;\n else if (t > w.s) sum += tok * (t - w.s) / (w.e - w.s);\n });\n per[agent.id] = sum;\n total += sum;\n });\n return { per: per, total: total };\n }\n\n function setText(id, text) {\n var el = document.getElementById(id);\n if (el && el.textContent !== text) el.textContent = text;\n }\n\n var lastTokenTick = 0;\n function syncTokens() {\n var now = performance.now();\n if (now - lastTokenTick < 140) return;\n lastTokenTick = now;\n var state = window.WEAVE_DEBUG && window.WEAVE_DEBUG.state;\n if (!state) return;\n var usage = tokenUsage(state.t);\n var totalText = fmtTok(usage.total);\n setText(\"tokenHead\", totalText);\n setText(\"wcToken\", totalText + \" TOK\");\n var head = document.getElementById(\"tokenHead\");\n var real = !!(DATA.meta && DATA.meta.tokens && DATA.meta.tokens.simulated !== true);\n if (head) head.setAttribute(\"title\", Math.round(usage.total).toLocaleString() + (real ? \" tokens(来自会话投影)\" : \" tokens(模拟)\"));\n var selected = state.selected;\n var agentTok = usage.per[selected] || 0;\n setText(\"agentToken\", fmtTok(agentTok));\n var share = usage.total > 0 ? Math.round(agentTok / usage.total * 100) : 0;\n setText(\"agentTokenShare\", \"占全局 \" + share + \"%\");\n var bar = document.getElementById(\"agentTokenBar\");\n if (bar) bar.style.width = share + \"%\";\n }\n\n function decorateTokenLabels() {\n document.querySelectorAll(\".seg[data-agent]\").forEach(function (seg) {\n var id = seg.getAttribute(\"data-agent\");\n var idx = parseInt(seg.getAttribute(\"data-index\"), 10);\n var agent = agentById(id);\n var tok = tokenSegmentsFor(agent)[idx];\n if (!tok) return;\n var base = seg.getAttribute(\"title\") || \"\";\n if (base.indexOf(\"tok\") >= 0) return;\n seg.setAttribute(\"title\", base + \" · \" + fmtTok(tok) + \" tok\");\n });\n document.querySelectorAll(\".lane-label\").forEach(function (label, i) {\n var agentId = label.getAttribute(\"data-agent\");\n var agent = agentId ? agentById(agentId) : (DATA.agents || [])[i];\n if (!agent) return;\n var arr = tokenSegmentsFor(agent);\n var sum = arr.reduce(function (a, b) { return a + b; }, 0);\n label.setAttribute(\"title\", agent.name + \" · 全程 \" + fmtTok(sum) + \" tokens\");\n });\n }\n\n var EDGE_PAIRS = [];\n function readEdgePairs() {\n if (window.WEAVE_EDGES && window.WEAVE_EDGES.length) {\n EDGE_PAIRS = window.WEAVE_EDGES.map(function (e) { return [e.a, e.b]; });\n } else {\n EDGE_PAIRS = [];\n }\n }\n var hoverPair = null;\n var WEAVE_KEY = \"weave.v2.weave\";\n var LEFT_KEY = \"weave.v2.left\";\n var RIGHT_KEY = \"weave.v2.right\";\n\n function store(key, value) {\n try { __WEAVE_STORE__.setItem(key, value); } catch (e) {}\n }\n function readStore(key) {\n try { return __WEAVE_STORE__.getItem(key); } catch (e) { return null; }\n }\n function fmt(sec) {\n sec = Math.max(0, Math.min(__weaveEnd(), Math.round(sec)));\n var m = Math.floor(sec / 60);\n var s = sec % 60;\n return (m < 10 ? \"0\" + m : \"\" + m) + \":\" + (s < 10 ? \"0\" + s : \"\" + s);\n }\n function agentSeal(id) { return SEALS[id] || \"\"; }\n function agentColor(id) {\n var found = (DATA.agents || []).filter(function (a) { return a.id === id; })[0];\n return found ? found.color : \"#6b6150\";\n }\n\n /* ---------------------------------------------------------- node decor */\n\n function decorateNodes() {\n document.querySelectorAll(\".node[data-agent]\").forEach(function (node) {\n var id = node.getAttribute(\"data-agent\");\n var btn = node.querySelector(\".node-btn\");\n var agent = agentById(id);\n if (btn) btn.setAttribute(\"data-seal\", sealFor(agent, (DATA.agents || []).indexOf(agent)));\n var role = node.querySelector(\".node-role\");\n if (role && agent && agent.roleCn) role.textContent = agent.roleCn;\n });\n }\n\n function decorateInspector() {\n var insp = document.getElementById(\"inspector\");\n if (!insp) return;\n var nameEl = insp.querySelector(\".insp-name\");\n var avatar = insp.querySelector(\".insp-avatar\");\n if (!nameEl || !avatar) return;\n var text = nameEl.textContent || \"\";\n var agent = (DATA.agents || []).filter(function (a) { return text.indexOf(a.name) === 0; })[0];\n if (agent) avatar.setAttribute(\"data-seal\", sealFor(agent, (DATA.agents || []).indexOf(agent)));\n insp.querySelectorAll(\".insp-section\").forEach(function (sec) {\n sec.classList.toggle(\"insp-section--recent\", !!sec.querySelector(\".insp-events\"));\n sec.classList.toggle(\"insp-section--artifacts\", !!sec.querySelector(\".artifacts\"));\n });\n }\n\n /* ---------------------------------------------------------- weave fold */\n\n function setupWeave() {\n var plate = document.querySelector(\".plate-weave\");\n var toggle = document.getElementById(\"weaveToggle\");\n if (!plate || !toggle) return;\n\n var stored = readStore(WEAVE_KEY);\n // 默认收起:一根进度条;展开态由用户点击「展开织带」或按 T 决定并记忆\n var open = stored ? stored === \"open\" : false;\n\n function apply(next, persist) {\n open = !!next;\n plate.classList.toggle(\"is-collapsed\", !open);\n toggle.setAttribute(\"aria-expanded\", open ? \"true\" : \"false\");\n var label = toggle.querySelector(\"span\");\n if (label) label.textContent = open ? \"收起织带\" : \"展开织带\";\n toggle.setAttribute(\"title\", open ? \"收起完整织带(T)\" : \"展开完整织带(T)\");\n if (persist) store(WEAVE_KEY, open ? \"open\" : \"closed\");\n // 让 app.js 的舞台布局与泳道连线重新测量\n requestAnimationFrame(function () { window.dispatchEvent(new Event(\"resize\")); });\n updateCompact(true);\n }\n\n toggle.addEventListener(\"click\", function () { apply(!open, true); });\n\n /* compact progress bar */\n var fill = document.getElementById(\"wcFill\");\n var head = document.getElementById(\"wcHead\");\n var ticks = document.getElementById(\"wcTicks\");\n var track = document.getElementById(\"wcTrack\");\n var timeEl = document.getElementById(\"wcTime\");\n var statEl = document.getElementById(\"wcStat\");\n\n if (ticks) {\n ticks.innerHTML = \"\";\n (DATA.tasks || []).forEach(function (task) {\n var i = document.createElement(\"i\");\n i.style.left = (task.start / __weaveEnd() * 100).toFixed(3) + \"%\";\n i.style.setProperty(\"--c\", agentColor(task.owner));\n ticks.appendChild(i);\n });\n }\n\n var lastT = -1;\n function updateCompact(force) {\n if (open) return; // 收起时(compact 可见)才更新\n var state = window.WEAVE_DEBUG && window.WEAVE_DEBUG.state;\n var t = state ? state.t : 0;\n if (!force && Math.abs(t - lastT) < 0.2) return;\n lastT = t;\n var pct = Math.max(0, Math.min(1, t / __weaveEnd()));\n if (fill) fill.style.width = (pct * 100).toFixed(2) + \"%\";\n if (head) head.style.left = (pct * 100).toFixed(2) + \"%\";\n if (timeEl) timeEl.textContent = fmt(t);\n var done = (DATA.tasks || []).filter(function (task) { return t >= task.end; }).length;\n if (statEl) statEl.textContent = done + \" / \" + (DATA.tasks || []).length + \" 完成\";\n if (track) {\n track.setAttribute(\"aria-valuenow\", String(Math.round(t)));\n track.setAttribute(\"aria-valuetext\", fmt(t));\n }\n }\n\n if (track) {\n var dragging = false;\n function seekFromX(clientX) {\n var box = track.getBoundingClientRect();\n var ratio = Math.max(0, Math.min(1, (clientX - box.left) / box.width));\n if (window.WEAVE_LIVE && window.WEAVE_LIVE.isLive()) {\n window.WEAVE_LIVE.seekTo(ratio * __weaveEnd());\n return;\n }\n if (window.WEAVE_DEBUG) {\n window.WEAVE_DEBUG.pause();\n window.WEAVE_DEBUG.seek(ratio * __weaveEnd());\n }\n }\n track.addEventListener(\"pointerdown\", function (e) {\n if (e.button !== 0) return;\n dragging = true;\n try { track.setPointerCapture(e.pointerId); } catch (err) {}\n seekFromX(e.clientX);\n e.preventDefault();\n });\n track.addEventListener(\"pointermove\", function (e) {\n if (!dragging) return;\n seekFromX(e.clientX);\n });\n track.addEventListener(\"pointerup\", function () { dragging = false; });\n track.addEventListener(\"pointercancel\", function () { dragging = false; });\n track.addEventListener(\"keydown\", function (e) {\n var t = window.WEAVE_DEBUG ? window.WEAVE_DEBUG.state.t : 0;\n var next = null;\n if (e.key === \"ArrowLeft\") next = t - 10;\n else if (e.key === \"ArrowRight\") next = t + 10;\n else if (e.key === \"Home\") next = 0;\n else if (e.key === \"End\") next = __weaveEnd();\n if (next !== null) {\n e.preventDefault();\n if (window.WEAVE_LIVE && window.WEAVE_LIVE.isLive()) {\n if (e.key === \"End\") window.WEAVE_LIVE.returnLive();\n else window.WEAVE_LIVE.seekTo(next);\n return;\n }\n window.WEAVE_DEBUG.pause();\n window.WEAVE_DEBUG.seek(next);\n }\n });\n }\n\n (function raf() {\n updateCompact(false);\n syncTokens();\n requestAnimationFrame(raf);\n })();\n\n /* [EMBED] 数据热更新:重建紧凑进度条刻度并立即刷新 */\n window.WEAVE_EDITION_WEAVE_REFRESH = function () {\n if (!ticks) return;\n ticks.innerHTML = \"\";\n (DATA.tasks || []).forEach(function (task) {\n var i = document.createElement(\"i\");\n i.style.left = (task.start / __weaveEnd() * 100).toFixed(3) + \"%\";\n i.style.setProperty(\"--c\", agentColor(task.owner));\n ticks.appendChild(i);\n });\n lastT = -1;\n if (window.WEAVE_EDITION_SELECTED_RESET) window.WEAVE_EDITION_SELECTED_RESET();\n updateCompact(true);\n };\n\n apply(open, false);\n\n document.addEventListener(\"keydown\", function (e) {\n var tag = (e.target.tagName || \"\").toLowerCase();\n if (tag === \"input\" || tag === \"textarea\" || tag === \"select\" || e.target.isContentEditable) return;\n var dialog = document.getElementById(\"helpDialog\");\n if (dialog && dialog.open) return;\n if (e.key === \"t\" || e.key === \"T\") {\n e.preventDefault();\n apply(!open, true);\n }\n });\n }\n\n /* ---------------------------------------------------------- resizable rails */\n\n function setupSplitters() {\n var ws = document.querySelector(\".workspace\");\n var left = document.getElementById(\"splitLeft\");\n var right = document.getElementById(\"splitRight\");\n if (!ws || !left || !right) return;\n\n var MIN_LEFT = 196, MAX_LEFT = 430;\n var MIN_RIGHT = 248, MAX_RIGHT = 470;\n var MIN_CENTER = 360;\n var SPLITTERS = 20;\n\n function cssWidth(prop) {\n var v = getComputedStyle(ws).getPropertyValue(prop).trim();\n return parseFloat(v) || 0;\n }\n function bounds(which) {\n var total = ws.clientWidth - SPLITTERS;\n var lw = cssWidth(\"--left-w\");\n var rw = cssWidth(\"--right-w\");\n if (which === \"left\") {\n var max = Math.min(MAX_LEFT, total - MIN_CENTER - rw);\n left.setAttribute(\"aria-valuemin\", String(MIN_LEFT));\n left.setAttribute(\"aria-valuemax\", String(Math.max(MIN_LEFT, Math.round(max))));\n left.setAttribute(\"aria-valuenow\", String(Math.round(lw)));\n } else {\n var max2 = Math.min(MAX_RIGHT, total - MIN_CENTER - lw);\n right.setAttribute(\"aria-valuemin\", String(MIN_RIGHT));\n right.setAttribute(\"aria-valuemax\", String(Math.max(MIN_RIGHT, Math.round(max2))));\n right.setAttribute(\"aria-valuenow\", String(Math.round(rw)));\n }\n }\n function clampSide(which, value) {\n var total = ws.clientWidth - SPLITTERS;\n var lw = which === \"left\" ? value : cssWidth(\"--left-w\");\n var rw = which === \"right\" ? value : cssWidth(\"--right-w\");\n // 先保证中心区,再夹在自身范围内\n var others = which === \"left\" ? rw : lw;\n var max = Math.min(which === \"left\" ? MAX_LEFT : MAX_RIGHT, total - MIN_CENTER - others);\n var min = which === \"left\" ? MIN_LEFT : MIN_RIGHT;\n return Math.max(min, Math.min(Math.max(min, max), value));\n }\n function applyWidth(which, value, persist) {\n ws.style.setProperty(which === \"left\" ? \"--left-w\" : \"--right-w\", Math.round(value) + \"px\");\n if (persist) store(which === \"left\" ? LEFT_KEY : RIGHT_KEY, String(Math.round(value)));\n bounds(\"left\");\n bounds(\"right\");\n requestAnimationFrame(function () { window.dispatchEvent(new Event(\"resize\")); });\n }\n function reset(which) {\n ws.style.removeProperty(which === \"left\" ? \"--left-w\" : \"--right-w\");\n try { __WEAVE_STORE__.removeItem(which === \"left\" ? LEFT_KEY : RIGHT_KEY); } catch (e) {}\n bounds(\"left\");\n bounds(\"right\");\n requestAnimationFrame(function () { window.dispatchEvent(new Event(\"resize\")); });\n }\n\n // restore persisted widths\n var savedLeft = readStore(LEFT_KEY);\n var savedRight = readStore(RIGHT_KEY);\n if (savedLeft) ws.style.setProperty(\"--left-w\", parseFloat(savedLeft) + \"px\");\n if (savedRight) ws.style.setProperty(\"--right-w\", parseFloat(savedRight) + \"px\");\n bounds(\"left\");\n bounds(\"right\");\n\n var resizeTotal = function () { bounds(\"left\"); bounds(\"right\"); };\n window.addEventListener(\"resize\", resizeTotal);\n\n var drag = null;\n function onDown(e, which) {\n if (e.button !== 0) return;\n drag = {\n which: which,\n x: e.clientX,\n left: cssWidth(\"--left-w\"),\n right: cssWidth(\"--right-w\")\n };\n (which === \"left\" ? left : right).classList.add(\"is-active\");\n document.body.classList.add(\"is-resizing\");\n e.preventDefault();\n }\n function onMove(e) {\n if (!drag) return;\n var dx = e.clientX - drag.x;\n if (drag.which === \"left\") applyWidth(\"left\", clampSide(\"left\", drag.left + dx), false);\n else applyWidth(\"right\", clampSide(\"right\", drag.right - dx), false);\n }\n function onUp() {\n if (!drag) return;\n var target = drag.which === \"left\" ? left : right;\n target.classList.remove(\"is-active\");\n document.body.classList.remove(\"is-resizing\");\n var value = cssWidth(drag.which === \"left\" ? \"--left-w\" : \"--right-w\");\n store(drag.which === \"left\" ? LEFT_KEY : RIGHT_KEY, String(Math.round(value)));\n drag = null;\n }\n left.addEventListener(\"pointerdown\", function (e) { onDown(e, \"left\"); try { left.setPointerCapture(e.pointerId); } catch (err) {} });\n right.addEventListener(\"pointerdown\", function (e) { onDown(e, \"right\"); try { right.setPointerCapture(e.pointerId); } catch (err) {} });\n window.addEventListener(\"pointermove\", onMove);\n window.addEventListener(\"pointerup\", onUp);\n window.addEventListener(\"pointercancel\", onUp);\n\n left.addEventListener(\"dblclick\", function () { reset(\"left\"); });\n right.addEventListener(\"dblclick\", function () { reset(\"right\"); });\n\n function keyHandle(which, e) {\n var delta = e.shiftKey ? 32 : 8;\n var two = which === \"left\" ? 1 : -1;\n var base = cssWidth(which === \"left\" ? \"--left-w\" : \"--right-w\");\n if (e.key === \"ArrowLeft\" || e.key === \"ArrowRight\") {\n e.preventDefault();\n var step = (e.key === \"ArrowLeft\" ? -1 : 1) * delta * (which === \"left\" ? 1 : -1) * two;\n // simplify: left handle: left arrow narrows, right arrow widens\n var next = which === \"left\"\n ? base + (e.key === \"ArrowLeft\" ? -delta : delta)\n : base + (e.key === \"ArrowLeft\" ? delta : -delta);\n applyWidth(which, clampSide(which, next), true);\n } else if (e.key === \"Home\") {\n e.preventDefault();\n reset(which);\n }\n }\n left.addEventListener(\"keydown\", function (e) { keyHandle(\"left\", e); });\n right.addEventListener(\"keydown\", function (e) { keyHandle(\"right\", e); });\n }\n\n /* ---------------------------------------------------------- edge ↔ weave hover */\n\n function setupEdgeHover() {\n var layer = document.getElementById(\"edgeLayer\");\n if (!layer) return;\n var SVGNS = \"http://www.w3.org/2000/svg\";\n var PAIRS = EDGE_PAIRS;\n var messages = [];\n /* [EMBED] 消息引用随数据热更新 */\n function syncMessageRefs() {\n messages = (DATA.messages || []).slice().sort(function (a, b) { return a.t - b.t; });\n }\n syncMessageRefs();\n\n function key(a, b) { return a < b ? a + \"|\" + b : b + \"|\" + a; }\n function pairOfMsg(m) { return key(m.from, m.to); }\n function pairLabel(pair) {\n var ids = pair.split(\"|\");\n return ids.map(function (id) {\n var a = (DATA.agents || []).filter(function (x) { return x.id === id; })[0];\n return a ? a.name : id;\n }).join(\" ⇄ \");\n }\n\n var hits = [];\n var activePair = null;\n\n function clearHover() {\n document.querySelectorAll(\".is-edge-hover\").forEach(function (el) { el.classList.remove(\"is-edge-hover\"); });\n var stage = document.getElementById(\"stage\");\n if (stage) stage.classList.remove(\"has-edge-hover\");\n var plate = document.querySelector(\".plate-weave\");\n if (plate) plate.classList.remove(\"is-edge-focus\");\n var wcEdge = document.getElementById(\"wcEdge\");\n if (wcEdge) wcEdge.innerHTML = \"\";\n var laneMarks = document.getElementById(\"laneEdgeMarks\");\n if (laneMarks) laneMarks.innerHTML = \"\";\n activePair = null;\n hoverPair = null;\n }\n\n function applyHover(pair) {\n if (activePair === pair) return;\n clearHover();\n activePair = pair;\n hoverPair = pair;\n if (!pair) return;\n\n var ids = pair.split(\"|\");\n var stage = document.getElementById(\"stage\");\n if (stage) stage.classList.add(\"has-edge-hover\");\n var plate = document.querySelector(\".plate-weave\");\n if (plate) plate.classList.add(\"is-edge-focus\");\n\n // 1. the thread itself\n hits.forEach(function (rec) {\n if (rec.pair === pair) rec.path.classList.add(\"is-edge-hover\");\n });\n\n // 2. agent seals; segments / labels are synced by syncTimelineState()\n ids.forEach(function (id) {\n var node = document.querySelector('.node[data-agent=\"' + id + '\"]');\n if (node) node.classList.add(\"is-edge-hover\");\n });\n\n // 3. expanded weave: the message threads between this pair\n var paths = document.querySelectorAll(\"#laneLinks .lane-link\");\n var dots = document.querySelectorAll(\"#laneLinks .lane-link-dot\");\n messages.forEach(function (m, i) {\n if (pairOfMsg(m) !== pair) return;\n if (paths[i]) paths[i].classList.add(\"is-edge-hover\");\n if (dots[i]) dots[i].classList.add(\"is-edge-hover\");\n });\n\n // 4. collapsed weave: light up exact message moments on the one-line progress\n var times = messages.filter(function (m) { return pairOfMsg(m) === pair; }).map(function (m) { return m.t; });\n var wcEdge = document.getElementById(\"wcEdge\");\n if (wcEdge) {\n wcEdge.innerHTML = \"\";\n (DATA.agents || []).forEach(function (agent) {\n if (ids.indexOf(agent.id) < 0) return;\n (agent.work || []).forEach(function (w) {\n var band = document.createElement(\"span\");\n band.className = \"wc-edge-work\";\n band.style.left = (w.s / __weaveEnd() * 100).toFixed(3) + \"%\";\n band.style.width = ((w.e - w.s) / __weaveEnd() * 100).toFixed(3) + \"%\";\n band.style.setProperty(\"--c\", agent.color);\n wcEdge.appendChild(band);\n });\n });\n times.forEach(function (t) {\n var mark = document.createElement(\"span\");\n mark.className = \"wc-edge-mark\";\n mark.style.left = (t / __weaveEnd() * 100).toFixed(3) + \"%\";\n wcEdge.appendChild(mark);\n });\n var head = document.getElementById(\"wcHead\");\n if (head) head.setAttribute(\"title\", pairLabel(pair));\n }\n\n // 5. expanded weave: vertical time marks across all lanes\n var laneMarks = document.getElementById(\"laneEdgeMarks\");\n if (laneMarks) {\n laneMarks.innerHTML = \"\";\n times.forEach(function (t) {\n var mark = document.createElement(\"span\");\n mark.className = \"lane-edge-mark\";\n mark.style.left = (t / __weaveEnd() * 100).toFixed(3) + \"%\";\n laneMarks.appendChild(mark);\n });\n }\n }\n\n var lastBandSel = null;\n // [EMBED] 数据热更新后要强制重绘选中成员的工作段;lastBandSel 在本函数作用域内,\n // 外部(transform-edition 注入的 WEAVE_EDITION_WEAVE_REFRESH)只能通过这个钩子重置。\n window.WEAVE_EDITION_SELECTED_RESET = function () { lastBandSel = null; };\n function renderSelectedBands(selected) {\n if (lastBandSel === selected) return;\n lastBandSel = selected;\n var box = document.getElementById(\"wcSelected\");\n if (!box) return;\n box.innerHTML = \"\";\n if (!selected) return;\n var agent = (DATA.agents || []).filter(function (a) { return a.id === selected; })[0];\n if (!agent) return;\n (agent.work || []).forEach(function (w) {\n var band = document.createElement(\"span\");\n band.className = \"wc-selected-seg\";\n band.style.left = (w.s / __weaveEnd() * 100).toFixed(3) + \"%\";\n band.style.width = ((w.e - w.s) / __weaveEnd() * 100).toFixed(3) + \"%\";\n band.style.setProperty(\"--c\", agent.color);\n box.appendChild(band);\n });\n }\n\n function syncTimelineState() {\n var state = window.WEAVE_DEBUG && window.WEAVE_DEBUG.state;\n if (!state) return;\n var selected = state.selected;\n var focus = state.focus;\n var connected = {};\n if (selected) {\n connected[selected] = true;\n EDGE_PAIRS.forEach(function (pair) {\n if (pair[0] === selected) connected[pair[1]] = true;\n if (pair[1] === selected) connected[pair[0]] = true;\n });\n }\n var hoverIds = hoverPair ? hoverPair.split(\"|\") : [];\n document.querySelectorAll(\".seg\").forEach(function (seg) {\n var agent = seg.getAttribute(\"data-agent\");\n seg.classList.toggle(\"is-edge-hover\", hoverIds.indexOf(agent) >= 0);\n seg.classList.toggle(\"is-weave-dim\", !!focus && !connected[agent]);\n });\n document.querySelectorAll(\".lane-label\").forEach(function (label) {\n var agentId = label.getAttribute(\"data-agent\");\n if (!agentId) return;\n label.classList.toggle(\"is-edge-hover\", hoverIds.indexOf(agentId) >= 0);\n label.classList.toggle(\"is-agent-selected\", agentId === selected);\n label.classList.toggle(\"is-weave-dim\", !!focus && !connected[agentId]);\n });\n renderSelectedBands(selected);\n }\n\n function syncHits() {\n hits.forEach(function (rec) {\n var d = rec.path.getAttribute(\"d\");\n if (d && rec.hit.getAttribute(\"d\") !== d) rec.hit.setAttribute(\"d\", d);\n });\n // app.js 每帧重写节点 class;悬停期间把朱印高亮补回去\n if (activePair) {\n activePair.split(\"|\").forEach(function (id) {\n var node = document.querySelector('.node[data-agent=\"' + id + '\"]');\n if (node && !node.classList.contains(\"is-edge-hover\")) node.classList.add(\"is-edge-hover\");\n });\n }\n syncTimelineState();\n syncHits.__raf = requestAnimationFrame(syncHits);\n }\n\n function buildHits() {\n /* [EMBED] 数据热更新:刷新边/消息引用后重建命中层 */\n syncMessageRefs();\n PAIRS = EDGE_PAIRS;\n layer.querySelectorAll(\".edge-hit\").forEach(function (n) { n.remove(); });\n hits = [];\n var edges = Array.from(layer.querySelectorAll(\"path.edge\"));\n edges.forEach(function (path, i) {\n if (!PAIRS[i]) return;\n var hit = document.createElementNS(SVGNS, \"path\");\n hit.setAttribute(\"class\", \"edge-hit\");\n hit.setAttribute(\"d\", path.getAttribute(\"d\") || \"\");\n layer.appendChild(hit);\n var rec = { hit: hit, path: path, pair: key(PAIRS[i][0], PAIRS[i][1]) };\n hits.push(rec);\n hit.addEventListener(\"pointerenter\", function () { applyHover(rec.pair); });\n hit.addEventListener(\"pointerleave\", function () { if (activePair === rec.pair) clearHover(); });\n hit.addEventListener(\"pointercancel\", clearHover);\n });\n if (syncHits.__raf) cancelAnimationFrame(syncHits.__raf);\n syncHits.__raf = requestAnimationFrame(syncHits);\n }\n\n buildHits();\n /* [EMBED] 数据热更新后重建丝线 hover 命中层 */\n window.WEAVE_EDGE_HOVER_REBUILD = buildHits;\n var stage = document.getElementById(\"stage\");\n if (stage) {\n stage.addEventListener(\"pointerleave\", clearHover);\n stage.addEventListener(\"click\", function (e) {\n if (e.target && e.target.classList && e.target.classList.contains(\"edge-hit\")) clearHover();\n });\n }\n }\n\n /* ---------------------------------------------------------- blockers */\n\n function tagLaneLabels() {\n var labels = Array.from(document.querySelectorAll(\"#laneLabels .lane-label\"));\n labels.forEach(function (label, i) {\n if (label.classList.contains(\"lane-label--blocker\")) return;\n var agent = (DATA.agents || [])[i];\n if (agent && !label.getAttribute(\"data-agent\")) label.setAttribute(\"data-agent\", agent.id);\n });\n }\n\n function syncTightStage() {\n var stage = document.getElementById(\"stage\");\n if (!stage) return;\n var many = (DATA.agents || []).length > 5;\n var tight = many && stage.clientHeight > 0 && stage.clientHeight < 385;\n stage.classList.toggle(\"is-tight\", tight);\n }\n\n function setupTightStage() {\n var stage = document.getElementById(\"stage\");\n if (!stage) return;\n syncTightStage();\n if (window.ResizeObserver) new ResizeObserver(syncTightStage).observe(stage);\n }\n\n function setupTheme() {\n var root = document.documentElement;\n var btn = document.getElementById(\"themeSwitch\");\n var meta = document.getElementById(\"themeColor\");\n\n function current() {\n return root.getAttribute(\"data-theme\") === \"dark\" ? \"dark\" : \"light\";\n }\n function sync() {\n var dark = current() === \"dark\";\n if (btn) {\n var label = dark ? \"明暗主题:夜色,切换到纸本\" : \"明暗主题:纸本,切换到夜色\";\n btn.setAttribute(\"aria-checked\", dark ? \"true\" : \"false\");\n btn.setAttribute(\"aria-label\", label);\n btn.setAttribute(\"title\", label);\n }\n if (meta) meta.setAttribute(\"content\", dark ? \"#14110d\" : \"#f1ead9\");\n }\n function set(theme, persist) {\n root.setAttribute(\"data-theme\", theme === \"dark\" ? \"dark\" : \"light\");\n if (persist) {\n try { __WEAVE_STORE__.setItem(\"weave.v2.theme\", theme); } catch (e) {}\n }\n sync();\n }\n sync();\n\n function switchTheme() {\n var next = current() === \"dark\" ? \"light\" : \"dark\";\n var reduced = window.matchMedia && window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n if (!reduced && document.startViewTransition) {\n try {\n document.startViewTransition(function () { set(next, true); });\n return;\n } catch (e) {}\n }\n // fallback: temporarily cross-fade all themed surfaces\n document.documentElement.classList.add(\"theme-transition\");\n set(next, true);\n setTimeout(function () {\n document.documentElement.classList.remove(\"theme-transition\");\n }, reduced ? 0 : 1100);\n }\n\n if (btn) btn.addEventListener(\"click\", switchTheme);\n window.WEAVE_THEME = { get: current, set: set, switch: switchTheme };\n }\n\n function setupGraphZoom() {\n var stage = document.getElementById(\"stage\");\n var wrapper = document.getElementById(\"stageZoom\");\n if (!stage || !wrapper) return;\n var zoomInBtn = document.getElementById(\"zoomIn\");\n var zoomOutBtn = document.getElementById(\"zoomOut\");\n var pctEl = document.getElementById(\"zoomPct\");\n var resetBtn = document.getElementById(\"zoomReset\");\n var MIN = 0.75, MAX = 2.6;\n var scale = 1, tx = 0, ty = 0;\n var drag = null;\n\n function clampScale(v) { return Math.max(MIN, Math.min(MAX, v)); }\n function clampPan() {\n var W = stage.clientWidth, H = stage.clientHeight;\n if (!W || !H) return;\n if (scale <= 1) {\n tx = (W - W * scale) / 2;\n ty = (H - H * scale) / 2;\n } else {\n tx = Math.min(0, Math.max(W - W * scale, tx));\n ty = Math.min(0, Math.max(H - H * scale, ty));\n }\n }\n var stageLabel = \"多智能体协作织造图:\" + (DATA.agents || []).map(function (a) { return a.name; }).join(\"、\") + \";可用滚轮缩放、拖动平移\";\n stage.setAttribute(\"aria-label\", stageLabel);\n\n function update() {\n clampPan();\n // 2D transform, and no will-change: the stage repaints at the final zoom\n // instead of upscaling a composited bitmap (keeps HTML text / SVG crisp).\n wrapper.style.transform = \"translate(\" + tx.toFixed(2) + \"px,\" + ty.toFixed(2) + \"px) scale(\" + scale.toFixed(4) + \")\";\n stage.classList.toggle(\"can-pan\", scale > 1.001);\n if (pctEl) pctEl.textContent = Math.round(scale * 100) + \"%\";\n if (zoomInBtn) zoomInBtn.disabled = scale >= MAX - 0.001;\n if (zoomOutBtn) zoomOutBtn.disabled = scale <= MIN + 0.001;\n }\n function reset() { scale = 1; tx = 0; ty = 0; update(); }\n function zoomAt(factor, cx, cy) {\n var old = scale;\n var next = clampScale(scale * factor);\n if (Math.abs(next - old) < 0.0001) return;\n var W = stage.clientWidth, H = stage.clientHeight;\n var px = (typeof cx === \"number\") ? cx : W / 2;\n var py = (typeof cy === \"number\") ? cy : H / 2;\n var ratio = next / old;\n tx = px - (px - tx) * ratio;\n ty = py - (py - ty) * ratio;\n scale = next;\n update();\n }\n function zoomCenter(factor) { zoomAt(factor, stage.clientWidth / 2, stage.clientHeight / 2); }\n\n if (zoomInBtn) zoomInBtn.addEventListener(\"click\", function () { zoomCenter(1.2); });\n if (zoomOutBtn) zoomOutBtn.addEventListener(\"click\", function () { zoomCenter(1 / 1.2); });\n if (resetBtn) resetBtn.addEventListener(\"click\", reset);\n\n stage.addEventListener(\"wheel\", function (e) {\n if (e.target.closest && e.target.closest(\".stage-now\")) return;\n e.preventDefault();\n var factor = Math.exp(-e.deltaY * 0.0015);\n factor = Math.max(0.77, Math.min(1.3, factor));\n var rect = stage.getBoundingClientRect();\n zoomAt(factor, e.clientX - rect.left, e.clientY - rect.top);\n }, { passive: false });\n\n stage.addEventListener(\"pointerdown\", function (e) {\n if (e.pointerType === \"mouse\" && e.button !== 0) return;\n if (scale <= 1.001) return;\n if (e.target.closest && e.target.closest(\".node-btn, .stage-now, .graph-zoom, button, a, input, textarea, select\")) return;\n drag = { id: e.pointerId, x: e.clientX, y: e.clientY, tx: tx, ty: ty };\n stage.classList.add(\"is-panning\");\n try { stage.setPointerCapture(e.pointerId); } catch (err) {}\n e.preventDefault();\n });\n stage.addEventListener(\"pointermove\", function (e) {\n if (!drag || e.pointerId !== drag.id) return;\n tx = drag.tx + (e.clientX - drag.x);\n ty = drag.ty + (e.clientY - drag.y);\n update();\n e.preventDefault();\n });\n function endDrag(e) {\n if (!drag || (e && e.pointerId !== drag.id)) return;\n try { stage.releasePointerCapture(drag.id); } catch (err) {}\n drag = null;\n stage.classList.remove(\"is-panning\");\n }\n stage.addEventListener(\"pointerup\", endDrag);\n stage.addEventListener(\"pointercancel\", endDrag);\n\n stage.addEventListener(\"dblclick\", function (e) {\n if (e.target.closest && e.target.closest(\".node-btn, .stage-now\")) return;\n reset();\n });\n\n document.addEventListener(\"keydown\", function (e) {\n if (e.defaultPrevented || e.metaKey || e.ctrlKey || e.altKey) return;\n var tag = (e.target && e.target.tagName || \"\").toUpperCase();\n if (tag === \"INPUT\" || tag === \"TEXTAREA\" || tag === \"SELECT\" || (e.target && e.target.isContentEditable)) return;\n if (e.key === \"+\" || e.key === \"=\") { e.preventDefault(); zoomCenter(1.2); }\n else if (e.key === \"-\" || e.key === \"_\") { e.preventDefault(); zoomCenter(1 / 1.2); }\n else if (e.key === \"0\") { e.preventDefault(); reset(); }\n });\n\n if (window.ResizeObserver) new ResizeObserver(update).observe(stage);\n window.addEventListener(\"resize\", update);\n window.WEAVE_ZOOM = {\n state: function () { return { scale: scale, tx: tx, ty: ty }; },\n zoom: zoomCenter,\n zoomAt: zoomAt,\n reset: reset\n };\n update();\n }\n\n function setupLive() {\n var app = document.getElementById(\"app\");\n var replayBtn = document.getElementById(\"replayMode\");\n var liveBtn = document.getElementById(\"liveMode\");\n var jumpBtn = document.getElementById(\"liveJump\");\n var laneMarker = document.getElementById(\"liveEdgeLane\");\n var compactMarker = document.getElementById(\"liveEdgeCompact\");\n var scrub = document.getElementById(\"scrubInput\");\n var wcTrack = document.getElementById(\"wcTrack\");\n var laneTracks = document.getElementById(\"laneTracks\");\n function __weaveEnd() { return (DATA.meta && DATA.meta.duration) || 700; }\n var PLAYBACK = (DATA.meta && DATA.meta.playbackSeconds) || 80;\n var RATE = __weaveEnd() / PLAYBACK;\n var live = { mode: \"replay\", following: false, base: 0, epoch: 0, edge: 0 };\n var lastRangeMax = -1;\n\n function getState() { return window.WEAVE_DEBUG && window.WEAVE_DEBUG.state; }\n function now() { return performance.now(); }\n function currentEdge(ts) {\n if (live.mode !== \"live\") return 0;\n if (live.following) return getState() ? getState().t : 0;\n return Math.min(__weaveEnd(), live.base + ((ts - live.epoch) / 1000) * RATE);\n }\n function setRangeMax(value) {\n var max = Math.max(1, Math.ceil(value));\n if (max === lastRangeMax) return;\n lastRangeMax = max;\n if (scrub) {\n scrub.setAttribute(\"max\", String(max));\n scrub.setAttribute(\"aria-valuemax\", String(max));\n }\n if (wcTrack) wcTrack.setAttribute(\"aria-valuemax\", String(max));\n }\n function syncModeButtons() {\n if (replayBtn) replayBtn.setAttribute(\"aria-pressed\", live.mode === \"replay\" ? \"true\" : \"false\");\n if (liveBtn) liveBtn.setAttribute(\"aria-pressed\", live.mode === \"live\" ? \"true\" : \"false\");\n }\n function restoreRunState() {\n var st = getState();\n var runState = document.getElementById(\"runState\");\n if (!st || !runState) return;\n runState.textContent = st.completed ? \"已完成\" : (st.playing ? \"回放中\" : (st.t > 0 ? \"已暂停\" : \"待播放\"));\n }\n function updateUi(ts) {\n var st = getState();\n if (!st) return;\n ts = typeof ts === \"number\" ? ts : now();\n var edge = live.mode === \"live\" ? (live.following ? st.t : Math.min(__weaveEnd(), live.base + ((ts - live.epoch) / 1000) * RATE)) : __weaveEnd();\n live.edge = edge;\n var behind = live.mode === \"live\" && st.t < edge - 0.35;\n if (laneMarker) {\n laneMarker.hidden = !behind;\n if (behind) laneMarker.style.left = (edge / __weaveEnd() * 100).toFixed(3) + \"%\";\n }\n if (compactMarker) {\n compactMarker.hidden = !behind;\n if (behind) compactMarker.style.left = (edge / __weaveEnd() * 100).toFixed(3) + \"%\";\n }\n if (jumpBtn) {\n jumpBtn.hidden = !behind;\n if (behind) jumpBtn.title = \"跳到直播最新位置 · \" + fmt(edge);\n }\n syncModeButtons();\n if (app) {\n app.classList.toggle(\"is-live\", live.mode === \"live\");\n app.classList.toggle(\"is-live-following\", live.mode === \"live\" && live.following);\n app.classList.toggle(\"is-live-behind\", behind);\n }\n setRangeMax(live.mode === \"live\" ? edge : __weaveEnd());\n if (live.mode === \"live\") {\n var runState = document.getElementById(\"runState\");\n if (runState) runState.textContent = st.t >= __weaveEnd() - 0.001 ? \"直播结束\" : (behind ? \"回看中\" : \"直播中\");\n }\n }\n function startBehind(anchor) {\n if (live.mode !== \"live\" || !live.following) return;\n var edge = typeof anchor === \"number\" ? anchor : live.edge;\n live.following = false;\n live.base = Math.max(0, Math.min(__weaveEnd(), edge));\n live.epoch = now();\n live.edge = live.base;\n updateUi(live.epoch);\n }\n function enterLive() {\n var st = getState();\n if (!st) return;\n if (live.mode === \"live\") {\n if (!live.following) returnLive();\n return;\n }\n var start = st.t >= __weaveEnd() - 0.001 ? 0 : st.t;\n live.mode = \"live\";\n live.following = true;\n live.base = start;\n live.edge = start;\n live.epoch = now();\n st.speed = 1;\n document.querySelectorAll(\".speed-btn\").forEach(function (b) {\n b.setAttribute(\"aria-pressed\", b.dataset.speed === \"1\" ? \"true\" : \"false\");\n });\n window.WEAVE_DEBUG.seek(start);\n if (start < __weaveEnd() - 0.001) window.WEAVE_DEBUG.play();\n updateUi(now());\n }\n function exitLive() {\n if (live.mode !== \"live\") return;\n live.mode = \"replay\";\n live.following = false;\n window.WEAVE_DEBUG.pause();\n if (app) app.classList.remove(\"is-live\", \"is-live-following\", \"is-live-behind\");\n if (laneMarker) laneMarker.hidden = true;\n if (compactMarker) compactMarker.hidden = true;\n if (jumpBtn) jumpBtn.hidden = true;\n setRangeMax(__weaveEnd());\n syncModeButtons();\n restoreRunState();\n }\n function returnLive() {\n if (live.mode !== \"live\") return;\n var st = getState();\n if (!st) return;\n var edge = live.following ? st.t : Math.min(__weaveEnd(), live.base + ((now() - live.epoch) / 1000) * RATE);\n live.following = true;\n live.base = edge;\n live.edge = edge;\n live.epoch = now();\n window.WEAVE_DEBUG.seek(edge);\n if (edge < __weaveEnd() - 0.001) window.WEAVE_DEBUG.play();\n else window.WEAVE_DEBUG.pause();\n updateUi(now());\n }\n function seekTo(target) {\n if (live.mode !== \"live\") {\n if (window.WEAVE_DEBUG) {\n window.WEAVE_DEBUG.pause();\n window.WEAVE_DEBUG.seek(target);\n }\n return;\n }\n var st = getState();\n if (!st) return;\n var ts = now();\n var edge = live.following ? st.t : Math.min(__weaveEnd(), live.base + ((ts - live.epoch) / 1000) * RATE);\n target = Math.max(0, Math.min(edge, target));\n if (target >= edge - 0.75) {\n returnLive();\n return;\n }\n if (live.following) startBehind(edge);\n window.WEAVE_DEBUG.pause();\n window.WEAVE_DEBUG.seek(target);\n updateUi(ts);\n }\n\n if (replayBtn) replayBtn.addEventListener(\"click\", function () { if (live.mode === \"live\") exitLive(); });\n if (liveBtn) liveBtn.addEventListener(\"click\", function () {\n if (live.mode === \"replay\") enterLive();\n else if (!live.following) returnLive();\n });\n if (jumpBtn) jumpBtn.addEventListener(\"click\", returnLive);\n\n if (scrub) {\n scrub.addEventListener(\"pointerdown\", function () {\n if (live.mode === \"live\" && live.following) startBehind(live.edge);\n }, true);\n scrub.addEventListener(\"input\", function (e) {\n if (live.mode !== \"live\") return;\n e.stopImmediatePropagation();\n seekTo(parseFloat(scrub.value) || 0);\n }, true);\n }\n\n if (laneTracks) {\n laneTracks.addEventListener(\"pointerdown\", function (e) {\n if (live.mode !== \"live\" || e.button !== 0) return;\n if (e.target.closest && e.target.closest(\".seg\")) return;\n e.preventDefault();\n e.stopPropagation();\n var rect = laneTracks.getBoundingClientRect();\n var startEdge = live.following ? (getState() ? getState().t : 0) : Math.min(__weaveEnd(), live.base + ((now() - live.epoch) / 1000) * RATE);\n if (live.following) startBehind(startEdge);\n function at(clientX) {\n var ratio = Math.max(0, Math.min(1, (clientX - rect.left) / rect.width));\n seekTo(ratio * startEdge);\n }\n function move(ev) { at(ev.clientX); }\n function up() {\n window.removeEventListener(\"pointermove\", move);\n window.removeEventListener(\"pointerup\", up);\n }\n at(e.clientX);\n window.addEventListener(\"pointermove\", move);\n window.addEventListener(\"pointerup\", up);\n }, true);\n }\n\n document.addEventListener(\"keydown\", function (e) {\n if (live.mode !== \"live\") return;\n var help = document.getElementById(\"helpDialog\");\n if (help && help.open) return;\n var tag = (e.target && e.target.tagName || \"\").toLowerCase();\n if (tag === \"input\" || tag === \"textarea\" || tag === \"select\") return;\n if (e.key === \"1\" || e.key === \"2\" || e.key === \"4\") {\n e.preventDefault();\n e.stopImmediatePropagation();\n return;\n }\n if (e.key === \"ArrowLeft\" || e.key === \"ArrowRight\" || e.key === \"Home\" || e.key === \"End\") {\n e.preventDefault();\n e.stopImmediatePropagation();\n var st = getState();\n if (!st) return;\n if (e.key === \"End\") { returnLive(); return; }\n var delta = (e.shiftKey ? 60 : 10) * (e.key === \"ArrowLeft\" ? -1 : 1);\n seekTo(e.key === \"Home\" ? 0 : st.t + delta);\n }\n }, true);\n\n window.WEAVE_LIVE = {\n isLive: function () { return live.mode === \"live\"; },\n seekTo: seekTo,\n returnLive: returnLive,\n enter: enterLive,\n exit: exitLive,\n state: live\n };\n\n function tick(ts) {\n var st = getState();\n if (st && live.mode === \"live\") {\n if (live.following) {\n if (st.playing) {\n live.edge = st.t;\n live.base = st.t;\n live.epoch = ts;\n } else if (st.t < __weaveEnd() - 0.001) {\n startBehind(live.edge || st.t);\n } else {\n live.edge = __weaveEnd();\n live.following = false;\n }\n } else {\n var edge = Math.min(__weaveEnd(), live.base + ((ts - live.epoch) / 1000) * RATE);\n live.edge = edge;\n if (st.playing && st.t >= edge - 0.2) {\n live.following = true;\n live.edge = st.t;\n live.base = st.t;\n live.epoch = ts;\n }\n }\n // a segment/task click must never jump into the unstreamed future\n if (live.edge < __weaveEnd() - 0.001 && st.t > live.edge + 0.75) {\n window.WEAVE_DEBUG.pause();\n window.WEAVE_DEBUG.seek(live.edge);\n live.following = true;\n live.base = live.edge;\n live.epoch = ts;\n window.WEAVE_DEBUG.play();\n }\n updateUi(ts);\n }\n requestAnimationFrame(tick);\n }\n updateUi(now());\n requestAnimationFrame(tick);\n }\n\n function setupBlocker() {\n /* [EMBED] blocker 支持随数据热更新(初始可以为空) */\n var labels = document.getElementById(\"laneLabels\");\n var rows = document.getElementById(\"laneRows\");\n if (!labels || !rows) return;\n var blocker = DATA.blocker || { from: Infinity, to: Infinity, title: \"\", detail: \"\" };\n tagLaneLabels();\n\n // separate blocker row in the expanded weave\n var label = document.createElement(\"div\");\n label.className = \"lane-label lane-label--blocker\";\n label.innerHTML = '<span class=\"lane-blocker-dot\"></span><span>阻塞</span>';\n label.title = \"查看阻塞详情\";\n label.setAttribute(\"role\", \"button\");\n label.tabIndex = 0;\n label.hidden = true;\n\n var row = document.createElement(\"div\");\n row.className = \"lane-row lane-row--blocker\";\n var laneBand = document.createElement(\"button\");\n laneBand.type = \"button\";\n laneBand.className = \"lane-blocker-band\";\n laneBand.hidden = true;\n laneBand.setAttribute(\"aria-haspopup\", \"dialog\");\n laneBand.setAttribute(\"aria-controls\", \"blockerPop\");\n laneBand.setAttribute(\"aria-label\", \"查看阻塞详情\");\n var laneFill = document.createElement(\"span\");\n laneFill.className = \"lane-blocker-fill\";\n var laneText = document.createElement(\"span\");\n laneText.className = \"lane-blocker-text\";\n laneText.textContent = \"阻塞\";\n laneBand.appendChild(laneFill);\n laneBand.appendChild(laneText);\n row.appendChild(laneBand);\n row.hidden = true;\n\n labels.insertBefore(label, labels.firstChild);\n rows.insertBefore(row, rows.firstChild);\n requestAnimationFrame(function () { window.dispatchEvent(new Event(\"resize\")); });\n\n // collapsed weave: notice strip above the one-line progress\n var wcWrap = document.getElementById(\"wcBlockerWrap\");\n var wcBand = document.getElementById(\"wcBlockerBand\");\n var wcFill = document.getElementById(\"wcBlockerFill\");\n var wcText = document.getElementById(\"wcBlockerText\");\n\n var pop = document.getElementById(\"blockerPop\");\n var closeBtn = document.getElementById(\"blockerPopClose\");\n var popTitle = document.getElementById(\"blockerPopTitle\");\n var popDetail = document.getElementById(\"blockerPopDetail\");\n var popWindow = document.getElementById(\"bpWindow\");\n var jumpBtn = document.getElementById(\"bpJump\");\n var lensBtn = document.getElementById(\"bpLens\");\n\n var duration = 0;\n var outsideBound = false;\n\n function fillPopover() {\n if (popTitle) popTitle.textContent = blocker.title || \"阻塞\";\n if (popDetail) popDetail.textContent = blocker.detail || \"\";\n if (popWindow) popWindow.textContent = fmt(blocker.from) + \" – \" + fmt(blocker.to) + \" · \" + fmt(duration);\n }\n function onOutside(e) {\n if (pop && !pop.contains(e.target)) closePopover();\n }\n function onEsc(e) {\n if (e.key === \"Escape\") closePopover();\n }\n function closePopover() {\n if (!pop) return;\n pop.hidden = true;\n if (outsideBound) {\n document.removeEventListener(\"pointerdown\", onOutside, true);\n document.removeEventListener(\"keydown\", onEsc);\n outsideBound = false;\n }\n }\n function openPopover(anchorEl) {\n if (!pop) return;\n fillPopover();\n pop.hidden = false;\n var r = anchorEl.getBoundingClientRect();\n var pw = pop.offsetWidth;\n var ph = pop.offsetHeight;\n var left = Math.min(Math.max(8, r.left + r.width / 2 - pw / 2), window.innerWidth - pw - 8);\n var top = r.top - ph - 10;\n if (top < 8) top = Math.min(r.bottom + 10, window.innerHeight - ph - 8);\n pop.style.left = Math.round(left) + \"px\";\n pop.style.top = Math.round(Math.max(8, top)) + \"px\";\n if (closeBtn) setTimeout(function () { closeBtn.focus(); }, 0);\n if (!outsideBound) {\n setTimeout(function () {\n document.addEventListener(\"pointerdown\", onOutside, true);\n document.addEventListener(\"keydown\", onEsc);\n outsideBound = true;\n }, 0);\n }\n }\n\n if (closeBtn) closeBtn.addEventListener(\"click\", closePopover);\n if (jumpBtn) jumpBtn.addEventListener(\"click\", function () {\n if (window.WEAVE_DEBUG) { window.WEAVE_DEBUG.pause(); window.WEAVE_DEBUG.seek(blocker.from + 0.5); }\n closePopover();\n });\n if (lensBtn) lensBtn.addEventListener(\"click\", function () {\n var lensNode = document.querySelector('.node[data-agent=\"lens\"] .node-btn');\n if (lensNode) lensNode.click();\n closePopover();\n });\n\n laneBand.addEventListener(\"pointerdown\", function (e) { e.stopPropagation(); });\n laneBand.addEventListener(\"click\", function (e) { e.stopPropagation(); openPopover(laneBand); });\n label.addEventListener(\"click\", function () { openPopover(label); });\n label.addEventListener(\"keydown\", function (e) {\n if (e.key === \"Enter\" || e.key === \" \") { e.preventDefault(); openPopover(label); }\n });\n if (wcBand) wcBand.addEventListener(\"click\", function (e) { e.stopPropagation(); openPopover(wcBand); });\n\n var wasActive = false;\n var relayoutQueued = false;\n function queueRelayout() {\n if (relayoutQueued) return;\n relayoutQueued = true;\n requestAnimationFrame(function () {\n relayoutQueued = false;\n window.dispatchEvent(new Event(\"resize\"));\n });\n }\n\n function syncBlocker() {\n /* [EMBED] 每帧读取最新 blocker,并同步重算时间窗长度 */\n blocker = DATA.blocker || { from: Infinity, to: Infinity, title: \"\", detail: \"\" };\n duration = blocker.to - blocker.from;\n var state = window.WEAVE_DEBUG && window.WEAVE_DEBUG.state;\n var t = state ? state.t : 0;\n var active = t >= blocker.from;\n var resolved = t >= blocker.to;\n var elapsed = Math.max(0, Math.min(t, blocker.to) - blocker.from);\n var progress = duration > 0 ? elapsed / duration : 0;\n var short = window.innerWidth < 620;\n var statusText = resolved ? \"已解除\" : (blocker.title || \"阻塞\");\n var bandText = (short && !resolved ? \"阻塞\" : statusText) + \" · \" + fmt(duration);\n\n if (!active) {\n if (!laneBand.hidden) laneBand.hidden = true;\n if (!label.hidden) label.hidden = true;\n if (!row.hidden) row.hidden = true;\n if (wcWrap && !wcWrap.hidden) wcWrap.hidden = true;\n if (wasActive) { wasActive = false; queueRelayout(); }\n requestAnimationFrame(syncBlocker);\n return;\n }\n if (label.hidden) {\n // 只在阻塞真实存在且已经发生时,才让这条轨道出现\n label.hidden = false;\n row.hidden = false;\n wasActive = true;\n queueRelayout();\n }\n if (laneBand.hidden) laneBand.hidden = false;\n laneBand.style.left = (blocker.from / __weaveEnd() * 100).toFixed(3) + \"%\";\n laneBand.style.width = (duration / __weaveEnd() * 100).toFixed(3) + \"%\";\n laneFill.style.width = (progress * 100).toFixed(2) + \"%\";\n laneText.textContent = bandText;\n laneBand.classList.toggle(\"is-resolved\", resolved);\n\n if (wcWrap) {\n if (wcWrap.hidden) wcWrap.hidden = false;\n wcBand.style.left = (blocker.from / __weaveEnd() * 100).toFixed(3) + \"%\";\n wcBand.style.width = (duration / __weaveEnd() * 100).toFixed(3) + \"%\";\n wcFill.style.width = (progress * 100).toFixed(2) + \"%\";\n wcText.textContent = bandText;\n wcBand.classList.toggle(\"is-resolved\", resolved);\n }\n requestAnimationFrame(syncBlocker);\n }\n requestAnimationFrame(syncBlocker);\n\n /* [EMBED] app.js reload 会清空泳道容器,重建后把阻塞轨道补回去 */\n window.WEAVE_EDITION_BLOCKER_RESTORE = function () {\n if (!label.isConnected) labels.insertBefore(label, labels.firstChild);\n if (!row.isConnected) rows.insertBefore(row, rows.firstChild);\n label.hidden = true;\n row.hidden = true;\n requestAnimationFrame(function () { window.dispatchEvent(new Event(\"resize\")); });\n };\n }\n\n /* ---------------------------------------------------------- boot */\n\n function decorate() {\n document.body.classList.add(\"edition-silk\");\n setupTheme();\n readEdgePairs();\n tagLaneLabels();\n decorateNodes();\n decorateInspector();\n var insp = document.getElementById(\"inspector\");\n if (insp && window.MutationObserver) {\n new MutationObserver(decorateInspector).observe(insp, { childList: true, subtree: true });\n }\n setupWeave();\n setupSplitters();\n setupEdgeHover();\n setupTightStage();\n setupGraphZoom();\n setupLive();\n setupBlocker();\n decorateTokenLabels();\n setTimeout(decorateTokenLabels, 600);\n var tip = document.getElementById(\"tipToast\");\n if (tip) tip.textContent = \"点击丝印检视 · T 展开织带 · 拖动栏边调宽\";\n setTimeout(decorateNodes, 500);\n }\n\n /* [EMBED] 增强层延迟到 app.js 首次 init 完成后启动(数据热更新时由 refresh 重挂装饰) */\n var __editionBooted = false;\n function bootEdition() {\n if (__editionBooted) return;\n __editionBooted = true;\n requestAnimationFrame(function () { requestAnimationFrame(decorate); });\n }\n\n function refreshData() {\n if (!__editionBooted) return;\n readEdgePairs();\n ensureSeals();\n tagLaneLabels();\n decorateNodes();\n decorateInspector();\n decorateTokenLabels();\n generateTokensReset();\n if (window.WEAVE_EDGE_HOVER_REBUILD) window.WEAVE_EDGE_HOVER_REBUILD();\n if (window.WEAVE_EDITION_BLOCKER_RESTORE) window.WEAVE_EDITION_BLOCKER_RESTORE();\n if (window.WEAVE_EDITION_WEAVE_REFRESH) window.WEAVE_EDITION_WEAVE_REFRESH();\n requestAnimationFrame(function () { window.dispatchEvent(new Event(\"resize\")); });\n }\n\n /* [EMBED] 让动态生成的 token 模型随数据重建(演示数据中的固定模型不受影响) */\n function generateTokensReset() {\n Object.keys(generatedTokens).forEach(function (k) { delete generatedTokens[k]; });\n }\n\n window.WEAVE_EDITION = { boot: bootEdition, refresh: refreshData, decorate: decorate };\n})();\n\n</script>\n<script id=\"weave-live-adapter\">\n/* ---- weave-embed/src/live-adapter.js ---- */\n/* ==========================================================================\n * weave-embed/src/live-adapter.js\n * iframe 内运行时协议适配层(由 build.mjs 内联到 dist/weave.html 末尾)。\n *\n * 父 -> 子:{type:'weave:init', data, theme:'light'|'dark', live:boolean}\n * {type:'weave:update', data, live:boolean}\n * {type:'weave:theme', theme}\n * {type:'weave:dispose'}\n * 子 -> 父:{type:'weave:ready', version}\n * {type:'weave:event', event:'select-agent'|'seek'|'mode'|'error', payload}\n *\n * 设计约束:\n * - 所有 DOM/存储访问都在 sandbox(无 allow-same-origin)下可用,不依赖 localStorage;\n * - 首次 weave:init 之前只显示中性占位,不渲染任何会话数据;\n * - 错误尽力转发给父视图,避免静默失败。\n * ========================================================================== */\n(function () {\n \"use strict\";\n\n var VERSION = (typeof window.WEAVE_EMBED_VERSION === \"string\") ? window.WEAVE_EMBED_VERSION : \"weave-embed/dev\";\n var parentWin = (window.parent && window.parent !== window) ? window.parent : null;\n var body = document.body;\n /* [diagnostic] 错误环形缓冲:便于父视图 / 自测读取(不参与协议) */\n var errorLog = [];\n window.__WEAVE_ERRORS__ = errorLog;\n\n var initialized = false;\n var disposed = false;\n var liveMode = false\n var lastDataSig = null\n\n /* Structural signature: skip rebuilds when an update carries no visible change. */\n function dataSignature(data) {\n var meta = data.meta || {}\n var agents = Array.isArray(data.agents) ? data.agents : []\n var events = Array.isArray(data.events) ? data.events : []\n var tasks = Array.isArray(data.tasks) ? data.tasks : []\n var tail = events.slice(-4).map(function (e) {\n return [e.seq, e.time, e.endTime || 0, e.kind || \"\"].join(\":\")\n }).join(\",\")\n var agentSig = agents.map(function (a) {\n var work = Array.isArray(a.work) ? a.work : []\n var w = work.length ? work[work.length - 1] : null\n return [a.id, a.state || \"\", work.length, w ? (w.s + \"-\" + w.e + \"-\" + (w.label || \"\")) : \"\"].join(\":\")\n }).join(\",\")\n var taskSig = tasks.map(function (t) {\n return [t.id, t.status || \"\", t.start, t.end, t.owner || \"\"].join(\":\")\n }).join(\",\")\n var tokenSegs = meta.tokens && meta.tokens.segments ? meta.tokens.segments : {}\n var tokenSum = 0\n Object.keys(tokenSegs).forEach(function (key) {\n var arr = tokenSegs[key]\n if (!Array.isArray(arr)) return\n for (var i = 0; i < arr.length; i++) {\n var value = Number(arr[i])\n if (Number.isFinite(value) && value > 0) tokenSum += value\n }\n })\n var last = events.length ? events[events.length - 1] : null\n return [meta.runId, meta.goal, meta.duration, meta.playbackSeconds, agents.length, events.length, last ? last.time : 0, tail, agentSig, taskSig, tokenSum].join(\"|\")\n };\n var lastEmitted = { selected: null, t: null };\n var lastModeEmit = null;\n var liveTimer = null;\n var liveBar = null;\n var pendingInitTimer = null;\n\n var ac = (typeof AbortController === \"function\") ? new AbortController() : null;\n function listen(target, type, fn, opts) {\n if (!target) return;\n var o = opts ? Object.assign({}, opts) : {};\n if (ac && !o.signal) o.signal = ac.signal;\n try { target.addEventListener(type, fn, o); } catch (e) { /* 忽略不支持 signal 的旧环境 */ }\n }\n\n var placeholder = document.getElementById(\"weavePlaceholder\");\n var historyButton = placeholder ? placeholder.querySelector(\".wp-history\") : null;\n var historyStatus = placeholder ? placeholder.querySelector(\".wp-history-status\") : null;\n body.classList.add(\"weave-embed\");\n\n function emit(event, payload) {\n if (!parentWin || disposed) return;\n try {\n parentWin.postMessage({ type: \"weave:event\", event: event, payload: payload || {} }, \"*\");\n } catch (e) { /* 父视图已销毁 */ }\n }\n\n function reportError(scope, err) {\n var message = (err && err.message) ? String(err.message) : String(err);\n var payload = { scope: scope, message: message };\n if (err && err.stack) payload.stack = String(err.stack).slice(0, 2000);\n if (errorLog.length < 50) errorLog.push(payload);\n try { console.error(\"[weave-embed] \" + scope + \": \" + message); } catch (e) {}\n emit(\"error\", payload);\n }\n\n /* ---------------------------------------------------- local history load */\n function requestHistory() {\n if (!parentWin || disposed) return;\n if (historyButton) historyButton.disabled = true;\n if (historyStatus) {\n historyStatus.hidden = false;\n historyStatus.textContent = \"正在读取本地历史…\";\n }\n try {\n parentWin.postMessage({ type: \"weave:request-history\" }, \"*\");\n } catch (e) {\n reportError(\"history-request\", e);\n }\n }\n\n function showHistoryStatus(text, failed) {\n if (!historyStatus) return;\n historyStatus.hidden = false;\n historyStatus.textContent = String(text == null ? \"\" : text);\n if (failed && historyButton) historyButton.disabled = false;\n }\n\n /* ---------------------------------------------------------------- theme */\n function setTheme(theme) {\n try {\n if (window.WeaveLive && window.WeaveLive.setTheme) window.WeaveLive.setTheme(theme);\n } catch (e) { reportError(\"theme\", e); }\n }\n\n /* ---------------------------------------------------------- live chrome */\n function ensureLiveBar() {\n if (liveBar || !parentWin) return liveBar;\n liveBar = document.createElement(\"div\");\n liveBar.className = \"weave-livebar\";\n liveBar.hidden = true;\n liveBar.innerHTML =\n '<span class=\"weave-livebadge\"><i class=\"weave-livedot\" aria-hidden=\"true\"></i><span class=\"weave-livebadge-text\">直播跟随</span></span>' +\n '<button class=\"weave-livejump\" type=\"button\" hidden>回到最新</button>';\n body.appendChild(liveBar);\n var jump = liveBar.querySelector(\".weave-livejump\");\n if (jump) {\n listen(jump, \"click\", function () {\n try {\n liveMode = true;\n if (window.WeaveLive && window.WeaveLive.setLive) window.WeaveLive.setLive(true);\n if (lastModeEmit !== liveMode) { lastModeEmit = liveMode; emit(\"mode\", { live: true }); }\n var st = window.WeaveLive.getState();\n window.WeaveLive.seek(st.duration);\n emit(\"seek\", { t: st.duration, duration: st.duration, live: true, source: \"live-jump\" });\n lastEmitted.t = st.duration;\n updateLiveChrome();\n } catch (e) { reportError(\"live-jump\", e); }\n });\n }\n return liveBar;\n }\n\n function updateLiveChrome() {\n if (!parentWin) return;\n ensureLiveBar();\n if (!liveBar) return;\n // Keep the bar in replay mode too: it is the only way back to live after a\n // scrub (the host deliberately stops echoing live once the user seeks).\n if (!initialized) { liveBar.hidden = true; return; }\n liveBar.hidden = false;\n try {\n var st = window.WeaveLive.getState();\n var behind = st.t < st.duration - 0.75;\n var badgeText = liveBar.querySelector(\".weave-livebadge-text\");\n var jump = liveBar.querySelector(\".weave-livejump\");\n if (badgeText) badgeText.textContent = behind ? \"回看中\" : (liveMode ? \"直播跟随\" : \"回放\");\n liveBar.classList.toggle(\"is-behind\", !!behind || !liveMode);\n if (jump) jump.hidden = !(behind || !liveMode);\n } catch (e) { reportError(\"live-chrome\", e); }\n }\n\n /* --------------------------------------------------------------- live */\n function applyLive(live) {\n liveMode = !!live;\n try {\n if (window.WeaveLive && window.WeaveLive.setLive) window.WeaveLive.setLive(liveMode);\n } catch (e) { reportError(\"live\", e); }\n updateLiveChrome();\n if (lastModeEmit !== liveMode) {\n lastModeEmit = liveMode;\n emit(\"mode\", { live: liveMode });\n }\n }\n\n /* -------------------------------------------------------------- boot UI */\n function finishBoot() {\n body.classList.remove(\"weave-booting\");\n body.classList.add(\"weave-ready\");\n if (placeholder) placeholder.setAttribute(\"hidden\", \"\");\n try { window.dispatchEvent(new Event(\"weave:ready\")); } catch (e) {}\n }\n\n /* ------------------------------------------------------------ user events */\n function snapshotUser(force) {\n if (!initialized || disposed) return;\n var st;\n try { st = window.WeaveLive.getState(); } catch (e) { return; }\n if (!st) return;\n if (st.selected && st.selected !== lastEmitted.selected) {\n lastEmitted.selected = st.selected;\n emit(\"select-agent\", { agentId: st.selected });\n }\n var changed = lastEmitted.t === null || Math.abs(st.t - lastEmitted.t) > 0.4;\n if (changed || force) {\n // A user scrub behind the live edge leaves live follow immediately; the\n // parent will echo live:false on its next update so the runtime stops\n // pinning t to END on every refresh.\n if (liveMode && st.duration > 0 && st.t < st.duration - 0.75) {\n liveMode = false;\n try { window.WeaveLive.setLive(false); } catch (e) { reportError(\"user-seek-live\", e); }\n if (lastModeEmit !== liveMode) {\n lastModeEmit = liveMode;\n emit(\"mode\", { live: false, t: Math.round(st.t * 10) / 10, duration: st.duration });\n }\n }\n lastEmitted.t = st.t;\n emit(\"seek\", { t: Math.round(st.t * 10) / 10, duration: st.duration, live: liveMode, source: \"user\" });\n }\n }\n\n function scheduleUserSnapshot() {\n if (!initialized || disposed) return;\n window.setTimeout(function () {\n try { snapshotUser(false); } catch (e) { reportError(\"user-event\", e); }\n }, 0);\n }\n\n function within(target, selectors) {\n if (!target || !target.closest) return false;\n for (var i = 0; i < selectors.length; i++) {\n if (target.closest(selectors[i])) return true;\n }\n return false;\n }\n\n function bindUserEvents() {\n listen(document, \"click\", function (e) {\n if (within(e.target, [\".node-btn\", \".task-item\", \".feed-item\", \".lane-label\", \".plate-btn\"])) scheduleUserSnapshot();\n }, true);\n listen(document, \"pointerup\", function (e) {\n if (within(e.target, [\"#laneTracks\", \"#wcTrack\", \"#stage\", \"#scrubInput\"])) {\n window.setTimeout(function () { snapshotUser(true); }, 30);\n }\n }, true);\n listen(document, \"keydown\", function (e) {\n var key = e.key;\n if (key === \" \" || key === \"Spacebar\" || key === \"ArrowLeft\" || key === \"ArrowRight\" ||\n key === \"Home\" || key === \"End\" || key === \"r\" || key === \"R\" ||\n key === \"f\" || key === \"F\" || key === \"g\" || key === \"G\" ||\n key === \"1\" || key === \"2\" || key === \"4\") {\n window.setTimeout(function () { snapshotUser(true); }, 60);\n }\n }, true);\n }\n\n /* ------------------------------------------------------------- messages */\n function handleData(msg, isInit) {\n var data = msg.data;\n if (!data || typeof data !== \"object\" || !data.meta || typeof data.meta !== \"object\") {\n emit(\"error\", { scope: isInit ? \"init\" : \"update\", message: \"消息缺少 data.meta,已忽略\" });\n return;\n }\n if (typeof msg.theme === \"string\") setTheme(msg.theme);\n var wantLive = (typeof msg.live === \"boolean\") ? msg.live : liveMode;\n var modeChanged = wantLive !== liveMode;\n var sig = dataSignature(data);\n if (!isInit && sig === lastDataSig && !modeChanged) return;\n lastDataSig = sig;\n liveMode = wantLive;\n try { window.WeaveLive.setLive(liveMode); } catch (e) { reportError(\"setLive\", e); }\n\n if (isInit && initialized) {\n // Duplicate init frames (ready + onLoad + retry) must not rewind a live\n // view; the new data below is authoritative and reload keeps the playhead.\n }\n var st;\n try {\n st = window.WeaveLive.setData(data);\n } catch (e) {\n reportError(isInit ? \"init\" : \"update\", e);\n return;\n }\n if (!initialized) {\n initialized = true;\n finishBoot();\n if (pendingInitTimer) { window.clearTimeout(pendingInitTimer); pendingInitTimer = null; }\n }\n if (liveMode) {\n try { window.WeaveLive.setLive(true); } catch (e) { reportError(\"live-follow\", e); }\n }\n lastEmitted.t = st ? st.t : null;\n lastEmitted.selected = st ? st.selected : null;\n updateLiveChrome();\n if (lastModeEmit !== liveMode) {\n lastModeEmit = liveMode;\n emit(\"mode\", { live: liveMode, t: st ? st.t : 0, duration: st ? st.duration : 0 });\n }\n if (!liveTimer) {\n liveTimer = window.setInterval(updateLiveChrome, 400);\n }\n }\n\n function dispose() {\n if (disposed) return;\n disposed = true;\n if (pendingInitTimer) { window.clearTimeout(pendingInitTimer); pendingInitTimer = null; }\n if (liveTimer) { window.clearInterval(liveTimer); liveTimer = null; }\n if (ac) { try { ac.abort(); } catch (e) {} }\n if (liveBar && liveBar.parentNode) liveBar.parentNode.removeChild(liveBar);\n liveBar = null;\n try { window.WeaveLive.setLive(false); } catch (e) {}\n body.classList.add(\"weave-disposed\");\n body.classList.add(\"weave-booting\");\n if (placeholder) {\n placeholder.removeAttribute(\"hidden\");\n var title = placeholder.querySelector(\".wp-title\");\n var sub = placeholder.querySelector(\".wp-sub\");\n if (title) title.textContent = \"Weave\";\n if (sub) sub.textContent = \"视图已释放\";\n if (historyButton) historyButton.disabled = false;\n if (historyStatus) { historyStatus.hidden = true; historyStatus.textContent = \"\"; }\n }\n }\n\n function onMessage(ev) {\n if (disposed) return;\n if (parentWin && ev.source !== parentWin) return;\n var msg = ev.data;\n if (!msg || typeof msg !== \"object\" || typeof msg.type !== \"string\") return;\n try {\n if (msg.type === \"weave:init\") handleData(msg, true);\n else if (msg.type === \"weave:update\") handleData(msg, false);\n else if (msg.type === \"weave:theme\") setTheme(msg.theme);\n else if (msg.type === \"weave:dispose\") dispose();\n else if (msg.type === \"weave:history-status\") showHistoryStatus(msg.text, msg.failed === true);\n } catch (e) {\n reportError(\"message:\" + msg.type, e);\n }\n }\n\n /* ------------------------------------------------------------ ready / init */\n function announceReady() {\n if (!parentWin) return;\n try {\n parentWin.postMessage({\n type: \"weave:ready\",\n version: VERSION,\n capabilities: [\"setData\", \"setTheme\", \"setLive\", \"seek\", \"getState\"]\n }, \"*\");\n } catch (e) { /* ignore */ }\n }\n\n function start() {\n listen(window, \"message\", onMessage);\n listen(window, \"error\", function (e) {\n reportError(\"window-error\", e.error || e.message || \"window error\");\n });\n listen(window, \"unhandledrejection\", function (e) {\n reportError(\"unhandledrejection\", e.reason);\n });\n bindUserEvents();\n listen(historyButton, \"click\", requestHistory);\n announceReady();\n /* 父视图可能尚未完成监听:稍后补发一次 ready(幂等) */\n pendingInitTimer = window.setTimeout(function () {\n pendingInitTimer = null;\n if (!initialized && !disposed) announceReady();\n }, 1500);\n }\n\n if (document.readyState === \"loading\") {\n document.addEventListener(\"DOMContentLoaded\", start, { once: true });\n } else {\n start();\n }\n\n /* 调试入口(不参与协议) */\n window.__WEAVE_ADAPTER__ = {\n version: VERSION,\n state: function () {\n try { return window.WeaveLive.getState(); } catch (e) { return null; }\n }\n };\n})();\n</script>\n</body>\n</html>\n";
|
|
851
|
+
|
|
852
|
+
function emptySource() {
|
|
853
|
+
return {
|
|
854
|
+
getSnapshot: function () { return EMPTY_WEAVE_DATA },
|
|
855
|
+
subscribe: function () { return function () {} },
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
/** Build one observable WEAVE_DATA source for a session (cached per session). */
|
|
860
|
+
function makeWeaveSource(ctx, sessionId) {
|
|
861
|
+
var target = null
|
|
862
|
+
var targetSubscription = null
|
|
863
|
+
var bound = null
|
|
864
|
+
// The Session binding can be recreated (reconnect/resync). Re-resolve the
|
|
865
|
+
// target whenever the binding generation changes instead of pinning the
|
|
866
|
+
// first one forever (a failed first lookup used to freeze the view empty).
|
|
867
|
+
function bindTarget() {
|
|
868
|
+
var next = null
|
|
869
|
+
try { next = ctx.uiConversation.binding(sessionId) } catch (error) { next = null }
|
|
870
|
+
if (next === null) return
|
|
871
|
+
if (next === bound && target !== null) return
|
|
872
|
+
if (targetSubscription !== null) { try { targetSubscription() } catch (error) {} ; targetSubscription = null }
|
|
873
|
+
bound = next
|
|
874
|
+
target = null
|
|
875
|
+
try { target = next.target(TARGET) } catch (error) { target = null }
|
|
876
|
+
if (target !== null && typeof target.subscribe === 'function') targetSubscription = target.subscribe(invalidate)
|
|
877
|
+
}
|
|
878
|
+
var sessionsList = ctx.sessions && ctx.sessions.list ? ctx.sessions.list : null
|
|
879
|
+
var listeners = new Set()
|
|
880
|
+
var cached = null
|
|
881
|
+
var dirty = true
|
|
882
|
+
var disposed = false
|
|
883
|
+
var tick = null
|
|
884
|
+
function invalidate() {
|
|
885
|
+
if (disposed) return
|
|
886
|
+
dirty = true
|
|
887
|
+
listeners.forEach(function (listener) { listener() })
|
|
888
|
+
}
|
|
889
|
+
bindTarget()
|
|
890
|
+
var disposers = []
|
|
891
|
+
if (sessionsList !== null && typeof sessionsList.subscribe === 'function') disposers.push(sessionsList.subscribe(invalidate))
|
|
892
|
+
var lastWeave = null
|
|
893
|
+
var lastList = null
|
|
894
|
+
var lastBucket = -1
|
|
895
|
+
var hasCache = false
|
|
896
|
+
function compute() {
|
|
897
|
+
bindTarget()
|
|
898
|
+
var weave = null
|
|
899
|
+
if (target !== null) {
|
|
900
|
+
try { weave = target.getSnapshot() || null } catch (error) { weave = null }
|
|
901
|
+
}
|
|
902
|
+
var list = null
|
|
903
|
+
if (sessionsList !== null && typeof sessionsList.getSnapshot === 'function') {
|
|
904
|
+
try { list = sessionsList.getSnapshot() } catch (error) { list = null }
|
|
905
|
+
}
|
|
906
|
+
// Conversation snapshots publish for every event (deltas included), but the
|
|
907
|
+
// weave target and the session list often keep the same identities. Reuse
|
|
908
|
+
// the mapped data then; only the second-bucketed clock may change elapsed.
|
|
909
|
+
var bucket = Math.floor(Date.now() / 1000)
|
|
910
|
+
if (hasCache && weave === lastWeave && list === lastList && bucket === lastBucket) return cached
|
|
911
|
+
cached = buildWeaveData({ sessionId: sessionId, list: list, weave: weave, now: Date.now() })
|
|
912
|
+
lastWeave = weave
|
|
913
|
+
lastList = list
|
|
914
|
+
lastBucket = bucket
|
|
915
|
+
hasCache = true
|
|
916
|
+
return cached
|
|
917
|
+
}
|
|
918
|
+
return {
|
|
919
|
+
getSnapshot: function () {
|
|
920
|
+
if (dirty || cached === null) {
|
|
921
|
+
cached = compute()
|
|
922
|
+
dirty = false
|
|
923
|
+
}
|
|
924
|
+
return cached
|
|
925
|
+
},
|
|
926
|
+
subscribe: function (listener) {
|
|
927
|
+
listeners.add(listener)
|
|
928
|
+
// A live Session can stay quiet between events (long model calls); refresh
|
|
929
|
+
// the clock/elapsed fields periodically so the view still breathes.
|
|
930
|
+
if (tick === null) tick = window.setInterval(invalidate, 1500)
|
|
931
|
+
return function () {
|
|
932
|
+
listeners.delete(listener)
|
|
933
|
+
if (listeners.size === 0 && tick !== null) {
|
|
934
|
+
window.clearInterval(tick)
|
|
935
|
+
tick = null
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
},
|
|
939
|
+
dispose: function () {
|
|
940
|
+
disposed = true
|
|
941
|
+
if (tick !== null) { window.clearInterval(tick); tick = null }
|
|
942
|
+
if (targetSubscription !== null) { try { targetSubscription() } catch (error) {} ; targetSubscription = null }
|
|
943
|
+
disposers.forEach(function (dispose) { try { dispose() } catch (error) {} })
|
|
944
|
+
listeners.clear()
|
|
945
|
+
},
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
function currentTheme() {
|
|
950
|
+
try {
|
|
951
|
+
var value = document.documentElement.getAttribute('data-theme')
|
|
952
|
+
if (value === 'dark' || value === 'light') return value
|
|
953
|
+
return window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'
|
|
954
|
+
} catch (error) {
|
|
955
|
+
return 'light'
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
function WeaveView(props) {
|
|
960
|
+
var t = typeof props.t === 'function' ? props.t : function (key) { return key }
|
|
961
|
+
var useWeave = props.useWeave
|
|
962
|
+
var loadHistory = props.loadHistory
|
|
963
|
+
var snapshot = typeof useWeave === 'function'
|
|
964
|
+
? useWeave(function (value) { return value })
|
|
965
|
+
: EMPTY_WEAVE_DATA
|
|
966
|
+
var data = snapshot || EMPTY_WEAVE_DATA
|
|
967
|
+
var iframeRef = React.useRef(null)
|
|
968
|
+
var ackedRef = React.useRef(false)
|
|
969
|
+
var latestRef = React.useRef(data)
|
|
970
|
+
latestRef.current = data
|
|
971
|
+
var liveRef = React.useRef(true)
|
|
972
|
+
var [theme, setTheme] = React.useState(currentTheme())
|
|
973
|
+
var [acked, setAcked] = React.useState(false)
|
|
974
|
+
var [status, setStatus] = React.useState('')
|
|
975
|
+
var [histStatus, setHistStatus] = React.useState('')
|
|
976
|
+
var [failed, setFailed] = React.useState(false)
|
|
977
|
+
|
|
978
|
+
var post = React.useCallback(function (message) {
|
|
979
|
+
var frame = iframeRef.current
|
|
980
|
+
if (frame === null || frame === undefined || frame.contentWindow === null) return
|
|
981
|
+
try { frame.contentWindow.postMessage(message, '*') } catch (error) {}
|
|
982
|
+
}, [])
|
|
983
|
+
|
|
984
|
+
var postInit = React.useCallback(function () {
|
|
985
|
+
post({ type: 'weave:init', data: latestRef.current, theme: currentTheme(), live: liveRef.current })
|
|
986
|
+
}, [post])
|
|
987
|
+
|
|
988
|
+
var runHistory = React.useCallback(function () {
|
|
989
|
+
if (typeof loadHistory !== 'function') {
|
|
990
|
+
setHistStatus('当前会话不支持读取历史')
|
|
991
|
+
return
|
|
992
|
+
}
|
|
993
|
+
setHistStatus('正在读取本地历史…')
|
|
994
|
+
post({ type: 'weave:history-status', text: '正在读取本地历史…' })
|
|
995
|
+
Promise.resolve(loadHistory(80)).then(function (result) {
|
|
996
|
+
var ok = result !== null && result !== undefined && result.ok === true
|
|
997
|
+
var text = ok
|
|
998
|
+
? ('已读取 ' + result.pages + ' 页历史' + (result.hasMore ? '(还有更早)' : ''))
|
|
999
|
+
: ('读取历史失败:' + ((result && result.reason) || '未知原因'))
|
|
1000
|
+
setHistStatus(text)
|
|
1001
|
+
post({ type: 'weave:history-status', text: text, failed: !ok })
|
|
1002
|
+
window.setTimeout(function () {
|
|
1003
|
+
setHistStatus(function (current) { return current === text ? '' : current })
|
|
1004
|
+
}, 5000)
|
|
1005
|
+
}).catch(function (error) {
|
|
1006
|
+
var text = '读取历史失败:' + String((error && error.message) || error)
|
|
1007
|
+
setHistStatus(text)
|
|
1008
|
+
post({ type: 'weave:history-status', text: text, failed: true })
|
|
1009
|
+
})
|
|
1010
|
+
}, [loadHistory, post])
|
|
1011
|
+
|
|
1012
|
+
React.useEffect(function () {
|
|
1013
|
+
function onMessage(event) {
|
|
1014
|
+
var frame = iframeRef.current
|
|
1015
|
+
if (frame === null || frame === undefined || event.source !== frame.contentWindow) return
|
|
1016
|
+
var message = event.data
|
|
1017
|
+
if (message === null || typeof message !== 'object') return
|
|
1018
|
+
if (message.type === 'weave:ready') {
|
|
1019
|
+
postInit()
|
|
1020
|
+
return
|
|
1021
|
+
}
|
|
1022
|
+
if (message.type === 'weave:request-history') {
|
|
1023
|
+
runHistory()
|
|
1024
|
+
return
|
|
1025
|
+
}
|
|
1026
|
+
if (message.type === 'weave:event') {
|
|
1027
|
+
if (!ackedRef.current) {
|
|
1028
|
+
ackedRef.current = true
|
|
1029
|
+
setAcked(true)
|
|
1030
|
+
setStatus('')
|
|
1031
|
+
}
|
|
1032
|
+
if (message.event === 'seek') {
|
|
1033
|
+
var seek = message.payload || {}
|
|
1034
|
+
// Only the explicit "回到最新" jump resumes live following. Any other
|
|
1035
|
+
// seek is a user scrub: keep it local or the next update pins to END.
|
|
1036
|
+
liveRef.current = seek.source === 'live-jump'
|
|
1037
|
+
}
|
|
1038
|
+
if (message.event === 'mode' && message.payload && typeof message.payload.live === 'boolean') {
|
|
1039
|
+
liveRef.current = message.payload.live
|
|
1040
|
+
}
|
|
1041
|
+
if (message.event === 'error' && message.payload && message.payload.message) {
|
|
1042
|
+
setStatus('Weave 运行时报错:' + String(message.payload.message).slice(0, 80))
|
|
1043
|
+
}
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
1046
|
+
window.addEventListener('message', onMessage)
|
|
1047
|
+
return function () { window.removeEventListener('message', onMessage) }
|
|
1048
|
+
}, [postInit, runHistory])
|
|
1049
|
+
|
|
1050
|
+
React.useEffect(function () {
|
|
1051
|
+
// The iframe may announce ready before this component's listener attaches;
|
|
1052
|
+
// keep re-sending init until the runtime acknowledges with a event frame.
|
|
1053
|
+
var attempts = 0
|
|
1054
|
+
var timer = window.setInterval(function () {
|
|
1055
|
+
if (ackedRef.current) { window.clearInterval(timer); return }
|
|
1056
|
+
attempts += 1
|
|
1057
|
+
postInit()
|
|
1058
|
+
if (attempts === 3) setStatus('正在连接 Weave 运行时…')
|
|
1059
|
+
if (attempts >= 25) {
|
|
1060
|
+
setStatus('Weave 运行时未响应,请刷新页面或重启 DSH')
|
|
1061
|
+
window.clearInterval(timer)
|
|
1062
|
+
}
|
|
1063
|
+
}, 600)
|
|
1064
|
+
return function () { window.clearInterval(timer) }
|
|
1065
|
+
}, [postInit])
|
|
1066
|
+
|
|
1067
|
+
var updateTimerRef = React.useRef(null)
|
|
1068
|
+
React.useEffect(function () {
|
|
1069
|
+
// Do NOT clear the pending timer on every snapshot: DSH publishes a
|
|
1070
|
+
// Conversation snapshot for every event (stream deltas included), often
|
|
1071
|
+
// faster than the delay, so a cancel-on-change debounce starves updates and
|
|
1072
|
+
// the iframe freezes at its last frame. Keep one trailing timer and read the
|
|
1073
|
+
// latest data when it fires.
|
|
1074
|
+
if (updateTimerRef.current !== null) return undefined
|
|
1075
|
+
updateTimerRef.current = window.setTimeout(function () {
|
|
1076
|
+
updateTimerRef.current = null
|
|
1077
|
+
post({ type: 'weave:update', data: latestRef.current, live: liveRef.current })
|
|
1078
|
+
}, 150)
|
|
1079
|
+
return undefined
|
|
1080
|
+
}, [data, acked, post])
|
|
1081
|
+
|
|
1082
|
+
React.useEffect(function () {
|
|
1083
|
+
return function () {
|
|
1084
|
+
if (updateTimerRef.current !== null) {
|
|
1085
|
+
window.clearTimeout(updateTimerRef.current)
|
|
1086
|
+
updateTimerRef.current = null
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1089
|
+
}, [])
|
|
1090
|
+
|
|
1091
|
+
React.useEffect(function () {
|
|
1092
|
+
// DSH theme switches mutate data-theme on <html>; forward them so the
|
|
1093
|
+
// iframe does not keep the theme captured at mount.
|
|
1094
|
+
function push() {
|
|
1095
|
+
var next = currentTheme()
|
|
1096
|
+
setTheme(next)
|
|
1097
|
+
post({ type: 'weave:theme', theme: next })
|
|
1098
|
+
}
|
|
1099
|
+
var observer = new MutationObserver(push)
|
|
1100
|
+
try {
|
|
1101
|
+
observer.observe(document.documentElement, { attributes: true, attributeFilter: ['data-theme'] })
|
|
1102
|
+
} catch (error) {}
|
|
1103
|
+
return function () { observer.disconnect() }
|
|
1104
|
+
}, [post])
|
|
1105
|
+
|
|
1106
|
+
React.useEffect(function () {
|
|
1107
|
+
// DSH renders host "transcript width" handles ([data-width-handle]) beside
|
|
1108
|
+
// the content column. They resize the chat transcript, not this view's
|
|
1109
|
+
// columns, and inside Weave they read as a mystery drag box. Hide them only
|
|
1110
|
+
// while this view is mounted; chat keeps its own handles elsewhere.
|
|
1111
|
+
var existing = document.head.querySelector('style[data-weave-host-fix]')
|
|
1112
|
+
if (existing !== null) return function () {}
|
|
1113
|
+
var style = document.createElement('style')
|
|
1114
|
+
style.setAttribute('data-weave-host-fix', '')
|
|
1115
|
+
style.textContent = 'body:has([data-weave-view]) [data-width-handle] { display: none !important; }'
|
|
1116
|
+
document.head.appendChild(style)
|
|
1117
|
+
return function () {
|
|
1118
|
+
if (style.parentNode !== null) style.parentNode.removeChild(style)
|
|
1119
|
+
}
|
|
1120
|
+
}, [])
|
|
1121
|
+
|
|
1122
|
+
React.useEffect(function () {
|
|
1123
|
+
if (acked) post({ type: 'weave:theme', theme: theme })
|
|
1124
|
+
}, [theme, acked, post])
|
|
1125
|
+
|
|
1126
|
+
var children = []
|
|
1127
|
+
if (failed) {
|
|
1128
|
+
children.push(React.createElement('div', {
|
|
1129
|
+
key: 'error',
|
|
1130
|
+
style: { display: 'flex', alignItems: 'center', justifyContent: 'center', height: '100%', color: 'var(--dsw-alias-label-tertiary)', fontSize: '13px' },
|
|
1131
|
+
}, t('error')))
|
|
1132
|
+
}
|
|
1133
|
+
children.push(React.createElement('iframe', {
|
|
1134
|
+
key: 'frame',
|
|
1135
|
+
ref: iframeRef,
|
|
1136
|
+
title: t('view.weave.aria'),
|
|
1137
|
+
sandbox: 'allow-scripts',
|
|
1138
|
+
srcDoc: WEAVE_HTML,
|
|
1139
|
+
onLoad: function () { postInit() },
|
|
1140
|
+
onError: function () { setFailed(true) },
|
|
1141
|
+
style: { border: '0', width: '100%', height: '100%', display: 'block', background: 'transparent', colorScheme: 'normal' },
|
|
1142
|
+
}))
|
|
1143
|
+
if (status !== '' && !failed) {
|
|
1144
|
+
children.push(React.createElement('div', {
|
|
1145
|
+
key: 'status',
|
|
1146
|
+
style: {
|
|
1147
|
+
position: 'absolute', left: '10px', bottom: '10px', zIndex: 2, pointerEvents: 'none',
|
|
1148
|
+
padding: '4px 9px', borderRadius: '4px', background: 'rgba(20,17,13,0.82)',
|
|
1149
|
+
color: '#efe6d6', fontSize: '12px', lineHeight: '18px',
|
|
1150
|
+
},
|
|
1151
|
+
}, status))
|
|
1152
|
+
}
|
|
1153
|
+
var showHistoryChip = histStatus !== '' || (acked && data !== null && data !== undefined && Array.isArray(data.events) && data.events.length < 3)
|
|
1154
|
+
if (showHistoryChip && !failed) {
|
|
1155
|
+
children.push(React.createElement('button', {
|
|
1156
|
+
key: 'history',
|
|
1157
|
+
type: 'button',
|
|
1158
|
+
onClick: function () { runHistory() },
|
|
1159
|
+
title: '从本地会话历史补读更早的数据',
|
|
1160
|
+
style: {
|
|
1161
|
+
position: 'absolute', top: '48px', right: '8px', zIndex: 3,
|
|
1162
|
+
padding: '4px 10px', border: '1px solid rgba(178,58,38,0.5)', borderRadius: '4px',
|
|
1163
|
+
background: 'rgba(247,242,231,0.94)', color: '#8a2e1e',
|
|
1164
|
+
fontSize: '12px', lineHeight: '18px', cursor: 'pointer',
|
|
1165
|
+
},
|
|
1166
|
+
}, histStatus !== '' ? histStatus : '读取本地历史数据'))
|
|
1167
|
+
}
|
|
1168
|
+
return React.createElement('div', {
|
|
1169
|
+
'data-weave-view': '',
|
|
1170
|
+
style: { position: 'relative', display: 'flex', flexDirection: 'column', width: '100%', height: '100%', minHeight: '320px', overflow: 'hidden' },
|
|
1171
|
+
}, children)
|
|
1172
|
+
}
|
|
1173
|
+
|
|
1174
|
+
var historyLoads = new Map()
|
|
1175
|
+
|
|
1176
|
+
/** Page the local session history through the official session API. */
|
|
1177
|
+
function loadHistoryFor(ctx, sessionId, maxPages) {
|
|
1178
|
+
var key = String(sessionId)
|
|
1179
|
+
var pending = historyLoads.get(key)
|
|
1180
|
+
if (pending !== undefined) return pending
|
|
1181
|
+
// Bound one click: official paging is one page per request with a loading
|
|
1182
|
+
// guard. A deep 80-200 page synchronous loop froze the host and fought the
|
|
1183
|
+
// Chat/Trajectory paging loops.
|
|
1184
|
+
var limit = typeof maxPages === 'number' && maxPages > 0 ? Math.min(Math.floor(maxPages), 16) : 12
|
|
1185
|
+
var task = (async function () {
|
|
1186
|
+
try {
|
|
1187
|
+
var binding = null
|
|
1188
|
+
try { binding = ctx.sessions.binding(sessionId) } catch (error) { binding = null }
|
|
1189
|
+
var session = binding !== null && binding !== undefined && binding.session !== undefined ? binding.session : null
|
|
1190
|
+
if (session === null) return { ok: false, reason: '会话尚未连接' }
|
|
1191
|
+
var pages = 0
|
|
1192
|
+
var spins = 0
|
|
1193
|
+
while (pages < limit && spins < 200) {
|
|
1194
|
+
spins += 1
|
|
1195
|
+
var snapshot = typeof session.getSnapshot === 'function' ? session.getSnapshot() : null
|
|
1196
|
+
if (snapshot !== null && snapshot.openState !== 'open') {
|
|
1197
|
+
if (snapshot.openState === 'error') return { ok: false, reason: '会话打开失败' }
|
|
1198
|
+
await new Promise(function (resolve) { window.setTimeout(resolve, 120) })
|
|
1199
|
+
continue
|
|
1200
|
+
}
|
|
1201
|
+
if (snapshot !== null && snapshot.hasMore === false) break
|
|
1202
|
+
if (snapshot !== null && snapshot.loadingOlder === true) {
|
|
1203
|
+
await new Promise(function (resolve) { window.setTimeout(resolve, 80) })
|
|
1204
|
+
continue
|
|
1205
|
+
}
|
|
1206
|
+
var before = snapshot
|
|
1207
|
+
await session.loadOlder()
|
|
1208
|
+
pages += 1
|
|
1209
|
+
var after = typeof session.getSnapshot === 'function' ? session.getSnapshot() : null
|
|
1210
|
+
if (after === before) break
|
|
1211
|
+
if (after !== null && after.hasMore === false) break
|
|
1212
|
+
}
|
|
1213
|
+
var finalSnapshot = typeof session.getSnapshot === 'function' ? session.getSnapshot() : null
|
|
1214
|
+
return { ok: true, pages: pages, hasMore: finalSnapshot !== null && finalSnapshot.hasMore === true }
|
|
1215
|
+
} catch (error) {
|
|
1216
|
+
return { ok: false, reason: String((error && error.message) || error) }
|
|
1217
|
+
}
|
|
1218
|
+
})()
|
|
1219
|
+
historyLoads.set(key, task)
|
|
1220
|
+
task.then(function () { historyLoads.delete(key) }, function () { historyLoads.delete(key) })
|
|
1221
|
+
return task
|
|
1222
|
+
}
|
|
1223
|
+
|
|
1224
|
+
var sources = new Map()
|
|
1225
|
+
|
|
1226
|
+
function sourceFor(ctx, sessionId) {
|
|
1227
|
+
var key = String(sessionId)
|
|
1228
|
+
var existing = sources.get(key)
|
|
1229
|
+
if (existing !== undefined) return existing
|
|
1230
|
+
var source = makeWeaveSource(ctx, sessionId)
|
|
1231
|
+
sources.set(key, source)
|
|
1232
|
+
return source
|
|
1233
|
+
}
|
|
1234
|
+
|
|
1235
|
+
function apply(ctx) {
|
|
1236
|
+
ctx.effect(function () { return ctx.locale.register(NS, { zh: zh, en: { 'view.weave': 'Weave', 'view.weave.aria': 'Weave multi-agent observatory' } }) }, 'client-ui-weave: dictionaries')
|
|
1237
|
+
var t = ctx.locale.bind(NS)
|
|
1238
|
+
try {
|
|
1239
|
+
registerWeaveTarget(ctx)
|
|
1240
|
+
} catch (error) {
|
|
1241
|
+
if (ctx.logger !== undefined) ctx.logger.warn('weave: target registration failed: %s', error)
|
|
1242
|
+
}
|
|
1243
|
+
try {
|
|
1244
|
+
registerWeaveDefinitions(ctx)
|
|
1245
|
+
} catch (error) {
|
|
1246
|
+
if (ctx.logger !== undefined) ctx.logger.warn('weave: definition registration failed: %s', error)
|
|
1247
|
+
}
|
|
1248
|
+
ctx.effect(function () {
|
|
1249
|
+
return function () {
|
|
1250
|
+
sources.forEach(function (source) { source.dispose() })
|
|
1251
|
+
sources.clear()
|
|
1252
|
+
}
|
|
1253
|
+
}, 'client-ui-weave: sources')
|
|
1254
|
+
ctx.slots.inject('conversation.view', function () {
|
|
1255
|
+
return ctx.slots.register({
|
|
1256
|
+
name: 'conversation.view',
|
|
1257
|
+
id: 'weave',
|
|
1258
|
+
order: 50,
|
|
1259
|
+
locale: NS,
|
|
1260
|
+
label: function () { return t('view.weave') },
|
|
1261
|
+
inject: function (sessionId) {
|
|
1262
|
+
return {
|
|
1263
|
+
sessionId: sessionId,
|
|
1264
|
+
hooks: { weave: sourceFor(ctx, sessionId) },
|
|
1265
|
+
loadHistory: function (maxPages) { return loadHistoryFor(ctx, sessionId, maxPages) },
|
|
1266
|
+
}
|
|
1267
|
+
},
|
|
1268
|
+
}, WeaveView)
|
|
1269
|
+
})
|
|
1270
|
+
}
|
|
1271
|
+
|
|
1272
|
+
const inject = ['slots', 'sessions', 'uiConversation', 'locale']
|
|
1273
|
+
|
|
1274
|
+
exports.apply = apply
|
|
1275
|
+
exports.inject = inject
|
|
1276
|
+
return module.exports;}});
|