@bike4mind/cli 0.2.5-feat-auto-context-customization.17095 → 0.2.5-feat-server-side-tool-execution.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 CHANGED
@@ -135,42 +135,38 @@ Check your current API configuration:
135
135
  /api-info
136
136
  ```
137
137
 
138
- ### Tool API Keys
138
+ ### Built-in Tools
139
+
140
+ The CLI provides access to various tools that execute server-side using B4M company API keys:
141
+
142
+ **Local Tools (always available):**
143
+ - ✅ `dice_roll` - Roll dice with custom notation
144
+ - ✅ `math_evaluate` - Evaluate mathematical expressions
145
+ - ✅ `current_datetime` - Get current date and time
146
+ - ✅ `prompt_enhancement` - Improve prompts using LLM
147
+ - ✅ `file_read` - Read files from local filesystem
148
+ - ✅ `create_file` - Create or update files
149
+ - ✅ `glob_files` - Find files by pattern
150
+ - ✅ `grep_search` - Search file contents
151
+ - ✅ `delete_file` - Delete files
152
+
153
+ **B4M Server Tools (require authentication):**
154
+ - 🌐 `weather` - Get weather information worldwide (via OpenWeather)
155
+ - 🔍 `serper` - Search the web using Google (via Serper API)
156
+ - 🔬 `deep_research` - Perform in-depth research using web search
139
157
 
140
- Some built-in tools require API keys to function. Add them to `~/.bike4mind/config.json`:
141
-
142
- ```json
143
- {
144
- "toolApiKeys": {
145
- "openweather": "your-openweather-key",
146
- "serper": "your-serper-key"
147
- }
148
- }
149
- ```
150
-
151
- Or use environment variables (config takes precedence):
152
-
153
- ```bash
154
- export OPENWEATHER_API_KEY="your-key-here"
155
- export SERPER_API_KEY="your-key-here"
156
- ```
158
+ **Authentication:**
159
+ B4M server tools execute on the backend using company-managed API keys. Simply authenticate with `/login` to access them. No personal API keys needed!
157
160
 
158
- **Available Tools:**
159
- - ✅ `dice_roll` - No API key needed
160
- - ✅ `math_evaluate` - No API key needed
161
- - ✅ `current_datetime` - No API key needed
162
- - ✅ `prompt_enhancement` - No API key needed
163
- - 🔑 `weather_info` - Requires `toolApiKeys.openweather`
164
- - 🔑 `web_search` - Requires `toolApiKeys.serper`
165
- - 🔑 `deep_research` - Requires `toolApiKeys.serper`
161
+ ### MCP Servers
166
162
 
167
- **Get API Keys:**
168
- - OpenWeather API: https://openweathermap.org/api
169
- - Serper API: https://serper.dev/
163
+ MCP (Model Context Protocol) servers provide additional tools and capabilities.
170
164
 
171
- ### Optional: MCP Servers
165
+ **Built-in B4M Server:**
166
+ The CLI includes a built-in B4M MCP server (`b4m-tools`) that provides server-side tool execution. This server is automatically configured when you authenticate with `/login`.
172
167
 
173
- MCP (Model Context Protocol) servers provide additional tools and capabilities. Configure them in `~/.bike4mind/config.json`:
168
+ **Additional MCP Servers:**
169
+ You can add optional MCP servers in `~/.bike4mind/config.json`:
174
170
 
175
171
  ```json
176
172
  {
@@ -188,12 +184,12 @@ MCP (Model Context Protocol) servers provide additional tools and capabilities.
188
184
  }
189
185
  ```
190
186
 
191
- **Available MCP Servers:**
187
+ **Optional MCP Servers:**
192
188
  - 🔧 **GitHub** - Repository management, issues, PRs (requires `GITHUB_ACCESS_TOKEN`)
193
189
  - 🔧 **LinkedIn** - Post management, analytics (requires `LINKEDIN_ACCESS_TOKEN`, `COMPANY_NAME`)
194
190
  - 🔧 **Atlassian** - Jira/Confluence integration (requires `ATLASSIAN_ACCESS_TOKEN`, `ATLASSIAN_CLOUD_ID`, `ATLASSIAN_SITE_URL`)
195
191
 
196
- **Note:** MCP servers must be built and available in the `b4m-core/packages/mcp/dist/src/` directory. The CLI will automatically find them if you're running from the monorepo.
192
+ **Note:** The built-in `b4m-tools` MCP server is automatically bundled with the CLI and configured on authentication. Optional MCP servers can be added as needed for additional integrations.
197
193
 
198
194
  ## Session Storage
199
195
 
@@ -0,0 +1,79 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * B4M MCP Proxy Wrapper
4
+ *
5
+ * This wrapper script reads the CLI configuration to get the current JWT token
6
+ * and API URL, then launches the MCP proxy with those credentials.
7
+ *
8
+ * This allows the MCP proxy to authenticate with the B4M backend without
9
+ * requiring users to manually set environment variables.
10
+ *
11
+ * The wrapper reads from ~/.bike4mind/config.json to get:
12
+ * - auth.accessToken (JWT token)
13
+ * - apiConfig.customUrl (custom API URL, if set)
14
+ */
15
+
16
+ import { spawn } from 'child_process';
17
+ import { join, dirname } from 'path';
18
+ import { homedir } from 'os';
19
+ import { readFileSync } from 'fs';
20
+ import { fileURLToPath } from 'url';
21
+
22
+ const __dirname = dirname(fileURLToPath(import.meta.url));
23
+
24
+ // Read config to get current JWT token and API URL
25
+ const configPath = process.env.B4M_CONFIG_PATH || join(homedir(), '.bike4mind', 'config.json');
26
+
27
+ let authToken = '';
28
+ let apiUrl = 'https://api.bike4mind.com';
29
+
30
+ try {
31
+ const configData = readFileSync(configPath, 'utf-8');
32
+ const config = JSON.parse(configData);
33
+
34
+ // Get JWT access token
35
+ authToken = config.auth?.accessToken || '';
36
+
37
+ // Get custom API URL if configured
38
+ apiUrl = config.apiConfig?.customUrl || apiUrl;
39
+
40
+ if (!authToken) {
41
+ console.warn('⚠️ Warning: No authentication token found in config');
42
+ console.warn(' B4M server tools will not be available.');
43
+ console.warn(' Run /login in the CLI to authenticate.');
44
+ }
45
+ } catch (error) {
46
+ // Config doesn't exist or is invalid
47
+ // This is OK - user might not be authenticated yet
48
+ if (error.code !== 'ENOENT') {
49
+ console.error('Warning: Could not read B4M config:', error.message);
50
+ }
51
+ }
52
+
53
+ // Path to the bundled MCP proxy
54
+ const mcpProxyPath = join(__dirname, '../dist/mcp-proxy/index.js');
55
+
56
+ // Launch MCP proxy with dynamic environment variables
57
+ const child = spawn('node', [mcpProxyPath], {
58
+ stdio: 'inherit', // Inherit stdin/stdout/stderr for MCP protocol
59
+ env: {
60
+ ...process.env,
61
+ B4M_AUTH_TOKEN: authToken,
62
+ B4M_API_URL: apiUrl,
63
+ B4M_TIMEOUT: process.env.B4M_TIMEOUT || '30000',
64
+ },
65
+ });
66
+
67
+ // Handle process exit
68
+ child.on('exit', (code) => {
69
+ process.exit(code || 0);
70
+ });
71
+
72
+ // Handle signals
73
+ process.on('SIGINT', () => {
74
+ child.kill('SIGINT');
75
+ });
76
+
77
+ process.on('SIGTERM', () => {
78
+ child.kill('SIGTERM');
79
+ });
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  CurationArtifactType
4
- } from "./chunk-2RFX62SX.js";
4
+ } from "./chunk-WR6YZRQV.js";
5
5
  import "./chunk-PDX44BCA.js";
6
6
 
7
7
  // ../../b4m-core/packages/services/dist/src/notebookCurationService/artifactExtractor.js
@@ -7,11 +7,11 @@ import {
7
7
  getSettingsMap,
8
8
  getSettingsValue,
9
9
  secureParameters
10
- } from "./chunk-RM2KFSVU.js";
10
+ } from "./chunk-LYNNVNEC.js";
11
11
  import {
12
12
  KnowledgeType,
13
13
  SupportedFabFileMimeTypes
14
- } from "./chunk-2RFX62SX.js";
14
+ } from "./chunk-WR6YZRQV.js";
15
15
 
16
16
  // ../../b4m-core/packages/services/dist/src/fabFileService/create.js
17
17
  import { z } from "zod";
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  BadRequestError,
4
4
  secureParameters
5
- } from "./chunk-RM2KFSVU.js";
5
+ } from "./chunk-LYNNVNEC.js";
6
6
  import {
7
7
  GenericCreditDeductTransaction,
8
8
  ImageEditUsageTransaction,
@@ -10,7 +10,7 @@ import {
10
10
  RealtimeVoiceUsageTransaction,
11
11
  TextGenerationUsageTransaction,
12
12
  TransferCreditTransaction
13
- } from "./chunk-2RFX62SX.js";
13
+ } from "./chunk-WR6YZRQV.js";
14
14
 
15
15
  // ../../b4m-core/packages/services/dist/src/creditService/subtractCredits.js
16
16
  import { z } from "zod";
@@ -16,7 +16,7 @@ import {
16
16
  dayjsConfig_default,
17
17
  extractSnippetMeta,
18
18
  settingsMap
19
- } from "./chunk-2RFX62SX.js";
19
+ } from "./chunk-WR6YZRQV.js";
20
20
 
21
21
  // ../../b4m-core/packages/utils/dist/src/storage/S3Storage.js
22
22
  import { S3Client, PutObjectCommand, DeleteObjectCommand, GetObjectCommand, HeadObjectCommand } from "@aws-sdk/client-s3";
@@ -6,12 +6,12 @@ import {
6
6
  getSettingsByNames,
7
7
  obfuscateApiKey,
8
8
  secureParameters
9
- } from "./chunk-RM2KFSVU.js";
9
+ } from "./chunk-LYNNVNEC.js";
10
10
  import {
11
11
  ApiKeyType,
12
12
  MementoTier,
13
13
  isSupportedEmbeddingModel
14
- } from "./chunk-2RFX62SX.js";
14
+ } from "./chunk-WR6YZRQV.js";
15
15
 
16
16
  // ../../b4m-core/packages/services/dist/src/apiKeyService/get.js
17
17
  import { z } from "zod";
@@ -230,9 +230,7 @@ var b4mLLMTools = z3.enum([
230
230
  "create_file",
231
231
  "glob_files",
232
232
  "grep_search",
233
- "delete_file",
234
- // Knowledge base search
235
- "search_knowledge_base"
233
+ "delete_file"
236
234
  ]);
237
235
  var B4MLLMToolsList = b4mLLMTools.options.map((tool) => tool);
238
236
  var RechartsChartTypeSchema = z3.enum([
@@ -2,10 +2,10 @@
2
2
  import {
3
3
  createFabFile,
4
4
  createFabFileSchema
5
- } from "./chunk-QFDR3XXO.js";
6
- import "./chunk-RM2KFSVU.js";
5
+ } from "./chunk-6AJODFPC.js";
6
+ import "./chunk-LYNNVNEC.js";
7
7
  import "./chunk-AMDXHL6S.js";
8
- import "./chunk-2RFX62SX.js";
8
+ import "./chunk-WR6YZRQV.js";
9
9
  import "./chunk-PDX44BCA.js";
10
10
  export {
11
11
  createFabFile,