blun-king-cli 9.1.613 → 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 +4 -0
- package/LIESMICH.txt +1 -1
- package/README.md +1 -1
- 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 +16 -5
- package/agent-spine-plugin/src/lib/source-roots.js +1 -1
- package/blun.mjs +389 -236
- package/bundled-agent-sources.json +5 -5
- package/package.json +1 -1
- package/worker-host.mjs +52 -430
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
|
|
@@ -1959,6 +1953,16 @@ function measureSerializedRequest(body, requestBytes) {
|
|
|
1959
1953
|
const payload = parsed;
|
|
1960
1954
|
const messages = Array.isArray(payload["messages"]) ? payload["messages"] : [];
|
|
1961
1955
|
const tools = Array.isArray(payload["tools"]) ? payload["tools"] : void 0;
|
|
1956
|
+
let systemMessageBytes = 0;
|
|
1957
|
+
let conversationMessageBytes = 0;
|
|
1958
|
+
let toolResultMessageBytes = 0;
|
|
1959
|
+
for (const message of messages) {
|
|
1960
|
+
const size = Buffer.byteLength(JSON.stringify(message), "utf8");
|
|
1961
|
+
const role = message !== null && typeof message === "object" ? message["role"] : void 0;
|
|
1962
|
+
if (role === "system" || role === "developer") systemMessageBytes += size;
|
|
1963
|
+
else if (role === "tool") toolResultMessageBytes += size;
|
|
1964
|
+
else conversationMessageBytes += size;
|
|
1965
|
+
}
|
|
1962
1966
|
const toolDefinitions = Object.freeze((tools ?? []).map((tool, index) => {
|
|
1963
1967
|
const entry = tool !== null && typeof tool === "object" ? tool : void 0;
|
|
1964
1968
|
const fn = entry?.["function"];
|
|
@@ -1969,44 +1973,6 @@ function measureSerializedRequest(body, requestBytes) {
|
|
|
1969
1973
|
...typeof name === "string" && name.length > 0 && name.length <= 128 ? { name } : {}
|
|
1970
1974
|
});
|
|
1971
1975
|
}));
|
|
1972
|
-
const declaredNames = new Set(toolDefinitions.flatMap((tool) => tool.name === void 0 ? [] : [tool.name]));
|
|
1973
|
-
const callNames = /* @__PURE__ */ new Map();
|
|
1974
|
-
for (const message of messages) {
|
|
1975
|
-
if (message === null || typeof message !== "object" || message["role"] !== "assistant") continue;
|
|
1976
|
-
const calls = message["tool_calls"];
|
|
1977
|
-
if (!Array.isArray(calls)) continue;
|
|
1978
|
-
for (const call of calls) {
|
|
1979
|
-
if (call === null || typeof call !== "object") continue;
|
|
1980
|
-
const entry = call;
|
|
1981
|
-
const fn = entry["function"];
|
|
1982
|
-
const name = fn !== null && typeof fn === "object" ? fn["name"] : void 0;
|
|
1983
|
-
const id = entry["id"];
|
|
1984
|
-
if (typeof id !== "string" || id.length === 0) continue;
|
|
1985
|
-
callNames.set(id, callNames.has(id) ? void 0 : typeof name === "string" && declaredNames.has(name) ? name : void 0);
|
|
1986
|
-
}
|
|
1987
|
-
}
|
|
1988
|
-
let systemMessageBytes = 0;
|
|
1989
|
-
let conversationMessageBytes = 0;
|
|
1990
|
-
let toolResultMessageBytes = 0;
|
|
1991
|
-
const results = /* @__PURE__ */ new Map();
|
|
1992
|
-
for (const message of messages) {
|
|
1993
|
-
const size = Buffer.byteLength(JSON.stringify(message), "utf8");
|
|
1994
|
-
const role = message !== null && typeof message === "object" ? message["role"] : void 0;
|
|
1995
|
-
if (role === "system" || role === "developer") systemMessageBytes += size;
|
|
1996
|
-
else if (role === "tool") {
|
|
1997
|
-
toolResultMessageBytes += size;
|
|
1998
|
-
const id = message["tool_call_id"];
|
|
1999
|
-
const name = typeof id === "string" ? callNames.get(id) : void 0;
|
|
2000
|
-
const key = name ?? "";
|
|
2001
|
-
const previous = results.get(key);
|
|
2002
|
-
results.set(key, {
|
|
2003
|
-
...name === void 0 ? {} : { name },
|
|
2004
|
-
count: (previous?.count ?? 0) + 1,
|
|
2005
|
-
bytes: (previous?.bytes ?? 0) + size
|
|
2006
|
-
});
|
|
2007
|
-
} else conversationMessageBytes += size;
|
|
2008
|
-
}
|
|
2009
|
-
const toolResultByTool = Object.freeze(Array.from(results.values(), (entry) => Object.freeze(entry)));
|
|
2010
1976
|
const toolArrayOverheadBytes = tools === void 0 ? 0 : 2 + Math.max(0, tools.length - 1);
|
|
2011
1977
|
const toolSchemaBytes = toolDefinitions.reduce((sum, tool) => sum + tool.bytes, toolArrayOverheadBytes);
|
|
2012
1978
|
return Object.freeze({
|
|
@@ -2016,7 +1982,6 @@ function measureSerializedRequest(body, requestBytes) {
|
|
|
2016
1982
|
systemMessageBytes,
|
|
2017
1983
|
conversationMessageBytes,
|
|
2018
1984
|
toolResultMessageBytes,
|
|
2019
|
-
...toolResultByTool.length === 0 ? {} : { toolResultByTool },
|
|
2020
1985
|
toolSchemaBytes,
|
|
2021
1986
|
toolDefinitions,
|
|
2022
1987
|
toolArrayOverheadBytes,
|
|
@@ -2401,9 +2366,6 @@ function extractChatCompletionUsage(usage) {
|
|
|
2401
2366
|
const value = usage;
|
|
2402
2367
|
const promptTokens = typeof value["prompt_tokens"] === "number" ? value["prompt_tokens"] : 0;
|
|
2403
2368
|
const completionTokens = typeof value["completion_tokens"] === "number" ? value["completion_tokens"] : 0;
|
|
2404
|
-
const completionDetails = value["completion_tokens_details"];
|
|
2405
|
-
const reportedReasoning = completionDetails !== null && typeof completionDetails === "object" ? completionDetails["reasoning_tokens"] : void 0;
|
|
2406
|
-
const outputReasoning = typeof reportedReasoning === "number" && Number.isSafeInteger(reportedReasoning) && reportedReasoning >= 0 && reportedReasoning <= completionTokens ? reportedReasoning : void 0;
|
|
2407
2369
|
let cachedTokens = 0;
|
|
2408
2370
|
if (typeof value["cached_tokens"] === "number") cachedTokens = value["cached_tokens"];
|
|
2409
2371
|
else if (value["prompt_tokens_details"] !== null && typeof value["prompt_tokens_details"] === "object") {
|
|
@@ -2413,7 +2375,6 @@ function extractChatCompletionUsage(usage) {
|
|
|
2413
2375
|
return {
|
|
2414
2376
|
inputOther: promptTokens - cachedTokens,
|
|
2415
2377
|
output: completionTokens,
|
|
2416
|
-
...outputReasoning === void 0 ? {} : { outputReasoning },
|
|
2417
2378
|
inputCacheRead: cachedTokens,
|
|
2418
2379
|
inputCacheCreation: 0
|
|
2419
2380
|
};
|
|
@@ -2687,13 +2648,6 @@ function collectBlunVisionAttachments(messages) {
|
|
|
2687
2648
|
}
|
|
2688
2649
|
return attachments;
|
|
2689
2650
|
}
|
|
2690
|
-
function estimateBlunRequestExtraBytes(tools, messages) {
|
|
2691
|
-
const attachments = collectBlunVisionAttachments(messages);
|
|
2692
|
-
return {
|
|
2693
|
-
toolsBytes: tools.length === 0 ? 0 : Buffer.byteLength(JSON.stringify({ tools: tools.map(convertTool) }), "utf8"),
|
|
2694
|
-
visionBytes: attachments.length === 0 ? 0 : Buffer.byteLength(JSON.stringify({ visionAttachments: attachments }), "utf8")
|
|
2695
|
-
};
|
|
2696
|
-
}
|
|
2697
2651
|
function convertMessage(message) {
|
|
2698
2652
|
let reasoningContent = "";
|
|
2699
2653
|
const nonThinkParts = [];
|
|
@@ -3003,13 +2957,12 @@ var BlunChatProvider = class {
|
|
|
3003
2957
|
if (this._stream) createParams["stream_options"] = { include_usage: true };
|
|
3004
2958
|
try {
|
|
3005
2959
|
const client = this._createClient(options?.auth);
|
|
3006
|
-
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 ? {
|
|
3007
2961
|
...options.signal !== void 0 ? { signal: options.signal } : {},
|
|
3008
2962
|
...options.transportMaxRetries !== void 0 ? { maxRetries: options.transportMaxRetries } : {},
|
|
3009
|
-
...options.onRequestSent !== void 0 ? { onRequestSent: options.onRequestSent } : {},
|
|
3010
|
-
...options.onSerializedRequest !== void 0 ? { onSerializedRequest: options.onSerializedRequest } : {},
|
|
3011
2963
|
...options.onTransportAttempt !== void 0 ? { onTransportAttempt: options.onTransportAttempt } : {}
|
|
3012
2964
|
} : void 0;
|
|
2965
|
+
options?.onRequestSent?.();
|
|
3013
2966
|
let response;
|
|
3014
2967
|
try {
|
|
3015
2968
|
response = await client.chat.completions.create(createParams, requestOptions);
|
|
@@ -3018,6 +2971,7 @@ var BlunChatProvider = class {
|
|
|
3018
2971
|
const cap = rejection instanceof APIContextOverflowError ? contextOverflowOutputCap(rejection, createParams["max_completion_tokens"]) : void 0;
|
|
3019
2972
|
if (cap === void 0) throw rejection;
|
|
3020
2973
|
options?.signal?.throwIfAborted();
|
|
2974
|
+
options?.onRequestSent?.();
|
|
3021
2975
|
response = await client.chat.completions.create({
|
|
3022
2976
|
...createParams,
|
|
3023
2977
|
max_completion_tokens: cap
|
|
@@ -3404,11 +3358,9 @@ function emptyUsage() {
|
|
|
3404
3358
|
* Sum two TokenUsage values.
|
|
3405
3359
|
*/
|
|
3406
3360
|
function addUsage(a, b) {
|
|
3407
|
-
const outputReasoning = a.outputReasoning !== void 0 && b.outputReasoning !== void 0 ? a.outputReasoning + b.outputReasoning : a.output === 0 ? b.outputReasoning : b.output === 0 ? a.outputReasoning : void 0;
|
|
3408
3361
|
return {
|
|
3409
3362
|
inputOther: a.inputOther + b.inputOther,
|
|
3410
3363
|
output: a.output + b.output,
|
|
3411
|
-
...outputReasoning === void 0 ? {} : { outputReasoning },
|
|
3412
3364
|
inputCacheRead: a.inputCacheRead + b.inputCacheRead,
|
|
3413
3365
|
inputCacheCreation: a.inputCacheCreation + b.inputCacheCreation
|
|
3414
3366
|
};
|
|
@@ -9818,8 +9770,6 @@ const StringRecordSchema = record$2(string(), string());
|
|
|
9818
9770
|
const ProviderConfigSchema = object({
|
|
9819
9771
|
type: ProviderTypeSchema,
|
|
9820
9772
|
apiKey: string().optional(),
|
|
9821
|
-
memoryWorkspaceId: string().regex(/^blun-[0-9a-f]{64}$/u).optional(),
|
|
9822
|
-
memoryApiKeyHash: string().regex(/^[0-9a-f]{64}$/u).optional(),
|
|
9823
9773
|
baseUrl: string().optional(),
|
|
9824
9774
|
defaultModel: string().optional(),
|
|
9825
9775
|
oauth: OAuthRefSchema.optional(),
|
|
@@ -10368,8 +10318,7 @@ function tokenToWire(token) {
|
|
|
10368
10318
|
expires_at: token.expiresAt,
|
|
10369
10319
|
scope: token.scope,
|
|
10370
10320
|
token_type: token.tokenType,
|
|
10371
|
-
expires_in: token.expiresIn
|
|
10372
|
-
...token.memoryWorkspaceId === void 0 ? {} : { memory_workspace_id: token.memoryWorkspaceId }
|
|
10321
|
+
expires_in: token.expiresIn
|
|
10373
10322
|
};
|
|
10374
10323
|
}
|
|
10375
10324
|
function tokenFromWire(wire) {
|
|
@@ -10379,8 +10328,7 @@ function tokenFromWire(wire) {
|
|
|
10379
10328
|
expiresAt: typeof wire.expires_at === "number" ? wire.expires_at : 0,
|
|
10380
10329
|
scope: wire.scope ?? "",
|
|
10381
10330
|
tokenType: wire.token_type ?? "",
|
|
10382
|
-
expiresIn: typeof wire.expires_in === "number" ? wire.expires_in : 0
|
|
10383
|
-
...typeof wire.memory_workspace_id === "string" && wire.memory_workspace_id.length > 0 ? { memoryWorkspaceId: wire.memory_workspace_id } : {}
|
|
10331
|
+
expiresIn: typeof wire.expires_in === "number" ? wire.expires_in : 0
|
|
10384
10332
|
};
|
|
10385
10333
|
}
|
|
10386
10334
|
//#endregion
|
|
@@ -12771,27 +12719,6 @@ var OAuthManager = class {
|
|
|
12771
12719
|
const state = await this.loadState();
|
|
12772
12720
|
return state.kind === "valid" ? state.token.accessToken : void 0;
|
|
12773
12721
|
}
|
|
12774
|
-
async getCachedMemoryWorkspaceId() {
|
|
12775
|
-
const state = await this.loadState();
|
|
12776
|
-
return state.kind === "valid" && state.token.expiresAt > this.now() ? state.token.memoryWorkspaceId : void 0;
|
|
12777
|
-
}
|
|
12778
|
-
async cacheMemoryWorkspaceId(workspaceId) {
|
|
12779
|
-
if (workspaceId.length === 0) return false;
|
|
12780
|
-
const release = await this.acquireRefreshLock();
|
|
12781
|
-
try {
|
|
12782
|
-
const state = await this.loadState();
|
|
12783
|
-
if (state.kind !== "valid" || state.token.expiresAt <= this.now()) return false;
|
|
12784
|
-
if (state.token.memoryWorkspaceId === workspaceId) return true;
|
|
12785
|
-
if (state.token.memoryWorkspaceId !== void 0) return false;
|
|
12786
|
-
await this.storage.save(this.config.name, {
|
|
12787
|
-
...state.token,
|
|
12788
|
-
memoryWorkspaceId: workspaceId
|
|
12789
|
-
});
|
|
12790
|
-
return true;
|
|
12791
|
-
} finally {
|
|
12792
|
-
await release();
|
|
12793
|
-
}
|
|
12794
|
-
}
|
|
12795
12722
|
async logout() {
|
|
12796
12723
|
await this.inFlightRefresh?.promise.catch(() => void 0);
|
|
12797
12724
|
const release = await this.acquireRefreshLock();
|
|
@@ -12859,10 +12786,7 @@ var OAuthManager = class {
|
|
|
12859
12786
|
if (activeToken.refreshToken.length === 0) throw new OAuthUnauthorizedError(`Token for "${this.config.name}" has no refresh_token; re-login required.`);
|
|
12860
12787
|
try {
|
|
12861
12788
|
const refreshed = await this.refreshImpl(this.config, activeToken.refreshToken);
|
|
12862
|
-
await this.storage.save(this.config.name,
|
|
12863
|
-
...refreshed,
|
|
12864
|
-
memoryWorkspaceId: activeToken.memoryWorkspaceId
|
|
12865
|
-
});
|
|
12789
|
+
await this.storage.save(this.config.name, refreshed);
|
|
12866
12790
|
this.notifyRefresh({ success: true });
|
|
12867
12791
|
return refreshed.accessToken;
|
|
12868
12792
|
} catch (error) {
|
|
@@ -14239,16 +14163,6 @@ var BlunOAuthToolkit = class {
|
|
|
14239
14163
|
hasToken: await this.managerFor(name, oauthKey, oauthHost).hasToken()
|
|
14240
14164
|
}] };
|
|
14241
14165
|
}
|
|
14242
|
-
async getCachedMemoryWorkspaceId(oauthRef) {
|
|
14243
|
-
const oauthHost = this.oauthHostFor(oauthRef);
|
|
14244
|
-
const oauthKey = oauthRef?.key ?? this.defaultOAuthKey(void 0, oauthHost);
|
|
14245
|
-
return this.managerFor(BLUN_PROVIDER_NAME$1, oauthKey, oauthHost).getCachedMemoryWorkspaceId();
|
|
14246
|
-
}
|
|
14247
|
-
async cacheMemoryWorkspaceId(workspaceId, oauthRef) {
|
|
14248
|
-
const oauthHost = this.oauthHostFor(oauthRef);
|
|
14249
|
-
const oauthKey = oauthRef?.key ?? this.defaultOAuthKey(void 0, oauthHost);
|
|
14250
|
-
return this.managerFor(BLUN_PROVIDER_NAME$1, oauthKey, oauthHost).cacheMemoryWorkspaceId(workspaceId);
|
|
14251
|
-
}
|
|
14252
14166
|
async login(providerName, options = {}) {
|
|
14253
14167
|
const name = providerName ?? "managed:blun";
|
|
14254
14168
|
const oauthHost = this.oauthHostFor(options.oauthRef, options.oauthHost);
|
|
@@ -16316,8 +16230,6 @@ function providerToToml(provider, rawProvider) {
|
|
|
16316
16230
|
for (const key of [
|
|
16317
16231
|
"type",
|
|
16318
16232
|
"apiKey",
|
|
16319
|
-
"memoryWorkspaceId",
|
|
16320
|
-
"memoryApiKeyHash",
|
|
16321
16233
|
"baseUrl",
|
|
16322
16234
|
"defaultModel",
|
|
16323
16235
|
"oauth",
|
|
@@ -21845,15 +21757,10 @@ async function loadAgentsMdForRoots(kaos, brandHome, workDirs) {
|
|
|
21845
21757
|
const discovered = [];
|
|
21846
21758
|
const emptySources = /* @__PURE__ */ new Map();
|
|
21847
21759
|
const seen = /* @__PURE__ */ new Set();
|
|
21848
|
-
const notLoadedCandidates = /* @__PURE__ */ new Set();
|
|
21849
21760
|
const collect = async (path) => {
|
|
21850
21761
|
const file = await readAgentFile(kaos, path);
|
|
21851
|
-
if (file === void 0)
|
|
21852
|
-
notLoadedCandidates.add(kaos.normpath(path));
|
|
21853
|
-
return false;
|
|
21854
|
-
}
|
|
21762
|
+
if (file === void 0) return false;
|
|
21855
21763
|
const key = kaos.normpath(file.path);
|
|
21856
|
-
notLoadedCandidates.delete(key);
|
|
21857
21764
|
if (file.content.length === 0) {
|
|
21858
21765
|
emptySources.set(key, InstructionText.file(file.path, "", file.sourceTextBytes));
|
|
21859
21766
|
return false;
|
|
@@ -21889,10 +21796,7 @@ async function loadAgentsMdForRoots(kaos, brandHome, workDirs) {
|
|
|
21889
21796
|
return {
|
|
21890
21797
|
content,
|
|
21891
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,
|
|
21892
|
-
sources:
|
|
21893
|
-
...rendered.measure(),
|
|
21894
|
-
...notLoadedCandidates.size === 0 ? {} : { notLoadedCandidates: [...notLoadedCandidates] }
|
|
21895
|
-
}
|
|
21799
|
+
sources: rendered.measure()
|
|
21896
21800
|
};
|
|
21897
21801
|
}
|
|
21898
21802
|
async function loadAdditionalDirsInfo(kaos, additionalDirs) {
|
|
@@ -28874,20 +28778,17 @@ function createSystemPromptRenderer(merged) {
|
|
|
28874
28778
|
const counts = renderPromptContributions(merged.systemPromptTemplate, vars, rendered, true) ?? renderPromptContributions(merged.systemPromptTemplate, vars, rendered);
|
|
28875
28779
|
const sources = context.agentsMdSources;
|
|
28876
28780
|
const copies = counts?.instructionCopies ?? 0;
|
|
28877
|
-
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) &&
|
|
28878
|
-
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;
|
|
28879
28782
|
const instructionSources = copies === 0 ? {
|
|
28880
28783
|
version: 1,
|
|
28881
28784
|
totalBytes: 0,
|
|
28882
28785
|
generatedBytes: 0,
|
|
28883
|
-
files: sourceMatches ? sources.files.map((file) => copyInstructionFileBytes(file, 0)) : []
|
|
28884
|
-
...notLoadedCandidates
|
|
28786
|
+
files: sourceMatches ? sources.files.map((file) => copyInstructionFileBytes(file, 0)) : []
|
|
28885
28787
|
} : !sourceMatches ? void 0 : {
|
|
28886
28788
|
version: 1,
|
|
28887
28789
|
totalBytes: sources.totalBytes * copies,
|
|
28888
28790
|
generatedBytes: sources.generatedBytes * copies,
|
|
28889
|
-
files: sources.files.map((file) => copyInstructionFileBytes(file, copies))
|
|
28890
|
-
...notLoadedCandidates
|
|
28791
|
+
files: sources.files.map((file) => copyInstructionFileBytes(file, copies))
|
|
28891
28792
|
};
|
|
28892
28793
|
const skillListingSources = counts === void 0 ? void 0 : scaleSkillListingSources(skillSources, vars["BLUN_SKILLS"] ?? "", counts.skillListingBytes);
|
|
28893
28794
|
context.onContributions(counts === void 0 ? void 0 : {
|
|
@@ -230334,19 +230235,16 @@ var FullCompaction = class {
|
|
|
230334
230235
|
const projected = context.additionalMessages === void 0 ? messages : [...messages, ...context.additionalMessages];
|
|
230335
230236
|
const historyBudget = this.requestHistoryByteBudget(projected);
|
|
230336
230237
|
const historyThresholdReached = historyBudget !== void 0 && historyBudget.usedHistoryBytes >= historyBudget.thresholdHistoryBytes;
|
|
230337
|
-
const requestBudget = this.requestBodyByteBudget(projected, context);
|
|
230338
|
-
const requestThresholdReached = requestBudget !== void 0 && requestBudget.usedRequestBytesEstimate >= requestBudget.thresholdRequestBytes;
|
|
230339
230238
|
if (this.sessionCompactionFailures >= MAX_SESSION_COMPACTION_FAILURES) reason = "session_stopped";
|
|
230340
230239
|
else if (this.isCompacting) reason = "already_compacting";
|
|
230341
|
-
else if (thresholdTokens === void 0 && historyBudget === void 0
|
|
230342
|
-
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";
|
|
230343
230242
|
else if (!this.hasShrinkableHistory(projected)) reason = "nothing_to_compact";
|
|
230344
230243
|
return {
|
|
230345
230244
|
eligible: reason === "eligible",
|
|
230346
230245
|
usedTokens,
|
|
230347
230246
|
thresholdTokens,
|
|
230348
230247
|
...historyBudget,
|
|
230349
|
-
...requestBudget,
|
|
230350
230248
|
reason
|
|
230351
230249
|
};
|
|
230352
230250
|
}
|
|
@@ -230368,35 +230266,6 @@ var FullCompaction = class {
|
|
|
230368
230266
|
thresholdHistoryBytes: limit
|
|
230369
230267
|
};
|
|
230370
230268
|
}
|
|
230371
|
-
requestBodyByteBudget(messages, context) {
|
|
230372
|
-
const limit = this.agent.blunConfig?.loopControl?.maxRequestHistoryBytes;
|
|
230373
|
-
if (!this.agent.config.hasProvider || this.strategy.compactionBudgetTokens === void 0 || limit !== void 0 && (!Number.isSafeInteger(limit) || limit <= 0)) return void 0;
|
|
230374
|
-
const model = this.agent.activeResponderModel ?? this.agent.config.modelAlias;
|
|
230375
|
-
if (model === void 0 || this.agent.config.runtimeModel(model).provider.name !== "blun") return void 0;
|
|
230376
|
-
const systemPrompt = context.systemPrompt ?? this.agent.effectiveSystemPrompt;
|
|
230377
|
-
const tools = (context.tools ?? this.agent.tools.loopTools).map((tool) => ({
|
|
230378
|
-
name: tool.name,
|
|
230379
|
-
description: tool.description,
|
|
230380
|
-
parameters: tool.parameters
|
|
230381
|
-
}));
|
|
230382
|
-
let extraBytes;
|
|
230383
|
-
try {
|
|
230384
|
-
extraBytes = estimateBlunRequestExtraBytes(tools, messages);
|
|
230385
|
-
} catch {
|
|
230386
|
-
return;
|
|
230387
|
-
}
|
|
230388
|
-
if (Buffer.byteLength(JSON.stringify({
|
|
230389
|
-
systemPrompt,
|
|
230390
|
-
messages: []
|
|
230391
|
-
}), "utf8") >= BLUN_COMPACTION_REQUEST_BUDGET_BYTES) return void 0;
|
|
230392
|
-
return {
|
|
230393
|
-
usedRequestBytesEstimate: Buffer.byteLength(JSON.stringify({
|
|
230394
|
-
systemPrompt,
|
|
230395
|
-
messages
|
|
230396
|
-
}), "utf8") + extraBytes.toolsBytes + extraBytes.visionBytes,
|
|
230397
|
-
thresholdRequestBytes: BLUN_COMPACTION_REQUEST_BUDGET_BYTES
|
|
230398
|
-
};
|
|
230399
|
-
}
|
|
230400
230269
|
requestProactiveCompaction(context = {}) {
|
|
230401
230270
|
const status = this.proactiveCompactionStatus(context);
|
|
230402
230271
|
if (status.eligible && !this.proactiveCompactionRequested) {
|
|
@@ -230405,9 +230274,7 @@ var FullCompaction = class {
|
|
|
230405
230274
|
used_tokens: status.usedTokens,
|
|
230406
230275
|
threshold_tokens: status.thresholdTokens,
|
|
230407
230276
|
used_history_bytes: status.usedHistoryBytes,
|
|
230408
|
-
threshold_history_bytes: status.thresholdHistoryBytes
|
|
230409
|
-
used_request_bytes_estimate: status.usedRequestBytesEstimate,
|
|
230410
|
-
threshold_request_bytes: status.thresholdRequestBytes
|
|
230277
|
+
threshold_history_bytes: status.thresholdHistoryBytes
|
|
230411
230278
|
});
|
|
230412
230279
|
}
|
|
230413
230280
|
return status;
|
|
@@ -230536,9 +230403,7 @@ var FullCompaction = class {
|
|
|
230536
230403
|
const requestTokens = this.estimateCurrentRequestTokens(requestContext);
|
|
230537
230404
|
const budget = this.getCompactionBudgetTokens();
|
|
230538
230405
|
const historyBudget = this.requestHistoryByteBudget(projectedMessages);
|
|
230539
|
-
const
|
|
230540
|
-
const requestBudget = this.requestBodyByteBudget(projectedMessages, requestContext);
|
|
230541
|
-
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);
|
|
230542
230407
|
if (this.checkAutoCompaction(true, requestTokens, projectedMessages, proactive) && (proactive || this.strategy.shouldBlock(requestTokens))) await this.block(signal);
|
|
230543
230408
|
signal.throwIfAborted();
|
|
230544
230409
|
const compacted = this.agent.context.history !== historyBefore;
|
|
@@ -230748,10 +230613,7 @@ var FullCompaction = class {
|
|
|
230748
230613
|
dropOrphanResults: true
|
|
230749
230614
|
}), createUserMessage(requestInstruction)], capability));
|
|
230750
230615
|
};
|
|
230751
|
-
const estimateRequestBytes = (messages) => Buffer.byteLength(JSON.stringify(
|
|
230752
|
-
systemPrompt: this.agent.effectiveSystemPrompt,
|
|
230753
|
-
messages
|
|
230754
|
-
}), "utf8");
|
|
230616
|
+
const estimateRequestBytes = (messages) => Buffer.byteLength(JSON.stringify(messages), "utf8") + Buffer.byteLength(this.agent.config.systemPrompt, "utf8");
|
|
230755
230617
|
while (true) {
|
|
230756
230618
|
signal.throwIfAborted();
|
|
230757
230619
|
if (hierarchicalPassCount >= MAX_HIERARCHICAL_COMPACTION_PASSES) throw new BlunError(ErrorCodes.COMPACTION_FAILED, `Compaction stopped after ${String(MAX_HIERARCHICAL_COMPACTION_PASSES)} staged requests without reaching a final summary. The conversation history was not changed.`, { details: {
|
|
@@ -239114,32 +238976,6 @@ var import_turn_tool_performance_policy = (/* @__PURE__ */ __commonJSMin(((expor
|
|
|
239114
238976
|
"suchen"
|
|
239115
238977
|
]);
|
|
239116
238978
|
const TOOL_SEARCH_RELATED_TERM_GROUPS = Object.freeze([
|
|
239117
|
-
Object.freeze([
|
|
239118
|
-
"persist",
|
|
239119
|
-
"save",
|
|
239120
|
-
"speichere",
|
|
239121
|
-
"speichern",
|
|
239122
|
-
"store"
|
|
239123
|
-
]),
|
|
239124
|
-
Object.freeze([
|
|
239125
|
-
"erinnerung",
|
|
239126
|
-
"erinnerungen",
|
|
239127
|
-
"fact",
|
|
239128
|
-
"facts",
|
|
239129
|
-
"fakt",
|
|
239130
|
-
"fakten",
|
|
239131
|
-
"memory",
|
|
239132
|
-
"memories",
|
|
239133
|
-
"merk",
|
|
239134
|
-
"merken",
|
|
239135
|
-
"remember"
|
|
239136
|
-
]),
|
|
239137
|
-
Object.freeze([
|
|
239138
|
-
"note",
|
|
239139
|
-
"notes",
|
|
239140
|
-
"notiz",
|
|
239141
|
-
"notizen"
|
|
239142
|
-
]),
|
|
239143
238979
|
Object.freeze([
|
|
239144
238980
|
"checklist",
|
|
239145
238981
|
"list",
|
|
@@ -239337,27 +239173,10 @@ var import_turn_tool_performance_policy = (/* @__PURE__ */ __commonJSMin(((expor
|
|
|
239337
239173
|
function relatedSearchTerms(token) {
|
|
239338
239174
|
return TOOL_SEARCH_RELATED_TERM_GROUPS.find((terms) => terms.includes(token)) || [token];
|
|
239339
239175
|
}
|
|
239340
|
-
function withoutFencedCode(value) {
|
|
239341
|
-
const visibleLines = [];
|
|
239342
|
-
let fence = null;
|
|
239343
|
-
for (const line of String(value || "").split(/\r?\n/)) {
|
|
239344
|
-
const marker = line.match(/^ {0,3}(`{3,}|~{3,})/u)?.[1];
|
|
239345
|
-
if (fence) {
|
|
239346
|
-
if (marker?.[0] === fence[0] && marker.length >= fence.length && /^ {0,3}(?:`{3,}|~{3,})[ \t]*$/u.test(line)) fence = null;
|
|
239347
|
-
continue;
|
|
239348
|
-
}
|
|
239349
|
-
if (marker) {
|
|
239350
|
-
fence = marker;
|
|
239351
|
-
continue;
|
|
239352
|
-
}
|
|
239353
|
-
visibleLines.push(line);
|
|
239354
|
-
}
|
|
239355
|
-
return visibleLines.join("\n");
|
|
239356
|
-
}
|
|
239357
239176
|
function rankingIntentTexts(value) {
|
|
239358
239177
|
const text = String(value || "");
|
|
239359
239178
|
const channelBodies = [...text.matchAll(/(?:^|\r?\n)<channel\b[^>]*>\r?\n([\s\S]*?)\r?\n<\/channel>(?=\r?\n|$)/giu)].map((match) => match[1]);
|
|
239360
|
-
return (channelBodies.length > 0 ? channelBodies : [text]).map((intentText) => normalizeDeferredToolQuery(
|
|
239179
|
+
return (channelBodies.length > 0 ? channelBodies : [text]).map((intentText) => normalizeDeferredToolQuery(intentText.replace(TOOL_RANK_EMBEDDED_CONTENT_RE, " ")));
|
|
239361
239180
|
}
|
|
239362
239181
|
function rankingTokens(value) {
|
|
239363
239182
|
return [...new Set(String(value || "").normalize("NFKC").toLowerCase().match(/[\p{L}\p{N}]{3,}/gu) || [])].filter((token) => !TOOL_RANK_STOP_WORDS.has(token));
|
|
@@ -239415,7 +239234,7 @@ var import_turn_tool_performance_policy = (/* @__PURE__ */ __commonJSMin(((expor
|
|
|
239415
239234
|
if (document.nameTokens.has(token)) exactNameMatches += 1;
|
|
239416
239235
|
else if (relatedSearchTerms(token).some((term) => document.nameTokens.has(term))) relatedNameMatches += 1;
|
|
239417
239236
|
}
|
|
239418
|
-
return matchedTokens >= 2 || exactNameMatches >= 1 && score >= 10 ||
|
|
239237
|
+
return matchedTokens >= 2 || exactNameMatches >= 1 && score >= 10 || relatedNameMatches >= 1 && score >= 5 ? {
|
|
239419
239238
|
name: document.name,
|
|
239420
239239
|
score,
|
|
239421
239240
|
matchedTokens,
|
|
@@ -239436,11 +239255,11 @@ var import_turn_tool_performance_policy = (/* @__PURE__ */ __commonJSMin(((expor
|
|
|
239436
239255
|
function searchRelatedDeferredTools(tools, query, options = {}) {
|
|
239437
239256
|
const normalized = normalizeDeferredToolQuery(query).toLowerCase();
|
|
239438
239257
|
if (!normalized || normalized.startsWith("select:")) return [];
|
|
239439
|
-
const tokens = normalized.
|
|
239258
|
+
const tokens = normalized.split(/\s+/).filter(Boolean);
|
|
239440
239259
|
const requestedNameTokens = tokens.filter((token) => token.startsWith("+")).map((token) => token.slice(1)).filter(Boolean);
|
|
239441
239260
|
const relaxRequiredNameTokens = options.relaxRequiredNameTokens === true && requestedNameTokens.length > 0;
|
|
239442
239261
|
const requiredNameTokens = relaxRequiredNameTokens ? [] : requestedNameTokens;
|
|
239443
|
-
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));
|
|
239444
239263
|
if (searchTokens.length < 2 && !TOOL_SEARCH_SINGLE_TERM_RELATED_FALLBACKS.has(searchTokens[0])) return [];
|
|
239445
239264
|
const minimumMatchedTokens = searchTokens.length === 1 ? 1 : Math.max(2, Math.ceil(searchTokens.length * .75));
|
|
239446
239265
|
const ranked = tools.map((tool) => {
|
|
@@ -250244,8 +250063,7 @@ function logStepTiming(log, turnId, step, response) {
|
|
|
250244
250063
|
inputOtherTokens: response.usage.inputOther,
|
|
250245
250064
|
cacheReadTokens: response.usage.inputCacheRead,
|
|
250246
250065
|
cacheCreationTokens: response.usage.inputCacheCreation,
|
|
250247
|
-
outputTokens: response.usage.output
|
|
250248
|
-
...response.usage.outputReasoning === void 0 ? {} : { outputReasoningTokens: response.usage.outputReasoning }
|
|
250066
|
+
outputTokens: response.usage.output
|
|
250249
250067
|
});
|
|
250250
250068
|
}
|
|
250251
250069
|
function deriveStepStopReason(response) {
|
|
@@ -251233,7 +251051,6 @@ const MCP_OAUTH_AUTHORIZATION_URL_TOOL_UPDATE = "mcp.oauth.authorization_url";
|
|
|
251233
251051
|
const tokenUsageSchema = object({
|
|
251234
251052
|
inputOther: number$1(),
|
|
251235
251053
|
output: number$1(),
|
|
251236
|
-
outputReasoning: number$1().optional(),
|
|
251237
251054
|
inputCacheRead: number$1(),
|
|
251238
251055
|
inputCacheCreation: number$1()
|
|
251239
251056
|
});
|
|
@@ -267773,7 +267590,6 @@ var TurnFlow = class {
|
|
|
267773
267590
|
const appendedMessage = this.agent.context.history.at(-1);
|
|
267774
267591
|
const turnAnchor = appendedMessage !== previousLastMessage && appendedMessage?.role === "user" && appendedMessage.origin === origin ? appendedMessage : void 0;
|
|
267775
267592
|
const startedAt = Date.now();
|
|
267776
|
-
const preRequestHookStartedAt = performance.now();
|
|
267777
267593
|
let ended;
|
|
267778
267594
|
let blockedByUserPromptHook = false;
|
|
267779
267595
|
let completedStopReason;
|
|
@@ -267799,13 +267615,6 @@ var TurnFlow = class {
|
|
|
267799
267615
|
this.agent.log.warn("Turn-start observation failed");
|
|
267800
267616
|
}
|
|
267801
267617
|
signal.throwIfAborted();
|
|
267802
|
-
if (this.agent.type === "main" && process.env["BLUN_DIAG_PRE_REQUEST_PHASES"] === "1") try {
|
|
267803
|
-
this.agent.log.info("turn pre-request phase", {
|
|
267804
|
-
turnId,
|
|
267805
|
-
phase: "turn-hooks",
|
|
267806
|
-
durationMs: Math.max(0, Math.round(performance.now() - preRequestHookStartedAt))
|
|
267807
|
-
});
|
|
267808
|
-
} catch {}
|
|
267809
267618
|
const stopReason = await this.runStepLoop(turnId, signal, input, origin, turnAnchor, (response) => {
|
|
267810
267619
|
completedResponse = response;
|
|
267811
267620
|
});
|
|
@@ -267917,10 +267726,6 @@ var TurnFlow = class {
|
|
|
267917
267726
|
signal.throwIfAborted();
|
|
267918
267727
|
const blockResult = renderUserPromptHookBlockResult(promptHookResults);
|
|
267919
267728
|
if (blockResult !== void 0) {
|
|
267920
|
-
this.agent.log.warn("turn blocked by UserPromptSubmit hook", {
|
|
267921
|
-
turnId,
|
|
267922
|
-
reason: blockResult.message
|
|
267923
|
-
});
|
|
267924
267729
|
this.agent.context.appendMessage({
|
|
267925
267730
|
role: "assistant",
|
|
267926
267731
|
content: [{
|
|
@@ -267979,26 +267784,9 @@ var TurnFlow = class {
|
|
|
267979
267784
|
let stopHookContinuationUsed = false;
|
|
267980
267785
|
let goalOutcomeMessageContinuationUsed = false;
|
|
267981
267786
|
const deduper = new ToolCallDeduplicator({ telemetry: this.agent.telemetry });
|
|
267982
|
-
const diagnosePreRequest = this.agent.type === "main" && process.env["BLUN_DIAG_PRE_REQUEST_PHASES"] === "1";
|
|
267983
|
-
const recordPreRequestPhase = (phase, startedAt) => {
|
|
267984
|
-
if (!diagnosePreRequest) return;
|
|
267985
|
-
try {
|
|
267986
|
-
this.agent.log.info("turn pre-request phase", {
|
|
267987
|
-
turnId,
|
|
267988
|
-
phase,
|
|
267989
|
-
durationMs: Math.max(0, Math.round(performance.now() - startedAt))
|
|
267990
|
-
});
|
|
267991
|
-
} catch {}
|
|
267992
|
-
};
|
|
267993
|
-
let phaseStartedAt = performance.now();
|
|
267994
267787
|
await this.agent.mcp?.waitForInitialLoad(signal);
|
|
267995
|
-
recordPreRequestPhase("mcp-initial-load", phaseStartedAt);
|
|
267996
|
-
phaseStartedAt = performance.now();
|
|
267997
267788
|
const personalMemoryRecall = await this.agent.injection.injectPersonalMemoryForTurn(turnId, input, origin, signal);
|
|
267998
|
-
recordPreRequestPhase("personal-memory-recall", phaseStartedAt);
|
|
267999
|
-
phaseStartedAt = performance.now();
|
|
268000
267789
|
await this.agent.injection.injectGoal();
|
|
268001
|
-
recordPreRequestPhase("goal-injection", phaseStartedAt);
|
|
268002
267790
|
this.setActiveSteerAcceptance(turnId, true);
|
|
268003
267791
|
const turnNeedsThinking = blunTurnNeedsTools(blunThinkingIntentInput(input), origin);
|
|
268004
267792
|
let toolInput = input;
|
|
@@ -268009,14 +267797,12 @@ var TurnFlow = class {
|
|
|
268009
267797
|
const raw = [...this.agent.context.history];
|
|
268010
267798
|
const history = personalMemoryRecall === void 0 ? raw : [...raw, personalMemoryRecall];
|
|
268011
267799
|
const selected = taskToolsNeeded ? history : greetingHistory(history, greetingAnchor);
|
|
268012
|
-
const projectionStartedAt = performance.now();
|
|
268013
267800
|
const projected = await this.historicalToolProjection.project(selected, turnAnchor, tools, {
|
|
268014
267801
|
turnId: String(turnId),
|
|
268015
267802
|
stepNumber: this.currentStep,
|
|
268016
267803
|
signal,
|
|
268017
267804
|
llm: turnLLM
|
|
268018
267805
|
});
|
|
268019
|
-
recordPreRequestPhase("historical-tool-projection", projectionStartedAt);
|
|
268020
267806
|
const current = this.agent.context.history;
|
|
268021
267807
|
if (current.length !== raw.length || current.some((message, index) => message !== raw[index])) {
|
|
268022
267808
|
const latest = personalMemoryRecall === void 0 ? current : [...current, personalMemoryRecall];
|
|
@@ -268027,7 +267813,7 @@ var TurnFlow = class {
|
|
|
268027
267813
|
partialContext = selected.length < history.length || projected.changed;
|
|
268028
267814
|
return projected.history;
|
|
268029
267815
|
};
|
|
268030
|
-
const turnLLM = this.agent.llmForTurn(turnNeedsThinking ? void 0 : "off"
|
|
267816
|
+
const turnLLM = this.agent.llmForTurn(turnNeedsThinking ? void 0 : "off");
|
|
268031
267817
|
const turnTools = this.agent.tools.captureTurnTools();
|
|
268032
267818
|
while (true) {
|
|
268033
267819
|
signal.throwIfAborted();
|
|
@@ -268037,7 +267823,6 @@ var TurnFlow = class {
|
|
|
268037
267823
|
try {
|
|
268038
267824
|
const selectedTools = [];
|
|
268039
267825
|
this.refreshSelectedTools = (snapshot) => {
|
|
268040
|
-
const selectionStartedAt = performance.now();
|
|
268041
267826
|
if (snapshot.messages.length > 0) toolInput = snapshot.messages.flatMap((message) => message.content);
|
|
268042
267827
|
const eligibleTools = blunToolsForOrigin(this.agent.injection.filterPersonalMemoryToolsForTurn(turnId, input, origin, turnTools()), origin);
|
|
268043
267828
|
const intent = blunThinkingIntentInput(toolInput);
|
|
@@ -268050,7 +267835,6 @@ var TurnFlow = class {
|
|
|
268050
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);
|
|
268051
267836
|
}
|
|
268052
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)));
|
|
268053
|
-
recordPreRequestPhase("tool-selection", selectionStartedAt);
|
|
268054
267838
|
return selectedTools;
|
|
268055
267839
|
};
|
|
268056
267840
|
return (await runTurn({
|
|
@@ -268063,24 +267847,14 @@ var TurnFlow = class {
|
|
|
268063
267847
|
}, completion);
|
|
268064
267848
|
},
|
|
268065
267849
|
llm: turnLLM,
|
|
268066
|
-
buildMessages: async () => {
|
|
268067
|
-
|
|
268068
|
-
|
|
268069
|
-
|
|
268070
|
-
|
|
268071
|
-
|
|
268072
|
-
|
|
268073
|
-
|
|
268074
|
-
const messages = this.agent.context.project(await turnHistory(selectedTools), {
|
|
268075
|
-
synthesizeMissing: true,
|
|
268076
|
-
dropOrphanResults: true,
|
|
268077
|
-
dedupeDuplicateToolCalls: true,
|
|
268078
|
-
dropLeadingNonUser: true,
|
|
268079
|
-
mergeConsecutiveAssistants: true
|
|
268080
|
-
});
|
|
268081
|
-
recordPreRequestPhase("message-build-strict", startedAt);
|
|
268082
|
-
return messages;
|
|
268083
|
-
},
|
|
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
|
+
}),
|
|
268084
267858
|
dispatchEvent: this.buildDispatchEvent(turnId, signal, onFinalResponse, () => partialContext),
|
|
268085
267859
|
tools: selectedTools,
|
|
268086
267860
|
log: this.agent.log,
|
|
@@ -268097,10 +267871,8 @@ var TurnFlow = class {
|
|
|
268097
267871
|
},
|
|
268098
267872
|
hooks: {
|
|
268099
267873
|
beforeStep: async ({ signal: stepSignal, llm }) => {
|
|
268100
|
-
const injectionStartedAt = performance.now();
|
|
268101
267874
|
this.agent.microCompaction.detect();
|
|
268102
267875
|
await this.agent.injection.inject();
|
|
268103
|
-
recordPreRequestPhase("step-injection", injectionStartedAt);
|
|
268104
267876
|
stepSignal.throwIfAborted();
|
|
268105
267877
|
deduper.beginStep();
|
|
268106
267878
|
},
|
|
@@ -268138,17 +267910,6 @@ var TurnFlow = class {
|
|
|
268138
267910
|
signal.throwIfAborted();
|
|
268139
267911
|
if (stopBlock !== void 0) {
|
|
268140
267912
|
stopHookContinuationUsed = true;
|
|
268141
|
-
this.agent.log.warn("turn continuation blocked by Stop hook", {
|
|
268142
|
-
turnId,
|
|
268143
|
-
reason: stopBlock.reason
|
|
268144
|
-
});
|
|
268145
|
-
this.agent.emitEvent({
|
|
268146
|
-
type: "hook.result",
|
|
268147
|
-
turnId,
|
|
268148
|
-
hookEvent: "Stop",
|
|
268149
|
-
content: stopBlock.reason,
|
|
268150
|
-
blocked: true
|
|
268151
|
-
});
|
|
268152
267913
|
this.agent.context.appendUserMessage([{
|
|
268153
267914
|
type: "text",
|
|
268154
267915
|
text: stopBlock.reason
|
|
@@ -271651,7 +271412,6 @@ var FallbackLLM = class {
|
|
|
271651
271412
|
throw new Error("Fallback request preparation requires a fresh request boundary.");
|
|
271652
271413
|
}
|
|
271653
271414
|
let requestParams = params;
|
|
271654
|
-
let messagesReady = false;
|
|
271655
271415
|
const rebuildRequestMessages = async () => {
|
|
271656
271416
|
const messages = await rebuildMessages();
|
|
271657
271417
|
const suffix = requestParams.boundaryMessageSuffix;
|
|
@@ -271660,14 +271420,7 @@ var FallbackLLM = class {
|
|
|
271660
271420
|
while (true) {
|
|
271661
271421
|
const candidate = this.current;
|
|
271662
271422
|
try {
|
|
271663
|
-
|
|
271664
|
-
if (prepared !== void 0) if ("messagesReady" in prepared) {
|
|
271665
|
-
requestParams = prepared.params;
|
|
271666
|
-
messagesReady = true;
|
|
271667
|
-
} else {
|
|
271668
|
-
requestParams = prepared;
|
|
271669
|
-
messagesReady = false;
|
|
271670
|
-
}
|
|
271423
|
+
requestParams = await this.prepareRequest?.(candidate, requestParams, rebuildRequestMessages) ?? requestParams;
|
|
271671
271424
|
} catch (error) {
|
|
271672
271425
|
if (!isFallbackCandidateError(error) && !isUnavailableFallbackCandidate(error)) throw error;
|
|
271673
271426
|
const nextIndex = this.findNextCandidateIndex();
|
|
@@ -271677,14 +271430,13 @@ var FallbackLLM = class {
|
|
|
271677
271430
|
...requestParams,
|
|
271678
271431
|
messages: await rebuildRequestMessages()
|
|
271679
271432
|
};
|
|
271680
|
-
messagesReady = false;
|
|
271681
271433
|
requestParams.signal.throwIfAborted();
|
|
271682
271434
|
this.currentIndex = nextIndex;
|
|
271683
271435
|
this.onModelChanged(this.current.alias);
|
|
271684
271436
|
continue;
|
|
271685
271437
|
}
|
|
271686
271438
|
requestParams.signal.throwIfAborted();
|
|
271687
|
-
const messages =
|
|
271439
|
+
const messages = await rebuildRequestMessages();
|
|
271688
271440
|
requestParams.signal.throwIfAborted();
|
|
271689
271441
|
return {
|
|
271690
271442
|
...requestParams,
|
|
@@ -271786,13 +271538,8 @@ var LlmRequestLogger = class {
|
|
|
271786
271538
|
toolsEstimatedTokens = 0;
|
|
271787
271539
|
requestSequence = 0;
|
|
271788
271540
|
lastTurnRequest;
|
|
271789
|
-
|
|
271790
|
-
requestSignatures = /* @__PURE__ */ new Map();
|
|
271791
|
-
prefixComparisons = /* @__PURE__ */ new Map();
|
|
271792
|
-
lastSerializedRequest;
|
|
271793
|
-
constructor(log, serializedPrefixDiagnostic = process.env["BLUN_DIAG_SERIALIZED_PREFIX"] === "1") {
|
|
271541
|
+
constructor(log) {
|
|
271794
271542
|
this.log = log;
|
|
271795
|
-
this.serializedPrefixKey = serializedPrefixDiagnostic ? randomBytes(32) : void 0;
|
|
271796
271543
|
}
|
|
271797
271544
|
logRequest(input) {
|
|
271798
271545
|
const sequence = ++this.requestSequence;
|
|
@@ -271809,10 +271556,6 @@ var LlmRequestLogger = class {
|
|
|
271809
271556
|
toolsHash: fingerprint(JSON.stringify(toolSignature(tools)))
|
|
271810
271557
|
};
|
|
271811
271558
|
const signature = JSON.stringify(config);
|
|
271812
|
-
if (this.serializedPrefixKey !== void 0) {
|
|
271813
|
-
this.requestSignatures.set(sequence, signature);
|
|
271814
|
-
if (this.requestSignatures.size > 32) this.requestSignatures.delete(this.requestSignatures.keys().next().value);
|
|
271815
|
-
}
|
|
271816
271559
|
if (signature !== this.lastConfigLogSignature) {
|
|
271817
271560
|
this.lastConfigLogSignature = signature;
|
|
271818
271561
|
this.configRevision++;
|
|
@@ -271842,20 +271585,6 @@ var LlmRequestLogger = class {
|
|
|
271842
271585
|
}
|
|
271843
271586
|
};
|
|
271844
271587
|
if (partialMessageCount > 0) requestFields.partialMessageCount = partialMessageCount;
|
|
271845
|
-
const source = input.systemPromptContributions;
|
|
271846
|
-
if (source?.version === 1 && [
|
|
271847
|
-
source.totalBytes,
|
|
271848
|
-
source.instructionBytes,
|
|
271849
|
-
source.skillListingBytes,
|
|
271850
|
-
source.runtimeMemoryBytes,
|
|
271851
|
-
source.otherBytes
|
|
271852
|
-
].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 = {
|
|
271853
|
-
totalBytes: source.totalBytes,
|
|
271854
|
-
instructionBytes: source.instructionBytes,
|
|
271855
|
-
skillListingBytes: source.skillListingBytes,
|
|
271856
|
-
runtimeMemoryBytes: source.runtimeMemoryBytes,
|
|
271857
|
-
otherBytes: source.otherBytes
|
|
271858
|
-
};
|
|
271859
271588
|
this.log.info("llm request", requestFields);
|
|
271860
271589
|
if (fields?.turnStep !== void 0 && /^\d+\.\d+$/.test(fields.turnStep)) {
|
|
271861
271590
|
const historyTextOrigins = summarizeRequestTextOrigins(messages);
|
|
@@ -271881,51 +271610,10 @@ var LlmRequestLogger = class {
|
|
|
271881
271610
|
getLastTurnRequest() {
|
|
271882
271611
|
return this.lastTurnRequest === void 0 ? void 0 : structuredClone(this.lastTurnRequest);
|
|
271883
271612
|
}
|
|
271884
|
-
get serializedPrefixDiagnosticEnabled() {
|
|
271885
|
-
return this.serializedPrefixKey !== void 0;
|
|
271886
|
-
}
|
|
271887
|
-
observeSerializedRequest(body, fields, sequence) {
|
|
271888
|
-
const key = this.serializedPrefixKey;
|
|
271889
|
-
if (key === void 0 || !/^\d+\.\d+$/.test(fields?.turnStep ?? "")) return;
|
|
271890
|
-
const signature = this.requestSignatures.get(sequence);
|
|
271891
|
-
if (signature === void 0) return;
|
|
271892
|
-
try {
|
|
271893
|
-
const bytes = Buffer.from(body, "utf8");
|
|
271894
|
-
const granularityBytes = 1024;
|
|
271895
|
-
const chunks = [];
|
|
271896
|
-
for (let start = 0; start + granularityBytes <= bytes.length; start += granularityBytes) chunks.push(createHmac("sha256", key).update(bytes.subarray(start, start + granularityBytes)).digest("hex"));
|
|
271897
|
-
const previous = this.lastSerializedRequest;
|
|
271898
|
-
if (previous !== void 0 && previous.signature === signature) {
|
|
271899
|
-
let common = 0;
|
|
271900
|
-
while (common < previous.chunks.length && common < chunks.length && previous.chunks[common] === chunks[common]) common++;
|
|
271901
|
-
this.prefixComparisons.set(sequence, {
|
|
271902
|
-
version: 1,
|
|
271903
|
-
granularityBytes,
|
|
271904
|
-
previousBytes: previous.bytes,
|
|
271905
|
-
currentBytes: bytes.length,
|
|
271906
|
-
commonPrefixBytesLowerBound: common * granularityBytes,
|
|
271907
|
-
previousSequence: previous.sequence,
|
|
271908
|
-
currentSequence: sequence
|
|
271909
|
-
});
|
|
271910
|
-
if (this.prefixComparisons.size > 32) this.prefixComparisons.delete(this.prefixComparisons.keys().next().value);
|
|
271911
|
-
}
|
|
271912
|
-
this.lastSerializedRequest = {
|
|
271913
|
-
sequence,
|
|
271914
|
-
signature,
|
|
271915
|
-
bytes: bytes.length,
|
|
271916
|
-
chunks
|
|
271917
|
-
};
|
|
271918
|
-
} catch {
|
|
271919
|
-
this.lastSerializedRequest = void 0;
|
|
271920
|
-
}
|
|
271921
|
-
}
|
|
271922
271613
|
logTransportAttempt(stats, fields, sequence) {
|
|
271923
|
-
const serializedPrefix = sequence === void 0 ? void 0 : this.prefixComparisons.get(sequence);
|
|
271924
271614
|
this.log.info("llm transport attempt", {
|
|
271925
271615
|
...fields,
|
|
271926
|
-
...stats
|
|
271927
|
-
...this.serializedPrefixKey === void 0 || sequence === void 0 ? {} : { requestSequence: sequence },
|
|
271928
|
-
...serializedPrefix === void 0 ? {} : { serializedPrefix }
|
|
271616
|
+
...stats
|
|
271929
271617
|
});
|
|
271930
271618
|
if (sequence === void 0 || this.lastTurnRequest?.sequence !== sequence) return;
|
|
271931
271619
|
const breakdown = stats.requestBreakdown;
|
|
@@ -271947,11 +271635,6 @@ var LlmRequestLogger = class {
|
|
|
271947
271635
|
systemMessageBytes: breakdown.systemMessageBytes,
|
|
271948
271636
|
conversationMessageBytes: breakdown.conversationMessageBytes,
|
|
271949
271637
|
toolResultMessageBytes: breakdown.toolResultMessageBytes,
|
|
271950
|
-
...breakdown.toolResultByTool === void 0 ? {} : { toolResultByTool: breakdown.toolResultByTool.map((tool) => ({
|
|
271951
|
-
count: tool.count,
|
|
271952
|
-
bytes: tool.bytes,
|
|
271953
|
-
...tool.name === void 0 ? {} : { name: tool.name }
|
|
271954
|
-
})) },
|
|
271955
271638
|
toolSchemaBytes: breakdown.toolSchemaBytes,
|
|
271956
271639
|
otherBytes: breakdown.otherBytes,
|
|
271957
271640
|
...breakdown.toolArrayOverheadBytes === void 0 ? {} : { toolArrayOverheadBytes: breakdown.toolArrayOverheadBytes },
|
|
@@ -272013,8 +271696,7 @@ function copyContributions(value) {
|
|
|
272013
271696
|
version: source.version,
|
|
272014
271697
|
totalBytes: source.totalBytes,
|
|
272015
271698
|
generatedBytes: source.generatedBytes,
|
|
272016
|
-
files: source.files.map((file) => copyInstructionFileBytes(file))
|
|
272017
|
-
...source.notLoadedCandidates === void 0 ? {} : { notLoadedCandidates: [...source.notLoadedCandidates] }
|
|
271699
|
+
files: source.files.map((file) => copyInstructionFileBytes(file))
|
|
272018
271700
|
} }
|
|
272019
271701
|
};
|
|
272020
271702
|
}
|
|
@@ -272110,7 +271792,6 @@ var Agent$1 = class {
|
|
|
272110
271792
|
errorMemory;
|
|
272111
271793
|
replayBuilder;
|
|
272112
271794
|
additionalDirs;
|
|
272113
|
-
systemPromptStartedAt = /* @__PURE__ */ new Date();
|
|
272114
271795
|
activeProfile;
|
|
272115
271796
|
brandHome;
|
|
272116
271797
|
_activeResponderModel;
|
|
@@ -272198,7 +271879,6 @@ var Agent$1 = class {
|
|
|
272198
271879
|
const retryScope = providerRetryScope(modelAlias, provider);
|
|
272199
271880
|
await this.providerRetryWait.wait(retryScope, generateOptions?.signal);
|
|
272200
271881
|
const callerTransportAttempt = generateOptions?.onTransportAttempt;
|
|
272201
|
-
const callerSerializedRequest = generateOptions?.onSerializedRequest;
|
|
272202
271882
|
const ownedGenerateOptions = {
|
|
272203
271883
|
...generateOptions,
|
|
272204
271884
|
transportMaxRetries: 0
|
|
@@ -272221,12 +271901,6 @@ var Agent$1 = class {
|
|
|
272221
271901
|
callerTransportAttempt?.(stats);
|
|
272222
271902
|
this.llmRequestLogger.logTransportAttempt(stats, requestLogFields, requestSequence);
|
|
272223
271903
|
},
|
|
272224
|
-
...callerSerializedRequest !== void 0 || this.llmRequestLogger.serializedPrefixDiagnosticEnabled ? { onSerializedRequest: (body) => {
|
|
272225
|
-
try {
|
|
272226
|
-
callerSerializedRequest?.(body);
|
|
272227
|
-
} catch {}
|
|
272228
|
-
this.llmRequestLogger.observeSerializedRequest(body, requestLogFields, requestSequence);
|
|
272229
|
-
} } : {},
|
|
272230
271904
|
onRequestStart: () => {
|
|
272231
271905
|
requestOptions?.onRequestStart?.();
|
|
272232
271906
|
requestStarted = true;
|
|
@@ -272252,7 +271926,7 @@ var Agent$1 = class {
|
|
|
272252
271926
|
get llm() {
|
|
272253
271927
|
return this.llmForTurn();
|
|
272254
271928
|
}
|
|
272255
|
-
llmForTurn(thinkingEffort
|
|
271929
|
+
llmForTurn(thinkingEffort) {
|
|
272256
271930
|
const selectedAlias = this.config.model;
|
|
272257
271931
|
const modelProvider = this.modelProvider;
|
|
272258
271932
|
if (modelProvider === void 0) throw new BlunError(ErrorCodes.MODEL_NOT_CONFIGURED, "Provider not set");
|
|
@@ -272267,7 +271941,6 @@ var Agent$1 = class {
|
|
|
272267
271941
|
messages: await rebuildMessages()
|
|
272268
271942
|
};
|
|
272269
271943
|
let systemPrompt = this.effectiveSystemPrompt;
|
|
272270
|
-
const preflightStartedAt = performance.now();
|
|
272271
271944
|
const compacted = await this.fullCompaction.beforeStep(params.signal, {
|
|
272272
271945
|
messages: params.messages,
|
|
272273
271946
|
additionalMessages: steers.messages,
|
|
@@ -272276,31 +271949,17 @@ var Agent$1 = class {
|
|
|
272276
271949
|
rebuildSystemPrompt: () => systemPrompt = this.effectiveSystemPrompt,
|
|
272277
271950
|
tools: params.tools
|
|
272278
271951
|
});
|
|
272279
|
-
if (this.type === "main" && diagnosticTurnId !== void 0 && process.env["BLUN_DIAG_PRE_REQUEST_PHASES"] === "1") try {
|
|
272280
|
-
this.log.info("turn pre-request phase", {
|
|
272281
|
-
turnId: diagnosticTurnId,
|
|
272282
|
-
phase: "compaction-preflight",
|
|
272283
|
-
durationMs: Math.max(0, Math.round(performance.now() - preflightStartedAt))
|
|
272284
|
-
});
|
|
272285
|
-
} catch {}
|
|
272286
271952
|
const tools = params.tools.some((tool) => tool.name === "CompactConversation") && !this.fullCompaction.proactiveCompactionStatus({
|
|
272287
271953
|
messages: compacted ? await rebuildMessages() : params.messages,
|
|
272288
271954
|
additionalMessages: steers.messages,
|
|
272289
271955
|
systemPrompt,
|
|
272290
271956
|
tools: params.tools
|
|
272291
271957
|
}).eligible ? params.tools.filter((tool) => tool.name !== "CompactConversation") : params.tools;
|
|
272292
|
-
|
|
272293
|
-
if (compacted || steersCommitted) params = {
|
|
272294
|
-
...params,
|
|
272295
|
-
messages: await rebuildMessages()
|
|
272296
|
-
};
|
|
271958
|
+
this.turn.commitPendingSteers(steers);
|
|
272297
271959
|
return {
|
|
272298
|
-
params
|
|
272299
|
-
|
|
272300
|
-
|
|
272301
|
-
tools
|
|
272302
|
-
},
|
|
272303
|
-
messagesReady: true
|
|
271960
|
+
...params,
|
|
271961
|
+
systemPrompt,
|
|
271962
|
+
tools
|
|
272304
271963
|
};
|
|
272305
271964
|
}, (candidate, _params, error) => {
|
|
272306
271965
|
this.fullCompaction.observeContextOverflow(error, candidate.alias);
|
|
@@ -272394,7 +272053,6 @@ var Agent$1 = class {
|
|
|
272394
272053
|
let contributions;
|
|
272395
272054
|
const systemPrompt = profile.systemPrompt({
|
|
272396
272055
|
osEnv: this.kaos.osEnv,
|
|
272397
|
-
now: this.systemPromptStartedAt,
|
|
272398
272056
|
cwd: this.config.cwd,
|
|
272399
272057
|
skills: this.skills?.registry,
|
|
272400
272058
|
cwdListing: context?.cwdListing,
|
|
@@ -348094,39 +347752,6 @@ var BlunAuthFacade = class {
|
|
|
348094
347752
|
}
|
|
348095
347753
|
return this.toolkit.status(providerName, this.resolveRuntimeManagedAuth(providerName).oauthRef);
|
|
348096
347754
|
}
|
|
348097
|
-
async getCachedMemoryWorkspaceId() {
|
|
348098
|
-
const apiKey = nonEmpty(this.resolveManagedAuth(BLUN_PROVIDER_NAME$1).apiKey);
|
|
348099
|
-
if (apiKey !== void 0) {
|
|
348100
|
-
const provider = readConfigFileForUpdate(this.options.configPath).providers[BLUN_PROVIDER_NAME$1];
|
|
348101
|
-
if (provider?.apiKey !== apiKey || provider.memoryApiKeyHash !== memoryApiKeyHash(apiKey)) return;
|
|
348102
|
-
return provider.memoryWorkspaceId;
|
|
348103
|
-
}
|
|
348104
|
-
return this.toolkit.getCachedMemoryWorkspaceId(this.resolveRuntimeManagedAuth(BLUN_PROVIDER_NAME$1).oauthRef);
|
|
348105
|
-
}
|
|
348106
|
-
async cacheMemoryWorkspaceId(workspaceId) {
|
|
348107
|
-
const apiKey = nonEmpty(this.resolveManagedAuth(BLUN_PROVIDER_NAME$1).apiKey);
|
|
348108
|
-
if (apiKey !== void 0) {
|
|
348109
|
-
const hash = memoryApiKeyHash(apiKey);
|
|
348110
|
-
return mutateConfigFile(this.options.configPath, (config) => {
|
|
348111
|
-
const provider = config.providers[BLUN_PROVIDER_NAME$1];
|
|
348112
|
-
if (provider?.apiKey !== apiKey) return {
|
|
348113
|
-
config,
|
|
348114
|
-
result: false
|
|
348115
|
-
};
|
|
348116
|
-
if (provider.memoryApiKeyHash === hash && provider.memoryWorkspaceId !== void 0 && provider.memoryWorkspaceId !== workspaceId) return {
|
|
348117
|
-
config,
|
|
348118
|
-
result: false
|
|
348119
|
-
};
|
|
348120
|
-
provider.memoryApiKeyHash = hash;
|
|
348121
|
-
provider.memoryWorkspaceId = workspaceId;
|
|
348122
|
-
return {
|
|
348123
|
-
config,
|
|
348124
|
-
result: true
|
|
348125
|
-
};
|
|
348126
|
-
});
|
|
348127
|
-
}
|
|
348128
|
-
return this.toolkit.cacheMemoryWorkspaceId(workspaceId, this.resolveRuntimeManagedAuth(BLUN_PROVIDER_NAME$1).oauthRef);
|
|
348129
|
-
}
|
|
348130
347755
|
async login(providerName = BLUN_PROVIDER_NAME$1, options = {}) {
|
|
348131
347756
|
const auth = this.resolveManagedAuth(providerName);
|
|
348132
347757
|
const loginAuth = resolveBlunCodeLoginAuth({
|
|
@@ -348432,9 +348057,6 @@ function nonEmpty(value) {
|
|
|
348432
348057
|
const normalized = value?.trim();
|
|
348433
348058
|
return normalized === void 0 || normalized.length === 0 ? void 0 : normalized;
|
|
348434
348059
|
}
|
|
348435
|
-
function memoryApiKeyHash(apiKey) {
|
|
348436
|
-
return createHash("sha256").update(apiKey).digest("hex");
|
|
348437
|
-
}
|
|
348438
348060
|
function transitionAggregateError(message, primary, secondary) {
|
|
348439
348061
|
return new AggregateError([primary, secondary], message, { cause: primary });
|
|
348440
348062
|
}
|