@yaag/tui 0.1.4 → 0.2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yaag/tui",
3
- "version": "0.1.4",
3
+ "version": "0.2.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -19,6 +19,6 @@
19
19
  },
20
20
  "dependencies": {
21
21
  "@earendil-works/pi-tui": "^0.84.0",
22
- "@yaag/runtime": "0.1.4"
22
+ "@yaag/runtime": "0.2.0"
23
23
  }
24
24
  }
@@ -1,3 +1,4 @@
1
+ import type { RunSummary } from "@yaag/runtime";
1
2
  import { compactAgentLine, compactHeaderLine } from "./compact-render.ts";
2
3
  import { renderNodeTable } from "./node-table.ts";
3
4
  import { sanitizeTerminalLine } from "./terminal-text.ts";
@@ -16,9 +17,10 @@ export interface SnapshotRenderOptions {
16
17
  }
17
18
 
18
19
  /**
19
- * Renders the model-facing snapshot frame: one Run header line, then one line
20
- * per Agent with that Agent's Nested Node table, then the Result block when
21
- * the Run settled with a value.
20
+ * Renders the model-facing snapshot frame: one Run header line, one warning
21
+ * line when the Run lost its Checkpoint, then one line per Agent with that
22
+ * Agent's Nested Node table, then the Result block when the Run settled with a
23
+ * value.
22
24
  *
23
25
  * It draws no key footer and reads no input, so every line is content a model
24
26
  * can parse. Pure over the state; every untrusted string is sanitized and
@@ -30,6 +32,8 @@ export function renderSnapshot(
30
32
  ): readonly string[] {
31
33
  const header = { now: options.now, width: options.width, ...labelOf(options) };
32
34
  const lines: string[] = [compactHeaderLine(state, header)];
35
+ const warning = checkpointLostLine(state.summary, options.width);
36
+ if (warning !== undefined) lines.push(warning);
33
37
  const agents = buildTree(state, { now: options.now });
34
38
  const names = state.agentOrder.filter((name) => state.summary.agents[name] !== undefined);
35
39
  agents.forEach((agent, index) => {
@@ -46,6 +50,15 @@ export function renderSnapshot(
46
50
  ];
47
51
  }
48
52
 
53
+ /**
54
+ * One warning line for a Run that asked for a Checkpoint and lost it. The Run's
55
+ * own error is reported elsewhere; this line reports only the missing artifact.
56
+ */
57
+ function checkpointLostLine(summary: RunSummary, width: number): string | undefined {
58
+ if (summary.runState !== "ended" || summary.checkpointLost === undefined) return undefined;
59
+ return clamp(sanitizeTerminalLine(`! checkpoint lost: ${summary.checkpointLost}`), width);
60
+ }
61
+
49
62
  function labelOf(options: SnapshotRenderOptions): { readonly label?: string } {
50
63
  return options.label === undefined ? {} : { label: options.label };
51
64
  }