@bike4mind/cli 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +69 -67
- package/dist/{artifactExtractor-QN34RFDM.js → artifactExtractor-JZD2HZ6K.js} +1 -1
- package/dist/{chunk-XANFVWI6.js → chunk-43ZKBRTE.js} +2 -2
- package/dist/{chunk-B3YFSFVU.js → chunk-EVPT4ARN.js} +262 -204
- package/dist/{chunk-TPSQ5MIR.js → chunk-FNZZAMET.js} +2 -2
- package/dist/{chunk-MKO2KCCS.js → chunk-VVV7WLJ6.js} +1 -0
- package/dist/{chunk-KZGZGNHL.js → chunk-ZT7Z4QVD.js} +2 -2
- package/dist/{create-DGRMWHIN.js → create-42PUCFSO.js} +3 -3
- package/dist/index.js +142 -161
- package/dist/{llmMarkdownGenerator-JBDLN44A.js → llmMarkdownGenerator-KV37M3II.js} +1 -1
- package/dist/{markdownGenerator-MM5N3H5I.js → markdownGenerator-XVTS6PUQ.js} +1 -1
- package/dist/{mementoService-23ROW7I4.js → mementoService-ZGZR3QN6.js} +3 -3
- package/dist/{src-OVEHYUVN.js → src-2BQJS6GJ.js} +1 -1
- package/dist/{src-K5MFQICX.js → src-DPL74BDD.js} +2 -2
- package/dist/{subtractCredits-YAWCGKMX.js → subtractCredits-3GIBRYWF.js} +3 -3
- package/package.json +2 -1
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
dayjsConfig_default,
|
|
17
17
|
extractSnippetMeta,
|
|
18
18
|
settingsMap
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-VVV7WLJ6.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";
|
|
@@ -1051,19 +1051,29 @@ var BaseBedrockBackend = class {
|
|
|
1051
1051
|
}
|
|
1052
1052
|
if (func.some((f) => f.name)) {
|
|
1053
1053
|
for await (const tool of func) {
|
|
1054
|
-
const {
|
|
1055
|
-
|
|
1056
|
-
if (id && name && parameters && toolFn) {
|
|
1057
|
-
const result = await toolFn(JSON.parse(parameters));
|
|
1054
|
+
const { name, parameters } = tool;
|
|
1055
|
+
if (name && parameters) {
|
|
1058
1056
|
toolsUsed.push({ name, arguments: parameters });
|
|
1059
|
-
await handleToolResultStreaming(name, result, async (results) => {
|
|
1060
|
-
await callback(results, { inputTokens, outputTokens, toolsUsed });
|
|
1061
|
-
});
|
|
1062
|
-
this.pushToolMessages(messages, { id, name, parameters }, result);
|
|
1063
1057
|
}
|
|
1064
1058
|
}
|
|
1065
|
-
|
|
1066
|
-
|
|
1059
|
+
if (options.executeTools !== false) {
|
|
1060
|
+
for await (const tool of func) {
|
|
1061
|
+
const { id, name, parameters } = tool;
|
|
1062
|
+
const toolFn = options.tools?.find((tool2) => tool2.toolSchema.name === name)?.toolFn;
|
|
1063
|
+
if (id && name && parameters && toolFn) {
|
|
1064
|
+
const result = await toolFn(JSON.parse(parameters));
|
|
1065
|
+
await handleToolResultStreaming(name, result, async (results) => {
|
|
1066
|
+
await callback(results, { inputTokens, outputTokens, toolsUsed });
|
|
1067
|
+
});
|
|
1068
|
+
this.pushToolMessages(messages, { id, name, parameters }, result);
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
await callback(["\n\n"], { inputTokens, outputTokens, toolsUsed });
|
|
1072
|
+
await this.complete(model, messages, { ...options, thinking: { enabled: false, budget_tokens: 0 } }, callback, toolsUsed);
|
|
1073
|
+
} else {
|
|
1074
|
+
console.log("[BaseBedrockBackend] executeTools=false, passing tool calls to callback");
|
|
1075
|
+
await callback([null], { inputTokens, outputTokens, toolsUsed });
|
|
1076
|
+
}
|
|
1067
1077
|
return;
|
|
1068
1078
|
}
|
|
1069
1079
|
} else {
|
|
@@ -1084,16 +1094,24 @@ var BaseBedrockBackend = class {
|
|
|
1084
1094
|
const toolChoice = chunk?.choices.find((choice) => choice.statusEndReason === ChoiceEndReason.TOOL_USE);
|
|
1085
1095
|
if (toolChoice?.tool) {
|
|
1086
1096
|
const { id, name, parameters } = toolChoice.tool;
|
|
1087
|
-
|
|
1088
|
-
if (id && name && parameters && toolFn) {
|
|
1089
|
-
const result = await toolFn(JSON.parse(parameters));
|
|
1097
|
+
if (name && parameters) {
|
|
1090
1098
|
toolsUsed.push({ name, arguments: parameters });
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1099
|
+
}
|
|
1100
|
+
if (options.executeTools !== false) {
|
|
1101
|
+
const toolFn = options.tools?.find((tool) => tool.toolSchema.name === name)?.toolFn;
|
|
1102
|
+
if (id && name && parameters && toolFn) {
|
|
1103
|
+
const result = await toolFn(JSON.parse(parameters));
|
|
1104
|
+
await handleToolResultStreaming(name, result, async (results) => {
|
|
1105
|
+
await callback(results, { inputTokens, outputTokens, toolsUsed });
|
|
1106
|
+
});
|
|
1107
|
+
this.pushToolMessages(messages, { id, name, parameters }, result);
|
|
1108
|
+
await callback(["\n\n"], { inputTokens, outputTokens, toolsUsed });
|
|
1109
|
+
await this.complete(model, messages, { ...options, thinking: { enabled: false, budget_tokens: 0 } }, callback, toolsUsed);
|
|
1110
|
+
return;
|
|
1111
|
+
}
|
|
1112
|
+
} else {
|
|
1113
|
+
console.log("[BaseBedrockBackend] executeTools=false, passing tool calls to callback");
|
|
1114
|
+
await callback([null], { inputTokens, outputTokens, toolsUsed });
|
|
1097
1115
|
return;
|
|
1098
1116
|
}
|
|
1099
1117
|
}
|
|
@@ -3007,58 +3025,63 @@ var GeminiBackend = class {
|
|
|
3007
3025
|
}
|
|
3008
3026
|
if (toolCalls.length > 0 && options.tools?.length) {
|
|
3009
3027
|
console.log("[DEBUG] Gemini executing tools immediately:", toolCalls.map((tc) => tc.name));
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
const
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
await
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3028
|
+
if (options.executeTools !== false) {
|
|
3029
|
+
const assistantMessage = {
|
|
3030
|
+
role: "assistant",
|
|
3031
|
+
content: toolCalls.map((toolCall, index) => ({
|
|
3032
|
+
type: "tool_use",
|
|
3033
|
+
id: toolCall.id,
|
|
3034
|
+
name: toolCall.name,
|
|
3035
|
+
input: toolCall.parameters,
|
|
3036
|
+
// Only first tool call gets thought_signature (Gemini 3 requirement for parallel calls)
|
|
3037
|
+
thought_signature: index === 0 ? toolCall.thought_signature : void 0
|
|
3038
|
+
}))
|
|
3039
|
+
};
|
|
3040
|
+
messages.push(assistantMessage);
|
|
3041
|
+
for (const toolCall of toolCalls) {
|
|
3042
|
+
const toolFn = options.tools.find((tool) => tool.toolSchema.name === toolCall.name)?.toolFn;
|
|
3043
|
+
if (!toolFn) {
|
|
3044
|
+
console.warn(`[WARN] Tool ${toolCall.name} not found`);
|
|
3045
|
+
continue;
|
|
3046
|
+
}
|
|
3047
|
+
try {
|
|
3048
|
+
const result2 = await toolFn(toolCall.parameters);
|
|
3049
|
+
await handleToolResultStreaming(toolCall.name, result2, async (results) => {
|
|
3050
|
+
await callback(results, { toolsUsed });
|
|
3051
|
+
});
|
|
3052
|
+
messages.push({
|
|
3053
|
+
role: "tool",
|
|
3054
|
+
content: [
|
|
3055
|
+
{
|
|
3056
|
+
type: "tool_result",
|
|
3057
|
+
content: JSON.stringify({ result: result2 }),
|
|
3058
|
+
tool_use_id: toolCall.id
|
|
3059
|
+
}
|
|
3060
|
+
]
|
|
3061
|
+
});
|
|
3062
|
+
} catch (error) {
|
|
3063
|
+
if (error instanceof PermissionDeniedError) {
|
|
3064
|
+
throw error;
|
|
3065
|
+
}
|
|
3066
|
+
console.error(`[ERROR] Error executing tool ${toolCall.name}:`, error);
|
|
3067
|
+
messages.push({
|
|
3068
|
+
role: "tool",
|
|
3069
|
+
content: [
|
|
3070
|
+
{
|
|
3071
|
+
type: "tool_result",
|
|
3072
|
+
content: JSON.stringify({ error: error instanceof Error ? error.message : "Unknown error" }),
|
|
3073
|
+
tool_use_id: toolCall.id
|
|
3074
|
+
}
|
|
3075
|
+
]
|
|
3076
|
+
});
|
|
3046
3077
|
}
|
|
3047
|
-
console.error(`[ERROR] Error executing tool ${toolCall.name}:`, error);
|
|
3048
|
-
messages.push({
|
|
3049
|
-
role: "tool",
|
|
3050
|
-
content: [
|
|
3051
|
-
{
|
|
3052
|
-
type: "tool_result",
|
|
3053
|
-
content: JSON.stringify({ error: error instanceof Error ? error.message : "Unknown error" }),
|
|
3054
|
-
tool_use_id: toolCall.id
|
|
3055
|
-
}
|
|
3056
|
-
]
|
|
3057
|
-
});
|
|
3058
3078
|
}
|
|
3079
|
+
await callback(["\n\n"], { toolsUsed });
|
|
3080
|
+
await this.complete(modelName, messages, options, callback, toolsUsed);
|
|
3081
|
+
} else {
|
|
3082
|
+
console.log("[DEBUG] Gemini executeTools=false, passing tool calls to callback");
|
|
3083
|
+
await callback([null], { toolsUsed });
|
|
3059
3084
|
}
|
|
3060
|
-
await callback(["\n\n"], { toolsUsed });
|
|
3061
|
-
await this.complete(modelName, messages, options, callback, toolsUsed);
|
|
3062
3085
|
return;
|
|
3063
3086
|
}
|
|
3064
3087
|
} catch (error) {
|
|
@@ -3096,58 +3119,63 @@ var GeminiBackend = class {
|
|
|
3096
3119
|
}
|
|
3097
3120
|
if (!options.stream && toolCalls.length > 0 && options.tools?.length) {
|
|
3098
3121
|
console.log("[DEBUG] Gemini executing tools (non-streaming mode):", toolCalls.map((tc) => tc.name));
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
const
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
await
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3122
|
+
if (options.executeTools !== false) {
|
|
3123
|
+
const assistantMessage = {
|
|
3124
|
+
role: "assistant",
|
|
3125
|
+
content: toolCalls.map((toolCall, index) => ({
|
|
3126
|
+
type: "tool_use",
|
|
3127
|
+
id: toolCall.id,
|
|
3128
|
+
name: toolCall.name,
|
|
3129
|
+
input: toolCall.parameters,
|
|
3130
|
+
// Only first tool call gets thought_signature (Gemini 3 requirement for parallel calls)
|
|
3131
|
+
thought_signature: index === 0 ? toolCall.thought_signature : void 0
|
|
3132
|
+
}))
|
|
3133
|
+
};
|
|
3134
|
+
messages.push(assistantMessage);
|
|
3135
|
+
for (const toolCall of toolCalls) {
|
|
3136
|
+
const toolFn = options.tools.find((tool) => tool.toolSchema.name === toolCall.name)?.toolFn;
|
|
3137
|
+
if (!toolFn) {
|
|
3138
|
+
console.warn(`[WARN] Tool ${toolCall.name} not found`);
|
|
3139
|
+
continue;
|
|
3140
|
+
}
|
|
3141
|
+
try {
|
|
3142
|
+
const result = await toolFn(toolCall.parameters);
|
|
3143
|
+
await handleToolResultStreaming(toolCall.name, result, async (results) => {
|
|
3144
|
+
await callback(results, { toolsUsed });
|
|
3145
|
+
});
|
|
3146
|
+
messages.push({
|
|
3147
|
+
role: "tool",
|
|
3148
|
+
content: [
|
|
3149
|
+
{
|
|
3150
|
+
type: "tool_result",
|
|
3151
|
+
content: JSON.stringify({ result }),
|
|
3152
|
+
tool_use_id: toolCall.id
|
|
3153
|
+
}
|
|
3154
|
+
]
|
|
3155
|
+
});
|
|
3156
|
+
} catch (error) {
|
|
3157
|
+
if (error instanceof PermissionDeniedError) {
|
|
3158
|
+
throw error;
|
|
3159
|
+
}
|
|
3160
|
+
console.error(`[ERROR] Error executing tool ${toolCall.name}:`, error);
|
|
3161
|
+
messages.push({
|
|
3162
|
+
role: "tool",
|
|
3163
|
+
content: [
|
|
3164
|
+
{
|
|
3165
|
+
type: "tool_result",
|
|
3166
|
+
content: JSON.stringify({ error: error instanceof Error ? error.message : "Unknown error" }),
|
|
3167
|
+
tool_use_id: toolCall.id
|
|
3168
|
+
}
|
|
3169
|
+
]
|
|
3170
|
+
});
|
|
3135
3171
|
}
|
|
3136
|
-
console.error(`[ERROR] Error executing tool ${toolCall.name}:`, error);
|
|
3137
|
-
messages.push({
|
|
3138
|
-
role: "tool",
|
|
3139
|
-
content: [
|
|
3140
|
-
{
|
|
3141
|
-
type: "tool_result",
|
|
3142
|
-
content: JSON.stringify({ error: error instanceof Error ? error.message : "Unknown error" }),
|
|
3143
|
-
tool_use_id: toolCall.id
|
|
3144
|
-
}
|
|
3145
|
-
]
|
|
3146
|
-
});
|
|
3147
3172
|
}
|
|
3173
|
+
await callback(["\n\n"], { toolsUsed });
|
|
3174
|
+
await this.complete(modelName, messages, options, callback, toolsUsed);
|
|
3175
|
+
} else {
|
|
3176
|
+
console.log("[DEBUG] Gemini executeTools=false, passing tool calls to callback");
|
|
3177
|
+
await callback([null], { toolsUsed });
|
|
3148
3178
|
}
|
|
3149
|
-
await callback(["\n\n"], { toolsUsed });
|
|
3150
|
-
await this.complete(modelName, messages, options, callback, toolsUsed);
|
|
3151
3179
|
}
|
|
3152
3180
|
}
|
|
3153
3181
|
formatMessagesIntoGeminiContent(messages) {
|
|
@@ -4584,67 +4612,83 @@ var XAIBackend = class {
|
|
|
4584
4612
|
}
|
|
4585
4613
|
if (c.message.tool_calls && c.message.tool_calls.length > 0) {
|
|
4586
4614
|
for (const toolCall of c.message.tool_calls) {
|
|
4587
|
-
if (toolCall.type !== "function")
|
|
4615
|
+
if (toolCall.type !== "function")
|
|
4588
4616
|
continue;
|
|
4589
|
-
|
|
4590
|
-
const toolFn = options.tools?.find((tool) => tool.toolSchema.name === toolCall.function.name)?.toolFn;
|
|
4591
|
-
if (toolFn && toolCall.function.arguments) {
|
|
4617
|
+
if (toolCall.function.arguments) {
|
|
4592
4618
|
toolsUsed.push({
|
|
4593
4619
|
name: toolCall.function.name,
|
|
4594
4620
|
arguments: toolCall.function.arguments
|
|
4595
4621
|
});
|
|
4596
|
-
|
|
4597
|
-
|
|
4598
|
-
|
|
4599
|
-
|
|
4600
|
-
|
|
4601
|
-
|
|
4602
|
-
|
|
4603
|
-
|
|
4604
|
-
|
|
4605
|
-
|
|
4606
|
-
|
|
4607
|
-
|
|
4608
|
-
|
|
4609
|
-
|
|
4610
|
-
|
|
4611
|
-
|
|
4612
|
-
|
|
4613
|
-
|
|
4614
|
-
|
|
4615
|
-
|
|
4616
|
-
|
|
4617
|
-
|
|
4618
|
-
|
|
4619
|
-
|
|
4620
|
-
|
|
4621
|
-
|
|
4622
|
-
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
|
|
4626
|
-
|
|
4627
|
-
|
|
4628
|
-
|
|
4629
|
-
}
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
|
|
4636
|
-
|
|
4637
|
-
|
|
4638
|
-
|
|
4639
|
-
|
|
4640
|
-
|
|
4641
|
-
|
|
4642
|
-
|
|
4643
|
-
|
|
4622
|
+
}
|
|
4623
|
+
}
|
|
4624
|
+
if (options.executeTools !== false) {
|
|
4625
|
+
for (const toolCall of c.message.tool_calls) {
|
|
4626
|
+
if (toolCall.type !== "function") {
|
|
4627
|
+
continue;
|
|
4628
|
+
}
|
|
4629
|
+
const toolFn = options.tools?.find((tool) => tool.toolSchema.name === toolCall.function.name)?.toolFn;
|
|
4630
|
+
if (toolFn && toolCall.function.arguments) {
|
|
4631
|
+
try {
|
|
4632
|
+
const parsedParams = JSON.parse(toolCall.function.arguments);
|
|
4633
|
+
const result = await toolFn(parsedParams);
|
|
4634
|
+
this.pushToolMessages(messages, {
|
|
4635
|
+
id: toolCall.id,
|
|
4636
|
+
name: toolCall.function.name,
|
|
4637
|
+
parameters: toolCall.function.arguments
|
|
4638
|
+
}, result.toString());
|
|
4639
|
+
const isMcpTool = options.tools?.find((t) => t.toolSchema.name === toolCall.function.name)?._isMcpTool;
|
|
4640
|
+
if (isMcpTool) {
|
|
4641
|
+
await this.complete(model, messages, {
|
|
4642
|
+
...options,
|
|
4643
|
+
_internal: {
|
|
4644
|
+
toolCallCount: toolCallCount + 1
|
|
4645
|
+
}
|
|
4646
|
+
}, callback, toolsUsed);
|
|
4647
|
+
} else {
|
|
4648
|
+
await this.complete(model, messages, {
|
|
4649
|
+
...options,
|
|
4650
|
+
tools: void 0,
|
|
4651
|
+
_internal: void 0
|
|
4652
|
+
}, callback, toolsUsed);
|
|
4653
|
+
}
|
|
4654
|
+
return;
|
|
4655
|
+
} catch (error) {
|
|
4656
|
+
if (error instanceof PermissionDeniedError) {
|
|
4657
|
+
throw error;
|
|
4658
|
+
}
|
|
4659
|
+
console.warn(`Error processing ${toolCall.function.name} tool:`, error);
|
|
4660
|
+
this.pushToolMessages(messages, {
|
|
4661
|
+
id: toolCall.id,
|
|
4662
|
+
name: toolCall.function.name,
|
|
4663
|
+
parameters: toolCall.function.arguments
|
|
4664
|
+
}, `Error: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
4665
|
+
const isMcpToolError = options.tools?.find((t) => t.toolSchema.name === toolCall.function.name)?._isMcpTool;
|
|
4666
|
+
if (isMcpToolError) {
|
|
4667
|
+
await this.complete(model, messages, {
|
|
4668
|
+
...options,
|
|
4669
|
+
_internal: {
|
|
4670
|
+
toolCallCount: toolCallCount + 1
|
|
4671
|
+
}
|
|
4672
|
+
}, callback, toolsUsed);
|
|
4673
|
+
} else {
|
|
4674
|
+
await this.complete(model, messages, {
|
|
4675
|
+
...options,
|
|
4676
|
+
tools: void 0,
|
|
4677
|
+
_internal: void 0
|
|
4678
|
+
}, callback, toolsUsed);
|
|
4679
|
+
}
|
|
4680
|
+
return;
|
|
4644
4681
|
}
|
|
4645
|
-
return;
|
|
4646
4682
|
}
|
|
4647
4683
|
}
|
|
4684
|
+
} else {
|
|
4685
|
+
this.logger.debug(`[Tool Execution] executeTools=false, passing tool calls to callback`);
|
|
4686
|
+
await callback([null], {
|
|
4687
|
+
inputTokens: 0,
|
|
4688
|
+
outputTokens: 0,
|
|
4689
|
+
toolsUsed: toolsUsed.length > 0 ? toolsUsed : void 0
|
|
4690
|
+
});
|
|
4691
|
+
return;
|
|
4648
4692
|
}
|
|
4649
4693
|
} else {
|
|
4650
4694
|
streamedText[c.index] = c.message.content || "";
|
|
@@ -4700,43 +4744,57 @@ var XAIBackend = class {
|
|
|
4700
4744
|
}
|
|
4701
4745
|
if (func.length > 0) {
|
|
4702
4746
|
for await (const tool of func) {
|
|
4703
|
-
const {
|
|
4704
|
-
|
|
4705
|
-
|
|
4706
|
-
|
|
4707
|
-
|
|
4708
|
-
|
|
4709
|
-
|
|
4710
|
-
|
|
4711
|
-
|
|
4712
|
-
|
|
4713
|
-
|
|
4714
|
-
|
|
4715
|
-
|
|
4716
|
-
|
|
4717
|
-
|
|
4718
|
-
|
|
4719
|
-
|
|
4720
|
-
|
|
4721
|
-
|
|
4722
|
-
|
|
4723
|
-
|
|
4724
|
-
|
|
4725
|
-
|
|
4726
|
-
|
|
4727
|
-
|
|
4728
|
-
|
|
4747
|
+
const { name, parameters: parameters2 } = tool;
|
|
4748
|
+
if (name && parameters2) {
|
|
4749
|
+
toolsUsed.push({
|
|
4750
|
+
name,
|
|
4751
|
+
arguments: parameters2
|
|
4752
|
+
});
|
|
4753
|
+
}
|
|
4754
|
+
}
|
|
4755
|
+
if (options.executeTools !== false) {
|
|
4756
|
+
for await (const tool of func) {
|
|
4757
|
+
const { id, name, parameters: parameters2 } = tool;
|
|
4758
|
+
const toolFn = options.tools?.find((tool2) => tool2.toolSchema.name === name)?.toolFn;
|
|
4759
|
+
if (id && name && parameters2 && toolFn) {
|
|
4760
|
+
try {
|
|
4761
|
+
const result = await toolFn(JSON.parse(parameters2));
|
|
4762
|
+
this.pushToolMessages(messages, {
|
|
4763
|
+
id,
|
|
4764
|
+
name,
|
|
4765
|
+
parameters: parameters2
|
|
4766
|
+
}, result);
|
|
4767
|
+
} catch (error) {
|
|
4768
|
+
if (error instanceof PermissionDeniedError) {
|
|
4769
|
+
throw error;
|
|
4770
|
+
}
|
|
4771
|
+
this.logger.updateMetadata({
|
|
4772
|
+
tool: name,
|
|
4773
|
+
parameters: parameters2
|
|
4774
|
+
});
|
|
4775
|
+
if (error instanceof SyntaxError && /JSON/.test(error.message)) {
|
|
4776
|
+
this.logger.warn("JSON parse error processing tool parameters:", error);
|
|
4777
|
+
} else {
|
|
4778
|
+
this.logger.error("Error processing tool:", error);
|
|
4779
|
+
}
|
|
4780
|
+
this.pushToolMessages(messages, {
|
|
4781
|
+
id,
|
|
4782
|
+
name,
|
|
4783
|
+
parameters: parameters2
|
|
4784
|
+
}, `Error: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
4785
|
+
continue;
|
|
4729
4786
|
}
|
|
4730
|
-
this.pushToolMessages(messages, {
|
|
4731
|
-
id,
|
|
4732
|
-
name,
|
|
4733
|
-
parameters: parameters2
|
|
4734
|
-
}, `Error: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
4735
|
-
continue;
|
|
4736
4787
|
}
|
|
4737
4788
|
}
|
|
4789
|
+
await this.complete(model, messages, { ...options, tools: options.tools }, callback, toolsUsed);
|
|
4790
|
+
} else {
|
|
4791
|
+
this.logger.debug(`[Tool Execution] executeTools=false, passing tool calls to callback`);
|
|
4792
|
+
await callback([null], {
|
|
4793
|
+
inputTokens,
|
|
4794
|
+
outputTokens,
|
|
4795
|
+
toolsUsed: toolsUsed.length > 0 ? toolsUsed : void 0
|
|
4796
|
+
});
|
|
4738
4797
|
}
|
|
4739
|
-
await this.complete(model, messages, { ...options, tools: options.tools }, callback, toolsUsed);
|
|
4740
4798
|
}
|
|
4741
4799
|
}
|
|
4742
4800
|
formatMessages(messages) {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import {
|
|
3
3
|
BadRequestError,
|
|
4
4
|
secureParameters
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-EVPT4ARN.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-VVV7WLJ6.js";
|
|
14
14
|
|
|
15
15
|
// ../../b4m-core/packages/services/dist/src/creditService/subtractCredits.js
|
|
16
16
|
import { z } from "zod";
|
|
@@ -3770,6 +3770,7 @@ var AuthEvents;
|
|
|
3770
3770
|
AuthEvents2["RESET_LAND_PASSWORD"] = "Password Reset Landed";
|
|
3771
3771
|
AuthEvents2["RESET_PASSWORD_TOKEN_EXPIRED"] = "Password Reset Token Expired";
|
|
3772
3772
|
AuthEvents2["CHANGE_PASSWORD"] = "Password Changed";
|
|
3773
|
+
AuthEvents2["FORCE_CHANGE_PASSWORD"] = "Forced Password Changed";
|
|
3773
3774
|
AuthEvents2["ADMIN_RESET_PASSWORD"] = "Admin Password Reset";
|
|
3774
3775
|
AuthEvents2["FAILED_LOGIN"] = "Failed Login Attempt";
|
|
3775
3776
|
AuthEvents2["EMAIL_VERIFIED"] = "Email Verified";
|
|
@@ -7,11 +7,11 @@ import {
|
|
|
7
7
|
getSettingsMap,
|
|
8
8
|
getSettingsValue,
|
|
9
9
|
secureParameters
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-EVPT4ARN.js";
|
|
11
11
|
import {
|
|
12
12
|
KnowledgeType,
|
|
13
13
|
SupportedFabFileMimeTypes
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-VVV7WLJ6.js";
|
|
15
15
|
|
|
16
16
|
// ../../b4m-core/packages/services/dist/src/fabFileService/create.js
|
|
17
17
|
import { z } from "zod";
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
import {
|
|
3
3
|
createFabFile,
|
|
4
4
|
createFabFileSchema
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-ZT7Z4QVD.js";
|
|
6
|
+
import "./chunk-EVPT4ARN.js";
|
|
7
7
|
import "./chunk-CC67R4RB.js";
|
|
8
|
-
import "./chunk-
|
|
8
|
+
import "./chunk-VVV7WLJ6.js";
|
|
9
9
|
import "./chunk-PDX44BCA.js";
|
|
10
10
|
export {
|
|
11
11
|
createFabFile,
|