authorgravatar for yordis.prieto@gmail.comYordis Prieto <yordis.prieto@gmail.com> 2026-10-04 00:34:34-04:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2026-10-03 21:34:34-07:00
log60a56f11e73dfc9c26e74f8f8e93e391191fc3f8
treece21dd93951cff6c090e0f0a99bbc2ad48e98093
parent8fb068c4982fc50a2a2f57c3b6fd4731735cf0bf
signature Signed by PGP key B5690EEEBB952194

test(server): the registry's fake Claude CLI is a fixture file, not a generated string (#15463)

Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>

2 files changed, 75 insertions(+), 55 deletions(-)

apps/server/src/provider/Layers/ProviderInstanceRegistryLive.test.ts+4-55
......@@ -177,62 +177,11 @@ const makeTildeProviderFixtures = Effect.fn(
177177 );
178178 yield* fileSystem.chmod(codexPath, 0o755);
179179
180 yield* fileSystem.writeFileString(
180 yield* fileSystem.copyFile(
181 yield* path.fromFileUrl(
182 new URL("./testing/ProviderInstanceRegistryLive.fixture.mjs", import.meta.url),
183 ),
181184 claudePath,
182 [
183 "#!/usr/bin/env node",
184 'import { existsSync } from "node:fs";',
185 'import * as NodeReadline from "node:readline";',
186 'if (process.argv.includes("--version")) {',
187 ' process.stdout.write("claude 2.1.219\\n");',
188 " process.exit(0);",
189 "}",
190 "const lines = NodeReadline.createInterface({ input: process.stdin });",
191 'lines.on("line", (line) => {',
192 " const message = JSON.parse(line);",
193 ' if (message.type !== "control_request") return;',
194 ' if (message.request?.subtype === "get_usage") {',
195 " const marker = process.env.T3_CLAUDE_RESET_MARKER;",
196 " if (process.env.T3_CLAUDE_USAGE_FAILS_AFTER_CLAIM && marker && existsSync(marker)) {",
197 " process.stdout.write(JSON.stringify({",
198 ' type: "control_response",',
199 ' response: { subtype: "error", request_id: message.request_id, error: "usage failed" },',
200 ' }) + "\\n");',
201 " return;",
202 " }",
203 " process.stdout.write(JSON.stringify({",
204 ' type: "control_response",',
205 ' response: { subtype: "success", request_id: message.request_id, response: {',
206 ' session: {}, subscription_type: "pro", rate_limits_available: true,',
207 " rate_limits: { five_hour: { utilization: marker && existsSync(marker) ? 0 : 100, resets_at: null } },",
208 " } },",
209 ' }) + "\\n");',
210 " return;",
211 " }",
212 ' if (message.request?.subtype !== "initialize") return;',
213 " process.stdout.write(JSON.stringify({",
214 ' type: "control_response",',
215 " response: {",
216 ' subtype: "success",',
217 " request_id: message.request_id,",
218 " response: {",
219 " commands: [], agents: [], models: [],",
220 ' output_style: "default", available_output_styles: ["default"],',
221 ' account: { email: "test@example.com", subscriptionType: "pro", tokenSource: "oauth" },',
222 " },",
223 " },",
224 ' }) + "\\n");',
225 "});",
226 "// Stay alive for follow-up control requests, but never outlive the",
227 "// parent: the probe aborts the SDK without awaiting the child, so an",
228 "// unconditional interval would strand this process until reboot.",
229 "const keepAlive = setInterval(() => {}, 1_000);",
230 'lines.on("close", () => {',
231 " clearInterval(keepAlive);",
232 " process.exit(0);",
233 "});",
234 "",
235 ].join("\n"),
236185 );
237186 yield* fileSystem.chmod(claudePath, 0o755);
238187 yield* fileSystem.makeDirectory(claudeHomePath);
apps/server/src/provider/Layers/testing/ProviderInstanceRegistryLive.fixture.mjs created+71
......@@ -0,0 +1,71 @@
1#!/usr/bin/env node
2import * as NodeFS from "node:fs";
3import * as NodeReadline from "node:readline";
4if (process.argv.includes("--version")) {
5 process.stdout.write("claude 2.1.219\n");
6 process.exit(0);
7}
8const lines = NodeReadline.createInterface({ input: process.stdin });
9lines.on("line", (line) => {
10 const message = JSON.parse(line);
11 if (message.type !== "control_request") return;
12 if (message.request?.subtype === "get_usage") {
13 const marker = process.env.T3_CLAUDE_RESET_MARKER;
14 if (process.env.T3_CLAUDE_USAGE_FAILS_AFTER_CLAIM && marker && NodeFS.existsSync(marker)) {
15 process.stdout.write(
16 JSON.stringify({
17 type: "control_response",
18 response: { subtype: "error", request_id: message.request_id, error: "usage failed" },
19 }) + "\n",
20 );
21 return;
22 }
23 process.stdout.write(
24 JSON.stringify({
25 type: "control_response",
26 response: {
27 subtype: "success",
28 request_id: message.request_id,
29 response: {
30 session: {},
31 subscription_type: "pro",
32 rate_limits_available: true,
33 rate_limits: {
34 five_hour: {
35 utilization: marker && NodeFS.existsSync(marker) ? 0 : 100,
36 resets_at: null,
37 },
38 },
39 },
40 },
41 }) + "\n",
42 );
43 return;
44 }
45 if (message.request?.subtype !== "initialize") return;
46 process.stdout.write(
47 JSON.stringify({
48 type: "control_response",
49 response: {
50 subtype: "success",
51 request_id: message.request_id,
52 response: {
53 commands: [],
54 agents: [],
55 models: [],
56 output_style: "default",
57 available_output_styles: ["default"],
58 account: { email: "test@example.com", subscriptionType: "pro", tokenSource: "oauth" },
59 },
60 },
61 }) + "\n",
62 );
63});
64// Stay alive for follow-up control requests, but never outlive the
65// parent: the probe aborts the SDK without awaiting the child, so an
66// unconditional interval would strand this process until reboot.
67const keepAlive = setInterval(() => {}, 1_000);
68lines.on("close", () => {
69 clearInterval(keepAlive);
70 process.exit(0);
71});