@warlock.js/ai-panoptic 5.53.1 → 5.55.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/CHANGELOG.md CHANGED
@@ -4,6 +4,12 @@ All notable changes to `@warlock.js/ai-panoptic` are documented in this file.
4
4
 
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). `@warlock.js/*` packages are released in lockstep — every package shares the same version number, so a version below may list only the changes that affected this package.
6
6
 
7
+ ## 5.54.0 - 2026-11-16
8
+
9
+ ### Added
10
+
11
+ - `GET api/traces` in the local dashboard sends an `ETag` and answers `304` without a body when `If-None-Match` matches; the dashboard page sends the tag on each poll, so an idle dashboard transfers almost nothing.
12
+
7
13
  ## 5.53.0 - 2026-11-11
8
14
 
9
15
  ### Upgrading
package/cjs/index.cjs CHANGED
@@ -3854,13 +3854,19 @@ function dashboardHtml(basePath, title, evaluateEnabled = false, evaluateDefault
3854
3854
  try { savedTheme = localStorage.getItem(THEME_KEY) || "system"; } catch (e) {}
3855
3855
  applyTheme(savedTheme);
3856
3856
 
3857
+ var listEtag = null;
3857
3858
  function poll() {
3858
3859
  Promise.all([
3859
3860
  fetchAuthed(API + "/aggregate").then(function (r) { return r.json(); }),
3860
- fetchAuthed(API + "/traces").then(function (r) { return r.json(); })
3861
+ // Conditional poll: send the last ETag; a 304 means the list is unchanged.
3862
+ fetchAuthed(API + "/traces", listEtag ? { headers: { "If-None-Match": listEtag } } : undefined).then(function (r) {
3863
+ if (r.status === 304) return null;
3864
+ listEtag = r.headers.get("ETag") || null;
3865
+ return r.json();
3866
+ })
3861
3867
  ]).then(function (res) {
3862
3868
  renderStats(res[0]);
3863
- state.traces = res[1] || [];
3869
+ if (res[1] !== null) state.traces = res[1] || [];
3864
3870
  document.getElementById("meta").textContent = state.traces.length + " trace(s) · live";
3865
3871
  renderChips();
3866
3872
  renderList();
@@ -3977,7 +3983,10 @@ function isAuthorized(req, url, token, allowQueryToken) {
3977
3983
  *
3978
3984
  * - `GET api/traces` → the newest `?limit=` (default 200) matches of
3979
3985
  * `store.query(parseQuery(searchParams))`, as {@link TraceSummary}
3980
- * entries (no span tree or captured content); `?full=1` returns full traces
3986
+ * entries (no span tree or captured content); `?full=1` returns full traces.
3987
+ * The response carries an `ETag`; a request whose `If-None-Match` matches it
3988
+ * answers `304` without a body, so the dashboard's poll costs nothing while
3989
+ * nothing changed
3981
3990
  * - `GET api/traces/:id` → `store.get(id)` or `404` (`400` for a malformed id)
3982
3991
  * - `GET api/aggregate` → `store.aggregate(parseQuery(searchParams))`
3983
3992
  * - `GET {basePath}` → the self-contained HTML page
@@ -4040,7 +4049,7 @@ function createRequestHandler(store, config) {
4040
4049
  if (pathname === `${apiPrefix}/traces`) {
4041
4050
  const { limit, full } = parseListOptions(url.searchParams);
4042
4051
  const traces = store.query(parseQuery(url.searchParams)).slice(0, limit);
4043
- sendJson(res, 200, full ? traces : traces.map(toTraceSummary));
4052
+ sendJsonWithEtag(req, res, full ? traces : traces.map(toTraceSummary));
4044
4053
  return;
4045
4054
  }
4046
4055
  if (pathname.startsWith(`${apiPrefix}/traces/`)) {
@@ -4103,6 +4112,32 @@ function sendJson(res, status, body) {
4103
4112
  res.end(JSON.stringify(body));
4104
4113
  }
4105
4114
  /**
4115
+ * Write a JSON response with a weak `ETag` over its body. A request whose
4116
+ * `If-None-Match` lists that tag gets `304` with no body.
4117
+ */
4118
+ function sendJsonWithEtag(req, res, body) {
4119
+ const json = JSON.stringify(body);
4120
+ const etag = `W/"${(0, node_crypto.createHash)("sha1").update(json).digest("base64url")}"`;
4121
+ const header = req.headers["if-none-match"];
4122
+ const candidates = (Array.isArray(header) ? header.join(",") : header ?? "").split(",").map((value) => value.trim().replace(/^W\//, ""));
4123
+ if (candidates.includes("*") || candidates.includes(etag.slice(2))) {
4124
+ res.writeHead(304, {
4125
+ etag,
4126
+ "cache-control": "no-cache",
4127
+ ...SECURITY_HEADERS
4128
+ });
4129
+ res.end();
4130
+ return;
4131
+ }
4132
+ res.writeHead(200, {
4133
+ "content-type": "application/json; charset=utf-8",
4134
+ etag,
4135
+ "cache-control": "no-cache",
4136
+ ...SECURITY_HEADERS
4137
+ });
4138
+ res.end(json);
4139
+ }
4140
+ /**
4106
4141
  * Match `{apiPrefix}/traces/:traceId/spans/:spanId/evaluate` — the one
4107
4142
  * write route. Returns `undefined` for anything else, including the plain
4108
4143
  * `{apiPrefix}/traces/:id` read route (no `/spans/.../evaluate` suffix),