@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.
Files changed (197) hide show
  1. package/dist/index.mjs +450 -422
  2. package/package.json +4 -1
  3. package/.oxlintrc.json +0 -8
  4. package/resources/abacus.ico +0 -0
  5. package/resources/entitlements.plist +0 -9
  6. package/src/__e2e__/README.md +0 -196
  7. package/src/__e2e__/agent-interactions.e2e.test.tsx +0 -61
  8. package/src/__e2e__/cli-commands.e2e.test.tsx +0 -77
  9. package/src/__e2e__/conversation-throttle.e2e.test.ts +0 -453
  10. package/src/__e2e__/conversation.e2e.test.tsx +0 -56
  11. package/src/__e2e__/diff-preview.e2e.test.tsx +0 -3399
  12. package/src/__e2e__/file-creation.e2e.test.tsx +0 -149
  13. package/src/__e2e__/helpers/test-helpers.ts +0 -449
  14. package/src/__e2e__/keyboard-navigation.e2e.test.tsx +0 -34
  15. package/src/__e2e__/llm-models.e2e.test.ts +0 -402
  16. package/src/__e2e__/mcp/mcp-callback-flow.e2e.test.tsx +0 -71
  17. package/src/__e2e__/mcp/mcp-full-app-ui.e2e.test.tsx +0 -167
  18. package/src/__e2e__/mcp/mcp-ui-rendering.e2e.test.tsx +0 -185
  19. package/src/__e2e__/repl.e2e.test.tsx +0 -78
  20. package/src/__e2e__/shell-compatibility.e2e.test.tsx +0 -76
  21. package/src/__e2e__/theme-mcp.e2e.test.tsx +0 -98
  22. package/src/__e2e__/tool-permissions.e2e.test.tsx +0 -66
  23. package/src/args.ts +0 -22
  24. package/src/components/__tests__/react-compiler.test.tsx +0 -78
  25. package/src/components/__tests__/status-indicator.test.tsx +0 -403
  26. package/src/components/composer/__tests__/bash-runner.test.tsx +0 -263
  27. package/src/components/composer/agent-mode-indicator.tsx +0 -63
  28. package/src/components/composer/bash-runner.tsx +0 -54
  29. package/src/components/composer/commands/default-commands.tsx +0 -615
  30. package/src/components/composer/commands/handler.tsx +0 -59
  31. package/src/components/composer/commands/picker.tsx +0 -273
  32. package/src/components/composer/commands/registry.ts +0 -233
  33. package/src/components/composer/commands/types.ts +0 -33
  34. package/src/components/composer/context.tsx +0 -88
  35. package/src/components/composer/file-mention-picker.tsx +0 -83
  36. package/src/components/composer/help.tsx +0 -44
  37. package/src/components/composer/index.tsx +0 -1007
  38. package/src/components/composer/mentions.ts +0 -57
  39. package/src/components/composer/message-queue.tsx +0 -70
  40. package/src/components/composer/mode-panel.tsx +0 -35
  41. package/src/components/composer/modes/__tests__/bash-handler.test.tsx +0 -755
  42. package/src/components/composer/modes/__tests__/bash-renderer.test.tsx +0 -1108
  43. package/src/components/composer/modes/bash-handler.tsx +0 -132
  44. package/src/components/composer/modes/bash-renderer.tsx +0 -175
  45. package/src/components/composer/modes/default-handlers.tsx +0 -33
  46. package/src/components/composer/modes/index.ts +0 -41
  47. package/src/components/composer/modes/types.ts +0 -21
  48. package/src/components/composer/persistent-shell.ts +0 -283
  49. package/src/components/composer/process.ts +0 -65
  50. package/src/components/composer/types.ts +0 -9
  51. package/src/components/composer/use-mention-search.ts +0 -68
  52. package/src/components/error-boundry.tsx +0 -60
  53. package/src/components/exit-message.tsx +0 -29
  54. package/src/components/expanded-view.tsx +0 -74
  55. package/src/components/file-completion.tsx +0 -127
  56. package/src/components/header.tsx +0 -47
  57. package/src/components/logo.tsx +0 -37
  58. package/src/components/segments.tsx +0 -356
  59. package/src/components/status-indicator.tsx +0 -306
  60. package/src/components/tool-group-summary.tsx +0 -263
  61. package/src/components/tool-permissions/ask-user-question-permission-ui.tsx +0 -319
  62. package/src/components/tool-permissions/diff-preview.tsx +0 -359
  63. package/src/components/tool-permissions/index.ts +0 -5
  64. package/src/components/tool-permissions/permission-options.tsx +0 -401
  65. package/src/components/tool-permissions/permission-preview-header.tsx +0 -57
  66. package/src/components/tool-permissions/tool-permission-ui.tsx +0 -420
  67. package/src/components/tools/agent/ask-user-question.tsx +0 -107
  68. package/src/components/tools/agent/enter-plan-mode.tsx +0 -55
  69. package/src/components/tools/agent/exit-plan-mode.tsx +0 -83
  70. package/src/components/tools/agent/handoff-to-main.tsx +0 -27
  71. package/src/components/tools/agent/subagent.tsx +0 -37
  72. package/src/components/tools/agent/todo-write.tsx +0 -104
  73. package/src/components/tools/browser/close-tab.tsx +0 -58
  74. package/src/components/tools/browser/computer.tsx +0 -70
  75. package/src/components/tools/browser/get-interactive-elements.tsx +0 -54
  76. package/src/components/tools/browser/get-tab-content.tsx +0 -51
  77. package/src/components/tools/browser/navigate-to.tsx +0 -59
  78. package/src/components/tools/browser/new-tab.tsx +0 -60
  79. package/src/components/tools/browser/perform-action.tsx +0 -63
  80. package/src/components/tools/browser/refresh-tab.tsx +0 -43
  81. package/src/components/tools/browser/switch-tab.tsx +0 -58
  82. package/src/components/tools/filesystem/delete-file.tsx +0 -104
  83. package/src/components/tools/filesystem/edit.tsx +0 -220
  84. package/src/components/tools/filesystem/list-dir.tsx +0 -78
  85. package/src/components/tools/filesystem/read-file.tsx +0 -180
  86. package/src/components/tools/filesystem/upload-image.tsx +0 -76
  87. package/src/components/tools/ide/ide-diagnostics.tsx +0 -62
  88. package/src/components/tools/index.ts +0 -91
  89. package/src/components/tools/mcp/mcp-tool.tsx +0 -158
  90. package/src/components/tools/search/fetch-url.tsx +0 -73
  91. package/src/components/tools/search/file-search.tsx +0 -78
  92. package/src/components/tools/search/grep.tsx +0 -90
  93. package/src/components/tools/search/semantic-search.tsx +0 -66
  94. package/src/components/tools/search/web-search.tsx +0 -71
  95. package/src/components/tools/shared/index.tsx +0 -48
  96. package/src/components/tools/shared/zod-coercion.ts +0 -35
  97. package/src/components/tools/terminal/bash-tool-output.tsx +0 -188
  98. package/src/components/tools/terminal/get-terminal-output.tsx +0 -91
  99. package/src/components/tools/terminal/run-in-terminal.tsx +0 -131
  100. package/src/components/tools/types.ts +0 -16
  101. package/src/components/tools.tsx +0 -68
  102. package/src/components/ui/__tests__/divider.test.tsx +0 -61
  103. package/src/components/ui/__tests__/gradient.test.tsx +0 -125
  104. package/src/components/ui/__tests__/input.test.tsx +0 -166
  105. package/src/components/ui/__tests__/select.test.tsx +0 -273
  106. package/src/components/ui/__tests__/shimmer.test.tsx +0 -99
  107. package/src/components/ui/blinking-indicator.tsx +0 -27
  108. package/src/components/ui/divider.tsx +0 -162
  109. package/src/components/ui/gradient.tsx +0 -56
  110. package/src/components/ui/input.tsx +0 -228
  111. package/src/components/ui/select.tsx +0 -151
  112. package/src/components/ui/shimmer.tsx +0 -76
  113. package/src/context/agent-mode.tsx +0 -95
  114. package/src/context/extension-file.tsx +0 -136
  115. package/src/context/network-activity.tsx +0 -45
  116. package/src/context/notification.tsx +0 -62
  117. package/src/context/shell-size.tsx +0 -49
  118. package/src/context/shell-title.tsx +0 -38
  119. package/src/entrypoints/print-mode.ts +0 -312
  120. package/src/entrypoints/repl.tsx +0 -389
  121. package/src/hooks/use-agent.ts +0 -15
  122. package/src/hooks/use-api-client.ts +0 -1
  123. package/src/hooks/use-available-height.ts +0 -8
  124. package/src/hooks/use-cleanup.ts +0 -29
  125. package/src/hooks/use-interrupt-manager.ts +0 -242
  126. package/src/hooks/use-models.ts +0 -22
  127. package/src/index.ts +0 -217
  128. package/src/lib/__tests__/ansi.test.ts +0 -255
  129. package/src/lib/__tests__/cli.test.ts +0 -122
  130. package/src/lib/__tests__/commands.test.ts +0 -325
  131. package/src/lib/__tests__/constants.test.ts +0 -15
  132. package/src/lib/__tests__/focusables.test.ts +0 -25
  133. package/src/lib/__tests__/fs.test.ts +0 -231
  134. package/src/lib/__tests__/markdown.test.tsx +0 -348
  135. package/src/lib/__tests__/mcpCommandHandler.test.ts +0 -173
  136. package/src/lib/__tests__/mcpManagement.test.ts +0 -38
  137. package/src/lib/__tests__/path-paste.test.ts +0 -144
  138. package/src/lib/__tests__/path.test.ts +0 -300
  139. package/src/lib/__tests__/queries.test.ts +0 -39
  140. package/src/lib/__tests__/standaloneMcpService.test.ts +0 -71
  141. package/src/lib/__tests__/text-buffer.test.ts +0 -328
  142. package/src/lib/__tests__/text-utils.test.ts +0 -32
  143. package/src/lib/__tests__/timing.test.ts +0 -78
  144. package/src/lib/__tests__/utils.test.ts +0 -238
  145. package/src/lib/__tests__/vim-buffer-actions.test.ts +0 -154
  146. package/src/lib/ansi.ts +0 -150
  147. package/src/lib/cli-push-server.ts +0 -112
  148. package/src/lib/cli.ts +0 -44
  149. package/src/lib/clipboard.ts +0 -226
  150. package/src/lib/command-utils.ts +0 -93
  151. package/src/lib/commands.ts +0 -270
  152. package/src/lib/constants.ts +0 -3
  153. package/src/lib/extension-connection.ts +0 -181
  154. package/src/lib/focusables.ts +0 -7
  155. package/src/lib/fs.ts +0 -533
  156. package/src/lib/markdown/code-block.tsx +0 -63
  157. package/src/lib/markdown/index.ts +0 -4
  158. package/src/lib/markdown/link.tsx +0 -19
  159. package/src/lib/markdown/markdown.tsx +0 -372
  160. package/src/lib/markdown/types.ts +0 -15
  161. package/src/lib/mcpCommandHandler.ts +0 -121
  162. package/src/lib/mcpManagement.ts +0 -44
  163. package/src/lib/path-paste.ts +0 -185
  164. package/src/lib/path.ts +0 -179
  165. package/src/lib/queries.ts +0 -15
  166. package/src/lib/standaloneMcpService.ts +0 -688
  167. package/src/lib/status-utils.ts +0 -237
  168. package/src/lib/test-utils.tsx +0 -72
  169. package/src/lib/text-buffer.ts +0 -2415
  170. package/src/lib/text-utils.ts +0 -272
  171. package/src/lib/timing.ts +0 -63
  172. package/src/lib/types.ts +0 -295
  173. package/src/lib/utils.ts +0 -182
  174. package/src/lib/vim-buffer-actions.ts +0 -732
  175. package/src/providers/agent.tsx +0 -1063
  176. package/src/providers/api-client.tsx +0 -43
  177. package/src/services/logger.ts +0 -85
  178. package/src/terminal/detection.ts +0 -187
  179. package/src/terminal/exit.ts +0 -279
  180. package/src/terminal/notification.ts +0 -83
  181. package/src/terminal/progress.ts +0 -201
  182. package/src/terminal/setup.ts +0 -797
  183. package/src/terminal/types.ts +0 -51
  184. package/src/theme/context.tsx +0 -57
  185. package/src/theme/index.ts +0 -4
  186. package/src/theme/themed.tsx +0 -35
  187. package/src/theme/themes.json +0 -546
  188. package/src/theme/types.ts +0 -110
  189. package/src/tools/types.ts +0 -59
  190. package/src/tools/utils/__tests__/zod-coercion.test.ts +0 -33
  191. package/src/tools/utils/tool-ui-components.tsx +0 -649
  192. package/src/tools/utils/zod-coercion.ts +0 -35
  193. package/tsconfig.json +0 -16
  194. package/tsconfig.node.json +0 -29
  195. package/tsconfig.test.json +0 -27
  196. package/tsdown.config.ts +0 -17
  197. package/vitest.config.ts +0 -76
@@ -1,453 +0,0 @@
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
- });
@@ -1,56 +0,0 @@
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
- });