Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

refactor(claude): move the endpoint folder step to its own file (file-size ratchet)

AdityaUmale0bdb47a87630
diff --git a/server/drivers/claude-endpoint-folder.ts b/server/drivers/claude-endpoint-folder.ts
new file mode 100644
index 0000000000..901f7450df
--- /dev/null
+++ b/server/drivers/claude-endpoint-folder.ts
@@ -0,0 +1,13 @@
+import { mkdirSync } from "node:fs";
+
+/**
+ * A custom endpoint (Settings > Custom endpoint) gets its own Claude folder under providers/, but no sign-in that would
+ * make it. On a Cloud the bot box binds that folder as a required path, and bubblewrap stops the turn when it is missing
+ * ("Can't find source path"), so it is made before every spawn. Claude accounts and the default Claude are untouched.
+ */
+export function withEndpointFolder<T extends Record<string, string | undefined>>(
+ env: T, config: { endpointModels?: unknown; configDir?: string },
+): T {
+ if (config.endpointModels && config.configDir && env.CLAUDE_CONFIG_DIR) mkdirSync(env.CLAUDE_CONFIG_DIR, { recursive: true, mode: 0o700 });
+ return env;
+}
diff --git a/server/drivers/claude.ts b/server/drivers/claude.ts
index 02c4b90ba6..2e2c96f7b3 100644
--- a/server/drivers/claude.ts
+++ b/server/drivers/claude.ts
@@ -57,7 +57,7 @@ import {
} from "./local-inject.ts";
import { appendNative } from "./native.ts";
import type { KeepWarmContract } from "./claude-keepwarm.ts"; import { claudeForks } from "./claude-warm-summary.ts";
-import { BACKGROUND_CALL_TIMEOUT_MS, backgroundCallArgs, spawnBackgroundCall } from "./claude-background.ts";
+import { BACKGROUND_CALL_TIMEOUT_MS, backgroundCallArgs, spawnBackgroundCall } from "./claude-background.ts"; import { withEndpointFolder } from "./claude-endpoint-folder.ts";
import { permissionLaunchCwd, shellRequest } from "./permission-command.ts"; import { readToolPaths } from "../own-file-reads.ts";
import { SPAWNED_PROXIES } from "../proxy-paths.ts"; import { OWN_APPS_SERVER } from "../../shared/own-apps.ts";
import { extractMcpImages } from "../mcp-tool-images.ts"; import { claudeToolDraft } from "./tool-progress.ts";
@@ -1143,10 +1143,7 @@ export const ClaudeDriver: ProviderDriver<ClaudeConfig> = {
args.push("--allowedTools", allowed.join(","));
}
- const env = environment(config.endpointModels ? undefined : turnModel);
- // A custom endpoint has no sign-in to make its own folder, and the bot box binds that folder: bubblewrap stops a turn
- // whose folder is missing ("Can't find source path"), so it is made here before every spawn.
- if (config.endpointModels && config.configDir && env.CLAUDE_CONFIG_DIR) mkdirSync(env.CLAUDE_CONFIG_DIR, { recursive: true, mode: 0o700 });
+ const env = withEndpointFolder(environment(config.endpointModels ? undefined : turnModel), config);
const authSettings = isolated && !injected.injected
? readClaudeAuthSettings(env, input.environment) : {};
// The hook helper reads its bearer from a per-thread file refreshed every turn, so a