opencode-acp 1.14.27-pr.365.102 → 1.14.27-pr.370.105
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 +90 -59
- package/dist/index.js.map +1 -1
- package/dist/lib/config-validation.d.ts.map +1 -1
- package/dist/lib/config.d.ts +14 -1
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/hooks.d.ts.map +1 -1
- package/dist/lib/messages/index.d.ts +1 -1
- package/dist/lib/messages/index.d.ts.map +1 -1
- package/dist/lib/messages/inject/inject.d.ts.map +1 -1
- package/dist/lib/messages/query.d.ts +0 -16
- package/dist/lib/messages/query.d.ts.map +1 -1
- package/dist/lib/messages/reasoning-strip.d.ts +23 -0
- package/dist/lib/messages/reasoning-strip.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -909,6 +909,8 @@ var VALID_CONFIG_KEYS = /* @__PURE__ */ new Set([
|
|
|
909
909
|
"compress.preserveRecentMessages",
|
|
910
910
|
"compress.preserveRecentTokens",
|
|
911
911
|
"compress.preserveLastUserMessage",
|
|
912
|
+
"compress.stripProtectedReasoning",
|
|
913
|
+
"compress.stripProtectedReasoningThreshold",
|
|
912
914
|
"gc",
|
|
913
915
|
"gc.algorithm",
|
|
914
916
|
"gc.promotionThreshold",
|
|
@@ -1262,6 +1264,20 @@ function validateConfigTypes(config) {
|
|
|
1262
1264
|
actual: typeof compress.preserveLastUserMessage
|
|
1263
1265
|
});
|
|
1264
1266
|
}
|
|
1267
|
+
if (compress.stripProtectedReasoning !== void 0 && typeof compress.stripProtectedReasoning !== "boolean") {
|
|
1268
|
+
errors.push({
|
|
1269
|
+
key: "compress.stripProtectedReasoning",
|
|
1270
|
+
expected: "boolean",
|
|
1271
|
+
actual: typeof compress.stripProtectedReasoning
|
|
1272
|
+
});
|
|
1273
|
+
}
|
|
1274
|
+
if (compress.stripProtectedReasoningThreshold !== void 0 && (typeof compress.stripProtectedReasoningThreshold !== "number" || !Number.isFinite(compress.stripProtectedReasoningThreshold) || compress.stripProtectedReasoningThreshold < 0)) {
|
|
1275
|
+
errors.push({
|
|
1276
|
+
key: "compress.stripProtectedReasoningThreshold",
|
|
1277
|
+
expected: "number (>= 0)",
|
|
1278
|
+
actual: JSON.stringify(compress.stripProtectedReasoningThreshold)
|
|
1279
|
+
});
|
|
1280
|
+
}
|
|
1265
1281
|
if (typeof compress.iterationNudgeThreshold === "number" && compress.iterationNudgeThreshold < 1) {
|
|
1266
1282
|
errors.push({
|
|
1267
1283
|
key: "compress.iterationNudgeThreshold",
|
|
@@ -1659,7 +1675,9 @@ var defaultConfig = {
|
|
|
1659
1675
|
lastSegmentSoftBlock: true,
|
|
1660
1676
|
preserveRecentMessages: 5,
|
|
1661
1677
|
preserveRecentTokens: 5e3,
|
|
1662
|
-
preserveLastUserMessage: true
|
|
1678
|
+
preserveLastUserMessage: true,
|
|
1679
|
+
stripProtectedReasoning: true,
|
|
1680
|
+
stripProtectedReasoningThreshold: 2048
|
|
1663
1681
|
},
|
|
1664
1682
|
gc: {
|
|
1665
1683
|
algorithm: "truncate",
|
|
@@ -1829,7 +1847,9 @@ function mergeCompress(base, override) {
|
|
|
1829
1847
|
lastSegmentSoftBlock: override.lastSegmentSoftBlock ?? base.lastSegmentSoftBlock,
|
|
1830
1848
|
preserveRecentMessages: override.preserveRecentMessages ?? base.preserveRecentMessages,
|
|
1831
1849
|
preserveRecentTokens: override.preserveRecentTokens ?? base.preserveRecentTokens,
|
|
1832
|
-
preserveLastUserMessage: override.preserveLastUserMessage ?? base.preserveLastUserMessage
|
|
1850
|
+
preserveLastUserMessage: override.preserveLastUserMessage ?? base.preserveLastUserMessage,
|
|
1851
|
+
stripProtectedReasoning: override.stripProtectedReasoning ?? base.stripProtectedReasoning,
|
|
1852
|
+
stripProtectedReasoningThreshold: override.stripProtectedReasoningThreshold ?? base.stripProtectedReasoningThreshold
|
|
1833
1853
|
};
|
|
1834
1854
|
}
|
|
1835
1855
|
function mergeCommands(base, override) {
|
|
@@ -2092,56 +2112,6 @@ var messageHasCompressAttempt = (message) => {
|
|
|
2092
2112
|
const parts = Array.isArray(message.parts) ? message.parts : [];
|
|
2093
2113
|
return parts.some((part) => part.type === "tool" && part.tool === "compress");
|
|
2094
2114
|
};
|
|
2095
|
-
var isCaptureOnlyCompress = (message) => {
|
|
2096
|
-
if (!isMessageWithInfo(message)) {
|
|
2097
|
-
return false;
|
|
2098
|
-
}
|
|
2099
|
-
if (message.info.role !== "assistant") {
|
|
2100
|
-
return false;
|
|
2101
|
-
}
|
|
2102
|
-
const parts = Array.isArray(message.parts) ? message.parts : [];
|
|
2103
|
-
let sawBoundary = false;
|
|
2104
|
-
for (const part of parts) {
|
|
2105
|
-
if (!(part.type === "tool" && part.tool === "compress")) {
|
|
2106
|
-
continue;
|
|
2107
|
-
}
|
|
2108
|
-
for (const startId of extractCompressBoundaryIds(part.state?.input)) {
|
|
2109
|
-
sawBoundary = true;
|
|
2110
|
-
if (/^b\d+$/i.test(startId)) {
|
|
2111
|
-
return false;
|
|
2112
|
-
}
|
|
2113
|
-
}
|
|
2114
|
-
}
|
|
2115
|
-
return sawBoundary;
|
|
2116
|
-
};
|
|
2117
|
-
function extractCompressBoundaryIds(rawInput) {
|
|
2118
|
-
let content = [];
|
|
2119
|
-
if (typeof rawInput === "string") {
|
|
2120
|
-
try {
|
|
2121
|
-
const parsed = JSON.parse(rawInput);
|
|
2122
|
-
const c = parsed?.content;
|
|
2123
|
-
content = Array.isArray(c) ? c : [];
|
|
2124
|
-
} catch {
|
|
2125
|
-
return [];
|
|
2126
|
-
}
|
|
2127
|
-
} else if (rawInput && typeof rawInput === "object") {
|
|
2128
|
-
const c = rawInput.content;
|
|
2129
|
-
content = Array.isArray(c) ? c : [];
|
|
2130
|
-
}
|
|
2131
|
-
const ids = [];
|
|
2132
|
-
for (const entry of content) {
|
|
2133
|
-
if (!entry || typeof entry !== "object") {
|
|
2134
|
-
continue;
|
|
2135
|
-
}
|
|
2136
|
-
const { startId, endId } = entry;
|
|
2137
|
-
for (const sid of [startId, endId]) {
|
|
2138
|
-
if (typeof sid === "string" && sid.trim() !== "") {
|
|
2139
|
-
ids.push(sid.trim());
|
|
2140
|
-
}
|
|
2141
|
-
}
|
|
2142
|
-
}
|
|
2143
|
-
return ids;
|
|
2144
|
-
}
|
|
2145
2115
|
var isIgnoredUserMessage = (message) => {
|
|
2146
2116
|
if (!isMessageWithInfo(message)) {
|
|
2147
2117
|
return false;
|
|
@@ -7831,11 +7801,8 @@ var injectCompressNudges = (state, config, logger, messages, prompts, compressio
|
|
|
7831
7801
|
state.nudges.iterationNudgeAnchors.clear();
|
|
7832
7802
|
state.nudges.lastNudgeShownTokens = void 0;
|
|
7833
7803
|
state.nudges.lastToolOutputNudgeTokens = void 0;
|
|
7834
|
-
|
|
7835
|
-
|
|
7836
|
-
state.nudges.lastTier2NudgeTokens = currentTokens;
|
|
7837
|
-
state.nudges.lastTier3NudgeTokens = currentTokens;
|
|
7838
|
-
}
|
|
7804
|
+
state.nudges.lastTier2NudgeTokens = currentTokens;
|
|
7805
|
+
state.nudges.lastTier3NudgeTokens = currentTokens;
|
|
7839
7806
|
const currentTurnHasSuccessfulCompress = messages.slice(currentTurnStart).some((m) => m.info.role === "assistant" && messageHasCompress(m));
|
|
7840
7807
|
if (currentTurnHasSuccessfulCompress && wasNudgeTriggered && !state.nudges.compressBaselineSet) {
|
|
7841
7808
|
const baseline = state.nudges.lastPerMessageNudgeTokens;
|
|
@@ -8315,6 +8282,58 @@ function stripStaleMetadata(messages) {
|
|
|
8315
8282
|
});
|
|
8316
8283
|
});
|
|
8317
8284
|
}
|
|
8285
|
+
function stripProtectedReasoning(messages, protectedTools, threshold) {
|
|
8286
|
+
if (protectedTools.length === 0) {
|
|
8287
|
+
return 0;
|
|
8288
|
+
}
|
|
8289
|
+
const lastUserMessage = getLastUserMessage(messages);
|
|
8290
|
+
if (!lastUserMessage || lastUserMessage.info.role !== "user") {
|
|
8291
|
+
return 0;
|
|
8292
|
+
}
|
|
8293
|
+
let lastUserIndex = -1;
|
|
8294
|
+
for (let i = messages.length - 1; i >= 0; i--) {
|
|
8295
|
+
if (messages[i] === lastUserMessage) {
|
|
8296
|
+
lastUserIndex = i;
|
|
8297
|
+
break;
|
|
8298
|
+
}
|
|
8299
|
+
}
|
|
8300
|
+
if (lastUserIndex <= 0) {
|
|
8301
|
+
return 0;
|
|
8302
|
+
}
|
|
8303
|
+
const protectedSet = new Set(protectedTools);
|
|
8304
|
+
let removed = 0;
|
|
8305
|
+
for (let i = 0; i < lastUserIndex; i++) {
|
|
8306
|
+
const message = messages[i];
|
|
8307
|
+
if (!message || message.info.role !== "assistant") {
|
|
8308
|
+
continue;
|
|
8309
|
+
}
|
|
8310
|
+
const parts = Array.isArray(message.parts) ? message.parts : [];
|
|
8311
|
+
let hasProtectedTool = false;
|
|
8312
|
+
let reasoningLength = 0;
|
|
8313
|
+
for (const part of parts) {
|
|
8314
|
+
if (part.type === "tool") {
|
|
8315
|
+
if (protectedSet.has(part.tool)) {
|
|
8316
|
+
hasProtectedTool = true;
|
|
8317
|
+
}
|
|
8318
|
+
} else if (part.type === "reasoning") {
|
|
8319
|
+
reasoningLength += part.text.length;
|
|
8320
|
+
}
|
|
8321
|
+
}
|
|
8322
|
+
if (!hasProtectedTool) {
|
|
8323
|
+
continue;
|
|
8324
|
+
}
|
|
8325
|
+
if (reasoningLength <= threshold) {
|
|
8326
|
+
continue;
|
|
8327
|
+
}
|
|
8328
|
+
const filtered = parts.filter((part) => part.type !== "reasoning");
|
|
8329
|
+
if (filtered.length === parts.length) {
|
|
8330
|
+
continue;
|
|
8331
|
+
}
|
|
8332
|
+
message.parts = filtered;
|
|
8333
|
+
removed += parts.length - filtered.length;
|
|
8334
|
+
}
|
|
8335
|
+
return removed;
|
|
8336
|
+
}
|
|
8318
8337
|
|
|
8319
8338
|
// lib/messages/priority.ts
|
|
8320
8339
|
function buildPriorityMap(_config, _state, _messages) {
|
|
@@ -9431,7 +9450,7 @@ import { writeFile as writeFile2, mkdir as mkdir2 } from "fs/promises";
|
|
|
9431
9450
|
import { join as join3 } from "path";
|
|
9432
9451
|
import { existsSync as existsSync3 } from "fs";
|
|
9433
9452
|
import { homedir as homedir3 } from "os";
|
|
9434
|
-
var LOG_VERSION = true ? "1.14.27-pr.
|
|
9453
|
+
var LOG_VERSION = true ? "1.14.27-pr.370.105" : "dev";
|
|
9435
9454
|
var LEVEL_RANK = {
|
|
9436
9455
|
debug: 10,
|
|
9437
9456
|
info: 20,
|
|
@@ -11448,6 +11467,18 @@ function createChatMessageTransformHandler(client, registry4, logger, config, pr
|
|
|
11448
11467
|
prune(state, logger, config, output.messages);
|
|
11449
11468
|
truncateLargeToolOutputs(state, config, logger, output.messages);
|
|
11450
11469
|
hideConsumedCompressCalls(state, output.messages);
|
|
11470
|
+
if (config.compress.stripProtectedReasoning !== false) {
|
|
11471
|
+
const removedReasoning = stripProtectedReasoning(
|
|
11472
|
+
output.messages,
|
|
11473
|
+
config.compress.protectedTools,
|
|
11474
|
+
config.compress.stripProtectedReasoningThreshold ?? 2048
|
|
11475
|
+
);
|
|
11476
|
+
if (removedReasoning > 0) {
|
|
11477
|
+
logger.debug("stripProtectedReasoning: removed reasoning parts from historical protected messages", {
|
|
11478
|
+
removed: removedReasoning
|
|
11479
|
+
});
|
|
11480
|
+
}
|
|
11481
|
+
}
|
|
11451
11482
|
assignMessageRefs(state, output.messages);
|
|
11452
11483
|
const compressionPriorities = buildPriorityMap(config, state, output.messages);
|
|
11453
11484
|
prompts.reload();
|
|
@@ -11904,7 +11935,7 @@ var server = (async (ctx) => {
|
|
|
11904
11935
|
}
|
|
11905
11936
|
const logger = new Logger(config.debug, config.debug ? "debug" : config.logLevel);
|
|
11906
11937
|
logger.info("ACP plugin initialized", {
|
|
11907
|
-
version: true ? "1.14.27-pr.
|
|
11938
|
+
version: true ? "1.14.27-pr.370.105" : "dev",
|
|
11908
11939
|
workspace: ctx.directory,
|
|
11909
11940
|
logLevel: logger.level,
|
|
11910
11941
|
debug: config.debug,
|