@awebai/oats 0.50.0 → 0.52.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.
Files changed (132) hide show
  1. package/README.md +1 -0
  2. package/bin/oats.mjs +153 -51
  3. package/docs/capabilities.md +11 -3
  4. package/docs/configuration.md +134 -88
  5. package/docs/desktop-cli-api.md +994 -71
  6. package/docs/desktop-instance-start.md +56 -0
  7. package/docs/desktop.md +10 -7
  8. package/docs/execution-targets.md +230 -59
  9. package/docs/first-team.md +3 -1
  10. package/docs/harness-trust.md +50 -2
  11. package/docs/implementation.md +73 -8
  12. package/docs/integrations.md +9 -8
  13. package/docs/knowledge-reference/acceptance.md +1 -0
  14. package/docs/knowledge-reference/harvester.md +5 -3
  15. package/docs/knowledge-reference/model.md +5 -3
  16. package/docs/knowledge-theory.md +1 -1
  17. package/docs/knowledge.md +43 -7
  18. package/docs/launch-prompt-completion.md +50 -48
  19. package/docs/oats-local.schema.json +4 -3
  20. package/docs/official-catalog.md +4 -4
  21. package/docs/packages.md +14 -14
  22. package/docs/release-lane.md +15 -5
  23. package/docs/release-notes/v0.44.0.md +1 -1
  24. package/docs/release-notes/v0.51.0.md +156 -0
  25. package/docs/release-notes/v0.52.0.md +933 -0
  26. package/docs/schedules.md +91 -4
  27. package/docs/servers.md +21 -2
  28. package/docs/souls-and-instances.md +113 -21
  29. package/docs/tui.md +152 -0
  30. package/docs/workspaces.md +2 -2
  31. package/lib/claim.mjs +266 -0
  32. package/lib/core.mjs +845 -166
  33. package/lib/errors.mjs +170 -0
  34. package/lib/harness-trust-write.mjs +68 -27
  35. package/lib/harness-trust.mjs +34 -16
  36. package/lib/instance-inspect.mjs +40 -11
  37. package/lib/instance-lifecycle.mjs +169 -47
  38. package/lib/launch-preference.mjs +16 -0
  39. package/lib/launch-prompt-completion.mjs +7 -43
  40. package/lib/launch-prompt-evidence.mjs +14 -7
  41. package/lib/launch-prompt-fixtures/README.md +86 -152
  42. package/lib/launch-prompt-fixtures/dev-channel-confirmation.json +50 -0
  43. package/lib/launch-prompt-fixtures.mjs +122 -109
  44. package/lib/launch-prompt-transport.mjs +2 -56
  45. package/lib/launch-prompts.mjs +102 -100
  46. package/lib/schedule-host.mjs +154 -22
  47. package/lib/schedule.mjs +73 -24
  48. package/lib/servers.mjs +20 -4
  49. package/lib/session-viewer.mjs +87 -10
  50. package/lib/system-tools.mjs +39 -0
  51. package/lib/tmux-server-scope.mjs +62 -0
  52. package/lib/triggers.mjs +4 -4
  53. package/lib/workspace.mjs +5 -11
  54. package/lib/worktree-hooks.mjs +116 -23
  55. package/lib/worktree.mjs +89 -102
  56. package/package-catalog.json +3 -3
  57. package/package.json +7 -2
  58. package/packages/client/capability-show-contract.mjs +230 -0
  59. package/packages/client/capability-warnings-contract.mjs +57 -0
  60. package/packages/client/cli-adapter.mjs +548 -0
  61. package/packages/client/cli-environment.mjs +53 -0
  62. package/packages/client/cli-locator.mjs +253 -0
  63. package/packages/client/cli-probe-contract.mjs +47 -0
  64. package/packages/client/client-terms.mjs +60 -0
  65. package/packages/client/deployment-contract.mjs +68 -0
  66. package/packages/client/deployment-data.mjs +483 -0
  67. package/packages/client/deployment-facts.mjs +34 -0
  68. package/packages/client/deployment-label.mjs +76 -0
  69. package/packages/client/deployment-observer.mjs +89 -0
  70. package/packages/client/deployment-panel.mjs +142 -0
  71. package/packages/client/deployment-read-cli.mjs +53 -0
  72. package/packages/client/display-text.mjs +44 -0
  73. package/packages/client/harness-names.mjs +30 -0
  74. package/packages/client/inspect-contract.mjs +62 -0
  75. package/packages/client/instance-acts.mjs +54 -0
  76. package/packages/client/instance-admission.mjs +45 -0
  77. package/packages/client/instance-events-contract.mjs +74 -0
  78. package/packages/client/instance-git-contract.mjs +80 -0
  79. package/packages/client/instance-presentation.mjs +22 -0
  80. package/packages/client/instance-tree.mjs +453 -0
  81. package/packages/client/kernel-environment.mjs +11 -0
  82. package/packages/client/launch-contract.mjs +51 -0
  83. package/packages/client/launch-prompt-outcome.mjs +165 -0
  84. package/packages/client/lifecycle-cli.mjs +61 -0
  85. package/packages/client/lifecycle-contract.mjs +372 -0
  86. package/packages/client/liveness-main.mjs +10 -0
  87. package/packages/client/liveness.mjs +35 -0
  88. package/packages/client/machine-contract.mjs +123 -0
  89. package/packages/client/own-environment.mjs +22 -0
  90. package/packages/client/panel-views.mjs +286 -0
  91. package/packages/client/readiness-contract.mjs +172 -0
  92. package/packages/client/refresh-loop.mjs +52 -0
  93. package/packages/client/remote-address.mjs +126 -0
  94. package/packages/client/remote-roster.mjs +67 -0
  95. package/packages/client/roster-sections.mjs +80 -0
  96. package/packages/client/spawn-apply-cli.mjs +104 -0
  97. package/packages/client/spawn-apply-contract.mjs +183 -0
  98. package/packages/client/spawn-decision.mjs +46 -0
  99. package/packages/client/spawn-messages.mjs +119 -0
  100. package/packages/client/spawn-preview-cli.mjs +32 -0
  101. package/packages/client/spawn-preview-contract.mjs +314 -0
  102. package/packages/client/team-members.mjs +41 -0
  103. package/packages/client/team-rows.mjs +45 -0
  104. package/packages/client/terminal-contract.mjs +57 -0
  105. package/packages/client/tmux-status.mjs +66 -0
  106. package/packages/client/waiting-on-you.mjs +88 -0
  107. package/packages/client/workspace-admission.mjs +45 -0
  108. package/packages/client/workspace-cli.mjs +142 -0
  109. package/packages/client/workspace-views.mjs +147 -0
  110. package/packages/tui/README.md +46 -0
  111. package/packages/tui/bin/tui.mjs +7 -0
  112. package/packages/tui/lib/actions.mjs +29 -0
  113. package/packages/tui/lib/client.mjs +4 -0
  114. package/packages/tui/lib/main.mjs +105 -0
  115. package/packages/tui/lib/term/keys.mjs +323 -0
  116. package/packages/tui/lib/term/screen.mjs +122 -0
  117. package/packages/tui/lib/term/style.mjs +43 -0
  118. package/packages/tui/lib/term/text.mjs +49 -0
  119. package/packages/tui/lib/term/tty.mjs +168 -0
  120. package/packages/tui/lib/term/width.mjs +124 -0
  121. package/packages/tui/lib/views/frame.mjs +62 -0
  122. package/packages/tui/lib/views/help.mjs +28 -0
  123. package/packages/tui/package.json +8 -0
  124. package/skills/oats-getting-started/SKILL.md +29 -22
  125. package/lib/launch-prompt-fixtures/claude-2.1.289-darwin-arm64/frame-05-channel-seeded.txt +0 -35
  126. package/lib/launch-prompt-fixtures/claude-2.1.289-darwin-arm64/frame-06-first-after-channel.txt +0 -35
  127. package/lib/launch-prompt-fixtures/claude-2.1.289-darwin-arm64/frame-07-after-channel-200ms.txt +0 -35
  128. package/lib/launch-prompt-fixtures/claude-2.1.289-darwin-arm64/frame-08-installed-after-channel-200ms.txt +0 -35
  129. package/lib/launch-prompt-fixtures/claude-2.1.289-darwin-arm64/manifest.json +0 -77
  130. package/lib/launch-prompt-fixtures/claude-2.1.289-darwin-arm64/max-bypass-source.json +0 -88
  131. package/lib/launch-prompt-fixtures/structural-completion.json +0 -205
  132. package/lib/launch-prompt-policy.mjs +0 -87
@@ -0,0 +1,168 @@
1
+ // The guard: everything the TUI changes in the terminal, and the promise that it is put back.
2
+ // With term/screen.mjs it is the only module that produces an ESC byte. docs/tui.md lists the
3
+ // changes for operators; ENTER and LEAVE below are that list, and nothing else is ever switched on:
4
+ // no mouse or focus reporting, no keyboard protocol, no keypad or cursor-key mode, no title, no
5
+ // clipboard, no bell, no query that expects a reply.
6
+ //
7
+ // Handing the terminal to someone else (the shell at a suspend; a viewer in later versions) is
8
+ // leave() and enter(), and only that pair.
9
+
10
+ const mode = (number, on) => `\x1b[?${number}${on ? "h" : "l"}`;
11
+ /** After raw mode: the alternate screen, the cursor hidden, autowrap off, bracketed paste on.
12
+ * Autowrap is off so no row wraps where the terminal and width.mjs disagree about a character (a
13
+ * wrap on the last row would scroll the screen). Bracketed paste is on so pasted text arrives
14
+ * marked as a paste, not as keys. */
15
+ export const ENTER = mode(1049, true) + mode(25, false) + mode(7, false) + mode(2004, true);
16
+ /** The reverse, with the style reset; then raw mode off. */
17
+ export const LEAVE = mode(2004, false) + mode(7, true) + "\x1b[0m" + mode(25, true) + mode(1049, false);
18
+
19
+ /** 128 + the signal's number, as a shell reports a process the signal ended. */
20
+ export const SIGNAL_STATUS = Object.freeze({ SIGINT: 130, SIGTERM: 143, SIGHUP: 129, SIGQUIT: 131 });
21
+ /** The terminal went away with no signal (stdin ended, a write failed): as SIGHUP. */
22
+ export const TERMINAL_GONE_STATUS = SIGNAL_STATUS.SIGHUP;
23
+ /** How long a suspend waits for the stop before it concludes there was none. */
24
+ const STOP_GRACE_MS = 100;
25
+
26
+ /** A terminal on both ends that can be addressed: no escape byte is ever written to anything else. */
27
+ export function isTerminal({ stdin, stdout, env }) {
28
+ return stdin.isTTY === true && stdout.isTTY === true && typeof env.TERM === "string" && env.TERM !== "" && env.TERM !== "dumb";
29
+ }
30
+
31
+ /** The guard of one run. `frame()` answers the bytes of the newest frame when it is time to write
32
+ * one; `onInput(bytes)`, `onResize()` and `onRedraw()` (the screen must be drawn in full: after a
33
+ * suspend, after SIGCONT) are the events. `done` resolves once, with `{ status, error }`, after the
34
+ * terminal is restored and every listener is removed. */
35
+ export function createGuard({ stdin, stdout, proc, frame, onInput, onResize, onRedraw, setTimer = setTimeout, clearTimer = clearTimeout }) {
36
+ let entered = false, raw = false, modes = false;
37
+ let suspended = false, stopTimer = null;
38
+ let over = false, blocked = false, stale = false;
39
+ let settle;
40
+ const done = new Promise((resolve) => { settle = resolve; });
41
+ const listeners = [];
42
+ const on = (emitter, name, listener) => { emitter.on(name, listener); listeners.push([emitter, name, listener]); };
43
+ /** A terminal that is gone cannot be restored, and saying so helps nobody. */
44
+ const quietly = (act) => { try { act(); } catch { /* gone */ } };
45
+
46
+ /** Raw mode, then the modes. Each step is recorded before it is taken, so leave() undoes exactly
47
+ * what was done, whenever it is called. */
48
+ function enter() {
49
+ if (over || entered) return;
50
+ entered = true;
51
+ raw = true;
52
+ stdin.setRawMode(true);
53
+ if (!entered) return; // left while entering: nothing more is switched on
54
+ modes = true;
55
+ stdout.write(ENTER);
56
+ }
57
+ /** Put the terminal back. Idempotent; never throws. */
58
+ function leave() {
59
+ if (!entered) return;
60
+ entered = false;
61
+ if (modes) { modes = false; quietly(() => stdout.write(LEAVE)); }
62
+ if (raw) { raw = false; quietly(() => stdin.setRawMode(false)); }
63
+ }
64
+
65
+ /** The end of the run, by any way out: restore, stop listening, report once. */
66
+ function finish(status, error) {
67
+ if (over) return;
68
+ over = true;
69
+ leave();
70
+ if (stopTimer !== null) { clearTimer(stopTimer); stopTimer = null; }
71
+ for (const [emitter, name, listener] of listeners) emitter.removeListener(name, listener);
72
+ proc.removeListener("SIGTSTP", suspend);
73
+ quietly(() => stdin.pause());
74
+ settle({ status, error });
75
+ }
76
+
77
+ /** Run one of the loop's own steps. What it throws ends the run as an uncaught error would,
78
+ * without waiting for the process to say so. */
79
+ function attempt(step) {
80
+ try { step(); } catch (error) { finish(1, error); }
81
+ }
82
+
83
+ /** One write per frame. While the last write has not drained nothing is queued: the newest frame
84
+ * is made when it has. */
85
+ function draw() {
86
+ if (!entered || over) return;
87
+ if (blocked) { stale = true; return; }
88
+ const bytes = frame();
89
+ if (bytes && stdout.write(bytes) === false) blocked = true;
90
+ }
91
+ function drained() {
92
+ blocked = false;
93
+ if (stale) { stale = false; attempt(draw); }
94
+ }
95
+
96
+ /** Ctrl+Z, or SIGTSTP from outside: hand the terminal back, then stop as a cooked-mode program is
97
+ * stopped. In raw mode the terminal sends the byte, not the signal, so the TUI sends what the
98
+ * terminal would have: SIGTSTP to the whole foreground process group. A wrapper that did not
99
+ * exec (`sh -c`, `npx`) stops with it, and the shell sees a stopped job. */
100
+ function suspend() {
101
+ if (!entered || over) return;
102
+ leave();
103
+ suspended = true;
104
+ proc.removeListener("SIGTSTP", suspend); // the default action stops the process
105
+ quietly(() => proc.kill(0, "SIGTSTP"));
106
+ // Stopped, this timer fires only once the process is continued. Not stopped (SIGTSTP ignored,
107
+ // an orphaned process group), nothing would ever send SIGCONT: it brings the screen back.
108
+ stopTimer = setTimer(resume, STOP_GRACE_MS);
109
+ }
110
+ function resume() {
111
+ if (!suspended || over) return;
112
+ suspended = false;
113
+ if (stopTimer !== null) { clearTimer(stopTimer); stopTimer = null; }
114
+ proc.on("SIGTSTP", suspend);
115
+ try { enter(); } catch { return finish(TERMINAL_GONE_STATUS); }
116
+ attempt(onRedraw);
117
+ }
118
+ /** Take the terminal again where it may no longer be as enter() left it: something outside the
119
+ * program reset it (a shell while the process was stopped, a `reset` typed elsewhere, the
120
+ * multiplexer). Node does nothing when asked for the raw mode it believes it is in, so raw goes
121
+ * off and on; then the modes, then a full redraw. This is what Ctrl+L asks for: a redraw that
122
+ * left bracketed paste off would let a paste act as keys.
123
+ * The modes are written as LEAVE and then ENTER, in one write: the pair a suspend and a resume
124
+ * write. Entering the alternate screen also saves the cursor, and a terminal that is still on
125
+ * it may take a second entry as a new save, over the shell's position: the prompt would then
126
+ * land on the wrong row at the end. Leaving first puts back the cursor the first entry saved,
127
+ * so the second saves the same one. On a terminal that was reset, the leave changes nothing. */
128
+ function reassert() {
129
+ if (!entered || over) return;
130
+ quietly(() => { stdin.setRawMode(false); stdin.setRawMode(true); });
131
+ quietly(() => stdout.write(LEAVE + ENTER));
132
+ attempt(onRedraw);
133
+ }
134
+ /** SIGCONT. After our own suspend: come back. Otherwise the process was stopped and continued
135
+ * from outside while it held the terminal. */
136
+ function continued() {
137
+ if (over) return;
138
+ if (suspended) return resume();
139
+ reassert();
140
+ }
141
+
142
+ /** Every way out is registered before the terminal is touched; then enter. A signal cannot land
143
+ * inside enter(), which is synchronous, and one that lands after it finds its listener. */
144
+ function start() {
145
+ for (const [signal, status] of Object.entries(SIGNAL_STATUS)) on(proc, signal, () => finish(status));
146
+ on(proc, "SIGCONT", continued);
147
+ proc.on("SIGTSTP", suspend);
148
+ on(proc, "uncaughtException", (error) => finish(1, error));
149
+ on(proc, "unhandledRejection", (reason) => finish(1, reason));
150
+ on(proc, "exit", leave); // the last resort: a process.exit() nobody expected
151
+ // A dead terminal answers a write or a read with an error event. These two listeners are never
152
+ // removed: the write that restores the terminal can fail after the run is over, and an error
153
+ // event nobody hears is an uncaught exception, which would turn the status into 1.
154
+ for (const stream of [stdin, stdout]) stream.on("error", () => finish(TERMINAL_GONE_STATUS));
155
+ on(stdin, "end", () => finish(TERMINAL_GONE_STATUS));
156
+ on(stdin, "close", () => finish(TERMINAL_GONE_STATUS));
157
+ on(stdin, "data", (bytes) => { if (entered) attempt(() => onInput(bytes)); });
158
+ on(stdout, "resize", () => { if (entered) attempt(onResize); });
159
+ on(stdout, "drain", drained);
160
+ try { enter(); } catch (error) { return finish(1, error); }
161
+ if (!over) stdin.resume();
162
+ }
163
+
164
+ /** The terminal's size now; 80x24 when the terminal does not say. */
165
+ const size = () => ({ cols: Number.isInteger(stdout.columns) && stdout.columns > 0 ? stdout.columns : 80, rows: Number.isInteger(stdout.rows) && stdout.rows > 0 ? stdout.rows : 24 });
166
+
167
+ return { start, enter, leave, finish, suspend, reassert, attempt, draw, size, done, get entered() { return entered; } };
168
+ }
@@ -0,0 +1,124 @@
1
+ /** Terminal cell widths: how many cells a grapheme takes when `oats tui` writes it.
2
+ * Pure: no IO and no imports, only `Intl.Segmenter`, Unicode property escapes and
3
+ * one range table. A grapheme is the unit of layout: the terminal is given whole
4
+ * graphemes, each in the one or two cells this module says it takes. */
5
+
6
+ /** Longest grapheme written as itself, in UTF-16 units. The longest emoji sequences
7
+ * stay well under it; anything longer is a stack of marks on one base, and is replaced. */
8
+ export const MAX_GRAPHEME_UNITS = 32;
9
+ /** What stands in for a grapheme that must not reach the terminal. One cell. */
10
+ export const REPLACEMENT = "\uFFFD";
11
+
12
+ /** East Asian Wide (W) and Fullwidth (F) code points, as sorted, non-touching
13
+ * `[first, last]` pairs. Taken from Unicode 16.0 EastAsianWidth.txt and deliberately
14
+ * coarse: each pair is a whole block or run of blocks, so an unassigned code point
15
+ * inside one counts wide, as the standard says of the CJK blocks. No assigned
16
+ * narrow code point of 16.0 is inside a pair.
17
+ * Emoji are not decided by this table but by the Emoji_Presentation property of
18
+ * the running Node's ICU, which follows new emoji without a table change. */
19
+ export const WIDE_RANGES = Object.freeze([
20
+ [0x1100, 0x115f], // Hangul Jamo leading consonants
21
+ [0x2329, 0x232a], // angle brackets
22
+ [0x2630, 0x2637], // Yijing trigrams
23
+ [0x268a, 0x268f], // Yijing monograms and digrams
24
+ [0x2e80, 0x303e], // CJK radicals, Kangxi, description characters, CJK symbols (not U+303F)
25
+ [0x3041, 0x3247], // kana, Bopomofo, Hangul compatibility Jamo, Kanbun, strokes, enclosed CJK
26
+ [0x3250, 0xa4cf], // enclosed CJK, CJK compatibility, Extension A, hexagrams, ideographs, Yi
27
+ [0xa960, 0xa97f], // Hangul Jamo Extended-A
28
+ [0xac00, 0xd7a3], // Hangul syllables
29
+ [0xf900, 0xfaff], // CJK compatibility ideographs
30
+ [0xfe10, 0xfe19], // vertical forms
31
+ [0xfe30, 0xfe6f], // CJK compatibility forms, small form variants
32
+ [0xff01, 0xff60], // fullwidth forms
33
+ [0xffe0, 0xffe6], // fullwidth signs
34
+ [0x16fe0, 0x18d7f], // ideographic symbols and punctuation, Tangut, Khitan small script
35
+ [0x1aff0, 0x1b2ff], // kana extended and supplement, small kana, Nushu
36
+ [0x1d300, 0x1d376], // Tai Xuan Jing symbols, counting rod numerals
37
+ [0x1f200, 0x1f2ff], // enclosed ideographic supplement
38
+ [0x20000, 0x2fffd], // supplementary ideographic plane
39
+ [0x30000, 0x3fffd], // tertiary ideographic plane
40
+ ].map(Object.freeze));
41
+
42
+ const SEGMENTER = new Intl.Segmenter(undefined, { granularity: "grapheme" });
43
+
44
+ const PRINTABLE_ASCII = /^[\x20-\x7e]*$/;
45
+ /** Never written: C0, DEL and C1 controls (Cc) drive the terminal, a lone surrogate
46
+ * (Cs) is ill-formed, and terminals disagree on what the line and paragraph
47
+ * separators (Zl, Zp) do. With the `u` flag a paired surrogate is not Cs. */
48
+ const UNWRITABLE = /[\p{Cc}\p{Cs}\p{Zl}\p{Zp}]/u;
49
+ /** Only non-spacing and enclosing marks and format characters: nothing to draw on
50
+ * its own. Cf covers ZWJ, the direction marks, the soft hyphen and U+200B, U+2060,
51
+ * U+FEFF; the variation selectors are Mn. Spacing marks (Mc) take a cell. */
52
+ const ZERO_WIDTH = /^[\p{Mn}\p{Me}\p{Cf}]+$/u;
53
+ /** Drawn as emoji by default. A regional indicator is one, so a flag needs no rule. */
54
+ const EMOJI_PRESENTATION = /^\p{Emoji_Presentation}/u;
55
+ /** A text-presentation emoji turned into an emoji: by U+FE0F, by a skin tone on a
56
+ * base that takes one, or by a ZWJ join. A digit, `#` or `*` is an Emoji code point
57
+ * too, and U+FE0F alone does not widen it. */
58
+ const EMOJI_SEQUENCE = /(?![#*0-9])\p{Emoji}\uFE0F|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}|\p{Extended_Pictographic}\u200D\p{Extended_Pictographic}/u;
59
+ /** A digit, `#` or `*` is an emoji only as a whole keycap: base, U+FE0F, U+20E3. */
60
+ const KEYCAP = /^[#*0-9]\uFE0F\u20E3/;
61
+
62
+ function isWide(codePoint) {
63
+ if (codePoint < WIDE_RANGES[0][0]) return false;
64
+ let low = 0;
65
+ let high = WIDE_RANGES.length - 1;
66
+ while (low <= high) {
67
+ const middle = (low + high) >> 1;
68
+ const [first, last] = WIDE_RANGES[middle];
69
+ if (codePoint < first) high = middle - 1;
70
+ else if (codePoint > last) low = middle + 1;
71
+ else return true;
72
+ }
73
+ return false;
74
+ }
75
+
76
+ /** 0, 1 or 2 cells, or -1 for a grapheme that is replaced. The order is the rule:
77
+ * replaced before zero-width, so an endless run of marks is not measured, and
78
+ * zero-width before wide, so a lone wide combining mark (U+3099) takes no cell. */
79
+ function measure(grapheme) {
80
+ if (grapheme.length === 1) {
81
+ const unit = grapheme.charCodeAt(0);
82
+ if (unit >= 0x20 && unit <= 0x7e) return 1;
83
+ }
84
+ if (grapheme.length > MAX_GRAPHEME_UNITS || UNWRITABLE.test(grapheme)) return -1;
85
+ if (grapheme === "") return 0;
86
+ if (ZERO_WIDTH.test(grapheme)) return 0;
87
+ if (isWide(grapheme.codePointAt(0))) return 2;
88
+ if (EMOJI_PRESENTATION.test(grapheme) || EMOJI_SEQUENCE.test(grapheme) || KEYCAP.test(grapheme)) return 2;
89
+ return 1;
90
+ }
91
+
92
+ /** Cells one grapheme takes: 0, 1 or 2. Decided by its first code point, or by its
93
+ * emoji presentation; East Asian Ambiguous counts 1. A grapheme `cells()` replaces
94
+ * (a control, a lone surrogate, an over-long one) measures 1, the cell of its
95
+ * REPLACEMENT. */
96
+ export function graphemeWidth(grapheme) {
97
+ const width = measure(grapheme);
98
+ return width < 0 ? 1 : width;
99
+ }
100
+
101
+ /** The cells of a text: its graphemes in order, each `{ text, width }` with width 1
102
+ * or 2. A zero-width grapheme standing alone is dropped: it takes no cell and is not
103
+ * written. A grapheme that must not be written becomes one REPLACEMENT cell. */
104
+ export function cells(text) {
105
+ const out = [];
106
+ if (PRINTABLE_ASCII.test(text)) {
107
+ for (let index = 0; index < text.length; index++) out.push({ text: text[index], width: 1 });
108
+ return out;
109
+ }
110
+ for (const { segment } of SEGMENTER.segment(text)) {
111
+ const width = measure(segment);
112
+ if (width < 0) out.push({ text: REPLACEMENT, width: 1 });
113
+ else if (width > 0) out.push({ text: segment, width });
114
+ }
115
+ return out;
116
+ }
117
+
118
+ /** Total cells of a text: the sum over `cells(text)`. */
119
+ export function textWidth(text) {
120
+ if (PRINTABLE_ASCII.test(text)) return text.length;
121
+ let total = 0;
122
+ for (const cell of cells(text)) total += cell.width;
123
+ return total;
124
+ }
@@ -0,0 +1,62 @@
1
+ // The frame: (state, size) -> rows of safe text. Pure: no IO, no clock, no escape byte.
2
+ // Every word here is the TUI's own, so every span is lit(). Meaning never rests on colour alone:
3
+ // what is dim or bold also says what it is in words.
4
+ import { keyLabel } from "../actions.mjs";
5
+ import { lit } from "../term/text.mjs";
6
+ import { style } from "../term/style.mjs";
7
+ import { help } from "./help.mjs";
8
+
9
+ /** The frame is drawn from this size up (docs/tui.md); the design size is 80x24. */
10
+ export const MIN_SIZE = Object.freeze({ cols: 60, rows: 15 });
11
+ /** The views to come, named so the frame already has its shape. Drawn dim: none can be opened yet. */
12
+ const VIEWS = Object.freeze(["1 Instances", "2 Souls", "3 Capabilities"]);
13
+ const BODY = Object.freeze(["This preview draws the frame only.", "Views arrive in later releases."]);
14
+ const GAP = 3;
15
+ /** The longest run one lit() holds with room to spare: the display filter bounds a line, and a
16
+ * terminal can be wider than that bound. */
17
+ const RUN = 500;
18
+
19
+ const BOLD = style({ bold: true });
20
+ const DIM = style({ dim: true });
21
+
22
+ /** Spans left to right from `col`, GAP cells apart. */
23
+ function inline(col, texts, look) {
24
+ const spans = [];
25
+ for (const text of texts) { spans.push({ col, text: lit(text), ...(look ? { style: look } : {}) }); col += text.length + GAP; }
26
+ return spans;
27
+ }
28
+ const centred = (text, cols, look) => ({ col: Math.max(0, Math.floor((cols - text.length) / 2)), text: lit(text), ...(look ? { style: look } : {}) });
29
+ const tooSmall = (size) => size.cols < MIN_SIZE.cols || size.rows < MIN_SIZE.rows;
30
+
31
+ /** One row saying so, with the size found and the size needed. Short, and the sizes early: on a
32
+ * terminal this small the screen clips the end of the row. */
33
+ function tooSmallRows(size) {
34
+ const rows = Array.from({ length: size.rows }, () => []);
35
+ if (size.rows > 0) rows[0] = [{ col: 0, text: lit(`Terminal too small: ${size.cols}x${size.rows}, oats tui needs ${MIN_SIZE.cols}x${MIN_SIZE.rows}.`) }];
36
+ return rows;
37
+ }
38
+
39
+ /** The whole screen for a state: `{ view: "frame" | "help", actions, ascii }`. */
40
+ export function frame(state, size) {
41
+ if (tooSmall(size)) return tooSmallRows(size);
42
+ const rows = Array.from({ length: size.rows }, () => []);
43
+ const rule = [];
44
+ for (let col = 0; col < size.cols; col += RUN) rule.push({ col, text: lit((state.ascii ? "-" : "\u2500").repeat(Math.min(RUN, size.cols - col))), style: DIM });
45
+ const key = (id) => { const action = state.actions.find((a) => a.id === id); return action ? `${keyLabel(action.keys[0])} ${action.label}` : null; };
46
+
47
+ rows[0] = [{ col: 0, text: lit("oats"), style: BOLD }, { col: size.cols - "preview".length, text: lit("preview") }];
48
+ rows[1] = inline(0, VIEWS, DIM);
49
+ rows[2] = rule;
50
+ rows[size.rows - 2] = rule;
51
+ rows[size.rows - 1] = inline(0, [key(state.view === "help" ? "close" : "help"), key("quit")].filter(Boolean));
52
+
53
+ const top = 3, height = size.rows - 5;
54
+ if (state.view === "help") help(state.actions, { cols: size.cols, rows: height }).forEach((spans, i) => { rows[top + i] = spans; });
55
+ else {
56
+ // One line where it fits, else a line per sentence.
57
+ const lines = BODY.join(" ").length <= size.cols ? [BODY.join(" ")] : BODY;
58
+ const first = top + Math.max(0, Math.floor((height - lines.length) / 2));
59
+ lines.forEach((line, i) => { rows[first + i] = [centred(line, size.cols)]; });
60
+ }
61
+ return rows;
62
+ }
@@ -0,0 +1,28 @@
1
+ // The help view: the action table as rows of safe text. Pure: no IO, no clock, no escape byte.
2
+ // It is generated from the table the reducer acts on, so it names every key that does something
3
+ // and no key that does not.
4
+ import { keyLabel } from "../actions.mjs";
5
+ import { lit } from "../term/text.mjs";
6
+ import { style } from "../term/style.mjs";
7
+
8
+ const TITLE = style({ bold: true });
9
+ const KEYS = style({ bold: true });
10
+ const HINT = style({ dim: true });
11
+ const INDENT = 2;
12
+ const GAP = 3;
13
+
14
+ /** The keys of an action as a person reads them: `q, Ctrl+C`. */
15
+ export const keysLabel = (action) => action.keys.map(keyLabel).join(", ");
16
+
17
+ /** `size.rows` rows for an area `size.cols` wide: a title, one row per action (its keys, then
18
+ * what it does), and how to close. */
19
+ export function help(actions, size) {
20
+ const rows = Array.from({ length: size.rows }, () => []);
21
+ const column = INDENT + Math.max(...actions.map((action) => keysLabel(action).length)) + GAP;
22
+ const put = (r, ...spans) => { if (r < size.rows) rows[r] = spans; };
23
+ put(1, { col: INDENT, text: lit("Keys"), style: TITLE });
24
+ actions.forEach((action, i) => put(3 + i, { col: INDENT, text: lit(keysLabel(action)), style: KEYS }, { col: column, text: lit(action.label) }));
25
+ const closing = ["close", "help"].map((id) => actions.find((action) => action.id === id)).filter(Boolean).map((action) => keyLabel(action.keys[0]));
26
+ if (closing.length) put(4 + actions.length, { col: INDENT, text: lit(`${closing.join(" or ")} closes this help`), style: HINT });
27
+ return rows;
28
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "name": "@awebai/oats-tui",
3
+ "version": "0.0.0",
4
+ "private": true,
5
+ "description": "OATS TUI (preview): the terminal client behind `oats tui`. Shipped inside @awebai/oats, never published on its own.",
6
+ "type": "module",
7
+ "license": "MIT"
8
+ }
@@ -60,7 +60,7 @@ members:
60
60
  - git:github.com/acme/agents # the host is a member too
61
61
  - git:github.com/acme/platform
62
62
  packages:
63
- oats.framework: v1.9.0 # bare versions resolve through the official catalog
63
+ oats.framework: v1.9.3 # bare versions resolve through the official catalog
64
64
  oats.okf: v4.1.1
65
65
  defaults:
66
66
  capabilities: { oats.core: { from: package } }
@@ -171,12 +171,15 @@ oats spawn backend-expert --task "First concrete task"
171
171
  oats status
172
172
  ```
173
173
 
174
- Before configuring unattended development-channel confirmation, read
175
- `docs/configuration.md#exact-home-launch-prompt-consent`. The sole opt-in is
176
- `oats-local.yaml` `launchPromptAnswers.homes.<absolute-canonical-home>.awebDevelopmentChannel`;
177
- it defaults false and requires the owner's explicit authorization for that home.
178
- Never infer consent from provider development mode, harness trust settings or
179
- a request to spawn. `workspaceTrust` is unsupported; remove it and handle
174
+ OATS confirms Claude's development-channel prompt by itself whenever it
175
+ launches Claude with `--dangerously-load-development-channels
176
+ plugin:aweb-channel@awebai-marketplace` (the default `delivery: channel`,
177
+ `claudeChannelMode: development`); see
178
+ `docs/configuration.md#the-development-channel-confirmation`. There is no
179
+ consent setting. To keep the prompt for a person, set
180
+ `settings.oats.aweb.delivery: session` or `claudeChannelMode: approved` in
181
+ `oats-local.yaml`. An old `launchPromptAnswers` block is ignored with a warning
182
+ (remove it); one with `awebDevelopmentChannel: false` is refused. Handle
180
183
  folder trust explicitly with `oats harness trust --dir D --harness claude --plan`,
181
184
  then the same command without `--plan` to apply. Run it on the target host with
182
185
  native configuration writers quiescent. Use `codex` or `all` for those selected
@@ -185,20 +188,24 @@ The command changes only deployment-root trust and records an audit under
185
188
  `D/.agents/harness-trust.jsonl`. A failure can retain an applied native change;
186
189
  inspect its per-file outcome and audit before retrying. Nested Git boundaries
187
190
  can prevent Claude inheritance. See [harness trust](../../docs/harness-trust.md). Folder-trust
188
- and API-key questions remain unexpected and blocked. Only the qualified Claude
189
- 2.1.289 executable digest, `darwin-arm64` platform and 110x35 geometry documented
190
- there can match the exact aweb development-channel frame. A reported version
191
- alone is insufficient. Preview reports policy without terminal input;
192
- `--no-launch` never answers. If launch returns `E_SPAWN_INCOMPLETE`, inspect the
193
- retained home/pane: do not respawn, repeat keys or treat `launched:false` as an
194
- absent process.
195
- Completion retains the exact empty-frame families and, only after the submitted
196
- channel Enter, can recognize the qualified bottom composer/effort-footer region.
197
- See [the bounded completion contract](../../docs/launch-prompt-completion.md).
198
- Known question markers block first; normal shortcut/interrupt hints do not.
199
- Unknown dialogs retaining that region may be misclassified completed. Completion
200
- closes input authority, not a readiness or idle-state promise. Missing effort or
201
- trailing notices still block. Required private evidence failure is incomplete.
191
+ and API-key questions remain unexpected and blocked. The confirmation is
192
+ answered with one Enter only when the screen equals an entry of the tolerance
193
+ list, on any pane width wide enough to wrap at word boundaries; a new Claude
194
+ wording blocks loudly until a reviewed change adds it. `--no-launch` never
195
+ answers. Where channels are unavailable for the Claude account, Claude ignores
196
+ the flag and shows no confirmation: the start succeeds with `launchPrompts.status:
197
+ "flag-ignored"`, no key, and a warning that the instance has no channel delivery,
198
+ so mail and chat will not wake it until delivery changes.
199
+ On a first spawn that notice can be hidden behind another one; the start then
200
+ blocks, and the error says to look at the pane and restart a running session.
201
+ If launch returns `E_SPAWN_INCOMPLETE`, inspect the retained home/pane:
202
+ do not respawn, repeat keys or treat `launched:false` as an absent process.
203
+ After the Enter, completion is reporting only: 2 s of consecutive clean captures
204
+ (no question marker, no confirmation; the screen may change) complete; a marker
205
+ or the confirmation coming back blocks; no such window by the 30 s bound is an
206
+ observation timeout after the one Enter. See [the completion contract](../../docs/launch-prompt-completion.md).
207
+ Unknown dialogs without a marker may be reported completed. Completion closes
208
+ input authority, not a readiness or idle-state promise.
202
209
 
203
210
  Create and spawn only when asked. After the first spawn, the `oats.setup`
204
211
  skills carry the rest of the deployment (messaging, more souls, rebuilds); the
@@ -208,6 +215,6 @@ model in full is `docs/workspaces.md` in the OATS repository.
208
215
  For a retained launch-prompt block after a submitted answer, inspect the existing
209
216
  launch event and private frame receipt as described in
210
217
  `docs/execution-targets.md#private-unmatched-launch-evidence`. Do not transmit raw
211
- screen text or treat a saved frame as a new accepted signature. A structurally completed frame is also saved privately. A saved artifact alone
218
+ screen text or treat a saved frame as a new accepted signature. A completed frame is also saved privately. A saved artifact alone
212
219
  does not establish completion: verify the final checked launch outcome. Missing
213
220
  effort or unsupported footer shapes can block while the pane is active.
@@ -1,35 +0,0 @@
1
-
2
- ──────────────────────────────────────────────────────────────────────────────────────────────────────────────
3
- WARNING: Loading development channels
4
-
5
- --dangerously-load-development-channels is for local channel development only. Do not use this option to
6
- run channels you have downloaded off the internet.
7
-
8
- Please use --channels to run a list of approved channels.
9
-
10
- Channels: plugin:aweb-channel@awebai-marketplace
11
-
12
- ❯ 1. I am using this for local development
13
- 2. Exit
14
-
15
- Enter to confirm · Esc to cancel
16
-
17
-
18
-
19
-
20
-
21
-
22
-
23
-
24
-
25
-
26
-
27
-
28
-
29
-
30
-
31
-
32
-
33
-
34
-
35
-
@@ -1,35 +0,0 @@
1
- ▐▛███▛█ Claude Code v2.1.289
2
- ▝▜██████▀ Opus 5.5 · API Usage Billing
3
- ▝▝ ▝▝ ~/…/instances/oats-kernel-expert-wake-lifecycle/work/708-fixtures/private-run/target
4
-
5
- ▎ Channels (experimental) messages from plugin:aweb-channel@awebai-marketplace inject directly in this session
6
- ▎ · restart without --dangerously-load-development-channels to stop
7
- ▎ plugin:aweb-channel@awebai-marketplace · plugin not installed
8
-
9
- ──────────────────────────────────────────────────────────────────────────────────────────────────────────────
10
- ❯ 
11
- ──────────────────────────────────────────────────────────────────────────────────────────────────────────────
12
- ⏵⏵ auto mode on (shift+tab to cycle) · ← for agents ◐ medium · /effort
13
-
14
-
15
-
16
-
17
-
18
-
19
-
20
-
21
-
22
-
23
-
24
-
25
-
26
-
27
-
28
-
29
-
30
-
31
-
32
-
33
-
34
-
35
-
@@ -1,35 +0,0 @@
1
- ▐▛███▛█ Claude Code v2.1.289
2
- ▝▜██████▀ Opus 5.5 · API Usage Billing
3
- ▝▝ ▝▝ ~/…/instances/oats-kernel-expert-wake-lifecycle/work/708-fixtures/installed-run/target
4
-
5
- ▎ Channels (experimental) messages from plugin:aweb-channel@awebai-marketplace inject directly in this session
6
- ▎ · restart without --dangerously-load-development-channels to stop
7
-
8
- ──────────────────────────────────────────────────────────────────────────────────────────────────────────────
9
- ❯ 
10
- ──────────────────────────────────────────────────────────────────────────────────────────────────────────────
11
- ⏵⏵ auto mode on (shift+tab to cycle) · ← for agents ◐ medium · /effort
12
-
13
-
14
-
15
-
16
-
17
-
18
-
19
-
20
-
21
-
22
-
23
-
24
-
25
-
26
-
27
-
28
-
29
-
30
-
31
-
32
-
33
-
34
-
35
-