@golba98/codexa 1.0.1 → 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.
- package/README.md +391 -94
- package/package.json +14 -8
- package/src/app.tsx +196 -63
- package/src/commands/handler.ts +9 -4
- package/src/config/buildInfo.ts +3 -0
- package/src/config/launchArgs.ts +10 -0
- package/src/config/layeredConfig.ts +0 -0
- package/src/config/persistence.ts +51 -0
- package/src/config/runtimeConfig.ts +4 -0
- package/src/config/settings.ts +6 -13
- package/src/config/toml-serialize.ts +0 -0
- package/src/config/trustStore.ts +0 -0
- package/src/config/updateCheckCache.ts +63 -0
- package/src/core/attachments.ts +0 -0
- package/src/core/auth/codexAuth.ts +0 -0
- package/src/core/channel.ts +23 -0
- package/src/core/cleanupFastFail.ts +0 -0
- package/src/core/clipboard.ts +0 -0
- package/src/core/codex.ts +0 -0
- package/src/core/codexExecArgs.ts +0 -0
- package/src/core/codexLaunch.ts +0 -0
- package/src/core/codexPrompt.ts +0 -0
- package/src/core/executables/claudeExecutable.ts +0 -0
- package/src/core/executables/codexExecutable.ts +1 -0
- package/src/core/executables/executableResolver.ts +61 -43
- package/src/core/executables/geminiExecutable.ts +0 -0
- package/src/core/githubDiagnostics.ts +0 -0
- package/src/core/hollowResponseFormat.ts +0 -0
- package/src/core/inputDebug.ts +0 -0
- package/src/core/launchContext.ts +33 -33
- package/src/core/models/codexCapabilities.ts +0 -0
- package/src/core/models/codexModelCapabilities.ts +0 -0
- package/src/core/models/modelSpecs.ts +0 -0
- package/src/core/perf/profiler.ts +0 -0
- package/src/core/perf/renderDebug.ts +0 -0
- package/src/core/planStorage.ts +0 -0
- package/src/core/process/CommandRunner.ts +0 -0
- package/src/core/process/processValidation.ts +9 -5
- package/src/core/projectInstructions.ts +0 -0
- package/src/core/providerLauncher/launcher.ts +59 -42
- package/src/core/providerLauncher/registry.ts +0 -0
- package/src/core/providerLauncher/types.ts +0 -0
- package/src/core/providerLauncher/workspaceConfig.ts +0 -0
- package/src/core/providerRuntime/anthropic.ts +0 -0
- package/src/core/providerRuntime/capabilityProfile.ts +0 -0
- package/src/core/providerRuntime/claudeCodeDiscovery.ts +0 -0
- package/src/core/providerRuntime/contextMetadata.ts +0 -0
- package/src/core/providerRuntime/gemini.ts +0 -0
- package/src/core/providerRuntime/lmstudio.ts +0 -0
- package/src/core/providerRuntime/local.ts +0 -0
- package/src/core/providerRuntime/models.ts +0 -0
- package/src/core/providerRuntime/reasoning.ts +0 -0
- package/src/core/providerRuntime/registry.ts +0 -0
- package/src/core/providerRuntime/types.ts +0 -0
- package/src/core/providers/codexJsonStream.ts +0 -0
- package/src/core/providers/codexSubprocess.ts +0 -0
- package/src/core/providers/codexTranscript.ts +0 -0
- package/src/core/providers/openaiNative.ts +0 -0
- package/src/core/providers/registry.ts +0 -0
- package/src/core/providers/types.ts +0 -0
- package/src/core/terminal/startupClear.ts +20 -0
- package/src/core/terminal/terminalCapabilities.ts +0 -0
- package/src/core/terminal/terminalControl.ts +0 -0
- package/src/core/terminal/terminalSanitize.ts +0 -0
- package/src/core/terminal/terminalSelection.ts +0 -0
- package/src/core/terminal/terminalTitle.ts +0 -0
- package/src/core/updateCheck.ts +188 -0
- package/src/core/workspaceActivity.ts +0 -0
- package/src/core/workspaceGuard.ts +0 -0
- package/src/core/workspaceRoot.ts +0 -0
- package/src/exec.ts +0 -0
- package/src/headless/execArgs.ts +1 -0
- package/src/headless/execRunner.ts +0 -0
- package/src/index.tsx +13 -9
- package/src/session/appSession.ts +0 -0
- package/src/session/chatLifecycle.ts +0 -0
- package/src/session/liveRenderScheduler.ts +0 -0
- package/src/session/planFlow.ts +0 -0
- package/src/session/planTranscript.ts +0 -0
- package/src/session/promptRunSchedule.ts +0 -0
- package/src/session/types.ts +2 -1
- package/src/test/runtimeTestUtils.ts +0 -0
- package/src/types/react-dom.d.ts +0 -0
- package/src/ui/ActionRequiredBlock.tsx +5 -5
- package/src/ui/ActivityBars.tsx +3 -3
- package/src/ui/ActivityIndicator.tsx +6 -6
- package/src/ui/AgentBlock.tsx +6 -6
- package/src/ui/AnimatedStatusText.tsx +1 -1
- package/src/ui/AppShell.tsx +13 -5
- package/src/ui/AttachmentImportPanel.tsx +8 -8
- package/src/ui/AuthPanel.tsx +20 -20
- package/src/ui/BackendPicker.tsx +0 -0
- package/src/ui/BottomComposer.tsx +117 -78
- package/src/ui/DashCard.tsx +3 -3
- package/src/ui/Markdown.tsx +17 -17
- package/src/ui/ModePicker.tsx +0 -0
- package/src/ui/ModelPicker.tsx +0 -0
- package/src/ui/ModelPickerScreen.tsx +10 -10
- package/src/ui/ModelReasoningPicker.tsx +14 -14
- package/src/ui/Panel.tsx +3 -3
- package/src/ui/PermissionsPanel.tsx +0 -0
- package/src/ui/PlanActionPicker.tsx +6 -6
- package/src/ui/PlanReviewPanel.tsx +8 -8
- package/src/ui/ProviderPicker.tsx +18 -18
- package/src/ui/ReasoningPicker.tsx +0 -0
- package/src/ui/RunFooter.tsx +3 -3
- package/src/ui/SelectionPanel.tsx +4 -4
- package/src/ui/SettingsPanel.tsx +8 -8
- package/src/ui/Spinner.tsx +1 -1
- package/src/ui/StaticIntroItem.tsx +0 -0
- package/src/ui/StaticTranscriptItem.tsx +0 -0
- package/src/ui/TextEntryPanel.tsx +10 -10
- package/src/ui/ThemePicker.tsx +0 -0
- package/src/ui/ThinkingBlock.tsx +8 -8
- package/src/ui/Timeline.tsx +21 -17
- package/src/ui/TopHeader.tsx +421 -257
- package/src/ui/TurnGroup.tsx +31 -31
- package/src/ui/UpdateAvailableCard.tsx +41 -0
- package/src/ui/UpdatePromptPanel.tsx +203 -0
- package/src/ui/busyStatusAnimation.ts +0 -0
- package/src/ui/commandNormalize.ts +0 -0
- package/src/ui/diffRenderer.ts +0 -0
- package/src/ui/focus.ts +3 -0
- package/src/ui/inputBuffer.ts +0 -0
- package/src/ui/layout.ts +1 -1
- package/src/ui/logoVariants.ts +107 -0
- package/src/ui/modeDisplay.ts +12 -12
- package/src/ui/outputPipeline.ts +0 -0
- package/src/ui/progressEntries.ts +0 -0
- package/src/ui/runActivityView.ts +0 -0
- package/src/ui/runtimeDisplay.ts +100 -0
- package/src/ui/slashCommands.ts +0 -0
- package/src/ui/terminalAnswerFormat.ts +0 -0
- package/src/ui/textLayout.ts +0 -0
- package/src/ui/theme.tsx +274 -395
- package/src/ui/themeFlow.ts +0 -0
- package/src/ui/timelineMeasure.ts +29 -19
- package/src/ui/useThrottledValue.ts +0 -0
- package/scripts/audit-codexa-capabilities.mjs +0 -466
- package/scripts/smoke-terminal-bench.mjs +0 -35
- package/src/appRenderStability.test.ts +0 -131
- package/src/commands/handler.test.ts +0 -643
- package/src/config/launchArgs.test.ts +0 -158
- package/src/config/layeredConfig.test.ts +0 -143
- package/src/config/persistence.test.ts +0 -110
- package/src/config/runtimeConfig.test.ts +0 -218
- package/src/config/settings.test.ts +0 -155
- package/src/config/trustStore.test.ts +0 -29
- package/src/core/attachments.test.ts +0 -155
- package/src/core/auth/codexAuth.test.ts +0 -68
- package/src/core/cleanupFastFail.test.ts +0 -76
- package/src/core/codexExecArgs.test.ts +0 -195
- package/src/core/codexLaunch.test.ts +0 -205
- package/src/core/codexPrompt.test.ts +0 -252
- package/src/core/executables/codexExecutable.test.ts +0 -212
- package/src/core/executables/executableResolver.test.ts +0 -129
- package/src/core/executables/geminiExecutable.test.ts +0 -116
- package/src/core/executables/pathSanityScan.test.ts +0 -47
- package/src/core/githubDiagnostics.test.ts +0 -92
- package/src/core/hollowResponseFormat.test.ts +0 -58
- package/src/core/launchContext.test.ts +0 -157
- package/src/core/models/codexCapabilities.test.ts +0 -45
- package/src/core/models/codexModelCapabilities.test.ts +0 -246
- package/src/core/models/modelSpecs.test.ts +0 -283
- package/src/core/perf/renderDebug.test.ts +0 -230
- package/src/core/planStorage.test.ts +0 -143
- package/src/core/process/CommandRunner.test.ts +0 -105
- package/src/core/projectInstructions.test.ts +0 -50
- package/src/core/providerLauncher/launcher.test.ts +0 -238
- package/src/core/providerLauncher/registry.test.ts +0 -324
- package/src/core/providerLauncher/workspaceConfig.test.ts +0 -638
- package/src/core/providerRuntime/anthropic.test.ts +0 -1120
- package/src/core/providerRuntime/capabilityProfile.test.ts +0 -311
- package/src/core/providerRuntime/contextMetadata.test.ts +0 -468
- package/src/core/providerRuntime/gemini.test.ts +0 -437
- package/src/core/providerRuntime/lmstudio.test.ts +0 -168
- package/src/core/providerRuntime/local.test.ts +0 -787
- package/src/core/providerRuntime/registry.test.ts +0 -233
- package/src/core/providers/codexJsonStream.test.ts +0 -148
- package/src/core/providers/codexSubprocess.test.ts +0 -68
- package/src/core/providers/codexTranscript.test.ts +0 -284
- package/src/core/terminal/terminalCapabilities.test.ts +0 -93
- package/src/core/terminal/terminalControl.test.ts +0 -75
- package/src/core/terminal/terminalSanitize.test.ts +0 -22
- package/src/core/terminal/terminalSelection.test.ts +0 -42
- package/src/core/terminal/terminalTitle.test.ts +0 -328
- package/src/core/workspaceActivity.test.ts +0 -163
- package/src/core/workspaceGuard.test.ts +0 -151
- package/src/core/workspaceRoot.test.ts +0 -23
- package/src/exec.test.ts +0 -13
- package/src/headless/execArgs.test.ts +0 -147
- package/src/headless/execRunner.test.ts +0 -434
- package/src/index.test.tsx +0 -618
- package/src/session/appSession.test.ts +0 -897
- package/src/session/chatLifecycle.test.ts +0 -64
- package/src/session/liveRenderScheduler.test.ts +0 -201
- package/src/session/planFlow.test.ts +0 -103
- package/src/session/planTranscript.test.ts +0 -65
- package/src/session/promptRunSchedule.test.ts +0 -36
- package/src/ui/ActivityIndicator.test.tsx +0 -58
- package/src/ui/AgentBlock.test.ts +0 -6
- package/src/ui/AnimatedStatusText.test.ts +0 -16
- package/src/ui/AppShell.test.tsx +0 -1739
- package/src/ui/AttachmentImportPanel.test.tsx +0 -204
- package/src/ui/BottomComposer.test.ts +0 -674
- package/src/ui/CodexLogo.tsx +0 -55
- package/src/ui/Markdown.test.ts +0 -157
- package/src/ui/ModelPickerProviderScope.test.tsx +0 -411
- package/src/ui/ModelPickerScreen.test.tsx +0 -99
- package/src/ui/ModelPickerState.test.tsx +0 -151
- package/src/ui/ModelReasoningPicker.test.tsx +0 -447
- package/src/ui/PlanReviewPanel.test.tsx +0 -267
- package/src/ui/PromptCardBorder.test.tsx +0 -161
- package/src/ui/ProviderPicker.test.tsx +0 -289
- package/src/ui/ProviderShortcut.test.tsx +0 -143
- package/src/ui/SettingsPanel.test.tsx +0 -233
- package/src/ui/Timeline.test.ts +0 -2067
- package/src/ui/TimelineNavigation.test.tsx +0 -201
- package/src/ui/TopHeader.test.tsx +0 -239
- package/src/ui/TurnGroup.test.tsx +0 -365
- package/src/ui/busyStatusAnimation.test.ts +0 -30
- package/src/ui/commandNormalize.test.ts +0 -142
- package/src/ui/diffRenderer.test.ts +0 -102
- package/src/ui/focusFlow.test.tsx +0 -1098
- package/src/ui/inputBuffer.test.ts +0 -151
- package/src/ui/layout.test.ts +0 -145
- package/src/ui/modeDisplay.test.ts +0 -42
- package/src/ui/runActivityView.test.ts +0 -89
- package/src/ui/runLifecycleView.test.tsx +0 -237
- package/src/ui/statusRenderIsolation.test.tsx +0 -654
- package/src/ui/terminalAnswerFormat.test.ts +0 -19
- package/src/ui/textLayout.test.ts +0 -18
- package/src/ui/themeFlow.test.ts +0 -53
- package/src/ui/timelineMeasureCache.test.ts +0 -986
|
@@ -1,238 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert/strict";
|
|
2
|
-
import { EventEmitter } from "events";
|
|
3
|
-
import test from "node:test";
|
|
4
|
-
import { buildProviderLaunchSpec, launchProviderCli } from "./launcher.js";
|
|
5
|
-
import type { ProviderConfig } from "./types.js";
|
|
6
|
-
|
|
7
|
-
function makeProvider(overrides: Partial<ProviderConfig> = {}): ProviderConfig {
|
|
8
|
-
return {
|
|
9
|
-
id: "openai",
|
|
10
|
-
displayName: "OpenAI",
|
|
11
|
-
currentModel: "gpt-5.4",
|
|
12
|
-
backendType: "codex-cli-auth",
|
|
13
|
-
routeMode: "in-codexa",
|
|
14
|
-
enabled: true,
|
|
15
|
-
statusLabel: "Enabled",
|
|
16
|
-
launchCommand: { executable: "codex", args: [] },
|
|
17
|
-
isDefault: true,
|
|
18
|
-
isActiveRoute: true,
|
|
19
|
-
routeUnavailableReason: null,
|
|
20
|
-
...overrides,
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
test("builds launch specs for enabled providers", () => {
|
|
25
|
-
const spec = buildProviderLaunchSpec(makeProvider({
|
|
26
|
-
launchCommand: { executable: "claude", args: ["--resume"] },
|
|
27
|
-
}), "C:\\Workspace");
|
|
28
|
-
|
|
29
|
-
assert.equal("status" in spec, false);
|
|
30
|
-
if ("status" in spec) return;
|
|
31
|
-
assert.equal(spec.executable, "claude");
|
|
32
|
-
assert.deepEqual(spec.args, ["--resume"]);
|
|
33
|
-
assert.equal(spec.cwd, "C:\\Workspace");
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
test("disabled providers fail before spawning", () => {
|
|
37
|
-
const result = buildProviderLaunchSpec(makeProvider({
|
|
38
|
-
id: "local",
|
|
39
|
-
displayName: "Local",
|
|
40
|
-
backendType: "local-openai-compatible",
|
|
41
|
-
enabled: false,
|
|
42
|
-
statusLabel: "Disabled",
|
|
43
|
-
launchCommand: null,
|
|
44
|
-
isDefault: false,
|
|
45
|
-
}), "C:\\Workspace");
|
|
46
|
-
|
|
47
|
-
assert.equal("status" in result, true);
|
|
48
|
-
assert.equal("status" in result ? result.status : "", "disabled");
|
|
49
|
-
assert.match("status" in result ? result.message : "", /Configure a command/i);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
test("unsafe configured launch commands fail before spawning", () => {
|
|
53
|
-
const result = buildProviderLaunchSpec(makeProvider({
|
|
54
|
-
launchCommand: { executable: "codex & calc", args: [] },
|
|
55
|
-
}), "C:\\Workspace");
|
|
56
|
-
|
|
57
|
-
assert.equal("status" in result, true);
|
|
58
|
-
assert.equal("status" in result ? result.status : "", "spawn-error");
|
|
59
|
-
assert.match("status" in result ? result.message : "", /unsafe launch command/i);
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
test("missing command spawn errors become friendly launch results", async () => {
|
|
63
|
-
const child = new EventEmitter();
|
|
64
|
-
const spawnImpl = (() => {
|
|
65
|
-
queueMicrotask(() => {
|
|
66
|
-
const error = new Error("not found") as NodeJS.ErrnoException;
|
|
67
|
-
error.code = "ENOENT";
|
|
68
|
-
child.emit("error", error);
|
|
69
|
-
});
|
|
70
|
-
return child;
|
|
71
|
-
}) as unknown as typeof import("child_process").spawn;
|
|
72
|
-
|
|
73
|
-
const result = await launchProviderCli(makeProvider(), {
|
|
74
|
-
cwd: "C:\\Workspace",
|
|
75
|
-
commandExists: () => true,
|
|
76
|
-
spawnImpl,
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
assert.equal(result.status, "missing-command");
|
|
80
|
-
assert.match(result.message, /codex.*PATH/i);
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
test("missing command preflight fails before suspending raw mode", async () => {
|
|
84
|
-
const rawModes: boolean[] = [];
|
|
85
|
-
let didSpawn = false;
|
|
86
|
-
|
|
87
|
-
const result = await launchProviderCli(makeProvider(), {
|
|
88
|
-
cwd: "C:\\Workspace",
|
|
89
|
-
stdin: {
|
|
90
|
-
isRaw: true,
|
|
91
|
-
setRawMode(enabled) {
|
|
92
|
-
rawModes.push(enabled);
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
commandExists: () => false,
|
|
96
|
-
spawnImpl: (() => {
|
|
97
|
-
didSpawn = true;
|
|
98
|
-
return new EventEmitter();
|
|
99
|
-
}) as unknown as typeof import("child_process").spawn,
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
assert.equal(result.status, "missing-command");
|
|
103
|
-
assert.equal(didSpawn, false);
|
|
104
|
-
assert.deepEqual(rawModes, []);
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
test("launch restores raw mode after child exits", async () => {
|
|
108
|
-
const child = new EventEmitter();
|
|
109
|
-
const rawModes: boolean[] = [];
|
|
110
|
-
const spawnImpl = (() => {
|
|
111
|
-
queueMicrotask(() => child.emit("close", 0, null));
|
|
112
|
-
return child;
|
|
113
|
-
}) as unknown as typeof import("child_process").spawn;
|
|
114
|
-
|
|
115
|
-
const result = await launchProviderCli(makeProvider(), {
|
|
116
|
-
cwd: "C:\\Workspace",
|
|
117
|
-
stdin: {
|
|
118
|
-
isRaw: true,
|
|
119
|
-
setRawMode(enabled) {
|
|
120
|
-
rawModes.push(enabled);
|
|
121
|
-
},
|
|
122
|
-
},
|
|
123
|
-
commandExists: () => true,
|
|
124
|
-
spawnImpl,
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
assert.equal(result.status, "completed");
|
|
128
|
-
assert.deepEqual(rawModes, [false, true]);
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
test("launch passes the workspace root as the child cwd", async () => {
|
|
132
|
-
const child = new EventEmitter();
|
|
133
|
-
let observedCwd = "";
|
|
134
|
-
let observedShell: boolean | undefined = undefined;
|
|
135
|
-
const spawnImpl = ((_executable: string, _args: string[], options: { cwd?: string; shell?: boolean }) => {
|
|
136
|
-
observedCwd = options.cwd ?? "";
|
|
137
|
-
observedShell = options.shell;
|
|
138
|
-
queueMicrotask(() => child.emit("close", 0, null));
|
|
139
|
-
return child;
|
|
140
|
-
}) as unknown as typeof import("child_process").spawn;
|
|
141
|
-
|
|
142
|
-
const result = await launchProviderCli(makeProvider(), {
|
|
143
|
-
cwd: "C:\\Workspace\\Project",
|
|
144
|
-
commandExists: () => true,
|
|
145
|
-
spawnImpl,
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
assert.equal(result.status, "completed");
|
|
149
|
-
assert.equal(observedCwd, "C:\\Workspace\\Project");
|
|
150
|
-
assert.equal(observedShell, false);
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
test("launch wraps Windows batch commands without enabling shell mode", async () => {
|
|
154
|
-
if (process.platform !== "win32") return;
|
|
155
|
-
|
|
156
|
-
const child = new EventEmitter();
|
|
157
|
-
let observedExecutable = "";
|
|
158
|
-
let observedArgs: string[] = [];
|
|
159
|
-
let observedShell: boolean | undefined = undefined;
|
|
160
|
-
const spawnImpl = ((executable: string, args: string[], options: { shell?: boolean }) => {
|
|
161
|
-
observedExecutable = executable;
|
|
162
|
-
observedArgs = args;
|
|
163
|
-
observedShell = options.shell;
|
|
164
|
-
queueMicrotask(() => child.emit("close", 0, null));
|
|
165
|
-
return child;
|
|
166
|
-
}) as unknown as typeof import("child_process").spawn;
|
|
167
|
-
|
|
168
|
-
const result = await launchProviderCli(makeProvider({
|
|
169
|
-
launchCommand: { executable: "codex.cmd", args: ["--resume"] },
|
|
170
|
-
}), {
|
|
171
|
-
cwd: "C:\\Workspace",
|
|
172
|
-
commandExists: () => true,
|
|
173
|
-
spawnImpl,
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
assert.equal(result.status, "completed");
|
|
177
|
-
assert.equal(observedExecutable, "cmd.exe");
|
|
178
|
-
assert.deepEqual(observedArgs, ["/d", "/s", "/c", "call", "codex.cmd", "--resume"]);
|
|
179
|
-
assert.equal(observedShell, false);
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
test("launch runs suspend and resume hooks around raw mode changes", async () => {
|
|
183
|
-
const child = new EventEmitter();
|
|
184
|
-
const events: string[] = [];
|
|
185
|
-
const spawnImpl = (() => {
|
|
186
|
-
events.push("spawn");
|
|
187
|
-
queueMicrotask(() => child.emit("close", 0, null));
|
|
188
|
-
return child;
|
|
189
|
-
}) as unknown as typeof import("child_process").spawn;
|
|
190
|
-
|
|
191
|
-
const result = await launchProviderCli(makeProvider(), {
|
|
192
|
-
cwd: "C:\\Workspace",
|
|
193
|
-
stdin: {
|
|
194
|
-
isRaw: true,
|
|
195
|
-
setRawMode(enabled) {
|
|
196
|
-
events.push(enabled ? "raw-on" : "raw-off");
|
|
197
|
-
},
|
|
198
|
-
},
|
|
199
|
-
beforeLaunch: () => events.push("before"),
|
|
200
|
-
afterLaunch: () => events.push("after"),
|
|
201
|
-
commandExists: () => true,
|
|
202
|
-
spawnImpl,
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
assert.equal(result.status, "completed");
|
|
206
|
-
assert.deepEqual(events, ["before", "raw-off", "spawn", "raw-on", "after"]);
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
test("launch restores terminal state after child spawn error", async () => {
|
|
210
|
-
const child = new EventEmitter();
|
|
211
|
-
const events: string[] = [];
|
|
212
|
-
const spawnImpl = (() => {
|
|
213
|
-
events.push("spawn");
|
|
214
|
-
queueMicrotask(() => {
|
|
215
|
-
const error = new Error("blocked") as NodeJS.ErrnoException;
|
|
216
|
-
error.code = "EPERM";
|
|
217
|
-
child.emit("error", error);
|
|
218
|
-
});
|
|
219
|
-
return child;
|
|
220
|
-
}) as unknown as typeof import("child_process").spawn;
|
|
221
|
-
|
|
222
|
-
const result = await launchProviderCli(makeProvider(), {
|
|
223
|
-
cwd: "C:\\Workspace",
|
|
224
|
-
stdin: {
|
|
225
|
-
isRaw: true,
|
|
226
|
-
setRawMode(enabled) {
|
|
227
|
-
events.push(enabled ? "raw-on" : "raw-off");
|
|
228
|
-
},
|
|
229
|
-
},
|
|
230
|
-
beforeLaunch: () => events.push("before"),
|
|
231
|
-
afterLaunch: () => events.push("after"),
|
|
232
|
-
commandExists: () => true,
|
|
233
|
-
spawnImpl,
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
assert.equal(result.status, "spawn-error");
|
|
237
|
-
assert.deepEqual(events, ["before", "raw-off", "spawn", "raw-on", "after"]);
|
|
238
|
-
});
|
|
@@ -1,324 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert/strict";
|
|
2
|
-
import test from "node:test";
|
|
3
|
-
import { buildProviderRegistry, getDefaultProviderId } from "./registry.js";
|
|
4
|
-
import { checkLocalProvider, resetLocalProviderStateForTests } from "../providerRuntime/local.js";
|
|
5
|
-
import { resetGeminiRouteValidationCacheForTests } from "../providerRuntime/gemini.js";
|
|
6
|
-
import { resetGeminiExecutableCacheForTests } from "../executables/geminiExecutable.js";
|
|
7
|
-
import { setProviderActiveRoute } from "./workspaceConfig.js";
|
|
8
|
-
import { resolveActiveProviderRoute } from "../providerRuntime/registry.js";
|
|
9
|
-
|
|
10
|
-
test("provider registry exposes the default launcher providers", () => {
|
|
11
|
-
const providers = buildProviderRegistry({ activeModel: "gpt-5.4" });
|
|
12
|
-
|
|
13
|
-
assert.deepEqual(providers.map((provider) => provider.id), ["openai", "anthropic", "google", "local"]);
|
|
14
|
-
assert.equal(providers[0]?.displayName, "OpenAI");
|
|
15
|
-
assert.equal(providers[0]?.currentModel, "gpt-5.4");
|
|
16
|
-
assert.deepEqual(providers[0]?.launchCommand, { executable: "codex", args: [] });
|
|
17
|
-
assert.deepEqual(providers[1]?.launchCommand, { executable: "claude", args: [] });
|
|
18
|
-
assert.deepEqual(providers[2]?.launchCommand, { executable: "gemini", args: [] });
|
|
19
|
-
assert.equal(providers[3]?.enabled, false);
|
|
20
|
-
assert.equal(providers[3]?.launchCommand, null);
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
test("workspace config can set the default provider", () => {
|
|
24
|
-
const providers = buildProviderRegistry({
|
|
25
|
-
activeModel: "gpt-5.4",
|
|
26
|
-
workspaceConfig: { workspaceDefaultProviderId: "anthropic" },
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
assert.equal(getDefaultProviderId({ workspaceDefaultProviderId: "anthropic" }), "anthropic");
|
|
30
|
-
assert.equal(providers.find((provider) => provider.id === "anthropic")?.isDefault, true);
|
|
31
|
-
assert.equal(providers.find((provider) => provider.id === "openai")?.isDefault, false);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
test("provider registry keeps workspace default separate from active route", () => {
|
|
35
|
-
const providers = buildProviderRegistry({
|
|
36
|
-
activeModel: "gpt-5.4",
|
|
37
|
-
workspaceConfig: {
|
|
38
|
-
workspaceDefaultProviderId: "anthropic",
|
|
39
|
-
activeRoute: {
|
|
40
|
-
providerId: "openai",
|
|
41
|
-
modelId: "gpt-5.4",
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
assert.equal(providers.find((provider) => provider.id === "anthropic")?.isDefault, true);
|
|
47
|
-
assert.equal(providers.find((provider) => provider.id === "anthropic")?.isActiveRoute, false);
|
|
48
|
-
assert.equal(providers.find((provider) => provider.id === "openai")?.isDefault, false);
|
|
49
|
-
assert.equal(providers.find((provider) => provider.id === "openai")?.isActiveRoute, true);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
test("unvalidated local provider remains disabled until endpoint discovery succeeds", () => {
|
|
53
|
-
resetLocalProviderStateForTests();
|
|
54
|
-
const providers = buildProviderRegistry({
|
|
55
|
-
activeModel: "gpt-5.4",
|
|
56
|
-
workspaceConfig: {
|
|
57
|
-
workspaceDefaultProviderId: "anthropic",
|
|
58
|
-
activeRoute: {
|
|
59
|
-
providerId: "local",
|
|
60
|
-
modelId: "llama-local",
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
assert.equal(providers.find((provider) => provider.id === "anthropic")?.isDefault, true);
|
|
66
|
-
assert.equal(providers.find((provider) => provider.id === "local")?.isActiveRoute, true);
|
|
67
|
-
assert.equal(providers.find((provider) => provider.id === "local")?.routeMode, "in-codexa");
|
|
68
|
-
assert.equal(providers.find((provider) => provider.id === "local")?.enabled, false);
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
test("google can be selected as an active in-Codexa route", () => {
|
|
72
|
-
const providers = buildProviderRegistry({
|
|
73
|
-
activeModel: "gpt-5.4",
|
|
74
|
-
workspaceConfig: {
|
|
75
|
-
activeRoute: {
|
|
76
|
-
providerId: "google",
|
|
77
|
-
modelId: "gemini-3-flash-preview",
|
|
78
|
-
backendKind: "gemini-cli-auth",
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
assert.equal(providers.find((provider) => provider.id === "google")?.isActiveRoute, true);
|
|
84
|
-
assert.equal(providers.find((provider) => provider.id === "google")?.routeMode, "in-codexa");
|
|
85
|
-
assert.equal(providers.find((provider) => provider.id === "google")?.currentModel, "gemini-3-flash-preview");
|
|
86
|
-
assert.equal(providers.find((provider) => provider.id === "openai")?.isActiveRoute, false);
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
test("anthropic can be selected as an active in-Codexa route", () => {
|
|
90
|
-
const providers = buildProviderRegistry({
|
|
91
|
-
activeModel: "gpt-5.4",
|
|
92
|
-
workspaceConfig: {
|
|
93
|
-
activeRoute: {
|
|
94
|
-
providerId: "anthropic",
|
|
95
|
-
modelId: "claude-sonnet-4-20250514",
|
|
96
|
-
backendKind: "anthropic-api-key",
|
|
97
|
-
},
|
|
98
|
-
},
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
assert.equal(providers.find((provider) => provider.id === "anthropic")?.isActiveRoute, true);
|
|
102
|
-
assert.equal(providers.find((provider) => provider.id === "anthropic")?.routeMode, "in-codexa");
|
|
103
|
-
assert.equal(providers.find((provider) => provider.id === "anthropic")?.currentModel, "claude-sonnet-4-20250514");
|
|
104
|
-
assert.equal(providers.find((provider) => provider.id === "openai")?.isActiveRoute, false);
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
test("discovered local models enable local provider and display selected model", async () => {
|
|
109
|
-
resetLocalProviderStateForTests();
|
|
110
|
-
const localOverride = {
|
|
111
|
-
currentModel: "google/gemma-4-26b-a4b",
|
|
112
|
-
};
|
|
113
|
-
await checkLocalProvider({
|
|
114
|
-
override: localOverride,
|
|
115
|
-
fetchImpl: (async (input) => {
|
|
116
|
-
if (String(input).includes("/api/v0/")) {
|
|
117
|
-
return new Response(null, { status: 404 });
|
|
118
|
-
}
|
|
119
|
-
return new Response(JSON.stringify({
|
|
120
|
-
data: [{ id: "google/gemma-4-26b-a4b" }],
|
|
121
|
-
}), { status: 200 });
|
|
122
|
-
}) as typeof fetch,
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
const providers = buildProviderRegistry({
|
|
126
|
-
activeModel: "gpt-5.4",
|
|
127
|
-
workspaceConfig: {
|
|
128
|
-
activeRoute: {
|
|
129
|
-
providerId: "local",
|
|
130
|
-
modelId: "google/gemma-4-26b-a4b",
|
|
131
|
-
backendKind: "local-openai-compatible",
|
|
132
|
-
},
|
|
133
|
-
providers: {
|
|
134
|
-
local: localOverride,
|
|
135
|
-
},
|
|
136
|
-
},
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
const local = providers.find((provider) => provider.id === "local");
|
|
140
|
-
assert.equal(local?.enabled, true);
|
|
141
|
-
assert.equal(local?.currentModel, "google/gemma-4-26b-a4b");
|
|
142
|
-
assert.equal(local?.backendType, "local-openai-compatible");
|
|
143
|
-
assert.equal(local?.statusLabel, "Enabled");
|
|
144
|
-
assert.deepEqual(local?.launchCommand, null);
|
|
145
|
-
resetLocalProviderStateForTests();
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
test("LM Studio loaded Local model replaces stale active route in provider registry", async () => {
|
|
149
|
-
resetLocalProviderStateForTests();
|
|
150
|
-
try {
|
|
151
|
-
await checkLocalProvider({
|
|
152
|
-
override: {
|
|
153
|
-
currentModel: "google/gemma-4-26b-a4b",
|
|
154
|
-
defaultModel: "google/gemma-4-26b-a4b",
|
|
155
|
-
baseUrl: "http://localhost:1234/v1",
|
|
156
|
-
},
|
|
157
|
-
fetchImpl: (async (input) => {
|
|
158
|
-
if (String(input).includes("/api/v0/")) {
|
|
159
|
-
return new Response(JSON.stringify({
|
|
160
|
-
data: [{
|
|
161
|
-
id: "qwen/qwen3.6-27b",
|
|
162
|
-
state: "loaded",
|
|
163
|
-
loaded_context_length: 32000,
|
|
164
|
-
max_context_length: 262144,
|
|
165
|
-
capabilities: ["tool_use"],
|
|
166
|
-
}],
|
|
167
|
-
object: "list",
|
|
168
|
-
}), { status: 200 });
|
|
169
|
-
}
|
|
170
|
-
return new Response(JSON.stringify({
|
|
171
|
-
data: [{ id: "google/gemma-4-26b-a4b" }, { id: "qwen/qwen3.6-27b" }],
|
|
172
|
-
}), { status: 200 });
|
|
173
|
-
}) as typeof fetch,
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
const providers = buildProviderRegistry({
|
|
177
|
-
activeModel: "gpt-5.4",
|
|
178
|
-
workspaceConfig: {
|
|
179
|
-
activeRoute: {
|
|
180
|
-
providerId: "local",
|
|
181
|
-
modelId: "google/gemma-4-26b-a4b",
|
|
182
|
-
backendKind: "local-openai-compatible",
|
|
183
|
-
},
|
|
184
|
-
providers: {
|
|
185
|
-
local: {
|
|
186
|
-
currentModel: "google/gemma-4-26b-a4b",
|
|
187
|
-
defaultModel: "google/gemma-4-26b-a4b",
|
|
188
|
-
baseUrl: "http://localhost:1234/v1",
|
|
189
|
-
},
|
|
190
|
-
},
|
|
191
|
-
},
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
const local = providers.find((provider) => provider.id === "local");
|
|
195
|
-
assert.equal(local?.currentModel, "qwen/qwen3.6-27b");
|
|
196
|
-
assert.equal(local?.contextLengthLabel, "32,000");
|
|
197
|
-
assert.equal(local?.contextLengthSource, "lmstudio-api");
|
|
198
|
-
assert.equal(local?.capabilityProfile?.supportsToolCalls, true);
|
|
199
|
-
assert.equal(local?.capabilityProfile?.supportsVision, null);
|
|
200
|
-
} finally {
|
|
201
|
-
resetLocalProviderStateForTests();
|
|
202
|
-
}
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
// ─── Provider status label / color sync tests ────────────────────────────────
|
|
206
|
-
|
|
207
|
-
async function withNoGeminiConfig<T>(callback: () => T | Promise<T>): Promise<T> {
|
|
208
|
-
const savedGemini = process.env.GEMINI_API_KEY;
|
|
209
|
-
const savedGoogle = process.env.GOOGLE_API_KEY;
|
|
210
|
-
const savedExe = process.env.GEMINI_EXECUTABLE;
|
|
211
|
-
const savedCliPath = process.env.GEMINI_CLI_PATH;
|
|
212
|
-
try {
|
|
213
|
-
delete process.env.GEMINI_API_KEY;
|
|
214
|
-
delete process.env.GOOGLE_API_KEY;
|
|
215
|
-
delete process.env.GEMINI_EXECUTABLE;
|
|
216
|
-
delete process.env.GEMINI_CLI_PATH;
|
|
217
|
-
resetGeminiRouteValidationCacheForTests();
|
|
218
|
-
resetGeminiExecutableCacheForTests();
|
|
219
|
-
return await callback();
|
|
220
|
-
} finally {
|
|
221
|
-
if (savedGemini === undefined) delete process.env.GEMINI_API_KEY; else process.env.GEMINI_API_KEY = savedGemini;
|
|
222
|
-
if (savedGoogle === undefined) delete process.env.GOOGLE_API_KEY; else process.env.GOOGLE_API_KEY = savedGoogle;
|
|
223
|
-
if (savedExe === undefined) delete process.env.GEMINI_EXECUTABLE; else process.env.GEMINI_EXECUTABLE = savedExe;
|
|
224
|
-
if (savedCliPath === undefined) delete process.env.GEMINI_CLI_PATH; else process.env.GEMINI_CLI_PATH = savedCliPath;
|
|
225
|
-
resetGeminiRouteValidationCacheForTests();
|
|
226
|
-
resetGeminiExecutableCacheForTests();
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
test("google shows 'Needs config' statusLabel when no API key or CLI validation is present", async () => {
|
|
231
|
-
await withNoGeminiConfig(() => {
|
|
232
|
-
const providers = buildProviderRegistry({ activeModel: "gpt-5.4" });
|
|
233
|
-
const google = providers.find((p) => p.id === "google");
|
|
234
|
-
assert.equal(google?.statusLabel, "Needs config");
|
|
235
|
-
assert.notEqual(google?.routeUnavailableReason, null);
|
|
236
|
-
});
|
|
237
|
-
});
|
|
238
|
-
|
|
239
|
-
test("google shows 'Enabled' statusLabel when GEMINI_API_KEY is set", async () => {
|
|
240
|
-
const saved = process.env.GEMINI_API_KEY;
|
|
241
|
-
try {
|
|
242
|
-
process.env.GEMINI_API_KEY = "test-key";
|
|
243
|
-
resetGeminiRouteValidationCacheForTests();
|
|
244
|
-
const providers = buildProviderRegistry({ activeModel: "gpt-5.4" });
|
|
245
|
-
const google = providers.find((p) => p.id === "google");
|
|
246
|
-
assert.equal(google?.statusLabel, "Enabled");
|
|
247
|
-
assert.equal(google?.routeUnavailableReason, null);
|
|
248
|
-
} finally {
|
|
249
|
-
if (saved === undefined) delete process.env.GEMINI_API_KEY; else process.env.GEMINI_API_KEY = saved;
|
|
250
|
-
resetGeminiRouteValidationCacheForTests();
|
|
251
|
-
}
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
test("google 'Needs config' survives workspace config override with no enabled field", async () => {
|
|
255
|
-
await withNoGeminiConfig(() => {
|
|
256
|
-
const providers = buildProviderRegistry({
|
|
257
|
-
activeModel: "gpt-5.4",
|
|
258
|
-
workspaceConfig: {
|
|
259
|
-
providers: {
|
|
260
|
-
google: { currentModel: "gemini-3-flash-preview", currentReasoning: "medium" },
|
|
261
|
-
},
|
|
262
|
-
},
|
|
263
|
-
});
|
|
264
|
-
const google = providers.find((p) => p.id === "google");
|
|
265
|
-
assert.equal(google?.statusLabel, "Needs config");
|
|
266
|
-
assert.notEqual(google?.routeUnavailableReason, null);
|
|
267
|
-
});
|
|
268
|
-
});
|
|
269
|
-
|
|
270
|
-
test("'Active' text is display-layer only — registry statusLabel stays 'Enabled' for active route when configured", async () => {
|
|
271
|
-
const saved = process.env.GEMINI_API_KEY;
|
|
272
|
-
try {
|
|
273
|
-
process.env.GEMINI_API_KEY = "test-key";
|
|
274
|
-
resetGeminiRouteValidationCacheForTests();
|
|
275
|
-
const providers = buildProviderRegistry({
|
|
276
|
-
activeModel: "gpt-5.4",
|
|
277
|
-
workspaceConfig: {
|
|
278
|
-
activeRoute: { providerId: "google", modelId: "gemini-3-flash-preview", backendKind: "gemini-cli-auth" },
|
|
279
|
-
},
|
|
280
|
-
});
|
|
281
|
-
const google = providers.find((p) => p.id === "google");
|
|
282
|
-
assert.equal(google?.isActiveRoute, true);
|
|
283
|
-
assert.equal(google?.statusLabel, "Enabled");
|
|
284
|
-
} finally {
|
|
285
|
-
if (saved === undefined) delete process.env.GEMINI_API_KEY; else process.env.GEMINI_API_KEY = saved;
|
|
286
|
-
resetGeminiRouteValidationCacheForTests();
|
|
287
|
-
}
|
|
288
|
-
});
|
|
289
|
-
|
|
290
|
-
test("resolveActiveProviderRoute returns google route when configured via API key", async () => {
|
|
291
|
-
const saved = process.env.GEMINI_API_KEY;
|
|
292
|
-
try {
|
|
293
|
-
process.env.GEMINI_API_KEY = "test-key";
|
|
294
|
-
resetGeminiRouteValidationCacheForTests();
|
|
295
|
-
const route = resolveActiveProviderRoute({
|
|
296
|
-
workspaceConfigActiveRoute: {
|
|
297
|
-
providerId: "google",
|
|
298
|
-
modelId: "gemini-3-flash-preview",
|
|
299
|
-
backendKind: "gemini-cli-auth",
|
|
300
|
-
},
|
|
301
|
-
currentModel: "gpt-5.4",
|
|
302
|
-
currentReasoning: "medium",
|
|
303
|
-
});
|
|
304
|
-
assert.equal(route.providerId, "google");
|
|
305
|
-
assert.equal(route.modelId, "gemini-3-flash-preview");
|
|
306
|
-
} finally {
|
|
307
|
-
if (saved === undefined) delete process.env.GEMINI_API_KEY; else process.env.GEMINI_API_KEY = saved;
|
|
308
|
-
resetGeminiRouteValidationCacheForTests();
|
|
309
|
-
}
|
|
310
|
-
});
|
|
311
|
-
|
|
312
|
-
test("setProviderActiveRoute does not update activeRoute when google is not configured", async () => {
|
|
313
|
-
await withNoGeminiConfig(() => {
|
|
314
|
-
const original: import("./types.js").ProviderWorkspaceConfig = {
|
|
315
|
-
activeRoute: { providerId: "openai", modelId: "gpt-5.4", backendKind: "codex-cli-auth" },
|
|
316
|
-
};
|
|
317
|
-
const result = setProviderActiveRoute(original, {
|
|
318
|
-
providerId: "google",
|
|
319
|
-
modelId: "gemini-3-flash-preview",
|
|
320
|
-
backendKind: "gemini-cli-auth",
|
|
321
|
-
});
|
|
322
|
-
assert.equal(result.activeRoute?.providerId, "openai");
|
|
323
|
-
});
|
|
324
|
-
});
|