@bastani/atomic 0.9.38-alpha.8 → 0.9.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/CHANGELOG.md +112 -0
  2. package/dist/builtin/intercom/CHANGELOG.md +10 -0
  3. package/dist/builtin/intercom/package.json +1 -1
  4. package/dist/builtin/mcp/package.json +1 -1
  5. package/dist/builtin/subagents/CHANGELOG.md +10 -0
  6. package/dist/builtin/subagents/package.json +1 -1
  7. package/dist/builtin/web-access/CHANGELOG.md +7 -0
  8. package/dist/builtin/web-access/package.json +1 -1
  9. package/dist/builtin/workflows/CHANGELOG.md +60 -0
  10. package/dist/builtin/workflows/package.json +1 -1
  11. package/dist/builtin/workflows/src/extension/index.bundle.mjs +5 -0
  12. package/dist/core/agent-session-prompt.d.ts.map +1 -1
  13. package/dist/core/agent-session-prompt.js +57 -15
  14. package/dist/core/agent-session-prompt.js.map +1 -1
  15. package/dist/core/queued-input-admission.d.ts +20 -0
  16. package/dist/core/queued-input-admission.d.ts.map +1 -0
  17. package/dist/core/queued-input-admission.js +55 -0
  18. package/dist/core/queued-input-admission.js.map +1 -0
  19. package/dist/core/storage/session/legacy-session-store.d.ts +6 -3
  20. package/dist/core/storage/session/legacy-session-store.d.ts.map +1 -1
  21. package/dist/core/storage/session/legacy-session-store.js +26 -12
  22. package/dist/core/storage/session/legacy-session-store.js.map +1 -1
  23. package/dist/core/storage/session/legacy-session-summary.d.ts +11 -0
  24. package/dist/core/storage/session/legacy-session-summary.d.ts.map +1 -0
  25. package/dist/core/storage/session/legacy-session-summary.js +103 -0
  26. package/dist/core/storage/session/legacy-session-summary.js.map +1 -0
  27. package/dist/extensions/mcp/client/transports/streamable-http.js +9 -8
  28. package/dist/extensions/mcp/client/transports/streamable-http.js.map +1 -1
  29. package/dist/main-session.d.ts.map +1 -1
  30. package/dist/main-session.js +4 -1
  31. package/dist/main-session.js.map +1 -1
  32. package/dist/modes/interactive/components/chat-session-host-actions.d.ts +4 -0
  33. package/dist/modes/interactive/components/chat-session-host-actions.d.ts.map +1 -1
  34. package/dist/modes/interactive/components/chat-session-host-actions.js +104 -30
  35. package/dist/modes/interactive/components/chat-session-host-actions.js.map +1 -1
  36. package/dist/modes/interactive/components/chat-session-host-events.d.ts.map +1 -1
  37. package/dist/modes/interactive/components/chat-session-host-events.js +1 -0
  38. package/dist/modes/interactive/components/chat-session-host-events.js.map +1 -1
  39. package/dist/modes/interactive/components/chat-session-host-state.d.ts +4 -0
  40. package/dist/modes/interactive/components/chat-session-host-state.d.ts.map +1 -1
  41. package/dist/modes/interactive/components/chat-session-host-state.js +4 -0
  42. package/dist/modes/interactive/components/chat-session-host-state.js.map +1 -1
  43. package/dist/modes/interactive/components/session-selector.js +4 -3
  44. package/dist/modes/interactive/components/session-selector.js.map +1 -1
  45. package/dist/modes/interactive/interactive-input-handling.js +8 -2
  46. package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
  47. package/dist/modes/interactive/interactive-mode-base.d.ts +4 -0
  48. package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
  49. package/dist/modes/interactive/interactive-mode-base.js +4 -0
  50. package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
  51. package/dist/modes/interactive/interactive-process-lifecycle.js +8 -2
  52. package/dist/modes/interactive/interactive-process-lifecycle.js.map +1 -1
  53. package/dist/modes/interactive/interactive-queueing.js +94 -73
  54. package/dist/modes/interactive/interactive-queueing.js.map +1 -1
  55. package/dist/modes/interactive/interactive-session-runtime.js +1 -0
  56. package/dist/modes/interactive/interactive-session-runtime.js.map +1 -1
  57. package/docs/docs.json +5 -2
  58. package/docs/llama-cpp.md +94 -1
  59. package/docs/sessions.md +1 -1
  60. package/docs/usage.md +2 -0
  61. package/npm-shrinkwrap.json +32 -32
  62. package/package.json +3 -3
  63. package/docs/nvidia-rtx-llama-cpp.md +0 -101
@@ -21,6 +21,7 @@ InteractiveModeBase.prototype.clearAllQueues = function (options) {
21
21
  .filter((msg) => msg.mode === "followUp")
22
22
  .map((msg) => msg.text);
23
23
  this.compactionQueuedMessages = [];
24
+ this.compactionSendFailed = false;
24
25
  return {
25
26
  steering: [...steering, ...compactionSteering],
26
27
  followUp: [...followUp, ...compactionFollowUp],
@@ -68,7 +69,12 @@ InteractiveModeBase.prototype.queueCompactionMessage = function (text, mode) {
68
69
  this.editor.addToHistory?.(text);
69
70
  this.editor.setText("");
70
71
  this.updatePendingMessagesDisplay();
71
- this.showStatus("Queued message for after compaction");
72
+ if (this.compactionActive) {
73
+ this.showStatus("Queued message for after compaction");
74
+ return;
75
+ }
76
+ if (!this.compactionFlushPending)
77
+ void this.flushCompactionQueue({ willRetry: false });
72
78
  };
73
79
  InteractiveModeBase.prototype.isExtensionCommand = function (text) {
74
80
  if (!text.startsWith("/"))
@@ -79,85 +85,100 @@ InteractiveModeBase.prototype.isExtensionCommand = function (text) {
79
85
  return !!extensionRunner.getCommand(commandName);
80
86
  };
81
87
  InteractiveModeBase.prototype.flushCompactionQueue = async function (options) {
82
- if (this.compactionQueuedMessages.length === 0) {
88
+ if (this.compactionFlushPending || this.compactionQueuedMessages.length === 0)
83
89
  return;
90
+ this.compactionFlushPending = true;
91
+ this.compactionSendFailed = false;
92
+ try {
93
+ await sendCompactionQueue(this, options?.willRetry === true);
84
94
  }
85
- const queuedMessages = [...this.compactionQueuedMessages];
86
- this.compactionQueuedMessages = [];
87
- this.updatePendingMessagesDisplay();
88
- const restoreQueue = (error, messages = queuedMessages) => {
89
- this.compactionQueuedMessages = [
90
- ...messages,
91
- ...this.compactionQueuedMessages.filter((message) => !messages.includes(message)),
92
- ];
95
+ finally {
96
+ this.compactionFlushPending = false;
93
97
  this.updatePendingMessagesDisplay();
94
- this.showError(`Failed to send queued message${messages.length > 1 ? "s" : ""}: ${error instanceof Error ? error.message : String(error)}`);
95
- };
96
- try {
97
- if (!options?.willRetry && (this.session.isStreaming || this.session.queuedMessagesPaused)) {
98
- await Promise.all(queuedMessages.map((message) => this.session.prompt(message.text, { streamingBehavior: message.mode })));
99
- this.updatePendingMessagesDisplay();
100
- return;
101
- }
102
- if (options?.willRetry) {
103
- // When retry is pending, queue messages for the retry turn
104
- for (const message of queuedMessages) {
105
- if (this.isExtensionCommand(message.text)) {
106
- await this.session.prompt(message.text);
107
- }
108
- else if (message.mode === "followUp") {
109
- await this.session.followUp(message.text);
110
- }
111
- else {
112
- await this.session.steer(message.text);
113
- }
114
- }
115
- this.updatePendingMessagesDisplay();
116
- return;
117
- }
118
- // Find first non-extension-command message to use as prompt
119
- const firstPromptIndex = queuedMessages.findIndex((message) => !this.isExtensionCommand(message.text));
120
- if (firstPromptIndex === -1) {
121
- // All extension commands - execute them all
122
- for (const message of queuedMessages) {
123
- await this.session.prompt(message.text);
124
- }
125
- return;
126
- }
127
- // Execute any extension commands before the first prompt
128
- const preCommands = queuedMessages.slice(0, firstPromptIndex);
129
- const firstPrompt = queuedMessages[firstPromptIndex];
130
- const rest = queuedMessages.slice(firstPromptIndex + 1);
131
- for (const message of preCommands) {
132
- await this.session.prompt(message.text);
98
+ }
99
+ const arrivedAfterDrain = this.compactionQueuedMessages.length > 0 && !this.compactionSendFailed && !this.compactionActive;
100
+ if (arrivedAfterDrain)
101
+ await this.flushCompactionQueue(options);
102
+ };
103
+ async function sendCompactionQueue(mode, willRetry) {
104
+ const queueOnly = !willRetry && (mode.session.isStreaming || mode.session.queuedMessagesPaused);
105
+ if (queueOnly) {
106
+ await drainCompactionQueue(mode, (message) => mode.session.prompt(message.text, { streamingBehavior: message.mode }));
107
+ return;
108
+ }
109
+ if (!willRetry && !(await startCompactionQueuePrompt(mode)))
110
+ return;
111
+ await drainCompactionQueue(mode, (message) => {
112
+ if (mode.isExtensionCommand(message.text))
113
+ return mode.session.prompt(message.text);
114
+ if (message.mode === "followUp")
115
+ return mode.session.followUp(message.text);
116
+ return mode.session.steer(message.text);
117
+ });
118
+ }
119
+ function showCompactionQueueError(mode, error) {
120
+ mode.showError(`Failed to send queued message: ${error instanceof Error ? error.message : String(error)}`);
121
+ }
122
+ function takeNextCompactionMessage(mode) {
123
+ const [next, ...rest] = mode.compactionQueuedMessages;
124
+ mode.compactionQueuedMessages = rest;
125
+ mode.updatePendingMessagesDisplay();
126
+ return next;
127
+ }
128
+ function returnCompactionMessage(mode, message, error) {
129
+ mode.compactionQueuedMessages = [message, ...mode.compactionQueuedMessages];
130
+ mode.compactionSendFailed = true;
131
+ mode.updatePendingMessagesDisplay();
132
+ showCompactionQueueError(mode, error);
133
+ }
134
+ /**
135
+ * Deliver messages one at a time from the front of the compaction queue. Input submitted meanwhile
136
+ * joins the back of that queue, so a failed message returns to the front ahead of everything after it.
137
+ */
138
+ async function drainCompactionQueue(mode, deliver, limit = Number.POSITIVE_INFINITY) {
139
+ for (let delivered = 0; delivered < limit; delivered++) {
140
+ const message = takeNextCompactionMessage(mode);
141
+ if (!message)
142
+ break;
143
+ try {
144
+ await deliver(message);
133
145
  }
134
- // Start a prompt when idle, or preserve its delivery mode if a run is
135
- // still winding down after compaction.
136
- const promptPromise = this.session
137
- .prompt(firstPrompt.text, { streamingBehavior: firstPrompt.mode })
138
- .catch((error) => {
139
- restoreQueue(error, [firstPrompt]);
140
- });
141
- // Queue remaining messages
142
- for (const message of rest) {
143
- if (this.isExtensionCommand(message.text)) {
144
- await this.session.prompt(message.text);
145
- }
146
- else if (message.mode === "followUp") {
147
- await this.session.followUp(message.text);
148
- }
149
- else {
150
- await this.session.steer(message.text);
151
- }
146
+ catch (error) {
147
+ returnCompactionMessage(mode, message, error);
148
+ return false;
152
149
  }
153
- this.updatePendingMessagesDisplay();
154
- void promptPromise;
155
150
  }
156
- catch (error) {
157
- this.session.clearQueue();
158
- restoreQueue(error);
151
+ return true;
152
+ }
153
+ /**
154
+ * Run leading extension commands, then start the first prompt. The rest of the batch stays in the
155
+ * compaction queue until that prompt is accepted, so a rejected prompt is restored ahead of it.
156
+ */
157
+ async function startCompactionQueuePrompt(mode) {
158
+ const firstPromptIndex = mode.compactionQueuedMessages.findIndex((message) => !mode.isExtensionCommand(message.text));
159
+ const leadingCommands = firstPromptIndex === -1 ? mode.compactionQueuedMessages.length : firstPromptIndex;
160
+ const ranCommands = await drainCompactionQueue(mode, (message) => mode.session.prompt(message.text), leadingCommands);
161
+ if (!ranCommands)
162
+ return false;
163
+ const first = takeNextCompactionMessage(mode);
164
+ if (!first)
165
+ return false;
166
+ let accept;
167
+ const accepted = new Promise((resolve) => {
168
+ accept = resolve;
169
+ });
170
+ const prompt = mode.session.prompt(first.text, {
171
+ streamingBehavior: first.mode,
172
+ preflightResult: (success) => accept(success),
173
+ });
174
+ prompt.then(() => accept(true), () => accept(false));
175
+ if (await accepted) {
176
+ prompt.catch((error) => showCompactionQueueError(mode, error));
177
+ return true;
159
178
  }
160
- };
179
+ returnCompactionMessage(mode, first, await prompt.then(() => undefined, (error) => error));
180
+ return false;
181
+ }
161
182
  InteractiveModeBase.prototype.flushPendingBashComponents = function () {
162
183
  for (const component of this.pendingBashComponents) {
163
184
  this.pendingMessagesContainer.removeChild(component);
@@ -1 +1 @@
1
- {"version":3,"file":"interactive-queueing.js","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-queueing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,8BAA8B,EAAE,MAAM,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAE1G,mBAAmB,CAAC,SAAS,CAAC,oBAAoB,GAAG;IAIpD,OAAO;QACN,QAAQ,EAAE;YACT,GAAG,IAAI,CAAC,OAAO,CAAC,mBAAmB,EAAE;YACrC,GAAG,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC;SAC7F;QACD,QAAQ,EA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Q,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAC3C,CAAC;iBAAM,CAAC;gBACP,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YACxC,CAAC;QACF,CAAC;QACD,IAAI,CAAC,4BAA4B,EAAE,CAAC;QACpC,KAAK,aAAa,CAAC;IACpB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;QAC1B,YAAY,CAAC,KAAK,CAAC,CAAC;IACrB,CAAC;AACF,CAAC,CAAC;AAEF,mBAAmB,CAAC,SAAS,CAAC,0BAA0B,GAAG;IAC1D,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,qBAAqB,EAAE,CAAC;QACpD,IAAI,CAAC,wBAAwB,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;QACrD,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;IACxC,CAAC;IACD,IAAI,CAAC,qBAAqB,GAAG,EAAE,CAAC;AACjC,CAAC,CAAC","sourcesContent":["import { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport { combineQueuedMessagesForEditor, Spacer, TruncatedText, theme } from \"./interactive-mode-deps.ts\";\n\nInteractiveModeBase.prototype.getAllQueuedMessages = function (this: InteractiveModeBase): {\n\tsteering: string[];\n\tfollowUp: string[];\n} {\n\treturn {\n\t\tsteering: [\n\t\t\t...this.session.getSteeringMessages(),\n\t\t\t...this.compactionQueuedMessages.filter((msg) => msg.mode === \"steer\").map((msg) => msg.text),\n\t\t],\n\t\tfollowUp: [\n\t\t\t...this.session.getFollowUpMessages(),\n\t\t\t...this.compactionQueuedMessages.filter((msg) => msg.mode === \"followUp\").map((msg) => msg.text),\n\t\t],\n\t};\n};\n\nInteractiveModeBase.prototype.clearAllQueues = function (\n\tthis: InteractiveModeBase,\n\toptions?: { preserveUnprotectedCustomMessages?: boolean },\n): {\n\tsteering: string[];\n\tfollowUp: string[];\n} {\n\tconst { steering, followUp } = this.session.clearQueue(options);\n\tconst compactionSteering = this.compactionQueuedMessages\n\t\t.filter((msg) => msg.mode === \"steer\")\n\t\t.map((msg) => msg.text);\n\tconst compactionFollowUp = this.compactionQueuedMessages\n\t\t.filter((msg) => msg.mode === \"followUp\")\n\t\t.map((msg) => msg.text);\n\tthis.compactionQueuedMessages = [];\n\treturn {\n\t\tsteering: [...steering, ...compactionSteering],\n\t\tfollowUp: [...followUp, ...compactionFollowUp],\n\t};\n};\n\nInteractiveModeBase.prototype.updatePendingMessagesDisplay = function (this: InteractiveModeBase): void {\n\tthis.pendingMessagesContainer.clear();\n\tconst { steering: steeringMessages, followUp: followUpMessages } = this.getAllQueuedMessages();\n\tif (steeringMessages.length > 0 || followUpMessages.length > 0) {\n\t\tthis.pendingMessagesContainer.addChild(new Spacer(1));\n\t\tfor (const message of steeringMessages) {\n\t\t\tconst text = theme.fg(\"dim\", `Steering: ${message}`);\n\t\t\tthis.pendingMessagesContainer.addChild(new TruncatedText(text, 1, 0));\n\t\t}\n\t\tfor (const message of followUpMessages) {\n\t\t\tconst text = theme.fg(\"dim\", `Follow-up: ${message}`);\n\t\t\tthis.pendingMessagesContainer.addChild(new TruncatedText(text, 1, 0));\n\t\t}\n\t\tconst dequeueHint = this.getAppKeyDisplay(\"app.message.dequeue\");\n\t\tconst hintText = theme.fg(\"dim\", `↳ ${dequeueHint} to edit all queued messages`);\n\t\tthis.pendingMessagesContainer.addChild(new TruncatedText(hintText, 1, 0));\n\t}\n};\n\nInteractiveModeBase.prototype.restoreQueuedMessagesToEditor = function (\n\tthis: InteractiveModeBase,\n\toptions?: {\n\t\tabort?: boolean;\n\t\tcurrentText?: string;\n\t\tpreserveUnprotectedCustomMessages?: boolean;\n\t},\n): number {\n\tconst { steering, followUp } = this.clearAllQueues(options);\n\tconst allQueued = [...steering, ...followUp];\n\tif (allQueued.length === 0) {\n\t\tthis.updatePendingMessagesDisplay();\n\t\tif (options?.abort) {\n\t\t\tvoid this.session.abort();\n\t\t}\n\t\treturn 0;\n\t}\n\tconst currentText = options?.currentText ?? this.editor.getText();\n\tconst combinedText = combineQueuedMessagesForEditor(allQueued, currentText);\n\tthis.editor.setText(combinedText);\n\tthis.updatePendingMessagesDisplay();\n\tif (options?.abort) {\n\t\tvoid this.session.abort();\n\t}\n\treturn allQueued.length;\n};\n\nInteractiveModeBase.prototype.queueCompactionMessage = function (\n\tthis: InteractiveModeBase,\n\ttext: string,\n\tmode: \"steer\" | \"followUp\",\n): void {\n\tthis.compactionQueuedMessages.push({ text, mode });\n\tthis.editor.addToHistory?.(text);\n\tthis.editor.setText(\"\");\n\tthis.updatePendingMessagesDisplay();\n\tthis.showStatus(\"Queued message for after compaction\");\n};\n\nInteractiveModeBase.prototype.isExtensionCommand = function (this: InteractiveModeBase, text: string): boolean {\n\tif (!text.startsWith(\"/\")) return false;\n\n\tconst extensionRunner = this.session.extensionRunner;\n\n\tconst spaceIndex = text.indexOf(\" \");\n\tconst commandName = spaceIndex === -1 ? text.slice(1) : text.slice(1, spaceIndex);\n\treturn !!extensionRunner.getCommand(commandName);\n};\n\nInteractiveModeBase.prototype.flushCompactionQueue = async function (\n\tthis: InteractiveModeBase,\n\toptions?: {\n\t\twillRetry?: boolean;\n\t},\n): Promise<void> {\n\tif (this.compactionQueuedMessages.length === 0) {\n\t\treturn;\n\t}\n\n\tconst queuedMessages = [...this.compactionQueuedMessages];\n\tthis.compactionQueuedMessages = [];\n\tthis.updatePendingMessagesDisplay();\n\n\tconst restoreQueue = (error: unknown, messages = queuedMessages) => {\n\t\tthis.compactionQueuedMessages = [\n\t\t\t...messages,\n\t\t\t...this.compactionQueuedMessages.filter((message) => !messages.includes(message)),\n\t\t];\n\t\tthis.updatePendingMessagesDisplay();\n\t\tthis.showError(\n\t\t\t`Failed to send queued message${messages.length > 1 ? \"s\" : \"\"}: ${\n\t\t\t\terror instanceof Error ? error.message : String(error)\n\t\t\t}`,\n\t\t);\n\t};\n\n\ttry {\n\t\tif (!options?.willRetry && (this.session.isStreaming || this.session.queuedMessagesPaused)) {\n\t\t\tawait Promise.all(\n\t\t\t\tqueuedMessages.map((message) => this.session.prompt(message.text, { streamingBehavior: message.mode })),\n\t\t\t);\n\t\t\tthis.updatePendingMessagesDisplay();\n\t\t\treturn;\n\t\t}\n\t\tif (options?.willRetry) {\n\t\t\t// When retry is pending, queue messages for the retry turn\n\t\t\tfor (const message of queuedMessages) {\n\t\t\t\tif (this.isExtensionCommand(message.text)) {\n\t\t\t\t\tawait this.session.prompt(message.text);\n\t\t\t\t} else if (message.mode === \"followUp\") {\n\t\t\t\t\tawait this.session.followUp(message.text);\n\t\t\t\t} else {\n\t\t\t\t\tawait this.session.steer(message.text);\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.updatePendingMessagesDisplay();\n\t\t\treturn;\n\t\t}\n\n\t\t// Find first non-extension-command message to use as prompt\n\t\tconst firstPromptIndex = queuedMessages.findIndex((message) => !this.isExtensionCommand(message.text));\n\t\tif (firstPromptIndex === -1) {\n\t\t\t// All extension commands - execute them all\n\t\t\tfor (const message of queuedMessages) {\n\t\t\t\tawait this.session.prompt(message.text);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\t// Execute any extension commands before the first prompt\n\t\tconst preCommands = queuedMessages.slice(0, firstPromptIndex);\n\t\tconst firstPrompt = queuedMessages[firstPromptIndex];\n\t\tconst rest = queuedMessages.slice(firstPromptIndex + 1);\n\n\t\tfor (const message of preCommands) {\n\t\t\tawait this.session.prompt(message.text);\n\t\t}\n\n\t\t// Start a prompt when idle, or preserve its delivery mode if a run is\n\t\t// still winding down after compaction.\n\t\tconst promptPromise = this.session\n\t\t\t.prompt(firstPrompt.text, { streamingBehavior: firstPrompt.mode })\n\t\t\t.catch((error) => {\n\t\t\t\trestoreQueue(error, [firstPrompt]);\n\t\t\t});\n\n\t\t// Queue remaining messages\n\t\tfor (const message of rest) {\n\t\t\tif (this.isExtensionCommand(message.text)) {\n\t\t\t\tawait this.session.prompt(message.text);\n\t\t\t} else if (message.mode === \"followUp\") {\n\t\t\t\tawait this.session.followUp(message.text);\n\t\t\t} else {\n\t\t\t\tawait this.session.steer(message.text);\n\t\t\t}\n\t\t}\n\t\tthis.updatePendingMessagesDisplay();\n\t\tvoid promptPromise;\n\t} catch (error) {\n\t\tthis.session.clearQueue();\n\t\trestoreQueue(error);\n\t}\n};\n\nInteractiveModeBase.prototype.flushPendingBashComponents = function (this: InteractiveModeBase): void {\n\tfor (const component of this.pendingBashComponents) {\n\t\tthis.pendingMessagesContainer.removeChild(component);\n\t\tthis.chatContainer.addChild(component);\n\t}\n\tthis.pendingBashComponents = [];\n};\n"]}
1
+ {"version":3,"file":"interactive-queueing.js","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-queueing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,8BAA8B,EAAE,MAAM,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAG1G,mBAAmB,CAAC,SAAS,CAAC,oBAAoB,GAAG;IAIpD,OAAO;QACN,QAAQ,EAAE;YACT,GAAG,IAAI,CAAC,OAAO,CAAC,mBAAmB,EAAE;YACrC,GAAG,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC;SAC7F;QACD,QAAQ,EAAE;YACT,GAAG,IAAI,CAAC,OAAO,CAAC,mBAAmB,EAAE;YACrC,GAAG,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,KAAK,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CA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B,GAAG;IAC1D,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,qBAAqB,EAAE,CAAC;QACpD,IAAI,CAAC,wBAAwB,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;QACrD,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;IACxC,CAAC;IACD,IAAI,CAAC,qBAAqB,GAAG,EAAE,CAAC;AACjC,CAAC,CAAC","sourcesContent":["import { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport { combineQueuedMessagesForEditor, Spacer, TruncatedText, theme } from \"./interactive-mode-deps.ts\";\nimport type { CompactionQueuedMessage } from \"./interactive-mode-types.ts\";\n\nInteractiveModeBase.prototype.getAllQueuedMessages = function (this: InteractiveModeBase): {\n\tsteering: string[];\n\tfollowUp: string[];\n} {\n\treturn {\n\t\tsteering: [\n\t\t\t...this.session.getSteeringMessages(),\n\t\t\t...this.compactionQueuedMessages.filter((msg) => msg.mode === \"steer\").map((msg) => msg.text),\n\t\t],\n\t\tfollowUp: [\n\t\t\t...this.session.getFollowUpMessages(),\n\t\t\t...this.compactionQueuedMessages.filter((msg) => msg.mode === \"followUp\").map((msg) => msg.text),\n\t\t],\n\t};\n};\n\nInteractiveModeBase.prototype.clearAllQueues = function (\n\tthis: InteractiveModeBase,\n\toptions?: { preserveUnprotectedCustomMessages?: boolean },\n): {\n\tsteering: string[];\n\tfollowUp: string[];\n} {\n\tconst { steering, followUp } = this.session.clearQueue(options);\n\tconst compactionSteering = this.compactionQueuedMessages\n\t\t.filter((msg) => msg.mode === \"steer\")\n\t\t.map((msg) => msg.text);\n\tconst compactionFollowUp = this.compactionQueuedMessages\n\t\t.filter((msg) => msg.mode === \"followUp\")\n\t\t.map((msg) => msg.text);\n\tthis.compactionQueuedMessages = [];\n\tthis.compactionSendFailed = false;\n\treturn {\n\t\tsteering: [...steering, ...compactionSteering],\n\t\tfollowUp: [...followUp, ...compactionFollowUp],\n\t};\n};\n\nInteractiveModeBase.prototype.updatePendingMessagesDisplay = function (this: InteractiveModeBase): void {\n\tthis.pendingMessagesContainer.clear();\n\tconst { steering: steeringMessages, followUp: followUpMessages } = this.getAllQueuedMessages();\n\tif (steeringMessages.length > 0 || followUpMessages.length > 0) {\n\t\tthis.pendingMessagesContainer.addChild(new Spacer(1));\n\t\tfor (const message of steeringMessages) {\n\t\t\tconst text = theme.fg(\"dim\", `Steering: ${message}`);\n\t\t\tthis.pendingMessagesContainer.addChild(new TruncatedText(text, 1, 0));\n\t\t}\n\t\tfor (const message of followUpMessages) {\n\t\t\tconst text = theme.fg(\"dim\", `Follow-up: ${message}`);\n\t\t\tthis.pendingMessagesContainer.addChild(new TruncatedText(text, 1, 0));\n\t\t}\n\t\tconst dequeueHint = this.getAppKeyDisplay(\"app.message.dequeue\");\n\t\tconst hintText = theme.fg(\"dim\", `↳ ${dequeueHint} to edit all queued messages`);\n\t\tthis.pendingMessagesContainer.addChild(new TruncatedText(hintText, 1, 0));\n\t}\n};\n\nInteractiveModeBase.prototype.restoreQueuedMessagesToEditor = function (\n\tthis: InteractiveModeBase,\n\toptions?: {\n\t\tabort?: boolean;\n\t\tcurrentText?: string;\n\t\tpreserveUnprotectedCustomMessages?: boolean;\n\t},\n): number {\n\tconst { steering, followUp } = this.clearAllQueues(options);\n\tconst allQueued = [...steering, ...followUp];\n\tif (allQueued.length === 0) {\n\t\tthis.updatePendingMessagesDisplay();\n\t\tif (options?.abort) {\n\t\t\tvoid this.session.abort();\n\t\t}\n\t\treturn 0;\n\t}\n\tconst currentText = options?.currentText ?? this.editor.getText();\n\tconst combinedText = combineQueuedMessagesForEditor(allQueued, currentText);\n\tthis.editor.setText(combinedText);\n\tthis.updatePendingMessagesDisplay();\n\tif (options?.abort) {\n\t\tvoid this.session.abort();\n\t}\n\treturn allQueued.length;\n};\n\nInteractiveModeBase.prototype.queueCompactionMessage = function (\n\tthis: InteractiveModeBase,\n\ttext: string,\n\tmode: \"steer\" | \"followUp\",\n): void {\n\tthis.compactionQueuedMessages.push({ text, mode });\n\tthis.editor.addToHistory?.(text);\n\tthis.editor.setText(\"\");\n\tthis.updatePendingMessagesDisplay();\n\tif (this.compactionActive) {\n\t\tthis.showStatus(\"Queued message for after compaction\");\n\t\treturn;\n\t}\n\tif (!this.compactionFlushPending) void this.flushCompactionQueue({ willRetry: false });\n};\n\nInteractiveModeBase.prototype.isExtensionCommand = function (this: InteractiveModeBase, text: string): boolean {\n\tif (!text.startsWith(\"/\")) return false;\n\n\tconst extensionRunner = this.session.extensionRunner;\n\n\tconst spaceIndex = text.indexOf(\" \");\n\tconst commandName = spaceIndex === -1 ? text.slice(1) : text.slice(1, spaceIndex);\n\treturn !!extensionRunner.getCommand(commandName);\n};\n\nInteractiveModeBase.prototype.flushCompactionQueue = async function (\n\tthis: InteractiveModeBase,\n\toptions?: {\n\t\twillRetry?: boolean;\n\t},\n): Promise<void> {\n\tif (this.compactionFlushPending || this.compactionQueuedMessages.length === 0) return;\n\tthis.compactionFlushPending = true;\n\tthis.compactionSendFailed = false;\n\ttry {\n\t\tawait sendCompactionQueue(this, options?.willRetry === true);\n\t} finally {\n\t\tthis.compactionFlushPending = false;\n\t\tthis.updatePendingMessagesDisplay();\n\t}\n\tconst arrivedAfterDrain =\n\t\tthis.compactionQueuedMessages.length > 0 && !this.compactionSendFailed && !this.compactionActive;\n\tif (arrivedAfterDrain) await this.flushCompactionQueue(options);\n};\n\nasync function sendCompactionQueue(mode: InteractiveModeBase, willRetry: boolean): Promise<void> {\n\tconst queueOnly = !willRetry && (mode.session.isStreaming || mode.session.queuedMessagesPaused);\n\tif (queueOnly) {\n\t\tawait drainCompactionQueue(mode, (message) =>\n\t\t\tmode.session.prompt(message.text, { streamingBehavior: message.mode }),\n\t\t);\n\t\treturn;\n\t}\n\tif (!willRetry && !(await startCompactionQueuePrompt(mode))) return;\n\tawait drainCompactionQueue(mode, (message) => {\n\t\tif (mode.isExtensionCommand(message.text)) return mode.session.prompt(message.text);\n\t\tif (message.mode === \"followUp\") return mode.session.followUp(message.text);\n\t\treturn mode.session.steer(message.text);\n\t});\n}\n\nfunction showCompactionQueueError(mode: InteractiveModeBase, error: unknown): void {\n\tmode.showError(`Failed to send queued message: ${error instanceof Error ? error.message : String(error)}`);\n}\n\nfunction takeNextCompactionMessage(mode: InteractiveModeBase): CompactionQueuedMessage | undefined {\n\tconst [next, ...rest] = mode.compactionQueuedMessages;\n\tmode.compactionQueuedMessages = rest;\n\tmode.updatePendingMessagesDisplay();\n\treturn next;\n}\n\nfunction returnCompactionMessage(mode: InteractiveModeBase, message: CompactionQueuedMessage, error: unknown): void {\n\tmode.compactionQueuedMessages = [message, ...mode.compactionQueuedMessages];\n\tmode.compactionSendFailed = true;\n\tmode.updatePendingMessagesDisplay();\n\tshowCompactionQueueError(mode, error);\n}\n\n/**\n * Deliver messages one at a time from the front of the compaction queue. Input submitted meanwhile\n * joins the back of that queue, so a failed message returns to the front ahead of everything after it.\n */\nasync function drainCompactionQueue(\n\tmode: InteractiveModeBase,\n\tdeliver: (message: CompactionQueuedMessage) => Promise<unknown>,\n\tlimit = Number.POSITIVE_INFINITY,\n): Promise<boolean> {\n\tfor (let delivered = 0; delivered < limit; delivered++) {\n\t\tconst message = takeNextCompactionMessage(mode);\n\t\tif (!message) break;\n\t\ttry {\n\t\t\tawait deliver(message);\n\t\t} catch (error) {\n\t\t\treturnCompactionMessage(mode, message, error);\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n/**\n * Run leading extension commands, then start the first prompt. The rest of the batch stays in the\n * compaction queue until that prompt is accepted, so a rejected prompt is restored ahead of it.\n */\nasync function startCompactionQueuePrompt(mode: InteractiveModeBase): Promise<boolean> {\n\tconst firstPromptIndex = mode.compactionQueuedMessages.findIndex(\n\t\t(message) => !mode.isExtensionCommand(message.text),\n\t);\n\tconst leadingCommands = firstPromptIndex === -1 ? mode.compactionQueuedMessages.length : firstPromptIndex;\n\tconst ranCommands = await drainCompactionQueue(\n\t\tmode,\n\t\t(message) => mode.session.prompt(message.text),\n\t\tleadingCommands,\n\t);\n\tif (!ranCommands) return false;\n\tconst first = takeNextCompactionMessage(mode);\n\tif (!first) return false;\n\tlet accept!: (accepted: boolean) => void;\n\tconst accepted = new Promise<boolean>((resolve) => {\n\t\taccept = resolve;\n\t});\n\tconst prompt = mode.session.prompt(first.text, {\n\t\tstreamingBehavior: first.mode,\n\t\tpreflightResult: (success) => accept(success),\n\t});\n\tprompt.then(\n\t\t() => accept(true),\n\t\t() => accept(false),\n\t);\n\tif (await accepted) {\n\t\tprompt.catch((error) => showCompactionQueueError(mode, error));\n\t\treturn true;\n\t}\n\treturnCompactionMessage(\n\t\tmode,\n\t\tfirst,\n\t\tawait prompt.then(\n\t\t\t() => undefined,\n\t\t\t(error: unknown) => error,\n\t\t),\n\t);\n\treturn false;\n}\n\nInteractiveModeBase.prototype.flushPendingBashComponents = function (this: InteractiveModeBase): void {\n\tfor (const component of this.pendingBashComponents) {\n\t\tthis.pendingMessagesContainer.removeChild(component);\n\t\tthis.chatContainer.addChild(component);\n\t}\n\tthis.pendingBashComponents = [];\n};\n"]}
@@ -160,6 +160,7 @@ InteractiveModeBase.prototype.renderCurrentSessionState = function () {
160
160
  this.chatContainer.clear();
161
161
  this.pendingMessagesContainer.clear();
162
162
  this.compactionQueuedMessages = [];
163
+ this.compactionSendFailed = false;
163
164
  this.streamingComponent = undefined;
164
165
  this.streamingMessage = undefined;
165
166
  this.pendingTools.clear();
@@ -1 +1 @@
1
- {"version":3,"file":"interactive-session-runtime.js","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-session-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAEhE,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,0BAA0B,EAAE,MAAM,2CAA2C,CAAC;AACvF,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,mBAA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,KAAK,EAAE,CAAC;IAC3B,IAAI,CAAC,wBAAwB,CAAC,KAAK,EAAE,CAAC;IACtC,IAAI,CAAC,wBAAwB,GAAG,EAAE,CAAC;IACnC,IAAI,CAAC,kBAAkB,GAAG,SAAS,CAAC;IACpC,IAAI,CAAC,gBAAgB,GAAG,SAAS,CAAC;IAClC,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;IAC1B,IAAI,CAAC,qBAAqB,EAAE,CAAC;AAC9B,CAAC,CAAC;AAEF,mBAAmB,CAAC,SAAS,CAAC,2BAA2B,GAAG,UAE3D,QAAgB;IAEhB,OAAO,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,oBAAoB,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC,CAAC;AACpH,CAAC,CAAC","sourcesContent":["import { setCapabilityOverrides } from \"@earendil-works/pi-tui\";\nimport type { ToolRenderers } from \"../../core/extensions/types.ts\";\nimport { ensurePngTranscoder } from \"../../utils/image-convert.ts\";\nimport { IsolatedInteractiveRuntime } from \"../interactive-engine/isolated-runtime.js\";\nimport { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport { setRegisteredThemes, stopThemeWatcher, Text, theme } from \"./interactive-mode-deps.ts\";\n\nInteractiveModeBase.prototype.bindCurrentSessionExtensions = async function (this: InteractiveModeBase): Promise<void> {\n\tconst uiContext = this.createExtensionUIContext();\n\tconst session = this.session;\n\tthis.runtimeHost?.setProjectTrustContextFactory?.((cwd) => this.createProjectTrustContext(cwd));\n\tawait this.session.bindExtensions({\n\t\tonUIPrompt: (event) => {\n\t\t\tif (!(this.runtimeHost instanceof IsolatedInteractiveRuntime) && this.session === session) {\n\t\t\t\tthis.programStatus.handleUIPrompt(event);\n\t\t\t}\n\t\t},\n\t\tuiContext,\n\t\tmode: \"tui\",\n\t\tisPresentationOnly: this.runtimeHost instanceof IsolatedInteractiveRuntime,\n\t\tcommandContextActions: {\n\t\t\twaitForIdle: () => this.session.agent.waitForIdle(),\n\t\t\tnewSession: async (options) => {\n\t\t\t\tInteractiveModeBase.prototype.clearWorkingLoader.call(this);\n\t\t\t\ttry {\n\t\t\t\t\tconst result = await this.runtimeHost.newSession(options);\n\t\t\t\t\tif (!result.cancelled) {\n\t\t\t\t\t\tthis.renderCurrentSessionState();\n\t\t\t\t\t\tthis.ui.requestRender();\n\t\t\t\t\t}\n\t\t\t\t\treturn result;\n\t\t\t\t} catch (error: unknown) {\n\t\t\t\t\treturn this.handleFatalRuntimeError(\"Failed to create session\", error);\n\t\t\t\t}\n\t\t\t},\n\t\t\tfork: async (entryId, options) => {\n\t\t\t\ttry {\n\t\t\t\t\tconst result = await this.runtimeHost.fork(entryId, options);\n\t\t\t\t\tif (!result.cancelled) {\n\t\t\t\t\t\tthis.renderCurrentSessionState();\n\t\t\t\t\t\tthis.editor.setText(result.selectedText ?? \"\");\n\t\t\t\t\t\tthis.showStatus(\"Forked to new session\");\n\t\t\t\t\t}\n\t\t\t\t\treturn { cancelled: result.cancelled };\n\t\t\t\t} catch (error: unknown) {\n\t\t\t\t\treturn this.handleFatalRuntimeError(\"Failed to fork session\", error);\n\t\t\t\t}\n\t\t\t},\n\t\t\tnavigateTree: async (targetId, options) => {\n\t\t\t\tconst result = await this.session.navigateTree(targetId, {\n\t\t\t\t\tsummarize: options?.summarize,\n\t\t\t\t\tcustomInstructions: options?.customInstructions,\n\t\t\t\t\treplaceInstructions: options?.replaceInstructions,\n\t\t\t\t\tlabel: options?.label,\n\t\t\t\t});\n\t\t\t\tif (result.cancelled) {\n\t\t\t\t\treturn { cancelled: true };\n\t\t\t\t}\n\n\t\t\t\tthis.chatContainer.clear();\n\t\t\t\tthis.renderInitialMessages();\n\t\t\t\tif (result.editorText && !this.editor.getText().trim()) {\n\t\t\t\t\tthis.editor.setText(result.editorText);\n\t\t\t\t}\n\t\t\t\tthis.showStatus(\"Navigated to selected point\");\n\t\t\t\tvoid this.flushCompactionQueue({ willRetry: false });\n\t\t\t\treturn { cancelled: false };\n\t\t\t},\n\t\t\tswitchSession: async (sessionPath, options) => {\n\t\t\t\treturn this.handleResumeSession(sessionPath, options);\n\t\t\t},\n\t\t\treload: async () => {\n\t\t\t\tawait this.handleReloadCommand();\n\t\t\t},\n\t\t},\n\t\tshutdownHandler: () => {\n\t\t\tthis.shutdownRequested = true;\n\t\t\tif (!this.session.isStreaming) {\n\t\t\t\tvoid this.shutdown();\n\t\t\t}\n\t\t},\n\t\tonError: (error) => {\n\t\t\tthis.showExtensionError(error.extensionPath, error.error, error.stack);\n\t\t},\n\t});\n\n\tsetRegisteredThemes(this.session.resourceLoader.getThemes().themes);\n\tthis.setupAutocompleteProvider();\n\n\tconst extensionRunner = this.session.extensionRunner;\n\tthis.setupExtensionShortcuts(extensionRunner);\n\tif (!this.deferredStartupPending && !this.initialStartupBinding) {\n\t\tthis.showLoadedResources({ force: true, showDiagnosticsWhenQuiet: true });\n\t\tthis.showStartupNoticesIfNeeded();\n\t}\n};\n\nInteractiveModeBase.prototype.applyRuntimeSettings = function (this: InteractiveModeBase): void {\n\tsetCapabilityOverrides(this.settingsManager.getTerminalCapabilityOverrides());\n\tensurePngTranscoder(() => {\n\t\tthis.ui.invalidate();\n\t\tthis.ui.requestRender();\n\t});\n\tthis.setFullscreenCopyOnSelect(this.settingsManager.getFullscreenCopyOnSelect());\n\tthis.setFullscreenWheelScrollLines(this.settingsManager.getFullscreenWheelScrollLines());\n\tthis.transcriptScrollView?.setScrollbar(this.settingsManager.getFullscreenScrollbar());\n\tthis.footer.setSession(this.session);\n\tthis.usageMeter.setSession(this.session);\n\tthis.usageMeter.setAutoCompactEnabled(this.session.autoCompactionEnabled);\n\tthis.footerDataProvider.setCwd(this.sessionManager.getCwd());\n\tthis.hideThinkingBlock = this.settingsManager.getHideThinkingBlock();\n\tthis.outputPad = this.settingsManager.getOutputPad();\n\tthis.ui.setShowHardwareCursor(this.settingsManager.getShowHardwareCursor());\n\tthis.ui.setClearOnShrink(this.settingsManager.getClearOnShrink());\n\tconst editorPaddingX = this.settingsManager.getEditorPaddingX();\n\tconst autocompleteMaxVisible = this.settingsManager.getAutocompleteMaxVisible();\n\tthis.defaultEditor.setPaddingX(editorPaddingX);\n\tthis.defaultEditor.setAutocompleteMaxVisible(autocompleteMaxVisible);\n\tif (this.editor !== this.defaultEditor) {\n\t\tthis.editor.setPaddingX?.(editorPaddingX);\n\t\tthis.editor.setAutocompleteMaxVisible?.(autocompleteMaxVisible);\n\t}\n};\n\nInteractiveModeBase.prototype.rebindCurrentSession = async function (this: InteractiveModeBase): Promise<void> {\n\t// The session this rebind was started for. Binding extensions is async, and a\n\t// session replacement (startup switch, /new, resume) can install a different\n\t// session and start its own rebind while this one is still awaiting. Without\n\t// the guard below both rebinds call subscribeToAgent() and every agent event\n\t// is rendered twice.\n\tconst session = this.session;\n\n\tthis.unsubscribe?.();\n\tthis.unsubscribe = undefined;\n\tthis.programStatus.reset();\n\tthis.applyRuntimeSettings();\n\tawait this.bindCurrentSessionExtensions();\n\n\tif (this.session !== session) {\n\t\t// A newer rebind owns the current session; it subscribes and finishes the\n\t\t// remaining runtime updates itself.\n\t\treturn;\n\t}\n\n\tthis.subscribeToAgent();\n\tawait this.updateAvailableProviderCount();\n\tthis.updateEditorBorderColor();\n\tthis.updateTerminalTitle();\n};\n\nInteractiveModeBase.prototype.handleFatalRuntimeError = async function (\n\tthis: InteractiveModeBase,\n\tprefix: string,\n\terror: unknown,\n): Promise<never> {\n\tconst message = error instanceof Error ? error.message : String(error);\n\tthis.showError(`${prefix}: ${message}`);\n\tconst extensionHint = this.getCrashExtensionHint(error);\n\tif (extensionHint) {\n\t\tthis.chatContainer.addChild(new Text(theme.fg(\"warning\", extensionHint), this.outputPad, 0));\n\t}\n\tstopThemeWatcher();\n\t// A fatal exit keeps the transcript visible: the error the user just saw\n\t// must remain on screen after the process dies, whatever the setting says.\n\tthis.stop(\"transcript\");\n\tprocess.exit(1);\n};\n\nInteractiveModeBase.prototype.renderCurrentSessionState = function (this: InteractiveModeBase): void {\n\tthis.managedToolStatusGeneration++;\n\tthis.managedToolStatusStarted = false;\n\tthis.lastStatusSpacer = undefined;\n\tthis.lastStatusText = undefined;\n\tthis.chatContainer.clear();\n\tthis.pendingMessagesContainer.clear();\n\tthis.compactionQueuedMessages = [];\n\tthis.streamingComponent = undefined;\n\tthis.streamingMessage = undefined;\n\tthis.pendingTools.clear();\n\tthis.renderInitialMessages();\n};\n\nInteractiveModeBase.prototype.getRegisteredToolDefinition = function (\n\tthis: InteractiveModeBase,\n\ttoolName: string,\n): ToolRenderers | undefined {\n\treturn this.session.extensionRunner.resolveToolRenderers(toolName, () => this.session.getToolDefinition(toolName));\n};\n"]}
1
+ {"version":3,"file":"interactive-session-runtime.js","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-session-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAEhE,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,0BAA0B,EAAE,MAAM,2CAA2C,CAAC;AACvF,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAEhG,mBAAmB,CAAC,SAAS,CAAC,4BAA4B,GAAG,KAAK;IACjE,MAAM,SAAS,GAAG,IAAI,CAAC,wBAAwB,EAAE,CAAC;IAClD,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;IAC7B,IAAI,CAAC,WAAW,EAAE,6BAA6B,EAAE,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,yBAAyB,CAAC,GAAG,CAAC,CAAC,CAAC;IAChG,MAAM,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC;QACjC,UAAU,EAAE,CAAC,KAAK,EAAE,E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AO,CAAC,eAAe,CAAC,oBAAoB,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC,CAAC;AACpH,CAAC,CAAC","sourcesContent":["import { setCapabilityOverrides } from \"@earendil-works/pi-tui\";\nimport type { ToolRenderers } from \"../../core/extensions/types.ts\";\nimport { ensurePngTranscoder } from \"../../utils/image-convert.ts\";\nimport { IsolatedInteractiveRuntime } from \"../interactive-engine/isolated-runtime.js\";\nimport { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport { setRegisteredThemes, stopThemeWatcher, Text, theme } from \"./interactive-mode-deps.ts\";\n\nInteractiveModeBase.prototype.bindCurrentSessionExtensions = async function (this: InteractiveModeBase): Promise<void> {\n\tconst uiContext = this.createExtensionUIContext();\n\tconst session = this.session;\n\tthis.runtimeHost?.setProjectTrustContextFactory?.((cwd) => this.createProjectTrustContext(cwd));\n\tawait this.session.bindExtensions({\n\t\tonUIPrompt: (event) => {\n\t\t\tif (!(this.runtimeHost instanceof IsolatedInteractiveRuntime) && this.session === session) {\n\t\t\t\tthis.programStatus.handleUIPrompt(event);\n\t\t\t}\n\t\t},\n\t\tuiContext,\n\t\tmode: \"tui\",\n\t\tisPresentationOnly: this.runtimeHost instanceof IsolatedInteractiveRuntime,\n\t\tcommandContextActions: {\n\t\t\twaitForIdle: () => this.session.agent.waitForIdle(),\n\t\t\tnewSession: async (options) => {\n\t\t\t\tInteractiveModeBase.prototype.clearWorkingLoader.call(this);\n\t\t\t\ttry {\n\t\t\t\t\tconst result = await this.runtimeHost.newSession(options);\n\t\t\t\t\tif (!result.cancelled) {\n\t\t\t\t\t\tthis.renderCurrentSessionState();\n\t\t\t\t\t\tthis.ui.requestRender();\n\t\t\t\t\t}\n\t\t\t\t\treturn result;\n\t\t\t\t} catch (error: unknown) {\n\t\t\t\t\treturn this.handleFatalRuntimeError(\"Failed to create session\", error);\n\t\t\t\t}\n\t\t\t},\n\t\t\tfork: async (entryId, options) => {\n\t\t\t\ttry {\n\t\t\t\t\tconst result = await this.runtimeHost.fork(entryId, options);\n\t\t\t\t\tif (!result.cancelled) {\n\t\t\t\t\t\tthis.renderCurrentSessionState();\n\t\t\t\t\t\tthis.editor.setText(result.selectedText ?? \"\");\n\t\t\t\t\t\tthis.showStatus(\"Forked to new session\");\n\t\t\t\t\t}\n\t\t\t\t\treturn { cancelled: result.cancelled };\n\t\t\t\t} catch (error: unknown) {\n\t\t\t\t\treturn this.handleFatalRuntimeError(\"Failed to fork session\", error);\n\t\t\t\t}\n\t\t\t},\n\t\t\tnavigateTree: async (targetId, options) => {\n\t\t\t\tconst result = await this.session.navigateTree(targetId, {\n\t\t\t\t\tsummarize: options?.summarize,\n\t\t\t\t\tcustomInstructions: options?.customInstructions,\n\t\t\t\t\treplaceInstructions: options?.replaceInstructions,\n\t\t\t\t\tlabel: options?.label,\n\t\t\t\t});\n\t\t\t\tif (result.cancelled) {\n\t\t\t\t\treturn { cancelled: true };\n\t\t\t\t}\n\n\t\t\t\tthis.chatContainer.clear();\n\t\t\t\tthis.renderInitialMessages();\n\t\t\t\tif (result.editorText && !this.editor.getText().trim()) {\n\t\t\t\t\tthis.editor.setText(result.editorText);\n\t\t\t\t}\n\t\t\t\tthis.showStatus(\"Navigated to selected point\");\n\t\t\t\tvoid this.flushCompactionQueue({ willRetry: false });\n\t\t\t\treturn { cancelled: false };\n\t\t\t},\n\t\t\tswitchSession: async (sessionPath, options) => {\n\t\t\t\treturn this.handleResumeSession(sessionPath, options);\n\t\t\t},\n\t\t\treload: async () => {\n\t\t\t\tawait this.handleReloadCommand();\n\t\t\t},\n\t\t},\n\t\tshutdownHandler: () => {\n\t\t\tthis.shutdownRequested = true;\n\t\t\tif (!this.session.isStreaming) {\n\t\t\t\tvoid this.shutdown();\n\t\t\t}\n\t\t},\n\t\tonError: (error) => {\n\t\t\tthis.showExtensionError(error.extensionPath, error.error, error.stack);\n\t\t},\n\t});\n\n\tsetRegisteredThemes(this.session.resourceLoader.getThemes().themes);\n\tthis.setupAutocompleteProvider();\n\n\tconst extensionRunner = this.session.extensionRunner;\n\tthis.setupExtensionShortcuts(extensionRunner);\n\tif (!this.deferredStartupPending && !this.initialStartupBinding) {\n\t\tthis.showLoadedResources({ force: true, showDiagnosticsWhenQuiet: true });\n\t\tthis.showStartupNoticesIfNeeded();\n\t}\n};\n\nInteractiveModeBase.prototype.applyRuntimeSettings = function (this: InteractiveModeBase): void {\n\tsetCapabilityOverrides(this.settingsManager.getTerminalCapabilityOverrides());\n\tensurePngTranscoder(() => {\n\t\tthis.ui.invalidate();\n\t\tthis.ui.requestRender();\n\t});\n\tthis.setFullscreenCopyOnSelect(this.settingsManager.getFullscreenCopyOnSelect());\n\tthis.setFullscreenWheelScrollLines(this.settingsManager.getFullscreenWheelScrollLines());\n\tthis.transcriptScrollView?.setScrollbar(this.settingsManager.getFullscreenScrollbar());\n\tthis.footer.setSession(this.session);\n\tthis.usageMeter.setSession(this.session);\n\tthis.usageMeter.setAutoCompactEnabled(this.session.autoCompactionEnabled);\n\tthis.footerDataProvider.setCwd(this.sessionManager.getCwd());\n\tthis.hideThinkingBlock = this.settingsManager.getHideThinkingBlock();\n\tthis.outputPad = this.settingsManager.getOutputPad();\n\tthis.ui.setShowHardwareCursor(this.settingsManager.getShowHardwareCursor());\n\tthis.ui.setClearOnShrink(this.settingsManager.getClearOnShrink());\n\tconst editorPaddingX = this.settingsManager.getEditorPaddingX();\n\tconst autocompleteMaxVisible = this.settingsManager.getAutocompleteMaxVisible();\n\tthis.defaultEditor.setPaddingX(editorPaddingX);\n\tthis.defaultEditor.setAutocompleteMaxVisible(autocompleteMaxVisible);\n\tif (this.editor !== this.defaultEditor) {\n\t\tthis.editor.setPaddingX?.(editorPaddingX);\n\t\tthis.editor.setAutocompleteMaxVisible?.(autocompleteMaxVisible);\n\t}\n};\n\nInteractiveModeBase.prototype.rebindCurrentSession = async function (this: InteractiveModeBase): Promise<void> {\n\t// The session this rebind was started for. Binding extensions is async, and a\n\t// session replacement (startup switch, /new, resume) can install a different\n\t// session and start its own rebind while this one is still awaiting. Without\n\t// the guard below both rebinds call subscribeToAgent() and every agent event\n\t// is rendered twice.\n\tconst session = this.session;\n\n\tthis.unsubscribe?.();\n\tthis.unsubscribe = undefined;\n\tthis.programStatus.reset();\n\tthis.applyRuntimeSettings();\n\tawait this.bindCurrentSessionExtensions();\n\n\tif (this.session !== session) {\n\t\t// A newer rebind owns the current session; it subscribes and finishes the\n\t\t// remaining runtime updates itself.\n\t\treturn;\n\t}\n\n\tthis.subscribeToAgent();\n\tawait this.updateAvailableProviderCount();\n\tthis.updateEditorBorderColor();\n\tthis.updateTerminalTitle();\n};\n\nInteractiveModeBase.prototype.handleFatalRuntimeError = async function (\n\tthis: InteractiveModeBase,\n\tprefix: string,\n\terror: unknown,\n): Promise<never> {\n\tconst message = error instanceof Error ? error.message : String(error);\n\tthis.showError(`${prefix}: ${message}`);\n\tconst extensionHint = this.getCrashExtensionHint(error);\n\tif (extensionHint) {\n\t\tthis.chatContainer.addChild(new Text(theme.fg(\"warning\", extensionHint), this.outputPad, 0));\n\t}\n\tstopThemeWatcher();\n\t// A fatal exit keeps the transcript visible: the error the user just saw\n\t// must remain on screen after the process dies, whatever the setting says.\n\tthis.stop(\"transcript\");\n\tprocess.exit(1);\n};\n\nInteractiveModeBase.prototype.renderCurrentSessionState = function (this: InteractiveModeBase): void {\n\tthis.managedToolStatusGeneration++;\n\tthis.managedToolStatusStarted = false;\n\tthis.lastStatusSpacer = undefined;\n\tthis.lastStatusText = undefined;\n\tthis.chatContainer.clear();\n\tthis.pendingMessagesContainer.clear();\n\tthis.compactionQueuedMessages = [];\n\tthis.compactionSendFailed = false;\n\tthis.streamingComponent = undefined;\n\tthis.streamingMessage = undefined;\n\tthis.pendingTools.clear();\n\tthis.renderInitialMessages();\n};\n\nInteractiveModeBase.prototype.getRegisteredToolDefinition = function (\n\tthis: InteractiveModeBase,\n\ttoolName: string,\n): ToolRenderers | undefined {\n\treturn this.session.extensionRunner.resolveToolRenderers(toolName, () => this.session.getToolDefinition(toolName));\n};\n"]}
package/docs/docs.json CHANGED
@@ -60,8 +60,7 @@
60
60
  "group": "Models and providers",
61
61
  "pages": [
62
62
  "providers",
63
- "llama-cpp",
64
- "nvidia-rtx-llama-cpp"
63
+ "llama-cpp"
65
64
  ]
66
65
  },
67
66
  {
@@ -260,6 +259,10 @@
260
259
  "source": "/tree",
261
260
  "destination": "/sessions"
262
261
  },
262
+ {
263
+ "source": "/nvidia-rtx-llama-cpp",
264
+ "destination": "/llama-cpp#nvidia-rtx-recipes"
265
+ },
263
266
  {
264
267
  "source": "/tools/edit",
265
268
  "destination": "/tools#edit"
package/docs/llama-cpp.md CHANGED
@@ -32,7 +32,7 @@ llama-server \
32
32
 
33
33
  Single-file models can sit directly in the model directory. Put multimodal and multi-shard models in separate subdirectories with their projection or shard files. Restart the router after manually adding files. Per-model context sizes and other options can be set with [model presets](https://github.com/ggml-org/llama.cpp/blob/master/tools/server/README.md#model-presets).
34
34
 
35
- For settings tuned to a specific NVIDIA GPU and model, see [Run Atomic with NVIDIA RTX and llama.cpp](/nvidia-rtx-llama-cpp).
35
+ For settings tuned to a specific NVIDIA GPU and model, see [NVIDIA RTX recipes](#nvidia-rtx-recipes).
36
36
 
37
37
  ## Configure Atomic
38
38
 
@@ -70,6 +70,99 @@ If the router disconnects, choose **Retry** to reconnect and refresh state witho
70
70
 
71
71
  Each llama model uses the router-reported loaded context (`meta.n_ctx`, then training context, otherwise Atomic's fallback) for both `contextWindow` and `maxTokens`; Atomic no longer applies a separate 16K output cap. The server remains authoritative and may impose a smaller practical generation limit.
72
72
 
73
+ ## NVIDIA RTX recipes
74
+
75
+ [NVIDIA Local AI Inference Recipes](https://nvidia.github.io/local-ai-inference-recipes/index.html) provides llama.cpp settings tuned for specific NVIDIA hardware and models. Each recipe gives a single-model `llama-server` command. Convert it into a router preset so the router can serve it alongside other models. The examples below use Windows PowerShell.
76
+
77
+ ### Before you begin
78
+
79
+ 1. Open the [recipe catalog](https://nvidia.github.io/local-ai-inference-recipes/index.html), select your hardware, operating system, and model, then choose **llama.cpp**. Check the prerequisites and memory requirements. Keep the recipe's launch command for the conversion below.
80
+ 2. Install llama.cpp with the recipe's setup instructions. The recipe's settings depend on its build, for example CUDA support or speculative decoding options.
81
+ 3. Run `llama-server --help` and check that it lists `--models-preset`. Without it, the build cannot load the recipe as a router preset. Use a newer build that still meets the recipe's requirements.
82
+ 4. Install Atomic with the [Quickstart](/quickstart). On native Windows, also see [Run Atomic on Windows](/windows).
83
+
84
+ ### Convert the recipe to a preset
85
+
86
+ A preset lists the settings for one or more models. Each section name becomes the model ID shown in Atomic. Save the preset next to `llama-server`, or pass its full path when starting the router.
87
+
88
+ Convert each option from the recipe command into one preset line:
89
+
90
+ - Remove the leading dashes: `--ctx-size 65536` becomes `ctx-size = 65536`.
91
+ - Write options without a value as `true`: `--jinja` becomes `jinja = true`.
92
+ - Remove quotes and PowerShell line-continuation backticks around values.
93
+ - Leave out `--host` and `--port`. They belong on the router command line.
94
+ - Add `load-on-startup = true` so the router loads the model when it starts.
95
+ - Replace short model-file options with their long preset keys:
96
+
97
+ | Recipe option | Preset key |
98
+ |---|---|
99
+ | `-hf` | `hf-repo` |
100
+ | `-hff` | `hf-file` |
101
+ | `-hfrd` | `hf-repo-draft` |
102
+ | `--spec-draft-model` | `spec-draft-model` |
103
+
104
+ For example, this recipe command:
105
+
106
+ ```powershell
107
+ llama-server.exe -hf "unsloth/Qwen3.8-27B-GGUF" `
108
+ -hff "Qwen3.8-27B-UD-Q4_K_M.gguf" `
109
+ -hfrd "z-lab/Qwen3.8-27B-DFlash2-GGUF" `
110
+ --spec-draft-model "Qwen3.8-27B-DFlash2-Q4_K_M.gguf" `
111
+ --no-mmproj `
112
+ --host 127.0.0.1 `
113
+ --port 9931 `
114
+ --batch-size 4096 `
115
+ --ubatch-size 1024 `
116
+ --ctx-size 65536 `
117
+ --parallel 1 `
118
+ -ngl 999 `
119
+ --jinja `
120
+ --chat-template-kwargs '{"preserve_thinking":true}' `
121
+ --spec-type draft-dflash `
122
+ --spec-draft-n-max 7 `
123
+ --spec-draft-backend-sampling
124
+ ```
125
+
126
+ becomes `qwen3.8-27b.ini`:
127
+
128
+ ```ini
129
+ version = 1
130
+
131
+ [qwen3.8-27b]
132
+ load-on-startup = true
133
+ hf-repo = unsloth/Qwen3.8-27B-GGUF
134
+ hf-file = Qwen3.8-27B-UD-Q4_K_M.gguf
135
+ hf-repo-draft = z-lab/Qwen3.8-27B-DFlash2-GGUF
136
+ spec-draft-model = Qwen3.8-27B-DFlash2-Q4_K_M.gguf
137
+ no-mmproj = true
138
+ batch-size = 4096
139
+ ubatch-size = 1024
140
+ ctx-size = 65536
141
+ parallel = 1
142
+ ngl = 999
143
+ jinja = true
144
+ chat-template-kwargs = {"preserve_thinking":true}
145
+ spec-type = draft-dflash
146
+ spec-draft-n-max = 7
147
+ spec-draft-backend-sampling = true
148
+ ```
149
+
150
+ ### Start the recipe router
151
+
152
+ Open PowerShell in the llama.cpp folder and run:
153
+
154
+ ```powershell
155
+ .\llama-server.exe --models-preset qwen3.8-27b.ini --host 127.0.0.1 --port 8080
156
+ ```
157
+
158
+ If the recipe requires a Hugging Face token, set `$env:HF_TOKEN` in the same PowerShell window before starting the router. On its first start, the router downloads the model files.
159
+
160
+ Use the [health checks](#troubleshooting) to confirm that the server is ready. In Windows PowerShell, use `curl.exe` rather than `curl`, which PowerShell maps to a different command. The model is ready when `/models` lists `qwen3.8-27b` with the status `loaded`.
161
+
162
+ Then follow [Configure Atomic](#configure-atomic) and connect to `http://127.0.0.1:8080`. The preset section name is the model ID, so select `qwen3.8-27b` in `/model` for this example.
163
+
164
+ NVIDIA recipe memory settings assume that only the selected model uses the GPU. If `/llama` shows other loaded models, unload them before using the recipe model.
165
+
73
166
  ## Classification
74
167
 
75
168
  Classifier models answer typed `choice`, `bool`, and `score` questions about JSON state, like TypeSafe's Jev models, so a local model can make `model: "auto"` routing decisions. Extensions can call `ctx.modelRegistry.classify()` and codemode scripts can call `models.classify()`; see [Classifier models](/models#use-classifier-models). Atomic lists llama.cpp models as classifiers in two ways:
package/docs/sessions.md CHANGED
@@ -12,7 +12,7 @@ Sessions auto-save to the local SQLite database at `~/.atomic/workflows/journal.
12
12
 
13
13
  To choose another store, set `sessions.storage` in settings. Use shared `storage` to select one database for both sessions and workflow runs. JSONL is available only when explicitly selected. Memory is available through `--no-session`, `{ "memory": true }` in settings, or an explicit SDK option; it is never a fallback for a failed persistent store.
14
14
 
15
- When the default SQLite store is selected, sessions saved before it became the default stay in `~/.atomic/agent/sessions` and appear in `/resume` and `--continue` next to newer ones. This includes sessions in formats 1, 2, and 3 and early 0.9.38 alpha sessions. A session is copied into the database the first time you open it, with `/resume`, `--continue`, `--session`, or `--fork`, and is read from the database afterwards. The original files are never modified or deleted, unreadable files are skipped, and workflow stage sessions stay hidden from `/resume` but remain openable by session ID. Deleting one of these sessions keeps it out of the list. Selecting a store yourself, as described below, shows only that store.
15
+ When the default SQLite store is selected, sessions saved before it became the default stay in `~/.atomic/agent/sessions` and appear in `/resume` and `--continue` next to newer ones. This includes sessions in formats 1, 2, and 3 and early 0.9.38 alpha sessions. A session is copied into the database the first time you open it, with `/resume`, `--continue`, `--session`, or `--fork`, and is read from the database afterwards. The original files are never modified or deleted, unreadable files are skipped, and workflow stage sessions stay hidden from `/resume` but remain openable by session ID. Until a session larger than 32 KiB is opened, the list shows it from its first message and its most recent entries, so its message count may be understated and `/resume` search matches only that text; opening it shows the full session. Deleting one of these sessions keeps it out of the list. Selecting a store yourself, as described below, shows only that store.
16
16
 
17
17
  Project-local storage settings apply after you approve project trust, including on the first launch. Atomic re-selects storage before saving a new conversation; resumed conversations stay in their original store. Generated resume commands for JSONL sessions include `--session-dir`; keep that option when reopening the conversation, even if the directory was previously the default.
18
18
 
package/docs/usage.md CHANGED
@@ -102,6 +102,8 @@ You can submit messages while the agent is still working:
102
102
 
103
103
  Each queue preserves submission order, and steering messages take priority over follow-ups. Messages submitted during compaction keep their queue type and join that queue when compaction finishes or is cancelled, even if the agent is still working.
104
104
 
105
+ If the first message sent after compaction fails, it stays queued with the messages after it, in the order you typed them, and Atomic shows the error. Anything you submit next is queued behind them, and your next submission sends them again in order. **ALT+Up** retrieves them to the editor in that same order.
106
+
105
107
  Both interrupts hold a queued message only while it is still waiting in the queue. A message the agent has already picked up is written into the transcript, and an interrupt that cancels its reply before any output appears no longer strands it: Atomic answers it instead of returning it to the editor. A reply that had already started printing is left as-is and is not restarted. Sending a message while that recovered reply is still streaming is safe — it is delivered as soon as the reply finishes.
106
108
 
107
109
  Both abort routes ask the agent to stop cooperatively. Escape waits as long as the agent needs, and neither route terminates the engine during normal cancellation.