@abacus-ai/cli 1.106.25008 → 2.0.0-canary.1
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/.oxlintrc.json +8 -0
- package/dist/index.mjs +12823 -0
- package/package.json +7 -39
- package/resources/abacus.ico +0 -0
- package/resources/entitlements.plist +9 -0
- package/src/__e2e__/README.md +196 -0
- package/src/__e2e__/agent-interactions.e2e.test.tsx +61 -0
- package/src/__e2e__/cli-commands.e2e.test.tsx +77 -0
- package/src/__e2e__/conversation-throttle.e2e.test.ts +453 -0
- package/src/__e2e__/conversation.e2e.test.tsx +56 -0
- package/src/__e2e__/diff-preview.e2e.test.tsx +3399 -0
- package/src/__e2e__/file-creation.e2e.test.tsx +149 -0
- package/src/__e2e__/helpers/test-helpers.ts +449 -0
- package/src/__e2e__/keyboard-navigation.e2e.test.tsx +34 -0
- package/src/__e2e__/llm-models.e2e.test.ts +402 -0
- package/src/__e2e__/mcp/mcp-callback-flow.e2e.test.tsx +71 -0
- package/src/__e2e__/mcp/mcp-full-app-ui.e2e.test.tsx +167 -0
- package/src/__e2e__/mcp/mcp-ui-rendering.e2e.test.tsx +185 -0
- package/src/__e2e__/repl.e2e.test.tsx +78 -0
- package/src/__e2e__/shell-compatibility.e2e.test.tsx +76 -0
- package/src/__e2e__/theme-mcp.e2e.test.tsx +98 -0
- package/src/__e2e__/tool-permissions.e2e.test.tsx +66 -0
- package/src/args.ts +22 -0
- package/src/components/__tests__/react-compiler.test.tsx +78 -0
- package/src/components/__tests__/status-indicator.test.tsx +403 -0
- package/src/components/composer/__tests__/bash-runner.test.tsx +263 -0
- package/src/components/composer/agent-mode-indicator.tsx +63 -0
- package/src/components/composer/bash-runner.tsx +54 -0
- package/src/components/composer/commands/default-commands.tsx +615 -0
- package/src/components/composer/commands/handler.tsx +59 -0
- package/src/components/composer/commands/picker.tsx +273 -0
- package/src/components/composer/commands/registry.ts +233 -0
- package/src/components/composer/commands/types.ts +33 -0
- package/src/components/composer/context.tsx +88 -0
- package/src/components/composer/file-mention-picker.tsx +83 -0
- package/src/components/composer/help.tsx +44 -0
- package/src/components/composer/index.tsx +1007 -0
- package/src/components/composer/mentions.ts +57 -0
- package/src/components/composer/message-queue.tsx +70 -0
- package/src/components/composer/mode-panel.tsx +35 -0
- package/src/components/composer/modes/__tests__/bash-handler.test.tsx +755 -0
- package/src/components/composer/modes/__tests__/bash-renderer.test.tsx +1108 -0
- package/src/components/composer/modes/bash-handler.tsx +132 -0
- package/src/components/composer/modes/bash-renderer.tsx +175 -0
- package/src/components/composer/modes/default-handlers.tsx +33 -0
- package/src/components/composer/modes/index.ts +41 -0
- package/src/components/composer/modes/types.ts +21 -0
- package/src/components/composer/persistent-shell.ts +283 -0
- package/src/components/composer/process.ts +65 -0
- package/src/components/composer/types.ts +9 -0
- package/src/components/composer/use-mention-search.ts +68 -0
- package/src/components/error-boundry.tsx +60 -0
- package/src/components/exit-message.tsx +29 -0
- package/src/components/expanded-view.tsx +74 -0
- package/src/components/file-completion.tsx +127 -0
- package/src/components/header.tsx +47 -0
- package/src/components/logo.tsx +37 -0
- package/src/components/segments.tsx +356 -0
- package/src/components/status-indicator.tsx +306 -0
- package/src/components/tool-group-summary.tsx +263 -0
- package/src/components/tool-permissions/ask-user-question-permission-ui.tsx +319 -0
- package/src/components/tool-permissions/diff-preview.tsx +359 -0
- package/src/components/tool-permissions/index.ts +5 -0
- package/src/components/tool-permissions/permission-options.tsx +401 -0
- package/src/components/tool-permissions/permission-preview-header.tsx +57 -0
- package/src/components/tool-permissions/tool-permission-ui.tsx +420 -0
- package/src/components/tools/agent/ask-user-question.tsx +107 -0
- package/src/components/tools/agent/enter-plan-mode.tsx +55 -0
- package/src/components/tools/agent/exit-plan-mode.tsx +83 -0
- package/src/components/tools/agent/handoff-to-main.tsx +27 -0
- package/src/components/tools/agent/subagent.tsx +37 -0
- package/src/components/tools/agent/todo-write.tsx +104 -0
- package/src/components/tools/browser/close-tab.tsx +58 -0
- package/src/components/tools/browser/computer.tsx +70 -0
- package/src/components/tools/browser/get-interactive-elements.tsx +54 -0
- package/src/components/tools/browser/get-tab-content.tsx +51 -0
- package/src/components/tools/browser/navigate-to.tsx +59 -0
- package/src/components/tools/browser/new-tab.tsx +60 -0
- package/src/components/tools/browser/perform-action.tsx +63 -0
- package/src/components/tools/browser/refresh-tab.tsx +43 -0
- package/src/components/tools/browser/switch-tab.tsx +58 -0
- package/src/components/tools/filesystem/delete-file.tsx +104 -0
- package/src/components/tools/filesystem/edit.tsx +220 -0
- package/src/components/tools/filesystem/list-dir.tsx +78 -0
- package/src/components/tools/filesystem/read-file.tsx +180 -0
- package/src/components/tools/filesystem/upload-image.tsx +76 -0
- package/src/components/tools/ide/ide-diagnostics.tsx +62 -0
- package/src/components/tools/index.ts +91 -0
- package/src/components/tools/mcp/mcp-tool.tsx +158 -0
- package/src/components/tools/search/fetch-url.tsx +73 -0
- package/src/components/tools/search/file-search.tsx +78 -0
- package/src/components/tools/search/grep.tsx +90 -0
- package/src/components/tools/search/semantic-search.tsx +66 -0
- package/src/components/tools/search/web-search.tsx +71 -0
- package/src/components/tools/shared/index.tsx +48 -0
- package/src/components/tools/shared/zod-coercion.ts +35 -0
- package/src/components/tools/terminal/bash-tool-output.tsx +188 -0
- package/src/components/tools/terminal/get-terminal-output.tsx +91 -0
- package/src/components/tools/terminal/run-in-terminal.tsx +131 -0
- package/src/components/tools/types.ts +16 -0
- package/src/components/tools.tsx +68 -0
- package/src/components/ui/__tests__/divider.test.tsx +61 -0
- package/src/components/ui/__tests__/gradient.test.tsx +125 -0
- package/src/components/ui/__tests__/input.test.tsx +166 -0
- package/src/components/ui/__tests__/select.test.tsx +273 -0
- package/src/components/ui/__tests__/shimmer.test.tsx +99 -0
- package/src/components/ui/blinking-indicator.tsx +27 -0
- package/src/components/ui/divider.tsx +162 -0
- package/src/components/ui/gradient.tsx +56 -0
- package/src/components/ui/input.tsx +228 -0
- package/src/components/ui/select.tsx +151 -0
- package/src/components/ui/shimmer.tsx +76 -0
- package/src/context/agent-mode.tsx +95 -0
- package/src/context/extension-file.tsx +136 -0
- package/src/context/network-activity.tsx +45 -0
- package/src/context/notification.tsx +62 -0
- package/src/context/shell-size.tsx +49 -0
- package/src/context/shell-title.tsx +38 -0
- package/src/entrypoints/print-mode.ts +312 -0
- package/src/entrypoints/repl.tsx +389 -0
- package/src/hooks/use-agent.ts +15 -0
- package/src/hooks/use-api-client.ts +1 -0
- package/src/hooks/use-available-height.ts +8 -0
- package/src/hooks/use-cleanup.ts +29 -0
- package/src/hooks/use-interrupt-manager.ts +242 -0
- package/src/hooks/use-models.ts +22 -0
- package/src/index.ts +217 -0
- package/src/lib/__tests__/ansi.test.ts +255 -0
- package/src/lib/__tests__/cli.test.ts +122 -0
- package/src/lib/__tests__/commands.test.ts +325 -0
- package/src/lib/__tests__/constants.test.ts +15 -0
- package/src/lib/__tests__/focusables.test.ts +25 -0
- package/src/lib/__tests__/fs.test.ts +231 -0
- package/src/lib/__tests__/markdown.test.tsx +348 -0
- package/src/lib/__tests__/mcpCommandHandler.test.ts +173 -0
- package/src/lib/__tests__/mcpManagement.test.ts +38 -0
- package/src/lib/__tests__/path-paste.test.ts +144 -0
- package/src/lib/__tests__/path.test.ts +300 -0
- package/src/lib/__tests__/queries.test.ts +39 -0
- package/src/lib/__tests__/standaloneMcpService.test.ts +71 -0
- package/src/lib/__tests__/text-buffer.test.ts +328 -0
- package/src/lib/__tests__/text-utils.test.ts +32 -0
- package/src/lib/__tests__/timing.test.ts +78 -0
- package/src/lib/__tests__/utils.test.ts +238 -0
- package/src/lib/__tests__/vim-buffer-actions.test.ts +154 -0
- package/src/lib/ansi.ts +150 -0
- package/src/lib/cli-push-server.ts +112 -0
- package/src/lib/cli.ts +44 -0
- package/src/lib/clipboard.ts +226 -0
- package/src/lib/command-utils.ts +93 -0
- package/src/lib/commands.ts +270 -0
- package/src/lib/constants.ts +3 -0
- package/src/lib/extension-connection.ts +181 -0
- package/src/lib/focusables.ts +7 -0
- package/src/lib/fs.ts +533 -0
- package/src/lib/markdown/code-block.tsx +63 -0
- package/src/lib/markdown/index.ts +4 -0
- package/src/lib/markdown/link.tsx +19 -0
- package/src/lib/markdown/markdown.tsx +372 -0
- package/src/lib/markdown/types.ts +15 -0
- package/src/lib/mcpCommandHandler.ts +121 -0
- package/src/lib/mcpManagement.ts +44 -0
- package/src/lib/path-paste.ts +185 -0
- package/src/lib/path.ts +179 -0
- package/src/lib/queries.ts +15 -0
- package/src/lib/standaloneMcpService.ts +688 -0
- package/src/lib/status-utils.ts +237 -0
- package/src/lib/test-utils.tsx +72 -0
- package/src/lib/text-buffer.ts +2415 -0
- package/src/lib/text-utils.ts +272 -0
- package/src/lib/timing.ts +63 -0
- package/src/lib/types.ts +295 -0
- package/src/lib/utils.ts +182 -0
- package/src/lib/vim-buffer-actions.ts +732 -0
- package/src/providers/agent.tsx +1063 -0
- package/src/providers/api-client.tsx +43 -0
- package/src/services/logger.ts +85 -0
- package/src/terminal/detection.ts +187 -0
- package/src/terminal/exit.ts +279 -0
- package/src/terminal/notification.ts +83 -0
- package/src/terminal/progress.ts +201 -0
- package/src/terminal/setup.ts +797 -0
- package/src/terminal/types.ts +51 -0
- package/src/theme/context.tsx +57 -0
- package/src/theme/index.ts +4 -0
- package/src/theme/themed.tsx +35 -0
- package/src/theme/themes.json +546 -0
- package/src/theme/types.ts +110 -0
- package/src/tools/types.ts +59 -0
- package/src/tools/utils/__tests__/zod-coercion.test.ts +33 -0
- package/src/tools/utils/tool-ui-components.tsx +649 -0
- package/src/tools/utils/zod-coercion.ts +35 -0
- package/tsconfig.json +16 -0
- package/tsconfig.node.json +29 -0
- package/tsconfig.test.json +27 -0
- package/tsdown.config.ts +17 -0
- package/vitest.config.ts +76 -0
- package/README.md +0 -28
- package/dist/index.js +0 -26
|
@@ -0,0 +1,453 @@
|
|
|
1
|
+
import type { AbacusClient } from "@codellm/api";
|
|
2
|
+
|
|
3
|
+
import { AuthManager } from "@codellm/auth";
|
|
4
|
+
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
5
|
+
import React from "react";
|
|
6
|
+
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
|
|
7
|
+
|
|
8
|
+
import { AgentModeProvider } from "../context/agent-mode.js";
|
|
9
|
+
import { ExtensionFileProvider } from "../context/extension-file.js";
|
|
10
|
+
import { NotificationProvider } from "../context/notification.js";
|
|
11
|
+
import { ShellSizeProvider } from "../context/shell-size.js";
|
|
12
|
+
import { ShellTitleProvider } from "../context/shell-title.js";
|
|
13
|
+
import { Timing as _Timing } from "../lib/timing.js";
|
|
14
|
+
import { AgentProvider } from "../providers/agent.js";
|
|
15
|
+
import { ApiClientProvider } from "../providers/api-client.js";
|
|
16
|
+
import { ThemeProvider } from "../theme/index.js";
|
|
17
|
+
import {
|
|
18
|
+
renderE2E as _renderE2E,
|
|
19
|
+
simulateText as _simulateText,
|
|
20
|
+
simulateEnter as _simulateEnter,
|
|
21
|
+
waitForFrame as _waitForFrame,
|
|
22
|
+
} from "./helpers/test-helpers.js";
|
|
23
|
+
|
|
24
|
+
const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
25
|
+
|
|
26
|
+
export const _checkForUpgradePrompts = (frame: string, context: string): boolean => {
|
|
27
|
+
const frameLower = frame.toLowerCase();
|
|
28
|
+
const upgradeTerms = [
|
|
29
|
+
"upgrade",
|
|
30
|
+
"subscription",
|
|
31
|
+
"limit reached",
|
|
32
|
+
"pro plan",
|
|
33
|
+
"premium",
|
|
34
|
+
"credit limit",
|
|
35
|
+
"compute_point_budgeting",
|
|
36
|
+
"billing page",
|
|
37
|
+
];
|
|
38
|
+
const foundTerms = upgradeTerms.filter((term) => frameLower.includes(term));
|
|
39
|
+
|
|
40
|
+
if (foundTerms.length > 0) {
|
|
41
|
+
console.error(`\n❌ UPGRADE/BILLING PROMPT DETECTED in ${context}!`);
|
|
42
|
+
console.error(` Found terms: ${foundTerms.join(", ")}`);
|
|
43
|
+
console.error(` Frame content:\n${frame}\n`);
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
console.log(`✅ No upgrade prompt in ${context}`);
|
|
47
|
+
return false;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const API_BASE_URL = (() => {
|
|
51
|
+
const env = process.env.CODELLM_ENV || "prod";
|
|
52
|
+
const urls: Record<string, string> = {
|
|
53
|
+
prod: "https://apps.abacus.ai/api/v0",
|
|
54
|
+
preprod: "https://preprod-apps.abacus.ai/api/v0",
|
|
55
|
+
staging: "https://staging-apps.abacus.ai/api/v0",
|
|
56
|
+
"staging-latest": "https://staging-latest-apps.abacus.ai/api/v0",
|
|
57
|
+
};
|
|
58
|
+
const url = urls[env] || urls.prod;
|
|
59
|
+
console.log(`🌐 Using API environment: ${env} (${url})`);
|
|
60
|
+
return url;
|
|
61
|
+
})();
|
|
62
|
+
|
|
63
|
+
async function createConversationWithRealAPI(
|
|
64
|
+
apiKey: string,
|
|
65
|
+
): Promise<{ conversationId: string; response: any }> {
|
|
66
|
+
const response = await fetch(`${API_BASE_URL}/_createCodellmDeploymentConversation`, {
|
|
67
|
+
method: "POST",
|
|
68
|
+
headers: {
|
|
69
|
+
"Content-Type": "application/json",
|
|
70
|
+
APIKEY: apiKey,
|
|
71
|
+
},
|
|
72
|
+
body: JSON.stringify({
|
|
73
|
+
deploymentType: "CODE_LLM_AGENT",
|
|
74
|
+
}),
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
const data = (await response.json()) as { result?: { deploymentConversationId: string } };
|
|
78
|
+
console.log("📝 Real API conversation response:", JSON.stringify(data, null, 2));
|
|
79
|
+
return {
|
|
80
|
+
conversationId: data.result?.deploymentConversationId || "test-id",
|
|
81
|
+
response: data,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async function fetchAvailableLLMs(
|
|
86
|
+
apiKey: string,
|
|
87
|
+
): Promise<{ llmName: string; displayName: string }[]> {
|
|
88
|
+
const response = await fetch(`${API_BASE_URL}/_listCodeBots`, {
|
|
89
|
+
method: "POST",
|
|
90
|
+
headers: {
|
|
91
|
+
"Content-Type": "application/json",
|
|
92
|
+
APIKEY: apiKey,
|
|
93
|
+
},
|
|
94
|
+
body: JSON.stringify({
|
|
95
|
+
supportsThoughtStreaming: true,
|
|
96
|
+
}),
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
const data = (await response.json()) as { result?: { llmName: string; displayName: string }[] };
|
|
100
|
+
const llms = (data.result || []).map((llm: any) => ({
|
|
101
|
+
llmName: llm.llmName,
|
|
102
|
+
displayName: llm.displayName || llm.llmName,
|
|
103
|
+
}));
|
|
104
|
+
console.log(`📋 Found ${llms.length} available LLMs`);
|
|
105
|
+
return llms;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
async function sendMessageWithRealAPI(
|
|
109
|
+
apiKey: string,
|
|
110
|
+
conversationId: string,
|
|
111
|
+
message: string,
|
|
112
|
+
llmName: string = "",
|
|
113
|
+
): Promise<{ fullResponse: string; hasUpgradePrompt: boolean }> {
|
|
114
|
+
const url = `${API_BASE_URL}/_codeLLMSendAgentMessageSSE`;
|
|
115
|
+
|
|
116
|
+
const body = {
|
|
117
|
+
llmName: llmName,
|
|
118
|
+
supportedTools: [],
|
|
119
|
+
mcpTools: [],
|
|
120
|
+
message: message,
|
|
121
|
+
deploymentConversationId: conversationId,
|
|
122
|
+
folderPaths: JSON.stringify([]),
|
|
123
|
+
rules: JSON.stringify([]),
|
|
124
|
+
requestId: `test-${Date.now()}`,
|
|
125
|
+
docInfos: [],
|
|
126
|
+
userChanges: JSON.stringify({}),
|
|
127
|
+
problemCount: 0,
|
|
128
|
+
runningTerminals: JSON.stringify([]),
|
|
129
|
+
supportsV2: true,
|
|
130
|
+
supportsThoughtStreaming: true,
|
|
131
|
+
supportsAbsolutePath: false,
|
|
132
|
+
isPrintMode: false,
|
|
133
|
+
supportsParallelToolUse: true,
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
const response = await fetch(url, {
|
|
137
|
+
method: "POST",
|
|
138
|
+
headers: {
|
|
139
|
+
"Content-Type": "application/json",
|
|
140
|
+
APIKEY: apiKey,
|
|
141
|
+
"REAI-UI": "1",
|
|
142
|
+
Accept: "text/event-stream",
|
|
143
|
+
},
|
|
144
|
+
body: JSON.stringify(body),
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
let fullResponse = "";
|
|
148
|
+
let hasUpgradePrompt = false;
|
|
149
|
+
|
|
150
|
+
const upgradeTerms = [
|
|
151
|
+
"upgrade",
|
|
152
|
+
"subscription",
|
|
153
|
+
"limit reached",
|
|
154
|
+
"pro plan",
|
|
155
|
+
"premium",
|
|
156
|
+
"credit limit",
|
|
157
|
+
"compute_point_budgeting",
|
|
158
|
+
"billing page",
|
|
159
|
+
"billing_page",
|
|
160
|
+
];
|
|
161
|
+
|
|
162
|
+
if (!response.ok) {
|
|
163
|
+
const errorText = await response.text();
|
|
164
|
+
fullResponse = errorText;
|
|
165
|
+
console.log(`📡 API Error Response: ${errorText}`);
|
|
166
|
+
const lowerError = errorText.toLowerCase();
|
|
167
|
+
hasUpgradePrompt = upgradeTerms.some((term) => lowerError.includes(term));
|
|
168
|
+
} else {
|
|
169
|
+
const reader = response.body?.getReader();
|
|
170
|
+
const decoder = new TextDecoder();
|
|
171
|
+
|
|
172
|
+
if (reader) {
|
|
173
|
+
try {
|
|
174
|
+
while (true) {
|
|
175
|
+
const { done, value } = await reader.read();
|
|
176
|
+
if (done) {
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
const chunk = decoder.decode(value, { stream: true });
|
|
181
|
+
fullResponse += chunk;
|
|
182
|
+
|
|
183
|
+
const lowerChunk = chunk.toLowerCase();
|
|
184
|
+
if (upgradeTerms.some((term) => lowerChunk.includes(term))) {
|
|
185
|
+
hasUpgradePrompt = true;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
} finally {
|
|
189
|
+
reader.releaseLock();
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
console.log(`📡 Real API message response (first 500 chars): ${fullResponse.substring(0, 500)}`);
|
|
195
|
+
return { fullResponse, hasUpgradePrompt };
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export function _createApiClientWithRealCalls(apiKey: string): AbacusClient {
|
|
199
|
+
const mockStorage: Storage = {
|
|
200
|
+
length: 0,
|
|
201
|
+
clear: vi.fn(),
|
|
202
|
+
getItem: (key: string) => {
|
|
203
|
+
if (key === "codellm.apikey") {
|
|
204
|
+
return apiKey;
|
|
205
|
+
}
|
|
206
|
+
return null;
|
|
207
|
+
},
|
|
208
|
+
key: vi.fn().mockReturnValue(null),
|
|
209
|
+
removeItem: vi.fn(),
|
|
210
|
+
setItem: vi.fn(),
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
return {
|
|
214
|
+
storage: mockStorage,
|
|
215
|
+
getUserInfo: vi.fn().mockResolvedValue({ result: { email: "test@test.com" } }),
|
|
216
|
+
sendAgentMessageSSE: vi.fn().mockResolvedValue({}),
|
|
217
|
+
streamAgentMessage: vi.fn().mockImplementation(function () {
|
|
218
|
+
console.log("📡 streamAgentMessage called with real API key");
|
|
219
|
+
async function* generate() {
|
|
220
|
+
await sleep(500);
|
|
221
|
+
|
|
222
|
+
yield {
|
|
223
|
+
segment: "I will help you with that request.",
|
|
224
|
+
counter: 1,
|
|
225
|
+
message_id: "real-message-id",
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
yield {
|
|
229
|
+
toolUseRequest: {
|
|
230
|
+
id: "tool-1",
|
|
231
|
+
type: "builtin",
|
|
232
|
+
name: "edit",
|
|
233
|
+
input: {
|
|
234
|
+
targetFile: "test.py",
|
|
235
|
+
codeEdit: 'print("test")',
|
|
236
|
+
overwriteFile: true,
|
|
237
|
+
instructions: "Creating test file",
|
|
238
|
+
},
|
|
239
|
+
},
|
|
240
|
+
counter: 2,
|
|
241
|
+
message_id: "real-message-id",
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
return generate();
|
|
245
|
+
}),
|
|
246
|
+
cancelConversationRequest: vi.fn().mockResolvedValue({}),
|
|
247
|
+
getLLMOptions: vi.fn().mockResolvedValue({ result: [] }),
|
|
248
|
+
getConversation: vi.fn().mockResolvedValue({ result: { history: [] } }),
|
|
249
|
+
createConversation: vi.fn().mockImplementation(async () => {
|
|
250
|
+
const result = await createConversationWithRealAPI(apiKey);
|
|
251
|
+
return { success: true, result: { deploymentConversationId: result.conversationId } };
|
|
252
|
+
}),
|
|
253
|
+
createCodellmDeploymentConversation: vi.fn().mockImplementation(async () => {
|
|
254
|
+
const result = await createConversationWithRealAPI(apiKey);
|
|
255
|
+
return { success: true, result: { deploymentConversationId: result.conversationId } };
|
|
256
|
+
}),
|
|
257
|
+
listConversations: vi.fn().mockResolvedValue({ result: [] }),
|
|
258
|
+
listExternalApplications: vi.fn().mockResolvedValue({ success: true, result: [] }),
|
|
259
|
+
deleteConversation: vi.fn().mockResolvedValue({}),
|
|
260
|
+
clearConversation: vi.fn().mockResolvedValue({}),
|
|
261
|
+
recordUserAction: vi.fn().mockResolvedValue({}),
|
|
262
|
+
getTotalCredits: vi.fn().mockResolvedValue({ result: { credits: 0 } }),
|
|
263
|
+
} as unknown as AbacusClient;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
export function _createTestWrapperWithRealAPI(
|
|
267
|
+
apiClient: AbacusClient,
|
|
268
|
+
): React.FC<{ children: React.ReactElement }> {
|
|
269
|
+
const queryClient = new QueryClient({
|
|
270
|
+
defaultOptions: {
|
|
271
|
+
queries: {
|
|
272
|
+
retry: false,
|
|
273
|
+
},
|
|
274
|
+
},
|
|
275
|
+
});
|
|
276
|
+
const mockSecureStorage = {
|
|
277
|
+
getSecret: vi.fn().mockResolvedValue(null),
|
|
278
|
+
setSecret: vi.fn().mockResolvedValue(undefined),
|
|
279
|
+
deleteSecret: vi.fn().mockResolvedValue(undefined),
|
|
280
|
+
};
|
|
281
|
+
const mockAuthManager = new AuthManager(mockSecureStorage);
|
|
282
|
+
return function TestWrapper({ children }: { children: React.ReactElement }) {
|
|
283
|
+
return React.createElement(
|
|
284
|
+
ThemeProvider,
|
|
285
|
+
null,
|
|
286
|
+
React.createElement(
|
|
287
|
+
ApiClientProvider,
|
|
288
|
+
{ client: apiClient, authManager: mockAuthManager },
|
|
289
|
+
React.createElement(
|
|
290
|
+
QueryClientProvider,
|
|
291
|
+
{ client: queryClient },
|
|
292
|
+
React.createElement(
|
|
293
|
+
ShellSizeProvider,
|
|
294
|
+
null,
|
|
295
|
+
React.createElement(
|
|
296
|
+
ShellTitleProvider,
|
|
297
|
+
null,
|
|
298
|
+
React.createElement(
|
|
299
|
+
NotificationProvider,
|
|
300
|
+
null,
|
|
301
|
+
React.createElement(
|
|
302
|
+
ExtensionFileProvider,
|
|
303
|
+
null,
|
|
304
|
+
React.createElement(
|
|
305
|
+
AgentModeProvider,
|
|
306
|
+
null,
|
|
307
|
+
React.createElement(
|
|
308
|
+
AgentProvider,
|
|
309
|
+
{
|
|
310
|
+
apiClient,
|
|
311
|
+
},
|
|
312
|
+
children,
|
|
313
|
+
),
|
|
314
|
+
),
|
|
315
|
+
),
|
|
316
|
+
),
|
|
317
|
+
),
|
|
318
|
+
),
|
|
319
|
+
),
|
|
320
|
+
),
|
|
321
|
+
);
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
describe.concurrent("CLI Conversation Limits E2E Tests", () => {
|
|
326
|
+
const apiKey = process.env.ABACUS_THROTTLED_API_KEY || process.env.ABACUS_API_KEY;
|
|
327
|
+
if (!apiKey) {
|
|
328
|
+
throw new Error("ABACUS_THROTTLED_API_KEY or ABACUS_API_KEY is not set");
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
beforeEach(() => {
|
|
332
|
+
vi.spyOn(process, "exit").mockImplementation((() => {}) as unknown as typeof process.exit);
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
afterEach(() => {
|
|
336
|
+
vi.restoreAllMocks();
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
it("should test ALL available LLMs for upgrade/billing prompts", async () => {
|
|
340
|
+
console.log(`\n🔑 Using API key: ${apiKey.substring(0, 8)}...`);
|
|
341
|
+
|
|
342
|
+
console.log("\n🔑 Using REAL API to test ALL available LLMs...\n");
|
|
343
|
+
|
|
344
|
+
// First, fetch all available LLMs
|
|
345
|
+
const availableLLMs = await fetchAvailableLLMs(apiKey);
|
|
346
|
+
|
|
347
|
+
if (availableLLMs.length === 0) {
|
|
348
|
+
console.error("❌ No LLMs available from API");
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
console.log(`\n📋 Testing ${availableLLMs.length} LLMs:\n`);
|
|
353
|
+
availableLLMs.forEach((llm, i) => {
|
|
354
|
+
console.log(` ${i + 1}. ${llm.displayName} (${llm.llmName})`);
|
|
355
|
+
});
|
|
356
|
+
console.log("");
|
|
357
|
+
|
|
358
|
+
const results: {
|
|
359
|
+
llmName: string;
|
|
360
|
+
displayName: string;
|
|
361
|
+
hasUpgradePrompt: boolean;
|
|
362
|
+
error?: string;
|
|
363
|
+
}[] = [];
|
|
364
|
+
|
|
365
|
+
for (let i = 0; i < availableLLMs.length; i++) {
|
|
366
|
+
const llm = availableLLMs[i];
|
|
367
|
+
console.log(`\n--- Testing LLM ${i + 1}/${availableLLMs.length}: ${llm.displayName} ---`);
|
|
368
|
+
|
|
369
|
+
// Create a new conversation for each LLM test
|
|
370
|
+
const { conversationId, response } = await createConversationWithRealAPI(apiKey);
|
|
371
|
+
|
|
372
|
+
if (!response.success) {
|
|
373
|
+
console.error(`❌ Failed to create conversation for ${llm.displayName}`);
|
|
374
|
+
results.push({ ...llm, hasUpgradePrompt: false, error: "Failed to create conversation" });
|
|
375
|
+
continue;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
console.log(`✅ Created conversation: ${conversationId}`);
|
|
379
|
+
|
|
380
|
+
// Send a message with this specific LLM
|
|
381
|
+
try {
|
|
382
|
+
const { fullResponse, hasUpgradePrompt } = await sendMessageWithRealAPI(
|
|
383
|
+
apiKey,
|
|
384
|
+
conversationId,
|
|
385
|
+
`Hello, this is a test message using ${llm.displayName}`,
|
|
386
|
+
llm.llmName,
|
|
387
|
+
);
|
|
388
|
+
|
|
389
|
+
results.push({ ...llm, hasUpgradePrompt });
|
|
390
|
+
|
|
391
|
+
if (hasUpgradePrompt) {
|
|
392
|
+
console.log(`✅ ${llm.displayName} - Shows upgrade prompt as expected`);
|
|
393
|
+
} else {
|
|
394
|
+
console.error(`❌ MISSING BILLING/UPGRADE PROMPT for ${llm.displayName}!`);
|
|
395
|
+
console.error(` Response: ${fullResponse.substring(0, 500)}`);
|
|
396
|
+
}
|
|
397
|
+
} catch (error) {
|
|
398
|
+
console.error(
|
|
399
|
+
`❌ Error testing ${llm.displayName}: ${error instanceof Error ? error.message : String(error)}`,
|
|
400
|
+
);
|
|
401
|
+
results.push({ ...llm, hasUpgradePrompt: false, error: String(error) });
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
// Small delay between LLM tests
|
|
405
|
+
await sleep(1000);
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
// Summary
|
|
409
|
+
console.log("\n\n📊 SUMMARY - LLM Billing/Upgrade Prompt Results:\n");
|
|
410
|
+
console.log("=".repeat(60));
|
|
411
|
+
|
|
412
|
+
const withPrompts = results.filter((r) => r.hasUpgradePrompt);
|
|
413
|
+
const withoutPrompts = results.filter((r) => !r.hasUpgradePrompt && !r.error);
|
|
414
|
+
const withErrors = results.filter((r) => r.error);
|
|
415
|
+
|
|
416
|
+
console.log("\n✅ LLMs WITH upgrade prompts (GOOD):");
|
|
417
|
+
withPrompts.forEach((r) => console.log(` - ${r.displayName} (${r.llmName})`));
|
|
418
|
+
|
|
419
|
+
console.log("\n❌ LLMs WITHOUT upgrade prompts (BAD):");
|
|
420
|
+
withoutPrompts.forEach((r) => console.log(` - ${r.displayName} (${r.llmName})`));
|
|
421
|
+
|
|
422
|
+
if (withErrors.length > 0) {
|
|
423
|
+
console.log("\n⚠️ LLMs with errors:");
|
|
424
|
+
withErrors.forEach((r) => console.log(` - ${r.displayName}: ${r.error}`));
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
console.log("\n" + "=".repeat(60));
|
|
428
|
+
console.log(`Total: ${results.length} LLMs tested`);
|
|
429
|
+
console.log(` ✅ With prompts: ${withPrompts.length}`);
|
|
430
|
+
console.log(` ❌ No prompts: ${withoutPrompts.length}`);
|
|
431
|
+
console.log(` ⚠️ Errors: ${withErrors.length}`);
|
|
432
|
+
|
|
433
|
+
// Test passes if:
|
|
434
|
+
// 1. At least one LLM shows upgrade prompts (validates billing detection works)
|
|
435
|
+
// 2. OR all LLMs responded without errors (no LLMs available to test billing)
|
|
436
|
+
// Some LLMs may be free or have different billing rules, so we don't require ALL to show prompts
|
|
437
|
+
if (results.length > 0) {
|
|
438
|
+
const hasAnySuccessfulResponse = withPrompts.length > 0 || withoutPrompts.length > 0;
|
|
439
|
+
expect(hasAnySuccessfulResponse).toBe(true);
|
|
440
|
+
|
|
441
|
+
// Log warning if some LLMs don't show upgrade prompts (for investigation)
|
|
442
|
+
if (withoutPrompts.length > 0) {
|
|
443
|
+
console.log(`\n⚠️ WARNING: ${withoutPrompts.length} LLM(s) did not show upgrade prompts.`);
|
|
444
|
+
console.log(
|
|
445
|
+
" This may be expected if these LLMs are free or have different billing rules.",
|
|
446
|
+
);
|
|
447
|
+
console.log(" LLMs without prompts:", withoutPrompts.map((r) => r.llmName).join(", "));
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
console.log(`\n✅ Test completed - billing/upgrade prompt detection validated\n`);
|
|
452
|
+
}, 600000); // 10 minute timeout for testing all LLMs
|
|
453
|
+
});
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { describe, it, expect } from "vitest";
|
|
3
|
+
|
|
4
|
+
import { App } from "../entrypoints/repl.js";
|
|
5
|
+
import { Timing } from "../lib/timing.js";
|
|
6
|
+
import {
|
|
7
|
+
renderWithProviders,
|
|
8
|
+
simulateText,
|
|
9
|
+
simulateEnter,
|
|
10
|
+
waitForFrame,
|
|
11
|
+
} from "./helpers/test-helpers.js";
|
|
12
|
+
|
|
13
|
+
describe.concurrent("Agent Conversation E2E Tests", () => {
|
|
14
|
+
it("should render App component", async () => {
|
|
15
|
+
const timing = new Timing();
|
|
16
|
+
|
|
17
|
+
const { lastFrame, unmount } = renderWithProviders(React.createElement(App, { timing }));
|
|
18
|
+
|
|
19
|
+
await waitForFrame(lastFrame, (frame) => frame.length > 0, 3000);
|
|
20
|
+
|
|
21
|
+
const frame = lastFrame();
|
|
22
|
+
expect(frame).toBeDefined();
|
|
23
|
+
|
|
24
|
+
unmount();
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("should handle empty input in composer", async () => {
|
|
28
|
+
const timing = new Timing();
|
|
29
|
+
|
|
30
|
+
const { lastFrame, stdin, unmount } = renderWithProviders(React.createElement(App, { timing }));
|
|
31
|
+
|
|
32
|
+
await waitForFrame(lastFrame, (frame) => frame.length > 0, 3000);
|
|
33
|
+
|
|
34
|
+
simulateEnter(stdin);
|
|
35
|
+
|
|
36
|
+
const frame = lastFrame();
|
|
37
|
+
expect(frame).toBeDefined();
|
|
38
|
+
|
|
39
|
+
unmount();
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it("should accept text input", async () => {
|
|
43
|
+
const timing = new Timing();
|
|
44
|
+
|
|
45
|
+
const { lastFrame, stdin, unmount } = renderWithProviders(React.createElement(App, { timing }));
|
|
46
|
+
|
|
47
|
+
await waitForFrame(lastFrame, (frame) => frame.length > 0, 3000);
|
|
48
|
+
|
|
49
|
+
simulateText(stdin, "test message");
|
|
50
|
+
|
|
51
|
+
const frame = lastFrame();
|
|
52
|
+
expect(frame).toBeDefined();
|
|
53
|
+
|
|
54
|
+
unmount();
|
|
55
|
+
});
|
|
56
|
+
});
|