@travisennis/acai 0.0.12 → 0.0.14
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 +5 -2
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/index.js +91 -5
- package/dist/commands/history/types.d.ts +3 -2
- package/dist/commands/history/types.d.ts.map +1 -1
- package/dist/commands/init-project/utils.d.ts +0 -1
- package/dist/commands/init-project/utils.d.ts.map +1 -1
- package/dist/commands/init-project/utils.js +1 -1
- package/dist/commands/manager.d.ts.map +1 -1
- package/dist/commands/manager.js +0 -18
- package/dist/commands/share/html-renderer.d.ts.map +1 -1
- package/dist/commands/share/html-renderer.js +54 -48
- package/dist/commands/tools/index.js +39 -38
- package/dist/config/index.d.ts +0 -2
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +3 -7
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +94 -76
- package/dist/models/manager.d.ts +1 -10
- package/dist/models/manager.d.ts.map +1 -1
- package/dist/models/manager.js +2 -2
- package/dist/models/opencode-go-provider.d.ts +6 -4
- package/dist/models/opencode-go-provider.d.ts.map +1 -1
- package/dist/models/opencode-go-provider.js +55 -35
- package/dist/models/providers.d.ts +1 -1
- package/dist/models/providers.d.ts.map +1 -1
- package/dist/prompts/system-prompt.d.ts +0 -2
- package/dist/prompts/system-prompt.d.ts.map +1 -1
- package/dist/prompts/system-prompt.js +6 -10
- package/dist/repl/index.d.ts +27 -11
- package/dist/repl/index.d.ts.map +1 -1
- package/dist/repl/index.js +238 -254
- package/dist/sessions/manager.d.ts +41 -0
- package/dist/sessions/manager.d.ts.map +1 -1
- package/dist/sessions/manager.js +53 -0
- package/dist/sessions/summary.d.ts.map +1 -1
- package/dist/sessions/summary.js +18 -0
- package/dist/skills/index.d.ts +12 -2
- package/dist/skills/index.d.ts.map +1 -1
- package/dist/skills/index.js +123 -73
- package/dist/terminal/control.d.ts +1 -21
- package/dist/terminal/control.d.ts.map +1 -1
- package/dist/terminal/control.js +1 -32
- package/dist/terminal/formatting.d.ts +0 -33
- package/dist/terminal/formatting.d.ts.map +1 -1
- package/dist/terminal/formatting.js +0 -91
- package/dist/terminal/highlight/theme.d.ts +0 -37
- package/dist/terminal/highlight/theme.d.ts.map +1 -1
- package/dist/terminal/highlight/theme.js +1 -79
- package/dist/terminal/keys.d.ts +0 -97
- package/dist/terminal/keys.d.ts.map +1 -1
- package/dist/terminal/keys.js +0 -194
- package/dist/terminal/select-prompt.d.ts.map +1 -1
- package/dist/terminal/select-prompt.js +65 -51
- package/dist/terminal/style.d.ts +1 -1
- package/dist/terminal/style.d.ts.map +1 -1
- package/dist/terminal/supports-color.d.ts.map +1 -1
- package/dist/terminal/supports-color.js +38 -20
- package/dist/terminal/supports-hyperlinks.d.ts +3 -0
- package/dist/terminal/supports-hyperlinks.d.ts.map +1 -1
- package/dist/terminal/supports-hyperlinks.js +72 -31
- package/dist/terminal/table/layout-manager.d.ts +0 -20
- package/dist/terminal/table/layout-manager.d.ts.map +1 -1
- package/dist/terminal/table/layout-manager.js +68 -44
- package/dist/terminal/table/utils.d.ts +0 -1
- package/dist/terminal/table/utils.d.ts.map +1 -1
- package/dist/terminal/table/utils.js +2 -4
- package/dist/tools/apply-patch.d.ts +5 -3
- package/dist/tools/apply-patch.d.ts.map +1 -1
- package/dist/tools/apply-patch.js +154 -123
- package/dist/tools/bash.d.ts.map +1 -1
- package/dist/tools/bash.js +11 -8
- package/dist/tools/dynamic-tool-loader.d.ts +6 -1
- package/dist/tools/dynamic-tool-loader.d.ts.map +1 -1
- package/dist/tools/dynamic-tool-loader.js +154 -135
- package/dist/tools/index.d.ts +3 -133
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +0 -20
- package/dist/tools/read-file.d.ts.map +1 -1
- package/dist/tools/read-file.js +32 -13
- package/dist/tools/skill.d.ts.map +1 -1
- package/dist/tools/skill.js +20 -13
- package/dist/tools/web-fetch.d.ts +2 -6
- package/dist/tools/web-fetch.d.ts.map +1 -1
- package/dist/tools/web-fetch.js +59 -36
- package/dist/tools/web-search.d.ts +0 -4
- package/dist/tools/web-search.d.ts.map +1 -1
- package/dist/tools/web-search.js +40 -32
- package/dist/tui/autocomplete/utils.d.ts +0 -15
- package/dist/tui/autocomplete/utils.d.ts.map +1 -1
- package/dist/tui/autocomplete/utils.js +0 -85
- package/dist/tui/autocomplete.d.ts +1 -1
- package/dist/tui/autocomplete.d.ts.map +1 -1
- package/dist/tui/autocomplete.js +1 -1
- package/dist/tui/components/editor.d.ts +12 -0
- package/dist/tui/components/editor.d.ts.map +1 -1
- package/dist/tui/components/editor.js +181 -195
- package/dist/tui/components/input.d.ts +4 -0
- package/dist/tui/components/input.d.ts.map +1 -1
- package/dist/tui/components/input.js +33 -31
- package/dist/tui/components/markdown.d.ts +30 -0
- package/dist/tui/components/markdown.d.ts.map +1 -1
- package/dist/tui/components/markdown.js +274 -242
- package/dist/tui/components/modal.d.ts.map +1 -1
- package/dist/tui/components/modal.js +11 -11
- package/dist/tui/components/select-list.d.ts +5 -0
- package/dist/tui/components/select-list.d.ts.map +1 -1
- package/dist/tui/components/select-list.js +69 -98
- package/dist/tui/components/table.d.ts +6 -0
- package/dist/tui/components/table.d.ts.map +1 -1
- package/dist/tui/components/table.js +61 -52
- package/dist/tui/index.d.ts +1 -8
- package/dist/tui/index.d.ts.map +1 -1
- package/dist/tui/index.js +0 -8
- package/dist/tui/tui.d.ts +9 -0
- package/dist/tui/tui.d.ts.map +1 -1
- package/dist/tui/tui.js +78 -48
- package/dist/tui/utils.d.ts +7 -0
- package/dist/tui/utils.d.ts.map +1 -1
- package/dist/tui/utils.js +117 -53
- package/dist/utils/bash.d.ts.map +1 -1
- package/dist/utils/bash.js +156 -104
- package/dist/utils/command-protection.d.ts +3 -6
- package/dist/utils/command-protection.d.ts.map +1 -1
- package/dist/utils/command-protection.js +213 -100
- package/dist/utils/filesystem/operations.d.ts +0 -15
- package/dist/utils/filesystem/operations.d.ts.map +1 -1
- package/dist/utils/filesystem/operations.js +1 -38
- package/dist/utils/filesystem/security.d.ts.map +1 -1
- package/dist/utils/filesystem/security.js +22 -15
- package/dist/utils/filetype-detection.d.ts +0 -1
- package/dist/utils/filetype-detection.d.ts.map +1 -1
- package/dist/utils/filetype-detection.js +0 -12
- package/dist/utils/formatting.d.ts +0 -30
- package/dist/utils/formatting.d.ts.map +1 -1
- package/dist/utils/formatting.js +0 -44
- package/dist/utils/git.d.ts +4 -6
- package/dist/utils/git.d.ts.map +1 -1
- package/dist/utils/git.js +36 -46
- package/dist/utils/ignore.d.ts +1 -1
- package/dist/utils/ignore.d.ts.map +1 -1
- package/dist/utils/ignore.js +1 -1
- package/dist/utils/process.d.ts.map +1 -1
- package/dist/utils/process.js +77 -79
- package/dist/utils/yaml.d.ts +0 -1
- package/dist/utils/yaml.d.ts.map +1 -1
- package/dist/utils/yaml.js +80 -89
- package/dist/utils/zod.d.ts +0 -3
- package/dist/utils/zod.d.ts.map +1 -1
- package/dist/utils/zod.js +0 -7
- package/package.json +25 -24
- package/dist/agent/sub-agent.d.ts +0 -23
- package/dist/agent/sub-agent.d.ts.map +0 -1
- package/dist/agent/sub-agent.js +0 -109
- package/dist/commands/add-directory/index.d.ts +0 -3
- package/dist/commands/add-directory/index.d.ts.map +0 -1
- package/dist/commands/add-directory/index.js +0 -50
- package/dist/commands/add-directory/utils.d.ts +0 -3
- package/dist/commands/add-directory/utils.d.ts.map +0 -1
- package/dist/commands/add-directory/utils.js +0 -15
- package/dist/commands/clear/index.d.ts +0 -3
- package/dist/commands/clear/index.d.ts.map +0 -1
- package/dist/commands/clear/index.js +0 -13
- package/dist/commands/generate-rules/index.d.ts +0 -3
- package/dist/commands/generate-rules/index.d.ts.map +0 -1
- package/dist/commands/generate-rules/index.js +0 -206
- package/dist/commands/generate-rules/service.d.ts +0 -22
- package/dist/commands/generate-rules/service.d.ts.map +0 -1
- package/dist/commands/generate-rules/service.js +0 -103
- package/dist/commands/generate-rules/utils.d.ts +0 -5
- package/dist/commands/generate-rules/utils.d.ts.map +0 -1
- package/dist/commands/generate-rules/utils.js +0 -25
- package/dist/commands/handoff/index.d.ts +0 -3
- package/dist/commands/handoff/index.d.ts.map +0 -1
- package/dist/commands/handoff/index.js +0 -97
- package/dist/commands/handoff/utils.d.ts +0 -4
- package/dist/commands/handoff/utils.d.ts.map +0 -1
- package/dist/commands/handoff/utils.js +0 -123
- package/dist/commands/list-directories/index.d.ts +0 -3
- package/dist/commands/list-directories/index.d.ts.map +0 -1
- package/dist/commands/list-directories/index.js +0 -35
- package/dist/commands/pickup/index.d.ts +0 -3
- package/dist/commands/pickup/index.d.ts.map +0 -1
- package/dist/commands/pickup/index.js +0 -141
- package/dist/commands/pickup/types.d.ts +0 -6
- package/dist/commands/pickup/types.d.ts.map +0 -1
- package/dist/commands/pickup/types.js +0 -1
- package/dist/commands/pickup/utils.d.ts +0 -7
- package/dist/commands/pickup/utils.d.ts.map +0 -1
- package/dist/commands/pickup/utils.js +0 -56
- package/dist/commands/remove-directory/index.d.ts +0 -3
- package/dist/commands/remove-directory/index.d.ts.map +0 -1
- package/dist/commands/remove-directory/index.js +0 -55
- package/dist/commands/review/index.d.ts +0 -3
- package/dist/commands/review/index.d.ts.map +0 -1
- package/dist/commands/review/index.js +0 -12
- package/dist/commands/review/review-panel.d.ts +0 -3
- package/dist/commands/review/review-panel.d.ts.map +0 -1
- package/dist/commands/review/review-panel.js +0 -186
- package/dist/commands/review/utils.d.ts +0 -18
- package/dist/commands/review/utils.d.ts.map +0 -1
- package/dist/commands/review/utils.js +0 -146
- package/dist/commands/shell/index.d.ts +0 -3
- package/dist/commands/shell/index.d.ts.map +0 -1
- package/dist/commands/shell/index.js +0 -96
- package/dist/subagents/index.d.ts +0 -16
- package/dist/subagents/index.d.ts.map +0 -1
- package/dist/subagents/index.js +0 -231
- package/dist/terminal/index.d.ts +0 -9
- package/dist/terminal/index.d.ts.map +0 -1
- package/dist/terminal/index.js +0 -8
- package/dist/tools/agent.d.ts +0 -27
- package/dist/tools/agent.d.ts.map +0 -1
- package/dist/tools/agent.js +0 -81
- package/dist/tools/directory-tree.d.ts +0 -28
- package/dist/tools/directory-tree.d.ts.map +0 -1
- package/dist/tools/directory-tree.js +0 -154
- package/dist/tools/glob.d.ts +0 -35
- package/dist/tools/glob.d.ts.map +0 -1
- package/dist/tools/glob.js +0 -167
- package/dist/tools/grep.d.ts +0 -100
- package/dist/tools/grep.d.ts.map +0 -1
- package/dist/tools/grep.js +0 -608
- package/dist/tools/ls.d.ts +0 -26
- package/dist/tools/ls.d.ts.map +0 -1
- package/dist/tools/ls.js +0 -83
- package/dist/tui/components/header.d.ts +0 -21
- package/dist/tui/components/header.d.ts.map +0 -1
- package/dist/tui/components/header.js +0 -63
- package/dist/utils/bash/parse.d.ts +0 -19
- package/dist/utils/bash/parse.d.ts.map +0 -1
- package/dist/utils/bash/parse.js +0 -223
- package/dist/utils/bash/quote.d.ts +0 -6
- package/dist/utils/bash/quote.d.ts.map +0 -1
- package/dist/utils/bash/quote.js +0 -23
- package/dist/utils/generators.d.ts +0 -3
- package/dist/utils/generators.d.ts.map +0 -1
- package/dist/utils/generators.js +0 -25
- package/dist/utils/glob.d.ts +0 -52
- package/dist/utils/glob.d.ts.map +0 -1
- package/dist/utils/glob.js +0 -376
package/dist/repl/index.d.ts
CHANGED
|
@@ -68,7 +68,6 @@ export declare class Repl {
|
|
|
68
68
|
private allThinkingBlocks;
|
|
69
69
|
private allToolExecutions;
|
|
70
70
|
private verboseMode;
|
|
71
|
-
private config;
|
|
72
71
|
/** Creates a new Repl instance, initializing the TUI layout and components. */
|
|
73
72
|
constructor(options: ReplOptions);
|
|
74
73
|
/**
|
|
@@ -82,6 +81,16 @@ export declare class Repl {
|
|
|
82
81
|
* and agent lifecycle transitions (start, stop, error).
|
|
83
82
|
*/
|
|
84
83
|
handle(event: AgentEvent, state: AgentState): Promise<void>;
|
|
84
|
+
private handleAgentStart;
|
|
85
|
+
private handleMessageStart;
|
|
86
|
+
private handleMessage;
|
|
87
|
+
private handleMessageEnd;
|
|
88
|
+
private handleToolCallLifecycle;
|
|
89
|
+
private handleAgentStop;
|
|
90
|
+
private handleAgentError;
|
|
91
|
+
private handleThinkingStart;
|
|
92
|
+
private handleThinking;
|
|
93
|
+
private handleThinkingEnd;
|
|
85
94
|
/** Adds a user message component to the chat container. */
|
|
86
95
|
private addMessageToChat;
|
|
87
96
|
/**
|
|
@@ -112,6 +121,23 @@ export declare class Repl {
|
|
|
112
121
|
* responses, and tool executions.
|
|
113
122
|
*/
|
|
114
123
|
private reconstructSession;
|
|
124
|
+
/**
|
|
125
|
+
* Collects all tool results from tool-role messages into a map
|
|
126
|
+
* keyed by tool call ID.
|
|
127
|
+
*/
|
|
128
|
+
private collectToolResults;
|
|
129
|
+
/**
|
|
130
|
+
* Extracts the output value string from a tool result's output field.
|
|
131
|
+
*/
|
|
132
|
+
private extractToolOutputValue;
|
|
133
|
+
/**
|
|
134
|
+
* Renders a user message into the chat container.
|
|
135
|
+
*/
|
|
136
|
+
private renderUserMessageFromSession;
|
|
137
|
+
/**
|
|
138
|
+
* Renders tool call execution components for an assistant message.
|
|
139
|
+
*/
|
|
140
|
+
private renderToolCallsForAssistantMessage;
|
|
115
141
|
/**
|
|
116
142
|
* Extracts the text content from a user message,
|
|
117
143
|
* handling both string and array content formats.
|
|
@@ -158,16 +184,6 @@ export declare class Repl {
|
|
|
158
184
|
* and the TUI. Optionally triggers the exit callback.
|
|
159
185
|
*/
|
|
160
186
|
stop(showExitMessage?: boolean): void;
|
|
161
|
-
/**
|
|
162
|
-
* Generates rules automatically if autoGenerateRules is enabled
|
|
163
|
-
* and the session has messages.
|
|
164
|
-
*/
|
|
165
|
-
private maybeGenerateRules;
|
|
166
|
-
/**
|
|
167
|
-
* Triggers rule generation for use before exit.
|
|
168
|
-
* Returns a promise that resolves when rules are generated.
|
|
169
|
-
*/
|
|
170
|
-
triggerRuleGeneration(): Promise<void>;
|
|
171
187
|
}
|
|
172
188
|
export {};
|
|
173
189
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/repl/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/repl/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/repl/index.ts"],"names":[],"mappings":"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"}
|
package/dist/repl/index.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { generateRulesFromSession } from "../commands/generate-rules/service.js";
|
|
2
1
|
import { showModelSelector } from "../commands/model/model-panel.js";
|
|
3
|
-
import { showReviewPanel } from "../commands/review/review-panel.js";
|
|
4
2
|
import { parseSkillsPath } from "../config/index.js";
|
|
5
3
|
import { processPrompt } from "../prompts/mentions.js";
|
|
6
4
|
import { loadSkills } from "../skills/index.js";
|
|
@@ -50,8 +48,6 @@ export class Repl {
|
|
|
50
48
|
allToolExecutions = [];
|
|
51
49
|
// verbose mode state
|
|
52
50
|
verboseMode = false;
|
|
53
|
-
// ProjectConfig - initialized in init()
|
|
54
|
-
config;
|
|
55
51
|
/** Creates a new Repl instance, initializing the TUI layout and components. */
|
|
56
52
|
constructor(options) {
|
|
57
53
|
this.options = options;
|
|
@@ -110,8 +106,7 @@ export class Repl {
|
|
|
110
106
|
new SkillProvider(skills.getModelInvocable()),
|
|
111
107
|
]);
|
|
112
108
|
this.editor.setAutocompleteProvider(autocompleteProvider);
|
|
113
|
-
const { promptManager, modelManager, sessionManager, commands, promptHistory,
|
|
114
|
-
this.config = await configManager.getConfig();
|
|
109
|
+
const { promptManager, modelManager, sessionManager, commands, promptHistory, } = this.options;
|
|
115
110
|
// Listen for session title updates
|
|
116
111
|
// messageHistory.on("update-title", (title: string) => {
|
|
117
112
|
// this.footer.setTitle(title);
|
|
@@ -135,9 +130,6 @@ export class Repl {
|
|
|
135
130
|
this.tui.onCtrlN = () => {
|
|
136
131
|
void this.handleCtrlN();
|
|
137
132
|
};
|
|
138
|
-
this.tui.onCtrlR = () => {
|
|
139
|
-
void showReviewPanel(this.tui, this.chatContainer, this.editorContainer, this.editor);
|
|
140
|
-
};
|
|
141
133
|
this.tui.onCtrlM = () => {
|
|
142
134
|
void this.handleCtrlM();
|
|
143
135
|
};
|
|
@@ -164,48 +156,48 @@ export class Repl {
|
|
|
164
156
|
};
|
|
165
157
|
// Create editor for input
|
|
166
158
|
this.editor.onSubmit = async (text) => {
|
|
167
|
-
if (text.trim())
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
this.tui.requestRender();
|
|
178
|
-
return;
|
|
179
|
-
}
|
|
180
|
-
if (!promptManager.isPending()) {
|
|
181
|
-
const processedPrompt = await processPrompt(text, {
|
|
182
|
-
baseDir: process.cwd(),
|
|
183
|
-
model: modelConfig,
|
|
184
|
-
});
|
|
185
|
-
for (const context of processedPrompt.context) {
|
|
186
|
-
promptManager.addContext(context);
|
|
187
|
-
}
|
|
188
|
-
promptManager.set(processedPrompt.message);
|
|
189
|
-
}
|
|
190
|
-
else {
|
|
191
|
-
promptHistory.push(promptManager.get());
|
|
192
|
-
this.editor.addToHistory(promptManager.get());
|
|
193
|
-
}
|
|
194
|
-
// flag to see if the user prompt has added context
|
|
195
|
-
const hasAddedContext = promptManager.hasContext();
|
|
196
|
-
if (hasAddedContext) {
|
|
197
|
-
const contextTokenCount = promptManager.getContextTokenCount();
|
|
198
|
-
this.addComponentWithSpacing(new Text(style.green(`Context will be added to prompt. (${contextTokenCount} tokens)`)));
|
|
199
|
-
}
|
|
200
|
-
const userPrompt = promptManager.get();
|
|
201
|
-
const userMsg = promptManager.getUserMessage();
|
|
202
|
-
sessionManager.appendUserMessage(userMsg);
|
|
203
|
-
this.addMessageToChat({ role: "user", content: userPrompt });
|
|
159
|
+
if (!text.trim())
|
|
160
|
+
return;
|
|
161
|
+
// see if the text contains a command
|
|
162
|
+
const commandResult = await commands.handle({ userInput: text }, {
|
|
163
|
+
tui: this.tui,
|
|
164
|
+
container: this.chatContainer,
|
|
165
|
+
inputContainer: this.editorContainer,
|
|
166
|
+
editor: this.editor,
|
|
167
|
+
});
|
|
168
|
+
if (commandResult.continue) {
|
|
204
169
|
this.editor.setText("");
|
|
205
170
|
this.tui.requestRender();
|
|
206
|
-
|
|
207
|
-
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
if (!promptManager.isPending()) {
|
|
174
|
+
const processedPrompt = await processPrompt(text, {
|
|
175
|
+
baseDir: process.cwd(),
|
|
176
|
+
model: modelConfig,
|
|
177
|
+
});
|
|
178
|
+
for (const context of processedPrompt.context) {
|
|
179
|
+
promptManager.addContext(context);
|
|
208
180
|
}
|
|
181
|
+
promptManager.set(processedPrompt.message);
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
promptHistory.push(promptManager.get());
|
|
185
|
+
this.editor.addToHistory(promptManager.get());
|
|
186
|
+
}
|
|
187
|
+
// flag to see if the user prompt has added context
|
|
188
|
+
const hasAddedContext = promptManager.hasContext();
|
|
189
|
+
if (hasAddedContext) {
|
|
190
|
+
const contextTokenCount = promptManager.getContextTokenCount();
|
|
191
|
+
this.addComponentWithSpacing(new Text(style.green(`Context will be added to prompt. (${contextTokenCount} tokens)`)));
|
|
192
|
+
}
|
|
193
|
+
const userPrompt = promptManager.get();
|
|
194
|
+
const userMsg = promptManager.getUserMessage();
|
|
195
|
+
sessionManager.appendUserMessage(userMsg);
|
|
196
|
+
this.addMessageToChat({ role: "user", content: userPrompt });
|
|
197
|
+
this.editor.setText("");
|
|
198
|
+
this.tui.requestRender();
|
|
199
|
+
if (this.onInputCallback) {
|
|
200
|
+
this.onInputCallback(userPrompt);
|
|
209
201
|
}
|
|
210
202
|
};
|
|
211
203
|
// Start
|
|
@@ -234,158 +226,169 @@ export class Repl {
|
|
|
234
226
|
const eventType = event.type;
|
|
235
227
|
switch (eventType) {
|
|
236
228
|
case "agent-start":
|
|
237
|
-
|
|
238
|
-
startProgress();
|
|
239
|
-
// disable the submit functionality of the editor
|
|
240
|
-
this.editor.disableSubmit = true;
|
|
241
|
-
// Stop old loader before clearing
|
|
242
|
-
if (this.loadingAnimation) {
|
|
243
|
-
this.loadingAnimation.stop();
|
|
244
|
-
}
|
|
245
|
-
this.statusContainer.clear();
|
|
246
|
-
// Show loading animation
|
|
247
|
-
this.loadingAnimation = new Loader(this.tui, "Working... (esc to interrupt)");
|
|
248
|
-
this.statusContainer.addChild(this.loadingAnimation);
|
|
249
|
-
this.tui.requestRender();
|
|
229
|
+
this.handleAgentStart();
|
|
250
230
|
break;
|
|
251
231
|
case "step-start":
|
|
252
|
-
// this.tui.requestRender();
|
|
253
232
|
break;
|
|
254
233
|
case "step-stop":
|
|
255
|
-
// this.pendingTools.clear();
|
|
256
|
-
// this.tui.requestRender();
|
|
257
234
|
break;
|
|
258
235
|
case "message-start":
|
|
259
|
-
|
|
260
|
-
// Create assistant component for streaming
|
|
261
|
-
const assistantMessageComponent = new AssistantMessageComponent();
|
|
262
|
-
this.streamingComponent = assistantMessageComponent;
|
|
263
|
-
this.addComponentWithSpacing(assistantMessageComponent);
|
|
264
|
-
this.streamingComponent.updateContent(event);
|
|
265
|
-
this.tui.requestRender();
|
|
266
|
-
}
|
|
236
|
+
this.handleMessageStart(event);
|
|
267
237
|
break;
|
|
268
238
|
case "message":
|
|
269
|
-
|
|
270
|
-
// Update streaming component
|
|
271
|
-
if (this.streamingComponent && event.role === "assistant") {
|
|
272
|
-
this.streamingComponent.updateContent(event);
|
|
273
|
-
this.tui.requestRender();
|
|
274
|
-
}
|
|
275
|
-
}
|
|
239
|
+
this.handleMessage(event);
|
|
276
240
|
break;
|
|
277
241
|
case "message-end":
|
|
278
|
-
|
|
279
|
-
this.streamingComponent.updateContent(event);
|
|
280
|
-
this.streamingComponent = null;
|
|
281
|
-
this.tui.requestRender();
|
|
282
|
-
}
|
|
242
|
+
this.handleMessageEnd(event);
|
|
283
243
|
break;
|
|
284
|
-
case "tool-call-lifecycle":
|
|
285
|
-
|
|
286
|
-
if (component) {
|
|
287
|
-
component.update(event.events);
|
|
288
|
-
}
|
|
289
|
-
else {
|
|
290
|
-
// Create tool component for new tool call
|
|
291
|
-
const newComponent = new ToolExecutionComponent(event.events, {
|
|
292
|
-
verboseMode: this.verboseMode,
|
|
293
|
-
});
|
|
294
|
-
this.pendingTools.set(event.toolCallId, newComponent);
|
|
295
|
-
this.allToolExecutions.push(newComponent);
|
|
296
|
-
this.addComponentWithSpacing(newComponent);
|
|
297
|
-
}
|
|
298
|
-
this.tui.requestRender();
|
|
244
|
+
case "tool-call-lifecycle":
|
|
245
|
+
this.handleToolCallLifecycle(event);
|
|
299
246
|
break;
|
|
300
|
-
}
|
|
301
247
|
case "agent-stop":
|
|
302
|
-
|
|
303
|
-
stopProgress();
|
|
304
|
-
// send a terminal alert to indicate the agent is done
|
|
305
|
-
await alert();
|
|
306
|
-
// Stop loading animation
|
|
307
|
-
if (this.loadingAnimation) {
|
|
308
|
-
this.loadingAnimation.stop();
|
|
309
|
-
this.loadingAnimation = null;
|
|
310
|
-
this.statusContainer.clear();
|
|
311
|
-
}
|
|
312
|
-
// Clear streaming component reference
|
|
313
|
-
if (this.streamingComponent) {
|
|
314
|
-
this.streamingComponent = null;
|
|
315
|
-
}
|
|
316
|
-
this.pendingTools.clear();
|
|
317
|
-
this.editor.disableSubmit = false;
|
|
318
|
-
this.options.sessionManager.clearTransientMessages();
|
|
319
|
-
if (!this.options.noSession) {
|
|
320
|
-
await this.options.sessionManager.save();
|
|
321
|
-
}
|
|
322
|
-
// Refresh project status now that agent may have modified files
|
|
323
|
-
await getProjectStatus().then((ps) => {
|
|
324
|
-
this.footer.setState({
|
|
325
|
-
projectStatus: ps,
|
|
326
|
-
currentContextWindow: this.options.sessionManager.getLastTurnContextWindow(),
|
|
327
|
-
contextWindow: this.options.modelManager.getModelMetadata("repl").contextWindow,
|
|
328
|
-
});
|
|
329
|
-
this.tui.requestRender();
|
|
330
|
-
});
|
|
331
|
-
this.tui.requestRender();
|
|
248
|
+
await this.handleAgentStop();
|
|
332
249
|
break;
|
|
333
250
|
case "agent-error":
|
|
334
|
-
|
|
335
|
-
this.options.sessionManager.clearTransientMessages();
|
|
336
|
-
if (!this.options.noSession) {
|
|
337
|
-
await this.options.sessionManager.save();
|
|
338
|
-
}
|
|
339
|
-
// Stop loading animation
|
|
340
|
-
if (this.loadingAnimation) {
|
|
341
|
-
this.loadingAnimation.stop();
|
|
342
|
-
this.loadingAnimation = null;
|
|
343
|
-
this.statusContainer.clear();
|
|
344
|
-
}
|
|
345
|
-
// Clear streaming component reference
|
|
346
|
-
if (this.streamingComponent) {
|
|
347
|
-
this.streamingComponent = null;
|
|
348
|
-
}
|
|
349
|
-
this.pendingTools.clear();
|
|
350
|
-
this.editor.disableSubmit = false;
|
|
351
|
-
this.tui.requestRender();
|
|
251
|
+
await this.handleAgentError(event);
|
|
352
252
|
break;
|
|
353
|
-
case "thinking-start":
|
|
354
|
-
|
|
355
|
-
verboseMode: this.verboseMode,
|
|
356
|
-
});
|
|
357
|
-
this.thinkingBlockComponent = component;
|
|
358
|
-
this.allThinkingBlocks.push(component);
|
|
359
|
-
// If a streaming message component already exists (text came before thinking),
|
|
360
|
-
// insert the thinking block BEFORE it to ensure correct visual order
|
|
361
|
-
if (this.streamingComponent) {
|
|
362
|
-
this.chatContainer.insertChildBefore(this.streamingComponent, component);
|
|
363
|
-
this.chatContainer.insertChildBefore(this.streamingComponent, new Spacer(1));
|
|
364
|
-
}
|
|
365
|
-
else {
|
|
366
|
-
this.addComponentWithSpacing(component);
|
|
367
|
-
}
|
|
368
|
-
this.thinkingBlockComponent.updateContent(event);
|
|
369
|
-
this.tui.requestRender();
|
|
253
|
+
case "thinking-start":
|
|
254
|
+
this.handleThinkingStart(event);
|
|
370
255
|
break;
|
|
371
|
-
}
|
|
372
256
|
case "thinking":
|
|
373
|
-
|
|
374
|
-
this.thinkingBlockComponent.updateContent(event);
|
|
375
|
-
this.tui.requestRender();
|
|
376
|
-
}
|
|
257
|
+
this.handleThinking(event);
|
|
377
258
|
break;
|
|
378
259
|
case "thinking-end":
|
|
379
|
-
|
|
380
|
-
this.thinkingBlockComponent.endThinking();
|
|
381
|
-
this.thinkingBlockComponent = null;
|
|
382
|
-
this.tui.requestRender();
|
|
383
|
-
}
|
|
260
|
+
this.handleThinkingEnd();
|
|
384
261
|
break;
|
|
385
262
|
default:
|
|
386
263
|
eventType;
|
|
387
264
|
}
|
|
388
265
|
}
|
|
266
|
+
handleAgentStart() {
|
|
267
|
+
startProgress();
|
|
268
|
+
this.editor.disableSubmit = true;
|
|
269
|
+
if (this.loadingAnimation) {
|
|
270
|
+
this.loadingAnimation.stop();
|
|
271
|
+
}
|
|
272
|
+
this.statusContainer.clear();
|
|
273
|
+
this.loadingAnimation = new Loader(this.tui, "Working... (esc to interrupt)");
|
|
274
|
+
this.statusContainer.addChild(this.loadingAnimation);
|
|
275
|
+
this.tui.requestRender();
|
|
276
|
+
}
|
|
277
|
+
handleMessageStart(event) {
|
|
278
|
+
if (event.type === "message-start" && event.role === "assistant") {
|
|
279
|
+
const assistantMessageComponent = new AssistantMessageComponent();
|
|
280
|
+
this.streamingComponent = assistantMessageComponent;
|
|
281
|
+
this.addComponentWithSpacing(assistantMessageComponent);
|
|
282
|
+
this.streamingComponent.updateContent(event);
|
|
283
|
+
this.tui.requestRender();
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
handleMessage(event) {
|
|
287
|
+
if (event.type === "message" && event.role === "assistant") {
|
|
288
|
+
if (this.streamingComponent) {
|
|
289
|
+
this.streamingComponent.updateContent(event);
|
|
290
|
+
this.tui.requestRender();
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
handleMessageEnd(event) {
|
|
295
|
+
if (event.type === "message-end" &&
|
|
296
|
+
this.streamingComponent &&
|
|
297
|
+
event.role === "assistant") {
|
|
298
|
+
this.streamingComponent.updateContent(event);
|
|
299
|
+
this.streamingComponent = null;
|
|
300
|
+
this.tui.requestRender();
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
handleToolCallLifecycle(event) {
|
|
304
|
+
const component = this.pendingTools.get(event.toolCallId);
|
|
305
|
+
if (component) {
|
|
306
|
+
component.update(event.events);
|
|
307
|
+
}
|
|
308
|
+
else {
|
|
309
|
+
const newComponent = new ToolExecutionComponent(event.events, {
|
|
310
|
+
verboseMode: this.verboseMode,
|
|
311
|
+
});
|
|
312
|
+
this.pendingTools.set(event.toolCallId, newComponent);
|
|
313
|
+
this.allToolExecutions.push(newComponent);
|
|
314
|
+
this.addComponentWithSpacing(newComponent);
|
|
315
|
+
}
|
|
316
|
+
this.tui.requestRender();
|
|
317
|
+
}
|
|
318
|
+
async handleAgentStop() {
|
|
319
|
+
stopProgress();
|
|
320
|
+
await alert();
|
|
321
|
+
if (this.loadingAnimation) {
|
|
322
|
+
this.loadingAnimation.stop();
|
|
323
|
+
this.loadingAnimation = null;
|
|
324
|
+
this.statusContainer.clear();
|
|
325
|
+
}
|
|
326
|
+
if (this.streamingComponent) {
|
|
327
|
+
this.streamingComponent = null;
|
|
328
|
+
}
|
|
329
|
+
this.pendingTools.clear();
|
|
330
|
+
this.editor.disableSubmit = false;
|
|
331
|
+
this.options.sessionManager.clearTransientMessages();
|
|
332
|
+
if (!this.options.noSession) {
|
|
333
|
+
await this.options.sessionManager.save();
|
|
334
|
+
}
|
|
335
|
+
await getProjectStatus().then((ps) => {
|
|
336
|
+
this.footer.setState({
|
|
337
|
+
projectStatus: ps,
|
|
338
|
+
currentContextWindow: this.options.sessionManager.getLastTurnContextWindow(),
|
|
339
|
+
contextWindow: this.options.modelManager.getModelMetadata("repl").contextWindow,
|
|
340
|
+
});
|
|
341
|
+
this.tui.requestRender();
|
|
342
|
+
});
|
|
343
|
+
this.tui.requestRender();
|
|
344
|
+
}
|
|
345
|
+
async handleAgentError(event) {
|
|
346
|
+
logger.error(event, "agent-error");
|
|
347
|
+
this.options.sessionManager.clearTransientMessages();
|
|
348
|
+
if (!this.options.noSession) {
|
|
349
|
+
await this.options.sessionManager.save();
|
|
350
|
+
}
|
|
351
|
+
if (this.loadingAnimation) {
|
|
352
|
+
this.loadingAnimation.stop();
|
|
353
|
+
this.loadingAnimation = null;
|
|
354
|
+
this.statusContainer.clear();
|
|
355
|
+
}
|
|
356
|
+
if (this.streamingComponent) {
|
|
357
|
+
this.streamingComponent = null;
|
|
358
|
+
}
|
|
359
|
+
this.pendingTools.clear();
|
|
360
|
+
this.editor.disableSubmit = false;
|
|
361
|
+
this.tui.requestRender();
|
|
362
|
+
}
|
|
363
|
+
handleThinkingStart(event) {
|
|
364
|
+
const component = new ThinkingBlockComponent(undefined, {
|
|
365
|
+
verboseMode: this.verboseMode,
|
|
366
|
+
});
|
|
367
|
+
this.thinkingBlockComponent = component;
|
|
368
|
+
this.allThinkingBlocks.push(component);
|
|
369
|
+
if (this.streamingComponent) {
|
|
370
|
+
this.chatContainer.insertChildBefore(this.streamingComponent, component);
|
|
371
|
+
this.chatContainer.insertChildBefore(this.streamingComponent, new Spacer(1));
|
|
372
|
+
}
|
|
373
|
+
else {
|
|
374
|
+
this.addComponentWithSpacing(component);
|
|
375
|
+
}
|
|
376
|
+
this.thinkingBlockComponent.updateContent({ content: event.content });
|
|
377
|
+
this.tui.requestRender();
|
|
378
|
+
}
|
|
379
|
+
handleThinking(event) {
|
|
380
|
+
if (this.thinkingBlockComponent) {
|
|
381
|
+
this.thinkingBlockComponent.updateContent(event);
|
|
382
|
+
this.tui.requestRender();
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
handleThinkingEnd() {
|
|
386
|
+
if (this.thinkingBlockComponent) {
|
|
387
|
+
this.thinkingBlockComponent.endThinking();
|
|
388
|
+
this.thinkingBlockComponent = null;
|
|
389
|
+
this.tui.requestRender();
|
|
390
|
+
}
|
|
391
|
+
}
|
|
389
392
|
/** Adds a user message component to the chat container. */
|
|
390
393
|
addMessageToChat(message) {
|
|
391
394
|
if (message.role === "user") {
|
|
@@ -478,7 +481,25 @@ export class Repl {
|
|
|
478
481
|
this.chatContainer.clear();
|
|
479
482
|
// Get session messages
|
|
480
483
|
const messages = this.options.sessionManager.get();
|
|
481
|
-
|
|
484
|
+
const toolResults = this.collectToolResults(messages);
|
|
485
|
+
// Render all messages in order
|
|
486
|
+
for (let i = 0; i < messages.length; i++) {
|
|
487
|
+
const message = messages[i];
|
|
488
|
+
if (message.role === "user") {
|
|
489
|
+
this.renderUserMessageFromSession(message);
|
|
490
|
+
}
|
|
491
|
+
else if (message.role === "assistant") {
|
|
492
|
+
this.renderAssistantMessage(message);
|
|
493
|
+
this.renderToolCallsForAssistantMessage(message, toolResults);
|
|
494
|
+
}
|
|
495
|
+
// Tool messages are handled through their associated assistant message
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* Collects all tool results from tool-role messages into a map
|
|
500
|
+
* keyed by tool call ID.
|
|
501
|
+
*/
|
|
502
|
+
collectToolResults(messages) {
|
|
482
503
|
const toolResults = new Map();
|
|
483
504
|
for (const message of messages) {
|
|
484
505
|
if (message.role !== "tool")
|
|
@@ -487,49 +508,53 @@ export class Repl {
|
|
|
487
508
|
if (!Array.isArray(content))
|
|
488
509
|
continue;
|
|
489
510
|
for (const part of content) {
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
:
|
|
495
|
-
toolResults.set(part.toolCallId, {
|
|
496
|
-
toolName: part.toolName,
|
|
497
|
-
outputValue,
|
|
511
|
+
const toolPart = part;
|
|
512
|
+
if (toolPart.type === "tool-result") {
|
|
513
|
+
toolResults.set(toolPart.toolCallId ?? "", {
|
|
514
|
+
toolName: toolPart.toolName ?? "",
|
|
515
|
+
outputValue: this.extractToolOutputValue(toolPart.output),
|
|
498
516
|
isError: false,
|
|
499
517
|
});
|
|
500
518
|
}
|
|
501
519
|
}
|
|
502
520
|
}
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
521
|
+
return toolResults;
|
|
522
|
+
}
|
|
523
|
+
/**
|
|
524
|
+
* Extracts the output value string from a tool result's output field.
|
|
525
|
+
*/
|
|
526
|
+
extractToolOutputValue(output) {
|
|
527
|
+
if (output && typeof output === "object" && "value" in output) {
|
|
528
|
+
return String(output["value"]);
|
|
529
|
+
}
|
|
530
|
+
return "";
|
|
531
|
+
}
|
|
532
|
+
/**
|
|
533
|
+
* Renders a user message into the chat container.
|
|
534
|
+
*/
|
|
535
|
+
renderUserMessageFromSession(message) {
|
|
536
|
+
const textContent = this.extractUserMessageText(message);
|
|
537
|
+
if (textContent) {
|
|
538
|
+
const userComponent = new UserMessageComponent(textContent);
|
|
539
|
+
this.addComponentWithSpacing(userComponent);
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
/**
|
|
543
|
+
* Renders tool call execution components for an assistant message.
|
|
544
|
+
*/
|
|
545
|
+
renderToolCallsForAssistantMessage(message, toolResults) {
|
|
546
|
+
const toolCallsForThisAssistant = this.extractToolCallsFromAssistant(message, toolResults);
|
|
547
|
+
for (const toolCallContent of toolCallsForThisAssistant) {
|
|
548
|
+
const toolCallId = toolCallContent.toolCallId;
|
|
549
|
+
const events = this.createToolEvents(toolCallContent);
|
|
550
|
+
if (events.length > 0) {
|
|
551
|
+
const component = new ToolExecutionComponent(events, {
|
|
552
|
+
verboseMode: this.verboseMode,
|
|
553
|
+
});
|
|
554
|
+
this.pendingTools.set(toolCallId, component);
|
|
555
|
+
this.allToolExecutions.push(component);
|
|
556
|
+
this.addComponentWithSpacing(component);
|
|
531
557
|
}
|
|
532
|
-
// Tool messages are handled through their associated assistant message
|
|
533
558
|
}
|
|
534
559
|
}
|
|
535
560
|
/**
|
|
@@ -680,15 +705,11 @@ export class Repl {
|
|
|
680
705
|
*/
|
|
681
706
|
async handleCtrlN() {
|
|
682
707
|
if (!this.options.sessionManager.isEmpty()) {
|
|
683
|
-
// Auto-generate rules before starting new session if enabled
|
|
684
|
-
// Run in background - don't block new session from starting
|
|
685
|
-
this.maybeGenerateRules().catch((err) => logger.debug({ err }, "Background rule generation failed"));
|
|
686
708
|
if (!this.options.noSession) {
|
|
687
709
|
await this.options.sessionManager.save();
|
|
688
710
|
}
|
|
689
711
|
this.options.sessionManager.create(this.options.modelManager.getModel("repl").modelId);
|
|
690
712
|
}
|
|
691
|
-
this.config = await this.options.configManager.getConfig();
|
|
692
713
|
this.options.sessionManager.clearTransientMessages();
|
|
693
714
|
this.options.tokenTracker.reset();
|
|
694
715
|
setTerminalTitle(`acai: ${process.cwd()}`);
|
|
@@ -801,41 +822,4 @@ export class Repl {
|
|
|
801
822
|
this.isInitialized = false;
|
|
802
823
|
}
|
|
803
824
|
}
|
|
804
|
-
/**
|
|
805
|
-
* Generates rules automatically if autoGenerateRules is enabled
|
|
806
|
-
* and the session has messages.
|
|
807
|
-
*/
|
|
808
|
-
async maybeGenerateRules() {
|
|
809
|
-
try {
|
|
810
|
-
const config = this.config;
|
|
811
|
-
if (!config.autoGenerateRules) {
|
|
812
|
-
return;
|
|
813
|
-
}
|
|
814
|
-
if (this.options.sessionManager.isEmpty()) {
|
|
815
|
-
return;
|
|
816
|
-
}
|
|
817
|
-
const { rules } = await generateRulesFromSession({
|
|
818
|
-
modelManager: this.options.modelManager,
|
|
819
|
-
messages: this.options.sessionManager.get(),
|
|
820
|
-
tokenTracker: this.options.tokenTracker,
|
|
821
|
-
config: this.options.configManager,
|
|
822
|
-
workspace: this.options.workspace,
|
|
823
|
-
});
|
|
824
|
-
if (rules.length > 0) {
|
|
825
|
-
this.notification.setMessage(`Auto-generated ${rules.length} rule(s) saved`);
|
|
826
|
-
this.tui.requestRender();
|
|
827
|
-
}
|
|
828
|
-
}
|
|
829
|
-
catch (error) {
|
|
830
|
-
// Don't fail the session transition on rule generation errors
|
|
831
|
-
logger.debug({ error }, "Auto rule generation failed");
|
|
832
|
-
}
|
|
833
|
-
}
|
|
834
|
-
/**
|
|
835
|
-
* Triggers rule generation for use before exit.
|
|
836
|
-
* Returns a promise that resolves when rules are generated.
|
|
837
|
-
*/
|
|
838
|
-
async triggerRuleGeneration() {
|
|
839
|
-
await this.maybeGenerateRules();
|
|
840
|
-
}
|
|
841
825
|
}
|