billion-context-pi 0.1.60 → 0.1.61-pr.346.140

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
@@ -193,7 +193,7 @@ function formatRanges(compressible, protectedRanges) {
193
193
  if (compressible.length === 0 && protectedRanges.length === 0) {
194
194
  return "[No specific ranges detected \u2014 compress any consumed content.]";
195
195
  }
196
- const refNum2 = (ref) => {
196
+ const refNum = (ref) => {
197
197
  const m2 = ref.match(/\d+/);
198
198
  return m2 ? parseInt(m2[0], 10) : 0;
199
199
  };
@@ -202,8 +202,8 @@ function formatRanges(compressible, protectedRanges) {
202
202
  entries.push({
203
203
  startRef: r.startRef,
204
204
  endRef: r.endRef,
205
- startNum: refNum2(r.startRef),
206
- endNum: refNum2(r.endRef),
205
+ startNum: refNum(r.startRef),
206
+ endNum: refNum(r.endRef),
207
207
  count: r.count,
208
208
  tokens: r.tokens,
209
209
  toolPct: r.toolPct,
@@ -220,8 +220,8 @@ function formatRanges(compressible, protectedRanges) {
220
220
  entries.push({
221
221
  startRef: r.startRef,
222
222
  endRef: r.endRef,
223
- startNum: refNum2(r.startRef),
224
- endNum: refNum2(r.endRef),
223
+ startNum: refNum(r.startRef),
224
+ endNum: refNum(r.endRef),
225
225
  count: r.count,
226
226
  tokens: r.tokens,
227
227
  toolPct: 0,
@@ -1012,25 +1012,71 @@ var KEEP_LAST_ORPHANED = 2;
1012
1012
  function rangeKey(startRef, endRef) {
1013
1013
  return `${startRef}::${endRef}`;
1014
1014
  }
1015
- function rewriteCompressText(text, liveKeys) {
1015
+ function parseCallText(text) {
1016
+ const raw = text ?? "";
1017
+ const start = raw.indexOf("{");
1018
+ if (start < 0) return null;
1016
1019
  let parsed;
1017
1020
  try {
1018
- parsed = JSON.parse(text ?? "");
1021
+ parsed = JSON.parse(raw.slice(start));
1019
1022
  } catch {
1020
1023
  return null;
1021
1024
  }
1022
1025
  if (!parsed || typeof parsed !== "object") return null;
1023
1026
  const obj = parsed;
1024
- const content = obj.content;
1025
- if (!Array.isArray(content) || content.length === 0) return null;
1027
+ let content = null;
1028
+ let contentWasString = false;
1029
+ if (Array.isArray(obj.content)) {
1030
+ content = obj.content;
1031
+ } else if (typeof obj.content === "string") {
1032
+ contentWasString = true;
1033
+ try {
1034
+ const inner = JSON.parse(obj.content);
1035
+ if (Array.isArray(inner)) content = inner;
1036
+ } catch {
1037
+ content = null;
1038
+ }
1039
+ }
1040
+ if (!content || content.length === 0) return null;
1041
+ return { prefix: raw.slice(0, start), obj, content, contentWasString };
1042
+ }
1043
+ function rewriteCompressText(text, liveKeys) {
1044
+ const parsed = parseCallText(text);
1045
+ if (!parsed) return null;
1046
+ const { prefix, obj, content, contentWasString } = parsed;
1026
1047
  const kept = content.filter((entry) => {
1027
1048
  if (!entry || typeof entry !== "object") return false;
1028
- const s = typeof entry.startId === "string" ? entry.startId : typeof entry.messageId === "string" ? entry.messageId : "";
1029
- const e = typeof entry.endId === "string" ? entry.endId : typeof entry.messageId === "string" ? entry.messageId : "";
1030
- return liveKeys.has(rangeKey(s, e));
1049
+ const e = entry;
1050
+ const s = typeof e.startId === "string" ? e.startId : typeof e.messageId === "string" ? e.messageId : "";
1051
+ const end = typeof e.endId === "string" ? e.endId : typeof e.messageId === "string" ? e.messageId : "";
1052
+ return liveKeys.has(rangeKey(s, end));
1053
+ });
1054
+ if (kept.length === 0) return null;
1055
+ return prefix + serializeCompacted(obj, kept, contentWasString).text;
1056
+ }
1057
+ var SUMMARY_STUB_CHARS = 200;
1058
+ function compactEntry(entry) {
1059
+ if (!entry || typeof entry !== "object") return entry;
1060
+ const e = entry;
1061
+ if (typeof e.summary !== "string" || e.summary.length <= SUMMARY_STUB_CHARS) return entry;
1062
+ return { ...e, summary: `${e.summary.slice(0, SUMMARY_STUB_CHARS - 1)}\u2026` };
1063
+ }
1064
+ function serializeCompacted(obj, content, contentWasString) {
1065
+ let changed = false;
1066
+ const compacted = content.map((entry) => {
1067
+ const out = compactEntry(entry);
1068
+ if (out !== entry) changed = true;
1069
+ return out;
1031
1070
  });
1032
- if (kept.length === content.length || kept.length === 0) return null;
1033
- return JSON.stringify({ ...obj, content: kept });
1071
+ const outContent = contentWasString ? JSON.stringify(compacted) : compacted;
1072
+ return { text: JSON.stringify({ ...obj, content: outContent }), changed };
1073
+ }
1074
+ function compactCompressText(text) {
1075
+ const parsed = parseCallText(text);
1076
+ if (!parsed) return null;
1077
+ const { prefix, obj, content, contentWasString } = parsed;
1078
+ const { text: out, changed } = serializeCompacted(obj, content, contentWasString);
1079
+ return changed ? prefix + out : null;
1034
1080
  }
1035
1081
  function hideConsumedCompressCalls(state, messages) {
1036
1082
  const allBlockCallIds = /* @__PURE__ */ new Set();
@@ -1089,6 +1135,11 @@ function hideConsumedCompressCalls(state, messages) {
1089
1135
  continue;
1090
1136
  }
1091
1137
  }
1138
+ const compacted = compactCompressText(message.text);
1139
+ if (compacted !== null) {
1140
+ result.push({ ...message, text: compacted });
1141
+ continue;
1142
+ }
1092
1143
  }
1093
1144
  result.push(message);
1094
1145
  }
@@ -1609,10 +1660,6 @@ function adjustBoundariesForReasoningPairs(startIndex, endIndex, messages) {
1609
1660
  }
1610
1661
  return { startIndex: newStartIndex, endIndex: newEndIndex };
1611
1662
  }
1612
- function refNum(ref) {
1613
- const n = parseInt(ref.slice(1), 10);
1614
- return Number.isNaN(n) ? -1 : n;
1615
- }
1616
1663
  function estimateTextTokens(text) {
1617
1664
  return Math.ceil(text.length / 4);
1618
1665
  }
@@ -1665,42 +1712,50 @@ function buildCompressibleRanges(messages, state, config, protectedZoneRefs, cou
1665
1712
  const compressibleMsgs = [];
1666
1713
  const protectedMsgs = [];
1667
1714
  const protectedCallIds = collectProtectedToolCallIds(messages, config);
1715
+ let skipSinceCompressible = false;
1716
+ let skipSinceProtected = false;
1668
1717
  for (const msg of messages) {
1669
- if (isSyntheticOrPruned(msg, state)) continue;
1670
1718
  const ref = state.messageRefs.byRaw[msg.id];
1671
1719
  if (!ref || ref === "BLOCKED") continue;
1672
- const rn = refNum(ref);
1720
+ if (isSyntheticOrPruned(msg, state)) {
1721
+ skipSinceCompressible = true;
1722
+ skipSinceProtected = true;
1723
+ continue;
1724
+ }
1673
1725
  if (isMessageProtectedWithPairing(msg, config, protectedCallIds)) {
1674
1726
  protectedMsgs.push({
1675
1727
  ref,
1676
- refNum: rn,
1728
+ gapBefore: skipSinceProtected,
1677
1729
  tokens: countTokens(msg.text ?? ""),
1678
1730
  tools: msg.toolName ? [msg.toolName] : []
1679
1731
  });
1732
+ skipSinceProtected = false;
1733
+ skipSinceCompressible = true;
1680
1734
  continue;
1681
1735
  }
1682
1736
  if (protectedZoneRefs?.has(ref)) {
1737
+ skipSinceCompressible = true;
1738
+ skipSinceProtected = true;
1683
1739
  continue;
1684
1740
  }
1685
1741
  compressibleMsgs.push({
1686
1742
  ref,
1687
- refNum: rn,
1743
+ gapBefore: skipSinceCompressible,
1688
1744
  tokens: countTokens(msg.text ?? ""),
1689
1745
  chars: (msg.text ?? "").length,
1690
1746
  isTool: isToolMessage(msg),
1691
1747
  isUser: msg.role === "user"
1692
1748
  });
1749
+ skipSinceCompressible = false;
1750
+ skipSinceProtected = true;
1693
1751
  }
1694
1752
  const compressible = [];
1695
1753
  let cur = null;
1696
- let prevRefNum = -2;
1697
1754
  for (const info of compressibleMsgs) {
1698
- const hasGap = info.refNum > prevRefNum + 1;
1699
- if (cur && (info.isUser && cur.count >= 3 || hasGap)) {
1755
+ if (cur && (info.isUser && cur.count >= 3 || info.gapBefore)) {
1700
1756
  compressible.push(cur);
1701
1757
  cur = null;
1702
1758
  }
1703
- prevRefNum = info.refNum;
1704
1759
  if (!cur) {
1705
1760
  cur = {
1706
1761
  startRef: info.ref,
@@ -1727,14 +1782,11 @@ function buildCompressibleRanges(messages, state, config, protectedZoneRefs, cou
1727
1782
  if (cur) compressible.push(cur);
1728
1783
  const protectedRanges = [];
1729
1784
  let pcur = null;
1730
- let pPrevRefNum = -2;
1731
1785
  for (const info of protectedMsgs) {
1732
- const hasGap = info.refNum > pPrevRefNum + 1;
1733
- if (pcur && hasGap) {
1786
+ if (pcur && info.gapBefore) {
1734
1787
  protectedRanges.push(pcur);
1735
1788
  pcur = null;
1736
1789
  }
1737
- pPrevRefNum = info.refNum;
1738
1790
  if (!pcur) {
1739
1791
  pcur = {
1740
1792
  startRef: info.ref,
@@ -2904,7 +2956,7 @@ function renderUncompressedRanges(visible) {
2904
2956
  lines.push(" (no uncompressed messages)");
2905
2957
  return lines.join("\n");
2906
2958
  }
2907
- const refNum2 = (ref) => {
2959
+ const refNum = (ref) => {
2908
2960
  const m2 = ref.match(/\d+/);
2909
2961
  return m2 ? parseInt(m2[0], 10) : 0;
2910
2962
  };
@@ -2921,7 +2973,7 @@ function renderUncompressedRanges(visible) {
2921
2973
  };
2922
2974
  const merged = [];
2923
2975
  for (const m2 of visible) {
2924
- const num2 = refNum2(m2.ref);
2976
+ const num2 = refNum(m2.ref);
2925
2977
  const last = merged[merged.length - 1];
2926
2978
  if (last && num2 === last.startNum + last.count) {
2927
2979
  last.endRef = m2.ref;
@@ -3017,6 +3069,23 @@ function parseStringInput(raw, callId, diag) {
3017
3069
  diag.rawPrefix = raw.slice(0, 800);
3018
3070
  diag.length = raw.length;
3019
3071
  const cleaned = stripFence(raw.trim());
3072
+ const first = parseStringCore(cleaned, callId, diag);
3073
+ if (first.ranges.length === 0 || first.diagnostics.invalidItems > 0) {
3074
+ const normalized = normalizeSingleQuotes(cleaned);
3075
+ if (normalized !== void 0) {
3076
+ const retryDiag = { ok: false, kind: "ok", invalidItems: 0 };
3077
+ retryDiag.rawPrefix = diag.rawPrefix;
3078
+ retryDiag.length = diag.length;
3079
+ const retry = parseStringCore(normalized, callId, retryDiag);
3080
+ if (retry.ranges.length > first.ranges.length) {
3081
+ retryDiag.quoteSalvage = true;
3082
+ return retry;
3083
+ }
3084
+ }
3085
+ }
3086
+ return first;
3087
+ }
3088
+ function parseStringCore(cleaned, callId, diag) {
3020
3089
  if (cleaned === "") {
3021
3090
  diag.kind = "empty-input";
3022
3091
  return finish([], diag);
@@ -3060,6 +3129,7 @@ function parseObjectValue(value, callId, diag) {
3060
3129
  }
3061
3130
  entries = parsed.entries;
3062
3131
  salvaged = parsed.salvaged;
3132
+ if (parsed.quoteRepaired) diag.quoteSalvage = true;
3063
3133
  } else {
3064
3134
  diag.kind = "content-not-array";
3065
3135
  return finish([], diag);
@@ -3081,7 +3151,17 @@ function parseObjectValue(value, callId, diag) {
3081
3151
  }
3082
3152
  function parseContentArray(s) {
3083
3153
  const cleaned = stripFence(s.trim());
3084
- let value = cleaned === "" ? void 0 : tryParseLenient(cleaned);
3154
+ const direct = parseContentArrayCore(cleaned);
3155
+ if (direct !== null && direct.entries.length > 0) return direct;
3156
+ const normalized = normalizeSingleQuotes(cleaned);
3157
+ if (normalized !== void 0) {
3158
+ const retry = parseContentArrayCore(normalized);
3159
+ if (retry !== null && retry.entries.length > 0) return { ...retry, quoteRepaired: true };
3160
+ }
3161
+ return direct;
3162
+ }
3163
+ function parseContentArrayCore(s) {
3164
+ let value = s === "" ? void 0 : tryParseLenient(s);
3085
3165
  if (typeof value === "string") {
3086
3166
  value = tryParseLenient(stripFence(value));
3087
3167
  }
@@ -3089,7 +3169,7 @@ function parseContentArray(s) {
3089
3169
  return { entries: value, salvaged: false };
3090
3170
  }
3091
3171
  if (value === void 0) {
3092
- const entries = salvageContentEntries('{"content": ' + cleaned);
3172
+ const entries = salvageContentEntries('{"content": ' + s);
3093
3173
  return { entries, salvaged: entries.length > 0 };
3094
3174
  }
3095
3175
  return null;
@@ -3162,6 +3242,71 @@ function tryParseLenient(s) {
3162
3242
  }
3163
3243
  return void 0;
3164
3244
  }
3245
+ function normalizeSingleQuotes(raw) {
3246
+ if (!raw.includes("'") || !raw.includes("{") && !raw.includes("[")) return void 0;
3247
+ let out = "";
3248
+ let changed = false;
3249
+ let inDouble = false;
3250
+ let inSingle = false;
3251
+ for (let i = 0; i < raw.length; i++) {
3252
+ const ch = raw.charAt(i);
3253
+ if (inDouble) {
3254
+ out += ch;
3255
+ if (ch === "\\" && i + 1 < raw.length) {
3256
+ out += raw.charAt(i + 1);
3257
+ i++;
3258
+ } else if (ch === '"') {
3259
+ inDouble = false;
3260
+ }
3261
+ continue;
3262
+ }
3263
+ if (inSingle) {
3264
+ if (ch === "\\" && i + 1 < raw.length) {
3265
+ const next = raw.charAt(i + 1);
3266
+ out += next === "'" ? "'" : "\\" + next;
3267
+ i++;
3268
+ continue;
3269
+ }
3270
+ if (ch === "'") {
3271
+ out += '"';
3272
+ inSingle = false;
3273
+ changed = true;
3274
+ continue;
3275
+ }
3276
+ if (ch === '"') {
3277
+ out += '\\"';
3278
+ continue;
3279
+ }
3280
+ if (ch === "\n") {
3281
+ out += "\\n";
3282
+ continue;
3283
+ }
3284
+ if (ch === "\r") {
3285
+ out += "\\r";
3286
+ continue;
3287
+ }
3288
+ if (ch === " ") {
3289
+ out += "\\t";
3290
+ continue;
3291
+ }
3292
+ out += ch;
3293
+ continue;
3294
+ }
3295
+ if (ch === '"') {
3296
+ inDouble = true;
3297
+ out += ch;
3298
+ continue;
3299
+ }
3300
+ if (ch === "'") {
3301
+ inSingle = true;
3302
+ out += '"';
3303
+ changed = true;
3304
+ continue;
3305
+ }
3306
+ out += ch;
3307
+ }
3308
+ return changed ? out : void 0;
3309
+ }
3165
3310
  function stripFence(s) {
3166
3311
  if (!s.startsWith("```")) return s;
3167
3312
  const firstNewline = s.indexOf("\n");
@@ -3999,6 +4144,10 @@ function safeStringify(value) {
3999
4144
  function coreOutToAgentMessages(coreOut, originalById) {
4000
4145
  const out = [];
4001
4146
  const emittedSplit = /* @__PURE__ */ new Set();
4147
+ const kernelTextByCallId = /* @__PURE__ */ new Map();
4148
+ for (const core of coreOut) {
4149
+ if (core.toolCallId && core.text) kernelTextByCallId.set(core.toolCallId, core.text);
4150
+ }
4002
4151
  for (const core of coreOut) {
4003
4152
  if (core.id.startsWith("acp_summary_")) continue;
4004
4153
  const hashIdx = core.id.indexOf("#");
@@ -4015,11 +4164,37 @@ function coreOutToAgentMessages(coreOut, originalById) {
4015
4164
  const survivingCallIds = new Set(
4016
4165
  coreOut.filter((c) => c.id.startsWith(`${baseId}#`) && !c.id.startsWith("acp_summary_")).map((c) => c.toolCallId).filter((id) => !!id)
4017
4166
  );
4018
- out.push(reconstructToolCallMessage(original, core, survivingCallIds));
4167
+ out.push(reconstructToolCallMessage(original, core, survivingCallIds, kernelTextByCallId));
4019
4168
  }
4020
4169
  return out;
4021
4170
  }
4022
- function reconstructToolCallMessage(original, firstCore, survivingCallIds) {
4171
+ function compactedArgsFrom(kernelText, originalArgs) {
4172
+ if (!kernelText) return null;
4173
+ const start = kernelText.indexOf("{");
4174
+ if (start < 0) return null;
4175
+ let parsed;
4176
+ try {
4177
+ parsed = JSON.parse(kernelText.slice(start));
4178
+ } catch {
4179
+ return null;
4180
+ }
4181
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return null;
4182
+ if (safeStringify(parsed) === safeStringify(originalArgs)) return null;
4183
+ return parsed;
4184
+ }
4185
+ function syncToolCallArgs(blocks, kernelTextFor) {
4186
+ let changed = false;
4187
+ const out = blocks.map((block) => {
4188
+ const b2 = block;
4189
+ if (b2.type !== "toolCall" || !b2.id) return block;
4190
+ const compacted = compactedArgsFrom(kernelTextFor(b2.id), b2.arguments);
4191
+ if (compacted === null) return block;
4192
+ changed = true;
4193
+ return { ...b2, arguments: compacted };
4194
+ });
4195
+ return changed ? out : blocks;
4196
+ }
4197
+ function reconstructToolCallMessage(original, firstCore, survivingCallIds, kernelTextByCallId) {
4023
4198
  const base = original;
4024
4199
  const match = firstCore.text ? firstCore.text.match(REF_TAG) : null;
4025
4200
  const tag = match ? match[0] : null;
@@ -4030,7 +4205,10 @@ function reconstructToolCallMessage(original, firstCore, survivingCallIds) {
4030
4205
  if (b2.type === "toolCall") return survivingCallIds.has(b2.id ?? "");
4031
4206
  return true;
4032
4207
  });
4033
- const peeled2 = peelRefTagBlocks(filtered2);
4208
+ const peeled2 = syncToolCallArgs(
4209
+ peelRefTagBlocks(filtered2),
4210
+ (callId) => kernelTextByCallId.get(callId)
4211
+ );
4034
4212
  return { ...original, content: peeled2 };
4035
4213
  }
4036
4214
  const rawBlocks = Array.isArray(base.content) ? base.content : typeof base.content === "string" ? [{ type: "text", text: base.content }] : [];
@@ -4039,7 +4217,10 @@ function reconstructToolCallMessage(original, firstCore, survivingCallIds) {
4039
4217
  if (b2.type === "toolCall") return survivingCallIds.has(b2.id ?? "");
4040
4218
  return true;
4041
4219
  });
4042
- const peeled = peelRefTagBlocks(filtered);
4220
+ const peeled = syncToolCallArgs(
4221
+ peelRefTagBlocks(filtered),
4222
+ (callId) => kernelTextByCallId.get(callId)
4223
+ );
4043
4224
  const stableTag = rewriteTagTokens(tag, coreBodyOf(firstCore.text ?? "", tag));
4044
4225
  const lastTextIdx = [...peeled].reverse().findIndex((b2) => b2.type === "text");
4045
4226
  if (lastTextIdx >= 0) {
@@ -4060,11 +4241,23 @@ function coreBodyOf(coreText, tag) {
4060
4241
  return coreText.slice(bodyStart);
4061
4242
  }
4062
4243
  function patchRefTag(original, core) {
4244
+ const base = original;
4245
+ if (base.role === "assistant") {
4246
+ if (core.contentType === "tool-call" && core.toolCallId) {
4247
+ const rawBlocks2 = Array.isArray(base.content) ? base.content : [];
4248
+ const synced = syncToolCallArgs(
4249
+ rawBlocks2,
4250
+ (callId) => callId === core.toolCallId ? core.text : void 0
4251
+ );
4252
+ if (synced !== rawBlocks2) {
4253
+ return { ...original, content: synced };
4254
+ }
4255
+ }
4256
+ return original;
4257
+ }
4063
4258
  const match = core.text ? core.text.match(REF_TAG) : null;
4064
4259
  const tag = match ? match[0] : null;
4065
4260
  if (!tag) return original;
4066
- const base = original;
4067
- if (base.role === "assistant") return original;
4068
4261
  const coreBody = coreBodyOf(core.text ?? "", tag);
4069
4262
  const originalBody = extractText(base.content);
4070
4263
  const trimEnd = (s) => s.replace(/\s+$/, "");
@@ -9731,6 +9924,21 @@ function tier3OnlyRewrite(newBlocks, allBlocks) {
9731
9924
  }
9732
9925
  return spans;
9733
9926
  }
9927
+ function tierReadyHint(state, config) {
9928
+ if (!config.tiers.enabled) return "";
9929
+ const active = state.blocks.filter((b2) => b2.active);
9930
+ const first = (bs) => bs[0]?.blockId ?? "";
9931
+ const last = (bs) => bs[bs.length - 1]?.blockId ?? "";
9932
+ const t2 = active.filter((b2) => b2.tier === 2);
9933
+ if (t2.length >= config.tiers.tier3Trigger) {
9934
+ return `Actionable now: condense tier-2 blocks ${first(t2)}..${last(t2)} into a single tier-3 block (compress({ content: [{ startId: "${first(t2)}", endId: "${last(t2)}", summary: "..." }] })).`;
9935
+ }
9936
+ const t1 = active.filter((b2) => b2.tier === 1);
9937
+ if (t1.length >= config.tiers.tier2Trigger) {
9938
+ return `Actionable now: distill tier-1 blocks ${first(t1)}..${last(t1)} into a single tier-2 block (compress({ content: [{ startId: "${first(t1)}", endId: "${last(t1)}", summary: "..." }] })).`;
9939
+ }
9940
+ return "";
9941
+ }
9734
9942
  async function handleCompress(args, runtime, ctx, toolCallId) {
9735
9943
  const maybeRanges = normalizeRanges(args);
9736
9944
  if (typeof maybeRanges === "string") throw new Error(maybeRanges);
@@ -9801,8 +10009,9 @@ async function handleCompress(args, runtime, ctx, toolCallId) {
9801
10009
  event: "tier3-rewrite-rejected",
9802
10010
  spans: rewriteSpans
9803
10011
  });
10012
+ const hint = tierReadyHint(state, config);
9804
10013
  throw new Error(
9805
- `Range ${rewriteSpans.join(", ")} only re-condenses terminal tier-3 block(s) \u2014 T3 is the highest tier, so rewriting it reclaims nothing and can repeat forever (dog/billion-context-pi#3). Nothing was compressed. Use search_context or decompress to retrieve details, or pick a range containing uncompressed messages (acp_status lists compressible ranges).`
10014
+ `Range ${rewriteSpans.join(", ")} only re-condenses terminal tier-3 block(s) \u2014 T3 is the highest tier, so rewriting it reclaims nothing and can repeat forever (dog/billion-context-pi#3). Nothing was compressed. ` + (hint ? `${hint} ` : "") + `Use search_context or decompress to retrieve details, or pick a range containing uncompressed messages (acp_status lists compressible ranges).`
9806
10015
  );
9807
10016
  }
9808
10017
  await runtime.save(applied.state, ctx);
@@ -16540,7 +16749,7 @@ async function statusReport(runtime, ctx) {
16540
16749
  const sentTokens = estimateTokens(coreMessages, coveredIds, imageTokens) + systemPromptTokens;
16541
16750
  const viewSentTokens = adjustedTokenCount(runtime.core, coreMessages, state, config, sentTokens, imageTokens, systemPromptTokens);
16542
16751
  const turn = runtime.core.processTurn({ messages: coreMessages, state, config, tokenCount: anchorStale ? viewSentTokens : Math.max(viewSentTokens, realUsage?.tokens ?? 0) });
16543
- const versionStr = "0.1.60" ? `billion-context-pi@${"0.1.60"}` : void 0;
16752
+ const versionStr = "0.1.61" ? `billion-context-pi@${"0.1.61"}` : void 0;
16544
16753
  let text = buildStatusPanel({
16545
16754
  version: versionStr,
16546
16755
  tokenCount: sessionTokens,
@@ -17074,7 +17283,7 @@ async function autoInstallLatest(latest, extDirOverride) {
17074
17283
  "--no-fund",
17075
17284
  "--no-save"
17076
17285
  ];
17077
- const prevVersion = (await readPackageJson(join11(extDir, "package.json")))?.version ?? "0.1.60";
17286
+ const prevVersion = (await readPackageJson(join11(extDir, "package.json")))?.version ?? "0.1.61";
17078
17287
  const { code, stderr } = await runNpmImpl(installArgs(latest), { cwd: npmDir, timeout: 6e4 });
17079
17288
  if (code !== 0) {
17080
17289
  logWarn("update", {
@@ -17092,7 +17301,7 @@ async function autoInstallLatest(latest, extDirOverride) {
17092
17301
  }
17093
17302
  const verify = await verifyInstall(npmDir, latest);
17094
17303
  if (!verify.ok) {
17095
- const rollbackTo = SEMVER_RE.test(prevVersion) ? prevVersion : "0.1.60";
17304
+ const rollbackTo = SEMVER_RE.test(prevVersion) ? prevVersion : "0.1.61";
17096
17305
  logWarn("update", { event: "auto-install-verify-failed", latest, reason: verify.reason, rollbackTo });
17097
17306
  const rb = await runNpmImpl(installArgs(rollbackTo), { cwd: npmDir, timeout: 6e4 });
17098
17307
  logInfo("update", { event: "rollback", from: latest, to: rollbackTo, ok: rb.code === 0 });
@@ -17167,7 +17376,7 @@ async function checkForUpdate(autoUpdate, notify) {
17167
17376
  }
17168
17377
  const latest = await fetchLatestVersion(tag);
17169
17378
  if (!latest) return;
17170
- const current = runtimeVersion ?? "0.1.60";
17379
+ const current = runtimeVersion ?? "0.1.61";
17171
17380
  const hasUpdate = isVersionNewer(latest, current);
17172
17381
  debug.event("update-check", {
17173
17382
  current,
@@ -17345,7 +17554,7 @@ function wireSessionLifecycle(pi, runtime, standDownIfProxied) {
17345
17554
  setDelegatePolicy(DEFAULT_DELEGATE_POLICY);
17346
17555
  const sid = ctx.sessionManager.getSessionId();
17347
17556
  const modelInfo = ctx.model;
17348
- logInfo("session", { event: "start", sid, cwd: ctx.cwd, debug: runtime.adapter.debug ?? null, version: true ? "0.1.60" : null, model: modelInfo?.id ?? null, modelApi: modelInfo?.api ?? null, contextWindow: modelInfo?.contextWindow ?? null });
17557
+ logInfo("session", { event: "start", sid, cwd: ctx.cwd, debug: runtime.adapter.debug ?? null, version: true ? "0.1.61" : null, model: modelInfo?.id ?? null, modelApi: modelInfo?.api ?? null, contextWindow: modelInfo?.contextWindow ?? null });
17349
17558
  try {
17350
17559
  await runtime.reloadConfig(ctx.cwd);
17351
17560
  const delegateCfg = resolveDelegate(runtime.adapter);