@bike4mind/cli 0.2.31-feat-cli-websocket-streaming.19470 → 0.2.31-feat-wolfram-alpha-tool.19435
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/{HydrationEngine-YL2HWJ3V.js → HydrationEngine-WGYKF46H.js} +1 -1
- package/dist/{artifactExtractor-TFERMHLV.js → artifactExtractor-T2KT7N6X.js} +1 -1
- package/dist/{chunk-SYJA4DXH.js → chunk-DZRTVQWQ.js} +39 -178
- package/dist/{chunk-2HFZJMGD.js → chunk-HP6AES2S.js} +22 -91
- package/dist/{chunk-YJ5ZBTMG.js → chunk-L2AY6OBS.js} +2 -2
- package/dist/{chunk-NIWN4JNK.js → chunk-P3HKXYUI.js} +2 -2
- package/dist/{chunk-GQGOWACU.js → chunk-RUI6HNLO.js} +4 -8
- package/dist/{chunk-QFMQLZDW.js → chunk-VZMIFBOO.js} +8 -2
- package/dist/{create-ST2OYV5P.js → create-QJLBG5Q4.js} +3 -3
- package/dist/index.js +146 -709
- package/dist/{llmMarkdownGenerator-ZCY65G7S.js → llmMarkdownGenerator-TLV3FO6P.js} +1 -1
- package/dist/{markdownGenerator-U25WUMYV.js → markdownGenerator-MIVT6AKJ.js} +1 -1
- package/dist/{mementoService-GUKZKGHK.js → mementoService-FLW6PFJJ.js} +3 -3
- package/dist/{src-JPID56V3.js → src-2AR46ZFO.js} +1 -13
- package/dist/{src-PSIWH3X6.js → src-LKRWND4T.js} +2 -8
- package/dist/{subtractCredits-22VX543V.js → subtractCredits-VXZWDYWZ.js} +3 -3
- package/package.json +6 -6
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
CurationArtifactType
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-HP6AES2S.js";
|
|
5
5
|
|
|
6
6
|
// ../../b4m-core/packages/services/dist/src/notebookCurationService/artifactExtractor.js
|
|
7
7
|
var ARTIFACT_TAG_REGEX = /<artifact\s+(.*?)>([\s\S]*?)<\/artifact>/gi;
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
dayjsConfig_default,
|
|
17
17
|
extractSnippetMeta,
|
|
18
18
|
settingsMap
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-HP6AES2S.js";
|
|
20
20
|
import {
|
|
21
21
|
Logger
|
|
22
22
|
} from "./chunk-OCYRD7D6.js";
|
|
@@ -591,125 +591,6 @@ function getSettingsCacheStats() {
|
|
|
591
591
|
// ../../b4m-core/packages/utils/dist/src/ingest.js
|
|
592
592
|
import axios from "axios";
|
|
593
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
|
|
713
594
|
var URL_REGEX = /https?:\/\/(?:[-\w.])+(?:\:[0-9]+)?(?:\/(?:[\w\/_.])*(?:\?(?:[\w&=%.])*)?(?:\#(?:[\w.])*)?)?/gi;
|
|
714
595
|
function detectURLs(string) {
|
|
715
596
|
const urlsFound = string.match(URL_REGEX) || [];
|
|
@@ -722,22 +603,15 @@ function urlExists(stringWithPossibleUrl) {
|
|
|
722
603
|
const cleanString = stringWithPossibleUrl.replace(/\n/g, " ").replace(/,/g, " ");
|
|
723
604
|
return detectURLs(cleanString);
|
|
724
605
|
}
|
|
725
|
-
var URL_FETCH_TIMEOUT_MS = 1e4;
|
|
726
606
|
async function fetchAndParseURL(url, { logger }) {
|
|
727
607
|
logger.updateMetadata({ failedUrl: null });
|
|
728
608
|
try {
|
|
729
|
-
const ssrfValidation = await validateUrlForFetch(url);
|
|
730
|
-
if (!ssrfValidation.valid) {
|
|
731
|
-
throw new Error(`URL blocked for security reasons: ${ssrfValidation.error}`);
|
|
732
|
-
}
|
|
733
609
|
let urlMimeType = "text/plain";
|
|
734
610
|
if (url.split(".")?.pop()?.startsWith("pdf")) {
|
|
735
611
|
urlMimeType = "application/pdf";
|
|
736
612
|
}
|
|
737
613
|
const response = await axios.get(url, {
|
|
738
|
-
responseType: ["application/pdf"].includes(urlMimeType) ? "arraybuffer" : "text"
|
|
739
|
-
timeout: URL_FETCH_TIMEOUT_MS
|
|
740
|
-
// Prevent Lambda timeout exhaustion
|
|
614
|
+
responseType: ["application/pdf"].includes(urlMimeType) ? "arraybuffer" : "text"
|
|
741
615
|
});
|
|
742
616
|
const cheerio = await import("cheerio");
|
|
743
617
|
const htmlContent = response.data;
|
|
@@ -745,19 +619,17 @@ async function fetchAndParseURL(url, { logger }) {
|
|
|
745
619
|
const title = $("title").text() || url.split("/")?.pop();
|
|
746
620
|
let urlContent = null;
|
|
747
621
|
switch (urlMimeType) {
|
|
748
|
-
case "application/pdf":
|
|
622
|
+
case "application/pdf":
|
|
749
623
|
const pdfbuffer = Buffer.from(response.data);
|
|
750
624
|
urlContent = pdfbuffer;
|
|
751
625
|
break;
|
|
752
|
-
|
|
753
|
-
default: {
|
|
626
|
+
default:
|
|
754
627
|
let textContent = "";
|
|
755
628
|
$("body").find("p").each((index, element) => {
|
|
756
629
|
textContent += $(element).text() + "\n";
|
|
757
630
|
});
|
|
758
631
|
urlContent = textContent || htmlContent;
|
|
759
632
|
break;
|
|
760
|
-
}
|
|
761
633
|
}
|
|
762
634
|
logger.log(`Fetched ${title} with mimetype ${urlMimeType} and parsed ${url}`);
|
|
763
635
|
return { title, textContent: urlContent, mimeType: urlMimeType, ext: mime2.extension(urlMimeType) || null };
|
|
@@ -1283,30 +1155,8 @@ function separateUrls(urls) {
|
|
|
1283
1155
|
const nonImageUrls = urls.filter((url) => !imageExtensions.some((ext) => url.toLowerCase().endsWith(ext)));
|
|
1284
1156
|
return { imageUrls, nonImageUrls };
|
|
1285
1157
|
}
|
|
1286
|
-
|
|
1287
|
-
|
|
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
|
-
}
|
|
1158
|
+
var urlContentCache = /* @__PURE__ */ new Map();
|
|
1159
|
+
var CACHE_TTL_MS = 5 * 60 * 1e3;
|
|
1310
1160
|
async function processUrlsFromPrompt(userPrompt, maxContentBuffer, userId, sendStatusUpdate, logger, options = { verbose: false }) {
|
|
1311
1161
|
if (!hasURLs(userPrompt)) {
|
|
1312
1162
|
if (options?.verbose) {
|
|
@@ -1314,7 +1164,6 @@ async function processUrlsFromPrompt(userPrompt, maxContentBuffer, userId, sendS
|
|
|
1314
1164
|
}
|
|
1315
1165
|
return { userMessages: [], remainingPrompt: userPrompt };
|
|
1316
1166
|
}
|
|
1317
|
-
const urlContentCache = /* @__PURE__ */ new Map();
|
|
1318
1167
|
sendStatusUpdate("Processing URLs from user prompt...");
|
|
1319
1168
|
const userMessages = [];
|
|
1320
1169
|
const promptMeta = extractSnippetMeta(userPrompt);
|
|
@@ -1342,26 +1191,20 @@ async function processUrlsFromPrompt(userPrompt, maxContentBuffer, userId, sendS
|
|
|
1342
1191
|
try {
|
|
1343
1192
|
const cached = urlContentCache.get(url);
|
|
1344
1193
|
let textContent;
|
|
1345
|
-
if (cached) {
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
source: "same-request-dedup"
|
|
1351
|
-
});
|
|
1352
|
-
textContent = cached;
|
|
1194
|
+
if (cached && Date.now() - cached.timestamp < CACHE_TTL_MS) {
|
|
1195
|
+
if (options?.verbose) {
|
|
1196
|
+
logger.log(`Using cached content for URL: ${url}`);
|
|
1197
|
+
}
|
|
1198
|
+
textContent = cached.content;
|
|
1353
1199
|
} else {
|
|
1354
1200
|
const result = await fetchAndParseURL(url, { logger });
|
|
1355
1201
|
if (typeof result.textContent !== "string")
|
|
1356
1202
|
throw new Error("textContent is not a string");
|
|
1357
1203
|
textContent = result.textContent;
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
cacheHit: false,
|
|
1362
|
-
contentLength: textContent.length
|
|
1204
|
+
urlContentCache.set(url, {
|
|
1205
|
+
content: textContent,
|
|
1206
|
+
timestamp: Date.now()
|
|
1363
1207
|
});
|
|
1364
|
-
urlContentCache.set(url, textContent);
|
|
1365
1208
|
}
|
|
1366
1209
|
const message = {
|
|
1367
1210
|
role: "user",
|
|
@@ -2994,6 +2837,12 @@ IMPORTANT! Only when someone asks, remember that you are specifically the ${mode
|
|
|
2994
2837
|
resultLength: resultStr.length,
|
|
2995
2838
|
resultPreview: resultStr.substring(0, 100) + (resultStr.length > 100 ? "..." : "")
|
|
2996
2839
|
});
|
|
2840
|
+
const toolEntry = toolsUsed.find((t) => t.id === id || t.name === name);
|
|
2841
|
+
if (toolEntry) {
|
|
2842
|
+
toolEntry.returnValue = resultStr;
|
|
2843
|
+
toolEntry.executionTime = toolDuration;
|
|
2844
|
+
toolEntry.success = true;
|
|
2845
|
+
}
|
|
2997
2846
|
await handleToolResultStreaming(name, result, async (results) => {
|
|
2998
2847
|
await cb(results, {
|
|
2999
2848
|
inputTokens: 0,
|
|
@@ -3015,6 +2864,12 @@ IMPORTANT! Only when someone asks, remember that you are specifically the ${mode
|
|
|
3015
2864
|
durationMs: toolDuration,
|
|
3016
2865
|
error: error instanceof Error ? error.message : "Unknown error"
|
|
3017
2866
|
});
|
|
2867
|
+
const toolEntry = toolsUsed.find((t) => t.id === id || t.name === name);
|
|
2868
|
+
if (toolEntry) {
|
|
2869
|
+
toolEntry.error = error instanceof Error ? error.message : "Unknown error";
|
|
2870
|
+
toolEntry.executionTime = toolDuration;
|
|
2871
|
+
toolEntry.success = false;
|
|
2872
|
+
}
|
|
3018
2873
|
const toolId = id || `tool_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
3019
2874
|
this.pushToolMessages(messages, { id: toolId, name, parameters }, `Error processing ${name} tool: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
3020
2875
|
}
|
|
@@ -3140,6 +2995,12 @@ IMPORTANT! Only when someone asks, remember that you are specifically the ${mode
|
|
|
3140
2995
|
resultLength: resultStr.length,
|
|
3141
2996
|
resultPreview: resultStr.substring(0, 100) + (resultStr.length > 100 ? "..." : "")
|
|
3142
2997
|
});
|
|
2998
|
+
const toolEntry = toolsUsed.find((t) => t.id === id || t.name === name);
|
|
2999
|
+
if (toolEntry) {
|
|
3000
|
+
toolEntry.returnValue = resultStr;
|
|
3001
|
+
toolEntry.executionTime = toolDuration;
|
|
3002
|
+
toolEntry.success = true;
|
|
3003
|
+
}
|
|
3143
3004
|
await handleToolResultStreaming(name, result, async (results) => {
|
|
3144
3005
|
await cb(results, { toolsUsed });
|
|
3145
3006
|
});
|
|
@@ -3157,6 +3018,12 @@ IMPORTANT! Only when someone asks, remember that you are specifically the ${mode
|
|
|
3157
3018
|
durationMs: toolDuration,
|
|
3158
3019
|
error: error instanceof Error ? error.message : "Unknown error"
|
|
3159
3020
|
});
|
|
3021
|
+
const toolEntry = toolsUsed.find((t) => t.id === id || t.name === name);
|
|
3022
|
+
if (toolEntry) {
|
|
3023
|
+
toolEntry.error = error instanceof Error ? error.message : "Unknown error";
|
|
3024
|
+
toolEntry.executionTime = toolDuration;
|
|
3025
|
+
toolEntry.success = false;
|
|
3026
|
+
}
|
|
3160
3027
|
const toolId = id || `tool_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
3161
3028
|
this.pushToolMessages(messages, { id: toolId, name, parameters }, `Error processing ${name} tool: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
3162
3029
|
}
|
|
@@ -11757,9 +11624,6 @@ function findAutomaticFallback(originalModel, availableModels, apiKeyTable, logg
|
|
|
11757
11624
|
"gemini-2.5-flash-preview-05-20": ["claude-3-5-haiku-20241022", "gpt-4o-mini", "claude-3-haiku-20240307"],
|
|
11758
11625
|
"gemini-1.5-pro": ["claude-3-5-sonnet-20241022", "gpt-4o", "claude-3-opus-20240229"],
|
|
11759
11626
|
"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"],
|
|
11763
11627
|
// Claude models fallback to other Claude models or GPT
|
|
11764
11628
|
"claude-3-5-sonnet-20241022": ["claude-3-opus-20240229", "gpt-4o", "claude-3-sonnet-20240229"],
|
|
11765
11629
|
"claude-3-opus-20240229": ["claude-3-5-sonnet-20241022", "gpt-4o", "claude-3-sonnet-20240229"],
|
|
@@ -11769,7 +11633,7 @@ function findAutomaticFallback(originalModel, availableModels, apiKeyTable, logg
|
|
|
11769
11633
|
};
|
|
11770
11634
|
const preferences = fallbackPreferences[originalModel.id] || [];
|
|
11771
11635
|
if (preferences.length === 0) {
|
|
11772
|
-
preferences.push("claude-
|
|
11636
|
+
preferences.push("claude-3-5-sonnet-20241022", "gpt-4o", "claude-3-haiku-20240307");
|
|
11773
11637
|
}
|
|
11774
11638
|
for (const modelId of preferences) {
|
|
11775
11639
|
const fallbackModel = availableModels.find((m) => m.id === modelId);
|
|
@@ -12175,9 +12039,6 @@ export {
|
|
|
12175
12039
|
warmUpSettingsCache,
|
|
12176
12040
|
shutdownSettingsCache,
|
|
12177
12041
|
getSettingsCacheStats,
|
|
12178
|
-
isPrivateIP,
|
|
12179
|
-
isPrivateOrInternalHostname,
|
|
12180
|
-
validateUrlForFetch,
|
|
12181
12042
|
URL_REGEX,
|
|
12182
12043
|
detectURLs,
|
|
12183
12044
|
hasURLs,
|
|
@@ -307,6 +307,7 @@ var b4mLLMTools = z5.enum([
|
|
|
307
307
|
"weather_info",
|
|
308
308
|
"web_search",
|
|
309
309
|
"web_fetch",
|
|
310
|
+
"wolfram_alpha",
|
|
310
311
|
"math_evaluate",
|
|
311
312
|
"mermaid_chart",
|
|
312
313
|
"current_datetime",
|
|
@@ -326,8 +327,6 @@ var b4mLLMTools = z5.enum([
|
|
|
326
327
|
// Knowledge base search
|
|
327
328
|
"search_knowledge_base",
|
|
328
329
|
"retrieve_knowledge_content",
|
|
329
|
-
// Agent delegation
|
|
330
|
-
"delegate_to_agent",
|
|
331
330
|
// Quantum optimization tools
|
|
332
331
|
"quantum_schedule",
|
|
333
332
|
"quantum_formulate",
|
|
@@ -1217,29 +1216,6 @@ var VoiceSessionSendTranscriptAction = z10.object({
|
|
|
1217
1216
|
conversationItemId: z10.string(),
|
|
1218
1217
|
timestamp: z10.coerce.date().optional()
|
|
1219
1218
|
});
|
|
1220
|
-
var CliCompletionRequestAction = z10.object({
|
|
1221
|
-
action: z10.literal("cli_completion_request"),
|
|
1222
|
-
accessToken: z10.string(),
|
|
1223
|
-
requestId: z10.string().uuid(),
|
|
1224
|
-
model: z10.string(),
|
|
1225
|
-
messages: z10.array(z10.object({
|
|
1226
|
-
role: z10.enum(["user", "assistant", "system"]),
|
|
1227
|
-
content: z10.union([z10.string(), z10.array(z10.unknown())])
|
|
1228
|
-
})),
|
|
1229
|
-
options: z10.object({
|
|
1230
|
-
temperature: z10.number().optional(),
|
|
1231
|
-
maxTokens: z10.number().optional(),
|
|
1232
|
-
stream: z10.boolean().optional(),
|
|
1233
|
-
tools: z10.array(z10.unknown()).optional()
|
|
1234
|
-
}).optional()
|
|
1235
|
-
});
|
|
1236
|
-
var CliToolRequestAction = z10.object({
|
|
1237
|
-
action: z10.literal("cli_tool_request"),
|
|
1238
|
-
accessToken: z10.string(),
|
|
1239
|
-
requestId: z10.string().uuid(),
|
|
1240
|
-
toolName: z10.string(),
|
|
1241
|
-
input: z10.record(z10.unknown())
|
|
1242
|
-
});
|
|
1243
1219
|
var VoiceSessionEndedAction = z10.object({
|
|
1244
1220
|
action: z10.literal("voice_session_ended"),
|
|
1245
1221
|
userId: z10.string(),
|
|
@@ -1528,36 +1504,6 @@ var VoiceCreditsExhaustedAction = z10.object({
|
|
|
1528
1504
|
creditsUsed: z10.number(),
|
|
1529
1505
|
clientId: z10.string().optional()
|
|
1530
1506
|
});
|
|
1531
|
-
var CliCompletionChunkAction = z10.object({
|
|
1532
|
-
action: z10.literal("cli_completion_chunk"),
|
|
1533
|
-
requestId: z10.string(),
|
|
1534
|
-
chunk: z10.object({
|
|
1535
|
-
type: z10.enum(["content", "tool_use"]),
|
|
1536
|
-
text: z10.string(),
|
|
1537
|
-
tools: z10.array(z10.unknown()).optional(),
|
|
1538
|
-
usage: z10.object({
|
|
1539
|
-
inputTokens: z10.number().optional(),
|
|
1540
|
-
outputTokens: z10.number().optional()
|
|
1541
|
-
}).optional(),
|
|
1542
|
-
thinking: z10.array(z10.unknown()).optional()
|
|
1543
|
-
})
|
|
1544
|
-
});
|
|
1545
|
-
var CliCompletionDoneAction = z10.object({
|
|
1546
|
-
action: z10.literal("cli_completion_done"),
|
|
1547
|
-
requestId: z10.string()
|
|
1548
|
-
});
|
|
1549
|
-
var CliCompletionErrorAction = z10.object({
|
|
1550
|
-
action: z10.literal("cli_completion_error"),
|
|
1551
|
-
requestId: z10.string(),
|
|
1552
|
-
error: z10.string()
|
|
1553
|
-
});
|
|
1554
|
-
var CliToolResponseAction = z10.object({
|
|
1555
|
-
action: z10.literal("cli_tool_response"),
|
|
1556
|
-
requestId: z10.string(),
|
|
1557
|
-
success: z10.boolean(),
|
|
1558
|
-
content: z10.unknown().optional(),
|
|
1559
|
-
error: z10.string().optional()
|
|
1560
|
-
});
|
|
1561
1507
|
var SessionCreatedAction = shareableDocumentSchema.extend({
|
|
1562
1508
|
action: z10.literal("session.created"),
|
|
1563
1509
|
id: z10.string(),
|
|
@@ -1592,9 +1538,7 @@ var MessageDataToServer = z10.discriminatedUnion("action", [
|
|
|
1592
1538
|
DataUnsubscribeRequestAction,
|
|
1593
1539
|
HeartbeatAction,
|
|
1594
1540
|
VoiceSessionSendTranscriptAction,
|
|
1595
|
-
VoiceSessionEndedAction
|
|
1596
|
-
CliCompletionRequestAction,
|
|
1597
|
-
CliToolRequestAction
|
|
1541
|
+
VoiceSessionEndedAction
|
|
1598
1542
|
]);
|
|
1599
1543
|
var MessageDataToClient = z10.discriminatedUnion("action", [
|
|
1600
1544
|
DataSubscriptionUpdateAction,
|
|
@@ -1620,11 +1564,7 @@ var MessageDataToClient = z10.discriminatedUnion("action", [
|
|
|
1620
1564
|
PiHistoryCompleteAction,
|
|
1621
1565
|
PiHistoryErrorAction,
|
|
1622
1566
|
SessionCreatedAction,
|
|
1623
|
-
VoiceCreditsExhaustedAction
|
|
1624
|
-
CliCompletionChunkAction,
|
|
1625
|
-
CliCompletionDoneAction,
|
|
1626
|
-
CliCompletionErrorAction,
|
|
1627
|
-
CliToolResponseAction
|
|
1567
|
+
VoiceCreditsExhaustedAction
|
|
1628
1568
|
]);
|
|
1629
1569
|
|
|
1630
1570
|
// ../../b4m-core/packages/common/dist/src/schemas/cliCompletions.js
|
|
@@ -2501,6 +2441,7 @@ var SettingKeySchema = z21.enum([
|
|
|
2501
2441
|
"SystemFiles",
|
|
2502
2442
|
"OpenWeatherKey",
|
|
2503
2443
|
"SerperKey",
|
|
2444
|
+
"WolframAlphaKey",
|
|
2504
2445
|
"VectorThreshold",
|
|
2505
2446
|
"bflApiKey",
|
|
2506
2447
|
"EnableMCPServer",
|
|
@@ -2938,10 +2879,13 @@ var API_SERVICE_GROUPS = {
|
|
|
2938
2879
|
},
|
|
2939
2880
|
SEARCH: {
|
|
2940
2881
|
id: "searchAPIService",
|
|
2941
|
-
name: "Search
|
|
2942
|
-
description: "
|
|
2882
|
+
name: "Search & Compute",
|
|
2883
|
+
description: "Search and computational API integration settings",
|
|
2943
2884
|
icon: "Search",
|
|
2944
|
-
settings: [
|
|
2885
|
+
settings: [
|
|
2886
|
+
{ key: "SerperKey", order: 1 },
|
|
2887
|
+
{ key: "WolframAlphaKey", order: 2 }
|
|
2888
|
+
]
|
|
2945
2889
|
},
|
|
2946
2890
|
CALENDAR: {
|
|
2947
2891
|
id: "calendarAPIService",
|
|
@@ -3724,6 +3668,16 @@ var settingsMap = {
|
|
|
3724
3668
|
order: 1,
|
|
3725
3669
|
isSensitive: true
|
|
3726
3670
|
}),
|
|
3671
|
+
WolframAlphaKey: makeStringSetting({
|
|
3672
|
+
key: "WolframAlphaKey",
|
|
3673
|
+
name: "Wolfram Alpha API Key",
|
|
3674
|
+
defaultValue: "",
|
|
3675
|
+
description: "The AppID for Wolfram Alpha LLM API. Get one at developer.wolframalpha.com.",
|
|
3676
|
+
category: "Tools",
|
|
3677
|
+
group: API_SERVICE_GROUPS.SEARCH.id,
|
|
3678
|
+
order: 2,
|
|
3679
|
+
isSensitive: true
|
|
3680
|
+
}),
|
|
3727
3681
|
VectorThreshold: makeNumberSetting({
|
|
3728
3682
|
key: "VectorThreshold",
|
|
3729
3683
|
name: "Vector Threshold",
|
|
@@ -9434,16 +9388,7 @@ var VIEW_REGISTRY = [
|
|
|
9434
9388
|
description: "Configure which solvers to race \u2014 greedy, simulated annealing, tabu search, genetic algorithm, ant colony",
|
|
9435
9389
|
navigationType: "action",
|
|
9436
9390
|
target: "scheduling.solvers",
|
|
9437
|
-
keywords: [
|
|
9438
|
-
"solvers",
|
|
9439
|
-
"tabu",
|
|
9440
|
-
"simulated annealing",
|
|
9441
|
-
"genetic algorithm",
|
|
9442
|
-
"ant colony",
|
|
9443
|
-
"greedy",
|
|
9444
|
-
"solver race",
|
|
9445
|
-
"configure solvers"
|
|
9446
|
-
]
|
|
9391
|
+
keywords: ["solvers", "tabu", "simulated annealing", "genetic algorithm", "ant colony", "greedy", "solver race", "configure solvers"]
|
|
9447
9392
|
},
|
|
9448
9393
|
{
|
|
9449
9394
|
id: "opti.scheduling.results",
|
|
@@ -9452,15 +9397,7 @@ var VIEW_REGISTRY = [
|
|
|
9452
9397
|
description: "View solver race results \u2014 progress, best schedule, makespan comparison, utilization",
|
|
9453
9398
|
navigationType: "action",
|
|
9454
9399
|
target: "scheduling.results",
|
|
9455
|
-
keywords: [
|
|
9456
|
-
"results",
|
|
9457
|
-
"race results",
|
|
9458
|
-
"makespan",
|
|
9459
|
-
"comparison",
|
|
9460
|
-
"best schedule",
|
|
9461
|
-
"utilization",
|
|
9462
|
-
"solver comparison"
|
|
9463
|
-
]
|
|
9400
|
+
keywords: ["results", "race results", "makespan", "comparison", "best schedule", "utilization", "solver comparison"]
|
|
9464
9401
|
},
|
|
9465
9402
|
{
|
|
9466
9403
|
id: "opti.scheduling.gantt",
|
|
@@ -10210,8 +10147,6 @@ export {
|
|
|
10210
10147
|
DataUnsubscribeRequestAction,
|
|
10211
10148
|
HeartbeatAction,
|
|
10212
10149
|
VoiceSessionSendTranscriptAction,
|
|
10213
|
-
CliCompletionRequestAction,
|
|
10214
|
-
CliToolRequestAction,
|
|
10215
10150
|
VoiceSessionEndedAction,
|
|
10216
10151
|
DataSubscriptionUpdateAction,
|
|
10217
10152
|
LLMStatusUpdateAction,
|
|
@@ -10236,10 +10171,6 @@ export {
|
|
|
10236
10171
|
ImportHistoryJobProgressUpdateAction,
|
|
10237
10172
|
ResearchModeStreamAction,
|
|
10238
10173
|
VoiceCreditsExhaustedAction,
|
|
10239
|
-
CliCompletionChunkAction,
|
|
10240
|
-
CliCompletionDoneAction,
|
|
10241
|
-
CliCompletionErrorAction,
|
|
10242
|
-
CliToolResponseAction,
|
|
10243
10174
|
SessionCreatedAction,
|
|
10244
10175
|
MessageDataToServer,
|
|
10245
10176
|
MessageDataToClient,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import {
|
|
3
3
|
BadRequestError,
|
|
4
4
|
secureParameters
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-DZRTVQWQ.js";
|
|
6
6
|
import {
|
|
7
7
|
CompletionApiUsageTransaction,
|
|
8
8
|
GenericCreditDeductTransaction,
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
TextGenerationUsageTransaction,
|
|
13
13
|
TransferCreditTransaction,
|
|
14
14
|
VideoGenerationUsageTransaction
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-HP6AES2S.js";
|
|
16
16
|
|
|
17
17
|
// ../../b4m-core/packages/services/dist/src/creditService/subtractCredits.js
|
|
18
18
|
import { z } from "zod";
|
|
@@ -7,11 +7,11 @@ import {
|
|
|
7
7
|
getSettingsMap,
|
|
8
8
|
getSettingsValue,
|
|
9
9
|
secureParameters
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-DZRTVQWQ.js";
|
|
11
11
|
import {
|
|
12
12
|
KnowledgeType,
|
|
13
13
|
SupportedFabFileMimeTypes
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-HP6AES2S.js";
|
|
15
15
|
|
|
16
16
|
// ../../b4m-core/packages/services/dist/src/fabFileService/create.js
|
|
17
17
|
import { z } from "zod";
|
|
@@ -595,13 +595,12 @@ var HydrationEngine = class {
|
|
|
595
595
|
return numericInputs[0] / numericInputs[1];
|
|
596
596
|
case "ABS":
|
|
597
597
|
return numericInputs.length > 0 ? Math.abs(numericInputs[0]) : 0;
|
|
598
|
-
case "ROUND":
|
|
598
|
+
case "ROUND":
|
|
599
599
|
if (numericInputs.length === 0)
|
|
600
600
|
return 0;
|
|
601
601
|
const decimals = numericInputs[1] ?? 0;
|
|
602
602
|
const factor = Math.pow(10, decimals);
|
|
603
603
|
return Math.round(numericInputs[0] * factor) / factor;
|
|
604
|
-
}
|
|
605
604
|
case "FLOOR":
|
|
606
605
|
return numericInputs.length > 0 ? Math.floor(numericInputs[0]) : 0;
|
|
607
606
|
case "CEIL":
|
|
@@ -625,13 +624,12 @@ var HydrationEngine = class {
|
|
|
625
624
|
return numericInputs.length > 0 ? Math.max(...numericInputs) : 0;
|
|
626
625
|
case "COUNT":
|
|
627
626
|
return inputs.filter((v) => v !== null).length;
|
|
628
|
-
case "MEDIAN":
|
|
627
|
+
case "MEDIAN":
|
|
629
628
|
if (numericInputs.length === 0)
|
|
630
629
|
return 0;
|
|
631
630
|
const sorted = [...numericInputs].sort((a, b) => a - b);
|
|
632
631
|
const mid = Math.floor(sorted.length / 2);
|
|
633
632
|
return sorted.length % 2 === 0 ? (sorted[mid - 1] + sorted[mid]) / 2 : sorted[mid];
|
|
634
|
-
}
|
|
635
633
|
// Logical
|
|
636
634
|
case "IF":
|
|
637
635
|
return inputs[0] ? inputs[1] : inputs[2];
|
|
@@ -651,14 +649,13 @@ var HydrationEngine = class {
|
|
|
651
649
|
return inputs.length >= 2 && inputs[0] >= inputs[1];
|
|
652
650
|
case "LESS_THAN_OR_EQUAL":
|
|
653
651
|
return inputs.length >= 2 && inputs[0] <= inputs[1];
|
|
654
|
-
case "BETWEEN":
|
|
652
|
+
case "BETWEEN":
|
|
655
653
|
if (inputs.length < 3)
|
|
656
654
|
return false;
|
|
657
655
|
const val = inputs[0];
|
|
658
656
|
const min = inputs[1];
|
|
659
657
|
const max = inputs[2];
|
|
660
658
|
return val >= min && val <= max;
|
|
661
|
-
}
|
|
662
659
|
// Financial
|
|
663
660
|
case "PERCENT_OF":
|
|
664
661
|
if (numericInputs.length < 2 || numericInputs[1] === 0)
|
|
@@ -717,12 +714,11 @@ var HydrationEngine = class {
|
|
|
717
714
|
case "REFERENCE":
|
|
718
715
|
return inputs[0];
|
|
719
716
|
// Pass through
|
|
720
|
-
case "LOOKUP":
|
|
717
|
+
case "LOOKUP":
|
|
721
718
|
if (inputs.length < 2)
|
|
722
719
|
return null;
|
|
723
720
|
const index = inputs[0];
|
|
724
721
|
return inputs[Math.min(index + 1, inputs.length - 1)];
|
|
725
|
-
}
|
|
726
722
|
default:
|
|
727
723
|
context.errors.push({
|
|
728
724
|
type: "INVALID_OPERATION",
|
|
@@ -6,12 +6,12 @@ import {
|
|
|
6
6
|
getSettingsByNames,
|
|
7
7
|
obfuscateApiKey,
|
|
8
8
|
secureParameters
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-DZRTVQWQ.js";
|
|
10
10
|
import {
|
|
11
11
|
ApiKeyType,
|
|
12
12
|
MementoTier,
|
|
13
13
|
isSupportedEmbeddingModel
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-HP6AES2S.js";
|
|
15
15
|
|
|
16
16
|
// ../../b4m-core/packages/services/dist/src/apiKeyService/get.js
|
|
17
17
|
import { z } from "zod";
|
|
@@ -62,6 +62,11 @@ var getOpenWeatherKey = async (adapters) => {
|
|
|
62
62
|
const settings = await db.adminSettings.findBySettingName("OpenWeatherKey");
|
|
63
63
|
return settings?.settingValue;
|
|
64
64
|
};
|
|
65
|
+
var getWolframAlphaKey = async (adapters) => {
|
|
66
|
+
const { db } = adapters;
|
|
67
|
+
const settings = await db.adminSettings.findBySettingName("WolframAlphaKey");
|
|
68
|
+
return settings?.settingValue;
|
|
69
|
+
};
|
|
65
70
|
var getEffectiveApiKey = async (userId, params, adapters) => {
|
|
66
71
|
const { db } = adapters;
|
|
67
72
|
const apiKey = await getApiKey(userId, params, adapters);
|
|
@@ -229,6 +234,7 @@ function findMostSimilarMemento(targetEmbedding, mementos) {
|
|
|
229
234
|
export {
|
|
230
235
|
getSerperKey,
|
|
231
236
|
getOpenWeatherKey,
|
|
237
|
+
getWolframAlphaKey,
|
|
232
238
|
getEffectiveApiKey,
|
|
233
239
|
getRelevantMementos,
|
|
234
240
|
findMostSimilarMemento
|