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,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Content-addressed message store (CCR foundation).
|
|
3
|
+
*
|
|
4
|
+
* Pure data + pure functions — zero I/O (DESIGN.md: "the core holds no state
|
|
5
|
+
* and performs no I/O"). The host persists this structure with its own
|
|
6
|
+
* mechanism (StateStore envelope, same path as block-level original caches);
|
|
7
|
+
* it deliberately does NOT live inside CompressionState so multi-megabyte
|
|
8
|
+
* originals don't get rewritten on every per-turn state save.
|
|
9
|
+
*
|
|
10
|
+
* Invariants:
|
|
11
|
+
* - Content-addressed dedup: identical text is stored once (byHash).
|
|
12
|
+
* - Append-only per ref: first write wins, entries are never removed or
|
|
13
|
+
* overwritten by fold/edit/truncate. Refs are never reissued by the kernel
|
|
14
|
+
* (id-never-reused contract), so ref → original is a stable function for
|
|
15
|
+
* the life of the session generation.
|
|
16
|
+
* - The ref → rawId alias is frozen at store time, so retrieval keeps working
|
|
17
|
+
* even after a host compaction archive prunes messageRefs (the store's own
|
|
18
|
+
* byRef index is the source of truth for retrieval).
|
|
19
|
+
* - Generation boundary: when a host rebase resets refs to m00001 (full-state
|
|
20
|
+
* rebase), the host resets the store with the state — otherwise old and new
|
|
21
|
+
* generations would share one ref namespace. Session-scoped compaction that
|
|
22
|
+
* keeps state (refs continue) leaves the store untouched on purpose.
|
|
23
|
+
* - Retention (cleanup/eviction) is a downstream policy decision, like all
|
|
24
|
+
* persisted state.
|
|
25
|
+
*/
|
|
26
|
+
export interface StoredEntry {
|
|
27
|
+
/** sha256 hex of the stored original text (key into byHash). */
|
|
28
|
+
hash: string;
|
|
29
|
+
/** Raw message id at store time. Frozen alias — survives ref-map pruning. */
|
|
30
|
+
rawId: string;
|
|
31
|
+
/** Placeholder kind label ("shell output", "file read", ...). */
|
|
32
|
+
kind: string;
|
|
33
|
+
/** Tool name at arrival, if any. */
|
|
34
|
+
toolName?: string;
|
|
35
|
+
/** Token count of the original, fixed at arrival (deterministic metadata). */
|
|
36
|
+
tokens: number;
|
|
37
|
+
/** Character length of the original. */
|
|
38
|
+
chars: number;
|
|
39
|
+
/** Deterministic head preview embedded in the placeholder. */
|
|
40
|
+
head: string;
|
|
41
|
+
}
|
|
42
|
+
export interface MessageContentStore {
|
|
43
|
+
version: 1;
|
|
44
|
+
/** Content-addressed originals: sha256(text) → text. Dedup lives here. */
|
|
45
|
+
byHash: Record<string, string>;
|
|
46
|
+
/** Per-ref index: ref → entry. Append-only; first write wins. */
|
|
47
|
+
byRef: Record<string, StoredEntry>;
|
|
48
|
+
}
|
|
49
|
+
export interface StoreSpec {
|
|
50
|
+
ref: string;
|
|
51
|
+
rawId: string;
|
|
52
|
+
text: string;
|
|
53
|
+
kind: string;
|
|
54
|
+
toolName?: string;
|
|
55
|
+
tokens: number;
|
|
56
|
+
head: string;
|
|
57
|
+
}
|
|
58
|
+
export declare function createContentStore(): MessageContentStore;
|
|
59
|
+
export declare function hashContent(text: string): string;
|
|
60
|
+
/** Append-only insert. Returns the input unchanged when the ref is already
|
|
61
|
+
* stored (first write wins); otherwise adds the entry, deduping content by
|
|
62
|
+
* hash. Immutably styled like the rest of the kernel. */
|
|
63
|
+
export declare function storeOriginal(store: MessageContentStore, spec: StoreSpec): MessageContentStore;
|
|
64
|
+
export type RetrieveResult = {
|
|
65
|
+
ok: true;
|
|
66
|
+
text: string;
|
|
67
|
+
entry: StoredEntry;
|
|
68
|
+
} | {
|
|
69
|
+
ok: false;
|
|
70
|
+
reason: "not-found";
|
|
71
|
+
};
|
|
72
|
+
/** Fetch an original by ref. Unknown/hallucinated refs → not-found (the cost
|
|
73
|
+
* is one tool call, by design). Resolves through the store's own byRef index
|
|
74
|
+
* — independent of messageRefs, which hosts may prune. */
|
|
75
|
+
export declare function retrieveByRef(store: MessageContentStore, ref: string): RetrieveResult;
|
|
76
|
+
export declare function hasStoredRef(store: MessageContentStore, ref: string): boolean;
|
|
77
|
+
export interface ContentStoreStats {
|
|
78
|
+
/** Number of stored refs. */
|
|
79
|
+
entries: number;
|
|
80
|
+
/** Number of unique contents after dedup. */
|
|
81
|
+
uniqueContents: number;
|
|
82
|
+
/** Total characters held across unique contents. */
|
|
83
|
+
totalChars: number;
|
|
84
|
+
}
|
|
85
|
+
export declare function contentStoreStats(store: MessageContentStore): ContentStoreStats;
|
|
86
|
+
//# sourceMappingURL=content-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-store.d.ts","sourceRoot":"","sources":["../src/content-store.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,MAAM,WAAW,WAAW;IAC1B,gEAAgE;IAChE,IAAI,EAAE,MAAM,CAAC;IACb,6EAA6E;IAC7E,KAAK,EAAE,MAAM,CAAC;IACd,iEAAiE;IACjE,IAAI,EAAE,MAAM,CAAC;IACb,oCAAoC;IACpC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,8EAA8E;IAC9E,MAAM,EAAE,MAAM,CAAC;IACf,wCAAwC;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,8DAA8D;IAC9D,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,CAAC,CAAC;IACX,0EAA0E;IAC1E,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,iEAAiE;IACjE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd;AAED,wBAAgB,kBAAkB,IAAI,mBAAmB,CAExD;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED;;0DAE0D;AAC1D,wBAAgB,aAAa,CAC3B,KAAK,EAAE,mBAAmB,EAC1B,IAAI,EAAE,SAAS,GACd,mBAAmB,CAiBrB;AAED,MAAM,MAAM,cAAc,GACtB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,WAAW,CAAA;CAAE,GAC9C;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,WAAW,CAAA;CAAE,CAAC;AAEvC;;2DAE2D;AAC3D,wBAAgB,aAAa,CAC3B,KAAK,EAAE,mBAAmB,EAC1B,GAAG,EAAE,MAAM,GACV,cAAc,CAMhB;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,mBAAmB,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAE7E;AAED,MAAM,WAAW,iBAAiB;IAChC,6BAA6B;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,6CAA6C;IAC7C,cAAc,EAAE,MAAM,CAAC;IACvB,oDAAoD;IACpD,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,mBAAmB,GACzB,iBAAiB,CAQnB"}
|
package/dist/crush.d.ts
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool-result valuator + deterministic compression ("crush") channel (#354):
|
|
3
|
+
* the two-tier absorb gate owned by the kernel. Tier 1: mechanical size
|
|
4
|
+
* reduction of eligible oversized tool results via registered crush plugins;
|
|
5
|
+
* tier 2: model distillation (the existing `[ACP absorb]` prompt path) only
|
|
6
|
+
* when a result is still over threshold after crushing. Pure function of
|
|
7
|
+
* (payload, config) — identical bytes on every turn a result is re-sent
|
|
8
|
+
* (prefix-cache stable); view-only like the absorb prompt, no kernel state
|
|
9
|
+
* is mutated.
|
|
10
|
+
*
|
|
11
|
+
* Plugin contract (CrushPluginDef.run): pure & deterministic, input never
|
|
12
|
+
* mutated, fail-open on any anomaly, sub-minimum-size inputs untouched. The
|
|
13
|
+
* kernel enforces what plugins must not each own: dispatch guards (JSON /
|
|
14
|
+
* source / log payloads never reach a strategy for another kind), the
|
|
15
|
+
* minReduction floor, and — for lossy log output — that every ERROR/FAIL line
|
|
16
|
+
* of the input survives in the output verbatim, else the result is rejected
|
|
17
|
+
* and the payload passes through unchanged.
|
|
18
|
+
*
|
|
19
|
+
* Default strategies (dispatched by content sniffing):
|
|
20
|
+
* - json-fold: field-variance folding (concept adapted from headroom
|
|
21
|
+
* SmartCrusher, headroomlabs-ai/headroom, Apache-2.0; implementation
|
|
22
|
+
* original TS). LOSSLESS BY CONSTRUCTION. Annotation vocabulary (reserved
|
|
23
|
+
* key `__acp_crush`):
|
|
24
|
+
* {"__acp_crush":"rows","rows":N,"const":{k:v,...},"items":[...]}
|
|
25
|
+
* array of N rows; every row = `const` merged with its `items` entry
|
|
26
|
+
* (same order); `items` omitted iff no row has a non-constant field.
|
|
27
|
+
* {"__acp_crush":"identical-run","count":N,"item":X}
|
|
28
|
+
* N consecutive identical elements X.
|
|
29
|
+
* Payloads legitimately containing a `__acp_crush` key cannot be told apart
|
|
30
|
+
* from crushed output — disable crush for them.
|
|
31
|
+
* - code-trim: structural trimmer (Python, JavaScript/TypeScript; sound for
|
|
32
|
+
* other // -comment languages). LOSSY: full-line comments, docstrings and
|
|
33
|
+
* blank-line runs are elided into one marker line (`# [acp-crush: elided N
|
|
34
|
+
* lines]` / `// [acp-crush: elided N lines]`) and NOT retained. Code lines,
|
|
35
|
+
* string literals and trailing comments stay byte-exact. A stronger AST
|
|
36
|
+
* implementation can register under kinds ["code"] to replace it.
|
|
37
|
+
* - log-select: build/test log condenser (ported from headroom LogCompressor,
|
|
38
|
+
* Apache-2.0): classifies every line (level / summary / stack-trace
|
|
39
|
+
* membership), keeps errors+fails first (within a keep budget; the kernel
|
|
40
|
+
* invariant above rejects any lossy result that drops an error line),
|
|
41
|
+
* deduped warnings, bounded stack traces (runtime frames collapsed to a
|
|
42
|
+
* marker), summary lines and ±3 context, caps the rest by score. LOSSY:
|
|
43
|
+
* noise lines are dropped, not retained. Upstream deviations: no CCR store
|
|
44
|
+
* — the omission footer carries honest counts instead of a retrieve hash;
|
|
45
|
+
* the keep budget is the fixed 100-line cap instead of headroom's adaptive
|
|
46
|
+
* Kneedle sizing (the cap only bounds output; the absorb gate and model
|
|
47
|
+
* compression already bound cost downstream). Only attempted when the
|
|
48
|
+
* payload is neither JSON-shaped nor confidently detected source code.
|
|
49
|
+
*
|
|
50
|
+
* Fail-open: parse errors, scanner bails (unterminated string/comment/
|
|
51
|
+
* template), low-confidence language detection, plugin exceptions, or
|
|
52
|
+
* reduction below the configured minimum leave the payload byte-identical.
|
|
53
|
+
* Query-aware relevance selection (headroom layer b) is deliberately not
|
|
54
|
+
* ported: hosts re-send tool results every turn, so the crush must stay
|
|
55
|
+
* query-independent or provider prefix caches churn.
|
|
56
|
+
*/
|
|
57
|
+
import { type TokenCountFn } from "./tokenize.js";
|
|
58
|
+
import type { AbsorbConfig, Config, CoreMessage, CrushConfig } from "./types.js";
|
|
59
|
+
export declare const DEFAULT_CRUSH_CONFIG: CrushConfig;
|
|
60
|
+
export type CrushKind = "json" | "code" | "log";
|
|
61
|
+
/** Caller context handed to every plugin run (tool identity etc.). */
|
|
62
|
+
export interface CrushMeta {
|
|
63
|
+
toolName?: string;
|
|
64
|
+
}
|
|
65
|
+
export interface CrushOutput {
|
|
66
|
+
text: string;
|
|
67
|
+
strategy: string;
|
|
68
|
+
lossy: boolean;
|
|
69
|
+
stats?: Record<string, unknown>;
|
|
70
|
+
}
|
|
71
|
+
/** Narrow synchronous compression contract. `null` = pass-through. */
|
|
72
|
+
export interface CrushPluginDef {
|
|
73
|
+
readonly id: string;
|
|
74
|
+
/** Content kinds this plugin may be dispatched on; the kernel refuses others. */
|
|
75
|
+
readonly kinds: readonly CrushKind[];
|
|
76
|
+
run(text: string, meta: CrushMeta): Omit<CrushOutput, "strategy"> | null;
|
|
77
|
+
}
|
|
78
|
+
export interface CrushOptions {
|
|
79
|
+
minReduction?: number;
|
|
80
|
+
countTokens?: TokenCountFn;
|
|
81
|
+
meta?: CrushMeta;
|
|
82
|
+
/** Plugins to try, in order. Default: all registered, registry order. */
|
|
83
|
+
plugins?: readonly CrushPluginDef[];
|
|
84
|
+
}
|
|
85
|
+
export type CrushDecisionKind = "skip" | "crushed" | "distill";
|
|
86
|
+
/** Valuator decision for one tool-result payload. */
|
|
87
|
+
export interface CrushEvaluation {
|
|
88
|
+
kind: CrushDecisionKind;
|
|
89
|
+
/** Final text: original for skip, crushed otherwise. */
|
|
90
|
+
text: string;
|
|
91
|
+
rawTokens: number;
|
|
92
|
+
newTokens?: number;
|
|
93
|
+
reduction?: number;
|
|
94
|
+
strategy?: string;
|
|
95
|
+
lossy?: boolean;
|
|
96
|
+
}
|
|
97
|
+
export declare function classifyCrushText(text: string): CrushKind;
|
|
98
|
+
/** Single-call entry shared by the arrival path (processTurn crush node) and
|
|
99
|
+
* the future retrieve path (#1097): classify, dispatch in order to the first
|
|
100
|
+
* kind-matched plugin that produces an accepted result. `null` = pass-through. */
|
|
101
|
+
export declare function crushText(text: string, options?: CrushOptions): CrushOutput | null;
|
|
102
|
+
export declare function crushJson(text: string): string | null;
|
|
103
|
+
export declare function crushCode(text: string): string | null;
|
|
104
|
+
export declare function crushLog(text: string): string | null;
|
|
105
|
+
export declare const jsonFoldPlugin: CrushPluginDef;
|
|
106
|
+
export declare const codeTrimPlugin: CrushPluginDef;
|
|
107
|
+
export declare const logSelectPlugin: CrushPluginDef;
|
|
108
|
+
export declare function registerCrushPlugin(def: CrushPluginDef): void;
|
|
109
|
+
export declare function unregisterCrushPlugin(id: string): void;
|
|
110
|
+
export declare function listCrushPlugins(): Array<Pick<CrushPluginDef, "id" | "kinds">>;
|
|
111
|
+
/** Test support: restore the built-in set exactly, in built-in order. */
|
|
112
|
+
export declare function resetCrushPlugins(): void;
|
|
113
|
+
export declare function resolveCrushConfig(config: Config): CrushConfig;
|
|
114
|
+
export interface EvaluateCrushInput {
|
|
115
|
+
text: string;
|
|
116
|
+
absorb: AbsorbConfig;
|
|
117
|
+
crush: CrushConfig;
|
|
118
|
+
/** Current context token count (context-pressure signal). */
|
|
119
|
+
tokenCount: number;
|
|
120
|
+
modelContextLimit: number;
|
|
121
|
+
meta?: CrushMeta;
|
|
122
|
+
countTokens?: TokenCountFn;
|
|
123
|
+
}
|
|
124
|
+
/** Two-tier gate decision for one tool-result payload. Pure: same input ⇒
|
|
125
|
+
* same bytes. `skip` = under the absorb gates; `crushed` = deterministic
|
|
126
|
+
* compression brought it under minToolTokens (no model round-trip);
|
|
127
|
+
* `distill` = still over (or uncrushable) — hand `text` to the absorb prompt
|
|
128
|
+
* path; when crushing succeeded `text` is the crushed payload. */
|
|
129
|
+
export declare function evaluateToolResult(input: EvaluateCrushInput): CrushEvaluation;
|
|
130
|
+
export interface ApplyCrushResult {
|
|
131
|
+
messages: CoreMessage[];
|
|
132
|
+
/** Results crushed below minToolTokens (no model round-trip). */
|
|
133
|
+
crushedCount: number;
|
|
134
|
+
/** Results forwarded to the absorb prompt path with crushed text. */
|
|
135
|
+
distilledCount: number;
|
|
136
|
+
}
|
|
137
|
+
/** Pipeline-facing application: view-only, deterministic per turn. Runs
|
|
138
|
+
* between absorb-hide and absorb-prompt so the prompt node re-decides on
|
|
139
|
+
* post-crush sizes in the same turn (atomic two-tier gate). Returns the
|
|
140
|
+
* input array unchanged when nothing qualifies. */
|
|
141
|
+
export declare function applyCrushToMessages(messages: CoreMessage[], config: Config, tokenCount: number, countTokens: TokenCountFn): ApplyCrushResult;
|
|
142
|
+
//# sourceMappingURL=crush.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crush.d.ts","sourceRoot":"","sources":["../src/crush.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AAQH,OAAO,EAAsB,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AACtE,OAAO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AY,CAAC;CAC5B;AAED;;;;mEAImE;AACnE,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,kBAAkB,GAAG,eAAe,CAgC7E;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,iEAAiE;IACjE,YAAY,EAAE,MAAM,CAAC;IACrB,qEAAqE;IACrE,cAAc,EAAE,MAAM,CAAC;CACxB;AAED;;;oDAGoD;AACpD,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,WAAW,EAAE,EACvB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,YAAY,GACxB,gBAAgB,CAqClB"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import type { Config, CompressionState, ImageBillingMode, ImageCompressionConfig, ImageFormat, ImageShrinkRecord } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Image pre-compression (#353, filed from billion-context#1095 analysis):
|
|
4
|
+
* screenshot-like tool-result images are downscaled ONCE at arrival before
|
|
5
|
+
* entering the wire; non-screenshot originals pass through untouched; the
|
|
6
|
+
* lossy step is backstopped by the image_full restore channel.
|
|
7
|
+
*
|
|
8
|
+
* Kernel scope (pure, zero native deps): routing decision + recipe, billing-
|
|
9
|
+
* aware token estimation (canonical copy — moved from billion-context
|
|
10
|
+
* src/image-tokens.ts), image_full contract (arg parsing, sticky-restore
|
|
11
|
+
* state machine, result strings, system-note fragment), shrink records and
|
|
12
|
+
* stats counters on session state.
|
|
13
|
+
*
|
|
14
|
+
* Host scope (NOT here): executing the recipe with a real encoder
|
|
15
|
+
* (deterministic resize fit-inside withoutEnlargement → flatten →
|
|
16
|
+
* webp{quality} / jpeg{quality, mozjpeg} / png{compressionLevel:9}, keeping
|
|
17
|
+
* the smaller of original vs encoded), sidecar file I/O under the #1097
|
|
18
|
+
* store, wire-body substitution across protocols, plugin-manifest
|
|
19
|
+
* registration, logging.
|
|
20
|
+
*
|
|
21
|
+
* Determinism is load-bearing: the downsampled bytes become the standing
|
|
22
|
+
* wire content after arrival-time substitution; a non-deterministic recipe
|
|
23
|
+
* would invalidate the provider prefix cache mid-session (same invariant as
|
|
24
|
+
* #1097's placeholder determinism).
|
|
25
|
+
*/
|
|
26
|
+
export declare const DEFAULT_IMAGE_COMPRESSION_CONFIG: Required<ImageCompressionConfig>;
|
|
27
|
+
/** Sub-field merge over defaults; hosts layer global → provider → model
|
|
28
|
+
* exactly like absorb (three levels). */
|
|
29
|
+
export declare function resolveImageCompressionConfig(config: Config): Required<ImageCompressionConfig>;
|
|
30
|
+
/** Pixels-mode fallback when dimensions cannot be parsed header-only: the
|
|
31
|
+
* worst-case high-detail bill. */
|
|
32
|
+
export declare const PIXEL_IMAGE_FALLBACK_TOKENS = 16384;
|
|
33
|
+
export interface ImageDimensions {
|
|
34
|
+
width: number;
|
|
35
|
+
height: number;
|
|
36
|
+
}
|
|
37
|
+
/** Header-only dimension parse: reads just enough leading bytes for container
|
|
38
|
+
* headers. Supports PNG / GIF / BMP / WebP (VP8X, VP8L, VP8 lossy) / JPEG
|
|
39
|
+
* (SOF segment scan). Unknown formats or truncated headers → undefined. */
|
|
40
|
+
export declare function parseImageDimensions(bytes: Uint8Array): ImageDimensions | undefined;
|
|
41
|
+
/** Base64 convenience entry: decodes only the leading slice — enough for
|
|
42
|
+
* container headers (PNG/GIF/BMP/WebP within 64 chars; JPEG SOF within ~350K
|
|
43
|
+
* chars of EXIF bloat). Node-targeted (Buffer). */
|
|
44
|
+
export declare function parseImageDimensionsFromBase64(b64: string): ImageDimensions | undefined;
|
|
45
|
+
/** OpenAI high-detail tile model: scale so the short side is at least 768
|
|
46
|
+
* (providers bill small images enlarged), cap the long side at 2048, then
|
|
47
|
+
* 85 + 170 per 512×512 tile. Bounds ≈ [765, 2805]. */
|
|
48
|
+
export declare function pixelTileEstimate(width: number, height: number): number;
|
|
49
|
+
/** One image attachment's metadata as seen by the routing decision. */
|
|
50
|
+
export interface ImageMeta {
|
|
51
|
+
mediaType: string;
|
|
52
|
+
/** Length of the base64 payload (characters). */
|
|
53
|
+
base64Length: number;
|
|
54
|
+
width?: number;
|
|
55
|
+
height?: number;
|
|
56
|
+
/** Upstream billing mode for this image. Default "bytes" (conservative). */
|
|
57
|
+
billing?: ImageBillingMode;
|
|
58
|
+
/** Optional base64 payload; only its leading decode budget is read, and
|
|
59
|
+
* only when width/height are missing in pixels mode. */
|
|
60
|
+
base64?: string;
|
|
61
|
+
}
|
|
62
|
+
/** Billing-aware estimate of an image's token cost. Pixels mode uses the tile
|
|
63
|
+
* model on real dimensions (header-parsed from the payload head when absent);
|
|
64
|
+
* bytes mode counts ceil(base64len/4). Unknown dims in pixels mode fall back
|
|
65
|
+
* to PIXEL_IMAGE_FALLBACK_TOKENS. */
|
|
66
|
+
export declare function estimateImageTokens(meta: ImageMeta): number;
|
|
67
|
+
/** Pluggable screenshot classifier. v1 ships the heuristic below; a trained
|
|
68
|
+
* router slots in here later without pipeline changes. */
|
|
69
|
+
export interface ScreenshotClassifier {
|
|
70
|
+
readonly name: string;
|
|
71
|
+
isScreenshotLike(meta: ImageMeta): boolean;
|
|
72
|
+
}
|
|
73
|
+
export interface HeuristicClassifierOptions {
|
|
74
|
+
/** Low end of the long/short aspect band. Default 1.4. */
|
|
75
|
+
aspectRatioMin?: number;
|
|
76
|
+
/** High end of the long/short aspect band. Default 2.6. */
|
|
77
|
+
aspectRatioMax?: number;
|
|
78
|
+
/** Short-side floor (px): below it even band-shaped images pass — small
|
|
79
|
+
* crops would be upscaled by the tile model and billed larger. Default 720. */
|
|
80
|
+
minShortSide?: number;
|
|
81
|
+
}
|
|
82
|
+
/** v1 heuristic: long/short aspect ratio within [1.4, 2.6] AND short side ≥
|
|
83
|
+
* 720 px. Missing dimensions → false (conservative: never route what cannot
|
|
84
|
+
* be classified). Known limitation: 3:2 photos (ratio 1.5) false-positive as
|
|
85
|
+
* screenshots until a trained router slots into the classifier interface. */
|
|
86
|
+
export declare function createHeuristicClassifier(options?: HeuristicClassifierOptions): ScreenshotClassifier;
|
|
87
|
+
export declare const DEFAULT_SCREENSHOT_CLASSIFIER: ScreenshotClassifier;
|
|
88
|
+
export type ImageRouteReason = "disabled" | "not-an-image" | "below-min-tokens" | "not-screenshot-like" | "downsample";
|
|
89
|
+
/** Downsample parameters the host executes with its own encoder (sharp etc.). */
|
|
90
|
+
export interface DownsampleRecipe {
|
|
91
|
+
/** Longest side (px) after resize. */
|
|
92
|
+
maxDimension: number;
|
|
93
|
+
quality: number;
|
|
94
|
+
format: ImageFormat;
|
|
95
|
+
}
|
|
96
|
+
export interface ImageRoutingDecision {
|
|
97
|
+
action: "pass" | "downsample";
|
|
98
|
+
reason: ImageRouteReason;
|
|
99
|
+
/** Token estimate of the ORIGINAL payload (host log lines). */
|
|
100
|
+
estimatedTokens: number;
|
|
101
|
+
recipe?: DownsampleRecipe;
|
|
102
|
+
}
|
|
103
|
+
/** Pure + deterministic: same input + config → identical decision, always.
|
|
104
|
+
* The host executes the returned recipe exactly once, at arrival time. */
|
|
105
|
+
export declare function decideImageRoute(meta: ImageMeta, config: Config, classifier?: ScreenshotClassifier): ImageRoutingDecision;
|
|
106
|
+
/** Failure-prefix convention (mirrors absorb's marker style): any resultText
|
|
107
|
+
* starting with this marks a rejected call. */
|
|
108
|
+
export declare const IMAGE_FULL_FAILURE_MARKER = "[image_full FAILED:";
|
|
109
|
+
/** Byte-stable system-prompt fragment; count = images downscaled so far in
|
|
110
|
+
* this session. Hosts inject it while the feature is enabled and shrinks
|
|
111
|
+
* exist. */
|
|
112
|
+
export declare function buildImageFullSystemNote(count: number): string;
|
|
113
|
+
/** Content-store entry-kind contract for image originals (#1097 store layout:
|
|
114
|
+
* binary sidecar entries under the same mNNNNN key scheme, append-once,
|
|
115
|
+
* drop-on-fold). The kernel owns this shape; file I/O stays host-side. */
|
|
116
|
+
export interface ImageStoreEntry {
|
|
117
|
+
kind: "image";
|
|
118
|
+
ref: string;
|
|
119
|
+
rawMessageId: string;
|
|
120
|
+
mediaType: string;
|
|
121
|
+
originalBytes: number;
|
|
122
|
+
createdAt: number;
|
|
123
|
+
}
|
|
124
|
+
export interface ParsedImageFull {
|
|
125
|
+
ref: string;
|
|
126
|
+
callId?: string;
|
|
127
|
+
}
|
|
128
|
+
/** Lenient arg parser mirroring parseAbsorbInput: accepts object or JSON-
|
|
129
|
+
* string payloads, key aliases (ref/messageId/of), trims whitespace. */
|
|
130
|
+
export declare function parseImageFullInput(input: unknown, callId?: string, onWarn?: (message: string) => void): ParsedImageFull | null;
|
|
131
|
+
/** Append one shrink record and bump cumulative stats. Pure: returns new state. */
|
|
132
|
+
export declare function recordImageShrink(state: CompressionState, record: ImageShrinkRecord): CompressionState;
|
|
133
|
+
export declare function isImageFullRestored(state: CompressionState, ref: string): boolean;
|
|
134
|
+
export declare function imageShrinksForRef(state: CompressionState, ref: string): ImageShrinkRecord[];
|
|
135
|
+
export interface ImageFullInput {
|
|
136
|
+
ref: string;
|
|
137
|
+
state: CompressionState;
|
|
138
|
+
config: Config;
|
|
139
|
+
}
|
|
140
|
+
export interface ImageFullOutcome {
|
|
141
|
+
state: CompressionState;
|
|
142
|
+
ok: boolean;
|
|
143
|
+
resultText: string;
|
|
144
|
+
}
|
|
145
|
+
/** Sticky-restore state machine. Success marks the ref restored for the rest
|
|
146
|
+
* of the session (idempotent re-calls report "already restored"). Failure
|
|
147
|
+
* modes return ok:false with an [image_full FAILED: ...] resultText. Pure:
|
|
148
|
+
* returns new state. */
|
|
149
|
+
export declare function applyImageFull(input: ImageFullInput): ImageFullOutcome;
|
|
150
|
+
/** Drop ref-keyed image_full state after a compaction reset (native-compaction
|
|
151
|
+
* archive, fork recovery, session restart). Refs are re-issued from m00001
|
|
152
|
+
* after a state reset, so stale entries would misattribute. Cumulative stats
|
|
153
|
+
* survive — they remain valid aggregates. Hosts MUST call this on every
|
|
154
|
+
* state reset. */
|
|
155
|
+
export declare function resetImageFullState(state: CompressionState): CompressionState;
|
|
156
|
+
//# sourceMappingURL=image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11 +32,20 @@ export { renderHandoff, renderMessage, matchSession } from "./handoff.js";
|
|
|
32
32
|
export type { HandoffInput, HandoffMeta, HandoffBlockFull } from "./handoff.js";
|
|
33
33
|
export { hideConsumedCompressCalls } from "./hide-consumed.js";
|
|
34
34
|
export type { HideConsumedResult } from "./hide-consumed.js";
|
|
35
|
-
export { ABSORB_TOOL_NAME, ABSORB_TOOL, ABSORB_TOOL_OPENAI, } from "./compress-tools.js";
|
|
35
|
+
export { ABSORB_TOOL_NAME, ABSORB_TOOL, ABSORB_TOOL_OPENAI, IMAGE_FULL_TOOL_NAME, IMAGE_FULL_TOOL, IMAGE_FULL_TOOL_OPENAI, IMAGE_FULL_TOOL_RESPONSES, } from "./compress-tools.js";
|
|
36
|
+
export { RETRIEVE_TOOL_NAME, RETRIEVE_TOOL, RETRIEVE_TOOL_OPENAI, RETRIEVE_TOOL_RESPONSES, RETRIEVE_TOOL_DESCRIPTION, } from "./compress-tools.js";
|
|
37
|
+
export { createContentStore, hashContent, storeOriginal, retrieveByRef, hasStoredRef, contentStoreStats, } from "./content-store.js";
|
|
38
|
+
export type { MessageContentStore, StoredEntry, StoreSpec, RetrieveResult, ContentStoreStats, } from "./content-store.js";
|
|
39
|
+
export { DEFAULT_CCR_CONFIG, resolveCcrConfig, STORED_PLACEHOLDER_MARKER, RETRIEVED_ID_PREFIX, classifyKind, normalizeHead, extractCommand, buildStoredPlaceholder, isStoredPlaceholderText, retrievedMessageId, isRetrievedMessage, buildRetrievalInjection, applyRetrieve, storeLargeResults, storeCoveredOriginals, noteRetrieval, ccrStoreNode, } from "./ccr.js";
|
|
40
|
+
export type { StoredPlaceholderInput, RetrievalInjection, ApplyRetrieveInput, ApplyRetrieveResult, StoreLargeResultsInput, StoreLargeResultsResult, CcrEffect, } from "./ccr.js";
|
|
36
41
|
export { ABSORB_PROMPT_MARKER, DEFAULT_ABSORB_CONFIG, resolveAbsorbConfig, buildAbsorbPrompt, buildAbsorbSystemPrompt, isAbsorbCandidate, hideAbsorbedMessages, appendAbsorbPrompts, parseAbsorbInput, applyAbsorb, } from "./absorb.js";
|
|
37
42
|
export type { AbsorbInput, AbsorbOutcome, ParsedAbsorb, AppendAbsorbPromptsResult, } from "./absorb.js";
|
|
38
43
|
export { RULE_TOOL_NAME, DEFAULT_RULE_LIMITS, RULES_USAGE_PROMPT, listRules, allocateRuleId, resolveRuleLimits, addRule, removeRule, clearRules, formatRulesForPrompt, formatRulesList, } from "./rules.js";
|
|
39
44
|
export type { RuleLimits, AddRuleResult, RemoveRuleResult, ClearRulesResult, } from "./rules.js";
|
|
45
|
+
export { DEFAULT_CRUSH_CONFIG, classifyCrushText, crushText, evaluateToolResult, applyCrushToMessages, resolveCrushConfig, registerCrushPlugin, unregisterCrushPlugin, listCrushPlugins, resetCrushPlugins, jsonFoldPlugin, codeTrimPlugin, logSelectPlugin, } from "./crush.js";
|
|
46
|
+
export type { CrushKind, CrushMeta, CrushOutput, CrushOptions, CrushPluginDef, CrushDecisionKind, CrushEvaluation, EvaluateCrushInput, ApplyCrushResult, } from "./crush.js";
|
|
47
|
+
export { DEFAULT_IMAGE_COMPRESSION_CONFIG, resolveImageCompressionConfig, PIXEL_IMAGE_FALLBACK_TOKENS, parseImageDimensions, parseImageDimensionsFromBase64, pixelTileEstimate, estimateImageTokens, createHeuristicClassifier, DEFAULT_SCREENSHOT_CLASSIFIER, decideImageRoute, buildImageFullSystemNote, parseImageFullInput, recordImageShrink, isImageFullRestored, imageShrinksForRef, applyImageFull, resetImageFullState, IMAGE_FULL_FAILURE_MARKER, } from "./image-compress.js";
|
|
48
|
+
export type { ImageDimensions, ImageMeta, ScreenshotClassifier, HeuristicClassifierOptions, ImageRouteReason, DownsampleRecipe, ImageRoutingDecision, ParsedImageFull, ImageStoreEntry, ImageFullInput, ImageFullOutcome, } from "./image-compress.js";
|
|
40
49
|
export { rebuildCompressionState } from "./rebuild.js";
|
|
41
50
|
export type { RebuildResult, RebuildPorts } from "./rebuild.js";
|
|
42
51
|
export { parseCompressArgs } from "./parse-compress-input.js";
|
|
@@ -53,4 +62,6 @@ export { collectLatestProtected, isMessageLatestProtected, isMessageProtected, m
|
|
|
53
62
|
export { runPipeline, makeIO, type PipelineNode, type PipelineContext, type NodeIO, type NodeEffects, } from "./pipeline.js";
|
|
54
63
|
export * from "./filter/index.js";
|
|
55
64
|
export { VIABLE_RANGE_MIN_TOKENS, viableRanges } from "./viable.js";
|
|
65
|
+
export { classifyTurn, verbosityDirective, renderSteeringBlock, applySteeringToPrompt, clampEffortToFloor, resolveVerbosityLevel, resolveOutputSteeringConfig, decideOutputSteering, VERBOSITY_LEVELS, EFFORT_LADDER, DEFAULT_OUTPUT_STEERING_CONFIG, DEFAULT_STEERING_SENTINEL, DEFAULT_VERBOSITY_LEVEL, MIN_VERBOSITY_LEVEL, MAX_VERBOSITY_LEVEL, } from "./output-steering.js";
|
|
66
|
+
export type { TurnKind, StructuralMessage, StructuralBlock, OutputSteeringConfig, OutputSteeringDecision, SteeringPlacement, EffortValue, } from "./output-steering.js";
|
|
56
67
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,YAAY,EACV,KAAK,EACL,eAAe,EACf,gBAAgB,EAChB,qBAAqB,GACtB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,SAAS,EACT,YAAY,EACZ,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,GAChB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC5D,cAAc,qBAAqB,CAAC;AACpC,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,WAAW,EACX,UAAU,EAC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