Skip to content

7.4 billion tokens per month. 34 free LLM providers. 635 free model endpoints. All behind one /v1 endpoint, plus any custom OpenAI-compatible endpoint. Smart routing, automatic failover, encrypted keys. Personal experimentation only.

TypeScript

fix(cli): launch Windows command shims (#1517)

ammanne71091fd0945
diff --git a/cli/package.json b/cli/package.json
index cd61eda1..c274dbcf 100644
--- a/cli/package.json
+++ b/cli/package.json
@@ -60,10 +60,12 @@
"node": ">=20.18.0 <25.0.0"
},
"dependencies": {
+ "cross-spawn": "^7.0.6",
"jsonc-parser": "^3.3.1",
"yaml": "^2.9.0"
},
"devDependencies": {
+ "@types/cross-spawn": "^6.0.6",
"@types/node": "^24.12.2",
"typescript": "~6.0.2",
"vitest": "^3.1.3",
diff --git a/cli/src/index.test.ts b/cli/src/index.test.ts
index 7c5cada7..19776d6a 100644
--- a/cli/src/index.test.ts
+++ b/cli/src/index.test.ts
@@ -87,6 +87,38 @@ describe('CLI arguments and launchers', () => {
}
});
+ it.skipIf(process.platform !== 'win32')('launches Windows command shims for both agents', async () => {
+ const directory = fs.mkdtempSync(path.join(os.tmpdir(), 'freellmapi-launch-'));
+ temporary.push(directory);
+ for (const command of ['codex', 'claude']) {
+ fs.writeFileSync(path.join(directory, `${command}.cmd`),
+ `@echo off\r\necho ${command} > "%FREELLMAPI_TEST_MARKER%"\r\nexit /b 17\r\n`);
+ }
+ const previousPath = process.env.PATH;
+ const previousMarker = process.env.FREELLMAPI_TEST_MARKER;
+ const previousFetch = globalThis.fetch;
+ const marker = path.join(directory, 'launched.txt');
+ process.env.PATH = `${directory};${process.env.SystemRoot}\\System32`;
+ process.env.FREELLMAPI_TEST_MARKER = marker;
+ globalThis.fetch = async () => new Response(JSON.stringify({
+ data: [{ id: 'test-model', available: true }],
+ }), { headers: { 'Content-Type': 'application/json' } });
+ try {
+ for (const [command, agent] of [['launch-codex', 'codex'], ['launch', 'claude']]) {
+ fs.rmSync(marker, { force: true });
+ expect(await main([command, '--url', 'http://127.0.0.1:3001', '--api-key', 'test-key']))
+ .toBe(17);
+ expect(fs.readFileSync(marker, 'utf8').trim()).toBe(agent);
+ }
+ } finally {
+ globalThis.fetch = previousFetch;
+ if (previousPath === undefined) delete process.env.PATH;
+ else process.env.PATH = previousPath;
+ if (previousMarker === undefined) delete process.env.FREELLMAPI_TEST_MARKER;
+ else process.env.FREELLMAPI_TEST_MARKER = previousMarker;
+ }
+ });
+
it('uses --model for ANTHROPIC_MODEL and defaults to the first available model', () => {
const explicit = claudeLaunchEnv(
{ ...baseOptions, model: 'reasoning-model' },
diff --git a/cli/src/index.ts b/cli/src/index.ts
index cdd8bc16..d872c88b 100644
--- a/cli/src/index.ts
+++ b/cli/src/index.ts
@@ -3,7 +3,7 @@ import os from 'node:os';
import fs from 'node:fs';
import path from 'node:path';
import process from 'node:process';
-import { spawn } from 'node:child_process';
+import spawn from 'cross-spawn';
import { Writable } from 'node:stream';
import { fileURLToPath } from 'node:url';
import { applyGeneratedFiles, printDryRunDiff } from './config-files.js';
diff --git a/package-lock.json b/package-lock.json
index aef9beff..a07ddca9 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -25,6 +25,7 @@
"version": "0.8.1",
"license": "MIT",
"dependencies": {
+ "cross-spawn": "^7.0.6",
"jsonc-parser": "^3.3.1",
"yaml": "^2.9.0"
},
@@ -33,6 +34,7 @@
},
"devDependencies": {
"@eslint/js": "^9.39.4",
+ "@types/cross-spawn": "^6.0.6",
"@types/node": "^24.12.2",
"eslint": "^9.39.4",
"globals": "^17.4.0",
@@ -3884,6 +3886,16 @@
"@types/node": "*"
}
},
+ "node_modules/@types/cross-spawn": {
+ "version": "6.0.6",
+ "resolved": "https://registry.npmjs.org/@types/cross-spawn/-/cross-spawn-6.0.6.tgz",
+ "integrity": "sha512-fXRhhUkG4H3TQk5dBhQ7m/JDdSNHKwR2BBia62lhwEIq9xGiQKLxd6LymNhn47SjXhsUEPmxi+PKw2OkW4LLjA==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@types/node": "*"
+ }
+ },
"node_modules/@types/d3-array": {
"version": "3.2.2",
"resolved": "https://registry.npmjs.org/@types/d3-array/-/d3-array-3.2.2.tgz",