TypeScript
test(server): the fake Claude CLI is a fixture file, not a generated string (#14950)
Yordis Prieto858b98b8fa61
diff --git a/apps/server/src/provider/Layers/ClaudeCapabilitiesProbe.test.ts b/apps/server/src/provider/Layers/ClaudeCapabilitiesProbe.test.tsindex bb6e5bd7c7d..ad54e41f0cc 100644--- a/apps/server/src/provider/Layers/ClaudeCapabilitiesProbe.test.ts+++ b/apps/server/src/provider/Layers/ClaudeCapabilitiesProbe.test.ts@@ -58,7 +58,9 @@ it.layer(NodeServices.layer)("Claude capability probe SDK boundary", (it) => {const fs = yield* FileSystem.FileSystem;const path = yield* Path.Path;const tempDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-claude-probe-sdk-" });- const executablePath = path.join(tempDir, "fake-claude.mjs");+ const executablePath = yield* path.fromFileUrl(+ new URL("./testing/ClaudeCapabilitiesProbe.fixture.mjs", import.meta.url),+ );const invocationPath = path.join(tempDir, "invocation.json");// The probe aborts the SDK without awaiting the child's exit, and on// Windows a directory that is still some process's cwd cannot be@@ -80,68 +82,6 @@ it.layer(NodeServices.layer)("Claude capability probe SDK boundary", (it) => {),);- yield* fs.writeFileString(- executablePath,- [- "#!/usr/bin/env node",- 'import { existsSync, readFileSync, writeFileSync } from "node:fs";',- 'import { createInterface } from "node:readline";',- "const args = process.argv.slice(2);",- 'const mcpConfigIndex = args.indexOf("--mcp-config");',- "const rawMcpConfig = mcpConfigIndex >= 0 ? args[mcpConfigIndex + 1] : undefined;",- "let mcpConfig;",- "if (rawMcpConfig) {",- ' const contents = existsSync(rawMcpConfig) ? readFileSync(rawMcpConfig, "utf8") : rawMcpConfig;',- " try { mcpConfig = JSON.parse(contents); } catch { mcpConfig = contents; }",- "}",- "writeFileSync(process.env.T3_PROBE_INVOCATION_PATH, JSON.stringify({",- " args,",- " cwd: process.cwd(),",- " connectorEnv: process.env.ENABLE_CLAUDEAI_MCP_SERVERS,",- " mcpConfig,",- "}));",- "const lines = createInterface({ input: process.stdin });",- 'lines.on("line", (line) => {',- " const message = JSON.parse(line);",- ' if (message.type !== "control_request") return;',- " const reply = (response) => process.stdout.write(JSON.stringify({",- ' type: "control_response",',- ' response: { subtype: "success", request_id: message.request_id, response },',- ' }) + "\\n");',- ' if (message.request?.subtype === "initialize") {',- " reply({",- ' commands: [{ name: "review", description: "Review changes", argumentHint: "[path]" }],',- " agents: [],",- ' output_style: "default",',- ' available_output_styles: ["default"],',- " models: [],",- ' account: { email: "[email protected]", subscriptionType: "pro", tokenSource: "oauth" },',- " });",- " }",- " // The probe follows initialize with get_usage on the same process.",- ' if (message.request?.subtype === "get_usage") {',- " reply({",- " session: {},",- ' subscription_type: "pro",',- " rate_limits_available: true,",- ' rate_limits: { five_hour: { utilization: 12, resets_at: "2026-07-18T14:39:00Z" } },',- " behaviors: null,",- " });",- " }",- "});",- "// Stay alive for follow-up control requests, but never outlive the",- "// parent: the probe aborts the SDK without awaiting the child, so an",- "// unconditional interval would strand this process until reboot.",- "const keepAlive = setInterval(() => {}, 1_000);",- 'lines.on("close", () => {',- " clearInterval(keepAlive);",- " process.exit(0);",- "});",- "",- ].join("\n"),- );- yield* fs.chmod(executablePath, 0o755);-const capabilities = yield* probeClaudeCapabilities(decodeClaudeSettings({ binaryPath: executablePath }),{diff --git a/apps/server/src/provider/Layers/testing/ClaudeCapabilitiesProbe.fixture.mjs b/apps/server/src/provider/Layers/testing/ClaudeCapabilitiesProbe.fixture.mjsnew file mode 100755index 00000000000..57fc1795cb6--- /dev/null+++ b/apps/server/src/provider/Layers/testing/ClaudeCapabilitiesProbe.fixture.mjs@@ -0,0 +1,66 @@+#!/usr/bin/env node+import * as NodeFS from "node:fs";+import * as NodeReadline from "node:readline";+const args = process.argv.slice(2);+const mcpConfigIndex = args.indexOf("--mcp-config");+const rawMcpConfig = mcpConfigIndex >= 0 ? args[mcpConfigIndex + 1] : undefined;+let mcpConfig;+if (rawMcpConfig) {+ const contents = NodeFS.existsSync(rawMcpConfig)+ ? NodeFS.readFileSync(rawMcpConfig, "utf8")+ : rawMcpConfig;+ try {+ mcpConfig = JSON.parse(contents);+ } catch {+ mcpConfig = contents;+ }+}+NodeFS.writeFileSync(+ process.env.T3_PROBE_INVOCATION_PATH,+ JSON.stringify({+ args,+ cwd: process.cwd(),+ connectorEnv: process.env.ENABLE_CLAUDEAI_MCP_SERVERS,+ mcpConfig,+ }),+);+const lines = NodeReadline.createInterface({ input: process.stdin });+lines.on("line", (line) => {+ const message = JSON.parse(line);+ if (message.type !== "control_request") return;+ const reply = (response) =>+ process.stdout.write(+ JSON.stringify({+ type: "control_response",+ response: { subtype: "success", request_id: message.request_id, response },+ }) + "\n",+ );+ if (message.request?.subtype === "initialize") {+ reply({+ commands: [{ name: "review", description: "Review changes", argumentHint: "[path]" }],+ agents: [],+ output_style: "default",+ available_output_styles: ["default"],+ models: [],+ account: { email: "[email protected]", subscriptionType: "pro", tokenSource: "oauth" },+ });+ }+ // The probe follows initialize with get_usage on the same process.+ if (message.request?.subtype === "get_usage") {+ reply({+ session: {},+ subscription_type: "pro",+ rate_limits_available: true,+ rate_limits: { five_hour: { utilization: 12, resets_at: "2026-07-18T14:39:00Z" } },+ behaviors: null,+ });+ }+});+// Stay alive for follow-up control requests, but never outlive the+// parent: the probe aborts the SDK without awaiting the child, so an+// unconditional interval would strand this process until reboot.+const keepAlive = setInterval(() => {}, 1_000);+lines.on("close", () => {+ clearInterval(keepAlive);+ process.exit(0);+});