@abacus-ai/cli 2.0.0-canary.1 → 2.0.0-canary.3
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/dist/index.mjs +450 -422
- package/package.json +4 -1
- package/.oxlintrc.json +0 -8
- package/resources/abacus.ico +0 -0
- package/resources/entitlements.plist +0 -9
- package/src/__e2e__/README.md +0 -196
- package/src/__e2e__/agent-interactions.e2e.test.tsx +0 -61
- package/src/__e2e__/cli-commands.e2e.test.tsx +0 -77
- package/src/__e2e__/conversation-throttle.e2e.test.ts +0 -453
- package/src/__e2e__/conversation.e2e.test.tsx +0 -56
- package/src/__e2e__/diff-preview.e2e.test.tsx +0 -3399
- package/src/__e2e__/file-creation.e2e.test.tsx +0 -149
- package/src/__e2e__/helpers/test-helpers.ts +0 -449
- package/src/__e2e__/keyboard-navigation.e2e.test.tsx +0 -34
- package/src/__e2e__/llm-models.e2e.test.ts +0 -402
- package/src/__e2e__/mcp/mcp-callback-flow.e2e.test.tsx +0 -71
- package/src/__e2e__/mcp/mcp-full-app-ui.e2e.test.tsx +0 -167
- package/src/__e2e__/mcp/mcp-ui-rendering.e2e.test.tsx +0 -185
- package/src/__e2e__/repl.e2e.test.tsx +0 -78
- package/src/__e2e__/shell-compatibility.e2e.test.tsx +0 -76
- package/src/__e2e__/theme-mcp.e2e.test.tsx +0 -98
- package/src/__e2e__/tool-permissions.e2e.test.tsx +0 -66
- package/src/args.ts +0 -22
- package/src/components/__tests__/react-compiler.test.tsx +0 -78
- package/src/components/__tests__/status-indicator.test.tsx +0 -403
- package/src/components/composer/__tests__/bash-runner.test.tsx +0 -263
- package/src/components/composer/agent-mode-indicator.tsx +0 -63
- package/src/components/composer/bash-runner.tsx +0 -54
- package/src/components/composer/commands/default-commands.tsx +0 -615
- package/src/components/composer/commands/handler.tsx +0 -59
- package/src/components/composer/commands/picker.tsx +0 -273
- package/src/components/composer/commands/registry.ts +0 -233
- package/src/components/composer/commands/types.ts +0 -33
- package/src/components/composer/context.tsx +0 -88
- package/src/components/composer/file-mention-picker.tsx +0 -83
- package/src/components/composer/help.tsx +0 -44
- package/src/components/composer/index.tsx +0 -1007
- package/src/components/composer/mentions.ts +0 -57
- package/src/components/composer/message-queue.tsx +0 -70
- package/src/components/composer/mode-panel.tsx +0 -35
- package/src/components/composer/modes/__tests__/bash-handler.test.tsx +0 -755
- package/src/components/composer/modes/__tests__/bash-renderer.test.tsx +0 -1108
- package/src/components/composer/modes/bash-handler.tsx +0 -132
- package/src/components/composer/modes/bash-renderer.tsx +0 -175
- package/src/components/composer/modes/default-handlers.tsx +0 -33
- package/src/components/composer/modes/index.ts +0 -41
- package/src/components/composer/modes/types.ts +0 -21
- package/src/components/composer/persistent-shell.ts +0 -283
- package/src/components/composer/process.ts +0 -65
- package/src/components/composer/types.ts +0 -9
- package/src/components/composer/use-mention-search.ts +0 -68
- package/src/components/error-boundry.tsx +0 -60
- package/src/components/exit-message.tsx +0 -29
- package/src/components/expanded-view.tsx +0 -74
- package/src/components/file-completion.tsx +0 -127
- package/src/components/header.tsx +0 -47
- package/src/components/logo.tsx +0 -37
- package/src/components/segments.tsx +0 -356
- package/src/components/status-indicator.tsx +0 -306
- package/src/components/tool-group-summary.tsx +0 -263
- package/src/components/tool-permissions/ask-user-question-permission-ui.tsx +0 -319
- package/src/components/tool-permissions/diff-preview.tsx +0 -359
- package/src/components/tool-permissions/index.ts +0 -5
- package/src/components/tool-permissions/permission-options.tsx +0 -401
- package/src/components/tool-permissions/permission-preview-header.tsx +0 -57
- package/src/components/tool-permissions/tool-permission-ui.tsx +0 -420
- package/src/components/tools/agent/ask-user-question.tsx +0 -107
- package/src/components/tools/agent/enter-plan-mode.tsx +0 -55
- package/src/components/tools/agent/exit-plan-mode.tsx +0 -83
- package/src/components/tools/agent/handoff-to-main.tsx +0 -27
- package/src/components/tools/agent/subagent.tsx +0 -37
- package/src/components/tools/agent/todo-write.tsx +0 -104
- package/src/components/tools/browser/close-tab.tsx +0 -58
- package/src/components/tools/browser/computer.tsx +0 -70
- package/src/components/tools/browser/get-interactive-elements.tsx +0 -54
- package/src/components/tools/browser/get-tab-content.tsx +0 -51
- package/src/components/tools/browser/navigate-to.tsx +0 -59
- package/src/components/tools/browser/new-tab.tsx +0 -60
- package/src/components/tools/browser/perform-action.tsx +0 -63
- package/src/components/tools/browser/refresh-tab.tsx +0 -43
- package/src/components/tools/browser/switch-tab.tsx +0 -58
- package/src/components/tools/filesystem/delete-file.tsx +0 -104
- package/src/components/tools/filesystem/edit.tsx +0 -220
- package/src/components/tools/filesystem/list-dir.tsx +0 -78
- package/src/components/tools/filesystem/read-file.tsx +0 -180
- package/src/components/tools/filesystem/upload-image.tsx +0 -76
- package/src/components/tools/ide/ide-diagnostics.tsx +0 -62
- package/src/components/tools/index.ts +0 -91
- package/src/components/tools/mcp/mcp-tool.tsx +0 -158
- package/src/components/tools/search/fetch-url.tsx +0 -73
- package/src/components/tools/search/file-search.tsx +0 -78
- package/src/components/tools/search/grep.tsx +0 -90
- package/src/components/tools/search/semantic-search.tsx +0 -66
- package/src/components/tools/search/web-search.tsx +0 -71
- package/src/components/tools/shared/index.tsx +0 -48
- package/src/components/tools/shared/zod-coercion.ts +0 -35
- package/src/components/tools/terminal/bash-tool-output.tsx +0 -188
- package/src/components/tools/terminal/get-terminal-output.tsx +0 -91
- package/src/components/tools/terminal/run-in-terminal.tsx +0 -131
- package/src/components/tools/types.ts +0 -16
- package/src/components/tools.tsx +0 -68
- package/src/components/ui/__tests__/divider.test.tsx +0 -61
- package/src/components/ui/__tests__/gradient.test.tsx +0 -125
- package/src/components/ui/__tests__/input.test.tsx +0 -166
- package/src/components/ui/__tests__/select.test.tsx +0 -273
- package/src/components/ui/__tests__/shimmer.test.tsx +0 -99
- package/src/components/ui/blinking-indicator.tsx +0 -27
- package/src/components/ui/divider.tsx +0 -162
- package/src/components/ui/gradient.tsx +0 -56
- package/src/components/ui/input.tsx +0 -228
- package/src/components/ui/select.tsx +0 -151
- package/src/components/ui/shimmer.tsx +0 -76
- package/src/context/agent-mode.tsx +0 -95
- package/src/context/extension-file.tsx +0 -136
- package/src/context/network-activity.tsx +0 -45
- package/src/context/notification.tsx +0 -62
- package/src/context/shell-size.tsx +0 -49
- package/src/context/shell-title.tsx +0 -38
- package/src/entrypoints/print-mode.ts +0 -312
- package/src/entrypoints/repl.tsx +0 -389
- package/src/hooks/use-agent.ts +0 -15
- package/src/hooks/use-api-client.ts +0 -1
- package/src/hooks/use-available-height.ts +0 -8
- package/src/hooks/use-cleanup.ts +0 -29
- package/src/hooks/use-interrupt-manager.ts +0 -242
- package/src/hooks/use-models.ts +0 -22
- package/src/index.ts +0 -217
- package/src/lib/__tests__/ansi.test.ts +0 -255
- package/src/lib/__tests__/cli.test.ts +0 -122
- package/src/lib/__tests__/commands.test.ts +0 -325
- package/src/lib/__tests__/constants.test.ts +0 -15
- package/src/lib/__tests__/focusables.test.ts +0 -25
- package/src/lib/__tests__/fs.test.ts +0 -231
- package/src/lib/__tests__/markdown.test.tsx +0 -348
- package/src/lib/__tests__/mcpCommandHandler.test.ts +0 -173
- package/src/lib/__tests__/mcpManagement.test.ts +0 -38
- package/src/lib/__tests__/path-paste.test.ts +0 -144
- package/src/lib/__tests__/path.test.ts +0 -300
- package/src/lib/__tests__/queries.test.ts +0 -39
- package/src/lib/__tests__/standaloneMcpService.test.ts +0 -71
- package/src/lib/__tests__/text-buffer.test.ts +0 -328
- package/src/lib/__tests__/text-utils.test.ts +0 -32
- package/src/lib/__tests__/timing.test.ts +0 -78
- package/src/lib/__tests__/utils.test.ts +0 -238
- package/src/lib/__tests__/vim-buffer-actions.test.ts +0 -154
- package/src/lib/ansi.ts +0 -150
- package/src/lib/cli-push-server.ts +0 -112
- package/src/lib/cli.ts +0 -44
- package/src/lib/clipboard.ts +0 -226
- package/src/lib/command-utils.ts +0 -93
- package/src/lib/commands.ts +0 -270
- package/src/lib/constants.ts +0 -3
- package/src/lib/extension-connection.ts +0 -181
- package/src/lib/focusables.ts +0 -7
- package/src/lib/fs.ts +0 -533
- package/src/lib/markdown/code-block.tsx +0 -63
- package/src/lib/markdown/index.ts +0 -4
- package/src/lib/markdown/link.tsx +0 -19
- package/src/lib/markdown/markdown.tsx +0 -372
- package/src/lib/markdown/types.ts +0 -15
- package/src/lib/mcpCommandHandler.ts +0 -121
- package/src/lib/mcpManagement.ts +0 -44
- package/src/lib/path-paste.ts +0 -185
- package/src/lib/path.ts +0 -179
- package/src/lib/queries.ts +0 -15
- package/src/lib/standaloneMcpService.ts +0 -688
- package/src/lib/status-utils.ts +0 -237
- package/src/lib/test-utils.tsx +0 -72
- package/src/lib/text-buffer.ts +0 -2415
- package/src/lib/text-utils.ts +0 -272
- package/src/lib/timing.ts +0 -63
- package/src/lib/types.ts +0 -295
- package/src/lib/utils.ts +0 -182
- package/src/lib/vim-buffer-actions.ts +0 -732
- package/src/providers/agent.tsx +0 -1063
- package/src/providers/api-client.tsx +0 -43
- package/src/services/logger.ts +0 -85
- package/src/terminal/detection.ts +0 -187
- package/src/terminal/exit.ts +0 -279
- package/src/terminal/notification.ts +0 -83
- package/src/terminal/progress.ts +0 -201
- package/src/terminal/setup.ts +0 -797
- package/src/terminal/types.ts +0 -51
- package/src/theme/context.tsx +0 -57
- package/src/theme/index.ts +0 -4
- package/src/theme/themed.tsx +0 -35
- package/src/theme/themes.json +0 -546
- package/src/theme/types.ts +0 -110
- package/src/tools/types.ts +0 -59
- package/src/tools/utils/__tests__/zod-coercion.test.ts +0 -33
- package/src/tools/utils/tool-ui-components.tsx +0 -649
- package/src/tools/utils/zod-coercion.ts +0 -35
- package/tsconfig.json +0 -16
- package/tsconfig.node.json +0 -29
- package/tsconfig.test.json +0 -27
- package/tsdown.config.ts +0 -17
- package/vitest.config.ts +0 -76
|
@@ -1,312 +0,0 @@
|
|
|
1
|
-
import { AgentMode, AgentSession, AutoAcceptProvider, PromptHistory } from "@codellm/agent";
|
|
2
|
-
import { AbacusClient } from "@codellm/api";
|
|
3
|
-
import { AuthManager } from "@codellm/auth";
|
|
4
|
-
import { product } from "@codellm/product";
|
|
5
|
-
|
|
6
|
-
import type { AgentArgs } from "../args.js";
|
|
7
|
-
|
|
8
|
-
import { logger } from "../services/logger.js";
|
|
9
|
-
import { onExit } from "../terminal/exit.js";
|
|
10
|
-
|
|
11
|
-
async function createApiClient(): Promise<{ apiClient: AbacusClient; authManager: AuthManager }> {
|
|
12
|
-
const authManager = await AuthManager.create();
|
|
13
|
-
const cliLogger = {
|
|
14
|
-
error: (message: string | Error, ...args: unknown[]) => logger.error(message, ...args),
|
|
15
|
-
debug: (...message: unknown[]) => logger.debug(...message),
|
|
16
|
-
warn: (message: string, ...args: unknown[]) => logger.warn(message, ...args),
|
|
17
|
-
};
|
|
18
|
-
return { apiClient: new AbacusClient(authManager, cliLogger), authManager };
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Enhanced instructions for high quality / deep-agent mode.
|
|
23
|
-
*/
|
|
24
|
-
const HIGH_QUALITY_INSTRUCTIONS = `
|
|
25
|
-
IMPORTANT INSTRUCTIONS: Your task is to follow the <task_description> EXACTLY and verify the solution within the FIXED TIME LIMIT.
|
|
26
|
-
A few things to keep in mind (Add Relevant ONES BELOW AS TODOS):
|
|
27
|
-
1. You are in a docker container without user interaction and fixed time limit. Assume HIGHEST permissions are available to the user.
|
|
28
|
-
2. Check running servers in the docker container e.g. with \`ps aux | grep python\` and \`docker ps -a\`
|
|
29
|
-
3. If the task requires a server to run in the background, use \`nohup\` to start it so that tests can access it.
|
|
30
|
-
4. Check the installed packages with \`pip list\`. Use already installed packages unless explicity mentioned to install new ones in the task_description.
|
|
31
|
-
5. Extract ALL filenames and IMPORTANT KEYWORDS mentioned in the task description.
|
|
32
|
-
6. Extract EVERY specific constraint (versions, paths, file locations, values) and list them as checkable assertions
|
|
33
|
-
7. Check all files and folders in the current directory with \`find . -type f \\( -name "*.py" -o -name "*.pyx" -o -name "*.pxd" -o -name "*.txt" \\) | head -20\`
|
|
34
|
-
8. When file names are not specified in the task description, use generic names like app.py etc.
|
|
35
|
-
9. Do NOT do manual conflict resolution when merging files.
|
|
36
|
-
10. When working with .ppm files, Do NOT use \`head -20\` or similar commands with .ppm files
|
|
37
|
-
11. For counting tokens, check both deepseek_solution and deepseek_reasoning and tokenize both separately when asked about deepseek
|
|
38
|
-
12. *CRITICAL*: Write a test script to validate ALL THE CONSTRAINTS, ALL THE POSSIBLE CASES AND SCENARIOS AND REQUIREMENTS for the task and MAKE SURE THEY PASS before declaring COMPLETION. IF ANY FAIL, DEBUG AND FIX AND DO NOT STOP UNTIL ALL TESTS PASS. ** VERY CRITICAL **: Your test scripts must invoke tools/binaries EXACTLY as specified in the task requirements
|
|
39
|
-
13. Follow task instructions precisely, especially file paths and naming conventions specified.
|
|
40
|
-
14. When creating the tar archive, ensure that when it's later extracted, the files will be found at the exact same absolute paths they currently exist at in the filesystem. The archive structure must preserve the full directory hierarchy for validation.
|
|
41
|
-
15. BEFORE claiming completion:
|
|
42
|
-
- STOP and re-read the FULL ORIGINAL task description
|
|
43
|
-
- For EACH constraint you listed in step 3:
|
|
44
|
-
a. Run a command to CHECK it
|
|
45
|
-
b. Record the actual result
|
|
46
|
-
c. Compare to expected result
|
|
47
|
-
- Create a validation table:
|
|
48
|
-
| Requirement | Expected | Actual | Pass/Fail |
|
|
49
|
-
- If ANY constraint fails: web_search for correct examples before proceeding AND FIX IT. Do not declare success.
|
|
50
|
-
Follow TASK instructions EXACTLY. Do NOT take shortcuts that bypass task requirements. Add "Re-read ALL requirements from task description and CONFIRM they are met" 2 times to the list of todos.`;
|
|
51
|
-
|
|
52
|
-
/** Write a JSON line to stdout (stream-json format). */
|
|
53
|
-
function emitJson(obj: Record<string, unknown>): void {
|
|
54
|
-
process.stdout.write(JSON.stringify(obj) + "\n");
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Authenticate for print mode: env vars first, then stored credentials.
|
|
59
|
-
*/
|
|
60
|
-
async function handleAuth(authManager: AuthManager, apiClient: AbacusClient): Promise<void> {
|
|
61
|
-
// Env-based auth (ephemeral) or stored credentials are both valid
|
|
62
|
-
if (authManager.isAuthenticated()) return;
|
|
63
|
-
|
|
64
|
-
try {
|
|
65
|
-
const userInfo = await apiClient.getUserInfo();
|
|
66
|
-
if (userInfo?.result?.email) return;
|
|
67
|
-
} catch {
|
|
68
|
-
// not authenticated
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
console.error(
|
|
72
|
-
`Error: Not authenticated. Please set ${product.envPrefix}API_KEY environment variable.`,
|
|
73
|
-
);
|
|
74
|
-
console.error("You can obtain your API key by visiting: https://abacus.ai/app/abacusai-cli");
|
|
75
|
-
console.error(
|
|
76
|
-
`\nUsage: ${product.envPrefix}API_KEY=your_key_here abacusai --print "your prompt"`,
|
|
77
|
-
);
|
|
78
|
-
process.exit(1);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Fuzzy model name matching.
|
|
83
|
-
*/
|
|
84
|
-
function findBestMatchingModel(
|
|
85
|
-
models: { name?: string; llmName: string }[],
|
|
86
|
-
requested: string,
|
|
87
|
-
): string | null {
|
|
88
|
-
const getFuzzyScore = (modelName: string): number => {
|
|
89
|
-
const name = modelName.toLowerCase();
|
|
90
|
-
if (name === requested) return 1000;
|
|
91
|
-
if (name.startsWith(requested)) return 900;
|
|
92
|
-
let score = 0;
|
|
93
|
-
let lastIndex = -1;
|
|
94
|
-
for (const char of requested) {
|
|
95
|
-
const index = name.indexOf(char, lastIndex + 1);
|
|
96
|
-
if (index === -1) return 0;
|
|
97
|
-
score += 100 - (index - lastIndex);
|
|
98
|
-
lastIndex = index;
|
|
99
|
-
}
|
|
100
|
-
score += Math.max(0, 50 - name.length);
|
|
101
|
-
return score;
|
|
102
|
-
};
|
|
103
|
-
let bestMatch: string | null = null;
|
|
104
|
-
let bestScore = 0;
|
|
105
|
-
for (const model of models) {
|
|
106
|
-
const score = Math.max(getFuzzyScore(model.name ?? ""), getFuzzyScore(model.llmName));
|
|
107
|
-
if (score > bestScore) {
|
|
108
|
-
bestScore = score;
|
|
109
|
-
bestMatch = model.llmName;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
return bestScore >= 100 ? bestMatch : null;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
async function selectModel(apiClient: AbacusClient, requestedModel?: string): Promise<string> {
|
|
116
|
-
const modelsResponse = await apiClient.listLLMModels();
|
|
117
|
-
const models = modelsResponse?.result ?? [];
|
|
118
|
-
|
|
119
|
-
if (!models.length) {
|
|
120
|
-
console.error("Error: No models available. Check your API key and connection.");
|
|
121
|
-
process.exit(1);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
if (!requestedModel) return models[0].llmName;
|
|
125
|
-
|
|
126
|
-
const match = findBestMatchingModel(models, requestedModel.toLowerCase());
|
|
127
|
-
if (!match) {
|
|
128
|
-
console.error(
|
|
129
|
-
`Warning: Model "${requestedModel}" not found. Using default: ${models[0].llmName}`,
|
|
130
|
-
);
|
|
131
|
-
return models[0].llmName;
|
|
132
|
-
}
|
|
133
|
-
return match;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Resolve the startup conversation ID from --resume / --continue flags.
|
|
138
|
-
*/
|
|
139
|
-
async function resolveConversationId(
|
|
140
|
-
agentArgs: AgentArgs | undefined,
|
|
141
|
-
apiClient: AbacusClient,
|
|
142
|
-
): Promise<string | undefined> {
|
|
143
|
-
if (agentArgs?.resume) return agentArgs.resume;
|
|
144
|
-
if (agentArgs?.continue) {
|
|
145
|
-
try {
|
|
146
|
-
const result = await apiClient.getConversationsList("CODE_LLM_AGENT");
|
|
147
|
-
const conversations = result?.result ?? [];
|
|
148
|
-
const latest = conversations.sort((a, b) => {
|
|
149
|
-
const aTime = a.lastEventCreatedAt ? new Date(a.lastEventCreatedAt).getTime() : 0;
|
|
150
|
-
const bTime = b.lastEventCreatedAt ? new Date(b.lastEventCreatedAt).getTime() : 0;
|
|
151
|
-
return bTime - aTime;
|
|
152
|
-
})[0];
|
|
153
|
-
return latest?.deploymentConversationId;
|
|
154
|
-
} catch {
|
|
155
|
-
// fall through — start a new conversation
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
return agentArgs?.conversationId;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* Print mode: run headlessly, stream events per output format, always Yolo.
|
|
163
|
-
*/
|
|
164
|
-
export async function runPrintMode({ agentArgs }: { agentArgs?: AgentArgs }): Promise<void> {
|
|
165
|
-
const { apiClient, authManager } = await createApiClient();
|
|
166
|
-
|
|
167
|
-
await handleAuth(authManager, apiClient);
|
|
168
|
-
|
|
169
|
-
// Configure custom base URL if provided
|
|
170
|
-
const baseUrl = process.env[`${product.envPrefix}BASE_URL`];
|
|
171
|
-
if (baseUrl) {
|
|
172
|
-
try {
|
|
173
|
-
new URL(baseUrl);
|
|
174
|
-
} catch {
|
|
175
|
-
console.error(`Invalid ${product.envPrefix}BASE_URL: ${baseUrl}`);
|
|
176
|
-
process.exit(1);
|
|
177
|
-
}
|
|
178
|
-
apiClient.setUrl(baseUrl);
|
|
179
|
-
apiClient.resetEndpoints();
|
|
180
|
-
await apiClient.getApiEndpoint();
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
const cwd = process.cwd();
|
|
184
|
-
const outputFormat = agentArgs?.["output-format"] ?? "text";
|
|
185
|
-
const model = await selectModel(apiClient, agentArgs?.model);
|
|
186
|
-
|
|
187
|
-
const session = new AgentSession({
|
|
188
|
-
allowedDirectories: [cwd],
|
|
189
|
-
primaryWorkspace: cwd,
|
|
190
|
-
apiClient,
|
|
191
|
-
mode: AgentMode.Yolo,
|
|
192
|
-
model,
|
|
193
|
-
permissionProvider: new AutoAcceptProvider(),
|
|
194
|
-
isPrintMode: true,
|
|
195
|
-
enablePromptRewrite: false,
|
|
196
|
-
supportsThoughtStreaming: true,
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
// Register graceful Ctrl+C handler
|
|
200
|
-
onExit(
|
|
201
|
-
async () => {
|
|
202
|
-
session.stop();
|
|
203
|
-
await new Promise((r) => setTimeout(r, 200));
|
|
204
|
-
},
|
|
205
|
-
{ wait: 1000 },
|
|
206
|
-
);
|
|
207
|
-
|
|
208
|
-
// Resolve startup conversation from --resume / --continue flags
|
|
209
|
-
const startupConversationId = await resolveConversationId(agentArgs, apiClient);
|
|
210
|
-
if (startupConversationId) {
|
|
211
|
-
await session.loadConversation(startupConversationId);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
let userMessage = agentArgs?.prompt ?? "";
|
|
215
|
-
if (process.env.DEEPAGENT_HIGH_QUALITY === "true") {
|
|
216
|
-
userMessage = `${HIGH_QUALITY_INSTRUCTIONS}\nThis is the task description: <task_description>${userMessage}</task_description>`;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
// Print startup header to stderr (not stdout, to keep stdout clean for piping)
|
|
220
|
-
const convLabel = startupConversationId
|
|
221
|
-
? `conversation: ${startupConversationId}`
|
|
222
|
-
: "conversation: new";
|
|
223
|
-
process.stderr.write(`model: ${model} | cwd: ${cwd} | ${convLabel}\n`);
|
|
224
|
-
|
|
225
|
-
// Record in prompt history
|
|
226
|
-
const promptHistory = new PromptHistory("cli-print");
|
|
227
|
-
await promptHistory.load();
|
|
228
|
-
promptHistory.append(userMessage);
|
|
229
|
-
|
|
230
|
-
// Accumulate text and thinking for grouped output
|
|
231
|
-
let accumulatedText = "";
|
|
232
|
-
let accumulatedThinking = "";
|
|
233
|
-
|
|
234
|
-
// Stream agent events
|
|
235
|
-
for await (const event of session.send(userMessage)) {
|
|
236
|
-
switch (event.type) {
|
|
237
|
-
case "text_delta":
|
|
238
|
-
accumulatedText += event.content;
|
|
239
|
-
break;
|
|
240
|
-
|
|
241
|
-
case "thinking_delta":
|
|
242
|
-
accumulatedThinking += event.content;
|
|
243
|
-
break;
|
|
244
|
-
|
|
245
|
-
case "tool_requested": {
|
|
246
|
-
const toolName = event.tool.name;
|
|
247
|
-
const toolId = event.tool.id;
|
|
248
|
-
if (outputFormat === "stream-json") {
|
|
249
|
-
emitJson({ type: "tool_call", name: toolName, id: toolId, input: event.tool.input });
|
|
250
|
-
} else {
|
|
251
|
-
const inputSummary = Object.entries(event.tool.input ?? {})
|
|
252
|
-
.slice(0, 2)
|
|
253
|
-
.map(([k, v]) => `${k}=${JSON.stringify(v).slice(0, 60)}`)
|
|
254
|
-
.join(", ");
|
|
255
|
-
process.stderr.write(` ⏺ ${toolName}(${inputSummary})\n`);
|
|
256
|
-
}
|
|
257
|
-
break;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
case "tool_execution_complete": {
|
|
261
|
-
if (outputFormat === "stream-json") {
|
|
262
|
-
const resultText =
|
|
263
|
-
typeof event.result?.content === "string" ? event.result.content.slice(0, 200) : "";
|
|
264
|
-
emitJson({ type: "tool_result", id: event.tool.id, result: resultText });
|
|
265
|
-
}
|
|
266
|
-
break;
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
case "notification":
|
|
270
|
-
if (outputFormat === "stream-json") {
|
|
271
|
-
emitJson({
|
|
272
|
-
type: "notification",
|
|
273
|
-
severity: event.severity,
|
|
274
|
-
message: event.message,
|
|
275
|
-
...(event.actions ? { actions: event.actions } : {}),
|
|
276
|
-
});
|
|
277
|
-
} else if (event.severity === "error" || event.severity === "warning") {
|
|
278
|
-
process.stderr.write(`[${event.severity}] ${event.message}\n`);
|
|
279
|
-
}
|
|
280
|
-
break;
|
|
281
|
-
|
|
282
|
-
case "error":
|
|
283
|
-
if (outputFormat === "stream-json") {
|
|
284
|
-
emitJson({ type: "error", message: event.error.message });
|
|
285
|
-
} else {
|
|
286
|
-
process.stderr.write(`Error: ${event.error.message}\n`);
|
|
287
|
-
}
|
|
288
|
-
break;
|
|
289
|
-
|
|
290
|
-
default:
|
|
291
|
-
break;
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
// Output final result based on format
|
|
296
|
-
if (outputFormat === "stream-json") {
|
|
297
|
-
if (accumulatedThinking) {
|
|
298
|
-
emitJson({ type: "thinking", content: accumulatedThinking });
|
|
299
|
-
}
|
|
300
|
-
if (accumulatedText) {
|
|
301
|
-
emitJson({ type: "text", content: accumulatedText });
|
|
302
|
-
}
|
|
303
|
-
emitJson({ type: "result", success: true });
|
|
304
|
-
} else {
|
|
305
|
-
if (accumulatedText) {
|
|
306
|
-
process.stdout.write(accumulatedText);
|
|
307
|
-
process.stdout.write("\n");
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
process.exit(0);
|
|
312
|
-
}
|
package/src/entrypoints/repl.tsx
DELETED
|
@@ -1,389 +0,0 @@
|
|
|
1
|
-
import type { AbacusClient } from "@codellm/api";
|
|
2
|
-
|
|
3
|
-
import { AuthManager } from "@codellm/auth";
|
|
4
|
-
import { View, render, useInput } from "@codellm/jar";
|
|
5
|
-
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
6
|
-
import {
|
|
7
|
-
Activity,
|
|
8
|
-
useEffect,
|
|
9
|
-
useState,
|
|
10
|
-
useDeferredValue,
|
|
11
|
-
useMemo,
|
|
12
|
-
useCallback,
|
|
13
|
-
useRef,
|
|
14
|
-
} from "react";
|
|
15
|
-
|
|
16
|
-
import type { AgentArgs } from "../args.js";
|
|
17
|
-
import type { HistorySegment } from "../lib/types.js";
|
|
18
|
-
|
|
19
|
-
import { Composer, type ComposerHandle } from "../components/composer/index.js";
|
|
20
|
-
import { AgentMode } from "../components/composer/types.js";
|
|
21
|
-
import { ExitMessage } from "../components/exit-message.js";
|
|
22
|
-
import { ExpandedView } from "../components/expanded-view.js";
|
|
23
|
-
import { Header } from "../components/header.js";
|
|
24
|
-
import { Segment } from "../components/segments.js";
|
|
25
|
-
import { StatusIndicator } from "../components/status-indicator.js";
|
|
26
|
-
import { GROUPABLE_TOOLS, ToolGroupSummary } from "../components/tool-group-summary.js";
|
|
27
|
-
import { ToolPermissionUI } from "../components/tool-permissions/tool-permission-ui.js";
|
|
28
|
-
import { PendingToolCallIdContext } from "../components/tools/shared/index.js";
|
|
29
|
-
import { AgentModeProvider } from "../context/agent-mode.js";
|
|
30
|
-
import { ExtensionFileProvider } from "../context/extension-file.js";
|
|
31
|
-
import { NetworkActivityProvider } from "../context/network-activity.js";
|
|
32
|
-
import { NotificationProvider } from "../context/notification.js";
|
|
33
|
-
import { ShellSizeProvider } from "../context/shell-size.js";
|
|
34
|
-
import { ShellTitleProvider, useShellTitle } from "../context/shell-title.js";
|
|
35
|
-
import { useAgent } from "../hooks/use-agent.js";
|
|
36
|
-
import { useApiClient } from "../hooks/use-api-client.js";
|
|
37
|
-
import { useInterruptManager } from "../hooks/use-interrupt-manager.js";
|
|
38
|
-
import { ANSI } from "../lib/ansi.js";
|
|
39
|
-
import { Timing } from "../lib/timing.js";
|
|
40
|
-
import { AgentProvider, AgentStatus } from "../providers/agent.js";
|
|
41
|
-
import { ApiClientProvider } from "../providers/api-client.js";
|
|
42
|
-
import { onExit, gracefulExit } from "../terminal/exit.js";
|
|
43
|
-
import { ThemeProvider } from "../theme/index.js";
|
|
44
|
-
|
|
45
|
-
/** Group consecutive "groupable" tool call segments together for compact rendering. */
|
|
46
|
-
type RenderItem =
|
|
47
|
-
| { kind: "segment"; segment: HistorySegment }
|
|
48
|
-
| { kind: "tool-group"; id: string; segments: HistorySegment[] };
|
|
49
|
-
|
|
50
|
-
function isToolSeg(seg: HistorySegment): boolean {
|
|
51
|
-
return seg.type === "code_llm_tool_call" || seg.type === "code_llm_agent_tool_request";
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function hasToolError(seg: HistorySegment): boolean {
|
|
55
|
-
const result = seg.toolUseResult as { rejected?: boolean; content?: string } | undefined;
|
|
56
|
-
return !!(result?.rejected || result?.content?.startsWith("Error:"));
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function groupSegments(segments: HistorySegment[]): RenderItem[] {
|
|
60
|
-
const items: RenderItem[] = [];
|
|
61
|
-
let i = 0;
|
|
62
|
-
while (i < segments.length) {
|
|
63
|
-
const seg = segments[i];
|
|
64
|
-
|
|
65
|
-
// Thinking segments render inline (visible while active + 2s after completion)
|
|
66
|
-
if (seg.type === "thinking") {
|
|
67
|
-
items.push({ kind: "segment", segment: seg });
|
|
68
|
-
i++;
|
|
69
|
-
continue;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
if (isToolSeg(seg) && GROUPABLE_TOOLS.has(getToolName(seg))) {
|
|
73
|
-
// Collect all consecutive groupable tool calls, treating thinking as transparent gaps
|
|
74
|
-
// Break the group at any completed tool that returned an error
|
|
75
|
-
const group: HistorySegment[] = [seg];
|
|
76
|
-
let j = i + 1;
|
|
77
|
-
while (j < segments.length) {
|
|
78
|
-
const next = segments[j];
|
|
79
|
-
if (next.type === "thinking") {
|
|
80
|
-
// Thinking between tool calls is transparent — skip without breaking the group
|
|
81
|
-
j++;
|
|
82
|
-
continue;
|
|
83
|
-
}
|
|
84
|
-
// If the last tool in the group errored, start a new group from here
|
|
85
|
-
if (hasToolError(group[group.length - 1]!)) {
|
|
86
|
-
break;
|
|
87
|
-
}
|
|
88
|
-
if (isToolSeg(next) && GROUPABLE_TOOLS.has(getToolName(next))) {
|
|
89
|
-
group.push(next);
|
|
90
|
-
j++;
|
|
91
|
-
} else {
|
|
92
|
-
break;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
if (group.length === 1) {
|
|
96
|
-
items.push({ kind: "segment", segment: group[0] });
|
|
97
|
-
} else {
|
|
98
|
-
items.push({ kind: "tool-group", id: group[0].id, segments: group });
|
|
99
|
-
}
|
|
100
|
-
i = j;
|
|
101
|
-
continue;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
items.push({ kind: "segment", segment: seg });
|
|
105
|
-
i++;
|
|
106
|
-
}
|
|
107
|
-
return items;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
function getToolName(seg: HistorySegment): string {
|
|
111
|
-
const req = seg.toolUseRequest;
|
|
112
|
-
if (!req) return "";
|
|
113
|
-
if (Array.isArray(req)) return (req[0] as { name?: string })?.name ?? "";
|
|
114
|
-
return (req as { name?: string }).name ?? "";
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/** Derive the most recent thinking timing from segments for the status indicator. */
|
|
118
|
-
function getThinkingTiming(segments: HistorySegment[]): {
|
|
119
|
-
thinkingStartTime: number | null;
|
|
120
|
-
thinkingEndTime: number | null;
|
|
121
|
-
} {
|
|
122
|
-
// Find the last thinking segment
|
|
123
|
-
for (let i = segments.length - 1; i >= 0; i--) {
|
|
124
|
-
const seg = segments[i];
|
|
125
|
-
if (seg.type === "thinking") {
|
|
126
|
-
return {
|
|
127
|
-
thinkingStartTime: seg.thinkingStartTime ?? null,
|
|
128
|
-
thinkingEndTime: seg.thinkingEndTime ?? null,
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
return { thinkingStartTime: null, thinkingEndTime: null };
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
export function App({ timing }: { timing: Timing }) {
|
|
136
|
-
const { setTitle } = useShellTitle();
|
|
137
|
-
|
|
138
|
-
const {
|
|
139
|
-
segments: rawSegments,
|
|
140
|
-
agentStatus,
|
|
141
|
-
pendingToolPermission,
|
|
142
|
-
conversationTitle,
|
|
143
|
-
conversationId,
|
|
144
|
-
addNotification,
|
|
145
|
-
stop,
|
|
146
|
-
rejectPendingPermission,
|
|
147
|
-
removeFirstFromQueue,
|
|
148
|
-
clearQueue,
|
|
149
|
-
retryState,
|
|
150
|
-
networkOnline,
|
|
151
|
-
} = useAgent();
|
|
152
|
-
|
|
153
|
-
const composerRef = useRef<ComposerHandle>(null);
|
|
154
|
-
|
|
155
|
-
const { authExpired, clearAuthExpired } = useApiClient();
|
|
156
|
-
|
|
157
|
-
// Show a notification segment when session expires
|
|
158
|
-
useEffect(() => {
|
|
159
|
-
if (authExpired) {
|
|
160
|
-
addNotification("Session expired — use /login to authenticate again.", "error");
|
|
161
|
-
clearAuthExpired();
|
|
162
|
-
}
|
|
163
|
-
}, [authExpired, addNotification, clearAuthExpired]);
|
|
164
|
-
|
|
165
|
-
// Expanded view: snapshot taken at moment of Ctrl+O
|
|
166
|
-
const [expandedSnapshot, setExpandedSnapshot] = useState<HistorySegment[] | null>(null);
|
|
167
|
-
|
|
168
|
-
const toggleExpand = useCallback(() => {
|
|
169
|
-
setExpandedSnapshot((prev) => {
|
|
170
|
-
if (prev !== null) return null; // close
|
|
171
|
-
// Snapshot: exclude transient/spinny
|
|
172
|
-
return rawSegments.filter((s) => !s.temp && !s.isSpinny);
|
|
173
|
-
});
|
|
174
|
-
}, [rawSegments]);
|
|
175
|
-
|
|
176
|
-
// Global Ctrl+O handler — only active when NOT in expanded mode.
|
|
177
|
-
// When expanded, ExpandedView's own useInput handles the key.
|
|
178
|
-
// Both handlers firing would cause a toggle → re-open race.
|
|
179
|
-
useInput(
|
|
180
|
-
(input, key) => {
|
|
181
|
-
if ((key.ctrl || key.super) && input === "o") {
|
|
182
|
-
toggleExpand();
|
|
183
|
-
}
|
|
184
|
-
},
|
|
185
|
-
{ isActive: expandedSnapshot === null },
|
|
186
|
-
);
|
|
187
|
-
|
|
188
|
-
const { lastItem, prevItems } = useMemo(() => {
|
|
189
|
-
const filtered = rawSegments.filter((s) => !s.temp && !s.isSpinny);
|
|
190
|
-
const items = groupSegments(filtered);
|
|
191
|
-
return {
|
|
192
|
-
lastItem: items.at(-1) ?? null,
|
|
193
|
-
prevItems: items.slice(0, -1),
|
|
194
|
-
};
|
|
195
|
-
}, [rawSegments]);
|
|
196
|
-
|
|
197
|
-
const deferredPrevItems = useDeferredValue(prevItems);
|
|
198
|
-
|
|
199
|
-
// Thinking timing for status indicator
|
|
200
|
-
const { thinkingStartTime, thinkingEndTime } = useMemo(
|
|
201
|
-
() => getThinkingTiming(rawSegments),
|
|
202
|
-
[rawSegments],
|
|
203
|
-
);
|
|
204
|
-
|
|
205
|
-
const isWaitingForPermission =
|
|
206
|
-
agentStatus === AgentStatus.WaitingForToolPermission && pendingToolPermission !== null;
|
|
207
|
-
|
|
208
|
-
const [exiting, setExiting] = useState(false);
|
|
209
|
-
const [exitDuration, setExitDuration] = useState("0");
|
|
210
|
-
const [exitCredits, setExitCredits] = useState(0);
|
|
211
|
-
|
|
212
|
-
useEffect(() => {
|
|
213
|
-
if (conversationTitle) {
|
|
214
|
-
setTitle(`${conversationTitle} • Abacus.AI CLI`);
|
|
215
|
-
} else {
|
|
216
|
-
setTitle("Abacus.AI CLI");
|
|
217
|
-
}
|
|
218
|
-
}, [conversationTitle, setTitle]);
|
|
219
|
-
|
|
220
|
-
useEffect(() => {
|
|
221
|
-
const unsubscribe = onExit(
|
|
222
|
-
async () => {
|
|
223
|
-
const duration = timing.getFormattedDuration();
|
|
224
|
-
|
|
225
|
-
setExitCredits(0);
|
|
226
|
-
setExitDuration(duration);
|
|
227
|
-
setExiting(true);
|
|
228
|
-
|
|
229
|
-
await new Promise<void>((resolve) => setTimeout(resolve, 100));
|
|
230
|
-
},
|
|
231
|
-
{ wait: 2000, streams: [process.stdout, process.stderr] },
|
|
232
|
-
);
|
|
233
|
-
|
|
234
|
-
return unsubscribe;
|
|
235
|
-
}, [timing]);
|
|
236
|
-
|
|
237
|
-
const hints = useInterruptManager({
|
|
238
|
-
agentStatus,
|
|
239
|
-
hasPendingPermission: pendingToolPermission !== null,
|
|
240
|
-
composerHasText: () => composerRef.current?.hasText() ?? false,
|
|
241
|
-
hasQueuedMessages: () => composerRef.current?.hasQueue() ?? false,
|
|
242
|
-
stopAgent: stop,
|
|
243
|
-
rejectPermission: rejectPendingPermission,
|
|
244
|
-
saveAndClearComposer: () => composerRef.current?.saveAndClear(),
|
|
245
|
-
clearComposer: () => composerRef.current?.clear(),
|
|
246
|
-
dequeueOne: removeFirstFromQueue,
|
|
247
|
-
clearQueue,
|
|
248
|
-
exitApp: () => gracefulExit(0),
|
|
249
|
-
});
|
|
250
|
-
|
|
251
|
-
const shouldShowStatusIndicator =
|
|
252
|
-
(agentStatus !== AgentStatus.Idle && agentStatus !== AgentStatus.WaitingForToolPermission) ||
|
|
253
|
-
retryState !== null ||
|
|
254
|
-
!networkOnline;
|
|
255
|
-
|
|
256
|
-
const pendingToolCallId = pendingToolPermission?.request.tool.id ?? null;
|
|
257
|
-
|
|
258
|
-
// Expanded mode: show static snapshot instead of normal UI
|
|
259
|
-
if (expandedSnapshot !== null) {
|
|
260
|
-
return <ExpandedView snapshot={expandedSnapshot} onClose={() => setExpandedSnapshot(null)} />;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
return (
|
|
264
|
-
<>
|
|
265
|
-
<View flexDirection="column" gap={1} paddingBottom={1} width="95%">
|
|
266
|
-
<Header />
|
|
267
|
-
<PendingToolCallIdContext.Provider value={pendingToolCallId}>
|
|
268
|
-
{deferredPrevItems.map((item) =>
|
|
269
|
-
item.kind === "segment" ? (
|
|
270
|
-
<Segment key={item.segment.id} segment={item.segment} />
|
|
271
|
-
) : (
|
|
272
|
-
<ToolGroupSummary key={item.id} segments={item.segments} />
|
|
273
|
-
),
|
|
274
|
-
)}
|
|
275
|
-
{lastItem &&
|
|
276
|
-
(lastItem.kind === "segment" ? (
|
|
277
|
-
<Segment key={lastItem.segment.id} segment={lastItem.segment} />
|
|
278
|
-
) : (
|
|
279
|
-
<ToolGroupSummary key={lastItem.id} segments={lastItem.segments} />
|
|
280
|
-
))}
|
|
281
|
-
</PendingToolCallIdContext.Provider>
|
|
282
|
-
{shouldShowStatusIndicator && (
|
|
283
|
-
<StatusIndicator
|
|
284
|
-
status={agentStatus}
|
|
285
|
-
thinkingStartTime={thinkingStartTime}
|
|
286
|
-
thinkingEndTime={thinkingEndTime}
|
|
287
|
-
retryState={retryState}
|
|
288
|
-
networkOnline={networkOnline}
|
|
289
|
-
/>
|
|
290
|
-
)}
|
|
291
|
-
</View>
|
|
292
|
-
|
|
293
|
-
{exiting ? (
|
|
294
|
-
<ExitMessage
|
|
295
|
-
duration={exitDuration}
|
|
296
|
-
credits={exitCredits}
|
|
297
|
-
conversationId={conversationId}
|
|
298
|
-
/>
|
|
299
|
-
) : (
|
|
300
|
-
<>
|
|
301
|
-
{isWaitingForPermission && <ToolPermissionUI pendingTool={pendingToolPermission} />}
|
|
302
|
-
<Activity mode={isWaitingForPermission ? "hidden" : "visible"}>
|
|
303
|
-
<Composer hints={hints} composerRef={composerRef} />
|
|
304
|
-
</Activity>
|
|
305
|
-
</>
|
|
306
|
-
)}
|
|
307
|
-
</>
|
|
308
|
-
);
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
export interface ReplConfig {
|
|
312
|
-
apiClient: AbacusClient;
|
|
313
|
-
authManager: AuthManager;
|
|
314
|
-
agentArgs?: AgentArgs;
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
export async function runRepl({ apiClient, authManager, agentArgs }: ReplConfig) {
|
|
318
|
-
const queryClient = new QueryClient();
|
|
319
|
-
const timing = new Timing();
|
|
320
|
-
|
|
321
|
-
let initialAgentMode: AgentMode | undefined;
|
|
322
|
-
if (agentArgs?.["dangerously-skip-permissions"]) {
|
|
323
|
-
initialAgentMode = AgentMode.Yolo;
|
|
324
|
-
} else if (agentArgs?.["auto-accept-edits"]) {
|
|
325
|
-
initialAgentMode = AgentMode.AcceptEdits;
|
|
326
|
-
} else if (agentArgs?.["plan-mode"]) {
|
|
327
|
-
initialAgentMode = AgentMode.PlanMode;
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
const stdout = process.stdout;
|
|
331
|
-
const write = (s: string) => {
|
|
332
|
-
if (stdout && stdout.writable) {
|
|
333
|
-
stdout.write(s);
|
|
334
|
-
}
|
|
335
|
-
};
|
|
336
|
-
const hideCursor = () => write(ANSI.HIDE_CURSOR);
|
|
337
|
-
const showCursor = () => write(ANSI.SHOW_CURSOR);
|
|
338
|
-
|
|
339
|
-
hideCursor();
|
|
340
|
-
const app = render(
|
|
341
|
-
<ThemeProvider>
|
|
342
|
-
<ApiClientProvider client={apiClient} authManager={authManager}>
|
|
343
|
-
<QueryClientProvider client={queryClient}>
|
|
344
|
-
<ShellSizeProvider>
|
|
345
|
-
<ShellTitleProvider>
|
|
346
|
-
<NotificationProvider>
|
|
347
|
-
<ExtensionFileProvider>
|
|
348
|
-
<AgentModeProvider initialMode={initialAgentMode}>
|
|
349
|
-
<NetworkActivityProvider>
|
|
350
|
-
<AgentProvider apiClient={apiClient} agentArgs={agentArgs}>
|
|
351
|
-
<App timing={timing} />
|
|
352
|
-
</AgentProvider>
|
|
353
|
-
</NetworkActivityProvider>
|
|
354
|
-
</AgentModeProvider>
|
|
355
|
-
</ExtensionFileProvider>
|
|
356
|
-
</NotificationProvider>
|
|
357
|
-
</ShellTitleProvider>
|
|
358
|
-
</ShellSizeProvider>
|
|
359
|
-
</QueryClientProvider>
|
|
360
|
-
</ApiClientProvider>
|
|
361
|
-
</ThemeProvider>,
|
|
362
|
-
{
|
|
363
|
-
exitOnCtrlC: false,
|
|
364
|
-
suspendable: true,
|
|
365
|
-
onSuspended: () => {
|
|
366
|
-
process.stderr.write("\nAbacus.AI has been suspended. Run `fg` to bring Abacus back.\n");
|
|
367
|
-
},
|
|
368
|
-
},
|
|
369
|
-
);
|
|
370
|
-
|
|
371
|
-
let cleanedUp = false;
|
|
372
|
-
const cleanup = () => {
|
|
373
|
-
if (cleanedUp) return;
|
|
374
|
-
cleanedUp = true;
|
|
375
|
-
showCursor();
|
|
376
|
-
};
|
|
377
|
-
|
|
378
|
-
const handleProcessExit = () => {
|
|
379
|
-
if (!cleanedUp) {
|
|
380
|
-
cleanedUp = true;
|
|
381
|
-
app.cleanupTerminal();
|
|
382
|
-
}
|
|
383
|
-
};
|
|
384
|
-
process.once("exit", handleProcessExit);
|
|
385
|
-
|
|
386
|
-
await app.waitUntilExit();
|
|
387
|
-
process.off("exit", handleProcessExit);
|
|
388
|
-
cleanup();
|
|
389
|
-
}
|