billion-context-pi 0.1.72 → 0.1.73-pr.474.271

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
@@ -12123,7 +12123,7 @@ function resolveActivePack(adapter, cwd, provider, modelId, resolver) {
12123
12123
  }
12124
12124
  var HOST_VERSION = (() => {
12125
12125
  try {
12126
- return "0.1.72";
12126
+ return "0.1.73";
12127
12127
  } catch {
12128
12128
  return "dev";
12129
12129
  }
@@ -18868,7 +18868,7 @@ async function statusReport(runtime, ctx) {
18868
18868
  const sentTokens = estimateTokens(coreMessages, coveredIds, imageTokens) + systemPromptTokens;
18869
18869
  const viewSentTokens = adjustedTokenCount(runtime.core, coreMessages, state, config, sentTokens, imageTokens, systemPromptTokens);
18870
18870
  const turn = runtime.core.processTurn({ messages: coreMessages, state, config, tokenCount: anchorStale ? viewSentTokens : Math.max(viewSentTokens, realUsage?.tokens ?? 0) });
18871
- const versionStr = "0.1.72" ? `billion-context-pi@${"0.1.72"} \xB7 pack: ${resolveSurfaceMeta(runtime.adapter, ctx?.cwd ?? process.cwd(), ctx?.model?.provider, ctx?.model?.id).pack}` : void 0;
18871
+ const versionStr = "0.1.73" ? `billion-context-pi@${"0.1.73"} \xB7 pack: ${resolveSurfaceMeta(runtime.adapter, ctx?.cwd ?? process.cwd(), ctx?.model?.provider, ctx?.model?.id).pack}` : void 0;
18872
18872
  let text = buildStatusPanel({
18873
18873
  version: versionStr,
18874
18874
  tokenCount: sessionTokens,
@@ -18889,6 +18889,61 @@ async function statusReport(runtime, ctx) {
18889
18889
  return text;
18890
18890
  }
18891
18891
 
18892
+ // src/live-only-tail.ts
18893
+ var MAX_LIVE_ONLY_TAIL = 8;
18894
+ function sigText(content) {
18895
+ if (typeof content === "string") return content;
18896
+ if (!Array.isArray(content)) return "";
18897
+ const parts = [];
18898
+ for (const block of content) {
18899
+ const b2 = block;
18900
+ if (b2?.type === "text" && typeof b2.text === "string") parts.push(b2.text);
18901
+ }
18902
+ return parts.join("\n");
18903
+ }
18904
+ function weakMessageSig(message) {
18905
+ const m2 = message ?? {};
18906
+ const role = typeof m2.role === "string" ? m2.role : "";
18907
+ const customType = typeof m2.customType === "string" ? m2.customType : "";
18908
+ const toolCallId = typeof m2.toolCallId === "string" ? m2.toolCallId : "";
18909
+ const text = sigText(m2.content);
18910
+ return [role, customType, toolCallId, String(text.length), text.slice(0, 32), text.length > 32 ? text.slice(-32) : ""].join("\0");
18911
+ }
18912
+ function entryAsLiveShape(entry) {
18913
+ if (entry.type === "message") {
18914
+ const msg = entry.message;
18915
+ return { role: msg.role, customType: msg.customType, toolCallId: msg.toolCallId, content: msg.content };
18916
+ }
18917
+ if (entry.type === "custom_message") {
18918
+ return { role: "custom", customType: entry.customType, content: entry.content };
18919
+ }
18920
+ return void 0;
18921
+ }
18922
+ function liveOnlyTail(entries, live) {
18923
+ const persisted = entries.filter((e) => e.type === "message" || e.type === "custom_message").map((e) => entryAsLiveShape(e)).filter((shape) => shape !== void 0);
18924
+ const max = Math.min(persisted.length, live.length);
18925
+ let i = 0;
18926
+ while (i < max && weakMessageSig(persisted[i]) === weakMessageSig(live[i])) i++;
18927
+ if (i === max) {
18928
+ const tail = live.slice(max);
18929
+ return tail.length > 0 && tail.length <= MAX_LIVE_ONLY_TAIL ? tail : null;
18930
+ }
18931
+ if (i === max - 1 && i === persisted.length - 1 && i === live.length - 1) {
18932
+ const liveMsg = live[i];
18933
+ if (liveMsg && typeof liveMsg.role === "string" && liveMsg.role === "user") {
18934
+ const before = sigText(persisted[i]?.content);
18935
+ const after = sigText(liveMsg.content);
18936
+ if (before && after && after.startsWith(before)) {
18937
+ const suffix = after.slice(before.length).trim();
18938
+ if (suffix.length > 0) {
18939
+ return [{ role: "user", content: [{ type: "text", text: suffix }], timestamp: Date.now() }];
18940
+ }
18941
+ }
18942
+ }
18943
+ }
18944
+ return null;
18945
+ }
18946
+
18892
18947
  // src/degeneration.ts
18893
18948
  var DEFAULT_DEGENERATION_GUARD = { enabled: true, minRun: 200 };
18894
18949
  var MIN_VALID_MIN_RUN = 8;
@@ -19480,7 +19535,7 @@ async function autoInstallLatest(latest, extDirOverride) {
19480
19535
  "--no-fund",
19481
19536
  "--no-save"
19482
19537
  ];
19483
- const prevVersion = (await readPackageJson(join15(extDir, "package.json")))?.version ?? "0.1.72";
19538
+ const prevVersion = (await readPackageJson(join15(extDir, "package.json")))?.version ?? "0.1.73";
19484
19539
  const { code, stderr } = await runNpmImpl(installArgs(latest), { cwd: npmDir, timeout: 6e4 });
19485
19540
  if (code !== 0) {
19486
19541
  logWarn("update", {
@@ -19498,7 +19553,7 @@ async function autoInstallLatest(latest, extDirOverride) {
19498
19553
  }
19499
19554
  const verify = await verifyInstall(npmDir, latest);
19500
19555
  if (!verify.ok) {
19501
- const rollbackTo = SEMVER_RE.test(prevVersion) ? prevVersion : "0.1.72";
19556
+ const rollbackTo = SEMVER_RE.test(prevVersion) ? prevVersion : "0.1.73";
19502
19557
  logWarn("update", { event: "auto-install-verify-failed", latest, reason: verify.reason, rollbackTo });
19503
19558
  const rb = await runNpmImpl(installArgs(rollbackTo), { cwd: npmDir, timeout: 6e4 });
19504
19559
  logInfo("update", { event: "rollback", from: latest, to: rollbackTo, ok: rb.code === 0 });
@@ -19573,7 +19628,7 @@ async function checkForUpdate(autoUpdate, notify) {
19573
19628
  }
19574
19629
  const latest = await fetchLatestVersion(tag);
19575
19630
  if (!latest) return;
19576
- const current = runtimeVersion ?? "0.1.72";
19631
+ const current = runtimeVersion ?? "0.1.73";
19577
19632
  const hasUpdate = isVersionNewer(latest, current);
19578
19633
  debug.event("update-check", {
19579
19634
  current,
@@ -19775,7 +19830,7 @@ function wireSessionLifecycle(pi, runtime, standDownIfProxied) {
19775
19830
  setDelegatePolicy(DEFAULT_DELEGATE_POLICY);
19776
19831
  const sid = ctx.sessionManager.getSessionId();
19777
19832
  const modelInfo = ctx.model;
19778
- logInfo("session", { event: "start", sid, cwd: ctx.cwd, debug: runtime.adapter.debug ?? null, version: true ? "0.1.72" : null, model: modelInfo?.id ?? null, modelApi: modelInfo?.api ?? null, contextWindow: modelInfo?.contextWindow ?? null });
19833
+ logInfo("session", { event: "start", sid, cwd: ctx.cwd, debug: runtime.adapter.debug ?? null, version: true ? "0.1.73" : null, model: modelInfo?.id ?? null, modelApi: modelInfo?.api ?? null, contextWindow: modelInfo?.contextWindow ?? null });
19779
19834
  let delegateStoodDown = false;
19780
19835
  try {
19781
19836
  await runtime.reloadConfig(ctx.cwd);
@@ -20031,6 +20086,11 @@ ${rendered.text}${example}`);
20031
20086
  ctx.ui.notify(`[ACP] compress failed ${outcome.count}\xD7 this turn \u2014 nudge paused until the next user message (emergency truncation still active).`);
20032
20087
  }
20033
20088
  }
20089
+ const liveTail = liveOnlyTail(entries, event.messages);
20090
+ if (liveTail && liveTail.length > 0) {
20091
+ rebuilt.push(...liveTail);
20092
+ logInfo("live-only-tail", { sid, event: "appended", tail: liveTail.length, outMsgs: rebuilt.length });
20093
+ }
20034
20094
  debug.event("context-out", { outMsgs: rebuilt.length, injected: turn.nudge?.shouldInject ?? false, emergency: turn.nudge?.breakdown?.emergencyOverride === 1 });
20035
20095
  const updateCheck = checkForUpdate(runtime.adapter.autoUpdate ?? true, (msg) => {
20036
20096
  if (ctx.hasUI) ctx.ui.notify(msg);