acp-kernel 0.0.83 → 0.0.84
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/DESIGN.md +16 -3
- package/README.md +104 -3
- package/dist/absorb.d.ts.map +1 -1
- package/dist/boundaries.d.ts.map +1 -1
- package/dist/ccr.d.ts +116 -0
- package/dist/ccr.d.ts.map +1 -0
- package/dist/{chunk-VPRKYTHW.js → chunk-6RNVHY67.js} +3 -3
- package/dist/{chunk-5TQA7ZQM.js → chunk-MXL3G3BN.js} +13 -2
- package/dist/chunk-MXL3G3BN.js.map +1 -0
- package/dist/compress-tools.d.ts +104 -2
- package/dist/compress-tools.d.ts.map +1 -1
- package/dist/compress.d.ts +8 -0
- package/dist/compress.d.ts.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/content-store.d.ts +86 -0
- package/dist/content-store.d.ts.map +1 -0
- package/dist/crush.d.ts +142 -0
- package/dist/crush.d.ts.map +1 -0
- package/dist/image-compress.d.ts +156 -0
- package/dist/image-compress.d.ts.map +1 -0
- package/dist/index.d.ts +12 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2909 -636
- package/dist/index.js.map +1 -1
- package/dist/output-steering.d.ts +176 -0
- package/dist/output-steering.d.ts.map +1 -0
- package/dist/panel/index.js +1 -1
- package/dist/persist/index.js +4 -2
- package/dist/persist/index.js.map +1 -1
- package/dist/persist/state-merge.d.ts.map +1 -1
- package/dist/pipeline.d.ts +3 -0
- package/dist/pipeline.d.ts.map +1 -1
- package/dist/rebuild.d.ts.map +1 -1
- package/dist/state.d.ts.map +1 -1
- package/dist/types.d.ts +82 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-5TQA7ZQM.js.map +0 -1
- /package/dist/{chunk-VPRKYTHW.js.map → chunk-6RNVHY67.js.map} +0 -0
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Output-side steering decisions (#355): turn-structure classification,
|
|
3
|
+
* verbosity levels (L0–L4), clamp-only effort routing.
|
|
4
|
+
*
|
|
5
|
+
* This module is the protocol-agnostic half of output-side compression. It
|
|
6
|
+
* DECIDES; adapters LAND. Adapters (e.g. billion-context) own:
|
|
7
|
+
* - mapping their wire body onto `StructuralMessage[]` (contract below),
|
|
8
|
+
* - writing the decision onto wire-specific fields (effort field names,
|
|
9
|
+
* system-prompt carriers, numeric budget floors),
|
|
10
|
+
* - config persistence and logging of returned warnings.
|
|
11
|
+
*
|
|
12
|
+
* Hard boundaries:
|
|
13
|
+
* 1. CLAMP-ONLY — `lowerEffort` never means "raise". Adapters lower only
|
|
14
|
+
* effort fields the client ALREADY sent; absent fields are never
|
|
15
|
+
* injected (models without effort support 400 on them), and values
|
|
16
|
+
* at/below the floor are left alone (`clampEffortToFloor`).
|
|
17
|
+
* 2. TAIL-ONLY injection — the verbosity directive goes at the TAIL of the
|
|
18
|
+
* system prompt (prefix cache requires stable head bytes; never prepend).
|
|
19
|
+
* `applySteeringToPrompt` replaces an existing sentinel block in place,
|
|
20
|
+
* so re-applying the same level is a byte-stable no-op (compress retries
|
|
21
|
+
* re-send through this path).
|
|
22
|
+
* 3. BYTE-STABLE directives — the L1–L4 texts below are frozen across
|
|
23
|
+
* releases. Editing one character busts the prefix cache of every
|
|
24
|
+
* session pinned at that level. Change only with a deliberate,
|
|
25
|
+
* announced cache bust.
|
|
26
|
+
*
|
|
27
|
+
* Origin: decision logic adapted from billion-context PR#1096
|
|
28
|
+
* (`2026-09-21_output-side-compression`, `src/output-steering.ts`; design per
|
|
29
|
+
* headroomlabs-ai/headroom's output-token-reduction proposal). Per-wire rules
|
|
30
|
+
* are preserved here as the normalization contract; wire-side landing stays
|
|
31
|
+
* in adapters.
|
|
32
|
+
*/
|
|
33
|
+
export type TurnKind = "new_user_ask" | "mechanical_continuation" | "error_continuation" | "unknown";
|
|
34
|
+
export interface StructuralBlock {
|
|
35
|
+
/**
|
|
36
|
+
* `text` / `image` / `document` — user signal ⇒ new_user_ask.
|
|
37
|
+
* `tool_result` — machine-produced result; accumulates toward a
|
|
38
|
+
* continuation verdict.
|
|
39
|
+
*/
|
|
40
|
+
kind: "text" | "image" | "document" | "tool_result";
|
|
41
|
+
/** `tool_result` only: the wire's error flag (Anthropic `is_error`). Absent = clean. */
|
|
42
|
+
isError?: boolean;
|
|
43
|
+
}
|
|
44
|
+
export interface StructuralMessage {
|
|
45
|
+
role: string;
|
|
46
|
+
/** Plain-string content (Anthropic/OpenAI allow string content). Mutually exclusive with `blocks` in practice; `text` wins when both present. */
|
|
47
|
+
text?: string;
|
|
48
|
+
blocks?: StructuralBlock[];
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Classify the FINAL turn purely structurally — block composition only, no
|
|
52
|
+
* content pattern-matching. Only the last message matters. Conservative by
|
|
53
|
+
* design: anything unrecognized yields `unknown` (never a guess), because an
|
|
54
|
+
* unrecognized composition may carry user intent we cannot see.
|
|
55
|
+
*/
|
|
56
|
+
export declare function classifyTurn(messages: readonly StructuralMessage[]): TurnKind;
|
|
57
|
+
/**
|
|
58
|
+
* Normalization contract (adapter responsibility — documented here because
|
|
59
|
+
* classification correctness depends on it):
|
|
60
|
+
*
|
|
61
|
+
* - Anthropic: pass through. String content → `text`; content blocks map by
|
|
62
|
+
* `type`: text/image/document → same kind; tool_result → tool_result with
|
|
63
|
+
* `isError = block.is_error === true`.
|
|
64
|
+
* - OpenAI chat: fold trailing consecutive `role:"tool"` messages into ONE
|
|
65
|
+
* synthetic final user message carrying tool_result blocks (no error flag
|
|
66
|
+
* exists on this wire → `isError` stays absent). A trailing user message
|
|
67
|
+
* passes through (string content → `text`; array content: non-empty text
|
|
68
|
+
* part → text block, otherwise unknown).
|
|
69
|
+
* - Responses: walk `input` BACKWARD from the end (clients re-send full
|
|
70
|
+
* history every request — scanning forward would hit the original ask on
|
|
71
|
+
* every turn). Items after the last user signal: `*_call_output`
|
|
72
|
+
* (function/custom_tool/local_shell/apply_patch) → tool_result blocks;
|
|
73
|
+
* assistant-side items (message/function_call/custom_tool_call/
|
|
74
|
+
* local_shell_call/apply_patch_call/reasoning) form the preceding
|
|
75
|
+
* assistant message(s). User signal = `input_text` (non-empty),
|
|
76
|
+
* `input_image`, `input_file`, or a role:"user" message with non-empty
|
|
77
|
+
* text. Trailing outputs ⇒ final user(tool_results); none ⇒ final
|
|
78
|
+
* user(text); pending call with no output yet ⇒ unknown.
|
|
79
|
+
* - Google: the last `contents` entry must be role:"user"; parts map:
|
|
80
|
+
* functionResponse → tool_result; non-empty text → text; empty text →
|
|
81
|
+
* dropped (neutral); inlineData/fileData/videoMetadata → image/document.
|
|
82
|
+
*
|
|
83
|
+
* Anything unrecognized maps to nothing (→ `unknown`), never to a guess.
|
|
84
|
+
*/
|
|
85
|
+
export declare const MIN_VERBOSITY_LEVEL = 0;
|
|
86
|
+
export declare const MAX_VERBOSITY_LEVEL = 4;
|
|
87
|
+
export declare const DEFAULT_VERBOSITY_LEVEL = 2;
|
|
88
|
+
/** Conciseness directives L1–L4. L0 = no directive. FROZEN across releases. */
|
|
89
|
+
export declare const VERBOSITY_LEVELS: Readonly<Record<number, string>>;
|
|
90
|
+
export declare function verbosityDirective(level: number): string | null;
|
|
91
|
+
/**
|
|
92
|
+
* Default sentinel wrapping the steering directive. Each host SHOULD pass its
|
|
93
|
+
* own sentinel so a body that passes through several proxies never collides
|
|
94
|
+
* (billion-context uses `<bili_output_steering>`). Must be a full opening
|
|
95
|
+
* XML-style tag `<name>`; the closing tag is derived as `</name>`.
|
|
96
|
+
*/
|
|
97
|
+
export declare const DEFAULT_STEERING_SENTINEL = "<acp_output_steering>";
|
|
98
|
+
export declare function renderSteeringBlock(level: number, sentinel?: string): string | null;
|
|
99
|
+
export interface SteeringPlacement {
|
|
100
|
+
updated: string;
|
|
101
|
+
changed: boolean;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Idempotently place `block` in `existing`: when a block wrapped by
|
|
105
|
+
* `sentinel` is present, replace it in place (preserving surrounding text);
|
|
106
|
+
* otherwise append at the tail. Never prepends. Re-applying the same block
|
|
107
|
+
* returns `changed: false` with byte-identical output (retry safety). A
|
|
108
|
+
* malformed (unclosed) sentinel block is consumed to the end of the string
|
|
109
|
+
* so re-application neither duplicates the closing tag nor grows the block.
|
|
110
|
+
*/
|
|
111
|
+
export declare function applySteeringToPrompt(existing: string, block: string, sentinel?: string): SteeringPlacement;
|
|
112
|
+
/**
|
|
113
|
+
* Ascending shared effort ladder (OpenAI chat / Responses / Anthropic
|
|
114
|
+
* output_config.effort use these values). Wire-specific NUMERIC budget floors
|
|
115
|
+
* (e.g. Anthropic thinking.budget_tokens ≥ 1024, Google thinkingBudget ≥ 128,
|
|
116
|
+
* dynamic `-1` untouched) live adapter-side — they are properties of wire
|
|
117
|
+
* fields, not of the decision.
|
|
118
|
+
*/
|
|
119
|
+
export declare const EFFORT_LADDER: readonly ["minimal", "low", "medium", "high", "xhigh"];
|
|
120
|
+
export type EffortValue = (typeof EFFORT_LADDER)[number];
|
|
121
|
+
/**
|
|
122
|
+
* Clamp-only floor computation. Returns the value to write, or null when the
|
|
123
|
+
* field is absent/unrecognized or already at/below `floor`. Never raises: a
|
|
124
|
+
* client that explicitly asked for `minimal` keeps it. Unrecognized values
|
|
125
|
+
* are left untouched rather than coerced — coercing an unknown value that
|
|
126
|
+
* happens to sit below the floor would be a raise.
|
|
127
|
+
*/
|
|
128
|
+
export declare function clampEffortToFloor(current: unknown, floor?: EffortValue): EffortValue | null;
|
|
129
|
+
export interface OutputSteeringConfig {
|
|
130
|
+
/** Master switch. Default OFF — both levers inert until explicitly on. */
|
|
131
|
+
enabled: boolean;
|
|
132
|
+
/** Verbosity level 0–4 (0 = no directive). Default 2. */
|
|
133
|
+
verbosityLevel: number;
|
|
134
|
+
/** Effort-routing sub-switch. Default on whenever `enabled` is. */
|
|
135
|
+
effortRouting: boolean;
|
|
136
|
+
}
|
|
137
|
+
export declare const DEFAULT_OUTPUT_STEERING_CONFIG: OutputSteeringConfig;
|
|
138
|
+
/**
|
|
139
|
+
* Resolve a raw verbosity level. An OMITTED field silently takes the default;
|
|
140
|
+
* a PRESENT but out-of-range value falls back WITH a warning (honest output —
|
|
141
|
+
* a valid partial config must not be accused of being malformed).
|
|
142
|
+
*/
|
|
143
|
+
export declare function resolveVerbosityLevel(v: unknown): {
|
|
144
|
+
level: number;
|
|
145
|
+
warning?: string;
|
|
146
|
+
};
|
|
147
|
+
/**
|
|
148
|
+
* Validate a raw `outputSteering` config value (e.g. parsed JSON). Malformed
|
|
149
|
+
* fields fall back to defaults rather than throwing; warnings are returned
|
|
150
|
+
* as data for the host to log. Non-object input yields pure defaults.
|
|
151
|
+
*/
|
|
152
|
+
export declare function resolveOutputSteeringConfig(v: unknown): {
|
|
153
|
+
config: OutputSteeringConfig;
|
|
154
|
+
warnings: string[];
|
|
155
|
+
};
|
|
156
|
+
export interface OutputSteeringDecision {
|
|
157
|
+
/** Structural classification of the final turn (echoed for observability/logging). */
|
|
158
|
+
turnKind: TurnKind;
|
|
159
|
+
/** Level to inject; 0 = inject nothing. Always 0 while disabled. */
|
|
160
|
+
verbosityLevel: number;
|
|
161
|
+
/**
|
|
162
|
+
* Clamp-only routing: true ⇔ enabled && effortRouting && mechanical
|
|
163
|
+
* continuation. The adapter lowers each effort field the client already
|
|
164
|
+
* sent toward its wire floor; it never injects absent fields and never
|
|
165
|
+
* raises any value.
|
|
166
|
+
*/
|
|
167
|
+
lowerEffort: boolean;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Single decision entry point: structural summary of the FINAL message list
|
|
171
|
+
* (+ resolved config) → steering decision. Pure, synchronous, side-effect
|
|
172
|
+
* free. Landing — which field gets written, which carrier holds the system
|
|
173
|
+
* prompt — is the adapter's job.
|
|
174
|
+
*/
|
|
175
|
+
export declare function decideOutputSteering(messages: readonly StructuralMessage[], config?: OutputSteeringConfig): OutputSteeringDecision;
|
|
176
|
+
//# sourceMappingURL=output-steering.d.ts.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
CHANGED
package/dist/persist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createInitialState
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-MXL3G3BN.js";
|
|
4
4
|
|
|
5
5
|
// src/persist/store.ts
|
|
6
6
|
import { createHash } from "crypto";
|
|
@@ -452,7 +452,9 @@ function mergeCompressionState(parsed) {
|
|
|
452
452
|
absorbed: parsed.absorbed ?? fresh.absorbed,
|
|
453
453
|
rules: parsed.rules ?? fresh.rules,
|
|
454
454
|
nextRuleId: parsed.nextRuleId ?? fresh.nextRuleId,
|
|
455
|
-
terminalStreak: parsed.terminalStreak
|
|
455
|
+
terminalStreak: parsed.terminalStreak,
|
|
456
|
+
imageFullRestored: parsed.imageFullRestored ?? fresh.imageFullRestored,
|
|
457
|
+
imageShrinks: parsed.imageShrinks ?? fresh.imageShrinks
|
|
456
458
|
};
|
|
457
459
|
}
|
|
458
460
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/persist/store.ts","../../src/persist/state-merge.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\nimport fs from \"node:fs\";\nimport fsp from \"node:fs/promises\";\nimport path from \"node:path\";\n\n/** Logger callback. Downstream routes it wherever it wants (file, stderr). */\nexport type PersistLogger = (level: \"info\" | \"warn\" | \"error\", msg: string) => void;\n\n/**\n * On-disk record shape. The store owns the envelope (version stamp, save\n * time, id) so atomicity and discovery can rely on it; the payload schema\n * is entirely downstream-owned. `payload` must be JSON-serializable.\n */\nexport interface PersistedEnvelope<T> {\n version: number;\n savedAt: number;\n id: string;\n payload: T;\n}\n\n/** A legacy (pre-envelope) record adopted on load. `version`/`savedAt`\n * preserve the source record's own stamps when present. */\nexport interface LegacyAdoption<T> {\n id: string;\n payload: T;\n version?: number;\n savedAt?: number;\n}\n\n/**\n * Optional record codec: transforms serialized envelopes between the store\n * and disk (e.g. compress and/or encrypt at rest). The store is\n * codec-agnostic — it hands `encode` the exact JSON string it would have\n * written and passes raw file bytes to `decode`, which must return that same\n * JSON string or throw, in which case the file is treated as corrupt\n * (skipped + logged) like any unreadable record. Format detection (magic\n * bytes, plaintext fallback for unencoded legacy files) is the codec's job,\n * so mixed trees of legacy plaintext and encoded files load fine.\n */\nexport interface StateStoreCodec {\n encode(data: string): Buffer | string;\n decode(buf: Buffer): string;\n}\n\nexport interface StateStoreOptions<T> {\n /**\n * Storage root. The kernel deliberately has NO default location: the\n * downstream decides where state lives (CLI dir, XDG data dir, plugin\n * dir, temp dir in tests). All records live under this directory.\n */\n dir: string;\n /**\n * Schema version stamped into every envelope. Owned by the downstream;\n * bump it when the payload shape changes. The store itself never\n * rejects a record over its version — migration policy belongs to the\n * reader.\n */\n version: number;\n /** Debounce window for scheduleSave, ms. Default 500. */\n debounceMs?: number;\n /** Default true. When false, all writes are silent no-ops and loads\n * return empty results. */\n enabled?: boolean;\n log?: PersistLogger;\n /**\n * Relative path (under `dir`) for a record, possibly namespaced into\n * subdirectories (e.g. `openai/host-hash.json`). Default: flat\n * `<sha256(id)[:24]>.json`.\n *\n * Because the path may depend on payload fields the store only learns\n * at write time, single-record loads resolve namespaced files only\n * after loadAll() has discovered them (or the store itself wrote\n * them). The flat default name is always checked as a fallback, so\n * downstreams using a custom relPath should call loadAll() at boot.\n */\n relPath?: (id: string, payload: T) => string;\n /**\n * Adopt records written by an older, pre-envelope schema. Receives the\n * parsed JSON of any file that failed the envelope-shape check; return\n * an adoption to load it as an envelope, or null to skip it. Adopted\n * records are re-persisted in the current envelope format on the next\n * dirty write — files migrate organically, and old files keep loading\n * (same policy billion-context's proxy used for its v1→v3 migration).\n */\n legacy?: (parsed: unknown) => LegacyAdoption<T> | null;\n /**\n * Payload validation on load. Return false to skip a record (foreign\n * schema, corrupt content). Default: envelope-shape check only\n * (string id, non-null payload).\n */\n validate?: (envelope: PersistedEnvelope<T>) => boolean;\n /**\n * Optional codec applied around every write (canonical + spill) and\n * read. See StateStoreCodec. Default: none — files are plain UTF-8 JSON.\n */\n codec?: StateStoreCodec;\n /**\n * Transient-write retry policy (Windows + hostile temp environments).\n * The whole write cycle — mkdir, temp write, rename — is retried with\n * exponential backoff when it fails with a TRANSIENT code: EPERM/EBUSY/\n * EACCES (a lock held by AV scan, search indexer, SMB) or ENOENT/ENOTDIR\n * (the temp file or its directory vanished between create and rename —\n * observed on CI Windows runners where a sweeper deletes freshly\n * created files under %TEMP%). The delay after attempt i is\n * min(retryBaseMs * 2^i, retryMaxMs). Defaults (6 attempts, 50ms base,\n * 1600ms cap) give a ~1.5s window per write path — long enough for most\n * locks to release, short enough not to stall a sync flush. When the\n * window is exhausted the write spills to a side file (see spillPath)\n * instead of dropping the data.\n */\n retryAttempts?: number;\n retryBaseMs?: number;\n retryMaxMs?: number;\n}\n\n/**\n * Crash-safe, debounce-coalescing JSON state store. Mechanism only — lifted\n * from billion-context's proxy SessionStore and generalized:\n *\n * - atomic writes: temp file + rename, so a crash mid-write never leaves a\n * truncated record (readers see either the old or the new file)\n * - whole-cycle retries with exponential backoff on transient fs failures:\n * Windows locks (EPERM/EBUSY/EACCES from AV/indexer/SMB) and vanishing\n * files/dirs (ENOENT/ENOTDIR — a sweeper deleting fresh temp files, seen\n * on CI Windows runners); when the window is exhausted the record spills\n * to a side file (`<name>.fb.json`) instead of being dropped, so a lock\n * held by AV/indexer/SMB never silently loses session data\n * - per-id serialization so concurrent writeNow calls never interleave\n * temp-file names or reorders writes\n * - debounced scheduleSave coalesces bursts into one write; the record is\n * built at WRITE time from a builder, so late mutations are picked up\n * - optional record codec (compress/encrypt at rest): encode on every write,\n * decode on every read; a decode failure is corrupt-file semantics\n * - loadAll skips `.tmp-*` orphans, corrupt JSON, and records whose\n * filename does not match their id — one bad file never blocks boot; it\n * reconciles a canonical record against its spill by savedAt (freshest wins)\n *\n * The store never deletes a record's data. On a successful canonical write it\n * removes a now-stale spill of the SAME id (a duplicate, not distinct data).\n * Session cleanup is a downstream policy decision (kernel position: persisted\n * state should not be deleted opportunistically).\n */\nexport class StateStore<T> {\n readonly enabled: boolean;\n private readonly dir: string;\n private readonly version: number;\n private readonly debounceMs: number;\n private readonly log: PersistLogger;\n private readonly legacyFn?: (parsed: unknown) => LegacyAdoption<T> | null;\n private readonly relPathFn?: (id: string, payload: T) => string;\n private readonly validateFn: (envelope: PersistedEnvelope<T>) => boolean;\n private readonly codec?: StateStoreCodec;\n private readonly retryAttempts: number;\n private readonly retryBaseMs: number;\n private readonly retryMaxMs: number;\n private readonly timers = new Map<string, NodeJS.Timeout>();\n private readonly pending = new Map<string, () => T>();\n private readonly writeChains = new Map<string, Promise<void>>();\n /** id → absolute path, populated by writes and loadAll. */\n private readonly discovered = new Map<string, string>();\n /** id → cumulative write-failure count, for rate-limited alerting. */\n private readonly failCounts = new Map<string, number>();\n /** Monotonic counter for unique temp filenames within a process. */\n private tmpSeq = 0;\n\n constructor(opts: StateStoreOptions<T>) {\n this.dir = opts.dir;\n this.version = opts.version;\n this.debounceMs = opts.debounceMs ?? 500;\n this.enabled = opts.enabled ?? true;\n this.log = opts.log ?? ((_level, _msg) => {});\n this.relPathFn = opts.relPath;\n this.legacyFn = opts.legacy;\n this.validateFn = opts.validate ?? defaultValidate;\n this.codec = opts.codec;\n this.retryAttempts = Math.max(1, opts.retryAttempts ?? 6);\n this.retryBaseMs = Math.max(1, opts.retryBaseMs ?? 50);\n this.retryMaxMs = Math.max(this.retryBaseMs, opts.retryMaxMs ?? 1600);\n }\n\n /** Debounced save. Coalesces bursts; the builder runs at write time, so\n * the freshest state is always persisted. Never throws. */\n scheduleSave(id: string, build: () => T): void {\n if (!this.enabled) return;\n this.pending.set(id, build);\n const existing = this.timers.get(id);\n if (existing) return;\n const timer = setTimeout(() => {\n this.timers.delete(id);\n const builder = this.pending.get(id);\n this.pending.delete(id);\n if (!builder) return;\n // Errors are logged inside writeInner; swallowing here keeps a\n // failed timer write from becoming an unhandledRejection.\n void this.writeNow(id, builder).catch(() => {});\n }, this.debounceMs);\n timer.unref?.();\n this.timers.set(id, timer);\n }\n\n /** Immediate save, serialized per id. Rejects on write failure; a\n * failing write never breaks the chain for the next one. */\n async writeNow(id: string, build: () => T): Promise<void> {\n if (!this.enabled) return;\n // The previous promise may reject (disk full, EPERM) — catch so our\n // chain doesn't break, then run our own write.\n const prev = this.writeChains.get(id) ?? Promise.resolve();\n const next = prev.catch(() => {}).then(() => this.writeInner(id, build));\n this.writeChains.set(id, next);\n // Clean up the chain entry once settled so the Map doesn't grow. The\n // .catch() is load-bearing: .finally() returns a derived promise that\n // nobody else holds — when the chain rejects it would surface as an\n // unhandledRejection and crash the host on default Node settings.\n next\n .finally(() => {\n if (this.writeChains.get(id) === next) this.writeChains.delete(id);\n })\n .catch(() => {});\n return next;\n }\n\n /** Synchronous flush for one id. Used where the caller cannot await\n * (memory eviction, sync shutdown paths). Cancels any pending debounce\n * timer. Returns true on success, false on failure — callers that use\n * the result to drop in-memory state must NOT drop it on failure. */\n flushSync(id: string, build: () => T): boolean {\n if (!this.enabled) return true;\n const timer = this.timers.get(id);\n if (timer) {\n clearTimeout(timer);\n this.timers.delete(id);\n this.pending.delete(id);\n }\n let payload: T;\n try {\n payload = build();\n } catch (e) {\n this.log(\"error\", `[persist] builder failed for ${id}: ${errText(e)}`);\n return false;\n }\n const file = this.resolvePath(id, payload);\n const data = this.serialize(id, payload);\n let lastErr: unknown;\n for (let attempt = 0; attempt < this.retryAttempts; attempt++) {\n // Fresh temp name + mkdir per attempt — same reasoning as the\n // async writeInner loop (delete-pending tombstones, swept dirs).\n const tmp = this.tempPath(file);\n try {\n fs.mkdirSync(path.dirname(file), { recursive: true });\n fs.writeFileSync(tmp, data);\n fs.renameSync(tmp, file);\n lastErr = undefined;\n break;\n } catch (e) {\n lastErr = e;\n try {\n fs.unlinkSync(tmp);\n } catch {\n // temp never created or already gone\n }\n if (!isTransientFsError(e) || attempt === this.retryAttempts - 1) break;\n // sync sleep (Atomics.wait) — backoff grows per attempt\n Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, this.backoffMs(attempt));\n }\n }\n if (!lastErr) {\n this.discovered.set(id, file);\n this.clearFailure(id);\n this.removeSpillSync(file);\n return true;\n }\n // The canonical write outlived the retry window (Windows lock held by\n // AV/indexer/SMB). Spill to a side file so the data still lands on\n // disk instead of being dropped — loadAll picks the freshest of the\n // canonical and the spill, with its own transient retry window.\n const spill = this.spillPathFor(file);\n let spillPath: string | null = null;\n for (let attempt = 0; attempt < this.retryAttempts && spillPath === null; attempt++) {\n try {\n fs.mkdirSync(path.dirname(spill), { recursive: true });\n fs.writeFileSync(spill, data);\n spillPath = spill;\n } catch (e) {\n if (!isTransientFsError(e) || attempt === this.retryAttempts - 1) break;\n Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, this.backoffMs(attempt));\n }\n }\n if (spillPath) this.discovered.set(id, spillPath);\n this.recordFailure(id, lastErr, spillPath);\n return spillPath !== null;\n }\n\n /** Load one record. Checks the discovered path (from a prior\n * write/loadAll), an optional relative-path hint, and the flat default\n * name. Returns null when absent, disabled, corrupt, or rejected by\n * validate. The hint covers namespaced records the store has not\n * discovered (e.g. an evicted session re-requested with its meta,\n * where the path depends on data the store cannot reconstruct from\n * the id alone). */\n loadSync(id: string, hint?: string): PersistedEnvelope<T> | null {\n if (!this.enabled) return null;\n const candidates = [\n this.discovered.get(id),\n hint ? path.join(this.dir, hint) : undefined,\n path.join(this.dir, flatFileNameFor(id)),\n ];\n for (const file of candidates) {\n if (!file) continue;\n const envelope = this.readEnvelope(file);\n if (envelope && envelope.id === id) return envelope;\n }\n return null;\n }\n\n /** Load every record under dir. Populates the discovery map (enables\n * loadSync for namespaced relPaths). Skips corrupt files, `.tmp-*`\n * orphans, and records whose filename does not match their id — one\n * bad file never blocks boot. Never throws. */\n async loadAll(): Promise<Map<string, PersistedEnvelope<T>>> {\n const out = new Map<string, PersistedEnvelope<T>>();\n if (!this.enabled) return out;\n const files = await this.walkJsonFiles(this.dir);\n for (const file of files) {\n const envelope = this.readEnvelope(file);\n if (!envelope) continue;\n const base = path.basename(file);\n const relBase = path.basename(this.relPathOf(envelope.id, envelope.payload));\n const flatBase = flatFileNameFor(envelope.id);\n // A file is a valid record for its envelope id when its name is the\n // canonical name OR a spill (`.fb`) of the canonical name. This lets\n // a spilled record (written while the canonical was locked) be\n // discovered and reconciled against the canonical by savedAt.\n let owner: string | null = null;\n if (base === relBase || base === flatBase) {\n owner = envelope.id;\n } else if (base.endsWith(\".fb.json\")) {\n const canonicalBase = `${base.slice(0, -\".fb.json\".length)}.json`;\n if (canonicalBase === relBase || canonicalBase === flatBase) {\n owner = envelope.id;\n }\n }\n if (owner === null) {\n this.log(\"warn\", `[persist] skipping ${rel(file, this.dir)}: filename does not match record id`);\n continue;\n }\n const existing = out.get(owner);\n if (!existing || envelope.savedAt >= existing.savedAt) {\n out.set(owner, envelope);\n this.discovered.set(owner, file);\n }\n }\n return out;\n }\n\n /** Whether a debounced write is pending for an id. */\n hasPending(id: string): boolean {\n return this.timers.has(id);\n }\n\n /** Ids with a pending debounced write. */\n pendingIds(): string[] {\n return [...this.timers.keys()];\n }\n\n /** Flush every pending debounced write immediately, then drain in-flight\n * writes. For graceful shutdown (SIGTERM/SIGINT). Never rejects. */\n async flushAll(): Promise<void> {\n const ids = this.pendingIds();\n for (const timer of this.timers.values()) clearTimeout(timer);\n this.timers.clear();\n const builders = new Map<string, () => T>();\n for (const id of ids) {\n const build = this.pending.get(id);\n if (build) builders.set(id, build);\n this.pending.delete(id);\n }\n await Promise.all(\n [...builders.entries()].map(([id, build]) =>\n this.writeNow(id, build).catch((e) => {\n this.log(\"error\", `[persist] shutdown flush failed for ${id}: ${errText(e)}`);\n }),\n ),\n );\n // Drain writes whose timer fired earlier but are still mid-flight.\n await Promise.allSettled([...this.writeChains.values()]);\n }\n\n /** Cancel all pending debounced writes without flushing (tests). */\n cancelAll(): void {\n for (const timer of this.timers.values()) clearTimeout(timer);\n this.timers.clear();\n this.pending.clear();\n }\n\n private async writeInner(id: string, build: () => T): Promise<void> {\n let payload: T;\n try {\n payload = build();\n } catch (e) {\n this.log(\"error\", `[persist] builder failed for ${id}: ${errText(e)}`);\n throw e;\n }\n const file = this.resolvePath(id, payload);\n const data = this.serialize(id, payload);\n let lastErr: unknown;\n for (let attempt = 0; attempt < this.retryAttempts; attempt++) {\n // Fresh temp name per attempt: on Windows a failed cleanup can\n // leave the previous name delete-pending, and creating over a\n // tombstoned name fails immediately — reusing it would burn every\n // remaining attempt before the write even happens. mkdir runs per\n // attempt too: a sweeper may have deleted the directory after the\n // previous cycle created it.\n const tmp = this.tempPath(file);\n try {\n await fsp.mkdir(path.dirname(file), { recursive: true });\n await fsp.writeFile(tmp, data);\n await fsp.rename(tmp, file);\n this.discovered.set(id, file);\n this.clearFailure(id);\n await this.removeSpill(file);\n return;\n } catch (e) {\n lastErr = e;\n // Clean up the .tmp orphan so the next write doesn't collide\n // with it.\n await fsp.unlink(tmp).catch(() => {});\n if (!isTransientFsError(e) || attempt === this.retryAttempts - 1) break;\n const { promise, resolve } = Promise.withResolvers<void>();\n setTimeout(resolve, this.backoffMs(attempt));\n await promise;\n }\n }\n // The canonical write outlived the retry window (Windows lock held\n // by AV/indexer/SMB, or a sweeper keeps deleting the fresh temp).\n // Spill to a side file so the data still lands on disk instead of\n // being dropped — loadAll picks the freshest of the canonical and\n // the spill. The spill write gets its own transient retry window for\n // the same reason (observed failing with ENOENT alongside the\n // canonical on CI Windows runners).\n const spill = this.spillPathFor(file);\n let spillPath: string | null = null;\n for (let attempt = 0; attempt < this.retryAttempts && spillPath === null; attempt++) {\n try {\n await fsp.mkdir(path.dirname(spill), { recursive: true });\n await fsp.writeFile(spill, data);\n spillPath = spill;\n } catch (e) {\n if (!isTransientFsError(e) || attempt === this.retryAttempts - 1) break;\n const { promise, resolve } = Promise.withResolvers<void>();\n setTimeout(resolve, this.backoffMs(attempt));\n await promise;\n }\n }\n if (spillPath) this.discovered.set(id, spillPath);\n this.recordFailure(id, lastErr, spillPath);\n throw lastErr;\n }\n\n private envelope(id: string, payload: T): PersistedEnvelope<T> {\n return { version: this.version, savedAt: Date.now(), id, payload };\n }\n\n /** Serialize an envelope for disk, applying the optional codec. Strings\n * are written as UTF-8 (the fs default); Buffer results pass through as\n * raw bytes. */\n private serialize(id: string, payload: T): Buffer | string {\n const json = JSON.stringify(this.envelope(id, payload));\n return this.codec ? this.codec.encode(json) : json;\n }\n\n /** Absolute path for a record: custom relPath (guarded against path\n * escape) or the flat hash default. */\n private resolvePath(id: string, payload: T): string {\n return path.join(this.dir, this.relPathOf(id, payload));\n }\n\n private relPathOf(id: string, payload: T): string {\n const custom = this.relPathFn?.(id, payload);\n if (!custom) return flatFileNameFor(id);\n const rel = path.normalize(custom);\n if (path.isAbsolute(rel) || rel.split(/[\\\\/]+/).includes(\"..\")) {\n this.log(\"warn\", `[persist] relPath for ${id} escapes dir; using flat name`);\n return flatFileNameFor(id);\n }\n return rel;\n }\n\n /** Unique temp file next to the destination (same dir ⇒ same volume ⇒\n * rename is atomic). Prefixed `.tmp-` so loadAll skips orphans. */\n private tempPath(dest: string): string {\n const seq = this.tmpSeq++;\n return path.join(path.dirname(dest), `.tmp-${path.basename(dest, \".json\")}-${process.pid}-${seq}`);\n }\n\n private backoffMs(attempt: number): number {\n return Math.min(this.retryBaseMs * 2 ** attempt, this.retryMaxMs);\n }\n\n /** Side file for a record whose canonical write keeps failing: the\n * canonical name with a `.fb` (fallback) infix, e.g. `a.json` →\n * `a.fb.json`. One slot per id, overwritten on each spill, so a stuck\n * lock never accumulates files. Ends in `.json` so loadAll discovers it. */\n private spillPathFor(file: string): string {\n const base = path.basename(file);\n const dot = base.lastIndexOf(\".\");\n const stem = dot > 0 ? base.slice(0, dot) : base;\n const ext = dot > 0 ? base.slice(dot) : \".json\";\n return path.join(path.dirname(file), `${stem}.fb${ext}`);\n }\n\n /** Remove a stale spill after a successful canonical write (best-effort). */\n private async removeSpill(file: string): Promise<void> {\n await fsp.unlink(this.spillPathFor(file)).catch(() => {});\n }\n\n private removeSpillSync(file: string): void {\n try {\n fs.unlinkSync(this.spillPathFor(file));\n } catch {\n // no spill or still locked — loadAll reconciles by savedAt\n }\n }\n\n /** Rate-limited failure alerting: log on the first failure and at each\n * power-of-two count (1,2,4,8,…), so a long lock yields ~log2(N) lines\n * instead of one per write. Includes the spill path so the operator can\n * see where the data landed. */\n private recordFailure(id: string, err: unknown, spillPath: string | null): void {\n const count = (this.failCounts.get(id) ?? 0) + 1;\n this.failCounts.set(id, count);\n const alertAt = count === 1 || (count >= 2 && (count & (count - 1)) === 0);\n if (!alertAt) return;\n const where = spillPath\n ? `; data spilled to ${rel(spillPath, this.dir)}`\n : \"; SPILLOVER ALSO FAILED — data at risk\";\n this.log(count === 1 ? \"error\" : \"warn\", `[persist] write failed for ${id} (total ${count}x): ${errText(err)}${where}`);\n }\n\n private clearFailure(id: string): void {\n this.failCounts.delete(id);\n }\n\n /** Parse + validate one file. Corrupt or invalid records return null\n * (logged) instead of throwing — load paths must never block boot. */\n private readEnvelope(file: string): PersistedEnvelope<T> | null {\n let parsed: unknown;\n try {\n const buf = fs.readFileSync(file);\n const text = this.codec ? this.codec.decode(buf) : buf.toString(\"utf8\");\n parsed = JSON.parse(text);\n } catch (e) {\n // A missing candidate path is an expected miss (loadSync probes);\n // only genuinely unreadable/corrupt files get logged.\n if ((e as NodeJS.ErrnoException).code !== \"ENOENT\") {\n this.log(\"warn\", `[persist] skipping corrupt file ${rel(file, this.dir)}: ${errText(e)}`);\n }\n return null;\n }\n if (isEnvelopeLike(parsed)) {\n if (!this.validateFn(parsed as PersistedEnvelope<T>)) {\n this.log(\"warn\", `[persist] skipping invalid record ${rel(file, this.dir)}`);\n return null;\n }\n return parsed as PersistedEnvelope<T>;\n }\n const adopted = this.adoptLegacy(parsed);\n if (adopted) return adopted;\n this.log(\"warn\", `[persist] skipping invalid record ${rel(file, this.dir)}`);\n return null;\n }\n\n /** Wrap a legacy (pre-envelope) record as an envelope via the `legacy`\n * hook, then validate the adopted payload like any other. */\n private adoptLegacy(parsed: unknown): PersistedEnvelope<T> | null {\n const adoption = this.legacyFn ? this.legacyFn(parsed) : null;\n if (!adoption || typeof adoption.id !== \"string\" || adoption.id.length === 0 || adoption.payload == null) {\n return null;\n }\n const source = parsed as Partial<PersistedEnvelope<T>>;\n const envelope: PersistedEnvelope<T> = {\n version: adoption.version ?? source.version ?? this.version,\n savedAt: adoption.savedAt ?? source.savedAt ?? 0,\n id: adoption.id,\n payload: adoption.payload,\n };\n if (!this.validateFn(envelope)) return null;\n return envelope;\n }\n\n /** Iterative recursive walk (no readdir-recursive dependency), skipping\n * `.tmp-*` names and non-.json files. */\n private async walkJsonFiles(root: string): Promise<string[]> {\n const out: string[] = [];\n const queue: string[] = [root];\n while (queue.length > 0) {\n const dir = queue.pop()!;\n let dirents: fs.Dirent[];\n try {\n dirents = await fsp.readdir(dir, { withFileTypes: true });\n } catch {\n continue; // missing dir → no records yet\n }\n for (const d of dirents) {\n if (d.name.startsWith(\".tmp-\")) continue;\n const full = path.join(dir, d.name);\n if (d.isDirectory()) queue.push(full);\n else if (d.isFile() && d.name.endsWith(\".json\")) out.push(full);\n }\n }\n return out;\n }\n}\n\nfunction defaultValidate<T>(envelope: PersistedEnvelope<T>): boolean {\n return typeof envelope.id === \"string\" && envelope.id.length > 0 && envelope.payload != null;\n}\n\nfunction isEnvelopeLike(value: unknown): value is PersistedEnvelope<unknown> {\n if (!value || typeof value !== \"object\") return false;\n const v = value as Partial<PersistedEnvelope<unknown>>;\n return typeof v.id === \"string\" && \"payload\" in v;\n}\n\n/** Deterministic flat filename: `<sha256(id)[:24]>.json`. Truncated hash —\n * 96 bits keeps collisions unreachable for realistic id counts, and short\n * names stay greppable. */\nexport function flatFileNameFor(id: string): string {\n return createHash(\"sha256\").update(id, \"utf8\").digest(\"hex\").slice(0, 24) + \".json\";\n}\n\n/** Transient fs failure codes worth retrying the whole write cycle for:\n * - EPERM/EBUSY/EACCES — a lock held on the file/dir (AV scan, search\n * indexer, SMB); releases within the backoff window.\n * - ENOENT/ENOTDIR — the temp file or its directory VANISHED between\n * create and rename (a sweeper deleting fresh files under %TEMP%, seen\n * on CI Windows runners), or a delete-pending tombstone from the same\n * sweep. Recreating the dir + rewriting a fresh temp heals it. */\nfunction isTransientFsError(e: unknown): boolean {\n const code = (e as NodeJS.ErrnoException).code;\n return code === \"EPERM\" || code === \"EBUSY\" || code === \"EACCES\" || code === \"ENOENT\" || code === \"ENOTDIR\";\n}\n\nfunction errText(e: unknown): string {\n return e instanceof Error ? e.message : String(e);\n}\n\n\nfunction rel(p: string, base: string): string {\n const r = path.relative(base, p);\n return r && !r.startsWith(\"..\") ? r : p;\n}\n","import type { CompressionState } from \"../types.js\";\nimport { createInitialState } from \"../state.js\";\n\n/**\n * Forward-compat: merge a parsed state with a fresh one so fields added in\n * later kernel versions get sane defaults instead of `undefined`. Nested\n * groups (nudge, stats) are shallow-merged per field so older snapshots\n * keep their values while newer counters default in.\n *\n * Lifted verbatim in behavior from billion-context's proxy mergeState.\n */\nexport function mergeCompressionState(parsed: CompressionState): CompressionState {\n const fresh = createInitialState();\n return {\n blocks: parsed.blocks ?? fresh.blocks,\n messageRefs: parsed.messageRefs ?? fresh.messageRefs,\n nudge: { ...fresh.nudge, ...(parsed.nudge ?? {}) },\n stats: { ...fresh.stats, ...(parsed.stats ?? {}) },\n nextBlockId: parsed.nextBlockId ?? fresh.nextBlockId,\n nextRunId: parsed.nextRunId ?? fresh.nextRunId,\n tokenSnapshot: parsed.tokenSnapshot ?? fresh.tokenSnapshot,\n absorbed: parsed.absorbed ?? fresh.absorbed,\n rules: parsed.rules ?? fresh.rules,\n nextRuleId: parsed.nextRuleId ?? fresh.nextRuleId,\n terminalStreak: parsed.terminalStreak,\n };\n}\n"],"mappings":";;;;;AAAA,SAAS,kBAAkB;AAC3B,OAAO,QAAQ;AACf,OAAO,SAAS;AAChB,OAAO,UAAU;AA2IV,IAAM,aAAN,MAAoB;AAAA,EACd;AAAA,EACQ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G;AAAA,IACjD,OAAO,EAAE,GAAG,MAAM,OAAO,GAAI,OAAO,SAAS,CAAC,EAAG;AAAA,IACjD,aAAa,OAAO,eAAe,MAAM;AAAA,IACzC,WAAW,OAAO,aAAa,MAAM;AAAA,IACrC,eAAe,OAAO,iBAAiB,MAAM;AAAA,IAC7C,UAAU,OAAO,YAAY,MAAM;AAAA,IACnC,OAAO,OAAO,SAAS,MAAM;AAAA,IAC7B,YAAY,OAAO,cAAc,MAAM;AAAA,IACvC,gBAAgB,OAAO;AAAA,EACzB;AACF;","names":["rel"]}
|
|
1
|
+
{"version":3,"sources":["../../src/persist/store.ts","../../src/persist/state-merge.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\nimport fs from \"node:fs\";\nimport fsp from \"node:fs/promises\";\nimport path from \"node:path\";\n\n/** Logger callback. Downstream routes it wherever it wants (file, stderr). */\nexport type PersistLogger = (level: \"info\" | \"warn\" | \"error\", msg: string) => void;\n\n/**\n * On-disk record shape. The store owns the envelope (version stamp, save\n * time, id) so atomicity and discovery can rely on it; the payload schema\n * is entirely downstream-owned. `payload` must be JSON-serializable.\n */\nexport interface PersistedEnvelope<T> {\n version: number;\n savedAt: number;\n id: string;\n payload: T;\n}\n\n/** A legacy (pre-envelope) record adopted on load. `version`/`savedAt`\n * preserve the source record's own stamps when present. */\nexport interface LegacyAdoption<T> {\n id: string;\n payload: T;\n version?: number;\n savedAt?: number;\n}\n\n/**\n * Optional record codec: transforms serialized envelopes between the store\n * and disk (e.g. compress and/or encrypt at rest). The store is\n * codec-agnostic — it hands `encode` the exact JSON string it would have\n * written and passes raw file bytes to `decode`, which must return that same\n * JSON string or throw, in which case the file is treated as corrupt\n * (skipped + logged) like any unreadable record. Format detection (magic\n * bytes, plaintext fallback for unencoded legacy files) is the codec's job,\n * so mixed trees of legacy plaintext and encoded files load fine.\n */\nexport interface StateStoreCodec {\n encode(data: string): Buffer | string;\n decode(buf: Buffer): string;\n}\n\nexport interface StateStoreOptions<T> {\n /**\n * Storage root. The kernel deliberately has NO default location: the\n * downstream decides where state lives (CLI dir, XDG data dir, plugin\n * dir, temp dir in tests). All records live under this directory.\n */\n dir: string;\n /**\n * Schema version stamped into every envelope. Owned by the downstream;\n * bump it when the payload shape changes. The store itself never\n * rejects a record over its version — migration policy belongs to the\n * reader.\n */\n version: number;\n /** Debounce window for scheduleSave, ms. Default 500. */\n debounceMs?: number;\n /** Default true. When false, all writes are silent no-ops and loads\n * return empty results. */\n enabled?: boolean;\n log?: PersistLogger;\n /**\n * Relative path (under `dir`) for a record, possibly namespaced into\n * subdirectories (e.g. `openai/host-hash.json`). Default: flat\n * `<sha256(id)[:24]>.json`.\n *\n * Because the path may depend on payload fields the store only learns\n * at write time, single-record loads resolve namespaced files only\n * after loadAll() has discovered them (or the store itself wrote\n * them). The flat default name is always checked as a fallback, so\n * downstreams using a custom relPath should call loadAll() at boot.\n */\n relPath?: (id: string, payload: T) => string;\n /**\n * Adopt records written by an older, pre-envelope schema. Receives the\n * parsed JSON of any file that failed the envelope-shape check; return\n * an adoption to load it as an envelope, or null to skip it. Adopted\n * records are re-persisted in the current envelope format on the next\n * dirty write — files migrate organically, and old files keep loading\n * (same policy billion-context's proxy used for its v1→v3 migration).\n */\n legacy?: (parsed: unknown) => LegacyAdoption<T> | null;\n /**\n * Payload validation on load. Return false to skip a record (foreign\n * schema, corrupt content). Default: envelope-shape check only\n * (string id, non-null payload).\n */\n validate?: (envelope: PersistedEnvelope<T>) => boolean;\n /**\n * Optional codec applied around every write (canonical + spill) and\n * read. See StateStoreCodec. Default: none — files are plain UTF-8 JSON.\n */\n codec?: StateStoreCodec;\n /**\n * Transient-write retry policy (Windows + hostile temp environments).\n * The whole write cycle — mkdir, temp write, rename — is retried with\n * exponential backoff when it fails with a TRANSIENT code: EPERM/EBUSY/\n * EACCES (a lock held by AV scan, search indexer, SMB) or ENOENT/ENOTDIR\n * (the temp file or its directory vanished between create and rename —\n * observed on CI Windows runners where a sweeper deletes freshly\n * created files under %TEMP%). The delay after attempt i is\n * min(retryBaseMs * 2^i, retryMaxMs). Defaults (6 attempts, 50ms base,\n * 1600ms cap) give a ~1.5s window per write path — long enough for most\n * locks to release, short enough not to stall a sync flush. When the\n * window is exhausted the write spills to a side file (see spillPath)\n * instead of dropping the data.\n */\n retryAttempts?: number;\n retryBaseMs?: number;\n retryMaxMs?: number;\n}\n\n/**\n * Crash-safe, debounce-coalescing JSON state store. Mechanism only — lifted\n * from billion-context's proxy SessionStore and generalized:\n *\n * - atomic writes: temp file + rename, so a crash mid-write never leaves a\n * truncated record (readers see either the old or the new file)\n * - whole-cycle retries with exponential backoff on transient fs failures:\n * Windows locks (EPERM/EBUSY/EACCES from AV/indexer/SMB) and vanishing\n * files/dirs (ENOENT/ENOTDIR — a sweeper deleting fresh temp files, seen\n * on CI Windows runners); when the window is exhausted the record spills\n * to a side file (`<name>.fb.json`) instead of being dropped, so a lock\n * held by AV/indexer/SMB never silently loses session data\n * - per-id serialization so concurrent writeNow calls never interleave\n * temp-file names or reorders writes\n * - debounced scheduleSave coalesces bursts into one write; the record is\n * built at WRITE time from a builder, so late mutations are picked up\n * - optional record codec (compress/encrypt at rest): encode on every write,\n * decode on every read; a decode failure is corrupt-file semantics\n * - loadAll skips `.tmp-*` orphans, corrupt JSON, and records whose\n * filename does not match their id — one bad file never blocks boot; it\n * reconciles a canonical record against its spill by savedAt (freshest wins)\n *\n * The store never deletes a record's data. On a successful canonical write it\n * removes a now-stale spill of the SAME id (a duplicate, not distinct data).\n * Session cleanup is a downstream policy decision (kernel position: persisted\n * state should not be deleted opportunistically).\n */\nexport class StateStore<T> {\n readonly enabled: boolean;\n private readonly dir: string;\n private readonly version: number;\n private readonly debounceMs: number;\n private readonly log: PersistLogger;\n private readonly legacyFn?: (parsed: unknown) => LegacyAdoption<T> | null;\n private readonly relPathFn?: (id: string, payload: T) => string;\n private readonly validateFn: (envelope: PersistedEnvelope<T>) => boolean;\n private readonly codec?: StateStoreCodec;\n private readonly retryAttempts: number;\n private readonly retryBaseMs: number;\n private readonly retryMaxMs: number;\n private readonly timers = new Map<string, NodeJS.Timeout>();\n private readonly pending = new Map<string, () => T>();\n private readonly writeChains = new Map<string, Promise<void>>();\n /** id → absolute path, populated by writes and loadAll. */\n private readonly discovered = new Map<string, string>();\n /** id → cumulative write-failure count, for rate-limited alerting. */\n private readonly failCounts = new Map<string, number>();\n /** Monotonic counter for unique temp filenames within a process. */\n private tmpSeq = 0;\n\n constructor(opts: StateStoreOptions<T>) {\n this.dir = opts.dir;\n this.version = opts.version;\n this.debounceMs = opts.debounceMs ?? 500;\n this.enabled = opts.enabled ?? true;\n this.log = opts.log ?? ((_level, _msg) => {});\n this.relPathFn = opts.relPath;\n this.legacyFn = opts.legacy;\n this.validateFn = opts.validate ?? defaultValidate;\n this.codec = opts.codec;\n this.retryAttempts = Math.max(1, opts.retryAttempts ?? 6);\n this.retryBaseMs = Math.max(1, opts.retryBaseMs ?? 50);\n this.retryMaxMs = Math.max(this.retryBaseMs, opts.retryMaxMs ?? 1600);\n }\n\n /** Debounced save. Coalesces bursts; the builder runs at write time, so\n * the freshest state is always persisted. Never throws. */\n scheduleSave(id: string, build: () => T): void {\n if (!this.enabled) return;\n this.pending.set(id, build);\n const existing = this.timers.get(id);\n if (existing) return;\n const timer = setTimeout(() => {\n this.timers.delete(id);\n const builder = this.pending.get(id);\n this.pending.delete(id);\n if (!builder) return;\n // Errors are logged inside writeInner; swallowing here keeps a\n // failed timer write from becoming an unhandledRejection.\n void this.writeNow(id, builder).catch(() => {});\n }, this.debounceMs);\n timer.unref?.();\n this.timers.set(id, timer);\n }\n\n /** Immediate save, serialized per id. Rejects on write failure; a\n * failing write never breaks the chain for the next one. */\n async writeNow(id: string, build: () => T): Promise<void> {\n if (!this.enabled) return;\n // The previous promise may reject (disk full, EPERM) — catch so our\n // chain doesn't break, then run our own write.\n const prev = this.writeChains.get(id) ?? Promise.resolve();\n const next = prev.catch(() => {}).then(() => this.writeInner(id, build));\n this.writeChains.set(id, next);\n // Clean up the chain entry once settled so the Map doesn't grow. The\n // .catch() is load-bearing: .finally() returns a derived promise that\n // nobody else holds — when the chain rejects it would surface as an\n // unhandledRejection and crash the host on default Node settings.\n next\n .finally(() => {\n if (this.writeChains.get(id) === next) this.writeChains.delete(id);\n })\n .catch(() => {});\n return next;\n }\n\n /** Synchronous flush for one id. Used where the caller cannot await\n * (memory eviction, sync shutdown paths). Cancels any pending debounce\n * timer. Returns true on success, false on failure — callers that use\n * the result to drop in-memory state must NOT drop it on failure. */\n flushSync(id: string, build: () => T): boolean {\n if (!this.enabled) return true;\n const timer = this.timers.get(id);\n if (timer) {\n clearTimeout(timer);\n this.timers.delete(id);\n this.pending.delete(id);\n }\n let payload: T;\n try {\n payload = build();\n } catch (e) {\n this.log(\"error\", `[persist] builder failed for ${id}: ${errText(e)}`);\n return false;\n }\n const file = this.resolvePath(id, payload);\n const data = this.serialize(id, payload);\n let lastErr: unknown;\n for (let attempt = 0; attempt < this.retryAttempts; attempt++) {\n // Fresh temp name + mkdir per attempt — same reasoning as the\n // async writeInner loop (delete-pending tombstones, swept dirs).\n const tmp = this.tempPath(file);\n try {\n fs.mkdirSync(path.dirname(file), { recursive: true });\n fs.writeFileSync(tmp, data);\n fs.renameSync(tmp, file);\n lastErr = undefined;\n break;\n } catch (e) {\n lastErr = e;\n try {\n fs.unlinkSync(tmp);\n } catch {\n // temp never created or already gone\n }\n if (!isTransientFsError(e) || attempt === this.retryAttempts - 1) break;\n // sync sleep (Atomics.wait) — backoff grows per attempt\n Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, this.backoffMs(attempt));\n }\n }\n if (!lastErr) {\n this.discovered.set(id, file);\n this.clearFailure(id);\n this.removeSpillSync(file);\n return true;\n }\n // The canonical write outlived the retry window (Windows lock held by\n // AV/indexer/SMB). Spill to a side file so the data still lands on\n // disk instead of being dropped — loadAll picks the freshest of the\n // canonical and the spill, with its own transient retry window.\n const spill = this.spillPathFor(file);\n let spillPath: string | null = null;\n for (let attempt = 0; attempt < this.retryAttempts && spillPath === null; attempt++) {\n try {\n fs.mkdirSync(path.dirname(spill), { recursive: true });\n fs.writeFileSync(spill, data);\n spillPath = spill;\n } catch (e) {\n if (!isTransientFsError(e) || attempt === this.retryAttempts - 1) break;\n Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, this.backoffMs(attempt));\n }\n }\n if (spillPath) this.discovered.set(id, spillPath);\n this.recordFailure(id, lastErr, spillPath);\n return spillPath !== null;\n }\n\n /** Load one record. Checks the discovered path (from a prior\n * write/loadAll), an optional relative-path hint, and the flat default\n * name. Returns null when absent, disabled, corrupt, or rejected by\n * validate. The hint covers namespaced records the store has not\n * discovered (e.g. an evicted session re-requested with its meta,\n * where the path depends on data the store cannot reconstruct from\n * the id alone). */\n loadSync(id: string, hint?: string): PersistedEnvelope<T> | null {\n if (!this.enabled) return null;\n const candidates = [\n this.discovered.get(id),\n hint ? path.join(this.dir, hint) : undefined,\n path.join(this.dir, flatFileNameFor(id)),\n ];\n for (const file of candidates) {\n if (!file) continue;\n const envelope = this.readEnvelope(file);\n if (envelope && envelope.id === id) return envelope;\n }\n return null;\n }\n\n /** Load every record under dir. Populates the discovery map (enables\n * loadSync for namespaced relPaths). Skips corrupt files, `.tmp-*`\n * orphans, and records whose filename does not match their id — one\n * bad file never blocks boot. Never throws. */\n async loadAll(): Promise<Map<string, PersistedEnvelope<T>>> {\n const out = new Map<string, PersistedEnvelope<T>>();\n if (!this.enabled) return out;\n const files = await this.walkJsonFiles(this.dir);\n for (const file of files) {\n const envelope = this.readEnvelope(file);\n if (!envelope) continue;\n const base = path.basename(file);\n const relBase = path.basename(this.relPathOf(envelope.id, envelope.payload));\n const flatBase = flatFileNameFor(envelope.id);\n // A file is a valid record for its envelope id when its name is the\n // canonical name OR a spill (`.fb`) of the canonical name. This lets\n // a spilled record (written while the canonical was locked) be\n // discovered and reconciled against the canonical by savedAt.\n let owner: string | null = null;\n if (base === relBase || base === flatBase) {\n owner = envelope.id;\n } else if (base.endsWith(\".fb.json\")) {\n const canonicalBase = `${base.slice(0, -\".fb.json\".length)}.json`;\n if (canonicalBase === relBase || canonicalBase === flatBase) {\n owner = envelope.id;\n }\n }\n if (owner === null) {\n this.log(\"warn\", `[persist] skipping ${rel(file, this.dir)}: filename does not match record id`);\n continue;\n }\n const existing = out.get(owner);\n if (!existing || envelope.savedAt >= existing.savedAt) {\n out.set(owner, envelope);\n this.discovered.set(owner, file);\n }\n }\n return out;\n }\n\n /** Whether a debounced write is pending for an id. */\n hasPending(id: string): boolean {\n return this.timers.has(id);\n }\n\n /** Ids with a pending debounced write. */\n pendingIds(): string[] {\n return [...this.timers.keys()];\n }\n\n /** Flush every pending debounced write immediately, then drain in-flight\n * writes. For graceful shutdown (SIGTERM/SIGINT). Never rejects. */\n async flushAll(): Promise<void> {\n const ids = this.pendingIds();\n for (const timer of this.timers.values()) clearTimeout(timer);\n this.timers.clear();\n const builders = new Map<string, () => T>();\n for (const id of ids) {\n const build = this.pending.get(id);\n if (build) builders.set(id, build);\n this.pending.delete(id);\n }\n await Promise.all(\n [...builders.entries()].map(([id, build]) =>\n this.writeNow(id, build).catch((e) => {\n this.log(\"error\", `[persist] shutdown flush failed for ${id}: ${errText(e)}`);\n }),\n ),\n );\n // Drain writes whose timer fired earlier but are still mid-flight.\n await Promise.allSettled([...this.writeChains.values()]);\n }\n\n /** Cancel all pending debounced writes without flushing (tests). */\n cancelAll(): void {\n for (const timer of this.timers.values()) clearTimeout(timer);\n this.timers.clear();\n this.pending.clear();\n }\n\n private async writeInner(id: string, build: () => T): Promise<void> {\n let payload: T;\n try {\n payload = build();\n } catch (e) {\n this.log(\"error\", `[persist] builder failed for ${id}: ${errText(e)}`);\n throw e;\n }\n const file = this.resolvePath(id, payload);\n const data = this.serialize(id, payload);\n let lastErr: unknown;\n for (let attempt = 0; attempt < this.retryAttempts; attempt++) {\n // Fresh temp name per attempt: on Windows a failed cleanup can\n // leave the previous name delete-pending, and creating over a\n // tombstoned name fails immediately — reusing it would burn every\n // remaining attempt before the write even happens. mkdir runs per\n // attempt too: a sweeper may have deleted the directory after the\n // previous cycle created it.\n const tmp = this.tempPath(file);\n try {\n await fsp.mkdir(path.dirname(file), { recursive: true });\n await fsp.writeFile(tmp, data);\n await fsp.rename(tmp, file);\n this.discovered.set(id, file);\n this.clearFailure(id);\n await this.removeSpill(file);\n return;\n } catch (e) {\n lastErr = e;\n // Clean up the .tmp orphan so the next write doesn't collide\n // with it.\n await fsp.unlink(tmp).catch(() => {});\n if (!isTransientFsError(e) || attempt === this.retryAttempts - 1) break;\n const { promise, resolve } = Promise.withResolvers<void>();\n setTimeout(resolve, this.backoffMs(attempt));\n await promise;\n }\n }\n // The canonical write outlived the retry window (Windows lock held\n // by AV/indexer/SMB, or a sweeper keeps deleting the fresh temp).\n // Spill to a side file so the data still lands on disk instead of\n // being dropped — loadAll picks the freshest of the canonical and\n // the spill. The spill write gets its own transient retry window for\n // the same reason (observed failing with ENOENT alongside the\n // canonical on CI Windows runners).\n const spill = this.spillPathFor(file);\n let spillPath: string | null = null;\n for (let attempt = 0; attempt < this.retryAttempts && spillPath === null; attempt++) {\n try {\n await fsp.mkdir(path.dirname(spill), { recursive: true });\n await fsp.writeFile(spill, data);\n spillPath = spill;\n } catch (e) {\n if (!isTransientFsError(e) || attempt === this.retryAttempts - 1) break;\n const { promise, resolve } = Promise.withResolvers<void>();\n setTimeout(resolve, this.backoffMs(attempt));\n await promise;\n }\n }\n if (spillPath) this.discovered.set(id, spillPath);\n this.recordFailure(id, lastErr, spillPath);\n throw lastErr;\n }\n\n private envelope(id: string, payload: T): PersistedEnvelope<T> {\n return { version: this.version, savedAt: Date.now(), id, payload };\n }\n\n /** Serialize an envelope for disk, applying the optional codec. Strings\n * are written as UTF-8 (the fs default); Buffer results pass through as\n * raw bytes. */\n private serialize(id: string, payload: T): Buffer | string {\n const json = JSON.stringify(this.envelope(id, payload));\n return this.codec ? this.codec.encode(json) : json;\n }\n\n /** Absolute path for a record: custom relPath (guarded against path\n * escape) or the flat hash default. */\n private resolvePath(id: string, payload: T): string {\n return path.join(this.dir, this.relPathOf(id, payload));\n }\n\n private relPathOf(id: string, payload: T): string {\n const custom = this.relPathFn?.(id, payload);\n if (!custom) return flatFileNameFor(id);\n const rel = path.normalize(custom);\n if (path.isAbsolute(rel) || rel.split(/[\\\\/]+/).includes(\"..\")) {\n this.log(\"warn\", `[persist] relPath for ${id} escapes dir; using flat name`);\n return flatFileNameFor(id);\n }\n return rel;\n }\n\n /** Unique temp file next to the destination (same dir ⇒ same volume ⇒\n * rename is atomic). Prefixed `.tmp-` so loadAll skips orphans. */\n private tempPath(dest: string): string {\n const seq = this.tmpSeq++;\n return path.join(path.dirname(dest), `.tmp-${path.basename(dest, \".json\")}-${process.pid}-${seq}`);\n }\n\n private backoffMs(attempt: number): number {\n return Math.min(this.retryBaseMs * 2 ** attempt, this.retryMaxMs);\n }\n\n /** Side file for a record whose canonical write keeps failing: the\n * canonical name with a `.fb` (fallback) infix, e.g. `a.json` →\n * `a.fb.json`. One slot per id, overwritten on each spill, so a stuck\n * lock never accumulates files. Ends in `.json` so loadAll discovers it. */\n private spillPathFor(file: string): string {\n const base = path.basename(file);\n const dot = base.lastIndexOf(\".\");\n const stem = dot > 0 ? base.slice(0, dot) : base;\n const ext = dot > 0 ? base.slice(dot) : \".json\";\n return path.join(path.dirname(file), `${stem}.fb${ext}`);\n }\n\n /** Remove a stale spill after a successful canonical write (best-effort). */\n private async removeSpill(file: string): Promise<void> {\n await fsp.unlink(this.spillPathFor(file)).catch(() => {});\n }\n\n private removeSpillSync(file: string): void {\n try {\n fs.unlinkSync(this.spillPathFor(file));\n } catch {\n // no spill or still locked — loadAll reconciles by savedAt\n }\n }\n\n /** Rate-limited failure alerting: log on the first failure and at each\n * power-of-two count (1,2,4,8,…), so a long lock yields ~log2(N) lines\n * instead of one per write. Includes the spill path so the operator can\n * see where the data landed. */\n private recordFailure(id: string, err: unknown, spillPath: string | null): void {\n const count = (this.failCounts.get(id) ?? 0) + 1;\n this.failCounts.set(id, count);\n const alertAt = count === 1 || (count >= 2 && (count & (count - 1)) === 0);\n if (!alertAt) return;\n const where = spillPath\n ? `; data spilled to ${rel(spillPath, this.dir)}`\n : \"; SPILLOVER ALSO FAILED — data at risk\";\n this.log(count === 1 ? \"error\" : \"warn\", `[persist] write failed for ${id} (total ${count}x): ${errText(err)}${where}`);\n }\n\n private clearFailure(id: string): void {\n this.failCounts.delete(id);\n }\n\n /** Parse + validate one file. Corrupt or invalid records return null\n * (logged) instead of throwing — load paths must never block boot. */\n private readEnvelope(file: string): PersistedEnvelope<T> | null {\n let parsed: unknown;\n try {\n const buf = fs.readFileSync(file);\n const text = this.codec ? this.codec.decode(buf) : buf.toString(\"utf8\");\n parsed = JSON.parse(text);\n } catch (e) {\n // A missing candidate path is an expected miss (loadSync probes);\n // only genuinely unreadable/corrupt files get logged.\n if ((e as NodeJS.ErrnoException).code !== \"ENOENT\") {\n this.log(\"warn\", `[persist] skipping corrupt file ${rel(file, this.dir)}: ${errText(e)}`);\n }\n return null;\n }\n if (isEnvelopeLike(parsed)) {\n if (!this.validateFn(parsed as PersistedEnvelope<T>)) {\n this.log(\"warn\", `[persist] skipping invalid record ${rel(file, this.dir)}`);\n return null;\n }\n return parsed as PersistedEnvelope<T>;\n }\n const adopted = this.adoptLegacy(parsed);\n if (adopted) return adopted;\n this.log(\"warn\", `[persist] skipping invalid record ${rel(file, this.dir)}`);\n return null;\n }\n\n /** Wrap a legacy (pre-envelope) record as an envelope via the `legacy`\n * hook, then validate the adopted payload like any other. */\n private adoptLegacy(parsed: unknown): PersistedEnvelope<T> | null {\n const adoption = this.legacyFn ? this.legacyFn(parsed) : null;\n if (!adoption || typeof adoption.id !== \"string\" || adoption.id.length === 0 || adoption.payload == null) {\n return null;\n }\n const source = parsed as Partial<PersistedEnvelope<T>>;\n const envelope: PersistedEnvelope<T> = {\n version: adoption.version ?? source.version ?? this.version,\n savedAt: adoption.savedAt ?? source.savedAt ?? 0,\n id: adoption.id,\n payload: adoption.payload,\n };\n if (!this.validateFn(envelope)) return null;\n return envelope;\n }\n\n /** Iterative recursive walk (no readdir-recursive dependency), skipping\n * `.tmp-*` names and non-.json files. */\n private async walkJsonFiles(root: string): Promise<string[]> {\n const out: string[] = [];\n const queue: string[] = [root];\n while (queue.length > 0) {\n const dir = queue.pop()!;\n let dirents: fs.Dirent[];\n try {\n dirents = await fsp.readdir(dir, { withFileTypes: true });\n } catch {\n continue; // missing dir → no records yet\n }\n for (const d of dirents) {\n if (d.name.startsWith(\".tmp-\")) continue;\n const full = path.join(dir, d.name);\n if (d.isDirectory()) queue.push(full);\n else if (d.isFile() && d.name.endsWith(\".json\")) out.push(full);\n }\n }\n return out;\n }\n}\n\nfunction defaultValidate<T>(envelope: PersistedEnvelope<T>): boolean {\n return typeof envelope.id === \"string\" && envelope.id.length > 0 && envelope.payload != null;\n}\n\nfunction isEnvelopeLike(value: unknown): value is PersistedEnvelope<unknown> {\n if (!value || typeof value !== \"object\") return false;\n const v = value as Partial<PersistedEnvelope<unknown>>;\n return typeof v.id === \"string\" && \"payload\" in v;\n}\n\n/** Deterministic flat filename: `<sha256(id)[:24]>.json`. Truncated hash —\n * 96 bits keeps collisions unreachable for realistic id counts, and short\n * names stay greppable. */\nexport function flatFileNameFor(id: string): string {\n return createHash(\"sha256\").update(id, \"utf8\").digest(\"hex\").slice(0, 24) + \".json\";\n}\n\n/** Transient fs failure codes worth retrying the whole write cycle for:\n * - EPERM/EBUSY/EACCES — a lock held on the file/dir (AV scan, search\n * indexer, SMB); releases within the backoff window.\n * - ENOENT/ENOTDIR — the temp file or its directory VANISHED between\n * create and rename (a sweeper deleting fresh files under %TEMP%, seen\n * on CI Windows runners), or a delete-pending tombstone from the same\n * sweep. Recreating the dir + rewriting a fresh temp heals it. */\nfunction isTransientFsError(e: unknown): boolean {\n const code = (e as NodeJS.ErrnoException).code;\n return code === \"EPERM\" || code === \"EBUSY\" || code === \"EACCES\" || code === \"ENOENT\" || code === \"ENOTDIR\";\n}\n\nfunction errText(e: unknown): string {\n return e instanceof Error ? e.message : String(e);\n}\n\n\nfunction rel(p: string, base: string): string {\n const r = path.relative(base, p);\n return r && !r.startsWith(\"..\") ? r : p;\n}\n","import type { CompressionState } from \"../types.js\";\nimport { createInitialState } from \"../state.js\";\n\n/**\n * Forward-compat: merge a parsed state with a fresh one so fields added in\n * later kernel versions get sane defaults instead of `undefined`. Nested\n * groups (nudge, stats) are shallow-merged per field so older snapshots\n * keep their values while newer counters default in.\n *\n * Lifted verbatim in behavior from billion-context's proxy mergeState.\n */\nexport function mergeCompressionState(parsed: CompressionState): CompressionState {\n const fresh = createInitialState();\n return {\n blocks: parsed.blocks ?? fresh.blocks,\n messageRefs: parsed.messageRefs ?? fresh.messageRefs,\n nudge: { ...fresh.nudge, ...(parsed.nudge ?? {}) },\n stats: { ...fresh.stats, ...(parsed.stats ?? {}) },\n nextBlockId: parsed.nextBlockId ?? fresh.nextBlockId,\n nextRunId: parsed.nextRunId ?? fresh.nextRunId,\n tokenSnapshot: parsed.tokenSnapshot ?? fresh.tokenSnapshot,\n absorbed: parsed.absorbed ?? fresh.absorbed,\n rules: parsed.rules ?? fresh.rules,\n nextRuleId: parsed.nextRuleId ?? fresh.nextRuleId,\n terminalStreak: parsed.terminalStreak,\n imageFullRestored: parsed.imageFullRestored ?? fresh.imageFullRestored,\n imageShrinks: parsed.imageShrinks ?? fresh.imageShrinks,\n };\n}\n"],"mappings":";;;;;AAAA,SAAS,kBAAkB;AAC3B,OAAO,QAAQ;AACf,OAAO,SAAS;AAChB,OAAO,UAAU;AA2IV,IAAM,aAAN,MAAoB;AAAA,EACd;AAAA,EACQ;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,SAAS,oBAAI,IAA4B;AAAA,EACzC,UAAU,oBAAI,IAAqB;AAAA,EACnC,cAAc,o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AC7C,UAAU,OAAO,YAAY,MAAM;AAAA,IACnC,OAAO,OAAO,SAAS,MAAM;AAAA,IAC7B,YAAY,OAAO,cAAc,MAAM;AAAA,IACvC,gBAAgB,OAAO;AAAA,IACvB,mBAAmB,OAAO,qBAAqB,MAAM;AAAA,IACrD,cAAc,OAAO,gBAAgB,MAAM;AAAA,EAC7C;AACF;","names":["rel"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state-merge.d.ts","sourceRoot":"","sources":["../../src/persist/state-merge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAGpD;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,gBAAgB,GAAG,gBAAgB,
|
|
1
|
+
{"version":3,"file":"state-merge.d.ts","sourceRoot":"","sources":["../../src/persist/state-merge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAGpD;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,gBAAgB,GAAG,gBAAgB,CAiBhF"}
|
package/dist/pipeline.d.ts
CHANGED
|
@@ -3,6 +3,9 @@ export interface PipelineContext {
|
|
|
3
3
|
readonly config: import("./types.js").Config;
|
|
4
4
|
readonly tokenCount: number;
|
|
5
5
|
readonly countTokens: (text: string) => number;
|
|
6
|
+
/** Per-session CCR content store for this turn (ccr-store node updates it
|
|
7
|
+
* via effects.ccr; processTurn echoes it back in the result). */
|
|
8
|
+
readonly contentStore: import("./content-store.js").MessageContentStore;
|
|
6
9
|
}
|
|
7
10
|
export interface NodeEffects {
|
|
8
11
|
nudge?: NudgeDecision;
|
package/dist/pipeline.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../src/pipeline.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB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C,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,eAAe,GAAG,MAAM,CAAC;IAC9C,OAAO,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,eAAe,KAAK,OAAO,CAAC;CACzD;AAED,wBAAgB,MAAM,CACpB,QAAQ,EAAE,WAAW,EAAE,EACvB,KAAK,EAAE,gBAAgB,EACvB,OAAO,GAAE,WAAgB,GACxB,MAAM,CAER;AAED,wBAAgB,WAAW,CACzB,KAAK,EAAE,SAAS,YAAY,EAAE,EAC9B,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,eAAe,GACnB,MAAM,CAOR"}
|
package/dist/rebuild.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rebuild.d.ts","sourceRoot":"","sources":["../src/rebuild.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rebuild.d.ts","sourceRoot":"","sources":["../src/rebuild.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEhE,MAAM,WAAW,aAAa;IAC1B,KAAK,EAAE,gBAAgB,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,YAAY;IACzB,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;CAC1C;AAED;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CACnC,KAAK,EAAE,gBAAgB,EACvB,QAAQ,EAAE,WAAW,EAAE,EACvB,MAAM,EAAE,OAAO,YAAY,EAAE,MAAM,EACnC,KAAK,GAAE,YAAiB,GACzB,aAAa,CAqBf"}
|
package/dist/state.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../src/state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAErE,wBAAgB,kBAAkB,IAAI,gBAAgB,
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../src/state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAErE,wBAAgB,kBAAkB,IAAI,gBAAgB,CA8BrD;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,gBAAgB,GAAG,MAAM,CAI/D;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,gBAAgB,GAAG,MAAM,CAI7D;AAED,wBAAgB,SAAS,CACvB,KAAK,EAAE,gBAAgB,EACvB,OAAO,EAAE,MAAM,GACd,gBAAgB,GAAG,SAAS,CAE9B;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,gBAAgB,GAAG,gBAAgB,EAAE,CAExE;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,gBAAgB,GAAG,GAAG,CAAC,MAAM,CAAC,CAOtE;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,gBAAgB,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAMxE;AAED,wBAAgB,eAAe,CAC7B,KAAK,EAAE,gBAAgB,EACvB,kBAAkB,EAAE,MAAM,GACzB,IAAI,CAQN"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { MessageContentStore } from "./content-store.js";
|
|
1
2
|
export type MessageRole = "user" | "assistant" | "system" | "tool";
|
|
2
3
|
export type MessageContentType = "text" | "tool-call" | "tool-result" | "reasoning";
|
|
3
4
|
export interface CoreMessage {
|
|
@@ -82,6 +83,16 @@ export interface CompressionStats {
|
|
|
82
83
|
compressionCount: number;
|
|
83
84
|
/** Cumulative tokens reclaimed by absorb (instant tool-result hiding). Optional for pre-absorb persisted states. */
|
|
84
85
|
absorbedTokens?: number;
|
|
86
|
+
/** Cumulative images downscaled at arrival (image pre-compression, #353). Optional for pre-feature persisted states. */
|
|
87
|
+
imagesShrunk?: number;
|
|
88
|
+
/** Cumulative decoded-byte savings from image downsampling. */
|
|
89
|
+
imageBytesSaved?: number;
|
|
90
|
+
/** Cumulative estimated-token savings from image downsampling. */
|
|
91
|
+
imageTokensSaved?: number;
|
|
92
|
+
/** Cumulative messages stored in the CCR content store. Optional for pre-CCR persisted states. */
|
|
93
|
+
storedCount?: number;
|
|
94
|
+
/** Cumulative successful acp_retrieve calls. Optional for pre-CCR persisted states. */
|
|
95
|
+
retrievalCount?: number;
|
|
85
96
|
}
|
|
86
97
|
/** One instant tool-result absorption: the original tool-call + tool-result
|
|
87
98
|
* pair is hidden from view once recorded; the model's absorb call (carrying
|
|
@@ -141,6 +152,63 @@ export interface RulesConfig {
|
|
|
141
152
|
maxRules?: number;
|
|
142
153
|
maxRuleChars?: number;
|
|
143
154
|
}
|
|
155
|
+
export interface CrushStrategyOverride {
|
|
156
|
+
/** Set false to disable this strategy even when crush is enabled. Default true. */
|
|
157
|
+
enabled?: boolean;
|
|
158
|
+
/** Tool-name patterns (glob suffix allowed) this strategy skips. */
|
|
159
|
+
excludeTools?: string[];
|
|
160
|
+
}
|
|
161
|
+
/** Deterministic tool-result compression ("crush") — tier 1 of the absorb
|
|
162
|
+
* gate (see crush.ts). Absent/disabled = feature off. */
|
|
163
|
+
export interface CrushConfig {
|
|
164
|
+
enabled: boolean;
|
|
165
|
+
/** Minimum relative size reduction to accept a crushed result. In (0, 1]. */
|
|
166
|
+
minReduction: number;
|
|
167
|
+
/** Per-strategy toggles/exclusions keyed by plugin id (json-fold, code-trim, log-select, ...). */
|
|
168
|
+
strategies?: Record<string, CrushStrategyOverride>;
|
|
169
|
+
}
|
|
170
|
+
export type ImageFormat = "webp" | "jpeg" | "png";
|
|
171
|
+
/** How upstream bills this image's payload: pixel-tile model (Anthropic / OpenAI high-detail) or raw byte counting (some relays). */
|
|
172
|
+
export type ImageBillingMode = "pixels" | "bytes";
|
|
173
|
+
/** Image pre-compression routing/downsample + image_full restore (#353). Hosts perform the three-level (global → provider → model) sub-field merge exactly like absorb. Default off: disabled ⇒ byte-identical pass-through. */
|
|
174
|
+
export interface ImageCompressionConfig {
|
|
175
|
+
enabled: boolean;
|
|
176
|
+
/** Only route images whose token estimate >= this. Default 512. */
|
|
177
|
+
minTokens?: number;
|
|
178
|
+
/** Longest side (px) of the downsample recipe. Default 1280. */
|
|
179
|
+
maxDimension?: number;
|
|
180
|
+
/** Lossy encode quality (1-100) of the downsample recipe. Default 80. */
|
|
181
|
+
quality?: number;
|
|
182
|
+
/** Encode format of the downsample recipe. Default "webp". */
|
|
183
|
+
format?: ImageFormat;
|
|
184
|
+
}
|
|
185
|
+
/** One arrival-time image downsample, reported by the host after executing the kernel's recipe. Drives image_full validation and session stats. */
|
|
186
|
+
export interface ImageShrinkRecord {
|
|
187
|
+
ref: string;
|
|
188
|
+
rawMessageId: string;
|
|
189
|
+
mediaType: string;
|
|
190
|
+
format: ImageFormat;
|
|
191
|
+
/** Decoded byte length of the original payload. */
|
|
192
|
+
originalBytes: number;
|
|
193
|
+
/** Decoded byte length after encoding. */
|
|
194
|
+
shrunkBytes: number;
|
|
195
|
+
/** Kernel token estimate of the original payload. */
|
|
196
|
+
tokensBefore: number;
|
|
197
|
+
/** Kernel token estimate of the shrunk payload. */
|
|
198
|
+
tokensAfter: number;
|
|
199
|
+
createdAt: number;
|
|
200
|
+
}
|
|
201
|
+
export interface CcrConfig {
|
|
202
|
+
enabled: boolean;
|
|
203
|
+
/** Model-facing retrieve tool name (adapters may rename, e.g. acp_retrieve). */
|
|
204
|
+
toolName: string;
|
|
205
|
+
/** Only tool results >= this many tokens are stored + replaced. 0 = all. */
|
|
206
|
+
minToolTokens: number;
|
|
207
|
+
/** Tool-name patterns (glob suffix allowed) never CCR-stored, independent of protectedTools. */
|
|
208
|
+
excludeTools: string[];
|
|
209
|
+
/** Max characters for the placeholder's head/command preview. */
|
|
210
|
+
maxHeadChars: number;
|
|
211
|
+
}
|
|
144
212
|
export interface CompressionState {
|
|
145
213
|
blocks: CompressionBlock[];
|
|
146
214
|
messageRefs: MessageRefMap;
|
|
@@ -167,6 +235,10 @@ export interface CompressionState {
|
|
|
167
235
|
* issued id is never re-issued with different content. Optional: defaults
|
|
168
236
|
* to 1 when absent on older persisted states. */
|
|
169
237
|
nextRuleId?: number;
|
|
238
|
+
/** image_full sticky-restore: refs whose images were restored to full resolution for the rest of the session. MUST be cleared on compaction reset (resetImageFullState) — refs are re-issued after state reset, so stale entries would misattribute. Optional: pre-feature persisted states lack it. */
|
|
239
|
+
imageFullRestored?: string[];
|
|
240
|
+
/** Arrival-time downsample records (#353). Optional: pre-feature persisted states lack it. */
|
|
241
|
+
imageShrinks?: ImageShrinkRecord[];
|
|
170
242
|
nextBlockId: number;
|
|
171
243
|
nextRunId: number;
|
|
172
244
|
}
|
|
@@ -245,6 +317,12 @@ export interface Config {
|
|
|
245
317
|
absorb?: AbsorbConfig;
|
|
246
318
|
/** Persistent acp_rule reminders (see rules.ts). Absent/disabled = feature off. */
|
|
247
319
|
rules?: RulesConfig;
|
|
320
|
+
/** Deterministic tool-result compression, tier 1 of the absorb gate (see crush.ts). Requires absorb enabled. */
|
|
321
|
+
crush?: CrushConfig;
|
|
322
|
+
/** Image pre-compression routing/downsample + image_full restore (see image-compress.ts). Absent/disabled = feature off. */
|
|
323
|
+
imageCompression?: ImageCompressionConfig;
|
|
324
|
+
/** Lossless content-cached retrieval for oversized tool results (see ccr.ts). Absent/disabled = feature off. */
|
|
325
|
+
ccr?: CcrConfig;
|
|
248
326
|
messageFilters?: import("./filter/types.js").MessageFiltersConfig;
|
|
249
327
|
}
|
|
250
328
|
export type CompressMode = "range" | "message";
|
|
@@ -391,6 +469,10 @@ export interface ProcessTurnResult {
|
|
|
391
469
|
/** Set when emergency truncation ran at/above its threshold but reclaimed
|
|
392
470
|
* nothing — hosts should warn-log this (it was silent before, #300). */
|
|
393
471
|
truncationSkipped?: string;
|
|
472
|
+
/** Per-session content store after this turn (pass back as input.contentStore
|
|
473
|
+
* next turn and persist via the host's own mechanism). Always present;
|
|
474
|
+
* empty until CCR stores something. */
|
|
475
|
+
contentStore: MessageContentStore;
|
|
394
476
|
}
|
|
395
477
|
export interface StatusReport {
|
|
396
478
|
contextUsage: number;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,WAAW,GAAG,QAAQ,GAAG,MAAM,CAAC;AAEnE,MAAM,MAAM,kBAAkB,GAC5B,MAAM,GAAG,WAAW,GAAG,aAAa,GAAG,WAAW,CAAC;AAErD,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,WAAW,CAAC;IAClB,WAAW,EAAE,kBAAkB,CAAC;IAChC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;;uDAMmD;IACnD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;;;;;;6EAQyE;IACzE,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,MAAM,eAAe,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAExC,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,KAAK,CAAC;AAE9C,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,eAAe,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,mBAAmB,EAAE,MAAM,EAAE,CAAC;IAC9B,cAAc,EAAE,MAAM,EAAE,CA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