Skip to content

Commit 405dbc6

Browse files
la14-1louisgvclaude
authored
refactor: use getSpawnCloudConfigPath(), remove dead _cloudName param (#3010) (#3012)
Replace hand-constructed openrouter.json path with getSpawnCloudConfigPath("openrouter") for single-source-of-truth path resolution. Remove unused _cloudName parameter since the function delegates ALL cloud credentials unconditionally. Agent: ux-engineer Co-authored-by: B <6723574+louisgv@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent fd36ff0 commit 405dbc6

3 files changed

Lines changed: 9 additions & 10 deletions

File tree

packages/cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@openrouter/spawn",
3-
"version": "0.26.10",
3+
"version": "0.26.11",
44
"type": "module",
55
"bin": {
66
"spawn": "cli.js"

packages/cli/src/__tests__/recursive-spawn.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ describe("recursive spawn", () => {
269269
};
270270

271271
// No credential files exist in test sandbox, so should warn and return
272-
await delegateCloudCredentials(mockRunner, "hetzner");
272+
await delegateCloudCredentials(mockRunner);
273273

274274
// Should not have run mkdir since there are no files to delegate
275275
expect(commands.length).toBe(0);
@@ -294,7 +294,7 @@ describe("recursive spawn", () => {
294294
downloadFile: async () => {},
295295
};
296296

297-
await delegateCloudCredentials(mockRunner, "hetzner");
297+
await delegateCloudCredentials(mockRunner);
298298

299299
// Should have run mkdir + 2 file writes
300300
expect(commands.length).toBe(3);
@@ -326,7 +326,7 @@ describe("recursive spawn", () => {
326326
};
327327

328328
// Should not throw
329-
await delegateCloudCredentials(mockRunner, "hetzner");
329+
await delegateCloudCredentials(mockRunner);
330330
// At least 2 calls: mkdir + file write(s) that fail
331331
expect(callCount).toBeGreaterThanOrEqual(2);
332332
});
@@ -351,7 +351,7 @@ describe("recursive spawn", () => {
351351
};
352352

353353
// Should not throw, just warn
354-
await delegateCloudCredentials(mockRunner, "hetzner");
354+
await delegateCloudCredentials(mockRunner);
355355
// mkdir was called and failed
356356
expect(callCount).toBe(1);
357357
});

packages/cli/src/shared/orchestrate.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { offerGithubAuth, setupAutoUpdate, wrapSshCall } from "./agent-setup.js"
1414
import { tryTarballInstall } from "./agent-tarball.js";
1515
import { generateEnvConfig } from "./agents.js";
1616
import { getOrPromptApiKey } from "./oauth.js";
17-
import { getSpawnCloudConfigPath, getSpawnPreferencesPath, getUserHome } from "./paths.js";
17+
import { getSpawnCloudConfigPath, getSpawnPreferencesPath } from "./paths.js";
1818
import { asyncTryCatch, asyncTryCatchIf, isOperationalError, tryCatch } from "./result.js";
1919
import { isWindows } from "./shell.js";
2020
import { injectSpawnSkill } from "./spawn-skill.js";
@@ -137,7 +137,7 @@ export async function installSpawnCli(runner: CloudRunner): Promise<void> {
137137
}
138138

139139
/** Copy local cloud credentials to the remote VM for recursive spawning. */
140-
export async function delegateCloudCredentials(runner: CloudRunner, _cloudName: string): Promise<void> {
140+
export async function delegateCloudCredentials(runner: CloudRunner): Promise<void> {
141141
logStep("Delegating cloud credentials to VM...");
142142

143143
const filesToDelegate: {
@@ -147,7 +147,6 @@ export async function delegateCloudCredentials(runner: CloudRunner, _cloudName:
147147

148148
// Delegate ALL cloud credentials so the child VM can spawn on any cloud,
149149
// not just the one the parent is running on.
150-
const configDir = `${getUserHome()}/.config/spawn`;
151150
const cloudNames = [
152151
"hetzner",
153152
"digitalocean",
@@ -166,7 +165,7 @@ export async function delegateCloudCredentials(runner: CloudRunner, _cloudName:
166165
}
167166

168167
// OpenRouter credentials (always needed for child spawns)
169-
const orConfigPath = `${configDir}/openrouter.json`;
168+
const orConfigPath = getSpawnCloudConfigPath("openrouter");
170169
if (existsSync(orConfigPath)) {
171170
filesToDelegate.push({
172171
localPath: orConfigPath,
@@ -577,7 +576,7 @@ async function postInstall(
577576
(!enabledSteps || enabledSteps.has("spawn"))
578577
) {
579578
await installSpawnCli(cloud.runner);
580-
await delegateCloudCredentials(cloud.runner, cloud.cloudName);
579+
await delegateCloudCredentials(cloud.runner);
581580
await injectSpawnSkill(cloud.runner, agentName);
582581
}
583582

0 commit comments

Comments
 (0)