acp-kernel 0.0.96-pr.466.321 → 0.0.97-pr.468.322

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":"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;IACvE,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,GAAG,sBAAsB,CAAC;IACvE,YAAY,IAAI,YAAY,EAAE,CAAC;IAC/B,UAAU,CACR,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,gBAAgB,GACtB,gBAAgB,GAAG,SAAS,CAAC;IAChC,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,gBAAgB,GAAG,gBAAgB,EAAE,CAAC;IACnE,MAAM,CACJ,KAAK,EAAE,gBAAgB,EACvB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AM,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,CAke7D;AA+qCD,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
package/dist/index.js CHANGED
@@ -290,10 +290,54 @@ function stripOrphanedReasoning(messages) {
290
290
  return messages.filter((_, i) => !drop.has(i));
291
291
  }
292
292
 
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));
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;
296
338
  }
339
+
340
+ // src/sync.ts
297
341
  function syncBlocks(messages, state) {
298
342
  const presentIds = new Set(messages.map((message) => message.id));
299
343
  const presentBases = /* @__PURE__ */ new Set();
@@ -349,7 +393,8 @@ function syncBlocks(messages, state) {
349
393
  continue;
350
394
  }
351
395
  block.active = true;
352
- if (!isBlockStillPresent(block, presentBases, presentIds)) {
396
+ const stillPresent = block.effectiveMessageIds.some((id) => presentBases.has(baseIdOf(id))) || presentIds.has(summaryMessageId(block.blockId));
397
+ if (!stillPresent) {
353
398
  block.active = false;
354
399
  deactivated.push(block.blockId);
355
400
  }
@@ -357,101 +402,6 @@ function syncBlocks(messages, state) {
357
402
  return { state: result, deactivated };
358
403
  }
359
404
 
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
-
455
405
  // src/config.ts
456
406
  function defaultConfig(modelContextLimit, overrides = {}) {
457
407
  const base = {
@@ -5095,11 +5045,13 @@ function createCore(ports = {}) {
5095
5045
  };
5096
5046
  const strategy = input.renderTags ?? "all";
5097
5047
  const nodes = buildNodes(strategy);
5048
+ const inboundIds = input.messages.map((m) => m.id);
5098
5049
  const result = runPipeline(nodes, initial, ctx);
5050
+ const state = { ...result.state, lastPassIds: inboundIds };
5099
5051
  const ccrEffect = result.effects.ccr;
5100
5052
  return {
5101
5053
  messages: result.messages,
5102
- state: result.state,
5054
+ state,
5103
5055
  nudge: result.effects.nudge,
5104
5056
  terminalEscape: result.effects.terminalEscape,
5105
5057
  truncationSkipped: result.effects.truncationSkipped,