claude-code-infinite 1.0.29 → 1.0.30
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.
- package/README.md +57 -7
- package/dist/cli-lifecycle.d.ts +45 -1
- package/dist/cli-lifecycle.d.ts.map +1 -1
- package/dist/cli-lifecycle.js +59 -0
- package/dist/cli-lifecycle.js.map +1 -1
- package/dist/cli-main.js +49 -15
- package/dist/cli-main.js.map +1 -1
- package/dist/count-tokens.d.ts +15 -0
- package/dist/count-tokens.d.ts.map +1 -1
- package/dist/count-tokens.js +23 -1
- package/dist/count-tokens.js.map +1 -1
- package/dist/diagnostics-schema.d.ts.map +1 -1
- package/dist/diagnostics-schema.js +5 -0
- package/dist/diagnostics-schema.js.map +1 -1
- package/dist/diagnostics.d.ts.map +1 -1
- package/dist/diagnostics.js +18 -1
- package/dist/diagnostics.js.map +1 -1
- package/dist/final-index.d.ts +7 -1
- package/dist/final-index.d.ts.map +1 -1
- package/dist/final-index.js +10 -3
- package/dist/final-index.js.map +1 -1
- package/dist/image-refs.d.ts +51 -0
- package/dist/image-refs.d.ts.map +1 -0
- package/dist/image-refs.js +169 -0
- package/dist/image-refs.js.map +1 -0
- package/dist/image-tokens.d.ts +37 -0
- package/dist/image-tokens.d.ts.map +1 -0
- package/dist/image-tokens.js +158 -0
- package/dist/image-tokens.js.map +1 -0
- package/dist/memtree-body.d.ts +52 -0
- package/dist/memtree-body.d.ts.map +1 -0
- package/dist/memtree-body.js +99 -0
- package/dist/memtree-body.js.map +1 -0
- package/dist/memtree.d.ts +77 -3
- package/dist/memtree.d.ts.map +1 -1
- package/dist/memtree.js +267 -53
- package/dist/memtree.js.map +1 -1
- package/dist/paused-session.d.ts.map +1 -1
- package/dist/paused-session.js +11 -8
- package/dist/paused-session.js.map +1 -1
- package/dist/prefix-store.d.ts +2 -0
- package/dist/prefix-store.d.ts.map +1 -1
- package/dist/prefix-store.js +4 -0
- package/dist/prefix-store.js.map +1 -1
- package/dist/prepared-compression.d.ts +78 -0
- package/dist/prepared-compression.d.ts.map +1 -0
- package/dist/prepared-compression.js +127 -0
- package/dist/prepared-compression.js.map +1 -0
- package/dist/proxy.d.ts +363 -14
- package/dist/proxy.d.ts.map +1 -1
- package/dist/proxy.js +708 -90
- package/dist/proxy.js.map +1 -1
- package/dist/reqlog.d.ts +55 -0
- package/dist/reqlog.d.ts.map +1 -1
- package/dist/reqlog.js.map +1 -1
- package/dist/request-sizing.d.ts +21 -2
- package/dist/request-sizing.d.ts.map +1 -1
- package/dist/request-sizing.js +57 -11
- package/dist/request-sizing.js.map +1 -1
- package/dist/route-identity.d.ts +27 -0
- package/dist/route-identity.d.ts.map +1 -1
- package/dist/route-identity.js +88 -8
- package/dist/route-identity.js.map +1 -1
- package/dist/token-estimate.d.ts +3 -20
- package/dist/token-estimate.d.ts.map +1 -1
- package/dist/token-estimate.js +9 -50
- package/dist/token-estimate.js.map +1 -1
- package/dist/tool-output-store.d.ts +12 -0
- package/dist/tool-output-store.d.ts.map +1 -0
- package/dist/tool-output-store.js +146 -0
- package/dist/tool-output-store.js.map +1 -0
- package/dist/tool-result-truncation.d.ts +32 -0
- package/dist/tool-result-truncation.d.ts.map +1 -0
- package/dist/tool-result-truncation.js +135 -0
- package/dist/tool-result-truncation.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What an inline image costs, from its header alone (polychat
|
|
3
|
+
* image_tokens.py mirrors the same rule): Anthropic counts
|
|
4
|
+
* ceil(w / 28) * ceil(h / 28) visual tokens after scaling the image down,
|
|
5
|
+
* aspect kept, to its model tier's limits (Claude 4.7+ and unknown models:
|
|
6
|
+
* long edge 2576 px and 4,784 tokens; older Claude: 1568 px and 1,568).
|
|
7
|
+
* A 574x551 screenshot is 420 tokens, not the ~74k its base64 would be as text.
|
|
8
|
+
*/
|
|
9
|
+
declare const HIGH_RES: {
|
|
10
|
+
maxEdge: number;
|
|
11
|
+
maxTokens: number;
|
|
12
|
+
};
|
|
13
|
+
export interface ImageTotals {
|
|
14
|
+
/** Base64 characters of the inline images (their JSON bytes). */
|
|
15
|
+
imageBytes: number;
|
|
16
|
+
/** Their visual tokens by the rule above (the tier cap when a header is unreadable). */
|
|
17
|
+
imageTokens: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Inline images among a request body's message (and tool result) content
|
|
21
|
+
* blocks; `model` picks the tier. Image-shaped JSON anywhere else (tool
|
|
22
|
+
* inputs, schemas, system) is ordinary text.
|
|
23
|
+
*/
|
|
24
|
+
export declare function bodyImages(body: Buffer, model: string | undefined): ImageTotals;
|
|
25
|
+
/** Remember `totals` for another copy of the same bytes. */
|
|
26
|
+
export declare function rememberImages(body: Buffer, model: string | undefined, totals: ImageTotals): void;
|
|
27
|
+
/** Visual tokens of a w x h image in `tier` (polychat visual_tokens). */
|
|
28
|
+
export declare function visualTokens(width: number, height: number, tier?: {
|
|
29
|
+
maxEdge: number;
|
|
30
|
+
maxTokens: number;
|
|
31
|
+
}): number;
|
|
32
|
+
/** Claude before 4.7 is standard; 4.7+, other and unknown models are high-res. */
|
|
33
|
+
export declare function imageTier(model: string | undefined): typeof HIGH_RES;
|
|
34
|
+
/** Width and height from a PNG, GIF, WebP or JPEG header; undefined when unreadable. */
|
|
35
|
+
export declare function imageDimensions(base64: string): [number, number] | undefined;
|
|
36
|
+
export {};
|
|
37
|
+
//# sourceMappingURL=image-tokens.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-tokens.d.ts","sourceRoot":"","sources":["../src/image-tokens.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,QAAA,MAAM,QAAQ;;;CAAsC,CAAC;AAOrD,MAAM,WAAW,WAAW;IAC1B,iEAAiE;IACjE,UAAU,EAAE,MAAM,CAAC;IACnB,wFAAwF;IACxF,WAAW,EAAE,MAAM,CAAC;CACrB;AAOD;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,WAAW,CAM/E;AAED,4DAA4D;AAC5D,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,MAAM,EAAE,WAAW,GAAG,IAAI,CAEjG;AAsBD,yEAAyE;AACzE,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI;;;CAAW,GAAG,MAAM,CAYnF;AAED,kFAAkF;AAClF,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,QAAQ,CAMpE;AAED,wFAAwF;AACxF,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAQ5E"}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What an inline image costs, from its header alone (polychat
|
|
3
|
+
* image_tokens.py mirrors the same rule): Anthropic counts
|
|
4
|
+
* ceil(w / 28) * ceil(h / 28) visual tokens after scaling the image down,
|
|
5
|
+
* aspect kept, to its model tier's limits (Claude 4.7+ and unknown models:
|
|
6
|
+
* long edge 2576 px and 4,784 tokens; older Claude: 1568 px and 1,568).
|
|
7
|
+
* A 574x551 screenshot is 420 tokens, not the ~74k its base64 would be as text.
|
|
8
|
+
*/
|
|
9
|
+
const PATCH_PX = 28;
|
|
10
|
+
const HIGH_RES = { maxEdge: 2576, maxTokens: 4_784 };
|
|
11
|
+
const STANDARD = { maxEdge: 1568, maxTokens: 1_568 };
|
|
12
|
+
/** Base64 characters decoded to find a header (48 KB of bytes). */
|
|
13
|
+
const HEADER_BASE64_CHARS = 65_536;
|
|
14
|
+
const CLAUDE_VERSION_RE = /claude-(?:opus|sonnet|haiku|fable|mythos|instant)?-?(\d{1,2})(?:[-.](\d{1,2}))?(?![0-9])/i;
|
|
15
|
+
const NO_IMAGES = Object.freeze({ imageBytes: 0, imageTokens: 0 });
|
|
16
|
+
/** Totals already worked out for a body and model: a body is parsed once,
|
|
17
|
+
* however often it is sized (a weak key: dropped with the body). */
|
|
18
|
+
const totalsByBody = new WeakMap();
|
|
19
|
+
/**
|
|
20
|
+
* Inline images among a request body's message (and tool result) content
|
|
21
|
+
* blocks; `model` picks the tier. Image-shaped JSON anywhere else (tool
|
|
22
|
+
* inputs, schemas, system) is ordinary text.
|
|
23
|
+
*/
|
|
24
|
+
export function bodyImages(body, model) {
|
|
25
|
+
const known = totalsByBody.get(body);
|
|
26
|
+
if (known && known.model === model)
|
|
27
|
+
return known.totals;
|
|
28
|
+
const totals = parseImages(body, model);
|
|
29
|
+
totalsByBody.set(body, { model, totals });
|
|
30
|
+
return totals;
|
|
31
|
+
}
|
|
32
|
+
/** Remember `totals` for another copy of the same bytes. */
|
|
33
|
+
export function rememberImages(body, model, totals) {
|
|
34
|
+
totalsByBody.set(body, { model, totals });
|
|
35
|
+
}
|
|
36
|
+
function parseImages(body, model) {
|
|
37
|
+
// Most bodies carry no image: skip the parse.
|
|
38
|
+
if (!body.includes('"image"'))
|
|
39
|
+
return NO_IMAGES;
|
|
40
|
+
let parsed;
|
|
41
|
+
try {
|
|
42
|
+
parsed = JSON.parse(body.toString("utf-8"));
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return NO_IMAGES;
|
|
46
|
+
}
|
|
47
|
+
const totals = { imageBytes: 0, imageTokens: 0 };
|
|
48
|
+
const tier = imageTier(model);
|
|
49
|
+
const messages = parsed?.messages;
|
|
50
|
+
if (!Array.isArray(messages))
|
|
51
|
+
return totals;
|
|
52
|
+
for (const message of messages) {
|
|
53
|
+
const content = message?.content;
|
|
54
|
+
if (Array.isArray(content))
|
|
55
|
+
addImages(content, tier, totals);
|
|
56
|
+
}
|
|
57
|
+
return Object.freeze(totals);
|
|
58
|
+
}
|
|
59
|
+
/** Visual tokens of a w x h image in `tier` (polychat visual_tokens). */
|
|
60
|
+
export function visualTokens(width, height, tier = HIGH_RES) {
|
|
61
|
+
if (!(width > 0) || !(height > 0))
|
|
62
|
+
return tier.maxTokens;
|
|
63
|
+
const longest = Math.max(width, height);
|
|
64
|
+
let longEdge = Math.max(1, Math.floor(longest * Math.min(1, tier.maxEdge / longest)));
|
|
65
|
+
while (longEdge > 1) {
|
|
66
|
+
const scale = longEdge / longest;
|
|
67
|
+
const tokens = Math.ceil(Math.max(1, Math.floor(width * scale)) / PATCH_PX) *
|
|
68
|
+
Math.ceil(Math.max(1, Math.floor(height * scale)) / PATCH_PX);
|
|
69
|
+
if (tokens <= tier.maxTokens)
|
|
70
|
+
return tokens;
|
|
71
|
+
longEdge -= Math.max(1, Math.floor(longEdge / 200));
|
|
72
|
+
}
|
|
73
|
+
return 1;
|
|
74
|
+
}
|
|
75
|
+
/** Claude before 4.7 is standard; 4.7+, other and unknown models are high-res. */
|
|
76
|
+
export function imageTier(model) {
|
|
77
|
+
const match = model ? CLAUDE_VERSION_RE.exec(model) : null;
|
|
78
|
+
if (!match)
|
|
79
|
+
return HIGH_RES;
|
|
80
|
+
const major = Number(match[1]);
|
|
81
|
+
const minor = match[2] ? Number(match[2]) : 0;
|
|
82
|
+
return major > 4 || (major === 4 && minor >= 7) ? HIGH_RES : STANDARD;
|
|
83
|
+
}
|
|
84
|
+
/** Width and height from a PNG, GIF, WebP or JPEG header; undefined when unreadable. */
|
|
85
|
+
export function imageDimensions(base64) {
|
|
86
|
+
let bytes;
|
|
87
|
+
try {
|
|
88
|
+
bytes = Buffer.from(base64.slice(0, HEADER_BASE64_CHARS), "base64");
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
return undefined;
|
|
92
|
+
}
|
|
93
|
+
return pngSize(bytes) ?? gifSize(bytes) ?? webpSize(bytes) ?? jpegSize(bytes);
|
|
94
|
+
}
|
|
95
|
+
function addImages(blocks, tier, totals) {
|
|
96
|
+
for (const item of blocks) {
|
|
97
|
+
if (!item || typeof item !== "object")
|
|
98
|
+
continue;
|
|
99
|
+
const block = item;
|
|
100
|
+
const source = block.source;
|
|
101
|
+
if (block.type === "image" && source && typeof source === "object") {
|
|
102
|
+
const data = source.type === "base64" && typeof source.data === "string" ? source.data : "";
|
|
103
|
+
totals.imageBytes += data.length;
|
|
104
|
+
const size = data ? imageDimensions(data) : undefined;
|
|
105
|
+
totals.imageTokens += size ? visualTokens(size[0], size[1], tier) : tier.maxTokens;
|
|
106
|
+
}
|
|
107
|
+
else if (block.type === "tool_result" && Array.isArray(block.content)) {
|
|
108
|
+
addImages(block.content, tier, totals);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
function pngSize(b) {
|
|
113
|
+
if (b.length < 24 || b.readUInt32BE(0) !== 0x89504e47 || b.toString("ascii", 12, 16) !== "IHDR") {
|
|
114
|
+
return undefined;
|
|
115
|
+
}
|
|
116
|
+
return [b.readUInt32BE(16), b.readUInt32BE(20)];
|
|
117
|
+
}
|
|
118
|
+
function gifSize(b) {
|
|
119
|
+
if (b.length < 10 || b.toString("ascii", 0, 3) !== "GIF")
|
|
120
|
+
return undefined;
|
|
121
|
+
return [b.readUInt16LE(6), b.readUInt16LE(8)];
|
|
122
|
+
}
|
|
123
|
+
function webpSize(b) {
|
|
124
|
+
if (b.length < 30 || b.toString("ascii", 0, 4) !== "RIFF" || b.toString("ascii", 8, 12) !== "WEBP") {
|
|
125
|
+
return undefined;
|
|
126
|
+
}
|
|
127
|
+
const chunk = b.toString("ascii", 12, 16);
|
|
128
|
+
if (chunk === "VP8X")
|
|
129
|
+
return [1 + b.readUIntLE(24, 3), 1 + b.readUIntLE(27, 3)];
|
|
130
|
+
if (chunk === "VP8L") {
|
|
131
|
+
const bits = b.readUInt32LE(21);
|
|
132
|
+
return [1 + (bits & 0x3fff), 1 + ((bits >> 14) & 0x3fff)];
|
|
133
|
+
}
|
|
134
|
+
if (chunk === "VP8 ")
|
|
135
|
+
return [b.readUInt16LE(26) & 0x3fff, b.readUInt16LE(28) & 0x3fff];
|
|
136
|
+
return undefined;
|
|
137
|
+
}
|
|
138
|
+
const JPEG_FRAME_MARKERS = new Set([0xc0, 0xc1, 0xc2, 0xc3, 0xc5, 0xc6, 0xc7, 0xc9, 0xca, 0xcb,
|
|
139
|
+
0xcd, 0xce, 0xcf]);
|
|
140
|
+
function jpegSize(b) {
|
|
141
|
+
if (b.length < 4 || b[0] !== 0xff || b[1] !== 0xd8)
|
|
142
|
+
return undefined;
|
|
143
|
+
let i = 2;
|
|
144
|
+
for (let steps = 0; steps < 2_048 && i + 9 < b.length; steps++) {
|
|
145
|
+
if (b[i] !== 0xff)
|
|
146
|
+
return undefined;
|
|
147
|
+
const marker = b[i + 1];
|
|
148
|
+
if (marker === 0xff) {
|
|
149
|
+
i++;
|
|
150
|
+
continue;
|
|
151
|
+
}
|
|
152
|
+
if (JPEG_FRAME_MARKERS.has(marker))
|
|
153
|
+
return [b.readUInt16BE(i + 7), b.readUInt16BE(i + 5)];
|
|
154
|
+
i += 2 + b.readUInt16BE(i + 2);
|
|
155
|
+
}
|
|
156
|
+
return undefined;
|
|
157
|
+
}
|
|
158
|
+
//# sourceMappingURL=image-tokens.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-tokens.js","sourceRoot":"","sources":["../src/image-tokens.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,QAAQ,GAAG,EAAE,CAAC;AACpB,MAAM,QAAQ,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;AACrD,MAAM,QAAQ,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;AACrD,mEAAmE;AACnE,MAAM,mBAAmB,GAAG,MAAM,CAAC;AACnC,MAAM,iBAAiB,GACrB,2FAA2F,CAAC;AAS9F,MAAM,SAAS,GAAgB,MAAM,CAAC,MAAM,CAAC,EAAE,UAA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GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAC1F,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IACjC,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The body of a MemTree call: image references (image-refs.ts) and a hard size limit.
|
|
3
|
+
*
|
|
4
|
+
* MemTree is served over HTTP/1 by Cloud Run, which refuses request bodies over
|
|
5
|
+
* 32 MiB (a 413 before the server sees anything), so a body over MAX_MEMTREE_BODY_BYTES
|
|
6
|
+
* is never sent. An index call is sent with its oldest inline images replaced by a
|
|
7
|
+
* text placeholder until it fits (indexing loses those images, the session goes on);
|
|
8
|
+
* a compress call is not sent at all and the turn degrades as on any failed compress.
|
|
9
|
+
*/
|
|
10
|
+
import { type ImageRefs, type Referenced } from "./image-refs.js";
|
|
11
|
+
import type { Message } from "./turns.js";
|
|
12
|
+
/** Under Cloud Run's 32 MiB HTTP/1 limit, with room for headers and rounding. */
|
|
13
|
+
export declare const MAX_MEMTREE_BODY_BYTES: number;
|
|
14
|
+
export declare const IMAGE_OMITTED_TEXT = "[image omitted by ccc: the MemTree upload was over its size limit]";
|
|
15
|
+
/** What the limit did to a call: sent with images dropped, or not sent. */
|
|
16
|
+
export interface BodyLimitNote {
|
|
17
|
+
action: "trimmed" | "skipped";
|
|
18
|
+
/** The body's size before anything was dropped. */
|
|
19
|
+
requestBytes: number;
|
|
20
|
+
imagesDropped: number;
|
|
21
|
+
}
|
|
22
|
+
export interface PlannedBody {
|
|
23
|
+
/** The JSON to send; undefined when nothing that fits could be built. */
|
|
24
|
+
payload?: string;
|
|
25
|
+
/** Shas sent as references (a 409 then asks for their bytes). */
|
|
26
|
+
refs: string[];
|
|
27
|
+
limit?: BodyLimitNote;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* `body` with its messages as sent: stored images as references when `imageRefs` is
|
|
31
|
+
* given, then, over `limitBytes`, an index call's oldest images dropped. `serialized`
|
|
32
|
+
* is the messages' JSON already made (with references from the same `imageRefs`).
|
|
33
|
+
*/
|
|
34
|
+
export declare function planMemtreeBody(args: {
|
|
35
|
+
body: Record<string, unknown>;
|
|
36
|
+
messages: Message[];
|
|
37
|
+
serialized?: Referenced<string>;
|
|
38
|
+
imageRefs?: ImageRefs;
|
|
39
|
+
indexOnly: boolean;
|
|
40
|
+
limitBytes?: number;
|
|
41
|
+
}): PlannedBody;
|
|
42
|
+
/** `body` (without messages) as JSON, with `messagesJson` as its `messages`. */
|
|
43
|
+
export declare function withMessagesJson(body: Record<string, unknown>, messagesJson: string): string;
|
|
44
|
+
/**
|
|
45
|
+
* `messages` with inline images, oldest first, replaced by IMAGE_OMITTED_TEXT until
|
|
46
|
+
* at least `excessBytes` are saved; copy on write. References cost nothing and stay.
|
|
47
|
+
*/
|
|
48
|
+
export declare function dropOldestImages(messages: Message[], excessBytes: number): {
|
|
49
|
+
messages: Message[];
|
|
50
|
+
dropped: number;
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=memtree-body.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memtree-body.d.ts","sourceRoot":"","sources":["../src/memtree-body.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAoB,KAAK,SAAS,EAAE,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACpF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C,iFAAiF;AACjF,eAAO,MAAM,sBAAsB,QAAmB,CAAC;AACvD,eAAO,MAAM,kBAAkB,uEACuC,CAAC;AAIvE,2EAA2E;AAC3E,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,SAAS,GAAG,SAAS,CAAC;IAC9B,mDAAmD;IACnD,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,WAAW;IAC1B,yEAAyE;IACzE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iEAAiE;IACjE,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE;IACpC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,UAAU,CAAC,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;IAChC,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,GAAG,WAAW,CA+Bd;AAED,gFAAgF;AAChF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAK5F;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,WAAW,EAAE,MAAM,GAAG;IAC1E,QAAQ,EAAE,OAAO,EAAE,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;CACtC,CAQA"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The body of a MemTree call: image references (image-refs.ts) and a hard size limit.
|
|
3
|
+
*
|
|
4
|
+
* MemTree is served over HTTP/1 by Cloud Run, which refuses request bodies over
|
|
5
|
+
* 32 MiB (a 413 before the server sees anything), so a body over MAX_MEMTREE_BODY_BYTES
|
|
6
|
+
* is never sent. An index call is sent with its oldest inline images replaced by a
|
|
7
|
+
* text placeholder until it fits (indexing loses those images, the session goes on);
|
|
8
|
+
* a compress call is not sent at all and the turn degrades as on any failed compress.
|
|
9
|
+
*/
|
|
10
|
+
import { IMAGE_REF_PREFIX } from "./image-refs.js";
|
|
11
|
+
/** Under Cloud Run's 32 MiB HTTP/1 limit, with room for headers and rounding. */
|
|
12
|
+
export const MAX_MEMTREE_BODY_BYTES = 30 * 1024 * 1024;
|
|
13
|
+
export const IMAGE_OMITTED_TEXT = "[image omitted by ccc: the MemTree upload was over its size limit]";
|
|
14
|
+
const PLACEHOLDER = { type: "text", text: IMAGE_OMITTED_TEXT };
|
|
15
|
+
const PLACEHOLDER_BYTES = Buffer.byteLength(JSON.stringify(PLACEHOLDER), "utf-8");
|
|
16
|
+
/**
|
|
17
|
+
* `body` with its messages as sent: stored images as references when `imageRefs` is
|
|
18
|
+
* given, then, over `limitBytes`, an index call's oldest images dropped. `serialized`
|
|
19
|
+
* is the messages' JSON already made (with references from the same `imageRefs`).
|
|
20
|
+
*/
|
|
21
|
+
export function planMemtreeBody(args) {
|
|
22
|
+
const limit = args.limitBytes ?? MAX_MEMTREE_BODY_BYTES;
|
|
23
|
+
const referenced = () => args.imageRefs?.referenceMessages(args.messages)
|
|
24
|
+
?? { value: args.messages, refs: [] };
|
|
25
|
+
let sent = args.serialized;
|
|
26
|
+
if (sent === undefined) {
|
|
27
|
+
const { value, refs } = referenced();
|
|
28
|
+
sent = { value: JSON.stringify(value), refs };
|
|
29
|
+
}
|
|
30
|
+
const payload = withMessagesJson(args.body, sent.value);
|
|
31
|
+
const bytes = Buffer.byteLength(payload, "utf-8");
|
|
32
|
+
if (bytes <= limit)
|
|
33
|
+
return { payload, refs: sent.refs };
|
|
34
|
+
const skipped = { refs: [], limit: { action: "skipped", requestBytes: bytes,
|
|
35
|
+
imagesDropped: 0 } };
|
|
36
|
+
if (!args.indexOnly)
|
|
37
|
+
return skipped;
|
|
38
|
+
const { value, refs } = referenced();
|
|
39
|
+
// Each round drops what the last one left over; it stops when nothing is left to drop.
|
|
40
|
+
let trimmed = { messages: value, dropped: 0 };
|
|
41
|
+
let size = bytes;
|
|
42
|
+
while (size > limit) {
|
|
43
|
+
const next = dropOldestImages(trimmed.messages, size - limit);
|
|
44
|
+
if (next.dropped === 0)
|
|
45
|
+
return skipped;
|
|
46
|
+
trimmed = { messages: next.messages, dropped: trimmed.dropped + next.dropped };
|
|
47
|
+
const fitted = withMessagesJson(args.body, JSON.stringify(trimmed.messages));
|
|
48
|
+
size = Buffer.byteLength(fitted, "utf-8");
|
|
49
|
+
if (size <= limit) {
|
|
50
|
+
return { payload: fitted, refs,
|
|
51
|
+
limit: { action: "trimmed", requestBytes: bytes, imagesDropped: trimmed.dropped } };
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return skipped;
|
|
55
|
+
}
|
|
56
|
+
/** `body` (without messages) as JSON, with `messagesJson` as its `messages`. */
|
|
57
|
+
export function withMessagesJson(body, messagesJson) {
|
|
58
|
+
const { messages: _ignored, ...rest } = body;
|
|
59
|
+
const head = JSON.stringify(rest);
|
|
60
|
+
return head === "{}" ? `{"messages":${messagesJson}}`
|
|
61
|
+
: `${head.slice(0, -1)},"messages":${messagesJson}}`;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* `messages` with inline images, oldest first, replaced by IMAGE_OMITTED_TEXT until
|
|
65
|
+
* at least `excessBytes` are saved; copy on write. References cost nothing and stay.
|
|
66
|
+
*/
|
|
67
|
+
export function dropOldestImages(messages, excessBytes) {
|
|
68
|
+
const state = { saved: 0, dropped: 0, excess: excessBytes };
|
|
69
|
+
const out = messages.map((message) => {
|
|
70
|
+
if (state.saved >= state.excess || !Array.isArray(message?.content))
|
|
71
|
+
return message;
|
|
72
|
+
const content = dropInBlocks(message.content, state);
|
|
73
|
+
return content === message.content ? message : { ...message, content };
|
|
74
|
+
});
|
|
75
|
+
return { messages: out, dropped: state.dropped };
|
|
76
|
+
}
|
|
77
|
+
function dropInBlocks(blocks, state) {
|
|
78
|
+
let changed = false;
|
|
79
|
+
const out = blocks.map((block) => {
|
|
80
|
+
if (state.saved >= state.excess)
|
|
81
|
+
return block;
|
|
82
|
+
if (block?.type === "tool_result" && Array.isArray(block.content)) {
|
|
83
|
+
const content = dropInBlocks(block.content, state);
|
|
84
|
+
if (content === block.content)
|
|
85
|
+
return block;
|
|
86
|
+
changed = true;
|
|
87
|
+
return { ...block, content };
|
|
88
|
+
}
|
|
89
|
+
const data = block?.type === "image" ? block.source?.data : undefined;
|
|
90
|
+
if (typeof data !== "string" || data.startsWith(IMAGE_REF_PREFIX))
|
|
91
|
+
return block;
|
|
92
|
+
changed = true;
|
|
93
|
+
state.saved += Buffer.byteLength(JSON.stringify(block), "utf-8") - PLACEHOLDER_BYTES;
|
|
94
|
+
state.dropped += 1;
|
|
95
|
+
return PLACEHOLDER;
|
|
96
|
+
});
|
|
97
|
+
return changed ? out : blocks;
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=memtree-body.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memtree-body.js","sourceRoot":"","sources":["../src/memtree-body.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,gBAAgB,EAAmC,MAAM,iBAAiB,CAAC;AAGpF,iFAAiF;AACjF,MAAM,CAAC,MAAM,sBAAsB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AACvD,MAAM,CAAC,MAAM,kBAAkB,GAC7B,oEAAoE,CAAC;AACvE,MAAM,WAAW,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,kBAAkB,EAAE,CAAC;AAC/D,MAAM,iBAAiB,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC,CAAC;AAkBlF;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,IAO/B;IACC,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,IAAI,sBAAsB,CAAC;IACxD,MAAM,UAAU,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,SAAS,EAAE,iBAAiB,CAAC,IAAI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AO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAAC;YAAE,OAAO,KAAK,CAAC;QAChF,OAAO,GAAG,IAAI,CAAC;QACf,KAAK,CAAC,KAAK,IAAI,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,GAAG,iBAAiB,CAAC;QACrF,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC;QACnB,OAAO,WAAW,CAAC;IACrB,CAAC,CAAC,CAAC;IACH,OAAO,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC;AAChC,CAAC"}
|
package/dist/memtree.d.ts
CHANGED
|
@@ -23,13 +23,21 @@ import type { PaymentLinkCache } from "./payment-link.js";
|
|
|
23
23
|
import { type Message } from "./turns.js";
|
|
24
24
|
export declare const CLIENT_NAME = "cc-infinite";
|
|
25
25
|
/**
|
|
26
|
-
* Sent as `x-client-features` on
|
|
26
|
+
* Sent as `x-client-features` on every MemTree call. `near-window-budget`: ccc lifts
|
|
27
27
|
* Claude Code's local refusal near the window (claude-env.ts) and compresses
|
|
28
28
|
* mid-turn, so the server may give it the 900k budget on 1M-window models
|
|
29
|
-
* (older ccc keeps 800k).
|
|
29
|
+
* (older ccc keeps 800k). `image-refs`: ccc reads the stored images an answer
|
|
30
|
+
* lists and sends those images as references afterwards (image-refs.ts).
|
|
30
31
|
*/
|
|
31
|
-
export declare const CLIENT_FEATURES = "near-window-budget";
|
|
32
|
+
export declare const CLIENT_FEATURES = "near-window-budget,image-refs";
|
|
32
33
|
export declare const CLIENT_VERSION: string;
|
|
34
|
+
/**
|
|
35
|
+
* Added to a compress call's budget per KiB of its upload: a large session's
|
|
36
|
+
* body (20+ MB) takes seconds to send on a slow link before the server even
|
|
37
|
+
* starts, so a flat budget times out on size alone (2026-10-23: every tool
|
|
38
|
+
* turn's compress of a 21.5 MB body timed out at 15 s with MemTree healthy).
|
|
39
|
+
*/
|
|
40
|
+
export declare const COMPRESS_TIMEOUT_MS_PER_KIB = 1;
|
|
33
41
|
/**
|
|
34
42
|
* A main-lane Stop followed by this long without a new request is taken as the
|
|
35
43
|
* session's end, and its final index goes out (exit sends it at once). Shorter
|
|
@@ -82,6 +90,13 @@ export interface CompressRequestMeta {
|
|
|
82
90
|
* proxy tells them apart).
|
|
83
91
|
*/
|
|
84
92
|
compressionThresholdTokens?: number;
|
|
93
|
+
/**
|
|
94
|
+
* Server `prepare`: a compression asked for ahead of need (the proxy's
|
|
95
|
+
* prepared compression, prepared-compression.ts), compressed to
|
|
96
|
+
* `compressionTargetTokens` whatever its size and billed as the compression
|
|
97
|
+
* it replaces. Part of the cache key: it changes the server's answer.
|
|
98
|
+
*/
|
|
99
|
+
prepare?: boolean;
|
|
85
100
|
/**
|
|
86
101
|
* Server `client_input_tokens`: the proxy's own estimate of the request's
|
|
87
102
|
* input tokens, the one its fallback gate refuses over-budget input by.
|
|
@@ -145,6 +160,11 @@ export interface CompressResult {
|
|
|
145
160
|
* back to the cached_tokens heuristic (see didMemtreeCompress).
|
|
146
161
|
*/
|
|
147
162
|
compressed?: boolean;
|
|
163
|
+
/**
|
|
164
|
+
* True on the answer to a `prepare` call from a server that prepares (and
|
|
165
|
+
* bills a preparation as the compression it replaces); older servers omit it.
|
|
166
|
+
*/
|
|
167
|
+
prepared?: boolean;
|
|
148
168
|
/**
|
|
149
169
|
* The model's whole-request budget the server computed (tokens), whatever
|
|
150
170
|
* target the request set. Servers that predate it omit the field.
|
|
@@ -298,6 +318,7 @@ export declare class MemtreeClient {
|
|
|
298
318
|
private baseUrl;
|
|
299
319
|
private apiKey;
|
|
300
320
|
private compressTimeoutMs;
|
|
321
|
+
private compressSuccessAt;
|
|
301
322
|
private longCompressTimeoutMs;
|
|
302
323
|
private debug;
|
|
303
324
|
private reqlog;
|
|
@@ -318,8 +339,18 @@ export declare class MemtreeClient {
|
|
|
318
339
|
private indexedHashes;
|
|
319
340
|
/** In-flight index-only calls, tracked so shutdown cannot outrun their logs. */
|
|
320
341
|
private backgroundIndexes;
|
|
342
|
+
/** Conversations (indexLaneKey) with a background index call in flight. */
|
|
343
|
+
private readonly indexLanesBusy;
|
|
344
|
+
/** Per busy conversation, the newest index call waiting for the one in flight. */
|
|
345
|
+
private readonly indexLanesNext;
|
|
346
|
+
/** Per conversation, the history the exit's final index carries (flushFinalIndexes). */
|
|
347
|
+
private readonly finalIndexLanes;
|
|
321
348
|
/** Once draining begins, no later request may create another log producer. */
|
|
322
349
|
private backgroundClosing;
|
|
350
|
+
/** drainBackground ran out and is aborting what is left (exit_index_cut, not an error). */
|
|
351
|
+
private drainCutting;
|
|
352
|
+
/** Images MemTree stores, sent as references instead of their bytes. */
|
|
353
|
+
private readonly imageRefs;
|
|
323
354
|
/** Session → its main lane's latest conversation, for the final index. */
|
|
324
355
|
private readonly mainConversations;
|
|
325
356
|
/** Session → its final index waiting for the session to stay idle. */
|
|
@@ -337,6 +368,8 @@ export declare class MemtreeClient {
|
|
|
337
368
|
private lastAnswerKeyInvalid;
|
|
338
369
|
/** Complete compression request key → whether its latest failure arms fuse. */
|
|
339
370
|
private compressFailureArming;
|
|
371
|
+
/** HTTP status of each key's latest failed compress (absent: no response). */
|
|
372
|
+
private compressFailureStatus;
|
|
340
373
|
/**
|
|
341
374
|
* Non-null when the server last answered 402 (unpaid MemTree key): the
|
|
342
375
|
* server's human-readable detail text. Set by both compression and
|
|
@@ -372,6 +405,14 @@ export declare class MemtreeClient {
|
|
|
372
405
|
* timeout rather than a fast server error.
|
|
373
406
|
*/
|
|
374
407
|
get compressBudgetMs(): number;
|
|
408
|
+
/** The blocking-compress budget for an upload of `bytes` (COMPRESS_TIMEOUT_MS_PER_KIB). */
|
|
409
|
+
compressBudgetForBytes(bytes: number): number;
|
|
410
|
+
/**
|
|
411
|
+
* When a compress call (not an index-only one) last got a live successful
|
|
412
|
+
* answer (epoch ms; 0: never). A compress timing out while others succeed
|
|
413
|
+
* is its size or a slow reply, not an outage.
|
|
414
|
+
*/
|
|
415
|
+
get lastCompressSuccessAt(): number;
|
|
375
416
|
/**
|
|
376
417
|
* Non-secret identity of the MemTree backend and account this client uses:
|
|
377
418
|
* a hash over the origin and a hash of the key. Persisted state is valid only
|
|
@@ -421,6 +462,11 @@ export declare class MemtreeClient {
|
|
|
421
462
|
* the fuse needs positive evidence of a responsive server.
|
|
422
463
|
*/
|
|
423
464
|
lastCompressFailureArming(hash: string, modelContextLimit: number, meta?: CompressRequestMeta): boolean;
|
|
465
|
+
/**
|
|
466
|
+
* The HTTP status of the latest failed compress of this request, sampled at
|
|
467
|
+
* its settle like lastCompressFailureArming; undefined when it got none.
|
|
468
|
+
*/
|
|
469
|
+
lastCompressFailureStatus(hash: string, modelContextLimit: number, meta?: CompressRequestMeta): number | undefined;
|
|
424
470
|
/**
|
|
425
471
|
* Blocking user-turn compression. Returns null on ANY failure (timeout,
|
|
426
472
|
* network, 4xx/5xx including 402) — the caller must degrade to passthrough.
|
|
@@ -449,6 +495,20 @@ export declare class MemtreeClient {
|
|
|
449
495
|
indexInBackground(hash: string, messages: Message[], modelContextLimit: number, sessionId?: string, clientMeta?: Record<string, string>,
|
|
450
496
|
/** Times for retained original messages, in the positions actually sent. */
|
|
451
497
|
messageTimesFor?: (messages: Message[]) => MessageTimes): void;
|
|
498
|
+
/**
|
|
499
|
+
* At most one background index call per conversation. Each call carries the whole
|
|
500
|
+
* history, so while one uploads only the newest waiting call is worth sending: a long
|
|
501
|
+
* session's tool rounds otherwise stacked 25 MB uploads, up to 16 at once, and starved
|
|
502
|
+
* the compress calls that share the link (long-session test, staging 2026-10-24). A
|
|
503
|
+
* waiting call is replaced only by one whose history extends it; otherwise it goes now.
|
|
504
|
+
*/
|
|
505
|
+
private enqueueIndex;
|
|
506
|
+
private startLaneIndex;
|
|
507
|
+
/**
|
|
508
|
+
* At shutdown: send every waiting call now, inside the drain, except one whose history
|
|
509
|
+
* the final index carries (a main session's, unless it was rewound since).
|
|
510
|
+
*/
|
|
511
|
+
private sendWaitingIndexes;
|
|
452
512
|
/**
|
|
453
513
|
* The main lane's latest conversation for a session, kept for its final
|
|
454
514
|
* index (scheduleFinalIndex). A new request also means the session did not
|
|
@@ -509,6 +569,20 @@ export declare class MemtreeClient {
|
|
|
509
569
|
private rememberInFlight;
|
|
510
570
|
private remember;
|
|
511
571
|
private callContextMemory;
|
|
572
|
+
/** One POST of a MemTree call's body. */
|
|
573
|
+
private postContextMemory;
|
|
574
|
+
/**
|
|
575
|
+
* Whether a failed answer to a call that sent references asks for their bytes: the
|
|
576
|
+
* server lacks some images (409: those are forgotten), or refuses references (400:
|
|
577
|
+
* this request's forgotten, or none ever again when the key may not send them).
|
|
578
|
+
*/
|
|
579
|
+
private refusedRefs;
|
|
580
|
+
/**
|
|
581
|
+
* A body over the limit that nothing could shrink (memtree-body.ts): never sent.
|
|
582
|
+
* Logged like any call, with `bodyLimit` (memtree_body_limit, not memtree_error); the
|
|
583
|
+
* error carries 413, the status the server's front end would have answered.
|
|
584
|
+
*/
|
|
585
|
+
private oversized;
|
|
512
586
|
private log;
|
|
513
587
|
}
|
|
514
588
|
/** What noteMainConversation keeps: the last main-lane request as sent to MemTree. */
|
package/dist/memtree.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memtree.d.ts","sourceRoot":"","sources":["../src/memtree.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,EAAwC,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAC/F,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAExE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"memtree.d.ts","sourceRoot":"","sources":["../src/memtree.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,EAAwC,KAAK,gBAAgB,EA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