acp-kernel 0.0.96-pr.465.320 → 0.0.96-pr.466.321
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 +102 -51
- package/dist/index.js.map +1 -1
- package/dist/instance-reid.d.ts +41 -33
- package/dist/instance-reid.d.ts.map +1 -1
- package/dist/persist/index.js +1 -3
- package/dist/persist/index.js.map +1 -1
- package/dist/persist/state-merge.d.ts.map +1 -1
- package/dist/sync.d.ts +10 -1
- package/dist/sync.d.ts.map +1 -1
- package/dist/types.d.ts +0 -10
- 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,G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U,EAAE,MAAM,CAAC;IACnB;;;;;;;;;;;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,CA6d7D;AA+qCD,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -102,46 +102,6 @@ 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
|
-
|
|
145
105
|
// src/prune.ts
|
|
146
106
|
var SUMMARY_HEADER = "[Compressed conversation section]";
|
|
147
107
|
var SUMMARY_ID_PREFIX = "acp_summary_";
|
|
@@ -331,6 +291,9 @@ function stripOrphanedReasoning(messages) {
|
|
|
331
291
|
}
|
|
332
292
|
|
|
333
293
|
// src/sync.ts
|
|
294
|
+
function isBlockStillPresent(block, presentBases, presentIds) {
|
|
295
|
+
return block.effectiveMessageIds.some((id) => presentBases.has(baseIdOf(id))) || presentIds.has(summaryMessageId(block.blockId));
|
|
296
|
+
}
|
|
334
297
|
function syncBlocks(messages, state) {
|
|
335
298
|
const presentIds = new Set(messages.map((message) => message.id));
|
|
336
299
|
const presentBases = /* @__PURE__ */ new Set();
|
|
@@ -358,8 +321,7 @@ function syncBlocks(messages, state) {
|
|
|
358
321
|
nextRuleId: state.nextRuleId,
|
|
359
322
|
terminalStreak: state.terminalStreak,
|
|
360
323
|
nextBlockId: state.nextBlockId,
|
|
361
|
-
nextRunId: state.nextRunId
|
|
362
|
-
lastPassIds: state.lastPassIds ? [...state.lastPassIds] : void 0
|
|
324
|
+
nextRunId: state.nextRunId
|
|
363
325
|
};
|
|
364
326
|
const liveRefs = new Set(
|
|
365
327
|
messages.map((m) => result.messageRefs.byRaw[m.id]).filter((r) => typeof r === "string")
|
|
@@ -387,8 +349,7 @@ function syncBlocks(messages, state) {
|
|
|
387
349
|
continue;
|
|
388
350
|
}
|
|
389
351
|
block.active = true;
|
|
390
|
-
|
|
391
|
-
if (!stillPresent) {
|
|
352
|
+
if (!isBlockStillPresent(block, presentBases, presentIds)) {
|
|
392
353
|
block.active = false;
|
|
393
354
|
deactivated.push(block.blockId);
|
|
394
355
|
}
|
|
@@ -396,6 +357,101 @@ function syncBlocks(messages, state) {
|
|
|
396
357
|
return { state: result, deactivated };
|
|
397
358
|
}
|
|
398
359
|
|
|
360
|
+
// src/instance-reid.ts
|
|
361
|
+
var CONTENT_HASH_ROOT = /^h_([0-9a-f]{16})(?:_\d+)?(?:#.*)?$/;
|
|
362
|
+
function clusterRoot(id) {
|
|
363
|
+
const m = CONTENT_HASH_ROOT.exec(id);
|
|
364
|
+
return m ? `h_${m[1]}` : null;
|
|
365
|
+
}
|
|
366
|
+
function instanceNumber(id, root) {
|
|
367
|
+
if (!id.startsWith(`${root}_`)) return null;
|
|
368
|
+
const n = Number(id.slice(root.length + 1));
|
|
369
|
+
return Number.isInteger(n) && n > 0 ? n : null;
|
|
370
|
+
}
|
|
371
|
+
function remintCoveredLiveIds(messages, state) {
|
|
372
|
+
const liveBases = /* @__PURE__ */ new Set();
|
|
373
|
+
const liveIds = /* @__PURE__ */ new Set();
|
|
374
|
+
for (const message of messages) {
|
|
375
|
+
if (typeof message.id !== "string") continue;
|
|
376
|
+
liveIds.add(message.id);
|
|
377
|
+
liveBases.add(baseIdOf(message.id));
|
|
378
|
+
}
|
|
379
|
+
const consumed = /* @__PURE__ */ new Set();
|
|
380
|
+
for (const block of state.blocks) {
|
|
381
|
+
for (const id of block.directBlockIds) consumed.add(id);
|
|
382
|
+
}
|
|
383
|
+
const coverersByBase = /* @__PURE__ */ new Map();
|
|
384
|
+
const coveredBases = /* @__PURE__ */ new Set();
|
|
385
|
+
let anyCoverage = false;
|
|
386
|
+
for (const block of state.blocks) {
|
|
387
|
+
if (consumed.has(block.blockId) || block.expanded) continue;
|
|
388
|
+
if (!isBlockStillPresent(block, liveBases, liveIds)) continue;
|
|
389
|
+
const bases = /* @__PURE__ */ new Set();
|
|
390
|
+
for (const id of block.effectiveMessageIds) bases.add(baseIdOf(id));
|
|
391
|
+
let allPresent = bases.size > 0;
|
|
392
|
+
for (const base of bases) {
|
|
393
|
+
if (!liveBases.has(base)) {
|
|
394
|
+
allPresent = false;
|
|
395
|
+
break;
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
const replaying = allPresent && !liveIds.has(summaryMessageId(block.blockId));
|
|
399
|
+
anyCoverage = true;
|
|
400
|
+
for (const base of bases) {
|
|
401
|
+
coveredBases.add(base);
|
|
402
|
+
const flags = coverersByBase.get(base);
|
|
403
|
+
if (flags) flags.push(replaying);
|
|
404
|
+
else coverersByBase.set(base, [replaying]);
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
if (!anyCoverage) return messages;
|
|
408
|
+
const groups = /* @__PURE__ */ new Map();
|
|
409
|
+
for (let i = 0; i < messages.length; i++) {
|
|
410
|
+
const id = messages[i].id;
|
|
411
|
+
if (typeof id !== "string") continue;
|
|
412
|
+
const root = clusterRoot(id);
|
|
413
|
+
if (root === null) continue;
|
|
414
|
+
const idxs = groups.get(root);
|
|
415
|
+
if (idxs) idxs.push(i);
|
|
416
|
+
else groups.set(root, [i]);
|
|
417
|
+
}
|
|
418
|
+
const next = [...messages];
|
|
419
|
+
let changed = false;
|
|
420
|
+
for (const [root, idxs] of groups) {
|
|
421
|
+
const remintIdx = [];
|
|
422
|
+
for (const i of idxs) {
|
|
423
|
+
const flags = coverersByBase.get(baseIdOf(messages[i].id));
|
|
424
|
+
if (!flags) continue;
|
|
425
|
+
const positionalReplay = flags.every((replaying) => replaying);
|
|
426
|
+
if (positionalReplay) continue;
|
|
427
|
+
remintIdx.push(i);
|
|
428
|
+
}
|
|
429
|
+
if (remintIdx.length === 0) continue;
|
|
430
|
+
const reminting = new Set(remintIdx);
|
|
431
|
+
const taken = /* @__PURE__ */ new Set();
|
|
432
|
+
for (const base of coveredBases) {
|
|
433
|
+
const n = instanceNumber(base, root);
|
|
434
|
+
if (n !== null) taken.add(n);
|
|
435
|
+
}
|
|
436
|
+
for (const i of idxs) {
|
|
437
|
+
if (reminting.has(i)) continue;
|
|
438
|
+
const n = instanceNumber(baseIdOf(messages[i].id), root);
|
|
439
|
+
if (n !== null) taken.add(n);
|
|
440
|
+
}
|
|
441
|
+
let k = 1;
|
|
442
|
+
for (const i of remintIdx) {
|
|
443
|
+
while (taken.has(k)) k++;
|
|
444
|
+
const id = messages[i].id;
|
|
445
|
+
const hash = id.indexOf("#");
|
|
446
|
+
const tail = hash > 0 ? id.slice(hash) : "";
|
|
447
|
+
next[i] = { ...messages[i], id: `${root}_${k}${tail}` };
|
|
448
|
+
taken.add(k);
|
|
449
|
+
changed = true;
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
return changed ? next : messages;
|
|
453
|
+
}
|
|
454
|
+
|
|
399
455
|
// src/config.ts
|
|
400
456
|
function defaultConfig(modelContextLimit, overrides = {}) {
|
|
401
457
|
const base = {
|
|
@@ -5032,7 +5088,6 @@ function createCore(ports = {}) {
|
|
|
5032
5088
|
countTokens,
|
|
5033
5089
|
contentStore
|
|
5034
5090
|
};
|
|
5035
|
-
const inboundIds = input.messages.map((m) => m.id);
|
|
5036
5091
|
const initial = {
|
|
5037
5092
|
messages: input.messages,
|
|
5038
5093
|
state: input.state,
|
|
@@ -5044,10 +5099,7 @@ function createCore(ports = {}) {
|
|
|
5044
5099
|
const ccrEffect = result.effects.ccr;
|
|
5045
5100
|
return {
|
|
5046
5101
|
messages: result.messages,
|
|
5047
|
-
|
|
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 },
|
|
5102
|
+
state: result.state,
|
|
5051
5103
|
nudge: result.effects.nudge,
|
|
5052
5104
|
terminalEscape: result.effects.terminalEscape,
|
|
5053
5105
|
truncationSkipped: result.effects.truncationSkipped,
|
|
@@ -5865,8 +5917,7 @@ function cloneState(state) {
|
|
|
5865
5917
|
terminalStreak: state.terminalStreak,
|
|
5866
5918
|
nextBlockId: state.nextBlockId,
|
|
5867
5919
|
nextRunId: state.nextRunId,
|
|
5868
|
-
hiddenOrphanRefs: state.hiddenOrphanRefs ? [...state.hiddenOrphanRefs] : void 0
|
|
5869
|
-
lastPassIds: state.lastPassIds ? [...state.lastPassIds] : void 0
|
|
5920
|
+
hiddenOrphanRefs: state.hiddenOrphanRefs ? [...state.hiddenOrphanRefs] : void 0
|
|
5870
5921
|
};
|
|
5871
5922
|
}
|
|
5872
5923
|
function scoreRelevance(block, terms) {
|