@goodtiming/baton-sdk 1.3.0 → 1.3.1
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.cjs +42 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +42 -21
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/version.ts
|
|
2
|
-
var SDK_VERSION = "ts-1.3.
|
|
2
|
+
var SDK_VERSION = "ts-1.3.1";
|
|
3
3
|
|
|
4
4
|
// src/events.ts
|
|
5
5
|
import { z } from "zod";
|
|
@@ -3187,19 +3187,29 @@ var ANNOTATION_INPUT_SHAPE = {
|
|
|
3187
3187
|
// zod renders "any value" as `{}`, which some MCP clients refuse (reportToolSchema.test.ts).
|
|
3188
3188
|
context: z2.record(z2.string(), z2.unknown()).meta({ additionalProperties: true }).nullable().optional()
|
|
3189
3189
|
};
|
|
3190
|
+
var ANNOTATION_ARGS = z2.object(ANNOTATION_INPUT_SHAPE);
|
|
3190
3191
|
function isReport(whatHappened) {
|
|
3191
3192
|
return typeof whatHappened === "string" && !isBlank(whatHappened);
|
|
3192
3193
|
}
|
|
3193
|
-
|
|
3194
|
+
var INVALID_PARAMS = -32602;
|
|
3195
|
+
function registerAnnotationTool(server, options, callArguments) {
|
|
3194
3196
|
const tool = buildAnnotationTool(server, options);
|
|
3195
|
-
|
|
3196
|
-
tool.name,
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
)
|
|
3200
|
-
|
|
3197
|
+
if (callArguments === void 0) {
|
|
3198
|
+
server.registerTool(tool.name, { description: tool.description, inputSchema: ANNOTATION_INPUT_SHAPE }, tool.handler);
|
|
3199
|
+
return;
|
|
3200
|
+
}
|
|
3201
|
+
server.registerTool(tool.name, { description: tool.description }, async (extra) => {
|
|
3202
|
+
const args = callArguments();
|
|
3203
|
+
const { validateToolInput } = server;
|
|
3204
|
+
let parsed;
|
|
3205
|
+
try {
|
|
3206
|
+
parsed = await validateToolInput?.call(server, { inputSchema: ANNOTATION_ARGS }, args, tool.name);
|
|
3207
|
+
} catch (err) {
|
|
3208
|
+
if (err?.code === INVALID_PARAMS) throw err;
|
|
3209
|
+
}
|
|
3210
|
+
return isRecord(parsed) ? tool.handler(parsed, extra) : callAnnotationTool(tool, args, extra);
|
|
3211
|
+
});
|
|
3201
3212
|
}
|
|
3202
|
-
var ANNOTATION_ARGS = z2.object(ANNOTATION_INPUT_SHAPE);
|
|
3203
3213
|
function annotationInputJsonSchema(major) {
|
|
3204
3214
|
return annotationJsonSchemas[major] ??= (major === 2 ? standardInputJsonSchema(ANNOTATION_ARGS) : void 0) ?? toolInputJsonSchema(ANNOTATION_INPUT_SHAPE);
|
|
3205
3215
|
}
|
|
@@ -4418,11 +4428,9 @@ var TOOLS_LIST_SEAM = /* @__PURE__ */ Symbol("batonToolsListSeam");
|
|
|
4418
4428
|
var TOOLS_CALL_METHOD = "tools/call";
|
|
4419
4429
|
var TOOLS_CALL_SEAM = /* @__PURE__ */ Symbol("batonToolsCallSeam");
|
|
4420
4430
|
function installRequestSeam(lowLevel, method, seamTag, wrap) {
|
|
4421
|
-
|
|
4422
|
-
const
|
|
4423
|
-
|
|
4424
|
-
const handlers = table;
|
|
4425
|
-
const setRequestHandler = originalSet;
|
|
4431
|
+
if (!takesRequestSeams(lowLevel)) return;
|
|
4432
|
+
const handlers = lowLevel._requestHandlers;
|
|
4433
|
+
const setRequestHandler = lowLevel.setRequestHandler;
|
|
4426
4434
|
const wrapCurrent = () => {
|
|
4427
4435
|
const handler = handlers.get(method);
|
|
4428
4436
|
if (typeof handler !== "function" || handler[seamTag]) return;
|
|
@@ -4438,18 +4446,24 @@ function installRequestSeam(lowLevel, method, seamTag, wrap) {
|
|
|
4438
4446
|
return registered;
|
|
4439
4447
|
};
|
|
4440
4448
|
}
|
|
4449
|
+
function takesRequestSeams(lowLevel) {
|
|
4450
|
+
return lowLevel._requestHandlers instanceof Map && typeof lowLevel.setRequestHandler === "function";
|
|
4451
|
+
}
|
|
4441
4452
|
function installToolsListSeam(lowLevel, ctx, listsOwnReportTool) {
|
|
4442
4453
|
const names = [...requiredParamNames(ctx.intentParamMode), TOOL_NAME_PARAM_NAME];
|
|
4443
4454
|
const isInjected = (toolName, paramName) => toolName === ctx.annotationToolName ? paramName === TOOL_NAME_PARAM_NAME : ctx.paramRegistry.get(toolName)?.[paramName] === "injected";
|
|
4444
4455
|
const advertise = (result) => {
|
|
4456
|
+
let served = result;
|
|
4445
4457
|
try {
|
|
4446
|
-
|
|
4458
|
+
if (!listsOwnReportTool && ctx.annotationToolName !== "") {
|
|
4459
|
+
served = withToolInputSchema(result, ctx.annotationToolName, annotationInputJsonSchema(lowLevelMajor(lowLevel)));
|
|
4460
|
+
}
|
|
4447
4461
|
return advertiseIntentParamsRequired(served, names, isInjected);
|
|
4448
4462
|
} catch (err) {
|
|
4449
4463
|
stderrLine(
|
|
4450
|
-
`baton: tools/list advertisement failed; serving the
|
|
4464
|
+
`baton: tools/list advertisement failed; serving the list without it: ${String(err)}`
|
|
4451
4465
|
);
|
|
4452
|
-
return
|
|
4466
|
+
return served;
|
|
4453
4467
|
}
|
|
4454
4468
|
};
|
|
4455
4469
|
installRequestSeam(lowLevel, TOOLS_LIST_METHOD, TOOLS_LIST_SEAM, (handler) => (...args) => {
|
|
@@ -4847,14 +4861,15 @@ function installToolsCallSeam(lowLevel, toolEntry, ctx) {
|
|
|
4847
4861
|
(handler) => async (...args) => {
|
|
4848
4862
|
const request = args[0];
|
|
4849
4863
|
const name = request?.params?.name;
|
|
4864
|
+
const toolArgs = request?.params?.arguments;
|
|
4850
4865
|
const slot = {
|
|
4851
4866
|
innerFired: false,
|
|
4852
4867
|
flushTerminal: null,
|
|
4853
4868
|
stripped: stripIntentParams(request?.params, ctx),
|
|
4854
4869
|
strippedFor: typeof name === "string" ? name : null,
|
|
4855
|
-
validation: "unseen"
|
|
4870
|
+
validation: "unseen",
|
|
4871
|
+
arguments: name === ctx.annotationToolName ? toolArgs : void 0
|
|
4856
4872
|
};
|
|
4857
|
-
const toolArgs = request?.params?.arguments;
|
|
4858
4873
|
if (typeof name === "string" && toolEntry(name) != null && await hiddenFrom(slot, name, isRecord(toolArgs) ? toolArgs : {}, args[1], ctx)) {
|
|
4859
4874
|
return answerHidden(lowLevel, name, (outcome2) => settleCall(slot, outcome2, args, toolEntry, ctx, "tool_hidden"));
|
|
4860
4875
|
}
|
|
@@ -5349,7 +5364,13 @@ function install(server, supplied, resolved, { sentSurfaces, warned: warned4, co
|
|
|
5349
5364
|
checkGivenTools?.();
|
|
5350
5365
|
return handle(annotationToolName);
|
|
5351
5366
|
}
|
|
5352
|
-
|
|
5367
|
+
if (annotationOptions) {
|
|
5368
|
+
registerAnnotationTool(
|
|
5369
|
+
server,
|
|
5370
|
+
annotationOptions,
|
|
5371
|
+
takesRequestSeams(lowLevel) ? () => callSlots.getStore()?.arguments : void 0
|
|
5372
|
+
);
|
|
5373
|
+
}
|
|
5353
5374
|
const existing = internals._registeredTools;
|
|
5354
5375
|
if (existing) {
|
|
5355
5376
|
for (const [name, entry] of Object.entries(existing)) {
|
|
@@ -5362,7 +5383,7 @@ function install(server, supplied, resolved, { sentSurfaces, warned: warned4, co
|
|
|
5362
5383
|
wireEntry(String(args[0]), registered, ctx);
|
|
5363
5384
|
return registered;
|
|
5364
5385
|
};
|
|
5365
|
-
return handle(
|
|
5386
|
+
return handle(annotationToolName);
|
|
5366
5387
|
}
|
|
5367
5388
|
function reportsFor(config) {
|
|
5368
5389
|
if (config.reportMode !== "on") return void 0;
|