bitfab-cli 0.2.384 → 0.2.386
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/index.js +53 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -23747,9 +23747,54 @@ function toolConfig(contract) {
|
|
|
23747
23747
|
return {
|
|
23748
23748
|
title: contract.title,
|
|
23749
23749
|
description: contract.description,
|
|
23750
|
-
inputSchema: contract.inputSchema
|
|
23750
|
+
inputSchema: external_exports.strictObject(contract.inputSchema)
|
|
23751
23751
|
};
|
|
23752
23752
|
}
|
|
23753
|
+
function isRecord(value) {
|
|
23754
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
23755
|
+
}
|
|
23756
|
+
function appendToolParameterWarning(result, warning) {
|
|
23757
|
+
if (!isRecord(result) || !Array.isArray(result.content)) {
|
|
23758
|
+
return result;
|
|
23759
|
+
}
|
|
23760
|
+
return {
|
|
23761
|
+
...result,
|
|
23762
|
+
content: [...result.content, { type: "text", text: warning }]
|
|
23763
|
+
};
|
|
23764
|
+
}
|
|
23765
|
+
function installToolParameterWarnings(protocolServer, contracts, receiver) {
|
|
23766
|
+
const method = "tools/call";
|
|
23767
|
+
const originalHandler = protocolServer._requestHandlers.get(method);
|
|
23768
|
+
if (!originalHandler) {
|
|
23769
|
+
throw new Error("Cannot install tool parameter warnings before tools register");
|
|
23770
|
+
}
|
|
23771
|
+
const contractsByName = new Map(contracts.map((toolContract) => [toolContract.name, toolContract]));
|
|
23772
|
+
protocolServer._requestHandlers.set(method, async (request, extra) => {
|
|
23773
|
+
if (!isRecord(request) || !isRecord(request.params)) {
|
|
23774
|
+
return originalHandler(request, extra);
|
|
23775
|
+
}
|
|
23776
|
+
const { name, arguments: args } = request.params;
|
|
23777
|
+
if (typeof name !== "string" || !isRecord(args)) {
|
|
23778
|
+
return originalHandler(request, extra);
|
|
23779
|
+
}
|
|
23780
|
+
const toolContract = contractsByName.get(name);
|
|
23781
|
+
if (!toolContract) {
|
|
23782
|
+
return originalHandler(request, extra);
|
|
23783
|
+
}
|
|
23784
|
+
const supportedNames = new Set(Object.keys(toolContract.inputSchema));
|
|
23785
|
+
const unsupportedNames = Object.keys(args).filter((key) => !supportedNames.has(key));
|
|
23786
|
+
if (unsupportedNames.length === 0) {
|
|
23787
|
+
return originalHandler(request, extra);
|
|
23788
|
+
}
|
|
23789
|
+
const supportedArgs = Object.fromEntries(Object.entries(args).filter(([key]) => supportedNames.has(key)));
|
|
23790
|
+
const result = await originalHandler({
|
|
23791
|
+
...request,
|
|
23792
|
+
params: { ...request.params, arguments: supportedArgs }
|
|
23793
|
+
}, extra);
|
|
23794
|
+
const parameterLabel = unsupportedNames.length === 1 ? "parameter" : "parameters";
|
|
23795
|
+
return appendToolParameterWarning(result, `Warning: ${receiver} ignored unsupported ${parameterLabel} for ${name}: ${unsupportedNames.join(", ")}. Update Bitfab if you expected ${unsupportedNames.length === 1 ? "it" : "them"} to take effect.`);
|
|
23796
|
+
});
|
|
23797
|
+
}
|
|
23753
23798
|
var getBitfabApiKey = {
|
|
23754
23799
|
name: "get_bitfab_api_key",
|
|
23755
23800
|
title: "Get Bitfab API Key",
|
|
@@ -24918,7 +24963,7 @@ var semver3 = __toESM(require_semver2(), 1);
|
|
|
24918
24963
|
// ../bitfab-plugin-lib/dist/bakedSdkVersions.js
|
|
24919
24964
|
var BAKED_SDK_VERSIONS = {
|
|
24920
24965
|
typescript: "0.60.1",
|
|
24921
|
-
python: "0.60.
|
|
24966
|
+
python: "0.60.2",
|
|
24922
24967
|
ruby: "0.60.1",
|
|
24923
24968
|
go: "0.60.1"
|
|
24924
24969
|
};
|
|
@@ -43230,6 +43275,7 @@ function createMcpServer(platform2, getConfig2, pluginVersion) {
|
|
|
43230
43275
|
for (const { contract, handle } of handlers) {
|
|
43231
43276
|
server.registerTool(contract.name, toolConfig(contract), async (args) => handle(args));
|
|
43232
43277
|
}
|
|
43278
|
+
installToolParameterWarnings(server.server, handlers.map(({ contract }) => contract), `Bitfab plugin ${pluginVersion}`);
|
|
43233
43279
|
return { server, proxy };
|
|
43234
43280
|
}
|
|
43235
43281
|
async function startMcpServer(platform2, getConfig2, pluginVersion) {
|
|
@@ -46049,7 +46095,7 @@ var AUTO_APPROVED_TOOLS = /* @__PURE__ */ new Set([
|
|
|
46049
46095
|
).map((tool) => `mcp__Bitfab__${tool.name}`)
|
|
46050
46096
|
]);
|
|
46051
46097
|
var OTHER_VALUE = "__bitfab_other__";
|
|
46052
|
-
function
|
|
46098
|
+
function isRecord2(value) {
|
|
46053
46099
|
return typeof value === "object" && value !== null;
|
|
46054
46100
|
}
|
|
46055
46101
|
function parseQuestions(input) {
|
|
@@ -46057,11 +46103,11 @@ function parseQuestions(input) {
|
|
|
46057
46103
|
return [];
|
|
46058
46104
|
}
|
|
46059
46105
|
return input.questions.flatMap((candidate) => {
|
|
46060
|
-
if (!
|
|
46106
|
+
if (!isRecord2(candidate) || typeof candidate.question !== "string" || !Array.isArray(candidate.options)) {
|
|
46061
46107
|
return [];
|
|
46062
46108
|
}
|
|
46063
46109
|
const options = candidate.options.flatMap((option) => {
|
|
46064
|
-
if (!
|
|
46110
|
+
if (!isRecord2(option) || typeof option.label !== "string") {
|
|
46065
46111
|
return [];
|
|
46066
46112
|
}
|
|
46067
46113
|
return [
|
|
@@ -46253,7 +46299,7 @@ function createPreToolUseHook() {
|
|
|
46253
46299
|
if (input.hook_event_name !== "PreToolUse") {
|
|
46254
46300
|
return { continue: true };
|
|
46255
46301
|
}
|
|
46256
|
-
const toolInput =
|
|
46302
|
+
const toolInput = isRecord2(input.tool_input) ? input.tool_input : {};
|
|
46257
46303
|
if (input.tool_name === "AskUserQuestion") {
|
|
46258
46304
|
return { continue: true };
|
|
46259
46305
|
}
|
|
@@ -46284,7 +46330,7 @@ function createPostToolUseHook(verification) {
|
|
|
46284
46330
|
}
|
|
46285
46331
|
verification.recordToolSuccess(
|
|
46286
46332
|
input.tool_name,
|
|
46287
|
-
|
|
46333
|
+
isRecord2(input.tool_input) ? input.tool_input : {},
|
|
46288
46334
|
input.tool_response
|
|
46289
46335
|
);
|
|
46290
46336
|
return { continue: true };
|
package/package.json
CHANGED