@bike4mind/cli 0.2.5-feat-server-side-tool-execution.17096 → 0.2.5-feat-auto-context-customization.17096
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/README.md +33 -29
- package/dist/{artifactExtractor-GXQ5YZF7.js → artifactExtractor-JPM5X4QR.js} +1 -1
- package/dist/{chunk-WR6YZRQV.js → chunk-2RFX62SX.js} +3 -1
- package/dist/{chunk-WNBKV4FX.js → chunk-55PRVW6C.js} +2 -2
- package/dist/{chunk-LEG2UM5Q.js → chunk-GXADX53I.js} +2 -2
- package/dist/{chunk-6AJODFPC.js → chunk-QFDR3XXO.js} +2 -2
- package/dist/{chunk-LYNNVNEC.js → chunk-RM2KFSVU.js} +1 -1
- package/dist/{create-LOAAI36O.js → create-YNOMI6YQ.js} +3 -3
- package/dist/index.js +207 -179
- package/dist/{llmMarkdownGenerator-4ZR3FLEQ.js → llmMarkdownGenerator-T3OBRBEL.js} +1 -1
- package/dist/{markdownGenerator-7WE7WKME.js → markdownGenerator-3CHNICAY.js} +1 -1
- package/dist/{mementoService-XGFAWC5F.js → mementoService-NXPL4ZYA.js} +3 -3
- package/dist/{src-32Z2VZMC.js → src-TKRGPJT4.js} +2 -2
- package/dist/{src-6J6LFPZ6.js → src-XWYCD3H6.js} +1 -1
- package/dist/{subtractCredits-VMGWNJS7.js → subtractCredits-KSYATBCK.js} +3 -3
- package/package.json +6 -8
- package/bin/b4m-mcp-proxy.mjs +0 -79
- package/dist/mcp-proxy/client.d.ts +0 -47
- package/dist/mcp-proxy/client.d.ts.map +0 -1
- package/dist/mcp-proxy/client.js +0 -124
- package/dist/mcp-proxy/client.js.map +0 -1
- package/dist/mcp-proxy/index.d.ts +0 -32
- package/dist/mcp-proxy/index.d.ts.map +0 -1
- package/dist/mcp-proxy/index.js +0 -187
- package/dist/mcp-proxy/index.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -4,9 +4,9 @@ import {
|
|
|
4
4
|
getEffectiveApiKey,
|
|
5
5
|
getOpenWeatherKey,
|
|
6
6
|
getSerperKey
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
7
|
+
} from "./chunk-55PRVW6C.js";
|
|
8
|
+
import "./chunk-GXADX53I.js";
|
|
9
|
+
import "./chunk-QFDR3XXO.js";
|
|
10
10
|
import {
|
|
11
11
|
BFLImageService,
|
|
12
12
|
BaseStorage,
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
OpenAIBackend,
|
|
16
16
|
OpenAIImageService,
|
|
17
17
|
XAIImageService
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-RM2KFSVU.js";
|
|
19
19
|
import {
|
|
20
20
|
Logger
|
|
21
21
|
} from "./chunk-AMDXHL6S.js";
|
|
@@ -73,7 +73,7 @@ import {
|
|
|
73
73
|
XAI_IMAGE_MODELS,
|
|
74
74
|
b4mLLMTools,
|
|
75
75
|
getMcpProviderMetadata
|
|
76
|
-
} from "./chunk-
|
|
76
|
+
} from "./chunk-2RFX62SX.js";
|
|
77
77
|
import {
|
|
78
78
|
__require
|
|
79
79
|
} from "./chunk-PDX44BCA.js";
|
|
@@ -1408,16 +1408,16 @@ var AuthTokensSchema = z.object({
|
|
|
1408
1408
|
var ApiConfigSchema = z.object({
|
|
1409
1409
|
customUrl: z.string().url().optional()
|
|
1410
1410
|
});
|
|
1411
|
-
var LegacyApiConfigSchema = z.object({
|
|
1412
|
-
environment: z.enum(["production", "staging", "preview", "local", "custom"]),
|
|
1413
|
-
customUrl: z.string().url().optional()
|
|
1414
|
-
});
|
|
1415
1411
|
var CliConfigSchema = z.object({
|
|
1416
1412
|
version: z.string(),
|
|
1417
1413
|
userId: z.string(),
|
|
1418
1414
|
auth: AuthTokensSchema.optional(),
|
|
1419
1415
|
defaultModel: z.string(),
|
|
1420
1416
|
apiConfig: ApiConfigSchema.optional(),
|
|
1417
|
+
toolApiKeys: z.object({
|
|
1418
|
+
openweather: z.string().optional(),
|
|
1419
|
+
serper: z.string().optional()
|
|
1420
|
+
}).optional(),
|
|
1421
1421
|
mcpServers: z.array(
|
|
1422
1422
|
z.object({
|
|
1423
1423
|
name: z.string(),
|
|
@@ -1442,36 +1442,15 @@ var CliConfigSchema = z.object({
|
|
|
1442
1442
|
}),
|
|
1443
1443
|
trustedTools: z.array(z.string()).optional().default([])
|
|
1444
1444
|
});
|
|
1445
|
-
var getCliPackageRoot = () => {
|
|
1446
|
-
const currentFile = new URL(import.meta.url).pathname;
|
|
1447
|
-
const currentDir = path4.dirname(currentFile);
|
|
1448
|
-
if (currentDir.endsWith("/dist") || currentDir.includes("/dist/")) {
|
|
1449
|
-
return path4.resolve(currentDir, "..");
|
|
1450
|
-
}
|
|
1451
|
-
if (currentDir.includes("/src")) {
|
|
1452
|
-
const srcIndex = currentDir.lastIndexOf("/src");
|
|
1453
|
-
return currentDir.substring(0, srcIndex);
|
|
1454
|
-
}
|
|
1455
|
-
return process.cwd();
|
|
1456
|
-
};
|
|
1457
1445
|
var DEFAULT_CONFIG = {
|
|
1458
1446
|
version: "0.1.0",
|
|
1459
1447
|
userId: uuidv4(),
|
|
1460
1448
|
defaultModel: "claude-sonnet-4-5-20250929",
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
args: [path4.join(getCliPackageRoot(), "bin/b4m-mcp-proxy.mjs")],
|
|
1467
|
-
// Absolute path to wrapper script
|
|
1468
|
-
env: {
|
|
1469
|
-
// Token and API URL injected dynamically by wrapper script
|
|
1470
|
-
B4M_TIMEOUT: "30000"
|
|
1471
|
-
},
|
|
1472
|
-
enabled: true
|
|
1473
|
-
}
|
|
1474
|
-
],
|
|
1449
|
+
toolApiKeys: {
|
|
1450
|
+
openweather: void 0,
|
|
1451
|
+
serper: void 0
|
|
1452
|
+
},
|
|
1453
|
+
mcpServers: [],
|
|
1475
1454
|
preferences: {
|
|
1476
1455
|
maxTokens: 4096,
|
|
1477
1456
|
temperature: 0.7,
|
|
@@ -1526,14 +1505,11 @@ var ConfigStore = class {
|
|
|
1526
1505
|
const data = await fs4.readFile(this.configPath, "utf-8");
|
|
1527
1506
|
const rawConfig = JSON.parse(data);
|
|
1528
1507
|
if (rawConfig.apiConfig && "environment" in rawConfig.apiConfig) {
|
|
1529
|
-
const
|
|
1530
|
-
if (
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
} else {
|
|
1535
|
-
rawConfig.apiConfig = {};
|
|
1536
|
-
}
|
|
1508
|
+
const oldApiConfig = rawConfig.apiConfig;
|
|
1509
|
+
if (oldApiConfig.environment === "custom" && oldApiConfig.customUrl) {
|
|
1510
|
+
rawConfig.apiConfig = { customUrl: oldApiConfig.customUrl };
|
|
1511
|
+
} else {
|
|
1512
|
+
rawConfig.apiConfig = {};
|
|
1537
1513
|
}
|
|
1538
1514
|
}
|
|
1539
1515
|
const validated = CliConfigSchema.parse(rawConfig);
|
|
@@ -1550,6 +1526,10 @@ var ConfigStore = class {
|
|
|
1550
1526
|
...DEFAULT_CONFIG.tools,
|
|
1551
1527
|
...validated.tools
|
|
1552
1528
|
},
|
|
1529
|
+
toolApiKeys: {
|
|
1530
|
+
...DEFAULT_CONFIG.toolApiKeys,
|
|
1531
|
+
...validated.toolApiKeys || {}
|
|
1532
|
+
},
|
|
1553
1533
|
trustedTools: validated.trustedTools || []
|
|
1554
1534
|
};
|
|
1555
1535
|
return this.config;
|
|
@@ -1584,6 +1564,10 @@ var ConfigStore = class {
|
|
|
1584
1564
|
tools: {
|
|
1585
1565
|
...existingConfig.tools,
|
|
1586
1566
|
...config.tools || {}
|
|
1567
|
+
},
|
|
1568
|
+
toolApiKeys: {
|
|
1569
|
+
...existingConfig.toolApiKeys,
|
|
1570
|
+
...config.toolApiKeys || {}
|
|
1587
1571
|
}
|
|
1588
1572
|
};
|
|
1589
1573
|
}
|
|
@@ -1736,26 +1720,6 @@ var ConfigStore = class {
|
|
|
1736
1720
|
}
|
|
1737
1721
|
await this.save(config);
|
|
1738
1722
|
}
|
|
1739
|
-
/**
|
|
1740
|
-
* Ensure B4M MCP server is configured (auto-add if missing)
|
|
1741
|
-
* This provides server-side tools (weather, serper) to the CLI
|
|
1742
|
-
*/
|
|
1743
|
-
async ensureB4mMcpServer() {
|
|
1744
|
-
const config = await this.load();
|
|
1745
|
-
const hasB4mServer = config.mcpServers.some((s) => s.name === "b4m-tools");
|
|
1746
|
-
if (!hasB4mServer) {
|
|
1747
|
-
config.mcpServers.push({
|
|
1748
|
-
name: "b4m-tools",
|
|
1749
|
-
command: "node",
|
|
1750
|
-
args: [path4.join(getCliPackageRoot(), "bin/b4m-mcp-proxy.mjs")],
|
|
1751
|
-
env: {
|
|
1752
|
-
B4M_TIMEOUT: "30000"
|
|
1753
|
-
},
|
|
1754
|
-
enabled: true
|
|
1755
|
-
});
|
|
1756
|
-
await this.save(config);
|
|
1757
|
-
}
|
|
1758
|
-
}
|
|
1759
1723
|
};
|
|
1760
1724
|
|
|
1761
1725
|
// src/storage/CommandHistoryStore.ts
|
|
@@ -3123,7 +3087,9 @@ var updateSchema = z76.object({
|
|
|
3123
3087
|
name: z76.string().optional(),
|
|
3124
3088
|
description: z76.string().optional(),
|
|
3125
3089
|
billingContact: z76.string().optional(),
|
|
3126
|
-
currentCredits: z76.coerce.number().optional()
|
|
3090
|
+
currentCredits: z76.coerce.number().optional(),
|
|
3091
|
+
systemPrompt: z76.string().max(1e4).optional()
|
|
3092
|
+
// ~2500 tokens
|
|
3127
3093
|
});
|
|
3128
3094
|
|
|
3129
3095
|
// ../../b4m-core/packages/services/dist/src/organizationService/delete.js
|
|
@@ -4317,8 +4283,8 @@ async function processAndStoreImages(images, context) {
|
|
|
4317
4283
|
const buffer = await downloadImage(image);
|
|
4318
4284
|
const fileType = await fileTypeFromBuffer2(buffer);
|
|
4319
4285
|
const filename = `${uuidv45()}.${fileType?.ext}`;
|
|
4320
|
-
const
|
|
4321
|
-
return
|
|
4286
|
+
const path13 = await context.imageGenerateStorage.upload(buffer, filename, {});
|
|
4287
|
+
return path13;
|
|
4322
4288
|
}));
|
|
4323
4289
|
}
|
|
4324
4290
|
async function updateQuestAndReturnMarkdown(storedImageUrls, context) {
|
|
@@ -5502,8 +5468,8 @@ async function processAndStoreImage(imageUrl, context) {
|
|
|
5502
5468
|
const buffer = await downloadImage2(imageUrl);
|
|
5503
5469
|
const fileType = await fileTypeFromBuffer3(buffer);
|
|
5504
5470
|
const filename = `${uuidv46()}.${fileType?.ext}`;
|
|
5505
|
-
const
|
|
5506
|
-
return
|
|
5471
|
+
const path13 = await context.imageGenerateStorage.upload(buffer, filename, {});
|
|
5472
|
+
return path13;
|
|
5507
5473
|
}
|
|
5508
5474
|
async function updateQuestAndReturnMarkdown2(storedImagePath, context) {
|
|
5509
5475
|
await context.onFinish?.("edit_image", storedImagePath);
|
|
@@ -7915,6 +7881,92 @@ var deleteFileTool = {
|
|
|
7915
7881
|
})
|
|
7916
7882
|
};
|
|
7917
7883
|
|
|
7884
|
+
// ../../b4m-core/packages/services/dist/src/llm/tools/implementation/knowledgeBaseSearch/index.js
|
|
7885
|
+
function formatSearchResults(files) {
|
|
7886
|
+
if (files.length === 0) {
|
|
7887
|
+
return "No documents found matching your search query in your knowledge base.";
|
|
7888
|
+
}
|
|
7889
|
+
const formattedFiles = files.map((file, index) => {
|
|
7890
|
+
const tags = file.tags?.map((t) => t.name).join(", ") || "none";
|
|
7891
|
+
const notes = file.notes ? `
|
|
7892
|
+
Notes: ${file.notes}` : "";
|
|
7893
|
+
const fileType = file.type || "FILE";
|
|
7894
|
+
return `${index + 1}. **${file.fileName}**
|
|
7895
|
+
Type: ${fileType} | MIME: ${file.mimeType}
|
|
7896
|
+
Tags: ${tags}${notes}`;
|
|
7897
|
+
});
|
|
7898
|
+
return `Found ${files.length} document(s) in your knowledge base:
|
|
7899
|
+
|
|
7900
|
+
` + formattedFiles.join("\n\n") + "\n\n*To use these documents in your conversation, you can ask me to reference specific files by name.*";
|
|
7901
|
+
}
|
|
7902
|
+
var knowledgeBaseSearchTool = {
|
|
7903
|
+
name: "search_knowledge_base",
|
|
7904
|
+
implementation: (context) => ({
|
|
7905
|
+
toolFn: async (value) => {
|
|
7906
|
+
const params = value;
|
|
7907
|
+
const { query, tags, file_type, max_results = 5 } = params;
|
|
7908
|
+
console.log("\u{1F4DA} Knowledge Base Search: Starting search for query:", query);
|
|
7909
|
+
if (!context.db.fabfiles) {
|
|
7910
|
+
console.error("\u274C Knowledge Base Search: fabfiles repository not available");
|
|
7911
|
+
return "Knowledge base search is not available at this time.";
|
|
7912
|
+
}
|
|
7913
|
+
try {
|
|
7914
|
+
const searchResults = await context.db.fabfiles.search(context.userId, query, {
|
|
7915
|
+
tags: tags || [],
|
|
7916
|
+
type: file_type,
|
|
7917
|
+
shared: false
|
|
7918
|
+
// Search all accessible files, not just shared
|
|
7919
|
+
}, {
|
|
7920
|
+
page: 1,
|
|
7921
|
+
limit: Math.min(max_results, 10)
|
|
7922
|
+
// Cap at 10 results
|
|
7923
|
+
}, {
|
|
7924
|
+
by: "fileName",
|
|
7925
|
+
direction: "asc"
|
|
7926
|
+
}, {
|
|
7927
|
+
includeShared: true
|
|
7928
|
+
// Include organization and explicitly shared files
|
|
7929
|
+
});
|
|
7930
|
+
console.log("\u{1F4DA} Knowledge Base Search: Found", searchResults.data.length, "results");
|
|
7931
|
+
return formatSearchResults(searchResults.data);
|
|
7932
|
+
} catch (error) {
|
|
7933
|
+
console.error("\u274C Knowledge Base Search: Error during search:", error);
|
|
7934
|
+
return "An error occurred while searching your knowledge base. Please try again.";
|
|
7935
|
+
}
|
|
7936
|
+
},
|
|
7937
|
+
toolSchema: {
|
|
7938
|
+
name: "search_knowledge_base",
|
|
7939
|
+
description: "Search the user's uploaded knowledge base (fab files). Returns relevant documents from the user's own files, organization-shared files, and files explicitly shared with them. Use this tool when the user asks about their own documents, uploaded files, or organization knowledge.",
|
|
7940
|
+
parameters: {
|
|
7941
|
+
type: "object",
|
|
7942
|
+
properties: {
|
|
7943
|
+
query: {
|
|
7944
|
+
type: "string",
|
|
7945
|
+
description: "The search query to find relevant documents by filename or content"
|
|
7946
|
+
},
|
|
7947
|
+
tags: {
|
|
7948
|
+
type: "array",
|
|
7949
|
+
items: { type: "string" },
|
|
7950
|
+
description: "Optional: filter results to only include files with these tags"
|
|
7951
|
+
},
|
|
7952
|
+
file_type: {
|
|
7953
|
+
type: "string",
|
|
7954
|
+
enum: ["pdf", "text", "image", "excel", "word", "json", "csv", "markdown", "code", "url"],
|
|
7955
|
+
description: "Optional: filter results by file type"
|
|
7956
|
+
},
|
|
7957
|
+
max_results: {
|
|
7958
|
+
type: "number",
|
|
7959
|
+
description: "Maximum number of results to return (default: 5, max: 10)",
|
|
7960
|
+
minimum: 1,
|
|
7961
|
+
maximum: 10
|
|
7962
|
+
}
|
|
7963
|
+
},
|
|
7964
|
+
required: ["query"]
|
|
7965
|
+
}
|
|
7966
|
+
}
|
|
7967
|
+
})
|
|
7968
|
+
};
|
|
7969
|
+
|
|
7918
7970
|
// ../../b4m-core/packages/services/dist/src/llm/tools/index.js
|
|
7919
7971
|
var tools = {
|
|
7920
7972
|
dice_roll: diceRollTool,
|
|
@@ -7942,7 +7994,9 @@ var tools = {
|
|
|
7942
7994
|
create_file: createFileTool,
|
|
7943
7995
|
glob_files: globFilesTool,
|
|
7944
7996
|
grep_search: grepSearchTool,
|
|
7945
|
-
delete_file: deleteFileTool
|
|
7997
|
+
delete_file: deleteFileTool,
|
|
7998
|
+
// Knowledge base search
|
|
7999
|
+
search_knowledge_base: knowledgeBaseSearchTool
|
|
7946
8000
|
};
|
|
7947
8001
|
var generateTools = (userId, user, logger2, { db }, storage, imageGenerateStorage, statusUpdate, onStart, onFinish, llm, config, model) => {
|
|
7948
8002
|
const context = {
|
|
@@ -8222,21 +8276,21 @@ var NoOpStorage = class extends BaseStorage {
|
|
|
8222
8276
|
async upload(input, destination, options) {
|
|
8223
8277
|
return `/tmp/${destination}`;
|
|
8224
8278
|
}
|
|
8225
|
-
async download(
|
|
8279
|
+
async download(path13) {
|
|
8226
8280
|
throw new Error("Download not supported in CLI");
|
|
8227
8281
|
}
|
|
8228
|
-
async delete(
|
|
8282
|
+
async delete(path13) {
|
|
8229
8283
|
}
|
|
8230
|
-
async getSignedUrl(
|
|
8231
|
-
return `/tmp/${
|
|
8284
|
+
async getSignedUrl(path13) {
|
|
8285
|
+
return `/tmp/${path13}`;
|
|
8232
8286
|
}
|
|
8233
|
-
getPublicUrl(
|
|
8234
|
-
return `/tmp/${
|
|
8287
|
+
getPublicUrl(path13) {
|
|
8288
|
+
return `/tmp/${path13}`;
|
|
8235
8289
|
}
|
|
8236
|
-
async getPreview(
|
|
8237
|
-
return `/tmp/${
|
|
8290
|
+
async getPreview(path13) {
|
|
8291
|
+
return `/tmp/${path13}`;
|
|
8238
8292
|
}
|
|
8239
|
-
async getMetadata(
|
|
8293
|
+
async getMetadata(path13) {
|
|
8240
8294
|
return { size: 0, contentType: "application/octet-stream" };
|
|
8241
8295
|
}
|
|
8242
8296
|
};
|
|
@@ -8308,7 +8362,7 @@ function wrapToolWithPermission(tool, permissionManager, showPermissionPrompt, a
|
|
|
8308
8362
|
}
|
|
8309
8363
|
};
|
|
8310
8364
|
}
|
|
8311
|
-
function generateCliTools(userId, llm, model, permissionManager, showPermissionPrompt, agentContext) {
|
|
8365
|
+
function generateCliTools(userId, llm, model, permissionManager, showPermissionPrompt, agentContext, toolApiKeys) {
|
|
8312
8366
|
const logger2 = new CliLogger();
|
|
8313
8367
|
const storage = new NoOpStorage();
|
|
8314
8368
|
const user = {
|
|
@@ -8323,27 +8377,50 @@ function generateCliTools(userId, llm, model, permissionManager, showPermissionP
|
|
|
8323
8377
|
};
|
|
8324
8378
|
const onFinish = async (toolName, data) => {
|
|
8325
8379
|
};
|
|
8380
|
+
const mockAdminSettings = {
|
|
8381
|
+
findBySettingName: async (settingName) => {
|
|
8382
|
+
if (settingName === "OpenWeatherKey") {
|
|
8383
|
+
const key = toolApiKeys?.openweather || process.env.OPENWEATHER_API_KEY;
|
|
8384
|
+
if (key) {
|
|
8385
|
+
return { settingValue: key };
|
|
8386
|
+
}
|
|
8387
|
+
}
|
|
8388
|
+
if (settingName === "SerperKey") {
|
|
8389
|
+
const key = toolApiKeys?.serper || process.env.SERPER_API_KEY;
|
|
8390
|
+
if (key) {
|
|
8391
|
+
return { settingValue: key };
|
|
8392
|
+
}
|
|
8393
|
+
}
|
|
8394
|
+
return null;
|
|
8395
|
+
}
|
|
8396
|
+
};
|
|
8326
8397
|
const dbAdapters = {
|
|
8327
8398
|
db: {
|
|
8328
8399
|
apiKeys: null,
|
|
8329
|
-
adminSettings:
|
|
8400
|
+
adminSettings: mockAdminSettings
|
|
8330
8401
|
}
|
|
8331
8402
|
};
|
|
8403
|
+
const hasSerperKey = !!(toolApiKeys?.serper || process.env.SERPER_API_KEY);
|
|
8404
|
+
const hasOpenWeatherKey = !!(toolApiKeys?.openweather || process.env.OPENWEATHER_API_KEY);
|
|
8332
8405
|
const toolConfig = {
|
|
8333
|
-
//
|
|
8406
|
+
// Enable these tools for CLI (no external API keys needed)
|
|
8334
8407
|
dice_roll: {},
|
|
8335
8408
|
math_evaluate: {},
|
|
8336
8409
|
current_datetime: {},
|
|
8337
8410
|
prompt_enhancement: {},
|
|
8338
|
-
// File operation tools (CLI-specific
|
|
8411
|
+
// File operation tools (CLI-specific)
|
|
8339
8412
|
file_read: {},
|
|
8340
8413
|
create_file: {},
|
|
8341
8414
|
glob_files: {},
|
|
8342
8415
|
grep_search: {},
|
|
8343
|
-
delete_file: {}
|
|
8344
|
-
//
|
|
8345
|
-
|
|
8346
|
-
//
|
|
8416
|
+
delete_file: {},
|
|
8417
|
+
// Tools requiring API keys (only include if API key is available)
|
|
8418
|
+
...hasSerperKey && { web_search: {} },
|
|
8419
|
+
// Requires SERPER_API_KEY
|
|
8420
|
+
...hasOpenWeatherKey && { weather_info: {} },
|
|
8421
|
+
// Requires OPENWEATHER_API_KEY
|
|
8422
|
+
...hasSerperKey && { deep_research: {} }
|
|
8423
|
+
// Requires SERPER_API_KEY
|
|
8347
8424
|
// Disable web-only tools
|
|
8348
8425
|
// blog_publish: undefined,
|
|
8349
8426
|
// blog_edit: undefined,
|
|
@@ -8803,14 +8880,12 @@ var MCPClient = class {
|
|
|
8803
8880
|
mcp;
|
|
8804
8881
|
transport = null;
|
|
8805
8882
|
envVariables;
|
|
8806
|
-
customScriptPath;
|
|
8807
8883
|
tools = [];
|
|
8808
8884
|
serverName;
|
|
8809
|
-
constructor({ envVariables, name, selectedRepositories
|
|
8885
|
+
constructor({ envVariables, name, selectedRepositories }) {
|
|
8810
8886
|
this.mcp = new Client2({ name: "mcp-client-cli", version: "1.0.0" });
|
|
8811
8887
|
this.envVariables = [...envVariables];
|
|
8812
8888
|
this.serverName = name;
|
|
8813
|
-
this.customScriptPath = customScriptPath;
|
|
8814
8889
|
if (name === "github" && selectedRepositories) {
|
|
8815
8890
|
const reposJson = JSON.stringify(selectedRepositories);
|
|
8816
8891
|
this.envVariables.push({
|
|
@@ -8821,35 +8896,26 @@ var MCPClient = class {
|
|
|
8821
8896
|
}
|
|
8822
8897
|
async connectToServer() {
|
|
8823
8898
|
try {
|
|
8824
|
-
|
|
8825
|
-
|
|
8826
|
-
|
|
8827
|
-
|
|
8828
|
-
|
|
8829
|
-
|
|
8830
|
-
|
|
8831
|
-
|
|
8832
|
-
|
|
8833
|
-
|
|
8834
|
-
|
|
8835
|
-
|
|
8836
|
-
|
|
8837
|
-
|
|
8838
|
-
|
|
8839
|
-
|
|
8840
|
-
|
|
8841
|
-
|
|
8842
|
-
|
|
8843
|
-
|
|
8844
|
-
];
|
|
8845
|
-
const foundPath = candidatePaths.find((p) => existsSync6(p));
|
|
8846
|
-
if (!foundPath) {
|
|
8847
|
-
const getDirectories = (source) => readdirSync3(source, { withFileTypes: true }).filter((dirent) => dirent.isDirectory()).map((dirent) => dirent.name);
|
|
8848
|
-
console.error(`[MCP] Server script not found. Tried paths:`, candidatePaths);
|
|
8849
|
-
console.error(`[MCP] Available directories in ${root}:`, getDirectories(root));
|
|
8850
|
-
throw new Error(`MCP Server script path not found for ${this.serverName}. Root: ${root}, Available dirs: ${getDirectories(root).join(", ")}`);
|
|
8851
|
-
}
|
|
8852
|
-
serverScriptPath = foundPath;
|
|
8899
|
+
const root = process.env.INIT_CWD || process.cwd();
|
|
8900
|
+
const candidatePaths = [
|
|
8901
|
+
// When running from SST Lambda with node_modules structure (copyFiles)
|
|
8902
|
+
path12.join(root, `node_modules/@bike4mind/mcp/dist/src/${this.serverName}/index.js`),
|
|
8903
|
+
// When running from SST Lambda deployed environment (/var/task)
|
|
8904
|
+
path12.join(root, `b4m-core/packages/mcp/dist/src/${this.serverName}/index.js`),
|
|
8905
|
+
// When running from SST Lambda (.sst/artifacts/mcpHandler-dev), navigate to monorepo root (3 levels up)
|
|
8906
|
+
path12.join(root, `../../../b4m-core/packages/mcp/dist/src/${this.serverName}/index.js`),
|
|
8907
|
+
// When running from packages/client (Next.js app), navigate to monorepo root (2 levels up)
|
|
8908
|
+
path12.join(root, `../../b4m-core/packages/mcp/dist/src/${this.serverName}/index.js`),
|
|
8909
|
+
// Original paths (backward compatibility)
|
|
8910
|
+
path12.join(root, `/b4m-core/packages/mcp/dist/src/${this.serverName}/index.js`),
|
|
8911
|
+
path12.join(root, "core", "mcp", "servers", this.serverName, "dist", "index.js")
|
|
8912
|
+
];
|
|
8913
|
+
const serverScriptPath = candidatePaths.find((p) => existsSync6(p));
|
|
8914
|
+
if (!serverScriptPath) {
|
|
8915
|
+
const getDirectories = (source) => readdirSync3(source, { withFileTypes: true }).filter((dirent) => dirent.isDirectory()).map((dirent) => dirent.name);
|
|
8916
|
+
console.error(`[MCP] Server script not found. Tried paths:`, candidatePaths);
|
|
8917
|
+
console.error(`[MCP] Available directories in ${root}:`, getDirectories(root));
|
|
8918
|
+
throw new Error(`MCP Server script path not found for ${this.serverName}. Root: ${root}, Available dirs: ${getDirectories(root).join(", ")}`);
|
|
8853
8919
|
}
|
|
8854
8920
|
console.log(`[MCP] Using server: ${this.serverName} at ${serverScriptPath}`);
|
|
8855
8921
|
this.transport = new StdioClientTransport({
|
|
@@ -8931,20 +8997,6 @@ var MCPClient = class {
|
|
|
8931
8997
|
};
|
|
8932
8998
|
|
|
8933
8999
|
// src/utils/mcpAdapter.ts
|
|
8934
|
-
import path13 from "path";
|
|
8935
|
-
import { fileURLToPath } from "url";
|
|
8936
|
-
var getCliPackageRoot2 = () => {
|
|
8937
|
-
const currentFile = fileURLToPath(import.meta.url);
|
|
8938
|
-
const currentDir = path13.dirname(currentFile);
|
|
8939
|
-
if (currentDir.includes("/dist")) {
|
|
8940
|
-
return path13.resolve(currentDir, "..");
|
|
8941
|
-
}
|
|
8942
|
-
if (currentDir.includes("/src")) {
|
|
8943
|
-
const srcIndex = currentDir.lastIndexOf("/src");
|
|
8944
|
-
return currentDir.substring(0, srcIndex);
|
|
8945
|
-
}
|
|
8946
|
-
return process.cwd();
|
|
8947
|
-
};
|
|
8948
9000
|
var McpManager = class {
|
|
8949
9001
|
constructor(config) {
|
|
8950
9002
|
this.servers = /* @__PURE__ */ new Map();
|
|
@@ -8980,16 +9032,9 @@ var McpManager = class {
|
|
|
8980
9032
|
key,
|
|
8981
9033
|
value
|
|
8982
9034
|
}));
|
|
8983
|
-
let scriptPath = serverConfig.args?.[0];
|
|
8984
|
-
if (scriptPath && !path13.isAbsolute(scriptPath)) {
|
|
8985
|
-
scriptPath = path13.join(getCliPackageRoot2(), scriptPath);
|
|
8986
|
-
logger.debug(`Resolved MCP script path: ${scriptPath}`);
|
|
8987
|
-
}
|
|
8988
9035
|
const client = new MCPClient({
|
|
8989
9036
|
envVariables,
|
|
8990
|
-
name: serverConfig.name
|
|
8991
|
-
// Pass custom script path for bundled servers like b4m-tools
|
|
8992
|
-
customScriptPath: scriptPath
|
|
9037
|
+
name: serverConfig.name
|
|
8993
9038
|
});
|
|
8994
9039
|
await client.connectToServer();
|
|
8995
9040
|
const mcpData = {
|
|
@@ -9447,7 +9492,7 @@ import { isAxiosError as isAxiosError2 } from "axios";
|
|
|
9447
9492
|
// package.json
|
|
9448
9493
|
var package_default = {
|
|
9449
9494
|
name: "@bike4mind/cli",
|
|
9450
|
-
version: "0.2.5-feat-
|
|
9495
|
+
version: "0.2.5-feat-auto-context-customization.17096+23b9f23d6",
|
|
9451
9496
|
type: "module",
|
|
9452
9497
|
description: "Interactive CLI tool for Bike4Mind with ReAct agents",
|
|
9453
9498
|
license: "UNLICENSED",
|
|
@@ -9480,7 +9525,6 @@ var package_default = {
|
|
|
9480
9525
|
scripts: {
|
|
9481
9526
|
dev: "tsx src/index.tsx",
|
|
9482
9527
|
build: "tsup",
|
|
9483
|
-
postbuild: "node scripts/bundle-mcp-proxy.mjs",
|
|
9484
9528
|
typecheck: "tsc --noEmit",
|
|
9485
9529
|
test: "vitest run",
|
|
9486
9530
|
"test:watch": "vitest",
|
|
@@ -9550,11 +9594,10 @@ var package_default = {
|
|
|
9550
9594
|
},
|
|
9551
9595
|
devDependencies: {
|
|
9552
9596
|
"@bike4mind/agents": "0.1.0",
|
|
9553
|
-
"@bike4mind/common": "2.37.1-feat-
|
|
9554
|
-
"@bike4mind/mcp": "1.19.6-feat-
|
|
9555
|
-
"@bike4mind/
|
|
9556
|
-
"@bike4mind/
|
|
9557
|
-
"@bike4mind/utils": "2.1.1-feat-server-side-tool-execution.17096+d6b936a82",
|
|
9597
|
+
"@bike4mind/common": "2.37.1-feat-auto-context-customization.17096+23b9f23d6",
|
|
9598
|
+
"@bike4mind/mcp": "1.19.6-feat-auto-context-customization.17096+23b9f23d6",
|
|
9599
|
+
"@bike4mind/services": "2.32.2-feat-auto-context-customization.17096+23b9f23d6",
|
|
9600
|
+
"@bike4mind/utils": "2.1.1-feat-auto-context-customization.17096+23b9f23d6",
|
|
9558
9601
|
"@types/diff": "^5.0.9",
|
|
9559
9602
|
"@types/jsonwebtoken": "^9.0.4",
|
|
9560
9603
|
"@types/node": "^22.9.0",
|
|
@@ -9566,7 +9609,7 @@ var package_default = {
|
|
|
9566
9609
|
typescript: "^5.9.3",
|
|
9567
9610
|
vitest: "^3.2.4"
|
|
9568
9611
|
},
|
|
9569
|
-
gitHead: "
|
|
9612
|
+
gitHead: "23b9f23d64c9e7444d7eebf7034f6cdd4ce6db45"
|
|
9570
9613
|
};
|
|
9571
9614
|
|
|
9572
9615
|
// src/config/constants.ts
|
|
@@ -9673,7 +9716,6 @@ function CliApp() {
|
|
|
9673
9716
|
isAuthenticated = true;
|
|
9674
9717
|
const daysUntilExpiry = Math.floor((expiresAt.getTime() - Date.now()) / (1e3 * 60 * 60 * 24));
|
|
9675
9718
|
console.log(`\u2705 Authenticated (expires in ${daysUntilExpiry} day${daysUntilExpiry !== 1 ? "s" : ""})`);
|
|
9676
|
-
await state.configStore.ensureB4mMcpServer();
|
|
9677
9719
|
}
|
|
9678
9720
|
}
|
|
9679
9721
|
if (!isAuthenticated) {
|
|
@@ -9771,6 +9813,10 @@ function CliApp() {
|
|
|
9771
9813
|
setPermissionPrompt(prompt);
|
|
9772
9814
|
});
|
|
9773
9815
|
};
|
|
9816
|
+
console.log("\u{1F511} Tool API Keys:", {
|
|
9817
|
+
openweather: config.toolApiKeys?.openweather ? "\u2713 configured" : "\u2717 missing",
|
|
9818
|
+
serper: config.toolApiKeys?.serper ? "\u2713 configured" : "\u2717 missing"
|
|
9819
|
+
});
|
|
9774
9820
|
const agentContext = {
|
|
9775
9821
|
currentAgent: null,
|
|
9776
9822
|
observationQueue: []
|
|
@@ -9781,35 +9827,18 @@ function CliApp() {
|
|
|
9781
9827
|
modelInfo.id,
|
|
9782
9828
|
permissionManager,
|
|
9783
9829
|
promptFn,
|
|
9784
|
-
agentContext
|
|
9830
|
+
agentContext,
|
|
9831
|
+
config.toolApiKeys
|
|
9785
9832
|
);
|
|
9786
|
-
console.log(`\u{1F6E0}\uFE0F Loaded ${b4mTools.length}
|
|
9787
|
-
|
|
9788
|
-
|
|
9789
|
-
|
|
9790
|
-
|
|
9791
|
-
|
|
9792
|
-
|
|
9793
|
-
|
|
9794
|
-
|
|
9795
|
-
toolCounts.forEach(({ serverName, count }) => {
|
|
9796
|
-
console.log(` \u{1F4E1} ${serverName}: ${count} tool(s)`);
|
|
9797
|
-
});
|
|
9798
|
-
}
|
|
9799
|
-
const hasB4mServer = mcpManager.getServerNames().includes("b4m-tools");
|
|
9800
|
-
if (hasB4mServer) {
|
|
9801
|
-
console.log("\u{1F310} B4M server tools available (weather, web search)");
|
|
9802
|
-
} else if (!authTokens) {
|
|
9803
|
-
console.log("\u2139\uFE0F Weather and search tools require authentication");
|
|
9804
|
-
console.log(" Run /login to enable B4M server tools");
|
|
9805
|
-
}
|
|
9806
|
-
} catch (error) {
|
|
9807
|
-
console.log("\u26A0\uFE0F MCP server initialization failed - continuing with local tools only");
|
|
9808
|
-
if (error instanceof Error) {
|
|
9809
|
-
console.log(` Error: ${error.message}`);
|
|
9810
|
-
}
|
|
9811
|
-
mcpManager = null;
|
|
9812
|
-
mcpTools = [];
|
|
9833
|
+
console.log(`\u{1F6E0}\uFE0F Loaded ${b4mTools.length} B4M tool(s)`);
|
|
9834
|
+
const mcpManager = new McpManager(config);
|
|
9835
|
+
await mcpManager.initialize();
|
|
9836
|
+
const mcpTools = mcpManager.getTools();
|
|
9837
|
+
if (mcpTools.length > 0) {
|
|
9838
|
+
const toolCounts = mcpManager.getToolCount();
|
|
9839
|
+
toolCounts.forEach(({ serverName, count }) => {
|
|
9840
|
+
console.log(` \u{1F4E1} ${serverName}: ${count} tool(s)`);
|
|
9841
|
+
});
|
|
9813
9842
|
}
|
|
9814
9843
|
const allTools = [...b4mTools, ...mcpTools];
|
|
9815
9844
|
console.log(`\u2705 Total: ${allTools.length} tool(s) available`);
|
|
@@ -10273,10 +10302,9 @@ No usage data available for the last ${USAGE_DAYS} days.`);
|
|
|
10273
10302
|
{
|
|
10274
10303
|
apiUrl: loginApiUrl,
|
|
10275
10304
|
configStore: state.configStore,
|
|
10276
|
-
onSuccess:
|
|
10305
|
+
onSuccess: () => {
|
|
10277
10306
|
setState((prev) => ({ ...prev, showLoginFlow: false }));
|
|
10278
10307
|
console.log("\n\u2705 Login successful! Initializing CLI...\n");
|
|
10279
|
-
await state.configStore.ensureB4mMcpServer();
|
|
10280
10308
|
init().catch((err) => {
|
|
10281
10309
|
console.error("\n\u274C Initialization failed:", err.message, "\n");
|
|
10282
10310
|
exit();
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
import {
|
|
3
3
|
findMostSimilarMemento,
|
|
4
4
|
getRelevantMementos
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-55PRVW6C.js";
|
|
6
|
+
import "./chunk-RM2KFSVU.js";
|
|
7
7
|
import "./chunk-AMDXHL6S.js";
|
|
8
|
-
import "./chunk-
|
|
8
|
+
import "./chunk-2RFX62SX.js";
|
|
9
9
|
import "./chunk-PDX44BCA.js";
|
|
10
10
|
export {
|
|
11
11
|
findMostSimilarMemento,
|
|
@@ -120,7 +120,7 @@ import {
|
|
|
120
120
|
validateMermaidSyntax,
|
|
121
121
|
warmUpSettingsCache,
|
|
122
122
|
withRetry
|
|
123
|
-
} from "./chunk-
|
|
123
|
+
} from "./chunk-RM2KFSVU.js";
|
|
124
124
|
import {
|
|
125
125
|
Logger,
|
|
126
126
|
NotificationDeduplicator,
|
|
@@ -129,7 +129,7 @@ import {
|
|
|
129
129
|
postLowCreditsNotificationToSlack,
|
|
130
130
|
postMessageToSlack
|
|
131
131
|
} from "./chunk-AMDXHL6S.js";
|
|
132
|
-
import "./chunk-
|
|
132
|
+
import "./chunk-2RFX62SX.js";
|
|
133
133
|
import "./chunk-PDX44BCA.js";
|
|
134
134
|
export {
|
|
135
135
|
AWSBackend,
|