@warlock.js/ai-panoptic 5.52.0 → 5.53.1

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.
Files changed (34) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/cjs/index.cjs +592 -424
  3. package/cjs/index.cjs.map +1 -1
  4. package/esm/config/apply-panoptic-config.d.mts.map +1 -1
  5. package/esm/config/apply-panoptic-config.mjs +9 -3
  6. package/esm/config/apply-panoptic-config.mjs.map +1 -1
  7. package/esm/config/panoptic-config.type.d.mts +7 -0
  8. package/esm/config/panoptic-config.type.d.mts.map +1 -1
  9. package/esm/dashboard/index.d.mts +1 -0
  10. package/esm/dashboard/index.mjs +1 -1
  11. package/esm/dashboard/parse-query.mjs +23 -1
  12. package/esm/dashboard/parse-query.mjs.map +1 -1
  13. package/esm/dashboard/serve.mjs +55 -10
  14. package/esm/dashboard/serve.mjs.map +1 -1
  15. package/esm/dashboard/trace-summary.d.mts +24 -0
  16. package/esm/dashboard/trace-summary.d.mts.map +1 -0
  17. package/esm/dashboard/trace-summary.mjs +27 -0
  18. package/esm/dashboard/trace-summary.mjs.map +1 -0
  19. package/esm/dashboard/ui.html.mjs +68 -18
  20. package/esm/dashboard/ui.html.mjs.map +1 -1
  21. package/esm/index.d.mts +2 -1
  22. package/esm/index.mjs +1 -1
  23. package/esm/store/cache-trace-store.d.mts.map +1 -1
  24. package/esm/store/cache-trace-store.mjs +37 -17
  25. package/esm/store/cache-trace-store.mjs.map +1 -1
  26. package/esm/store/in-memory-trace-store.d.mts.map +1 -1
  27. package/esm/store/in-memory-trace-store.mjs +2 -9
  28. package/esm/store/in-memory-trace-store.mjs.map +1 -1
  29. package/esm/store/sort-newest-first.mjs +14 -0
  30. package/esm/store/sort-newest-first.mjs.map +1 -0
  31. package/llms-full.txt +9 -9
  32. package/llms.txt +1 -1
  33. package/package.json +4 -4
  34. package/skills/use-local-dashboard/SKILL.md +9 -9
@@ -22,6 +22,10 @@ import { WARLOCK_LOGO_DATA_URI } from "./warlock-logo.mjs";
22
22
  * state — selected trace, selected span, collapsed nodes — lives in JS,
23
23
  * NOT the DOM, so the 2s poll never disturbs an open drawer.
24
24
  *
25
+ * The 2s poll reads the newest trace summaries (`api/traces`: no span
26
+ * tree, no captured content); opening a trace fetches its full tree from
27
+ * `api/traces/:id` and re-fetches it only when its summary changes.
28
+ *
25
29
  * The list is filterable entirely client-side over the polled traces: a
26
30
  * free-text search (name + session), status / type / session filter
27
31
  * chips, an "errors only" header toggle, and an optional group-by-session
@@ -322,6 +326,8 @@ function dashboardHtml(basePath, title, evaluateEnabled = false, evaluateDefault
322
326
 
323
327
  var state = {
324
328
  traces: [], selectedId: null, selectedSpanId: null, collapsed: {}, sig: null,
329
+ detail: null, // full trace of the open drawer (GET /traces/:id)
330
+ loadingId: null, // trace id whose full tree is being fetched
325
331
  // Client-side filter state (search box + chips + errors-only header toggle).
326
332
  filter: { text: "", statuses: {}, types: {}, sessionId: null, promptKey: null, errorsOnly: false },
327
333
  groupBySession: false, // session-grouping list toggle
@@ -427,7 +433,11 @@ function dashboardHtml(basePath, title, evaluateEnabled = false, evaluateDefault
427
433
  for (var i = 0; i < k.length; i++) n += countSpans(k[i]);
428
434
  return n;
429
435
  }
430
- function traceSig(t) { return t.root.status + "|" + countSpans(t.root) + "|" + t.duration + "|" + (t.usage && t.usage.total); }
436
+ // Works on a list summary (spanCount) and on a full trace (counted).
437
+ function traceSig(t) {
438
+ var spans = t.spanCount != null ? t.spanCount : countSpans(t.root);
439
+ return t.root.status + "|" + spans + "|" + t.duration + "|" + (t.usage && t.usage.total);
440
+ }
431
441
  // Sum every priced lane of a cost object into one USD number.
432
442
  function costSumObj(c) {
433
443
  if (!c) return 0;
@@ -447,6 +457,7 @@ function dashboardHtml(basePath, title, evaluateEnabled = false, evaluateDefault
447
457
  return sum;
448
458
  }
449
459
  function traceCost(t) {
460
+ if (typeof t.totalCost === "number") return t.totalCost; // list summary: computed server-side
450
461
  var explicit = costSumObj(t.cost);
451
462
  return explicit > 0 ? explicit : rollupCost(t.root);
452
463
  }
@@ -1106,8 +1117,12 @@ function dashboardHtml(basePath, title, evaluateEnabled = false, evaluateDefault
1106
1117
  + (st.result ? evalResultHtml(st.result) : "")
1107
1118
  + "</div>";
1108
1119
  }
1120
+ // The full trace of the open drawer, once it has loaded.
1121
+ function openDetail() {
1122
+ return state.detail && state.detail.traceId === state.selectedId ? state.detail : null;
1123
+ }
1109
1124
  function rerenderDetail() {
1110
- var t = findTrace(state.selectedId);
1125
+ var t = openDetail();
1111
1126
  if (!t) return;
1112
1127
  var sel = findSpan(t.root, state.selectedSpanId) || t.root;
1113
1128
  document.getElementById("drawer-detail").innerHTML = renderDetail(sel, t);
@@ -1199,14 +1214,14 @@ function dashboardHtml(basePath, title, evaluateEnabled = false, evaluateDefault
1199
1214
  // Re-render only the left pane (after a view switch) without disturbing
1200
1215
  // the detail panel or scroll position of the detail side.
1201
1216
  function renderLeftPane() {
1202
- var t = findTrace(state.selectedId);
1217
+ var t = openDetail();
1203
1218
  if (!t) return;
1204
1219
  document.getElementById("drawer-tree").innerHTML = viewSwitcher() + leftPaneHtml(t);
1205
1220
  }
1206
1221
 
1207
1222
  function selectSpan(id) {
1208
1223
  state.selectedSpanId = id;
1209
- var t = findTrace(state.selectedId);
1224
+ var t = openDetail();
1210
1225
  if (!t) return;
1211
1226
  document.getElementById("drawer-detail").innerHTML = renderDetail(findSpan(t.root, id) || t.root, t);
1212
1227
  // Highlight in whichever left pane is active (tree nodes or Gantt rows).
@@ -1219,7 +1234,7 @@ function dashboardHtml(basePath, title, evaluateEnabled = false, evaluateDefault
1219
1234
  }
1220
1235
  function toggleSpan(id) {
1221
1236
  state.collapsed[id] = !state.collapsed[id];
1222
- var t = findTrace(state.selectedId);
1237
+ var t = openDetail();
1223
1238
  if (t) renderLeftPane();
1224
1239
  }
1225
1240
  function setView(v) {
@@ -1228,15 +1243,49 @@ function dashboardHtml(basePath, title, evaluateEnabled = false, evaluateDefault
1228
1243
  renderLeftPane();
1229
1244
  }
1230
1245
 
1246
+ // Drawer placeholder while the full trace loads, or when it cannot.
1247
+ function renderDrawerMessage(text) {
1248
+ document.getElementById("drawer-head").innerHTML =
1249
+ '<button class="drawer-close" type="button" title="Close (Esc)">✕ Close</button>';
1250
+ document.getElementById("drawer-body").innerHTML = '<div class="empty">' + esc(text) + "</div>";
1251
+ }
1252
+ // Fetch the full trace (span tree + captured content) for the drawer.
1253
+ // The list only carries summaries, so the drawer always reads this.
1254
+ function loadDetail(id, spanId) {
1255
+ state.loadingId = id;
1256
+ fetchAuthed(API + "/traces/" + encodeURIComponent(id)).then(function (r) {
1257
+ return r.json().then(function (data) { return { ok: r.ok, status: r.status, data: data }; });
1258
+ }).then(function (res) {
1259
+ if (state.loadingId === id) state.loadingId = null;
1260
+ if (state.selectedId !== id) return;
1261
+ if (!res.ok) {
1262
+ var code = res.data && res.data.error;
1263
+ renderDrawerMessage(res.status === 404
1264
+ ? "This trace is no longer in the store: older traces are dropped once the store reaches its capacity. Close this panel and pick a recent trace."
1265
+ : "Could not load this trace (" + (code || ("HTTP " + res.status)) + "). Close this panel and try again.");
1266
+ return;
1267
+ }
1268
+ var t = res.data;
1269
+ var wanted = spanId || state.selectedSpanId;
1270
+ state.detail = t;
1271
+ state.selectedSpanId = (wanted && findSpan(t.root, wanted)) ? wanted : t.root.spanId;
1272
+ state.sig = traceSig(t);
1273
+ renderDrawer(t);
1274
+ writeHash();
1275
+ }).catch(function () {
1276
+ if (state.loadingId === id) state.loadingId = null;
1277
+ if (state.selectedId !== id) return;
1278
+ renderDrawerMessage("Could not reach the dashboard server to load this trace. Check that the app is still running, then reopen the trace.");
1279
+ });
1280
+ }
1231
1281
  function openTrace(id, spanId) {
1232
1282
  state.selectedId = id;
1233
- var t = findTrace(id);
1234
- if (t) {
1235
- state.selectedSpanId = (spanId && findSpan(t.root, spanId)) ? spanId : t.root.spanId;
1236
- state.collapsed = {};
1237
- renderDrawer(t);
1238
- state.sig = traceSig(t);
1239
- }
1283
+ state.selectedSpanId = spanId || null;
1284
+ state.collapsed = {};
1285
+ state.detail = null;
1286
+ state.sig = null;
1287
+ renderDrawerMessage("Loading trace…");
1288
+ loadDetail(id, spanId);
1240
1289
  document.getElementById("drawer").classList.add("open");
1241
1290
  document.getElementById("drawer").setAttribute("aria-hidden", "false");
1242
1291
  document.getElementById("backdrop").classList.add("open");
@@ -1244,7 +1293,7 @@ function dashboardHtml(basePath, title, evaluateEnabled = false, evaluateDefault
1244
1293
  writeHash();
1245
1294
  }
1246
1295
  function closeDrawer() {
1247
- state.selectedId = null; state.selectedSpanId = null; state.sig = null;
1296
+ state.selectedId = null; state.selectedSpanId = null; state.sig = null; state.detail = null;
1248
1297
  document.getElementById("drawer").classList.remove("open");
1249
1298
  document.getElementById("drawer").setAttribute("aria-hidden", "true");
1250
1299
  document.getElementById("backdrop").classList.remove("open");
@@ -1284,15 +1333,15 @@ function dashboardHtml(basePath, title, evaluateEnabled = false, evaluateDefault
1284
1333
  });
1285
1334
  return out;
1286
1335
  }
1287
- // Open whatever the hash points at, if that trace is loaded. Returns
1288
- // true when it acted so the caller can mark the one-time load as done.
1336
+ // Open whatever the hash points at. The drawer fetches the trace by id,
1337
+ // so a deep link works even when the trace is past the polled list.
1338
+ // Returns true when it acted so the caller can mark the one-time load as done.
1289
1339
  function applyHash() {
1290
1340
  var h = readHash();
1291
1341
  if (!h.trace) {
1292
1342
  if (state.selectedId) closeDrawer();
1293
1343
  return true;
1294
1344
  }
1295
- if (!findTrace(h.trace)) return false; // not polled yet — retry next poll
1296
1345
  openTrace(h.trace, h.span || undefined);
1297
1346
  return true;
1298
1347
  }
@@ -1444,9 +1493,10 @@ function dashboardHtml(basePath, title, evaluateEnabled = false, evaluateDefault
1444
1493
  // has actually arrived in a poll (it may not be in the first batch).
1445
1494
  if (!state.hashApplied) {
1446
1495
  if (applyHash()) state.hashApplied = true;
1447
- } else if (state.selectedId) {
1496
+ } else if (state.selectedId && openDetail() && state.loadingId === null) {
1497
+ // Re-fetch the open trace only when its summary changed.
1448
1498
  var t = findTrace(state.selectedId);
1449
- if (t) { var sig = traceSig(t); if (sig !== state.sig) { renderDrawer(t); state.sig = sig; } }
1499
+ if (t && traceSig(t) !== state.sig) loadDetail(state.selectedId);
1450
1500
  }
1451
1501
  }).catch(function (e) {
1452
1502
  document.getElementById("meta").textContent = "disconnected";