zcode-acp-server 0.11.9 → 0.14.1

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 (108) hide show
  1. package/README.md +144 -32
  2. package/dist/backend/client.d.ts.map +1 -1
  3. package/dist/backend/client.js +10 -0
  4. package/dist/backend/client.js.map +1 -1
  5. package/dist/backend/listener.d.ts.map +1 -1
  6. package/dist/backend/listener.js +6 -5
  7. package/dist/backend/listener.js.map +1 -1
  8. package/dist/backend/resolve.d.ts.map +1 -1
  9. package/dist/backend/resolve.js +35 -1
  10. package/dist/backend/resolve.js.map +1 -1
  11. package/dist/bin/hub.d.ts +3 -3
  12. package/dist/bin/hub.d.ts.map +1 -1
  13. package/dist/bin/hub.js +22 -12
  14. package/dist/bin/hub.js.map +1 -1
  15. package/dist/bin/quota.d.ts +14 -6
  16. package/dist/bin/quota.d.ts.map +1 -1
  17. package/dist/bin/quota.js +27 -19
  18. package/dist/bin/quota.js.map +1 -1
  19. package/dist/cli.d.ts +38 -0
  20. package/dist/cli.d.ts.map +1 -0
  21. package/dist/cli.js +129 -0
  22. package/dist/cli.js.map +1 -0
  23. package/dist/config/runtime-model.d.ts +10 -10
  24. package/dist/config/runtime-model.js +10 -10
  25. package/dist/handlers/account.d.ts +1 -1
  26. package/dist/handlers/account.js +1 -1
  27. package/dist/handlers/dispatch.d.ts.map +1 -1
  28. package/dist/handlers/dispatch.js +42 -36
  29. package/dist/handlers/dispatch.js.map +1 -1
  30. package/dist/handlers/io.d.ts.map +1 -1
  31. package/dist/handlers/io.js +19 -13
  32. package/dist/handlers/io.js.map +1 -1
  33. package/dist/handlers/session.d.ts +58 -4
  34. package/dist/handlers/session.d.ts.map +1 -1
  35. package/dist/handlers/session.js +288 -56
  36. package/dist/handlers/session.js.map +1 -1
  37. package/dist/index.d.ts +4 -1
  38. package/dist/index.d.ts.map +1 -1
  39. package/dist/index.js +27 -8
  40. package/dist/index.js.map +1 -1
  41. package/dist/interaction/adapter.d.ts +1 -0
  42. package/dist/interaction/adapter.d.ts.map +1 -1
  43. package/dist/interaction/adapter.js +5 -1
  44. package/dist/interaction/adapter.js.map +1 -1
  45. package/dist/quota/color.d.ts +4 -4
  46. package/dist/quota/color.d.ts.map +1 -1
  47. package/dist/quota/color.js +7 -5
  48. package/dist/quota/color.js.map +1 -1
  49. package/dist/quota/combined.d.ts +1 -1
  50. package/dist/quota/combined.js +4 -4
  51. package/dist/quota/combined.js.map +1 -1
  52. package/dist/quota/format.d.ts +1 -1
  53. package/dist/quota/opencode-go/format.d.ts.map +1 -1
  54. package/dist/quota/opencode-go/format.js +5 -1
  55. package/dist/quota/opencode-go/format.js.map +1 -1
  56. package/dist/quota/opencode-go/index.d.ts +1 -1
  57. package/dist/quota/opencode-go/index.js +1 -1
  58. package/dist/quota/opencode-go/types.d.ts +1 -1
  59. package/dist/quota/opencode-go/types.js +1 -1
  60. package/dist/quota/rounding.d.ts +8 -0
  61. package/dist/quota/rounding.d.ts.map +1 -0
  62. package/dist/quota/rounding.js +10 -0
  63. package/dist/quota/rounding.js.map +1 -0
  64. package/dist/remote/config.d.ts +1 -1
  65. package/dist/remote/config.d.ts.map +1 -1
  66. package/dist/remote/config.js +1 -1
  67. package/dist/remote/config.js.map +1 -1
  68. package/dist/remote/endpoint.d.ts +1 -1
  69. package/dist/remote/endpoint.js +1 -1
  70. package/dist/remote/hub-server.d.ts +1 -1
  71. package/dist/remote/hub-server.js +1 -1
  72. package/dist/repl/App.d.ts +108 -0
  73. package/dist/repl/App.d.ts.map +1 -0
  74. package/dist/repl/App.js +706 -0
  75. package/dist/repl/App.js.map +1 -0
  76. package/dist/repl/history.d.ts +25 -0
  77. package/dist/repl/history.d.ts.map +1 -0
  78. package/dist/repl/history.js +73 -0
  79. package/dist/repl/history.js.map +1 -0
  80. package/dist/repl/input-buffer.d.ts +77 -0
  81. package/dist/repl/input-buffer.d.ts.map +1 -0
  82. package/dist/repl/input-buffer.js +174 -0
  83. package/dist/repl/input-buffer.js.map +1 -0
  84. package/dist/repl/model.d.ts +275 -0
  85. package/dist/repl/model.d.ts.map +1 -0
  86. package/dist/repl/model.js +596 -0
  87. package/dist/repl/model.js.map +1 -0
  88. package/dist/repl/mouse.d.ts +49 -0
  89. package/dist/repl/mouse.d.ts.map +1 -0
  90. package/dist/repl/mouse.js +165 -0
  91. package/dist/repl/mouse.js.map +1 -0
  92. package/dist/repl/run.d.ts +12 -0
  93. package/dist/repl/run.d.ts.map +1 -0
  94. package/dist/repl/run.js +902 -0
  95. package/dist/repl/run.js.map +1 -0
  96. package/dist/server.d.ts +18 -0
  97. package/dist/server.d.ts.map +1 -1
  98. package/dist/server.js +31 -3
  99. package/dist/server.js.map +1 -1
  100. package/dist/translators/tool-helpers.d.ts.map +1 -1
  101. package/dist/translators/tool-helpers.js +3 -0
  102. package/dist/translators/tool-helpers.js.map +1 -1
  103. package/docs/ARCHITECTURE.md +1 -1
  104. package/docs/BACKLOG.md +40 -21
  105. package/docs/REMOTE-CLIENTS.md +2 -2
  106. package/docs/TROUBLESHOOTING.md +1 -1
  107. package/docs/adr/0007-unified-cli-entry-and-bin-pruning.md +40 -0
  108. package/package.json +9 -4
@@ -0,0 +1,596 @@
1
+ /**
2
+ * Pure REPL turn state machine: folds ACP SessionUpdate notifications for one
3
+ * prompt turn into renderable entries. No React, no I/O — exported for unit
4
+ * tests.
5
+ *
6
+ * Chunk ordering follows what the bridge emits per turn: thought chunks and
7
+ * message chunks arrive interleaved as streams (buffered until the stream
8
+ * switches), tool calls arrive as discrete events keyed by toolCallId, and a
9
+ * tool_call_update may later change only the status of an existing row.
10
+ */
11
+ import stringWidth from "string-width";
12
+ /**
13
+ * Compact plan-quota summary for the prompt line's status row, e.g.
14
+ * `"5h 34% · wk 8%"`. Token windows only (5h / weekly — all GLM exposes);
15
+ * MCP detail lives in the full `/quota` card, not a one-line indicator, and
16
+ * unknown future windows are skipped rather than mislabeled. Returns null
17
+ * when there is nothing worth showing (fetch failed / auth expired /
18
+ * transient busy) so the row degrades to its previous form instead of
19
+ * nagging.
20
+ */
21
+ export function formatQuotaLine(result) {
22
+ if (result === null || result.kind !== "success")
23
+ return null;
24
+ const parts = [];
25
+ for (const item of result.items) {
26
+ const label = item.key === "token_5h" ? "5h" : item.key === "token_week" ? "wk" : null;
27
+ if (label === null)
28
+ continue;
29
+ // Compact status-line readout: integer percents on purpose — the 0.1-step
30
+ // precision rule (quota/rounding.ts) belongs to the /quota card only.
31
+ parts.push(`${label} ${Math.round(item.usedPercent)}%`);
32
+ }
33
+ return parts.length > 0 ? parts.join(" · ") : null;
34
+ }
35
+ /**
36
+ * Estimated rendered line count of `text` when wrapped at `width` display
37
+ * columns (CJK-aware via string-width). Word-wrap vs hard-cut can differ by a
38
+ * line on pathological words — close enough for viewport slicing.
39
+ */
40
+ export function estimateLines(text, width) {
41
+ if (width <= 0)
42
+ return 1;
43
+ let lines = 0;
44
+ for (const raw of text.split("\n")) {
45
+ lines += Math.max(1, Math.ceil(stringWidth(raw) / width));
46
+ }
47
+ return lines;
48
+ }
49
+ /**
50
+ * Hard-wrap the (logically single-line, "\n"-tolerant) editor text into visual
51
+ * rows of at most `width` display columns. CJK-aware via string-width; a
52
+ * character wider than a whole row still occupies its own row.
53
+ */
54
+ export function wrapEditorLine(text, width) {
55
+ if (width <= 0)
56
+ return [{ text, start: 0 }];
57
+ const rows = [];
58
+ let current = "";
59
+ let start = 0;
60
+ let used = 0;
61
+ const cps = Array.from(text);
62
+ cps.forEach((ch, i) => {
63
+ if (ch === "\n") {
64
+ rows.push({ text: current, start });
65
+ current = "";
66
+ start = i + 1;
67
+ used = 0;
68
+ return;
69
+ }
70
+ const w = stringWidth(ch);
71
+ if (used > 0 && used + w > width) {
72
+ rows.push({ text: current, start });
73
+ current = "";
74
+ start = i;
75
+ used = 0;
76
+ }
77
+ current += ch;
78
+ used += w;
79
+ });
80
+ if (current || text.endsWith("\n") || text === "")
81
+ rows.push({ text: current, start });
82
+ // A "\n" at the exact end already closed an empty trailing row above.
83
+ return rows.length > 0 ? rows : [{ text: "", start: 0 }];
84
+ }
85
+ /** Locate the caret within wrapEditorLine's layout. O(caret), fine for prompts. */
86
+ export function locateCaret(text, caret, width) {
87
+ const clamped = Math.max(0, Math.min(Array.from(text).length, caret));
88
+ const rows = wrapEditorLine(text, width);
89
+ // Width-based placement alone would misplace the caret when wide chars
90
+ // straddle a cut boundary, so anchor on each row's start offset instead.
91
+ const rowIndexAtStart = new Map();
92
+ rows.forEach((r, idx) => rowIndexAtStart.set(r.start, idx));
93
+ let row = 0;
94
+ let col = 0;
95
+ let rowOffset = 0;
96
+ Array.from(text)
97
+ .slice(0, clamped)
98
+ .forEach((ch, i) => {
99
+ const mapped = rowIndexAtStart.get(i);
100
+ if (mapped !== undefined) {
101
+ row = mapped;
102
+ col = 0;
103
+ rowOffset = 0;
104
+ }
105
+ col += stringWidth(ch);
106
+ rowOffset += 1;
107
+ });
108
+ // Caret sitting exactly on a row's start offset belongs to THAT row's head
109
+ // (start-of-next-line), not past the previous row's last column.
110
+ const atBoundary = rowIndexAtStart.get(clamped);
111
+ if (clamped > 0 && atBoundary !== undefined) {
112
+ return { row: atBoundary, col: 0, rowOffset: 0, totalRows: rows.length };
113
+ }
114
+ return {
115
+ row: Math.min(row, rows.length - 1),
116
+ col,
117
+ rowOffset,
118
+ totalRows: rows.length,
119
+ };
120
+ }
121
+ /**
122
+ * Widest prompt prefix the input box ever shows ("starting… " while the
123
+ * bridge session initializes). Text-row reservation for the app layout uses
124
+ * this narrowest inner width so reserved rows NEVER undercount what
125
+ * InputLine actually renders — an undercount makes ink's frame overflow the
126
+ * terminal (see the completion-menu note in App.tsx).
127
+ */
128
+ const INPUT_PREFIX_COLS = stringWidth("starting… ");
129
+ /** Visual text rows of the input editor at terminal width `cols`. */
130
+ export function editorTextRows(text, cols) {
131
+ const inner = Math.max(4, cols - 2 - INPUT_PREFIX_COLS);
132
+ return wrapEditorLine(text, inner).length;
133
+ }
134
+ /**
135
+ * Rows the whole bordered input box occupies: 2 border + status row + text.
136
+ * Used by both the layout fold (App) and as InputLine's own height — keep in
137
+ * one place so they can never drift apart.
138
+ */
139
+ export function inputBoxRows(editorText, cols) {
140
+ return editorTextRows(editorText, cols) + 3;
141
+ }
142
+ /**
143
+ * Sliding viewport over a picker's full item list: pinned to the head while
144
+ * the selection fits in the first window, then the selection rides the
145
+ * window's bottom edge one row per step until the list tail clamps it.
146
+ * Pickers stay short no matter how many sessions/options exist — rendering
147
+ * the full list would blow up the dynamic footer and jolt the scrollback.
148
+ */
149
+ export function pickerWindow(items, index, max = 8) {
150
+ if (items.length === 0)
151
+ return { slice: [], start: 0 };
152
+ const size = Math.min(Math.max(1, max), items.length);
153
+ const clampedIndex = Math.max(0, Math.min(index, items.length - 1));
154
+ const start = Math.min(Math.max(0, clampedIndex - size + 1), items.length - size);
155
+ return { slice: items.slice(start, start + size), start };
156
+ }
157
+ export function createTurnState() {
158
+ return { entries: [], textBuf: "", thinkBuf: "" };
159
+ }
160
+ /** Extract displayable text from any content block shape (text/thought). */
161
+ function blockText(content) {
162
+ if (content && typeof content === "object" && "text" in content) {
163
+ const t = content.text;
164
+ return typeof t === "string" ? t : "";
165
+ }
166
+ return "";
167
+ }
168
+ /**
169
+ * Fold pending stream buffers into entries. The live tail renders entries
170
+ * first and the streaming buffers last, so a segment that starts later must
171
+ * not stay buffered below entries that streamed earlier — flush on every
172
+ * transition to keep the tail in stream order. At most one buffer is
173
+ * non-empty between transitions; both are handled for safety.
174
+ */
175
+ function flushBuffers(next) {
176
+ if (next.thinkBuf.trim()) {
177
+ next.entries = [...next.entries, { kind: "thinking", text: next.thinkBuf.trim() }];
178
+ next.thinkBuf = "";
179
+ }
180
+ if (next.textBuf.trim()) {
181
+ next.entries = [...next.entries, { kind: "assistant", text: next.textBuf.trim() }];
182
+ next.textBuf = "";
183
+ }
184
+ }
185
+ /**
186
+ * Apply one update to the live turn state. Returns a NEW state object (safe
187
+ * for React-style always-replace updates). Unknown update kinds are ignored.
188
+ */
189
+ export function applyUpdate(state, update) {
190
+ const next = {
191
+ entries: state.entries,
192
+ textBuf: state.textBuf,
193
+ thinkBuf: state.thinkBuf,
194
+ };
195
+ switch (update.sessionUpdate) {
196
+ case "agent_message_chunk": {
197
+ const chunk = blockText(update.content);
198
+ // Entering prose flushes the thought stream as its own dim entry.
199
+ // Continuation chunks must not re-flush, and the buffer side is
200
+ // trim-tested: a whitespace-only thought chunk must not count as a
201
+ // segment (it would otherwise shred every following prose chunk into
202
+ // its own entry).
203
+ if (chunk && next.thinkBuf.trim())
204
+ flushBuffers(next);
205
+ next.textBuf = next.textBuf + chunk;
206
+ return next;
207
+ }
208
+ case "agent_thought_chunk": {
209
+ const chunk = blockText(update.content);
210
+ // Symmetric: entering thinking flushes the prose segment as its own
211
+ // entry — otherwise it stays pinned below every later entry until the
212
+ // turn ends and the tail renders out of stream order.
213
+ if (chunk.trim() && !next.thinkBuf.trim())
214
+ flushBuffers(next);
215
+ next.thinkBuf = next.thinkBuf + chunk;
216
+ return next;
217
+ }
218
+ case "tool_call":
219
+ case "tool_call_update": {
220
+ const id = update.toolCallId ?? "";
221
+ const title = update.title ?? id;
222
+ const status = update.status ?? "pending";
223
+ const idx = next.entries.findIndex((e) => e.kind === "tool" && e.id === id && id !== "");
224
+ // tool_call_update may arrive for a call we never saw (pre-turn replay
225
+ // leftovers); render it as a fresh row instead of dropping it.
226
+ if (idx >= 0) {
227
+ const old = next.entries[idx];
228
+ if (old.kind === "tool") {
229
+ const entries = [...next.entries];
230
+ entries[idx] = { kind: "tool", id, title: update.title ?? old.title, status };
231
+ next.entries = entries;
232
+ }
233
+ }
234
+ else {
235
+ // A fresh row starts a non-prose segment: flush pending buffers so
236
+ // the row lands after everything streamed before it. In-place status
237
+ // updates keep buffers alone — a live thinking stream would shred
238
+ // into fragments on every status change.
239
+ flushBuffers(next);
240
+ next.entries = [...next.entries, { kind: "tool", id, title, status }];
241
+ }
242
+ return next;
243
+ }
244
+ case "plan": {
245
+ // First version renders plans as a one-line note; full plan UI is a
246
+ // follow-up. Counts entries when the shape provides them.
247
+ flushBuffers(next);
248
+ const items = Array.isArray(update.entries) ? update.entries.length : 0;
249
+ next.entries = [
250
+ ...next.entries,
251
+ { kind: "note", text: items > 0 ? `plan · ${items} steps` : "plan updated" },
252
+ ];
253
+ return next;
254
+ }
255
+ default:
256
+ return next;
257
+ }
258
+ }
259
+ /**
260
+ * Close out a turn: flush any pending thought/text buffers as final entries
261
+ * and append the stop-reason note. Returns only the finished entries — the
262
+ * turn state is discarded afterwards.
263
+ */
264
+ export function finishTurn(state, stopReason) {
265
+ const entries = [...state.entries];
266
+ if (state.thinkBuf.trim())
267
+ entries.push({ kind: "thinking", text: state.thinkBuf.trim() });
268
+ if (state.textBuf.trim())
269
+ entries.push({ kind: "assistant", text: state.textBuf.trim() });
270
+ if (stopReason && stopReason !== "end_turn") {
271
+ entries.push({ kind: "note", text: `stopped: ${stopReason}` });
272
+ }
273
+ return entries;
274
+ }
275
+ export function parseCommand(text) {
276
+ const t = text.trim();
277
+ if (t === "/exit" || t === "/quit" || t === "/q")
278
+ return "exit";
279
+ if (t === "/sessions")
280
+ return "sessions";
281
+ if (t === "/new")
282
+ return "new";
283
+ return null;
284
+ }
285
+ /**
286
+ * Compact relative age for a session's `updatedAt` ("just now", "5m ago",
287
+ * "2h ago", "3d ago", else the ISO date). Empty for absent/unparsable input.
288
+ */
289
+ export function relativeTime(iso) {
290
+ if (!iso)
291
+ return "";
292
+ const t = Date.parse(iso);
293
+ if (Number.isNaN(t))
294
+ return "";
295
+ const diff = Date.now() - t;
296
+ if (diff < 60_000)
297
+ return "just now";
298
+ const mins = Math.floor(diff / 60_000);
299
+ if (mins < 60)
300
+ return `${mins}m ago`;
301
+ const hours = Math.floor(mins / 60);
302
+ if (hours < 24)
303
+ return `${hours}h ago`;
304
+ const days = Math.floor(hours / 24);
305
+ if (days < 30)
306
+ return `${days}d ago`;
307
+ return new Date(t).toISOString().slice(0, 10);
308
+ }
309
+ export function createReplStatus() {
310
+ return { commands: [], model: null, mode: null, thought: null };
311
+ }
312
+ /** Shared by both lists below so /help and /exit keep one description each. */
313
+ const HELP_COMMAND = { name: "help", description: "list commands (REPL-local)" };
314
+ const NEW_COMMAND = { name: "new", description: "start a fresh session" };
315
+ const EXIT_COMMAND = { name: "exit", description: "quit the REPL" };
316
+ /** Commands shown before the bridge's first `available_commands_update`. */
317
+ export const FALLBACK_COMMANDS = [
318
+ HELP_COMMAND,
319
+ { name: "model", description: "show or switch model" },
320
+ { name: "mode", description: "show or switch mode" },
321
+ { name: "thought", description: "show or switch thought level" },
322
+ { name: "compact", description: "compact conversation context" },
323
+ { name: "mcp", description: "list configured MCP servers" },
324
+ { name: "quota", description: "show plan usage card" },
325
+ NEW_COMMAND,
326
+ EXIT_COMMAND,
327
+ ];
328
+ /** REPL-local commands, always offered regardless of what the bridge advertises. */
329
+ const LOCAL_COMMANDS = [
330
+ HELP_COMMAND,
331
+ { name: "sessions", description: "list and resume project sessions" },
332
+ NEW_COMMAND,
333
+ EXIT_COMMAND,
334
+ ];
335
+ /**
336
+ * The command menu: bridge-advertised commands (or the fallback list before
337
+ * the first push) with the REPL-local entries merged in front — without the
338
+ * merge, /help and /exit vanish from completion and /help output as soon as
339
+ * the bridge's own list lands (the bridge only advertises ITS commands).
340
+ */
341
+ export function commandMenu(status) {
342
+ const advertised = status.commands.length > 0 ? status.commands : FALLBACK_COMMANDS;
343
+ const locals = LOCAL_COMMANDS.filter((l) => !advertised.some((a) => a.name === l.name));
344
+ return [...locals, ...advertised];
345
+ }
346
+ /**
347
+ * Fold a status-relevant session update into the status. Called for EVERY
348
+ * update (idle and in-turn): the config/command pushes that follow a switch
349
+ * slash-command arrive while that turn is still active. Unknown kinds return
350
+ * the SAME object reference so callers can skip the rerender.
351
+ */
352
+ export function applyStatusUpdate(status, update) {
353
+ switch (update.sessionUpdate) {
354
+ case "available_commands_update": {
355
+ const list = (update.availableCommands ?? []).map((c) => ({
356
+ name: c.name,
357
+ description: c.description ?? "",
358
+ }));
359
+ return { ...status, commands: list };
360
+ }
361
+ case "config_option_update": {
362
+ const next = { ...status };
363
+ for (const opt of update.configOptions ?? []) {
364
+ if (opt.id !== "model" && opt.id !== "mode" && opt.id !== "thought")
365
+ continue;
366
+ // The union also has boolean/toggle variants; only selects carry options.
367
+ if (opt.type !== "select")
368
+ continue;
369
+ // Select entries are options or one-level groups — flatten groups.
370
+ const options = (opt.options ?? []).flatMap((o) => "value" in o
371
+ ? [{ value: o.value, name: o.name ?? o.value }]
372
+ : (o.options ?? []).map((g) => ({ value: g.value, name: g.name ?? g.value })));
373
+ next[opt.id] = { current: opt.currentValue, options };
374
+ }
375
+ return next;
376
+ }
377
+ case "current_mode_update": {
378
+ return {
379
+ ...status,
380
+ mode: { current: update.currentModeId, options: status.mode?.options ?? [] },
381
+ };
382
+ }
383
+ default:
384
+ return status;
385
+ }
386
+ }
387
+ /** Display label for a select's current value (name over raw value). */
388
+ export function selectLabel(select) {
389
+ if (!select)
390
+ return "";
391
+ return select.options.find((o) => o.value === select.current)?.name ?? select.current;
392
+ }
393
+ /**
394
+ * Seed the status from the session/new RESPONSE: the bridge ships the initial
395
+ * model/mode/thought selects in the response body, not as a follow-up
396
+ * notification (later changes do push config_option_update notifications).
397
+ */
398
+ export function seedStatusFromNewSession(status, response) {
399
+ return applyStatusUpdate(status, {
400
+ sessionUpdate: "config_option_update",
401
+ configOptions: response.configOptions ?? [],
402
+ });
403
+ }
404
+ /**
405
+ * Render a config select as note lines: one per option, current marked with a
406
+ * bullet. The raw `value` is what the user types after /model etc., so it is
407
+ * shown whenever it differs from the display name (third-party models).
408
+ */
409
+ export function formatConfigList(title, select) {
410
+ if (!select || select.options.length === 0) {
411
+ return [`${title}: no options advertised yet`];
412
+ }
413
+ const lines = [`${title}:`];
414
+ for (const o of select.options) {
415
+ const mark = o.value === select.current ? "●" : " ";
416
+ const hint = o.value !== o.name ? ` (${o.value})` : "";
417
+ lines.push(`${mark} ${o.name}${hint}`);
418
+ }
419
+ return lines;
420
+ }
421
+ function helpEntries(status) {
422
+ const lines = ["commands:"];
423
+ for (const c of commandMenu(status)) {
424
+ lines.push(` /${c.name} — ${c.description}`);
425
+ }
426
+ lines.push("/model, /mode, /thought without an argument list options; with one they switch.");
427
+ return lines.map((text) => ({ kind: "note", text }));
428
+ }
429
+ /**
430
+ * REPL-local commands that never reach the bridge: `/help`, and the arg-less
431
+ * listing form of `/model` `/mode` `/thought` (the bridge rejects those with
432
+ * -32602). Everything else — including the switch forms with an argument —
433
+ * returns null and is sent as a prompt (the bridge's slash interception is
434
+ * the battle-tested path editors use).
435
+ */
436
+ export function handleLocalCommand(text, status) {
437
+ const stripped = text.trim();
438
+ if (!stripped.startsWith("/"))
439
+ return null;
440
+ const spaceIdx = stripped.indexOf(" ");
441
+ const cmd = (spaceIdx < 0 ? stripped : stripped.slice(0, spaceIdx)).toLowerCase();
442
+ const hasArg = spaceIdx >= 0 && stripped.slice(spaceIdx + 1).trim().length > 0;
443
+ if (cmd === "/help")
444
+ return helpEntries(status);
445
+ if (cmd === "/model" || cmd === "/mode" || cmd === "/thought") {
446
+ if (hasArg)
447
+ return null;
448
+ const key = cmd.slice(1);
449
+ return formatConfigList(cmd, status[key]).map((text) => ({ kind: "note", text }));
450
+ }
451
+ return null;
452
+ }
453
+ /**
454
+ * Max rows the menu renders — longer lists narrow with the typed prefix.
455
+ * Also the FIXED slot count of the rendered menu block (blanks beyond the
456
+ * candidate count): constant height keeps ink's frame updates equal-size,
457
+ * which is what keeps the top highlight visible (see App.tsx menu block).
458
+ */
459
+ export const COMPLETION_LIMIT = 8;
460
+ /** Commands whose single argument is completable from the config selects. */
461
+ const CONFIG_COMMANDS = new Set(["model", "mode", "thought"]);
462
+ /** Whether `cmd` (bare name, no slash) takes a completable config argument. */
463
+ export function isConfigCommand(cmd) {
464
+ return CONFIG_COMMANDS.has(cmd);
465
+ }
466
+ /**
467
+ * True when the line sits in a config command's argument menu ("/model v…").
468
+ * There the highlighted option IS the decision — enter executes the switch
469
+ * directly. Every other completion context (command names, skill commands,
470
+ * plugins) only FILLS the line; sending stays the user's explicit choice.
471
+ * Only meaningful when a completion menu is open (line starts with "/").
472
+ */
473
+ export function isConfigArgumentMenu(value) {
474
+ if (!value.startsWith("/"))
475
+ return false;
476
+ const spaceIdx = value.indexOf(" ");
477
+ if (spaceIdx < 0)
478
+ return false;
479
+ return CONFIG_COMMANDS.has(value.slice(1, spaceIdx).toLowerCase());
480
+ }
481
+ /**
482
+ * Bare command names whose whole action needs no input ("exit", "help", ...):
483
+ * enter ON PICK runs them directly, like config argument menus. Anything not
484
+ * listed here — skills, plugin commands, unknown advertised names — keeps
485
+ * fill semantics because its bare form usually expects an argument, and
486
+ * sending must stay the user's explicit act.
487
+ */
488
+ const ONE_SHOT_COMMANDS = new Set(["help", "sessions", "new", "exit", "compact", "mcp", "quota"]);
489
+ /** Whether the "/"-prefixed single-token line executes immediately when picked. */
490
+ export function isOneShotCommandValue(value) {
491
+ if (!value.startsWith("/") || value.indexOf(" ") >= 0)
492
+ return false;
493
+ return ONE_SHOT_COMMANDS.has(value.slice(1).toLowerCase());
494
+ }
495
+ /**
496
+ * Completion candidates for the current line, or null outside a completion
497
+ * context:
498
+ * - "/par" → advertised commands matching the prefix ("/" alone = all)
499
+ * - "/model v" → model option values/names matching the argument prefix
500
+ * - other text, a second space, or a select not yet advertised → null/[]
501
+ */
502
+ export function completionCandidates(value, status) {
503
+ if (!value.startsWith("/"))
504
+ return null;
505
+ const spaceIdx = value.indexOf(" ");
506
+ if (spaceIdx < 0) {
507
+ const query = value.slice(1).toLowerCase();
508
+ return commandMenu(status)
509
+ .filter((c) => c.name.toLowerCase().startsWith(query))
510
+ .slice(0, COMPLETION_LIMIT)
511
+ .map((c) => ({ value: `/${c.name}`, label: `/${c.name}`, description: c.description }));
512
+ }
513
+ const cmd = value.slice(1, spaceIdx).toLowerCase();
514
+ if (!CONFIG_COMMANDS.has(cmd))
515
+ return null;
516
+ const arg = value.slice(spaceIdx + 1);
517
+ if (arg.includes(" "))
518
+ return null; // past the single argument
519
+ const select = status[cmd];
520
+ if (!select)
521
+ return null;
522
+ const query = arg.toLowerCase();
523
+ return select.options
524
+ .filter((o) => o.value.toLowerCase().startsWith(query) || o.name.toLowerCase().startsWith(query))
525
+ .slice(0, COMPLETION_LIMIT)
526
+ .map((o) => ({
527
+ value: o.value,
528
+ label: o.name,
529
+ description: o.value !== o.name ? o.value : undefined,
530
+ current: o.value === select.current,
531
+ }));
532
+ }
533
+ /**
534
+ * Insert a chosen candidate into the line. Command completions keep a
535
+ * trailing space so the argument menu opens immediately; option completions
536
+ * replace the argument in place (`/model <value>`).
537
+ */
538
+ export function applyCompletion(value, item) {
539
+ const spaceIdx = value.indexOf(" ");
540
+ if (spaceIdx < 0)
541
+ return `${item.value} `;
542
+ return `${value.slice(0, spaceIdx + 1)}${item.value}`;
543
+ }
544
+ /**
545
+ * Parse an `elicitation/create` form payload (the bridge's AskUserQuestion
546
+ * mapping — see `buildAskUserElicitationForm`) into renderable questions:
547
+ * `q_<i>` string fields with `oneOf` const/title options (single-select) or
548
+ * array fields with `items.anyOf` (multi-select).
549
+ *
550
+ * The `q_<i>_other` free-text companions are skipped (the picker has a
551
+ * built-in custom-answer row) and the skip sentinel option is dropped (esc
552
+ * covers skip). Returns null when the payload has no renderable question.
553
+ */
554
+ export function parseQuestionForm(params) {
555
+ if (!params || typeof params !== "object")
556
+ return null;
557
+ const schema = params.requestedSchema;
558
+ if (!schema || typeof schema !== "object")
559
+ return null;
560
+ const props = schema.properties;
561
+ if (!props || typeof props !== "object")
562
+ return null;
563
+ const entries = Object.entries(props)
564
+ .filter(([key]) => /^q_\d+$/.test(key))
565
+ .sort((a, b) => Number(a[0].slice(2)) - Number(b[0].slice(2)));
566
+ const forms = [];
567
+ for (const [key, prop] of entries) {
568
+ if (!prop || typeof prop !== "object")
569
+ continue;
570
+ const p = prop;
571
+ if (typeof p.title !== "string")
572
+ continue;
573
+ const raw = Array.isArray(p.oneOf)
574
+ ? p.oneOf
575
+ : Array.isArray(p.items?.anyOf)
576
+ ? p.items.anyOf
577
+ : null;
578
+ if (raw === null)
579
+ continue;
580
+ const options = [];
581
+ for (const o of raw) {
582
+ if (!o || typeof o !== "object")
583
+ continue;
584
+ const value = o.const;
585
+ if (typeof value !== "string" || value === "__skip__")
586
+ continue;
587
+ const title = o.title;
588
+ options.push({ value, label: typeof title === "string" ? title : value });
589
+ }
590
+ if (options.length === 0)
591
+ continue;
592
+ forms.push({ key, title: p.title, multiSelect: p.type === "array", options });
593
+ }
594
+ return forms.length > 0 ? forms : null;
595
+ }
596
+ //# sourceMappingURL=model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.js","sourceRoot":"","sources":["../../src/repl/model.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,WAAW,MAAM,cAAc,CAAC;AASvC;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAAC,MAA0B;IACxD,IAAI,MAAM,KAAK,IAAI,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IAC9D,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;QAChC,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,KAAK,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,KAAK,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;QACvF,IAAI,KAAK,KAAK,IAAI;YAAE,SAAS;QAC7B,0EAA0E;QAC1E,sEAAsE;QACtE,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAC1D,CAAC;IACD,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC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