@lunaroute/cli 0.14.2 → 0.14.4
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/dist/index.js +265 -87
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { Command, InvalidArgumentError, Option } from "commander";
|
|
5
5
|
|
|
6
6
|
// package.json
|
|
7
|
-
var version = "0.14.
|
|
7
|
+
var version = "0.14.4";
|
|
8
8
|
|
|
9
9
|
// src/login.ts
|
|
10
10
|
import { createServer } from "http";
|
|
@@ -1093,6 +1093,11 @@ function resolveClaudeDesktopAppliedProfile(platform = process.platform) {
|
|
|
1093
1093
|
if (!isRegularFile(candidate)) return null;
|
|
1094
1094
|
return dirname2(realpathSync(candidate)) === realpathSync(claudeDesktopConfigLibraryDir()) ? candidate : null;
|
|
1095
1095
|
}
|
|
1096
|
+
var CLAUDE_DESKTOP_NO_PROFILE = "Claude Desktop has not created a third-party inference profile yet \u2014 in Desktop open Help \u2192 Troubleshooting \u2192 Enable Developer Mode, then Developer \u2192 Configure Third-Party Inference once; then re-run.";
|
|
1097
|
+
var CLAUDE_DESKTOP_UNVERIFIED_PLATFORM = "The Claude Desktop profile path is verified on Linux only \u2014 this platform's path is unverified (kata yc1y), so the CLI will not guess it. Configure Desktop by hand instead: Help \u2192 Troubleshooting \u2192 Enable Developer Mode, then Developer \u2192 Configure Third-Party Inference.";
|
|
1098
|
+
function claudeDesktopRefusal() {
|
|
1099
|
+
return process.platform === "linux" ? CLAUDE_DESKTOP_NO_PROFILE : CLAUDE_DESKTOP_UNVERIFIED_PLATFORM;
|
|
1100
|
+
}
|
|
1096
1101
|
|
|
1097
1102
|
// src/setup/adapters/opencode.ts
|
|
1098
1103
|
var EXTENSION = "@lunaroute/opencode-extension";
|
|
@@ -1426,9 +1431,9 @@ function buildPlan3(ctx) {
|
|
|
1426
1431
|
|
|
1427
1432
|
// src/setup/routing-url.ts
|
|
1428
1433
|
function validatedRoutingUrl(routingUrl) {
|
|
1429
|
-
function fail2(
|
|
1434
|
+
function fail2(reason2) {
|
|
1430
1435
|
throw new Error(
|
|
1431
|
-
`routingUrl rejected (reason: ${
|
|
1436
|
+
`routingUrl rejected (reason: ${reason2}; <redacted URL>) \u2014 check --routing-url or the profile's routing URL`
|
|
1432
1437
|
);
|
|
1433
1438
|
}
|
|
1434
1439
|
if (!/^https?:\/\/[^/?#]/.test(routingUrl)) fail2("invalid-url");
|
|
@@ -1931,6 +1936,9 @@ function buildPlan11(ctx) {
|
|
|
1931
1936
|
};
|
|
1932
1937
|
}
|
|
1933
1938
|
|
|
1939
|
+
// src/setup/remove.ts
|
|
1940
|
+
import { closeSync as closeSync2, constants as constants2, existsSync as existsSync6, fstatSync as fstatSync2, lstatSync as lstatSync3, openSync as openSync2, unlinkSync } from "fs";
|
|
1941
|
+
|
|
1934
1942
|
// src/setup/snapshot.ts
|
|
1935
1943
|
import {
|
|
1936
1944
|
chmodSync as chmodSync4,
|
|
@@ -2119,6 +2127,248 @@ function restoreClaudeDesktopProfile(profilePath) {
|
|
|
2119
2127
|
return { restored: true };
|
|
2120
2128
|
}
|
|
2121
2129
|
|
|
2130
|
+
// src/setup/remove.ts
|
|
2131
|
+
var REVERSES = {
|
|
2132
|
+
"claude-desktop": removeClaudeDesktop,
|
|
2133
|
+
codex: removeCodex,
|
|
2134
|
+
"claude-code": printOnlyRemove("claude-code"),
|
|
2135
|
+
agy: printOnlyRemove("agy"),
|
|
2136
|
+
"copilot-cli": printOnlyRemove("copilot-cli"),
|
|
2137
|
+
generic: printOnlyRemove("generic")
|
|
2138
|
+
};
|
|
2139
|
+
async function runRemove(harness, opts, deps) {
|
|
2140
|
+
if (!Object.hasOwn(REVERSES, harness)) {
|
|
2141
|
+
console.error(`${harness} has no reverse; supports: ${Object.keys(REVERSES).join(", ")}.`);
|
|
2142
|
+
return 1;
|
|
2143
|
+
}
|
|
2144
|
+
return REVERSES[harness](opts, deps);
|
|
2145
|
+
}
|
|
2146
|
+
async function removeClaudeDesktop(opts, deps) {
|
|
2147
|
+
const profilePath = resolveClaudeDesktopAppliedProfile();
|
|
2148
|
+
if (!profilePath) {
|
|
2149
|
+
console.error(claudeDesktopRefusal());
|
|
2150
|
+
return 1;
|
|
2151
|
+
}
|
|
2152
|
+
const snapPath = claudeDesktopSnapshotPath(profilePath);
|
|
2153
|
+
const status = claudeDesktopSnapshotStatus(profilePath);
|
|
2154
|
+
const hasSnapshot = status === "regular";
|
|
2155
|
+
const takenAt = hasSnapshot ? claudeDesktopSnapshotTakenAt(profilePath) : null;
|
|
2156
|
+
if (opts.print) {
|
|
2157
|
+
console.log(
|
|
2158
|
+
hasSnapshot ? `# would restore ${profilePath} from ${snapPath}${takenAt ? ` (taken ${takenAt})` : ""}` : status === "invalid" ? `# would refuse: ${snapPath} is not a regular file` : `# would leave ${profilePath} unchanged (no snapshot)`
|
|
2159
|
+
);
|
|
2160
|
+
if (!hasSnapshot) printClaudeDesktopKeysByHand(profilePath);
|
|
2161
|
+
return 0;
|
|
2162
|
+
}
|
|
2163
|
+
if (status === "invalid") {
|
|
2164
|
+
console.error(
|
|
2165
|
+
`Refusing to touch ${profilePath}: ${snapPath} is not a regular file (a symlink, directory or FIFO), so it is not a usable snapshot. Inspect and remove it by hand.`
|
|
2166
|
+
);
|
|
2167
|
+
return 1;
|
|
2168
|
+
}
|
|
2169
|
+
if (!hasSnapshot) {
|
|
2170
|
+
console.log(
|
|
2171
|
+
"No snapshot exists for this profile \u2014 nothing was changed, and nothing was removed (a hand-configured profile can hold exactly the values we would write, and value matching is not authorship). Remove these by hand:"
|
|
2172
|
+
);
|
|
2173
|
+
printClaudeDesktopKeysByHand(profilePath);
|
|
2174
|
+
return 0;
|
|
2175
|
+
}
|
|
2176
|
+
try {
|
|
2177
|
+
const question = `Restore ${profilePath} from the snapshot at ${snapPath}${takenAt ? ` taken ${takenAt}` : ""}?`;
|
|
2178
|
+
if (!await deps.confirm(question, { yes: opts.yes })) {
|
|
2179
|
+
console.log("Skipped. Nothing written.");
|
|
2180
|
+
return 0;
|
|
2181
|
+
}
|
|
2182
|
+
} catch (err) {
|
|
2183
|
+
if (err instanceof NonInteractiveTerminalError) {
|
|
2184
|
+
console.error(
|
|
2185
|
+
"No interactive terminal available. Re-run with --yes to accept prompts, or --print to preview without writing."
|
|
2186
|
+
);
|
|
2187
|
+
return 1;
|
|
2188
|
+
}
|
|
2189
|
+
throw err;
|
|
2190
|
+
}
|
|
2191
|
+
try {
|
|
2192
|
+
const { restored } = restoreClaudeDesktopProfile(profilePath);
|
|
2193
|
+
console.log(
|
|
2194
|
+
restored ? `Restored ${profilePath} from ${snapPath}.` : `Already restored \u2014 ${profilePath} matches the snapshot; nothing written.`
|
|
2195
|
+
);
|
|
2196
|
+
return 0;
|
|
2197
|
+
} catch (err) {
|
|
2198
|
+
console.error(err instanceof Error ? err.message : String(err));
|
|
2199
|
+
return 1;
|
|
2200
|
+
}
|
|
2201
|
+
}
|
|
2202
|
+
function printClaudeDesktopKeysByHand(profilePath) {
|
|
2203
|
+
console.log(` in ${profilePath}:`);
|
|
2204
|
+
for (const [k, v] of Object.entries(claudeDesktopKeys("<your-routing-url>", "<your-lr_\u2026-key>"))) {
|
|
2205
|
+
if (k === "inferenceCustomHeaders") continue;
|
|
2206
|
+
console.log(` delete ${k} only if it is ${JSON.stringify(v)}`);
|
|
2207
|
+
}
|
|
2208
|
+
console.log(
|
|
2209
|
+
' inside inferenceCustomHeaders, delete ONLY the "X-LunaRoute-Client": "claude-desktop" entry \u2014 keep your other header entries'
|
|
2210
|
+
);
|
|
2211
|
+
}
|
|
2212
|
+
var PRINTED_VARS = {
|
|
2213
|
+
"claude-code": [
|
|
2214
|
+
"LUNAROUTE_API_KEY",
|
|
2215
|
+
"ANTHROPIC_BASE_URL",
|
|
2216
|
+
"ANTHROPIC_AUTH_TOKEN",
|
|
2217
|
+
"ANTHROPIC_MODEL",
|
|
2218
|
+
"CLAUDE_CODE_MAX_CONTEXT_TOKENS",
|
|
2219
|
+
"CLAUDE_CODE_MAX_OUTPUT_TOKENS",
|
|
2220
|
+
"ANTHROPIC_DEFAULT_HAIKU_MODEL",
|
|
2221
|
+
"CLAUDE_CODE_GATEWAY_HINT_HEADERS",
|
|
2222
|
+
"ANTHROPIC_CUSTOM_HEADERS",
|
|
2223
|
+
"CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY"
|
|
2224
|
+
],
|
|
2225
|
+
agy: ["AGY_LLM_GATEWAY_URL", "AGY_LLM_GATEWAY_API_KEY"],
|
|
2226
|
+
"copilot-cli": [
|
|
2227
|
+
"LUNAROUTE_API_KEY",
|
|
2228
|
+
"COPILOT_PROVIDER_TYPE",
|
|
2229
|
+
"COPILOT_PROVIDER_BASE_URL",
|
|
2230
|
+
"COPILOT_PROVIDER_API_KEY",
|
|
2231
|
+
"COPILOT_MODEL"
|
|
2232
|
+
],
|
|
2233
|
+
generic: ["LUNAROUTE_API_KEY"]
|
|
2234
|
+
};
|
|
2235
|
+
function renderUnsetBlock(vars) {
|
|
2236
|
+
return [
|
|
2237
|
+
"",
|
|
2238
|
+
"The commands below clear every variable in the list \u2014 delete from the list any you did not add (LUNAROUTE_API_KEY may also serve another harness).",
|
|
2239
|
+
"",
|
|
2240
|
+
"POSIX: delete the export lines you added to your startup file (~/.zshrc, ~/.bashrc, ~/.profile), then clear them in shells that are already open:",
|
|
2241
|
+
` unset ${vars.join(" ")}`,
|
|
2242
|
+
"",
|
|
2243
|
+
"Windows: this clears the current session value and the persistent user variable; then open a NEW window:",
|
|
2244
|
+
` foreach ($v in ${vars.map((v) => `'${v}'`).join(",")}) { Remove-Item "Env:$v" -ErrorAction SilentlyContinue; [Environment]::SetEnvironmentVariable($v, $null, 'User') }`,
|
|
2245
|
+
"",
|
|
2246
|
+
"Delete only the ones you added \u2014 LUNAROUTE_API_KEY may also serve another harness.",
|
|
2247
|
+
"The CLI's own stored key stays until you run `lunaroute logout` (add -p <profile> for a non-default profile)."
|
|
2248
|
+
];
|
|
2249
|
+
}
|
|
2250
|
+
function printOnlyRemove(harness) {
|
|
2251
|
+
return async () => {
|
|
2252
|
+
const vars = PRINTED_VARS[harness] ?? [];
|
|
2253
|
+
console.log(
|
|
2254
|
+
`${harness} setup wrote no harness configuration files on this machine \u2014 this command changed nothing.`
|
|
2255
|
+
);
|
|
2256
|
+
for (const line of renderUnsetBlock(vars)) console.log(line);
|
|
2257
|
+
return 0;
|
|
2258
|
+
};
|
|
2259
|
+
}
|
|
2260
|
+
function isEnoent(err) {
|
|
2261
|
+
return err?.code === "ENOENT";
|
|
2262
|
+
}
|
|
2263
|
+
function reason(err) {
|
|
2264
|
+
return err instanceof Error ? err.message : String(err);
|
|
2265
|
+
}
|
|
2266
|
+
async function removeCodex(opts, deps) {
|
|
2267
|
+
const path = codexProfilePath();
|
|
2268
|
+
let before;
|
|
2269
|
+
try {
|
|
2270
|
+
before = lstatSync3(path);
|
|
2271
|
+
} catch (err) {
|
|
2272
|
+
if (isEnoent(err)) {
|
|
2273
|
+
console.log(`Nothing to remove: ${path} does not exist.`);
|
|
2274
|
+
return 0;
|
|
2275
|
+
}
|
|
2276
|
+
console.error(`${path} could not be checked: ${reason(err)}`);
|
|
2277
|
+
return 1;
|
|
2278
|
+
}
|
|
2279
|
+
if (!before.isFile()) {
|
|
2280
|
+
console.error(`${path} is not a regular file \u2014 refusing to remove it.`);
|
|
2281
|
+
return 1;
|
|
2282
|
+
}
|
|
2283
|
+
if (opts.print) {
|
|
2284
|
+
console.log(`# would delete ${path}`);
|
|
2285
|
+
console.log(`# it holds only LunaRoute's profile \u2014 hand edits you made to it go too`);
|
|
2286
|
+
return 0;
|
|
2287
|
+
}
|
|
2288
|
+
let fd;
|
|
2289
|
+
try {
|
|
2290
|
+
const open2 = deps.open ?? ((p) => openSync2(p, constants2.O_RDONLY | constants2.O_NOFOLLOW | constants2.O_NONBLOCK));
|
|
2291
|
+
fd = open2(path);
|
|
2292
|
+
} catch (err) {
|
|
2293
|
+
const code = err?.code;
|
|
2294
|
+
if (code === "EACCES" || code === "EPERM") {
|
|
2295
|
+
console.error(
|
|
2296
|
+
`${path} cannot be read to verify it \u2014 nothing was removed. Make it readable and re-run, or delete it by hand.`
|
|
2297
|
+
);
|
|
2298
|
+
return 1;
|
|
2299
|
+
} else if (code === "ELOOP") {
|
|
2300
|
+
console.error(`${path} is not a regular file \u2014 refusing to remove it.`);
|
|
2301
|
+
return 1;
|
|
2302
|
+
} else if (isEnoent(err)) {
|
|
2303
|
+
console.log(`Nothing to remove: ${path} does not exist.`);
|
|
2304
|
+
return 0;
|
|
2305
|
+
} else {
|
|
2306
|
+
console.error(`${path} could not be checked: ${reason(err)}`);
|
|
2307
|
+
return 1;
|
|
2308
|
+
}
|
|
2309
|
+
}
|
|
2310
|
+
try {
|
|
2311
|
+
const identity = fstatSync2(fd);
|
|
2312
|
+
if (!identity.isFile()) {
|
|
2313
|
+
console.error(`${path} is not a regular file \u2014 refusing to remove it.`);
|
|
2314
|
+
return 1;
|
|
2315
|
+
}
|
|
2316
|
+
if (identity.dev !== before.dev || identity.ino !== before.ino) {
|
|
2317
|
+
console.error(`${path} changed while it was being checked \u2014 nothing was removed.`);
|
|
2318
|
+
return 1;
|
|
2319
|
+
}
|
|
2320
|
+
try {
|
|
2321
|
+
const question = `Delete ${path}? It holds only LunaRoute's profile, but edits you made to it go too.`;
|
|
2322
|
+
if (!await deps.confirm(question, { yes: opts.yes })) {
|
|
2323
|
+
console.log("Skipped. Nothing removed.");
|
|
2324
|
+
return 0;
|
|
2325
|
+
}
|
|
2326
|
+
} catch (err) {
|
|
2327
|
+
if (err instanceof NonInteractiveTerminalError) {
|
|
2328
|
+
console.error(
|
|
2329
|
+
"No interactive terminal available. Re-run with --yes to accept prompts, or --print to preview without writing."
|
|
2330
|
+
);
|
|
2331
|
+
return 1;
|
|
2332
|
+
}
|
|
2333
|
+
throw err;
|
|
2334
|
+
}
|
|
2335
|
+
let after;
|
|
2336
|
+
try {
|
|
2337
|
+
after = lstatSync3(path);
|
|
2338
|
+
} catch (err) {
|
|
2339
|
+
if (isEnoent(err)) {
|
|
2340
|
+
console.log(`Nothing to remove: ${path} does not exist.`);
|
|
2341
|
+
return 0;
|
|
2342
|
+
}
|
|
2343
|
+
console.error(`${path} could not be re-checked: ${reason(err)}`);
|
|
2344
|
+
return 1;
|
|
2345
|
+
}
|
|
2346
|
+
if (!after.isFile() || after.dev !== identity.dev || after.ino !== identity.ino) {
|
|
2347
|
+
console.error(`${path} changed while you were deciding \u2014 nothing was removed.`);
|
|
2348
|
+
return 1;
|
|
2349
|
+
}
|
|
2350
|
+
const unlink = deps.unlink ?? unlinkSync;
|
|
2351
|
+
try {
|
|
2352
|
+
unlink(path);
|
|
2353
|
+
} catch (err) {
|
|
2354
|
+
if (isEnoent(err)) {
|
|
2355
|
+
console.log(`Nothing to remove: ${path} does not exist.`);
|
|
2356
|
+
return 0;
|
|
2357
|
+
}
|
|
2358
|
+
console.error(`${path} could not be removed: ${reason(err)}`);
|
|
2359
|
+
return 1;
|
|
2360
|
+
}
|
|
2361
|
+
console.log(`Removed ${path}.`);
|
|
2362
|
+
if (existsSync6(`${path}.bak`)) {
|
|
2363
|
+
console.log(`Kept ${path}.bak (from an earlier setup) \u2014 delete it by hand if you want it gone.`);
|
|
2364
|
+
}
|
|
2365
|
+
for (const line of renderUnsetBlock(["LUNAROUTE_API_KEY"])) console.log(line);
|
|
2366
|
+
return 0;
|
|
2367
|
+
} finally {
|
|
2368
|
+
closeSync2(fd);
|
|
2369
|
+
}
|
|
2370
|
+
}
|
|
2371
|
+
|
|
2122
2372
|
// src/commands/setup.ts
|
|
2123
2373
|
var ADAPTERS = {
|
|
2124
2374
|
opencode: buildPlan,
|
|
@@ -2155,6 +2405,10 @@ async function runSetup(harness, opts, deps = {
|
|
|
2155
2405
|
);
|
|
2156
2406
|
return 1;
|
|
2157
2407
|
}
|
|
2408
|
+
if (opts.remove && (opts.key !== void 0 || opts.routingUrl !== void 0 || opts.extension || opts.models)) {
|
|
2409
|
+
console.error("--remove takes no setup flags; drop --key, --extension, --models or --routing-url.");
|
|
2410
|
+
return 1;
|
|
2411
|
+
}
|
|
2158
2412
|
if (opts.remove) return runRemove(harness, opts, deps);
|
|
2159
2413
|
let stored = loadProfile(opts.profile);
|
|
2160
2414
|
const settings = resolveSettings(opts.profile);
|
|
@@ -2366,11 +2620,6 @@ async function runPiSetup(opts, stored, routingUrl, deps) {
|
|
|
2366
2620
|
return 1;
|
|
2367
2621
|
}
|
|
2368
2622
|
}
|
|
2369
|
-
var CLAUDE_DESKTOP_NO_PROFILE = "Claude Desktop has not created a third-party inference profile yet \u2014 in Desktop open Help \u2192 Troubleshooting \u2192 Enable Developer Mode, then Developer \u2192 Configure Third-Party Inference once; then re-run.";
|
|
2370
|
-
var CLAUDE_DESKTOP_UNVERIFIED_PLATFORM = "The Claude Desktop profile path is verified on Linux only \u2014 this platform's path is unverified (kata yc1y), so the CLI will not guess it. Configure Desktop by hand instead: Help \u2192 Troubleshooting \u2192 Enable Developer Mode, then Developer \u2192 Configure Third-Party Inference.";
|
|
2371
|
-
function claudeDesktopRefusal() {
|
|
2372
|
-
return process.platform === "linux" ? CLAUDE_DESKTOP_NO_PROFILE : CLAUDE_DESKTOP_UNVERIFIED_PLATFORM;
|
|
2373
|
-
}
|
|
2374
2623
|
async function runClaudeDesktopSetup(creds, routingUrl, opts, deps) {
|
|
2375
2624
|
const profilePath = resolveClaudeDesktopAppliedProfile();
|
|
2376
2625
|
if (!profilePath) {
|
|
@@ -2433,77 +2682,6 @@ function printClaudeDesktopPreview(profilePath, routingUrl) {
|
|
|
2433
2682
|
}
|
|
2434
2683
|
console.log(`# inferenceCustomHeaders["X-LunaRoute-Client"] = "claude-desktop" (your other entries are kept)`);
|
|
2435
2684
|
}
|
|
2436
|
-
var REVERSIBLE = ["claude-desktop"];
|
|
2437
|
-
async function runRemove(harness, opts, deps) {
|
|
2438
|
-
if (!REVERSIBLE.includes(harness)) {
|
|
2439
|
-
console.error(`${harness} has no reverse; supports: ${REVERSIBLE.join(", ")}.`);
|
|
2440
|
-
return 1;
|
|
2441
|
-
}
|
|
2442
|
-
const profilePath = resolveClaudeDesktopAppliedProfile();
|
|
2443
|
-
if (!profilePath) {
|
|
2444
|
-
console.error(claudeDesktopRefusal());
|
|
2445
|
-
return 1;
|
|
2446
|
-
}
|
|
2447
|
-
const snapPath = claudeDesktopSnapshotPath(profilePath);
|
|
2448
|
-
const status = claudeDesktopSnapshotStatus(profilePath);
|
|
2449
|
-
const hasSnapshot = status === "regular";
|
|
2450
|
-
const takenAt = hasSnapshot ? claudeDesktopSnapshotTakenAt(profilePath) : null;
|
|
2451
|
-
if (opts.print) {
|
|
2452
|
-
console.log(
|
|
2453
|
-
hasSnapshot ? `# would restore ${profilePath} from ${snapPath}${takenAt ? ` (taken ${takenAt})` : ""}` : status === "invalid" ? `# would refuse: ${snapPath} is not a regular file` : `# would leave ${profilePath} unchanged (no snapshot)`
|
|
2454
|
-
);
|
|
2455
|
-
if (!hasSnapshot) printClaudeDesktopKeysByHand(profilePath);
|
|
2456
|
-
return 0;
|
|
2457
|
-
}
|
|
2458
|
-
if (status === "invalid") {
|
|
2459
|
-
console.error(
|
|
2460
|
-
`Refusing to touch ${profilePath}: ${snapPath} is not a regular file (a symlink, directory or FIFO), so it is not a usable snapshot. Inspect and remove it by hand.`
|
|
2461
|
-
);
|
|
2462
|
-
return 1;
|
|
2463
|
-
}
|
|
2464
|
-
if (!hasSnapshot) {
|
|
2465
|
-
console.log(
|
|
2466
|
-
"No snapshot exists for this profile \u2014 nothing was changed, and nothing was removed (a hand-configured profile can hold exactly the values we would write, and value matching is not authorship). Remove these by hand:"
|
|
2467
|
-
);
|
|
2468
|
-
printClaudeDesktopKeysByHand(profilePath);
|
|
2469
|
-
return 0;
|
|
2470
|
-
}
|
|
2471
|
-
try {
|
|
2472
|
-
const question = `Restore ${profilePath} from the snapshot at ${snapPath}${takenAt ? ` taken ${takenAt}` : ""}?`;
|
|
2473
|
-
if (!await deps.confirm(question, { yes: opts.yes })) {
|
|
2474
|
-
console.log("Skipped. Nothing written.");
|
|
2475
|
-
return 0;
|
|
2476
|
-
}
|
|
2477
|
-
} catch (err) {
|
|
2478
|
-
if (err instanceof NonInteractiveTerminalError) {
|
|
2479
|
-
console.error(
|
|
2480
|
-
"No interactive terminal available. Re-run with --yes to accept prompts, or --print to preview without writing."
|
|
2481
|
-
);
|
|
2482
|
-
return 1;
|
|
2483
|
-
}
|
|
2484
|
-
throw err;
|
|
2485
|
-
}
|
|
2486
|
-
try {
|
|
2487
|
-
const { restored } = restoreClaudeDesktopProfile(profilePath);
|
|
2488
|
-
console.log(
|
|
2489
|
-
restored ? `Restored ${profilePath} from ${snapPath}.` : `Already restored \u2014 ${profilePath} matches the snapshot; nothing written.`
|
|
2490
|
-
);
|
|
2491
|
-
return 0;
|
|
2492
|
-
} catch (err) {
|
|
2493
|
-
console.error(err instanceof Error ? err.message : String(err));
|
|
2494
|
-
return 1;
|
|
2495
|
-
}
|
|
2496
|
-
}
|
|
2497
|
-
function printClaudeDesktopKeysByHand(profilePath) {
|
|
2498
|
-
console.log(` in ${profilePath}:`);
|
|
2499
|
-
for (const [k, v] of Object.entries(claudeDesktopKeys("<your-routing-url>", "<your-lr_\u2026-key>"))) {
|
|
2500
|
-
if (k === "inferenceCustomHeaders") continue;
|
|
2501
|
-
console.log(` delete ${k} only if it is ${JSON.stringify(v)}`);
|
|
2502
|
-
}
|
|
2503
|
-
console.log(
|
|
2504
|
-
' inside inferenceCustomHeaders, delete ONLY the "X-LunaRoute-Client": "claude-desktop" entry \u2014 keep your other header entries'
|
|
2505
|
-
);
|
|
2506
|
-
}
|
|
2507
2685
|
async function runHermesSetup(creds, routingUrl, opts, deps) {
|
|
2508
2686
|
const commands = hermesConfigSetArgs(routingUrl, creds.routing_key);
|
|
2509
2687
|
try {
|
|
@@ -3384,12 +3562,12 @@ function buildRunSpec2(ctx) {
|
|
|
3384
3562
|
}
|
|
3385
3563
|
|
|
3386
3564
|
// src/run/adapters/zed.ts
|
|
3387
|
-
import { existsSync as
|
|
3565
|
+
import { existsSync as existsSync7, readFileSync as readFileSync8, realpathSync as realpathSync2 } from "fs";
|
|
3388
3566
|
import { homedir as homedir3 } from "os";
|
|
3389
3567
|
import { basename as basename2, dirname as dirname4, join as join6 } from "path";
|
|
3390
3568
|
|
|
3391
3569
|
// src/run/which.ts
|
|
3392
|
-
import { accessSync, constants as
|
|
3570
|
+
import { accessSync, constants as constants3 } from "fs";
|
|
3393
3571
|
import { join as join5 } from "path";
|
|
3394
3572
|
function which(cmd, env, platform) {
|
|
3395
3573
|
const pathVar = env.PATH ?? env.Path ?? "";
|
|
@@ -3400,7 +3578,7 @@ function which(cmd, env, platform) {
|
|
|
3400
3578
|
for (const ext of alreadyHasExt ? [""] : exts) {
|
|
3401
3579
|
const candidate = join5(dir, cmd + ext);
|
|
3402
3580
|
try {
|
|
3403
|
-
accessSync(candidate, platform === "win32" ?
|
|
3581
|
+
accessSync(candidate, platform === "win32" ? constants3.F_OK : constants3.X_OK);
|
|
3404
3582
|
return candidate;
|
|
3405
3583
|
} catch {
|
|
3406
3584
|
}
|
|
@@ -3411,7 +3589,7 @@ function which(cmd, env, platform) {
|
|
|
3411
3589
|
|
|
3412
3590
|
// src/run/adapters/zed.ts
|
|
3413
3591
|
function firstExisting(paths) {
|
|
3414
|
-
for (const path of paths) if (
|
|
3592
|
+
for (const path of paths) if (existsSync7(path)) return path;
|
|
3415
3593
|
return null;
|
|
3416
3594
|
}
|
|
3417
3595
|
function resolveZedCommand(deps = {}) {
|
|
@@ -3425,7 +3603,7 @@ function resolveZedCommand(deps = {}) {
|
|
|
3425
3603
|
const real = realpathSync2(shim);
|
|
3426
3604
|
if (basename2(real) === "cli") {
|
|
3427
3605
|
const app = join6(dirname4(real), "zed");
|
|
3428
|
-
if (
|
|
3606
|
+
if (existsSync7(app)) return app;
|
|
3429
3607
|
}
|
|
3430
3608
|
return real;
|
|
3431
3609
|
} catch {
|
|
@@ -3473,13 +3651,13 @@ function buildRunSpec3(ctx, deps = {}) {
|
|
|
3473
3651
|
}
|
|
3474
3652
|
|
|
3475
3653
|
// src/run/adapters/agy.ts
|
|
3476
|
-
import { accessSync as accessSync2, constants as
|
|
3654
|
+
import { accessSync as accessSync2, constants as constants4 } from "fs";
|
|
3477
3655
|
import { homedir as homedir4 } from "os";
|
|
3478
3656
|
import { join as join7 } from "path";
|
|
3479
3657
|
function firstRunnable(paths, platform) {
|
|
3480
3658
|
for (const path of paths) {
|
|
3481
3659
|
try {
|
|
3482
|
-
accessSync2(path, platform === "win32" ?
|
|
3660
|
+
accessSync2(path, platform === "win32" ? constants4.F_OK : constants4.X_OK);
|
|
3483
3661
|
return path;
|
|
3484
3662
|
} catch {
|
|
3485
3663
|
}
|
|
@@ -3637,7 +3815,7 @@ apiKey.command("show").description('Show the stored API key (same as "lunaroute
|
|
|
3637
3815
|
program.command("logout").description("Remove stored credentials for the active profile.").action(() => {
|
|
3638
3816
|
logout(program.opts().profile);
|
|
3639
3817
|
});
|
|
3640
|
-
program.command("setup <harness>").description("Configure a coding harness (opencode | pi | hermes | claude-code | claude-desktop | codex | copilot-cli | openclaw | dsh | zed | agy | generic).").option("--print", "print the config instead of writing files", false).option("--routing-url <url>", "override the routing base URL").option("--yes", "accept all confirmation prompts without a TTY (for scripts)", false).option("--extension", "pi only: jump straight to installing the Pi extension").option("--models", "pi only: jump straight to writing the models.json provider block").option("--remove", "claude-desktop
|
|
3818
|
+
program.command("setup <harness>").description("Configure a coding harness (opencode | pi | hermes | claude-code | claude-desktop | codex | copilot-cli | openclaw | dsh | zed | agy | generic).").option("--print", "print the config instead of writing files", false).option("--routing-url <url>", "override the routing base URL").option("--yes", "accept all confirmation prompts without a TTY (for scripts)", false).option("--extension", "pi only: jump straight to installing the Pi extension").option("--models", "pi only: jump straight to writing the models.json provider block").option("--remove", "undo a setup: claude-desktop restores its snapshot, codex deletes its profile file, export-only harnesses print what to remove").option("--key <key>", "a LunaRoute routing key (lr_\u2026), e.g. from the dashboard's onboarding page \u2014 stores it and skips the browser login").action(async (harness, opts) => {
|
|
3641
3819
|
const code = await runSetup(harness, {
|
|
3642
3820
|
profile: program.opts().profile,
|
|
3643
3821
|
print: opts.print,
|