TypeScript
test(server): the registry's fake Claude CLI is a fixture file, not a generated string (#15463)
Yordis Prieto60a56f11e73d
diff --git a/apps/server/src/provider/Layers/ProviderInstanceRegistryLive.test.ts b/apps/server/src/provider/Layers/ProviderInstanceRegistryLive.test.tsindex 1b6f23b08eb..ef6366749be 100644--- a/apps/server/src/provider/Layers/ProviderInstanceRegistryLive.test.ts+++ b/apps/server/src/provider/Layers/ProviderInstanceRegistryLive.test.ts@@ -177,62 +177,11 @@ const makeTildeProviderFixtures = Effect.fn();yield* fileSystem.chmod(codexPath, 0o755);- yield* fileSystem.writeFileString(+ yield* fileSystem.copyFile(+ yield* path.fromFileUrl(+ new URL("./testing/ProviderInstanceRegistryLive.fixture.mjs", import.meta.url),+ ),claudePath,- [- "#!/usr/bin/env node",- 'import { existsSync } from "node:fs";',- 'import * as NodeReadline from "node:readline";',- 'if (process.argv.includes("--version")) {',- ' process.stdout.write("claude 2.1.219\\n");',- " process.exit(0);",- "}",- "const lines = NodeReadline.createInterface({ input: process.stdin });",- 'lines.on("line", (line) => {',- " const message = JSON.parse(line);",- ' if (message.type !== "control_request") return;',- ' if (message.request?.subtype === "get_usage") {',- " const marker = process.env.T3_CLAUDE_RESET_MARKER;",- " if (process.env.T3_CLAUDE_USAGE_FAILS_AFTER_CLAIM && marker && existsSync(marker)) {",- " process.stdout.write(JSON.stringify({",- ' type: "control_response",',- ' response: { subtype: "error", request_id: message.request_id, error: "usage failed" },',- ' }) + "\\n");',- " return;",- " }",- " process.stdout.write(JSON.stringify({",- ' type: "control_response",',- ' response: { subtype: "success", request_id: message.request_id, response: {',- ' session: {}, subscription_type: "pro", rate_limits_available: true,',- " rate_limits: { five_hour: { utilization: marker && existsSync(marker) ? 0 : 100, resets_at: null } },",- " } },",- ' }) + "\\n");',- " return;",- " }",- ' if (message.request?.subtype !== "initialize") return;',- " process.stdout.write(JSON.stringify({",- ' type: "control_response",',- " response: {",- ' subtype: "success",',- " request_id: message.request_id,",- " response: {",- " commands: [], agents: [], models: [],",- ' output_style: "default", available_output_styles: ["default"],',- ' account: { email: "[email protected]", subscriptionType: "pro", tokenSource: "oauth" },',- " },",- " },",- ' }) + "\\n");',- "});",- "// 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* fileSystem.chmod(claudePath, 0o755);yield* fileSystem.makeDirectory(claudeHomePath);diff --git a/apps/server/src/provider/Layers/testing/ProviderInstanceRegistryLive.fixture.mjs b/apps/server/src/provider/Layers/testing/ProviderInstanceRegistryLive.fixture.mjsnew file mode 100755index 00000000000..054ca04703e--- /dev/null+++ b/apps/server/src/provider/Layers/testing/ProviderInstanceRegistryLive.fixture.mjs@@ -0,0 +1,71 @@+#!/usr/bin/env node+import * as NodeFS from "node:fs";+import * as NodeReadline from "node:readline";+if (process.argv.includes("--version")) {+ process.stdout.write("claude 2.1.219\n");+ process.exit(0);+}+const lines = NodeReadline.createInterface({ input: process.stdin });+lines.on("line", (line) => {+ const message = JSON.parse(line);+ if (message.type !== "control_request") return;+ if (message.request?.subtype === "get_usage") {+ const marker = process.env.T3_CLAUDE_RESET_MARKER;+ if (process.env.T3_CLAUDE_USAGE_FAILS_AFTER_CLAIM && marker && NodeFS.existsSync(marker)) {+ process.stdout.write(+ JSON.stringify({+ type: "control_response",+ response: { subtype: "error", request_id: message.request_id, error: "usage failed" },+ }) + "\n",+ );+ return;+ }+ process.stdout.write(+ JSON.stringify({+ type: "control_response",+ response: {+ subtype: "success",+ request_id: message.request_id,+ response: {+ session: {},+ subscription_type: "pro",+ rate_limits_available: true,+ rate_limits: {+ five_hour: {+ utilization: marker && NodeFS.existsSync(marker) ? 0 : 100,+ resets_at: null,+ },+ },+ },+ },+ }) + "\n",+ );+ return;+ }+ if (message.request?.subtype !== "initialize") return;+ process.stdout.write(+ JSON.stringify({+ type: "control_response",+ response: {+ subtype: "success",+ request_id: message.request_id,+ response: {+ commands: [],+ agents: [],+ models: [],+ output_style: "default",+ available_output_styles: ["default"],+ account: { email: "[email protected]", subscriptionType: "pro", tokenSource: "oauth" },+ },+ },+ }) + "\n",+ );+});+// 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);+});