acp-kernel 0.0.62 → 0.0.63-pr.229.94

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.
@@ -1 +1 @@
1
- {"version":3,"file":"reasoning-pairs.d.ts","sourceRoot":"","sources":["../src/reasoning-pairs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,iCAAiC,CAC/C,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,WAAW,EAAE,GACtB;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAwD1C"}
1
+ {"version":3,"file":"reasoning-pairs.d.ts","sourceRoot":"","sources":["../src/reasoning-pairs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,iCAAiC,CAC/C,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,WAAW,EAAE,GACtB;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAoE1C"}
@@ -1 +1 @@
1
- {"version":3,"file":"hybrid.d.ts","sourceRoot":"","sources":["../../../src/search/algorithms/hybrid.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAA0B,MAAM,aAAa,CAAC;AAwB3E,eAAO,MAAM,eAAe,EAAE,eAe7B,CAAC"}
1
+ {"version":3,"file":"hybrid.d.ts","sourceRoot":"","sources":["../../../src/search/algorithms/hybrid.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAA0B,MAAM,aAAa,CAAC;AAwB3E,eAAO,MAAM,eAAe,EAAE,eAgB7B,CAAC"}
@@ -4,16 +4,38 @@
4
4
  * A search over the compressed history re-scores the SAME immutable docs on
5
5
  * every call — compressed block summaries and folded message text never
6
6
  * change. Without this cache, every search_context call re-tokenized the
7
- * entire corpus (segmenter CJK pass ≈ 0.3s/MB cold) plus re-lowercased it
8
- * and rebuilt the bigram set for each channel: a 5MB session cost ~3s PER
9
- * CALL, growing linearly with session length. With the cache the corpus is
10
- * processed once; later searches are O(docs × query-terms).
7
+ * entire corpus (segmenter pass ≈ 0.1–0.6s/MB cold, content-dependent) plus
8
+ * re-lowercased it and rebuilt the bigram set for each channel: a 5MB session
9
+ * cost seconds PER CALL, growing linearly with session length. With the cache
10
+ * the corpus is processed once; later searches are O(docs × query-terms).
11
11
  *
12
- * Keyed by doc text (immutable). Bounded by total cached source chars —
13
- * oldest docs are evicted when the cap is exceeded, so a long-lived
14
- * process serving many sessions cannot grow unboundedly. Hosts that want to
15
- * release the memory eagerly on session shutdown/switch can call
16
- * clearDocFeatures() (optional: the cap already bounds it).
12
+ * Keyed by doc text (immutable), bounded by total cached SOURCE CHARS. Eviction
13
+ * is least-recently-used: a hit re-inserts the doc at the tail, so the docs a
14
+ * host keeps re-touching are retained. LRU helps when access is HETEROGENEOUS
15
+ * (a hot subset across many queries; a long-lived multi-session process). It
16
+ * does NOT help when every call re-scans the ENTIRE corpus below the cap — no
17
+ * hot subset exists, the window slides past every doc each call, and
18
+ * (corpus − cap) is re-tokenized every time.
19
+ *
20
+ * Sizing consequence: if your corpus exceeds the cap and each search rescans
21
+ * it whole, the ONLY setting that stops re-tokenization is
22
+ * setDocCacheCap(≥ corpus) (or Infinity). Do NOT lower the cap to save memory
23
+ * there — it trades bounded memory for a full re-tokenize of the excess on
24
+ * EVERY call. The default (8MB) suits hosts running many sessions that cannot
25
+ * afford to pin one corpus.
26
+ *
27
+ * The cap is in SOURCE CHARS, a loose proxy for retained heap: feature memory
28
+ * scales with DISTINCT token/bigram count, content-dependent (≈ 2×–49× per
29
+ * source char, latin prose → high-entropy CJK). The cap bounds billed chars,
30
+ * not a hard memory limit.
31
+ *
32
+ * The cap is MODULE-GLOBAL — setDocCacheCap() sets process-wide state shared
33
+ * by every acp-kernel consumer in the process. Fine while one consumer runs
34
+ * per process; a per-scope cache (keyed by doc ref) would let a host scope a
35
+ * cap to one session instead (see #227).
36
+ *
37
+ * Hosts that want to release the memory eagerly on session shutdown/switch
38
+ * can call clearDocFeatures() (optional: the cap already bounds it).
17
39
  */
18
40
  export interface DocFeatures {
19
41
  /** Stemmed term frequencies (BM25 channel). */
@@ -30,7 +52,9 @@ export declare function docFeatures(text: string): DocFeatures;
30
52
  export declare function clearDocFeatures(): void;
31
53
  /**
32
54
  * Set the cache cap in source chars. Docs larger than the cap are never
33
- * cached. Also used by tests to exercise eviction.
55
+ * cached. Pass a value ≥ the corpus size (or Infinity) to cache the whole
56
+ * corpus — a single-session host then avoids re-tokenizing on every call.
57
+ * Also used by tests to exercise eviction.
34
58
  */
35
59
  export declare function setDocCacheCap(chars: number): void;
36
60
  /** Cache occupancy — for diagnostics. */
@@ -1 +1 @@
1
- {"version":3,"file":"doc-cache.d.ts","sourceRoot":"","sources":["../../src/search/doc-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAIH,MAAM,WAAW,WAAW;IACxB,+CAA+C;IAC/C,EAAE,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxB,oDAAoD;IACpD,GAAG,EAAE,MAAM,CAAC;IACZ,qDAAqD;IACrD,KAAK,EAAE,MAAM,CAAC;IACd,sDAAsD;IACtD,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CACtB;AAeD,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAcrD;AAED,kEAAkE;AAClE,wBAAgB,gBAAgB,IAAI,IAAI,CAGvC;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAOlD;AAED,yCAAyC;AACzC,wBAAgB,YAAY,IAAI;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAEjE"}
1
+ {"version":3,"file":"doc-cache.d.ts","sourceRoot":"","sources":["../../src/search/doc-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAIH,MAAM,WAAW,WAAW;IACxB,+CAA+C;IAC/C,EAAE,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxB,oDAAoD;IACpD,GAAG,EAAE,MAAM,CAAC;IACZ,qDAAqD;IACrD,KAAK,EAAE,MAAM,CAAC;IACd,sDAAsD;IACtD,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CACtB;AAeD,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAmBrD;AAED,kEAAkE;AAClE,wBAAgB,gBAAgB,IAAI,IAAI,CAGvC;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAOlD;AAED,yCAAyC;AACzC,wBAAgB,YAAY,IAAI;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAEjE"}
@@ -0,0 +1,23 @@
1
+ import type { CoreMessage } from "./types.js";
2
+ /**
3
+ * Atomic turn groups for compression integrity (#684).
4
+ *
5
+ * A turn is a reasoning run, the assistant text/tool-call burst that follows
6
+ * it, and every tool-result paired (by toolCallId) to the burst's calls.
7
+ * Strict-echo thinking providers (DeepSeek: "The `reasoning_content` in the
8
+ * thinking mode must be passed back to the API") reject a rebuilt request
9
+ * whose assistant tool-call turn survives without its reasoning, and every
10
+ * OpenAI-wire provider rejects a result whose call is gone. Turns are
11
+ * therefore atomic for folding: all members fold together, or none do.
12
+ *
13
+ * Grouping is adjacency-based, mirroring {@link adjustBoundariesForReasoningPairs}:
14
+ * a reasoning run pairs with the assistant burst immediately following it.
15
+ * Bursts without a preceding reasoning run still group with their sibling
16
+ * calls and results. Messages belonging to no turn (user messages, system,
17
+ * orphan reasoning, summaries) get no group — they carry no pairing
18
+ * constraint. Groups are disjoint.
19
+ *
20
+ * @returns disjoint member-id arrays; a message appears in at most one group.
21
+ */
22
+ export declare function computeTurnGroups(messages: CoreMessage[]): string[][];
23
+ //# sourceMappingURL=turn-integrity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"turn-integrity.d.ts","sourceRoot":"","sources":["../src/turn-integrity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAS9C;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,WAAW,EAAE,GAAG,MAAM,EAAE,EAAE,CA2ErE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "acp-kernel",
3
- "version": "0.0.62",
3
+ "version": "0.0.63-pr.229.94",
4
4
  "description": "Framework-agnostic context-compression engine (model-driven, 3-tier LSM). Pure core: no host dependency.",
5
5
  "license": "MIT",
6
6
  "author": "ranxianglei",