@bike4mind/cli 0.2.37 → 0.2.38-add-notebook-project-fixes.20160
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-QIDCYO4J.js → artifactExtractor-Z6UQO2IR.js} +1 -1
- package/dist/{chunk-AOP6RYDY.js → chunk-5APQNY55.js} +2 -2
- package/dist/{chunk-LJG44UT3.js → chunk-AU7OYPU4.js} +2 -2
- package/dist/{chunk-FACWWYF7.js → chunk-F4TQZA4G.js} +6 -6
- package/dist/{chunk-H7RVLAQD.js → chunk-HJVFUXVX.js} +1 -1
- package/dist/{chunk-NJQYWIDJ.js → chunk-J3YSVA6W.js} +2 -2
- package/dist/{chunk-EY65E4W4.js → chunk-OCFOJXLA.js} +39 -11
- package/dist/{chunk-5YLGNW2B.js → chunk-QCDYXXSD.js} +163 -54
- package/dist/{chunk-XIB66EG7.js → chunk-XBAC2O32.js} +298 -94
- package/dist/commands/doctorCommand.js +1 -1
- package/dist/commands/headlessCommand.js +20 -18
- package/dist/commands/mcpCommand.js +2 -2
- package/dist/commands/updateCommand.js +1 -1
- package/dist/{create-IFIWNV4T.js → create-MVD65MYF.js} +3 -3
- package/dist/index.js +54 -35
- package/dist/{llmMarkdownGenerator-7D3C33BP.js → llmMarkdownGenerator-MEEKZGSS.js} +1 -1
- package/dist/{markdownGenerator-C2QW7FBH.js → markdownGenerator-NKNJTN6H.js} +1 -1
- package/dist/{mementoService-ABCCDW6T.js → mementoService-QPAN6H6A.js} +3 -3
- package/dist/{src-ZPD2SIIU.js → src-I44AUY66.js} +11 -1
- package/dist/{src-D6KSYF2W.js → src-UJ7SX2X5.js} +2 -2
- package/dist/{subtractCredits-QKF6HTX3.js → subtractCredits-K56NLITN.js} +3 -3
- package/package.json +6 -6
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
CurationArtifactType
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-OCFOJXLA.js";
|
|
5
5
|
|
|
6
6
|
// ../../b4m-core/packages/services/dist/src/notebookCurationService/artifactExtractor.js
|
|
7
7
|
var ARTIFACT_TAG_REGEX = /<artifact\s+(.*?)>([\s\S]*?)<\/artifact>/gi;
|
|
@@ -7,11 +7,11 @@ import {
|
|
|
7
7
|
getSettingsMap,
|
|
8
8
|
getSettingsValue,
|
|
9
9
|
secureParameters
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-QCDYXXSD.js";
|
|
11
11
|
import {
|
|
12
12
|
KnowledgeType,
|
|
13
13
|
SupportedFabFileMimeTypes
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-OCFOJXLA.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-QCDYXXSD.js";
|
|
6
6
|
import {
|
|
7
7
|
CompletionApiUsageTransaction,
|
|
8
8
|
GenericCreditDeductTransaction,
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
ToolUsageTransaction,
|
|
14
14
|
TransferCreditTransaction,
|
|
15
15
|
VideoGenerationUsageTransaction
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-OCFOJXLA.js";
|
|
17
17
|
|
|
18
18
|
// ../../b4m-core/packages/services/dist/src/creditService/subtractCredits.js
|
|
19
19
|
import { z } from "zod";
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// package.json
|
|
4
4
|
var package_default = {
|
|
5
5
|
name: "@bike4mind/cli",
|
|
6
|
-
version: "0.2.
|
|
6
|
+
version: "0.2.38-add-notebook-project-fixes.20160+6312c53db",
|
|
7
7
|
type: "module",
|
|
8
8
|
description: "Interactive CLI tool for Bike4Mind with ReAct agents",
|
|
9
9
|
license: "UNLICENSED",
|
|
@@ -117,10 +117,10 @@ var package_default = {
|
|
|
117
117
|
},
|
|
118
118
|
devDependencies: {
|
|
119
119
|
"@bike4mind/agents": "0.1.0",
|
|
120
|
-
"@bike4mind/common": "2.58.
|
|
121
|
-
"@bike4mind/mcp": "1.32.
|
|
122
|
-
"@bike4mind/services": "2.54.
|
|
123
|
-
"@bike4mind/utils": "2.11.
|
|
120
|
+
"@bike4mind/common": "2.58.1-add-notebook-project-fixes.20160+6312c53db",
|
|
121
|
+
"@bike4mind/mcp": "1.32.6-add-notebook-project-fixes.20160+6312c53db",
|
|
122
|
+
"@bike4mind/services": "2.54.2-add-notebook-project-fixes.20160+6312c53db",
|
|
123
|
+
"@bike4mind/utils": "2.11.1-add-notebook-project-fixes.20160+6312c53db",
|
|
124
124
|
"@types/better-sqlite3": "^7.6.13",
|
|
125
125
|
"@types/diff": "^5.0.9",
|
|
126
126
|
"@types/jsonwebtoken": "^9.0.4",
|
|
@@ -138,7 +138,7 @@ var package_default = {
|
|
|
138
138
|
optionalDependencies: {
|
|
139
139
|
"@vscode/ripgrep": "^1.17.0"
|
|
140
140
|
},
|
|
141
|
-
gitHead: "
|
|
141
|
+
gitHead: "6312c53db7d33ec00d8d5c85e4c7d04177fbf7f0"
|
|
142
142
|
};
|
|
143
143
|
|
|
144
144
|
// src/utils/updateChecker.ts
|
|
@@ -6,12 +6,12 @@ import {
|
|
|
6
6
|
getSettingsByNames,
|
|
7
7
|
obfuscateApiKey,
|
|
8
8
|
secureParameters
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-QCDYXXSD.js";
|
|
10
10
|
import {
|
|
11
11
|
ApiKeyType,
|
|
12
12
|
MementoTier,
|
|
13
13
|
isSupportedEmbeddingModel
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-OCFOJXLA.js";
|
|
15
15
|
|
|
16
16
|
// ../../b4m-core/packages/services/dist/src/apiKeyService/get.js
|
|
17
17
|
import { z } from "zod";
|
|
@@ -641,6 +641,7 @@ var CollectionType;
|
|
|
641
641
|
CollectionType2["PROJECT"] = "project";
|
|
642
642
|
CollectionType2["AI_IMAGE"] = "ai_image";
|
|
643
643
|
})(CollectionType || (CollectionType = {}));
|
|
644
|
+
var ROTATABLE_INTEGRATIONS = ["github", "atlassian", "slack"];
|
|
644
645
|
|
|
645
646
|
// ../../b4m-core/packages/common/dist/src/types/entities/UserApiKeyTypes.js
|
|
646
647
|
var ApiKeyScope;
|
|
@@ -1130,6 +1131,17 @@ var JiraWebhookDeliveryStatus;
|
|
|
1130
1131
|
JiraWebhookDeliveryStatus2["Pending"] = "pending";
|
|
1131
1132
|
})(JiraWebhookDeliveryStatus || (JiraWebhookDeliveryStatus = {}));
|
|
1132
1133
|
|
|
1134
|
+
// ../../b4m-core/packages/common/dist/src/types/entities/SystemPromptTypes.js
|
|
1135
|
+
var AdminSystemPromptCategory;
|
|
1136
|
+
(function(AdminSystemPromptCategory2) {
|
|
1137
|
+
AdminSystemPromptCategory2["SYSTEM"] = "system";
|
|
1138
|
+
AdminSystemPromptCategory2["ADMIN"] = "admin";
|
|
1139
|
+
AdminSystemPromptCategory2["AUTOMATION"] = "automation";
|
|
1140
|
+
AdminSystemPromptCategory2["VOICE"] = "voice";
|
|
1141
|
+
AdminSystemPromptCategory2["QUANTUM"] = "quantum";
|
|
1142
|
+
AdminSystemPromptCategory2["SALES_INTELLIGENCE"] = "sales_intelligence";
|
|
1143
|
+
})(AdminSystemPromptCategory || (AdminSystemPromptCategory = {}));
|
|
1144
|
+
|
|
1133
1145
|
// ../../b4m-core/packages/common/dist/src/types/common.js
|
|
1134
1146
|
var SupportedFabFileMimeTypes;
|
|
1135
1147
|
(function(SupportedFabFileMimeTypes2) {
|
|
@@ -5780,6 +5792,7 @@ var LinkedInApi = class {
|
|
|
5780
5792
|
};
|
|
5781
5793
|
|
|
5782
5794
|
// ../../b4m-core/packages/common/dist/src/rateLimitHeaders.js
|
|
5795
|
+
var RATE_LIMIT_INTEGRATIONS = ["github", "jira", "confluence", "slack"];
|
|
5783
5796
|
function getHeader(headers, name) {
|
|
5784
5797
|
if (!headers || typeof headers !== "object")
|
|
5785
5798
|
return null;
|
|
@@ -5828,16 +5841,24 @@ function parseRateLimitHeaders(headers) {
|
|
|
5828
5841
|
}
|
|
5829
5842
|
}
|
|
5830
5843
|
let usagePercent = null;
|
|
5831
|
-
if (limit !== null && limit > 0 && remaining !== null) {
|
|
5844
|
+
if (limit !== null && limit > 0 && remaining !== null && remaining >= 0) {
|
|
5832
5845
|
usagePercent = Math.round((limit - remaining) / limit * 100);
|
|
5833
5846
|
}
|
|
5834
5847
|
return { limit, remaining, resetAt, retryAfterMs, usagePercent };
|
|
5835
5848
|
}
|
|
5849
|
+
function hasRateLimitInfo(info) {
|
|
5850
|
+
return info.limit !== null || info.remaining !== null || info.retryAfterMs !== null;
|
|
5851
|
+
}
|
|
5836
5852
|
function isNearLimit(info, thresholdPercent = 80) {
|
|
5837
5853
|
if (info.usagePercent === null)
|
|
5838
5854
|
return false;
|
|
5839
5855
|
return info.usagePercent >= thresholdPercent;
|
|
5840
5856
|
}
|
|
5857
|
+
function normalizeEndpoint(endpoint) {
|
|
5858
|
+
if (!endpoint || !endpoint.includes("/"))
|
|
5859
|
+
return endpoint;
|
|
5860
|
+
return endpoint.replace(/\/[A-Z][A-Z0-9]+-\d+/g, "/{key}").replace(/\/\d+/g, "/{id}").replace(/\/repos\/[^/]+\/[^/]+/, "/repos/{owner}/{repo}");
|
|
5861
|
+
}
|
|
5841
5862
|
function buildRateLimitLogEntry(integration, endpoint, info, wasThrottled = false) {
|
|
5842
5863
|
return {
|
|
5843
5864
|
type: wasThrottled ? "RATE_LIMIT_ERROR" : "RATE_LIMIT",
|
|
@@ -6108,16 +6129,17 @@ var ConfluenceApi = class {
|
|
|
6108
6129
|
body: options.body ? JSON.stringify(options.body) : void 0
|
|
6109
6130
|
});
|
|
6110
6131
|
const rateLimitInfo = parseRateLimitHeaders(response.headers);
|
|
6111
|
-
if (rateLimitInfo
|
|
6132
|
+
if (hasRateLimitInfo(rateLimitInfo)) {
|
|
6112
6133
|
const logEntry = buildRateLimitLogEntry("confluence", path, rateLimitInfo);
|
|
6113
6134
|
console.error(JSON.stringify(logEntry));
|
|
6114
|
-
|
|
6115
|
-
|
|
6116
|
-
|
|
6135
|
+
if (isNearLimit(rateLimitInfo)) {
|
|
6136
|
+
console.error(`[Confluence] Rate limit warning: ${rateLimitInfo.usagePercent}% used (${rateLimitInfo.remaining}/${rateLimitInfo.limit} remaining)`);
|
|
6137
|
+
}
|
|
6117
6138
|
}
|
|
6118
6139
|
if (response.status === 429 && (options._retryCount ?? 0) < 1) {
|
|
6119
6140
|
const retryAfterMs = rateLimitInfo.retryAfterMs ?? 5e3;
|
|
6120
|
-
const
|
|
6141
|
+
const jitterMs = Math.floor(Math.random() * 1e3);
|
|
6142
|
+
const delayMs = Math.min(retryAfterMs + jitterMs, 1e4);
|
|
6121
6143
|
const logEntry = buildRateLimitLogEntry("confluence", path, rateLimitInfo, true);
|
|
6122
6144
|
console.error(JSON.stringify(logEntry));
|
|
6123
6145
|
console.error(`[Confluence] Rate limited on ${path}, retrying after ${delayMs}ms`);
|
|
@@ -8327,16 +8349,17 @@ var JiraApi = class {
|
|
|
8327
8349
|
body: options.body ? JSON.stringify(options.body) : void 0
|
|
8328
8350
|
});
|
|
8329
8351
|
const rateLimitInfo = parseRateLimitHeaders(response.headers);
|
|
8330
|
-
if (rateLimitInfo
|
|
8352
|
+
if (hasRateLimitInfo(rateLimitInfo)) {
|
|
8331
8353
|
const logEntry = buildRateLimitLogEntry("jira", path, rateLimitInfo);
|
|
8332
8354
|
console.error(JSON.stringify(logEntry));
|
|
8333
|
-
|
|
8334
|
-
|
|
8335
|
-
|
|
8355
|
+
if (isNearLimit(rateLimitInfo)) {
|
|
8356
|
+
console.error(`[Jira] Rate limit warning: ${rateLimitInfo.usagePercent}% used (${rateLimitInfo.remaining}/${rateLimitInfo.limit} remaining)`);
|
|
8357
|
+
}
|
|
8336
8358
|
}
|
|
8337
8359
|
if (response.status === 429 && (options._retryCount ?? 0) < 1) {
|
|
8338
8360
|
const retryAfterMs = rateLimitInfo.retryAfterMs ?? 5e3;
|
|
8339
|
-
const
|
|
8361
|
+
const jitterMs = Math.floor(Math.random() * 1e3);
|
|
8362
|
+
const delayMs = Math.min(retryAfterMs + jitterMs, 1e4);
|
|
8340
8363
|
const logEntry = buildRateLimitLogEntry("jira", path, rateLimitInfo, true);
|
|
8341
8364
|
console.error(JSON.stringify(logEntry));
|
|
8342
8365
|
console.error(`[Jira] Rate limited on ${path}, retrying after ${delayMs}ms`);
|
|
@@ -10418,6 +10441,7 @@ export {
|
|
|
10418
10441
|
shareableDocumentSchema,
|
|
10419
10442
|
DefaultLLMParams,
|
|
10420
10443
|
CollectionType,
|
|
10444
|
+
ROTATABLE_INTEGRATIONS,
|
|
10421
10445
|
ApiKeyScope,
|
|
10422
10446
|
ApiKeyStatus,
|
|
10423
10447
|
MementoTier,
|
|
@@ -10473,6 +10497,7 @@ export {
|
|
|
10473
10497
|
WebhookAuditStatus,
|
|
10474
10498
|
COMMON_JIRA_WEBHOOK_EVENTS,
|
|
10475
10499
|
JiraWebhookDeliveryStatus,
|
|
10500
|
+
AdminSystemPromptCategory,
|
|
10476
10501
|
SupportedFabFileMimeTypes,
|
|
10477
10502
|
REASONING_EFFORT_LABELS,
|
|
10478
10503
|
REASONING_EFFORT_DESCRIPTIONS,
|
|
@@ -10693,8 +10718,11 @@ export {
|
|
|
10693
10718
|
extractSnippetMeta,
|
|
10694
10719
|
searchSchema,
|
|
10695
10720
|
LinkedInApi,
|
|
10721
|
+
RATE_LIMIT_INTEGRATIONS,
|
|
10696
10722
|
parseRateLimitHeaders,
|
|
10723
|
+
hasRateLimitInfo,
|
|
10697
10724
|
isNearLimit,
|
|
10725
|
+
normalizeEndpoint,
|
|
10698
10726
|
buildRateLimitLogEntry,
|
|
10699
10727
|
RESTRICTION_OPERATIONS,
|
|
10700
10728
|
RESTRICTION_SUBJECT_TYPES,
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
dayjsConfig_default,
|
|
20
20
|
extractSnippetMeta,
|
|
21
21
|
settingsMap
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-OCFOJXLA.js";
|
|
23
23
|
|
|
24
24
|
// ../../b4m-core/packages/utils/dist/src/storage/S3Storage.js
|
|
25
25
|
import { S3Client, PutObjectCommand, DeleteObjectCommand, GetObjectCommand, HeadObjectCommand } from "@aws-sdk/client-s3";
|
|
@@ -2995,7 +2995,7 @@ IMPORTANT! Only when someone asks, remember that you are specifically the ${mode
|
|
|
2995
2995
|
const modelInfo = await this.getModelInfo();
|
|
2996
2996
|
const currentModelInfo = modelInfo.find((m) => m.id === model);
|
|
2997
2997
|
if (currentModelInfo?.can_think) {
|
|
2998
|
-
if (options.thinking?.enabled
|
|
2998
|
+
if (options.thinking?.enabled === true) {
|
|
2999
2999
|
const thinkingBudget = options.thinking?.budget_tokens ?? 16e3;
|
|
3000
3000
|
apiParams.max_tokens = Math.max(apiParams.max_tokens ?? 4096, thinkingBudget + 1e3);
|
|
3001
3001
|
apiParams.temperature = 1;
|
|
@@ -3547,13 +3547,27 @@ IMPORTANT! Only when someone asks, remember that you are specifically the ${mode
|
|
|
3547
3547
|
};
|
|
3548
3548
|
});
|
|
3549
3549
|
}
|
|
3550
|
-
pushToolMessages(messages, tool, result,
|
|
3550
|
+
pushToolMessages(messages, tool, result, thinkingBlocks) {
|
|
3551
3551
|
if (this.isThinkingEnabled && this.lastAssistantContent.length > 0) {
|
|
3552
3552
|
messages.push({
|
|
3553
3553
|
role: "assistant",
|
|
3554
3554
|
content: this.lastAssistantContent
|
|
3555
3555
|
});
|
|
3556
3556
|
this.logger.debug(`[AnthropicBackend] Including ${this.lastAssistantContent.length} content blocks (thinking + tool_use) in assistant message`);
|
|
3557
|
+
} else if (thinkingBlocks && thinkingBlocks.length > 0) {
|
|
3558
|
+
messages.push({
|
|
3559
|
+
role: "assistant",
|
|
3560
|
+
content: [
|
|
3561
|
+
...thinkingBlocks,
|
|
3562
|
+
{
|
|
3563
|
+
type: "tool_use",
|
|
3564
|
+
id: tool.id,
|
|
3565
|
+
name: tool.name,
|
|
3566
|
+
input: JSON.parse(tool.parameters || "{}")
|
|
3567
|
+
}
|
|
3568
|
+
]
|
|
3569
|
+
});
|
|
3570
|
+
this.logger.debug(`[AnthropicBackend] Including ${thinkingBlocks.length} explicit thinking blocks in assistant message`);
|
|
3557
3571
|
} else {
|
|
3558
3572
|
messages.push({
|
|
3559
3573
|
role: "assistant",
|
|
@@ -3700,6 +3714,9 @@ var AWSBackend = class {
|
|
|
3700
3714
|
this.currentModel = model;
|
|
3701
3715
|
throw new Error("AWSBackend does not support text completion, only speech-to-text transcription");
|
|
3702
3716
|
}
|
|
3717
|
+
pushToolMessages(_messages, _tool, _result) {
|
|
3718
|
+
throw new Error("AWSBackend does not support tool messages");
|
|
3719
|
+
}
|
|
3703
3720
|
async getModelInfo() {
|
|
3704
3721
|
return [
|
|
3705
3722
|
{
|
|
@@ -4351,7 +4368,7 @@ ${modelIdentity}` : modelIdentity;
|
|
|
4351
4368
|
}
|
|
4352
4369
|
const supportsThinking = model.includes("claude-3-7") || model.includes("claude-opus-4") || model.includes("claude-sonnet-4");
|
|
4353
4370
|
if (supportsThinking) {
|
|
4354
|
-
if (options.thinking?.enabled
|
|
4371
|
+
if (options.thinking?.enabled === true) {
|
|
4355
4372
|
const thinkingBudget = options.thinking?.budget_tokens ?? 16e3;
|
|
4356
4373
|
body.max_tokens = Math.max(maxTokens, thinkingBudget + 1e3);
|
|
4357
4374
|
body.temperature = 1;
|
|
@@ -4604,18 +4621,17 @@ ${modelIdentity}` : modelIdentity;
|
|
|
4604
4621
|
};
|
|
4605
4622
|
});
|
|
4606
4623
|
}
|
|
4607
|
-
pushToolMessages(messages, tool, result) {
|
|
4608
|
-
const
|
|
4609
|
-
|
|
4610
|
-
|
|
4611
|
-
|
|
4612
|
-
|
|
4613
|
-
|
|
4614
|
-
|
|
4615
|
-
];
|
|
4624
|
+
pushToolMessages(messages, tool, result, thinkingBlocks) {
|
|
4625
|
+
const toolUseBlock = {
|
|
4626
|
+
type: "tool_use",
|
|
4627
|
+
id: tool.id,
|
|
4628
|
+
name: tool.name,
|
|
4629
|
+
input: JSON.parse(tool.parameters || "{}")
|
|
4630
|
+
};
|
|
4631
|
+
const assistantContent = thinkingBlocks && thinkingBlocks.length > 0 ? [...thinkingBlocks, toolUseBlock] : [toolUseBlock];
|
|
4616
4632
|
messages.push({
|
|
4617
4633
|
role: "assistant",
|
|
4618
|
-
content:
|
|
4634
|
+
content: assistantContent
|
|
4619
4635
|
});
|
|
4620
4636
|
messages.push({
|
|
4621
4637
|
role: "user",
|
|
@@ -4817,7 +4833,7 @@ ${finalResponse}`;
|
|
|
4817
4833
|
translateStreamChunk(model, chunk) {
|
|
4818
4834
|
return this.translateChunk(model, chunk);
|
|
4819
4835
|
}
|
|
4820
|
-
pushToolMessages(messages, _tool, _result) {
|
|
4836
|
+
pushToolMessages(messages, _tool, _result, _thinkingBlocks) {
|
|
4821
4837
|
return messages;
|
|
4822
4838
|
}
|
|
4823
4839
|
};
|
|
@@ -4922,7 +4938,7 @@ ${m.content}
|
|
|
4922
4938
|
}
|
|
4923
4939
|
};
|
|
4924
4940
|
}
|
|
4925
|
-
pushToolMessages(_messages, _tool, _result) {
|
|
4941
|
+
pushToolMessages(_messages, _tool, _result, _thinkingBlocks) {
|
|
4926
4942
|
throw new Error("Bedrock JurassicTwo: pushToolMessages not yet supported.");
|
|
4927
4943
|
}
|
|
4928
4944
|
};
|
|
@@ -5089,7 +5105,7 @@ var LlamaBedrockBackend = class extends BaseBedrockBackend {
|
|
|
5089
5105
|
}
|
|
5090
5106
|
};
|
|
5091
5107
|
}
|
|
5092
|
-
pushToolMessages(messages, _tool, _result) {
|
|
5108
|
+
pushToolMessages(messages, _tool, _result, _thinkingBlocks) {
|
|
5093
5109
|
return messages;
|
|
5094
5110
|
}
|
|
5095
5111
|
};
|
|
@@ -5250,7 +5266,7 @@ var TitanBedrockBackend = class extends BaseBedrockBackend {
|
|
|
5250
5266
|
}
|
|
5251
5267
|
throw new Error("Bedrock Titan: Unsupported chunk format.");
|
|
5252
5268
|
}
|
|
5253
|
-
pushToolMessages(_messages, _tool, _result) {
|
|
5269
|
+
pushToolMessages(_messages, _tool, _result, _thinkingBlocks) {
|
|
5254
5270
|
throw new Error("Bedrock Titan: push tool messages not supported.");
|
|
5255
5271
|
}
|
|
5256
5272
|
};
|
|
@@ -5278,7 +5294,7 @@ var UndifferentiatedBedrockBackend = class extends BaseBedrockBackend {
|
|
|
5278
5294
|
translateChunk(model, chunk) {
|
|
5279
5295
|
throw new Error("UndifferentiatedBedrockBackend does not support translateChunk");
|
|
5280
5296
|
}
|
|
5281
|
-
pushToolMessages(messages, tool, result) {
|
|
5297
|
+
pushToolMessages(messages, tool, result, _thinkingBlocks) {
|
|
5282
5298
|
throw new Error("UndifferentiatedBedrockBackend does not support pushToolMessages");
|
|
5283
5299
|
}
|
|
5284
5300
|
};
|
|
@@ -5294,6 +5310,9 @@ var BFLBackend = class {
|
|
|
5294
5310
|
this.currentModel = model;
|
|
5295
5311
|
throw new Error("BFLBackend does not support text completion, only image generation");
|
|
5296
5312
|
}
|
|
5313
|
+
pushToolMessages(_messages, _tool, _result, _thinkingBlocks) {
|
|
5314
|
+
throw new Error("BFLBackend does not support tool messages");
|
|
5315
|
+
}
|
|
5297
5316
|
async getModelInfo() {
|
|
5298
5317
|
return [
|
|
5299
5318
|
// BFL Models first - modern, state-of-the-art image generation
|
|
@@ -5479,15 +5498,17 @@ var GeminiBackend = class {
|
|
|
5479
5498
|
} else {
|
|
5480
5499
|
this.logger.warn("[Gemini] Missing thought_signature for tool call:", { toolName });
|
|
5481
5500
|
}
|
|
5501
|
+
const toolId = uuidv4();
|
|
5482
5502
|
toolCalls.push({
|
|
5483
|
-
id:
|
|
5503
|
+
id: toolId,
|
|
5484
5504
|
name: toolName,
|
|
5485
5505
|
parameters: toolArgs,
|
|
5486
5506
|
thought_signature: thoughtSignature
|
|
5487
5507
|
});
|
|
5488
5508
|
toolsUsed.push({
|
|
5489
5509
|
name: toolName,
|
|
5490
|
-
arguments: JSON.stringify(toolArgs)
|
|
5510
|
+
arguments: JSON.stringify(toolArgs),
|
|
5511
|
+
id: toolId
|
|
5491
5512
|
});
|
|
5492
5513
|
}
|
|
5493
5514
|
async getModelInfo() {
|
|
@@ -5862,8 +5883,9 @@ var GeminiBackend = class {
|
|
|
5862
5883
|
description: tool.toolSchema.description,
|
|
5863
5884
|
parameters: {
|
|
5864
5885
|
...params,
|
|
5865
|
-
type: params.type.toUpperCase()
|
|
5886
|
+
type: params.type.toUpperCase(),
|
|
5866
5887
|
// "object" -> "OBJECT"
|
|
5888
|
+
properties: params.properties ? this.sanitizeProperties(params.properties) : params.properties
|
|
5867
5889
|
}
|
|
5868
5890
|
};
|
|
5869
5891
|
})
|
|
@@ -6046,7 +6068,24 @@ var GeminiBackend = class {
|
|
|
6046
6068
|
logCacheStats(this.logger, cacheStats, { streaming: false });
|
|
6047
6069
|
}
|
|
6048
6070
|
}
|
|
6049
|
-
|
|
6071
|
+
const textParts = [];
|
|
6072
|
+
r.candidates?.forEach((candidate) => {
|
|
6073
|
+
candidate.content?.parts?.forEach((part) => {
|
|
6074
|
+
if (part.text) {
|
|
6075
|
+
textParts.push(part.text);
|
|
6076
|
+
}
|
|
6077
|
+
if (part.functionCall) {
|
|
6078
|
+
this.registerToolCall(part.functionCall, part, toolCalls, toolsUsed);
|
|
6079
|
+
}
|
|
6080
|
+
if (part.function_call) {
|
|
6081
|
+
this.registerToolCall(part.function_call, part, toolCalls, toolsUsed);
|
|
6082
|
+
}
|
|
6083
|
+
if (part.name && part.args && !part.text) {
|
|
6084
|
+
this.registerToolCall({ name: part.name, args: part.args }, part, toolCalls, toolsUsed);
|
|
6085
|
+
}
|
|
6086
|
+
});
|
|
6087
|
+
});
|
|
6088
|
+
await callback(textParts.length ? textParts : [], {
|
|
6050
6089
|
inputTokens: r.usageMetadata?.promptTokenCount ?? 0,
|
|
6051
6090
|
outputTokens: r.usageMetadata?.candidatesTokenCount ?? 0,
|
|
6052
6091
|
toolsUsed,
|
|
@@ -6252,12 +6291,80 @@ var GeminiBackend = class {
|
|
|
6252
6291
|
}
|
|
6253
6292
|
];
|
|
6254
6293
|
}
|
|
6294
|
+
/**
|
|
6295
|
+
* Strip JSON Schema fields that Gemini's API doesn't support
|
|
6296
|
+
* (e.g., exclusiveMinimum, exclusiveMaximum, additionalProperties on nested objects).
|
|
6297
|
+
*/
|
|
6298
|
+
sanitizeProperties(properties) {
|
|
6299
|
+
const unsupportedFields = [
|
|
6300
|
+
"exclusiveMinimum",
|
|
6301
|
+
"exclusiveMaximum",
|
|
6302
|
+
"minLength",
|
|
6303
|
+
"maxLength",
|
|
6304
|
+
"pattern",
|
|
6305
|
+
"minItems",
|
|
6306
|
+
"maxItems",
|
|
6307
|
+
"uniqueItems",
|
|
6308
|
+
"additionalProperties",
|
|
6309
|
+
"default",
|
|
6310
|
+
"$schema"
|
|
6311
|
+
];
|
|
6312
|
+
const sanitized = {};
|
|
6313
|
+
for (const [key, value] of Object.entries(properties)) {
|
|
6314
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
6315
|
+
const prop = { ...value };
|
|
6316
|
+
for (const field of unsupportedFields) {
|
|
6317
|
+
delete prop[field];
|
|
6318
|
+
}
|
|
6319
|
+
if (prop.properties && typeof prop.properties === "object") {
|
|
6320
|
+
prop.properties = this.sanitizeProperties(prop.properties);
|
|
6321
|
+
}
|
|
6322
|
+
if (prop.items && typeof prop.items === "object") {
|
|
6323
|
+
const items = { ...prop.items };
|
|
6324
|
+
for (const field of unsupportedFields) {
|
|
6325
|
+
delete items[field];
|
|
6326
|
+
}
|
|
6327
|
+
if (items.properties && typeof items.properties === "object") {
|
|
6328
|
+
items.properties = this.sanitizeProperties(items.properties);
|
|
6329
|
+
}
|
|
6330
|
+
prop.items = items;
|
|
6331
|
+
}
|
|
6332
|
+
sanitized[key] = prop;
|
|
6333
|
+
} else {
|
|
6334
|
+
sanitized[key] = value;
|
|
6335
|
+
}
|
|
6336
|
+
}
|
|
6337
|
+
return sanitized;
|
|
6338
|
+
}
|
|
6255
6339
|
getGenerationConfig(model, options) {
|
|
6256
6340
|
return {
|
|
6257
6341
|
temperature: options.temperature ?? 0.9,
|
|
6258
6342
|
maxOutputTokens: options.maxTokens ?? 8192
|
|
6259
6343
|
};
|
|
6260
6344
|
}
|
|
6345
|
+
pushToolMessages(messages, tool, result, _thinkingBlocks) {
|
|
6346
|
+
messages.push({
|
|
6347
|
+
role: "assistant",
|
|
6348
|
+
content: [
|
|
6349
|
+
{
|
|
6350
|
+
type: "tool_use",
|
|
6351
|
+
id: tool.id,
|
|
6352
|
+
name: tool.name,
|
|
6353
|
+
input: JSON.parse(tool.parameters || "{}")
|
|
6354
|
+
}
|
|
6355
|
+
]
|
|
6356
|
+
});
|
|
6357
|
+
messages.push({
|
|
6358
|
+
role: "tool",
|
|
6359
|
+
content: [
|
|
6360
|
+
{
|
|
6361
|
+
type: "tool_result",
|
|
6362
|
+
tool_use_id: tool.id,
|
|
6363
|
+
content: result
|
|
6364
|
+
}
|
|
6365
|
+
]
|
|
6366
|
+
});
|
|
6367
|
+
}
|
|
6261
6368
|
};
|
|
6262
6369
|
|
|
6263
6370
|
// ../../b4m-core/packages/utils/dist/src/llm/ollamaBackend.js
|
|
@@ -6381,29 +6488,27 @@ var OllamaBackend = class {
|
|
|
6381
6488
|
};
|
|
6382
6489
|
});
|
|
6383
6490
|
}
|
|
6384
|
-
|
|
6385
|
-
|
|
6386
|
-
|
|
6387
|
-
|
|
6388
|
-
|
|
6389
|
-
|
|
6390
|
-
|
|
6391
|
-
|
|
6392
|
-
|
|
6393
|
-
|
|
6394
|
-
|
|
6395
|
-
|
|
6396
|
-
|
|
6397
|
-
|
|
6398
|
-
|
|
6399
|
-
|
|
6400
|
-
|
|
6401
|
-
|
|
6402
|
-
|
|
6403
|
-
|
|
6404
|
-
|
|
6405
|
-
// messages.push(toolCallMessage, resultMessage);
|
|
6406
|
-
// }
|
|
6491
|
+
pushToolMessages(messages, tool, result, _thinkingBlocks) {
|
|
6492
|
+
messages.push({
|
|
6493
|
+
content: null,
|
|
6494
|
+
role: "assistant",
|
|
6495
|
+
tool_calls: [
|
|
6496
|
+
{
|
|
6497
|
+
id: tool.id,
|
|
6498
|
+
type: "function",
|
|
6499
|
+
function: {
|
|
6500
|
+
name: tool.name,
|
|
6501
|
+
arguments: tool.parameters
|
|
6502
|
+
}
|
|
6503
|
+
}
|
|
6504
|
+
]
|
|
6505
|
+
});
|
|
6506
|
+
messages.push({
|
|
6507
|
+
role: "tool",
|
|
6508
|
+
content: result,
|
|
6509
|
+
tool_call_id: tool.id
|
|
6510
|
+
});
|
|
6511
|
+
}
|
|
6407
6512
|
// private formatTools(tools: ICompletionOptionTools[]): Tool[] {
|
|
6408
6513
|
// return tools.map(tool => ({
|
|
6409
6514
|
// type: 'function' as const,
|
|
@@ -7169,7 +7274,8 @@ var OpenAIBackend = class {
|
|
|
7169
7274
|
if (toolCall.function.arguments) {
|
|
7170
7275
|
toolsUsed.push({
|
|
7171
7276
|
name: toolCall.function.name,
|
|
7172
|
-
arguments: toolCall.function.arguments
|
|
7277
|
+
arguments: toolCall.function.arguments,
|
|
7278
|
+
id: toolCall.id
|
|
7173
7279
|
});
|
|
7174
7280
|
}
|
|
7175
7281
|
}
|
|
@@ -7343,7 +7449,8 @@ var OpenAIBackend = class {
|
|
|
7343
7449
|
if (tool.name && tool.parameters) {
|
|
7344
7450
|
toolsUsed.push({
|
|
7345
7451
|
name: tool.name,
|
|
7346
|
-
arguments: tool.parameters
|
|
7452
|
+
arguments: tool.parameters,
|
|
7453
|
+
id: tool.id
|
|
7347
7454
|
});
|
|
7348
7455
|
}
|
|
7349
7456
|
}
|
|
@@ -7448,7 +7555,7 @@ Only when someone asks, remember that you are specifically the ${model} model.`;
|
|
|
7448
7555
|
});
|
|
7449
7556
|
return isO1Model ? formattedMessages : [systemMessage, ...formattedMessages];
|
|
7450
7557
|
}
|
|
7451
|
-
pushToolMessages(messages, tool, result) {
|
|
7558
|
+
pushToolMessages(messages, tool, result, _thinkingBlocks) {
|
|
7452
7559
|
messages.push({
|
|
7453
7560
|
content: null,
|
|
7454
7561
|
role: "assistant",
|
|
@@ -7726,7 +7833,7 @@ var XAIBackend = class {
|
|
|
7726
7833
|
parameters.tools = this.formatTools(options.tools);
|
|
7727
7834
|
}
|
|
7728
7835
|
const supportsThinking = await this.modelSupportsThinking(model);
|
|
7729
|
-
const thinkingEnabled = supportsThinking && options.thinking?.enabled
|
|
7836
|
+
const thinkingEnabled = supportsThinking && options.thinking?.enabled === true;
|
|
7730
7837
|
const cacheStrategy = options.cacheStrategy;
|
|
7731
7838
|
let headers = {};
|
|
7732
7839
|
if (cacheStrategy?.enableCaching) {
|
|
@@ -7764,7 +7871,8 @@ var XAIBackend = class {
|
|
|
7764
7871
|
if (toolCall.function.arguments) {
|
|
7765
7872
|
toolsUsed.push({
|
|
7766
7873
|
name: toolCall.function.name,
|
|
7767
|
-
arguments: toolCall.function.arguments
|
|
7874
|
+
arguments: toolCall.function.arguments,
|
|
7875
|
+
id: toolCall.id
|
|
7768
7876
|
});
|
|
7769
7877
|
}
|
|
7770
7878
|
}
|
|
@@ -7905,11 +8013,12 @@ var XAIBackend = class {
|
|
|
7905
8013
|
}
|
|
7906
8014
|
if (func.length > 0) {
|
|
7907
8015
|
for await (const tool of func) {
|
|
7908
|
-
const { name, parameters: parameters2 } = tool;
|
|
8016
|
+
const { name, parameters: parameters2, id } = tool;
|
|
7909
8017
|
if (name) {
|
|
7910
8018
|
toolsUsed.push({
|
|
7911
8019
|
name,
|
|
7912
|
-
arguments: parameters2 || "{}"
|
|
8020
|
+
arguments: parameters2 || "{}",
|
|
8021
|
+
id
|
|
7913
8022
|
});
|
|
7914
8023
|
}
|
|
7915
8024
|
}
|
|
@@ -7984,7 +8093,7 @@ var XAIBackend = class {
|
|
|
7984
8093
|
function: tool.toolSchema
|
|
7985
8094
|
}));
|
|
7986
8095
|
}
|
|
7987
|
-
pushToolMessages(messages, tool, result) {
|
|
8096
|
+
pushToolMessages(messages, tool, result, _thinkingBlocks) {
|
|
7988
8097
|
messages.push({
|
|
7989
8098
|
content: null,
|
|
7990
8099
|
role: "assistant",
|