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