opencode-acp 1.14.25-pr.348.72 → 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,10 +7380,19 @@ function resolveKnownWindow(config, state, providerId, modelId) {
|
|
|
7378
7380
|
function estimateWireTokens(state, messages) {
|
|
7379
7381
|
const base = getCurrentTokenUsage(state, messages);
|
|
7380
7382
|
if (base > 0) {
|
|
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
|
+
}
|
|
7381
7393
|
let trailing = 0;
|
|
7382
|
-
|
|
7383
|
-
|
|
7384
|
-
const parts = Array.isArray(lastAsst.parts) ? lastAsst.parts : [];
|
|
7394
|
+
if (lastAsstIdx >= 0) {
|
|
7395
|
+
const parts = Array.isArray(messages[lastAsstIdx].parts) ? messages[lastAsstIdx].parts : [];
|
|
7385
7396
|
for (let i = parts.length - 1; i >= 0; i--) {
|
|
7386
7397
|
const p = parts[i];
|
|
7387
7398
|
if (p?.type !== "tool") break;
|
|
@@ -7389,13 +7400,29 @@ function estimateWireTokens(state, messages) {
|
|
|
7389
7400
|
trailing += countTokens2(extractCompletedToolOutput(p) ?? "");
|
|
7390
7401
|
}
|
|
7391
7402
|
}
|
|
7392
|
-
|
|
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;
|
|
7393
7408
|
}
|
|
7394
|
-
|
|
7409
|
+
return preciseWireTokens(state, messages);
|
|
7410
|
+
}
|
|
7411
|
+
function preciseWireTokens(state, messages) {
|
|
7412
|
+
let total = state.systemPromptTokens ?? 0;
|
|
7395
7413
|
for (const msg of messages) {
|
|
7396
7414
|
total += countAllMessageTokens(msg);
|
|
7397
7415
|
}
|
|
7398
|
-
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;
|
|
7399
7426
|
}
|
|
7400
7427
|
function pruneToFit(state, config, logger, messages) {
|
|
7401
7428
|
if (!config.compress.overflowGuard) return;
|
|
@@ -7405,7 +7432,10 @@ function pruneToFit(state, config, logger, messages) {
|
|
|
7405
7432
|
const safeBudget = knownWindow - reserve;
|
|
7406
7433
|
if (safeBudget <= 0) return;
|
|
7407
7434
|
const estimate = estimateWireTokens(state, messages);
|
|
7408
|
-
if (estimate <= safeBudget)
|
|
7435
|
+
if (estimate <= safeBudget) {
|
|
7436
|
+
state.overflowGuardStuckLogged = false;
|
|
7437
|
+
return;
|
|
7438
|
+
}
|
|
7409
7439
|
const protectedRefs = computeProtectedRefs(messages, state, config.compress);
|
|
7410
7440
|
const lastNonIgnored = findLastNonIgnoredMessage(messages);
|
|
7411
7441
|
const lastMsgId = lastNonIgnored?.message.info.id;
|
|
@@ -7453,7 +7483,10 @@ function pruneToFit(state, config, logger, messages) {
|
|
|
7453
7483
|
afterTokens: Math.round(after)
|
|
7454
7484
|
};
|
|
7455
7485
|
if (clearedCount === 0) {
|
|
7456
|
-
|
|
7486
|
+
if (!state.overflowGuardStuckLogged) {
|
|
7487
|
+
state.overflowGuardStuckLogged = true;
|
|
7488
|
+
logger.error("ACP overflow guard: over window but no clearable tool outputs", detail);
|
|
7489
|
+
}
|
|
7457
7490
|
return;
|
|
7458
7491
|
}
|
|
7459
7492
|
if (after <= safeBudget) {
|
|
@@ -9272,7 +9305,7 @@ import { writeFile as writeFile2, mkdir as mkdir2 } from "fs/promises";
|
|
|
9272
9305
|
import { join as join3 } from "path";
|
|
9273
9306
|
import { existsSync as existsSync3 } from "fs";
|
|
9274
9307
|
import { homedir as homedir3 } from "os";
|
|
9275
|
-
var LOG_VERSION = true ? "1.14.25-pr.348.
|
|
9308
|
+
var LOG_VERSION = true ? "1.14.25-pr.348.74" : "dev";
|
|
9276
9309
|
var LEVEL_RANK = {
|
|
9277
9310
|
debug: 10,
|
|
9278
9311
|
info: 20,
|
|
@@ -11715,7 +11748,7 @@ var server = (async (ctx) => {
|
|
|
11715
11748
|
}
|
|
11716
11749
|
const logger = new Logger(config.debug, config.debug ? "debug" : config.logLevel);
|
|
11717
11750
|
logger.info("ACP plugin initialized", {
|
|
11718
|
-
version: true ? "1.14.25-pr.348.
|
|
11751
|
+
version: true ? "1.14.25-pr.348.74" : "dev",
|
|
11719
11752
|
workspace: ctx.directory,
|
|
11720
11753
|
logLevel: logger.level,
|
|
11721
11754
|
debug: config.debug,
|