fascicle 0.12.3 → 0.12.7
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/CHANGELOG.md +61 -6
- package/README.md +3 -2
- package/dist/agents.d.ts +1 -1
- package/dist/agents.js +1 -1
- package/dist/{core-DdJEhyQc.js → core-CFdEjtiT.js} +281 -270
- package/dist/core-CFdEjtiT.js.map +1 -0
- package/dist/{engine-J4lIxpw5.js → engine-DQiQHiy8.js} +182 -34
- package/dist/engine-DQiQHiy8.js.map +1 -0
- package/dist/index.d.ts +28 -2
- package/dist/index.js +48 -4
- package/dist/index.js.map +1 -1
- package/dist/{invoke-CH_eJZeS.js → invoke-eEYMZmWg.js} +3 -3
- package/dist/{invoke-CH_eJZeS.js.map → invoke-eEYMZmWg.js.map} +1 -1
- package/dist/{leading_system-BUCT-PwD.js → leading_system-DQmlA6Fs.js} +2 -2
- package/dist/{leading_system-BUCT-PwD.js.map → leading_system-DQmlA6Fs.js.map} +1 -1
- package/dist/mcp.d.ts +1 -1
- package/dist/mcp.js +1 -1
- package/dist/otel.d.ts +20 -2
- package/dist/otel.js +228 -8
- package/dist/otel.js.map +1 -1
- package/dist/stdio.js +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +3 -3
- package/dist/{types-DU6cvoA4.d.ts → types-CLigYA62.d.ts} +28 -2
- package/dist/viewer-app/assets/index-BGb1-MwM.js +2 -0
- package/dist/viewer-app/assets/index-D7kvKs40.css +1 -0
- package/dist/viewer-app/fonts/sora-OFL.txt +93 -0
- package/dist/viewer-app/fonts/sora-latin.woff2 +0 -0
- package/dist/viewer-app/fonts/spline-sans-mono-OFL.txt +93 -0
- package/dist/viewer-app/fonts/spline-sans-mono-latin.woff2 +0 -0
- package/dist/viewer-app/index.html +13 -0
- package/dist/viewer.d.ts +17 -3
- package/dist/viewer.js +210 -50
- package/dist/viewer.js.map +1 -1
- package/package.json +14 -3
- package/dist/core-DdJEhyQc.js.map +0 -1
- package/dist/engine-J4lIxpw5.js.map +0 -1
- package/dist/static/viewer.html +0 -375
package/dist/static/viewer.html
DELETED
|
@@ -1,375 +0,0 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="utf-8" />
|
|
5
|
-
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
|
6
|
-
<title>fascicle viewer</title>
|
|
7
|
-
<style>
|
|
8
|
-
:root {
|
|
9
|
-
color-scheme: light;
|
|
10
|
-
--fg: #1f2328;
|
|
11
|
-
--muted: #57606a;
|
|
12
|
-
--bg: #f6f7f8;
|
|
13
|
-
--panel: #ffffff;
|
|
14
|
-
--border: #d0d7de;
|
|
15
|
-
--accent: #b08900;
|
|
16
|
-
--accent-soft: #fff4c2;
|
|
17
|
-
--error: #a53a2c;
|
|
18
|
-
--error-soft: #fbe1dc;
|
|
19
|
-
--pulse: #cce4ff;
|
|
20
|
-
}
|
|
21
|
-
* { box-sizing: border-box }
|
|
22
|
-
html, body { margin: 0; height: 100% }
|
|
23
|
-
body {
|
|
24
|
-
font: 13px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
|
25
|
-
color: var(--fg);
|
|
26
|
-
background: var(--bg);
|
|
27
|
-
}
|
|
28
|
-
header {
|
|
29
|
-
display: flex; align-items: center; gap: 12px;
|
|
30
|
-
padding: 8px 12px;
|
|
31
|
-
background: var(--panel);
|
|
32
|
-
border-bottom: 1px solid var(--border);
|
|
33
|
-
}
|
|
34
|
-
header h1 { margin: 0; font: inherit; font-weight: 600 }
|
|
35
|
-
header .conn { color: var(--muted) }
|
|
36
|
-
header .conn.ok { color: #1a7f37 }
|
|
37
|
-
header .conn.err { color: var(--error) }
|
|
38
|
-
header label { color: var(--muted) }
|
|
39
|
-
header select { font: inherit; padding: 2px 4px; border: 1px solid var(--border); background: #fff }
|
|
40
|
-
main {
|
|
41
|
-
display: grid;
|
|
42
|
-
grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
|
|
43
|
-
gap: 0;
|
|
44
|
-
height: calc(100vh - 38px);
|
|
45
|
-
}
|
|
46
|
-
section { overflow: auto; padding: 8px 12px; background: var(--panel); }
|
|
47
|
-
section + section { border-left: 1px solid var(--border) }
|
|
48
|
-
h2 { margin: 0 0 8px 0; font: inherit; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em }
|
|
49
|
-
ul.tree { list-style: none; margin: 0; padding-left: 0 }
|
|
50
|
-
ul.tree ul { list-style: none; margin: 0; padding-left: 16px; border-left: 1px dotted var(--border) }
|
|
51
|
-
.node {
|
|
52
|
-
display: flex; gap: 8px; align-items: baseline;
|
|
53
|
-
padding: 2px 6px; border-radius: 4px;
|
|
54
|
-
}
|
|
55
|
-
.node .label { font-weight: 600 }
|
|
56
|
-
.node .kind { color: var(--muted); font-size: 11px; padding: 0 4px; border: 1px solid var(--border); border-radius: 3px }
|
|
57
|
-
.node .id { color: var(--muted); font-size: 11px }
|
|
58
|
-
.node .elapsed { margin-left: auto; color: var(--muted); font-size: 11px }
|
|
59
|
-
.node .cost { color: var(--accent); font-size: 11px; padding-left: 6px; font-variant-numeric: tabular-nums }
|
|
60
|
-
.node.running { background: var(--accent-soft); animation: pulse 1.6s ease-in-out infinite }
|
|
61
|
-
.node.errored { background: var(--error-soft); color: var(--error) }
|
|
62
|
-
.node.suspended { background: #ececec; font-style: italic }
|
|
63
|
-
.node.emit-flash { background: var(--pulse); transition: background 200ms }
|
|
64
|
-
@keyframes pulse {
|
|
65
|
-
0%, 100% { background: var(--accent-soft) }
|
|
66
|
-
50% { background: #ffe690 }
|
|
67
|
-
}
|
|
68
|
-
.log {
|
|
69
|
-
font-size: 12px;
|
|
70
|
-
}
|
|
71
|
-
.log .row {
|
|
72
|
-
display: grid; grid-template-columns: 80px 90px 130px 1fr;
|
|
73
|
-
gap: 8px; padding: 2px 0; border-bottom: 1px solid var(--border);
|
|
74
|
-
cursor: pointer;
|
|
75
|
-
}
|
|
76
|
-
.log .row:hover { background: var(--bg) }
|
|
77
|
-
.log .row .ts { color: var(--muted) }
|
|
78
|
-
.log .row .kind { font-weight: 600 }
|
|
79
|
-
.log .row .span { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
|
|
80
|
-
.log .row .payload { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted) }
|
|
81
|
-
.log .row.err .kind { color: var(--error) }
|
|
82
|
-
details { margin: 6px 0 }
|
|
83
|
-
details > pre { background: var(--bg); padding: 8px; overflow: auto; margin: 4px 0 0 0; border: 1px solid var(--border); border-radius: 4px }
|
|
84
|
-
.empty { color: var(--muted); padding: 16px 0 }
|
|
85
|
-
footer { color: var(--muted); padding: 4px 12px; border-top: 1px solid var(--border); background: var(--panel); font-size: 11px }
|
|
86
|
-
</style>
|
|
87
|
-
</head>
|
|
88
|
-
<body>
|
|
89
|
-
<header>
|
|
90
|
-
<h1>fascicle viewer</h1>
|
|
91
|
-
<span class="conn" id="conn">connecting…</span>
|
|
92
|
-
<label>run:
|
|
93
|
-
<select id="run-filter"><option value="">all</option></select>
|
|
94
|
-
</label>
|
|
95
|
-
<span style="margin-left:auto" id="counts"></span>
|
|
96
|
-
</header>
|
|
97
|
-
<main>
|
|
98
|
-
<section>
|
|
99
|
-
<h2>spans</h2>
|
|
100
|
-
<div id="tree"></div>
|
|
101
|
-
</section>
|
|
102
|
-
<section>
|
|
103
|
-
<h2>events</h2>
|
|
104
|
-
<div class="log" id="log"></div>
|
|
105
|
-
</section>
|
|
106
|
-
</main>
|
|
107
|
-
<footer id="footer">localhost dev tool — no auth, no persistence</footer>
|
|
108
|
-
<script>
|
|
109
|
-
(() => {
|
|
110
|
-
const $tree = document.getElementById('tree')
|
|
111
|
-
const $log = document.getElementById('log')
|
|
112
|
-
const $conn = document.getElementById('conn')
|
|
113
|
-
const $filter = document.getElementById('run-filter')
|
|
114
|
-
const $counts = document.getElementById('counts')
|
|
115
|
-
|
|
116
|
-
const spans = new Map()
|
|
117
|
-
const roots = []
|
|
118
|
-
const log_rows = []
|
|
119
|
-
const run_ids = new Set()
|
|
120
|
-
const open_stacks = new Map() // run_id -> [span_id...] (deepest last)
|
|
121
|
-
const cost_by_run = new Map() // run_id -> total cost in usd
|
|
122
|
-
let unattributed_cost = 0 // cost events with no matching run / open span
|
|
123
|
-
let active_run = ''
|
|
124
|
-
let total = 0
|
|
125
|
-
let errors = 0
|
|
126
|
-
|
|
127
|
-
function empty_message(text) {
|
|
128
|
-
const div = document.createElement('div')
|
|
129
|
-
div.className = 'empty'
|
|
130
|
-
div.textContent = text
|
|
131
|
-
return div
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
$tree.replaceChildren(empty_message('waiting for events…'))
|
|
135
|
-
|
|
136
|
-
$filter.addEventListener('change', () => {
|
|
137
|
-
active_run = $filter.value
|
|
138
|
-
render_tree()
|
|
139
|
-
render_log()
|
|
140
|
-
})
|
|
141
|
-
|
|
142
|
-
function set_conn(state, label) {
|
|
143
|
-
$conn.className = 'conn ' + state
|
|
144
|
-
$conn.textContent = label
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
function ensure_run(id) {
|
|
148
|
-
if (!id || run_ids.has(id)) return
|
|
149
|
-
run_ids.add(id)
|
|
150
|
-
const opt = document.createElement('option')
|
|
151
|
-
opt.value = id
|
|
152
|
-
opt.textContent = id
|
|
153
|
-
$filter.appendChild(opt)
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
function span_visible(span) {
|
|
157
|
-
if (!active_run) return true
|
|
158
|
-
return span.run_id === active_run
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
function format_elapsed(span) {
|
|
162
|
-
if (!span.started_at) return ''
|
|
163
|
-
const end = span.ended_at ?? Date.now()
|
|
164
|
-
const ms = Math.max(0, end - span.started_at)
|
|
165
|
-
if (ms < 1000) return ms + 'ms'
|
|
166
|
-
return (ms / 1000).toFixed(2) + 's'
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
function format_cost(usd) {
|
|
170
|
-
// < 1¢ shown to 4 decimals, otherwise to 2 decimals (per research/explorations/2026-04-eval-surface.md §5)
|
|
171
|
-
if (usd < 0.01) return '$' + usd.toFixed(4)
|
|
172
|
-
return '$' + usd.toFixed(2)
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
function span_cost_total(span) {
|
|
176
|
-
// Direct cost on this span plus the rolled-up cost of every descendant.
|
|
177
|
-
let sum = span.cost_self
|
|
178
|
-
for (const cid of span.children) {
|
|
179
|
-
const child = spans.get(cid)
|
|
180
|
-
if (child) sum += span_cost_total(child)
|
|
181
|
-
}
|
|
182
|
-
return sum
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
function render_tree() {
|
|
186
|
-
if (spans.size === 0) {
|
|
187
|
-
$tree.replaceChildren(empty_message('waiting for events…'))
|
|
188
|
-
return
|
|
189
|
-
}
|
|
190
|
-
const ul = document.createElement('ul')
|
|
191
|
-
ul.className = 'tree'
|
|
192
|
-
for (const id of roots) {
|
|
193
|
-
const span = spans.get(id)
|
|
194
|
-
if (!span || !span_visible(span)) continue
|
|
195
|
-
ul.appendChild(render_node(span))
|
|
196
|
-
}
|
|
197
|
-
$tree.replaceChildren(ul)
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
function render_node(span) {
|
|
201
|
-
const li = document.createElement('li')
|
|
202
|
-
const node = document.createElement('div')
|
|
203
|
-
node.className = 'node ' + span.state
|
|
204
|
-
if (span.flash_until && span.flash_until > Date.now()) node.classList.add('emit-flash')
|
|
205
|
-
const label = document.createElement('span')
|
|
206
|
-
label.className = 'label'
|
|
207
|
-
label.textContent = span.label
|
|
208
|
-
node.appendChild(label)
|
|
209
|
-
if (span.kind && span.kind !== span.label) {
|
|
210
|
-
const kind = document.createElement('span')
|
|
211
|
-
kind.className = 'kind'
|
|
212
|
-
kind.textContent = span.kind
|
|
213
|
-
node.appendChild(kind)
|
|
214
|
-
}
|
|
215
|
-
const sid = document.createElement('span')
|
|
216
|
-
sid.className = 'id'
|
|
217
|
-
sid.textContent = span.span_id
|
|
218
|
-
const elapsed = document.createElement('span')
|
|
219
|
-
elapsed.className = 'elapsed'
|
|
220
|
-
elapsed.textContent = format_elapsed(span)
|
|
221
|
-
node.appendChild(sid)
|
|
222
|
-
node.appendChild(elapsed)
|
|
223
|
-
const cost = span_cost_total(span)
|
|
224
|
-
if (cost > 0) {
|
|
225
|
-
const cost_el = document.createElement('span')
|
|
226
|
-
cost_el.className = 'cost'
|
|
227
|
-
cost_el.textContent = format_cost(cost)
|
|
228
|
-
node.appendChild(cost_el)
|
|
229
|
-
}
|
|
230
|
-
li.appendChild(node)
|
|
231
|
-
if (span.children.length) {
|
|
232
|
-
const ul = document.createElement('ul')
|
|
233
|
-
for (const cid of span.children) {
|
|
234
|
-
const child = spans.get(cid)
|
|
235
|
-
if (child) ul.appendChild(render_node(child))
|
|
236
|
-
}
|
|
237
|
-
li.appendChild(ul)
|
|
238
|
-
}
|
|
239
|
-
return li
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
function render_log() {
|
|
243
|
-
const visible = log_rows.filter((r) => !active_run || r.run_id === active_run)
|
|
244
|
-
const slice = visible.slice(-200)
|
|
245
|
-
$log.replaceChildren()
|
|
246
|
-
for (const row of slice) {
|
|
247
|
-
const div = document.createElement('div')
|
|
248
|
-
const failed_run = row.kind === 'run_end' && row.event.status === 'failed'
|
|
249
|
-
div.className = 'row' + (row.kind === 'error' || failed_run ? ' err' : '')
|
|
250
|
-
const ts = document.createElement('span'); ts.className = 'ts'
|
|
251
|
-
ts.textContent = new Date(row.ts).toLocaleTimeString()
|
|
252
|
-
const kind = document.createElement('span'); kind.className = 'kind'; kind.textContent = row.kind
|
|
253
|
-
const span = document.createElement('span'); span.className = 'span'; span.textContent = row.span_id ?? ''
|
|
254
|
-
const payload = document.createElement('span'); payload.className = 'payload'
|
|
255
|
-
payload.textContent = row.preview
|
|
256
|
-
div.appendChild(ts); div.appendChild(kind); div.appendChild(span); div.appendChild(payload)
|
|
257
|
-
div.addEventListener('click', () => {
|
|
258
|
-
const open = div.nextSibling
|
|
259
|
-
if (open && open.tagName === 'DETAILS') { open.remove(); return }
|
|
260
|
-
const det = document.createElement('details')
|
|
261
|
-
det.open = true
|
|
262
|
-
const pre = document.createElement('pre')
|
|
263
|
-
pre.textContent = JSON.stringify(row.event, null, 2)
|
|
264
|
-
det.appendChild(pre)
|
|
265
|
-
div.after(det)
|
|
266
|
-
})
|
|
267
|
-
$log.appendChild(div)
|
|
268
|
-
}
|
|
269
|
-
let cost_total
|
|
270
|
-
if (active_run) {
|
|
271
|
-
cost_total = cost_by_run.get(active_run) ?? 0
|
|
272
|
-
} else {
|
|
273
|
-
cost_total = unattributed_cost
|
|
274
|
-
for (const v of cost_by_run.values()) cost_total += v
|
|
275
|
-
}
|
|
276
|
-
const cost_label = cost_total > 0 ? ' · ' + format_cost(cost_total) : ''
|
|
277
|
-
$counts.textContent = total + ' events · ' + errors + ' errors' + cost_label
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
function preview(event) {
|
|
281
|
-
const { kind, span_id, run_id, parent_span_id, name, ...rest } = event
|
|
282
|
-
const txt = JSON.stringify(rest)
|
|
283
|
-
return txt.length > 100 ? txt.slice(0, 100) + '…' : txt
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
function ingest(event) {
|
|
287
|
-
total++
|
|
288
|
-
ensure_run(event.run_id)
|
|
289
|
-
const ts = Date.now()
|
|
290
|
-
if (event.kind === 'span_start') {
|
|
291
|
-
const span = {
|
|
292
|
-
span_id: event.span_id,
|
|
293
|
-
label: event.id ?? event.name,
|
|
294
|
-
kind: event.name,
|
|
295
|
-
run_id: event.run_id,
|
|
296
|
-
parent_span_id: event.parent_span_id,
|
|
297
|
-
state: 'running',
|
|
298
|
-
children: [],
|
|
299
|
-
started_at: ts,
|
|
300
|
-
ended_at: null,
|
|
301
|
-
flash_until: 0,
|
|
302
|
-
cost_self: 0,
|
|
303
|
-
}
|
|
304
|
-
spans.set(event.span_id, span)
|
|
305
|
-
if (event.parent_span_id && spans.has(event.parent_span_id)) {
|
|
306
|
-
spans.get(event.parent_span_id).children.push(event.span_id)
|
|
307
|
-
} else {
|
|
308
|
-
roots.push(event.span_id)
|
|
309
|
-
}
|
|
310
|
-
const stack_key = event.run_id ?? ''
|
|
311
|
-
if (!open_stacks.has(stack_key)) open_stacks.set(stack_key, [])
|
|
312
|
-
open_stacks.get(stack_key).push(event.span_id)
|
|
313
|
-
} else if (event.kind === 'span_end') {
|
|
314
|
-
const span = spans.get(event.span_id)
|
|
315
|
-
if (span) {
|
|
316
|
-
span.ended_at = ts
|
|
317
|
-
const has_error = event.error !== undefined
|
|
318
|
-
span.state = has_error ? 'errored' : 'done'
|
|
319
|
-
if (has_error) errors++
|
|
320
|
-
}
|
|
321
|
-
const stack_key = event.run_id ?? ''
|
|
322
|
-
const stack = open_stacks.get(stack_key)
|
|
323
|
-
if (stack) {
|
|
324
|
-
const idx = stack.lastIndexOf(event.span_id)
|
|
325
|
-
if (idx !== -1) stack.splice(idx, 1)
|
|
326
|
-
}
|
|
327
|
-
} else if (event.kind === 'cost') {
|
|
328
|
-
const usd = typeof event.total_usd === 'number' ? event.total_usd : 0
|
|
329
|
-
const run_key = event.run_id ?? ''
|
|
330
|
-
cost_by_run.set(run_key, (cost_by_run.get(run_key) ?? 0) + usd)
|
|
331
|
-
const stack = open_stacks.get(run_key)
|
|
332
|
-
const target_id = stack && stack.length > 0 ? stack[stack.length - 1] : null
|
|
333
|
-
const target = target_id ? spans.get(target_id) : null
|
|
334
|
-
if (target) target.cost_self += usd
|
|
335
|
-
else unattributed_cost += usd
|
|
336
|
-
} else if (event.kind === 'emit') {
|
|
337
|
-
const span = spans.get(event.span_id)
|
|
338
|
-
if (span) span.flash_until = ts + 200
|
|
339
|
-
} else if (event.kind === 'error') {
|
|
340
|
-
errors++
|
|
341
|
-
const span = spans.get(event.span_id)
|
|
342
|
-
if (span) span.state = 'errored'
|
|
343
|
-
} else if (event.kind === 'suspend') {
|
|
344
|
-
const span = spans.get(event.span_id)
|
|
345
|
-
if (span) span.state = 'suspended'
|
|
346
|
-
}
|
|
347
|
-
log_rows.push({
|
|
348
|
-
ts,
|
|
349
|
-
kind: event.kind,
|
|
350
|
-
span_id: event.span_id,
|
|
351
|
-
run_id: event.run_id,
|
|
352
|
-
event,
|
|
353
|
-
preview: preview(event),
|
|
354
|
-
})
|
|
355
|
-
if (log_rows.length > 5000) log_rows.splice(0, log_rows.length - 5000)
|
|
356
|
-
render_tree()
|
|
357
|
-
render_log()
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
function connect() {
|
|
361
|
-
const es = new EventSource('/api/events')
|
|
362
|
-
es.addEventListener('open', () => set_conn('ok', 'live'))
|
|
363
|
-
es.addEventListener('error', () => set_conn('err', 'reconnecting…'))
|
|
364
|
-
es.addEventListener('trajectory', (e) => {
|
|
365
|
-
try { ingest(JSON.parse(e.data)) } catch {}
|
|
366
|
-
})
|
|
367
|
-
es.addEventListener('close', () => { es.close(); set_conn('err', 'closed') })
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
connect()
|
|
371
|
-
setInterval(render_tree, 250)
|
|
372
|
-
})()
|
|
373
|
-
</script>
|
|
374
|
-
</body>
|
|
375
|
-
</html>
|