@golba98/codexa 1.0.2 → 1.0.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 (150) hide show
  1. package/README.md +391 -94
  2. package/package.json +12 -7
  3. package/src/app.tsx +149 -117
  4. package/src/commands/handler.ts +4 -4
  5. package/src/config/buildInfo.ts +2 -2
  6. package/src/config/persistence.ts +10 -0
  7. package/src/config/settings.ts +7 -15
  8. package/src/config/updateCheckCache.ts +19 -1
  9. package/src/core/channel.ts +23 -0
  10. package/src/core/executables/codexExecutable.ts +1 -0
  11. package/src/core/executables/executableResolver.ts +61 -43
  12. package/src/core/launchContext.ts +33 -33
  13. package/src/core/process/processValidation.ts +9 -5
  14. package/src/core/providerLauncher/launcher.ts +59 -42
  15. package/src/core/updateCheck.ts +111 -95
  16. package/src/session/types.ts +2 -1
  17. package/src/ui/ActionRequiredBlock.tsx +5 -5
  18. package/src/ui/ActivityBars.tsx +3 -3
  19. package/src/ui/ActivityIndicator.tsx +6 -6
  20. package/src/ui/AgentBlock.tsx +6 -6
  21. package/src/ui/AnimatedStatusText.tsx +1 -1
  22. package/src/ui/AppShell.tsx +9 -24
  23. package/src/ui/AttachmentImportPanel.tsx +8 -8
  24. package/src/ui/AuthPanel.tsx +20 -20
  25. package/src/ui/BottomComposer.tsx +117 -78
  26. package/src/ui/DashCard.tsx +3 -3
  27. package/src/ui/Markdown.tsx +17 -17
  28. package/src/ui/ModelPickerScreen.tsx +10 -10
  29. package/src/ui/ModelReasoningPicker.tsx +14 -14
  30. package/src/ui/Panel.tsx +3 -3
  31. package/src/ui/PlanActionPicker.tsx +6 -6
  32. package/src/ui/PlanReviewPanel.tsx +8 -8
  33. package/src/ui/ProviderPicker.tsx +18 -18
  34. package/src/ui/RunFooter.tsx +3 -3
  35. package/src/ui/SelectionPanel.tsx +4 -4
  36. package/src/ui/SettingsPanel.tsx +8 -8
  37. package/src/ui/Spinner.tsx +1 -1
  38. package/src/ui/TextEntryPanel.tsx +10 -10
  39. package/src/ui/ThinkingBlock.tsx +8 -8
  40. package/src/ui/Timeline.tsx +21 -17
  41. package/src/ui/TopHeader.tsx +421 -293
  42. package/src/ui/TurnGroup.tsx +31 -31
  43. package/src/ui/UpdateAvailableCard.tsx +41 -0
  44. package/src/ui/UpdatePromptPanel.tsx +203 -0
  45. package/src/ui/focus.ts +3 -0
  46. package/src/ui/layout.ts +1 -1
  47. package/src/ui/logoVariants.ts +107 -0
  48. package/src/ui/modeDisplay.ts +12 -12
  49. package/src/ui/runtimeDisplay.ts +100 -0
  50. package/src/ui/theme.tsx +274 -395
  51. package/src/ui/timelineMeasure.ts +29 -19
  52. package/scripts/audit-codexa-capabilities.mjs +0 -466
  53. package/scripts/gen-build-info.mjs +0 -33
  54. package/scripts/smoke-terminal-bench.mjs +0 -35
  55. package/src/appRenderStability.test.ts +0 -131
  56. package/src/commands/handler.test.ts +0 -655
  57. package/src/config/launchArgs.test.ts +0 -189
  58. package/src/config/layeredConfig.test.ts +0 -143
  59. package/src/config/persistence.test.ts +0 -114
  60. package/src/config/runtimeConfig.test.ts +0 -218
  61. package/src/config/settings.test.ts +0 -155
  62. package/src/config/trustStore.test.ts +0 -29
  63. package/src/core/attachments.test.ts +0 -155
  64. package/src/core/auth/codexAuth.test.ts +0 -68
  65. package/src/core/cleanupFastFail.test.ts +0 -76
  66. package/src/core/codexExecArgs.test.ts +0 -195
  67. package/src/core/codexLaunch.test.ts +0 -205
  68. package/src/core/codexPrompt.test.ts +0 -252
  69. package/src/core/executables/codexExecutable.test.ts +0 -212
  70. package/src/core/executables/executableResolver.test.ts +0 -129
  71. package/src/core/executables/geminiExecutable.test.ts +0 -116
  72. package/src/core/executables/pathSanityScan.test.ts +0 -47
  73. package/src/core/githubDiagnostics.test.ts +0 -92
  74. package/src/core/hollowResponseFormat.test.ts +0 -58
  75. package/src/core/launchContext.test.ts +0 -157
  76. package/src/core/models/codexCapabilities.test.ts +0 -45
  77. package/src/core/models/codexModelCapabilities.test.ts +0 -246
  78. package/src/core/models/modelSpecs.test.ts +0 -283
  79. package/src/core/perf/renderDebug.test.ts +0 -230
  80. package/src/core/planStorage.test.ts +0 -143
  81. package/src/core/process/CommandRunner.test.ts +0 -105
  82. package/src/core/projectInstructions.test.ts +0 -50
  83. package/src/core/providerLauncher/launcher.test.ts +0 -238
  84. package/src/core/providerLauncher/registry.test.ts +0 -324
  85. package/src/core/providerLauncher/workspaceConfig.test.ts +0 -638
  86. package/src/core/providerRuntime/anthropic.test.ts +0 -1120
  87. package/src/core/providerRuntime/capabilityProfile.test.ts +0 -311
  88. package/src/core/providerRuntime/contextMetadata.test.ts +0 -468
  89. package/src/core/providerRuntime/gemini.test.ts +0 -437
  90. package/src/core/providerRuntime/lmstudio.test.ts +0 -168
  91. package/src/core/providerRuntime/local.test.ts +0 -787
  92. package/src/core/providerRuntime/registry.test.ts +0 -233
  93. package/src/core/providers/codexJsonStream.test.ts +0 -148
  94. package/src/core/providers/codexSubprocess.test.ts +0 -68
  95. package/src/core/providers/codexTranscript.test.ts +0 -284
  96. package/src/core/terminal/startupClear.test.ts +0 -55
  97. package/src/core/terminal/terminalCapabilities.test.ts +0 -93
  98. package/src/core/terminal/terminalControl.test.ts +0 -75
  99. package/src/core/terminal/terminalSanitize.test.ts +0 -22
  100. package/src/core/terminal/terminalSelection.test.ts +0 -42
  101. package/src/core/terminal/terminalTitle.test.ts +0 -328
  102. package/src/core/updateCheck.test.ts +0 -194
  103. package/src/core/workspaceActivity.test.ts +0 -163
  104. package/src/core/workspaceGuard.test.ts +0 -151
  105. package/src/core/workspaceRoot.test.ts +0 -23
  106. package/src/exec.test.ts +0 -13
  107. package/src/headless/execArgs.test.ts +0 -147
  108. package/src/headless/execRunner.test.ts +0 -436
  109. package/src/index.test.tsx +0 -620
  110. package/src/session/appSession.test.ts +0 -897
  111. package/src/session/chatLifecycle.test.ts +0 -64
  112. package/src/session/liveRenderScheduler.test.ts +0 -201
  113. package/src/session/planFlow.test.ts +0 -103
  114. package/src/session/planTranscript.test.ts +0 -65
  115. package/src/session/promptRunSchedule.test.ts +0 -36
  116. package/src/ui/ActivityIndicator.test.tsx +0 -58
  117. package/src/ui/AgentBlock.test.ts +0 -6
  118. package/src/ui/AnimatedStatusText.test.ts +0 -16
  119. package/src/ui/AppShell.test.tsx +0 -1776
  120. package/src/ui/AttachmentImportPanel.test.tsx +0 -204
  121. package/src/ui/BottomComposer.test.ts +0 -674
  122. package/src/ui/CodexLogo.tsx +0 -55
  123. package/src/ui/Markdown.test.ts +0 -157
  124. package/src/ui/ModelPickerProviderScope.test.tsx +0 -411
  125. package/src/ui/ModelPickerScreen.test.tsx +0 -99
  126. package/src/ui/ModelPickerState.test.tsx +0 -151
  127. package/src/ui/ModelReasoningPicker.test.tsx +0 -447
  128. package/src/ui/PlanReviewPanel.test.tsx +0 -267
  129. package/src/ui/PromptCardBorder.test.tsx +0 -161
  130. package/src/ui/ProviderPicker.test.tsx +0 -289
  131. package/src/ui/ProviderShortcut.test.tsx +0 -143
  132. package/src/ui/SettingsPanel.test.tsx +0 -233
  133. package/src/ui/Timeline.test.ts +0 -2067
  134. package/src/ui/TimelineNavigation.test.tsx +0 -201
  135. package/src/ui/TopHeader.test.tsx +0 -254
  136. package/src/ui/TurnGroup.test.tsx +0 -365
  137. package/src/ui/busyStatusAnimation.test.ts +0 -30
  138. package/src/ui/commandNormalize.test.ts +0 -142
  139. package/src/ui/diffRenderer.test.ts +0 -102
  140. package/src/ui/focusFlow.test.tsx +0 -1098
  141. package/src/ui/inputBuffer.test.ts +0 -151
  142. package/src/ui/layout.test.ts +0 -146
  143. package/src/ui/modeDisplay.test.ts +0 -42
  144. package/src/ui/runActivityView.test.ts +0 -89
  145. package/src/ui/runLifecycleView.test.tsx +0 -237
  146. package/src/ui/statusRenderIsolation.test.tsx +0 -654
  147. package/src/ui/terminalAnswerFormat.test.ts +0 -19
  148. package/src/ui/textLayout.test.ts +0 -18
  149. package/src/ui/themeFlow.test.ts +0 -53
  150. package/src/ui/timelineMeasureCache.test.ts +0 -986
@@ -1,638 +0,0 @@
1
- import assert from "node:assert/strict";
2
- import { mkdtempSync, rmSync } from "fs";
3
- import { tmpdir } from "os";
4
- import { join } from "path";
5
- import test from "node:test";
6
- import { buildProviderRegistry } from "./registry.js";
7
- import { resetGeminiRouteValidationCacheForTests } from "../providerRuntime/gemini.js";
8
- import { checkLocalProvider, resetLocalProviderStateForTests } from "../providerRuntime/local.js";
9
- import {
10
- getProviderWorkspaceConfigFile,
11
- loadProviderWorkspaceConfig,
12
- parseProviderWorkspaceConfig,
13
- saveProviderWorkspaceConfig,
14
- serializeProviderWorkspaceConfig,
15
- setProviderActiveRoute,
16
- setProviderDefaultReasoning,
17
- setProviderDefaultModel,
18
- setProviderWorkspaceDefault,
19
- } from "./workspaceConfig.js";
20
-
21
- function withGeminiEnv<T>(
22
- env: Partial<NodeJS.ProcessEnv>,
23
- callback: () => T,
24
- ): T {
25
- const originalGemini = process.env.GEMINI_API_KEY;
26
- const originalGoogle = process.env.GOOGLE_API_KEY;
27
-
28
- try {
29
- if ("GEMINI_API_KEY" in env) {
30
- process.env.GEMINI_API_KEY = env.GEMINI_API_KEY;
31
- } else {
32
- delete process.env.GEMINI_API_KEY;
33
- }
34
- if ("GOOGLE_API_KEY" in env) {
35
- process.env.GOOGLE_API_KEY = env.GOOGLE_API_KEY;
36
- } else {
37
- delete process.env.GOOGLE_API_KEY;
38
- }
39
- resetGeminiRouteValidationCacheForTests();
40
- return callback();
41
- } finally {
42
- if (originalGemini === undefined) {
43
- delete process.env.GEMINI_API_KEY;
44
- } else {
45
- process.env.GEMINI_API_KEY = originalGemini;
46
- }
47
- if (originalGoogle === undefined) {
48
- delete process.env.GOOGLE_API_KEY;
49
- } else {
50
- process.env.GOOGLE_API_KEY = originalGoogle;
51
- }
52
- resetGeminiRouteValidationCacheForTests();
53
- }
54
- }
55
-
56
- test("parses provider workspace config from Codexa-owned JSON", () => {
57
- const config = parseProviderWorkspaceConfig({
58
- default_provider_id: "google",
59
- activeRoute: {
60
- providerId: "openai",
61
- modelId: "gpt-5.5",
62
- reasoning: "high",
63
- },
64
- providers: {
65
- local: {
66
- current_model: "llama",
67
- current_reasoning: "medium",
68
- type: "openai-compatible",
69
- base_url: "http://localhost:1234/v1",
70
- api_key: "lm-studio",
71
- default_model: "llama",
72
- command: "ollama",
73
- },
74
- unknown: {
75
- command: "ignored",
76
- },
77
- },
78
- });
79
-
80
- assert.equal(config.workspaceDefaultProviderId, "google");
81
- assert.deepEqual(config.activeRoute, {
82
- providerId: "openai",
83
- modelId: "gpt-5.5",
84
- backendKind: "codex-cli-auth",
85
- reasoning: "high",
86
- });
87
- assert.deepEqual(config.providers?.local, {
88
- currentModel: "llama",
89
- currentReasoning: "medium",
90
- type: "openai-compatible",
91
- baseUrl: "http://localhost:1234/v1",
92
- apiKey: "lm-studio",
93
- defaultModel: "llama",
94
- command: "ollama",
95
- });
96
- assert.equal("unknown" in (config.providers ?? {}), false);
97
- });
98
-
99
- test("legacy Antigravity active/default config falls back to OpenAI and drops provider override", () => {
100
- const config = parseProviderWorkspaceConfig({
101
- workspaceDefaultProviderId: "antigravity",
102
- activeRoute: {
103
- providerId: "antigravity",
104
- modelId: "external-antigravity-default",
105
- backendKind: "antigravity-cli-auth",
106
- reasoning: "medium",
107
- },
108
- providers: {
109
- antigravity: {
110
- current_model: "external-antigravity-default",
111
- current_reasoning: "medium",
112
- },
113
- openai: {
114
- current_model: "gpt-5.4-mini",
115
- current_reasoning: "low",
116
- },
117
- },
118
- });
119
-
120
- assert.deepEqual(config.activeRoute, {
121
- providerId: "openai",
122
- modelId: "gpt-5.4-mini",
123
- backendKind: "codex-cli-auth",
124
- reasoning: "low",
125
- });
126
- assert.equal(config.workspaceDefaultProviderId, "openai");
127
- assert.equal(config.providers?.openai?.currentModel, "gpt-5.4-mini");
128
- assert.equal((config.providers as Record<string, unknown> | undefined)?.antigravity, undefined);
129
- assert.deepEqual(config.migrationNotice, {
130
- deprecatedProviderId: "antigravity",
131
- revertedProviderId: "openai",
132
- });
133
- assert.doesNotMatch(JSON.stringify(serializeProviderWorkspaceConfig(config)), /antigravity/i);
134
- });
135
-
136
- test("legacy Antigravity backend aliases are treated as deprecated routes", () => {
137
- const config = parseProviderWorkspaceConfig({
138
- active_route: {
139
- provider_id: "openai",
140
- model_id: "external-antigravity-default",
141
- backend_kind: "agy",
142
- },
143
- });
144
-
145
- assert.equal(config.activeRoute?.providerId, "openai");
146
- assert.equal(config.activeRoute?.backendKind, "codex-cli-auth");
147
- assert.equal(config.migrationNotice?.revertedProviderId, "openai");
148
- });
149
-
150
- test("serializes and persists provider workspace defaults", () => {
151
- const tempRoot = mkdtempSync(join(tmpdir(), "codexa-provider-config-"));
152
- try {
153
- const config = setProviderWorkspaceDefault({}, "anthropic");
154
- saveProviderWorkspaceConfig(tempRoot, config);
155
-
156
- assert.equal(getProviderWorkspaceConfigFile(tempRoot), join(tempRoot, ".codexa", "providers.json"));
157
- assert.deepEqual(loadProviderWorkspaceConfig(tempRoot), {
158
- workspaceDefaultProviderId: "anthropic",
159
- });
160
- assert.deepEqual(serializeProviderWorkspaceConfig(config), {
161
- workspaceDefaultProviderId: "anthropic",
162
- });
163
- } finally {
164
- rmSync(tempRoot, { recursive: true, force: true });
165
- }
166
- });
167
-
168
- test("loaded workspace default is applied to a fresh provider registry", () => {
169
- const tempRoot = mkdtempSync(join(tmpdir(), "codexa-provider-restart-"));
170
- try {
171
- saveProviderWorkspaceConfig(tempRoot, setProviderWorkspaceDefault({}, "google"));
172
-
173
- const loadedConfig = loadProviderWorkspaceConfig(tempRoot);
174
- const providers = buildProviderRegistry({
175
- activeModel: "gpt-5.4",
176
- workspaceConfig: loadedConfig,
177
- });
178
-
179
- assert.equal(providers.find((provider) => provider.id === "google")?.isDefault, true);
180
- assert.equal(providers.find((provider) => provider.id === "openai")?.isDefault, false);
181
- } finally {
182
- rmSync(tempRoot, { recursive: true, force: true });
183
- }
184
- });
185
-
186
- test("workspace provider config reload preserves default and active route separately", () => {
187
- const tempRoot = mkdtempSync(join(tmpdir(), "codexa-provider-route-"));
188
- try {
189
- saveProviderWorkspaceConfig(tempRoot, {
190
- workspaceDefaultProviderId: "anthropic",
191
- activeRoute: {
192
- providerId: "openai",
193
- modelId: "gpt-5.5",
194
- backendKind: "codex-cli-auth",
195
- reasoning: "high",
196
- },
197
- });
198
-
199
- assert.deepEqual(loadProviderWorkspaceConfig(tempRoot), {
200
- workspaceDefaultProviderId: "anthropic",
201
- activeRoute: {
202
- providerId: "openai",
203
- modelId: "gpt-5.5",
204
- backendKind: "codex-cli-auth",
205
- reasoning: "high",
206
- },
207
- });
208
- } finally {
209
- rmSync(tempRoot, { recursive: true, force: true });
210
- }
211
- });
212
-
213
- test("active Anthropic route persists without secrets", () => {
214
- const tempRoot = mkdtempSync(join(tmpdir(), "codexa-provider-anthropic-route-"));
215
- const original = process.env.ANTHROPIC_API_KEY;
216
-
217
- try {
218
- process.env.ANTHROPIC_API_KEY = "secret-test-key";
219
- saveProviderWorkspaceConfig(tempRoot, {
220
- workspaceDefaultProviderId: "anthropic",
221
- activeRoute: {
222
- providerId: "anthropic",
223
- modelId: "claude-sonnet-4-20250514",
224
- backendKind: "claude-code-auth",
225
- reasoning: "high",
226
- },
227
- });
228
-
229
- const loaded = loadProviderWorkspaceConfig(tempRoot);
230
- assert.deepEqual(loaded, {
231
- workspaceDefaultProviderId: "anthropic",
232
- activeRoute: {
233
- providerId: "anthropic",
234
- modelId: "claude-sonnet-4-20250514",
235
- backendKind: "claude-code-auth",
236
- reasoning: "high",
237
- },
238
- });
239
- assert.doesNotMatch(JSON.stringify(serializeProviderWorkspaceConfig(loaded)), /secret-test-key/);
240
- } finally {
241
- if (original === undefined) {
242
- delete process.env.ANTHROPIC_API_KEY;
243
- } else {
244
- process.env.ANTHROPIC_API_KEY = original;
245
- }
246
- rmSync(tempRoot, { recursive: true, force: true });
247
- }
248
- });
249
-
250
- test("setProviderActiveRoute rejects unconfigured Gemini routes", () => {
251
- withGeminiEnv({}, () => {
252
- const config = setProviderActiveRoute({
253
- activeRoute: {
254
- providerId: "openai",
255
- modelId: "gpt-5.5",
256
- backendKind: "codex-cli-auth",
257
- reasoning: "high",
258
- },
259
- }, {
260
- providerId: "google",
261
- modelId: "gemini-2.5-flash",
262
- backendKind: "gemini-cli-auth",
263
- reasoning: "high",
264
- });
265
-
266
- assert.deepEqual(config.activeRoute, {
267
- providerId: "openai",
268
- modelId: "gpt-5.5",
269
- backendKind: "codex-cli-auth",
270
- reasoning: "high",
271
- });
272
- });
273
- });
274
-
275
- test("setProviderActiveRoute persists Gemini routes when GEMINI_API_KEY is configured", () => {
276
- withGeminiEnv({ GEMINI_API_KEY: "test-gemini-key" }, () => {
277
- const config = setProviderActiveRoute({}, {
278
- providerId: "google",
279
- modelId: "gemini-2.5-flash",
280
- backendKind: "gemini-api-key",
281
- reasoning: "high",
282
- });
283
-
284
- assert.deepEqual(config.activeRoute, {
285
- providerId: "google",
286
- modelId: "gemini-2.5-flash",
287
- backendKind: "gemini-api-key",
288
- reasoning: "high",
289
- });
290
- assert.doesNotMatch(JSON.stringify(serializeProviderWorkspaceConfig(config)), /test-gemini-key/);
291
- });
292
- });
293
-
294
- // ---------------------------------------------------------------------------
295
- // setProviderDefaultModel
296
- // ---------------------------------------------------------------------------
297
-
298
- test("setProviderDefaultModel saves model without overwriting other provider fields", () => {
299
- const initial = {
300
- providers: {
301
- anthropic: { currentModel: "opus", currentReasoning: "high", enabled: true },
302
- google: { currentModel: "gemini-2.5-pro" },
303
- },
304
- };
305
- const updated = setProviderDefaultModel(initial, "anthropic", "sonnet");
306
- assert.equal(updated.providers?.["anthropic"]?.currentModel, "sonnet");
307
- assert.equal(updated.providers?.["anthropic"]?.currentReasoning, "high", "reasoning must be preserved");
308
- assert.equal(updated.providers?.["anthropic"]?.enabled, true, "enabled flag must be preserved");
309
- assert.equal(updated.providers?.["google"]?.currentModel, "gemini-2.5-pro", "other provider unchanged");
310
- });
311
-
312
- test("setProviderDefaultModel creates providers entry when none exists", () => {
313
- const config = setProviderDefaultModel({}, "anthropic", "haiku");
314
- assert.equal(config.providers?.["anthropic"]?.currentModel, "haiku");
315
- });
316
-
317
- test("setProviderDefaultModel round-trips through serialize/parse", () => {
318
- const config = setProviderDefaultModel({}, "anthropic", "sonnet");
319
- const serialized = serializeProviderWorkspaceConfig(config);
320
- const reparsed = parseProviderWorkspaceConfig(serialized);
321
- assert.equal(reparsed.providers?.["anthropic"]?.currentModel, "sonnet");
322
- });
323
-
324
- test("setProviderDefaultReasoning saves provider-scoped reasoning without touching other providers", () => {
325
- const initial = {
326
- providers: {
327
- openai: { currentReasoning: "high" },
328
- anthropic: { currentModel: "sonnet", currentReasoning: "medium" },
329
- },
330
- };
331
- const updated = setProviderDefaultReasoning(initial, "anthropic", "max");
332
- assert.equal(updated.providers?.anthropic?.currentModel, "sonnet");
333
- assert.equal(updated.providers?.anthropic?.currentReasoning, "max");
334
- assert.equal(updated.providers?.openai?.currentReasoning, "high");
335
- });
336
-
337
- test("provider default reasoning round-trips through serialize/parse", () => {
338
- const config = setProviderDefaultReasoning(
339
- setProviderDefaultModel({}, "anthropic", "sonnet"),
340
- "anthropic",
341
- "xhigh",
342
- );
343
- const serialized = serializeProviderWorkspaceConfig(config);
344
- assert.deepEqual(serialized.providers, {
345
- anthropic: {
346
- current_model: "sonnet",
347
- current_reasoning: "xhigh",
348
- },
349
- });
350
- const reparsed = parseProviderWorkspaceConfig(serialized);
351
- assert.equal(reparsed.providers?.anthropic?.currentModel, "sonnet");
352
- assert.equal(reparsed.providers?.anthropic?.currentReasoning, "xhigh");
353
- });
354
-
355
- test("Anthropic claudeCommandPath round-trips through serialize/parse", () => {
356
- const config = parseProviderWorkspaceConfig({
357
- providers: {
358
- anthropic: {
359
- current_model: "sonnet",
360
- claude_command_path: "C:\\Users\\Example\\.local\\bin\\claude.exe",
361
- },
362
- },
363
- });
364
-
365
- assert.equal(config.providers?.anthropic?.claudeCommandPath, "C:\\Users\\Example\\.local\\bin\\claude.exe");
366
- const serialized = serializeProviderWorkspaceConfig(config);
367
- assert.deepEqual(serialized.providers, {
368
- anthropic: {
369
- current_model: "sonnet",
370
- claude_command_path: "C:\\Users\\Example\\.local\\bin\\claude.exe",
371
- },
372
- });
373
- });
374
-
375
- test("Gemini geminiCommandPath round-trips through serialize/parse", () => {
376
- const config = parseProviderWorkspaceConfig({
377
- providers: {
378
- google: {
379
- current_model: "gemini-2.5-flash",
380
- gemini_command_path: "C:\\Users\\Example\\AppData\\Roaming\\npm\\gemini.cmd",
381
- },
382
- },
383
- });
384
-
385
- assert.equal(config.providers?.google?.geminiCommandPath, "C:\\Users\\Example\\AppData\\Roaming\\npm\\gemini.cmd");
386
- const serialized = serializeProviderWorkspaceConfig(config);
387
- assert.deepEqual(serialized.providers, {
388
- google: {
389
- current_model: "gemini-2.5-flash",
390
- gemini_command_path: "C:\\Users\\Example\\AppData\\Roaming\\npm\\gemini.cmd",
391
- },
392
- });
393
- });
394
-
395
- test("Codex codexCommandPath round-trips through serialize/parse", () => {
396
- const config = parseProviderWorkspaceConfig({
397
- providers: {
398
- openai: {
399
- current_model: "gpt-5.4",
400
- codex_command_path: "C:\\Users\\Example\\AppData\\Roaming\\npm\\codex.cmd",
401
- },
402
- },
403
- });
404
-
405
- assert.equal(config.providers?.openai?.codexCommandPath, "C:\\Users\\Example\\AppData\\Roaming\\npm\\codex.cmd");
406
- const serialized = serializeProviderWorkspaceConfig(config);
407
- assert.deepEqual(serialized.providers, {
408
- openai: {
409
- current_model: "gpt-5.4",
410
- codex_command_path: "C:\\Users\\Example\\AppData\\Roaming\\npm\\codex.cmd",
411
- },
412
- });
413
- });
414
-
415
- test("Local OpenAI-compatible config round-trips through serialize/parse", () => {
416
- const config = parseProviderWorkspaceConfig({
417
- providers: {
418
- local: {
419
- enabled: true,
420
- type: "openai-compatible",
421
- base_url: "http://localhost:1234/v1",
422
- api_key: "lm-studio",
423
- pinned_model: "qwen/qwen3.6-27b",
424
- default_model: "google/gemma-4-26b-a4b",
425
- models: {
426
- "google/gemma-4-26b-a4b": {
427
- contextLength: 8192,
428
- },
429
- },
430
- },
431
- },
432
- });
433
-
434
- assert.deepEqual(config.providers?.local, {
435
- enabled: true,
436
- type: "openai-compatible",
437
- baseUrl: "http://localhost:1234/v1",
438
- apiKey: "lm-studio",
439
- pinnedModel: "qwen/qwen3.6-27b",
440
- defaultModel: "google/gemma-4-26b-a4b",
441
- models: {
442
- "google/gemma-4-26b-a4b": {
443
- contextLength: 8192,
444
- },
445
- },
446
- });
447
- assert.deepEqual(serializeProviderWorkspaceConfig(config).providers, {
448
- local: {
449
- enabled: true,
450
- type: "openai-compatible",
451
- base_url: "http://localhost:1234/v1",
452
- api_key: "lm-studio",
453
- pinned_model: "qwen/qwen3.6-27b",
454
- default_model: "google/gemma-4-26b-a4b",
455
- models: {
456
- "google/gemma-4-26b-a4b": {
457
- contextLength: 8192,
458
- },
459
- },
460
- },
461
- });
462
- });
463
-
464
- test("provider model context length config rejects invalid values", () => {
465
- const config = parseProviderWorkspaceConfig({
466
- providers: {
467
- local: {
468
- models: {
469
- zero: { contextLength: 0 },
470
- negative: { contextLength: -1 },
471
- decimal: { contextLength: 8192.5 },
472
- text: { contextLength: "8192" },
473
- valid: { context_length: 32768 },
474
- },
475
- },
476
- },
477
- });
478
-
479
- assert.deepEqual(config.providers?.local?.models, {
480
- valid: {
481
- contextLength: 32768,
482
- },
483
- });
484
- });
485
-
486
- test("setProviderActiveRoute persists Local routes after endpoint discovery", async () => {
487
- resetLocalProviderStateForTests();
488
- try {
489
- await checkLocalProvider({
490
- fetchImpl: (async (input) => {
491
- if (String(input).includes("/api/v0/")) {
492
- return new Response(null, { status: 404 });
493
- }
494
- return new Response(JSON.stringify({
495
- data: [{ id: "google/gemma-4-26b-a4b" }],
496
- }), { status: 200 });
497
- }) as typeof fetch,
498
- });
499
- const config = setProviderActiveRoute({}, {
500
- providerId: "local",
501
- modelId: "google/gemma-4-26b-a4b",
502
- backendKind: "local-openai-compatible",
503
- });
504
-
505
- assert.deepEqual(config.activeRoute, {
506
- providerId: "local",
507
- modelId: "google/gemma-4-26b-a4b",
508
- backendKind: "local-openai-compatible",
509
- });
510
- } finally {
511
- resetLocalProviderStateForTests();
512
- }
513
- });
514
-
515
- test("Gemini workspace config normalizes legacy flash model IDs to preview", () => {
516
- const config = parseProviderWorkspaceConfig({
517
- activeRoute: {
518
- providerId: "google",
519
- modelId: "gemini-3-flash",
520
- backendKind: "gemini-cli-auth",
521
- modelSelection: {
522
- kind: "manual",
523
- modelId: "gemini-3-flash",
524
- },
525
- },
526
- providers: {
527
- google: {
528
- current_model: "gemini-3-flash",
529
- },
530
- },
531
- });
532
-
533
- assert.equal(config.activeRoute?.modelId, "gemini-3-flash-preview");
534
- assert.deepEqual(config.activeRoute?.modelSelection, {
535
- kind: "manual",
536
- modelId: "gemini-3-flash-preview",
537
- });
538
- assert.equal(config.providers?.google?.currentModel, "gemini-3-flash-preview");
539
- });
540
-
541
- test("Local model capability fields round-trip through serialize/parse", () => {
542
- const config = parseProviderWorkspaceConfig({
543
- providers: {
544
- local: {
545
- enabled: true,
546
- type: "openai-compatible",
547
- base_url: "http://localhost:1234/v1",
548
- api_key: "lm-studio",
549
- default_model: "test-model",
550
- models: {
551
- "test-model": {
552
- contextLength: 8192,
553
- supportsToolCalls: false,
554
- supportsStreaming: true,
555
- supportsSystemPrompt: true,
556
- maxOutputTokens: 4096,
557
- },
558
- },
559
- },
560
- },
561
- });
562
-
563
- assert.deepEqual(config.providers?.local?.models?.["test-model"], {
564
- contextLength: 8192,
565
- supportsToolCalls: false,
566
- supportsStreaming: true,
567
- supportsSystemPrompt: true,
568
- maxOutputTokens: 4096,
569
- });
570
-
571
- const serialized = serializeProviderWorkspaceConfig(config);
572
- const reparsed = parseProviderWorkspaceConfig(serialized);
573
- assert.deepEqual(reparsed.providers?.local?.models?.["test-model"], {
574
- contextLength: 8192,
575
- supportsToolCalls: false,
576
- supportsStreaming: true,
577
- supportsSystemPrompt: true,
578
- maxOutputTokens: 4096,
579
- });
580
- });
581
-
582
- test("Local model capability boolean string values are rejected", () => {
583
- const config = parseProviderWorkspaceConfig({
584
- providers: {
585
- local: {
586
- models: {
587
- "bad-model": {
588
- supportsStreaming: "true",
589
- supportsToolCalls: 1,
590
- supportsSystemPrompt: null,
591
- },
592
- },
593
- },
594
- },
595
- });
596
-
597
- // None of the invalid values should create a model entry
598
- assert.equal(config.providers?.local?.models?.["bad-model"], undefined);
599
- });
600
-
601
- test("Local model maxOutputTokens: 4096 round-trips; invalid values are rejected", () => {
602
- const config = parseProviderWorkspaceConfig({
603
- providers: {
604
- local: {
605
- models: {
606
- valid: { max_output_tokens: 4096 },
607
- zero: { maxOutputTokens: 0 },
608
- negative: { max_output_tokens: -512 },
609
- decimal: { maxOutputTokens: 1024.5 },
610
- },
611
- },
612
- },
613
- });
614
-
615
- assert.deepEqual(config.providers?.local?.models?.valid, { maxOutputTokens: 4096 });
616
- assert.equal(config.providers?.local?.models?.zero, undefined);
617
- assert.equal(config.providers?.local?.models?.negative, undefined);
618
- assert.equal(config.providers?.local?.models?.decimal, undefined);
619
- });
620
-
621
- test("setProviderActiveRoute persists Gemini routes when GOOGLE_API_KEY is configured", () => {
622
- withGeminiEnv({ GOOGLE_API_KEY: "test-google-key" }, () => {
623
- const config = setProviderActiveRoute({}, {
624
- providerId: "google",
625
- modelId: "gemini-2.5-flash",
626
- backendKind: "gemini-api-key",
627
- reasoning: "high",
628
- });
629
-
630
- assert.deepEqual(config.activeRoute, {
631
- providerId: "google",
632
- modelId: "gemini-2.5-flash",
633
- backendKind: "gemini-api-key",
634
- reasoning: "high",
635
- });
636
- assert.doesNotMatch(JSON.stringify(serializeProviderWorkspaceConfig(config)), /test-google-key/);
637
- });
638
- });