@rivet-dev/agentos 0.2.15 → 0.2.16-rc.2

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 (29) hide show
  1. package/assets/inspector-tabs-app/assets/__vite-browser-external-2447137e-BIHI7g3E.js +1 -0
  2. package/assets/inspector-tabs-app/assets/agentos-hero-logo-E3fapwXM.svg +74 -0
  3. package/assets/inspector-tabs-app/assets/filesystem-DQPPvVO9.js +1 -0
  4. package/assets/inspector-tabs-app/assets/hooks-CdZ_23e1.js +1 -0
  5. package/assets/inspector-tabs-app/assets/index-CvS46tYl.js +110 -0
  6. package/assets/inspector-tabs-app/assets/index-DG_s1YoH.css +1 -0
  7. package/assets/inspector-tabs-app/assets/scroll-area-D0TYc2jF.js +1 -0
  8. package/assets/inspector-tabs-app/assets/sed-BwsOyU9v.svg +1 -0
  9. package/assets/inspector-tabs-app/assets/system-C1DTBU1d.js +2 -0
  10. package/assets/inspector-tabs-app/assets/terminal-DhW76lRS.js +13 -0
  11. package/assets/inspector-tabs-app/assets/transcript-OolSpSiF.js +1 -0
  12. package/assets/inspector-tabs-app/assets/useSuspenseQuery-j2bgzu1R.js +1 -0
  13. package/assets/inspector-tabs-app/assets/vm-boot-gate-DG5U7SkD.js +1 -0
  14. package/assets/inspector-tabs-app/assets/vm-status-badges-CKabwPpS.js +5 -0
  15. package/assets/inspector-tabs-app/index.html +2 -2
  16. package/dist/index.d.ts +98 -2
  17. package/dist/index.js +445 -5
  18. package/dist/index.js.map +1 -1
  19. package/package.json +5 -4
  20. package/assets/inspector-tabs-app/assets/badge-BmCA5T7W.js +0 -1
  21. package/assets/inspector-tabs-app/assets/filesystem-Ddl1E2J2.js +0 -1
  22. package/assets/inspector-tabs-app/assets/index-BGua85-g.js +0 -125
  23. package/assets/inspector-tabs-app/assets/index-Dt5XhJ9h.css +0 -1
  24. package/assets/inspector-tabs-app/assets/mounts-DGpRABb5.js +0 -1
  25. package/assets/inspector-tabs-app/assets/processes-kG2x8aAp.js +0 -1
  26. package/assets/inspector-tabs-app/assets/scroll-area-DzEUZzTZ.js +0 -1
  27. package/assets/inspector-tabs-app/assets/software-CIIxhwyc.js +0 -1
  28. package/assets/inspector-tabs-app/assets/transcript-DEti4eM2.js +0 -1
  29. package/assets/inspector-tabs-app/assets/useSuspenseQuery-DmE5ZTv0.js +0 -1
package/dist/index.js CHANGED
@@ -1,4 +1,6 @@
1
- import "./chunk-V6TY7KAL.js";
1
+ import {
2
+ __publicField
3
+ } from "./chunk-V6TY7KAL.js";
2
4
 
3
5
  // src/index.ts
4
6
  import { setup as rivetkitSetup } from "rivetkit";
@@ -6,6 +8,8 @@ export * from "@rivet-dev/agentos-core";
6
8
 
7
9
  // src/actor.ts
8
10
  import crypto from "crypto";
11
+ import { dirname, join } from "path";
12
+ import { fileURLToPath } from "url";
9
13
  import {
10
14
  AgentOs
11
15
  } from "@rivet-dev/agentos-core";
@@ -16,6 +20,270 @@ import {
16
20
  } from "rivetkit";
17
21
  import { db } from "rivetkit/db";
18
22
  import { migrations } from "rivetkit/unstable/migrations";
23
+
24
+ // src/shell-replay.ts
25
+ import { readFile } from "fs/promises";
26
+ import { createRequire } from "module";
27
+ var MAX_REPLAY_SHELLS = 32;
28
+ var MAX_SCROLLBACK_LINES = 1e3;
29
+ var MAX_COLS = 1e3;
30
+ var MAX_ROWS = 1e3;
31
+ var DEFAULT_COLS = 80;
32
+ var DEFAULT_ROWS = 24;
33
+ var ghosttyPromise;
34
+ async function loadGhostty() {
35
+ ghosttyPromise ?? (ghosttyPromise = (async () => {
36
+ const require2 = createRequire(import.meta.url);
37
+ const { Ghostty } = await import("ghostty-web");
38
+ const bytes = await readFile(
39
+ require2.resolve("ghostty-web/ghostty-vt.wasm")
40
+ );
41
+ const { instance } = await WebAssembly.instantiate(bytes, {
42
+ env: { log: () => {
43
+ } }
44
+ });
45
+ return new Ghostty(instance);
46
+ })());
47
+ return ghosttyPromise;
48
+ }
49
+ var CELL_BOLD = 1;
50
+ var CELL_ITALIC = 2;
51
+ var CELL_UNDERLINE = 4;
52
+ var CELL_STRIKETHROUGH = 8;
53
+ var CELL_INVERSE = 16;
54
+ var CELL_INVISIBLE = 32;
55
+ var CELL_BLINK = 64;
56
+ var CELL_FAINT = 128;
57
+ var RESTORED_DEC_MODES = [
58
+ 1,
59
+ // DECCKM — application cursor keys
60
+ 7,
61
+ // DECAWM — autowrap
62
+ 1e3,
63
+ // mouse: click tracking
64
+ 1002,
65
+ // mouse: button-event tracking
66
+ 1003,
67
+ // mouse: any-event tracking
68
+ 1004,
69
+ // focus in/out reporting
70
+ 1005,
71
+ // mouse: UTF-8 coordinates
72
+ 1006,
73
+ // mouse: SGR coordinates
74
+ 1015,
75
+ // mouse: urxvt coordinates
76
+ 2004
77
+ // bracketed paste
78
+ ];
79
+ var DEFAULT_STYLE = { fg: null, bg: null, flags: 0 };
80
+ function rgb(r, g, b) {
81
+ return r << 16 | g << 8 | b;
82
+ }
83
+ function styleOf(cell, defaultFg, defaultBg) {
84
+ const fg = rgb(cell.fg_r, cell.fg_g, cell.fg_b);
85
+ const bg = rgb(cell.bg_r, cell.bg_g, cell.bg_b);
86
+ return {
87
+ fg: fg === defaultFg ? null : fg,
88
+ bg: bg === defaultBg ? null : bg,
89
+ flags: cell.flags
90
+ };
91
+ }
92
+ function sameStyle(a, b) {
93
+ return a.fg === b.fg && a.bg === b.bg && a.flags === b.flags;
94
+ }
95
+ function sgr(style) {
96
+ const params = [0];
97
+ if (style.flags & CELL_BOLD) params.push(1);
98
+ if (style.flags & CELL_FAINT) params.push(2);
99
+ if (style.flags & CELL_ITALIC) params.push(3);
100
+ if (style.flags & CELL_UNDERLINE) params.push(4);
101
+ if (style.flags & CELL_BLINK) params.push(5);
102
+ if (style.flags & CELL_INVERSE) params.push(7);
103
+ if (style.flags & CELL_INVISIBLE) params.push(8);
104
+ if (style.flags & CELL_STRIKETHROUGH) params.push(9);
105
+ if (style.fg !== null) {
106
+ params.push(
107
+ 38,
108
+ 2,
109
+ style.fg >> 16 & 255,
110
+ style.fg >> 8 & 255,
111
+ style.fg & 255
112
+ );
113
+ }
114
+ if (style.bg !== null) {
115
+ params.push(
116
+ 48,
117
+ 2,
118
+ style.bg >> 16 & 255,
119
+ style.bg >> 8 & 255,
120
+ style.bg & 255
121
+ );
122
+ }
123
+ return `\x1B[${params.join(";")}m`;
124
+ }
125
+ function serializeRow(cells, cols, defaultFg, defaultBg, graphemeAt) {
126
+ let lastMeaningful = -1;
127
+ for (let x = 0; x < cols; x++) {
128
+ const cell = cells[x];
129
+ if (!cell) continue;
130
+ const blank = cell.codepoint === 0 || cell.codepoint === 32;
131
+ if (!blank || !sameStyle(styleOf(cell, defaultFg, defaultBg), DEFAULT_STYLE)) {
132
+ lastMeaningful = x;
133
+ }
134
+ }
135
+ if (lastMeaningful < 0) return "\x1B[0m\x1B[K";
136
+ let out = "";
137
+ let current = DEFAULT_STYLE;
138
+ out += sgr(current);
139
+ for (let x = 0; x <= lastMeaningful; x++) {
140
+ const cell = cells[x];
141
+ if (!cell) {
142
+ out += " ";
143
+ continue;
144
+ }
145
+ if (cell.width === 0) continue;
146
+ const style = styleOf(cell, defaultFg, defaultBg);
147
+ if (!sameStyle(style, current)) {
148
+ out += sgr(style);
149
+ current = style;
150
+ }
151
+ if (cell.grapheme_len > 0) {
152
+ out += graphemeAt(x);
153
+ } else if (cell.codepoint === 0) {
154
+ out += " ";
155
+ } else {
156
+ out += String.fromCodePoint(cell.codepoint);
157
+ }
158
+ }
159
+ return `${out}\x1B[0m\x1B[K`;
160
+ }
161
+ function clamp(value, fallback, max) {
162
+ if (!Number.isFinite(value) || value === void 0 || value <= 0)
163
+ return fallback;
164
+ return Math.min(Math.floor(value), max);
165
+ }
166
+ var ShellReplayStore = class {
167
+ constructor() {
168
+ __publicField(this, "entries", /* @__PURE__ */ new Map());
169
+ __publicField(this, "ghostty", null);
170
+ }
171
+ /** Instantiates the WASM module. Callers must await this before opening a
172
+ * shell so that `open` itself can be synchronous: a PTY starts producing
173
+ * output the moment it exists, and any await between opening it and
174
+ * subscribing is a window where output is lost to every consumer. */
175
+ async warm() {
176
+ this.ghostty ?? (this.ghostty = await loadGhostty());
177
+ }
178
+ open(shellId, cols, rows) {
179
+ if (this.entries.has(shellId)) return;
180
+ if (this.entries.size >= MAX_REPLAY_SHELLS) {
181
+ throw new Error(
182
+ `agent-os shell replay limit reached (${MAX_REPLAY_SHELLS} emulators); close a shell or raise MAX_REPLAY_SHELLS in shell-replay.ts`
183
+ );
184
+ }
185
+ if (!this.ghostty) {
186
+ throw new Error("agent-os shell replay used before warm() resolved");
187
+ }
188
+ const width = clamp(cols, DEFAULT_COLS, MAX_COLS);
189
+ const height = clamp(rows, DEFAULT_ROWS, MAX_ROWS);
190
+ const term = this.ghostty.createTerminal(width, height, {
191
+ scrollbackLimit: MAX_SCROLLBACK_LINES
192
+ });
193
+ term.write("\x1Bc");
194
+ this.entries.set(shellId, { term, cols: width, rows: height, seq: 0 });
195
+ }
196
+ /** Feeds one broadcast chunk and returns its sequence number. Clients use
197
+ * it to drop chunks a snapshot already contains. Returns 0 when this shell
198
+ * has no emulator, which clients read as "no replay available". */
199
+ feed(shellId, data) {
200
+ const entry = this.entries.get(shellId);
201
+ if (!entry) return 0;
202
+ entry.term.write(data);
203
+ return ++entry.seq;
204
+ }
205
+ resize(shellId, cols, rows) {
206
+ const entry = this.entries.get(shellId);
207
+ if (!entry) return;
208
+ entry.cols = clamp(cols, entry.cols, MAX_COLS);
209
+ entry.rows = clamp(rows, entry.rows, MAX_ROWS);
210
+ entry.term.resize(entry.cols, entry.rows);
211
+ }
212
+ close(shellId) {
213
+ const entry = this.entries.get(shellId);
214
+ if (!entry) return;
215
+ this.entries.delete(shellId);
216
+ entry.term.free();
217
+ }
218
+ has(shellId) {
219
+ return this.entries.has(shellId);
220
+ }
221
+ snapshot(shellId, mode) {
222
+ const entry = this.entries.get(shellId);
223
+ if (!entry) return null;
224
+ const { term, cols, rows, seq } = entry;
225
+ const base = { shellId, seq, cols, rows };
226
+ if (mode === "none") return { ...base, mode, data: "" };
227
+ term.update();
228
+ const colors = term.getColors();
229
+ const defaultFg = rgb(
230
+ colors.foreground.r,
231
+ colors.foreground.g,
232
+ colors.foreground.b
233
+ );
234
+ const defaultBg = rgb(
235
+ colors.background.r,
236
+ colors.background.g,
237
+ colors.background.b
238
+ );
239
+ const alternate = term.isAlternateScreen();
240
+ let out = "\x1Bc";
241
+ if (mode === "scrollback" && !alternate) {
242
+ const available = Math.min(
243
+ term.getScrollbackLength(),
244
+ MAX_SCROLLBACK_LINES
245
+ );
246
+ for (let i = available; i > 0; i--) {
247
+ const offset = i - 1;
248
+ const line = term.getScrollbackLine(offset);
249
+ if (!line) continue;
250
+ out += serializeRow(
251
+ line,
252
+ cols,
253
+ defaultFg,
254
+ defaultBg,
255
+ (col) => term.getScrollbackGraphemeString(offset, col)
256
+ );
257
+ out += "\r\n";
258
+ }
259
+ }
260
+ if (alternate) out += "\x1B[?1049h";
261
+ for (const decMode of RESTORED_DEC_MODES) {
262
+ out += term.getMode(decMode) ? `\x1B[?${decMode}h` : `\x1B[?${decMode}l`;
263
+ }
264
+ const viewport = term.getViewport();
265
+ out += "\x1B[H";
266
+ for (let y = 0; y < rows; y++) {
267
+ if (y > 0) out += "\r\n";
268
+ const row = viewport.slice(y * cols, (y + 1) * cols);
269
+ out += serializeRow(
270
+ row,
271
+ cols,
272
+ defaultFg,
273
+ defaultBg,
274
+ (col) => term.getGraphemeString(y, col)
275
+ );
276
+ }
277
+ const cursor = term.getCursor();
278
+ const cy = Math.min(Math.max(cursor.viewportY, 0), rows - 1) + 1;
279
+ const cx = Math.min(Math.max(cursor.viewportX, 0), cols - 1) + 1;
280
+ out += `\x1B[0m\x1B[${cy};${cx}H`;
281
+ out += cursor.visible ? "\x1B[?25h" : "\x1B[?25l";
282
+ return { ...base, mode, data: out };
283
+ }
284
+ };
285
+
286
+ // src/actor.ts
19
287
  var DEFAULT_ACTION_TIMEOUT_MS = 2147483647;
20
288
  var DEFAULT_SLEEP_GRACE_PERIOD_MS = 15 * 6e4;
21
289
  var DEFAULT_PREVIEW_TTL_SECONDS = 3600;
@@ -29,6 +297,7 @@ var ACTOR_SQLITE_INLINE_THRESHOLD = 64 * 1024;
29
297
  var ROOT_NAMESPACE = "agentos-root";
30
298
  var PREVIEW_PATH_PATTERN = /^\/fetch\/([a-f0-9]{48})(\/.*)?$/;
31
299
  var MAX_SQLITE_SAFE_INTEGER = Number.MAX_SAFE_INTEGER;
300
+ var MAX_OPEN_SHELLS = 32;
32
301
  var ACTOR_SQLITE_MIGRATIONS = [
33
302
  {
34
303
  version: 1,
@@ -69,11 +338,29 @@ var optionResolvers = /* @__PURE__ */ new WeakMap();
69
338
  var vmStartResolvers = /* @__PURE__ */ new WeakMap();
70
339
  var vmStopResolvers = /* @__PURE__ */ new WeakMap();
71
340
  var vmDisposedResolvers = /* @__PURE__ */ new WeakMap();
341
+ var HEALTH_WARNINGS_CAP = 50;
342
+ var HEALTH_AGENT_EXITS_CAP = 50;
343
+ var healthBuffers = /* @__PURE__ */ new Map();
344
+ function healthBuffersFor(actorId) {
345
+ let buffers = healthBuffers.get(actorId);
346
+ if (!buffers) {
347
+ buffers = { warnings: [], agentExits: [] };
348
+ healthBuffers.set(actorId, buffers);
349
+ }
350
+ return buffers;
351
+ }
352
+ function pushCapped(buffer, item, cap) {
353
+ buffer.push(item);
354
+ while (buffer.length > cap) buffer.shift();
355
+ }
72
356
  function runtimeFor(c) {
73
357
  let runtime = runtimes.get(c.actorId);
74
358
  if (!runtime) {
75
359
  runtime = {
76
360
  vm: null,
361
+ bootedVm: null,
362
+ openShells: /* @__PURE__ */ new Map(),
363
+ shellReplay: new ShellReplayStore(),
77
364
  subscribedSessions: /* @__PURE__ */ new Map(),
78
365
  vmCleanupRan: false,
79
366
  fetchStreamHolds: /* @__PURE__ */ new Map()
@@ -135,6 +422,18 @@ async function ensureVm(c, options) {
135
422
  msg: "agent-os agent adapter exited unexpectedly",
136
423
  ...event2
137
424
  });
425
+ pushCapped(
426
+ healthBuffersFor(c.actorId).agentExits,
427
+ {
428
+ ts: Date.now(),
429
+ sessionId: event2.sessionId,
430
+ agentType: event2.agentType,
431
+ exitCode: event2.exitCode,
432
+ restart: event2.restart,
433
+ restartCount: event2.restartCount
434
+ },
435
+ HEALTH_AGENT_EXITS_CAP
436
+ );
138
437
  c.broadcast("agentExit", event2);
139
438
  try {
140
439
  resolvedOptions.onAgentExit?.(event2);
@@ -146,6 +445,26 @@ async function ensureVm(c, options) {
146
445
  });
147
446
  }
148
447
  },
448
+ onLimitWarning: (warning) => {
449
+ c.log.warn({
450
+ msg: "agent-os runtime limit is near capacity",
451
+ ...warning
452
+ });
453
+ pushCapped(
454
+ healthBuffersFor(c.actorId).warnings,
455
+ { ts: Date.now(), ...warning },
456
+ HEALTH_WARNINGS_CAP
457
+ );
458
+ try {
459
+ options?.onLimitWarning?.(warning);
460
+ } catch (error) {
461
+ c.log.error({
462
+ msg: "agent-os onLimitWarning hook failed",
463
+ limit: warning.limit,
464
+ error
465
+ });
466
+ }
467
+ },
149
468
  rootFilesystem: {
150
469
  type: "native",
151
470
  plugin: {
@@ -194,6 +513,7 @@ async function ensureVm(c, options) {
194
513
  }
195
514
  }
196
515
  vm.onCronEvent((cronEvent) => c.broadcast("cronEvent", cronEvent));
516
+ runtime.bootedVm = vm;
197
517
  c.broadcast("vmBooted", {});
198
518
  c.log.info({
199
519
  msg: "agent-os vm booted",
@@ -205,6 +525,7 @@ async function ensureVm(c, options) {
205
525
  return await runtime.vm;
206
526
  } catch (error) {
207
527
  runtime.vm = null;
528
+ runtime.bootedVm = null;
208
529
  c.log.error({
209
530
  msg: "agent-os vm bootstrap failed",
210
531
  actorId: c.actorId,
@@ -215,9 +536,11 @@ async function ensureVm(c, options) {
215
536
  }
216
537
  }
217
538
  async function disposeVm(c, reason) {
539
+ if (reason === "destroy") healthBuffers.delete(c.actorId);
218
540
  const runtime = runtimes.get(c.actorId);
219
541
  if (!runtime) return;
220
542
  const vm = runtime.vm;
543
+ runtime.bootedVm = null;
221
544
  runtimes.delete(c.actorId);
222
545
  for (const unsubscribers of runtime.subscribedSessions.values()) {
223
546
  for (const unsubscribe of unsubscribers) unsubscribe();
@@ -763,14 +1086,30 @@ function createAgentOsActions(options, hooks = {}, preview = {}, maxSessionSubsc
763
1086
  },
764
1087
  openShell: async (c, ...args) => {
765
1088
  const vm = await ensureVm(c, options);
1089
+ const runtime = runtimeFor(c);
1090
+ if (runtime.openShells.size >= MAX_OPEN_SHELLS) {
1091
+ throw new Error(
1092
+ `agent-os shell limit reached (${MAX_OPEN_SHELLS} open); close a shell or raise MAX_OPEN_SHELLS`
1093
+ );
1094
+ }
1095
+ await runtime.shellReplay.warm();
766
1096
  const shell = vm.terminal.open(...args);
1097
+ runtime.openShells.set(shell.shellId, { openedAt: Date.now() });
1098
+ runtime.shellReplay.open(shell.shellId, args[0]?.cols, args[0]?.rows);
767
1099
  const unsubscribeData = vm.onShellData(
768
1100
  shell.shellId,
769
- (event2) => c.broadcast("shellData", event2)
1101
+ (event2) => c.broadcast("shellData", {
1102
+ ...event2,
1103
+ seq: runtime.shellReplay.feed(event2.shellId, event2.data)
1104
+ })
770
1105
  );
771
1106
  const unsubscribeStderr = vm.onShellStderr(
772
1107
  shell.shellId,
773
- (event2) => c.broadcast("shellStderr", event2)
1108
+ (event2) => (
1109
+ // A diagnostic tap carrying bytes `shellData` already delivered, so
1110
+ // it is never folded into replay and carries no sequence.
1111
+ c.broadcast("shellStderr", { ...event2, seq: 0 })
1112
+ )
774
1113
  );
775
1114
  const unsubscribeExit = vm.onShellExit(
776
1115
  shell.shellId,
@@ -778,6 +1117,8 @@ function createAgentOsActions(options, hooks = {}, preview = {}, maxSessionSubsc
778
1117
  );
779
1118
  void c.keepAwake(
780
1119
  vm.terminal.wait(shell.shellId).finally(() => {
1120
+ runtime.openShells.delete(shell.shellId);
1121
+ runtime.shellReplay.close(shell.shellId);
781
1122
  unsubscribeData();
782
1123
  unsubscribeStderr();
783
1124
  unsubscribeExit();
@@ -791,8 +1132,29 @@ function createAgentOsActions(options, hooks = {}, preview = {}, maxSessionSubsc
791
1132
  );
792
1133
  return shell;
793
1134
  },
1135
+ // Observe-only: enumerates shells this actor opened without booting a
1136
+ // sleeping VM (a sleeping VM has none). Clients must not track shell ids
1137
+ // themselves — a shell outlives the page that opened it and keeps the VM
1138
+ // awake, so it has to stay discoverable.
1139
+ listShells: async (c) => {
1140
+ const runtime = runtimes.get(c.actorId);
1141
+ if (!runtime?.bootedVm) return [];
1142
+ return [...runtime.openShells.entries()].map(([shellId, entry]) => ({ shellId, openedAt: entry.openedAt })).sort((a, b) => a.openedAt - b.openedAt);
1143
+ },
794
1144
  writeShell: async (c, ...args) => (await ensureVm(c, options)).terminal.write(...args),
795
- resizeShell: async (c, ...args) => (await ensureVm(c, options)).terminal.resize(...args),
1145
+ resizeShell: async (c, ...args) => {
1146
+ const result = (await ensureVm(c, options)).terminal.resize(...args);
1147
+ runtimeFor(c).shellReplay.resize(args[0], args[1], args[2]);
1148
+ return result;
1149
+ },
1150
+ // Observe-only, like `listShells`: repainting a shell must never boot a
1151
+ // VM, and a sleeping VM has no live shells to repaint. Returns `null`
1152
+ // for an unknown shell so a client falls back to no replay.
1153
+ shellSnapshot: async (c, shellId, mode = "screen") => {
1154
+ const runtime = runtimes.get(c.actorId);
1155
+ if (!runtime?.bootedVm) return null;
1156
+ return runtime.shellReplay.snapshot(shellId, mode);
1157
+ },
796
1158
  closeShell: async (c, ...args) => (await ensureVm(c, options)).terminal.close(...args),
797
1159
  waitShell: async (c, ...args) => (await ensureVm(c, options)).terminal.wait(...args),
798
1160
  httpRequest: async (c, ...args) => (await ensureVm(c, options)).network.httpRequest(...args),
@@ -869,6 +1231,33 @@ function createAgentOsActions(options, hooks = {}, preview = {}, maxSessionSubsc
869
1231
  listCronJobs: async (c) => (await ensureVm(c, options)).cron.list(),
870
1232
  cancelCronJob: async (c, ...args) => (await ensureVm(c, options)).cron.cancel(...args),
871
1233
  listAgents: async (c) => (await ensureVm(c, options)).agents.list(),
1234
+ // Observe-only: reports VM liveness and the post-mortem buffers without
1235
+ // ever booting the VM (deliberately no ensureVm).
1236
+ health: async (c) => {
1237
+ const runtime = runtimes.get(c.actorId);
1238
+ const buffers = healthBuffersFor(c.actorId);
1239
+ let booted = false;
1240
+ let sessions = null;
1241
+ let sidecar = null;
1242
+ const vm = runtime?.bootedVm;
1243
+ if (runtime && vm) {
1244
+ booted = true;
1245
+ sessions = runtime.subscribedSessions.size;
1246
+ const description = vm.sidecar.describe();
1247
+ sidecar = {
1248
+ state: description.state,
1249
+ activeVmCount: description.activeVmCount
1250
+ };
1251
+ }
1252
+ return {
1253
+ booted,
1254
+ sessions,
1255
+ sidecar,
1256
+ warnings: [...buffers.warnings],
1257
+ agentExits: [...buffers.agentExits],
1258
+ stderrTail: []
1259
+ };
1260
+ },
872
1261
  openSession: async (c, input) => {
873
1262
  const vm = await ensureVm(c, options);
874
1263
  try {
@@ -1146,6 +1535,8 @@ function createAgentOsActions(options, hooks = {}, preview = {}, maxSessionSubsc
1146
1535
  },
1147
1536
  terminal: {
1148
1537
  open: flat.openShell,
1538
+ list: flat.listShells,
1539
+ snapshot: flat.shellSnapshot,
1149
1540
  write: flat.writeShell,
1150
1541
  resize: flat.resizeShell,
1151
1542
  wait: flat.waitShell,
@@ -1231,6 +1622,8 @@ function createAgentOsActions(options, hooks = {}, preview = {}, maxSessionSubsc
1231
1622
  writeProcessStdin: nested.process.writeStdin,
1232
1623
  closeProcessStdin: nested.process.closeStdin,
1233
1624
  openShell: nested.terminal.open,
1625
+ listShells: nested.terminal.list,
1626
+ shellSnapshot: nested.terminal.snapshot,
1234
1627
  writeShell: nested.terminal.write,
1235
1628
  resizeShell: nested.terminal.resize,
1236
1629
  closeShell: nested.terminal.close,
@@ -1261,7 +1654,9 @@ function createAgentOsActions(options, hooks = {}, preview = {}, maxSessionSubsc
1261
1654
  linkSoftware: nested.software.link,
1262
1655
  // Preview URLs are RivetKit-specific and intentionally stay flat.
1263
1656
  createPreviewUrl: flat.createPreviewUrl,
1264
- expirePreviewUrl: flat.expirePreviewUrl
1657
+ expirePreviewUrl: flat.expirePreviewUrl,
1658
+ // Observe-only runtime health, also RivetKit-specific.
1659
+ health: flat.health
1265
1660
  };
1266
1661
  }
1267
1662
  var agentOsOptionKeys = [
@@ -1330,6 +1725,46 @@ function assertNoReservedKeys(kind, custom, builtIns) {
1330
1725
  throw new Error(`agentOS() ${kind} name is reserved: ${key}`);
1331
1726
  }
1332
1727
  }
1728
+ var INSPECTOR_TABS_ASSET_DIR = join(
1729
+ dirname(fileURLToPath(import.meta.url)),
1730
+ "..",
1731
+ "assets",
1732
+ "inspector-tabs-app"
1733
+ );
1734
+ var AGENTOS_INSPECTOR_CONFIG = {
1735
+ tabs: [
1736
+ {
1737
+ id: "transcript",
1738
+ label: "Transcript",
1739
+ source: INSPECTOR_TABS_ASSET_DIR,
1740
+ icon: "comments"
1741
+ },
1742
+ {
1743
+ id: "filesystem",
1744
+ label: "Filesystem",
1745
+ source: INSPECTOR_TABS_ASSET_DIR,
1746
+ icon: "folder-tree"
1747
+ },
1748
+ {
1749
+ id: "terminal",
1750
+ label: "Terminal",
1751
+ source: INSPECTOR_TABS_ASSET_DIR,
1752
+ icon: "terminal"
1753
+ },
1754
+ {
1755
+ id: "system",
1756
+ label: "System",
1757
+ source: INSPECTOR_TABS_ASSET_DIR,
1758
+ icon: "layer-group"
1759
+ },
1760
+ // Processes/software/mounts live as sections inside the System tab.
1761
+ // `metadata` is dashboard-owned and not hideable (the schema only
1762
+ // accepts the six built-in ids below), so it stays.
1763
+ ...["workflow", "database", "state", "queue", "connections", "console"].map(
1764
+ (id) => ({ id, hidden: true })
1765
+ )
1766
+ ]
1767
+ };
1333
1768
  function createAgentOS(config = {}) {
1334
1769
  const split = splitConfig(config);
1335
1770
  const actorConfig = split.actorConfig;
@@ -1385,6 +1820,11 @@ function createAgentOS(config = {}) {
1385
1820
  ...actorConfig.options,
1386
1821
  enableActorRuntimeSocket: true
1387
1822
  },
1823
+ // Register the custom agent-os inspector tabs (and hide the built-in
1824
+ // rivetkit tabs) so the dashboard renders the agent-os UI. Without
1825
+ // this the shipped tab assets are never surfaced. A caller-supplied
1826
+ // inspector config wins.
1827
+ inspector: actorConfig.inspector ?? AGENTOS_INSPECTOR_CONFIG,
1388
1828
  db: db({ onMigrate: migrateAgentOsActorTables }),
1389
1829
  events: { ...actorConfig.events ?? {}, ...builtInEvents },
1390
1830
  actions: { ...actorConfig.actions ?? {}, ...actions },