@seanhogg/builderforce-memory 2026.10.62 → 2026.10.66

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (177) hide show
  1. package/dist/knowledge/pack/frame.d.ts +12 -3
  2. package/dist/knowledge/pack/frame.d.ts.map +1 -1
  3. package/dist/knowledge/pack/frame.js +18 -4
  4. package/dist/knowledge/pack/frame.js.map +1 -1
  5. package/dist/knowledge/pack/manifest.d.ts +11 -3
  6. package/dist/knowledge/pack/manifest.d.ts.map +1 -1
  7. package/dist/knowledge/pack/manifest.js +26 -12
  8. package/dist/knowledge/pack/manifest.js.map +1 -1
  9. package/dist/knowledge/pack/sections/extr.d.ts.map +1 -1
  10. package/dist/knowledge/pack/sections/extr.js +16 -4
  11. package/dist/knowledge/pack/sections/extr.js.map +1 -1
  12. package/dist/knowledge/pack/sections/extrLists.d.ts +0 -1
  13. package/dist/knowledge/pack/sections/extrLists.d.ts.map +1 -1
  14. package/dist/knowledge/pack/sections/extrLists.js +5 -6
  15. package/dist/knowledge/pack/sections/extrLists.js.map +1 -1
  16. package/dist/knowledge/pack/sections/facts.d.ts.map +1 -1
  17. package/dist/knowledge/pack/sections/facts.js +3 -2
  18. package/dist/knowledge/pack/sections/facts.js.map +1 -1
  19. package/dist/knowledge/pack/sections/rows.d.ts.map +1 -1
  20. package/dist/knowledge/pack/sections/rows.js +11 -2
  21. package/dist/knowledge/pack/sections/rows.js.map +1 -1
  22. package/dist/knowledge/pack/strings.d.ts.map +1 -1
  23. package/dist/knowledge/pack/strings.js +6 -1
  24. package/dist/knowledge/pack/strings.js.map +1 -1
  25. package/dist/knowledge/pack/varint.d.ts +14 -0
  26. package/dist/knowledge/pack/varint.d.ts.map +1 -1
  27. package/dist/knowledge/pack/varint.js +32 -1
  28. package/dist/knowledge/pack/varint.js.map +1 -1
  29. package/dist/knowledge/review.d.ts +6 -6
  30. package/dist/knowledge/review.d.ts.map +1 -1
  31. package/dist/knowledge/review.js +56 -329
  32. package/dist/knowledge/review.js.map +1 -1
  33. package/dist/knowledge/reviewAnalyse.d.ts +17 -0
  34. package/dist/knowledge/reviewAnalyse.d.ts.map +1 -0
  35. package/dist/knowledge/reviewAnalyse.js +61 -0
  36. package/dist/knowledge/reviewAnalyse.js.map +1 -0
  37. package/dist/knowledge/reviewApply.d.ts +33 -0
  38. package/dist/knowledge/reviewApply.d.ts.map +1 -0
  39. package/dist/knowledge/reviewApply.js +121 -0
  40. package/dist/knowledge/reviewApply.js.map +1 -0
  41. package/dist/knowledge/reviewContext.d.ts +77 -0
  42. package/dist/knowledge/reviewContext.d.ts.map +1 -0
  43. package/dist/knowledge/reviewContext.js +111 -0
  44. package/dist/knowledge/reviewContext.js.map +1 -0
  45. package/dist/knowledge/reviewFinish.d.ts +9 -0
  46. package/dist/knowledge/reviewFinish.d.ts.map +1 -0
  47. package/dist/knowledge/reviewFinish.js +62 -0
  48. package/dist/knowledge/reviewFinish.js.map +1 -0
  49. package/dist/knowledge/reviewRunModel.d.ts +3 -0
  50. package/dist/knowledge/reviewRunModel.d.ts.map +1 -1
  51. package/dist/knowledge/reviewRunModel.js.map +1 -1
  52. package/dist/knowledge/stores/extractLogWriter.d.ts +16 -3
  53. package/dist/knowledge/stores/extractLogWriter.d.ts.map +1 -1
  54. package/dist/knowledge/stores/extractLogWriter.js +38 -13
  55. package/dist/knowledge/stores/extractLogWriter.js.map +1 -1
  56. package/dist/knowledge/stores/extractRefs.d.ts +68 -0
  57. package/dist/knowledge/stores/extractRefs.d.ts.map +1 -0
  58. package/dist/knowledge/stores/extractRefs.js +168 -0
  59. package/dist/knowledge/stores/extractRefs.js.map +1 -0
  60. package/dist/knowledge/stores/localSnapshotStore.d.ts +5 -0
  61. package/dist/knowledge/stores/localSnapshotStore.d.ts.map +1 -1
  62. package/dist/knowledge/stores/localSnapshotStore.js +25 -5
  63. package/dist/knowledge/stores/localSnapshotStore.js.map +1 -1
  64. package/dist/knowledge/stores/rowDelta.d.ts +6 -0
  65. package/dist/knowledge/stores/rowDelta.d.ts.map +1 -1
  66. package/dist/knowledge/stores/rowDelta.js.map +1 -1
  67. package/dist/knowledge/stores/rowMemory.d.ts +30 -0
  68. package/dist/knowledge/stores/rowMemory.d.ts.map +1 -1
  69. package/dist/knowledge/stores/rowMemory.js +46 -1
  70. package/dist/knowledge/stores/rowMemory.js.map +1 -1
  71. package/dist/knowledge/stores/rowSync.d.ts.map +1 -1
  72. package/dist/knowledge/stores/rowSync.js +2 -1
  73. package/dist/knowledge/stores/rowSync.js.map +1 -1
  74. package/dist/knowledge/stores/snapshotFormat.d.ts +13 -2
  75. package/dist/knowledge/stores/snapshotFormat.d.ts.map +1 -1
  76. package/dist/knowledge/stores/snapshotFormat.js +22 -9
  77. package/dist/knowledge/stores/snapshotFormat.js.map +1 -1
  78. package/dist/stats/distributions.d.ts +34 -0
  79. package/dist/stats/distributions.d.ts.map +1 -0
  80. package/dist/stats/distributions.js +180 -0
  81. package/dist/stats/distributions.js.map +1 -0
  82. package/dist/stats/estimators.d.ts +53 -0
  83. package/dist/stats/estimators.d.ts.map +1 -0
  84. package/dist/stats/estimators.js +79 -0
  85. package/dist/stats/estimators.js.map +1 -0
  86. package/dist/stats/fitting.d.ts +48 -0
  87. package/dist/stats/fitting.d.ts.map +1 -0
  88. package/dist/stats/fitting.js +209 -0
  89. package/dist/stats/fitting.js.map +1 -0
  90. package/dist/stats/index.d.ts +26 -0
  91. package/dist/stats/index.d.ts.map +1 -0
  92. package/dist/stats/index.js +18 -0
  93. package/dist/stats/index.js.map +1 -0
  94. package/dist/stats/information.d.ts +9 -0
  95. package/dist/stats/information.d.ts.map +1 -0
  96. package/dist/stats/information.js +21 -0
  97. package/dist/stats/information.js.map +1 -0
  98. package/dist/stats/multivariate.d.ts +25 -0
  99. package/dist/stats/multivariate.d.ts.map +1 -0
  100. package/dist/stats/multivariate.js +89 -0
  101. package/dist/stats/multivariate.js.map +1 -0
  102. package/dist/stats/policies.d.ts +19 -0
  103. package/dist/stats/policies.d.ts.map +1 -0
  104. package/dist/stats/policies.js +75 -0
  105. package/dist/stats/policies.js.map +1 -0
  106. package/dist/stats/prng.d.ts +11 -0
  107. package/dist/stats/prng.d.ts.map +1 -0
  108. package/dist/stats/prng.js +41 -0
  109. package/dist/stats/prng.js.map +1 -0
  110. package/dist/stats/scores.d.ts +33 -0
  111. package/dist/stats/scores.d.ts.map +1 -0
  112. package/dist/stats/scores.js +134 -0
  113. package/dist/stats/scores.js.map +1 -0
  114. package/dist/stats/tests.d.ts +48 -0
  115. package/dist/stats/tests.d.ts.map +1 -0
  116. package/dist/stats/tests.js +143 -0
  117. package/dist/stats/tests.js.map +1 -0
  118. package/dist/stats/timeSeries.d.ts +34 -0
  119. package/dist/stats/timeSeries.d.ts.map +1 -0
  120. package/dist/stats/timeSeries.js +71 -0
  121. package/dist/stats/timeSeries.js.map +1 -0
  122. package/dist/working/fold.d.ts +65 -0
  123. package/dist/working/fold.d.ts.map +1 -0
  124. package/dist/working/fold.js +228 -0
  125. package/dist/working/fold.js.map +1 -0
  126. package/dist/working/index.d.ts +3 -0
  127. package/dist/working/index.d.ts.map +1 -1
  128. package/dist/working/index.js +2 -0
  129. package/dist/working/index.js.map +1 -1
  130. package/dist/working/textSummary.d.ts +46 -0
  131. package/dist/working/textSummary.d.ts.map +1 -0
  132. package/dist/working/textSummary.js +142 -0
  133. package/dist/working/textSummary.js.map +1 -0
  134. package/package.json +5 -1
  135. package/src/contract/exports.snapshot.json +48 -1
  136. package/src/contract/regression.extractEviction.test.ts +162 -0
  137. package/src/contract/regression.fixCommits.test.ts +112 -0
  138. package/src/contract/regression.packWire.test.ts +174 -0
  139. package/src/contract/types.contract.test.ts +2 -1
  140. package/src/knowledge/pack/frame.ts +21 -5
  141. package/src/knowledge/pack/manifest.ts +26 -11
  142. package/src/knowledge/pack/sections/extr.ts +14 -4
  143. package/src/knowledge/pack/sections/extrLists.ts +4 -6
  144. package/src/knowledge/pack/sections/facts.ts +3 -2
  145. package/src/knowledge/pack/sections/rows.ts +11 -2
  146. package/src/knowledge/pack/strings.ts +5 -1
  147. package/src/knowledge/pack/varint.ts +33 -1
  148. package/src/knowledge/review.ts +58 -311
  149. package/src/knowledge/reviewAnalyse.ts +59 -0
  150. package/src/knowledge/reviewApply.ts +128 -0
  151. package/src/knowledge/reviewContext.ts +158 -0
  152. package/src/knowledge/reviewFinish.ts +63 -0
  153. package/src/knowledge/reviewRunModel.ts +3 -0
  154. package/src/knowledge/stores/extractLogWriter.ts +36 -12
  155. package/src/knowledge/stores/extractRefs.ts +161 -0
  156. package/src/knowledge/stores/localSnapshotStore.ts +22 -5
  157. package/src/knowledge/stores/rowDelta.ts +6 -0
  158. package/src/knowledge/stores/rowMemory.ts +50 -1
  159. package/src/knowledge/stores/rowSync.ts +2 -1
  160. package/src/knowledge/stores/snapshotFormat.ts +27 -10
  161. package/src/stats/distributions.ts +180 -0
  162. package/src/stats/estimators.ts +101 -0
  163. package/src/stats/fitting.ts +252 -0
  164. package/src/stats/index.ts +59 -0
  165. package/src/stats/information.ts +20 -0
  166. package/src/stats/multivariate.ts +93 -0
  167. package/src/stats/policies.ts +84 -0
  168. package/src/stats/prng.ts +45 -0
  169. package/src/stats/scores.ts +135 -0
  170. package/src/stats/stats.test.ts +294 -0
  171. package/src/stats/tests.ts +164 -0
  172. package/src/stats/timeSeries.ts +92 -0
  173. package/src/working/fold.test.ts +196 -0
  174. package/src/working/fold.ts +252 -0
  175. package/src/working/index.ts +13 -0
  176. package/src/working/textSummary.test.ts +113 -0
  177. package/src/working/textSummary.ts +156 -0
@@ -0,0 +1,228 @@
1
+ /**
2
+ * Advisory folds of the working transcript (PRD 45 §4.7 B6/B7) — pure post-processing
3
+ * over the messages {@link buildWorkingTranscript} returns, before a host sends them to
4
+ * the model. The folds are COMPRESSION ONLY: the run's own transcript (`state.transcript`)
5
+ * and its trace keep every message at full fidelity; only what the MODEL sees is folded.
6
+ *
7
+ * B6 — fold superseded reads: when an edit/write to path P succeeds at step N, every
8
+ * earlier `read_file` result for P in the model transcript becomes a one-line marker.
9
+ * The stale content leaves the model's window (the edit changed those bytes — anything
10
+ * the model still needs it re-reads), and stays in the trace at full fidelity.
11
+ *
12
+ * B7 — fold repeated narration: assistant text PRECEDING tool calls whose word-set
13
+ * overlaps the previous such text by ≥ {@link NARRATION_OVERLAP} becomes
14
+ * `"(progress note)"`. A final answer and a turn without tool calls are NEVER folded —
15
+ * those carry the run's actual output.
16
+ *
17
+ * A "step" is the index of the assistant message carrying the tool call, in the message
18
+ * list the fold runs over (the model transcript, system prompt included).
19
+ *
20
+ * Pure: no `node:*`, no I/O — runs wherever the `./working` subpath runs.
21
+ */
22
+ /** B7's fold threshold: |intersection| / |union| of the two texts' word sets (Jaccard). */
23
+ export const NARRATION_OVERLAP = 0.8;
24
+ /** B6's replacement for a read result whose file a later successful edit superseded. */
25
+ export function supersededReadMarker(path, step) {
26
+ return `(read of ${path} superseded by the edit at step ${step} — re-read if needed)`;
27
+ }
28
+ /** B7's replacement for a tool-call turn's narration that merely repeats the previous one. */
29
+ export const PROGRESS_NOTE = '(progress note)';
30
+ function callsOf(m) {
31
+ return Array.isArray(m.tool_calls) ? m.tool_calls : [];
32
+ }
33
+ function nameOf(call) {
34
+ const name = call.function?.name;
35
+ return typeof name === 'string' && name.length > 0 ? name : null;
36
+ }
37
+ /** The `path` argument of a tool call — from the object form or parsed out of a JSON string. */
38
+ function pathOf(call) {
39
+ const raw = call.function?.arguments;
40
+ let parsed = raw;
41
+ if (typeof raw === 'string') {
42
+ try {
43
+ parsed = JSON.parse(raw);
44
+ }
45
+ catch {
46
+ return null;
47
+ }
48
+ }
49
+ if (!parsed || typeof parsed !== 'object')
50
+ return null;
51
+ const path = parsed.path;
52
+ return typeof path === 'string' && path.length > 0 ? path : null;
53
+ }
54
+ /** The tool result answering `call`: by `tool_call_id` when present, else positionally. */
55
+ function resultFor(convo, call, callIndex) {
56
+ const id = typeof call.id === 'string' && call.id.length > 0 ? call.id : null;
57
+ if (id) {
58
+ const byId = convo.find((m) => m.role === 'tool' && m.tool_call_id === id);
59
+ if (byId)
60
+ return byId;
61
+ }
62
+ // No ids (or an unmatched one): the nth tool result answers the nth call.
63
+ const results = convo.filter((m) => m.role === 'tool');
64
+ return results[callIndex];
65
+ }
66
+ /** Did the tool call SUCCEED? An explicit `{ok:false}` / `error` fails; anything else —
67
+ * including a textual error, which is still informative — passes. Absent result fails
68
+ * (a write nobody confirmed changed nothing). */
69
+ function succeeded(m) {
70
+ if (!m)
71
+ return false;
72
+ const content = m.content;
73
+ if (typeof content === 'string')
74
+ return content.trim().length > 0;
75
+ if (!content || typeof content !== 'object')
76
+ return false;
77
+ const r = content;
78
+ if (typeof r.ok === 'boolean')
79
+ return r.ok;
80
+ return r.error == null;
81
+ }
82
+ const EDIT_OR_WRITE = /^(edit|write)/i;
83
+ const READ = /^read/i;
84
+ function wordSet(text) {
85
+ return new Set(text
86
+ .toLowerCase()
87
+ .split(/[^a-z0-9_]+/)
88
+ .filter((w) => w.length > 0));
89
+ }
90
+ /**
91
+ * Jaccard similarity of two texts' word sets (lower-cased `[a-z0-9_]` words): |A ∩ B| / |A ∪ B|, 0 when either has no word.
92
+ * The measure B7 folds repeated narration by (see {@link isRepeatedNarration}).
93
+ */
94
+ export function wordOverlap(a, b) {
95
+ const sa = wordSet(a);
96
+ const sb = wordSet(b);
97
+ if (sa.size === 0 || sb.size === 0)
98
+ return 0;
99
+ let intersection = 0;
100
+ for (const w of sa)
101
+ if (sb.has(w))
102
+ intersection += 1;
103
+ return intersection / (sa.size + sb.size - intersection);
104
+ }
105
+ /** Containment: is every word of the smaller set present in the larger? True when one
106
+ * narration is the other plus a trailing qualifier ("…once more", "…again", "…now") —
107
+ * a repeat Jaccard under-counts because the union grows with the qualifier's words. */
108
+ export function wordContained(a, b) {
109
+ const sa = wordSet(a);
110
+ const sb = wordSet(b);
111
+ if (sa.size === 0 || sb.size === 0)
112
+ return false;
113
+ const [small, large] = sa.size <= sb.size ? [sa, sb] : [sb, sa];
114
+ for (const w of small)
115
+ if (!large.has(w))
116
+ return false;
117
+ return true;
118
+ }
119
+ /**
120
+ * B7's detector: `text` merely repeats `previous` — their {@link wordOverlap} is at least `overlap`
121
+ * (default {@link NARRATION_OVERLAP}), or one's words are all in the other ({@link wordContained}).
122
+ */
123
+ export function isRepeatedNarration(text, previous, overlap = NARRATION_OVERLAP) {
124
+ return wordOverlap(text, previous) >= overlap || wordContained(text, previous);
125
+ }
126
+ /** The narration an assistant turn carries before its tool calls — null when it carries
127
+ * none (an empty-content tool-call turn, or any turn without tool calls). */
128
+ function narrationOf(m) {
129
+ const content = m.content;
130
+ const text = typeof content === 'string' ? content : content == null ? '' : JSON.stringify(content);
131
+ const t = text.trim();
132
+ return callsOf(m).length > 0 && t.length > 0 ? t : null;
133
+ }
134
+ /** Tracks which read CALLS were superseded, so `foldWorkingTranscript`'s B7 pass can
135
+ * skip the narration that introduced a read whose content B6 just replaced. */
136
+ const SUPERSEDED_CALL = new WeakSet();
137
+ /**
138
+ * B6 — fold reads a later successful edit/write superseded. Returns the input unchanged
139
+ * (same reference, no copy) when nothing is superseded; otherwise a new list whose
140
+ * replaced messages are shallow copies with only `content` changed. The caller's
141
+ * transcript is never touched.
142
+ */
143
+ export function foldSupersededReads(msgs) {
144
+ const edits = [];
145
+ const reads = [];
146
+ let callIndex = 0;
147
+ for (let i = 0; i < msgs.length; i++) {
148
+ const m = msgs[i];
149
+ for (const call of callsOf(m)) {
150
+ const name = nameOf(call);
151
+ if (!name)
152
+ continue;
153
+ const path = pathOf(call);
154
+ const result = resultFor(msgs, call, callIndex);
155
+ if (path && EDIT_OR_WRITE.test(name)) {
156
+ if (succeeded(result))
157
+ edits.push({ path, step: i });
158
+ }
159
+ else if (path && READ.test(name) && result) {
160
+ reads.push({ step: i, path, result, call });
161
+ }
162
+ callIndex += 1;
163
+ }
164
+ }
165
+ if (edits.length === 0 || reads.length === 0)
166
+ return msgs;
167
+ const superseded = new Map();
168
+ for (const read of reads) {
169
+ // The LATEST successful edit of the same path after the read wins — an earlier read
170
+ // re-made after an edit is not superseded by that edit.
171
+ let step = -1;
172
+ for (const e of edits) {
173
+ if (e.path === read.path && e.step > read.step && e.step > step)
174
+ step = e.step;
175
+ }
176
+ if (step >= 0) {
177
+ superseded.set(read.result, supersededReadMarker(read.path, step));
178
+ SUPERSEDED_CALL.add(read.call);
179
+ }
180
+ }
181
+ if (superseded.size === 0)
182
+ return msgs;
183
+ return msgs.map((m) => {
184
+ const marker = superseded.get(m);
185
+ return marker == null ? m : { ...m, content: marker };
186
+ });
187
+ }
188
+ /**
189
+ * B7 — fold a tool-call turn's narration when it merely repeats the previous one.
190
+ * Only assistant messages WITH tool calls are candidates: a final answer and a turn
191
+ * without tool calls are never folded. The FIRST narration is kept verbatim (it has no
192
+ * predecessor to repeat); each later one folds when its word-set overlap with the most
193
+ * recent kept narration is ≥ {@link NARRATION_OVERLAP}. Once folded, it does not become
194
+ * the comparison text — the model keeps the last thing actually said.
195
+ */
196
+ export function foldRepeatedNarration(msgs, overlap = NARRATION_OVERLAP) {
197
+ let lastKept = null;
198
+ let changed = false;
199
+ const out = msgs.map((m) => {
200
+ if (m.role !== 'assistant')
201
+ return m;
202
+ const narration = narrationOf(m);
203
+ if (narration == null)
204
+ return m; // no tool calls, or no narration: never folded
205
+ // A narration that introduced a read B6 folded is the model's only record of why it
206
+ // read — it never folds itself, but it IS what a later repeat is compared against.
207
+ if (callsOf(m).some((call) => SUPERSEDED_CALL.has(call))) {
208
+ lastKept = narration;
209
+ return m;
210
+ }
211
+ if (lastKept != null && isRepeatedNarration(narration, lastKept, overlap)) {
212
+ changed = true;
213
+ return { ...m, content: PROGRESS_NOTE };
214
+ }
215
+ lastKept = narration;
216
+ return m;
217
+ });
218
+ return changed ? out : msgs;
219
+ }
220
+ /**
221
+ * Both folds, B6 then B7, over the working transcript a host is about to send to the
222
+ * model. Pure and advisory: `msgs` is not mutated, and the run's own transcript/trace
223
+ * keep every message at full fidelity.
224
+ */
225
+ export function foldWorkingTranscript(msgs) {
226
+ return foldRepeatedNarration(foldSupersededReads(msgs));
227
+ }
228
+ //# sourceMappingURL=fold.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fold.js","sourceRoot":"","sources":["../../src/working/fold.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAIH,2FAA2F;AAC3F,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAErC,wFAAwF;AACxF,MAAM,UAAU,oBAAoB,CAAC,IAAY,EAAE,IAAY;IAC7D,OAAO,YAAY,IAAI,mCAAmC,IAAI,uBAAuB,CAAC;AACxF,CAAC;AAED,8FAA8F;AAC9F,MAAM,CAAC,MAAM,aAAa,GAAG,iBAAiB,CAAC;AAY/C,SAAS,OAAO,CAAC,CAAoB;IACnC,OAAO,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAE,CAAC,CAAC,UAA8B,CAAC,CAAC,CAAC,EAAE,CAAC;AAC9E,CAAC;AAED,SAAS,MAAM,CAAC,IAAmB;IACjC,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC;IACjC,OAAO,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;AACnE,CAAC;AAED,gGAAgG;AAChG,SAAS,MAAM,CAAC,IAAmB;IACjC,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC;IACrC,IAAI,MAAM,GAAY,GAAG,CAAC;IAC1B,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QAC5B,IAAI,CAAC;YACH,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC3B,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC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AO,CAAC,CAAC;QACrC,MAAM,SAAS,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;QACjC,IAAI,SAAS,IAAI,IAAI;YAAE,OAAO,CAAC,CAAC,CAAC,+CAA+C;QAChF,oFAAoF;QACpF,mFAAmF;QACnF,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;YACzD,QAAQ,GAAG,SAAS,CAAC;YACrB,OAAO,CAAC,CAAC;QACX,CAAC;QACD,IAAI,QAAQ,IAAI,IAAI,IAAI,mBAAmB,CAAC,SAAS,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE,CAAC;YAC1E,OAAO,GAAG,IAAI,CAAC;YACf,OAAO,EAAE,GAAG,CAAC,EAAE,OAAO,EAAE,aAAa,EAAO,CAAC;QAC/C,CAAC;QACD,QAAQ,GAAG,SAAS,CAAC;QACrB,OAAO,CAAC,CAAC;IACX,CAAC,CAAC,CAAC;IACH,OAAO,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAE,IAAY,CAAC;AACvC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAA8B,IAAkB;IACnF,OAAO,qBAAqB,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC;AAC1D,CAAC"}
@@ -29,6 +29,9 @@ export { rankByCount } from './rank.js';
29
29
  export type { Observation, WorkingMemorySnapshot, ConsolidatedMemory, ConsolidateOptions } from './types.js';
30
30
  export { HISTORY_WINDOW, HISTORY_TOKEN_BUDGET, COMPACT_TAIL_TOKEN_BUDGET, windowed, stillInWorkingContext, transcriptTokens, buildWorkingTranscript, } from './transcript.js';
31
31
  export type { TranscriptMessage, CompactMemo, WorkingTranscriptState, TranscriptFold } from './transcript.js';
32
+ export { NARRATION_OVERLAP, PROGRESS_NOTE, supersededReadMarker, foldSupersededReads, foldRepeatedNarration, foldWorkingTranscript, wordOverlap, wordContained, isRepeatedNarration, } from './fold.js';
33
+ export { DEFAULT_MAX_MERGE_DEPTH, chunkText, chunkedTextSummary } from './textSummary.js';
34
+ export type { ChunkedTextSummaryOptions } from './textSummary.js';
32
35
  export { TRANSCRIPT_SUMMARY_PROMPT, TRANSCRIPT_SUMMARY_MAX_TOKENS, TRANSCRIPT_SUMMARY_INPUT_TOKENS, renderForSummary, summaryChunks, summarizeTranscript } from './summary.js';
33
36
  export type { SummaryCompletion } from './summary.js';
34
37
  export { CONSOLIDATION_META, CONSOLIDATION_MARKER_PREFIX, consolidationMetadata, consolidationMarkerOf, consolidationMarkerContent, isConsolidationMarker, lastConsolidationIndex, scopeToConsolidation, foldKeepFromId, } from './consolidationMarker.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/working/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EACjB,wBAAwB,EACxB,sBAAsB,GACvB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,uBAAuB,EACvB,sBAAsB,EACtB,iBAAiB,EACjB,UAAU,EACV,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,oBAAoB,GACrB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,YAAY,EAAE,WAAW,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAC7G,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,yBAAyB,EACzB,QAAQ,EACR,qBAAqB,EACrB,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EAAE,iBAAiB,EAAE,WAAW,EAAE,sB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OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,oBAAoB,EACpB,mBAAmB,EACnB,qBAAqB,EACrB,qBAAqB,EACrB,WAAW,EACX,aAAa,EACb,mBAAmB,GACpB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,uBAAuB,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC1F,YAAY,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,yBAAyB,EAAE,6BAA6B,EAAE,+BAA+B,EAAE,gBAAgB,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAC/K,YAAY,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EACL,kBAAkB,EAClB,2BAA2B,EAC3B,qBAAqB,EACrB,qBAAqB,EACrB,0BAA0B,EAC1B,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,EACpB,cAAc,GACf,MAAM,0BAA0B,CAAC;AAClC,YAAY,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC"}
@@ -27,6 +27,8 @@ export { consolidate, mergeConsolidated, consolidatedKey, consolidatedFiles, wit
27
27
  export { CONSOLIDATED_KEY_PREFIX, CONSOLIDATED_ROOT_AREA, MAX_RECALLED_MAPS, areaOfPath, areasNamedIn, areasOfPathsIn, consolidatedArea, consolidatedFactsFor, } from './codemapAreas.js';
28
28
  export { rankByCount } from './rank.js';
29
29
  export { HISTORY_WINDOW, HISTORY_TOKEN_BUDGET, COMPACT_TAIL_TOKEN_BUDGET, windowed, stillInWorkingContext, transcriptTokens, buildWorkingTranscript, } from './transcript.js';
30
+ export { NARRATION_OVERLAP, PROGRESS_NOTE, supersededReadMarker, foldSupersededReads, foldRepeatedNarration, foldWorkingTranscript, wordOverlap, wordContained, isRepeatedNarration, } from './fold.js';
31
+ export { DEFAULT_MAX_MERGE_DEPTH, chunkText, chunkedTextSummary } from './textSummary.js';
30
32
  export { TRANSCRIPT_SUMMARY_PROMPT, TRANSCRIPT_SUMMARY_MAX_TOKENS, TRANSCRIPT_SUMMARY_INPUT_TOKENS, renderForSummary, summaryChunks, summarizeTranscript } from './summary.js';
31
33
  export { CONSOLIDATION_META, CONSOLIDATION_MARKER_PREFIX, consolidationMetadata, consolidationMarkerOf, consolidationMarkerContent, isConsolidationMarker, lastConsolidationIndex, scopeToConsolidation, foldKeepFromId, } from './consolidationMarker.js';
32
34
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/working/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EACjB,wBAAwB,EACxB,sBAAsB,GACvB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,uBAAuB,EACvB,sBAAsB,EACtB,iBAAiB,EACjB,UAAU,EACV,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,oBAAoB,GACrB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,yBAAyB,EACzB,QAAQ,EACR,qBAAqB,EACrB,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,yBAAyB,EAAE,6BAA6B,EAAE,+BAA+B,EAAE,gBAAgB,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAE/K,OAAO,EACL,kBAAkB,EAClB,2BAA2B,EAC3B,qBAAqB,EACrB,qBAAqB,EACrB,0BAA0B,EAC1B,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,EACpB,cAAc,GACf,MAAM,0BAA0B,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/working/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EACjB,wBAAwB,EACxB,sBAAsB,GACvB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,uBAAuB,EACvB,sBAAsB,EACtB,iBAAiB,EACjB,UAAU,EACV,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,oBAAoB,GACrB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,yBAAyB,EACzB,QAAQ,EACR,qBAAqB,EACrB,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,oBAAoB,EACpB,mBAAmB,EACnB,qBAAqB,EACrB,qBAAqB,EACrB,WAAW,EACX,aAAa,EACb,mBAAmB,GACpB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,uBAAuB,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAE1F,OAAO,EAAE,yBAAyB,EAAE,6BAA6B,EAAE,+BAA+B,EAAE,gBAAgB,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAE/K,OAAO,EACL,kBAAkB,EAClB,2BAA2B,EAC3B,qBAAqB,EACrB,qBAAqB,EACrB,0BAA0B,EAC1B,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,EACpB,cAAc,GACf,MAAM,0BAA0B,CAAC"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Chunked text summaries — the TEXT-level primitive beside the message-level {@link summaryChunks} /
3
+ * {@link summarizeTranscript} (summary.ts): a small window (an on-device model) takes a long text.
4
+ *
5
+ * 1. the text fits the chunk limit → ONE `summarizeChunk(text)` call;
6
+ * 2. otherwise split on paragraph, then line boundaries (then a hard cut) into chunks under the limit,
7
+ * re-measured with the caller's own `measure` and split again when the char estimate under-cut;
8
+ * 3. summarize each chunk; any chunk declined (`null`) → `null`;
9
+ * 4. summarize the joined summaries, recursing while still over the limit, up to `maxMergeDepth`;
10
+ * 5. past `maxChunks` leaf chunks, past the depth, or a merge that did not shrink the text → `null`
11
+ * (the caller's existing path takes it).
12
+ *
13
+ * Pure over an injected `measure` and an injected one-chunk summarizer: it knows no model API. An aborted
14
+ * `signal` rejects with an `AbortError` (and only an abort throws). Ported from brain-embedded's
15
+ * `onDevice/chunkedSummary.ts`, behaviour for behaviour; the one change is that a hard cut never splits a
16
+ * UTF-16 surrogate pair.
17
+ */
18
+ /** Merging summaries must shrink the text; this bounds a pathological recursion. */
19
+ export declare const DEFAULT_MAX_MERGE_DEPTH = 3;
20
+ export interface ChunkedTextSummaryOptions {
21
+ text: string;
22
+ /** The window, in the units `measure` counts (tokens). */
23
+ limit: number;
24
+ /** The size of `text` in the window's units. */
25
+ measure(text: string, signal?: AbortSignal): number | Promise<number>;
26
+ /** Summarizes one in-window piece; `null` = declined (the whole summary is then `null`). */
27
+ summarizeChunk(chunk: string, signal?: AbortSignal): Promise<string | null>;
28
+ /** More leaf chunks than this → `null` without summarizing any. */
29
+ maxChunks: number;
30
+ /** Merge rounds before giving up (default {@link DEFAULT_MAX_MERGE_DEPTH}). */
31
+ maxMergeDepth?: number;
32
+ /** Units each call spends outside the chunk (instruction + expected reply); never more than half the window. Default 0. */
33
+ reserveTokens?: number;
34
+ /** Share of the remaining window a chunk may fill (default 1; an on-device host uses 0.8 for headroom). */
35
+ budgetShare?: number;
36
+ signal?: AbortSignal;
37
+ }
38
+ /**
39
+ * `text` as chunks of at most `maxChars` (a lone surrogate pair at `maxChars` 1 is the one exception): pieces cut on
40
+ * paragraph, then line, then hard boundaries, packed greedily. Joined, the chunks give back `text`, except that a
41
+ * trailing whitespace-only remainder is dropped.
42
+ */
43
+ export declare function chunkText(text: string, maxChars: number): string[];
44
+ /** See the module comment. Resolves to the summary, or `null` when it cannot be made within the bounds. */
45
+ export declare function chunkedTextSummary(o: ChunkedTextSummaryOptions): Promise<string | null>;
46
+ //# sourceMappingURL=textSummary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"textSummary.d.ts","sourceRoot":"","sources":["../../src/working/textSummary.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAMH,oFAAoF;AACpF,eAAO,MAAM,uBAAuB,IAAI,CAAC;AAEzC,MAAM,WAAW,yBAAyB;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,0DAA0D;IAC1D,KAAK,EAAE,MAAM,CAAC;IACd,gDAAgD;IAChD,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACtE,4FAA4F;IAC5F,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC5E,mEAAmE;IACnE,SAAS,EAAE,MAAM,CAAC;IAClB,+EAA+E;IAC/E,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,2HAA2H;IAC3H,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,2GAA2G;IAC3G,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAyCD;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAalE;AAyBD,2GAA2G;AAC3G,wBAAsB,kBAAkB,CAAC,CAAC,EAAE,yBAAyB,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAE7F"}
@@ -0,0 +1,142 @@
1
+ /**
2
+ * Chunked text summaries — the TEXT-level primitive beside the message-level {@link summaryChunks} /
3
+ * {@link summarizeTranscript} (summary.ts): a small window (an on-device model) takes a long text.
4
+ *
5
+ * 1. the text fits the chunk limit → ONE `summarizeChunk(text)` call;
6
+ * 2. otherwise split on paragraph, then line boundaries (then a hard cut) into chunks under the limit,
7
+ * re-measured with the caller's own `measure` and split again when the char estimate under-cut;
8
+ * 3. summarize each chunk; any chunk declined (`null`) → `null`;
9
+ * 4. summarize the joined summaries, recursing while still over the limit, up to `maxMergeDepth`;
10
+ * 5. past `maxChunks` leaf chunks, past the depth, or a merge that did not shrink the text → `null`
11
+ * (the caller's existing path takes it).
12
+ *
13
+ * Pure over an injected `measure` and an injected one-chunk summarizer: it knows no model API. An aborted
14
+ * `signal` rejects with an `AbortError` (and only an abort throws). Ported from brain-embedded's
15
+ * `onDevice/chunkedSummary.ts`, behaviour for behaviour; the one change is that a hard cut never splits a
16
+ * UTF-16 surrogate pair.
17
+ */
18
+ /** Separators from the coarsest boundary to the finest; past the last, a hard cut. */
19
+ const SEPARATORS = ['\n\n', '\n'];
20
+ /** Bounds the re-measure/re-split of a chunk the first estimate under-cut. */
21
+ const MAX_REFIT_ATTEMPTS = 3;
22
+ /** Merging summaries must shrink the text; this bounds a pathological recursion. */
23
+ export const DEFAULT_MAX_MERGE_DEPTH = 3;
24
+ function abortError() {
25
+ const e = new Error('Aborted');
26
+ e.name = 'AbortError';
27
+ return e;
28
+ }
29
+ function throwIfAborted(signal) {
30
+ if (signal?.aborted)
31
+ throw abortError();
32
+ }
33
+ /** A hard cut of `text` into slices of at most `maxChars`, never between the halves of a surrogate pair. */
34
+ function hardCut(text, maxChars) {
35
+ const out = [];
36
+ let at = 0;
37
+ while (at < text.length) {
38
+ let end = Math.min(text.length, at + maxChars);
39
+ const last = text.charCodeAt(end - 1);
40
+ // A high surrogate at the cut belongs with the low one after it: cut before it (or keep the pair whole when it is the slice).
41
+ if (end < text.length && last >= 0xd800 && last <= 0xdbff)
42
+ end = end - 1 > at ? end - 1 : end + 1;
43
+ out.push(text.slice(at, end));
44
+ at = end;
45
+ }
46
+ return out;
47
+ }
48
+ /**
49
+ * Cut `text` into pieces of at most `maxChars`: paragraphs first, then lines, then a hard cut. A piece still
50
+ * over `maxChars` moves to the NEXT level only, so every recursion strictly descends and the split terminates;
51
+ * the separator stays on its piece, so joining the pieces gives back `text`.
52
+ */
53
+ function pieces(text, maxChars, level = 0) {
54
+ if (text.length <= maxChars)
55
+ return [text];
56
+ const separator = SEPARATORS[level];
57
+ if (separator === undefined)
58
+ return hardCut(text, maxChars);
59
+ const parts = text.split(separator);
60
+ if (parts.length === 1)
61
+ return pieces(text, maxChars, level + 1);
62
+ return parts.flatMap((p, i) => pieces(i < parts.length - 1 ? p + separator : p, maxChars, level + 1));
63
+ }
64
+ /**
65
+ * `text` as chunks of at most `maxChars` (a lone surrogate pair at `maxChars` 1 is the one exception): pieces cut on
66
+ * paragraph, then line, then hard boundaries, packed greedily. Joined, the chunks give back `text`, except that a
67
+ * trailing whitespace-only remainder is dropped.
68
+ */
69
+ export function chunkText(text, maxChars) {
70
+ const max = Math.max(1, Math.floor(maxChars));
71
+ const chunks = [];
72
+ let current = '';
73
+ for (const piece of pieces(text, max)) {
74
+ if (current && current.length + piece.length > max) {
75
+ chunks.push(current);
76
+ current = '';
77
+ }
78
+ current += piece;
79
+ }
80
+ if (current.trim())
81
+ chunks.push(current);
82
+ return chunks;
83
+ }
84
+ /** Re-measure each chunk with the real measure; a chunk still over `limit` is split again (bounded). */
85
+ async function fitChunks(chunks, limit, o) {
86
+ const out = [];
87
+ for (const chunk of chunks) {
88
+ let parts = [chunk];
89
+ for (let attempt = 0; attempt < MAX_REFIT_ATTEMPTS; attempt++) {
90
+ const next = [];
91
+ let over = false;
92
+ for (const part of parts) {
93
+ throwIfAborted(o.signal);
94
+ const tokens = await o.measure(part, o.signal);
95
+ if (tokens <= limit || part.length <= 1) {
96
+ next.push(part);
97
+ continue;
98
+ }
99
+ over = true;
100
+ next.push(...chunkText(part, Math.max(1, Math.floor(((part.length / tokens) * limit) * 0.9))));
101
+ }
102
+ parts = next;
103
+ if (!over)
104
+ break;
105
+ }
106
+ out.push(...parts);
107
+ }
108
+ return out;
109
+ }
110
+ /** See the module comment. Resolves to the summary, or `null` when it cannot be made within the bounds. */
111
+ export async function chunkedTextSummary(o) {
112
+ return summarizeAt(o, 0);
113
+ }
114
+ async function summarizeAt(o, depth) {
115
+ const { text, signal } = o;
116
+ throwIfAborted(signal);
117
+ // The reserve never takes more than half the window, so a tiny window still holds a chunk.
118
+ const room = Math.max(Math.floor(o.limit / 2), o.limit - (o.reserveTokens ?? 0));
119
+ const limit = Math.max(1, Math.floor(room * (o.budgetShare ?? 1)));
120
+ const tokens = await o.measure(text, signal);
121
+ if (tokens <= limit)
122
+ return o.summarizeChunk(text, signal);
123
+ if (depth >= (o.maxMergeDepth ?? DEFAULT_MAX_MERGE_DEPTH))
124
+ return null;
125
+ const chunks = await fitChunks(chunkText(text, Math.max(1, Math.floor((text.length / tokens) * limit))), limit, o);
126
+ if (chunks.length > o.maxChunks)
127
+ return null;
128
+ const summaries = [];
129
+ for (const chunk of chunks) {
130
+ throwIfAborted(signal);
131
+ const summary = await o.summarizeChunk(chunk, signal);
132
+ if (summary === null)
133
+ return null;
134
+ summaries.push(summary);
135
+ }
136
+ const merged = summaries.join('\n\n');
137
+ // A merge that did not shrink the text will not converge.
138
+ if (merged.length >= text.length)
139
+ return null;
140
+ return summarizeAt({ ...o, text: merged }, depth + 1);
141
+ }
142
+ //# sourceMappingURL=textSummary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"textSummary.js","sourceRoot":"","sources":["../../src/working/textSummary.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,sFAAsF;AACtF,MAAM,UAAU,GAAG,CAAC,MAAM,EAAE,IAAI,CAAU,CAAC;AAC3C,8EAA8E;AAC9E,MAAM,kBAAkB,GAAG,CAAC,CAA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,MAAM,SAAS,GAAa,EAAE,CAAC;IAC/B,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,cAAc,CAAC,MAAM,CAAC,CAAC;QACvB,MAAM,OAAO,GAAG,MAAM,CAAC,CAAC,cAAc,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACtD,IAAI,OAAO,KAAK,IAAI;YAAE,OAAO,IAAI,CAAC;QAClC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC1B,CAAC;IACD,MAAM,MAAM,GAAG,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACtC,0DAA0D;IAC1D,IAAI,MAAM,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IAC9C,OAAO,WAAW,CAAC,EAAE,GAAG,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;AACxD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seanhogg/builderforce-memory",
3
- "version": "2026.10.62",
3
+ "version": "2026.10.66",
4
4
  "description": "BuilderForce Agent Memory — runtime layer. SSM execution, Transformer orchestration, online distillation, enterprise RAG (ingestion pipelines, vector-store adapters, tenant/ACL-scoped hybrid retrieval), multi-agent graph orchestration, LLM telemetry and cost accounting, persistent agent memory, and token-saving agent-run memory (code maps, a prompt-cache-safe working memory, chunked transcript windowing) for BuilderForce.ai agents.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -34,6 +34,10 @@
34
34
  "types": "./dist/working/index.d.ts",
35
35
  "import": "./dist/working/index.js"
36
36
  },
37
+ "./stats": {
38
+ "types": "./dist/stats/index.d.ts",
39
+ "import": "./dist/stats/index.js"
40
+ },
37
41
  "./distillation": {
38
42
  "types": "./dist/distillation/index.d.ts",
39
43
  "import": "./dist/distillation/index.js"
@@ -527,6 +527,41 @@
527
527
  "toDecayLambda",
528
528
  "tokenize"
529
529
  ],
530
+ "./stats": [
531
+ "bayesianOnlineChangePoint",
532
+ "betaPosterior",
533
+ "brierScore",
534
+ "chapmanEstimate",
535
+ "createRng",
536
+ "cusum",
537
+ "effortAwareRecall",
538
+ "entropyOfCounts",
539
+ "expectedCalibrationError",
540
+ "fitBayesianLogistic",
541
+ "fitIsotonic",
542
+ "fitPlattScaling",
543
+ "gammaPoissonPosterior",
544
+ "gammaQuantile",
545
+ "garwoodPoissonInterval",
546
+ "goelOkumotoMLE",
547
+ "inverseRegularizedIncompleteBeta",
548
+ "kaplanMeier",
549
+ "ledoitWolfCovariance",
550
+ "lincolnPetersenEstimate",
551
+ "ndcgAtK",
552
+ "normalDraw",
553
+ "pairedBootstrapCi",
554
+ "popt",
555
+ "prAuc",
556
+ "psi",
557
+ "regularizedIncompleteBeta",
558
+ "regularizedIncompleteGamma",
559
+ "shannonEntropy",
560
+ "signTestSprt",
561
+ "thompsonRank",
562
+ "thompsonSample",
563
+ "wilcoxonSignedRank"
564
+ ],
530
565
  "./telemetry": [
531
566
  "ANTHROPIC_PRICE_BOOK",
532
567
  "ConsoleSpanExporter",
@@ -588,10 +623,13 @@
588
623
  "CONSOLIDATED_ROOT_AREA",
589
624
  "CONSOLIDATION_MARKER_PREFIX",
590
625
  "CONSOLIDATION_META",
626
+ "DEFAULT_MAX_MERGE_DEPTH",
591
627
  "HISTORY_TOKEN_BUDGET",
592
628
  "HISTORY_WINDOW",
593
629
  "MAX_RECALLED_MAPS",
594
630
  "MIN_CONSOLIDATED_FILES",
631
+ "NARRATION_OVERLAP",
632
+ "PROGRESS_NOTE",
595
633
  "TRANSCRIPT_SUMMARY_INPUT_TOKENS",
596
634
  "TRANSCRIPT_SUMMARY_MAX_TOKENS",
597
635
  "TRANSCRIPT_SUMMARY_PROMPT",
@@ -600,6 +638,8 @@
600
638
  "areasNamedIn",
601
639
  "areasOfPathsIn",
602
640
  "buildWorkingTranscript",
641
+ "chunkText",
642
+ "chunkedTextSummary",
603
643
  "consolidate",
604
644
  "consolidatedArea",
605
645
  "consolidatedFactsFor",
@@ -609,7 +649,11 @@
609
649
  "consolidationMarkerOf",
610
650
  "consolidationMetadata",
611
651
  "foldKeepFromId",
652
+ "foldRepeatedNarration",
653
+ "foldSupersededReads",
654
+ "foldWorkingTranscript",
612
655
  "isConsolidationMarker",
656
+ "isRepeatedNarration",
613
657
  "lastConsolidationIndex",
614
658
  "mergeConsolidated",
615
659
  "rankByCount",
@@ -618,8 +662,11 @@
618
662
  "stillInWorkingContext",
619
663
  "summarizeTranscript",
620
664
  "summaryChunks",
665
+ "supersededReadMarker",
621
666
  "transcriptTokens",
622
667
  "windowed",
623
- "withoutConsolidatedFiles"
668
+ "withoutConsolidatedFiles",
669
+ "wordContained",
670
+ "wordOverlap"
624
671
  ]
625
672
  }