opencode-acp 1.18.4 → 1.18.5-pr.487.222
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 +128 -11
- package/dist/index.js.map +1 -1
- package/dist/lib/config-validation.d.ts.map +1 -1
- package/dist/lib/config.d.ts +13 -0
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/hooks.d.ts.map +1 -1
- package/dist/lib/messages/sticky-truncation.d.ts +55 -0
- package/dist/lib/messages/sticky-truncation.d.ts.map +1 -0
- package/dist/lib/messages/truncate-tools.d.ts.map +1 -1
- package/dist/lib/state/persistence.d.ts +2 -0
- package/dist/lib/state/persistence.d.ts.map +1 -1
- package/dist/lib/state/state.d.ts.map +1 -1
- package/dist/lib/state/types.d.ts +10 -0
- package/dist/lib/state/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -921,6 +921,7 @@ var VALID_CONFIG_KEYS = /* @__PURE__ */ new Set([
|
|
|
921
921
|
"compress.images.minBytes",
|
|
922
922
|
"compress.images.ttlDays",
|
|
923
923
|
"compress.completionReserveTokens",
|
|
924
|
+
"compress.emergencyTruncation",
|
|
924
925
|
"gc",
|
|
925
926
|
"gc.algorithm",
|
|
926
927
|
"gc.promotionThreshold",
|
|
@@ -1350,6 +1351,13 @@ function validateConfigTypes(config) {
|
|
|
1350
1351
|
actual: typeof compress.completionReserveTokens
|
|
1351
1352
|
});
|
|
1352
1353
|
}
|
|
1354
|
+
if (compress.emergencyTruncation !== void 0 && typeof compress.emergencyTruncation !== "boolean") {
|
|
1355
|
+
errors.push({
|
|
1356
|
+
key: "compress.emergencyTruncation",
|
|
1357
|
+
expected: "boolean",
|
|
1358
|
+
actual: typeof compress.emergencyTruncation
|
|
1359
|
+
});
|
|
1360
|
+
}
|
|
1353
1361
|
if (typeof compress.completionReserveTokens === "number" && compress.completionReserveTokens < 0) {
|
|
1354
1362
|
errors.push({
|
|
1355
1363
|
key: "compress.completionReserveTokens",
|
|
@@ -1422,6 +1430,7 @@ function validateConfigTypes(config) {
|
|
|
1422
1430
|
const OVERRIDE_FIELD_TYPES = {
|
|
1423
1431
|
showCompression: "boolean",
|
|
1424
1432
|
summaryBuffer: "boolean",
|
|
1433
|
+
emergencyTruncation: "boolean",
|
|
1425
1434
|
protectTags: "boolean",
|
|
1426
1435
|
protectUserMessages: "boolean",
|
|
1427
1436
|
lastSegmentSoftBlock: "boolean",
|
|
@@ -1809,6 +1818,7 @@ var defaultConfig = {
|
|
|
1809
1818
|
permission: "allow",
|
|
1810
1819
|
showCompression: true,
|
|
1811
1820
|
summaryBuffer: true,
|
|
1821
|
+
emergencyTruncation: false,
|
|
1812
1822
|
candidates: false,
|
|
1813
1823
|
maxContextLimit: "80%",
|
|
1814
1824
|
minContextLimit: "80%",
|
|
@@ -2017,7 +2027,8 @@ function mergeCompress(base, override) {
|
|
|
2017
2027
|
minBytes: override.images?.minBytes ?? base.images?.minBytes ?? DEFAULT_COMPRESS_IMAGES.minBytes,
|
|
2018
2028
|
ttlDays: override.images?.ttlDays ?? base.images?.ttlDays ?? DEFAULT_COMPRESS_IMAGES.ttlDays
|
|
2019
2029
|
},
|
|
2020
|
-
completionReserveTokens: override.completionReserveTokens ?? base.completionReserveTokens
|
|
2030
|
+
completionReserveTokens: override.completionReserveTokens ?? base.completionReserveTokens,
|
|
2031
|
+
emergencyTruncation: override.emergencyTruncation ?? base.emergencyTruncation
|
|
2021
2032
|
};
|
|
2022
2033
|
}
|
|
2023
2034
|
function mergeCommands(base, override) {
|
|
@@ -2955,7 +2966,8 @@ function saveSessionState(sessionState, logger, sessionName) {
|
|
|
2955
2966
|
modelContextLimit: sessionState.modelContextLimit,
|
|
2956
2967
|
modelProviderID: sessionState.modelProviderID,
|
|
2957
2968
|
modelID: sessionState.modelID,
|
|
2958
|
-
imageArchive: sessionState.imageArchive
|
|
2969
|
+
imageArchive: sessionState.imageArchive,
|
|
2970
|
+
stickyTruncations: sessionState.stickyTruncations
|
|
2959
2971
|
};
|
|
2960
2972
|
const key = saveQueueKey(sessionState.sessionId, sessionState.storageDir);
|
|
2961
2973
|
let queue = saveQueues.get(key);
|
|
@@ -5124,7 +5136,8 @@ function createSessionState() {
|
|
|
5124
5136
|
qualityGateRetryPending: false,
|
|
5125
5137
|
noContextLimitWarned: false,
|
|
5126
5138
|
imageArchive: {},
|
|
5127
|
-
imagePruneDone: false
|
|
5139
|
+
imagePruneDone: false,
|
|
5140
|
+
stickyTruncations: {}
|
|
5128
5141
|
};
|
|
5129
5142
|
}
|
|
5130
5143
|
function resetSessionState(state) {
|
|
@@ -5170,6 +5183,7 @@ function resetSessionState(state) {
|
|
|
5170
5183
|
state.noContextLimitWarned = false;
|
|
5171
5184
|
state.imageArchive = {};
|
|
5172
5185
|
state.imagePruneDone = false;
|
|
5186
|
+
state.stickyTruncations = {};
|
|
5173
5187
|
}
|
|
5174
5188
|
async function ensureSessionInitialized(client, state, sessionId, logger, messages, config, projectDir) {
|
|
5175
5189
|
if (state.sessionId === sessionId) {
|
|
@@ -5198,6 +5212,13 @@ async function ensureSessionInitialized(client, state, sessionId, logger, messag
|
|
|
5198
5212
|
if (parentSessionId) {
|
|
5199
5213
|
try {
|
|
5200
5214
|
const parent = await loadSessionState(parentSessionId, logger);
|
|
5215
|
+
if (parent?.stickyTruncations) {
|
|
5216
|
+
for (const [callID, output] of Object.entries(parent.stickyTruncations)) {
|
|
5217
|
+
if (typeof output === "string") {
|
|
5218
|
+
state.stickyTruncations[callID] = output;
|
|
5219
|
+
}
|
|
5220
|
+
}
|
|
5221
|
+
}
|
|
5201
5222
|
const response = parent ? await client.session.messages({ path: { id: parentSessionId } }) : void 0;
|
|
5202
5223
|
const parentMessages = Array.isArray(response?.data) ? response.data : Array.isArray(response) ? response : [];
|
|
5203
5224
|
if (parent && parentMessages.length > 0) {
|
|
@@ -5263,6 +5284,14 @@ async function ensureSessionInitialized(client, state, sessionId, logger, messag
|
|
|
5263
5284
|
}
|
|
5264
5285
|
}
|
|
5265
5286
|
}
|
|
5287
|
+
const persistedSticky = persisted.stickyTruncations;
|
|
5288
|
+
if (persistedSticky && typeof persistedSticky === "object") {
|
|
5289
|
+
for (const [callID, output] of Object.entries(persistedSticky)) {
|
|
5290
|
+
if (typeof output === "string") {
|
|
5291
|
+
state.stickyTruncations[callID] = output;
|
|
5292
|
+
}
|
|
5293
|
+
}
|
|
5294
|
+
}
|
|
5266
5295
|
const persistedAny = persisted;
|
|
5267
5296
|
if (persistedAny._persistedMessageIds) {
|
|
5268
5297
|
state.messageIds = {
|
|
@@ -11329,7 +11358,7 @@ import { writeFile as writeFile2, mkdir as mkdir2 } from "fs/promises";
|
|
|
11329
11358
|
import { join as join5 } from "path";
|
|
11330
11359
|
import { existsSync as existsSync5 } from "fs";
|
|
11331
11360
|
import { homedir as homedir3 } from "os";
|
|
11332
|
-
var LOG_VERSION = true ? "1.18.
|
|
11361
|
+
var LOG_VERSION = true ? "1.18.5-pr.487.222" : "dev";
|
|
11333
11362
|
var LEVEL_RANK = {
|
|
11334
11363
|
debug: 10,
|
|
11335
11364
|
info: 20,
|
|
@@ -12184,6 +12213,7 @@ function truncateLargeToolOutputs(state, config, logger, messages) {
|
|
|
12184
12213
|
const part = parts[pi];
|
|
12185
12214
|
if (part?.type !== "tool") continue;
|
|
12186
12215
|
if (part.state?.status !== "completed") continue;
|
|
12216
|
+
if (part.tool === "compress") continue;
|
|
12187
12217
|
const content = extractCompletedToolOutput(part);
|
|
12188
12218
|
if (content === void 0) continue;
|
|
12189
12219
|
if (content === "[Old tool result content cleared]") continue;
|
|
@@ -12224,6 +12254,74 @@ function truncateLargeToolOutputs(state, config, logger, messages) {
|
|
|
12224
12254
|
}
|
|
12225
12255
|
}
|
|
12226
12256
|
|
|
12257
|
+
// lib/messages/sticky-truncation.ts
|
|
12258
|
+
function collectToolParts(messages) {
|
|
12259
|
+
const parts = [];
|
|
12260
|
+
for (const message of messages) {
|
|
12261
|
+
const messageParts = Array.isArray(message.parts) ? message.parts : [];
|
|
12262
|
+
for (const part of messageParts) {
|
|
12263
|
+
if (part?.type === "tool") {
|
|
12264
|
+
parts.push(part);
|
|
12265
|
+
}
|
|
12266
|
+
}
|
|
12267
|
+
}
|
|
12268
|
+
return parts;
|
|
12269
|
+
}
|
|
12270
|
+
function applyStickyTruncations(state, messages, logger) {
|
|
12271
|
+
const frozen = state.stickyTruncations;
|
|
12272
|
+
if (Object.keys(frozen).length === 0) return;
|
|
12273
|
+
let replayed = 0;
|
|
12274
|
+
const seen = /* @__PURE__ */ new Set();
|
|
12275
|
+
for (const part of collectToolParts(messages)) {
|
|
12276
|
+
const callID = typeof part.callID === "string" ? part.callID : void 0;
|
|
12277
|
+
if (!callID) continue;
|
|
12278
|
+
seen.add(callID);
|
|
12279
|
+
const recorded = frozen[callID];
|
|
12280
|
+
if (recorded === void 0) continue;
|
|
12281
|
+
if (!part.state) continue;
|
|
12282
|
+
if (part.state.output === recorded) continue;
|
|
12283
|
+
part.state.output = recorded;
|
|
12284
|
+
replayed++;
|
|
12285
|
+
}
|
|
12286
|
+
for (const callID of Object.keys(frozen)) {
|
|
12287
|
+
if (!seen.has(callID)) delete frozen[callID];
|
|
12288
|
+
}
|
|
12289
|
+
if (replayed > 0) {
|
|
12290
|
+
logger.debug("Sticky truncation: replayed frozen tool outputs", {
|
|
12291
|
+
replayed,
|
|
12292
|
+
frozen: Object.keys(frozen).length
|
|
12293
|
+
});
|
|
12294
|
+
}
|
|
12295
|
+
}
|
|
12296
|
+
function snapshotToolOutputs(messages) {
|
|
12297
|
+
const snapshot = /* @__PURE__ */ new Map();
|
|
12298
|
+
for (const part of collectToolParts(messages)) {
|
|
12299
|
+
const callID = typeof part.callID === "string" ? part.callID : void 0;
|
|
12300
|
+
if (!callID) continue;
|
|
12301
|
+
const content = extractCompletedToolOutput(part);
|
|
12302
|
+
if (content === void 0) continue;
|
|
12303
|
+
snapshot.set(callID, content);
|
|
12304
|
+
}
|
|
12305
|
+
return snapshot;
|
|
12306
|
+
}
|
|
12307
|
+
function recordStickyTruncations(state, messages, before, logger) {
|
|
12308
|
+
let recorded = 0;
|
|
12309
|
+
for (const part of collectToolParts(messages)) {
|
|
12310
|
+
const callID = typeof part.callID === "string" ? part.callID : void 0;
|
|
12311
|
+
if (!callID) continue;
|
|
12312
|
+
if (typeof part.state?.output !== "string") continue;
|
|
12313
|
+
const prior = before.get(callID);
|
|
12314
|
+
if (prior === void 0 || prior === part.state.output) continue;
|
|
12315
|
+
if (state.stickyTruncations[callID] === part.state.output) continue;
|
|
12316
|
+
state.stickyTruncations[callID] = part.state.output;
|
|
12317
|
+
recorded++;
|
|
12318
|
+
}
|
|
12319
|
+
if (recorded > 0) {
|
|
12320
|
+
logger.info("Sticky truncation: froze truncated tool outputs", { recorded });
|
|
12321
|
+
}
|
|
12322
|
+
return recorded;
|
|
12323
|
+
}
|
|
12324
|
+
|
|
12227
12325
|
// lib/messages/enforce-budget.ts
|
|
12228
12326
|
var DEFAULT_COMPLETION_RESERVE_TOKENS = 32768;
|
|
12229
12327
|
var TRUNCATION_MARKER2 = "[truncated for context space";
|
|
@@ -13594,13 +13692,32 @@ ${text}`);
|
|
|
13594
13692
|
prePruneTokens,
|
|
13595
13693
|
candidateMessages
|
|
13596
13694
|
);
|
|
13597
|
-
|
|
13598
|
-
state,
|
|
13695
|
+
const emergencyTruncationEnabled = applyCompressOverrides(
|
|
13599
13696
|
config,
|
|
13600
|
-
|
|
13601
|
-
|
|
13602
|
-
);
|
|
13603
|
-
|
|
13697
|
+
dropReasoningModel?.providerID ?? state.modelProviderID,
|
|
13698
|
+
dropReasoningModel?.modelID ?? state.modelID
|
|
13699
|
+
).compress.emergencyTruncation;
|
|
13700
|
+
if (emergencyTruncationEnabled === true) {
|
|
13701
|
+
applyStickyTruncations(state, output.messages, logger);
|
|
13702
|
+
const toolOutputsBefore = snapshotToolOutputs(output.messages);
|
|
13703
|
+
truncateLargeToolOutputs(
|
|
13704
|
+
state,
|
|
13705
|
+
config,
|
|
13706
|
+
logger,
|
|
13707
|
+
output.messages.filter((message) => !isSyntheticMessage(message))
|
|
13708
|
+
);
|
|
13709
|
+
enforceContextBudget(state, config, logger, output.messages);
|
|
13710
|
+
const frozenCount = recordStickyTruncations(
|
|
13711
|
+
state,
|
|
13712
|
+
output.messages,
|
|
13713
|
+
toolOutputsBefore,
|
|
13714
|
+
logger
|
|
13715
|
+
);
|
|
13716
|
+
if (frozenCount > 0) {
|
|
13717
|
+
saveSessionState(state, logger).catch(() => {
|
|
13718
|
+
});
|
|
13719
|
+
}
|
|
13720
|
+
}
|
|
13604
13721
|
injectMessageIds(state, config, output.messages, compressionPriorities);
|
|
13605
13722
|
hideFailedCompressCalls(output.messages);
|
|
13606
13723
|
stripStaleMetadata(output.messages);
|
|
@@ -14039,7 +14156,7 @@ var server = (async (ctx) => {
|
|
|
14039
14156
|
}
|
|
14040
14157
|
const logger = new Logger(config.debug, config.debug ? "debug" : config.logLevel);
|
|
14041
14158
|
logger.info("ACP plugin initialized", {
|
|
14042
|
-
version: true ? "1.18.
|
|
14159
|
+
version: true ? "1.18.5-pr.487.222" : "dev",
|
|
14043
14160
|
workspace: ctx.directory,
|
|
14044
14161
|
logLevel: logger.level,
|
|
14045
14162
|
debug: config.debug,
|