my-durable 0.0.120 → 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.
@@ -12,7 +12,7 @@ import {
12
12
  type SelectItem,
13
13
  } from "@earendil-works/pi-tui";
14
14
  import { THINKING_LEVELS, type ThinkingLevel } from "../../dpi-sdk/src/api.ts";
15
- import type { ArchivedView, DeviceTree, EnvFileView, NotifySinkView, ScheduleView } from "../../dpi-sdk/src/api.ts";
15
+ import type { ArchivedView, DeviceTree, EnvFileView, GraphRecord, GraphRunRecord, NotifySinkView, ScheduleView } from "../../dpi-sdk/src/api.ts";
16
16
  import { agentTree, type TreeNode } from "../../dpi-sdk/src/models.ts";
17
17
  import { fmtBytes, fmtDur } from "./commands.ts";
18
18
  import { oneLine, sanitizeTerminal } from "./sanitize.ts";
@@ -319,28 +319,41 @@ export function pickSession(app: App): Promise<string | undefined> {
319
319
  };
320
320
  }),
321
321
  ];
322
+ // r13 NIT (fixed run-14): a pick* promise used to hang FOREVER when its
323
+ // overlay was dismissed outside the picker's esc path — app-level ctrl+c
324
+ // closes overlays through closeOverlay() (app.ts:1060), which fires the
325
+ // overlay's onClose and never the picker's onCancel. The onClose below
326
+ // settles the same promise. Promise resolution is first-wins, so every
327
+ // pick path must settle BEFORE closeOverlay — otherwise the close's
328
+ // onClose undefined would win over the picked id. Double-resolve is
329
+ // harmless; order is everything.
330
+ const settle = (value: string | undefined) => {
331
+ done(value);
332
+ app.closeOverlay();
333
+ };
322
334
  app.overlay(
323
335
  new Picker(`Sessions on ${oneLine(app.device.id)}`, items, (item) => {
324
- app.closeOverlay();
325
336
  // +New hands the flow to the new-session chain — resolve undefined so
326
337
  // a waiting /export stays quiet instead of flashing "cancelled" over
327
338
  // a flow that is telling its own story.
328
339
  if (item.value === "+new") {
329
- done(undefined);
340
+ settle(undefined);
330
341
  return void newSession(app);
331
342
  }
332
343
  const s = tree.sessions.find((x) => x.id === item.value)!;
333
344
  const root = s.agents.find((a) => a.kind === "root") ?? s.agents[0];
345
+ settle(s.id);
334
346
  void app.attach(s.id, root?.id ?? 1);
335
- done(s.id);
336
347
  }, () => {
337
348
  // Esc must never surprise-quit (0.0.52): with no attached session the
338
349
  // cancel used to pass exitIfNothing=true and picker→Esc→Esc killed the
339
350
  // whole process (R4 finding 1). Landing in the herd/network view is the
340
351
  // honest cancel; quitting stays on q / ctrl+c / /quit.
341
- app.closeOverlay();
342
- done(undefined);
352
+ settle(undefined);
343
353
  }),
354
+ // The external-dismissal door (ctrl+c at app level): see the r13 NIT
355
+ // note above — resolves undefined, never hangs.
356
+ () => done(undefined),
344
357
  );
345
358
  })();
346
359
  });
@@ -398,27 +411,50 @@ export async function newSession(app: App, presetName?: string) {
398
411
  */
399
412
  export function walkDirs(app: App, path: string): Promise<string | undefined | null> {
400
413
  return new Promise((done) => {
414
+ // r13 NIT (fixed run-14): the external-dismissal settle — see pickSession.
415
+ // One wrinkle unique to this flow: stepping DOWN a level legitimately
416
+ // closes this step's overlay to mount the next, and that close must NOT
417
+ // settle the walk (the promise stays pending across steps). The per-step
418
+ // `handoff` mark tells the overlay onClose "a successor owns the keyboard
419
+ // now"; only a dismissal with no successor resolves undefined.
420
+ let settled = false;
421
+ const settle = (v: string | undefined | null) => {
422
+ if (settled) return;
423
+ settled = true;
424
+ done(v);
425
+ };
401
426
  const step = async (at: string) => {
402
427
  // A cold tunnel lists in 2-20s — hold the message line so the silence
403
428
  // never reads as a dead app (R4 finding 8).
404
429
  app.setPending(`listing ${at || "start dirs"} on ${app.device.name}…`);
405
430
  const listing = await app.client.dirs(at).catch((e: Error) => (app.flash(e.message, true), undefined));
406
431
  app.setPending(null);
407
- if (!listing) return done(null);
432
+ if (!listing) return settle(null);
408
433
  const items: SelectItem[] = [
409
434
  ...(listing.path ? [{ value: `use:${listing.path}`, label: `✓ Use ${oneLine(String(listing.path ?? ""))}` }] : []),
410
435
  ...(listing.path ? [{ value: listing.parent ?? "", label: listing.parent ? ".." : "⌂ start dirs" }] : []),
411
436
  ...listing.dirs.map((d) => ({ value: d.path, label: `${oneLine(String(d.name ?? ""))}/` })),
412
437
  ];
438
+ let handoff = false;
413
439
  app.overlay(
414
440
  new Picker(`Working directory on ${oneLine(String(app.device.name ?? ""))}`, items, (item) => {
415
- app.closeOverlay();
416
- if (item.value.startsWith("use:")) done(item.value.slice(4));
417
- else void step(item.value);
441
+ if (item.value.startsWith("use:")) {
442
+ // Settle BEFORE the close: the close fires the overlay onClose,
443
+ // and first-wins resolution must let the PICKED path win.
444
+ settle(item.value.slice(4));
445
+ app.closeOverlay();
446
+ } else {
447
+ handoff = true;
448
+ app.closeOverlay();
449
+ void step(item.value);
450
+ }
418
451
  }, () => {
419
452
  app.closeOverlay();
420
- done(undefined);
453
+ settle(undefined);
421
454
  }),
455
+ () => {
456
+ if (!handoff) settle(undefined);
457
+ },
422
458
  );
423
459
  };
424
460
  void step(path);
@@ -428,17 +464,19 @@ export function walkDirs(app: App, path: string): Promise<string | undefined | n
428
464
  function chooseModel(app: App, current?: string) {
429
465
  return new Promise<(typeof app.info.models)[number] | undefined>((done) => {
430
466
  const models = app.info.models;
467
+ // r13 NIT (fixed run-14): the overlay onClose settles the promise on
468
+ // external dismissal (app-level ctrl+c bypasses the picker's onCancel —
469
+ // see pickSession). Pick paths settle BEFORE closeOverlay so the picked
470
+ // model wins the first-wins resolution.
471
+ const settle = (m: (typeof app.info.models)[number] | undefined) => {
472
+ done(m);
473
+ app.closeOverlay();
474
+ };
431
475
  const picker = new Picker(
432
476
  `Model (${oneLine(String(app.device.name ?? ""))})`,
433
477
  models.map((m) => ({ value: `${m.provider}/${m.id}`, label: oneLine(String(m.name ?? "")), description: `${oneLine(String(m.tier ?? ""))} │ ${oneLine(String(m.provider ?? ""))}` })),
434
- (item) => {
435
- app.closeOverlay();
436
- done(models.find((m) => `${m.provider}/${m.id}` === item.value));
437
- },
438
- () => {
439
- app.closeOverlay();
440
- done(undefined);
441
- },
478
+ (item) => settle(models.find((m) => `${m.provider}/${m.id}` === item.value)),
479
+ () => settle(undefined),
442
480
  undefined,
443
481
  // The keyless device still lists the built-in catalog — say why chat
444
482
  // will fail, instead of letting the first request be the messenger.
@@ -448,7 +486,7 @@ function chooseModel(app: App, current?: string) {
448
486
  );
449
487
  const index = models.findIndex((m) => m.id === current);
450
488
  if (index >= 0) picker.list.setSelectedIndex(index);
451
- app.overlay(picker);
489
+ app.overlay(picker, () => done(undefined));
452
490
  });
453
491
  }
454
492
 
@@ -459,22 +497,23 @@ function chooseModel(app: App, current?: string) {
459
497
  */
460
498
  export function pickThinking(app: App, current?: string) {
461
499
  return new Promise<ThinkingLevel | undefined>((done) => {
500
+ // r13 NIT (fixed run-14): same settle-before-close wiring as pickSession —
501
+ // an externally dismissed overlay (ctrl+c at app level) resolves undefined
502
+ // instead of hanging the /thinking chain.
503
+ const settle = (level: ThinkingLevel | undefined) => {
504
+ done(level);
505
+ app.closeOverlay();
506
+ };
462
507
  const picker = new Picker(
463
508
  "Thinking level",
464
509
  THINKING_LEVELS.map((level) => ({ value: level, label: level })),
465
- (item) => {
466
- app.closeOverlay();
467
- done(item.value as ThinkingLevel);
468
- },
469
- () => {
470
- app.closeOverlay();
471
- done(undefined);
472
- },
510
+ (item) => settle(item.value as ThinkingLevel),
511
+ () => settle(undefined),
473
512
  );
474
513
  const wanted = current && THINKING_LEVELS.includes(current as ThinkingLevel) ? current : "medium";
475
514
  const index = THINKING_LEVELS.indexOf(wanted as ThinkingLevel);
476
515
  if (index >= 0) picker.list.setSelectedIndex(index);
477
- app.overlay(picker);
516
+ app.overlay(picker, () => done(undefined));
478
517
  });
479
518
  }
480
519
 
@@ -552,11 +591,16 @@ const fmtClock = (ms: number) => {
552
591
  };
553
592
 
554
593
  /** The trigger half of a schedule row: "every 30m" or "daily 09:30".
555
- * dailyAt is device-authored — oneLine at this compose boundary (r12
556
- * 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. */
557
601
  const triggerOf = (s: Pick<ScheduleView, "everyMinutes" | "dailyAt">) =>
558
602
  s.everyMinutes != null
559
- ? `every ${s.everyMinutes}m`
603
+ ? `every ${Number(s.everyMinutes) || "?"}m`
560
604
  : s.dailyAt
561
605
  ? `daily ${oneLine(s.dailyAt)}`
562
606
  : "no trigger";
@@ -869,21 +913,29 @@ export async function pickNotify(app: App) {
869
913
  const TRANSCRIPT_MAX_LINES = 400;
870
914
  const TRANSCRIPT_MAX_BYTES = 100 * 1024;
871
915
 
872
- export function capTranscriptLines(text: string): string[] {
916
+ export function capTranscriptLines(
917
+ text: string,
918
+ opts?: { maxLines?: number; maxBytes?: number },
919
+ ): string[] {
920
+ // run-14: :graphs detail rides the same helper with a tighter line budget;
921
+ // the defaults keep the r13 :archive contract byte-for-byte (the r13 tests
922
+ // pin the marker format AND both caps — do not shift them silently).
923
+ const maxLines = opts?.maxLines ?? TRANSCRIPT_MAX_LINES;
924
+ const maxBytes = opts?.maxBytes ?? TRANSCRIPT_MAX_BYTES;
873
925
  const raw = String(text ?? "");
874
926
  let cut = false;
875
927
  let body = raw;
876
- if (Buffer.byteLength(body, "utf8") > TRANSCRIPT_MAX_BYTES) {
928
+ if (Buffer.byteLength(body, "utf8") > maxBytes) {
877
929
  // Byte-boundary cut on the UTF-8 encoding (a char-count slice could leave
878
930
  // up to 4× the budget for multibyte text); toString drops any dangling
879
931
  // multibyte fragment as U+FFFD.
880
932
  cut = true;
881
- body = Buffer.from(body, "utf8").subarray(0, TRANSCRIPT_MAX_BYTES).toString("utf8");
933
+ body = Buffer.from(body, "utf8").subarray(0, maxBytes).toString("utf8");
882
934
  }
883
935
  const total = raw.split("\n").length;
884
936
  const all = body.split("\n");
885
- const lines = all.slice(0, TRANSCRIPT_MAX_LINES);
886
- if (all.length > TRANSCRIPT_MAX_LINES) cut = true;
937
+ const lines = all.slice(0, maxLines);
938
+ if (all.length > maxLines) cut = true;
887
939
  const out = lines.map((l) => sanitizeTerminal(l));
888
940
  if (cut) {
889
941
  // The count names the lines the operator will not see (a byte cut can hide
@@ -968,3 +1020,170 @@ export async function pickArchived(app: App) {
968
1020
  ),
969
1021
  );
970
1022
  }
1023
+
1024
+ // ---------------------------------------------- run-14: :graphs
1025
+ // The last uncovered SDK surface (client.graphs/graph/runGraph/removeGraph).
1026
+ // The palette is a keyboard, not a DAG editor: NO create/update door — the
1027
+ // web FE owns graph authoring (run-14 Unit A scope). The TUI lists, dumps
1028
+ // detail, fires a run and removes behind the same y/n gate the other
1029
+ // destructive doors use. Every device-authored field (graph name, cwd, task
1030
+ // names/ids/deps, run ids/status) goes through oneLine INCLUDING the label
1031
+ // path — pi-tui never LF-normalizes labels (the r12 m1 lesson, pinned by
1032
+ // test in tui-graphs-r14.test.ts).
1033
+
1034
+ /** Detail cap (run-14): the :archive convention — the dump adds at most this
1035
+ * many body lines to the 500-entry log ring, plus the LEADING truncation
1036
+ * marker when it cut (same counting :archive's 400 uses). */
1037
+ const GRAPH_DETAIL_MAX_LINES = 200;
1038
+
1039
+ /** Runs the detail view shows — the newest 10; older ones stay on the device
1040
+ * (a 100-run graph would flood the log ring for no reading value). */
1041
+ const GRAPH_DETAIL_MAX_RUNS = 10;
1042
+
1043
+ /** lastRun glyph for the row label — the status IS the vocabulary:
1044
+ * ✓ ok · ✗ failed · ● running · ⏸ interrupted · ◇ never ran. */
1045
+ const graphRunGlyph = (status: string) =>
1046
+ status === "ok" ? "✓" : status === "failed" ? "✗" : status === "running" ? "●" : status === "interrupted" ? "⏸" : "◇";
1047
+
1048
+ /** The lastRun half of a row: "ok 1m ago" / "never run". Age is measured
1049
+ * from finishedAt when the run closed, else startedAt (a running graph has
1050
+ * no finish yet); a garbage timestamp degrades to no age, never a NaN row. */
1051
+ const graphRunState = (run: GraphRunRecord | undefined, now: number): string => {
1052
+ if (!run) return "never run";
1053
+ const t = Date.parse(String(run.finishedAt ?? run.startedAt ?? ""));
1054
+ const age = Number.isFinite(t) && t > 0 ? ` ${fmtDur(Math.max(0, (now - t) / 1000))} ago` : "";
1055
+ return `${oneLine(String(run.status ?? "?"))}${age}`;
1056
+ };
1057
+
1058
+ /**
1059
+ * The :graphs detail dump — pure for tests (now is injectable). Graph meta,
1060
+ * one line per task (id · name · deps · model), then the last ≤10 runs with
1061
+ * per-run ok/total counts. Every field is device-authored: logEvent writes
1062
+ * verbatim, so a task name must never split its own log line (r12 m1). The
1063
+ * caller caps the joined text through capTranscriptLines.
1064
+ */
1065
+ export function graphDetailLines(graph: GraphRecord, runs: GraphRunRecord[], now = Date.now()): string[] {
1066
+ const tasks = Array.isArray(graph.tasks) ? graph.tasks : [];
1067
+ const age = (iso: unknown) => {
1068
+ const t = Date.parse(String(iso ?? ""));
1069
+ return Number.isFinite(t) && t > 0 ? fmtDur(Math.max(0, (now - t) / 1000)) : "?";
1070
+ };
1071
+ const lines: string[] = [
1072
+ `${oneLine(String(graph.name ?? "?"))} — ${tasks.length} task${tasks.length === 1 ? "" : "s"} · ${oneLine(String(graph.cwd ?? ""))}`,
1073
+ `created ${age(graph.createdAt)} ago · updated ${age(graph.updatedAt)} ago${graph.archivedAt ? " · archived" : ""}`,
1074
+ ];
1075
+ for (const t of tasks)
1076
+ lines.push(
1077
+ ` ${oneLine(String(t?.id ?? "?"))} ${oneLine(String(t?.name ?? "?"))} · deps [${(Array.isArray(t?.dependsOn) ? t.dependsOn : [])
1078
+ .map((d) => oneLine(String(d)))
1079
+ .join(", ")}]${t?.model ? ` · ${oneLine(String(t.model?.provider ?? "?"))}/${oneLine(String(t.model?.modelId ?? "?"))}` : ""}`,
1080
+ );
1081
+ lines.push("");
1082
+ const recent = (Array.isArray(runs) ? runs : []).slice(-GRAPH_DETAIL_MAX_RUNS);
1083
+ if (!recent.length) {
1084
+ lines.push("no runs yet");
1085
+ return lines;
1086
+ }
1087
+ lines.push(`last ${recent.length} run${recent.length === 1 ? "" : "s"}:`);
1088
+ for (const run of recent) {
1089
+ const states = Object.values(run?.tasks ?? {});
1090
+ const total = states.length;
1091
+ const ok = states.filter((s) => s?.status === "ok").length;
1092
+ const failed = states.filter((s) => s?.status === "failed").length;
1093
+ lines.push(
1094
+ ` run ${oneLine(String(run?.id ?? "?"))} · ${oneLine(String(run?.status ?? "?"))} · ${ok}/${total} ok${failed ? ` · ${failed} failed` : ""} · started ${age(run?.startedAt)} ago${run?.finishedAt ? ` · finished ${age(run?.finishedAt)} ago` : ""}`,
1095
+ );
1096
+ }
1097
+ return lines;
1098
+ }
1099
+
1100
+ /** /graphs (run-14): list · enter detail · r run · d delete. No create door —
1101
+ * DAG editing belongs to the web FE. Enter keeps the list up (reading is
1102
+ * read-only, the pickArchived pattern) and dumps the capped detail into the
1103
+ * log view; r/d close + refetch on fresh device state. */
1104
+ export async function pickGraphs(app: App) {
1105
+ let list: Array<GraphRecord & { lastRun?: GraphRunRecord }>;
1106
+ try {
1107
+ list = (await app.client.graphs()).graphs;
1108
+ } catch (e) {
1109
+ return app.notify(`graphs: ${(e as Error).message.slice(0, 80)}`, true);
1110
+ }
1111
+ if (!list.length)
1112
+ return app.notify("no task-graphs on this device — create one in the web FE");
1113
+ // Sort by name — the oneLine'd name, so hostile whitespace cannot reorder
1114
+ // the rows either (the rows are composed from the same fold).
1115
+ const graphs = [...list].sort((a, b) =>
1116
+ oneLine(String(a.name ?? "")).localeCompare(oneLine(String(b.name ?? ""))),
1117
+ );
1118
+ const now = Date.now();
1119
+ const items: SelectItem[] = graphs.map((g) => {
1120
+ const n = Array.isArray(g.tasks) ? g.tasks.length : 0;
1121
+ return {
1122
+ // value is never rendered — keep the RAW id so detail/run/remove hit the
1123
+ // device's true graph (same rule as pickArchived's session ids).
1124
+ value: String(g.id ?? ""),
1125
+ label: `${graphRunGlyph(String(g.lastRun?.status ?? ""))} ${oneLine(String(g.name ?? ""))}`,
1126
+ description: `${n} task${n === 1 ? "" : "s"} · ${oneLine(String(g.cwd ?? ""))} · last ${graphRunState(g.lastRun, now)}`,
1127
+ };
1128
+ });
1129
+ // r14 review n7: a graph whose name is "" falls through to the id — the
1130
+ // ?? only catches nullish, and an empty toast ("removed ") reads as a bug.
1131
+ const labelOf = (id: string) => {
1132
+ const name = oneLine(String(graphs.find((x) => x.id === id)?.name ?? ""));
1133
+ return name || oneLine(id);
1134
+ };
1135
+ const showDetail = async (item: SelectItem) => {
1136
+ const label = labelOf(item.value);
1137
+ try {
1138
+ const { graph, runs } = await app.client.graph(item.value);
1139
+ const lines = capTranscriptLines(graphDetailLines(graph, runs).join("\n"), {
1140
+ maxLines: GRAPH_DETAIL_MAX_LINES,
1141
+ });
1142
+ for (const line of lines) app.logEvent("graph", line);
1143
+ app.notify(`${label} — detail, ${lines.length} line${lines.length === 1 ? "" : "s"} (log view: L)`);
1144
+ } catch (e) {
1145
+ app.notify(`graph: ${(e as Error).message.slice(0, 80)}`, true);
1146
+ }
1147
+ };
1148
+ app.overlay(
1149
+ new ActionPicker(
1150
+ `Graphs on ${oneLine(app.device.id)}`,
1151
+ items,
1152
+ (item) => void showDetail(item),
1153
+ () => app.closeOverlay(),
1154
+ "enter detail · r run · d delete · esc close",
1155
+ {
1156
+ // Fire-and-forget by design (run-14): the device owns the run; the TUI
1157
+ // toasts "started" and does NOT poll or attach — results land in this
1158
+ // same detail view on the next visit (or the tasks tab).
1159
+ r: async (item) => {
1160
+ const label = labelOf(item.value);
1161
+ app.closeOverlay();
1162
+ await app.run(async () => {
1163
+ await app.client.runGraph(item.value);
1164
+ app.notify(`graph ${label} started`);
1165
+ app.logEvent("graph", `${label} run fired by hand`);
1166
+ });
1167
+ void pickGraphs(app);
1168
+ },
1169
+ d: async (item) => {
1170
+ const label = labelOf(item.value);
1171
+ // The same y/n gate /reset and /schedules d ask (R4 finding 4): a
1172
+ // destructive door confirms; esc or anything not starting with y
1173
+ // keeps the graph.
1174
+ const ok = await app.prompt(`Remove graph ${label}? y/n`, "");
1175
+ if (ok === undefined || !ok.trim().toLowerCase().startsWith("y"))
1176
+ return app.flash("remove cancelled"), undefined;
1177
+ app.closeOverlay();
1178
+ await app.run(async () => {
1179
+ await app.client.removeGraph(item.value);
1180
+ app.notify(`removed ${label}`);
1181
+ app.logEvent("graph", `removed ${label}`);
1182
+ });
1183
+ void pickGraphs(app);
1184
+ },
1185
+ },
1186
+ "run/remove only — DAG editing lives in the web FE",
1187
+ ),
1188
+ );
1189
+ }
@@ -311,13 +311,21 @@ export function renderHeader(
311
311
  devicesTotal?: number;
312
312
  conn: string;
313
313
  connOk: boolean;
314
+ /**
315
+ * run-14 (hub resilience): a countdown to the next reconnect attempt
316
+ * (`↻12s`), appended to the conn chip while the hub is OFFLINE so the
317
+ * operator sees WHEN the retry fires instead of a dead `hub offline`.
318
+ * Absent (live, connecting, direct devices) → byte-identical to the
319
+ * pre-run-14 render — the r12/r13 header tests pin those bytes.
320
+ */
321
+ retry?: string;
314
322
  },
315
323
  ): string {
316
324
  const left = [
317
325
  `${c.accent("▲")} ${c.bold("dpi")}`,
318
326
  c.muted("tui"),
319
327
  c.muted("│"),
320
- `${opts.connOk ? c.ok("●") : c.err("○")} ${c.text(opts.conn)}`,
328
+ `${opts.connOk ? c.ok("●") : c.err("○")} ${c.text(opts.conn)}${opts.retry ? c.muted(` · ${opts.retry}`) : ""}`,
321
329
  c.muted(`${opts.sessions} session${opts.sessions === 1 ? "" : "s"}`),
322
330
  opts.devicesTotal !== undefined
323
331
  ? c.muted(`${opts.devicesOnline ?? 0}/${opts.devicesTotal} devices`)
@@ -484,10 +492,17 @@ export function renderOps(
484
492
 
485
493
  section("VITALS", "vitals", () => {
486
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 : [];
487
502
  const out = [
488
- ` ${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}`)}`,
489
- ` ${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))}`,
490
- ` ${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")}`,
491
506
  // run-12 phase 1 typed these into the SDK: event-loop lag is the stall
492
507
  // loadavg cannot express, and gitSpawns' queued(+high) is the number
493
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.120",
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",