my-durable 0.0.121 → 0.0.122

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.
@@ -518,20 +518,23 @@ export class App {
518
518
  // stale rows through an outage, and sessions born while the hub was down
519
519
  // only appeared after a manual switch. Refresh once per live transition;
520
520
  // the in-flight guard collapses concurrent hellos into one /tree.
521
+ // run-15 u3-8: the /device re-fetch (R5 finding 5) rides the SAME
522
+ // single-flight guard — it used to fire per live transition, so a
523
+ // flapping hub stampeded /tree AND /device in lockstep.
521
524
  if (!this.muxSessionsBusy) {
522
525
  this.muxSessionsBusy = true;
523
- void this.refreshSessions().finally(() => (this.muxSessionsBusy = false));
526
+ void this.refreshSessions()
527
+ // …and re-fetch the device info (R5 finding 5): the model catalog rode
528
+ // the boot-time /device fetch, so after a reconnect the cached catalog
529
+ // could miss the session's model and the ctx bar died ("ctx —").
530
+ .then(() => this.client.device({ timeoutMs: 10_000 }))
531
+ .then((info) => {
532
+ this.info = info;
533
+ this.requestRender();
534
+ })
535
+ .catch(() => {})
536
+ .finally(() => (this.muxSessionsBusy = false));
524
537
  }
525
- // …and re-fetch the device info (R5 finding 5): the model catalog rode
526
- // the boot-time /device fetch, so after a reconnect the cached catalog
527
- // could miss the session's model and the ctx bar died ("ctx —").
528
- void this.client
529
- .device({ timeoutMs: 10_000 })
530
- .then((info) => {
531
- this.info = info;
532
- this.requestRender();
533
- })
534
- .catch(() => {});
535
538
  }
536
539
  this.requestRender();
537
540
  }
@@ -1497,7 +1500,11 @@ export class App {
1497
1500
  if (this.tab === "state") {
1498
1501
  const u = sumUsage(s.usage);
1499
1502
  const state = {
1500
- device: this.device.id,
1503
+ // run-15 u3-5: the device id is registry/hub-supplied and rides the
1504
+ // JSON.stringify below RAW — the C1 range (OSC/CSI 8-bit) survives both
1505
+ // stringify and the muted() paint, so oneLine at the data boundary like
1506
+ // every other chrome row (R20 cold-1 M4 discipline).
1507
+ device: oneLine(this.device.id),
1501
1508
  session: this.sessionId,
1502
1509
  agent: this.agentId,
1503
1510
  connection: this.connection,
@@ -445,25 +445,35 @@ export async function runCommand(app: App, text: string): Promise<boolean> {
445
445
  if (!arg) return app.flash("usage: /find <text> — searches every session's transcript", true), true;
446
446
  await app.run(async () => {
447
447
  const result = await app.client.searchSessions(arg, "all");
448
- const shown = result.matches.slice(0, 12);
448
+ // run-15 u3-3 (MED): the search response is a JSON.parse cast — a
449
+ // missing/non-array `matches` threw in .slice()/.length and a missing
450
+ // `where` threw in the Panel body (which re-runs EVERY render, so the
451
+ // crash looped the whole TUI). Normalize once HERE; the closure below
452
+ // reads only the coerced list. Sanitize/hit-slicing discipline (R18/R19/R20)
453
+ // is unchanged.
454
+ const matches = Array.isArray(result?.matches) ? result.matches : [];
455
+ const shown = matches.slice(0, 12);
449
456
  app.overlay(
450
457
  new Panel(() => {
451
458
  const lines = [
452
- c.bold(c.accent(`"${sanitizeTerminal(arg)}" — ${sanitizeTerminal(String(result.matches.length))} session${result.matches.length === 1 ? "" : "s"}`)),
459
+ c.bold(c.accent(`"${sanitizeTerminal(arg)}" — ${sanitizeTerminal(String(matches.length))} session${matches.length === 1 ? "" : "s"}`)),
453
460
  "",
454
461
  ];
455
- if (!result.matches.length) lines.push(c.muted("No matches (names, folders, models or transcripts)."));
462
+ if (!matches.length) lines.push(c.muted("No matches (names, folders, models or transcripts)."));
456
463
  for (const m of shown) {
457
464
  lines.push(
458
465
  // R20 h5: the match header is in the SAME panel as the fixed hit
459
466
  // lines — a \n in a session name split the row above the hits.
460
- `${c.secondary(oneLine(m.name))} ${c.muted(oneLine(m.cwd))}${m.where.includes("transcript") ? " " + c.warn("◍ transcript") : ""}`,
467
+ // run-15 u3-3: `where` is wire-borne too — guard the membership
468
+ // test so a missing/hostile value renders no marker instead of
469
+ // throwing (String() keeps array membership semantics).
470
+ `${c.secondary(oneLine(m.name))} ${c.muted(oneLine(m.cwd))}${String(m.where ?? "").includes("transcript") ? " " + c.warn("◍ transcript") : ""}`,
461
471
  );
462
472
  for (const hit of (m.hits ?? []).slice(0, 3))
463
473
  lines.push(c.muted(findHitLine(m.name, hit)));
464
474
  }
465
- if (result.matches.length > shown.length) lines.push(c.muted(`… ${sanitizeTerminal(String(result.matches.length - shown.length))} more`));
466
- if (result.scanned?.truncated)
475
+ if (matches.length > shown.length) lines.push(c.muted(`… ${sanitizeTerminal(String(matches.length - shown.length))} more`));
476
+ if (result?.scanned?.truncated)
467
477
  lines.push(c.muted(`scan budget reached (${sanitizeTerminal(String(result.scanned.entries))} entries) — refine the query`));
468
478
  lines.push("", c.muted("esc close"));
469
479
  return lines;
@@ -160,7 +160,11 @@ export function pairingViewLines(
160
160
  lines.push(c.muted(oneLine(`device: ${status.deviceName ?? status.deviceUid ?? "?"} · uid ${status.deviceUid ?? "?"}`)));
161
161
  lines.push("");
162
162
  lines.push(c.bold("key fingerprint (compare with the hub wizard):"));
163
- for (const line of wrapFingerprint(status.fingerprint, width)) lines.push(` ${c.secondary(oneLine(line))}`);
163
+ // run-15 u3-7: fingerprint is typed string by convention only — a hostile
164
+ // pairing status rode a non-string straight into the fingerprint block. A
165
+ // non-string renders NO chunk rows instead of leaking the raw value.
166
+ const fpRows = typeof status.fingerprint === "string" ? wrapFingerprint(status.fingerprint, width) : [];
167
+ for (const line of fpRows) lines.push(` ${c.secondary(oneLine(line))}`);
164
168
  lines.push("");
165
169
  if (status.pending) {
166
170
  lines.push(c.warn("Awaiting approval on the hub…"));
@@ -591,11 +591,16 @@ const fmtClock = (ms: number) => {
591
591
  };
592
592
 
593
593
  /** The trigger half of a schedule row: "every 30m" or "daily 09:30".
594
- * dailyAt is device-authored — oneLine at this compose boundary (r12
595
- * review m1: LF here would split the picker row). */
594
+ * Both halves are device-authored — oneLine at this compose boundary (r12
595
+ * review m1: LF here would split the picker row). run-15 u3-1 (HIGH): the
596
+ * everyMinutes half used to ride the row RAW while dailyAt was oneLine'd one
597
+ * line below — the field is typed number by convention only, and a hostile
598
+ * device rode a string OSC payload (␛]0;pwned␇) straight into the terminal.
599
+ * Number-coerce exactly like renderOps' SCHEDULES row: a hostile string
600
+ * degrades to `every ?m`, never to an escape sequence. */
596
601
  const triggerOf = (s: Pick<ScheduleView, "everyMinutes" | "dailyAt">) =>
597
602
  s.everyMinutes != null
598
- ? `every ${s.everyMinutes}m`
603
+ ? `every ${Number(s.everyMinutes) || "?"}m`
599
604
  : s.dailyAt
600
605
  ? `daily ${oneLine(s.dailyAt)}`
601
606
  : "no trigger";
@@ -492,10 +492,17 @@ export function renderOps(
492
492
 
493
493
  section("VITALS", "vitals", () => {
494
494
  const v = data.vitals!;
495
+ // run-15 u3-2 (MED): vitals ride the wire as a JSON.parse cast — typed
496
+ // only by convention, so EVERY shape deref degrades instead of throwing
497
+ // (the section builder runs on every frame; one bad payload used to kill
498
+ // the whole ops view). loadavg via Array.isArray; memory/disk via ?.
499
+ // (humanBytes/uptimeOf already Number-coerce their inputs, eventLoop and
500
+ // gitSpawns were already optional-chained).
501
+ const load = Array.isArray(v.loadavg) ? v.loadavg : [];
495
502
  const out = [
496
- ` ${c.muted("up")} ${c.text(uptimeOf(v.uptime))} ${c.muted("proc")} ${c.text(uptimeOf(v.processUptime))} ${c.muted("load")} ${c.text(v.loadavg.map((n) => (Number(n) || 0).toFixed(2)).join(" "))} ${c.muted(`×${Number(v.cpuCount) || 0}`)}`,
497
- ` ${c.muted("mem")} ${c.text(`${humanBytes(v.memory.usedBytes)}/${humanBytes(v.memory.totalBytes)}`)} ${c.muted("free")} ${c.text(humanBytes(v.memory.freeBytes))} ${c.muted("rss")} ${c.text(humanBytes(v.memory.processRssBytes))} ${c.muted("heap")} ${c.text(humanBytes(v.memory.heapUsedBytes))}`,
498
- ` ${c.muted("disk")} ${v.disk.known ? `${c.text(`${humanBytes(v.disk.freeBytes)}/${humanBytes(v.disk.totalBytes)}`)} ${c.muted("free")} ${c.muted(oneLine(String(v.disk.path ?? "")))}` : c.muted("unknown")}`,
503
+ ` ${c.muted("up")} ${c.text(uptimeOf(v.uptime))} ${c.muted("proc")} ${c.text(uptimeOf(v.processUptime))} ${c.muted("load")} ${c.text(load.map((n) => (Number(n) || 0).toFixed(2)).join(" ") || c.muted("—"))} ${c.muted(`×${Number(v.cpuCount) || 0}`)}`,
504
+ ` ${c.muted("mem")} ${c.text(`${humanBytes(v.memory?.usedBytes)}/${humanBytes(v.memory?.totalBytes)}`)} ${c.muted("free")} ${c.text(humanBytes(v.memory?.freeBytes))} ${c.muted("rss")} ${c.text(humanBytes(v.memory?.processRssBytes))} ${c.muted("heap")} ${c.text(humanBytes(v.memory?.heapUsedBytes))}`,
505
+ ` ${c.muted("disk")} ${v.disk?.known ? `${c.text(`${humanBytes(v.disk?.freeBytes)}/${humanBytes(v.disk?.totalBytes)}`)} ${c.muted("free")} ${c.muted(oneLine(String(v.disk?.path ?? "")))}` : c.muted("unknown")}`,
499
506
  // run-12 phase 1 typed these into the SDK: event-loop lag is the stall
500
507
  // loadavg cannot express, and gitSpawns' queued(+high) is the number
501
508
  // that says "a status fan-out is stalling the panel" (run-11 h2-2).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "my-durable",
3
- "version": "0.0.121",
3
+ "version": "0.0.122",
4
4
  "description": "Durable Pi — the durable agent network: hub web UI, device backend daemon, TUI admin and the shared SDK, packaged as one runnable monorepo install",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -29,7 +29,7 @@
29
29
  "@earendil-works/pi-durable": "1.3.0",
30
30
  "@earendil-works/pi-tui": "1.3.0",
31
31
  "@sinclair/typebox": "0.34.52",
32
- "dompurify": "^3.2.0",
32
+ "dompurify": "^3.4.17",
33
33
  "express": "^5.1.0",
34
34
  "lucide-vue-next": "^0.468.0",
35
35
  "marked": "^17.0.0",