opencode-acp 1.14.25-pr.348.70 → 1.14.25-pr.348.72

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
@@ -7378,7 +7378,18 @@ function resolveKnownWindow(config, state, providerId, modelId) {
7378
7378
  function estimateWireTokens(state, messages) {
7379
7379
  const base = getCurrentTokenUsage(state, messages);
7380
7380
  if (base > 0) {
7381
- return base + WIRE_SAFETY_MARGIN;
7381
+ let trailing = 0;
7382
+ const lastAsst = [...messages].reverse().find((m) => m.info.role === "assistant");
7383
+ if (lastAsst) {
7384
+ const parts = Array.isArray(lastAsst.parts) ? lastAsst.parts : [];
7385
+ for (let i = parts.length - 1; i >= 0; i--) {
7386
+ const p = parts[i];
7387
+ if (p?.type !== "tool") break;
7388
+ if (p.state.status !== "completed") break;
7389
+ trailing += countTokens2(extractCompletedToolOutput(p) ?? "");
7390
+ }
7391
+ }
7392
+ return base + trailing + WIRE_SAFETY_MARGIN;
7382
7393
  }
7383
7394
  let total = 0;
7384
7395
  for (const msg of messages) {
@@ -7430,7 +7441,6 @@ function pruneToFit(state, config, logger, messages) {
7430
7441
  clearedCount++;
7431
7442
  }
7432
7443
  }
7433
- if (clearedCount === 0) return;
7434
7444
  const after = estimate - freed;
7435
7445
  const detail = {
7436
7446
  session: state.sessionId,
@@ -7442,6 +7452,10 @@ function pruneToFit(state, config, logger, messages) {
7442
7452
  freedTokens: Math.round(freed),
7443
7453
  afterTokens: Math.round(after)
7444
7454
  };
7455
+ if (clearedCount === 0) {
7456
+ logger.error("ACP overflow guard: over window but no clearable tool outputs", detail);
7457
+ return;
7458
+ }
7445
7459
  if (after <= safeBudget) {
7446
7460
  logger.warn("ACP overflow guard: cleared tool outputs to fit context window", detail);
7447
7461
  } else {
@@ -9258,7 +9272,7 @@ import { writeFile as writeFile2, mkdir as mkdir2 } from "fs/promises";
9258
9272
  import { join as join3 } from "path";
9259
9273
  import { existsSync as existsSync3 } from "fs";
9260
9274
  import { homedir as homedir3 } from "os";
9261
- var LOG_VERSION = true ? "1.14.25-pr.348.70" : "dev";
9275
+ var LOG_VERSION = true ? "1.14.25-pr.348.72" : "dev";
9262
9276
  var LEVEL_RANK = {
9263
9277
  debug: 10,
9264
9278
  info: 20,
@@ -11701,7 +11715,7 @@ var server = (async (ctx) => {
11701
11715
  }
11702
11716
  const logger = new Logger(config.debug, config.debug ? "debug" : config.logLevel);
11703
11717
  logger.info("ACP plugin initialized", {
11704
- version: true ? "1.14.25-pr.348.70" : "dev",
11718
+ version: true ? "1.14.25-pr.348.72" : "dev",
11705
11719
  workspace: ctx.directory,
11706
11720
  logLevel: logger.level,
11707
11721
  debug: config.debug,