blun-king-cli 9.1.481 → 9.1.482
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/bin/tool-result-offload-policy.cjs +13 -1
- package/blun.mjs +5 -2
- package/package.json +1 -1
|
@@ -14,6 +14,7 @@ const TOOL_RESULT_HISTORICAL_REPLACEMENT_BUDGET_CHARS = 600;
|
|
|
14
14
|
const TOOL_RESULT_SUCCESS_KEEP_RECENT_MESSAGES = 12;
|
|
15
15
|
const TOOL_RESULT_HISTORICAL_SUCCESS_MARKER = '[Old tool result content cleared]';
|
|
16
16
|
const TOOL_RESULT_REPEAT_MARKER = '[Repeated tool result omitted]';
|
|
17
|
+
const READ_CONTINUATION_LINE_OFFSET_RE = /^Continue reading with line_offset=(\d+)\. Do not assume you have reached the end of the file\.$/mu;
|
|
17
18
|
|
|
18
19
|
function shouldOffloadToolResult(textLength) {
|
|
19
20
|
return Number.isFinite(textLength) && textLength > TOOL_RESULT_MAX_CHARS;
|
|
@@ -32,6 +33,12 @@ function createToolResultPreview(text) {
|
|
|
32
33
|
return `${text.slice(0, headChars)}\n\n[... ${String(omittedChars)} characters omitted ...]\n\n${text.slice(-tailChars)}`;
|
|
33
34
|
}
|
|
34
35
|
|
|
36
|
+
function readContinuationLineOffset(text) {
|
|
37
|
+
if (typeof text !== 'string') return undefined;
|
|
38
|
+
const value = Number(text.match(READ_CONTINUATION_LINE_OFFSET_RE)?.[1]);
|
|
39
|
+
return Number.isSafeInteger(value) && value >= 1 ? value : undefined;
|
|
40
|
+
}
|
|
41
|
+
|
|
35
42
|
function isPersistedToolResultReference(content) {
|
|
36
43
|
if (!Array.isArray(content)) return false;
|
|
37
44
|
|
|
@@ -89,10 +96,14 @@ function compactPersistedToolResultReference(content) {
|
|
|
89
96
|
const outputPath = lines.find((line) => line.startsWith('output_path: '));
|
|
90
97
|
if (outputPath === undefined) return part;
|
|
91
98
|
const recoveryLines = [TOOL_RESULT_OFFLOAD_MARKER];
|
|
92
|
-
for (const prefix of ['tool_name: ', 'output_size_chars: ']) {
|
|
99
|
+
for (const prefix of ['tool_name: ', 'output_size_chars: ', 'next_line_offset: ']) {
|
|
93
100
|
const line = lines.find((candidate) => candidate.startsWith(prefix));
|
|
94
101
|
if (line !== undefined) recoveryLines.push(line);
|
|
95
102
|
}
|
|
103
|
+
if (recoveryLines.some((line) => line.startsWith('next_line_offset: '))) {
|
|
104
|
+
const nextStep = lines.find((line) => line.startsWith('next_step: '));
|
|
105
|
+
if (nextStep !== undefined) recoveryLines.push(nextStep);
|
|
106
|
+
}
|
|
96
107
|
recoveryLines.push(outputPath);
|
|
97
108
|
const text = recoveryLines.join('\n');
|
|
98
109
|
if (text === part.text) return part;
|
|
@@ -298,6 +309,7 @@ module.exports = {
|
|
|
298
309
|
dedupeRepeatedSuccessfulToolResults,
|
|
299
310
|
freshToolResultIds,
|
|
300
311
|
isPersistedToolResultReference,
|
|
312
|
+
readContinuationLineOffset,
|
|
301
313
|
selectHistoricalToolResultOffloads,
|
|
302
314
|
selectToolResultBatchOffloads,
|
|
303
315
|
shouldKeepFreshToolResult,
|
package/blun.mjs
CHANGED
|
@@ -261032,6 +261032,7 @@ async function persistHistoricalToolResultForModel(options, knownText) {
|
|
|
261032
261032
|
};
|
|
261033
261033
|
}
|
|
261034
261034
|
function renderHistoricalToolResultReference(toolName, toolCallId, text, outputPath, storageMode) {
|
|
261035
|
+
const nextLineOffset = toolName === "Read" ? readContinuationLineOffset(text) : void 0;
|
|
261035
261036
|
return [
|
|
261036
261037
|
TOOL_RESULT_OFFLOAD_MARKER,
|
|
261037
261038
|
"An older tool result was archived to keep the active context fast.",
|
|
@@ -261040,14 +261041,15 @@ function renderHistoricalToolResultReference(toolName, toolCallId, text, outputP
|
|
|
261040
261041
|
`tool_call_id: ${toolCallId}`,
|
|
261041
261042
|
`output_size_chars: ${String(text.length)}`,
|
|
261042
261043
|
`output_size_bytes: ${String(Buffer.byteLength(text, "utf8"))}`,
|
|
261044
|
+
...(nextLineOffset === void 0 ? [] : [`next_line_offset: ${String(nextLineOffset)}`]),
|
|
261043
261045
|
`output_path: ${outputPath}`,
|
|
261044
|
-
`next_step: Use Read with output_path using n_lines <= ${String(TOOL_RESULT_RECOVERY_PAGE_LINES)}; advance line_offset between calls.`
|
|
261046
|
+
nextLineOffset === void 0 ? `next_step: Use Read with output_path using n_lines <= ${String(TOOL_RESULT_RECOVERY_PAGE_LINES)}; advance line_offset between calls.` : `next_step: Continue the original Read with line_offset=${String(nextLineOffset)}; do not restart at the beginning.`
|
|
261045
261047
|
].join("\n");
|
|
261046
261048
|
}
|
|
261047
261049
|
function safeToolResultFileStem(toolName, toolCallId) {
|
|
261048
261050
|
return `${toolName}-${toolCallId}`.replace(/[^a-zA-Z0-9._-]+/g, "_").replace(/^_+|_+$/g, "").slice(0, 80) || "tool-result";
|
|
261049
261051
|
}
|
|
261050
|
-
var TOOL_RESULT_MAX_CHARS, TOOL_RESULT_PREVIEW_CHARS, TOOL_RESULT_RECOVERY_PAGE_LINES, TOOL_RESULT_OFFLOAD_MARKER, TOOL_RESULT_HISTORICAL_KEEP_RECENT_MESSAGES, shouldKeepFreshToolResult, shouldOffloadToolResult, createToolResultPreview, compactPersistedToolResultReference, compactHistoricalSuccessfulToolResults, dedupeRepeatedSuccessfulToolResults, selectToolResultBatchOffloads, selectHistoricalToolResultOffloads, buildToolResultOffloadTelemetry;
|
|
261052
|
+
var TOOL_RESULT_MAX_CHARS, TOOL_RESULT_PREVIEW_CHARS, TOOL_RESULT_RECOVERY_PAGE_LINES, TOOL_RESULT_OFFLOAD_MARKER, TOOL_RESULT_HISTORICAL_KEEP_RECENT_MESSAGES, shouldKeepFreshToolResult, shouldOffloadToolResult, createToolResultPreview, compactPersistedToolResultReference, compactHistoricalSuccessfulToolResults, dedupeRepeatedSuccessfulToolResults, readContinuationLineOffset, selectToolResultBatchOffloads, selectHistoricalToolResultOffloads, buildToolResultOffloadTelemetry;
|
|
261051
261053
|
var init_tool_result_budget = __esmMin((() => {
|
|
261052
261054
|
init_dist$6();
|
|
261053
261055
|
const toolResultOffloadPolicy = createRequire(import.meta.url)("./bin/tool-result-offload-policy.cjs");
|
|
@@ -261064,6 +261066,7 @@ var init_tool_result_budget = __esmMin((() => {
|
|
|
261064
261066
|
compactHistoricalSuccessfulToolResults = toolResultOffloadPolicy.compactHistoricalSuccessfulToolResults;
|
|
261065
261067
|
dedupeRepeatedSuccessfulToolResults = toolResultOffloadPolicy.dedupeRepeatedSuccessfulToolResults;
|
|
261066
261068
|
freshToolResultIds = toolResultOffloadPolicy.freshToolResultIds;
|
|
261069
|
+
readContinuationLineOffset = toolResultOffloadPolicy.readContinuationLineOffset;
|
|
261067
261070
|
selectToolResultBatchOffloads = toolResultOffloadPolicy.selectToolResultBatchOffloads;
|
|
261068
261071
|
selectHistoricalToolResultOffloads = toolResultOffloadPolicy.selectHistoricalToolResultOffloads;
|
|
261069
261072
|
}));
|