@bike4mind/cli 0.2.10-slack-metrics-admin-dashboard.17271 → 0.2.11-fix-extendend-thinking-with-tool-use.17316

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-DJPXSSP4.js";
4
+ } from "./chunk-3OX632TE.js";
5
5
  import "./chunk-PDX44BCA.js";
6
6
 
7
7
  // ../../b4m-core/packages/services/dist/src/notebookCurationService/artifactExtractor.js
@@ -5901,6 +5901,9 @@ function buildSSEEvent(text, info) {
5901
5901
  outputTokens: info.outputTokens
5902
5902
  };
5903
5903
  }
5904
+ if (info?.thinking && info.thinking.length > 0) {
5905
+ event.thinking = info.thinking;
5906
+ }
5904
5907
  return event;
5905
5908
  }
5906
5909
  function formatSSEError(error) {
@@ -6,12 +6,12 @@ import {
6
6
  getSettingsByNames,
7
7
  obfuscateApiKey,
8
8
  secureParameters
9
- } from "./chunk-GCVIRGIN.js";
9
+ } from "./chunk-JYH72REB.js";
10
10
  import {
11
11
  ApiKeyType,
12
12
  MementoTier,
13
13
  isSupportedEmbeddingModel
14
- } from "./chunk-DJPXSSP4.js";
14
+ } from "./chunk-3OX632TE.js";
15
15
 
16
16
  // ../../b4m-core/packages/services/dist/src/apiKeyService/get.js
17
17
  import { z } from "zod";
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  BadRequestError,
4
4
  secureParameters
5
- } from "./chunk-GCVIRGIN.js";
5
+ } from "./chunk-JYH72REB.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-DJPXSSP4.js";
13
+ } from "./chunk-3OX632TE.js";
14
14
 
15
15
  // ../../b4m-core/packages/services/dist/src/creditService/subtractCredits.js
16
16
  import { z } from "zod";
@@ -7,11 +7,11 @@ import {
7
7
  getSettingsMap,
8
8
  getSettingsValue,
9
9
  secureParameters
10
- } from "./chunk-GCVIRGIN.js";
10
+ } from "./chunk-JYH72REB.js";
11
11
  import {
12
12
  KnowledgeType,
13
13
  SupportedFabFileMimeTypes
14
- } from "./chunk-DJPXSSP4.js";
14
+ } from "./chunk-3OX632TE.js";
15
15
 
16
16
  // ../../b4m-core/packages/services/dist/src/fabFileService/create.js
17
17
  import { z } from "zod";
@@ -16,7 +16,7 @@ import {
16
16
  dayjsConfig_default,
17
17
  extractSnippetMeta,
18
18
  settingsMap
19
- } from "./chunk-DJPXSSP4.js";
19
+ } from "./chunk-3OX632TE.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";
@@ -249,6 +249,17 @@ var AnthropicBackend = class {
249
249
  this._api = new Anthropic({ apiKey });
250
250
  this.logger = logger ?? new Logger();
251
251
  }
252
+ /**
253
+ * Get thinking blocks from the last assistant content.
254
+ * Filters to only include thinking/redacted_thinking blocks.
255
+ * Returns undefined if thinking is disabled or no blocks are present.
256
+ */
257
+ getThinkingBlocks() {
258
+ if (!this.isThinkingEnabled)
259
+ return void 0;
260
+ const blocks = this.lastAssistantContent.filter((block) => block?.type === "thinking" || block?.type === "redacted_thinking");
261
+ return blocks.length > 0 ? blocks : void 0;
262
+ }
252
263
  async getModelInfo() {
253
264
  return [
254
265
  {
@@ -701,8 +712,12 @@ var AnthropicBackend = class {
701
712
  this.logger.debug(`[Tool Execution] Last few messages:`, JSON.stringify(messages.slice(-3), null, 2));
702
713
  await this.complete(model, messages, options, cb, toolsUsed);
703
714
  } else {
704
- this.logger.debug(`[Tool Execution] executeTools=false, passing tool calls to callback`);
705
- await cb([null], { toolsUsed });
715
+ const thinkingBlocks = this.getThinkingBlocks();
716
+ this.logger.debug(`[Tool Execution] executeTools=false, passing tool calls to callback with ${thinkingBlocks?.length || 0} thinking blocks`);
717
+ await cb([null], {
718
+ toolsUsed,
719
+ thinking: thinkingBlocks
720
+ });
706
721
  }
707
722
  return;
708
723
  }
@@ -774,8 +789,12 @@ var AnthropicBackend = class {
774
789
  await this.complete(model, messages, { ...options, tools: void 0, _internal: void 0 }, cb, toolsUsed);
775
790
  }
776
791
  } else {
777
- this.logger.debug(`[Tool Execution] executeTools=false, passing tool calls to callback`);
778
- await cb([null], { toolsUsed });
792
+ const thinkingBlocks = this.getThinkingBlocks();
793
+ this.logger.debug(`[Tool Execution] executeTools=false, passing tool calls to callback with ${thinkingBlocks?.length || 0} thinking blocks`);
794
+ await cb([null], {
795
+ toolsUsed,
796
+ thinking: thinkingBlocks
797
+ });
779
798
  }
780
799
  return;
781
800
  }
@@ -2,10 +2,10 @@
2
2
  import {
3
3
  createFabFile,
4
4
  createFabFileSchema
5
- } from "./chunk-AQBZVAYO.js";
6
- import "./chunk-GCVIRGIN.js";
5
+ } from "./chunk-HPYQM2B7.js";
6
+ import "./chunk-JYH72REB.js";
7
7
  import "./chunk-AMDXHL6S.js";
8
- import "./chunk-DJPXSSP4.js";
8
+ import "./chunk-3OX632TE.js";
9
9
  import "./chunk-PDX44BCA.js";
10
10
  export {
11
11
  createFabFile,
package/dist/index.js CHANGED
@@ -4,9 +4,9 @@ import {
4
4
  getEffectiveApiKey,
5
5
  getOpenWeatherKey,
6
6
  getSerperKey
7
- } from "./chunk-GO75FMLY.js";
8
- import "./chunk-VZU4Z7WI.js";
9
- import "./chunk-AQBZVAYO.js";
7
+ } from "./chunk-7JR6VASX.js";
8
+ import "./chunk-7ORA6KGN.js";
9
+ import "./chunk-HPYQM2B7.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-GCVIRGIN.js";
18
+ } from "./chunk-JYH72REB.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-DJPXSSP4.js";
76
+ } from "./chunk-3OX632TE.js";
77
77
  import {
78
78
  __require
79
79
  } from "./chunk-PDX44BCA.js";
@@ -82,7 +82,7 @@ import {
82
82
  import React17, { useState as useState8, useEffect as useEffect3, useCallback, useRef as useRef2 } from "react";
83
83
  import { render, Box as Box16, Text as Text16, useApp, useInput as useInput6 } from "ink";
84
84
  import { execSync } from "child_process";
85
- import { v4 as uuidv49 } from "uuid";
85
+ import { v4 as uuidv410 } from "uuid";
86
86
 
87
87
  // src/components/App.tsx
88
88
  import React11, { useState as useState4 } from "react";
@@ -1523,7 +1523,7 @@ ${errorBlock}`;
1523
1523
  onSave: onSaveConfig,
1524
1524
  onClose: () => setShowConfigEditor(false)
1525
1525
  }
1526
- )) : permissionPrompt ? /* @__PURE__ */ React11.createElement(Box10, { flexDirection: "column", paddingX: 1 }, /* @__PURE__ */ React11.createElement(
1526
+ )) : /* @__PURE__ */ React11.createElement(React11.Fragment, null, /* @__PURE__ */ React11.createElement(Static, { items: messages }, (message) => /* @__PURE__ */ React11.createElement(Box10, { key: message.id, flexDirection: "column", paddingX: 1 }, /* @__PURE__ */ React11.createElement(MessageItem, { message }))), /* @__PURE__ */ React11.createElement(Box10, { flexDirection: "column" }, pendingMessages.map((message) => /* @__PURE__ */ React11.createElement(Box10, { key: message.id, flexDirection: "column", paddingX: 1 }, /* @__PURE__ */ React11.createElement(MessageItem, { message })))), permissionPrompt && /* @__PURE__ */ React11.createElement(Box10, { flexDirection: "column", paddingX: 1 }, /* @__PURE__ */ React11.createElement(
1527
1527
  PermissionPrompt,
1528
1528
  {
1529
1529
  toolName: permissionPrompt.toolName,
@@ -1532,7 +1532,7 @@ ${errorBlock}`;
1532
1532
  canBeTrusted: permissionPrompt.canBeTrusted,
1533
1533
  onResponse: onPermissionResponse
1534
1534
  }
1535
- )) : /* @__PURE__ */ React11.createElement(React11.Fragment, null, /* @__PURE__ */ React11.createElement(Static, { items: messages }, (message, index) => /* @__PURE__ */ React11.createElement(Box10, { key: `${message.timestamp}-${message.role}-${index}`, flexDirection: "column", paddingX: 1 }, /* @__PURE__ */ React11.createElement(MessageItem, { message }))), /* @__PURE__ */ React11.createElement(Box10, { flexDirection: "column" }, pendingMessages.map((message, index) => /* @__PURE__ */ React11.createElement(Box10, { key: `pending-${message.timestamp}-${index}`, flexDirection: "column", paddingX: 1 }, /* @__PURE__ */ React11.createElement(MessageItem, { message })))), /* @__PURE__ */ React11.createElement(AgentThinking, null), exitRequested && /* @__PURE__ */ React11.createElement(Box10, { paddingX: 1, marginBottom: 1 }, /* @__PURE__ */ React11.createElement(Text10, { color: "yellow", bold: true }, "Press Ctrl+C again to exit")), /* @__PURE__ */ React11.createElement(Box10, { borderStyle: "single", borderColor: isBashMode ? "yellow" : "cyan", paddingX: 1 }, /* @__PURE__ */ React11.createElement(
1535
+ )), !permissionPrompt && /* @__PURE__ */ React11.createElement(AgentThinking, null), exitRequested && /* @__PURE__ */ React11.createElement(Box10, { paddingX: 1, marginBottom: 1 }, /* @__PURE__ */ React11.createElement(Text10, { color: "yellow", bold: true }, "Press Ctrl+C again to exit")), /* @__PURE__ */ React11.createElement(Box10, { borderStyle: "single", borderColor: isBashMode ? "yellow" : "cyan", paddingX: 1 }, /* @__PURE__ */ React11.createElement(
1536
1536
  InputPrompt,
1537
1537
  {
1538
1538
  onSubmit: handleSubmit,
@@ -1932,6 +1932,7 @@ function LoginFlow({ apiUrl = "http://localhost:3000", configStore, onSuccess, o
1932
1932
  import { promises as fs3 } from "fs";
1933
1933
  import path3 from "path";
1934
1934
  import { homedir } from "os";
1935
+ import { v4 as uuidv4 } from "uuid";
1935
1936
  var SessionStore = class {
1936
1937
  constructor(basePath) {
1937
1938
  this.basePath = basePath || path3.join(homedir(), ".bike4mind", "sessions");
@@ -1967,7 +1968,14 @@ var SessionStore = class {
1967
1968
  const filePath = path3.join(this.basePath, `${id}.json`);
1968
1969
  try {
1969
1970
  const data = await fs3.readFile(filePath, "utf-8");
1970
- return JSON.parse(data);
1971
+ const session = JSON.parse(data);
1972
+ session.messages = session.messages.map((msg) => {
1973
+ if (!msg.id) {
1974
+ return { ...msg, id: uuidv4() };
1975
+ }
1976
+ return msg;
1977
+ });
1978
+ return session;
1971
1979
  } catch (error) {
1972
1980
  if (error.code === "ENOENT") {
1973
1981
  return null;
@@ -1996,7 +2004,14 @@ var SessionStore = class {
1996
2004
  jsonFiles.map(async (file) => {
1997
2005
  const filePath = path3.join(this.basePath, file);
1998
2006
  const data = await fs3.readFile(filePath, "utf-8");
1999
- return JSON.parse(data);
2007
+ const session = JSON.parse(data);
2008
+ session.messages = session.messages.map((msg) => {
2009
+ if (!msg.id) {
2010
+ return { ...msg, id: uuidv4() };
2011
+ }
2012
+ return msg;
2013
+ });
2014
+ return session;
2000
2015
  })
2001
2016
  );
2002
2017
  return sessions.sort((a, b) => new Date(b.updatedAt).getTime() - new Date(a.updatedAt).getTime());
@@ -2050,7 +2065,7 @@ var SessionStore = class {
2050
2065
  import { promises as fs4, existsSync as existsSync3 } from "fs";
2051
2066
  import path4 from "path";
2052
2067
  import { homedir as homedir2 } from "os";
2053
- import { v4 as uuidv4 } from "uuid";
2068
+ import { v4 as uuidv42 } from "uuid";
2054
2069
  import { z } from "zod";
2055
2070
  var AuthTokensSchema = z.object({
2056
2071
  accessToken: z.string(),
@@ -2144,7 +2159,7 @@ var ProjectLocalConfigSchema = z.object({
2144
2159
  });
2145
2160
  var DEFAULT_CONFIG = {
2146
2161
  version: "0.1.0",
2147
- userId: uuidv4(),
2162
+ userId: uuidv42(),
2148
2163
  defaultModel: "claude-sonnet-4-5-20250929",
2149
2164
  toolApiKeys: {
2150
2165
  openweather: void 0,
@@ -2426,7 +2441,7 @@ var ConfigStore = class {
2426
2441
  * Reset configuration to defaults
2427
2442
  */
2428
2443
  async reset() {
2429
- this.config = { ...DEFAULT_CONFIG, userId: uuidv4() };
2444
+ this.config = { ...DEFAULT_CONFIG, userId: uuidv42() };
2430
2445
  await this.save();
2431
2446
  return this.config;
2432
2447
  }
@@ -3129,6 +3144,7 @@ ${options.context}` : this.getSystemPrompt()
3129
3144
  }
3130
3145
  if (completionInfo.toolsUsed && completionInfo.toolsUsed.length > 0) {
3131
3146
  hadToolCalls = true;
3147
+ const thinkingBlocks = completionInfo.thinking || [];
3132
3148
  for (const toolUse of completionInfo.toolsUsed) {
3133
3149
  const toolCallId = `${toolUse.name}_${JSON.stringify(toolUse.arguments)}`;
3134
3150
  if (processedToolIds.has(toolCallId)) {
@@ -3161,16 +3177,23 @@ ${options.context}` : this.getSystemPrompt()
3161
3177
  const params = typeof toolUse.arguments === "string" ? JSON.parse(toolUse.arguments) : toolUse.arguments;
3162
3178
  observation = await tool.toolFn(params);
3163
3179
  const toolCallId2 = `${toolUse.name}_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
3180
+ const assistantContent = [
3181
+ // Include thinking blocks first (required by Anthropic when thinking is enabled)
3182
+ ...thinkingBlocks,
3183
+ // Then the tool use
3184
+ {
3185
+ type: "tool_use",
3186
+ id: toolCallId2,
3187
+ name: toolUse.name,
3188
+ input: params
3189
+ }
3190
+ ];
3191
+ this.context.logger.debug(
3192
+ `[assistantContent] ${assistantContent.length} blocks (${thinkingBlocks.length} thinking, 1 tool_use)`
3193
+ );
3164
3194
  messages.push({
3165
3195
  role: "assistant",
3166
- content: [
3167
- {
3168
- type: "tool_use",
3169
- id: toolCallId2,
3170
- name: toolUse.name,
3171
- input: params
3172
- }
3173
- ]
3196
+ content: assistantContent
3174
3197
  });
3175
3198
  messages.push({
3176
3199
  role: "user",
@@ -4336,7 +4359,7 @@ var listFabFilesSchema = z86.object({
4336
4359
 
4337
4360
  // ../../b4m-core/packages/services/dist/src/fabFileService/update.js
4338
4361
  import mime from "mime-types";
4339
- import { v4 as uuidv42 } from "uuid";
4362
+ import { v4 as uuidv43 } from "uuid";
4340
4363
  import { z as z87 } from "zod";
4341
4364
  var updateFabFileSchema = z87.object({
4342
4365
  id: z87.string(),
@@ -4457,7 +4480,7 @@ var editFabFileSchema = z98.object({
4457
4480
 
4458
4481
  // ../../b4m-core/packages/services/dist/src/fabFileService/applyEdit.js
4459
4482
  import mime2 from "mime-types";
4460
- import { v4 as uuidv43 } from "uuid";
4483
+ import { v4 as uuidv44 } from "uuid";
4461
4484
  import { z as z99 } from "zod";
4462
4485
  var applyEditSchema = z99.object({
4463
4486
  id: z99.string(),
@@ -5285,7 +5308,7 @@ import { toFile } from "openai/uploads";
5285
5308
  import { Readable } from "stream";
5286
5309
  import { TranscribeClient, StartTranscriptionJobCommand, GetTranscriptionJobCommand, LanguageCode, MediaFormat } from "@aws-sdk/client-transcribe";
5287
5310
  import { S3Client, PutObjectCommand, GetObjectCommand, DeleteObjectCommand } from "@aws-sdk/client-s3";
5288
- import { v4 as uuidv44 } from "uuid";
5311
+ import { v4 as uuidv45 } from "uuid";
5289
5312
 
5290
5313
  // ../../b4m-core/packages/services/dist/src/emailIngestionService/processIngestedEmail.js
5291
5314
  import { randomUUID as randomUUID5 } from "crypto";
@@ -5446,7 +5469,7 @@ var weatherTool = {
5446
5469
  // ../../b4m-core/packages/services/dist/src/llm/tools/implementation/imageGeneration/index.js
5447
5470
  import axios6 from "axios";
5448
5471
  import { fileTypeFromBuffer as fileTypeFromBuffer2 } from "file-type";
5449
- import { v4 as uuidv45 } from "uuid";
5472
+ import { v4 as uuidv46 } from "uuid";
5450
5473
  async function downloadImage(url) {
5451
5474
  if (url.startsWith("data:image/")) {
5452
5475
  const base64Data = url.split(",")[1];
@@ -5460,7 +5483,7 @@ async function processAndStoreImages(images, context) {
5460
5483
  return Promise.all(images.map(async (image) => {
5461
5484
  const buffer = await downloadImage(image);
5462
5485
  const fileType = await fileTypeFromBuffer2(buffer);
5463
- const filename = `${uuidv45()}.${fileType?.ext}`;
5486
+ const filename = `${uuidv46()}.${fileType?.ext}`;
5464
5487
  const path16 = await context.imageGenerateStorage.upload(buffer, filename, {});
5465
5488
  return path16;
5466
5489
  }));
@@ -6629,7 +6652,7 @@ Return only the edited content without any markdown code blocks or explanations.
6629
6652
  // ../../b4m-core/packages/services/dist/src/llm/tools/implementation/imageEdit/index.js
6630
6653
  import axios7 from "axios";
6631
6654
  import { fileTypeFromBuffer as fileTypeFromBuffer3 } from "file-type";
6632
- import { v4 as uuidv46 } from "uuid";
6655
+ import { v4 as uuidv47 } from "uuid";
6633
6656
  async function downloadImage2(url) {
6634
6657
  if (url.startsWith("data:image/")) {
6635
6658
  const base64Data = url.split(",")[1];
@@ -6673,7 +6696,7 @@ async function getImageFromFileId(fileId, context) {
6673
6696
  async function processAndStoreImage(imageUrl, context) {
6674
6697
  const buffer = await downloadImage2(imageUrl);
6675
6698
  const fileType = await fileTypeFromBuffer3(buffer);
6676
- const filename = `${uuidv46()}.${fileType?.ext}`;
6699
+ const filename = `${uuidv47()}.${fileType?.ext}`;
6677
6700
  const path16 = await context.imageGenerateStorage.upload(buffer, filename, {});
6678
6701
  return path16;
6679
6702
  }
@@ -8579,7 +8602,8 @@ var fileReadTool = {
8579
8602
  return content;
8580
8603
  } catch (error) {
8581
8604
  context.logger.error("\u274C FileRead: Failed", error);
8582
- throw error;
8605
+ const errorMessage = error instanceof Error ? error.message : String(error);
8606
+ return `Error reading file: ${errorMessage}`;
8583
8607
  }
8584
8608
  },
8585
8609
  toolSchema: {
@@ -9649,7 +9673,7 @@ var QuestStartBodySchema = z139.object({
9649
9673
  // ../../b4m-core/packages/services/dist/src/llm/ImageGeneration.js
9650
9674
  import axios8 from "axios";
9651
9675
  import { fileTypeFromBuffer as fileTypeFromBuffer4 } from "file-type";
9652
- import { v4 as uuidv47 } from "uuid";
9676
+ import { v4 as uuidv48 } from "uuid";
9653
9677
  import { z as z140 } from "zod";
9654
9678
  import { fromZodError as fromZodError2 } from "zod-validation-error";
9655
9679
  var ImageGenerationBodySchema = OpenAIImageGenerationInput.extend({
@@ -9670,7 +9694,7 @@ var ImageGenerationBodySchema = OpenAIImageGenerationInput.extend({
9670
9694
  // ../../b4m-core/packages/services/dist/src/llm/ImageEdit.js
9671
9695
  import axios9 from "axios";
9672
9696
  import { fileTypeFromBuffer as fileTypeFromBuffer5 } from "file-type";
9673
- import { v4 as uuidv48 } from "uuid";
9697
+ import { v4 as uuidv49 } from "uuid";
9674
9698
  import { z as z141 } from "zod";
9675
9699
  import { fromZodError as fromZodError3 } from "zod-validation-error";
9676
9700
  var ImageEditBodySchema = OpenAIImageGenerationInput.extend({
@@ -10224,7 +10248,31 @@ function wrapToolWithPermission(tool, permissionManager, showPermissionPrompt, a
10224
10248
  }
10225
10249
  };
10226
10250
  }
10227
- function generateCliTools(userId, llm, model, permissionManager, showPermissionPrompt, agentContext, configStore, apiClient) {
10251
+ var TOOL_NAME_MAPPING = {
10252
+ // Claude Code -> B4M
10253
+ read: "file_read",
10254
+ write: "create_file",
10255
+ edit: "edit_file",
10256
+ delete: "delete_file",
10257
+ glob: "glob_files",
10258
+ grep: "grep_search",
10259
+ bash: "bash_execute",
10260
+ // B4M -> Claude Code (reverse mapping)
10261
+ file_read: "read",
10262
+ create_file: "write",
10263
+ edit_file: "edit",
10264
+ delete_file: "delete",
10265
+ glob_files: "glob",
10266
+ grep_search: "grep",
10267
+ bash_execute: "bash"
10268
+ };
10269
+ function normalizeToolName(toolName) {
10270
+ if (toolName.includes("_")) {
10271
+ return toolName;
10272
+ }
10273
+ return TOOL_NAME_MAPPING[toolName] || toolName;
10274
+ }
10275
+ function generateCliTools(userId, llm, model, permissionManager, showPermissionPrompt, agentContext, configStore, apiClient, toolFilter) {
10228
10276
  const logger2 = new CliLogger();
10229
10277
  const storage = new NoOpStorage();
10230
10278
  const user = {
@@ -10294,9 +10342,24 @@ function generateCliTools(userId, llm, model, permissionManager, showPermissionP
10294
10342
  toolConfig,
10295
10343
  model
10296
10344
  );
10297
- const tools2 = Object.entries(toolsMap).filter(([key]) => toolConfig[key] !== void 0).map(
10345
+ let tools2 = Object.entries(toolsMap).filter(([key]) => toolConfig[key] !== void 0).map(
10298
10346
  ([_, tool]) => wrapToolWithPermission(tool, permissionManager, showPermissionPrompt, agentContext, configStore, apiClient)
10299
10347
  );
10348
+ if (toolFilter) {
10349
+ const { allowedTools, deniedTools } = toolFilter;
10350
+ const normalizedAllowed = allowedTools?.map(normalizeToolName);
10351
+ const normalizedDenied = deniedTools?.map(normalizeToolName);
10352
+ tools2 = tools2.filter((tool) => {
10353
+ const toolName = tool.toolSchema.name;
10354
+ if (normalizedDenied && normalizedDenied.includes(toolName)) {
10355
+ return false;
10356
+ }
10357
+ if (normalizedAllowed && normalizedAllowed.length > 0) {
10358
+ return normalizedAllowed.includes(toolName);
10359
+ }
10360
+ return true;
10361
+ });
10362
+ }
10300
10363
  return { tools: tools2, agentContext };
10301
10364
  }
10302
10365
 
@@ -11079,6 +11142,7 @@ var ServerLlmBackend = class {
11079
11142
  let accumulatedText = "";
11080
11143
  let lastUsageInfo = {};
11081
11144
  let toolsUsed = [];
11145
+ let thinkingBlocks = [];
11082
11146
  let receivedDone = false;
11083
11147
  const parser = createParser({
11084
11148
  onEvent: (event) => {
@@ -11092,9 +11156,12 @@ var ServerLlmBackend = class {
11092
11156
  if (toolsUsed.length > 0) {
11093
11157
  const info = {
11094
11158
  toolsUsed,
11159
+ thinking: thinkingBlocks.length > 0 ? thinkingBlocks : void 0,
11095
11160
  ...lastUsageInfo
11096
11161
  };
11097
- logger.debug("[ServerLlmBackend] Calling callback with tools, will wait for completion");
11162
+ logger.debug(
11163
+ `[ServerLlmBackend] Calling callback with tools, thinking blocks: ${thinkingBlocks.length}`
11164
+ );
11098
11165
  callback([cleanedText], info).catch((err) => {
11099
11166
  logger.error("[ServerLlmBackend] Callback error:", err);
11100
11167
  reject(err);
@@ -11150,6 +11217,10 @@ var ServerLlmBackend = class {
11150
11217
  if (parsed.tools && parsed.tools.length > 0) {
11151
11218
  toolsUsed = parsed.tools;
11152
11219
  }
11220
+ if (parsed.thinking && parsed.thinking.length > 0) {
11221
+ thinkingBlocks = parsed.thinking;
11222
+ logger.debug(`[ServerLlmBackend] Received ${thinkingBlocks.length} thinking blocks`);
11223
+ }
11153
11224
  if (parsed.usage) {
11154
11225
  lastUsageInfo = {
11155
11226
  inputTokens: parsed.usage.inputTokens,
@@ -11472,7 +11543,7 @@ import { isAxiosError as isAxiosError2 } from "axios";
11472
11543
  // package.json
11473
11544
  var package_default = {
11474
11545
  name: "@bike4mind/cli",
11475
- version: "0.2.10-slack-metrics-admin-dashboard.17271+2a5835a72",
11546
+ version: "0.2.11-fix-extendend-thinking-with-tool-use.17316+abc8cdb0e",
11476
11547
  type: "module",
11477
11548
  description: "Interactive CLI tool for Bike4Mind with ReAct agents",
11478
11549
  license: "UNLICENSED",
@@ -11576,10 +11647,10 @@ var package_default = {
11576
11647
  },
11577
11648
  devDependencies: {
11578
11649
  "@bike4mind/agents": "0.1.0",
11579
- "@bike4mind/common": "2.39.1-slack-metrics-admin-dashboard.17271+2a5835a72",
11580
- "@bike4mind/mcp": "1.20.4-slack-metrics-admin-dashboard.17271+2a5835a72",
11581
- "@bike4mind/services": "2.34.2-slack-metrics-admin-dashboard.17271+2a5835a72",
11582
- "@bike4mind/utils": "2.1.4-slack-metrics-admin-dashboard.17271+2a5835a72",
11650
+ "@bike4mind/common": "2.40.1-fix-extendend-thinking-with-tool-use.17316+abc8cdb0e",
11651
+ "@bike4mind/mcp": "1.20.5-fix-extendend-thinking-with-tool-use.17316+abc8cdb0e",
11652
+ "@bike4mind/services": "2.35.1-fix-extendend-thinking-with-tool-use.17316+abc8cdb0e",
11653
+ "@bike4mind/utils": "2.1.5-fix-extendend-thinking-with-tool-use.17316+abc8cdb0e",
11583
11654
  "@types/better-sqlite3": "^7.6.13",
11584
11655
  "@types/diff": "^5.0.9",
11585
11656
  "@types/jsonwebtoken": "^9.0.4",
@@ -11592,7 +11663,7 @@ var package_default = {
11592
11663
  typescript: "^5.9.3",
11593
11664
  vitest: "^3.2.4"
11594
11665
  },
11595
- gitHead: "2a5835a72cd38a7e839d4180a2deca9bcd2e2008"
11666
+ gitHead: "abc8cdb0e7f31a4b7bc948b332e6d130be260378"
11596
11667
  };
11597
11668
 
11598
11669
  // src/config/constants.ts
@@ -11600,6 +11671,353 @@ var USAGE_DAYS = 30;
11600
11671
  var MODEL_NAME_COLUMN_WIDTH = 18;
11601
11672
  var USAGE_CACHE_TTL = 5 * 60 * 1e3;
11602
11673
 
11674
+ // src/agents/SubagentOrchestrator.ts
11675
+ var SubagentOrchestrator = class {
11676
+ constructor(deps) {
11677
+ this.beforeRunCallback = null;
11678
+ this.afterRunCallback = null;
11679
+ this.deps = deps;
11680
+ }
11681
+ /**
11682
+ * Set a callback to be invoked before each subagent.run()
11683
+ * Use this to subscribe to agent events (e.g., subagent.on('action', handler))
11684
+ */
11685
+ setBeforeRunCallback(callback) {
11686
+ this.beforeRunCallback = callback;
11687
+ }
11688
+ /**
11689
+ * Set a callback to be invoked after each subagent.run()
11690
+ * Use this to unsubscribe from agent events (e.g., subagent.off('action', handler))
11691
+ */
11692
+ setAfterRunCallback(callback) {
11693
+ this.afterRunCallback = callback;
11694
+ }
11695
+ /**
11696
+ * Delegate a task to a specialized subagent
11697
+ *
11698
+ * @param options - Configuration for subagent execution
11699
+ * @returns Subagent result with summary
11700
+ */
11701
+ async delegateToSubagent(options) {
11702
+ const { task, type, thoroughness, parentSessionId, config: configOverride } = options;
11703
+ const baseConfig = this.deps.subagentConfigs.get(type);
11704
+ if (!baseConfig) {
11705
+ throw new Error(`No configuration found for subagent type: ${type}`);
11706
+ }
11707
+ const config = {
11708
+ ...baseConfig,
11709
+ ...configOverride,
11710
+ type
11711
+ };
11712
+ const model = config.model || "claude-3-5-haiku-20241022";
11713
+ const maxIterations = this.getMaxIterations(config, thoroughness);
11714
+ const toolFilter = {
11715
+ allowedTools: config.allowedTools,
11716
+ deniedTools: config.deniedTools
11717
+ };
11718
+ const agentContext = {
11719
+ currentAgent: null,
11720
+ observationQueue: []
11721
+ };
11722
+ const { tools: tools2, agentContext: updatedContext } = generateCliTools(
11723
+ this.deps.userId,
11724
+ this.deps.llm,
11725
+ model,
11726
+ this.deps.permissionManager,
11727
+ this.deps.showPermissionPrompt,
11728
+ agentContext,
11729
+ this.deps.configStore,
11730
+ this.deps.apiClient,
11731
+ toolFilter
11732
+ );
11733
+ this.deps.logger.debug(`Spawning ${type} subagent with ${tools2.length} tools, thoroughness: ${thoroughness}`);
11734
+ const subagent = new ReActAgent({
11735
+ userId: this.deps.userId,
11736
+ logger: this.deps.logger,
11737
+ llm: this.deps.llm,
11738
+ model,
11739
+ tools: tools2,
11740
+ maxIterations,
11741
+ systemPrompt: config.systemPrompt || this.getDefaultSystemPrompt(type)
11742
+ });
11743
+ updatedContext.currentAgent = subagent;
11744
+ if (this.beforeRunCallback) {
11745
+ this.beforeRunCallback(subagent, type);
11746
+ }
11747
+ const startTime = Date.now();
11748
+ const result = await subagent.run(task, {
11749
+ maxIterations
11750
+ });
11751
+ const duration = Date.now() - startTime;
11752
+ if (this.afterRunCallback) {
11753
+ this.afterRunCallback(subagent, type);
11754
+ }
11755
+ this.deps.logger.debug(
11756
+ `Subagent completed in ${duration}ms, ${result.completionInfo.iterations} iterations, ${result.completionInfo.totalTokens} tokens`
11757
+ );
11758
+ const summary = this.summarizeResult(result, type);
11759
+ const subagentResult = {
11760
+ ...result,
11761
+ subagentType: type,
11762
+ thoroughness,
11763
+ summary,
11764
+ parentSessionId
11765
+ };
11766
+ return subagentResult;
11767
+ }
11768
+ /**
11769
+ * Get max iterations based on thoroughness and config
11770
+ */
11771
+ getMaxIterations(config, thoroughness) {
11772
+ const defaults = {
11773
+ quick: 2,
11774
+ medium: 5,
11775
+ very_thorough: 10
11776
+ };
11777
+ const configIterations = config.maxIterations || defaults;
11778
+ return configIterations[thoroughness];
11779
+ }
11780
+ /**
11781
+ * Get default system prompt for subagent type
11782
+ */
11783
+ getDefaultSystemPrompt(type) {
11784
+ switch (type) {
11785
+ case "explore":
11786
+ return `You are a code exploration specialist. Your job is to search and analyze codebases efficiently.
11787
+
11788
+ Focus on:
11789
+ - Finding relevant files and functions
11790
+ - Understanding code structure and patterns
11791
+ - Providing clear, concise summaries
11792
+
11793
+ You have read-only access. Use file_read, grep_search, and glob_files to explore.
11794
+
11795
+ When you find what you're looking for, provide a clear summary including:
11796
+ 1. What you found (files, functions, patterns)
11797
+ 2. Key insights or observations
11798
+ 3. Relevant code locations
11799
+
11800
+ Be thorough but concise. Your summary will be used by the main agent.`;
11801
+ case "plan":
11802
+ return `You are a task planning specialist. Your job is to break down complex tasks into clear, actionable steps.
11803
+
11804
+ Focus on:
11805
+ - Identifying dependencies and blockers
11806
+ - Creating logical sequence of steps
11807
+ - Estimating scope and priorities
11808
+
11809
+ Provide a structured plan that the main agent can execute.`;
11810
+ case "review":
11811
+ return `You are a code review specialist. Your job is to analyze code quality and identify issues.
11812
+
11813
+ Focus on:
11814
+ - Code quality and best practices
11815
+ - Potential bugs and edge cases
11816
+ - Performance and security considerations
11817
+
11818
+ Provide actionable feedback with specific file and line references.`;
11819
+ default:
11820
+ return "You are a helpful AI assistant.";
11821
+ }
11822
+ }
11823
+ /**
11824
+ * Summarize subagent result for parent agent
11825
+ */
11826
+ summarizeResult(result, type) {
11827
+ const { finalAnswer, steps, completionInfo } = result;
11828
+ const toolCalls = steps.filter((s) => s.type === "action");
11829
+ const filesRead = toolCalls.filter((s) => s.metadata?.toolName === "file_read").length;
11830
+ const searches = toolCalls.filter((s) => s.metadata?.toolName === "grep_search").length;
11831
+ const globs = toolCalls.filter((s) => s.metadata?.toolName === "glob_files").length;
11832
+ let summary = `**${type.charAt(0).toUpperCase() + type.slice(1)} Subagent Results**
11833
+
11834
+ `;
11835
+ summary += `*Execution: ${completionInfo.iterations} iterations, ${completionInfo.toolCalls} tool calls*
11836
+
11837
+ `;
11838
+ if (type === "explore") {
11839
+ summary += `*Exploration: ${filesRead} files read, ${searches} searches, ${globs} glob patterns*
11840
+
11841
+ `;
11842
+ }
11843
+ const maxLength = 1e3;
11844
+ if (finalAnswer.length > maxLength) {
11845
+ summary += finalAnswer.slice(0, maxLength) + "\n\n...(truncated)";
11846
+ } else {
11847
+ summary += finalAnswer;
11848
+ }
11849
+ return summary;
11850
+ }
11851
+ };
11852
+
11853
+ // src/agents/configs.ts
11854
+ var EXPLORE_CONFIG = {
11855
+ type: "explore",
11856
+ model: "claude-3-5-haiku-20241022",
11857
+ systemPrompt: `You are a code exploration specialist. Your job is to search and analyze codebases efficiently.
11858
+
11859
+ Focus on:
11860
+ - Finding relevant files and functions
11861
+ - Understanding code structure and patterns
11862
+ - Providing clear, concise summaries
11863
+
11864
+ You have read-only access. Use file_read, grep_search, and glob_files to explore.
11865
+
11866
+ When you find what you're looking for, provide a clear summary including:
11867
+ 1. What you found (files, functions, patterns)
11868
+ 2. Key insights or observations
11869
+ 3. Relevant code locations
11870
+
11871
+ Be thorough but concise. Your summary will be used by the main agent.`,
11872
+ allowedTools: [
11873
+ "file_read",
11874
+ "grep_search",
11875
+ "glob_files",
11876
+ "bash_execute",
11877
+ // Only for read-only commands like ls, cat, find
11878
+ "current_datetime",
11879
+ "math_evaluate"
11880
+ ],
11881
+ deniedTools: [
11882
+ "create_file",
11883
+ "edit_file",
11884
+ "delete_file",
11885
+ "web_search",
11886
+ "weather_info",
11887
+ "blog_publish",
11888
+ "blog_edit",
11889
+ "blog_draft"
11890
+ ],
11891
+ maxIterations: {
11892
+ quick: 2,
11893
+ medium: 5,
11894
+ very_thorough: 10
11895
+ },
11896
+ defaultThoroughness: "medium"
11897
+ };
11898
+ var PLAN_CONFIG = {
11899
+ type: "plan",
11900
+ model: "claude-3-5-haiku-20241022",
11901
+ systemPrompt: `You are a task planning specialist. Your job is to break down complex tasks into clear, actionable steps.
11902
+
11903
+ Focus on:
11904
+ - Identifying dependencies and blockers
11905
+ - Creating logical sequence of steps
11906
+ - Estimating scope and priorities
11907
+
11908
+ You can explore the codebase to understand the current architecture before planning.
11909
+
11910
+ Provide a structured plan that the main agent can execute.`,
11911
+ allowedTools: ["file_read", "grep_search", "glob_files", "bash_execute", "current_datetime", "math_evaluate"],
11912
+ deniedTools: ["create_file", "edit_file", "delete_file", "web_search", "weather_info"],
11913
+ maxIterations: {
11914
+ quick: 3,
11915
+ medium: 7,
11916
+ very_thorough: 12
11917
+ },
11918
+ defaultThoroughness: "medium"
11919
+ };
11920
+ var REVIEW_CONFIG = {
11921
+ type: "review",
11922
+ model: "claude-sonnet-4-5-20250929",
11923
+ // Use latest Sonnet for better reasoning
11924
+ systemPrompt: `You are a code review specialist. Your job is to analyze code quality and identify issues.
11925
+
11926
+ Focus on:
11927
+ - Code quality and best practices
11928
+ - Potential bugs and edge cases
11929
+ - Performance and security considerations
11930
+
11931
+ You have read-only access to analyze code.
11932
+
11933
+ Provide actionable feedback with specific file and line references.`,
11934
+ allowedTools: ["file_read", "grep_search", "glob_files", "bash_execute", "current_datetime"],
11935
+ deniedTools: ["create_file", "edit_file", "delete_file", "web_search", "weather_info"],
11936
+ maxIterations: {
11937
+ quick: 3,
11938
+ medium: 8,
11939
+ very_thorough: 15
11940
+ },
11941
+ defaultThoroughness: "medium"
11942
+ };
11943
+ function getDefaultSubagentConfigs() {
11944
+ return /* @__PURE__ */ new Map([
11945
+ ["explore", EXPLORE_CONFIG],
11946
+ ["plan", PLAN_CONFIG],
11947
+ ["review", REVIEW_CONFIG]
11948
+ ]);
11949
+ }
11950
+
11951
+ // src/agents/delegateTool.ts
11952
+ function createSubagentDelegateTool(orchestrator, parentSessionId) {
11953
+ return {
11954
+ toolFn: async (args) => {
11955
+ const params = args;
11956
+ if (!params.task) {
11957
+ throw new Error("subagent_delegate: task parameter is required");
11958
+ }
11959
+ if (!params.type) {
11960
+ throw new Error("subagent_delegate: type parameter is required");
11961
+ }
11962
+ const thoroughness = params.thoroughness || "medium";
11963
+ const type = params.type;
11964
+ const result = await orchestrator.delegateToSubagent({
11965
+ task: params.task,
11966
+ type,
11967
+ thoroughness,
11968
+ parentSessionId
11969
+ });
11970
+ return result.summary;
11971
+ },
11972
+ toolSchema: {
11973
+ name: "subagent_delegate",
11974
+ description: `Delegate a task to a specialized subagent for focused work.
11975
+
11976
+ **When to use this tool:**
11977
+ - **Explore**: When you need to search through the codebase, find files, or understand code structure (read-only)
11978
+ - **Plan**: When you need to break down a complex task into actionable steps
11979
+ - **Review**: When you need to analyze code quality and identify potential issues
11980
+
11981
+ **Benefits:**
11982
+ - Keeps main conversation focused and clean
11983
+ - Uses specialized prompts optimized for each task type
11984
+ - Faster execution with appropriate models (Haiku for explore/plan, Sonnet for review)
11985
+
11986
+ **Example uses:**
11987
+ - "Find all files that use the authentication system" \u2192 explore
11988
+ - "Search for components that handle user input" \u2192 explore
11989
+ - "Break down implementing a new feature into steps" \u2192 plan
11990
+ - "Review this module for potential bugs" \u2192 review`,
11991
+ parameters: {
11992
+ type: "object",
11993
+ properties: {
11994
+ task: {
11995
+ type: "string",
11996
+ description: "Clear description of what you want the subagent to do. Be specific about what you're looking for or what needs to be accomplished."
11997
+ },
11998
+ type: {
11999
+ type: "string",
12000
+ enum: ["explore", "plan", "review"],
12001
+ description: `Type of subagent to use:
12002
+ - explore: Read-only codebase exploration and search (fast, uses Haiku)
12003
+ - plan: Task breakdown and planning (uses Haiku)
12004
+ - review: Code quality analysis and review (uses Sonnet for better reasoning)`
12005
+ },
12006
+ thoroughness: {
12007
+ type: "string",
12008
+ enum: ["quick", "medium", "very_thorough"],
12009
+ description: `How thoroughly to execute:
12010
+ - quick: Fast lookup, 1-2 iterations
12011
+ - medium: Balanced exploration, 3-5 iterations (default)
12012
+ - very_thorough: Comprehensive analysis, 8-10 iterations`
12013
+ }
12014
+ },
12015
+ required: ["task", "type"]
12016
+ }
12017
+ }
12018
+ };
12019
+ }
12020
+
11603
12021
  // src/index.tsx
11604
12022
  process.removeAllListeners("warning");
11605
12023
  process.on("warning", (warning) => {
@@ -11630,7 +12048,8 @@ function CliApp() {
11630
12048
  permissionPrompt: null,
11631
12049
  trustLocationSelector: null,
11632
12050
  rewindSelector: null,
11633
- sessionSelector: null
12051
+ sessionSelector: null,
12052
+ orchestrator: null
11634
12053
  });
11635
12054
  const [isInitialized, setIsInitialized] = useState8(false);
11636
12055
  const [initError, setInitError] = useState8(null);
@@ -11730,7 +12149,7 @@ function CliApp() {
11730
12149
  if (!isAuthenticated) {
11731
12150
  console.log("\u2139\uFE0F AI features disabled. Available commands: /login, /help, /config\n");
11732
12151
  const minimalSession = {
11733
- id: uuidv49(),
12152
+ id: uuidv410(),
11734
12153
  name: `Session ${(/* @__PURE__ */ new Date()).toLocaleString()}`,
11735
12154
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
11736
12155
  updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
@@ -11774,7 +12193,7 @@ function CliApp() {
11774
12193
  }
11775
12194
  llm.currentModel = modelInfo.id;
11776
12195
  const newSession = {
11777
- id: uuidv49(),
12196
+ id: uuidv410(),
11778
12197
  name: `Session ${(/* @__PURE__ */ new Date()).toLocaleString()}`,
11779
12198
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
11780
12199
  updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
@@ -11847,7 +12266,34 @@ function CliApp() {
11847
12266
  console.log(` \u{1F4E1} ${serverName}: ${count} tool(s)`);
11848
12267
  });
11849
12268
  }
11850
- const allTools = [...b4mTools, ...mcpTools];
12269
+ const subagentConfigs = getDefaultSubagentConfigs();
12270
+ if (config.subagents) {
12271
+ if (config.subagents.explore) {
12272
+ const currentConfig = subagentConfigs.get("explore");
12273
+ subagentConfigs.set("explore", { ...currentConfig, ...config.subagents.explore });
12274
+ }
12275
+ if (config.subagents.plan) {
12276
+ const currentConfig = subagentConfigs.get("plan");
12277
+ subagentConfigs.set("plan", { ...currentConfig, ...config.subagents.plan });
12278
+ }
12279
+ if (config.subagents.review) {
12280
+ const currentConfig = subagentConfigs.get("review");
12281
+ subagentConfigs.set("review", { ...currentConfig, ...config.subagents.review });
12282
+ }
12283
+ }
12284
+ const orchestrator = new SubagentOrchestrator({
12285
+ userId: config.userId,
12286
+ llm,
12287
+ logger: silentLogger,
12288
+ permissionManager,
12289
+ showPermissionPrompt: promptFn,
12290
+ configStore: state.configStore,
12291
+ apiClient,
12292
+ subagentConfigs
12293
+ });
12294
+ const subagentDelegateTool = createSubagentDelegateTool(orchestrator, newSession.id);
12295
+ const allTools = [...b4mTools, ...mcpTools, subagentDelegateTool];
12296
+ console.log(`\u{1F916} Subagent delegation enabled (explore, plan, review)`);
11851
12297
  const projectDir = state.configStore.getProjectConfigDir();
11852
12298
  const contextResult = await loadContextFiles(projectDir);
11853
12299
  if (contextResult.globalContext) {
@@ -11884,6 +12330,15 @@ FOR CODING TASKS:
11884
12330
  - When searching for code: Use grep_search or glob_files to find relevant files
11885
12331
  - Permission system will ask for approval before any file writes
11886
12332
 
12333
+ SUBAGENT DELEGATION:
12334
+ - You have access to specialized subagents via the subagent_delegate tool
12335
+ - Use subagents for focused exploration, planning, or review tasks:
12336
+ * explore: Fast read-only codebase search (e.g., "find all auth files", "locate API endpoints")
12337
+ * plan: Break down complex tasks into actionable steps
12338
+ * review: Analyze code quality and identify issues
12339
+ - Subagents keep the main conversation clean and run faster with optimized models
12340
+ - Delegate when you need to search extensively or analyze code structure
12341
+
11887
12342
  FOR GENERAL TASKS:
11888
12343
  - Use available tools to get information (weather, web search, calculations, etc.)
11889
12344
  - When user asks follow-up questions, use conversation context to understand what they're referring to
@@ -11894,6 +12349,7 @@ EXAMPLES:
11894
12349
  - "how about Japan?" \u2192 use weather tool for Japan (applying same question from context)
11895
12350
  - "enhance README" \u2192 file_read \u2192 generate \u2192 create_file
11896
12351
  - "what packages installed?" \u2192 glob_files "**/package.json" \u2192 file_read
12352
+ - "find all components using React hooks" \u2192 subagent_delegate(task="find all components using React hooks", type="explore")
11897
12353
 
11898
12354
  Remember: Use context from previous messages to understand follow-up questions.${contextSection}`;
11899
12355
  const maxIterations = config.preferences.maxIterations === null ? 999999 : config.preferences.maxIterations;
@@ -11910,6 +12366,27 @@ Remember: Use context from previous messages to understand follow-up questions.$
11910
12366
  });
11911
12367
  agentContext.currentAgent = agent;
11912
12368
  agent.observationQueue = agentContext.observationQueue;
12369
+ const stepHandler = (step) => {
12370
+ const { pendingMessages, updatePendingMessage } = useCliStore.getState();
12371
+ const lastIdx = pendingMessages.length - 1;
12372
+ if (lastIdx >= 0 && pendingMessages[lastIdx].role === "assistant") {
12373
+ const existingSteps = pendingMessages[lastIdx].metadata?.steps || [];
12374
+ updatePendingMessage(lastIdx, {
12375
+ ...pendingMessages[lastIdx],
12376
+ metadata: {
12377
+ ...pendingMessages[lastIdx].metadata,
12378
+ steps: [...existingSteps, step]
12379
+ }
12380
+ });
12381
+ }
12382
+ };
12383
+ agent.on("action", stepHandler);
12384
+ orchestrator.setBeforeRunCallback((subagent, _subagentType) => {
12385
+ subagent.on("action", stepHandler);
12386
+ });
12387
+ orchestrator.setAfterRunCallback((subagent, _subagentType) => {
12388
+ subagent.off("action", stepHandler);
12389
+ });
11913
12390
  setState((prev) => ({
11914
12391
  ...prev,
11915
12392
  session: newSession,
@@ -11918,8 +12395,10 @@ Remember: Use context from previous messages to understand follow-up questions.$
11918
12395
  permissionManager,
11919
12396
  config,
11920
12397
  // Store config for synchronous access
11921
- availableModels: models
12398
+ availableModels: models,
11922
12399
  // Store models for ConfigEditor
12400
+ orchestrator
12401
+ // Store orchestrator for step handler updates
11923
12402
  }));
11924
12403
  setStoreSession(newSession);
11925
12404
  setIsInitialized(true);
@@ -11983,11 +12462,13 @@ Remember: Use context from previous messages to understand follow-up questions.$
11983
12462
  messageContent = multimodalMessage.content;
11984
12463
  }
11985
12464
  const userMessage = {
12465
+ id: uuidv410(),
11986
12466
  role: "user",
11987
12467
  content: userMessageContent,
11988
12468
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
11989
12469
  };
11990
12470
  const pendingAssistantMessage = {
12471
+ id: uuidv410(),
11991
12472
  role: "assistant",
11992
12473
  content: "...",
11993
12474
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
@@ -12018,7 +12499,10 @@ Remember: Use context from previous messages to understand follow-up questions.$
12018
12499
  const currentSession = useCliStore.getState().session;
12019
12500
  if (!currentSession) return;
12020
12501
  const updatedMessages = [...currentSession.messages];
12502
+ const lastMessage = updatedMessages[updatedMessages.length - 1];
12021
12503
  updatedMessages[updatedMessages.length - 1] = {
12504
+ id: lastMessage.id,
12505
+ // Preserve the original message ID
12022
12506
  role: "assistant",
12023
12507
  content: result.finalAnswer,
12024
12508
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
@@ -12108,22 +12592,6 @@ Remember: Use context from previous messages to understand follow-up questions.$
12108
12592
  return;
12109
12593
  }
12110
12594
  useCliStore.getState().setIsThinking(true);
12111
- const currentSteps = [];
12112
- const stepHandler = (step) => {
12113
- currentSteps.push(step);
12114
- const { pendingMessages, updatePendingMessage } = useCliStore.getState();
12115
- const lastIdx = pendingMessages.length - 1;
12116
- if (lastIdx >= 0 && pendingMessages[lastIdx].role === "assistant") {
12117
- updatePendingMessage(lastIdx, {
12118
- ...pendingMessages[lastIdx],
12119
- metadata: {
12120
- ...pendingMessages[lastIdx].metadata,
12121
- steps: [...currentSteps]
12122
- }
12123
- });
12124
- }
12125
- };
12126
- state.agent.on("action", stepHandler);
12127
12595
  try {
12128
12596
  let messageContent = message;
12129
12597
  let userMessageContent = message;
@@ -12133,11 +12601,13 @@ Remember: Use context from previous messages to understand follow-up questions.$
12133
12601
  userMessageContent = message;
12134
12602
  }
12135
12603
  const userMessage = {
12604
+ id: uuidv410(),
12136
12605
  role: "user",
12137
12606
  content: userMessageContent,
12138
12607
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
12139
12608
  };
12140
12609
  const pendingAssistantMessage = {
12610
+ id: uuidv410(),
12141
12611
  role: "assistant",
12142
12612
  content: "...",
12143
12613
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
@@ -12167,6 +12637,8 @@ Remember: Use context from previous messages to understand follow-up questions.$
12167
12637
  }
12168
12638
  const successfulToolCalls = result.steps.filter((s) => s.type === "observation").length;
12169
12639
  const finalAssistantMessage = {
12640
+ id: pendingAssistantMessage.id,
12641
+ // Preserve the original message ID
12170
12642
  role: "assistant",
12171
12643
  content: result.finalAnswer,
12172
12644
  timestamp: pendingAssistantMessage.timestamp,
@@ -12205,8 +12677,6 @@ Remember: Use context from previous messages to understand follow-up questions.$
12205
12677
  }
12206
12678
  }
12207
12679
  console.error("Error processing message:", error);
12208
- } finally {
12209
- state.agent.off("action", stepHandler);
12210
12680
  }
12211
12681
  };
12212
12682
  const handleBashCommand = useCallback(
@@ -12228,11 +12698,13 @@ Remember: Use context from previous messages to understand follow-up questions.$
12228
12698
  isError = true;
12229
12699
  }
12230
12700
  const userMessage = {
12701
+ id: uuidv410(),
12231
12702
  role: "user",
12232
12703
  content: `$ ${command}`,
12233
12704
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
12234
12705
  };
12235
12706
  const assistantMessage = {
12707
+ id: uuidv410(),
12236
12708
  role: "assistant",
12237
12709
  content: isError ? `\u274C Error:
12238
12710
  ${output}` : output.trim() || "(no output)",
@@ -12643,7 +13115,7 @@ Custom Commands:
12643
13115
  console.clear();
12644
13116
  const model = state.session?.model || state.config?.defaultModel || "claude-sonnet";
12645
13117
  const newSession = {
12646
- id: uuidv49(),
13118
+ id: uuidv410(),
12647
13119
  name: `Session ${(/* @__PURE__ */ new Date()).toLocaleString()}`,
12648
13120
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
12649
13121
  updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  CurationArtifactType
4
- } from "./chunk-DJPXSSP4.js";
4
+ } from "./chunk-3OX632TE.js";
5
5
  import "./chunk-PDX44BCA.js";
6
6
 
7
7
  // ../../b4m-core/packages/services/dist/src/notebookCurationService/llmMarkdownGenerator.js
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  CurationArtifactType
4
- } from "./chunk-DJPXSSP4.js";
4
+ } from "./chunk-3OX632TE.js";
5
5
  import "./chunk-PDX44BCA.js";
6
6
 
7
7
  // ../../b4m-core/packages/services/dist/src/notebookCurationService/markdownGenerator.js
@@ -2,10 +2,10 @@
2
2
  import {
3
3
  findMostSimilarMemento,
4
4
  getRelevantMementos
5
- } from "./chunk-GO75FMLY.js";
6
- import "./chunk-GCVIRGIN.js";
5
+ } from "./chunk-7JR6VASX.js";
6
+ import "./chunk-JYH72REB.js";
7
7
  import "./chunk-AMDXHL6S.js";
8
- import "./chunk-DJPXSSP4.js";
8
+ import "./chunk-3OX632TE.js";
9
9
  import "./chunk-PDX44BCA.js";
10
10
  export {
11
11
  findMostSimilarMemento,
@@ -293,7 +293,7 @@ import {
293
293
  validateQuestMasterArtifactV2,
294
294
  validateReactArtifactV2,
295
295
  validateSvgArtifactV2
296
- } from "./chunk-DJPXSSP4.js";
296
+ } from "./chunk-3OX632TE.js";
297
297
  import "./chunk-PDX44BCA.js";
298
298
  export {
299
299
  ALL_IMAGE_MODELS,
@@ -120,7 +120,7 @@ import {
120
120
  validateMermaidSyntax,
121
121
  warmUpSettingsCache,
122
122
  withRetry
123
- } from "./chunk-GCVIRGIN.js";
123
+ } from "./chunk-JYH72REB.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-DJPXSSP4.js";
132
+ import "./chunk-3OX632TE.js";
133
133
  import "./chunk-PDX44BCA.js";
134
134
  export {
135
135
  AWSBackend,
@@ -2,10 +2,10 @@
2
2
  import {
3
3
  SubtractCreditsSchema,
4
4
  subtractCredits
5
- } from "./chunk-VZU4Z7WI.js";
6
- import "./chunk-GCVIRGIN.js";
5
+ } from "./chunk-7ORA6KGN.js";
6
+ import "./chunk-JYH72REB.js";
7
7
  import "./chunk-AMDXHL6S.js";
8
- import "./chunk-DJPXSSP4.js";
8
+ import "./chunk-3OX632TE.js";
9
9
  import "./chunk-PDX44BCA.js";
10
10
  export {
11
11
  SubtractCreditsSchema,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bike4mind/cli",
3
- "version": "0.2.10-slack-metrics-admin-dashboard.17271+2a5835a72",
3
+ "version": "0.2.11-fix-extendend-thinking-with-tool-use.17316+abc8cdb0e",
4
4
  "type": "module",
5
5
  "description": "Interactive CLI tool for Bike4Mind with ReAct agents",
6
6
  "license": "UNLICENSED",
@@ -104,10 +104,10 @@
104
104
  },
105
105
  "devDependencies": {
106
106
  "@bike4mind/agents": "0.1.0",
107
- "@bike4mind/common": "2.39.1-slack-metrics-admin-dashboard.17271+2a5835a72",
108
- "@bike4mind/mcp": "1.20.4-slack-metrics-admin-dashboard.17271+2a5835a72",
109
- "@bike4mind/services": "2.34.2-slack-metrics-admin-dashboard.17271+2a5835a72",
110
- "@bike4mind/utils": "2.1.4-slack-metrics-admin-dashboard.17271+2a5835a72",
107
+ "@bike4mind/common": "2.40.1-fix-extendend-thinking-with-tool-use.17316+abc8cdb0e",
108
+ "@bike4mind/mcp": "1.20.5-fix-extendend-thinking-with-tool-use.17316+abc8cdb0e",
109
+ "@bike4mind/services": "2.35.1-fix-extendend-thinking-with-tool-use.17316+abc8cdb0e",
110
+ "@bike4mind/utils": "2.1.5-fix-extendend-thinking-with-tool-use.17316+abc8cdb0e",
111
111
  "@types/better-sqlite3": "^7.6.13",
112
112
  "@types/diff": "^5.0.9",
113
113
  "@types/jsonwebtoken": "^9.0.4",
@@ -120,5 +120,5 @@
120
120
  "typescript": "^5.9.3",
121
121
  "vitest": "^3.2.4"
122
122
  },
123
- "gitHead": "2a5835a72cd38a7e839d4180a2deca9bcd2e2008"
123
+ "gitHead": "abc8cdb0e7f31a4b7bc948b332e6d130be260378"
124
124
  }