@di-code/coding-agent 0.1.3 → 0.1.4
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 +20 -10
- package/dist/core/context-builder.d.ts.map +1 -1
- package/dist/core/context-builder.js +6 -2
- package/dist/core/context-builder.js.map +1 -1
- package/dist/core/image-input.d.ts +1 -1
- package/dist/core/image-input.d.ts.map +1 -1
- package/dist/core/image-input.js +55 -10
- package/dist/core/image-input.js.map +1 -1
- package/dist/core/session/session-storage.d.ts.map +1 -1
- package/dist/core/session/session-storage.js +1 -0
- package/dist/core/session/session-storage.js.map +1 -1
- package/dist/core/session.d.ts +17 -2
- package/dist/core/session.d.ts.map +1 -1
- package/dist/core/session.js +89 -0
- package/dist/core/session.js.map +1 -1
- package/dist/core/tools/bash.d.ts +2 -2
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit-diff.d.ts +25 -0
- package/dist/core/tools/edit-diff.d.ts.map +1 -0
- package/dist/core/tools/edit-diff.js +136 -0
- package/dist/core/tools/edit-diff.js.map +1 -0
- package/dist/core/tools/edit.d.ts +13 -4
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +64 -30
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/read.d.ts +2 -2
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/write.d.ts +2 -2
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js.map +1 -1
- package/dist/entry.js +9 -2
- package/dist/entry.js.map +1 -1
- package/dist/main.d.ts +3 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +34 -6
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive-components.d.ts +2 -0
- package/dist/modes/interactive-components.d.ts.map +1 -1
- package/dist/modes/interactive-components.js +40 -13
- package/dist/modes/interactive-components.js.map +1 -1
- package/dist/modes/interactive-diff.d.ts +8 -0
- package/dist/modes/interactive-diff.d.ts.map +1 -0
- package/dist/modes/interactive-diff.js +78 -0
- package/dist/modes/interactive-diff.js.map +1 -0
- package/dist/modes/interactive-layout.d.ts +4 -0
- package/dist/modes/interactive-layout.d.ts.map +1 -1
- package/dist/modes/interactive-layout.js +4 -0
- package/dist/modes/interactive-layout.js.map +1 -1
- package/dist/modes/interactive-state.d.ts +5 -0
- package/dist/modes/interactive-state.d.ts.map +1 -1
- package/dist/modes/interactive-state.js +64 -11
- package/dist/modes/interactive-state.js.map +1 -1
- package/dist/modes/interactive.d.ts +10 -0
- package/dist/modes/interactive.d.ts.map +1 -1
- package/dist/modes/interactive.js +190 -20
- package/dist/modes/interactive.js.map +1 -1
- package/dist/provider-onboarding.d.ts +8 -1
- package/dist/provider-onboarding.d.ts.map +1 -1
- package/dist/provider-onboarding.js +46 -23
- package/dist/provider-onboarding.js.map +1 -1
- package/dist/rpc-entry.js +1 -1
- package/dist/rpc-entry.js.map +1 -1
- package/dist/startup.d.ts +11 -3
- package/dist/startup.d.ts.map +1 -1
- package/dist/startup.js +216 -87
- package/dist/startup.js.map +1 -1
- package/package.json +5 -4
|
@@ -3,6 +3,8 @@ import { extname, resolve } from "node:path";
|
|
|
3
3
|
import { CombinedAutocompleteProvider, Editor, Key, matchesKey, SelectList, SettingsList, } from "@di-code/tui";
|
|
4
4
|
import { cleanupStaleClipboardImages, clipboardImageDirectory, isClipboardImagePath, readClipboardImagePath, removeClipboardImage, } from "../core/clipboard-image.js";
|
|
5
5
|
import { extractImageAttachments } from "../core/image-input.js";
|
|
6
|
+
import { showInteractiveProviderOnboarding, } from "../provider-onboarding.js";
|
|
7
|
+
import { loadStartupConfiguration, removeGlobalProviderApiKey, resolveStartupRuntime } from "../startup.js";
|
|
6
8
|
import { AutocompleteMenu, InteractiveChat, InteractiveComposer, InteractiveFooter, InteractiveHeader, } from "./interactive-components.js";
|
|
7
9
|
import { InteractiveLayout } from "./interactive-layout.js";
|
|
8
10
|
import { InteractiveProjection } from "./interactive-state.js";
|
|
@@ -10,6 +12,20 @@ export { InteractiveProjection } from "./interactive-state.js";
|
|
|
10
12
|
const IMAGE_EXTENSIONS = new Set([".gif", ".jpeg", ".jpg", ".png", ".webp"]);
|
|
11
13
|
const PASTE_IMAGE_KEY = process.platform === "win32" ? Key.alt("v") : Key.ctrl("v");
|
|
12
14
|
const PASTE_IMAGE_SHORTCUT = process.platform === "win32" ? "Alt+V" : "Ctrl+V";
|
|
15
|
+
const BUILTIN_SLASH_COMMANDS = [
|
|
16
|
+
{ name: "help", description: "Show interactive commands" },
|
|
17
|
+
{ name: "clear", description: "Clear visible messages" },
|
|
18
|
+
{ name: "model", description: "Open the model selector" },
|
|
19
|
+
{ name: "session", description: "Open the session selector" },
|
|
20
|
+
{ name: "theme", description: "Open the theme selector" },
|
|
21
|
+
{ name: "settings", description: "Open the settings selector" },
|
|
22
|
+
{ name: "login", description: "Choose a Provider and save its global API key" },
|
|
23
|
+
{ name: "logout", description: "Remove the current Provider global API key" },
|
|
24
|
+
{ name: "compact", description: "Compact the persisted context now" },
|
|
25
|
+
{ name: "usage", description: "Show token and cost usage" },
|
|
26
|
+
{ name: "retry", description: "Retry the last failed prompt" },
|
|
27
|
+
{ name: "steer", description: "Steer the running agent" },
|
|
28
|
+
];
|
|
13
29
|
function asImageAttachmentReference(pasted, cwd) {
|
|
14
30
|
if (pasted.includes("\n"))
|
|
15
31
|
return pasted;
|
|
@@ -37,6 +53,10 @@ function normalizeDroppedImagePrompt(prompt, cwd) {
|
|
|
37
53
|
? prompt
|
|
38
54
|
: `${imageReference}${normalizeDroppedImagePrompt(prefix[2] ?? "", cwd)}`;
|
|
39
55
|
}
|
|
56
|
+
function steeringCommandArgument(prompt) {
|
|
57
|
+
const match = /^\/steer(?:\s+([\s\S]*))?$/i.exec(prompt);
|
|
58
|
+
return match ? (match[1] ?? "").trim() : undefined;
|
|
59
|
+
}
|
|
40
60
|
export class InteractiveMode {
|
|
41
61
|
projection = new InteractiveProjection();
|
|
42
62
|
root;
|
|
@@ -45,6 +65,7 @@ export class InteractiveMode {
|
|
|
45
65
|
tui;
|
|
46
66
|
sessionChoices;
|
|
47
67
|
extensionHost;
|
|
68
|
+
providerOnboarding;
|
|
48
69
|
readClipboardImagePath;
|
|
49
70
|
clipboardDirectory;
|
|
50
71
|
clipboardFiles = new Set();
|
|
@@ -56,6 +77,7 @@ export class InteractiveMode {
|
|
|
56
77
|
started = false;
|
|
57
78
|
lastFailedPrompt;
|
|
58
79
|
queuedPrompts = [];
|
|
80
|
+
steeringPrompts = [];
|
|
59
81
|
onExit;
|
|
60
82
|
theme = "dark";
|
|
61
83
|
overlay;
|
|
@@ -65,27 +87,17 @@ export class InteractiveMode {
|
|
|
65
87
|
preserveClipboardFiles = false;
|
|
66
88
|
constructor(options) {
|
|
67
89
|
this.session = options.session;
|
|
90
|
+
this.projection.configureFilePreview(this.session.allowedRoot, () => this.refresh());
|
|
68
91
|
this.tui = options.tui;
|
|
69
92
|
this.onExit = options.onExit;
|
|
70
93
|
this.sessionChoices = [...(options.sessions ?? [])];
|
|
71
94
|
this.extensionHost = options.extensionHost;
|
|
95
|
+
this.providerOnboarding = options.providerOnboarding;
|
|
72
96
|
this.readClipboardImagePath = options.readClipboardImagePath ?? readClipboardImagePath;
|
|
73
97
|
this.clipboardDirectory = clipboardImageDirectory(this.session.allowedRoot);
|
|
74
|
-
const commands = [
|
|
75
|
-
{ name: "help", description: "Show interactive commands" },
|
|
76
|
-
{ name: "clear", description: "Clear visible messages" },
|
|
77
|
-
{ name: "model", description: "Open the model selector" },
|
|
78
|
-
{ name: "session", description: "Open the session selector" },
|
|
79
|
-
{ name: "theme", description: "Open the theme selector" },
|
|
80
|
-
{ name: "settings", description: "Open the settings selector" },
|
|
81
|
-
{ name: "compact", description: "Compact the persisted context now" },
|
|
82
|
-
{ name: "usage", description: "Show token and cost usage" },
|
|
83
|
-
{ name: "retry", description: "Retry the last failed prompt" },
|
|
84
|
-
];
|
|
85
|
-
const allCommands = [...commands, ...(this.extensionHost?.listCommands() ?? [])];
|
|
86
98
|
const autocomplete = {
|
|
87
|
-
getSuggestions: (context, autocompleteOptions) => new CombinedAutocompleteProvider(
|
|
88
|
-
applyCompletion: (context, item, prefix) => new CombinedAutocompleteProvider(
|
|
99
|
+
getSuggestions: (context, autocompleteOptions) => new CombinedAutocompleteProvider(this.listSlashCommands(), this.session.allowedRoot).getSuggestions(context, autocompleteOptions),
|
|
100
|
+
applyCompletion: (context, item, prefix) => new CombinedAutocompleteProvider(this.listSlashCommands(), this.session.allowedRoot).applyCompletion(context, item, prefix),
|
|
89
101
|
};
|
|
90
102
|
this.editor = new Editor({
|
|
91
103
|
maxHeight: 3,
|
|
@@ -106,7 +118,7 @@ export class InteractiveMode {
|
|
|
106
118
|
this.editor.onAutocompleteChange = () => this.updateAutocompleteOverlay();
|
|
107
119
|
const readViewState = () => ({
|
|
108
120
|
...this.projection.state,
|
|
109
|
-
model: this.session.modelId
|
|
121
|
+
model: `${this.session.modelId}${this.session.thinkingLevel ? `(${this.session.thinkingLevel})` : ""}`,
|
|
110
122
|
theme: this.theme,
|
|
111
123
|
pasteImageShortcut: PASTE_IMAGE_SHORTCUT,
|
|
112
124
|
});
|
|
@@ -170,6 +182,21 @@ export class InteractiveMode {
|
|
|
170
182
|
this.onExit?.();
|
|
171
183
|
}
|
|
172
184
|
handleCommand(data) {
|
|
185
|
+
if (matchesKey(data, Key.alt("s"))) {
|
|
186
|
+
void this.submitSteering(this.editor.getValue());
|
|
187
|
+
return true;
|
|
188
|
+
}
|
|
189
|
+
if (data === "\x1b[Z") {
|
|
190
|
+
try {
|
|
191
|
+
const level = this.session.cycleThinkingLevel();
|
|
192
|
+
this.projection.setStatus(level ? `thinking=${level}` : "Current model does not support thinking levels.");
|
|
193
|
+
}
|
|
194
|
+
catch (cause) {
|
|
195
|
+
this.projection.setError(cause instanceof Error ? cause.message : String(cause));
|
|
196
|
+
}
|
|
197
|
+
this.refresh();
|
|
198
|
+
return true;
|
|
199
|
+
}
|
|
173
200
|
if (data === "\x14") {
|
|
174
201
|
this.openThemeSelector();
|
|
175
202
|
return true;
|
|
@@ -331,10 +358,16 @@ export class InteractiveMode {
|
|
|
331
358
|
items: this.editor.getAutocompleteItems(),
|
|
332
359
|
index: this.editor.getAutocompleteIndex(),
|
|
333
360
|
}));
|
|
361
|
+
const editorBounds = this.root.getEditorBounds(this.tui.columns);
|
|
334
362
|
this.autocompleteOverlay = this.tui.showOverlay(menu, {
|
|
335
363
|
width: "55%",
|
|
336
364
|
maxHeight: 8,
|
|
337
365
|
anchor: "bottom-left",
|
|
366
|
+
placement: {
|
|
367
|
+
anchorRow: editorBounds.end - 1,
|
|
368
|
+
avoidStartRow: editorBounds.start,
|
|
369
|
+
preferred: "below",
|
|
370
|
+
},
|
|
338
371
|
margin: 1,
|
|
339
372
|
nonCapturing: true,
|
|
340
373
|
});
|
|
@@ -366,6 +399,12 @@ export class InteractiveMode {
|
|
|
366
399
|
this.unsubscribeSession = this.session.subscribeSession((event) => {
|
|
367
400
|
if (!this.started)
|
|
368
401
|
return;
|
|
402
|
+
if (event.type === "queue_update") {
|
|
403
|
+
this.steeringPrompts = [...event.steering];
|
|
404
|
+
this.refreshQueue();
|
|
405
|
+
this.refresh();
|
|
406
|
+
return;
|
|
407
|
+
}
|
|
369
408
|
this.projection.apply(event);
|
|
370
409
|
this.refresh();
|
|
371
410
|
});
|
|
@@ -385,10 +424,12 @@ export class InteractiveMode {
|
|
|
385
424
|
return;
|
|
386
425
|
this.unsubscribeSession?.();
|
|
387
426
|
this.session = next;
|
|
427
|
+
this.projection.configureFilePreview(next.allowedRoot, () => this.refresh());
|
|
388
428
|
this.clipboardDirectory = clipboardImageDirectory(next.allowedRoot);
|
|
389
429
|
void cleanupStaleClipboardImages(next.allowedRoot);
|
|
390
430
|
this.queuedPrompts = [];
|
|
391
|
-
this.
|
|
431
|
+
this.steeringPrompts = [];
|
|
432
|
+
this.refreshQueue();
|
|
392
433
|
this.projection.replaceTranscript(next.transcript);
|
|
393
434
|
this.projection.setUsage(next.usage);
|
|
394
435
|
this.projection.setStatus(`session=${choice.id}`);
|
|
@@ -406,7 +447,12 @@ export class InteractiveMode {
|
|
|
406
447
|
const prompt = text.trim();
|
|
407
448
|
if (prompt.length === 0 || !this.started)
|
|
408
449
|
return;
|
|
409
|
-
|
|
450
|
+
const steeringArgument = steeringCommandArgument(prompt);
|
|
451
|
+
if (steeringArgument !== undefined) {
|
|
452
|
+
await this.submitSteering(steeringArgument);
|
|
453
|
+
return;
|
|
454
|
+
}
|
|
455
|
+
if (prompt.startsWith("/") && !this.isLoadedSkillCommand(prompt)) {
|
|
410
456
|
this.editor.setValue("");
|
|
411
457
|
this.handleSlashCommand(prompt);
|
|
412
458
|
return;
|
|
@@ -423,7 +469,7 @@ export class InteractiveMode {
|
|
|
423
469
|
}
|
|
424
470
|
if (this.promptInFlight) {
|
|
425
471
|
this.queuedPrompts.push(prompt);
|
|
426
|
-
this.
|
|
472
|
+
this.refreshQueue();
|
|
427
473
|
this.root.invalidate();
|
|
428
474
|
this.tui.requestRender();
|
|
429
475
|
return;
|
|
@@ -453,13 +499,51 @@ export class InteractiveMode {
|
|
|
453
499
|
this.activeAbort = undefined;
|
|
454
500
|
this.projection.setRetrying(false);
|
|
455
501
|
const next = this.queuedPrompts.shift();
|
|
456
|
-
this.
|
|
502
|
+
this.refreshQueue();
|
|
457
503
|
this.root.invalidate();
|
|
458
504
|
this.tui.requestRender();
|
|
459
505
|
if (next && this.started)
|
|
460
506
|
void this.submit(next);
|
|
461
507
|
}
|
|
462
508
|
}
|
|
509
|
+
async submitSteering(text) {
|
|
510
|
+
const prompt = text.trim();
|
|
511
|
+
if (prompt.length === 0) {
|
|
512
|
+
this.projection.setError("Steering content must not be empty.");
|
|
513
|
+
this.refresh();
|
|
514
|
+
return;
|
|
515
|
+
}
|
|
516
|
+
if (this.sessionSwitching) {
|
|
517
|
+
this.projection.setError("A session is opening; wait before steering the agent.");
|
|
518
|
+
this.refresh();
|
|
519
|
+
return;
|
|
520
|
+
}
|
|
521
|
+
if (this.compactionInFlight) {
|
|
522
|
+
this.projection.setError("A compaction is running; wait before steering the agent.");
|
|
523
|
+
this.refresh();
|
|
524
|
+
return;
|
|
525
|
+
}
|
|
526
|
+
if (!this.promptInFlight) {
|
|
527
|
+
this.projection.setError("Steering is only available while a prompt is running.");
|
|
528
|
+
this.refresh();
|
|
529
|
+
return;
|
|
530
|
+
}
|
|
531
|
+
try {
|
|
532
|
+
const input = await extractImageAttachments(normalizeDroppedImagePrompt(prompt, this.session.allowedRoot), this.session.allowedRoot);
|
|
533
|
+
await this.session.steerWithImages(input.text, input.images);
|
|
534
|
+
this.editor.setValue("");
|
|
535
|
+
}
|
|
536
|
+
catch (cause) {
|
|
537
|
+
this.projection.setError(cause instanceof Error ? cause.message : String(cause));
|
|
538
|
+
}
|
|
539
|
+
this.refresh();
|
|
540
|
+
}
|
|
541
|
+
refreshQueue() {
|
|
542
|
+
this.projection.setQueue([
|
|
543
|
+
...this.steeringPrompts.map((prompt) => `steer: ${prompt}`),
|
|
544
|
+
...this.queuedPrompts.map((prompt) => `queued: ${prompt}`),
|
|
545
|
+
]);
|
|
546
|
+
}
|
|
463
547
|
async cleanupUnreferencedClipboardFiles() {
|
|
464
548
|
const text = this.editor.getValue();
|
|
465
549
|
const files = [...this.clipboardFiles].filter((path) => !text.includes(path));
|
|
@@ -480,7 +564,9 @@ export class InteractiveMode {
|
|
|
480
564
|
const args = argParts.join(" ");
|
|
481
565
|
switch (command) {
|
|
482
566
|
case "help":
|
|
483
|
-
this.projection.setStatus(
|
|
567
|
+
this.projection.setStatus(`commands: ${this.listSlashCommands()
|
|
568
|
+
.map((item) => `/${item.name}`)
|
|
569
|
+
.join(" ")}`);
|
|
484
570
|
break;
|
|
485
571
|
case "clear":
|
|
486
572
|
this.projection.clearVisibleMessages();
|
|
@@ -498,6 +584,12 @@ export class InteractiveMode {
|
|
|
498
584
|
case "settings":
|
|
499
585
|
this.openSettingsSelector();
|
|
500
586
|
return;
|
|
587
|
+
case "login":
|
|
588
|
+
this.openProviderLogin();
|
|
589
|
+
return;
|
|
590
|
+
case "logout":
|
|
591
|
+
void this.logoutProvider();
|
|
592
|
+
return;
|
|
501
593
|
case "compact":
|
|
502
594
|
void this.runManualCompaction();
|
|
503
595
|
return;
|
|
@@ -523,6 +615,84 @@ export class InteractiveMode {
|
|
|
523
615
|
}
|
|
524
616
|
this.refresh();
|
|
525
617
|
}
|
|
618
|
+
openProviderLogin() {
|
|
619
|
+
if (!this.providerOnboarding) {
|
|
620
|
+
this.projection.setError("Provider login is unavailable in this session.");
|
|
621
|
+
this.refresh();
|
|
622
|
+
return;
|
|
623
|
+
}
|
|
624
|
+
if (this.promptInFlight || this.sessionSwitching) {
|
|
625
|
+
this.projection.setError("Cannot change Provider while a prompt is running.");
|
|
626
|
+
this.refresh();
|
|
627
|
+
return;
|
|
628
|
+
}
|
|
629
|
+
this.editor.cancelAutocomplete();
|
|
630
|
+
this.closeAutocompleteOverlay();
|
|
631
|
+
void showInteractiveProviderOnboarding({ ...this.providerOnboarding, tui: this.tui })
|
|
632
|
+
.then((runtime) => {
|
|
633
|
+
if (!this.started)
|
|
634
|
+
return;
|
|
635
|
+
this.tui.setFocus(this.editor);
|
|
636
|
+
if (!runtime) {
|
|
637
|
+
this.refresh();
|
|
638
|
+
return;
|
|
639
|
+
}
|
|
640
|
+
this.session.setRuntime(runtime.provider, runtime.model);
|
|
641
|
+
this.projection.setStatus(`provider=${runtime.provider.id} model=${runtime.model.id}`);
|
|
642
|
+
this.refresh();
|
|
643
|
+
})
|
|
644
|
+
.catch((cause) => {
|
|
645
|
+
if (this.started)
|
|
646
|
+
this.tui.setFocus(this.editor);
|
|
647
|
+
this.projection.setError(cause instanceof Error ? cause.message : String(cause));
|
|
648
|
+
this.refresh();
|
|
649
|
+
});
|
|
650
|
+
}
|
|
651
|
+
async logoutProvider() {
|
|
652
|
+
if (!this.providerOnboarding) {
|
|
653
|
+
this.projection.setError("Provider logout is unavailable in this session.");
|
|
654
|
+
this.refresh();
|
|
655
|
+
return;
|
|
656
|
+
}
|
|
657
|
+
if (this.promptInFlight || this.sessionSwitching) {
|
|
658
|
+
this.projection.setError("Cannot change Provider while a prompt is running.");
|
|
659
|
+
this.refresh();
|
|
660
|
+
return;
|
|
661
|
+
}
|
|
662
|
+
const providerId = this.session.providerId;
|
|
663
|
+
const modelId = this.session.modelId;
|
|
664
|
+
try {
|
|
665
|
+
const removed = await removeGlobalProviderApiKey(this.providerOnboarding.agentDir, providerId);
|
|
666
|
+
if (!removed) {
|
|
667
|
+
this.projection.setStatus(`no global API key stored for provider=${providerId}`);
|
|
668
|
+
this.refresh();
|
|
669
|
+
return;
|
|
670
|
+
}
|
|
671
|
+
const configuration = await loadStartupConfiguration(this.session.allowedRoot, this.providerOnboarding.configuration.environment, this.providerOnboarding.agentDir);
|
|
672
|
+
const runtime = resolveStartupRuntime({
|
|
673
|
+
...configuration.environment,
|
|
674
|
+
DI_CODE_PROVIDER: providerId,
|
|
675
|
+
DI_CODE_MODEL: modelId,
|
|
676
|
+
}, configuration.providers, configuration.defaults);
|
|
677
|
+
this.session.setRuntime(runtime.provider, runtime.model);
|
|
678
|
+
this.projection.setStatus(`global API key removed for provider=${providerId}; environment variables may still apply`);
|
|
679
|
+
}
|
|
680
|
+
catch (cause) {
|
|
681
|
+
this.projection.setError(cause instanceof Error ? cause.message : String(cause));
|
|
682
|
+
}
|
|
683
|
+
this.refresh();
|
|
684
|
+
}
|
|
685
|
+
listSlashCommands() {
|
|
686
|
+
const skills = this.session.availableSkills.map((skill) => ({
|
|
687
|
+
name: `skill:${skill.name}`,
|
|
688
|
+
description: skill.description,
|
|
689
|
+
}));
|
|
690
|
+
return [...BUILTIN_SLASH_COMMANDS, ...(this.extensionHost?.listCommands() ?? []), ...skills];
|
|
691
|
+
}
|
|
692
|
+
isLoadedSkillCommand(input) {
|
|
693
|
+
const name = /^\/skill:([a-z0-9]+(?:-[a-z0-9]+)*)(?:\s|$)/.exec(input)?.[1];
|
|
694
|
+
return name !== undefined && this.session.availableSkills.some((skill) => skill.name === name);
|
|
695
|
+
}
|
|
526
696
|
formatUsage() {
|
|
527
697
|
const usage = this.session.usage;
|
|
528
698
|
return `usage: requests=${usage.requestCount} input=${usage.inputTokens} output=${usage.outputTokens} total=${usage.totalTokens} cost=$${usage.cost.total.toFixed(4)} context=${usage.estimatedContextTokens}/${usage.contextWindow}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interactive.js","sourceRoot":"","sources":["../../src/modes/interactive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAEN,4BAA4B,EAC5B,MAAM,EACN,GAAG,EACH,UAAU,EAEV,UAAU,EACV,YAAY,GAEZ,MAAM,cAAc,CAAC;AACtB,OAAO,EACN,2BAA2B,EAC3B,uBAAuB,EACvB,oBAAoB,EACpB,sBAAsB,EACtB,oBAAoB,GACpB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAGjE,OAAO,EACN,gBAAgB,EAChB,eAAe,EACf,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,GAEjB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAI/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAC7E,MAAM,eAAe,GAAG,OAAO,CAAC,QAAQ,KA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IAAI,CAAC,OAAO,EAAE,CAAC;YACf,OAAO;QACR,CAAC;QACD,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC;QAC/B,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,4BAA4B,CAAC,CAAC;QACxD,IAAI,CAAC,OAAO,EAAE,CAAC;QACf,IAAI,CAAC;YACJ,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;YAC7B,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,4BAA4B,CAAC,CAAC;QACzD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QAClF,CAAC;gBAAS,CAAC;YACV,IAAI,CAAC,kBAAkB,GAAG,KAAK,CAAC;YAChC,IAAI,CAAC,OAAO,EAAE,CAAC;QAChB,CAAC;IACF,CAAC;CACD","sourcesContent":["import { statSync } from \"node:fs\";\nimport { extname, resolve } from \"node:path\";\nimport {\n\ttype AutocompleteProvider,\n\tCombinedAutocompleteProvider,\n\tEditor,\n\tKey,\n\tmatchesKey,\n\ttype OverlayHandle,\n\tSelectList,\n\tSettingsList,\n\ttype TUI,\n} from \"@di-code/tui\";\nimport {\n\tcleanupStaleClipboardImages,\n\tclipboardImageDirectory,\n\tisClipboardImagePath,\n\treadClipboardImagePath,\n\tremoveClipboardImage,\n} from \"../core/clipboard-image.ts\";\nimport { extractImageAttachments } from \"../core/image-input.ts\";\nimport type { AgentSession, AgentSessionEvent } from \"../core/session.ts\";\nimport type { ExtensionHost } from \"../extensions/runtime.ts\";\nimport {\n\tAutocompleteMenu,\n\tInteractiveChat,\n\tInteractiveComposer,\n\tInteractiveFooter,\n\tInteractiveHeader,\n\ttype InteractiveViewState,\n} from \"./interactive-components.ts\";\nimport { InteractiveLayout } from \"./interactive-layout.ts\";\nimport { InteractiveProjection } from \"./interactive-state.ts\";\n\nexport type { AgentSessionEvent };\nexport type { InteractiveMessage, InteractiveProcessItem, InteractiveState } from \"./interactive-state.ts\";\nexport { InteractiveProjection } from \"./interactive-state.ts\";\n\nconst IMAGE_EXTENSIONS = new Set([\".gif\", \".jpeg\", \".jpg\", \".png\", \".webp\"]);\nconst PASTE_IMAGE_KEY = process.platform === \"win32\" ? Key.alt(\"v\") : Key.ctrl(\"v\");\nconst PASTE_IMAGE_SHORTCUT = process.platform === \"win32\" ? \"Alt+V\" : \"Ctrl+V\";\n\nfunction asImageAttachmentReference(pasted: string, cwd: string): string {\n\tif (pasted.includes(\"\\n\")) return pasted;\n\tconst candidate = pasted.trim().replace(/^(?:\"([\\s\\S]*)\"|'([\\s\\S]*)')$/, \"$1$2\");\n\tif (!candidate || !IMAGE_EXTENSIONS.has(extname(candidate).toLowerCase())) return pasted;\n\ttry {\n\t\tif (!statSync(resolve(cwd, candidate)).isFile()) return pasted;\n\t} catch {\n\t\treturn pasted;\n\t}\n\treturn `@\"${candidate.replaceAll('\"', '\\\\\"')}\" `;\n}\n\nfunction normalizeDroppedImagePrompt(prompt: string, cwd: string): string {\n\tconst normalized = asImageAttachmentReference(prompt, cwd);\n\tif (normalized !== prompt) return normalized;\n\tconst prefix = /^((?:(?:[A-Za-z]:[\\\\/])|(?:\\.\\.?[\\\\/])|\\/)[\\s\\S]*?\\.(?:gif|jpe?g|png|webp))([\\s\\S]*)$/i.exec(prompt);\n\tif (!prefix) return prompt;\n\tconst imageReference = asImageAttachmentReference(prefix[1] ?? \"\", cwd);\n\treturn imageReference === prefix[1]\n\t\t? prompt\n\t\t: `${imageReference}${normalizeDroppedImagePrompt(prefix[2] ?? \"\", cwd)}`;\n}\n\nexport interface InteractiveModeOptions {\n\treadonly session: AgentSession;\n\treadonly tui: TUI;\n\treadonly onExit?: () => void;\n\treadonly sessions?: readonly InteractiveSessionChoice[];\n\treadonly extensionHost?: ExtensionHost;\n\treadonly readClipboardImagePath?: (directory?: string) => Promise<string | null>;\n}\n\nexport interface InteractiveSessionChoice {\n\treadonly id: string;\n\treadonly label: string;\n\treadonly description?: string;\n\topen(): AgentSession | Promise<AgentSession>;\n}\n\nexport class InteractiveMode {\n\tprivate readonly projection = new InteractiveProjection();\n\tprivate readonly root: InteractiveLayout;\n\tprivate readonly editor: Editor;\n\tprivate session: AgentSession;\n\tprivate readonly tui: TUI;\n\tprivate readonly sessionChoices: readonly InteractiveSessionChoice[];\n\tprivate readonly extensionHost?: ExtensionHost;\n\tprivate readonly readClipboardImagePath: (directory?: string) => Promise<string | null>;\n\tprivate clipboardDirectory: string;\n\tprivate readonly clipboardFiles = new Set<string>();\n\tprivate unsubscribeSession?: () => void;\n\tprivate sessionSwitching = false;\n\tprivate promptInFlight = false;\n\tprivate compactionInFlight = false;\n\tprivate activeAbort?: AbortController;\n\tprivate started = false;\n\tprivate lastFailedPrompt?: string;\n\tprivate queuedPrompts: string[] = [];\n\tprivate readonly onExit?: () => void;\n\tprivate theme: \"dark\" | \"light\" = \"dark\";\n\tprivate overlay?: OverlayHandle;\n\tprivate autocompleteOverlay?: OverlayHandle;\n\tprivate spinnerTimer?: ReturnType<typeof setInterval>;\n\tprivate shutdownEmitted = false;\n\tprivate preserveClipboardFiles = false;\n\n\tconstructor(options: InteractiveModeOptions) {\n\t\tthis.session = options.session;\n\t\tthis.tui = options.tui;\n\t\tthis.onExit = options.onExit;\n\t\tthis.sessionChoices = [...(options.sessions ?? [])];\n\t\tthis.extensionHost = options.extensionHost;\n\t\tthis.readClipboardImagePath = options.readClipboardImagePath ?? readClipboardImagePath;\n\t\tthis.clipboardDirectory = clipboardImageDirectory(this.session.allowedRoot);\n\t\tconst commands = [\n\t\t\t{ name: \"help\", description: \"Show interactive commands\" },\n\t\t\t{ name: \"clear\", description: \"Clear visible messages\" },\n\t\t\t{ name: \"model\", description: \"Open the model selector\" },\n\t\t\t{ name: \"session\", description: \"Open the session selector\" },\n\t\t\t{ name: \"theme\", description: \"Open the theme selector\" },\n\t\t\t{ name: \"settings\", description: \"Open the settings selector\" },\n\t\t\t{ name: \"compact\", description: \"Compact the persisted context now\" },\n\t\t\t{ name: \"usage\", description: \"Show token and cost usage\" },\n\t\t\t{ name: \"retry\", description: \"Retry the last failed prompt\" },\n\t\t] as const;\n\t\tconst allCommands = [...commands, ...(this.extensionHost?.listCommands() ?? [])];\n\t\tconst autocomplete: AutocompleteProvider = {\n\t\t\tgetSuggestions: (context, autocompleteOptions) =>\n\t\t\t\tnew CombinedAutocompleteProvider(allCommands, this.session.allowedRoot).getSuggestions(\n\t\t\t\t\tcontext,\n\t\t\t\t\tautocompleteOptions,\n\t\t\t\t),\n\t\t\tapplyCompletion: (context, item, prefix) =>\n\t\t\t\tnew CombinedAutocompleteProvider(allCommands, this.session.allowedRoot).applyCompletion(context, item, prefix),\n\t\t};\n\t\tthis.editor = new Editor({\n\t\t\tmaxHeight: 3,\n\t\t\tautocomplete,\n\t\t});\n\t\tthis.editor.onSubmit = (text) => void this.submit(text);\n\t\tthis.editor.onEscape = () => this.activeAbort?.abort();\n\t\tthis.editor.onCommand = (data) => this.handleCommand(data);\n\t\tthis.editor.onInterrupt = () => this.exit();\n\t\tthis.editor.onChange = () => {\n\t\t\tif (!this.preserveClipboardFiles) {\n\t\t\t\tvoid this.cleanupUnreferencedClipboardFiles().catch((cause) => {\n\t\t\t\t\tthis.projection.setError(cause instanceof Error ? cause.message : String(cause));\n\t\t\t\t\tthis.refresh();\n\t\t\t\t});\n\t\t\t}\n\t\t};\n\t\tthis.editor.onAutocompleteChange = () => this.updateAutocompleteOverlay();\n\t\tconst readViewState = (): InteractiveViewState => ({\n\t\t\t...this.projection.state,\n\t\t\tmodel: this.session.modelId,\n\t\t\ttheme: this.theme,\n\t\t\tpasteImageShortcut: PASTE_IMAGE_SHORTCUT,\n\t\t});\n\t\tthis.root = new InteractiveLayout({\n\t\t\theader: new InteractiveHeader(readViewState),\n\t\t\tchat: new InteractiveChat(readViewState),\n\t\t\tcomposer: new InteractiveComposer(readViewState),\n\t\t\teditor: this.editor,\n\t\t\tfooter: new InteractiveFooter(readViewState),\n\t\t});\n\t\tthis.tui.addChild(this.root);\n\t\tthis.tui.setFocus(this.editor);\n\t}\n\n\tstart(initialPrompt?: string): void {\n\t\tif (this.started) throw new Error(\"Interactive mode is already started\");\n\t\tthis.started = true;\n\t\tthis.shutdownEmitted = false;\n\t\tvoid this.extensionHost?.emit({ type: \"session_start\", cwd: this.session.allowedRoot });\n\t\tthis.projection.replaceTranscript(this.session.transcript);\n\t\tthis.projection.setUsage(this.session.usage);\n\t\tthis.subscribeToSession();\n\t\tvoid cleanupStaleClipboardImages(this.session.allowedRoot).catch((cause) => {\n\t\t\tthis.projection.setError(cause instanceof Error ? cause.message : String(cause));\n\t\t\tthis.refresh();\n\t\t});\n\t\ttry {\n\t\t\tthis.tui.start();\n\t\t} catch (cause) {\n\t\t\tthis.started = false;\n\t\t\tthis.unsubscribeSession?.();\n\t\t\tthis.unsubscribeSession = undefined;\n\t\t\tthrow cause;\n\t\t}\n\t\tthis.startSpinnerTimer();\n\t\tif (initialPrompt?.trim()) void this.submit(initialPrompt);\n\t}\n\n\tstop(): void {\n\t\tif (!this.started && !this.unsubscribeSession) return;\n\t\tthis.started = false;\n\t\tthis.activeAbort?.abort();\n\t\tthis.activeAbort = undefined;\n\t\tthis.stopSpinnerTimer();\n\t\tthis.projection.clearTransientProcess();\n\t\tthis.closeOverlay();\n\t\tthis.closeAutocompleteOverlay();\n\t\tthis.unsubscribeSession?.();\n\t\tthis.unsubscribeSession = undefined;\n\t\tvoid this.cleanupClipboardFiles();\n\t\tthis.tui.stop({ finalLines: this.root.renderTranscript(this.tui.columns) });\n\t\tif (!this.shutdownEmitted) {\n\t\t\tthis.shutdownEmitted = true;\n\t\t\tvoid this.extensionHost?.emit({ type: \"session_shutdown\", reason: \"user\" });\n\t\t}\n\t}\n\n\tprivate exit(): void {\n\t\tthis.stop();\n\t\tthis.onExit?.();\n\t}\n\n\tprivate handleCommand(data: string): boolean {\n\t\tif (data === \"\\x14\") {\n\t\t\tthis.openThemeSelector();\n\t\t\treturn true;\n\t\t}\n\t\tif (data === \"\\x13\") {\n\t\t\tthis.openSettingsSelector();\n\t\t\treturn true;\n\t\t}\n\t\tif (data === \"\\x0f\") {\n\t\t\tthis.openModelSelector();\n\t\t\treturn true;\n\t\t}\n\t\tif (data === \"\\x0c\") {\n\t\t\tthis.openSessionSelector();\n\t\t\treturn true;\n\t\t}\n\t\tif (data === \"\\x12\" && this.lastFailedPrompt && !this.promptInFlight) {\n\t\t\tvoid this.submit(this.lastFailedPrompt, true);\n\t\t\treturn true;\n\t\t}\n\t\tif (matchesKey(data, PASTE_IMAGE_KEY)) {\n\t\t\tvoid this.attachClipboardImage();\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tprivate async attachClipboardImage(): Promise<void> {\n\t\ttry {\n\t\t\tconst path = await this.readClipboardImagePath(this.clipboardDirectory);\n\t\t\tif (!path) {\n\t\t\t\tthis.projection.setStatus(\"Clipboard has no supported image.\");\n\t\t\t} else {\n\t\t\t\tthis.editor.insertTextAtCursor(path);\n\t\t\t\tif (isClipboardImagePath(path, this.clipboardDirectory)) this.clipboardFiles.add(path);\n\t\t\t}\n\t\t} catch (cause) {\n\t\t\tthis.projection.setError(cause instanceof Error ? cause.message : String(cause));\n\t\t}\n\t\tthis.refresh();\n\t}\n\n\tprivate openThemeSelector(): void {\n\t\tconst list = new SelectList([\n\t\t\t{ value: \"dark\", label: \"Dark\", description: \"Dark terminal theme\" },\n\t\t\t{ value: \"light\", label: \"Light\", description: \"Light terminal theme\" },\n\t\t]);\n\t\tlist.onSelect = (item) => {\n\t\t\tthis.theme = item.value === \"light\" ? \"light\" : \"dark\";\n\t\t\tthis.projection.setStatus(`theme=${this.theme}`);\n\t\t\tthis.closeOverlay();\n\t\t\tthis.refresh();\n\t\t};\n\t\tlist.onCancel = () => this.closeOverlay();\n\t\tthis.showOverlay(list);\n\t}\n\n\tprivate openModelSelector(): void {\n\t\tconst list = new SelectList(\n\t\t\tthis.session.availableModels.map((model) => ({\n\t\t\t\tvalue: model.id,\n\t\t\t\tlabel: model.name,\n\t\t\t\tdescription: `${model.provider} / ${model.id} / context ${model.contextWindow}`,\n\t\t\t})),\n\t\t);\n\t\tlist.onSelect = (item) => {\n\t\t\ttry {\n\t\t\t\tthis.session.setModel(item.value);\n\t\t\t\tthis.projection.setStatus(`model=${item.value}`);\n\t\t\t\tthis.closeOverlay();\n\t\t\t\tthis.refresh();\n\t\t\t} catch (cause) {\n\t\t\t\tthis.projection.setError(cause instanceof Error ? cause.message : String(cause));\n\t\t\t}\n\t\t};\n\t\tlist.onCancel = () => this.closeOverlay();\n\t\tthis.showOverlay(list);\n\t}\n\n\tprivate openSessionSelector(): void {\n\t\tconst list = new SelectList([\n\t\t\t{\n\t\t\t\tvalue: \"__current__\",\n\t\t\t\tlabel: \"Current session\",\n\t\t\t\tdescription: this.session.sessionFile ?? \"In-memory session\",\n\t\t\t},\n\t\t\t...this.sessionChoices.map((choice) => ({\n\t\t\t\tvalue: choice.id,\n\t\t\t\tlabel: choice.label,\n\t\t\t\t...(choice.description ? { description: choice.description } : {}),\n\t\t\t})),\n\t\t]);\n\t\tlist.onSelect = (item) => {\n\t\t\tif (item.value === \"__current__\") {\n\t\t\t\tthis.projection.setStatus(\"session=current\");\n\t\t\t\tthis.closeOverlay();\n\t\t\t\tthis.refresh();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst choice = this.sessionChoices.find((candidate) => candidate.id === item.value);\n\t\t\tif (!choice) return;\n\t\t\tthis.closeOverlay();\n\t\t\tvoid this.switchSession(choice);\n\t\t};\n\t\tlist.onCancel = () => this.closeOverlay();\n\t\tthis.showOverlay(list);\n\t}\n\n\tprivate openSettingsSelector(): void {\n\t\tconst list = new SettingsList([\n\t\t\t{\n\t\t\t\tid: \"compaction\",\n\t\t\t\tlabel: \"Context compaction\",\n\t\t\t\tcurrentValue: this.session.compactionEnabled ? \"on\" : \"off\",\n\t\t\t\tvalues: [\"on\", \"off\"],\n\t\t\t\tdescription: \"Summarize older persisted context before the model limit is reached.\",\n\t\t\t},\n\t\t]);\n\t\tlist.onChange = (id, value) => {\n\t\t\tif (id !== \"compaction\") return;\n\t\t\ttry {\n\t\t\t\tconst enabled = this.session.setCompactionEnabled(value === \"on\");\n\t\t\t\tlist.updateValue(id, enabled ? \"on\" : \"off\");\n\t\t\t\tthis.projection.setStatus(\n\t\t\t\t\tenabled === (value === \"on\")\n\t\t\t\t\t\t? `compaction=${enabled ? \"on\" : \"off\"}`\n\t\t\t\t\t\t: \"compaction unavailable without a persisted session\",\n\t\t\t\t);\n\t\t\t} catch (cause) {\n\t\t\t\tlist.updateValue(id, this.session.compactionEnabled ? \"on\" : \"off\");\n\t\t\t\tthis.projection.setError(cause instanceof Error ? cause.message : String(cause));\n\t\t\t\tthis.closeOverlay();\n\t\t\t}\n\t\t\tthis.refresh();\n\t\t};\n\t\tlist.onCancel = () => this.closeOverlay();\n\t\tthis.showOverlay(list);\n\t}\n\n\tprivate showOverlay(component: SelectList | SettingsList): void {\n\t\tthis.editor.cancelAutocomplete();\n\t\tthis.closeAutocompleteOverlay();\n\t\tthis.closeOverlay();\n\t\tthis.overlay = this.tui.showOverlay(component, {\n\t\t\twidth: \"70%\",\n\t\t\tmaxHeight: \"60%\",\n\t\t\tanchor: \"center\",\n\t\t\tmargin: 1,\n\t\t});\n\t}\n\n\tprivate closeOverlay(): void {\n\t\tthis.overlay?.hide();\n\t\tthis.overlay = undefined;\n\t}\n\n\tprivate updateAutocompleteOverlay(): void {\n\t\tthis.closeAutocompleteOverlay();\n\t\tif (!this.editor.isShowingAutocomplete()) {\n\t\t\tthis.refresh();\n\t\t\treturn;\n\t\t}\n\t\tconst menu = new AutocompleteMenu(() => ({\n\t\t\titems: this.editor.getAutocompleteItems(),\n\t\t\tindex: this.editor.getAutocompleteIndex(),\n\t\t}));\n\t\tthis.autocompleteOverlay = this.tui.showOverlay(menu, {\n\t\t\twidth: \"55%\",\n\t\t\tmaxHeight: 8,\n\t\t\tanchor: \"bottom-left\",\n\t\t\tmargin: 1,\n\t\t\tnonCapturing: true,\n\t\t});\n\t\tthis.refresh();\n\t}\n\n\tprivate closeAutocompleteOverlay(): void {\n\t\tthis.autocompleteOverlay?.hide();\n\t\tthis.autocompleteOverlay = undefined;\n\t}\n\n\tprivate refresh(): void {\n\t\tthis.root.invalidate();\n\t\tthis.tui.requestRender();\n\t}\n\n\tprivate startSpinnerTimer(): void {\n\t\tthis.stopSpinnerTimer();\n\t\tthis.spinnerTimer = setInterval(() => {\n\t\t\tif (this.projection.advanceSpinner()) this.refresh();\n\t\t}, 120);\n\t\tthis.spinnerTimer.unref?.();\n\t}\n\n\tprivate stopSpinnerTimer(): void {\n\t\tif (this.spinnerTimer) clearInterval(this.spinnerTimer);\n\t\tthis.spinnerTimer = undefined;\n\t}\n\n\tprivate subscribeToSession(): void {\n\t\tthis.unsubscribeSession?.();\n\t\tthis.unsubscribeSession = this.session.subscribeSession((event) => {\n\t\t\tif (!this.started) return;\n\t\t\tthis.projection.apply(event);\n\t\t\tthis.refresh();\n\t\t});\n\t}\n\n\tprivate async switchSession(choice: InteractiveSessionChoice): Promise<void> {\n\t\tif (this.promptInFlight || this.sessionSwitching) {\n\t\t\tthis.projection.setError(\"Cannot switch sessions while a prompt is running.\");\n\t\t\tthis.refresh();\n\t\t\treturn;\n\t\t}\n\t\tthis.sessionSwitching = true;\n\t\tthis.projection.setStatus(`opening session=${choice.id}`);\n\t\tthis.refresh();\n\t\ttry {\n\t\t\tconst next = await choice.open();\n\t\t\tif (!this.started) return;\n\t\t\tthis.unsubscribeSession?.();\n\t\t\tthis.session = next;\n\t\t\tthis.clipboardDirectory = clipboardImageDirectory(next.allowedRoot);\n\t\t\tvoid cleanupStaleClipboardImages(next.allowedRoot);\n\t\t\tthis.queuedPrompts = [];\n\t\t\tthis.projection.setQueue([]);\n\t\t\tthis.projection.replaceTranscript(next.transcript);\n\t\t\tthis.projection.setUsage(next.usage);\n\t\t\tthis.projection.setStatus(`session=${choice.id}`);\n\t\t\tthis.subscribeToSession();\n\t\t} catch (cause) {\n\t\t\tthis.projection.setError(cause instanceof Error ? cause.message : String(cause));\n\t\t} finally {\n\t\t\tthis.sessionSwitching = false;\n\t\t}\n\t\tthis.refresh();\n\t}\n\n\tprivate async submit(text: string, retry = false): Promise<void> {\n\t\tconst prompt = text.trim();\n\t\tif (prompt.length === 0 || !this.started) return;\n\t\tif (prompt.startsWith(\"/\")) {\n\t\t\tthis.editor.setValue(\"\");\n\t\t\tthis.handleSlashCommand(prompt);\n\t\t\treturn;\n\t\t}\n\t\tif (this.sessionSwitching) {\n\t\t\tthis.projection.setError(\"A session is opening; wait before submitting a prompt.\");\n\t\t\tthis.refresh();\n\t\t\treturn;\n\t\t}\n\t\tif (this.compactionInFlight) {\n\t\t\tthis.projection.setError(\"A compaction is running; wait before submitting a prompt.\");\n\t\t\tthis.refresh();\n\t\t\treturn;\n\t\t}\n\t\tif (this.promptInFlight) {\n\t\t\tthis.queuedPrompts.push(prompt);\n\t\t\tthis.projection.setQueue(this.queuedPrompts);\n\t\t\tthis.root.invalidate();\n\t\t\tthis.tui.requestRender();\n\t\t\treturn;\n\t\t}\n\t\tthis.promptInFlight = true;\n\t\tthis.activeAbort = new AbortController();\n\t\tthis.projection.setRetrying(retry);\n\t\ttry {\n\t\t\tconst input = await extractImageAttachments(\n\t\t\t\tnormalizeDroppedImagePrompt(prompt, this.session.allowedRoot),\n\t\t\t\tthis.session.allowedRoot,\n\t\t\t);\n\t\t\tthis.preserveClipboardFiles = true;\n\t\t\tthis.editor.setValue(\"\");\n\t\t\tconst result = await this.session.promptWithImages(input.text, input.images, this.activeAbort.signal);\n\t\t\tif (result.stopReason === \"error\" || result.stopReason === \"aborted\") this.lastFailedPrompt = prompt;\n\t\t\telse {\n\t\t\t\tthis.lastFailedPrompt = undefined;\n\t\t\t\tawait this.cleanupClipboardFiles();\n\t\t\t}\n\t\t} catch (cause) {\n\t\t\tthis.lastFailedPrompt = prompt;\n\t\t\tthis.projection.setError(cause instanceof Error ? cause.message : String(cause));\n\t\t} finally {\n\t\t\tthis.preserveClipboardFiles = false;\n\t\t\tthis.promptInFlight = false;\n\t\t\tthis.activeAbort = undefined;\n\t\t\tthis.projection.setRetrying(false);\n\t\t\tconst next = this.queuedPrompts.shift();\n\t\t\tthis.projection.setQueue(this.queuedPrompts);\n\t\t\tthis.root.invalidate();\n\t\t\tthis.tui.requestRender();\n\t\t\tif (next && this.started) void this.submit(next);\n\t\t}\n\t}\n\n\tprivate async cleanupUnreferencedClipboardFiles(): Promise<void> {\n\t\tconst text = this.editor.getValue();\n\t\tconst files = [...this.clipboardFiles].filter((path) => !text.includes(path));\n\t\tawait Promise.all(files.map((path) => removeClipboardImage(path, this.clipboardDirectory)));\n\t\tfor (const path of files) this.clipboardFiles.delete(path);\n\t}\n\n\tprivate async cleanupClipboardFiles(): Promise<void> {\n\t\tconst files = [...this.clipboardFiles];\n\t\tawait Promise.all(files.map((path) => removeClipboardImage(path, this.clipboardDirectory)));\n\t\tfor (const path of files) this.clipboardFiles.delete(path);\n\t}\n\n\tprivate handleSlashCommand(input: string): void {\n\t\tconst trimmed = input.slice(1).trim();\n\t\tconst [rawCommand = \"\", ...argParts] = trimmed.split(/\\s+/);\n\t\tconst command = rawCommand.toLowerCase();\n\t\tconst args = argParts.join(\" \");\n\t\tswitch (command) {\n\t\t\tcase \"help\":\n\t\t\t\tthis.projection.setStatus(\"commands: /clear /model /session /theme /settings /compact /usage /retry\");\n\t\t\t\tbreak;\n\t\t\tcase \"clear\":\n\t\t\t\tthis.projection.clearVisibleMessages();\n\t\t\t\tthis.projection.setStatus(\"visible messages cleared\");\n\t\t\t\tbreak;\n\t\t\tcase \"model\":\n\t\t\t\tthis.openModelSelector();\n\t\t\t\treturn;\n\t\t\tcase \"session\":\n\t\t\t\tthis.openSessionSelector();\n\t\t\t\treturn;\n\t\t\tcase \"theme\":\n\t\t\t\tthis.openThemeSelector();\n\t\t\t\treturn;\n\t\t\tcase \"settings\":\n\t\t\t\tthis.openSettingsSelector();\n\t\t\t\treturn;\n\t\t\tcase \"compact\":\n\t\t\t\tvoid this.runManualCompaction();\n\t\t\t\treturn;\n\t\t\tcase \"usage\":\n\t\t\t\tthis.projection.setStatus(this.formatUsage());\n\t\t\t\tbreak;\n\t\t\tcase \"retry\":\n\t\t\t\tif (this.lastFailedPrompt && !this.promptInFlight) void this.submit(this.lastFailedPrompt, true);\n\t\t\t\telse this.projection.setStatus(\"nothing to retry\");\n\t\t\t\tbreak;\n\t\t\tdefault: {\n\t\t\t\tif (this.extensionHost?.listCommands().some((entry) => entry.name === command)) {\n\t\t\t\t\tvoid this.extensionHost.runCommand(command, args).catch((cause) => {\n\t\t\t\t\t\tthis.projection.setError(cause instanceof Error ? cause.message : String(cause));\n\t\t\t\t\t\tthis.refresh();\n\t\t\t\t\t});\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tthis.projection.setError(`Unknown command: /${command}`);\n\t\t\t}\n\t\t}\n\t\tthis.refresh();\n\t}\n\n\tprivate formatUsage(): string {\n\t\tconst usage = this.session.usage;\n\t\treturn `usage: requests=${usage.requestCount} input=${usage.inputTokens} output=${usage.outputTokens} total=${usage.totalTokens} cost=$${usage.cost.total.toFixed(4)} context=${usage.estimatedContextTokens}/${usage.contextWindow}`;\n\t}\n\n\tprivate async runManualCompaction(): Promise<void> {\n\t\tif (this.promptInFlight || this.compactionInFlight) {\n\t\t\tthis.projection.setError(\"Cannot compact while a prompt is running.\");\n\t\t\tthis.refresh();\n\t\t\treturn;\n\t\t}\n\t\tthis.compactionInFlight = true;\n\t\tthis.projection.setStatus(\"starting manual compaction\");\n\t\tthis.refresh();\n\t\ttry {\n\t\t\tawait this.session.compact();\n\t\t\tthis.projection.setStatus(\"manual compaction complete\");\n\t\t} catch (cause) {\n\t\t\tthis.projection.setError(cause instanceof Error ? cause.message : String(cause));\n\t\t} finally {\n\t\t\tthis.compactionInFlight = false;\n\t\t\tthis.refresh();\n\t\t}\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"interactive.js","sourceRoot":"","sources":["../../src/modes/interactive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAEN,4BAA4B,EAE5B,MAAM,EACN,GAAG,EACH,UAAU,EAEV,UAAU,EACV,YAAY,GAGZ,MAAM,cAAc,CAAC;AACtB,OAAO,EACN,2BAA2B,EAC3B,uBAAuB,EACvB,oBAAoB,EACpB,sBAAsB,EACtB,oBAAoB,GACpB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAGjE,OAAO,EAEN,iCAAiC,GACjC,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,wBAAwB,EAAE,0BAA0B,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAC5G,OAAO,EACN,gBAAgB,EAChB,eAAe,EACf,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,GAEjB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAI/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAC7E,MAAM,eAAe,GAAG,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC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AK,CAAC;QACjC,OAAO,mBAAmB,KAAK,CAAC,YAAY,UAAU,KAAK,CAAC,WAAW,WAAW,KAAK,CAAC,YAAY,UAAU,KAAK,CAAC,WAAW,UAAU,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,YAAY,KAAK,CAAC,sBAAsB,IAAI,KAAK,CAAC,aAAa,EAAE,CAAC;IACvO,CAAC;IAEO,KAAK,CAAC,mBAAmB;QAChC,IAAI,IAAI,CAAC,cAAc,IAAI,IAAI,CAAC,kBAAkB,EAAE,CAAC;YACpD,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,2CAA2C,CAAC,CAAC;YACtE,IAAI,CAAC,OAAO,EAAE,CAAC;YACf,OAAO;QACR,CAAC;QACD,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC;QAC/B,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,4BAA4B,CAAC,CAAC;QACxD,IAAI,CAAC,OAAO,EAAE,CAAC;QACf,IAAI,CAAC;YACJ,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;YAC7B,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,4BAA4B,CAAC,CAAC;QACzD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QAClF,CAAC;gBAAS,CAAC;YACV,IAAI,CAAC,kBAAkB,GAAG,KAAK,CAAC;YAChC,IAAI,CAAC,OAAO,EAAE,CAAC;QAChB,CAAC;IACF,CAAC;CACD","sourcesContent":["import { statSync } from \"node:fs\";\nimport { extname, resolve } from \"node:path\";\nimport {\n\ttype AutocompleteProvider,\n\tCombinedAutocompleteProvider,\n\ttype Component,\n\tEditor,\n\tKey,\n\tmatchesKey,\n\ttype OverlayHandle,\n\tSelectList,\n\tSettingsList,\n\ttype SlashCommand,\n\ttype TUI,\n} from \"@di-code/tui\";\nimport {\n\tcleanupStaleClipboardImages,\n\tclipboardImageDirectory,\n\tisClipboardImagePath,\n\treadClipboardImagePath,\n\tremoveClipboardImage,\n} from \"../core/clipboard-image.ts\";\nimport { extractImageAttachments } from \"../core/image-input.ts\";\nimport type { AgentSession, AgentSessionEvent } from \"../core/session.ts\";\nimport type { ExtensionHost } from \"../extensions/runtime.ts\";\nimport {\n\ttype InteractiveProviderOnboardingOptions,\n\tshowInteractiveProviderOnboarding,\n} from \"../provider-onboarding.ts\";\nimport { loadStartupConfiguration, removeGlobalProviderApiKey, resolveStartupRuntime } from \"../startup.ts\";\nimport {\n\tAutocompleteMenu,\n\tInteractiveChat,\n\tInteractiveComposer,\n\tInteractiveFooter,\n\tInteractiveHeader,\n\ttype InteractiveViewState,\n} from \"./interactive-components.ts\";\nimport { InteractiveLayout } from \"./interactive-layout.ts\";\nimport { InteractiveProjection } from \"./interactive-state.ts\";\n\nexport type { AgentSessionEvent };\nexport type { InteractiveMessage, InteractiveProcessItem, InteractiveState } from \"./interactive-state.ts\";\nexport { InteractiveProjection } from \"./interactive-state.ts\";\n\nconst IMAGE_EXTENSIONS = new Set([\".gif\", \".jpeg\", \".jpg\", \".png\", \".webp\"]);\nconst PASTE_IMAGE_KEY = process.platform === \"win32\" ? Key.alt(\"v\") : Key.ctrl(\"v\");\nconst PASTE_IMAGE_SHORTCUT = process.platform === \"win32\" ? \"Alt+V\" : \"Ctrl+V\";\nconst BUILTIN_SLASH_COMMANDS: readonly SlashCommand[] = [\n\t{ name: \"help\", description: \"Show interactive commands\" },\n\t{ name: \"clear\", description: \"Clear visible messages\" },\n\t{ name: \"model\", description: \"Open the model selector\" },\n\t{ name: \"session\", description: \"Open the session selector\" },\n\t{ name: \"theme\", description: \"Open the theme selector\" },\n\t{ name: \"settings\", description: \"Open the settings selector\" },\n\t{ name: \"login\", description: \"Choose a Provider and save its global API key\" },\n\t{ name: \"logout\", description: \"Remove the current Provider global API key\" },\n\t{ name: \"compact\", description: \"Compact the persisted context now\" },\n\t{ name: \"usage\", description: \"Show token and cost usage\" },\n\t{ name: \"retry\", description: \"Retry the last failed prompt\" },\n\t{ name: \"steer\", description: \"Steer the running agent\" },\n];\n\nfunction asImageAttachmentReference(pasted: string, cwd: string): string {\n\tif (pasted.includes(\"\\n\")) return pasted;\n\tconst candidate = pasted.trim().replace(/^(?:\"([\\s\\S]*)\"|'([\\s\\S]*)')$/, \"$1$2\");\n\tif (!candidate || !IMAGE_EXTENSIONS.has(extname(candidate).toLowerCase())) return pasted;\n\ttry {\n\t\tif (!statSync(resolve(cwd, candidate)).isFile()) return pasted;\n\t} catch {\n\t\treturn pasted;\n\t}\n\treturn `@\"${candidate.replaceAll('\"', '\\\\\"')}\" `;\n}\n\nfunction normalizeDroppedImagePrompt(prompt: string, cwd: string): string {\n\tconst normalized = asImageAttachmentReference(prompt, cwd);\n\tif (normalized !== prompt) return normalized;\n\tconst prefix = /^((?:(?:[A-Za-z]:[\\\\/])|(?:\\.\\.?[\\\\/])|\\/)[\\s\\S]*?\\.(?:gif|jpe?g|png|webp))([\\s\\S]*)$/i.exec(prompt);\n\tif (!prefix) return prompt;\n\tconst imageReference = asImageAttachmentReference(prefix[1] ?? \"\", cwd);\n\treturn imageReference === prefix[1]\n\t\t? prompt\n\t\t: `${imageReference}${normalizeDroppedImagePrompt(prefix[2] ?? \"\", cwd)}`;\n}\n\nfunction steeringCommandArgument(prompt: string): string | undefined {\n\tconst match = /^\\/steer(?:\\s+([\\s\\S]*))?$/i.exec(prompt);\n\treturn match ? (match[1] ?? \"\").trim() : undefined;\n}\n\nexport interface InteractiveModeOptions {\n\treadonly session: AgentSession;\n\treadonly tui: TUI;\n\treadonly onExit?: () => void;\n\treadonly sessions?: readonly InteractiveSessionChoice[];\n\treadonly extensionHost?: ExtensionHost;\n\treadonly providerOnboarding?: Omit<InteractiveProviderOnboardingOptions, \"tui\">;\n\treadonly readClipboardImagePath?: (directory?: string) => Promise<string | null>;\n}\n\nexport interface InteractiveSessionChoice {\n\treadonly id: string;\n\treadonly label: string;\n\treadonly description?: string;\n\topen(): AgentSession | Promise<AgentSession>;\n}\n\nexport class InteractiveMode {\n\tprivate readonly projection = new InteractiveProjection();\n\tprivate readonly root: InteractiveLayout;\n\tprivate readonly editor: Editor;\n\tprivate session: AgentSession;\n\tprivate readonly tui: TUI;\n\tprivate readonly sessionChoices: readonly InteractiveSessionChoice[];\n\tprivate readonly extensionHost?: ExtensionHost;\n\tprivate readonly providerOnboarding?: Omit<InteractiveProviderOnboardingOptions, \"tui\">;\n\tprivate readonly readClipboardImagePath: (directory?: string) => Promise<string | null>;\n\tprivate clipboardDirectory: string;\n\tprivate readonly clipboardFiles = new Set<string>();\n\tprivate unsubscribeSession?: () => void;\n\tprivate sessionSwitching = false;\n\tprivate promptInFlight = false;\n\tprivate compactionInFlight = false;\n\tprivate activeAbort?: AbortController;\n\tprivate started = false;\n\tprivate lastFailedPrompt?: string;\n\tprivate queuedPrompts: string[] = [];\n\tprivate steeringPrompts: string[] = [];\n\tprivate readonly onExit?: () => void;\n\tprivate theme: \"dark\" | \"light\" = \"dark\";\n\tprivate overlay?: OverlayHandle;\n\tprivate autocompleteOverlay?: OverlayHandle;\n\tprivate spinnerTimer?: ReturnType<typeof setInterval>;\n\tprivate shutdownEmitted = false;\n\tprivate preserveClipboardFiles = false;\n\n\tconstructor(options: InteractiveModeOptions) {\n\t\tthis.session = options.session;\n\t\tthis.projection.configureFilePreview(this.session.allowedRoot, () => this.refresh());\n\t\tthis.tui = options.tui;\n\t\tthis.onExit = options.onExit;\n\t\tthis.sessionChoices = [...(options.sessions ?? [])];\n\t\tthis.extensionHost = options.extensionHost;\n\t\tthis.providerOnboarding = options.providerOnboarding;\n\t\tthis.readClipboardImagePath = options.readClipboardImagePath ?? readClipboardImagePath;\n\t\tthis.clipboardDirectory = clipboardImageDirectory(this.session.allowedRoot);\n\t\tconst autocomplete: AutocompleteProvider = {\n\t\t\tgetSuggestions: (context, autocompleteOptions) =>\n\t\t\t\tnew CombinedAutocompleteProvider(this.listSlashCommands(), this.session.allowedRoot).getSuggestions(\n\t\t\t\t\tcontext,\n\t\t\t\t\tautocompleteOptions,\n\t\t\t\t),\n\t\t\tapplyCompletion: (context, item, prefix) =>\n\t\t\t\tnew CombinedAutocompleteProvider(this.listSlashCommands(), this.session.allowedRoot).applyCompletion(\n\t\t\t\t\tcontext,\n\t\t\t\t\titem,\n\t\t\t\t\tprefix,\n\t\t\t\t),\n\t\t};\n\t\tthis.editor = new Editor({\n\t\t\tmaxHeight: 3,\n\t\t\tautocomplete,\n\t\t});\n\t\tthis.editor.onSubmit = (text) => void this.submit(text);\n\t\tthis.editor.onEscape = () => this.activeAbort?.abort();\n\t\tthis.editor.onCommand = (data) => this.handleCommand(data);\n\t\tthis.editor.onInterrupt = () => this.exit();\n\t\tthis.editor.onChange = () => {\n\t\t\tif (!this.preserveClipboardFiles) {\n\t\t\t\tvoid this.cleanupUnreferencedClipboardFiles().catch((cause) => {\n\t\t\t\t\tthis.projection.setError(cause instanceof Error ? cause.message : String(cause));\n\t\t\t\t\tthis.refresh();\n\t\t\t\t});\n\t\t\t}\n\t\t};\n\t\tthis.editor.onAutocompleteChange = () => this.updateAutocompleteOverlay();\n\t\tconst readViewState = (): InteractiveViewState => ({\n\t\t\t...this.projection.state,\n\t\t\tmodel: `${this.session.modelId}${this.session.thinkingLevel ? `(${this.session.thinkingLevel})` : \"\"}`,\n\t\t\ttheme: this.theme,\n\t\t\tpasteImageShortcut: PASTE_IMAGE_SHORTCUT,\n\t\t});\n\t\tthis.root = new InteractiveLayout({\n\t\t\theader: new InteractiveHeader(readViewState),\n\t\t\tchat: new InteractiveChat(readViewState),\n\t\t\tcomposer: new InteractiveComposer(readViewState),\n\t\t\teditor: this.editor,\n\t\t\tfooter: new InteractiveFooter(readViewState),\n\t\t});\n\t\tthis.tui.addChild(this.root);\n\t\tthis.tui.setFocus(this.editor);\n\t}\n\n\tstart(initialPrompt?: string): void {\n\t\tif (this.started) throw new Error(\"Interactive mode is already started\");\n\t\tthis.started = true;\n\t\tthis.shutdownEmitted = false;\n\t\tvoid this.extensionHost?.emit({ type: \"session_start\", cwd: this.session.allowedRoot });\n\t\tthis.projection.replaceTranscript(this.session.transcript);\n\t\tthis.projection.setUsage(this.session.usage);\n\t\tthis.subscribeToSession();\n\t\tvoid cleanupStaleClipboardImages(this.session.allowedRoot).catch((cause) => {\n\t\t\tthis.projection.setError(cause instanceof Error ? cause.message : String(cause));\n\t\t\tthis.refresh();\n\t\t});\n\t\ttry {\n\t\t\tthis.tui.start();\n\t\t} catch (cause) {\n\t\t\tthis.started = false;\n\t\t\tthis.unsubscribeSession?.();\n\t\t\tthis.unsubscribeSession = undefined;\n\t\t\tthrow cause;\n\t\t}\n\t\tthis.startSpinnerTimer();\n\t\tif (initialPrompt?.trim()) void this.submit(initialPrompt);\n\t}\n\n\tstop(): void {\n\t\tif (!this.started && !this.unsubscribeSession) return;\n\t\tthis.started = false;\n\t\tthis.activeAbort?.abort();\n\t\tthis.activeAbort = undefined;\n\t\tthis.stopSpinnerTimer();\n\t\tthis.projection.clearTransientProcess();\n\t\tthis.closeOverlay();\n\t\tthis.closeAutocompleteOverlay();\n\t\tthis.unsubscribeSession?.();\n\t\tthis.unsubscribeSession = undefined;\n\t\tvoid this.cleanupClipboardFiles();\n\t\tthis.tui.stop({ finalLines: this.root.renderTranscript(this.tui.columns) });\n\t\tif (!this.shutdownEmitted) {\n\t\t\tthis.shutdownEmitted = true;\n\t\t\tvoid this.extensionHost?.emit({ type: \"session_shutdown\", reason: \"user\" });\n\t\t}\n\t}\n\n\tprivate exit(): void {\n\t\tthis.stop();\n\t\tthis.onExit?.();\n\t}\n\n\tprivate handleCommand(data: string): boolean {\n\t\tif (matchesKey(data, Key.alt(\"s\"))) {\n\t\t\tvoid this.submitSteering(this.editor.getValue());\n\t\t\treturn true;\n\t\t}\n\t\tif (data === \"\\x1b[Z\") {\n\t\t\ttry {\n\t\t\t\tconst level = this.session.cycleThinkingLevel();\n\t\t\t\tthis.projection.setStatus(level ? `thinking=${level}` : \"Current model does not support thinking levels.\");\n\t\t\t} catch (cause) {\n\t\t\t\tthis.projection.setError(cause instanceof Error ? cause.message : String(cause));\n\t\t\t}\n\t\t\tthis.refresh();\n\t\t\treturn true;\n\t\t}\n\t\tif (data === \"\\x14\") {\n\t\t\tthis.openThemeSelector();\n\t\t\treturn true;\n\t\t}\n\t\tif (data === \"\\x13\") {\n\t\t\tthis.openSettingsSelector();\n\t\t\treturn true;\n\t\t}\n\t\tif (data === \"\\x0f\") {\n\t\t\tthis.openModelSelector();\n\t\t\treturn true;\n\t\t}\n\t\tif (data === \"\\x0c\") {\n\t\t\tthis.openSessionSelector();\n\t\t\treturn true;\n\t\t}\n\t\tif (data === \"\\x12\" && this.lastFailedPrompt && !this.promptInFlight) {\n\t\t\tvoid this.submit(this.lastFailedPrompt, true);\n\t\t\treturn true;\n\t\t}\n\t\tif (matchesKey(data, PASTE_IMAGE_KEY)) {\n\t\t\tvoid this.attachClipboardImage();\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tprivate async attachClipboardImage(): Promise<void> {\n\t\ttry {\n\t\t\tconst path = await this.readClipboardImagePath(this.clipboardDirectory);\n\t\t\tif (!path) {\n\t\t\t\tthis.projection.setStatus(\"Clipboard has no supported image.\");\n\t\t\t} else {\n\t\t\t\tthis.editor.insertTextAtCursor(path);\n\t\t\t\tif (isClipboardImagePath(path, this.clipboardDirectory)) this.clipboardFiles.add(path);\n\t\t\t}\n\t\t} catch (cause) {\n\t\t\tthis.projection.setError(cause instanceof Error ? cause.message : String(cause));\n\t\t}\n\t\tthis.refresh();\n\t}\n\n\tprivate openThemeSelector(): void {\n\t\tconst list = new SelectList([\n\t\t\t{ value: \"dark\", label: \"Dark\", description: \"Dark terminal theme\" },\n\t\t\t{ value: \"light\", label: \"Light\", description: \"Light terminal theme\" },\n\t\t]);\n\t\tlist.onSelect = (item) => {\n\t\t\tthis.theme = item.value === \"light\" ? \"light\" : \"dark\";\n\t\t\tthis.projection.setStatus(`theme=${this.theme}`);\n\t\t\tthis.closeOverlay();\n\t\t\tthis.refresh();\n\t\t};\n\t\tlist.onCancel = () => this.closeOverlay();\n\t\tthis.showOverlay(list);\n\t}\n\n\tprivate openModelSelector(): void {\n\t\tconst list = new SelectList(\n\t\t\tthis.session.availableModels.map((model) => ({\n\t\t\t\tvalue: model.id,\n\t\t\t\tlabel: model.name,\n\t\t\t\tdescription: `${model.provider} / ${model.id} / context ${model.contextWindow}`,\n\t\t\t})),\n\t\t);\n\t\tlist.onSelect = (item) => {\n\t\t\ttry {\n\t\t\t\tthis.session.setModel(item.value);\n\t\t\t\tthis.projection.setStatus(`model=${item.value}`);\n\t\t\t\tthis.closeOverlay();\n\t\t\t\tthis.refresh();\n\t\t\t} catch (cause) {\n\t\t\t\tthis.projection.setError(cause instanceof Error ? cause.message : String(cause));\n\t\t\t}\n\t\t};\n\t\tlist.onCancel = () => this.closeOverlay();\n\t\tthis.showOverlay(list);\n\t}\n\n\tprivate openSessionSelector(): void {\n\t\tconst list = new SelectList([\n\t\t\t{\n\t\t\t\tvalue: \"__current__\",\n\t\t\t\tlabel: \"Current session\",\n\t\t\t\tdescription: this.session.sessionFile ?? \"In-memory session\",\n\t\t\t},\n\t\t\t...this.sessionChoices.map((choice) => ({\n\t\t\t\tvalue: choice.id,\n\t\t\t\tlabel: choice.label,\n\t\t\t\t...(choice.description ? { description: choice.description } : {}),\n\t\t\t})),\n\t\t]);\n\t\tlist.onSelect = (item) => {\n\t\t\tif (item.value === \"__current__\") {\n\t\t\t\tthis.projection.setStatus(\"session=current\");\n\t\t\t\tthis.closeOverlay();\n\t\t\t\tthis.refresh();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst choice = this.sessionChoices.find((candidate) => candidate.id === item.value);\n\t\t\tif (!choice) return;\n\t\t\tthis.closeOverlay();\n\t\t\tvoid this.switchSession(choice);\n\t\t};\n\t\tlist.onCancel = () => this.closeOverlay();\n\t\tthis.showOverlay(list);\n\t}\n\n\tprivate openSettingsSelector(): void {\n\t\tconst list = new SettingsList([\n\t\t\t{\n\t\t\t\tid: \"compaction\",\n\t\t\t\tlabel: \"Context compaction\",\n\t\t\t\tcurrentValue: this.session.compactionEnabled ? \"on\" : \"off\",\n\t\t\t\tvalues: [\"on\", \"off\"],\n\t\t\t\tdescription: \"Summarize older persisted context before the model limit is reached.\",\n\t\t\t},\n\t\t]);\n\t\tlist.onChange = (id, value) => {\n\t\t\tif (id !== \"compaction\") return;\n\t\t\ttry {\n\t\t\t\tconst enabled = this.session.setCompactionEnabled(value === \"on\");\n\t\t\t\tlist.updateValue(id, enabled ? \"on\" : \"off\");\n\t\t\t\tthis.projection.setStatus(\n\t\t\t\t\tenabled === (value === \"on\")\n\t\t\t\t\t\t? `compaction=${enabled ? \"on\" : \"off\"}`\n\t\t\t\t\t\t: \"compaction unavailable without a persisted session\",\n\t\t\t\t);\n\t\t\t} catch (cause) {\n\t\t\t\tlist.updateValue(id, this.session.compactionEnabled ? \"on\" : \"off\");\n\t\t\t\tthis.projection.setError(cause instanceof Error ? cause.message : String(cause));\n\t\t\t\tthis.closeOverlay();\n\t\t\t}\n\t\t\tthis.refresh();\n\t\t};\n\t\tlist.onCancel = () => this.closeOverlay();\n\t\tthis.showOverlay(list);\n\t}\n\n\tprivate showOverlay(component: Component): void {\n\t\tthis.editor.cancelAutocomplete();\n\t\tthis.closeAutocompleteOverlay();\n\t\tthis.closeOverlay();\n\t\tthis.overlay = this.tui.showOverlay(component, {\n\t\t\twidth: \"70%\",\n\t\t\tmaxHeight: \"60%\",\n\t\t\tanchor: \"center\",\n\t\t\tmargin: 1,\n\t\t});\n\t}\n\n\tprivate closeOverlay(): void {\n\t\tthis.overlay?.hide();\n\t\tthis.overlay = undefined;\n\t}\n\n\tprivate updateAutocompleteOverlay(): void {\n\t\tthis.closeAutocompleteOverlay();\n\t\tif (!this.editor.isShowingAutocomplete()) {\n\t\t\tthis.refresh();\n\t\t\treturn;\n\t\t}\n\t\tconst menu = new AutocompleteMenu(() => ({\n\t\t\titems: this.editor.getAutocompleteItems(),\n\t\t\tindex: this.editor.getAutocompleteIndex(),\n\t\t}));\n\t\tconst editorBounds = this.root.getEditorBounds(this.tui.columns);\n\t\tthis.autocompleteOverlay = this.tui.showOverlay(menu, {\n\t\t\twidth: \"55%\",\n\t\t\tmaxHeight: 8,\n\t\t\tanchor: \"bottom-left\",\n\t\t\tplacement: {\n\t\t\t\tanchorRow: editorBounds.end - 1,\n\t\t\t\tavoidStartRow: editorBounds.start,\n\t\t\t\tpreferred: \"below\",\n\t\t\t},\n\t\t\tmargin: 1,\n\t\t\tnonCapturing: true,\n\t\t});\n\t\tthis.refresh();\n\t}\n\n\tprivate closeAutocompleteOverlay(): void {\n\t\tthis.autocompleteOverlay?.hide();\n\t\tthis.autocompleteOverlay = undefined;\n\t}\n\n\tprivate refresh(): void {\n\t\tthis.root.invalidate();\n\t\tthis.tui.requestRender();\n\t}\n\n\tprivate startSpinnerTimer(): void {\n\t\tthis.stopSpinnerTimer();\n\t\tthis.spinnerTimer = setInterval(() => {\n\t\t\tif (this.projection.advanceSpinner()) this.refresh();\n\t\t}, 120);\n\t\tthis.spinnerTimer.unref?.();\n\t}\n\n\tprivate stopSpinnerTimer(): void {\n\t\tif (this.spinnerTimer) clearInterval(this.spinnerTimer);\n\t\tthis.spinnerTimer = undefined;\n\t}\n\n\tprivate subscribeToSession(): void {\n\t\tthis.unsubscribeSession?.();\n\t\tthis.unsubscribeSession = this.session.subscribeSession((event) => {\n\t\t\tif (!this.started) return;\n\t\t\tif (event.type === \"queue_update\") {\n\t\t\t\tthis.steeringPrompts = [...event.steering];\n\t\t\t\tthis.refreshQueue();\n\t\t\t\tthis.refresh();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.projection.apply(event);\n\t\t\tthis.refresh();\n\t\t});\n\t}\n\n\tprivate async switchSession(choice: InteractiveSessionChoice): Promise<void> {\n\t\tif (this.promptInFlight || this.sessionSwitching) {\n\t\t\tthis.projection.setError(\"Cannot switch sessions while a prompt is running.\");\n\t\t\tthis.refresh();\n\t\t\treturn;\n\t\t}\n\t\tthis.sessionSwitching = true;\n\t\tthis.projection.setStatus(`opening session=${choice.id}`);\n\t\tthis.refresh();\n\t\ttry {\n\t\t\tconst next = await choice.open();\n\t\t\tif (!this.started) return;\n\t\t\tthis.unsubscribeSession?.();\n\t\t\tthis.session = next;\n\t\t\tthis.projection.configureFilePreview(next.allowedRoot, () => this.refresh());\n\t\t\tthis.clipboardDirectory = clipboardImageDirectory(next.allowedRoot);\n\t\t\tvoid cleanupStaleClipboardImages(next.allowedRoot);\n\t\t\tthis.queuedPrompts = [];\n\t\t\tthis.steeringPrompts = [];\n\t\t\tthis.refreshQueue();\n\t\t\tthis.projection.replaceTranscript(next.transcript);\n\t\t\tthis.projection.setUsage(next.usage);\n\t\t\tthis.projection.setStatus(`session=${choice.id}`);\n\t\t\tthis.subscribeToSession();\n\t\t} catch (cause) {\n\t\t\tthis.projection.setError(cause instanceof Error ? cause.message : String(cause));\n\t\t} finally {\n\t\t\tthis.sessionSwitching = false;\n\t\t}\n\t\tthis.refresh();\n\t}\n\n\tprivate async submit(text: string, retry = false): Promise<void> {\n\t\tconst prompt = text.trim();\n\t\tif (prompt.length === 0 || !this.started) return;\n\t\tconst steeringArgument = steeringCommandArgument(prompt);\n\t\tif (steeringArgument !== undefined) {\n\t\t\tawait this.submitSteering(steeringArgument);\n\t\t\treturn;\n\t\t}\n\t\tif (prompt.startsWith(\"/\") && !this.isLoadedSkillCommand(prompt)) {\n\t\t\tthis.editor.setValue(\"\");\n\t\t\tthis.handleSlashCommand(prompt);\n\t\t\treturn;\n\t\t}\n\t\tif (this.sessionSwitching) {\n\t\t\tthis.projection.setError(\"A session is opening; wait before submitting a prompt.\");\n\t\t\tthis.refresh();\n\t\t\treturn;\n\t\t}\n\t\tif (this.compactionInFlight) {\n\t\t\tthis.projection.setError(\"A compaction is running; wait before submitting a prompt.\");\n\t\t\tthis.refresh();\n\t\t\treturn;\n\t\t}\n\t\tif (this.promptInFlight) {\n\t\t\tthis.queuedPrompts.push(prompt);\n\t\t\tthis.refreshQueue();\n\t\t\tthis.root.invalidate();\n\t\t\tthis.tui.requestRender();\n\t\t\treturn;\n\t\t}\n\t\tthis.promptInFlight = true;\n\t\tthis.activeAbort = new AbortController();\n\t\tthis.projection.setRetrying(retry);\n\t\ttry {\n\t\t\tconst input = await extractImageAttachments(\n\t\t\t\tnormalizeDroppedImagePrompt(prompt, this.session.allowedRoot),\n\t\t\t\tthis.session.allowedRoot,\n\t\t\t);\n\t\t\tthis.preserveClipboardFiles = true;\n\t\t\tthis.editor.setValue(\"\");\n\t\t\tconst result = await this.session.promptWithImages(input.text, input.images, this.activeAbort.signal);\n\t\t\tif (result.stopReason === \"error\" || result.stopReason === \"aborted\") this.lastFailedPrompt = prompt;\n\t\t\telse {\n\t\t\t\tthis.lastFailedPrompt = undefined;\n\t\t\t\tawait this.cleanupClipboardFiles();\n\t\t\t}\n\t\t} catch (cause) {\n\t\t\tthis.lastFailedPrompt = prompt;\n\t\t\tthis.projection.setError(cause instanceof Error ? cause.message : String(cause));\n\t\t} finally {\n\t\t\tthis.preserveClipboardFiles = false;\n\t\t\tthis.promptInFlight = false;\n\t\t\tthis.activeAbort = undefined;\n\t\t\tthis.projection.setRetrying(false);\n\t\t\tconst next = this.queuedPrompts.shift();\n\t\t\tthis.refreshQueue();\n\t\t\tthis.root.invalidate();\n\t\t\tthis.tui.requestRender();\n\t\t\tif (next && this.started) void this.submit(next);\n\t\t}\n\t}\n\n\tprivate async submitSteering(text: string): Promise<void> {\n\t\tconst prompt = text.trim();\n\t\tif (prompt.length === 0) {\n\t\t\tthis.projection.setError(\"Steering content must not be empty.\");\n\t\t\tthis.refresh();\n\t\t\treturn;\n\t\t}\n\t\tif (this.sessionSwitching) {\n\t\t\tthis.projection.setError(\"A session is opening; wait before steering the agent.\");\n\t\t\tthis.refresh();\n\t\t\treturn;\n\t\t}\n\t\tif (this.compactionInFlight) {\n\t\t\tthis.projection.setError(\"A compaction is running; wait before steering the agent.\");\n\t\t\tthis.refresh();\n\t\t\treturn;\n\t\t}\n\t\tif (!this.promptInFlight) {\n\t\t\tthis.projection.setError(\"Steering is only available while a prompt is running.\");\n\t\t\tthis.refresh();\n\t\t\treturn;\n\t\t}\n\t\ttry {\n\t\t\tconst input = await extractImageAttachments(\n\t\t\t\tnormalizeDroppedImagePrompt(prompt, this.session.allowedRoot),\n\t\t\t\tthis.session.allowedRoot,\n\t\t\t);\n\t\t\tawait this.session.steerWithImages(input.text, input.images);\n\t\t\tthis.editor.setValue(\"\");\n\t\t} catch (cause) {\n\t\t\tthis.projection.setError(cause instanceof Error ? cause.message : String(cause));\n\t\t}\n\t\tthis.refresh();\n\t}\n\n\tprivate refreshQueue(): void {\n\t\tthis.projection.setQueue([\n\t\t\t...this.steeringPrompts.map((prompt) => `steer: ${prompt}`),\n\t\t\t...this.queuedPrompts.map((prompt) => `queued: ${prompt}`),\n\t\t]);\n\t}\n\n\tprivate async cleanupUnreferencedClipboardFiles(): Promise<void> {\n\t\tconst text = this.editor.getValue();\n\t\tconst files = [...this.clipboardFiles].filter((path) => !text.includes(path));\n\t\tawait Promise.all(files.map((path) => removeClipboardImage(path, this.clipboardDirectory)));\n\t\tfor (const path of files) this.clipboardFiles.delete(path);\n\t}\n\n\tprivate async cleanupClipboardFiles(): Promise<void> {\n\t\tconst files = [...this.clipboardFiles];\n\t\tawait Promise.all(files.map((path) => removeClipboardImage(path, this.clipboardDirectory)));\n\t\tfor (const path of files) this.clipboardFiles.delete(path);\n\t}\n\n\tprivate handleSlashCommand(input: string): void {\n\t\tconst trimmed = input.slice(1).trim();\n\t\tconst [rawCommand = \"\", ...argParts] = trimmed.split(/\\s+/);\n\t\tconst command = rawCommand.toLowerCase();\n\t\tconst args = argParts.join(\" \");\n\t\tswitch (command) {\n\t\t\tcase \"help\":\n\t\t\t\tthis.projection.setStatus(\n\t\t\t\t\t`commands: ${this.listSlashCommands()\n\t\t\t\t\t\t.map((item) => `/${item.name}`)\n\t\t\t\t\t\t.join(\" \")}`,\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\tcase \"clear\":\n\t\t\t\tthis.projection.clearVisibleMessages();\n\t\t\t\tthis.projection.setStatus(\"visible messages cleared\");\n\t\t\t\tbreak;\n\t\t\tcase \"model\":\n\t\t\t\tthis.openModelSelector();\n\t\t\t\treturn;\n\t\t\tcase \"session\":\n\t\t\t\tthis.openSessionSelector();\n\t\t\t\treturn;\n\t\t\tcase \"theme\":\n\t\t\t\tthis.openThemeSelector();\n\t\t\t\treturn;\n\t\t\tcase \"settings\":\n\t\t\t\tthis.openSettingsSelector();\n\t\t\t\treturn;\n\t\t\tcase \"login\":\n\t\t\t\tthis.openProviderLogin();\n\t\t\t\treturn;\n\t\t\tcase \"logout\":\n\t\t\t\tvoid this.logoutProvider();\n\t\t\t\treturn;\n\t\t\tcase \"compact\":\n\t\t\t\tvoid this.runManualCompaction();\n\t\t\t\treturn;\n\t\t\tcase \"usage\":\n\t\t\t\tthis.projection.setStatus(this.formatUsage());\n\t\t\t\tbreak;\n\t\t\tcase \"retry\":\n\t\t\t\tif (this.lastFailedPrompt && !this.promptInFlight) void this.submit(this.lastFailedPrompt, true);\n\t\t\t\telse this.projection.setStatus(\"nothing to retry\");\n\t\t\t\tbreak;\n\t\t\tdefault: {\n\t\t\t\tif (this.extensionHost?.listCommands().some((entry) => entry.name === command)) {\n\t\t\t\t\tvoid this.extensionHost.runCommand(command, args).catch((cause) => {\n\t\t\t\t\t\tthis.projection.setError(cause instanceof Error ? cause.message : String(cause));\n\t\t\t\t\t\tthis.refresh();\n\t\t\t\t\t});\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tthis.projection.setError(`Unknown command: /${command}`);\n\t\t\t}\n\t\t}\n\t\tthis.refresh();\n\t}\n\n\tprivate openProviderLogin(): void {\n\t\tif (!this.providerOnboarding) {\n\t\t\tthis.projection.setError(\"Provider login is unavailable in this session.\");\n\t\t\tthis.refresh();\n\t\t\treturn;\n\t\t}\n\t\tif (this.promptInFlight || this.sessionSwitching) {\n\t\t\tthis.projection.setError(\"Cannot change Provider while a prompt is running.\");\n\t\t\tthis.refresh();\n\t\t\treturn;\n\t\t}\n\t\tthis.editor.cancelAutocomplete();\n\t\tthis.closeAutocompleteOverlay();\n\t\tvoid showInteractiveProviderOnboarding({ ...this.providerOnboarding, tui: this.tui })\n\t\t\t.then((runtime) => {\n\t\t\t\tif (!this.started) return;\n\t\t\t\tthis.tui.setFocus(this.editor);\n\t\t\t\tif (!runtime) {\n\t\t\t\t\tthis.refresh();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tthis.session.setRuntime(runtime.provider, runtime.model);\n\t\t\t\tthis.projection.setStatus(`provider=${runtime.provider.id} model=${runtime.model.id}`);\n\t\t\t\tthis.refresh();\n\t\t\t})\n\t\t\t.catch((cause) => {\n\t\t\t\tif (this.started) this.tui.setFocus(this.editor);\n\t\t\t\tthis.projection.setError(cause instanceof Error ? cause.message : String(cause));\n\t\t\t\tthis.refresh();\n\t\t\t});\n\t}\n\n\tprivate async logoutProvider(): Promise<void> {\n\t\tif (!this.providerOnboarding) {\n\t\t\tthis.projection.setError(\"Provider logout is unavailable in this session.\");\n\t\t\tthis.refresh();\n\t\t\treturn;\n\t\t}\n\t\tif (this.promptInFlight || this.sessionSwitching) {\n\t\t\tthis.projection.setError(\"Cannot change Provider while a prompt is running.\");\n\t\t\tthis.refresh();\n\t\t\treturn;\n\t\t}\n\t\tconst providerId = this.session.providerId;\n\t\tconst modelId = this.session.modelId;\n\t\ttry {\n\t\t\tconst removed = await removeGlobalProviderApiKey(this.providerOnboarding.agentDir, providerId);\n\t\t\tif (!removed) {\n\t\t\t\tthis.projection.setStatus(`no global API key stored for provider=${providerId}`);\n\t\t\t\tthis.refresh();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst configuration = await loadStartupConfiguration(\n\t\t\t\tthis.session.allowedRoot,\n\t\t\t\tthis.providerOnboarding.configuration.environment,\n\t\t\t\tthis.providerOnboarding.agentDir,\n\t\t\t);\n\t\t\tconst runtime = resolveStartupRuntime(\n\t\t\t\t{\n\t\t\t\t\t...configuration.environment,\n\t\t\t\t\tDI_CODE_PROVIDER: providerId,\n\t\t\t\t\tDI_CODE_MODEL: modelId,\n\t\t\t\t},\n\t\t\t\tconfiguration.providers,\n\t\t\t\tconfiguration.defaults,\n\t\t\t);\n\t\t\tthis.session.setRuntime(runtime.provider, runtime.model);\n\t\t\tthis.projection.setStatus(\n\t\t\t\t`global API key removed for provider=${providerId}; environment variables may still apply`,\n\t\t\t);\n\t\t} catch (cause) {\n\t\t\tthis.projection.setError(cause instanceof Error ? cause.message : String(cause));\n\t\t}\n\t\tthis.refresh();\n\t}\n\n\tprivate listSlashCommands(): readonly SlashCommand[] {\n\t\tconst skills = this.session.availableSkills.map((skill) => ({\n\t\t\tname: `skill:${skill.name}`,\n\t\t\tdescription: skill.description,\n\t\t}));\n\t\treturn [...BUILTIN_SLASH_COMMANDS, ...(this.extensionHost?.listCommands() ?? []), ...skills];\n\t}\n\n\tprivate isLoadedSkillCommand(input: string): boolean {\n\t\tconst name = /^\\/skill:([a-z0-9]+(?:-[a-z0-9]+)*)(?:\\s|$)/.exec(input)?.[1];\n\t\treturn name !== undefined && this.session.availableSkills.some((skill) => skill.name === name);\n\t}\n\n\tprivate formatUsage(): string {\n\t\tconst usage = this.session.usage;\n\t\treturn `usage: requests=${usage.requestCount} input=${usage.inputTokens} output=${usage.outputTokens} total=${usage.totalTokens} cost=$${usage.cost.total.toFixed(4)} context=${usage.estimatedContextTokens}/${usage.contextWindow}`;\n\t}\n\n\tprivate async runManualCompaction(): Promise<void> {\n\t\tif (this.promptInFlight || this.compactionInFlight) {\n\t\t\tthis.projection.setError(\"Cannot compact while a prompt is running.\");\n\t\t\tthis.refresh();\n\t\t\treturn;\n\t\t}\n\t\tthis.compactionInFlight = true;\n\t\tthis.projection.setStatus(\"starting manual compaction\");\n\t\tthis.refresh();\n\t\ttry {\n\t\t\tawait this.session.compact();\n\t\t\tthis.projection.setStatus(\"manual compaction complete\");\n\t\t} catch (cause) {\n\t\t\tthis.projection.setError(cause instanceof Error ? cause.message : String(cause));\n\t\t} finally {\n\t\t\tthis.compactionInFlight = false;\n\t\t\tthis.refresh();\n\t\t}\n\t}\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Terminal } from "@di-code/tui";
|
|
1
|
+
import { type Terminal, TUI } from "@di-code/tui";
|
|
2
2
|
import type { CliCommand } from "./cli.ts";
|
|
3
3
|
import { type StartupConfiguration, type StartupRuntime } from "./startup.ts";
|
|
4
4
|
export type StartupRunCommand = Extract<CliCommand, {
|
|
@@ -7,7 +7,14 @@ export type StartupRunCommand = Extract<CliCommand, {
|
|
|
7
7
|
export interface ProviderOnboardingOptions {
|
|
8
8
|
readonly configuration: StartupConfiguration;
|
|
9
9
|
readonly terminal: Terminal;
|
|
10
|
+
readonly agentDir: string;
|
|
11
|
+
}
|
|
12
|
+
export interface InteractiveProviderOnboardingOptions {
|
|
13
|
+
readonly configuration: StartupConfiguration;
|
|
14
|
+
readonly agentDir: string;
|
|
15
|
+
readonly tui: TUI;
|
|
10
16
|
}
|
|
11
17
|
export declare function shouldStartProviderOnboarding(command: StartupRunCommand, isInteractiveTerminal: boolean, configuration: StartupConfiguration): boolean;
|
|
12
18
|
export declare function runProviderOnboarding(options: ProviderOnboardingOptions): Promise<StartupRuntime | undefined>;
|
|
19
|
+
export declare function showInteractiveProviderOnboarding(options: InteractiveProviderOnboardingOptions): Promise<StartupRuntime | undefined>;
|
|
13
20
|
//# sourceMappingURL=provider-onboarding.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider-onboarding.d.ts","sourceRoot":"","sources":["../src/provider-onboarding.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"provider-onboarding.d.ts","sourceRoot":"","sources":["../src/provider-onboarding.ts"],"names":[],"mappings":"AACA,OAAO,EAON,KAAK,QAAQ,EAEb,GAAG,EACH,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAEN,KAAK,oBAAoB,EACzB,KAAK,cAAc,EAEnB,MAAM,cAAc,CAAC;AAEtB,MAAM,MAAM,iBAAiB,GAAG,OAAO,CAAC,UAAU,EAAE;IAAE,IAAI,EAAE,KAAK,CAAA;CAAE,CAAC,CAAC;AAErE,MAAM,WAAW,yBAAyB;IACzC,QAAQ,CAAC,aAAa,EAAE,oBAAoB,CAAC;IAC7C,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,oCAAoC;IACpD,QAAQ,CAAC,aAAa,EAAE,oBAAoB,CAAC;IAC7C,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC;CAClB;AAED,wBAAgB,6BAA6B,CAC5C,OAAO,EAAE,iBAAiB,EAC1B,qBAAqB,EAAE,OAAO,EAC9B,aAAa,EAAE,oBAAoB,GACjC,OAAO,CAOT;AA6LD,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC,CAe7G;AAED,wBAAgB,iCAAiC,CAChD,OAAO,EAAE,oCAAoC,GAC3C,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC,CAiBrC"}
|