@bike4mind/cli 0.2.46-fix-empty-text-content-block.20674 → 0.2.47-docs-clawdbot-comparison-analysis.20779

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.
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  CurationArtifactType
4
- } from "./chunk-LE6YGEIO.js";
4
+ } from "./chunk-YIYLUPY4.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;
@@ -7,11 +7,11 @@ import {
7
7
  getSettingsMap,
8
8
  getSettingsValue,
9
9
  secureParameters
10
- } from "./chunk-4OFEAY5V.js";
10
+ } from "./chunk-XOS5NYUQ.js";
11
11
  import {
12
12
  KnowledgeType,
13
13
  SupportedFabFileMimeTypes
14
- } from "./chunk-LE6YGEIO.js";
14
+ } from "./chunk-YIYLUPY4.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-4OFEAY5V.js";
5
+ } from "./chunk-XOS5NYUQ.js";
6
6
  import {
7
7
  CompletionApiUsageTransaction,
8
8
  GenericCreditDeductTransaction,
@@ -13,7 +13,7 @@ import {
13
13
  ToolUsageTransaction,
14
14
  TransferCreditTransaction,
15
15
  VideoGenerationUsageTransaction
16
- } from "./chunk-LE6YGEIO.js";
16
+ } from "./chunk-YIYLUPY4.js";
17
17
 
18
18
  // ../../b4m-core/packages/services/dist/src/creditService/subtractCredits.js
19
19
  import { z } from "zod";
@@ -6,12 +6,12 @@ import {
6
6
  getSettingsByNames,
7
7
  obfuscateApiKey,
8
8
  secureParameters
9
- } from "./chunk-4OFEAY5V.js";
9
+ } from "./chunk-XOS5NYUQ.js";
10
10
  import {
11
11
  ApiKeyType,
12
12
  MementoTier,
13
13
  isSupportedEmbeddingModel
14
- } from "./chunk-LE6YGEIO.js";
14
+ } from "./chunk-YIYLUPY4.js";
15
15
 
16
16
  // ../../b4m-core/packages/services/dist/src/apiKeyService/get.js
17
17
  import { z } from "zod";
@@ -3,7 +3,7 @@
3
3
  // package.json
4
4
  var package_default = {
5
5
  name: "@bike4mind/cli",
6
- version: "0.2.46-fix-empty-text-content-block.20674+b27597f82",
6
+ version: "0.2.47-docs-clawdbot-comparison-analysis.20779+efa4609d7",
7
7
  type: "module",
8
8
  description: "Interactive CLI tool for Bike4Mind with ReAct agents",
9
9
  license: "UNLICENSED",
@@ -109,6 +109,7 @@ var package_default = {
109
109
  uuid: "^9.0.1",
110
110
  voyageai: "^0.0.4",
111
111
  "web-tree-sitter": "0.25.10",
112
+ ws: "^8.19.0",
112
113
  xlsx: "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz",
113
114
  yargs: "^17.7.2",
114
115
  yauzl: "^3.1.3",
@@ -118,10 +119,10 @@ var package_default = {
118
119
  },
119
120
  devDependencies: {
120
121
  "@bike4mind/agents": "0.1.0",
121
- "@bike4mind/common": "2.64.2-fix-empty-text-content-block.20674+b27597f82",
122
- "@bike4mind/mcp": "1.33.8-fix-empty-text-content-block.20674+b27597f82",
123
- "@bike4mind/services": "2.60.2-fix-empty-text-content-block.20674+b27597f82",
124
- "@bike4mind/utils": "2.15.1-fix-empty-text-content-block.20674+b27597f82",
122
+ "@bike4mind/common": "2.65.1-docs-clawdbot-comparison-analysis.20779+efa4609d7",
123
+ "@bike4mind/mcp": "1.33.9-docs-clawdbot-comparison-analysis.20779+efa4609d7",
124
+ "@bike4mind/services": "2.61.1-docs-clawdbot-comparison-analysis.20779+efa4609d7",
125
+ "@bike4mind/utils": "2.15.2-docs-clawdbot-comparison-analysis.20779+efa4609d7",
125
126
  "@types/better-sqlite3": "^7.6.13",
126
127
  "@types/diff": "^5.0.9",
127
128
  "@types/jsonwebtoken": "^9.0.4",
@@ -129,6 +130,7 @@ var package_default = {
129
130
  "@types/picomatch": "^4.0.2",
130
131
  "@types/react": "^19.2.7",
131
132
  "@types/uuid": "^9.0.7",
133
+ "@types/ws": "^8.18.1",
132
134
  "@types/yargs": "^17.0.32",
133
135
  "ink-testing-library": "^4.0.0",
134
136
  tsup: "^8.5.1",
@@ -139,7 +141,7 @@ var package_default = {
139
141
  optionalDependencies: {
140
142
  "@vscode/ripgrep": "^1.17.0"
141
143
  },
142
- gitHead: "b27597f8244b0b1cfc23e74d63d93d9b20b9dfa8"
144
+ gitHead: "efa4609d79d34107c0d673b48f69f5fc7b9804b4"
143
145
  };
144
146
 
145
147
  // src/utils/updateChecker.ts
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  ChatModels
4
- } from "./chunk-LE6YGEIO.js";
4
+ } from "./chunk-YIYLUPY4.js";
5
5
  import {
6
6
  DEFAULT_SANDBOX_CONFIG
7
7
  } from "./chunk-4BIBE3J7.js";
@@ -4,7 +4,7 @@ import {
4
4
  getOpenWeatherKey,
5
5
  getSerperKey,
6
6
  getWolframAlphaKey
7
- } from "./chunk-NSSADS6L.js";
7
+ } from "./chunk-DOG7VPYY.js";
8
8
  import {
9
9
  BFLImageService,
10
10
  BaseStorage,
@@ -16,14 +16,14 @@ import {
16
16
  OpenAIBackend,
17
17
  OpenAIImageService,
18
18
  XAIImageService
19
- } from "./chunk-4OFEAY5V.js";
19
+ } from "./chunk-XOS5NYUQ.js";
20
20
  import {
21
21
  Logger
22
22
  } from "./chunk-PFBYGCOW.js";
23
23
  import {
24
24
  ConfigStore,
25
25
  logger
26
- } from "./chunk-GBJZWQ4U.js";
26
+ } from "./chunk-IHZWVZA3.js";
27
27
  import {
28
28
  ALERT_THRESHOLDS,
29
29
  AiEvents,
@@ -84,7 +84,7 @@ import {
84
84
  getViewById,
85
85
  resolveNavigationIntents,
86
86
  sanitizeTelemetryError
87
- } from "./chunk-LE6YGEIO.js";
87
+ } from "./chunk-YIYLUPY4.js";
88
88
 
89
89
  // src/utils/fileSearch.ts
90
90
  import * as fs from "fs";
@@ -5304,9 +5304,9 @@ ${math.format(result, { precision: params.precision })}`;
5304
5304
  console.log("\u{1F522} Math Tool: Final formatted result:", formattedResult);
5305
5305
  return formattedResult;
5306
5306
  } catch (error) {
5307
- console.debug("\u274C Math Tool: Evaluation error:", error);
5308
5307
  const errorMessage = error instanceof Error ? error.message : "Unknown error";
5309
- throw new Error(`Failed to evaluate math expression: ${errorMessage}`);
5308
+ console.error(`\u274C Math Tool: Evaluation error for expression "${params.expression}":`, errorMessage);
5309
+ return `Error: Failed to evaluate math expression "${params.expression}". Reason: ${errorMessage}. Please provide a valid mathematical expression using numbers and operators only (no natural language).`;
5310
5310
  }
5311
5311
  }
5312
5312
  function solveQuadratic(equation, variable) {
@@ -16634,6 +16634,9 @@ var WebSocketLlmBackend = class {
16634
16634
  };
16635
16635
 
16636
16636
  // src/ws/WebSocketConnectionManager.ts
16637
+ import WsWebSocket from "ws";
16638
+ var useWsPolyfill = typeof globalThis.WebSocket === "undefined";
16639
+ var WS = useWsPolyfill ? WsWebSocket : globalThis.WebSocket;
16637
16640
  var WebSocketConnectionManager = class {
16638
16641
  constructor(wsUrl, getToken) {
16639
16642
  this.ws = null;
@@ -16641,6 +16644,7 @@ var WebSocketConnectionManager = class {
16641
16644
  this.reconnectAttempts = 0;
16642
16645
  this.maxReconnectDelay = 3e4;
16643
16646
  this.handlers = /* @__PURE__ */ new Map();
16647
+ this.actionHandlers = /* @__PURE__ */ new Map();
16644
16648
  this.disconnectHandlers = /* @__PURE__ */ new Set();
16645
16649
  this.reconnectTimer = null;
16646
16650
  this.connected = false;
@@ -16663,7 +16667,13 @@ var WebSocketConnectionManager = class {
16663
16667
  }
16664
16668
  return new Promise((resolve3, reject) => {
16665
16669
  logger.debug(`[WS] Connecting to ${this.wsUrl}...`);
16666
- this.ws = new WebSocket(this.wsUrl, [`access_token.${token}`]);
16670
+ if (useWsPolyfill) {
16671
+ this.ws = new WsWebSocket(this.wsUrl, {
16672
+ headers: { "Sec-WebSocket-Protocol": `access_token.${token}` }
16673
+ });
16674
+ } else {
16675
+ this.ws = new WS(this.wsUrl, [`access_token.${token}`]);
16676
+ }
16667
16677
  this.ws.onopen = () => {
16668
16678
  logger.debug("[WS] Connected");
16669
16679
  this.connected = true;
@@ -16680,7 +16690,12 @@ var WebSocketConnectionManager = class {
16680
16690
  if (requestId && this.handlers.has(requestId)) {
16681
16691
  this.handlers.get(requestId)(message);
16682
16692
  } else {
16683
- logger.debug(`[WS] Unhandled message: ${message.action || "unknown"}`);
16693
+ const action = message.action;
16694
+ if (action && this.actionHandlers.has(action)) {
16695
+ this.actionHandlers.get(action)(message);
16696
+ } else {
16697
+ logger.debug(`[WS] Unhandled message: ${action || "unknown"}`);
16698
+ }
16684
16699
  }
16685
16700
  } catch (err) {
16686
16701
  logger.debug(`[WS] Failed to parse message: ${err}`);
@@ -16695,11 +16710,13 @@ var WebSocketConnectionManager = class {
16695
16710
  }
16696
16711
  };
16697
16712
  this.ws.onerror = (err) => {
16698
- logger.debug(`[WS] Error: ${err}`);
16713
+ const underlying = err.error;
16714
+ const detail = underlying?.message || String(err);
16715
+ logger.debug(`[WS] Error: ${detail}`);
16699
16716
  if (this.connecting) {
16700
16717
  this.connecting = false;
16701
16718
  this.connected = false;
16702
- reject(new Error("WebSocket connection failed"));
16719
+ reject(new Error(`WebSocket connection failed: ${detail}`));
16703
16720
  }
16704
16721
  };
16705
16722
  });
@@ -16712,7 +16729,7 @@ var WebSocketConnectionManager = class {
16712
16729
  * Send a JSON message over the WebSocket connection.
16713
16730
  */
16714
16731
  send(data) {
16715
- if (!this.ws || this.ws.readyState !== WebSocket.OPEN) {
16732
+ if (!this.ws || this.ws.readyState !== WS.OPEN) {
16716
16733
  throw new Error("WebSocket is not connected");
16717
16734
  }
16718
16735
  const payload = JSON.stringify(data);
@@ -16735,6 +16752,19 @@ var WebSocketConnectionManager = class {
16735
16752
  offRequest(requestId) {
16736
16753
  this.handlers.delete(requestId);
16737
16754
  }
16755
+ /**
16756
+ * Register a handler for messages matching a specific action type.
16757
+ * Used for server-pushed commands like keep_command.
16758
+ */
16759
+ onAction(action, handler) {
16760
+ this.actionHandlers.set(action, handler);
16761
+ }
16762
+ /**
16763
+ * Remove a handler for a specific action type.
16764
+ */
16765
+ offAction(action) {
16766
+ this.actionHandlers.delete(action);
16767
+ }
16738
16768
  /**
16739
16769
  * Register a handler that fires when the connection drops.
16740
16770
  */
@@ -16758,13 +16788,14 @@ var WebSocketConnectionManager = class {
16758
16788
  this.ws = null;
16759
16789
  }
16760
16790
  this.handlers.clear();
16791
+ this.actionHandlers.clear();
16761
16792
  this.disconnectHandlers.clear();
16762
16793
  }
16763
16794
  startHeartbeat() {
16764
16795
  this.stopHeartbeat();
16765
16796
  this.heartbeatInterval = setInterval(
16766
16797
  () => {
16767
- if (this.ws && this.ws.readyState === WebSocket.OPEN) {
16798
+ if (this.ws && this.ws.readyState === WS.OPEN) {
16768
16799
  this.ws.send(JSON.stringify({ action: "heartbeat" }));
16769
16800
  logger.debug("[WS] Heartbeat sent");
16770
16801
  }
@@ -20,7 +20,7 @@ import {
20
20
  extractSnippetMeta,
21
21
  isGPTImageModel,
22
22
  settingsMap
23
- } from "./chunk-LE6YGEIO.js";
23
+ } from "./chunk-YIYLUPY4.js";
24
24
 
25
25
  // ../../b4m-core/packages/utils/dist/src/storage/S3Storage.js
26
26
  import { S3Client, PutObjectCommand, DeleteObjectCommand, GetObjectCommand, HeadObjectCommand } from "@aws-sdk/client-s3";
@@ -7516,19 +7516,34 @@ var OpenAIBackend = class {
7516
7516
  const parsedParams = JSON.parse(toolCall.function.arguments);
7517
7517
  const result = await toolFn(parsedParams);
7518
7518
  this.logger.debug(`[Tool Result] Tool executed for ${toolCall.function.name}:`, result.toString().substring(0, 200) + "...");
7519
+ let artifactWasStreamed = false;
7519
7520
  await handleToolResultStreaming(toolCall.function.name, result, async (results) => {
7521
+ artifactWasStreamed = true;
7520
7522
  await callback(results, {
7521
7523
  inputTokens: 0,
7522
7524
  outputTokens: 0,
7523
7525
  toolsUsed: toolsUsed.length > 0 ? toolsUsed : void 0
7524
7526
  });
7525
7527
  });
7528
+ const resultStr = result.toString();
7529
+ const sanitizedResult = artifactWasStreamed ? resultStr.replace(/<artifact(?:\s[^>]*)?>[\s\S]*?<\/artifact>/gi, "[Artifact rendered and delivered to user]") : resultStr;
7526
7530
  this.pushToolMessages(messages, {
7527
7531
  id: toolCall.id,
7528
7532
  name: toolCall.function.name,
7529
7533
  parameters: toolCall.function.arguments
7530
- }, result.toString());
7534
+ }, sanitizedResult);
7531
7535
  const isMcpTool = options.tools?.find((t) => t.toolSchema.name === toolCall.function.name)?._isMcpTool;
7536
+ let recursiveBuffer = "";
7537
+ let recursiveMeta = { inputTokens: 0, outputTokens: 0 };
7538
+ const recursiveCallback = artifactWasStreamed ? async (results, meta) => {
7539
+ for (const r of results) {
7540
+ if (r != null)
7541
+ recursiveBuffer += r;
7542
+ }
7543
+ if (meta.inputTokens || meta.outputTokens) {
7544
+ recursiveMeta = { ...meta };
7545
+ }
7546
+ } : callback;
7532
7547
  if (isMcpTool) {
7533
7548
  await this.complete(model, messages, {
7534
7549
  ...options,
@@ -7536,7 +7551,7 @@ var OpenAIBackend = class {
7536
7551
  ...options._internal,
7537
7552
  toolCallCount: toolCallCount + 1
7538
7553
  }
7539
- }, callback, toolsUsed);
7554
+ }, recursiveCallback, toolsUsed);
7540
7555
  } else {
7541
7556
  await this.complete(model, messages, {
7542
7557
  ...options,
@@ -7545,7 +7560,13 @@ var OpenAIBackend = class {
7545
7560
  ...options._internal,
7546
7561
  toolCallCount: toolCallCount + 1
7547
7562
  }
7548
- }, callback, toolsUsed);
7563
+ }, recursiveCallback, toolsUsed);
7564
+ }
7565
+ if (artifactWasStreamed && recursiveBuffer) {
7566
+ const cleaned = recursiveBuffer.replace(/<artifact(?:\s[^>]*)?>[\s\S]*?<\/artifact>/gi, "").trim();
7567
+ if (cleaned) {
7568
+ await callback([cleaned], recursiveMeta);
7569
+ }
7549
7570
  }
7550
7571
  return;
7551
7572
  } catch (error) {
@@ -7680,6 +7701,7 @@ var OpenAIBackend = class {
7680
7701
  }
7681
7702
  }
7682
7703
  if (options.executeTools !== false) {
7704
+ let anyArtifactWasStreamed = false;
7683
7705
  for await (const tool of func) {
7684
7706
  const { id, name } = tool;
7685
7707
  const parameters2 = tool.parameters || "{}";
@@ -7691,6 +7713,7 @@ var OpenAIBackend = class {
7691
7713
  const result = await toolFn(JSON.parse(parameters2));
7692
7714
  this.logger.debug(`[Tool Result] Tool executed for ${name}:`, result.toString().substring(0, 200) + "...");
7693
7715
  await handleToolResultStreaming(name, result, async (results) => {
7716
+ anyArtifactWasStreamed = true;
7694
7717
  await callback(results, {
7695
7718
  inputTokens,
7696
7719
  outputTokens,
@@ -7698,11 +7721,13 @@ var OpenAIBackend = class {
7698
7721
  cacheStats
7699
7722
  });
7700
7723
  });
7724
+ const resultStr = result.toString();
7725
+ const sanitizedResult = anyArtifactWasStreamed ? resultStr.replace(/<artifact(?:\s[^>]*)?>[\s\S]*?<\/artifact>/gi, "[Artifact rendered and delivered to user]") : resultStr;
7701
7726
  this.pushToolMessages(messages, {
7702
7727
  id,
7703
7728
  name,
7704
7729
  parameters: parameters2
7705
- }, result);
7730
+ }, sanitizedResult);
7706
7731
  } catch (error) {
7707
7732
  if (error instanceof PermissionDeniedError) {
7708
7733
  throw error;
@@ -7720,13 +7745,37 @@ var OpenAIBackend = class {
7720
7745
  }
7721
7746
  }
7722
7747
  }
7723
- await this.complete(model, messages, {
7724
- ...options,
7725
- _internal: {
7726
- ...options._internal,
7727
- toolCallCount: toolCallCount + 1
7748
+ if (anyArtifactWasStreamed) {
7749
+ let recursiveBuffer = "";
7750
+ let recursiveMeta = { inputTokens: 0, outputTokens: 0 };
7751
+ await this.complete(model, messages, {
7752
+ ...options,
7753
+ _internal: {
7754
+ ...options._internal,
7755
+ toolCallCount: toolCallCount + 1
7756
+ }
7757
+ }, async (results, meta) => {
7758
+ for (const r of results) {
7759
+ if (r != null)
7760
+ recursiveBuffer += r;
7761
+ }
7762
+ if (meta.inputTokens || meta.outputTokens) {
7763
+ recursiveMeta = { ...meta };
7764
+ }
7765
+ }, toolsUsed);
7766
+ const cleaned = recursiveBuffer.replace(/<artifact(?:\s[^>]*)?>[\s\S]*?<\/artifact>/gi, "").trim();
7767
+ if (cleaned) {
7768
+ await callback([cleaned], recursiveMeta);
7728
7769
  }
7729
- }, callback, toolsUsed);
7770
+ } else {
7771
+ await this.complete(model, messages, {
7772
+ ...options,
7773
+ _internal: {
7774
+ ...options._internal,
7775
+ toolCallCount: toolCallCount + 1
7776
+ }
7777
+ }, callback, toolsUsed);
7778
+ }
7730
7779
  } else {
7731
7780
  this.logger.debug(`[Tool Execution] executeTools=false, passing tool calls to callback`);
7732
7781
  await callback([null], {