@awebai/oats 0.68.1 → 0.69.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 (99) hide show
  1. package/bin/oats.mjs +180 -36
  2. package/docs/capabilities.md +73 -10
  3. package/docs/capability-manifest.schema.json +1 -1
  4. package/docs/configuration.md +68 -2
  5. package/docs/design/2026-09-23-workspace-module-contracts.md +6 -4
  6. package/docs/design/2026-10-22-module-upgrade.md +1 -1
  7. package/docs/desktop-cli-api.md +600 -25
  8. package/docs/desktop-instance-start.md +59 -3
  9. package/docs/desktop.md +175 -10
  10. package/docs/execution-targets.md +536 -62
  11. package/docs/harness-trust.md +3 -1
  12. package/docs/implementation.md +33 -15
  13. package/docs/integrations.md +2 -2
  14. package/docs/knowledge.md +25 -16
  15. package/docs/oats-local.schema.json +2 -2
  16. package/docs/official-catalog.md +6 -5
  17. package/docs/packages.md +14 -14
  18. package/docs/release-notes/v0.69.0.md +658 -0
  19. package/docs/release-notes/v0.69.1.md +25 -0
  20. package/docs/release-notes/v0.69.2.md +259 -0
  21. package/docs/servers.md +51 -7
  22. package/docs/soul.schema.json +1 -0
  23. package/docs/souls-and-instances.md +46 -9
  24. package/docs/tui.md +177 -21
  25. package/docs/upgrading.md +16 -7
  26. package/docs/workspaces.md +2 -2
  27. package/injects/instance-boundary.md +19 -33
  28. package/injects/work-attached.md +8 -13
  29. package/injects/work-checkout.md +16 -30
  30. package/injects/work-directory.md +9 -15
  31. package/injects/work-workspace.md +8 -19
  32. package/injects/work-worktree.md +18 -33
  33. package/lib/capability-contract.mjs +2 -2
  34. package/lib/core.mjs +496 -127
  35. package/lib/file-pieces.mjs +49 -0
  36. package/lib/instance-background.mjs +54 -0
  37. package/lib/instance-events.mjs +25 -4
  38. package/lib/instance-inspect.mjs +3 -0
  39. package/lib/instance-lifecycle.mjs +35 -0
  40. package/lib/instance-resolution.mjs +3 -2
  41. package/lib/instance-same-work.mjs +67 -0
  42. package/lib/instance-upgrade.mjs +18 -0
  43. package/lib/launch-prompt-fixtures/README.md +62 -0
  44. package/lib/launch-prompt-fixtures/resume-confirmation.json +32 -0
  45. package/lib/launch-prompt-fixtures.mjs +49 -0
  46. package/lib/launch-prompt-resume.mjs +55 -0
  47. package/lib/login-environment.mjs +27 -9
  48. package/lib/materialize.mjs +23 -2
  49. package/lib/resolve.mjs +32 -5
  50. package/lib/schedule.mjs +3 -3
  51. package/lib/servers.mjs +136 -27
  52. package/lib/session-end.mjs +82 -0
  53. package/lib/session-input.mjs +43 -9
  54. package/lib/session-resume-contract.mjs +33 -0
  55. package/lib/session-resume.mjs +337 -0
  56. package/lib/session-seen.mjs +163 -0
  57. package/lib/session-viewer.mjs +147 -44
  58. package/lib/soul-composition.mjs +15 -11
  59. package/lib/start-env.mjs +110 -0
  60. package/lib/tmux-server-scope.mjs +139 -14
  61. package/lib/workspace.mjs +41 -6
  62. package/package-catalog.json +11 -5
  63. package/package.json +1 -1
  64. package/packages/client/cli-adapter.mjs +39 -8
  65. package/packages/client/cli-locator.mjs +3 -2
  66. package/packages/client/deployment-data.mjs +16 -0
  67. package/packages/client/deployment-panel.mjs +7 -0
  68. package/packages/client/file-output-exec.mjs +98 -0
  69. package/packages/client/instance-tree.mjs +64 -14
  70. package/packages/client/launch-prompt-outcome.mjs +25 -13
  71. package/packages/client/own-codes.mjs +2 -0
  72. package/packages/client/panel-views.mjs +11 -3
  73. package/packages/client/remote-roster.mjs +5 -1
  74. package/packages/client/roster-sections.mjs +50 -6
  75. package/packages/client/same-work.mjs +49 -0
  76. package/packages/client/session-attach.mjs +35 -5
  77. package/packages/client/session-resume-cli.mjs +64 -0
  78. package/packages/client/session-resume-trigger.mjs +167 -0
  79. package/packages/client/session-resume.mjs +332 -0
  80. package/packages/client/soul-rows.mjs +2 -0
  81. package/packages/client/spawn-apply-contract.mjs +2 -1
  82. package/packages/client/spawn-decision.mjs +4 -1
  83. package/packages/client/spawn-preview-contract.mjs +12 -1
  84. package/packages/client/spawn-preview.mjs +2 -0
  85. package/packages/client/tmux-status.mjs +30 -7
  86. package/packages/client/waiting-on-you.mjs +11 -4
  87. package/packages/client/workspace-step.mjs +17 -5
  88. package/packages/record/lib/last-conversation.mjs +123 -0
  89. package/packages/record/lib/session-roots.mjs +10 -1
  90. package/packages/tui/README.md +2 -2
  91. package/packages/tui/lib/client.mjs +7 -3
  92. package/packages/tui/lib/main.mjs +49 -14
  93. package/packages/tui/lib/model.mjs +146 -55
  94. package/packages/tui/lib/store.mjs +84 -27
  95. package/packages/tui/lib/term/text.mjs +12 -9
  96. package/packages/tui/lib/views/frame.mjs +74 -7
  97. package/packages/tui/lib/views/help.mjs +10 -3
  98. package/packages/tui/lib/views/instances.mjs +41 -3
  99. package/skills/oats-getting-started/SKILL.md +117 -4
@@ -76,17 +76,20 @@ export function shownEnd(value, width, { ascii = false } = {}) {
76
76
  * broken at spaces where it can be and between graphemes where it cannot, the last row ending
77
77
  * in the cut mark when more was left. For a sentence that must be read whole (a kernel's
78
78
  * reason). Filtered first and cut after, as shownEnd is; nothing to show gives no row, and
79
- * neither does a row too narrow for the first grapheme. */
80
- export function shownLines(value, width, max, { ascii = false } = {}) {
79
+ * neither does a row too narrow for the first grapheme. `first` is the first row's width, when
80
+ * something else stands before the text on that row; every other row is `width` cells. */
81
+ export function shownLines(value, width, max, { ascii = false, first = width } = {}) {
81
82
  const line = displayLine(value);
82
- if (line === null || width < 1 || max < 1) return [];
83
+ if (line === null || width < 1 || first < 1 || max < 1) return [];
83
84
  if (line === DETAIL_WITHHELD) return [WITHHELD];
84
85
  const rows = [];
86
+ const roomOf = (row) => (row === 0 ? first : width);
85
87
  let rest = cells(line);
86
88
  while (rest.length && rows.length < max) {
87
- if (widthOf(rest) <= width) { rows.push(rest); rest = []; break; }
89
+ const room = roomOf(rows.length);
90
+ if (widthOf(rest) <= room) { rows.push(rest); rest = []; break; }
88
91
  let end = 0;
89
- for (let used = 0; end < rest.length && used + rest[end].width <= width; used += rest[end].width) end++;
92
+ for (let used = 0; end < rest.length && used + rest[end].width <= room; used += rest[end].width) end++;
90
93
  // Back to the last space inside the row, when there is one: the row ends before it.
91
94
  let cut = end;
92
95
  while (cut > 0 && rest[cut]?.text !== " " && rest[cut - 1].text !== " ") cut--;
@@ -98,12 +101,12 @@ export function shownLines(value, width, max, { ascii = false } = {}) {
98
101
  while (rest.length && rest[0].text === " ") rest.shift();
99
102
  rows.push(row);
100
103
  }
101
- const mark = cutMark(ascii);
102
- if (rest.length && rows.length && mark.length <= width) {
104
+ const mark = cutMark(ascii), lastRoom = roomOf(rows.length - 1);
105
+ if (rest.length && rows.length && mark.length <= lastRoom) {
103
106
  // More was left: the last row gives up its end to the mark. (A row too narrow for the mark
104
- // keeps what it has: no row is ever wider than `width`.)
107
+ // keeps what it has: no row is ever wider than its room.)
105
108
  const last = rows[rows.length - 1];
106
- while (last.length && widthOf(last) + mark.length > width) last.pop();
109
+ while (last.length && widthOf(last) + mark.length > lastRoom) last.pop();
107
110
  while (last.length && last[last.length - 1].text === " ") last.pop();
108
111
  last.push(...cells(mark));
109
112
  }
@@ -16,7 +16,7 @@ import { style } from "../term/style.mjs";
16
16
  import { act } from "./act.mjs";
17
17
  import { detail } from "./detail.mjs";
18
18
  import { help, keyText, paletteGroupKeys } from "./help.mjs";
19
- import { instances, measured } from "./instances.mjs";
19
+ import { NEEDS_INPUT, WAITS, instances, measured } from "./instances.mjs";
20
20
  import { textWidth } from "../term/width.mjs";
21
21
  import { palette } from "./palette.mjs";
22
22
  import { soulDetail, soulsList, soulsListed } from "./souls.mjs";
@@ -252,6 +252,19 @@ function viewRow(m, view, cols, open) {
252
252
  const made = (id, key, word) => ({ id, key, word: typeof word === "string" ? { spans: [{ col: 0, text: lit(word), width: word.length }], width: word.length } : word });
253
253
  /** A hint of keys that are no action's (a key name the TUI writes, like `Enter`). */
254
254
  const own = (id, keys, word) => made(id, { text: lit(keys), width: keys.length }, word);
255
+ /** The viewer's scroll keys (docs/tui.md, "Tabs"), the viewer's own and never the TUI's, as the
256
+ * model's `scrollKeys` says the shown tab's host takes them: Shift+PageUp, and Ctrl+B [ where its
257
+ * viewer takes that too; none for a host whose kernel does not say. Both keys where the row holds
258
+ * them; where it holds one, `short`: Ctrl+B [ (cheatRows, withKeys). A block of its own, so its
259
+ * long key does not move the other hints' column. */
260
+ const SCROLL_BOTH = "Shift+PageUp or Ctrl+B [", SCROLL_PREFIX = "Ctrl+B [", SCROLL_SHIFT = "Shift+PageUp";
261
+ function scrollHints(m) {
262
+ if (!m.scrollKeys?.shift) return [];
263
+ const hint = own("scroll", m.scrollKeys.prefix ? SCROLL_BOTH : SCROLL_SHIFT, "scroll back");
264
+ return [{ ...hint, block: "scroll", ...(m.scrollKeys.prefix ? { short: { text: lit(SCROLL_PREFIX), width: SCROLL_PREFIX.length } } : {}) }];
265
+ }
266
+ /** A hint with its `short` key where its own key and word do not fit `room` cells. */
267
+ const fitted = (h, room) => (h.short && h.key.width + GAP + h.word.width > room ? { ...h, key: h.short } : h);
255
268
  /** `types <the leader>`: what the leader pressed twice does while a terminal has the focus. */
256
269
  function types(m) {
257
270
  const key = leaderText(m);
@@ -296,7 +309,7 @@ function cheatSheet(m) {
296
309
  const listing = !["help", "switcher", "souls", "capabilities"].includes(m.view);
297
310
  if (listing && m.terminal?.focus === "terminal" && !m.palette && !m.spawn) {
298
311
  const label = backKeyLabel(m.detachKey), list = keyLabel(LEADER.find((entry) => entry.does === "list").keys[0]);
299
- const leader = [made("list", keyText(`${label} ${list}`), "the list"), made("again", keyText(`${label} ${label}`), types(m))];
312
+ const leader = [made("list", keyText(`${label} ${list}`), "the list"), made("again", keyText(`${label} ${label}`), types(m)), ...scrollHints(m)];
300
313
  return m.chordsLead ? [...chordHints(m), ...led(leader)] : [...led(leader), ...chordHints(m)];
301
314
  }
302
315
  if (m.palette) return led([own("run", "Enter", "run"), own("move", "Up/Down", "move"), own("close", "Esc", "close"), paletteGroups(m)]);
@@ -321,7 +334,9 @@ function cheatSheet(m) {
321
334
  }
322
335
  // A view's list or its detail: a small sheet; the rest is the leader's, the palette's and the help's.
323
336
  const asking = listing && m.opening?.phase === "preflight";
337
+ // On the Background heading (#1579) Enter opens the section or closes it.
324
338
  const enter = asking ? [hint("close", "stop opening")] : listing && m.onTerminal ? [hint("open", "focus terminal")] : listing && m.openable ? [hint("open")]
339
+ : listing && m.onBackground && m.focus === "list" ? [hint("open", m.onBackground === "open" ? "close" : "open")]
325
340
  : soul?.detail ? [hint("open", soul.focus === "detail" ? "instances" : "detail")]
326
341
  : capability?.detail ? (capability.focus !== "detail" ? [hint("open", "detail")] : capability.mark >= 0 ? [hint("open", "soul")] : []) : [];
327
342
  const detailed = soul ? soul.focus === "detail" && Boolean(soul.detail) : capability ? capability.focus === "detail" && Boolean(capability.detail) : listing && m.focus === "detail";
@@ -386,8 +401,9 @@ function givenUp(hints) {
386
401
  * (the chords') have a column of their own, after their own widest key, and as far left as
387
402
  * leaves their words whole: those words are the TUI's own and short, where their keys are long
388
403
  * (`Alt+Shift+Left/Right` in the 30 cells beside a terminal). */
389
- function cheatRows(hints, cols) {
404
+ function cheatRows(given, cols) {
390
405
  const edge = cols - MARGIN;
406
+ const hints = given.map((h) => fitted(h, edge - MARGIN));
391
407
  const columns = new Map();
392
408
  for (const h of hints) {
393
409
  const c = columns.get(h.block) ?? { widest: 0, word: 6 };
@@ -412,13 +428,15 @@ const titleSheet = (m) => cheatSheet(m).filter((h) => m.chordsLead || h.block !=
412
428
  * right, dim, as many as fit after what the row holds, given up from the end. With `first`, the
413
429
  * first key always stands (a detail page's way back): what the row holds is cut to leave it room. */
414
430
  function withKeys(given, hints, cols, { skip = ["leader", "palette", "help", "quit"], first = false } = {}) {
415
- const keys = hints.filter((h) => !skip.includes(h.id));
416
431
  const widthOf = (list) => list.reduce((sum, h) => sum + h.key.width + 1 + h.word.width, 0) + Math.max(0, list.length - 1) * GAP;
417
- const limit = first && keys.length ? cols - MARGIN - widthOf(keys.slice(0, 1)) - GAP : Infinity;
432
+ const whole = hints.filter((h) => !skip.includes(h.id));
433
+ const limit = first && whole.length ? cols - MARGIN - widthOf(whole.slice(0, 1)) - GAP : Infinity;
418
434
  const row = limit === Infinity ? given : given.filter((span) => span.text === undefined || span.col < limit)
419
435
  .map((span) => (span.text === undefined ? span : { ...span, width: Math.min(span.width ?? textWidth(textOf(span.text)), limit - span.col) }));
420
436
  // What the row holds ends where its text does: a span may be given more cells than its text takes.
421
437
  const end = row.reduce((most, span) => (span.text !== undefined ? Math.max(most, span.col + Math.min(span.width ?? Infinity, textWidth(textOf(span.text)))) : most), 0);
438
+ // A hint with a short key takes it when the row, after what it holds, cannot hold every key as it is.
439
+ const keys = end + GAP + widthOf(whole) <= cols - MARGIN ? whole : whole.map((h) => (h.short ? { ...h, key: h.short } : h));
422
440
  let kept = keys;
423
441
  // Given up from the end, the leader last (givenUp).
424
442
  while (kept.length && end + GAP + widthOf(kept) > cols - MARGIN) kept = givenUp(kept);
@@ -690,10 +708,58 @@ function terminalAt(m, size, g) {
690
708
  const both = Boolean(m.split) && !zoom && groups.length === 2 && splitFits(m.split, { cols: panel.cols, rows: panel.rows + 1 });
691
709
  const [first, second, rule] = both ? splitRegions(panel, m.split) : [panel, null, null];
692
710
  const regions = (both ? [{ ...first, group: 0 }, { ...second, group: 1 }] : [{ ...panel, group: focused }])
693
- .map((r) => ({ ...r, id: groups[r.group]?.shown ?? null, focused: r.group === focused, whole }));
711
+ .map((r) => waited({ ...r, id: groups[r.group]?.shown ?? null, focused: r.group === focused, whole }, groups[r.group]?.waiting ?? null, m.ascii));
694
712
  return { ...regions.find((r) => r.focused), panel, regions, rule };
695
713
  }
696
714
 
715
+ /** THE WAITING ROW (docs/tui.md, "Tabs"; awebai/oats#1502), under a group's tab bar while its
716
+ * shown agent has a live claim: `Needs input` in the list's needs-input look (reverse video in the
717
+ * waiting colour, a cell of padding each side), then the claim's age dim after a dot (` · `,
718
+ * ` - ` in ASCII), then its message, the agent's text through the shared filter, or, with none,
719
+ * the TUI's words for its reason. The age stands before the message, so no cut removes it. The
720
+ * message wraps to at most WAITING_ROWS rows and to no more than a quarter of the region's
721
+ * height, the last row ending in the cut mark when more was left. */
722
+ const WAITING_ROWS = 3;
723
+ /** The cells before the age: the tag with its padding, a blank, the dot and a blank. */
724
+ const WAITING_LEAD = NEEDS_INPUT.length + 2 + 3;
725
+ /** The widest age the shared words give (packages/client/waiting-on-you.mjs waitedText). */
726
+ const WAITING_AGE_WIDEST = "under a minute".length;
727
+ /** The waiting row's text as rows: the first after the lead and the age (`age` cells of it), every
728
+ * other from the region's second cell, each with a cell of margin at the end. */
729
+ function waitingLines(waiting, cols, rows, age, ascii) {
730
+ const max = Math.max(1, Math.min(WAITING_ROWS, Math.floor(rows / 4)));
731
+ // The TUI's words are its own, and pass the shared filter as they are.
732
+ return shownLines(waiting.message ?? waiting.words, cols - 2, max, { ascii, first: cols - WAITING_LEAD - age - 2 });
733
+ }
734
+ /** A region with its waiting rows taken from the top of the agent's screen: `waiting` the rows
735
+ * waitingRows draws, or null. How many is counted with the widest age, so the agent's pane is
736
+ * resized when the claim starts, clears or changes its text, and never as its age grows. */
737
+ function waited(region, waiting, ascii) {
738
+ if (waiting === null || region.id === null) return { ...region, waiting: null };
739
+ const taken = waitingLines(waiting, region.cols, region.rows, WAITING_AGE_WIDEST, ascii).length;
740
+ if (taken === 0) return { ...region, waiting: null };
741
+ return { ...region, top: region.top + taken, rows: region.rows - taken, waiting: { ...waiting, taken } };
742
+ }
743
+ /** The waiting rows of a region that has them (waited): `taken` rows, the first holding the tag
744
+ * and the age. Drawn with the region's own age; a shorter one than the widest leaves the message
745
+ * more room, never fewer rows than were taken: the rest stay blank. */
746
+ function waitingRows(region, ascii) {
747
+ const { waiting } = region, col = region.col, end = col + region.cols;
748
+ const dot = ascii ? "-" : "\u00b7";
749
+ const lines = waitingLines(waiting, region.cols, region.rows + waiting.taken, waiting.age.length, ascii).slice(0, waiting.taken);
750
+ const first = [
751
+ { col, width: NEEDS_INPUT.length + 2, style: WAITS }, { col: col + 1, text: lit(NEEDS_INPUT), style: WAITS, width: NEEDS_INPUT.length },
752
+ { col: col + NEEDS_INPUT.length + 3, text: lit(dot), style: DIM, width: 1 },
753
+ { col: col + NEEDS_INPUT.length + 5, text: lit(waiting.age), style: DIM, width: waiting.age.length },
754
+ ];
755
+ const at = col + WAITING_LEAD + waiting.age.length + 1;
756
+ return Array.from({ length: waiting.taken }, (_, i) => {
757
+ const line = lines[i], start = i === 0 ? at : col + 1;
758
+ const spans = line ? [{ col: start, text: line, width: Math.max(0, Math.min(textWidth(textOf(line)), end - start)) }] : [];
759
+ return i === 0 ? [...first, ...spans] : spans;
760
+ });
761
+ }
762
+
697
763
  /** A hidden tab's mark for output since it was last shown (docs/tui.md, "Tabs"). */
698
764
  const ACTIVITY = "\u2022";
699
765
  /** What stands between a tab's agent and its machine, another machine's: ` · ` (` - ` in ASCII). */
@@ -834,10 +900,11 @@ function regionRows(m, area) {
834
900
  // A model made by hand may name its terminal and no tabs: its one tab is that terminal.
835
901
  const tabs = group.tabs.length ? group.tabs : [{ name: m.terminal?.name, machine: m.terminal?.routed ? m.terminal.machine : null, shown: true, activity: false }];
836
902
  const title = stripRow(tabs, area, { focused, ascii: m.ascii, numbers: m.tabNumbers !== false });
903
+ const waiting = area.waiting ? waitingRows(area, m.ascii) : [];
837
904
  const screenOf = area.focused ? m.screen : m.screens?.get(group.shown) ?? null;
838
905
  const lines = screenOf?.lines ?? [];
839
906
  const body = Array.from({ length: area.rows }, (_, r) => (lines[r] ?? [])
840
907
  .filter((span) => span.col < area.cols)
841
908
  .map((span) => ({ ...span, col: area.col + span.col, width: Math.min(span.width ?? area.cols, area.cols - span.col) })));
842
- return [title, ...body];
909
+ return [title, ...waiting, ...body];
843
910
  }
@@ -39,6 +39,8 @@ export const NOT_YET = Object.freeze([
39
39
  Object.freeze({ what: "see a capability's skills and files", command: "oats capabilities show <name>" }),
40
40
  Object.freeze({ what: "open an agent in its own tmux window", command: "oats session attach --home <home>" }),
41
41
  Object.freeze({ what: "start with another harness or model", command: "oats session start --home <home>" }),
42
+ // The list places a background instance (#1579); moving one into or out of the background is the kernel's verb.
43
+ Object.freeze({ what: "move an instance into or out of the background", command: "oats instance background <name> on|off" }),
42
44
  Object.freeze({ what: "add a machine to this workspace", command: "oats server connect <id> --ssh <alias> --dir <path on that machine>" }),
43
45
  Object.freeze({ what: "check a machine", command: "oats server check <id>" }),
44
46
  Object.freeze({ what: "remove a machine", command: "oats server remove <id>" }),
@@ -112,10 +114,15 @@ function commandRows(command, at, cols) {
112
114
  * takes, what it does not do, and where the keys that can be the back key are listed (the help
113
115
  * does not restate the grammar). */
114
116
  export const OPEN_RULES = Object.freeze([
115
- "While the terminal has the focus every other key goes to the agent, Ctrl+C and Ctrl+Z too.",
116
- "Up to 4 terminals are open at a time, each a tab. They have no scrollback but the viewer's own, and no mouse.",
117
+ "While the terminal has the focus every key but its scroll keys goes to the agent, Ctrl+C and Ctrl+Z too.",
118
+ "Up to 4 terminals, as tabs, no mouse. Shift+PageUp or Ctrl+B [ (tmux 3.3+) scrolls back; PageUp, PageDown move, q leaves.",
117
119
  "docs/tui.md has the keys that can be the leader.",
118
120
  ]);
121
+ /** OPEN_RULES for a leader of Ctrl+B, which the TUI takes before the viewer reads it: Ctrl+B [
122
+ * cannot be typed into a terminal there, so the help does not name it. */
123
+ const OPEN_RULES_CTRL_B = Object.freeze(OPEN_RULES.map((sentence, i) => (i === 1 ? "Up to 4 terminals, as tabs, no mouse. Shift+PageUp scrolls back; PageUp, PageDown move, q leaves." : sentence)));
124
+ /** The rules for the leader `detachKey`. */
125
+ const openRulesFor = (detachKey) => (backKeyLabel(detachKey) === "Ctrl+B" ? OPEN_RULES_CTRL_B : OPEN_RULES);
119
126
  /** The rows under the line of `open`, in `room` cells: the leader then Esc, which takes the focus
120
127
  * from the open terminal, and the leader twice, which types it into the terminal (tui.json's
121
128
  * open.detachKey, text from outside), then OPEN_RULES, each sentence on as many rows as it needs. */
@@ -128,7 +135,7 @@ function openRows(detachKey, room, chorded = false) {
128
135
  return [
129
136
  ...pair(`${label} ${esc}`, "takes the focus from the terminal back to the list; the agent keeps running."),
130
137
  ...pair(`${label} ${label}`, "types the leader into the terminal."),
131
- ...[...OPEN_RULES, ...(chorded ? [CHORD_OPEN_RULE] : [])].flatMap((sentence) => flow(words(sentence), room).map((text) => [{ col: 0, text: lit(text) }])),
138
+ ...[...openRulesFor(detachKey), ...(chorded ? [CHORD_OPEN_RULE] : [])].flatMap((sentence) => flow(words(sentence), room).map((text) => [{ col: 0, text: lit(text) }])),
132
139
  ];
133
140
  }
134
141
  /** Under OPEN_RULES, while the chords are listed: they too are the TUI's in a terminal. */
@@ -7,7 +7,9 @@
7
7
  // and its name, and a word only where the mark can't say it. Children stand under their parent by
8
8
  // indentation alone; a folded row says how many it folds away, `+n`, and how many of those wait,
9
9
  // `N below`. In a view of two or more deployments the list also holds a heading per deployment
10
- // and the sentences the model sets under one: a heading says in words what it is of.
10
+ // and the sentences the model sets under one: a heading says in words what it is of. Last stands
11
+ // the Background section's heading (#1579), which can be selected: its chevron says whether the
12
+ // section is open, and the needs-input tag whether a row in it waits.
11
13
  import { keyLabel } from "../actions.mjs";
12
14
  import { lit, shown, shownEnd, textOf } from "../term/text.mjs";
13
15
  import { COLORS, style } from "../term/style.mjs";
@@ -21,6 +23,11 @@ export const MARKS = Object.freeze({
21
23
  utf8: Object.freeze({ running: "●", stopped: "○", shell: "◌", unknown: "?", held: "◆", selected: ">", waiting: "!" }),
22
24
  ascii: Object.freeze({ running: "*", stopped: "-", shell: "~", unknown: "?", held: "#", selected: ">", waiting: "!" }),
23
25
  });
26
+ /** The Background heading's chevron (#1579), open and closed, in UTF-8 and in ASCII: no state's mark. */
27
+ export const CHEVRONS = Object.freeze({
28
+ utf8: Object.freeze({ open: "▾", closed: "▸" }),
29
+ ascii: Object.freeze({ open: "v", closed: ">" }),
30
+ });
24
31
  export const marksOf = (ascii) => (ascii ? MARKS.ascii : MARKS.utf8);
25
32
 
26
33
  /** Two cells of indent per level, and no deeper than this many levels: a deeper row sits at the last. */
@@ -53,6 +60,7 @@ const PLAIN = style();
53
60
  const BOLD = style({ bold: true });
54
61
  const DIM = style({ dim: true });
55
62
  const SELECTED = style({ reverse: true });
63
+ const SELECTED_BOLD = style({ reverse: true, bold: true });
56
64
  /** The look of each state mark: the Souls view draws an instance's mark in its detail as the list does.
57
65
  * No state is yellow: yellow says needs input, and only that. */
58
66
  export const LOOK = Object.freeze({ running: style({ fg: "green" }), stopped: DIM, shell: DIM, unknown: DIM, held: style({ fg: "magenta" }) });
@@ -78,12 +86,13 @@ export function markLook(mark, colour) {
78
86
  * one cell), so the reverse video and the `!` carry it under NO_COLOR. On the selected row, which
79
87
  * is in reverse already, it is the other way round: not reversed, a gap in the selection's bar.
80
88
  * An instance's colour never draws it. */
81
- const WAITS = style({ fg: "yellow", bold: true, reverse: true });
89
+ export const WAITS = style({ fg: "yellow", bold: true, reverse: true });
82
90
  const WAITS_SELECTED = style({ fg: "yellow", bold: true });
83
91
 
84
92
  /** The words for an instance that needs input: the shared home's for a claim that names no reason
85
93
  * of its own (packages/client/waiting-on-you.mjs, waitingLabel, which the detail says; a test pins
86
- * them equal), and the help's for the mark. A row says them by its mark, not in words. */
94
+ * them equal), the help's for the mark, and the waiting row's (views/frame.mjs). A list row says
95
+ * them by its mark, not in words. */
87
96
  export const NEEDS_INPUT = "Needs input";
88
97
  /** The roll-up tag's words, the Desktop's (packages/desktop/renderer/shell.mjs, needsInputMark; a
89
98
  * test pins them equal): `N below` on a row that folds away N waiting rows, `99+ below` past 99,
@@ -164,6 +173,34 @@ function instanceRow(row, cols, wordWidth, marks) {
164
173
  return spans;
165
174
  }
166
175
 
176
+ /** The Background section's heading (#1579). */
177
+ export const BACKGROUND = "Background";
178
+ /** The Background section's heading in a pane `cols` wide (lib/model.mjs backgroundRow): its chevron in
179
+ * the mark's column, open or closed, the word in bold where a row's name stands, as a machine's heading
180
+ * is bold, and how many rows the section holds, dim. While a row in it waits, open or closed, the
181
+ * needs-input tag stands at the edge in the roll-up's look, `Needs input` and no time, where the word
182
+ * and the count fit beside it, else the needs-input mark alone in the cells every row keeps. Selected,
183
+ * it is in reverse video with `>`, as a row is. */
184
+ function backgroundRow(item, cols, marks, chevrons) {
185
+ const spans = [], count = String(item.count);
186
+ const whole = BACKGROUND.length + GAP + count.length;
187
+ const tag = item.waiting ? (cols - NEEDS_INPUT.length - 3 - LEAD >= whole ? NEEDS_INPUT : marks.waiting) : null;
188
+ const end = tag === NEEDS_INPUT ? cols - NEEDS_INPUT.length - 3 : cols - EDGE;
189
+ if (item.selected) spans.push({ col: 0, width: cols, style: SELECTED });
190
+ if (item.selected && item.cursor !== false) spans.push({ col: 0, text: lit(marks.selected), style: SELECTED, width: 1 });
191
+ spans.push({ col: MARK, text: lit(item.open ? chevrons.open : chevrons.closed), style: item.selected ? SELECTED_BOLD : BOLD, width: 1 });
192
+ const word = Math.max(0, Math.min(BACKGROUND.length, end - LEAD));
193
+ if (word) spans.push({ col: LEAD, text: lit(BACKGROUND), style: item.selected ? SELECTED_BOLD : BOLD, width: word });
194
+ // The count whole or not at all: a cut number says another.
195
+ const at = LEAD + BACKGROUND.length + GAP;
196
+ if (at + count.length <= end) spans.push({ col: at, text: lit(count), style: item.selected ? SELECTED : DIM, width: count.length });
197
+ if (tag !== null) {
198
+ const look = item.selected ? WAITS_SELECTED : WAITS, col = cols - tag.length - 2;
199
+ if (col > MARK) spans.push({ col, width: tag.length + 2, style: look }, { col: col + 1, text: lit(tag), style: look, width: tag.length });
200
+ }
201
+ return spans;
202
+ }
203
+
167
204
  /** A deployment's heading in a pane `cols` wide: its label in bold, its path, and, when it is not
168
205
  * live, the shared word for its state and the short reason; at the right edge the time a machine
169
206
  * reported its rows at. The state and the time always stand. When the row is too narrow for the
@@ -233,6 +270,7 @@ export function instances(m, size) {
233
270
  else if (item.own) rows[i] = [{ col: SENTENCE_INDENT, text: lit(item.own), style: DIM, width: sentence }];
234
271
  else if (item.empty === "none") rows[i] = noneRow(m, aside);
235
272
  else if (item.empty) rows[i] = [{ col: SENTENCE_INDENT, text: lit(EMPTY_TEXT[item.empty]), style: DIM, width: aside }];
273
+ else if (item.kind === "background") rows[i] = backgroundRow(item, size.cols, marks, m.ascii ? CHEVRONS.ascii : CHEVRONS.utf8);
236
274
  else rows[i] = instanceRow(item, size.cols, m.wordWidth, marks);
237
275
  });
238
276
  const note = cutNote(m.above, m.below);
@@ -24,6 +24,17 @@ repositories belong to an organisation and which packages it trusts. A
24
24
  work, in its own home and terminal. Each workspace has a setup expert soul,
25
25
  `<workspace>-oats-setup-expert`, which holds the `oats.setup` capability.
26
26
 
27
+ **A machine found-list.** Your prompt may hand you a found-list, a JSON file
28
+ whose `machine.platform` is set (oats-omarchy's installer writes one). Then
29
+ the workspace you make is this machine's own workspace. Its setup soul is
30
+ the machine's steward, `oats.machine/steward`, in place of a setup expert
31
+ soul of its own, and the steward gets a global aweb address. Steps 1, 5, 6
32
+ and 7 say what changes. When the found-list lists a deployment whose
33
+ `steward` is `true`, this machine already has its workspace and steward:
34
+ tell the person so, and stop. Wherever a later step says to ask the
35
+ person, on a machine found-list you tell them what happened, as it is, and
36
+ stop instead: the person answers nothing after step 1.
37
+
27
38
  **How to work.**
28
39
  - **Ask first, then run.** Ask everything in one round (step 1), then run the
29
40
  steps yourself and read back what each did.
@@ -68,6 +79,8 @@ work, in its own home and terminal. Each workspace has a setup expert soul,
68
79
 
69
80
  ## 1. Ask, in one round
70
81
 
82
+ On a machine found-list, ask the machine's round below instead of this list.
83
+
71
84
  - **The use case:** what they want agents to do.
72
85
  - **Their repositories and project:** which repositories agents should work
73
86
  in, where they are cloned on this machine, and which are private.
@@ -103,6 +116,32 @@ work, in its own home and terminal. Each workspace has a setup expert soul,
103
116
  - **OATS Desktop:** installed and started unless they decline. **The TUI**
104
117
  (`oats tui`, a terminal client, preview): opened for them or not.
105
118
 
119
+ **The machine's round.** Read the found-list, then ask only these choices,
120
+ together, each with its default and one line on what it is. Enter, or
121
+ "yes", accepts every default. Nothing is asked after this round, and never
122
+ a key. The use case, repositories and knowledge tools are not asked: the
123
+ steward takes them up with the person later.
124
+ - **The workspace:** a new one, the machine's own. Its name defaults to the
125
+ hostname, lowercased, with every character outside `[a-z0-9-]` turned
126
+ into `-` (`Ada's-Laptop` gives `ada-s-laptop`). Its repository defaults to
127
+ `<github.login>/<workspace>-oats`, private. Or an existing workspace's
128
+ reference.
129
+ - **The namespace `N`:** the part of every agent's address before the `/`,
130
+ which other people's agents use to reach this machine's agents. Default:
131
+ the hostname, normalised as above, so the namespace is the machine's own. Messaging is
132
+ on, and the root's name `A` is `<workspace>-root`.
133
+ - **The steward's name:** lowercase letters and digits, words joined by
134
+ single `-`. Default: `steward`. It gives `R`, the steward's instance name
135
+ here and the name in its address, `N.aweb.ai/R`. `R` is the chosen name,
136
+ or `<hostname>-<chosen name>` (the hostname normalised as above) when the
137
+ person says `N` is a namespace another machine already uses, so that this
138
+ machine never adopts the other machine's resident.
139
+ - **The deployment directory `D`:** default `<home>/Agents/<workspace>`,
140
+ with the home folder spelled out.
141
+ - **OATS Desktop:** installed and started by default; the TUI not opened.
142
+ - **The harness:** the found-list's `harness`. Ask only when it names none,
143
+ with the one you are as the default.
144
+
106
145
  ## 2. Check, and install what is missing
107
146
 
108
147
  ```bash
@@ -311,8 +350,9 @@ name: acme
311
350
  members:
312
351
  - git:github.com/acme/acme-oats # the host is a member too
313
352
  packages:
314
- oats.framework: v1.14.1 # the installed CLI's catalog versions (below)
315
- oats.aweb: v1.31.0 # messaging, and tasks: agent identities, mail, chat and tasks
353
+ oats.framework: v1.16.1 # the installed CLI's catalog versions (below)
354
+ oats.aweb: v1.32.0 # messaging, and tasks: agent identities, mail, chat and tasks
355
+ oats.machine: v0.1.1 # on a machine found-list only: the machine's steward
316
356
  defaults:
317
357
  capabilities:
318
358
  oats.core: { from: package }
@@ -325,11 +365,15 @@ defaultTeam: acme # every soul starts in this team
325
365
 
326
366
  - **The versions** are the installed CLI's catalog's:
327
367
  `"$(oats root)/package-catalog.json"`, `packages."oats.framework".ref`
328
- (for example `oats-framework/v1.14.1`: write the part after the `/`) and
368
+ (for example `oats-framework/v1.16.1`: write the part after the `/`) and
329
369
  `packages."oats.aweb".ref`, but never below `v1.31.0`: that release
330
370
  carries `oats.aweb-tasks`, and a bare version resolves through the
331
371
  catalog's tag convention even when the installed catalog names an older
332
372
  one.
373
+ - **On a machine found-list only,** keep the `oats.machine` line, at the
374
+ catalog's `packages."oats.machine".ref`, and write none of the
375
+ `souls/<workspace>-oats-setup-expert` files below: the steward is the
376
+ workspace's setup soul. Elsewhere, leave the line out.
333
377
  - **The team** is `default:N.aweb.ai`, with `N` the username from step 1;
334
378
  its label (here `acme`) is the workspace name.
335
379
  - **Tasks** use aweb, the same identities as messaging: agents assign,
@@ -454,6 +498,9 @@ oats onboard D --workspace W
454
498
  - **Before 0.61.0,** read `oats souls --dir D --json`: the soul named
455
499
  `<workspace>-oats-setup-expert`, else one whose definition declares
456
500
  `oats.setup`.
501
+ - **On a machine found-list,** `S` is `oats.machine/steward`. An existing
502
+ workspace that doesn't offer it: stop, and say that its owner adds
503
+ `oats.machine` to its `packages:`.
457
504
  - **An existing workspace with no such soul:** stop. Show the person the soul
458
505
  files from step 5 and say that the workspace's owner adds them by pull
459
506
  request to its host repository. Once that is merged, run
@@ -464,6 +511,15 @@ at `D/<repo name>`. A new workspace already has it (step 5). For an existing
464
511
  one, clone the repository that holds `S` with the `git clone` line
465
512
  `oats onboard` printed for it, if that line says it is missing.
466
513
 
514
+ **On a machine found-list, record the steward's harness** on this machine
515
+ first. Its soul names none, and without this every later check (readiness,
516
+ harness trust) and the spawn would use the default, pi:
517
+
518
+ ```bash
519
+ oats soul launch set S --harness <harness> --dir D --plan
520
+ oats soul launch set S --harness <harness> --dir D
521
+ ```
522
+
467
523
  ## 7. Hand over to the setup expert
468
524
 
469
525
  **Messaging on this machine first, when the setup expert takes it.** Read
@@ -497,6 +553,8 @@ can't spawn on this machine until it has messaging too. Set it up now:
497
553
  `D/<repo>` change the team id in `oats-workspace.yaml` to
498
554
  `default:N.aweb.ai`, commit and push it, run `oats sync --dir D`, and run
499
555
  both lines again. Then skip items 3 and 4 and go to the check (item 5).
556
+ On a machine found-list, ask nothing: tell the person that the run
557
+ failed, most likely because `N` is taken, and stop.
500
558
  3. **Existing workspace: the person gets an invite token** from a member of `L`, who runs
501
559
  `oats aweb invite --soul <their soul> --label L --json` in their own
502
560
  deployment and passes the token to the person privately, never by
@@ -521,6 +579,48 @@ can't spawn on this machine until it has messaging too. Set it up now:
521
579
  The setup expert does the rest of this machine's messaging
522
580
  (`/oats-host-delivery`).
523
581
 
582
+ **The steward's global address (machine found-list only).** The steward
583
+ gets a global, contacts-only aweb address, `<namespace>/R`, made by the
584
+ team root you just signed up, with no API key and nothing for the person to
585
+ type. `R` is the steward's name from step 1, for the resident and the
586
+ instance alike.
587
+
588
+ Without messaging there is no address to make: skip this. Otherwise it
589
+ needs every one of these, and when one fails, take the fallback below:
590
+ - a new workspace: a root that joined by invite (items 3 and 4) does not own
591
+ the namespace, so aweb would refuse the create;
592
+ - `oats.aweb` 1.33.0 or later: the `oats.aweb` row of the
593
+ `oats inspect` you read above, `result.capabilities[].version`;
594
+ - aw 1.36.48 or later: `aw.version` in the check (item 5).
595
+
596
+ Plan, then create, both from `D` and with no `AWEB_API_KEY`:
597
+
598
+ ```bash
599
+ cd "D" && env -u AWEB_API_KEY oats aweb resident create R --team-label L --plan --json
600
+ cd "D" && env -u AWEB_API_KEY oats aweb resident create R --team-label L --json
601
+ ```
602
+
603
+ - **The plan** changes nothing. Run the create only when the plan's `ok` is
604
+ true and either `result.init.route` is `root` (a new resident) or
605
+ `result.init` is `null` (`R` already holds it; the create adopts it and
606
+ never makes a second one). Anything else, a refusal included (no team
607
+ root, say), is the fallback.
608
+ - **`--team-label L`** puts the resident in the team that is already the
609
+ default, so the run maps nothing new and prints the spawn line as its one
610
+ step (`result.steps`). If it prints another step first, stop and tell the
611
+ person what it says: that step is theirs.
612
+ - **Success** prints `PASS resident <address> …`, and `result.address` is
613
+ the steward's address. Spawn with the grant-seat options below.
614
+ - **A failure** is reported to the person as it is, and you spawn nothing.
615
+ If the create was interrupted (killed, or timed out with no answer), run
616
+ the same line again, unchanged, and nothing else. Never empty
617
+ `D/.aweb-residents/R`: the identity may already exist.
618
+ - **The fallback:** spawn the steward without the grant-seat options. It gets
619
+ a local team identity, as every instance does. Tell the person in one line,
620
+ without asking anything: the steward has a local team identity and no
621
+ global address because of <the reason>, and the GLOBAL residents and grant
622
+ seats section of `/oats-aweb` moves it to one later. Never ask for a key.
623
+
524
624
  **Write the hand-over** to `D/.oats-handover.md`. It holds no secret.
525
625
 
526
626
  ```markdown
@@ -528,6 +628,8 @@ The setup expert does the rest of this machine's messaging
528
628
 
529
629
  - Workspace: <workspace> (W), new | existing; deployment directory: D
530
630
  - Setup expert: S, harness <harness>
631
+ - Machine found-list only: steward R, address N.aweb.ai/R | local team
632
+ identity (<the fallback's reason>)
531
633
 
532
634
  ## The person's answers
533
635
  <step 1's answers, in their words: use case, repositories and where they
@@ -567,6 +669,16 @@ oats spawn S --dir D --task-file D/.oats-handover.md --preview
567
669
  oats spawn S --dir D --task-file D/.oats-handover.md
568
670
  ```
569
671
 
672
+ **On a machine found-list,** name the steward `R` (its harness was recorded
673
+ in step 6). With its global address:
674
+
675
+ ```bash
676
+ oats spawn S --dir D --task-file D/.oats-handover.md --name R --provider oats.aweb identity.mode=global --provider oats.aweb identity.resident=R --preview
677
+ oats spawn S --dir D --task-file D/.oats-handover.md --name R --provider oats.aweb identity.mode=global --provider oats.aweb identity.resident=R
678
+ ```
679
+
680
+ In the fallback, or without messaging, leave out both `--provider` options.
681
+
570
682
  - **The preview** shows what the spawn would create. If it reports a
571
683
  problem, stop and tell the person what it says.
572
684
  - **The spawn** prints the instance's home `H`. Then delete the hand-over
@@ -600,7 +712,8 @@ oats spawn S --dir D --task-file D/.oats-handover.md
600
712
  their own terminal, as "How to work" says, with the command
601
713
  `oats tui --dir "D"`.
602
714
 
603
- **Tell the person where the setup expert is**, and that it continues from
715
+ **Tell the person where the setup expert is** (on a machine found-list, the
716
+ steward, and its address), and that it continues from
604
717
  here: in the Desktop or the TUI you started. Without either, they reach it
605
718
  with `oats session attach --home H` in a terminal.
606
719