Open History to see the last commit
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});