@causyne/agent 1.20.62 → 1.20.63
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/README.md +2 -2
- package/package.json +1 -1
- package/src/acp/client.js +48 -0
- package/src/acp/client.ts +44 -0
- package/src/agentLoop.js +181 -11
- package/src/agentLoop.ts +184 -11
- package/src/cliMode.js +9 -0
- package/src/commands.js +31 -0
- package/src/decisionPolicy.js +18 -1
- package/src/decisionPolicy.ts +18 -1
- package/src/implementationPlan.js +26 -0
- package/src/implementationPlan.ts +25 -0
- package/src/observer/coldObserver.js +6 -1
- package/src/observer/coldObserver.ts +6 -1
- package/src/observer.js +24 -2
- package/src/observer.ts +24 -2
- package/src/providers/acp.js +2 -8
- package/src/providers/acp.ts +2 -8
- package/src/providers/antigravity.js +7 -10
- package/src/providers/antigravity.ts +7 -10
- package/src/smartToolsUse.js +1 -1
- package/src/smartToolsUse.ts +1 -1
- package/src/toolPacks.js +1 -1
- package/src/toolPacks.ts +1 -1
- package/src/tools/toolSelfRepair.js +51 -8
- package/src/tools/toolSelfRepair.ts +42 -9
- package/src/tui/CausyneRotor.js +234 -0
- package/src/tui/CausyneRotor.ts +280 -0
- package/src/tui/activityLayout.js +1 -1
- package/src/tui/activityLayout.ts +1 -1
- package/src/tui/chatRenderer.js +56 -7
- package/src/tui/chatboxClipboard.js +96 -10
- package/src/tui/chatboxClipboard.ts +121 -11
- package/src/tui/clipboardImage.js +308 -0
- package/src/tui/clipboardImage.ts +320 -0
- package/src/tui/codeStreamRenderer.js +89 -1
- package/src/tui/codeStreamRenderer.ts +109 -1
- package/src/tui/dialogs.js +5 -2
- package/src/tui/engineSpinner.js +20 -0
- package/src/tui/engineSpinner.ts +46 -0
- package/src/tui/lineEditor.js +44 -12
- package/src/tui/messageInteraction.js +16 -5
- package/src/tui/messageInteraction.ts +14 -5
- package/src/tui/observerPicker.js +4 -8
- package/src/tui/observerPicker.ts +4 -8
- package/src/tui/prompt.js +70 -40
- package/src/tui/runningLight.js +213 -0
- package/src/tui/runningLight.ts +271 -0
- package/src/tui/sessionSidebar.js +7 -1
- package/src/tui/sessionSidebar.ts +7 -1
- package/src/tui/stage.js +4 -4
- package/src/tui/stageSurface.js +21 -14
- package/src/tui/statusLine.js +27 -4
- package/src/tui/statusLine.ts +27 -4
- package/src/tui/theme.js +5 -2
- package/src/tui/thinkingBox.js +41 -10
- package/src/tui/thinkingBox.ts +43 -10
- package/src/tui/turnRail.js +155 -24
- package/src/tui/turnRail.ts +170 -22
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Engine Spinner Adapter for CausyneRotor.
|
|
3
|
+
*
|
|
4
|
+
* Bridges the terminal spinner interfaces directly to CausyneRotor.ts.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export {
|
|
8
|
+
renderCausyneRotor,
|
|
9
|
+
startCausyneRotor,
|
|
10
|
+
getRotorSpinnerFrames,
|
|
11
|
+
getRotorSpinnerFrame,
|
|
12
|
+
getAnimatedDots,
|
|
13
|
+
formatAnimatedStatus,
|
|
14
|
+
COLORS,
|
|
15
|
+
type RotorMotion,
|
|
16
|
+
type RotorOptions,
|
|
17
|
+
} from './CausyneRotor.js';
|
|
18
|
+
|
|
19
|
+
import {
|
|
20
|
+
getRotorSpinnerFrames,
|
|
21
|
+
getRotorSpinnerFrame,
|
|
22
|
+
} from './CausyneRotor.js';
|
|
23
|
+
|
|
24
|
+
export type EngineSpinnerStyle = 'turbine' | 'iris' | 'reactor' | 'compact' | 'ascii';
|
|
25
|
+
|
|
26
|
+
export interface EngineSpinnerOptions {
|
|
27
|
+
style?: EngineSpinnerStyle | undefined;
|
|
28
|
+
unicode?: boolean | undefined;
|
|
29
|
+
color?: boolean | 'truecolor' | '256' | '16' | 'none' | undefined;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function detectSpinnerStyle(): EngineSpinnerStyle {
|
|
33
|
+
return 'turbine';
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function getEngineFrames(options: EngineSpinnerOptions = {}): readonly string[] {
|
|
37
|
+
const unicode = options.unicode !== false;
|
|
38
|
+
const color = options.color !== false && options.color !== 'none';
|
|
39
|
+
return getRotorSpinnerFrames(color, unicode);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function getEngineFrame(tick: number, options: EngineSpinnerOptions = {}): string {
|
|
43
|
+
const unicode = options.unicode !== false;
|
|
44
|
+
const color = options.color !== false && options.color !== 'none';
|
|
45
|
+
return getRotorSpinnerFrame(tick, color, unicode);
|
|
46
|
+
}
|
package/src/tui/lineEditor.js
CHANGED
|
@@ -366,38 +366,70 @@ export class LineEditor {
|
|
|
366
366
|
const prefixWidth = visibleWidth(prefix);
|
|
367
367
|
const budget = Math.max(1, usable - prefixWidth);
|
|
368
368
|
const line = this.lines[index];
|
|
369
|
+
const isCurrentLine = index === this.line;
|
|
369
370
|
|
|
370
371
|
let row = prefix;
|
|
371
372
|
let used = 0;
|
|
372
373
|
let placed = false;
|
|
373
374
|
|
|
374
|
-
|
|
375
|
-
|
|
375
|
+
let pos = 0;
|
|
376
|
+
while (pos <= line.length) {
|
|
377
|
+
if (isCurrentLine && pos === this.col && !placed) {
|
|
376
378
|
cursorRow = rows.length;
|
|
377
379
|
cursorCol = prefixWidth + used;
|
|
378
380
|
placed = true;
|
|
379
381
|
}
|
|
380
|
-
if (
|
|
382
|
+
if (pos === line.length) break;
|
|
383
|
+
|
|
384
|
+
const isSpace = /\s/.test(line[pos]);
|
|
385
|
+
let nextPos = pos;
|
|
386
|
+
let tokenWidth = 0;
|
|
387
|
+
while (nextPos < line.length && (/\s/.test(line[nextPos]) === isSpace)) {
|
|
388
|
+
tokenWidth += visibleWidth(line[nextPos]);
|
|
389
|
+
nextPos++;
|
|
390
|
+
}
|
|
381
391
|
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
if (used + charWidth > budget) {
|
|
392
|
+
// If non-whitespace word exceeds remaining space on non-empty line: wrap to next line!
|
|
393
|
+
if (used > 0 && used + tokenWidth > budget && !isSpace) {
|
|
385
394
|
rows.push(row);
|
|
386
395
|
row = prefix;
|
|
387
396
|
used = 0;
|
|
388
|
-
|
|
389
|
-
if (placed && cursorRow === rows.length - 1 && cursorCol === prefixWidth + budget) {
|
|
397
|
+
if (isCurrentLine && pos === this.col && !placed) {
|
|
390
398
|
cursorRow = rows.length;
|
|
391
399
|
cursorCol = prefixWidth;
|
|
400
|
+
placed = true;
|
|
392
401
|
}
|
|
393
402
|
}
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
403
|
+
|
|
404
|
+
while (pos < nextPos) {
|
|
405
|
+
if (isCurrentLine && pos === this.col && !placed) {
|
|
406
|
+
cursorRow = rows.length;
|
|
407
|
+
cursorCol = prefixWidth + used;
|
|
408
|
+
placed = true;
|
|
409
|
+
}
|
|
410
|
+
const char = line[pos];
|
|
411
|
+
const charWidth = visibleWidth(char);
|
|
412
|
+
|
|
413
|
+
if (used + charWidth > budget && used > 0) {
|
|
414
|
+
rows.push(row);
|
|
415
|
+
row = prefix;
|
|
416
|
+
used = 0;
|
|
417
|
+
if (isCurrentLine && pos === this.col && !placed) {
|
|
418
|
+
cursorRow = rows.length;
|
|
419
|
+
cursorCol = prefixWidth;
|
|
420
|
+
placed = true;
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
const isSelected = range ? isInsideRange(index, pos, range) : false;
|
|
425
|
+
row += isSelected ? `\x1b[7m${char}\x1b[27m` : char;
|
|
426
|
+
used += charWidth;
|
|
427
|
+
pos++;
|
|
428
|
+
}
|
|
397
429
|
}
|
|
398
430
|
|
|
399
431
|
rows.push(row);
|
|
400
|
-
if (
|
|
432
|
+
if (isCurrentLine && !placed) {
|
|
401
433
|
cursorRow = rows.length - 1;
|
|
402
434
|
cursorCol = prefixWidth + used;
|
|
403
435
|
}
|
|
@@ -224,11 +224,22 @@ export function markHoveredMessage(rows, surface, contentWidth) {
|
|
|
224
224
|
if (row < padding || row >= rows.length)
|
|
225
225
|
continue;
|
|
226
226
|
const existingRow = rows[row] ?? '';
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
227
|
+
let content = existingRow;
|
|
228
|
+
if (transcriptRow === firstContentRow) {
|
|
229
|
+
const plainTrimmed = stripAnsi(existingRow).trimStart();
|
|
230
|
+
const alreadyHasMarker = /^[▸│┃|▌┌└├╭╰▪●•]/.test(plainTrimmed);
|
|
231
|
+
if (!alreadyHasMarker) {
|
|
232
|
+
if (existingRow.startsWith(' ')) {
|
|
233
|
+
content = ` ${paint('accent', '▸')} ${existingRow.slice(3)}`;
|
|
234
|
+
}
|
|
235
|
+
else if (existingRow.startsWith(' ')) {
|
|
236
|
+
content = ` ${paint('accent', '▸')}${existingRow.slice(2)}`;
|
|
237
|
+
}
|
|
238
|
+
else if (existingRow.startsWith(' ')) {
|
|
239
|
+
content = `${paint('accent', '▸')}${existingRow.slice(1)}`;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
232
243
|
rows[row] = fill('surfaceHi', padEnd(content, contentWidth));
|
|
233
244
|
}
|
|
234
245
|
}
|
|
@@ -308,11 +308,20 @@ export function markHoveredMessage(
|
|
|
308
308
|
const row = transcriptRow - surface.viewport.scrollTop + padding;
|
|
309
309
|
if (row < padding || row >= rows.length) continue;
|
|
310
310
|
const existingRow = rows[row] ?? '';
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
311
|
+
let content = existingRow;
|
|
312
|
+
if (transcriptRow === firstContentRow) {
|
|
313
|
+
const plainTrimmed = stripAnsi(existingRow).trimStart();
|
|
314
|
+
const alreadyHasMarker = /^[▸│┃|▌┌└├╭╰▪●•]/.test(plainTrimmed);
|
|
315
|
+
if (!alreadyHasMarker) {
|
|
316
|
+
if (existingRow.startsWith(' ')) {
|
|
317
|
+
content = ` ${paint('accent', '▸')} ${existingRow.slice(3)}`;
|
|
318
|
+
} else if (existingRow.startsWith(' ')) {
|
|
319
|
+
content = ` ${paint('accent', '▸')}${existingRow.slice(2)}`;
|
|
320
|
+
} else if (existingRow.startsWith(' ')) {
|
|
321
|
+
content = `${paint('accent', '▸')}${existingRow.slice(1)}`;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}
|
|
316
325
|
rows[row] = fill('surfaceHi', padEnd(content, contentWidth));
|
|
317
326
|
}
|
|
318
327
|
}
|
|
@@ -184,7 +184,6 @@ export function runInteractiveObserverPicker(prompt) {
|
|
|
184
184
|
// 4. Advisory Endpoint Input
|
|
185
185
|
if (action === 'endpoint') {
|
|
186
186
|
const current = coldObserver.getConfig();
|
|
187
|
-
prompt.closeLayer();
|
|
188
187
|
prompt.openLayer(new InputLayer({
|
|
189
188
|
title: 'Advisory Loopback Endpoint',
|
|
190
189
|
placeholder: 'http://localhost:11434/v1 (or "none" to clear)',
|
|
@@ -211,12 +210,11 @@ export function runInteractiveObserverPicker(prompt) {
|
|
|
211
210
|
openMenu();
|
|
212
211
|
}
|
|
213
212
|
}));
|
|
214
|
-
return;
|
|
213
|
+
return 'handled';
|
|
215
214
|
}
|
|
216
215
|
// 5. Advisory Model Input
|
|
217
216
|
if (action === 'model') {
|
|
218
217
|
const current = coldObserver.getConfig();
|
|
219
|
-
prompt.closeLayer();
|
|
220
218
|
prompt.openLayer(new InputLayer({
|
|
221
219
|
title: 'Advisory Model Name',
|
|
222
220
|
placeholder: 'model name (e.g. tiny, qwen2.5-coder) or "none"',
|
|
@@ -237,11 +235,10 @@ export function runInteractiveObserverPicker(prompt) {
|
|
|
237
235
|
openMenu();
|
|
238
236
|
}
|
|
239
237
|
}));
|
|
240
|
-
return;
|
|
238
|
+
return 'handled';
|
|
241
239
|
}
|
|
242
240
|
// 6. Test Advisory Endpoint
|
|
243
241
|
if (action === 'test') {
|
|
244
|
-
prompt.closeLayer();
|
|
245
242
|
void coldObserver.healthCheck().then((health) => {
|
|
246
243
|
const textLines = health.endpoint
|
|
247
244
|
? [
|
|
@@ -266,11 +263,10 @@ export function runInteractiveObserverPicker(prompt) {
|
|
|
266
263
|
onDismiss: () => openMenu()
|
|
267
264
|
}));
|
|
268
265
|
});
|
|
269
|
-
return;
|
|
266
|
+
return 'handled';
|
|
270
267
|
}
|
|
271
268
|
// 7. Audit History
|
|
272
269
|
if (action === 'audit') {
|
|
273
|
-
prompt.closeLayer();
|
|
274
270
|
const recentAudits = coldObserver.getAuditHistory();
|
|
275
271
|
const lines = recentAudits.length === 0
|
|
276
272
|
? ['No Cold Observer audit records yet.', '', 'Press Esc or Enter to return to Observer setup.']
|
|
@@ -288,7 +284,7 @@ export function runInteractiveObserverPicker(prompt) {
|
|
|
288
284
|
height: 18,
|
|
289
285
|
onDismiss: () => openMenu()
|
|
290
286
|
}));
|
|
291
|
-
return;
|
|
287
|
+
return 'handled';
|
|
292
288
|
}
|
|
293
289
|
// 8. Reset Defaults
|
|
294
290
|
if (action === 'reset') {
|
|
@@ -238,7 +238,6 @@ export function runInteractiveObserverPicker(prompt: PromptHost): Promise<string
|
|
|
238
238
|
// 4. Advisory Endpoint Input
|
|
239
239
|
if (action === 'endpoint') {
|
|
240
240
|
const current = coldObserver.getConfig();
|
|
241
|
-
prompt.closeLayer();
|
|
242
241
|
prompt.openLayer(new InputLayer({
|
|
243
242
|
title: 'Advisory Loopback Endpoint',
|
|
244
243
|
placeholder: 'http://localhost:11434/v1 (or "none" to clear)',
|
|
@@ -264,13 +263,12 @@ export function runInteractiveObserverPicker(prompt: PromptHost): Promise<string
|
|
|
264
263
|
openMenu();
|
|
265
264
|
}
|
|
266
265
|
}));
|
|
267
|
-
return;
|
|
266
|
+
return 'handled';
|
|
268
267
|
}
|
|
269
268
|
|
|
270
269
|
// 5. Advisory Model Input
|
|
271
270
|
if (action === 'model') {
|
|
272
271
|
const current = coldObserver.getConfig();
|
|
273
|
-
prompt.closeLayer();
|
|
274
272
|
prompt.openLayer(new InputLayer({
|
|
275
273
|
title: 'Advisory Model Name',
|
|
276
274
|
placeholder: 'model name (e.g. tiny, qwen2.5-coder) or "none"',
|
|
@@ -291,12 +289,11 @@ export function runInteractiveObserverPicker(prompt: PromptHost): Promise<string
|
|
|
291
289
|
openMenu();
|
|
292
290
|
}
|
|
293
291
|
}));
|
|
294
|
-
return;
|
|
292
|
+
return 'handled';
|
|
295
293
|
}
|
|
296
294
|
|
|
297
295
|
// 6. Test Advisory Endpoint
|
|
298
296
|
if (action === 'test') {
|
|
299
|
-
prompt.closeLayer();
|
|
300
297
|
void coldObserver.healthCheck().then((health) => {
|
|
301
298
|
const textLines = health.endpoint
|
|
302
299
|
? [
|
|
@@ -322,12 +319,11 @@ export function runInteractiveObserverPicker(prompt: PromptHost): Promise<string
|
|
|
322
319
|
onDismiss: () => openMenu()
|
|
323
320
|
}));
|
|
324
321
|
});
|
|
325
|
-
return;
|
|
322
|
+
return 'handled';
|
|
326
323
|
}
|
|
327
324
|
|
|
328
325
|
// 7. Audit History
|
|
329
326
|
if (action === 'audit') {
|
|
330
|
-
prompt.closeLayer();
|
|
331
327
|
const recentAudits = coldObserver.getAuditHistory();
|
|
332
328
|
const lines = recentAudits.length === 0
|
|
333
329
|
? ['No Cold Observer audit records yet.', '', 'Press Esc or Enter to return to Observer setup.']
|
|
@@ -346,7 +342,7 @@ export function runInteractiveObserverPicker(prompt: PromptHost): Promise<string
|
|
|
346
342
|
height: 18,
|
|
347
343
|
onDismiss: () => openMenu()
|
|
348
344
|
}));
|
|
349
|
-
return;
|
|
345
|
+
return 'handled';
|
|
350
346
|
}
|
|
351
347
|
|
|
352
348
|
// 8. Reset Defaults
|
package/src/tui/prompt.js
CHANGED
|
@@ -30,6 +30,8 @@ import { renderUsageCardRows, collectUsageCardData } from './usageCard.js';
|
|
|
30
30
|
import { commandPalette, skillPicker, ApprovalLayer, DecisionLayer, ConfirmLayer, HomeLayer, TextLayer } from './dialogs.js';
|
|
31
31
|
import { describeTool } from './toolDisplay.js';
|
|
32
32
|
import { readClipboardSync, writeClipboardSync } from './clipboardSync.js';
|
|
33
|
+
import { readClipboardImageSync, formatByteSize, loadLocalImageAttachment } from './clipboardImage.js';
|
|
34
|
+
import { pasteIntoChatbox } from './chatboxClipboard.js';
|
|
33
35
|
import { handleViewportWheel, handleScrollbarMouse } from './scrollInteraction.js';
|
|
34
36
|
import { centerRows, sessionRows, dialogWidth, dialogHeight } from './layout.js';
|
|
35
37
|
import { settleStageResize } from './resizeRecovery.js';
|
|
@@ -169,6 +171,7 @@ export class ChatPrompt {
|
|
|
169
171
|
this.redrawScheduled = false;
|
|
170
172
|
this.resizeTimer = null;
|
|
171
173
|
this.suspendedSurface = null;
|
|
174
|
+
this.pendingAttachments = [];
|
|
172
175
|
}
|
|
173
176
|
|
|
174
177
|
// -------------------------------------------------------------------------
|
|
@@ -383,7 +386,8 @@ export class ChatPrompt {
|
|
|
383
386
|
elapsedMs: since ? Date.now() - since : 0,
|
|
384
387
|
steps: this.renderer.stepCount || 0,
|
|
385
388
|
width: Math.max(10, width - 1),
|
|
386
|
-
spinnerFrame: frame
|
|
389
|
+
spinnerFrame: frame,
|
|
390
|
+
tick: this.tick
|
|
387
391
|
})];
|
|
388
392
|
}
|
|
389
393
|
|
|
@@ -437,7 +441,7 @@ export class ChatPrompt {
|
|
|
437
441
|
this.tickTimer = setInterval(() => {
|
|
438
442
|
this.tick++;
|
|
439
443
|
if (this.busy) this.scheduleDraw();
|
|
440
|
-
},
|
|
444
|
+
}, 125);
|
|
441
445
|
if (this.tickTimer.unref) this.tickTimer.unref();
|
|
442
446
|
}
|
|
443
447
|
|
|
@@ -545,7 +549,7 @@ export class ChatPrompt {
|
|
|
545
549
|
showText(title, text, options = {}) {
|
|
546
550
|
const panelWidth = dialogWidth(this.width(), options.width || 76);
|
|
547
551
|
const contentWidth = Math.max(12, panelWidth - 4);
|
|
548
|
-
let lines = wrapBlock(safeDisplay(String(text == null ? '' : text)), contentWidth);
|
|
552
|
+
let lines = wrapBlock(safeDisplay(String(text == null ? '' : text)), contentWidth, { hang: 0 });
|
|
549
553
|
if (lines.length > 0 && lines[0].trim().toLowerCase() === String(title || '').trim().toLowerCase()) {
|
|
550
554
|
lines = lines.slice(1);
|
|
551
555
|
if (lines.length > 0 && /^[-─═_]+$/.test(lines[0].trim())) {
|
|
@@ -696,6 +700,22 @@ export class ChatPrompt {
|
|
|
696
700
|
return false;
|
|
697
701
|
}
|
|
698
702
|
|
|
703
|
+
/**
|
|
704
|
+
* Consume and return any pending multimodal attachments (e.g. pasted screenshots).
|
|
705
|
+
*/
|
|
706
|
+
consumeAttachments() {
|
|
707
|
+
const list = Array.isArray(this.pendingAttachments) ? this.pendingAttachments.slice() : [];
|
|
708
|
+
this.pendingAttachments = [];
|
|
709
|
+
return list;
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
/**
|
|
713
|
+
* Paste clipboard content: seamlessly supports text and screenshot images.
|
|
714
|
+
*/
|
|
715
|
+
pasteClipboard() {
|
|
716
|
+
pasteIntoChatbox(this);
|
|
717
|
+
}
|
|
718
|
+
|
|
699
719
|
setBusy(busy) {
|
|
700
720
|
this.busy = busy;
|
|
701
721
|
resetTurnInterruptState(this, busy);
|
|
@@ -715,6 +735,22 @@ export class ChatPrompt {
|
|
|
715
735
|
this.usageCard = null;
|
|
716
736
|
}
|
|
717
737
|
|
|
738
|
+
// Instant slash command shortcuts that operate directly on the prompt surface
|
|
739
|
+
if (text === '/usage') {
|
|
740
|
+
void this.toggleUsageCard();
|
|
741
|
+
return;
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
if (text === '/observer' || text === '/observer status') {
|
|
745
|
+
import('./observerPicker.js').then(({ runInteractiveObserverPicker }) => {
|
|
746
|
+
void runInteractiveObserverPicker(this);
|
|
747
|
+
}).catch((err) => {
|
|
748
|
+
this.notice = err instanceof Error ? err.message : String(err);
|
|
749
|
+
this.scheduleDraw();
|
|
750
|
+
});
|
|
751
|
+
return;
|
|
752
|
+
}
|
|
753
|
+
|
|
718
754
|
// Control commands take priority over busy turns so the user is never locked out.
|
|
719
755
|
// Commands like /stop, /new, /model, /session, /sessions, /continuum, /clear can interrupt
|
|
720
756
|
// a stalled/long-running turn and execute immediately.
|
|
@@ -741,9 +777,15 @@ export class ChatPrompt {
|
|
|
741
777
|
}
|
|
742
778
|
|
|
743
779
|
if (this.busy) {
|
|
744
|
-
//
|
|
780
|
+
// If user typed another slash command while busy, notify them rather than queuing
|
|
781
|
+
// it as a chat prompt to the model.
|
|
782
|
+
if (this.isCommand(text)) {
|
|
783
|
+
this.notice = `Command ${text} queued — will execute when current turn completes`;
|
|
784
|
+
} else {
|
|
785
|
+
this.notice = `queued (${this.queue.length + 1}) — sends when this turn ends`;
|
|
786
|
+
}
|
|
745
787
|
this.queue.push(text);
|
|
746
|
-
this.
|
|
788
|
+
this.scheduleDraw();
|
|
747
789
|
return;
|
|
748
790
|
}
|
|
749
791
|
|
|
@@ -847,13 +889,7 @@ export class ChatPrompt {
|
|
|
847
889
|
if (this.surface && typeof this.surface.captureMouse === 'function') {
|
|
848
890
|
this.surface.captureMouse();
|
|
849
891
|
}
|
|
850
|
-
this
|
|
851
|
-
if (typeof key.text === 'string' && !key.text.includes('\n') && key.text.length < 60) {
|
|
852
|
-
this.refreshCompletion();
|
|
853
|
-
} else {
|
|
854
|
-
this.completion = null;
|
|
855
|
-
}
|
|
856
|
-
this.scheduleDraw();
|
|
892
|
+
pasteIntoChatbox(this, key.text);
|
|
857
893
|
return;
|
|
858
894
|
}
|
|
859
895
|
|
|
@@ -931,18 +967,7 @@ export class ChatPrompt {
|
|
|
931
967
|
case 'p': return this.openPalette();
|
|
932
968
|
case 'l': return this.clearScreen();
|
|
933
969
|
case 'o': return this.expand();
|
|
934
|
-
case 'v':
|
|
935
|
-
const text = readClipboardSync();
|
|
936
|
-
if (text) {
|
|
937
|
-
this.editor.insert(text);
|
|
938
|
-
this.refreshCompletion();
|
|
939
|
-
this.notice = 'pasted from clipboard';
|
|
940
|
-
} else {
|
|
941
|
-
this.notice = 'clipboard is empty';
|
|
942
|
-
}
|
|
943
|
-
this.scheduleDraw();
|
|
944
|
-
return;
|
|
945
|
-
}
|
|
970
|
+
case 'v': return this.pasteClipboard();
|
|
946
971
|
default: break;
|
|
947
972
|
}
|
|
948
973
|
}
|
|
@@ -979,18 +1004,7 @@ export class ChatPrompt {
|
|
|
979
1004
|
this.scheduleDraw();
|
|
980
1005
|
return;
|
|
981
1006
|
}
|
|
982
|
-
if (key.alt && key.name === 'v')
|
|
983
|
-
const text = readClipboardSync();
|
|
984
|
-
if (text) {
|
|
985
|
-
this.editor.insert(text);
|
|
986
|
-
this.refreshCompletion();
|
|
987
|
-
this.notice = 'pasted from clipboard';
|
|
988
|
-
} else {
|
|
989
|
-
this.notice = 'clipboard is empty';
|
|
990
|
-
}
|
|
991
|
-
this.scheduleDraw();
|
|
992
|
-
return;
|
|
993
|
-
}
|
|
1007
|
+
if (key.alt && key.name === 'v') return this.pasteClipboard();
|
|
994
1008
|
if (key.alt && key.name === 'b') return this.editor.moveWordLeft();
|
|
995
1009
|
if (key.alt && key.name === 'f') return this.editor.moveWordRight();
|
|
996
1010
|
}
|
|
@@ -1505,8 +1519,9 @@ export class ChatPrompt {
|
|
|
1505
1519
|
// surface you are writing INTO. Every row of the block is inset by the same
|
|
1506
1520
|
// gutter, so the caret column is a constant rather than a special case for
|
|
1507
1521
|
// row 0 — which is also one fewer thing for erase() to get wrong.
|
|
1522
|
+
const boxWidth = Math.max(20, width - 1);
|
|
1508
1523
|
const inset = visibleWidth(GLYPHS.bar) + GUTTER;
|
|
1509
|
-
const inner = Math.max(8,
|
|
1524
|
+
const inner = Math.max(8, boxWidth - inset);
|
|
1510
1525
|
const layout = this.editor.render(inner, '');
|
|
1511
1526
|
|
|
1512
1527
|
// Scroll the editor internally rather than growing without bound: keep a
|
|
@@ -1518,8 +1533,17 @@ export class ChatPrompt {
|
|
|
1518
1533
|
const caretRow = layout.cursorRow - top;
|
|
1519
1534
|
let body = window.slice();
|
|
1520
1535
|
|
|
1536
|
+
if (!this.editor.isEmpty) {
|
|
1537
|
+
body = body.map((line) => {
|
|
1538
|
+
if (typeof line !== 'string' || !line.includes('[Image ')) return line;
|
|
1539
|
+
return line.replace(/\[Image (\d+)\]/g, (_m, num) => {
|
|
1540
|
+
return paint('warn', bold(`[Image ${num}]`));
|
|
1541
|
+
});
|
|
1542
|
+
});
|
|
1543
|
+
}
|
|
1544
|
+
|
|
1521
1545
|
if (this.editor.isEmpty && !this.completion) {
|
|
1522
|
-
const idle = fitHints([`try "${this.example}"`, '/ commands', '@ files'], Math.max(8, inner), 'ask anything');
|
|
1546
|
+
const idle = fitHints([`try "${this.example}"`, '/ commands', '@ files', '^V image'], Math.max(8, inner), 'ask anything');
|
|
1523
1547
|
body = [dim(this.busy ? 'type to queue a message…' : idle)];
|
|
1524
1548
|
}
|
|
1525
1549
|
|
|
@@ -1546,7 +1570,7 @@ export class ChatPrompt {
|
|
|
1546
1570
|
const padded = new Array(padTop).fill('')
|
|
1547
1571
|
.concat(body, new Array(padBottom).fill(''));
|
|
1548
1572
|
const boxRows = barBlock(padded, {
|
|
1549
|
-
width,
|
|
1573
|
+
width: boxWidth,
|
|
1550
1574
|
role: this.busy ? 'accent' : 'user',
|
|
1551
1575
|
filled: true,
|
|
1552
1576
|
surface: 'surface',
|
|
@@ -1596,10 +1620,11 @@ export class ChatPrompt {
|
|
|
1596
1620
|
* nothing of ours is on the terminal for erase() to walk back over.
|
|
1597
1621
|
*/
|
|
1598
1622
|
present(all, caretRow, caretCol) {
|
|
1623
|
+
const hideCursor = Boolean(this.busy && this.editor.isEmpty);
|
|
1599
1624
|
if (this.surface) {
|
|
1600
1625
|
this.drawnRows = 0;
|
|
1601
1626
|
this.cursorRow = 0;
|
|
1602
|
-
this.surface.present(all, { row: caretRow, col: caretCol,
|
|
1627
|
+
this.surface.present(all, { row: caretRow, col: caretCol, hideCursor,
|
|
1603
1628
|
modal: Boolean(this.layer), inline: Boolean(this.layer && !isStartupDialog(this.surface)) });
|
|
1604
1629
|
return;
|
|
1605
1630
|
}
|
|
@@ -1612,6 +1637,11 @@ export class ChatPrompt {
|
|
|
1612
1637
|
this.cursorRow = caretRow;
|
|
1613
1638
|
this.out.write('\r');
|
|
1614
1639
|
if (caretCol > 0) this.out.write(`\x1b[${caretCol}C`);
|
|
1640
|
+
if (hideCursor) {
|
|
1641
|
+
this.out.write('\x1b[?25l');
|
|
1642
|
+
} else {
|
|
1643
|
+
this.out.write('\x1b[?25h');
|
|
1644
|
+
}
|
|
1615
1645
|
}
|
|
1616
1646
|
|
|
1617
1647
|
/**
|