@bike4mind/cli 0.2.11-fix-number-option-recorded.17312 → 0.2.11-fix-cli-edit-file.17320
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{artifactExtractor-JAGU7QRL.js → artifactExtractor-BZNU5FMW.js} +1 -1
- package/dist/{chunk-GO75FMLY.js → chunk-DGAIF2QC.js} +2 -2
- package/dist/{chunk-AQBZVAYO.js → chunk-RA3CZOUX.js} +2 -2
- package/dist/{chunk-VZU4Z7WI.js → chunk-RBZRTCAY.js} +2 -2
- package/dist/{chunk-GCVIRGIN.js → chunk-SQBLLN7K.js} +24 -5
- package/dist/{chunk-DJPXSSP4.js → chunk-WCYNJOOX.js} +4 -0
- package/dist/{create-ZDOTF7XD.js → create-4KCG4N2U.js} +3 -3
- package/dist/index.js +228 -84
- package/dist/{llmMarkdownGenerator-LXUGJ7QH.js → llmMarkdownGenerator-TUFLBYA3.js} +1 -1
- package/dist/{markdownGenerator-IMDG6OX6.js → markdownGenerator-2WSEU4QD.js} +1 -1
- package/dist/{mementoService-TURUS3OH.js → mementoService-75KFGFQT.js} +3 -3
- package/dist/{src-6ZRXGE5J.js → src-JZRDAJFC.js} +2 -2
- package/dist/{src-YNY32ELR.js → src-UHKJ3EHY.js} +1 -1
- package/dist/{subtractCredits-GOVKM3IR.js → subtractCredits-MOVABDWW.js} +3 -3
- package/package.json +6 -6
|
@@ -6,12 +6,12 @@ import {
|
|
|
6
6
|
getSettingsByNames,
|
|
7
7
|
obfuscateApiKey,
|
|
8
8
|
secureParameters
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-SQBLLN7K.js";
|
|
10
10
|
import {
|
|
11
11
|
ApiKeyType,
|
|
12
12
|
MementoTier,
|
|
13
13
|
isSupportedEmbeddingModel
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-WCYNJOOX.js";
|
|
15
15
|
|
|
16
16
|
// ../../b4m-core/packages/services/dist/src/apiKeyService/get.js
|
|
17
17
|
import { z } from "zod";
|
|
@@ -7,11 +7,11 @@ import {
|
|
|
7
7
|
getSettingsMap,
|
|
8
8
|
getSettingsValue,
|
|
9
9
|
secureParameters
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-SQBLLN7K.js";
|
|
11
11
|
import {
|
|
12
12
|
KnowledgeType,
|
|
13
13
|
SupportedFabFileMimeTypes
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-WCYNJOOX.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-
|
|
5
|
+
} from "./chunk-SQBLLN7K.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-
|
|
13
|
+
} from "./chunk-WCYNJOOX.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-
|
|
19
|
+
} from "./chunk-WCYNJOOX.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
|
-
|
|
705
|
-
|
|
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
|
-
|
|
778
|
-
|
|
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
|
}
|
|
@@ -228,6 +228,7 @@ var b4mLLMTools = z3.enum([
|
|
|
228
228
|
// File operation tools
|
|
229
229
|
"file_read",
|
|
230
230
|
"create_file",
|
|
231
|
+
"edit_local_file",
|
|
231
232
|
"glob_files",
|
|
232
233
|
"grep_search",
|
|
233
234
|
"delete_file",
|
|
@@ -5901,6 +5902,9 @@ function buildSSEEvent(text, info) {
|
|
|
5901
5902
|
outputTokens: info.outputTokens
|
|
5902
5903
|
};
|
|
5903
5904
|
}
|
|
5905
|
+
if (info?.thinking && info.thinking.length > 0) {
|
|
5906
|
+
event.thinking = info.thinking;
|
|
5907
|
+
}
|
|
5904
5908
|
return event;
|
|
5905
5909
|
}
|
|
5906
5910
|
function formatSSEError(error) {
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
import {
|
|
3
3
|
createFabFile,
|
|
4
4
|
createFabFileSchema
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-RA3CZOUX.js";
|
|
6
|
+
import "./chunk-SQBLLN7K.js";
|
|
7
7
|
import "./chunk-AMDXHL6S.js";
|
|
8
|
-
import "./chunk-
|
|
8
|
+
import "./chunk-WCYNJOOX.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-
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
7
|
+
} from "./chunk-DGAIF2QC.js";
|
|
8
|
+
import "./chunk-RBZRTCAY.js";
|
|
9
|
+
import "./chunk-RA3CZOUX.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-SQBLLN7K.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-WCYNJOOX.js";
|
|
77
77
|
import {
|
|
78
78
|
__require
|
|
79
79
|
} from "./chunk-PDX44BCA.js";
|
|
@@ -988,8 +988,8 @@ import { Box as Box6 } from "ink";
|
|
|
988
988
|
import React6 from "react";
|
|
989
989
|
import { Box as Box5, Text as Text6 } from "ink";
|
|
990
990
|
import Spinner from "ink-spinner";
|
|
991
|
-
var ThoughtStream = React6.memo(function ThoughtStream2({
|
|
992
|
-
return /* @__PURE__ */ React6.createElement(Box5, { flexDirection: "column", gap: 1 },
|
|
991
|
+
var ThoughtStream = React6.memo(function ThoughtStream2({ isThinking }) {
|
|
992
|
+
return /* @__PURE__ */ React6.createElement(Box5, { flexDirection: "column", gap: 1 }, isThinking && /* @__PURE__ */ React6.createElement(Box5, null, /* @__PURE__ */ React6.createElement(Text6, { color: "yellow" }, /* @__PURE__ */ React6.createElement(Spinner, { type: "dots" })), /* @__PURE__ */ React6.createElement(Text6, null, " Thinking...")));
|
|
993
993
|
});
|
|
994
994
|
|
|
995
995
|
// src/store/index.ts
|
|
@@ -1034,12 +1034,6 @@ var useCliStore = create((set) => ({
|
|
|
1034
1034
|
// UI state
|
|
1035
1035
|
isThinking: false,
|
|
1036
1036
|
setIsThinking: (thinking) => set({ isThinking: thinking }),
|
|
1037
|
-
agentSteps: [],
|
|
1038
|
-
addAgentStep: (step) => set((state) => ({
|
|
1039
|
-
agentSteps: [...state.agentSteps, step]
|
|
1040
|
-
})),
|
|
1041
|
-
setAgentSteps: (steps) => set({ agentSteps: steps }),
|
|
1042
|
-
clearAgentSteps: () => set({ agentSteps: [] }),
|
|
1043
1037
|
// Permission prompt
|
|
1044
1038
|
permissionPrompt: null,
|
|
1045
1039
|
setPermissionPrompt: (prompt) => set({ permissionPrompt: prompt }),
|
|
@@ -1054,11 +1048,10 @@ var useCliStore = create((set) => ({
|
|
|
1054
1048
|
// src/components/AgentThinking.tsx
|
|
1055
1049
|
var AgentThinking = React7.memo(function AgentThinking2() {
|
|
1056
1050
|
const isThinking = useCliStore((state) => state.isThinking);
|
|
1057
|
-
const agentSteps = useCliStore((state) => state.agentSteps);
|
|
1058
1051
|
if (!isThinking) {
|
|
1059
1052
|
return null;
|
|
1060
1053
|
}
|
|
1061
|
-
return /* @__PURE__ */ React7.createElement(Box6, { paddingX: 1, marginBottom: 1 }, /* @__PURE__ */ React7.createElement(ThoughtStream, {
|
|
1054
|
+
return /* @__PURE__ */ React7.createElement(Box6, { paddingX: 1, marginBottom: 1 }, /* @__PURE__ */ React7.createElement(ThoughtStream, { isThinking }));
|
|
1062
1055
|
});
|
|
1063
1056
|
|
|
1064
1057
|
// src/components/PermissionPrompt.tsx
|
|
@@ -1096,7 +1089,10 @@ function PermissionPrompt({
|
|
|
1096
1089
|
{ label: "\u2713 Allow once", value: "allow-once" },
|
|
1097
1090
|
{ label: "\u2717 Deny", value: "deny" }
|
|
1098
1091
|
];
|
|
1099
|
-
const
|
|
1092
|
+
const MAX_ARGS_LENGTH = 500;
|
|
1093
|
+
const rawArgsString = typeof args === "string" ? args : JSON.stringify(args, null, 2);
|
|
1094
|
+
const argsString = rawArgsString.length > MAX_ARGS_LENGTH ? rawArgsString.slice(0, MAX_ARGS_LENGTH) + `
|
|
1095
|
+
... (${rawArgsString.length - MAX_ARGS_LENGTH} more chars)` : rawArgsString;
|
|
1100
1096
|
return /* @__PURE__ */ React8.createElement(Box7, { flexDirection: "column", borderStyle: "bold", borderColor: "yellow", padding: 1, marginY: 1 }, /* @__PURE__ */ React8.createElement(Box7, null, /* @__PURE__ */ React8.createElement(Text7, { bold: true, color: "yellow" }, "\u26A0\uFE0F Permission Required")), /* @__PURE__ */ React8.createElement(Box7, { marginTop: 1 }, /* @__PURE__ */ React8.createElement(Text7, { dimColor: true }, "Tool: "), /* @__PURE__ */ React8.createElement(Text7, { bold: true, color: "cyan" }, toolName)), toolDescription && /* @__PURE__ */ React8.createElement(Box7, null, /* @__PURE__ */ React8.createElement(Text7, { dimColor: true }, "Action: "), /* @__PURE__ */ React8.createElement(Text7, null, toolDescription)), /* @__PURE__ */ React8.createElement(Box7, { marginTop: 1, flexDirection: "column" }, /* @__PURE__ */ React8.createElement(Text7, { bold: true }, "Arguments:"), /* @__PURE__ */ React8.createElement(Box7, { paddingLeft: 2, flexDirection: "column" }, /* @__PURE__ */ React8.createElement(Text7, { dimColor: true }, argsString))), preview && /* @__PURE__ */ React8.createElement(Box7, { marginTop: 1, flexDirection: "column" }, /* @__PURE__ */ React8.createElement(Text7, { bold: true }, "Preview:"), /* @__PURE__ */ React8.createElement(Box7, { borderStyle: "single", borderColor: "gray", paddingX: 1, flexDirection: "column" }, renderDiffPreview(preview))), !canBeTrusted && /* @__PURE__ */ React8.createElement(Box7, { marginTop: 1 }, /* @__PURE__ */ React8.createElement(Text7, { color: "red", dimColor: true }, "Note: This tool cannot be trusted due to its dangerous nature.")), /* @__PURE__ */ React8.createElement(Box7, { marginTop: 1 }, /* @__PURE__ */ React8.createElement(SelectInput, { items, onSelect: (item) => onResponse(item.value) })));
|
|
1101
1097
|
}
|
|
1102
1098
|
|
|
@@ -3149,6 +3145,7 @@ ${options.context}` : this.getSystemPrompt()
|
|
|
3149
3145
|
}
|
|
3150
3146
|
if (completionInfo.toolsUsed && completionInfo.toolsUsed.length > 0) {
|
|
3151
3147
|
hadToolCalls = true;
|
|
3148
|
+
const thinkingBlocks = completionInfo.thinking || [];
|
|
3152
3149
|
for (const toolUse of completionInfo.toolsUsed) {
|
|
3153
3150
|
const toolCallId = `${toolUse.name}_${JSON.stringify(toolUse.arguments)}`;
|
|
3154
3151
|
if (processedToolIds.has(toolCallId)) {
|
|
@@ -3181,16 +3178,23 @@ ${options.context}` : this.getSystemPrompt()
|
|
|
3181
3178
|
const params = typeof toolUse.arguments === "string" ? JSON.parse(toolUse.arguments) : toolUse.arguments;
|
|
3182
3179
|
observation = await tool.toolFn(params);
|
|
3183
3180
|
const toolCallId2 = `${toolUse.name}_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
3181
|
+
const assistantContent = [
|
|
3182
|
+
// Include thinking blocks first (required by Anthropic when thinking is enabled)
|
|
3183
|
+
...thinkingBlocks,
|
|
3184
|
+
// Then the tool use
|
|
3185
|
+
{
|
|
3186
|
+
type: "tool_use",
|
|
3187
|
+
id: toolCallId2,
|
|
3188
|
+
name: toolUse.name,
|
|
3189
|
+
input: params
|
|
3190
|
+
}
|
|
3191
|
+
];
|
|
3192
|
+
this.context.logger.debug(
|
|
3193
|
+
`[assistantContent] ${assistantContent.length} blocks (${thinkingBlocks.length} thinking, 1 tool_use)`
|
|
3194
|
+
);
|
|
3184
3195
|
messages.push({
|
|
3185
3196
|
role: "assistant",
|
|
3186
|
-
content:
|
|
3187
|
-
{
|
|
3188
|
-
type: "tool_use",
|
|
3189
|
-
id: toolCallId2,
|
|
3190
|
-
name: toolUse.name,
|
|
3191
|
-
input: params
|
|
3192
|
-
}
|
|
3193
|
-
]
|
|
3197
|
+
content: assistantContent
|
|
3194
3198
|
});
|
|
3195
3199
|
messages.push({
|
|
3196
3200
|
role: "user",
|
|
@@ -5481,8 +5485,8 @@ async function processAndStoreImages(images, context) {
|
|
|
5481
5485
|
const buffer = await downloadImage(image);
|
|
5482
5486
|
const fileType = await fileTypeFromBuffer2(buffer);
|
|
5483
5487
|
const filename = `${uuidv46()}.${fileType?.ext}`;
|
|
5484
|
-
const
|
|
5485
|
-
return
|
|
5488
|
+
const path17 = await context.imageGenerateStorage.upload(buffer, filename, {});
|
|
5489
|
+
return path17;
|
|
5486
5490
|
}));
|
|
5487
5491
|
}
|
|
5488
5492
|
async function updateQuestAndReturnMarkdown(storedImageUrls, context) {
|
|
@@ -6694,8 +6698,8 @@ async function processAndStoreImage(imageUrl, context) {
|
|
|
6694
6698
|
const buffer = await downloadImage2(imageUrl);
|
|
6695
6699
|
const fileType = await fileTypeFromBuffer3(buffer);
|
|
6696
6700
|
const filename = `${uuidv47()}.${fileType?.ext}`;
|
|
6697
|
-
const
|
|
6698
|
-
return
|
|
6701
|
+
const path17 = await context.imageGenerateStorage.upload(buffer, filename, {});
|
|
6702
|
+
return path17;
|
|
6699
6703
|
}
|
|
6700
6704
|
async function updateQuestAndReturnMarkdown2(storedImagePath, context) {
|
|
6701
6705
|
await context.onFinish?.("edit_image", storedImagePath);
|
|
@@ -9483,6 +9487,104 @@ BLOCKED OPERATIONS:
|
|
|
9483
9487
|
})
|
|
9484
9488
|
};
|
|
9485
9489
|
|
|
9490
|
+
// ../../b4m-core/packages/services/dist/src/llm/tools/implementation/editLocalFile/index.js
|
|
9491
|
+
import { promises as fs11 } from "fs";
|
|
9492
|
+
import { existsSync as existsSync7 } from "fs";
|
|
9493
|
+
import path13 from "path";
|
|
9494
|
+
import { diffLines as diffLines3 } from "diff";
|
|
9495
|
+
function generateDiff(original, modified) {
|
|
9496
|
+
const differences = diffLines3(original, modified);
|
|
9497
|
+
let diffString = "";
|
|
9498
|
+
let additions = 0;
|
|
9499
|
+
let deletions = 0;
|
|
9500
|
+
differences.forEach((part) => {
|
|
9501
|
+
if (part.added) {
|
|
9502
|
+
additions += part.count || 0;
|
|
9503
|
+
diffString += part.value.split("\n").filter((line) => line).map((line) => `+ ${line}`).join("\n");
|
|
9504
|
+
if (diffString && !diffString.endsWith("\n"))
|
|
9505
|
+
diffString += "\n";
|
|
9506
|
+
} else if (part.removed) {
|
|
9507
|
+
deletions += part.count || 0;
|
|
9508
|
+
diffString += part.value.split("\n").filter((line) => line).map((line) => `- ${line}`).join("\n");
|
|
9509
|
+
if (diffString && !diffString.endsWith("\n"))
|
|
9510
|
+
diffString += "\n";
|
|
9511
|
+
}
|
|
9512
|
+
});
|
|
9513
|
+
return { additions, deletions, diff: diffString.trim() };
|
|
9514
|
+
}
|
|
9515
|
+
async function editLocalFile(params) {
|
|
9516
|
+
const { path: filePath, old_string, new_string } = params;
|
|
9517
|
+
const normalizedPath = path13.normalize(filePath);
|
|
9518
|
+
const resolvedPath = path13.resolve(process.cwd(), normalizedPath);
|
|
9519
|
+
const cwd = path13.resolve(process.cwd());
|
|
9520
|
+
if (!resolvedPath.startsWith(cwd)) {
|
|
9521
|
+
throw new Error(`Access denied: Cannot edit files outside of current working directory`);
|
|
9522
|
+
}
|
|
9523
|
+
if (!existsSync7(resolvedPath)) {
|
|
9524
|
+
throw new Error(`File not found: ${filePath}`);
|
|
9525
|
+
}
|
|
9526
|
+
const currentContent = await fs11.readFile(resolvedPath, "utf-8");
|
|
9527
|
+
if (!currentContent.includes(old_string)) {
|
|
9528
|
+
const preview = old_string.length > 100 ? old_string.substring(0, 100) + "..." : old_string;
|
|
9529
|
+
throw new Error(`String to replace not found in file. Make sure the old_string matches exactly (including whitespace and line endings). Searched for: "${preview}"`);
|
|
9530
|
+
}
|
|
9531
|
+
const occurrences = currentContent.split(old_string).length - 1;
|
|
9532
|
+
if (occurrences > 1) {
|
|
9533
|
+
throw new Error(`Found ${occurrences} occurrences of the string to replace. Please provide a more specific old_string that matches exactly one location.`);
|
|
9534
|
+
}
|
|
9535
|
+
const newContent = currentContent.replace(old_string, new_string);
|
|
9536
|
+
await fs11.writeFile(resolvedPath, newContent, "utf-8");
|
|
9537
|
+
const diffResult = generateDiff(old_string, new_string);
|
|
9538
|
+
return `File edited successfully: ${filePath}
|
|
9539
|
+
Changes: +${diffResult.additions} lines, -${diffResult.deletions} lines
|
|
9540
|
+
|
|
9541
|
+
Diff:
|
|
9542
|
+
${diffResult.diff}`;
|
|
9543
|
+
}
|
|
9544
|
+
var editLocalFileTool = {
|
|
9545
|
+
name: "edit_file",
|
|
9546
|
+
implementation: (context) => ({
|
|
9547
|
+
toolFn: async (value) => {
|
|
9548
|
+
const params = value;
|
|
9549
|
+
context.logger.info(`\u{1F4DD} EditLocalFile: Editing file`, {
|
|
9550
|
+
path: params.path,
|
|
9551
|
+
oldStringLength: params.old_string.length,
|
|
9552
|
+
newStringLength: params.new_string.length
|
|
9553
|
+
});
|
|
9554
|
+
try {
|
|
9555
|
+
const result = await editLocalFile(params);
|
|
9556
|
+
context.logger.info("\u2705 EditLocalFile: Success", { path: params.path });
|
|
9557
|
+
return result;
|
|
9558
|
+
} catch (error) {
|
|
9559
|
+
context.logger.error("\u274C EditLocalFile: Failed", error);
|
|
9560
|
+
throw error;
|
|
9561
|
+
}
|
|
9562
|
+
},
|
|
9563
|
+
toolSchema: {
|
|
9564
|
+
name: "edit_file",
|
|
9565
|
+
description: "Edit a file by replacing a specific string with new content. The old_string must match exactly one location in the file (including whitespace). Use this for precise edits to existing files. For creating new files or complete rewrites, use create_file instead.",
|
|
9566
|
+
parameters: {
|
|
9567
|
+
type: "object",
|
|
9568
|
+
properties: {
|
|
9569
|
+
path: {
|
|
9570
|
+
type: "string",
|
|
9571
|
+
description: "Path to the file to edit (relative to current working directory)"
|
|
9572
|
+
},
|
|
9573
|
+
old_string: {
|
|
9574
|
+
type: "string",
|
|
9575
|
+
description: "The exact string to find and replace. Must match exactly one location in the file, including all whitespace and line endings."
|
|
9576
|
+
},
|
|
9577
|
+
new_string: {
|
|
9578
|
+
type: "string",
|
|
9579
|
+
description: "The string to replace old_string with. Can be empty to delete the old_string."
|
|
9580
|
+
}
|
|
9581
|
+
},
|
|
9582
|
+
required: ["path", "old_string", "new_string"]
|
|
9583
|
+
}
|
|
9584
|
+
}
|
|
9585
|
+
})
|
|
9586
|
+
};
|
|
9587
|
+
|
|
9486
9588
|
// ../../b4m-core/packages/services/dist/src/llm/tools/index.js
|
|
9487
9589
|
var tools = {
|
|
9488
9590
|
dice_roll: diceRollTool,
|
|
@@ -9508,6 +9610,7 @@ var tools = {
|
|
|
9508
9610
|
planet_visibility: planetVisibilityTool,
|
|
9509
9611
|
file_read: fileReadTool,
|
|
9510
9612
|
create_file: createFileTool,
|
|
9613
|
+
edit_local_file: editLocalFileTool,
|
|
9511
9614
|
glob_files: globFilesTool,
|
|
9512
9615
|
grep_search: grepSearchTool,
|
|
9513
9616
|
delete_file: deleteFileTool,
|
|
@@ -9751,10 +9854,10 @@ var ToolErrorType;
|
|
|
9751
9854
|
// src/utils/diffPreview.ts
|
|
9752
9855
|
import * as Diff from "diff";
|
|
9753
9856
|
import { readFile } from "fs/promises";
|
|
9754
|
-
import { existsSync as
|
|
9857
|
+
import { existsSync as existsSync8 } from "fs";
|
|
9755
9858
|
async function generateFileDiffPreview(args) {
|
|
9756
9859
|
try {
|
|
9757
|
-
if (!
|
|
9860
|
+
if (!existsSync8(args.path)) {
|
|
9758
9861
|
const lines2 = args.content.split("\n");
|
|
9759
9862
|
const preview = lines2.slice(0, 20).join("\n");
|
|
9760
9863
|
const hasMore = lines2.length > 20;
|
|
@@ -9776,18 +9879,26 @@ ${preview}${hasMore ? `
|
|
|
9776
9879
|
// Show 3 lines of context around changes
|
|
9777
9880
|
);
|
|
9778
9881
|
const lines = patch.split("\n");
|
|
9779
|
-
const
|
|
9780
|
-
return
|
|
9882
|
+
const diffLines4 = lines.slice(4);
|
|
9883
|
+
return diffLines4.join("\n");
|
|
9781
9884
|
} catch (error) {
|
|
9782
9885
|
return `[Error generating diff preview: ${error instanceof Error ? error.message : "Unknown error"}]`;
|
|
9783
9886
|
}
|
|
9784
9887
|
}
|
|
9888
|
+
function generateEditLocalFilePreview(args) {
|
|
9889
|
+
const patch = Diff.createPatch(args.path, args.old_string, args.new_string, "Current", "Proposed", { context: 3 });
|
|
9890
|
+
const lines = patch.split("\n");
|
|
9891
|
+
const diffLines4 = lines.slice(4);
|
|
9892
|
+
return `[Edit in: ${args.path}]
|
|
9893
|
+
|
|
9894
|
+
${diffLines4.join("\n")}`;
|
|
9895
|
+
}
|
|
9785
9896
|
async function generateFileDeletePreview(args) {
|
|
9786
9897
|
try {
|
|
9787
|
-
if (!
|
|
9898
|
+
if (!existsSync8(args.path)) {
|
|
9788
9899
|
return `[File does not exist: ${args.path}]`;
|
|
9789
9900
|
}
|
|
9790
|
-
const stats = await import("fs/promises").then((
|
|
9901
|
+
const stats = await import("fs/promises").then((fs14) => fs14.stat(args.path));
|
|
9791
9902
|
return `[File will be deleted]
|
|
9792
9903
|
|
|
9793
9904
|
Path: ${args.path}
|
|
@@ -9799,8 +9910,8 @@ Last modified: ${stats.mtime.toLocaleString()}`;
|
|
|
9799
9910
|
}
|
|
9800
9911
|
|
|
9801
9912
|
// src/utils/Logger.ts
|
|
9802
|
-
import
|
|
9803
|
-
import
|
|
9913
|
+
import fs12 from "fs/promises";
|
|
9914
|
+
import path14 from "path";
|
|
9804
9915
|
import os2 from "os";
|
|
9805
9916
|
var Logger2 = class _Logger {
|
|
9806
9917
|
constructor() {
|
|
@@ -9823,9 +9934,9 @@ var Logger2 = class _Logger {
|
|
|
9823
9934
|
*/
|
|
9824
9935
|
async initialize(sessionId) {
|
|
9825
9936
|
this.sessionId = sessionId;
|
|
9826
|
-
const debugDir =
|
|
9827
|
-
await
|
|
9828
|
-
this.logFilePath =
|
|
9937
|
+
const debugDir = path14.join(os2.homedir(), ".bike4mind", "debug");
|
|
9938
|
+
await fs12.mkdir(debugDir, { recursive: true });
|
|
9939
|
+
this.logFilePath = path14.join(debugDir, `${sessionId}.txt`);
|
|
9829
9940
|
await this.writeToFile("INFO", "=== CLI SESSION START ===");
|
|
9830
9941
|
}
|
|
9831
9942
|
/**
|
|
@@ -9889,7 +10000,7 @@ var Logger2 = class _Logger {
|
|
|
9889
10000
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace("T", " ").substring(0, 19);
|
|
9890
10001
|
const logEntry = `[${timestamp}] [${level}] ${message}
|
|
9891
10002
|
`;
|
|
9892
|
-
await
|
|
10003
|
+
await fs12.appendFile(this.logFilePath, logEntry, "utf-8");
|
|
9893
10004
|
} catch (error) {
|
|
9894
10005
|
console.error("File logging failed:", error);
|
|
9895
10006
|
}
|
|
@@ -10035,15 +10146,15 @@ var Logger2 = class _Logger {
|
|
|
10035
10146
|
async cleanupOldLogs() {
|
|
10036
10147
|
if (!this.fileLoggingEnabled) return;
|
|
10037
10148
|
try {
|
|
10038
|
-
const debugDir =
|
|
10039
|
-
const files = await
|
|
10149
|
+
const debugDir = path14.join(os2.homedir(), ".bike4mind", "debug");
|
|
10150
|
+
const files = await fs12.readdir(debugDir);
|
|
10040
10151
|
const now = Date.now();
|
|
10041
10152
|
const thirtyDaysAgo = now - 30 * 24 * 60 * 60 * 1e3;
|
|
10042
10153
|
for (const file of files) {
|
|
10043
|
-
const filePath =
|
|
10044
|
-
const stats = await
|
|
10154
|
+
const filePath = path14.join(debugDir, file);
|
|
10155
|
+
const stats = await fs12.stat(filePath);
|
|
10045
10156
|
if (stats.mtime.getTime() < thirtyDaysAgo) {
|
|
10046
|
-
await
|
|
10157
|
+
await fs12.unlink(filePath);
|
|
10047
10158
|
}
|
|
10048
10159
|
}
|
|
10049
10160
|
} catch (error) {
|
|
@@ -10137,21 +10248,21 @@ var NoOpStorage = class extends BaseStorage {
|
|
|
10137
10248
|
async upload(input, destination, options) {
|
|
10138
10249
|
return `/tmp/${destination}`;
|
|
10139
10250
|
}
|
|
10140
|
-
async download(
|
|
10251
|
+
async download(path17) {
|
|
10141
10252
|
throw new Error("Download not supported in CLI");
|
|
10142
10253
|
}
|
|
10143
|
-
async delete(
|
|
10254
|
+
async delete(path17) {
|
|
10144
10255
|
}
|
|
10145
|
-
async getSignedUrl(
|
|
10146
|
-
return `/tmp/${
|
|
10256
|
+
async getSignedUrl(path17) {
|
|
10257
|
+
return `/tmp/${path17}`;
|
|
10147
10258
|
}
|
|
10148
|
-
getPublicUrl(
|
|
10149
|
-
return `/tmp/${
|
|
10259
|
+
getPublicUrl(path17) {
|
|
10260
|
+
return `/tmp/${path17}`;
|
|
10150
10261
|
}
|
|
10151
|
-
async getPreview(
|
|
10152
|
-
return `/tmp/${
|
|
10262
|
+
async getPreview(path17) {
|
|
10263
|
+
return `/tmp/${path17}`;
|
|
10153
10264
|
}
|
|
10154
|
-
async getMetadata(
|
|
10265
|
+
async getMetadata(path17) {
|
|
10155
10266
|
return { size: 0, contentType: "application/octet-stream" };
|
|
10156
10267
|
}
|
|
10157
10268
|
};
|
|
@@ -10183,11 +10294,12 @@ function wrapToolWithPermission(tool, permissionManager, showPermissionPrompt, a
|
|
|
10183
10294
|
return result2;
|
|
10184
10295
|
}
|
|
10185
10296
|
let preview;
|
|
10186
|
-
if (toolName === "edit_file" && args?.path && args?.
|
|
10297
|
+
if (toolName === "edit_file" && args?.path && args?.old_string && typeof args?.new_string === "string") {
|
|
10187
10298
|
try {
|
|
10188
|
-
preview =
|
|
10299
|
+
preview = generateEditLocalFilePreview({
|
|
10189
10300
|
path: args.path,
|
|
10190
|
-
|
|
10301
|
+
old_string: args.old_string,
|
|
10302
|
+
new_string: args.new_string
|
|
10191
10303
|
});
|
|
10192
10304
|
} catch (error) {
|
|
10193
10305
|
preview = `[Could not generate preview: ${error instanceof Error ? error.message : "Unknown error"}]`;
|
|
@@ -10304,6 +10416,7 @@ function generateCliTools(userId, llm, model, permissionManager, showPermissionP
|
|
|
10304
10416
|
// File operation tools (CLI-specific, local execution)
|
|
10305
10417
|
file_read: {},
|
|
10306
10418
|
create_file: {},
|
|
10419
|
+
edit_local_file: {},
|
|
10307
10420
|
glob_files: {},
|
|
10308
10421
|
grep_search: {},
|
|
10309
10422
|
delete_file: {},
|
|
@@ -10386,6 +10499,7 @@ var DEFAULT_TOOL_CATEGORIES = {
|
|
|
10386
10499
|
// These tools can modify files, execute code, or have other dangerous side effects
|
|
10387
10500
|
// They ALWAYS require permission and cannot be trusted automatically
|
|
10388
10501
|
edit_file: "prompt_always",
|
|
10502
|
+
edit_local_file: "prompt_always",
|
|
10389
10503
|
create_file: "prompt_always",
|
|
10390
10504
|
delete_file: "prompt_always",
|
|
10391
10505
|
shell_execute: "prompt_always",
|
|
@@ -10552,8 +10666,8 @@ function getEnvironmentName(configApiConfig) {
|
|
|
10552
10666
|
}
|
|
10553
10667
|
|
|
10554
10668
|
// src/utils/contextLoader.ts
|
|
10555
|
-
import * as
|
|
10556
|
-
import * as
|
|
10669
|
+
import * as fs13 from "fs";
|
|
10670
|
+
import * as path15 from "path";
|
|
10557
10671
|
import { homedir as homedir4 } from "os";
|
|
10558
10672
|
var CONTEXT_FILE_SIZE_LIMIT = 100 * 1024;
|
|
10559
10673
|
var PROJECT_CONTEXT_FILES = [
|
|
@@ -10574,9 +10688,9 @@ function formatFileSize2(bytes) {
|
|
|
10574
10688
|
return `${(bytes / (1024 * 1024)).toFixed(1)}MB`;
|
|
10575
10689
|
}
|
|
10576
10690
|
function tryReadContextFile(dir, filename, source) {
|
|
10577
|
-
const filePath =
|
|
10691
|
+
const filePath = path15.join(dir, filename);
|
|
10578
10692
|
try {
|
|
10579
|
-
const stats =
|
|
10693
|
+
const stats = fs13.lstatSync(filePath);
|
|
10580
10694
|
if (stats.isDirectory()) {
|
|
10581
10695
|
return null;
|
|
10582
10696
|
}
|
|
@@ -10590,7 +10704,7 @@ function tryReadContextFile(dir, filename, source) {
|
|
|
10590
10704
|
error: `${source === "global" ? "Global" : "Project"} ${filename} exceeds 100KB limit (${formatFileSize2(stats.size)})`
|
|
10591
10705
|
};
|
|
10592
10706
|
}
|
|
10593
|
-
const content =
|
|
10707
|
+
const content = fs13.readFileSync(filePath, "utf-8");
|
|
10594
10708
|
return {
|
|
10595
10709
|
filename,
|
|
10596
10710
|
content,
|
|
@@ -10642,7 +10756,7 @@ ${project.content}`;
|
|
|
10642
10756
|
}
|
|
10643
10757
|
async function loadContextFiles(projectDir) {
|
|
10644
10758
|
const errors = [];
|
|
10645
|
-
const globalDir =
|
|
10759
|
+
const globalDir = path15.join(homedir4(), ".bike4mind");
|
|
10646
10760
|
const projectDirectory = projectDir || process.cwd();
|
|
10647
10761
|
const [globalResult, projectResult] = await Promise.all([
|
|
10648
10762
|
Promise.resolve(findContextFile(globalDir, GLOBAL_CONTEXT_FILES, "global")),
|
|
@@ -10678,8 +10792,8 @@ function substituteArguments(template, args) {
|
|
|
10678
10792
|
// ../../b4m-core/packages/mcp/dist/src/client.js
|
|
10679
10793
|
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
|
|
10680
10794
|
import { Client as Client2 } from "@modelcontextprotocol/sdk/client/index.js";
|
|
10681
|
-
import
|
|
10682
|
-
import { existsSync as
|
|
10795
|
+
import path16 from "path";
|
|
10796
|
+
import { existsSync as existsSync9, readdirSync as readdirSync3 } from "fs";
|
|
10683
10797
|
var MCPClient = class {
|
|
10684
10798
|
// Note: This class handles MCP server communication with repository filtering
|
|
10685
10799
|
mcp;
|
|
@@ -10719,18 +10833,18 @@ var MCPClient = class {
|
|
|
10719
10833
|
const root = process.env.INIT_CWD || process.cwd();
|
|
10720
10834
|
const candidatePaths = [
|
|
10721
10835
|
// When running from SST Lambda with node_modules structure (copyFiles)
|
|
10722
|
-
|
|
10836
|
+
path16.join(root, `node_modules/@bike4mind/mcp/dist/src/${this.serverName}/index.js`),
|
|
10723
10837
|
// When running from SST Lambda deployed environment (/var/task)
|
|
10724
|
-
|
|
10838
|
+
path16.join(root, `b4m-core/packages/mcp/dist/src/${this.serverName}/index.js`),
|
|
10725
10839
|
// When running from SST Lambda (.sst/artifacts/mcpHandler-dev), navigate to monorepo root (3 levels up)
|
|
10726
|
-
|
|
10840
|
+
path16.join(root, `../../../b4m-core/packages/mcp/dist/src/${this.serverName}/index.js`),
|
|
10727
10841
|
// When running from packages/client (Next.js app), navigate to monorepo root (2 levels up)
|
|
10728
|
-
|
|
10842
|
+
path16.join(root, `../../b4m-core/packages/mcp/dist/src/${this.serverName}/index.js`),
|
|
10729
10843
|
// Original paths (backward compatibility)
|
|
10730
|
-
|
|
10731
|
-
|
|
10844
|
+
path16.join(root, `/b4m-core/packages/mcp/dist/src/${this.serverName}/index.js`),
|
|
10845
|
+
path16.join(root, "core", "mcp", "servers", this.serverName, "dist", "index.js")
|
|
10732
10846
|
];
|
|
10733
|
-
const serverScriptPath = candidatePaths.find((p) =>
|
|
10847
|
+
const serverScriptPath = candidatePaths.find((p) => existsSync9(p));
|
|
10734
10848
|
if (!serverScriptPath) {
|
|
10735
10849
|
const getDirectories = (source) => readdirSync3(source, { withFileTypes: true }).filter((dirent) => dirent.isDirectory()).map((dirent) => dirent.name);
|
|
10736
10850
|
console.error(`[MCP] Server script not found. Tried paths:`, candidatePaths);
|
|
@@ -11139,6 +11253,7 @@ var ServerLlmBackend = class {
|
|
|
11139
11253
|
let accumulatedText = "";
|
|
11140
11254
|
let lastUsageInfo = {};
|
|
11141
11255
|
let toolsUsed = [];
|
|
11256
|
+
let thinkingBlocks = [];
|
|
11142
11257
|
let receivedDone = false;
|
|
11143
11258
|
const parser = createParser({
|
|
11144
11259
|
onEvent: (event) => {
|
|
@@ -11152,9 +11267,12 @@ var ServerLlmBackend = class {
|
|
|
11152
11267
|
if (toolsUsed.length > 0) {
|
|
11153
11268
|
const info = {
|
|
11154
11269
|
toolsUsed,
|
|
11270
|
+
thinking: thinkingBlocks.length > 0 ? thinkingBlocks : void 0,
|
|
11155
11271
|
...lastUsageInfo
|
|
11156
11272
|
};
|
|
11157
|
-
logger.debug(
|
|
11273
|
+
logger.debug(
|
|
11274
|
+
`[ServerLlmBackend] Calling callback with tools, thinking blocks: ${thinkingBlocks.length}`
|
|
11275
|
+
);
|
|
11158
11276
|
callback([cleanedText], info).catch((err) => {
|
|
11159
11277
|
logger.error("[ServerLlmBackend] Callback error:", err);
|
|
11160
11278
|
reject(err);
|
|
@@ -11210,6 +11328,10 @@ var ServerLlmBackend = class {
|
|
|
11210
11328
|
if (parsed.tools && parsed.tools.length > 0) {
|
|
11211
11329
|
toolsUsed = parsed.tools;
|
|
11212
11330
|
}
|
|
11331
|
+
if (parsed.thinking && parsed.thinking.length > 0) {
|
|
11332
|
+
thinkingBlocks = parsed.thinking;
|
|
11333
|
+
logger.debug(`[ServerLlmBackend] Received ${thinkingBlocks.length} thinking blocks`);
|
|
11334
|
+
}
|
|
11213
11335
|
if (parsed.usage) {
|
|
11214
11336
|
lastUsageInfo = {
|
|
11215
11337
|
inputTokens: parsed.usage.inputTokens,
|
|
@@ -11532,7 +11654,7 @@ import { isAxiosError as isAxiosError2 } from "axios";
|
|
|
11532
11654
|
// package.json
|
|
11533
11655
|
var package_default = {
|
|
11534
11656
|
name: "@bike4mind/cli",
|
|
11535
|
-
version: "0.2.11-fix-
|
|
11657
|
+
version: "0.2.11-fix-cli-edit-file.17320+9a3a7fada",
|
|
11536
11658
|
type: "module",
|
|
11537
11659
|
description: "Interactive CLI tool for Bike4Mind with ReAct agents",
|
|
11538
11660
|
license: "UNLICENSED",
|
|
@@ -11636,10 +11758,10 @@ var package_default = {
|
|
|
11636
11758
|
},
|
|
11637
11759
|
devDependencies: {
|
|
11638
11760
|
"@bike4mind/agents": "0.1.0",
|
|
11639
|
-
"@bike4mind/common": "2.40.1-fix-
|
|
11640
|
-
"@bike4mind/mcp": "1.20.5-fix-
|
|
11641
|
-
"@bike4mind/services": "2.35.1-fix-
|
|
11642
|
-
"@bike4mind/utils": "2.1.5-fix-
|
|
11761
|
+
"@bike4mind/common": "2.40.1-fix-cli-edit-file.17320+9a3a7fada",
|
|
11762
|
+
"@bike4mind/mcp": "1.20.5-fix-cli-edit-file.17320+9a3a7fada",
|
|
11763
|
+
"@bike4mind/services": "2.35.1-fix-cli-edit-file.17320+9a3a7fada",
|
|
11764
|
+
"@bike4mind/utils": "2.1.5-fix-cli-edit-file.17320+9a3a7fada",
|
|
11643
11765
|
"@types/better-sqlite3": "^7.6.13",
|
|
11644
11766
|
"@types/diff": "^5.0.9",
|
|
11645
11767
|
"@types/jsonwebtoken": "^9.0.4",
|
|
@@ -11652,7 +11774,7 @@ var package_default = {
|
|
|
11652
11774
|
typescript: "^5.9.3",
|
|
11653
11775
|
vitest: "^3.2.4"
|
|
11654
11776
|
},
|
|
11655
|
-
gitHead: "
|
|
11777
|
+
gitHead: "9a3a7fadaad1d08947a1d9d0b4164ed7ff723d1c"
|
|
11656
11778
|
};
|
|
11657
11779
|
|
|
11658
11780
|
// src/config/constants.ts
|
|
@@ -11894,6 +12016,7 @@ Focus on:
|
|
|
11894
12016
|
- Creating logical sequence of steps
|
|
11895
12017
|
- Estimating scope and priorities
|
|
11896
12018
|
|
|
12019
|
+
You have read-only access to analyze code.
|
|
11897
12020
|
You can explore the codebase to understand the current architecture before planning.
|
|
11898
12021
|
|
|
11899
12022
|
Provide a structured plan that the main agent can execute.`,
|
|
@@ -12037,7 +12160,8 @@ function CliApp() {
|
|
|
12037
12160
|
permissionPrompt: null,
|
|
12038
12161
|
trustLocationSelector: null,
|
|
12039
12162
|
rewindSelector: null,
|
|
12040
|
-
sessionSelector: null
|
|
12163
|
+
sessionSelector: null,
|
|
12164
|
+
orchestrator: null
|
|
12041
12165
|
});
|
|
12042
12166
|
const [isInitialized, setIsInitialized] = useState8(false);
|
|
12043
12167
|
const [initError, setInitError] = useState8(null);
|
|
@@ -12359,20 +12483,38 @@ Remember: Use context from previous messages to understand follow-up questions.$
|
|
|
12359
12483
|
const lastIdx = pendingMessages.length - 1;
|
|
12360
12484
|
if (lastIdx >= 0 && pendingMessages[lastIdx].role === "assistant") {
|
|
12361
12485
|
const existingSteps = pendingMessages[lastIdx].metadata?.steps || [];
|
|
12486
|
+
const MAX_INPUT_LENGTH = 500;
|
|
12487
|
+
let truncatedStep = step;
|
|
12488
|
+
if (step.type === "action" && step.metadata?.toolInput) {
|
|
12489
|
+
const inputStr = typeof step.metadata.toolInput === "string" ? step.metadata.toolInput : JSON.stringify(step.metadata.toolInput);
|
|
12490
|
+
if (inputStr.length > MAX_INPUT_LENGTH) {
|
|
12491
|
+
const truncatedInput = inputStr.slice(0, MAX_INPUT_LENGTH) + `... (${inputStr.length - MAX_INPUT_LENGTH} more chars)`;
|
|
12492
|
+
truncatedStep = {
|
|
12493
|
+
...step,
|
|
12494
|
+
metadata: {
|
|
12495
|
+
...step.metadata,
|
|
12496
|
+
toolInput: truncatedInput
|
|
12497
|
+
}
|
|
12498
|
+
};
|
|
12499
|
+
}
|
|
12500
|
+
}
|
|
12362
12501
|
updatePendingMessage(lastIdx, {
|
|
12363
12502
|
...pendingMessages[lastIdx],
|
|
12364
12503
|
metadata: {
|
|
12365
12504
|
...pendingMessages[lastIdx].metadata,
|
|
12366
|
-
steps: [...existingSteps,
|
|
12505
|
+
steps: [...existingSteps, truncatedStep]
|
|
12367
12506
|
}
|
|
12368
12507
|
});
|
|
12369
12508
|
}
|
|
12370
12509
|
};
|
|
12510
|
+
agent.on("thought", stepHandler);
|
|
12371
12511
|
agent.on("action", stepHandler);
|
|
12372
12512
|
orchestrator.setBeforeRunCallback((subagent, _subagentType) => {
|
|
12513
|
+
subagent.on("thought", stepHandler);
|
|
12373
12514
|
subagent.on("action", stepHandler);
|
|
12374
12515
|
});
|
|
12375
12516
|
orchestrator.setAfterRunCallback((subagent, _subagentType) => {
|
|
12517
|
+
subagent.off("thought", stepHandler);
|
|
12376
12518
|
subagent.off("action", stepHandler);
|
|
12377
12519
|
});
|
|
12378
12520
|
setState((prev) => ({
|
|
@@ -12383,8 +12525,10 @@ Remember: Use context from previous messages to understand follow-up questions.$
|
|
|
12383
12525
|
permissionManager,
|
|
12384
12526
|
config,
|
|
12385
12527
|
// Store config for synchronous access
|
|
12386
|
-
availableModels: models
|
|
12528
|
+
availableModels: models,
|
|
12387
12529
|
// Store models for ConfigEditor
|
|
12530
|
+
orchestrator
|
|
12531
|
+
// Store orchestrator for step handler updates
|
|
12388
12532
|
}));
|
|
12389
12533
|
setStoreSession(newSession);
|
|
12390
12534
|
setIsInitialized(true);
|
|
@@ -12439,6 +12583,7 @@ Remember: Use context from previous messages to understand follow-up questions.$
|
|
|
12439
12583
|
}
|
|
12440
12584
|
}
|
|
12441
12585
|
};
|
|
12586
|
+
state.agent.on("thought", stepHandler);
|
|
12442
12587
|
state.agent.on("action", stepHandler);
|
|
12443
12588
|
try {
|
|
12444
12589
|
let messageContent = fullTemplate;
|
|
@@ -12560,6 +12705,7 @@ Remember: Use context from previous messages to understand follow-up questions.$
|
|
|
12560
12705
|
setState((prev) => ({ ...prev, session: sessionWithError }));
|
|
12561
12706
|
setStoreSession(sessionWithError);
|
|
12562
12707
|
} finally {
|
|
12708
|
+
state.agent.off("thought", stepHandler);
|
|
12563
12709
|
state.agent.off("action", stepHandler);
|
|
12564
12710
|
}
|
|
12565
12711
|
};
|
|
@@ -12881,7 +13027,6 @@ Custom Commands:
|
|
|
12881
13027
|
logger.debug("=== Session Resumed ===");
|
|
12882
13028
|
setState((prev) => ({ ...prev, session: loadedSession }));
|
|
12883
13029
|
setStoreSession(loadedSession);
|
|
12884
|
-
useCliStore.getState().clearAgentSteps();
|
|
12885
13030
|
useCliStore.getState().clearPendingMessages();
|
|
12886
13031
|
usageCache = null;
|
|
12887
13032
|
console.log(`
|
|
@@ -13117,7 +13262,6 @@ Custom Commands:
|
|
|
13117
13262
|
logger.debug("=== New Session Started via /clear ===");
|
|
13118
13263
|
setState((prev) => ({ ...prev, session: newSession }));
|
|
13119
13264
|
setStoreSession(newSession);
|
|
13120
|
-
useCliStore.getState().clearAgentSteps();
|
|
13121
13265
|
useCliStore.getState().clearPendingMessages();
|
|
13122
13266
|
usageCache = null;
|
|
13123
13267
|
console.log("New session started.");
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
import {
|
|
3
3
|
findMostSimilarMemento,
|
|
4
4
|
getRelevantMementos
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-DGAIF2QC.js";
|
|
6
|
+
import "./chunk-SQBLLN7K.js";
|
|
7
7
|
import "./chunk-AMDXHL6S.js";
|
|
8
|
-
import "./chunk-
|
|
8
|
+
import "./chunk-WCYNJOOX.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-SQBLLN7K.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-WCYNJOOX.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-
|
|
6
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-RBZRTCAY.js";
|
|
6
|
+
import "./chunk-SQBLLN7K.js";
|
|
7
7
|
import "./chunk-AMDXHL6S.js";
|
|
8
|
-
import "./chunk-
|
|
8
|
+
import "./chunk-WCYNJOOX.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.11-fix-
|
|
3
|
+
"version": "0.2.11-fix-cli-edit-file.17320+9a3a7fada",
|
|
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.40.1-fix-
|
|
108
|
-
"@bike4mind/mcp": "1.20.5-fix-
|
|
109
|
-
"@bike4mind/services": "2.35.1-fix-
|
|
110
|
-
"@bike4mind/utils": "2.1.5-fix-
|
|
107
|
+
"@bike4mind/common": "2.40.1-fix-cli-edit-file.17320+9a3a7fada",
|
|
108
|
+
"@bike4mind/mcp": "1.20.5-fix-cli-edit-file.17320+9a3a7fada",
|
|
109
|
+
"@bike4mind/services": "2.35.1-fix-cli-edit-file.17320+9a3a7fada",
|
|
110
|
+
"@bike4mind/utils": "2.1.5-fix-cli-edit-file.17320+9a3a7fada",
|
|
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": "
|
|
123
|
+
"gitHead": "9a3a7fadaad1d08947a1d9d0b4164ed7ff723d1c"
|
|
124
124
|
}
|