billion-context-omp 0.2.0 → 0.2.1

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/index.js CHANGED
@@ -3166,6 +3166,15 @@ function freshSlot(preserveFrom) {
3166
3166
  }
3167
3167
  return slot;
3168
3168
  }
3169
+ function isViewFlip(foldedLen, lcp) {
3170
+ return foldedLen > 0 && lcp >= Math.floor(foldedLen / 2);
3171
+ }
3172
+ function preserveCompressedSlot(prev) {
3173
+ const slot = freshSlot(prev);
3174
+ slot.state = { ...slot.state, blocks: prev.state.blocks, messageRefs: prev.state.messageRefs, stats: prev.state.stats };
3175
+ slot.appliedCallIds = new Set(prev.appliedCallIds);
3176
+ return slot;
3177
+ }
3169
3178
  function stateHasCompressCall(state, callId) {
3170
3179
  return state.blocks.some((b) => b.compressCallId === callId);
3171
3180
  }
@@ -3217,8 +3226,9 @@ function createRuntime(adapter) {
3217
3226
  let lcp = 0;
3218
3227
  while (lcp < Math.min(ids.length, slot.identities.length) && ids[lcp] === slot.identities[lcp]) lcp++;
3219
3228
  if (lcp < slot.foldedLen) {
3220
- debug.event("fold-refold", { sid, foldedLen: slot.foldedLen, lcp, streamLen: ids.length });
3221
- slot = freshSlot(slot);
3229
+ const flip = isViewFlip(slot.foldedLen, lcp);
3230
+ debug.event("fold-refold", { sid, foldedLen: slot.foldedLen, lcp, streamLen: ids.length, flip });
3231
+ slot = flip ? preserveCompressedSlot(slot) : freshSlot(slot);
3222
3232
  slots.set(sid, slot);
3223
3233
  lcp = 0;
3224
3234
  }
@@ -3244,6 +3254,7 @@ function createRuntime(adapter) {
3244
3254
  debug.event("fold-replay-skipped", { sid, callId: call.id });
3245
3255
  continue;
3246
3256
  }
3257
+ if (slot.appliedCallIds.has(call.id) || stateHasCompressCall(slot.state, call.id)) continue;
3247
3258
  const stale = call.ranges.map((r, ri) => staleRange(r, ri, resultText, coreMessages, i, slot.state.messageRefs.byRef, slot.state.blocks)).find((s) => s !== false);
3248
3259
  if (stale) {
3249
3260
  debug.event("fold-replay-stale", { sid, callId: call.id, reason: stale });
@@ -4497,7 +4508,7 @@ async function statusReport(runtime, ctx) {
4497
4508
  const coveredIds = collectCoveredMessageIds(state);
4498
4509
  const sentTokens = estimateTokens(coreMessages, coveredIds) + systemPromptTokens;
4499
4510
  const turn = runtime.core.processTurn({ messages: coreMessages, state, config, tokenCount: sentTokens });
4500
- const versionStr = "0.2.0" ? `billion-context-omp@${"0.2.0"}` : void 0;
4511
+ const versionStr = "0.2.1" ? `billion-context-omp@${"0.2.1"}` : void 0;
4501
4512
  return buildStatusPanel({
4502
4513
  version: versionStr,
4503
4514
  tokenCount: sessionTokens,
@@ -5170,7 +5181,7 @@ async function checkForUpdate(autoUpdate, notify) {
5170
5181
  const data = await res.json();
5171
5182
  const latest = data.version;
5172
5183
  if (!latest) return;
5173
- const current = runtimeVersion ?? "0.2.0";
5184
+ const current = runtimeVersion ?? "0.2.1";
5174
5185
  const hasUpdate = isNewer(latest, current);
5175
5186
  debug.event("update-check", {
5176
5187
  current,
@@ -5486,7 +5497,7 @@ function wireCompactionDisable(pi, runtime) {
5486
5497
  function wireSessionLifecycle(pi, runtime) {
5487
5498
  pi.on("session_start", async (_event, ctx) => {
5488
5499
  const sid = ctx.sessionManager.getSessionId();
5489
- logInfo("session", { event: "start", sid, cwd: ctx.cwd, debug: runtime.adapter.debug ?? null, version: true ? "0.2.0" : null });
5500
+ logInfo("session", { event: "start", sid, cwd: ctx.cwd, debug: runtime.adapter.debug ?? null, version: true ? "0.2.1" : null });
5490
5501
  try {
5491
5502
  const user = await loadUserConfig(ctx.cwd);
5492
5503
  runtime.setAdapter(applyUserConfig(runtime.adapter, user));