claude-code-infinite 1.0.11 → 1.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. package/README.md +214 -47
  2. package/dist/cc-request.d.ts +94 -0
  3. package/dist/cc-request.d.ts.map +1 -0
  4. package/dist/cc-request.js +194 -0
  5. package/dist/cc-request.js.map +1 -0
  6. package/dist/claude-env.d.ts +30 -0
  7. package/dist/claude-env.d.ts.map +1 -0
  8. package/dist/claude-env.js +55 -0
  9. package/dist/claude-env.js.map +1 -0
  10. package/dist/cli-args.d.ts +32 -0
  11. package/dist/cli-args.d.ts.map +1 -0
  12. package/dist/cli-args.js +72 -0
  13. package/dist/cli-args.js.map +1 -0
  14. package/dist/cli-lifecycle.d.ts +17 -0
  15. package/dist/cli-lifecycle.d.ts.map +1 -0
  16. package/dist/cli-lifecycle.js +30 -0
  17. package/dist/cli-lifecycle.js.map +1 -0
  18. package/dist/cli-main.d.ts +15 -0
  19. package/dist/cli-main.d.ts.map +1 -0
  20. package/dist/cli-main.js +464 -0
  21. package/dist/cli-main.js.map +1 -0
  22. package/dist/cli.js +13 -178
  23. package/dist/cli.js.map +1 -1
  24. package/dist/config.d.ts +3 -0
  25. package/dist/config.d.ts.map +1 -1
  26. package/dist/config.js +29 -3
  27. package/dist/config.js.map +1 -1
  28. package/dist/count-tokens.d.ts +78 -0
  29. package/dist/count-tokens.d.ts.map +1 -0
  30. package/dist/count-tokens.js +277 -0
  31. package/dist/count-tokens.js.map +1 -0
  32. package/dist/final-index.d.ts +10 -0
  33. package/dist/final-index.d.ts.map +1 -0
  34. package/dist/final-index.js +37 -0
  35. package/dist/final-index.js.map +1 -0
  36. package/dist/hooks.d.ts +239 -0
  37. package/dist/hooks.d.ts.map +1 -0
  38. package/dist/hooks.js +618 -0
  39. package/dist/hooks.js.map +1 -0
  40. package/dist/index.d.ts +9 -0
  41. package/dist/index.d.ts.map +1 -1
  42. package/dist/index.js +8 -0
  43. package/dist/index.js.map +1 -1
  44. package/dist/memtree-fetch.d.ts +24 -0
  45. package/dist/memtree-fetch.d.ts.map +1 -0
  46. package/dist/memtree-fetch.js +121 -0
  47. package/dist/memtree-fetch.js.map +1 -0
  48. package/dist/memtree-finder.d.ts +99 -0
  49. package/dist/memtree-finder.d.ts.map +1 -0
  50. package/dist/memtree-finder.js +235 -0
  51. package/dist/memtree-finder.js.map +1 -0
  52. package/dist/memtree-links.d.ts +16 -0
  53. package/dist/memtree-links.d.ts.map +1 -0
  54. package/dist/memtree-links.js +66 -0
  55. package/dist/memtree-links.js.map +1 -0
  56. package/dist/memtree-mcp-config.d.ts +28 -0
  57. package/dist/memtree-mcp-config.d.ts.map +1 -0
  58. package/dist/memtree-mcp-config.js +121 -0
  59. package/dist/memtree-mcp-config.js.map +1 -0
  60. package/dist/memtree-mcp.d.ts +265 -0
  61. package/dist/memtree-mcp.d.ts.map +1 -0
  62. package/dist/memtree-mcp.js +667 -0
  63. package/dist/memtree-mcp.js.map +1 -0
  64. package/dist/memtree-newest.d.ts +74 -0
  65. package/dist/memtree-newest.d.ts.map +1 -0
  66. package/dist/memtree-newest.js +217 -0
  67. package/dist/memtree-newest.js.map +1 -0
  68. package/dist/memtree-tools.d.ts +105 -0
  69. package/dist/memtree-tools.d.ts.map +1 -0
  70. package/dist/memtree-tools.js +408 -0
  71. package/dist/memtree-tools.js.map +1 -0
  72. package/dist/memtree.d.ts +430 -0
  73. package/dist/memtree.d.ts.map +1 -0
  74. package/dist/memtree.js +1286 -0
  75. package/dist/memtree.js.map +1 -0
  76. package/dist/notices.d.ts +177 -0
  77. package/dist/notices.d.ts.map +1 -0
  78. package/dist/notices.js +469 -0
  79. package/dist/notices.js.map +1 -0
  80. package/dist/payment-gate.d.ts +53 -0
  81. package/dist/payment-gate.d.ts.map +1 -0
  82. package/dist/payment-gate.js +97 -0
  83. package/dist/payment-gate.js.map +1 -0
  84. package/dist/project-meta.d.ts +15 -0
  85. package/dist/project-meta.d.ts.map +1 -0
  86. package/dist/project-meta.js +80 -0
  87. package/dist/project-meta.js.map +1 -0
  88. package/dist/prompt-accounting.d.ts +12 -0
  89. package/dist/prompt-accounting.d.ts.map +1 -0
  90. package/dist/prompt-accounting.js +70 -0
  91. package/dist/prompt-accounting.js.map +1 -0
  92. package/dist/proxy.d.ts +204 -0
  93. package/dist/proxy.d.ts.map +1 -0
  94. package/dist/proxy.js +4299 -0
  95. package/dist/proxy.js.map +1 -0
  96. package/dist/reqlog.d.ts +427 -0
  97. package/dist/reqlog.d.ts.map +1 -0
  98. package/dist/reqlog.js +146 -0
  99. package/dist/reqlog.js.map +1 -0
  100. package/dist/request-sizing.d.ts +74 -0
  101. package/dist/request-sizing.d.ts.map +1 -0
  102. package/dist/request-sizing.js +121 -0
  103. package/dist/request-sizing.js.map +1 -0
  104. package/dist/resume-repair-file.d.ts +17 -0
  105. package/dist/resume-repair-file.d.ts.map +1 -0
  106. package/dist/resume-repair-file.js +100 -0
  107. package/dist/resume-repair-file.js.map +1 -0
  108. package/dist/resume-repair.d.ts +27 -0
  109. package/dist/resume-repair.d.ts.map +1 -0
  110. package/dist/resume-repair.js +198 -0
  111. package/dist/resume-repair.js.map +1 -0
  112. package/dist/route-cache.d.ts +5 -0
  113. package/dist/route-cache.d.ts.map +1 -0
  114. package/dist/route-cache.js +63 -0
  115. package/dist/route-cache.js.map +1 -0
  116. package/dist/route-fallback.d.ts +67 -0
  117. package/dist/route-fallback.d.ts.map +1 -0
  118. package/dist/route-fallback.js +126 -0
  119. package/dist/route-fallback.js.map +1 -0
  120. package/dist/route-identity.d.ts +6 -0
  121. package/dist/route-identity.d.ts.map +1 -0
  122. package/dist/route-identity.js +100 -0
  123. package/dist/route-identity.js.map +1 -0
  124. package/dist/transcript-usage.d.ts +57 -0
  125. package/dist/transcript-usage.d.ts.map +1 -0
  126. package/dist/transcript-usage.js +570 -0
  127. package/dist/transcript-usage.js.map +1 -0
  128. package/dist/turns.d.ts +77 -0
  129. package/dist/turns.d.ts.map +1 -0
  130. package/dist/turns.js +330 -0
  131. package/dist/turns.js.map +1 -0
  132. package/dist/update-check.d.ts +38 -0
  133. package/dist/update-check.d.ts.map +1 -0
  134. package/dist/update-check.js +67 -0
  135. package/dist/update-check.js.map +1 -0
  136. package/package.json +6 -2
@@ -0,0 +1,277 @@
1
+ /**
2
+ * Exact input-token counts from Anthropic's Count Tokens endpoint, made with
3
+ * the user's own credentials, for the size estimates that decide compaction
4
+ * and the fallback refusal (route-fallback.ts).
5
+ *
6
+ * The proxy normally sizes a request from an earlier response's reported
7
+ * usage (a tokens-per-byte sample). That sample can be missing (a fresh proxy
8
+ * after a resume), stale (a big jump of new content of unknown density), or
9
+ * wrong for the request at hand: on 2026-10-05 a 979-byte web-search helper
10
+ * reported 12,040 input tokens (server-side search results count as input),
11
+ * and the 12 tokens/byte it taught its lane sized the next 169,507-byte
12
+ * subagent request at 2.08M tokens and refused it. Counting is free but costs
13
+ * a round trip that re-uploads the body, so it runs only where the estimate
14
+ * is unknown or decides the outcome, never on every request.
15
+ */
16
+ import { createHash } from "node:crypto";
17
+ import https from "node:https";
18
+ import { approxTokensFromBytes } from "./reqlog.js";
19
+ /** Bound on a count call: past it the caller keeps its estimate. */
20
+ export const COUNT_TOKENS_TIMEOUT_MS = 3_000;
21
+ const MAX_COUNT_RESPONSE_BYTES = 64 * 1024;
22
+ const MAX_COUNT_COOLDOWNS = 128;
23
+ const COUNT_COOLDOWN_MS = 60_000;
24
+ /**
25
+ * Plausible tokens per byte for a sample. Text runs ~0.25-0.5. Above 1 the
26
+ * sample measured something other than the body (server tool results), as on
27
+ * 2026-10-05 (12 tokens/byte). The floor is loose on purpose: base64 images
28
+ * are very cheap per byte (a ~1.5MB screenshot is ~1.6k tokens), so a
29
+ * screenshot-heavy session can sit well under 0.1 and must stay calibrated
30
+ * rather than be counted on every request.
31
+ */
32
+ export const MIN_PLAUSIBLE_TOKENS_PER_BYTE = 0.02;
33
+ export const MAX_PLAUSIBLE_TOKENS_PER_BYTE = 1;
34
+ /** With no usable sample, count once bytes/4 reaches this share of the budget. */
35
+ const UNCALIBRATED_COUNT_SHARE = 0.4;
36
+ /** With a sample, count a jump of new content once the estimate nears the budget. */
37
+ const NEAR_BUDGET_SHARE = 0.85;
38
+ /** Growth since the sample (bytes/4) that counts as a jump, as a share of the budget. */
39
+ const JUMP_BUDGET_SHARE = 0.05;
40
+ /** Request fields Count Tokens accepts; others (max_tokens, stream, ...) it rejects. */
41
+ const COUNTABLE_FIELDS = [
42
+ "model", "messages", "system", "tools", "tool_choice", "thinking",
43
+ "context_management", "output_config", "output_format", "cache_control",
44
+ "mcp_servers", "speed", "compaction",
45
+ ];
46
+ /** Whether a sample's tokens-per-byte ratio can describe a request body. */
47
+ export function plausibleSample(sample) {
48
+ if (!sample || !(sample.tokens > 0) || !(sample.forwardedBytes > 0))
49
+ return false;
50
+ const ratio = sample.tokens / sample.forwardedBytes;
51
+ return ratio >= MIN_PLAUSIBLE_TOKENS_PER_BYTE && ratio <= MAX_PLAUSIBLE_TOKENS_PER_BYTE;
52
+ }
53
+ /**
54
+ * Whether to count a request of `bytes` before deciding on it: with no usable
55
+ * sample once its estimate is a real share of the budget, and with one only
56
+ * after a jump of new content brings it near the budget. Small growth on a
57
+ * calibrated sample is estimated well and is not counted.
58
+ */
59
+ export function shouldCountTokens(sample, bytes, estimateTokens, budgetTokens) {
60
+ if (!(budgetTokens > 0))
61
+ return false;
62
+ if (!plausibleSample(sample))
63
+ return estimateTokens >= UNCALIBRATED_COUNT_SHARE * budgetTokens;
64
+ if (bytes <= sample.forwardedBytes)
65
+ return false;
66
+ const addedTokens = approxTokensFromBytes(bytes - sample.forwardedBytes);
67
+ return addedTokens >= JUMP_BUDGET_SHARE * budgetTokens &&
68
+ estimateTokens >= NEAR_BUDGET_SHARE * budgetTokens;
69
+ }
70
+ /** Shared per proxy; only hashes of account/upstream identity are stored. */
71
+ export class CountTokensCooldowns {
72
+ capacity;
73
+ now;
74
+ entries = new Map();
75
+ constructor(capacity = MAX_COUNT_COOLDOWNS, now = Date.now) {
76
+ this.capacity = capacity;
77
+ this.now = now;
78
+ }
79
+ active(key) {
80
+ const until = this.entries.get(key);
81
+ if (until === undefined)
82
+ return false;
83
+ if (until > this.now())
84
+ return true;
85
+ this.entries.delete(key);
86
+ return false;
87
+ }
88
+ record(key, result) {
89
+ if (![401, 403, 429].includes(result.status ?? 0))
90
+ return;
91
+ const now = this.now();
92
+ for (const [entry, until] of this.entries)
93
+ if (until <= now)
94
+ this.entries.delete(entry);
95
+ this.entries.delete(key);
96
+ if (this.capacity <= 0)
97
+ return;
98
+ while (this.entries.size >= this.capacity)
99
+ this.entries.delete(this.entries.keys().next().value);
100
+ this.entries.set(key, now + cooldownDuration(result.retryAfter, now));
101
+ }
102
+ }
103
+ /** Exact results belong to this request and body, never a shared sample slot. */
104
+ export function createCountTokensSession(options, cooldowns = new CountTokensCooldowns()) {
105
+ const pending = new Map();
106
+ const completed = new Map();
107
+ const account = countAccountKey(options);
108
+ let deadline;
109
+ return {
110
+ peek: (body) => completed.get(bodyHash(body)),
111
+ count: (body) => {
112
+ const key = bodyHash(body);
113
+ const existing = pending.get(key);
114
+ if (existing)
115
+ return existing;
116
+ deadline ??= Date.now() + (options.timeoutMs ?? COUNT_TOKENS_TIMEOUT_MS);
117
+ const remaining = deadline - Date.now();
118
+ const skipped = options.signal?.aborted ? "aborted"
119
+ : cooldowns.active(account) ? "cooldown" : remaining <= 0 ? "deadline" : undefined;
120
+ const attempt = skipped
121
+ ? Promise.resolve({ ms: 0, outcome: skipped })
122
+ : countUpstreamTokens({ ...options, body, timeoutMs: remaining }).then((result) => {
123
+ cooldowns.record(account, result);
124
+ if (result.outcome !== "invalid-request" && result.outcome !== "deadline") {
125
+ try {
126
+ options.onAttempt?.(result);
127
+ }
128
+ catch { /* diagnostics cannot break forwarding */ }
129
+ }
130
+ return result;
131
+ });
132
+ const saved = attempt.then((result) => { completed.set(key, result); return result; });
133
+ pending.set(key, saved);
134
+ return saved;
135
+ },
136
+ };
137
+ }
138
+ /** All failures resolve without tokens, including synchronous request errors. */
139
+ export function countUpstreamTokens(args) {
140
+ const started = Date.now();
141
+ const payload = countTokensBody(args.body);
142
+ if (!payload || args.signal?.aborted)
143
+ return Promise.resolve({
144
+ ms: 0, outcome: args.signal?.aborted ? "aborted" : "invalid-request",
145
+ });
146
+ const remaining = (args.timeoutMs ?? COUNT_TOKENS_TIMEOUT_MS) - (Date.now() - started);
147
+ if (remaining <= 0)
148
+ return Promise.resolve({ ms: Date.now() - started, outcome: "deadline" });
149
+ return new Promise((resolve) => {
150
+ let done = false;
151
+ let request;
152
+ let timer;
153
+ const finish = (result) => {
154
+ if (done)
155
+ return;
156
+ done = true;
157
+ clearTimeout(timer);
158
+ args.signal?.removeEventListener("abort", abort);
159
+ resolve({ ...result, ms: Date.now() - started });
160
+ request?.destroy();
161
+ };
162
+ const abort = () => finish({ outcome: "aborted" });
163
+ timer = setTimeout(() => finish({ outcome: "timeout" }), remaining);
164
+ args.signal?.addEventListener("abort", abort, { once: true });
165
+ try {
166
+ request = args.upstream.module.request({
167
+ host: args.upstream.host,
168
+ port: args.upstream.port,
169
+ method: "POST",
170
+ path: countTokensPath(args.requestUrl),
171
+ headers: countTokensHeaders(args.headers, payload.length),
172
+ }, (res) => readCount(res, finish));
173
+ request.on("error", () => finish({ outcome: "network-error" }));
174
+ if (args.signal?.aborted)
175
+ abort();
176
+ else
177
+ request.end(payload);
178
+ }
179
+ catch {
180
+ finish({ outcome: "network-error" });
181
+ }
182
+ });
183
+ }
184
+ /** The countable subset of a Messages request body, or null if it is not one. */
185
+ export function countTokensBody(body) {
186
+ try {
187
+ const parsed = JSON.parse(body.toString("utf-8"));
188
+ if (!parsed || !Array.isArray(parsed.messages))
189
+ return null;
190
+ const countable = {};
191
+ for (const field of COUNTABLE_FIELDS) {
192
+ if (parsed[field] !== undefined)
193
+ countable[field] = parsed[field];
194
+ }
195
+ return Buffer.from(JSON.stringify(countable), "utf-8");
196
+ }
197
+ catch {
198
+ return null;
199
+ }
200
+ }
201
+ /** The Messages request's path with `/count_tokens` appended, query kept. */
202
+ export function countTokensPath(requestUrl) {
203
+ const url = new URL(requestUrl ?? "/v1/messages", "http://127.0.0.1");
204
+ url.pathname = `${url.pathname.replace(/\/+$/, "")}/count_tokens`;
205
+ return `${url.pathname}${url.search}`;
206
+ }
207
+ function countTokensHeaders(headers, length) {
208
+ const out = {};
209
+ for (const [key, value] of Object.entries(headers)) {
210
+ const lower = key.toLowerCase();
211
+ if (lower === "content-length" || lower === "accept-encoding")
212
+ continue;
213
+ out[key] = value;
214
+ }
215
+ out["content-length"] = String(length);
216
+ out["content-type"] = "application/json";
217
+ out["accept-encoding"] = "identity";
218
+ return out;
219
+ }
220
+ function readCount(res, done) {
221
+ const status = res.statusCode;
222
+ res.on("error", () => done({ outcome: "network-error", status }));
223
+ res.on("aborted", () => done({ outcome: "network-error", status }));
224
+ if (status !== 200) {
225
+ const outcome = status === 401 || status === 403 ? "auth"
226
+ : status === 429 ? "rate-limit" : status !== undefined && status >= 500
227
+ ? "server-error" : "http-error";
228
+ done({ outcome, status, retryAfter: res.headers["retry-after"] });
229
+ res.destroy();
230
+ return;
231
+ }
232
+ const chunks = [];
233
+ let bytes = 0;
234
+ res.on("data", (chunk) => {
235
+ bytes += chunk.length;
236
+ if (bytes > MAX_COUNT_RESPONSE_BYTES) {
237
+ done({ outcome: "invalid-response", status });
238
+ res.destroy();
239
+ }
240
+ else
241
+ chunks.push(chunk);
242
+ });
243
+ res.on("end", () => {
244
+ try {
245
+ const tokens = JSON.parse(Buffer.concat(chunks).toString("utf-8"))?.input_tokens;
246
+ if (typeof tokens === "number" && Number.isSafeInteger(tokens) && tokens >= 0) {
247
+ done({ tokens, outcome: "success", status });
248
+ }
249
+ else
250
+ done({ outcome: "invalid-response", status });
251
+ }
252
+ catch {
253
+ done({ outcome: "invalid-response", status });
254
+ }
255
+ });
256
+ }
257
+ function bodyHash(body) {
258
+ return createHash("sha256").update(body).digest("hex");
259
+ }
260
+ function countAccountKey(options) {
261
+ const credentials = Object.entries(options.headers)
262
+ .filter(([key]) => ["authorization", "x-api-key"].includes(key.toLowerCase()))
263
+ .map(([key, value]) => [key.toLowerCase(), value]).sort();
264
+ return bodyHash(Buffer.from(JSON.stringify([
265
+ options.upstream.module.globalAgent === https.globalAgent ? "https" : "http", options.upstream.host,
266
+ options.upstream.port, credentials,
267
+ ])));
268
+ }
269
+ function cooldownDuration(retryAfter, now) {
270
+ if (!retryAfter)
271
+ return COUNT_COOLDOWN_MS;
272
+ const seconds = Number(retryAfter);
273
+ const duration = Number.isFinite(seconds) ? seconds * 1000 : Date.parse(retryAfter) - now;
274
+ return Number.isFinite(duration)
275
+ ? Math.max(1000, Math.min(COUNT_COOLDOWN_MS, duration)) : COUNT_COOLDOWN_MS;
276
+ }
277
+ //# sourceMappingURL=count-tokens.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"count-tokens.js","sourceRoot":"","sources":["../src/count-tokens.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,KAAK,MAAM,YAAY,CAAC;AAC/B,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEpD,oEAAoE;AACpE,MAAM,CAAC,MAAM,uBAAuB,GAAG,KAAK,CAAC;AAC7C,MAAM,wBAAwB,GAAG,EAAE,GAAG,IAAI,CAAC;AAC3C,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAChC,MAAM,iBAAiB,GAAG,MAAM,CAAC;AACjC;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,IAAI,CAAC;AAClD,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC,CAAC;AAC/C,kFAAkF;AAClF,MAAM,wBAAwB,GAAG,GAAG,CAAC;AACrC,qFAAqF;AACrF,MAAM,iBAAiB,GAAG,IAAI,CAAC;AAC/B,yFA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Q,CAAC,IAAI;QACnG,OAAO,CAAC,QAAQ,CAAC,IAAI,EAAE,WAAW;KACnC,CAAC,CAAC,CAAC,CAAC;AACP,CAAC;AAED,SAAS,gBAAgB,CAAC,UAA8B,EAAE,GAAW;IACnE,IAAI,CAAC,UAAU;QAAE,OAAO,iBAAiB,CAAC;IAC1C,MAAM,OAAO,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;IACnC,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,GAAG,CAAC;IAC1F,OAAO,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC;QAC9B,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,iBAAiB,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC;AAChF,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { type Message } from "./turns.js";
2
+ export type FinalReplyReader = (signal?: AbortSignal) => Message | undefined | Promise<Message | undefined>;
3
+ export declare function prepareFinalMessages(messages: Message[], signal: AbortSignal): Promise<{
4
+ messages: Message[];
5
+ retained: Message[];
6
+ key: string;
7
+ serialized: string;
8
+ }>;
9
+ export declare function readFinalReply(reader: FinalReplyReader | undefined, signal: AbortSignal): Promise<Message | undefined>;
10
+ //# sourceMappingURL=final-index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"final-index.d.ts","sourceRoot":"","sources":["../src/final-index.ts"],"names":[],"mappings":"AAGA,OAAO,EAA0B,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAElE,MAAM,MAAM,gBAAgB,GAAG,CAAC,MAAM,CAAC,EAAE,WAAW,KAClD,OAAO,GAAG,SAAS,GAAG,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC,CAAC;AAErD,wBAAsB,oBAAoB,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC;IAC5F,QAAQ,EAAE,OAAO,EAAE,CAAC;IAAC,QAAQ,EAAE,OAAO,EAAE,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;CAC3E,CAAC,CAgBD;AAED,wBAAsB,cAAc,CAAC,MAAM,EAAE,gBAAgB,GAAG,SAAS,EACrC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC,CAYrF"}
@@ -0,0 +1,37 @@
1
+ /** Cooperative final-index preparation, covered by the background abort signal. */
2
+ import { createHash } from "node:crypto";
3
+ import { setImmediate as yieldTurn } from "node:timers/promises";
4
+ import { stripCcSystemReminders } from "./turns.js";
5
+ export async function prepareFinalMessages(messages, signal) {
6
+ const hash = createHash("sha256").update("[");
7
+ const cleaned = [], retained = [], serialized = [];
8
+ for (let i = 0; i < messages.length; i++) {
9
+ await yieldTurn(undefined, { signal });
10
+ hash.update((i ? "," : "") + JSON.stringify(messages[i]));
11
+ const [message] = stripCcSystemReminders([messages[i]]);
12
+ if (message) {
13
+ cleaned.push(message);
14
+ retained.push(messages[i]);
15
+ serialized.push(JSON.stringify(message));
16
+ }
17
+ }
18
+ signal.throwIfAborted();
19
+ return { messages: cleaned, retained, key: hash.update("]").digest("hex"),
20
+ serialized: `[${serialized.join(",")}]` };
21
+ }
22
+ export async function readFinalReply(reader, signal) {
23
+ await yieldTurn(undefined, { signal });
24
+ if (!reader)
25
+ return undefined;
26
+ // An unreadable transcript is optional. Cancellation is not: do not send
27
+ // a late request after exit or after a new main-lane request superseded it.
28
+ return new Promise((resolve, reject) => {
29
+ const abort = () => reject(signal.reason ?? new Error("final index aborted"));
30
+ signal.addEventListener("abort", abort, { once: true });
31
+ Promise.resolve().then(() => reader(signal)).then(resolve, () => resolve(undefined))
32
+ .finally(() => signal.removeEventListener("abort", abort));
33
+ if (signal.aborted)
34
+ abort();
35
+ });
36
+ }
37
+ //# sourceMappingURL=final-index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"final-index.js","sourceRoot":"","sources":["../src/final-index.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,YAAY,IAAI,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,sBAAsB,EAAgB,MAAM,YAAY,CAAC;AAKlE,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,QAAmB,EAAE,MAAmB;IAGjF,MAAM,IAAI,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC9C,MAAM,OAAO,GAAc,EAAE,EAAE,QAAQ,GAAc,EAAE,EAAE,UAAU,GAAa,EAAE,CAAC;IACnF,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACzC,MAAM,SAAS,CAAC,SAAS,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;QACvC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1D,MAAM,CAAC,OAAO,CAAC,GAAG,sBAAsB,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACxD,IAAI,OAAO,EAAE,CAAC;YACZ,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACtB,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;YAC3B,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC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never be represented as Anthropic assistant content: Claude
5
+ * Code can reuse that content for hidden requests such as away recaps. Modern
6
+ * Claude Code releases provide MessageDisplay, whose output changes only the
7
+ * rendered delta. Stop's top-level systemMessage is the fallback for turns
8
+ * that never render text (for example, a tool-only response).
9
+ */
10
+ export declare const MESSAGE_DISPLAY_MIN_VERSION = "2.1.166";
11
+ /** Trailer labels; kept here so hooks.ts stays free of notices.ts imports. */
12
+ export declare const TRAILER_LABEL = "\u2022 MemTree \u00B7";
13
+ /** Label on a line that carries a MemTree page link. */
14
+ export declare const LINK_LABEL = "\u2022 MemTree";
15
+ /**
16
+ * A MemTree link notice: the label (and note, if any) on the first line and
17
+ * the URL alone, indented, on the next, so a long URL wraps on its own
18
+ * rather than dragging the label or note onto a second line. Label and note
19
+ * come pre-styled; the URL stays bare for the terminal's linkifier.
20
+ */
21
+ export declare function linkLines(label: string, url: string, note?: string): string;
22
+ export declare const DEFAULT_NOTICE_TTL_MS: number;
23
+ /**
24
+ * `/memtree`: list the MemTree commands. The link label reads `/memtree` as a
25
+ * hint, and typing it exactly must not dead-end in "Unknown command".
26
+ */
27
+ export declare const MEMTREE_HELP_COMMAND = "memtree";
28
+ /** The session plugin's name, which prefixes its commands in Claude Code's menu. */
29
+ export declare const SESSION_PLUGIN_NAME = "ccc";
30
+ /** `/memtree-view`: print this session's MemTree page link. */
31
+ export declare const MEMTREE_VIEW_COMMAND = "memtree-view";
32
+ /**
33
+ * `/memtree-compact [tokens|off]`: compact this session on its next message
34
+ * and keep that compressed history until the budget is reached again.
35
+ */
36
+ export declare const MEMTREE_COMPACT_COMMAND = "memtree-compact";
37
+ /**
38
+ * The arguments of a submitted `/<name>` (bare or `/ccc:`-qualified), or
39
+ * undefined when the prompt is not that command.
40
+ */
41
+ export declare function sessionCommandArgs(prompt: string, name: string): string | undefined;
42
+ export declare function isMemtreeViewCommand(prompt: string): boolean;
43
+ type NoticeText = string | (() => string);
44
+ /**
45
+ * Resolves the link appended to the success line for a session at claim
46
+ * time, or undefined when there is none. Evaluated lazily so the newest
47
+ * value (for example a MemTree page whose index finished during the tool
48
+ * loop) is what the user sees. The link is rendered unstyled after the
49
+ * styled text: Claude Code linkifies bare URLs and would swallow a trailing
50
+ * SGR reset into the link text.
51
+ */
52
+ type LinkResolver = (sessionId: string | undefined) => SuccessLink | undefined;
53
+ /** A link to show on the success line, shown once per distinct `key`. */
54
+ export interface SuccessLink {
55
+ /** What makes this link news — e.g. the index it stands for, not its URL. */
56
+ key: string;
57
+ link: string;
58
+ /**
59
+ * A short hint shown after the link, e.g.
60
+ * "not used to compress this session" when the turn behind the page was
61
+ * passed through whole.
62
+ */
63
+ note?: string;
64
+ }
65
+ /**
66
+ * Where the trailer (`• MemTree · <link>`) is shown: under every finished
67
+ * assistant message (with Stop as the fallback for a turn that rendered no
68
+ * text), or on Stop only, once per turn.
69
+ */
70
+ export type TrailerPlacement = "message" | "stop" | "turn";
71
+ interface ColorCapableStream {
72
+ hasColors?: (count?: number, env?: NodeJS.ProcessEnv) => boolean;
73
+ }
74
+ /** Respect explicit monochrome settings and Node's platform color detection. */
75
+ export declare function terminalSupportsColor(env?: NodeJS.ProcessEnv, stream?: ColorCapableStream): boolean;
76
+ /** Evaluated in the proxy's terminal, not the hook relay's piped stdout. */
77
+ export declare function terminalSupportsHyperlinks(env?: NodeJS.ProcessEnv, stream?: {
78
+ isTTY?: boolean;
79
+ }): boolean;
80
+ export interface MessageDisplayHookInput {
81
+ hook_event_name: "MessageDisplay";
82
+ session_id: string;
83
+ turn_id: string;
84
+ message_id: string;
85
+ index: number;
86
+ final: boolean;
87
+ delta: string;
88
+ prompt_id?: string;
89
+ agent_id?: string;
90
+ }
91
+ export interface StopHookInput {
92
+ hook_event_name: "Stop";
93
+ session_id: string;
94
+ stop_hook_active?: boolean;
95
+ prompt_id?: string;
96
+ agent_id?: string;
97
+ }
98
+ export interface UserPromptSubmitHookInput {
99
+ hook_event_name: "UserPromptSubmit";
100
+ session_id: string;
101
+ prompt: string;
102
+ prompt_id?: string;
103
+ agent_id?: string;
104
+ }
105
+ export interface SubagentLifecycleHookInput {
106
+ hook_event_name: "SubagentStart" | "SubagentStop";
107
+ session_id: string;
108
+ agent_id: string;
109
+ agent_type?: string;
110
+ prompt_id?: string;
111
+ }
112
+ export interface SessionStartHookInput {
113
+ hook_event_name: "SessionStart";
114
+ session_id: string;
115
+ /** "startup" | "resume" | "clear" | "compact" | "fork". */
116
+ source?: string;
117
+ agent_id?: string;
118
+ prompt_id?: string;
119
+ }
120
+ export type NoticeHookInput = MessageDisplayHookInput | StopHookInput | UserPromptSubmitHookInput | SubagentLifecycleHookInput | SessionStartHookInput;
121
+ export type MessageDisplayHookOutput = {
122
+ hookSpecificOutput: {
123
+ hookEventName: "MessageDisplay";
124
+ displayContent: string;
125
+ };
126
+ };
127
+ export type StopHookOutput = {
128
+ systemMessage: string;
129
+ };
130
+ export type NoticeHookOutput = MessageDisplayHookOutput | StopHookOutput;
131
+ /**
132
+ * Single-session delivery queue. Claude Code serializes main-thread turns, so
133
+ * one replaceable pending notice is sufficient. A new user request clears any
134
+ * stale notice; tool-result requests deliberately do not.
135
+ */
136
+ export declare class NoticeDeliveryQueue {
137
+ private readonly ttlMs;
138
+ private readonly now;
139
+ private readonly color;
140
+ private pending;
141
+ private link;
142
+ /** Key of the last link shown; the same key is not repeated. */
143
+ private readonly delivered;
144
+ private trailer;
145
+ private trailerPlacement;
146
+ /** Key of the last trailer shown; a different key is announced as new. */
147
+ constructor(ttlMs?: number, now?: () => number, color?: boolean);
148
+ /** Replace stale delivery state when a new main human prompt is submitted. */
149
+ clearForUserRequest(): void;
150
+ /**
151
+ * Install the per-session link that rides the success line, shown once per
152
+ * change: `<success text> · <link>`. Unlike prefix/suffix notices it is
153
+ * not per-prompt; it describes the conversation's current state whenever a
154
+ * success line is next shown.
155
+ */
156
+ setLink(resolve: LinkResolver | null): void;
157
+ /**
158
+ * The link line for a resumed session, shown by the SessionStart hook
159
+ * before any new turn. Marks the key as shown, so the next trailer under a
160
+ * message renders dim (unchanged) rather than green (new).
161
+ */
162
+ resumeLine(link: SuccessLink, sessionId?: string): string;
163
+ /** Whether the next success line would carry a link not shown before. */
164
+ linkPending(sessionId: string | undefined): boolean;
165
+ /**
166
+ * Install the trailer: the newest link for the session, shown after every
167
+ * message (or on every Stop), the first time under a new `key` marked as
168
+ * new. Not once-per-key like the success-line link: the point is that the
169
+ * link is always at the bottom of the screen.
170
+ */
171
+ setTrailer(resolve: LinkResolver | null, placement?: TrailerPlacement): void;
172
+ queuePrefix(text: NoticeText, onDelivered?: () => void, promptId?: string): void;
173
+ queueSuffix(text: NoticeText, onDelivered?: () => void, promptId?: string): void;
174
+ /**
175
+ * Claim eligible notice parts atomically for one hook invocation. Subagent
176
+ * hooks share the plugin but must never consume the main turn's notice.
177
+ */
178
+ claim(input: NoticeHookInput): NoticeHookOutput | null;
179
+ private claimForDisplay;
180
+ private promptMatches;
181
+ private styleSuccess;
182
+ /** Warnings get the same own-line treatment as success, in yellow. */
183
+ private styleWarning;
184
+ /**
185
+ * The success line with the session's current MemTree page on its own
186
+ * indented line below it (`✓ … optimized · ~813k → 408k tokens` then
187
+ * ` <link>`), every time the line is shown. The URL stays bare for the
188
+ * terminal's linkifier. Marks the key shown, so the end-of-turn trailer
189
+ * does not repeat the same link.
190
+ */
191
+ private renderSuccess;
192
+ /** The session's current link, shown or not. Resolver failures never break a hook. */
193
+ private currentLink;
194
+ /** The link if its key changed since last shown, without marking it. Resolver failures never break a hook. */
195
+ private resolveLink;
196
+ /**
197
+ * The trailer line for this session, or undefined when there is no link.
198
+ * The first time a key is seen the label says so in green; afterwards the
199
+ * label is dim. The URL stays bare either way (linkifier-safe). Rendering
200
+ * marks the key as seen. Resolver failures never break a hook.
201
+ */
202
+ private renderTrailer;
203
+ /** The link notice with its note dim. */
204
+ private linkNotice;
205
+ private styleDim;
206
+ private deliveryFor;
207
+ private style;
208
+ private freshPending;
209
+ private dropIfEmpty;
210
+ }
211
+ /** Strictly validate the subset of Claude hook input that delivery relies on. */
212
+ export declare function parseNoticeHookInput(value: unknown): NoticeHookInput | null;
213
+ export interface SessionNoticePlugin {
214
+ dir: string;
215
+ close(): void;
216
+ }
217
+ /** Prepend the repeatable global option without disturbing any user argv. */
218
+ export declare function withSessionNoticePluginArgs(args: readonly string[], pluginDir: string): string[];
219
+ /**
220
+ * Build a minimal session-only plugin. --plugin-dir is repeatable, unlike
221
+ * --settings (where Claude keeps only the final occurrence), so this composes
222
+ * with all user settings and hooks.
223
+ */
224
+ export declare function createSessionNoticePlugin(hookUrl: string, opts?: {
225
+ messageDisplay?: boolean;
226
+ tempRoot?: string;
227
+ /** Session banner, rendered by Claude Code under a "SessionStart:… says:" label. */
228
+ startupMessage?: string;
229
+ /**
230
+ * Forward SessionStart(resume) to the proxy so a resumed session shows
231
+ * its MemTree link. SessionStart accepts no `http` hooks, so a tiny Node
232
+ * script (run with this process's own Node) relays stdin to `hookUrl`.
233
+ */
234
+ resumeLink?: boolean;
235
+ }): SessionNoticePlugin;
236
+ /** Return true only for known Claude versions that support MessageDisplay. */
237
+ export declare function supportsMessageDisplay(versionOutput: string): boolean;
238
+ export {};
239
+ //# sourceMappingURL=hooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH,eAAO,MAAM,2BAA2B,YAAY,CAAC;AACrD,8EAA8E;AAC9E,eAAO,MAAM,aAAa,0BAAgB,CAAC;AAC3C,wDAAwD;AACxD,eAAO,MAAM,UAAU,mBAAc,CAAC;AAEtC;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAE3E;AACD,eAAO,MAAM,qBAAqB,QAAiB,CAAC;AAQpD;;;GAGG;AACH,eAAO,MAAM,oBAAoB,YAAY,CAAC;AAC9C,oFAAoF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