opencode-acp 1.14.25-pr.350.73 → 1.14.25-pr.350.76
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
|
@@ -908,6 +908,7 @@ var VALID_CONFIG_KEYS = /* @__PURE__ */ new Set([
|
|
|
908
908
|
"compress.preserveRecentMessages",
|
|
909
909
|
"compress.preserveRecentTokens",
|
|
910
910
|
"compress.preserveLastUserMessage",
|
|
911
|
+
"compress.completionReserveTokens",
|
|
911
912
|
"gc",
|
|
912
913
|
"gc.algorithm",
|
|
913
914
|
"gc.promotionThreshold",
|
|
@@ -1261,6 +1262,20 @@ function validateConfigTypes(config) {
|
|
|
1261
1262
|
actual: typeof compress.preserveLastUserMessage
|
|
1262
1263
|
});
|
|
1263
1264
|
}
|
|
1265
|
+
if (compress.completionReserveTokens !== void 0 && typeof compress.completionReserveTokens !== "number") {
|
|
1266
|
+
errors.push({
|
|
1267
|
+
key: "compress.completionReserveTokens",
|
|
1268
|
+
expected: "number",
|
|
1269
|
+
actual: typeof compress.completionReserveTokens
|
|
1270
|
+
});
|
|
1271
|
+
}
|
|
1272
|
+
if (typeof compress.completionReserveTokens === "number" && compress.completionReserveTokens < 0) {
|
|
1273
|
+
errors.push({
|
|
1274
|
+
key: "compress.completionReserveTokens",
|
|
1275
|
+
expected: "non-negative number (>= 0)",
|
|
1276
|
+
actual: `${compress.completionReserveTokens}`
|
|
1277
|
+
});
|
|
1278
|
+
}
|
|
1264
1279
|
if (typeof compress.iterationNudgeThreshold === "number" && compress.iterationNudgeThreshold < 1) {
|
|
1265
1280
|
errors.push({
|
|
1266
1281
|
key: "compress.iterationNudgeThreshold",
|
|
@@ -9113,7 +9128,7 @@ import { writeFile as writeFile2, mkdir as mkdir2 } from "fs/promises";
|
|
|
9113
9128
|
import { join as join3 } from "path";
|
|
9114
9129
|
import { existsSync as existsSync3 } from "fs";
|
|
9115
9130
|
import { homedir as homedir3 } from "os";
|
|
9116
|
-
var LOG_VERSION = true ? "1.14.25-pr.350.
|
|
9131
|
+
var LOG_VERSION = true ? "1.14.25-pr.350.76" : "dev";
|
|
9117
9132
|
var LEVEL_RANK = {
|
|
9118
9133
|
debug: 10,
|
|
9119
9134
|
info: 20,
|
|
@@ -10014,18 +10029,21 @@ function resolveContextWindow(state) {
|
|
|
10014
10029
|
function estimateWireTokens(state, messages) {
|
|
10015
10030
|
const base = getCurrentTokenUsage(state, messages);
|
|
10016
10031
|
if (base > 0) {
|
|
10017
|
-
let
|
|
10032
|
+
let baseAssistant = -1;
|
|
10018
10033
|
for (let i = messages.length - 1; i >= 0; i--) {
|
|
10019
|
-
if (messages[i].info.role
|
|
10020
|
-
|
|
10021
|
-
|
|
10022
|
-
|
|
10034
|
+
if (messages[i].info.role !== "assistant") continue;
|
|
10035
|
+
const tokens = messages[i].info.tokens;
|
|
10036
|
+
if ((tokens?.input || 0) <= 0 && (tokens?.output || 0) <= 0) continue;
|
|
10037
|
+
baseAssistant = i;
|
|
10038
|
+
break;
|
|
10023
10039
|
}
|
|
10024
|
-
|
|
10025
|
-
|
|
10026
|
-
|
|
10040
|
+
if (baseAssistant >= 0) {
|
|
10041
|
+
let additions = 0;
|
|
10042
|
+
for (let i = baseAssistant + 1; i < messages.length; i++) {
|
|
10043
|
+
additions += countAllMessageTokens(messages[i]);
|
|
10044
|
+
}
|
|
10045
|
+
return base + additions;
|
|
10027
10046
|
}
|
|
10028
|
-
return base + additions;
|
|
10029
10047
|
}
|
|
10030
10048
|
let total = 0;
|
|
10031
10049
|
for (const m of messages) total += countAllMessageTokens(m);
|
|
@@ -10034,7 +10052,8 @@ function estimateWireTokens(state, messages) {
|
|
|
10034
10052
|
function enforceContextBudget(state, config, logger, messages) {
|
|
10035
10053
|
const window = resolveContextWindow(state);
|
|
10036
10054
|
if (window === void 0) return void 0;
|
|
10037
|
-
const
|
|
10055
|
+
const configuredReserve = config.compress?.completionReserveTokens;
|
|
10056
|
+
const reserve = typeof configuredReserve === "number" && Number.isFinite(configuredReserve) && configuredReserve >= 0 ? configuredReserve : DEFAULT_COMPLETION_RESERVE_TOKENS;
|
|
10038
10057
|
const budget = window - reserve;
|
|
10039
10058
|
if (budget <= 0) return void 0;
|
|
10040
10059
|
const estimatedTokens = estimateWireTokens(state, messages);
|
|
@@ -10085,6 +10104,7 @@ function enforceContextBudget(state, config, logger, messages) {
|
|
|
10085
10104
|
...${TRUNCATION_MARKER2} \u2014 original ~${c.tokens} tokens]...
|
|
10086
10105
|
|
|
10087
10106
|
` + suffix;
|
|
10107
|
+
if (truncated.length >= c.content.length) continue;
|
|
10088
10108
|
c.part.state.output = truncated;
|
|
10089
10109
|
saved += c.tokens - countTokens2(truncated);
|
|
10090
10110
|
truncatedCount++;
|
|
@@ -11244,7 +11264,7 @@ function createChatMessageTransformHandler(client, registry4, logger, config, pr
|
|
|
11244
11264
|
if (state.modelContextLimit === void 0 && !state.noContextLimitWarned && requestModel?.providerID && requestModel?.modelID && registry4.resolveModelLimit(requestModel.providerID, requestModel.modelID) === void 0) {
|
|
11245
11265
|
state.noContextLimitWarned = true;
|
|
11246
11266
|
logger.warn(
|
|
11247
|
-
'Model reports no context window and the catalog has no entry for it; all percentage thresholds (min/max/emergency, GC) and the context-budget guard are disabled. Set the model limit in opencode.json (e.g. "limit": {"context": 262144, "output": 16384})
|
|
11267
|
+
'Model reports no context window and the catalog has no entry for it; all percentage thresholds (min/max/emergency, GC) and the context-budget guard are disabled. Set the model limit in opencode.json (e.g. "limit": {"context": 262144, "output": 16384}) to enable them (also fixes the 32000 max_tokens fallback); an absolute compress.maxContextLimit in acp.jsonc only enables proactive nudges, not the guard.',
|
|
11248
11268
|
{
|
|
11249
11269
|
session: state.sessionId,
|
|
11250
11270
|
model: `${requestModel.providerID}/${requestModel.modelID}`
|
|
@@ -11707,7 +11727,7 @@ var server = (async (ctx) => {
|
|
|
11707
11727
|
}
|
|
11708
11728
|
const logger = new Logger(config.debug, config.debug ? "debug" : config.logLevel);
|
|
11709
11729
|
logger.info("ACP plugin initialized", {
|
|
11710
|
-
version: true ? "1.14.25-pr.350.
|
|
11730
|
+
version: true ? "1.14.25-pr.350.76" : "dev",
|
|
11711
11731
|
workspace: ctx.directory,
|
|
11712
11732
|
logLevel: logger.level,
|
|
11713
11733
|
debug: config.debug,
|