opencode-acp 1.14.25-pr.348.70 → 1.14.25-pr.348.74
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
|
@@ -4330,7 +4330,8 @@ function createSessionState() {
|
|
|
4330
4330
|
systemPromptTokens: void 0,
|
|
4331
4331
|
qualityGateRetryPending: false,
|
|
4332
4332
|
uncalibratedWindowTransforms: 0,
|
|
4333
|
-
uncalibratedWindowWarned: false
|
|
4333
|
+
uncalibratedWindowWarned: false,
|
|
4334
|
+
overflowGuardStuckLogged: false
|
|
4334
4335
|
};
|
|
4335
4336
|
}
|
|
4336
4337
|
function resetSessionState(state) {
|
|
@@ -4374,6 +4375,7 @@ function resetSessionState(state) {
|
|
|
4374
4375
|
state.qualityGateRetryPending = false;
|
|
4375
4376
|
state.uncalibratedWindowTransforms = 0;
|
|
4376
4377
|
state.uncalibratedWindowWarned = false;
|
|
4378
|
+
state.overflowGuardStuckLogged = false;
|
|
4377
4379
|
}
|
|
4378
4380
|
async function ensureSessionInitialized(client, state, sessionId, logger, messages, config) {
|
|
4379
4381
|
if (state.sessionId === sessionId) {
|
|
@@ -7378,13 +7380,49 @@ function resolveKnownWindow(config, state, providerId, modelId) {
|
|
|
7378
7380
|
function estimateWireTokens(state, messages) {
|
|
7379
7381
|
const base = getCurrentTokenUsage(state, messages);
|
|
7380
7382
|
if (base > 0) {
|
|
7381
|
-
|
|
7383
|
+
let lastAsstIdx = -1;
|
|
7384
|
+
for (let i = messages.length - 1; i >= 0; i--) {
|
|
7385
|
+
if (messages[i].info.role === "assistant") {
|
|
7386
|
+
lastAsstIdx = i;
|
|
7387
|
+
break;
|
|
7388
|
+
}
|
|
7389
|
+
}
|
|
7390
|
+
if (lastAsstIdx >= 0 && hasCompletedCompressPart(messages[lastAsstIdx])) {
|
|
7391
|
+
return preciseWireTokens(state, messages);
|
|
7392
|
+
}
|
|
7393
|
+
let trailing = 0;
|
|
7394
|
+
if (lastAsstIdx >= 0) {
|
|
7395
|
+
const parts = Array.isArray(messages[lastAsstIdx].parts) ? messages[lastAsstIdx].parts : [];
|
|
7396
|
+
for (let i = parts.length - 1; i >= 0; i--) {
|
|
7397
|
+
const p = parts[i];
|
|
7398
|
+
if (p?.type !== "tool") break;
|
|
7399
|
+
if (p.state.status !== "completed") break;
|
|
7400
|
+
trailing += countTokens2(extractCompletedToolOutput(p) ?? "");
|
|
7401
|
+
}
|
|
7402
|
+
}
|
|
7403
|
+
let afterLastAsst = 0;
|
|
7404
|
+
for (let i = lastAsstIdx + 1; i < messages.length; i++) {
|
|
7405
|
+
afterLastAsst += countAllMessageTokens(messages[i]);
|
|
7406
|
+
}
|
|
7407
|
+
return base + trailing + afterLastAsst + WIRE_SAFETY_MARGIN;
|
|
7382
7408
|
}
|
|
7383
|
-
|
|
7409
|
+
return preciseWireTokens(state, messages);
|
|
7410
|
+
}
|
|
7411
|
+
function preciseWireTokens(state, messages) {
|
|
7412
|
+
let total = state.systemPromptTokens ?? 0;
|
|
7384
7413
|
for (const msg of messages) {
|
|
7385
7414
|
total += countAllMessageTokens(msg);
|
|
7386
7415
|
}
|
|
7387
|
-
return total +
|
|
7416
|
+
return total + WIRE_SAFETY_MARGIN;
|
|
7417
|
+
}
|
|
7418
|
+
function hasCompletedCompressPart(message) {
|
|
7419
|
+
const parts = Array.isArray(message.parts) ? message.parts : [];
|
|
7420
|
+
for (const p of parts) {
|
|
7421
|
+
if (p?.type === "tool" && p.tool === "compress" && p.state.status === "completed") {
|
|
7422
|
+
return true;
|
|
7423
|
+
}
|
|
7424
|
+
}
|
|
7425
|
+
return false;
|
|
7388
7426
|
}
|
|
7389
7427
|
function pruneToFit(state, config, logger, messages) {
|
|
7390
7428
|
if (!config.compress.overflowGuard) return;
|
|
@@ -7394,7 +7432,10 @@ function pruneToFit(state, config, logger, messages) {
|
|
|
7394
7432
|
const safeBudget = knownWindow - reserve;
|
|
7395
7433
|
if (safeBudget <= 0) return;
|
|
7396
7434
|
const estimate = estimateWireTokens(state, messages);
|
|
7397
|
-
if (estimate <= safeBudget)
|
|
7435
|
+
if (estimate <= safeBudget) {
|
|
7436
|
+
state.overflowGuardStuckLogged = false;
|
|
7437
|
+
return;
|
|
7438
|
+
}
|
|
7398
7439
|
const protectedRefs = computeProtectedRefs(messages, state, config.compress);
|
|
7399
7440
|
const lastNonIgnored = findLastNonIgnoredMessage(messages);
|
|
7400
7441
|
const lastMsgId = lastNonIgnored?.message.info.id;
|
|
@@ -7430,7 +7471,6 @@ function pruneToFit(state, config, logger, messages) {
|
|
|
7430
7471
|
clearedCount++;
|
|
7431
7472
|
}
|
|
7432
7473
|
}
|
|
7433
|
-
if (clearedCount === 0) return;
|
|
7434
7474
|
const after = estimate - freed;
|
|
7435
7475
|
const detail = {
|
|
7436
7476
|
session: state.sessionId,
|
|
@@ -7442,6 +7482,13 @@ function pruneToFit(state, config, logger, messages) {
|
|
|
7442
7482
|
freedTokens: Math.round(freed),
|
|
7443
7483
|
afterTokens: Math.round(after)
|
|
7444
7484
|
};
|
|
7485
|
+
if (clearedCount === 0) {
|
|
7486
|
+
if (!state.overflowGuardStuckLogged) {
|
|
7487
|
+
state.overflowGuardStuckLogged = true;
|
|
7488
|
+
logger.error("ACP overflow guard: over window but no clearable tool outputs", detail);
|
|
7489
|
+
}
|
|
7490
|
+
return;
|
|
7491
|
+
}
|
|
7445
7492
|
if (after <= safeBudget) {
|
|
7446
7493
|
logger.warn("ACP overflow guard: cleared tool outputs to fit context window", detail);
|
|
7447
7494
|
} else {
|
|
@@ -9258,7 +9305,7 @@ import { writeFile as writeFile2, mkdir as mkdir2 } from "fs/promises";
|
|
|
9258
9305
|
import { join as join3 } from "path";
|
|
9259
9306
|
import { existsSync as existsSync3 } from "fs";
|
|
9260
9307
|
import { homedir as homedir3 } from "os";
|
|
9261
|
-
var LOG_VERSION = true ? "1.14.25-pr.348.
|
|
9308
|
+
var LOG_VERSION = true ? "1.14.25-pr.348.74" : "dev";
|
|
9262
9309
|
var LEVEL_RANK = {
|
|
9263
9310
|
debug: 10,
|
|
9264
9311
|
info: 20,
|
|
@@ -11701,7 +11748,7 @@ var server = (async (ctx) => {
|
|
|
11701
11748
|
}
|
|
11702
11749
|
const logger = new Logger(config.debug, config.debug ? "debug" : config.logLevel);
|
|
11703
11750
|
logger.info("ACP plugin initialized", {
|
|
11704
|
-
version: true ? "1.14.25-pr.348.
|
|
11751
|
+
version: true ? "1.14.25-pr.348.74" : "dev",
|
|
11705
11752
|
workspace: ctx.directory,
|
|
11706
11753
|
logLevel: logger.level,
|
|
11707
11754
|
debug: config.debug,
|