@inhuman.tools/harness-tui 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (167) hide show
  1. package/LICENSE.md +7 -0
  2. package/dist/index.d.ts +2 -0
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +2 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/interpreter/ComputedExecBox.d.ts +12 -0
  7. package/dist/interpreter/ComputedExecBox.d.ts.map +1 -0
  8. package/dist/interpreter/ComputedExecBox.js +88 -0
  9. package/dist/interpreter/ComputedExecBox.js.map +1 -0
  10. package/dist/interpreter/imageCapability.d.ts +9 -0
  11. package/dist/interpreter/imageCapability.d.ts.map +1 -0
  12. package/dist/interpreter/imageCapability.js +49 -0
  13. package/dist/interpreter/imageCapability.js.map +1 -0
  14. package/dist/interpreter/rpcCapability.d.ts +11 -0
  15. package/dist/interpreter/rpcCapability.d.ts.map +1 -0
  16. package/dist/interpreter/rpcCapability.js +91 -0
  17. package/dist/interpreter/rpcCapability.js.map +1 -0
  18. package/dist/interpreter/uiCapability.d.ts +34 -0
  19. package/dist/interpreter/uiCapability.d.ts.map +1 -0
  20. package/dist/interpreter/uiCapability.js +207 -0
  21. package/dist/interpreter/uiCapability.js.map +1 -0
  22. package/dist/schemas/index.d.ts +2 -0
  23. package/dist/schemas/index.d.ts.map +1 -0
  24. package/dist/schemas/index.js +2 -0
  25. package/dist/schemas/index.js.map +1 -0
  26. package/dist/schemas/worker-boot.d.ts +14 -0
  27. package/dist/schemas/worker-boot.d.ts.map +1 -0
  28. package/dist/schemas/worker-boot.js +15 -0
  29. package/dist/schemas/worker-boot.js.map +1 -0
  30. package/dist/tui/ack-prompt.d.ts +53 -0
  31. package/dist/tui/ack-prompt.d.ts.map +1 -0
  32. package/dist/tui/ack-prompt.js +61 -0
  33. package/dist/tui/ack-prompt.js.map +1 -0
  34. package/dist/tui/agents-drawer.d.ts +47 -0
  35. package/dist/tui/agents-drawer.d.ts.map +1 -0
  36. package/dist/tui/agents-drawer.js +314 -0
  37. package/dist/tui/agents-drawer.js.map +1 -0
  38. package/dist/tui/ask-shortcuts.d.ts +59 -0
  39. package/dist/tui/ask-shortcuts.d.ts.map +1 -0
  40. package/dist/tui/ask-shortcuts.js +96 -0
  41. package/dist/tui/ask-shortcuts.js.map +1 -0
  42. package/dist/tui/channel.d.ts +59 -0
  43. package/dist/tui/channel.d.ts.map +1 -0
  44. package/dist/tui/channel.js +27 -0
  45. package/dist/tui/channel.js.map +1 -0
  46. package/dist/tui/host-verbs.d.ts +7 -0
  47. package/dist/tui/host-verbs.d.ts.map +1 -0
  48. package/dist/tui/host-verbs.js +19 -0
  49. package/dist/tui/host-verbs.js.map +1 -0
  50. package/dist/tui/host.d.ts +25 -0
  51. package/dist/tui/host.d.ts.map +1 -0
  52. package/dist/tui/host.js +380 -0
  53. package/dist/tui/host.js.map +1 -0
  54. package/dist/tui/omnibox-seat.d.ts +132 -0
  55. package/dist/tui/omnibox-seat.d.ts.map +1 -0
  56. package/dist/tui/omnibox-seat.js +182 -0
  57. package/dist/tui/omnibox-seat.js.map +1 -0
  58. package/dist/tui/paint-controller.d.ts +170 -0
  59. package/dist/tui/paint-controller.d.ts.map +1 -0
  60. package/dist/tui/paint-controller.js +965 -0
  61. package/dist/tui/paint-controller.js.map +1 -0
  62. package/dist/tui/paint-dom.d.ts +336 -0
  63. package/dist/tui/paint-dom.d.ts.map +1 -0
  64. package/dist/tui/paint-dom.js +709 -0
  65. package/dist/tui/paint-dom.js.map +1 -0
  66. package/dist/tui/paint-source.d.ts +57 -0
  67. package/dist/tui/paint-source.d.ts.map +1 -0
  68. package/dist/tui/paint-source.js +570 -0
  69. package/dist/tui/paint-source.js.map +1 -0
  70. package/dist/tui/paint-transport.d.ts +42 -0
  71. package/dist/tui/paint-transport.d.ts.map +1 -0
  72. package/dist/tui/paint-transport.js +207 -0
  73. package/dist/tui/paint-transport.js.map +1 -0
  74. package/dist/tui/paint-types.d.ts +15 -0
  75. package/dist/tui/paint-types.d.ts.map +1 -0
  76. package/dist/tui/paint-types.js +6 -0
  77. package/dist/tui/paint-types.js.map +1 -0
  78. package/dist/tui/paint-widgets.d.ts +94 -0
  79. package/dist/tui/paint-widgets.d.ts.map +1 -0
  80. package/dist/tui/paint-widgets.js +877 -0
  81. package/dist/tui/paint-widgets.js.map +1 -0
  82. package/dist/tui/parse-args.d.ts +3 -0
  83. package/dist/tui/parse-args.d.ts.map +1 -0
  84. package/dist/tui/parse-args.js +13 -0
  85. package/dist/tui/parse-args.js.map +1 -0
  86. package/dist/tui/permissions-view.d.ts +93 -0
  87. package/dist/tui/permissions-view.d.ts.map +1 -0
  88. package/dist/tui/permissions-view.js +174 -0
  89. package/dist/tui/permissions-view.js.map +1 -0
  90. package/dist/tui/present-visual/approve.d.ts +10 -0
  91. package/dist/tui/present-visual/approve.d.ts.map +1 -0
  92. package/dist/tui/present-visual/approve.js +156 -0
  93. package/dist/tui/present-visual/approve.js.map +1 -0
  94. package/dist/tui/present-visual/dump.d.ts +47 -0
  95. package/dist/tui/present-visual/dump.d.ts.map +1 -0
  96. package/dist/tui/present-visual/dump.js +144 -0
  97. package/dist/tui/present-visual/dump.js.map +1 -0
  98. package/dist/tui/present-visual/journey-teardown.d.ts +3 -0
  99. package/dist/tui/present-visual/journey-teardown.d.ts.map +1 -0
  100. package/dist/tui/present-visual/journey-teardown.js +188 -0
  101. package/dist/tui/present-visual/journey-teardown.js.map +1 -0
  102. package/dist/tui/present-visual/journey.d.ts +15 -0
  103. package/dist/tui/present-visual/journey.d.ts.map +1 -0
  104. package/dist/tui/present-visual/journey.js +88 -0
  105. package/dist/tui/present-visual/journey.js.map +1 -0
  106. package/dist/tui/present-visual/raster.d.ts +3 -0
  107. package/dist/tui/present-visual/raster.d.ts.map +1 -0
  108. package/dist/tui/present-visual/raster.js +75 -0
  109. package/dist/tui/present-visual/raster.js.map +1 -0
  110. package/dist/tui/queue-shortcuts.d.ts +13 -0
  111. package/dist/tui/queue-shortcuts.d.ts.map +1 -0
  112. package/dist/tui/queue-shortcuts.js +23 -0
  113. package/dist/tui/queue-shortcuts.js.map +1 -0
  114. package/dist/tui/read-widen.d.ts +14 -0
  115. package/dist/tui/read-widen.d.ts.map +1 -0
  116. package/dist/tui/read-widen.js +45 -0
  117. package/dist/tui/read-widen.js.map +1 -0
  118. package/dist/tui/rewind-chrome.d.ts +29 -0
  119. package/dist/tui/rewind-chrome.d.ts.map +1 -0
  120. package/dist/tui/rewind-chrome.js +77 -0
  121. package/dist/tui/rewind-chrome.js.map +1 -0
  122. package/dist/tui/rust-present.d.ts +37 -0
  123. package/dist/tui/rust-present.d.ts.map +1 -0
  124. package/dist/tui/rust-present.js +205 -0
  125. package/dist/tui/rust-present.js.map +1 -0
  126. package/dist/tui/spinner-phase.d.ts +24 -0
  127. package/dist/tui/spinner-phase.d.ts.map +1 -0
  128. package/dist/tui/spinner-phase.js +25 -0
  129. package/dist/tui/spinner-phase.js.map +1 -0
  130. package/dist/tui/statusline-path.d.ts +10 -0
  131. package/dist/tui/statusline-path.d.ts.map +1 -0
  132. package/dist/tui/statusline-path.js +42 -0
  133. package/dist/tui/statusline-path.js.map +1 -0
  134. package/dist/tui/sugarcoat-paint.d.ts +14 -0
  135. package/dist/tui/sugarcoat-paint.d.ts.map +1 -0
  136. package/dist/tui/sugarcoat-paint.js +146 -0
  137. package/dist/tui/sugarcoat-paint.js.map +1 -0
  138. package/dist/tui/tape-spans.d.ts +64 -0
  139. package/dist/tui/tape-spans.d.ts.map +1 -0
  140. package/dist/tui/tape-spans.js +93 -0
  141. package/dist/tui/tape-spans.js.map +1 -0
  142. package/dist/tui/tea.d.ts +75 -0
  143. package/dist/tui/tea.d.ts.map +1 -0
  144. package/dist/tui/tea.js +2952 -0
  145. package/dist/tui/tea.js.map +1 -0
  146. package/dist/tui/vt-paint.d.ts +12 -0
  147. package/dist/tui/vt-paint.d.ts.map +1 -0
  148. package/dist/tui/vt-paint.js +123 -0
  149. package/dist/tui/vt-paint.js.map +1 -0
  150. package/dist/tui/wait-phrase.d.ts +31 -0
  151. package/dist/tui/wait-phrase.d.ts.map +1 -0
  152. package/dist/tui/wait-phrase.js +26 -0
  153. package/dist/tui/wait-phrase.js.map +1 -0
  154. package/dist/tui/widget-host.d.ts +34 -0
  155. package/dist/tui/widget-host.d.ts.map +1 -0
  156. package/dist/tui/widget-host.js +80 -0
  157. package/dist/tui/widget-host.js.map +1 -0
  158. package/dist/tui/work-cells.d.ts +47 -0
  159. package/dist/tui/work-cells.d.ts.map +1 -0
  160. package/dist/tui/work-cells.js +606 -0
  161. package/dist/tui/work-cells.js.map +1 -0
  162. package/dist/tui/worker-entry.d.ts +2 -0
  163. package/dist/tui/worker-entry.d.ts.map +1 -0
  164. package/dist/tui/worker-entry.js +98 -0
  165. package/dist/tui/worker-entry.js.map +1 -0
  166. package/package.json +84 -3
  167. package/README.md +0 -3
@@ -0,0 +1,709 @@
1
+ import equal from "fast-deep-equal";
2
+ import { detach, types } from "mobx-state-tree";
3
+ function lateNode() {
4
+ return PaintNode;
5
+ }
6
+ /** Replica / identity can hand `null` on first paint. MST strings refuse it. */
7
+ function faceText(value) {
8
+ return typeof value === "string" ? value : "";
9
+ }
10
+ const paintChildren = types.array(types.late(lateNode));
11
+ const SpeechPaint = types
12
+ .model("SpeechPaint", {
13
+ kind: types.literal("speech"),
14
+ text: types.optional(types.string, ""),
15
+ voice: types.optional(types.enumeration(["user", "assistant"]), "assistant"),
16
+ atMs: types.optional(types.maybeNull(types.number), null),
17
+ /** Selected pin: chrome_frame plus session-title annotation. */
18
+ recap: types.optional(types.boolean, false),
19
+ recapHotkeys: types.optional(types.frozen(), []),
20
+ annotation: types.optional(types.string, ""),
21
+ })
22
+ .actions((self) => ({
23
+ updateText(next) {
24
+ if (self.text === next)
25
+ return;
26
+ self.text = next;
27
+ },
28
+ setVoice(next) {
29
+ if (self.voice === next)
30
+ return;
31
+ self.voice = next;
32
+ },
33
+ setAtMs(next) {
34
+ if (self.atMs === next)
35
+ return;
36
+ self.atMs = next;
37
+ },
38
+ setRecap(next, annotation = "", hotkeys = []) {
39
+ if (self.recap === next && self.annotation === annotation && equal(self.recapHotkeys, hotkeys))
40
+ return;
41
+ self.recapHotkeys = next ? hotkeys : [];
42
+ self.recap = next;
43
+ self.annotation = next ? annotation : "";
44
+ },
45
+ }));
46
+ const ThinkingPaint = types
47
+ .model("ThinkingPaint", {
48
+ kind: types.literal("thinking"),
49
+ text: types.optional(types.string, ""),
50
+ })
51
+ .actions((self) => ({
52
+ updateText(next) {
53
+ if (self.text === next)
54
+ return;
55
+ self.text = next;
56
+ },
57
+ }));
58
+ const FailurePaint = types
59
+ .model("FailurePaint", {
60
+ kind: types.literal("failure"),
61
+ endDetail: types.optional(types.string, ""),
62
+ failReason: types.optional(types.string, ""),
63
+ })
64
+ .actions((self) => ({
65
+ updateEndDetail(next) {
66
+ if (self.endDetail === next)
67
+ return;
68
+ self.endDetail = next;
69
+ },
70
+ updateFailReason(next) {
71
+ if (self.failReason === next)
72
+ return;
73
+ self.failReason = next;
74
+ },
75
+ }));
76
+ const RecallPaint = types
77
+ .model("RecallPaint", {
78
+ kind: types.enumeration(["recall", "compact"]),
79
+ text: types.optional(types.string, ""),
80
+ })
81
+ .actions((self) => ({
82
+ updateText(next) {
83
+ if (self.text === next)
84
+ return;
85
+ self.text = next;
86
+ },
87
+ }));
88
+ const WorkCellPaint = types
89
+ .model("WorkCellPaint", {
90
+ kind: types.enumeration(["tool", "scheme", "loop", "ask", "wait"]),
91
+ toolCallId: types.optional(types.string, ""),
92
+ name: types.optional(types.string, ""),
93
+ object: types.optional(types.string, ""),
94
+ status: types.optional(types.string, ""),
95
+ caption: types.optional(types.string, ""),
96
+ state: types.optional(types.enumeration(["live", "ok", "fail", "ask", "judging"]), "live"),
97
+ indent: types.optional(types.boolean, false),
98
+ split: types.optional(types.boolean, false),
99
+ agent: types.optional(types.boolean, false),
100
+ pretty: types.optional(types.boolean, false),
101
+ prettyBlock: types.optional(types.string, ""),
102
+ response: types.optional(types.string, ""),
103
+ receiptKind: types.optional(types.enumeration([
104
+ "none",
105
+ "text",
106
+ "markdown",
107
+ "diff",
108
+ "stream",
109
+ "syntax",
110
+ "number",
111
+ "boolean",
112
+ "parts",
113
+ ]), "none"),
114
+ receiptText: types.optional(types.string, ""),
115
+ diffOld: types.optional(types.string, ""),
116
+ diffNew: types.optional(types.string, ""),
117
+ diffPath: types.optional(types.string, ""),
118
+ diffLineStart: types.optional(types.number, 0),
119
+ /** see tape-spans.ts preamble, CHANGE ONLY. */
120
+ fuse: types.optional(types.boolean, false),
121
+ /** Wait pin: epoch ms when this occupancy row first appeared. Write-once. */
122
+ startedAt: types.optional(types.maybeNull(types.number), null),
123
+ /** Live backoff until this epoch ms. Wait pin only. */
124
+ retryUntilMs: types.optional(types.maybeNull(types.number), null),
125
+ children: types.optional(paintChildren, []),
126
+ })
127
+ .actions((self) => ({
128
+ setFace(next) {
129
+ if (next.toolCallId !== undefined) {
130
+ const toolCallId = faceText(next.toolCallId);
131
+ if (self.toolCallId !== toolCallId)
132
+ self.toolCallId = toolCallId;
133
+ }
134
+ const name = faceText(next.name);
135
+ const object = faceText(next.object);
136
+ const status = faceText(next.status);
137
+ if (self.name !== name)
138
+ self.name = name;
139
+ if (self.object !== object)
140
+ self.object = object;
141
+ if (self.status !== status)
142
+ self.status = status;
143
+ if (next.caption !== undefined) {
144
+ const caption = faceText(next.caption);
145
+ if (self.caption !== caption)
146
+ self.caption = caption;
147
+ }
148
+ if (self.state !== next.state)
149
+ self.state = next.state;
150
+ if (self.indent !== next.indent)
151
+ self.indent = next.indent;
152
+ if (next.split !== undefined && self.split !== next.split)
153
+ self.split = next.split;
154
+ if (next.agent !== undefined && self.agent !== next.agent)
155
+ self.agent = next.agent;
156
+ if (next.pretty !== undefined && self.pretty !== next.pretty)
157
+ self.pretty = next.pretty;
158
+ if (next.prettyBlock !== undefined) {
159
+ const prettyBlock = faceText(next.prettyBlock);
160
+ if (self.prettyBlock !== prettyBlock)
161
+ self.prettyBlock = prettyBlock;
162
+ }
163
+ if (next.response !== undefined) {
164
+ const response = faceText(next.response);
165
+ if (self.response !== response)
166
+ self.response = response;
167
+ }
168
+ if (self.receiptKind !== next.receiptKind)
169
+ self.receiptKind = next.receiptKind;
170
+ const receiptText = faceText(next.receiptText);
171
+ const diffOld = faceText(next.diffOld);
172
+ const diffNew = faceText(next.diffNew);
173
+ const diffPath = faceText(next.diffPath);
174
+ if (self.receiptText !== receiptText)
175
+ self.receiptText = receiptText;
176
+ if (self.diffOld !== diffOld)
177
+ self.diffOld = diffOld;
178
+ if (self.diffNew !== diffNew)
179
+ self.diffNew = diffNew;
180
+ if (self.diffPath !== diffPath)
181
+ self.diffPath = diffPath;
182
+ if (next.diffLineStart !== undefined && self.diffLineStart !== next.diffLineStart) {
183
+ self.diffLineStart = next.diffLineStart;
184
+ }
185
+ if (next.fuse !== undefined && self.fuse !== next.fuse)
186
+ self.fuse = next.fuse;
187
+ if (next.startedAt != null && Number.isFinite(next.startedAt) && self.startedAt == null) {
188
+ self.startedAt = next.startedAt;
189
+ }
190
+ if (next.retryUntilMs !== undefined) {
191
+ const retryUntilMs = next.retryUntilMs != null && Number.isFinite(next.retryUntilMs) ? next.retryUntilMs : null;
192
+ if (self.retryUntilMs !== retryUntilMs)
193
+ self.retryUntilMs = retryUntilMs;
194
+ }
195
+ },
196
+ }));
197
+ const CompletionPaint = types
198
+ .model("CompletionPaint", {
199
+ kind: types.literal("completion"),
200
+ state: types.optional(types.enumeration(["live", "successful", "failed"]), "live"),
201
+ workerPresent: types.optional(types.boolean, false),
202
+ model: types.optional(types.string, ""),
203
+ startedAt: types.optional(types.maybeNull(types.number), null),
204
+ durationMs: types.optional(types.maybeNull(types.number), null),
205
+ thoughtLive: types.optional(types.boolean, false),
206
+ /** Live backoff until this epoch ms. Null when not waiting to retry. */
207
+ retryUntilMs: types.optional(types.maybeNull(types.number), null),
208
+ /** `summary` when the visible thought is a provider summary, not CoT. */
209
+ thoughtKind: types.optional(types.string, ""),
210
+ /** DEBUG=* cache-invariant mark. Empty when aligned or not debug. */
211
+ debugNote: types.optional(types.string, ""),
212
+ children: types.optional(paintChildren, []),
213
+ })
214
+ .actions((self) => ({
215
+ setState(next) {
216
+ if (self.state === next)
217
+ return;
218
+ self.state = next;
219
+ },
220
+ setWorkerPresent(next) {
221
+ if (self.workerPresent === next)
222
+ return;
223
+ self.workerPresent = next;
224
+ },
225
+ setModel(next) {
226
+ if (self.model === next)
227
+ return;
228
+ self.model = next;
229
+ },
230
+ setStartedAt(next) {
231
+ if (self.startedAt === next)
232
+ return;
233
+ self.startedAt = next;
234
+ },
235
+ setDurationMs(next) {
236
+ if (self.durationMs === next)
237
+ return;
238
+ self.durationMs = next;
239
+ },
240
+ setThoughtLive(next) {
241
+ if (self.thoughtLive === next)
242
+ return;
243
+ self.thoughtLive = next;
244
+ },
245
+ setRetryUntilMs(next) {
246
+ if (self.retryUntilMs === next)
247
+ return;
248
+ self.retryUntilMs = next;
249
+ },
250
+ setThoughtKind(next) {
251
+ if (self.thoughtKind === next)
252
+ return;
253
+ self.thoughtKind = next;
254
+ },
255
+ setDebugNote(next) {
256
+ if (self.debugNote === next)
257
+ return;
258
+ self.debugNote = next;
259
+ },
260
+ }));
261
+ function childHostActions(self) {
262
+ return {
263
+ appendChild(node) {
264
+ self.children.push(node);
265
+ },
266
+ insertChildAt(index, node) {
267
+ self.children.splice(index, 0, node);
268
+ },
269
+ removeChildAt(index) {
270
+ self.children.splice(index, 1);
271
+ },
272
+ /** Reorder without MST-killing the node. splice-remove destroys; detach does not. */
273
+ placeChild(index, node) {
274
+ if (self.children[index] === node)
275
+ return;
276
+ const at = self.children.indexOf(node);
277
+ if (at !== -1)
278
+ detach(self.children[at]);
279
+ self.children.splice(index, 0, node);
280
+ },
281
+ };
282
+ }
283
+ const TurnPaint = types
284
+ .model("TurnPaint", {
285
+ kind: types.literal("turn"),
286
+ children: types.optional(paintChildren, []),
287
+ })
288
+ .actions((self) => childHostActions(self));
289
+ const StackPaint = types
290
+ .model("StackPaint", {
291
+ kind: types.literal("stack"),
292
+ children: types.optional(paintChildren, []),
293
+ })
294
+ .actions((self) => childHostActions(self));
295
+ const PreviewPaint = types
296
+ .model("PreviewPaint", {
297
+ kind: types.literal("preview"),
298
+ children: types.optional(paintChildren, []),
299
+ })
300
+ .actions((self) => childHostActions(self));
301
+ const RewindPaint = types
302
+ .model("RewindPaint", {
303
+ kind: types.literal("rewind"),
304
+ atTip: types.optional(types.boolean, true),
305
+ seatRim: types.optional(types.boolean, true),
306
+ past: types.optional(types.frozen(), []),
307
+ future: types.optional(types.frozen(), []),
308
+ pastTotal: types.optional(types.number, 0),
309
+ futureTotal: types.optional(types.number, 0),
310
+ })
311
+ .actions((self) => ({
312
+ setFace(atTip, past, future, pastTotal = past.length, futureTotal = future.length, seatRim = atTip) {
313
+ if (self.atTip === atTip &&
314
+ self.seatRim === seatRim &&
315
+ self.pastTotal === pastTotal &&
316
+ self.futureTotal === futureTotal &&
317
+ equal(self.past, past) &&
318
+ equal(self.future, future)) {
319
+ return;
320
+ }
321
+ self.atTip = atTip;
322
+ self.seatRim = seatRim;
323
+ self.past = past;
324
+ self.future = future;
325
+ self.pastTotal = pastTotal;
326
+ self.futureTotal = futureTotal;
327
+ },
328
+ }));
329
+ export const RootPaint = types
330
+ .model("RootPaint", {
331
+ kind: types.literal("root"),
332
+ children: types.optional(paintChildren, []),
333
+ })
334
+ .actions((self) => childHostActions(self));
335
+ const StatuslinePaint = types
336
+ .model("StatuslinePaint", {
337
+ kind: types.literal("statusline"),
338
+ cwd: types.optional(types.string, ""),
339
+ /** Bright prefix of `cwd` (git root). Empty = paint `cwd` as one span. */
340
+ cwdRoot: types.optional(types.string, ""),
341
+ left: types.optional(types.string, ""),
342
+ /** Checkout clause, quieter than `left`. Empty omits it. */
343
+ note: types.optional(types.string, ""),
344
+ })
345
+ .actions((self) => ({
346
+ setCwd(next) {
347
+ if (self.cwd === next)
348
+ return;
349
+ self.cwd = next;
350
+ },
351
+ setCwdRoot(next) {
352
+ if (self.cwdRoot === next)
353
+ return;
354
+ self.cwdRoot = next;
355
+ },
356
+ setLeft(next) {
357
+ if (self.left === next)
358
+ return;
359
+ self.left = next;
360
+ },
361
+ setNote(next) {
362
+ if (self.note === next)
363
+ return;
364
+ self.note = next;
365
+ },
366
+ }));
367
+ const AgentsPaint = types
368
+ .model("AgentsPaint", {
369
+ kind: types.literal("agents"),
370
+ meterLeft: types.optional(types.string, ""),
371
+ meterRight: types.optional(types.string, ""),
372
+ open: types.optional(types.boolean, false),
373
+ focusKey: types.optional(types.string, ""),
374
+ scroll: types.optional(types.number, 0),
375
+ rows: types.optional(types.frozen(), []),
376
+ previewKey: types.optional(types.string, ""),
377
+ })
378
+ .actions((self) => ({
379
+ setFace(next) {
380
+ const meterLeft = faceText(next.meterLeft);
381
+ const meterRight = faceText(next.meterRight);
382
+ const focusKey = faceText(next.focusKey);
383
+ const previewKey = faceText(next.previewKey);
384
+ if (self.meterLeft !== meterLeft)
385
+ self.meterLeft = meterLeft;
386
+ if (self.meterRight !== meterRight)
387
+ self.meterRight = meterRight;
388
+ if (self.open !== next.open)
389
+ self.open = next.open;
390
+ if (self.focusKey !== focusKey)
391
+ self.focusKey = focusKey;
392
+ if (self.scroll !== next.scroll)
393
+ self.scroll = next.scroll;
394
+ if (!equal(self.rows, next.rows))
395
+ self.rows = next.rows;
396
+ if (self.previewKey !== previewKey)
397
+ self.previewKey = previewKey;
398
+ },
399
+ }));
400
+ const ComposerPaint = types
401
+ .model("ComposerPaint", {
402
+ kind: types.literal("composer"),
403
+ /** Painted face. Secret mode is already masked; raw secret never lives here. */
404
+ draft: types.optional(types.string, ""),
405
+ cursor: types.optional(types.number, 0),
406
+ mark: types.optional(types.maybeNull(types.number), null),
407
+ interactive: types.optional(types.boolean, true),
408
+ readOnly: types.optional(types.boolean, false),
409
+ mode: types.optional(types.enumeration(["normal", "secret", "isolated", "waiting"]), "normal"),
410
+ placeholder: types.optional(types.string, ""),
411
+ annotation: types.optional(types.string, ""),
412
+ joinAnnotation: types.optional(types.string, ""),
413
+ hotkeys: types.optional(types.frozen(), []),
414
+ errorLevel: types.optional(types.maybeNull(types.enumeration(["warning", "error"])), null),
415
+ errorMessage: types.optional(types.string, ""),
416
+ statusItems: types.optional(types.frozen(), []),
417
+ quotaWindows: types.optional(types.frozen(), []),
418
+ contextUsed: types.optional(types.number, 0),
419
+ contextLimit: types.optional(types.number, 0),
420
+ contourRole: types.optional(types.string, ""),
421
+ progress: types.optional(types.maybeNull(types.number), null),
422
+ progressColor: types.optional(types.string, ""),
423
+ progressGlowAt: types.optional(types.maybeNull(types.number), null),
424
+ progressAnnotation: types.optional(types.string, ""),
425
+ commandChoices: types.optional(types.maybeNull(types.frozen()), null),
426
+ commandAction: types.optional(types.maybeNull(types.frozen()), null),
427
+ selectedCommandKey: types.optional(types.maybeNull(types.string), null),
428
+ scrollOffset: types.optional(types.number, 0),
429
+ stackedBody: types.optional(types.string, ""),
430
+ stackedViewport: types.optional(types.number, 0),
431
+ stackedNumbered: types.optional(types.boolean, false),
432
+ stackedLang: types.optional(types.string, ""),
433
+ children: types.optional(paintChildren, []),
434
+ })
435
+ .actions((self) => ({
436
+ setDraft(next) {
437
+ if (self.draft === next)
438
+ return;
439
+ self.draft = next;
440
+ },
441
+ setCursor(next) {
442
+ if (self.cursor === next)
443
+ return;
444
+ self.cursor = next;
445
+ },
446
+ setMark(next) {
447
+ if (self.mark === next)
448
+ return;
449
+ self.mark = next;
450
+ },
451
+ setInteractive(next) {
452
+ if (self.interactive === next)
453
+ return;
454
+ self.interactive = next;
455
+ },
456
+ setReadOnly(next) {
457
+ if (self.readOnly === next)
458
+ return;
459
+ self.readOnly = next;
460
+ },
461
+ setMode(next) {
462
+ if (self.mode === next)
463
+ return;
464
+ self.mode = next;
465
+ },
466
+ setPlaceholder(next) {
467
+ if (self.placeholder === next)
468
+ return;
469
+ self.placeholder = next;
470
+ },
471
+ setAnnotation(next) {
472
+ if (self.annotation === next)
473
+ return;
474
+ self.annotation = next;
475
+ },
476
+ setJoinAnnotation(next) {
477
+ if (self.joinAnnotation === next)
478
+ return;
479
+ self.joinAnnotation = next;
480
+ },
481
+ setHotkeys(next) {
482
+ if (equal(self.hotkeys, next))
483
+ return;
484
+ self.hotkeys = next;
485
+ },
486
+ setError(level, message) {
487
+ if (self.errorLevel === level && self.errorMessage === message)
488
+ return;
489
+ self.errorLevel = level;
490
+ self.errorMessage = message;
491
+ },
492
+ setStatusItems(next) {
493
+ if (equal(self.statusItems, next))
494
+ return;
495
+ self.statusItems = next;
496
+ },
497
+ setQuotaWindows(next) {
498
+ if (equal(self.quotaWindows, next))
499
+ return;
500
+ self.quotaWindows = next;
501
+ },
502
+ setContextUsed(next) {
503
+ if (self.contextUsed === next)
504
+ return;
505
+ self.contextUsed = next;
506
+ },
507
+ setContextLimit(next) {
508
+ if (self.contextLimit === next)
509
+ return;
510
+ self.contextLimit = next;
511
+ },
512
+ setContourRole(next) {
513
+ if (self.contourRole === next)
514
+ return;
515
+ self.contourRole = next;
516
+ },
517
+ setProgress(next) {
518
+ if (self.progress === next)
519
+ return;
520
+ self.progress = next;
521
+ },
522
+ setProgressColor(next) {
523
+ if (self.progressColor === next)
524
+ return;
525
+ self.progressColor = next;
526
+ },
527
+ setProgressGlowAt(next) {
528
+ if (self.progressGlowAt === next)
529
+ return;
530
+ self.progressGlowAt = next;
531
+ },
532
+ setProgressAnnotation(next) {
533
+ if (self.progressAnnotation === next)
534
+ return;
535
+ self.progressAnnotation = next;
536
+ },
537
+ setCommandChoices(next) {
538
+ if (equal(self.commandChoices, next))
539
+ return;
540
+ self.commandChoices = next;
541
+ },
542
+ setCommandAction(next) {
543
+ if (equal(self.commandAction, next))
544
+ return;
545
+ self.commandAction = next;
546
+ },
547
+ setSelectedCommandKey(next) {
548
+ if (self.selectedCommandKey === next)
549
+ return;
550
+ self.selectedCommandKey = next;
551
+ },
552
+ setScrollOffset(next) {
553
+ if (self.scrollOffset === next)
554
+ return;
555
+ self.scrollOffset = next;
556
+ },
557
+ setStackedBody(next) {
558
+ if (self.stackedBody === next)
559
+ return;
560
+ self.stackedBody = next;
561
+ },
562
+ setStackedViewport(next) {
563
+ if (self.stackedViewport === next)
564
+ return;
565
+ self.stackedViewport = next;
566
+ },
567
+ setStackedNumbered(next) {
568
+ if (self.stackedNumbered === next)
569
+ return;
570
+ self.stackedNumbered = next;
571
+ },
572
+ setStackedLang(next) {
573
+ if (self.stackedLang === next)
574
+ return;
575
+ self.stackedLang = next;
576
+ },
577
+ appendChild(node) {
578
+ self.children.push(node);
579
+ },
580
+ removeChildAt(index) {
581
+ self.children.splice(index, 1);
582
+ },
583
+ }));
584
+ const KIND = {
585
+ speech: SpeechPaint,
586
+ thinking: ThinkingPaint,
587
+ failure: FailurePaint,
588
+ recall: RecallPaint,
589
+ compact: RecallPaint,
590
+ completion: CompletionPaint,
591
+ tool: WorkCellPaint,
592
+ scheme: WorkCellPaint,
593
+ loop: WorkCellPaint,
594
+ ask: WorkCellPaint,
595
+ wait: WorkCellPaint,
596
+ turn: TurnPaint,
597
+ stack: StackPaint,
598
+ preview: PreviewPaint,
599
+ rewind: RewindPaint,
600
+ root: RootPaint,
601
+ composer: ComposerPaint,
602
+ statusline: StatuslinePaint,
603
+ agents: AgentsPaint,
604
+ };
605
+ function dispatchPaint(snapshot) {
606
+ const kind = snapshot !== null && typeof snapshot === "object" && "kind" in snapshot
607
+ ? String(snapshot.kind)
608
+ : "";
609
+ const model = KIND[kind];
610
+ if (model === undefined) {
611
+ throw new Error(`unknown paint kind ${kind === "" ? "<missing>" : kind}`);
612
+ }
613
+ return model;
614
+ }
615
+ export const PaintNode = types.union({ dispatcher: dispatchPaint }, ...new Set(Object.values(KIND)));
616
+ /** MST `types.late` cannot name the recursive union; the dispatcher already minted each child. */
617
+ export function paintChildrenOf(node) {
618
+ if (!("children" in node))
619
+ return [];
620
+ const { children } = node;
621
+ if (!Array.isArray(children))
622
+ return [];
623
+ return children;
624
+ }
625
+ export function createPaintRoot() {
626
+ return RootPaint.create({ kind: "root", children: [] });
627
+ }
628
+ export function createCompletion(fields = {}) {
629
+ return CompletionPaint.create({
630
+ kind: "completion",
631
+ state: fields.state ?? "live",
632
+ workerPresent: fields.workerPresent ?? false,
633
+ model: fields.model ?? "",
634
+ startedAt: fields.startedAt ?? null,
635
+ durationMs: fields.durationMs ?? null,
636
+ thoughtLive: fields.thoughtLive ?? false,
637
+ retryUntilMs: fields.retryUntilMs ?? null,
638
+ thoughtKind: fields.thoughtKind ?? "",
639
+ children: [
640
+ { kind: "speech", text: "" },
641
+ { kind: "thinking", text: "" },
642
+ { kind: "failure", endDetail: "", failReason: "" },
643
+ ],
644
+ });
645
+ }
646
+ export function createTurn() {
647
+ return TurnPaint.create({ kind: "turn", children: [] });
648
+ }
649
+ export function createStack() {
650
+ return StackPaint.create({ kind: "stack", children: [] });
651
+ }
652
+ export function createPreview() {
653
+ return PreviewPaint.create({ kind: "preview", children: [] });
654
+ }
655
+ export function createRewind() {
656
+ return RewindPaint.create({ kind: "rewind" });
657
+ }
658
+ export function createComposer() {
659
+ return ComposerPaint.create({ kind: "composer" });
660
+ }
661
+ export function createStatusline() {
662
+ return StatuslinePaint.create({ kind: "statusline" });
663
+ }
664
+ export function createAgents() {
665
+ return AgentsPaint.create({ kind: "agents" });
666
+ }
667
+ export function createRecall(text = "") {
668
+ return RecallPaint.create({ kind: "recall", text });
669
+ }
670
+ export function createCompact(text = "") {
671
+ return RecallPaint.create({ kind: "compact", text });
672
+ }
673
+ export function createSpeech(text = "", voice = "assistant", atMs = null) {
674
+ return SpeechPaint.create({ kind: "speech", text, voice, atMs });
675
+ }
676
+ export function createWorkCell(kind) {
677
+ return WorkCellPaint.create({ kind });
678
+ }
679
+ export function isPaintRootChrome(kind) {
680
+ return (kind === "composer" ||
681
+ kind === "ask" ||
682
+ kind === "wait" ||
683
+ kind === "statusline" ||
684
+ kind === "agents" ||
685
+ kind === "preview" ||
686
+ kind === "rewind");
687
+ }
688
+ export function speechOf(node) {
689
+ const child = paintChildrenOf(node).at(0);
690
+ if (child === undefined || child.kind !== "speech") {
691
+ throw new Error("completion missing speech child");
692
+ }
693
+ return child;
694
+ }
695
+ export function thinkingOf(node) {
696
+ const child = paintChildrenOf(node).at(1);
697
+ if (child === undefined || child.kind !== "thinking") {
698
+ throw new Error("completion missing thinking child");
699
+ }
700
+ return child;
701
+ }
702
+ export function failureOf(node) {
703
+ const child = paintChildrenOf(node).at(2);
704
+ if (child === undefined || child.kind !== "failure") {
705
+ throw new Error("completion missing failure child");
706
+ }
707
+ return child;
708
+ }
709
+ //# sourceMappingURL=paint-dom.js.map