@bike4mind/cli 0.2.30-subagent-delegation.19188 → 0.2.31-b4m-cli-undo-command.19493
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{artifactExtractor-YSZB7U2T.js → artifactExtractor-Z6CL6QFN.js} +1 -1
- package/dist/{chunk-44RZA4RG.js → chunk-2LLA4MTN.js} +2 -2
- package/dist/{chunk-TVW4ZESU.js → chunk-BYXFQJYT.js} +10 -1
- package/dist/{chunk-ICLEQOH6.js → chunk-GE7Q64MS.js} +1570 -5
- package/dist/{chunk-FLA4PWXB.js → chunk-RI45VJW3.js} +262 -34
- package/dist/{chunk-YNQB2RM7.js → chunk-T67NGQW6.js} +2 -2
- package/dist/{chunk-PP5WVA27.js → chunk-ZOWCX4MQ.js} +2 -2
- package/dist/{create-NX7AO3LR.js → create-JNUW7ICC.js} +3 -3
- package/dist/index.js +3118 -503
- package/dist/{llmMarkdownGenerator-BYSKH6JZ.js → llmMarkdownGenerator-KGA4HTQN.js} +1 -1
- package/dist/{markdownGenerator-25VAIDTL.js → markdownGenerator-ERG7FI5H.js} +1 -1
- package/dist/{mementoService-HY2ZPJF2.js → mementoService-I56R5DNA.js} +3 -3
- package/dist/{src-EIUJ74FN.js → src-EMANOLFK.js} +12 -2
- package/dist/{src-3JKTTJ5U.js → src-IAR65K73.js} +59 -1
- package/dist/{store-FU6NDC2W.js → store-K5MB3SE7.js} +1 -1
- package/dist/{subtractCredits-XU7WMHLE.js → subtractCredits-3MEQF5CV.js} +3 -3
- package/package.json +9 -9
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
ModelBackend,
|
|
8
8
|
OpenAIEmbeddingModel,
|
|
9
9
|
PermissionDeniedError,
|
|
10
|
+
REASONING_SUPPORTED_MODELS,
|
|
10
11
|
SpeechToTextModels,
|
|
11
12
|
SupportedFabFileMimeTypes,
|
|
12
13
|
VIDEO_SIZE_CONSTRAINTS,
|
|
@@ -15,7 +16,7 @@ import {
|
|
|
15
16
|
dayjsConfig_default,
|
|
16
17
|
extractSnippetMeta,
|
|
17
18
|
settingsMap
|
|
18
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-GE7Q64MS.js";
|
|
19
20
|
import {
|
|
20
21
|
Logger
|
|
21
22
|
} from "./chunk-OCYRD7D6.js";
|
|
@@ -590,6 +591,125 @@ function getSettingsCacheStats() {
|
|
|
590
591
|
// ../../b4m-core/packages/utils/dist/src/ingest.js
|
|
591
592
|
import axios from "axios";
|
|
592
593
|
import mime2 from "mime-types";
|
|
594
|
+
|
|
595
|
+
// ../../b4m-core/packages/utils/dist/src/ssrfProtection.js
|
|
596
|
+
import dns from "dns";
|
|
597
|
+
import { promisify } from "util";
|
|
598
|
+
var dnsResolve4 = promisify(dns.resolve4);
|
|
599
|
+
var dnsResolve6 = promisify(dns.resolve6);
|
|
600
|
+
function isPrivateIPv4(ip) {
|
|
601
|
+
const ipv4Match = ip.match(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/);
|
|
602
|
+
if (!ipv4Match)
|
|
603
|
+
return false;
|
|
604
|
+
const [, a, b, c] = ipv4Match.map(Number);
|
|
605
|
+
if (a === 10)
|
|
606
|
+
return true;
|
|
607
|
+
if (a === 172 && b >= 16 && b <= 31)
|
|
608
|
+
return true;
|
|
609
|
+
if (a === 192 && b === 168)
|
|
610
|
+
return true;
|
|
611
|
+
if (a === 127)
|
|
612
|
+
return true;
|
|
613
|
+
if (a === 169 && b === 254)
|
|
614
|
+
return true;
|
|
615
|
+
if (a === 0)
|
|
616
|
+
return true;
|
|
617
|
+
if (a === 100 && b >= 64 && b <= 127)
|
|
618
|
+
return true;
|
|
619
|
+
if (a === 192 && b === 0 && c === 0)
|
|
620
|
+
return true;
|
|
621
|
+
if (a === 192 && b === 0 && c === 2 || a === 198 && b === 51 && c === 100 || a === 203 && b === 0 && c === 113)
|
|
622
|
+
return true;
|
|
623
|
+
if (a >= 224 && a <= 239)
|
|
624
|
+
return true;
|
|
625
|
+
if (a >= 240)
|
|
626
|
+
return true;
|
|
627
|
+
return false;
|
|
628
|
+
}
|
|
629
|
+
function isPrivateIPv6(ip) {
|
|
630
|
+
const normalized = ip.toLowerCase();
|
|
631
|
+
if (normalized === "::1" || normalized === "0:0:0:0:0:0:0:1")
|
|
632
|
+
return true;
|
|
633
|
+
if (normalized === "::" || normalized === "0:0:0:0:0:0:0:0")
|
|
634
|
+
return true;
|
|
635
|
+
if (normalized.startsWith("fe8") || normalized.startsWith("fe9") || normalized.startsWith("fea") || normalized.startsWith("feb"))
|
|
636
|
+
return true;
|
|
637
|
+
if (normalized.startsWith("fc") || normalized.startsWith("fd"))
|
|
638
|
+
return true;
|
|
639
|
+
if (normalized.startsWith("ff"))
|
|
640
|
+
return true;
|
|
641
|
+
const ipv4MappedMatch = normalized.match(/^::ffff:(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/);
|
|
642
|
+
if (ipv4MappedMatch) {
|
|
643
|
+
return isPrivateIPv4(ipv4MappedMatch[1]);
|
|
644
|
+
}
|
|
645
|
+
if (normalized.startsWith("2001:db8:") || normalized.startsWith("2001:0db8:"))
|
|
646
|
+
return true;
|
|
647
|
+
if (normalized.startsWith("100::") || normalized.startsWith("0100::"))
|
|
648
|
+
return true;
|
|
649
|
+
if (normalized.startsWith("64:ff9b:") || normalized.startsWith("0064:ff9b:"))
|
|
650
|
+
return true;
|
|
651
|
+
return false;
|
|
652
|
+
}
|
|
653
|
+
function isPrivateIP(ip) {
|
|
654
|
+
if (/^(\d{1,3}\.){3}\d{1,3}$/.test(ip)) {
|
|
655
|
+
return isPrivateIPv4(ip);
|
|
656
|
+
}
|
|
657
|
+
return isPrivateIPv6(ip);
|
|
658
|
+
}
|
|
659
|
+
function isPrivateOrInternalHostname(hostname) {
|
|
660
|
+
const normalized = hostname.toLowerCase();
|
|
661
|
+
if (normalized === "localhost" || normalized === "127.0.0.1" || normalized === "::1" || normalized === "0.0.0.0" || normalized.endsWith(".localhost") || normalized.endsWith(".local")) {
|
|
662
|
+
return true;
|
|
663
|
+
}
|
|
664
|
+
if (normalized === "169.254.169.254" || normalized === "instance-data" || normalized === "metadata.google.internal" || normalized === "metadata.internal") {
|
|
665
|
+
return true;
|
|
666
|
+
}
|
|
667
|
+
if (normalized.endsWith(".cluster.local") || normalized.endsWith(".svc.cluster.local") || normalized.endsWith(".pod.cluster.local")) {
|
|
668
|
+
return true;
|
|
669
|
+
}
|
|
670
|
+
if (/^(\d{1,3}\.){3}\d{1,3}$/.test(normalized)) {
|
|
671
|
+
return isPrivateIPv4(normalized);
|
|
672
|
+
}
|
|
673
|
+
if (normalized.includes(":")) {
|
|
674
|
+
return isPrivateIPv6(normalized);
|
|
675
|
+
}
|
|
676
|
+
return false;
|
|
677
|
+
}
|
|
678
|
+
async function validateUrlForFetch(url) {
|
|
679
|
+
try {
|
|
680
|
+
const parsed = new URL(url);
|
|
681
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
|
|
682
|
+
return { valid: false, error: "URL must use HTTP or HTTPS protocol" };
|
|
683
|
+
}
|
|
684
|
+
if (isPrivateOrInternalHostname(parsed.hostname)) {
|
|
685
|
+
return { valid: false, error: "URL points to a private or internal network" };
|
|
686
|
+
}
|
|
687
|
+
const isIPv4Address = /^(\d{1,3}\.){3}\d{1,3}$/.test(parsed.hostname);
|
|
688
|
+
const isIPv6Address = parsed.hostname.includes(":");
|
|
689
|
+
if (!isIPv4Address && !isIPv6Address) {
|
|
690
|
+
try {
|
|
691
|
+
const ipv4Addresses = await dnsResolve4(parsed.hostname).catch(() => []);
|
|
692
|
+
const ipv6Addresses = await dnsResolve6(parsed.hostname).catch(() => []);
|
|
693
|
+
const allAddresses = [...ipv4Addresses, ...ipv6Addresses];
|
|
694
|
+
if (allAddresses.length === 0) {
|
|
695
|
+
return { valid: false, error: "Could not resolve hostname" };
|
|
696
|
+
}
|
|
697
|
+
for (const ip of allAddresses) {
|
|
698
|
+
if (isPrivateIP(ip)) {
|
|
699
|
+
return { valid: false, error: `Hostname resolves to private IP address (${ip})` };
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
} catch {
|
|
703
|
+
return { valid: false, error: "Could not resolve hostname" };
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
return { valid: true };
|
|
707
|
+
} catch {
|
|
708
|
+
return { valid: false, error: "Invalid URL format" };
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
// ../../b4m-core/packages/utils/dist/src/ingest.js
|
|
593
713
|
var URL_REGEX = /https?:\/\/(?:[-\w.])+(?:\:[0-9]+)?(?:\/(?:[\w\/_.])*(?:\?(?:[\w&=%.])*)?(?:\#(?:[\w.])*)?)?/gi;
|
|
594
714
|
function detectURLs(string) {
|
|
595
715
|
const urlsFound = string.match(URL_REGEX) || [];
|
|
@@ -602,15 +722,22 @@ function urlExists(stringWithPossibleUrl) {
|
|
|
602
722
|
const cleanString = stringWithPossibleUrl.replace(/\n/g, " ").replace(/,/g, " ");
|
|
603
723
|
return detectURLs(cleanString);
|
|
604
724
|
}
|
|
725
|
+
var URL_FETCH_TIMEOUT_MS = 1e4;
|
|
605
726
|
async function fetchAndParseURL(url, { logger }) {
|
|
606
727
|
logger.updateMetadata({ failedUrl: null });
|
|
607
728
|
try {
|
|
729
|
+
const ssrfValidation = await validateUrlForFetch(url);
|
|
730
|
+
if (!ssrfValidation.valid) {
|
|
731
|
+
throw new Error(`URL blocked for security reasons: ${ssrfValidation.error}`);
|
|
732
|
+
}
|
|
608
733
|
let urlMimeType = "text/plain";
|
|
609
734
|
if (url.split(".")?.pop()?.startsWith("pdf")) {
|
|
610
735
|
urlMimeType = "application/pdf";
|
|
611
736
|
}
|
|
612
737
|
const response = await axios.get(url, {
|
|
613
|
-
responseType: ["application/pdf"].includes(urlMimeType) ? "arraybuffer" : "text"
|
|
738
|
+
responseType: ["application/pdf"].includes(urlMimeType) ? "arraybuffer" : "text",
|
|
739
|
+
timeout: URL_FETCH_TIMEOUT_MS
|
|
740
|
+
// Prevent Lambda timeout exhaustion
|
|
614
741
|
});
|
|
615
742
|
const cheerio = await import("cheerio");
|
|
616
743
|
const htmlContent = response.data;
|
|
@@ -618,17 +745,19 @@ async function fetchAndParseURL(url, { logger }) {
|
|
|
618
745
|
const title = $("title").text() || url.split("/")?.pop();
|
|
619
746
|
let urlContent = null;
|
|
620
747
|
switch (urlMimeType) {
|
|
621
|
-
case "application/pdf":
|
|
748
|
+
case "application/pdf": {
|
|
622
749
|
const pdfbuffer = Buffer.from(response.data);
|
|
623
750
|
urlContent = pdfbuffer;
|
|
624
751
|
break;
|
|
625
|
-
|
|
752
|
+
}
|
|
753
|
+
default: {
|
|
626
754
|
let textContent = "";
|
|
627
755
|
$("body").find("p").each((index, element) => {
|
|
628
756
|
textContent += $(element).text() + "\n";
|
|
629
757
|
});
|
|
630
758
|
urlContent = textContent || htmlContent;
|
|
631
759
|
break;
|
|
760
|
+
}
|
|
632
761
|
}
|
|
633
762
|
logger.log(`Fetched ${title} with mimetype ${urlMimeType} and parsed ${url}`);
|
|
634
763
|
return { title, textContent: urlContent, mimeType: urlMimeType, ext: mime2.extension(urlMimeType) || null };
|
|
@@ -1154,8 +1283,30 @@ function separateUrls(urls) {
|
|
|
1154
1283
|
const nonImageUrls = urls.filter((url) => !imageExtensions.some((ext) => url.toLowerCase().endsWith(ext)));
|
|
1155
1284
|
return { imageUrls, nonImageUrls };
|
|
1156
1285
|
}
|
|
1157
|
-
|
|
1158
|
-
|
|
1286
|
+
function sanitizeUrlForLogging(url) {
|
|
1287
|
+
try {
|
|
1288
|
+
const parsed = new URL(url);
|
|
1289
|
+
const sensitiveParams = [
|
|
1290
|
+
"token",
|
|
1291
|
+
"key",
|
|
1292
|
+
"api_key",
|
|
1293
|
+
"apikey",
|
|
1294
|
+
"secret",
|
|
1295
|
+
"password",
|
|
1296
|
+
"session",
|
|
1297
|
+
"auth",
|
|
1298
|
+
"access_token"
|
|
1299
|
+
];
|
|
1300
|
+
sensitiveParams.forEach((param) => {
|
|
1301
|
+
if (parsed.searchParams.has(param)) {
|
|
1302
|
+
parsed.searchParams.set(param, "[REDACTED]");
|
|
1303
|
+
}
|
|
1304
|
+
});
|
|
1305
|
+
return parsed.toString();
|
|
1306
|
+
} catch {
|
|
1307
|
+
return url.substring(0, 100) + (url.length > 100 ? "..." : "");
|
|
1308
|
+
}
|
|
1309
|
+
}
|
|
1159
1310
|
async function processUrlsFromPrompt(userPrompt, maxContentBuffer, userId, sendStatusUpdate, logger, options = { verbose: false }) {
|
|
1160
1311
|
if (!hasURLs(userPrompt)) {
|
|
1161
1312
|
if (options?.verbose) {
|
|
@@ -1163,6 +1314,7 @@ async function processUrlsFromPrompt(userPrompt, maxContentBuffer, userId, sendS
|
|
|
1163
1314
|
}
|
|
1164
1315
|
return { userMessages: [], remainingPrompt: userPrompt };
|
|
1165
1316
|
}
|
|
1317
|
+
const urlContentCache = /* @__PURE__ */ new Map();
|
|
1166
1318
|
sendStatusUpdate("Processing URLs from user prompt...");
|
|
1167
1319
|
const userMessages = [];
|
|
1168
1320
|
const promptMeta = extractSnippetMeta(userPrompt);
|
|
@@ -1190,20 +1342,26 @@ async function processUrlsFromPrompt(userPrompt, maxContentBuffer, userId, sendS
|
|
|
1190
1342
|
try {
|
|
1191
1343
|
const cached = urlContentCache.get(url);
|
|
1192
1344
|
let textContent;
|
|
1193
|
-
if (cached
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1345
|
+
if (cached) {
|
|
1346
|
+
logger.info("URL_FETCH", {
|
|
1347
|
+
userId,
|
|
1348
|
+
url: sanitizeUrlForLogging(url),
|
|
1349
|
+
cacheHit: true,
|
|
1350
|
+
source: "same-request-dedup"
|
|
1351
|
+
});
|
|
1352
|
+
textContent = cached;
|
|
1198
1353
|
} else {
|
|
1199
1354
|
const result = await fetchAndParseURL(url, { logger });
|
|
1200
1355
|
if (typeof result.textContent !== "string")
|
|
1201
1356
|
throw new Error("textContent is not a string");
|
|
1202
1357
|
textContent = result.textContent;
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1358
|
+
logger.info("URL_FETCH", {
|
|
1359
|
+
userId,
|
|
1360
|
+
url: sanitizeUrlForLogging(url),
|
|
1361
|
+
cacheHit: false,
|
|
1362
|
+
contentLength: textContent.length
|
|
1206
1363
|
});
|
|
1364
|
+
urlContentCache.set(url, textContent);
|
|
1207
1365
|
}
|
|
1208
1366
|
const message = {
|
|
1209
1367
|
role: "user",
|
|
@@ -2492,7 +2650,13 @@ var AnthropicBackend = class {
|
|
|
2492
2650
|
const rawTools = options.tools;
|
|
2493
2651
|
const normalizedTools = Array.isArray(rawTools) ? rawTools : rawTools ? [rawTools] : void 0;
|
|
2494
2652
|
options.tools = normalizedTools;
|
|
2495
|
-
|
|
2653
|
+
let system = this.consolidateSystemMessages(messages);
|
|
2654
|
+
if (system) {
|
|
2655
|
+
system += `
|
|
2656
|
+
IMPORTANT! Only when someone asks, remember that you are specifically the ${model} model.`;
|
|
2657
|
+
} else {
|
|
2658
|
+
system = `IMPORTANT! Only when someone asks, remember that you are specifically the ${model} model.`;
|
|
2659
|
+
}
|
|
2496
2660
|
let filteredMessages = ensureToolPairingIntegrity(this.filterRelevantMessages(messages), this.logger);
|
|
2497
2661
|
const countToolBlocks = (msgs) => {
|
|
2498
2662
|
let useCount = 0;
|
|
@@ -3851,7 +4015,10 @@ var AnthropicBedrockBackend = class extends BaseBedrockBackend {
|
|
|
3851
4015
|
}
|
|
3852
4016
|
return { ...m, content: "" };
|
|
3853
4017
|
}).filter((m) => m.content !== "" && (Array.isArray(m.content) ? m.content.length > 0 : true));
|
|
3854
|
-
|
|
4018
|
+
let systemMessage = messages.filter((m) => m.role === "system" && m.content).map((m) => typeof m.content === "string" ? m.content : JSON.stringify(m.content)).join("\n");
|
|
4019
|
+
const modelIdentity = `IMPORTANT! Only when someone asks, remember that you are specifically the ${model} model.`;
|
|
4020
|
+
systemMessage = systemMessage ? `${systemMessage}
|
|
4021
|
+
${modelIdentity}` : modelIdentity;
|
|
3855
4022
|
console.log(`[AnthropicBedrockBackend] Preparing payload for model: ${model}`);
|
|
3856
4023
|
const hasVendorPrefix = model.includes(":") || model.startsWith("global.") || model.startsWith("us.");
|
|
3857
4024
|
const modelId = hasVendorPrefix ? model : `anthropic.${model}`;
|
|
@@ -5912,12 +6079,12 @@ var GPT5_MODELS = [
|
|
|
5912
6079
|
var GPT5_1_MODELS = [ChatModels.GPT5_1, ChatModels.GPT5_1_CHAT_LATEST];
|
|
5913
6080
|
var GPT5_2_MODELS = [ChatModels.GPT5_2, ChatModels.GPT5_2_CHAT_LATEST];
|
|
5914
6081
|
var effortMap = {
|
|
5915
|
-
simple: "
|
|
6082
|
+
simple: "low",
|
|
5916
6083
|
contextual: "low",
|
|
5917
6084
|
complex: "medium"
|
|
5918
6085
|
};
|
|
5919
6086
|
var effortMap_GPT5_1_2 = {
|
|
5920
|
-
simple: "
|
|
6087
|
+
simple: "low",
|
|
5921
6088
|
contextual: "low",
|
|
5922
6089
|
complex: "medium"
|
|
5923
6090
|
};
|
|
@@ -6567,20 +6734,20 @@ var OpenAIBackend = class {
|
|
|
6567
6734
|
stream: true,
|
|
6568
6735
|
...options.maxTokens && { max_completion_tokens: options.maxTokens }
|
|
6569
6736
|
});
|
|
6570
|
-
|
|
6571
|
-
|
|
6572
|
-
|
|
6573
|
-
|
|
6574
|
-
|
|
6575
|
-
|
|
6576
|
-
|
|
6577
|
-
|
|
6578
|
-
|
|
6579
|
-
|
|
6580
|
-
|
|
6581
|
-
|
|
6582
|
-
}
|
|
6583
|
-
}
|
|
6737
|
+
if (REASONING_SUPPORTED_MODELS.has(model)) {
|
|
6738
|
+
let reasoningEffort;
|
|
6739
|
+
if (options.reasoningEffort) {
|
|
6740
|
+
reasoningEffort = options.reasoningEffort;
|
|
6741
|
+
this.logger.debug(`Using explicit reasoning effort: ${reasoningEffort}`);
|
|
6742
|
+
} else if (options.complexity && effortMap[options.complexity]) {
|
|
6743
|
+
reasoningEffort = isGPT5_1Model || isGPT5_2Model ? effortMap_GPT5_1_2[options.complexity] : effortMap[options.complexity];
|
|
6744
|
+
this.logger.debug(`Auto-classified reasoning effort from complexity '${options.complexity}': ${reasoningEffort}`);
|
|
6745
|
+
}
|
|
6746
|
+
if (reasoningEffort) {
|
|
6747
|
+
Object.assign(parameters, {
|
|
6748
|
+
reasoning_effort: reasoningEffort
|
|
6749
|
+
});
|
|
6750
|
+
}
|
|
6584
6751
|
}
|
|
6585
6752
|
} else {
|
|
6586
6753
|
const useStreaming = options.stream && (!options.n || options.n === 1);
|
|
@@ -11590,6 +11757,9 @@ function findAutomaticFallback(originalModel, availableModels, apiKeyTable, logg
|
|
|
11590
11757
|
"gemini-2.5-flash-preview-05-20": ["claude-3-5-haiku-20241022", "gpt-4o-mini", "claude-3-haiku-20240307"],
|
|
11591
11758
|
"gemini-1.5-pro": ["claude-3-5-sonnet-20241022", "gpt-4o", "claude-3-opus-20240229"],
|
|
11592
11759
|
"gemini-1.5-flash": ["claude-3-5-haiku-20241022", "gpt-4o-mini", "claude-3-haiku-20240307"],
|
|
11760
|
+
// Claude 4.5/4.6 Opus models fallback to Sonnet 4.5
|
|
11761
|
+
"claude-opus-4-5-20251101": ["claude-sonnet-4-5-20250929", "gpt-5", "claude-haiku-4-5-20251001"],
|
|
11762
|
+
"claude-opus-4-6": ["claude-sonnet-4-5-20250929", "gpt-5", "claude-haiku-4-5-20251001"],
|
|
11593
11763
|
// Claude models fallback to other Claude models or GPT
|
|
11594
11764
|
"claude-3-5-sonnet-20241022": ["claude-3-opus-20240229", "gpt-4o", "claude-3-sonnet-20240229"],
|
|
11595
11765
|
"claude-3-opus-20240229": ["claude-3-5-sonnet-20241022", "gpt-4o", "claude-3-sonnet-20240229"],
|
|
@@ -11599,7 +11769,7 @@ function findAutomaticFallback(originalModel, availableModels, apiKeyTable, logg
|
|
|
11599
11769
|
};
|
|
11600
11770
|
const preferences = fallbackPreferences[originalModel.id] || [];
|
|
11601
11771
|
if (preferences.length === 0) {
|
|
11602
|
-
preferences.push("claude-
|
|
11772
|
+
preferences.push("claude-sonnet-4-5-20250929", "gpt-5", "claude-haiku-4-5-20251001");
|
|
11603
11773
|
}
|
|
11604
11774
|
for (const modelId of preferences) {
|
|
11605
11775
|
const fallbackModel = availableModels.find((m) => m.id === modelId);
|
|
@@ -11988,6 +12158,59 @@ function buildVoiceInstructions(baseInstructions, historyContext) {
|
|
|
11988
12158
|
return `${baseInstructions}${historyContext}`;
|
|
11989
12159
|
}
|
|
11990
12160
|
|
|
12161
|
+
// ../../b4m-core/packages/utils/dist/src/lambdaErrorHandler.js
|
|
12162
|
+
var isRegistered = false;
|
|
12163
|
+
function classifyError(error) {
|
|
12164
|
+
if (error instanceof TypeError) {
|
|
12165
|
+
if (error.message === "terminated" || error.message.includes("fetch failed")) {
|
|
12166
|
+
return "network_terminated";
|
|
12167
|
+
}
|
|
12168
|
+
}
|
|
12169
|
+
if (error instanceof Error) {
|
|
12170
|
+
if (error.name === "AbortError") {
|
|
12171
|
+
return "network_timeout";
|
|
12172
|
+
}
|
|
12173
|
+
const connectionErrors = ["ECONNRESET", "ETIMEDOUT", "ECONNREFUSED", "EPIPE", "ENOTFOUND"];
|
|
12174
|
+
if (connectionErrors.some((code) => error.message.includes(code))) {
|
|
12175
|
+
return "network_connection";
|
|
12176
|
+
}
|
|
12177
|
+
}
|
|
12178
|
+
return "unhandled_rejection";
|
|
12179
|
+
}
|
|
12180
|
+
function buildLogEntry(error, category) {
|
|
12181
|
+
return {
|
|
12182
|
+
error: error instanceof Error ? error.message : String(error),
|
|
12183
|
+
stack: error instanceof Error ? error.stack : void 0,
|
|
12184
|
+
category,
|
|
12185
|
+
functionName: process.env.AWS_LAMBDA_FUNCTION_NAME,
|
|
12186
|
+
stage: process.env.SEED_STAGE_NAME,
|
|
12187
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
12188
|
+
};
|
|
12189
|
+
}
|
|
12190
|
+
function registerLambdaErrorHandlers(logger) {
|
|
12191
|
+
if (isRegistered)
|
|
12192
|
+
return;
|
|
12193
|
+
isRegistered = true;
|
|
12194
|
+
const log = logger || console;
|
|
12195
|
+
process.on("unhandledRejection", (reason) => {
|
|
12196
|
+
const category = classifyError(reason);
|
|
12197
|
+
const isNetworkError = category.startsWith("network_");
|
|
12198
|
+
const logEntry = buildLogEntry(reason, category);
|
|
12199
|
+
if (isNetworkError) {
|
|
12200
|
+
log.warn("[Lambda] Network error (unhandled rejection)", logEntry);
|
|
12201
|
+
} else {
|
|
12202
|
+
log.error("[Lambda] Unhandled promise rejection", logEntry);
|
|
12203
|
+
}
|
|
12204
|
+
});
|
|
12205
|
+
process.on("uncaughtException", (error) => {
|
|
12206
|
+
const logEntry = buildLogEntry(error, "uncaught_exception");
|
|
12207
|
+
log.error("[Lambda] Uncaught exception", logEntry);
|
|
12208
|
+
});
|
|
12209
|
+
}
|
|
12210
|
+
function _resetLambdaErrorHandlers() {
|
|
12211
|
+
isRegistered = false;
|
|
12212
|
+
}
|
|
12213
|
+
|
|
11991
12214
|
export {
|
|
11992
12215
|
BaseStorage,
|
|
11993
12216
|
S3Storage,
|
|
@@ -12005,6 +12228,9 @@ export {
|
|
|
12005
12228
|
warmUpSettingsCache,
|
|
12006
12229
|
shutdownSettingsCache,
|
|
12007
12230
|
getSettingsCacheStats,
|
|
12231
|
+
isPrivateIP,
|
|
12232
|
+
isPrivateOrInternalHostname,
|
|
12233
|
+
validateUrlForFetch,
|
|
12008
12234
|
URL_REGEX,
|
|
12009
12235
|
detectURLs,
|
|
12010
12236
|
hasURLs,
|
|
@@ -12122,5 +12348,7 @@ export {
|
|
|
12122
12348
|
calculateRetryDelay,
|
|
12123
12349
|
withRetry,
|
|
12124
12350
|
formatVoiceHistory,
|
|
12125
|
-
buildVoiceInstructions
|
|
12351
|
+
buildVoiceInstructions,
|
|
12352
|
+
registerLambdaErrorHandlers,
|
|
12353
|
+
_resetLambdaErrorHandlers
|
|
12126
12354
|
};
|
|
@@ -6,12 +6,12 @@ import {
|
|
|
6
6
|
getSettingsByNames,
|
|
7
7
|
obfuscateApiKey,
|
|
8
8
|
secureParameters
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-RI45VJW3.js";
|
|
10
10
|
import {
|
|
11
11
|
ApiKeyType,
|
|
12
12
|
MementoTier,
|
|
13
13
|
isSupportedEmbeddingModel
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-GE7Q64MS.js";
|
|
15
15
|
|
|
16
16
|
// ../../b4m-core/packages/services/dist/src/apiKeyService/get.js
|
|
17
17
|
import { z } from "zod";
|
|
@@ -7,11 +7,11 @@ import {
|
|
|
7
7
|
getSettingsMap,
|
|
8
8
|
getSettingsValue,
|
|
9
9
|
secureParameters
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-RI45VJW3.js";
|
|
11
11
|
import {
|
|
12
12
|
KnowledgeType,
|
|
13
13
|
SupportedFabFileMimeTypes
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-GE7Q64MS.js";
|
|
15
15
|
|
|
16
16
|
// ../../b4m-core/packages/services/dist/src/fabFileService/create.js
|
|
17
17
|
import { z } from "zod";
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import {
|
|
3
3
|
createFabFile,
|
|
4
4
|
createFabFileSchema
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-ZOWCX4MQ.js";
|
|
6
|
+
import "./chunk-RI45VJW3.js";
|
|
7
|
+
import "./chunk-GE7Q64MS.js";
|
|
8
8
|
import "./chunk-OCYRD7D6.js";
|
|
9
9
|
export {
|
|
10
10
|
createFabFile,
|