blun-king-cli 9.1.612 → 9.1.614
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/CHANGELOG.md +12 -1
- package/LIESMICH.txt +1 -1
- package/README.md +1 -1
- package/agent-spine-plugin/src/hook.js +4 -0
- package/agent-spine-plugin/src/lib/documents.js +1 -1
- package/agent-spine-plugin/src/lib/hook-context.js +1 -0
- package/agent-spine-plugin/src/lib/host-instruction-budget.js +1 -2
- package/agent-spine-plugin/src/lib/preflight.js +38 -9
- package/agent-spine-plugin/src/lib/source-roots.js +1 -1
- package/blun.mjs +1930 -560
- package/bundled-agent-sources.json +6 -6
- package/package.json +1 -1
- package/worker-host.mjs +30 -239
|
@@ -506,7 +506,7 @@
|
|
|
506
506
|
"agent-spine-plugin/src/cli-sharing.js": "4a4700510bfcb75fec34033cd270f3ac8e067a14dbcc7c7220613c365a66eb33",
|
|
507
507
|
"agent-spine-plugin/src/cli.js": "9f0e2c486db488234e84f573804268c4e4e9921a71f59c0d69c2003228ce87a3",
|
|
508
508
|
"agent-spine-plugin/src/codex-reader-launcher.js": "be1b50914e7ea10325b8136dd1926a559541cc9c5f5e2fad16a8c047cc2e8180",
|
|
509
|
-
"agent-spine-plugin/src/hook.js": "
|
|
509
|
+
"agent-spine-plugin/src/hook.js": "cfe335e04fc191180a129e5e416e11181dd2475f208c904059eafc9dc4b5a484",
|
|
510
510
|
"agent-spine-plugin/src/index.js": "ef3a85e94c1e70e054b5afa2ea0ccda28ed4c917ade8aba0388ad859bc9a30b5",
|
|
511
511
|
"agent-spine-plugin/src/lib/acceptance.js": "acace8d372e7580831d9f6352d4dc9a132f222ab288632c4c3d765b23b7a0947",
|
|
512
512
|
"agent-spine-plugin/src/lib/action-lesson-recall.js": "9a36d0602ed98bf0f7a374dc4f7702bffa4d5745fe6d1a05db2e4b327b0c3948",
|
|
@@ -554,7 +554,7 @@
|
|
|
554
554
|
"agent-spine-plugin/src/lib/delivery-shell-wrapper.js": "95e178bcf8e1d7ea0bca58aa6aa5ea594bd15cac31f242e0e19250994732cd13",
|
|
555
555
|
"agent-spine-plugin/src/lib/delivery-target.js": "29109a53a1dc487e10a41315194c88c4d9d0b425a07420d3420166f9050aded6",
|
|
556
556
|
"agent-spine-plugin/src/lib/delivery-verification.js": "b9e094ebccf22a15e35505181b6968644087e455ec6826ba2c67ea61a5f2f5cc",
|
|
557
|
-
"agent-spine-plugin/src/lib/documents.js": "
|
|
557
|
+
"agent-spine-plugin/src/lib/documents.js": "49043da206c9948f4400048443772e891ee3367bc6a94e15a48df20f36c22870",
|
|
558
558
|
"agent-spine-plugin/src/lib/feed-transport.js": "5236f0a7010e6896dd1dc28eb56b7562d2c9037da171119bf2b3fe82b7055055",
|
|
559
559
|
"agent-spine-plugin/src/lib/filesystem-retry.js": "eba6335a068b0f5226e7c6b001b2dbadb294ad572098a2b713a3c78449ad785a",
|
|
560
560
|
"agent-spine-plugin/src/lib/gateway-common.js": "18b42c4e28963ecad64091f1b3416332aa829fe13d869efbe6b67c749e31992f",
|
|
@@ -580,7 +580,7 @@
|
|
|
580
580
|
"agent-spine-plugin/src/lib/hook-artifact-guards.js": "9e05895e9353afec815127322baccaed619969c752f6b00154354731afc8fac4",
|
|
581
581
|
"agent-spine-plugin/src/lib/hook-audit.js": "05dee25020febcf628f7474b48cb7cd94dab84dd0127394d6ac80a5a5c91312c",
|
|
582
582
|
"agent-spine-plugin/src/lib/hook-briefing-use.js": "ca4aed816d27f027bcc42600e80fa09d886d975d134a596c003f15603a381ed1",
|
|
583
|
-
"agent-spine-plugin/src/lib/hook-context.js": "
|
|
583
|
+
"agent-spine-plugin/src/lib/hook-context.js": "a2fe610207dbe8e5fb5455aa0d148df8f233fcbe025e8b1007379b875a1fc84a",
|
|
584
584
|
"agent-spine-plugin/src/lib/hook-final-message.js": "364044bba68c211a4b0f0474e5d77b6b3eb9db22fb64faea9bce623e4f4a4c9f",
|
|
585
585
|
"agent-spine-plugin/src/lib/hook-input.js": "61e7257a1b0e06072e6159cf47fad4c97c52d6d7261eafdf0a9ea7f839845891",
|
|
586
586
|
"agent-spine-plugin/src/lib/hook-output.js": "38a05c10e612f8aa449cca3ad25705491825c229191365e114a4978a2b8d32e9",
|
|
@@ -589,7 +589,7 @@
|
|
|
589
589
|
"agent-spine-plugin/src/lib/hook-protection.js": "9a42a3f86c92ae09a6b312faf3b9ea7bbe72e89dd227c3b3468d968cca36628f",
|
|
590
590
|
"agent-spine-plugin/src/lib/hook-stop-verification.js": "f6b4636b2136c8244f4f5deb8cd3fee6fd646b7d6b495093ff0c675411226eb2",
|
|
591
591
|
"agent-spine-plugin/src/lib/hook-timeline.js": "27fcdae15e3b35372f598ee30c1c6ae72afde377e684938fadf76b9fa7b8ee90",
|
|
592
|
-
"agent-spine-plugin/src/lib/host-instruction-budget.js": "
|
|
592
|
+
"agent-spine-plugin/src/lib/host-instruction-budget.js": "214bafaa4dc54405bea73ad78aeb63f78dd27ccd34a27fb4c2245f6c9f578cd0",
|
|
593
593
|
"agent-spine-plugin/src/lib/https-transport.js": "c3482f88851d6c04bffac160bfcc8fb447e8b188abf0e3a1ce5a4d25a3ce2307",
|
|
594
594
|
"agent-spine-plugin/src/lib/identifier-analysis.js": "a925db33ea8efabd3ce0a5fac1e74418b8a95c36fac1fedb4eaf846d0b4bcc76",
|
|
595
595
|
"agent-spine-plugin/src/lib/indexed-memory-offline.js": "0d4c14fcdabda4bbe35c20a5526c8511253839bb310c0c2bfb5dd1abc57e047c",
|
|
@@ -637,7 +637,7 @@
|
|
|
637
637
|
"agent-spine-plugin/src/lib/persona-runtime.js": "1f4c2f44edacc80bf92fc6906c78410ead0e379f2aaf34fed4bda55d4effe393",
|
|
638
638
|
"agent-spine-plugin/src/lib/pre-answer-timeline-recall.js": "50780f8f6ec1578fc06b82cf8f2902a203232964b6745d8155049f5284ff9221",
|
|
639
639
|
"agent-spine-plugin/src/lib/preflight-delivery-id.js": "d1467ac8278de877a44253428c7503991a08cc64f61ec6409f0f153535c7a2a6",
|
|
640
|
-
"agent-spine-plugin/src/lib/preflight.js": "
|
|
640
|
+
"agent-spine-plugin/src/lib/preflight.js": "d3ef8476146c825c110335b38e8fa37ae95313845384251d801df208698dd0e2",
|
|
641
641
|
"agent-spine-plugin/src/lib/project-portfolio.js": "9125715201d97b694827b400c8829cecfbbc142d01b19bd16f92915be08a904f",
|
|
642
642
|
"agent-spine-plugin/src/lib/runtime.js": "e9cb158700de18038651bbb21ac8211fcad8d50b016c7276dd078146a21f5555",
|
|
643
643
|
"agent-spine-plugin/src/lib/selfstarter-core.js": "428ab53db57163b53d6125df914fee14bfbdd555c761cf89993d273f4d92f5a9",
|
|
@@ -672,7 +672,7 @@
|
|
|
672
672
|
"agent-spine-plugin/src/lib/session-timeline-windows-acl.js": "e76fe7834ea45758c38aba39ebe956336785a8978a9edc79bd2873def6657b75",
|
|
673
673
|
"agent-spine-plugin/src/lib/session-timeline.js": "6f14664024b454c3186ecba0b1b4d3402b5fc1e491f7cf5a4787a7be22536c07",
|
|
674
674
|
"agent-spine-plugin/src/lib/sharing.js": "dee040d25122a39d3b44e752d1a22f64331c14bdd800f7b85cb9edc3ca9728b6",
|
|
675
|
-
"agent-spine-plugin/src/lib/source-roots.js": "
|
|
675
|
+
"agent-spine-plugin/src/lib/source-roots.js": "3091993a184e4eccbc08faedca8524810d2589cb606d3b8128a13968a27fc069",
|
|
676
676
|
"agent-spine-plugin/src/lib/source-tree-scan.js": "23bcac5c72aca9c43556fc606e5d37bde43c4ae8ee92017b02a8a5b7098fcbf3",
|
|
677
677
|
"agent-spine-plugin/src/lib/sqlite-transport.js": "5a329d4428c69e67fd56280b7258654572a792c0f03fb11e1f6a95ba8e0cf68a",
|
|
678
678
|
"agent-spine-plugin/src/lib/task-knowledge-context.js": "4163bde2cf3fdcc1b51b4981d4425e996a042a2295e123b5941f360da029e543",
|
package/package.json
CHANGED
package/worker-host.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// BLUN_BUILD_INPUT_SHA256:
|
|
2
|
+
// BLUN_BUILD_INPUT_SHA256:0533ca113dc07cc119988be5e76555dec986b6881903f8e2b537f5adf96cc2c5
|
|
3
3
|
import { fileURLToPath as __cjsShimFileURLToPath } from 'node:url';
|
|
4
4
|
import { dirname as __cjsShimDirname } from 'node:path';
|
|
5
5
|
const __filename = __cjsShimFileURLToPath(import.meta.url);
|
|
6
6
|
const __dirname = __cjsShimDirname(__filename);
|
|
7
7
|
import { createRequire } from "node:module";
|
|
8
|
-
import crypto$1, { createHash,
|
|
8
|
+
import crypto$1, { createHash, randomBytes, randomInt, randomUUID } from "node:crypto";
|
|
9
9
|
import * as fs$12 from "node:fs";
|
|
10
10
|
import Kt, { appendFileSync, chmodSync, closeSync, constants, createReadStream, createWriteStream, existsSync, fstatSync, fsyncSync, linkSync, lstatSync, mkdirSync, openSync, opendirSync, promises, readFileSync, readSync, readdirSync, realpathSync, renameSync, statSync, unlinkSync, writeFileSync, writeSync } from "node:fs";
|
|
11
11
|
import * as path$11 from "node:path";
|
|
@@ -1888,9 +1888,6 @@ var FetchTransport = class {
|
|
|
1888
1888
|
const maxRetries = normalizeMaxRetries(requestOptions?.maxRetries);
|
|
1889
1889
|
const requestBytes = exactBodyBytes(init.body);
|
|
1890
1890
|
const requestBreakdown = pathname === "/chat/completions" && requestOptions?.onTransportAttempt !== void 0 && typeof init.body === "string" && requestBytes !== void 0 ? measureSerializedRequest(init.body, requestBytes) : void 0;
|
|
1891
|
-
if (pathname === "/chat/completions" && typeof init.body === "string") try {
|
|
1892
|
-
requestOptions?.onSerializedRequest?.(init.body);
|
|
1893
|
-
} catch {}
|
|
1894
1891
|
let attempt = 0;
|
|
1895
1892
|
while (true) {
|
|
1896
1893
|
const headers = new Headers(init.headers);
|
|
@@ -1899,9 +1896,6 @@ var FetchTransport = class {
|
|
|
1899
1896
|
const startedAt = performance.now();
|
|
1900
1897
|
const startedAtMs = Date.now();
|
|
1901
1898
|
try {
|
|
1902
|
-
try {
|
|
1903
|
-
requestOptions?.onRequestSent?.();
|
|
1904
|
-
} catch {}
|
|
1905
1899
|
const response = await this.fetch(`${this.baseUrl}${pathname}`, {
|
|
1906
1900
|
...init,
|
|
1907
1901
|
headers
|
|
@@ -2654,13 +2648,6 @@ function collectBlunVisionAttachments(messages) {
|
|
|
2654
2648
|
}
|
|
2655
2649
|
return attachments;
|
|
2656
2650
|
}
|
|
2657
|
-
function estimateBlunRequestExtraBytes(tools, messages) {
|
|
2658
|
-
const attachments = collectBlunVisionAttachments(messages);
|
|
2659
|
-
return {
|
|
2660
|
-
toolsBytes: tools.length === 0 ? 0 : Buffer.byteLength(JSON.stringify({ tools: tools.map(convertTool) }), "utf8"),
|
|
2661
|
-
visionBytes: attachments.length === 0 ? 0 : Buffer.byteLength(JSON.stringify({ visionAttachments: attachments }), "utf8")
|
|
2662
|
-
};
|
|
2663
|
-
}
|
|
2664
2651
|
function convertMessage(message) {
|
|
2665
2652
|
let reasoningContent = "";
|
|
2666
2653
|
const nonThinkParts = [];
|
|
@@ -2970,13 +2957,12 @@ var BlunChatProvider = class {
|
|
|
2970
2957
|
if (this._stream) createParams["stream_options"] = { include_usage: true };
|
|
2971
2958
|
try {
|
|
2972
2959
|
const client = this._createClient(options?.auth);
|
|
2973
|
-
const requestOptions = options?.signal !== void 0 || options?.transportMaxRetries !== void 0 || options?.
|
|
2960
|
+
const requestOptions = options?.signal !== void 0 || options?.transportMaxRetries !== void 0 || options?.onTransportAttempt !== void 0 ? {
|
|
2974
2961
|
...options.signal !== void 0 ? { signal: options.signal } : {},
|
|
2975
2962
|
...options.transportMaxRetries !== void 0 ? { maxRetries: options.transportMaxRetries } : {},
|
|
2976
|
-
...options.onRequestSent !== void 0 ? { onRequestSent: options.onRequestSent } : {},
|
|
2977
|
-
...options.onSerializedRequest !== void 0 ? { onSerializedRequest: options.onSerializedRequest } : {},
|
|
2978
2963
|
...options.onTransportAttempt !== void 0 ? { onTransportAttempt: options.onTransportAttempt } : {}
|
|
2979
2964
|
} : void 0;
|
|
2965
|
+
options?.onRequestSent?.();
|
|
2980
2966
|
let response;
|
|
2981
2967
|
try {
|
|
2982
2968
|
response = await client.chat.completions.create(createParams, requestOptions);
|
|
@@ -2985,6 +2971,7 @@ var BlunChatProvider = class {
|
|
|
2985
2971
|
const cap = rejection instanceof APIContextOverflowError ? contextOverflowOutputCap(rejection, createParams["max_completion_tokens"]) : void 0;
|
|
2986
2972
|
if (cap === void 0) throw rejection;
|
|
2987
2973
|
options?.signal?.throwIfAborted();
|
|
2974
|
+
options?.onRequestSent?.();
|
|
2988
2975
|
response = await client.chat.completions.create({
|
|
2989
2976
|
...createParams,
|
|
2990
2977
|
max_completion_tokens: cap
|
|
@@ -21770,15 +21757,10 @@ async function loadAgentsMdForRoots(kaos, brandHome, workDirs) {
|
|
|
21770
21757
|
const discovered = [];
|
|
21771
21758
|
const emptySources = /* @__PURE__ */ new Map();
|
|
21772
21759
|
const seen = /* @__PURE__ */ new Set();
|
|
21773
|
-
const notLoadedCandidates = /* @__PURE__ */ new Set();
|
|
21774
21760
|
const collect = async (path) => {
|
|
21775
21761
|
const file = await readAgentFile(kaos, path);
|
|
21776
|
-
if (file === void 0)
|
|
21777
|
-
notLoadedCandidates.add(kaos.normpath(path));
|
|
21778
|
-
return false;
|
|
21779
|
-
}
|
|
21762
|
+
if (file === void 0) return false;
|
|
21780
21763
|
const key = kaos.normpath(file.path);
|
|
21781
|
-
notLoadedCandidates.delete(key);
|
|
21782
21764
|
if (file.content.length === 0) {
|
|
21783
21765
|
emptySources.set(key, InstructionText.file(file.path, "", file.sourceTextBytes));
|
|
21784
21766
|
return false;
|
|
@@ -21814,10 +21796,7 @@ async function loadAgentsMdForRoots(kaos, brandHome, workDirs) {
|
|
|
21814
21796
|
return {
|
|
21815
21797
|
content,
|
|
21816
21798
|
warning: totalBytes > AGENTS_MD_RECOMMENDED_MAX_BYTES ? `AGENTS.md total ${formatKB(totalBytes)} KB exceeds the recommended ${formatKB(AGENTS_MD_RECOMMENDED_MAX_BYTES)} KB. Large instruction files increase cost and may impact performance; consider trimming.` : void 0,
|
|
21817
|
-
sources:
|
|
21818
|
-
...rendered.measure(),
|
|
21819
|
-
...notLoadedCandidates.size === 0 ? {} : { notLoadedCandidates: [...notLoadedCandidates] }
|
|
21820
|
-
}
|
|
21799
|
+
sources: rendered.measure()
|
|
21821
21800
|
};
|
|
21822
21801
|
}
|
|
21823
21802
|
async function loadAdditionalDirsInfo(kaos, additionalDirs) {
|
|
@@ -28799,20 +28778,17 @@ function createSystemPromptRenderer(merged) {
|
|
|
28799
28778
|
const counts = renderPromptContributions(merged.systemPromptTemplate, vars, rendered, true) ?? renderPromptContributions(merged.systemPromptTemplate, vars, rendered);
|
|
28800
28779
|
const sources = context.agentsMdSources;
|
|
28801
28780
|
const copies = counts?.instructionCopies ?? 0;
|
|
28802
|
-
const sourceMatches = sources !== void 0 && sources.version === 1 && Number.isSafeInteger(sources.generatedBytes) && sources.generatedBytes >= 0 && sources.files.every((file) => typeof file.path === "string" && Number.isSafeInteger(file.bytes) && file.bytes >= 0) &&
|
|
28803
|
-
const notLoadedCandidates = sourceMatches && sources.notLoadedCandidates !== void 0 ? { notLoadedCandidates: [...sources.notLoadedCandidates] } : {};
|
|
28781
|
+
const sourceMatches = sources !== void 0 && sources.version === 1 && Number.isSafeInteger(sources.generatedBytes) && sources.generatedBytes >= 0 && sources.files.every((file) => typeof file.path === "string" && Number.isSafeInteger(file.bytes) && file.bytes >= 0) && sources.totalBytes === Buffer.byteLength(vars["BLUN_AGENTS_MD"] ?? "", "utf8") && sources.generatedBytes + sources.files.reduce((sum, file) => sum + file.bytes, 0) === sources.totalBytes;
|
|
28804
28782
|
const instructionSources = copies === 0 ? {
|
|
28805
28783
|
version: 1,
|
|
28806
28784
|
totalBytes: 0,
|
|
28807
28785
|
generatedBytes: 0,
|
|
28808
|
-
files: sourceMatches ? sources.files.map((file) => copyInstructionFileBytes(file, 0)) : []
|
|
28809
|
-
...notLoadedCandidates
|
|
28786
|
+
files: sourceMatches ? sources.files.map((file) => copyInstructionFileBytes(file, 0)) : []
|
|
28810
28787
|
} : !sourceMatches ? void 0 : {
|
|
28811
28788
|
version: 1,
|
|
28812
28789
|
totalBytes: sources.totalBytes * copies,
|
|
28813
28790
|
generatedBytes: sources.generatedBytes * copies,
|
|
28814
|
-
files: sources.files.map((file) => copyInstructionFileBytes(file, copies))
|
|
28815
|
-
...notLoadedCandidates
|
|
28791
|
+
files: sources.files.map((file) => copyInstructionFileBytes(file, copies))
|
|
28816
28792
|
};
|
|
28817
28793
|
const skillListingSources = counts === void 0 ? void 0 : scaleSkillListingSources(skillSources, vars["BLUN_SKILLS"] ?? "", counts.skillListingBytes);
|
|
28818
28794
|
context.onContributions(counts === void 0 ? void 0 : {
|
|
@@ -230259,19 +230235,16 @@ var FullCompaction = class {
|
|
|
230259
230235
|
const projected = context.additionalMessages === void 0 ? messages : [...messages, ...context.additionalMessages];
|
|
230260
230236
|
const historyBudget = this.requestHistoryByteBudget(projected);
|
|
230261
230237
|
const historyThresholdReached = historyBudget !== void 0 && historyBudget.usedHistoryBytes >= historyBudget.thresholdHistoryBytes;
|
|
230262
|
-
const requestBudget = this.requestBodyByteBudget(projected, context);
|
|
230263
|
-
const requestThresholdReached = requestBudget !== void 0 && requestBudget.usedRequestBytesEstimate >= requestBudget.thresholdRequestBytes;
|
|
230264
230238
|
if (this.sessionCompactionFailures >= MAX_SESSION_COMPACTION_FAILURES) reason = "session_stopped";
|
|
230265
230239
|
else if (this.isCompacting) reason = "already_compacting";
|
|
230266
|
-
else if (thresholdTokens === void 0 && historyBudget === void 0
|
|
230267
|
-
else if (!historyThresholdReached &&
|
|
230240
|
+
else if (thresholdTokens === void 0 && historyBudget === void 0) reason = "no_budget";
|
|
230241
|
+
else if (!historyThresholdReached && (thresholdTokens === void 0 || !Number.isFinite(usedTokens) || usedTokens < thresholdTokens)) reason = "below_threshold";
|
|
230268
230242
|
else if (!this.hasShrinkableHistory(projected)) reason = "nothing_to_compact";
|
|
230269
230243
|
return {
|
|
230270
230244
|
eligible: reason === "eligible",
|
|
230271
230245
|
usedTokens,
|
|
230272
230246
|
thresholdTokens,
|
|
230273
230247
|
...historyBudget,
|
|
230274
|
-
...requestBudget,
|
|
230275
230248
|
reason
|
|
230276
230249
|
};
|
|
230277
230250
|
}
|
|
@@ -230293,35 +230266,6 @@ var FullCompaction = class {
|
|
|
230293
230266
|
thresholdHistoryBytes: limit
|
|
230294
230267
|
};
|
|
230295
230268
|
}
|
|
230296
|
-
requestBodyByteBudget(messages, context) {
|
|
230297
|
-
const limit = this.agent.blunConfig?.loopControl?.maxRequestHistoryBytes;
|
|
230298
|
-
if (!this.agent.config.hasProvider || this.strategy.compactionBudgetTokens === void 0 || limit === void 0 || !Number.isSafeInteger(limit) || limit <= 0) return void 0;
|
|
230299
|
-
const model = this.agent.activeResponderModel ?? this.agent.config.modelAlias;
|
|
230300
|
-
if (model === void 0 || this.agent.config.runtimeModel(model).provider.name !== "blun") return void 0;
|
|
230301
|
-
const systemPrompt = context.systemPrompt ?? this.agent.effectiveSystemPrompt;
|
|
230302
|
-
const tools = (context.tools ?? this.agent.tools.loopTools).map((tool) => ({
|
|
230303
|
-
name: tool.name,
|
|
230304
|
-
description: tool.description,
|
|
230305
|
-
parameters: tool.parameters
|
|
230306
|
-
}));
|
|
230307
|
-
let extraBytes;
|
|
230308
|
-
try {
|
|
230309
|
-
extraBytes = estimateBlunRequestExtraBytes(tools, messages);
|
|
230310
|
-
} catch {
|
|
230311
|
-
return;
|
|
230312
|
-
}
|
|
230313
|
-
if (Buffer.byteLength(JSON.stringify({
|
|
230314
|
-
systemPrompt,
|
|
230315
|
-
messages: []
|
|
230316
|
-
}), "utf8") + extraBytes.toolsBytes >= BLUN_COMPACTION_REQUEST_BUDGET_BYTES) return void 0;
|
|
230317
|
-
return {
|
|
230318
|
-
usedRequestBytesEstimate: Buffer.byteLength(JSON.stringify({
|
|
230319
|
-
systemPrompt,
|
|
230320
|
-
messages
|
|
230321
|
-
}), "utf8") + extraBytes.toolsBytes + extraBytes.visionBytes,
|
|
230322
|
-
thresholdRequestBytes: BLUN_COMPACTION_REQUEST_BUDGET_BYTES
|
|
230323
|
-
};
|
|
230324
|
-
}
|
|
230325
230269
|
requestProactiveCompaction(context = {}) {
|
|
230326
230270
|
const status = this.proactiveCompactionStatus(context);
|
|
230327
230271
|
if (status.eligible && !this.proactiveCompactionRequested) {
|
|
@@ -230330,9 +230274,7 @@ var FullCompaction = class {
|
|
|
230330
230274
|
used_tokens: status.usedTokens,
|
|
230331
230275
|
threshold_tokens: status.thresholdTokens,
|
|
230332
230276
|
used_history_bytes: status.usedHistoryBytes,
|
|
230333
|
-
threshold_history_bytes: status.thresholdHistoryBytes
|
|
230334
|
-
used_request_bytes_estimate: status.usedRequestBytesEstimate,
|
|
230335
|
-
threshold_request_bytes: status.thresholdRequestBytes
|
|
230277
|
+
threshold_history_bytes: status.thresholdHistoryBytes
|
|
230336
230278
|
});
|
|
230337
230279
|
}
|
|
230338
230280
|
return status;
|
|
@@ -230461,9 +230403,7 @@ var FullCompaction = class {
|
|
|
230461
230403
|
const requestTokens = this.estimateCurrentRequestTokens(requestContext);
|
|
230462
230404
|
const budget = this.getCompactionBudgetTokens();
|
|
230463
230405
|
const historyBudget = this.requestHistoryByteBudget(projectedMessages);
|
|
230464
|
-
const
|
|
230465
|
-
const requestBudget = this.requestBodyByteBudget(projectedMessages, requestContext);
|
|
230466
|
-
const proactive = (requestBudget !== void 0 && requestBudget.usedRequestBytesEstimate >= requestBudget.thresholdRequestBytes || historyThresholdReached || !this.isCompacting && budget !== void 0 && Number.isFinite(requestTokens) && requestTokens >= Math.max(1, Math.floor(budget * .9))) && this.hasShrinkableHistory(projectedMessages);
|
|
230406
|
+
const proactive = (historyBudget !== void 0 && historyBudget.usedHistoryBytes >= historyBudget.thresholdHistoryBytes || !this.isCompacting && budget !== void 0 && Number.isFinite(requestTokens) && requestTokens >= Math.max(1, Math.floor(budget * .9))) && this.hasShrinkableHistory(projectedMessages);
|
|
230467
230407
|
if (this.checkAutoCompaction(true, requestTokens, projectedMessages, proactive) && (proactive || this.strategy.shouldBlock(requestTokens))) await this.block(signal);
|
|
230468
230408
|
signal.throwIfAborted();
|
|
230469
230409
|
const compacted = this.agent.context.history !== historyBefore;
|
|
@@ -239036,32 +238976,6 @@ var import_turn_tool_performance_policy = (/* @__PURE__ */ __commonJSMin(((expor
|
|
|
239036
238976
|
"suchen"
|
|
239037
238977
|
]);
|
|
239038
238978
|
const TOOL_SEARCH_RELATED_TERM_GROUPS = Object.freeze([
|
|
239039
|
-
Object.freeze([
|
|
239040
|
-
"persist",
|
|
239041
|
-
"save",
|
|
239042
|
-
"speichere",
|
|
239043
|
-
"speichern",
|
|
239044
|
-
"store"
|
|
239045
|
-
]),
|
|
239046
|
-
Object.freeze([
|
|
239047
|
-
"erinnerung",
|
|
239048
|
-
"erinnerungen",
|
|
239049
|
-
"fact",
|
|
239050
|
-
"facts",
|
|
239051
|
-
"fakt",
|
|
239052
|
-
"fakten",
|
|
239053
|
-
"memory",
|
|
239054
|
-
"memories",
|
|
239055
|
-
"merk",
|
|
239056
|
-
"merken",
|
|
239057
|
-
"remember"
|
|
239058
|
-
]),
|
|
239059
|
-
Object.freeze([
|
|
239060
|
-
"note",
|
|
239061
|
-
"notes",
|
|
239062
|
-
"notiz",
|
|
239063
|
-
"notizen"
|
|
239064
|
-
]),
|
|
239065
238979
|
Object.freeze([
|
|
239066
238980
|
"checklist",
|
|
239067
238981
|
"list",
|
|
@@ -239320,7 +239234,7 @@ var import_turn_tool_performance_policy = (/* @__PURE__ */ __commonJSMin(((expor
|
|
|
239320
239234
|
if (document.nameTokens.has(token)) exactNameMatches += 1;
|
|
239321
239235
|
else if (relatedSearchTerms(token).some((term) => document.nameTokens.has(term))) relatedNameMatches += 1;
|
|
239322
239236
|
}
|
|
239323
|
-
return matchedTokens >= 2 || exactNameMatches >= 1 && score >= 10 ||
|
|
239237
|
+
return matchedTokens >= 2 || exactNameMatches >= 1 && score >= 10 || relatedNameMatches >= 1 && score >= 5 ? {
|
|
239324
239238
|
name: document.name,
|
|
239325
239239
|
score,
|
|
239326
239240
|
matchedTokens,
|
|
@@ -239341,11 +239255,11 @@ var import_turn_tool_performance_policy = (/* @__PURE__ */ __commonJSMin(((expor
|
|
|
239341
239255
|
function searchRelatedDeferredTools(tools, query, options = {}) {
|
|
239342
239256
|
const normalized = normalizeDeferredToolQuery(query).toLowerCase();
|
|
239343
239257
|
if (!normalized || normalized.startsWith("select:")) return [];
|
|
239344
|
-
const tokens = normalized.
|
|
239258
|
+
const tokens = normalized.split(/\s+/).filter(Boolean);
|
|
239345
239259
|
const requestedNameTokens = tokens.filter((token) => token.startsWith("+")).map((token) => token.slice(1)).filter(Boolean);
|
|
239346
239260
|
const relaxRequiredNameTokens = options.relaxRequiredNameTokens === true && requestedNameTokens.length > 0;
|
|
239347
239261
|
const requiredNameTokens = relaxRequiredNameTokens ? [] : requestedNameTokens;
|
|
239348
|
-
const searchTokens = [...tokens.filter((token) => !token.startsWith("+")), ...relaxRequiredNameTokens ? requestedNameTokens : []].filter((token) => !TOOL_SEARCH_INTENT_WORDS.has(token)
|
|
239262
|
+
const searchTokens = [...tokens.filter((token) => !token.startsWith("+")), ...relaxRequiredNameTokens ? requestedNameTokens : []].filter((token) => !TOOL_SEARCH_INTENT_WORDS.has(token));
|
|
239349
239263
|
if (searchTokens.length < 2 && !TOOL_SEARCH_SINGLE_TERM_RELATED_FALLBACKS.has(searchTokens[0])) return [];
|
|
239350
239264
|
const minimumMatchedTokens = searchTokens.length === 1 ? 1 : Math.max(2, Math.ceil(searchTokens.length * .75));
|
|
239351
239265
|
const ranked = tools.map((tool) => {
|
|
@@ -267676,7 +267590,6 @@ var TurnFlow = class {
|
|
|
267676
267590
|
const appendedMessage = this.agent.context.history.at(-1);
|
|
267677
267591
|
const turnAnchor = appendedMessage !== previousLastMessage && appendedMessage?.role === "user" && appendedMessage.origin === origin ? appendedMessage : void 0;
|
|
267678
267592
|
const startedAt = Date.now();
|
|
267679
|
-
const preRequestHookStartedAt = performance.now();
|
|
267680
267593
|
let ended;
|
|
267681
267594
|
let blockedByUserPromptHook = false;
|
|
267682
267595
|
let completedStopReason;
|
|
@@ -267702,13 +267615,6 @@ var TurnFlow = class {
|
|
|
267702
267615
|
this.agent.log.warn("Turn-start observation failed");
|
|
267703
267616
|
}
|
|
267704
267617
|
signal.throwIfAborted();
|
|
267705
|
-
if (this.agent.type === "main" && process.env["BLUN_DIAG_PRE_REQUEST_PHASES"] === "1") try {
|
|
267706
|
-
this.agent.log.info("turn pre-request phase", {
|
|
267707
|
-
turnId,
|
|
267708
|
-
phase: "turn-hooks",
|
|
267709
|
-
durationMs: Math.max(0, Math.round(performance.now() - preRequestHookStartedAt))
|
|
267710
|
-
});
|
|
267711
|
-
} catch {}
|
|
267712
267618
|
const stopReason = await this.runStepLoop(turnId, signal, input, origin, turnAnchor, (response) => {
|
|
267713
267619
|
completedResponse = response;
|
|
267714
267620
|
});
|
|
@@ -267878,26 +267784,9 @@ var TurnFlow = class {
|
|
|
267878
267784
|
let stopHookContinuationUsed = false;
|
|
267879
267785
|
let goalOutcomeMessageContinuationUsed = false;
|
|
267880
267786
|
const deduper = new ToolCallDeduplicator({ telemetry: this.agent.telemetry });
|
|
267881
|
-
const diagnosePreRequest = this.agent.type === "main" && process.env["BLUN_DIAG_PRE_REQUEST_PHASES"] === "1";
|
|
267882
|
-
const recordPreRequestPhase = (phase, startedAt) => {
|
|
267883
|
-
if (!diagnosePreRequest) return;
|
|
267884
|
-
try {
|
|
267885
|
-
this.agent.log.info("turn pre-request phase", {
|
|
267886
|
-
turnId,
|
|
267887
|
-
phase,
|
|
267888
|
-
durationMs: Math.max(0, Math.round(performance.now() - startedAt))
|
|
267889
|
-
});
|
|
267890
|
-
} catch {}
|
|
267891
|
-
};
|
|
267892
|
-
let phaseStartedAt = performance.now();
|
|
267893
267787
|
await this.agent.mcp?.waitForInitialLoad(signal);
|
|
267894
|
-
recordPreRequestPhase("mcp-initial-load", phaseStartedAt);
|
|
267895
|
-
phaseStartedAt = performance.now();
|
|
267896
267788
|
const personalMemoryRecall = await this.agent.injection.injectPersonalMemoryForTurn(turnId, input, origin, signal);
|
|
267897
|
-
recordPreRequestPhase("personal-memory-recall", phaseStartedAt);
|
|
267898
|
-
phaseStartedAt = performance.now();
|
|
267899
267789
|
await this.agent.injection.injectGoal();
|
|
267900
|
-
recordPreRequestPhase("goal-injection", phaseStartedAt);
|
|
267901
267790
|
this.setActiveSteerAcceptance(turnId, true);
|
|
267902
267791
|
const turnNeedsThinking = blunTurnNeedsTools(blunThinkingIntentInput(input), origin);
|
|
267903
267792
|
let toolInput = input;
|
|
@@ -267908,14 +267797,12 @@ var TurnFlow = class {
|
|
|
267908
267797
|
const raw = [...this.agent.context.history];
|
|
267909
267798
|
const history = personalMemoryRecall === void 0 ? raw : [...raw, personalMemoryRecall];
|
|
267910
267799
|
const selected = taskToolsNeeded ? history : greetingHistory(history, greetingAnchor);
|
|
267911
|
-
const projectionStartedAt = performance.now();
|
|
267912
267800
|
const projected = await this.historicalToolProjection.project(selected, turnAnchor, tools, {
|
|
267913
267801
|
turnId: String(turnId),
|
|
267914
267802
|
stepNumber: this.currentStep,
|
|
267915
267803
|
signal,
|
|
267916
267804
|
llm: turnLLM
|
|
267917
267805
|
});
|
|
267918
|
-
recordPreRequestPhase("historical-tool-projection", projectionStartedAt);
|
|
267919
267806
|
const current = this.agent.context.history;
|
|
267920
267807
|
if (current.length !== raw.length || current.some((message, index) => message !== raw[index])) {
|
|
267921
267808
|
const latest = personalMemoryRecall === void 0 ? current : [...current, personalMemoryRecall];
|
|
@@ -267926,7 +267813,7 @@ var TurnFlow = class {
|
|
|
267926
267813
|
partialContext = selected.length < history.length || projected.changed;
|
|
267927
267814
|
return projected.history;
|
|
267928
267815
|
};
|
|
267929
|
-
const turnLLM = this.agent.llmForTurn(turnNeedsThinking ? void 0 : "off"
|
|
267816
|
+
const turnLLM = this.agent.llmForTurn(turnNeedsThinking ? void 0 : "off");
|
|
267930
267817
|
const turnTools = this.agent.tools.captureTurnTools();
|
|
267931
267818
|
while (true) {
|
|
267932
267819
|
signal.throwIfAborted();
|
|
@@ -267936,7 +267823,6 @@ var TurnFlow = class {
|
|
|
267936
267823
|
try {
|
|
267937
267824
|
const selectedTools = [];
|
|
267938
267825
|
this.refreshSelectedTools = (snapshot) => {
|
|
267939
|
-
const selectionStartedAt = performance.now();
|
|
267940
267826
|
if (snapshot.messages.length > 0) toolInput = snapshot.messages.flatMap((message) => message.content);
|
|
267941
267827
|
const eligibleTools = blunToolsForOrigin(this.agent.injection.filterPersonalMemoryToolsForTurn(turnId, input, origin, turnTools()), origin);
|
|
267942
267828
|
const intent = blunThinkingIntentInput(toolInput);
|
|
@@ -267949,7 +267835,6 @@ var TurnFlow = class {
|
|
|
267949
267835
|
if (tool !== void 0 && !selectedTools.some((candidate) => candidate.name === name) && estimateTokensForTools([...selectedTools, tool]) <= (0, import_turn_tool_performance_policy.toolSchemaBudgetTokens)(this.agent.config.modelCapabilities?.max_context_tokens)) selectedTools.push(tool);
|
|
267950
267836
|
}
|
|
267951
267837
|
} else selectedTools.splice(0, selectedTools.length, ...eligibleTools.filter((tool) => BLUN_LANGUAGE_REVIEW_TOOL_NAMES.has(tool.name) || BLUN_TELEGRAM_OUTBOUND_TOOL_RE.test(tool.name)));
|
|
267952
|
-
recordPreRequestPhase("tool-selection", selectionStartedAt);
|
|
267953
267838
|
return selectedTools;
|
|
267954
267839
|
};
|
|
267955
267840
|
return (await runTurn({
|
|
@@ -267962,24 +267847,14 @@ var TurnFlow = class {
|
|
|
267962
267847
|
}, completion);
|
|
267963
267848
|
},
|
|
267964
267849
|
llm: turnLLM,
|
|
267965
|
-
buildMessages: async () => {
|
|
267966
|
-
|
|
267967
|
-
|
|
267968
|
-
|
|
267969
|
-
|
|
267970
|
-
|
|
267971
|
-
|
|
267972
|
-
|
|
267973
|
-
const messages = this.agent.context.project(await turnHistory(selectedTools), {
|
|
267974
|
-
synthesizeMissing: true,
|
|
267975
|
-
dropOrphanResults: true,
|
|
267976
|
-
dedupeDuplicateToolCalls: true,
|
|
267977
|
-
dropLeadingNonUser: true,
|
|
267978
|
-
mergeConsecutiveAssistants: true
|
|
267979
|
-
});
|
|
267980
|
-
recordPreRequestPhase("message-build-strict", startedAt);
|
|
267981
|
-
return messages;
|
|
267982
|
-
},
|
|
267850
|
+
buildMessages: async () => this.agent.context.project(await turnHistory(selectedTools), { dropOrphanResults: true }),
|
|
267851
|
+
buildMessagesStrict: async () => this.agent.context.project(await turnHistory(selectedTools), {
|
|
267852
|
+
synthesizeMissing: true,
|
|
267853
|
+
dropOrphanResults: true,
|
|
267854
|
+
dedupeDuplicateToolCalls: true,
|
|
267855
|
+
dropLeadingNonUser: true,
|
|
267856
|
+
mergeConsecutiveAssistants: true
|
|
267857
|
+
}),
|
|
267983
267858
|
dispatchEvent: this.buildDispatchEvent(turnId, signal, onFinalResponse, () => partialContext),
|
|
267984
267859
|
tools: selectedTools,
|
|
267985
267860
|
log: this.agent.log,
|
|
@@ -267996,10 +267871,8 @@ var TurnFlow = class {
|
|
|
267996
267871
|
},
|
|
267997
267872
|
hooks: {
|
|
267998
267873
|
beforeStep: async ({ signal: stepSignal, llm }) => {
|
|
267999
|
-
const injectionStartedAt = performance.now();
|
|
268000
267874
|
this.agent.microCompaction.detect();
|
|
268001
267875
|
await this.agent.injection.inject();
|
|
268002
|
-
recordPreRequestPhase("step-injection", injectionStartedAt);
|
|
268003
267876
|
stepSignal.throwIfAborted();
|
|
268004
267877
|
deduper.beginStep();
|
|
268005
267878
|
},
|
|
@@ -271665,13 +271538,8 @@ var LlmRequestLogger = class {
|
|
|
271665
271538
|
toolsEstimatedTokens = 0;
|
|
271666
271539
|
requestSequence = 0;
|
|
271667
271540
|
lastTurnRequest;
|
|
271668
|
-
|
|
271669
|
-
requestSignatures = /* @__PURE__ */ new Map();
|
|
271670
|
-
prefixComparisons = /* @__PURE__ */ new Map();
|
|
271671
|
-
lastSerializedRequest;
|
|
271672
|
-
constructor(log, serializedPrefixDiagnostic = process.env["BLUN_DIAG_SERIALIZED_PREFIX"] === "1") {
|
|
271541
|
+
constructor(log) {
|
|
271673
271542
|
this.log = log;
|
|
271674
|
-
this.serializedPrefixKey = serializedPrefixDiagnostic ? randomBytes(32) : void 0;
|
|
271675
271543
|
}
|
|
271676
271544
|
logRequest(input) {
|
|
271677
271545
|
const sequence = ++this.requestSequence;
|
|
@@ -271688,10 +271556,6 @@ var LlmRequestLogger = class {
|
|
|
271688
271556
|
toolsHash: fingerprint(JSON.stringify(toolSignature(tools)))
|
|
271689
271557
|
};
|
|
271690
271558
|
const signature = JSON.stringify(config);
|
|
271691
|
-
if (this.serializedPrefixKey !== void 0) {
|
|
271692
|
-
this.requestSignatures.set(sequence, signature);
|
|
271693
|
-
if (this.requestSignatures.size > 32) this.requestSignatures.delete(this.requestSignatures.keys().next().value);
|
|
271694
|
-
}
|
|
271695
271559
|
if (signature !== this.lastConfigLogSignature) {
|
|
271696
271560
|
this.lastConfigLogSignature = signature;
|
|
271697
271561
|
this.configRevision++;
|
|
@@ -271721,20 +271585,6 @@ var LlmRequestLogger = class {
|
|
|
271721
271585
|
}
|
|
271722
271586
|
};
|
|
271723
271587
|
if (partialMessageCount > 0) requestFields.partialMessageCount = partialMessageCount;
|
|
271724
|
-
const source = input.systemPromptContributions;
|
|
271725
|
-
if (source?.version === 1 && [
|
|
271726
|
-
source.totalBytes,
|
|
271727
|
-
source.instructionBytes,
|
|
271728
|
-
source.skillListingBytes,
|
|
271729
|
-
source.runtimeMemoryBytes,
|
|
271730
|
-
source.otherBytes
|
|
271731
|
-
].every((value) => Number.isSafeInteger(value) && value >= 0) && source.instructionBytes + source.skillListingBytes + source.runtimeMemoryBytes + source.otherBytes === source.totalBytes && source.totalBytes === Buffer.byteLength(systemPrompt, "utf8")) requestFields.systemPromptSourceBytes = {
|
|
271732
|
-
totalBytes: source.totalBytes,
|
|
271733
|
-
instructionBytes: source.instructionBytes,
|
|
271734
|
-
skillListingBytes: source.skillListingBytes,
|
|
271735
|
-
runtimeMemoryBytes: source.runtimeMemoryBytes,
|
|
271736
|
-
otherBytes: source.otherBytes
|
|
271737
|
-
};
|
|
271738
271588
|
this.log.info("llm request", requestFields);
|
|
271739
271589
|
if (fields?.turnStep !== void 0 && /^\d+\.\d+$/.test(fields.turnStep)) {
|
|
271740
271590
|
const historyTextOrigins = summarizeRequestTextOrigins(messages);
|
|
@@ -271760,51 +271610,10 @@ var LlmRequestLogger = class {
|
|
|
271760
271610
|
getLastTurnRequest() {
|
|
271761
271611
|
return this.lastTurnRequest === void 0 ? void 0 : structuredClone(this.lastTurnRequest);
|
|
271762
271612
|
}
|
|
271763
|
-
get serializedPrefixDiagnosticEnabled() {
|
|
271764
|
-
return this.serializedPrefixKey !== void 0;
|
|
271765
|
-
}
|
|
271766
|
-
observeSerializedRequest(body, fields, sequence) {
|
|
271767
|
-
const key = this.serializedPrefixKey;
|
|
271768
|
-
if (key === void 0 || !/^\d+\.\d+$/.test(fields?.turnStep ?? "")) return;
|
|
271769
|
-
const signature = this.requestSignatures.get(sequence);
|
|
271770
|
-
if (signature === void 0) return;
|
|
271771
|
-
try {
|
|
271772
|
-
const bytes = Buffer.from(body, "utf8");
|
|
271773
|
-
const granularityBytes = 1024;
|
|
271774
|
-
const chunks = [];
|
|
271775
|
-
for (let start = 0; start + granularityBytes <= bytes.length; start += granularityBytes) chunks.push(createHmac("sha256", key).update(bytes.subarray(start, start + granularityBytes)).digest("hex"));
|
|
271776
|
-
const previous = this.lastSerializedRequest;
|
|
271777
|
-
if (previous !== void 0 && previous.signature === signature) {
|
|
271778
|
-
let common = 0;
|
|
271779
|
-
while (common < previous.chunks.length && common < chunks.length && previous.chunks[common] === chunks[common]) common++;
|
|
271780
|
-
this.prefixComparisons.set(sequence, {
|
|
271781
|
-
version: 1,
|
|
271782
|
-
granularityBytes,
|
|
271783
|
-
previousBytes: previous.bytes,
|
|
271784
|
-
currentBytes: bytes.length,
|
|
271785
|
-
commonPrefixBytesLowerBound: common * granularityBytes,
|
|
271786
|
-
previousSequence: previous.sequence,
|
|
271787
|
-
currentSequence: sequence
|
|
271788
|
-
});
|
|
271789
|
-
if (this.prefixComparisons.size > 32) this.prefixComparisons.delete(this.prefixComparisons.keys().next().value);
|
|
271790
|
-
}
|
|
271791
|
-
this.lastSerializedRequest = {
|
|
271792
|
-
sequence,
|
|
271793
|
-
signature,
|
|
271794
|
-
bytes: bytes.length,
|
|
271795
|
-
chunks
|
|
271796
|
-
};
|
|
271797
|
-
} catch {
|
|
271798
|
-
this.lastSerializedRequest = void 0;
|
|
271799
|
-
}
|
|
271800
|
-
}
|
|
271801
271613
|
logTransportAttempt(stats, fields, sequence) {
|
|
271802
|
-
const serializedPrefix = sequence === void 0 ? void 0 : this.prefixComparisons.get(sequence);
|
|
271803
271614
|
this.log.info("llm transport attempt", {
|
|
271804
271615
|
...fields,
|
|
271805
|
-
...stats
|
|
271806
|
-
...this.serializedPrefixKey === void 0 || sequence === void 0 ? {} : { requestSequence: sequence },
|
|
271807
|
-
...serializedPrefix === void 0 ? {} : { serializedPrefix }
|
|
271616
|
+
...stats
|
|
271808
271617
|
});
|
|
271809
271618
|
if (sequence === void 0 || this.lastTurnRequest?.sequence !== sequence) return;
|
|
271810
271619
|
const breakdown = stats.requestBreakdown;
|
|
@@ -271887,8 +271696,7 @@ function copyContributions(value) {
|
|
|
271887
271696
|
version: source.version,
|
|
271888
271697
|
totalBytes: source.totalBytes,
|
|
271889
271698
|
generatedBytes: source.generatedBytes,
|
|
271890
|
-
files: source.files.map((file) => copyInstructionFileBytes(file))
|
|
271891
|
-
...source.notLoadedCandidates === void 0 ? {} : { notLoadedCandidates: [...source.notLoadedCandidates] }
|
|
271699
|
+
files: source.files.map((file) => copyInstructionFileBytes(file))
|
|
271892
271700
|
} }
|
|
271893
271701
|
};
|
|
271894
271702
|
}
|
|
@@ -271984,7 +271792,6 @@ var Agent$1 = class {
|
|
|
271984
271792
|
errorMemory;
|
|
271985
271793
|
replayBuilder;
|
|
271986
271794
|
additionalDirs;
|
|
271987
|
-
systemPromptStartedAt = /* @__PURE__ */ new Date();
|
|
271988
271795
|
activeProfile;
|
|
271989
271796
|
brandHome;
|
|
271990
271797
|
_activeResponderModel;
|
|
@@ -272072,7 +271879,6 @@ var Agent$1 = class {
|
|
|
272072
271879
|
const retryScope = providerRetryScope(modelAlias, provider);
|
|
272073
271880
|
await this.providerRetryWait.wait(retryScope, generateOptions?.signal);
|
|
272074
271881
|
const callerTransportAttempt = generateOptions?.onTransportAttempt;
|
|
272075
|
-
const callerSerializedRequest = generateOptions?.onSerializedRequest;
|
|
272076
271882
|
const ownedGenerateOptions = {
|
|
272077
271883
|
...generateOptions,
|
|
272078
271884
|
transportMaxRetries: 0
|
|
@@ -272095,12 +271901,6 @@ var Agent$1 = class {
|
|
|
272095
271901
|
callerTransportAttempt?.(stats);
|
|
272096
271902
|
this.llmRequestLogger.logTransportAttempt(stats, requestLogFields, requestSequence);
|
|
272097
271903
|
},
|
|
272098
|
-
...callerSerializedRequest !== void 0 || this.llmRequestLogger.serializedPrefixDiagnosticEnabled ? { onSerializedRequest: (body) => {
|
|
272099
|
-
try {
|
|
272100
|
-
callerSerializedRequest?.(body);
|
|
272101
|
-
} catch {}
|
|
272102
|
-
this.llmRequestLogger.observeSerializedRequest(body, requestLogFields, requestSequence);
|
|
272103
|
-
} } : {},
|
|
272104
271904
|
onRequestStart: () => {
|
|
272105
271905
|
requestOptions?.onRequestStart?.();
|
|
272106
271906
|
requestStarted = true;
|
|
@@ -272126,7 +271926,7 @@ var Agent$1 = class {
|
|
|
272126
271926
|
get llm() {
|
|
272127
271927
|
return this.llmForTurn();
|
|
272128
271928
|
}
|
|
272129
|
-
llmForTurn(thinkingEffort
|
|
271929
|
+
llmForTurn(thinkingEffort) {
|
|
272130
271930
|
const selectedAlias = this.config.model;
|
|
272131
271931
|
const modelProvider = this.modelProvider;
|
|
272132
271932
|
if (modelProvider === void 0) throw new BlunError(ErrorCodes.MODEL_NOT_CONFIGURED, "Provider not set");
|
|
@@ -272141,7 +271941,6 @@ var Agent$1 = class {
|
|
|
272141
271941
|
messages: await rebuildMessages()
|
|
272142
271942
|
};
|
|
272143
271943
|
let systemPrompt = this.effectiveSystemPrompt;
|
|
272144
|
-
const preflightStartedAt = performance.now();
|
|
272145
271944
|
const compacted = await this.fullCompaction.beforeStep(params.signal, {
|
|
272146
271945
|
messages: params.messages,
|
|
272147
271946
|
additionalMessages: steers.messages,
|
|
@@ -272150,13 +271949,6 @@ var Agent$1 = class {
|
|
|
272150
271949
|
rebuildSystemPrompt: () => systemPrompt = this.effectiveSystemPrompt,
|
|
272151
271950
|
tools: params.tools
|
|
272152
271951
|
});
|
|
272153
|
-
if (this.type === "main" && diagnosticTurnId !== void 0 && process.env["BLUN_DIAG_PRE_REQUEST_PHASES"] === "1") try {
|
|
272154
|
-
this.log.info("turn pre-request phase", {
|
|
272155
|
-
turnId: diagnosticTurnId,
|
|
272156
|
-
phase: "compaction-preflight",
|
|
272157
|
-
durationMs: Math.max(0, Math.round(performance.now() - preflightStartedAt))
|
|
272158
|
-
});
|
|
272159
|
-
} catch {}
|
|
272160
271952
|
const tools = params.tools.some((tool) => tool.name === "CompactConversation") && !this.fullCompaction.proactiveCompactionStatus({
|
|
272161
271953
|
messages: compacted ? await rebuildMessages() : params.messages,
|
|
272162
271954
|
additionalMessages: steers.messages,
|
|
@@ -272261,7 +272053,6 @@ var Agent$1 = class {
|
|
|
272261
272053
|
let contributions;
|
|
272262
272054
|
const systemPrompt = profile.systemPrompt({
|
|
272263
272055
|
osEnv: this.kaos.osEnv,
|
|
272264
|
-
now: this.systemPromptStartedAt,
|
|
272265
272056
|
cwd: this.config.cwd,
|
|
272266
272057
|
skills: this.skills?.registry,
|
|
272267
272058
|
cwdListing: context?.cwdListing,
|