acp-kernel 0.0.96-pr.463.319 → 0.0.96-pr.465.320
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/dist/compress.d.ts.map +1 -1
- package/dist/index.js +49 -52
- package/dist/index.js.map +1 -1
- package/dist/instance-reid.d.ts +33 -19
- package/dist/instance-reid.d.ts.map +1 -1
- package/dist/persist/index.js +3 -1
- package/dist/persist/index.js.map +1 -1
- package/dist/persist/state-merge.d.ts.map +1 -1
- package/dist/sync.d.ts.map +1 -1
- package/dist/types.d.ts +9 -9
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/compress.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compress.d.ts","sourceRoot":"","sources":["../src/compress.ts"],"names":[],"mappings":"AAKA,OAAO,EAAkC,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAgBhF,OAAO,KAAK,EAAE,mBAAmB,EAAa,MAAM,UAAU,CAAC;AAE/D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAI9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAgBvD,OAAO,EAGL,KAAK,YAAY,EAGlB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EACV,sBAAsB,EACtB,gBAAgB,EAChB,gBAAgB,EAEhB,MAAM,EAEN,WAAW,EAGX,iBAAiB,EAEjB,YAAY,EACb,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,KAAK;IACpB,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;CACxC;AAED,MAAM,WAAW,eAAe;IAC9B,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,iBAAiB,CAAC;IACxD;mEAC+D;IAC/D,QAAQ,CAAC,KAAK,EAAE,mBAAmB,EAAE,GAAG,EAAE,MAAM,GAAG,mBAAmB,CAAC;IACv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nB;;;;;;;;;;;OAWG;IACH,UAAU,CAAC,EAAE,cAAc,CAAC;IAC5B;8DAC0D;IAC1D,YAAY,CAAC,EAAE,mBAAmB,CAAC;CACpC;AAED,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE;QACN,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,MAAM,CAAC;QACf,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,eAAe,CAAC,EAAE,MAAM,CAAC;KAC1B,EAAE,CAAC;IACJ,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,KAAK,EAAE,gBAAgB,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,mBAAmB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CACnC;AAqND,wBAAgB,UAAU,CAAC,KAAK,GAAE,KAAU,GAAG,eAAe,CAie7D;AAgrCD,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -102,6 +102,46 @@ function highestUsedIndex(map) {
|
|
|
102
102
|
return highest;
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
+
// src/instance-reid.ts
|
|
106
|
+
var CONTENT_HASH_ROOT = /^h_([0-9a-f]{16})(?:_\d+)?(?:#.*)?$/;
|
|
107
|
+
function clusterRoot(id) {
|
|
108
|
+
const m = CONTENT_HASH_ROOT.exec(id);
|
|
109
|
+
return m ? `h_${m[1]}` : null;
|
|
110
|
+
}
|
|
111
|
+
function remintCoveredLiveIds(messages, state) {
|
|
112
|
+
const lastPass = state.lastPassIds;
|
|
113
|
+
if (lastPass === void 0) return messages;
|
|
114
|
+
const covered = new Set(coveredMessageIds(state));
|
|
115
|
+
if (covered.size === 0) return messages;
|
|
116
|
+
const seenLastPass = new Set(lastPass);
|
|
117
|
+
const groups = /* @__PURE__ */ new Map();
|
|
118
|
+
for (let i = 0; i < messages.length; i++) {
|
|
119
|
+
const root = clusterRoot(messages[i].id);
|
|
120
|
+
if (root === null) continue;
|
|
121
|
+
const idxs = groups.get(root);
|
|
122
|
+
if (idxs) idxs.push(i);
|
|
123
|
+
else groups.set(root, [i]);
|
|
124
|
+
}
|
|
125
|
+
const next = [...messages];
|
|
126
|
+
let changed = false;
|
|
127
|
+
for (const [root, idxs] of groups) {
|
|
128
|
+
const conflict = idxs.some((i) => covered.has(messages[i].id));
|
|
129
|
+
if (!conflict) continue;
|
|
130
|
+
let k = 1;
|
|
131
|
+
for (const i of idxs) {
|
|
132
|
+
const id = messages[i].id;
|
|
133
|
+
if (covered.has(id) && seenLastPass.has(id)) continue;
|
|
134
|
+
while (covered.has(`${root}_${k}`)) k++;
|
|
135
|
+
const hash = id.indexOf("#");
|
|
136
|
+
const tail = hash > 0 ? id.slice(hash) : "";
|
|
137
|
+
next[i] = { ...messages[i], id: `${root}_${k}${tail}` };
|
|
138
|
+
k++;
|
|
139
|
+
changed = true;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return changed ? next : messages;
|
|
143
|
+
}
|
|
144
|
+
|
|
105
145
|
// src/prune.ts
|
|
106
146
|
var SUMMARY_HEADER = "[Compressed conversation section]";
|
|
107
147
|
var SUMMARY_ID_PREFIX = "acp_summary_";
|
|
@@ -290,53 +330,6 @@ function stripOrphanedReasoning(messages) {
|
|
|
290
330
|
return messages.filter((_, i) => !drop.has(i));
|
|
291
331
|
}
|
|
292
332
|
|
|
293
|
-
// src/instance-reid.ts
|
|
294
|
-
var CONTENT_HASH_ROOT = /^h_([0-9a-f]{16})(?:_\d+)?(?:#.*)?$/;
|
|
295
|
-
function clusterRoot(id) {
|
|
296
|
-
const m = CONTENT_HASH_ROOT.exec(id);
|
|
297
|
-
return m ? `h_${m[1]}` : null;
|
|
298
|
-
}
|
|
299
|
-
function remintCoveredLiveIds(messages, state) {
|
|
300
|
-
const coveredBases = /* @__PURE__ */ new Set();
|
|
301
|
-
for (const id of coveredMessageIds(state)) coveredBases.add(baseIdOf(id));
|
|
302
|
-
if (coveredBases.size === 0) return messages;
|
|
303
|
-
if (!state.lastPassIds) return messages;
|
|
304
|
-
const prior = new Set(state.lastPassIds);
|
|
305
|
-
const groups = /* @__PURE__ */ new Map();
|
|
306
|
-
for (let i = 0; i < messages.length; i++) {
|
|
307
|
-
const root = clusterRoot(messages[i].id);
|
|
308
|
-
if (root === null) continue;
|
|
309
|
-
const idxs = groups.get(root);
|
|
310
|
-
if (idxs) idxs.push(i);
|
|
311
|
-
else groups.set(root, [i]);
|
|
312
|
-
}
|
|
313
|
-
const next = [...messages];
|
|
314
|
-
let changed = false;
|
|
315
|
-
for (const [root, idxs] of groups) {
|
|
316
|
-
const conflict = idxs.some(
|
|
317
|
-
(i) => coveredBases.has(baseIdOf(messages[i].id))
|
|
318
|
-
);
|
|
319
|
-
if (!conflict) continue;
|
|
320
|
-
const liveIds = new Set(idxs.map((i) => baseIdOf(messages[i].id)));
|
|
321
|
-
let k = 1;
|
|
322
|
-
for (const i of idxs) {
|
|
323
|
-
const id = messages[i].id;
|
|
324
|
-
const exactCovered = coveredBases.has(baseIdOf(id));
|
|
325
|
-
if (!exactCovered || prior.has(id)) continue;
|
|
326
|
-
while (coveredBases.has(`${root}_${k}`) || liveIds.has(`${root}_${k}`) || prior.has(`${root}_${k}`))
|
|
327
|
-
k++;
|
|
328
|
-
const hash = id.indexOf("#");
|
|
329
|
-
const tail = hash > 0 ? id.slice(hash) : "";
|
|
330
|
-
const minted = `${root}_${k}${tail}`;
|
|
331
|
-
liveIds.add(baseIdOf(minted));
|
|
332
|
-
next[i] = { ...messages[i], id: minted };
|
|
333
|
-
k++;
|
|
334
|
-
changed = true;
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
return changed ? next : messages;
|
|
338
|
-
}
|
|
339
|
-
|
|
340
333
|
// src/sync.ts
|
|
341
334
|
function syncBlocks(messages, state) {
|
|
342
335
|
const presentIds = new Set(messages.map((message) => message.id));
|
|
@@ -365,7 +358,8 @@ function syncBlocks(messages, state) {
|
|
|
365
358
|
nextRuleId: state.nextRuleId,
|
|
366
359
|
terminalStreak: state.terminalStreak,
|
|
367
360
|
nextBlockId: state.nextBlockId,
|
|
368
|
-
nextRunId: state.nextRunId
|
|
361
|
+
nextRunId: state.nextRunId,
|
|
362
|
+
lastPassIds: state.lastPassIds ? [...state.lastPassIds] : void 0
|
|
369
363
|
};
|
|
370
364
|
const liveRefs = new Set(
|
|
371
365
|
messages.map((m) => result.messageRefs.byRaw[m.id]).filter((r) => typeof r === "string")
|
|
@@ -5038,6 +5032,7 @@ function createCore(ports = {}) {
|
|
|
5038
5032
|
countTokens,
|
|
5039
5033
|
contentStore
|
|
5040
5034
|
};
|
|
5035
|
+
const inboundIds = input.messages.map((m) => m.id);
|
|
5041
5036
|
const initial = {
|
|
5042
5037
|
messages: input.messages,
|
|
5043
5038
|
state: input.state,
|
|
@@ -5045,13 +5040,14 @@ function createCore(ports = {}) {
|
|
|
5045
5040
|
};
|
|
5046
5041
|
const strategy = input.renderTags ?? "all";
|
|
5047
5042
|
const nodes = buildNodes(strategy);
|
|
5048
|
-
const inboundIds = input.messages.map((m) => m.id);
|
|
5049
5043
|
const result = runPipeline(nodes, initial, ctx);
|
|
5050
|
-
const state = { ...result.state, lastPassIds: inboundIds };
|
|
5051
5044
|
const ccrEffect = result.effects.ccr;
|
|
5052
5045
|
return {
|
|
5053
5046
|
messages: result.messages,
|
|
5054
|
-
|
|
5047
|
+
// This pass's inbound ids become the NEXT pass's echo discriminator
|
|
5048
|
+
// (#462). Written here — not by a node — so reconcile-live-ids reads the
|
|
5049
|
+
// PREVIOUS pass's snapshot during this one.
|
|
5050
|
+
state: { ...result.state, lastPassIds: inboundIds },
|
|
5055
5051
|
nudge: result.effects.nudge,
|
|
5056
5052
|
terminalEscape: result.effects.terminalEscape,
|
|
5057
5053
|
truncationSkipped: result.effects.truncationSkipped,
|
|
@@ -5869,7 +5865,8 @@ function cloneState(state) {
|
|
|
5869
5865
|
terminalStreak: state.terminalStreak,
|
|
5870
5866
|
nextBlockId: state.nextBlockId,
|
|
5871
5867
|
nextRunId: state.nextRunId,
|
|
5872
|
-
hiddenOrphanRefs: state.hiddenOrphanRefs ? [...state.hiddenOrphanRefs] : void 0
|
|
5868
|
+
hiddenOrphanRefs: state.hiddenOrphanRefs ? [...state.hiddenOrphanRefs] : void 0,
|
|
5869
|
+
lastPassIds: state.lastPassIds ? [...state.lastPassIds] : void 0
|
|
5873
5870
|
};
|
|
5874
5871
|
}
|
|
5875
5872
|
function scoreRelevance(block, terms) {
|