@goodtiming/baton-sdk 1.3.1 → 1.3.2
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 +1 -1
- package/dist/index.cjs +147 -49
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -4
- package/dist/index.d.ts +9 -4
- package/dist/index.js +147 -49
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -57,7 +57,7 @@ Sending to your own collector instead, or trying the package before you have a k
|
|
|
57
57
|
withBaton(server, { dsn: process.env.BATON_DSN, tools: TOOLS }); // or tools: () => TOOLS
|
|
58
58
|
```
|
|
59
59
|
|
|
60
|
-
Baton reads `tools` once per `withBaton` or `createBaton`, and never calls your `tools/list` handler itself. It also needs `tools` to leave its subagent sentence out of the instructions when a tool declares its own `user_goal`.
|
|
60
|
+
Baton reads `tools` once per `withBaton` or `createBaton`, and never calls your `tools/list` handler itself. It also needs `tools` to leave its subagent sentence out of the instructions when a tool declares its own `user_goal`. The snapshot of your tools comes from the lists you serve, never from `tools`, so a server sends none until it has served its whole list in one page.
|
|
61
61
|
- If your list has a tool with the report tool's name, yours is kept, Baton's report tool is not added, and the instructions stop naming it; the handle's `annotationToolName` still does. Until Baton has seen that list, a call to that name reaches Baton's report tool, so pass `tools` or set `annotationToolName` to another name.
|
|
62
62
|
- Baton has no tool registry to check a call against here, so `failure_kind` is never `unknown_tool`, `invalid_argument` or `output_schema_mismatch`. Such a failure is recorded as an error with no `failure_kind`.
|
|
63
63
|
|
package/dist/index.cjs
CHANGED
|
@@ -53,7 +53,7 @@ __export(index_exports, {
|
|
|
53
53
|
module.exports = __toCommonJS(index_exports);
|
|
54
54
|
|
|
55
55
|
// src/version.ts
|
|
56
|
-
var SDK_VERSION = "ts-1.3.
|
|
56
|
+
var SDK_VERSION = "ts-1.3.2";
|
|
57
57
|
|
|
58
58
|
// src/events.ts
|
|
59
59
|
var import_zod = require("zod");
|
|
@@ -287,7 +287,8 @@ var PromptListErrorPayloadSchema = import_zod.z.object({
|
|
|
287
287
|
var ToolListStartPayloadSchema = import_zod.z.object({}).strict();
|
|
288
288
|
var ToolListEndPayloadSchema = import_zod.z.object({
|
|
289
289
|
count: import_zod.z.number().int(),
|
|
290
|
-
...timingShape
|
|
290
|
+
...timingShape,
|
|
291
|
+
surface_hash: import_zod.z.string().nullable().optional()
|
|
291
292
|
}).strict();
|
|
292
293
|
var ToolListErrorPayloadSchema = import_zod.z.object({
|
|
293
294
|
...failureShape
|
|
@@ -507,6 +508,9 @@ function isPlainObject(value) {
|
|
|
507
508
|
function isRecord(value) {
|
|
508
509
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
509
510
|
}
|
|
511
|
+
function jsonObjectCopy(value) {
|
|
512
|
+
return isRecord(value) ? JSON.parse(JSON.stringify(value)) : void 0;
|
|
513
|
+
}
|
|
510
514
|
|
|
511
515
|
// src/scrub.ts
|
|
512
516
|
var DEPTH_LIMIT = 10;
|
|
@@ -3085,12 +3089,14 @@ function standardInputJsonSchema(schema) {
|
|
|
3085
3089
|
}
|
|
3086
3090
|
}
|
|
3087
3091
|
function toolInputJsonSchema(inputSchema2) {
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3092
|
+
return toolJsonSchema(inputSchema2, "input") ?? EMPTY_OBJECT_JSON_SCHEMA;
|
|
3093
|
+
}
|
|
3094
|
+
function toolOutputJsonSchema(outputSchema) {
|
|
3095
|
+
return outputSchema ? toolJsonSchema(outputSchema, "output") : void 0;
|
|
3096
|
+
}
|
|
3097
|
+
function toolJsonSchema(schema, pipeStrategy) {
|
|
3098
|
+
const objSchema = normalizeObjectSchema(schema);
|
|
3099
|
+
return objSchema ? toJsonSchemaCompat(objSchema, { strictUnions: true, pipeStrategy }) : void 0;
|
|
3094
3100
|
}
|
|
3095
3101
|
|
|
3096
3102
|
// src/integrations/mcp/safeScrub.ts
|
|
@@ -4051,6 +4057,9 @@ function assembleSurface(serverMeta, tools) {
|
|
|
4051
4057
|
tools
|
|
4052
4058
|
};
|
|
4053
4059
|
}
|
|
4060
|
+
function isWholeList(cursor, nextCursor) {
|
|
4061
|
+
return (cursor === void 0 || cursor === null) && (nextCursor === void 0 || nextCursor === null);
|
|
4062
|
+
}
|
|
4054
4063
|
var SENT_SURFACES_CAP = 256;
|
|
4055
4064
|
var SentSurfaces = class {
|
|
4056
4065
|
hashes = /* @__PURE__ */ new Set();
|
|
@@ -4094,12 +4103,14 @@ var CLEAN_OUTCOME = { failed: false, raised: false, result: void 0 };
|
|
|
4094
4103
|
var INTENT_PARAM_NAMES = [USER_GOAL_PARAM_NAME, ...RETIRED_PARAM_NAMES];
|
|
4095
4104
|
var callSlots = new asyncHooks.AsyncLocalStorage();
|
|
4096
4105
|
var SurfaceState = class {
|
|
4097
|
-
constructor(serverMeta, sentSurfaces) {
|
|
4106
|
+
constructor(serverMeta, sentSurfaces, fromRegistry) {
|
|
4098
4107
|
this.serverMeta = serverMeta;
|
|
4099
4108
|
this.sentSurfaces = sentSurfaces;
|
|
4109
|
+
this.fromRegistry = fromRegistry;
|
|
4100
4110
|
}
|
|
4101
4111
|
serverMeta;
|
|
4102
4112
|
sentSurfaces;
|
|
4113
|
+
fromRegistry;
|
|
4103
4114
|
/** Every tool this install has seen, keyed by its CURRENT name. `disabled`
|
|
4104
4115
|
* is tracked alongside rather than pruned, so re-enabling costs nothing and
|
|
4105
4116
|
* — crucially — never needs a re-capture, which would re-read Baton's own
|
|
@@ -4107,20 +4118,74 @@ var SurfaceState = class {
|
|
|
4107
4118
|
rawTools = /* @__PURE__ */ new Map();
|
|
4108
4119
|
dirty = false;
|
|
4109
4120
|
servedOverlayId = null;
|
|
4121
|
+
listed = false;
|
|
4122
|
+
/** `null` when this version of the surface could not be captured. */
|
|
4123
|
+
captured;
|
|
4124
|
+
/** The surface each low-level request was served, keyed by the request,
|
|
4125
|
+
* which every seam passes on as it came. Kept apart from the current
|
|
4126
|
+
* surface, which another listing can change before this one's end is sent:
|
|
4127
|
+
* `surfaceAtList.test.ts`, "gives two listings that finish together each its own hash". */
|
|
4128
|
+
listedSurfaces = /* @__PURE__ */ new WeakMap();
|
|
4129
|
+
get hasSurface() {
|
|
4130
|
+
return this.fromRegistry || this.listed;
|
|
4131
|
+
}
|
|
4132
|
+
/** A low-level Server served `request` its whole list, which then is the
|
|
4133
|
+
* surface: `surfaceAtList.test.ts`, "snapshots each list as served". */
|
|
4134
|
+
servedList(request, names) {
|
|
4135
|
+
this.listed = true;
|
|
4136
|
+
for (const name of [...this.rawTools.keys()]) {
|
|
4137
|
+
if (!names.has(name)) this.pruneTool(name);
|
|
4138
|
+
}
|
|
4139
|
+
const surface = this.capture();
|
|
4140
|
+
if (surface !== null) this.listedSurfaces.set(request, surface);
|
|
4141
|
+
}
|
|
4142
|
+
/** The surface a `tools/list` request was served, when it got the whole list. */
|
|
4143
|
+
surfaceListed(request, served) {
|
|
4144
|
+
const listed = this.listedSurfaces.get(request);
|
|
4145
|
+
if (listed !== void 0) return listed;
|
|
4146
|
+
const cursor = isRecord(request.params) ? request.params.cursor : void 0;
|
|
4147
|
+
const whole = isWholeList(cursor, isRecord(served) ? served.nextCursor : void 0);
|
|
4148
|
+
return this.fromRegistry && whole ? this.capture() : null;
|
|
4149
|
+
}
|
|
4150
|
+
/** The surface as it stands, and its hash; built once per change, so a
|
|
4151
|
+
* surface that cannot be hashed is reported once, not on every request. */
|
|
4152
|
+
capture() {
|
|
4153
|
+
if (this.captured !== void 0) return this.captured;
|
|
4154
|
+
try {
|
|
4155
|
+
const snapshot = this.buildSnapshot();
|
|
4156
|
+
this.captured = { snapshot, digest: surfaceHash(snapshot) };
|
|
4157
|
+
} catch (err) {
|
|
4158
|
+
stderrLine(`baton: surface snapshot capture failed: ${printable(err)}`);
|
|
4159
|
+
this.captured = null;
|
|
4160
|
+
}
|
|
4161
|
+
return this.captured;
|
|
4162
|
+
}
|
|
4163
|
+
changed() {
|
|
4164
|
+
this.dirty = true;
|
|
4165
|
+
this.captured = void 0;
|
|
4166
|
+
}
|
|
4110
4167
|
/** `inputSchemaJson` is already converted — by `ctx.vendorToolJsonSchema`,
|
|
4111
4168
|
* which picks the spelling THIS SDK major puts on the wire. */
|
|
4112
|
-
noteTool(name, inputSchemaJson, description) {
|
|
4169
|
+
noteTool(name, inputSchemaJson, description, outputSchemaJson) {
|
|
4113
4170
|
const before = this.rawTools.get(name);
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
if (same) return;
|
|
4171
|
+
if (before !== void 0 && before.tool.description === (description ?? null)) {
|
|
4172
|
+
const sameInput = before.tool.inputSchema === inputSchemaJson || JSON.stringify(before.tool.inputSchema) === JSON.stringify(inputSchemaJson);
|
|
4173
|
+
if (sameInput && JSON.stringify(before.tool.outputSchema) === JSON.stringify(outputSchemaJson)) return;
|
|
4118
4174
|
}
|
|
4175
|
+
const tool = { name, description: description ?? null, inputSchema: inputSchemaJson };
|
|
4176
|
+
const outputSchema = jsonObjectCopy(outputSchemaJson);
|
|
4177
|
+
if (outputSchema !== void 0) tool.outputSchema = outputSchema;
|
|
4119
4178
|
this.rawTools.set(name, { disabled: before?.disabled ?? false, tool });
|
|
4120
|
-
this.
|
|
4179
|
+
this.changed();
|
|
4180
|
+
}
|
|
4181
|
+
setOutputSchema(name, outputSchemaJson) {
|
|
4182
|
+
const tool = this.rawTools.get(name)?.tool;
|
|
4183
|
+
if (tool === void 0) return;
|
|
4184
|
+
const description = typeof tool.description === "string" ? tool.description : void 0;
|
|
4185
|
+
this.noteTool(name, tool.inputSchema, description, outputSchemaJson);
|
|
4121
4186
|
}
|
|
4122
4187
|
pruneTool(name) {
|
|
4123
|
-
if (this.rawTools.delete(name)) this.
|
|
4188
|
+
if (this.rawTools.delete(name)) this.changed();
|
|
4124
4189
|
}
|
|
4125
4190
|
/** Follow a `update({name})` rename, keeping the snapshot keyed the way
|
|
4126
4191
|
* `tools/list` now renders it. */
|
|
@@ -4129,7 +4194,7 @@ var SurfaceState = class {
|
|
|
4129
4194
|
if (!entry) return;
|
|
4130
4195
|
this.rawTools.delete(from);
|
|
4131
4196
|
this.rawTools.set(to, { ...entry, tool: { ...entry.tool, name: to } });
|
|
4132
|
-
this.
|
|
4197
|
+
this.changed();
|
|
4133
4198
|
}
|
|
4134
4199
|
/** Both majors filter `tools/list` on `tool.enabled`, so a disabled tool is
|
|
4135
4200
|
* not part of the surface a client sees and must not be part of the one we
|
|
@@ -4139,7 +4204,7 @@ var SurfaceState = class {
|
|
|
4139
4204
|
const entry = this.rawTools.get(name);
|
|
4140
4205
|
if (!entry || entry.disabled === !enabled) return;
|
|
4141
4206
|
entry.disabled = !enabled;
|
|
4142
|
-
this.
|
|
4207
|
+
this.changed();
|
|
4143
4208
|
}
|
|
4144
4209
|
buildSnapshot() {
|
|
4145
4210
|
const names = [...this.rawTools.keys()].sort().filter((n) => !this.rawTools.get(n).disabled);
|
|
@@ -4414,6 +4479,7 @@ function stripIntentParams(params, ctx) {
|
|
|
4414
4479
|
return stripped;
|
|
4415
4480
|
}
|
|
4416
4481
|
async function maybeEmitSurfaceSnapshot(ctx) {
|
|
4482
|
+
if (!ctx.surfaceState.hasSurface) return;
|
|
4417
4483
|
const overlayId = ctx.perCaller?.serverOverlay?.id ?? null;
|
|
4418
4484
|
if (overlayId !== ctx.surfaceState.servedOverlayId) {
|
|
4419
4485
|
ctx.surfaceState.servedOverlayId = overlayId;
|
|
@@ -4421,17 +4487,13 @@ async function maybeEmitSurfaceSnapshot(ctx) {
|
|
|
4421
4487
|
}
|
|
4422
4488
|
if (!ctx.surfaceState.dirty) return;
|
|
4423
4489
|
ctx.surfaceState.dirty = false;
|
|
4424
|
-
|
|
4425
|
-
|
|
4426
|
-
|
|
4427
|
-
|
|
4428
|
-
|
|
4429
|
-
} catch (err) {
|
|
4430
|
-
stderrLine(`baton: surface snapshot capture failed: ${String(err)}`);
|
|
4431
|
-
return;
|
|
4432
|
-
}
|
|
4490
|
+
const surface = ctx.surfaceState.capture();
|
|
4491
|
+
if (surface !== null) await sendSurface(ctx, surface);
|
|
4492
|
+
}
|
|
4493
|
+
async function sendSurface(ctx, { snapshot, digest }) {
|
|
4494
|
+
const overlayId = ctx.perCaller?.serverOverlay?.id ?? null;
|
|
4433
4495
|
const sent = ctx.surfaceState.sentSurfaces;
|
|
4434
|
-
if (sent.wasSent(digest, overlayId)) return;
|
|
4496
|
+
if (sent.wasSent(digest, overlayId)) return digest;
|
|
4435
4497
|
sent.mark(digest, overlayId);
|
|
4436
4498
|
const seam = buildSeamAugmentations({
|
|
4437
4499
|
injectedToolNames: ctx.annotationToolName ? [ctx.annotationToolName] : [],
|
|
@@ -4448,6 +4510,16 @@ async function maybeEmitSurfaceSnapshot(ctx) {
|
|
|
4448
4510
|
});
|
|
4449
4511
|
if (ctx.captureSettings !== void 0) seam.server_overlay = overlayId;
|
|
4450
4512
|
await ctx.emitSurface(ctx.fallbackSessionId, digest, { ...snapshot, seam_augmentations: seam });
|
|
4513
|
+
return digest;
|
|
4514
|
+
}
|
|
4515
|
+
async function listedSurfaceFields(ctx, request, served) {
|
|
4516
|
+
try {
|
|
4517
|
+
const surface = isRecord(request) ? ctx.surfaceState.surfaceListed(request, served) : null;
|
|
4518
|
+
return surface === null ? {} : { surface_hash: await sendSurface(ctx, surface) };
|
|
4519
|
+
} catch (err) {
|
|
4520
|
+
stderrLine(`baton: surface snapshot capture failed: ${printable(err)}`);
|
|
4521
|
+
return {};
|
|
4522
|
+
}
|
|
4451
4523
|
}
|
|
4452
4524
|
function declaredIntentParams(vendorSchema) {
|
|
4453
4525
|
const declared2 = {};
|
|
@@ -4460,7 +4532,7 @@ function captureAndInject(name, entry, ctx) {
|
|
|
4460
4532
|
if (!entry || typeof entry !== "object") return;
|
|
4461
4533
|
const mutable = entry;
|
|
4462
4534
|
const vendorSchema = ctx.vendorToolJsonSchema(name, mutable.inputSchema);
|
|
4463
|
-
ctx.surfaceState.noteTool(name, vendorSchema, mutable.description);
|
|
4535
|
+
ctx.surfaceState.noteTool(name, vendorSchema, mutable.description, ctx.vendorOutputJsonSchema(entry));
|
|
4464
4536
|
if (declaresParam(vendorSchema, USER_GOAL_PARAM_NAME)) ctx.dropSubagentClause(name);
|
|
4465
4537
|
const isV2 = typeof mutable.executor === "function";
|
|
4466
4538
|
try {
|
|
@@ -4574,10 +4646,6 @@ function installLowLevelToolSeams(lowLevel, ctx, annotationTool, known, warnOnce
|
|
|
4574
4646
|
const name = reportTool2?.name;
|
|
4575
4647
|
if (name !== void 0 && tools.some((tool) => tool.name === name)) leaveReportNameToVendor(name);
|
|
4576
4648
|
};
|
|
4577
|
-
const read = (tools, { surface }) => {
|
|
4578
|
-
if (surface) takeReportNameIfListed(tools);
|
|
4579
|
-
readToolList(tools, ctx, surface, skipNote);
|
|
4580
|
-
};
|
|
4581
4649
|
const learn = (tools) => {
|
|
4582
4650
|
keepGoalIfDeclared(tools);
|
|
4583
4651
|
for (const tool of tools) {
|
|
@@ -4605,8 +4673,8 @@ function installLowLevelToolSeams(lowLevel, ctx, annotationTool, known, warnOnce
|
|
|
4605
4673
|
);
|
|
4606
4674
|
}
|
|
4607
4675
|
}
|
|
4608
|
-
|
|
4609
|
-
|
|
4676
|
+
takeReportNameIfListed(known.givenTools);
|
|
4677
|
+
readToolList([...known.givenTools, ...known.served.values()], ctx, false, skipNote);
|
|
4610
4678
|
};
|
|
4611
4679
|
installRequestSeam(lowLevel, TOOLS_LIST_METHOD, LOW_LEVEL_LIST_SEAM, (handler) => async (...args) => {
|
|
4612
4680
|
catchUp();
|
|
@@ -4616,8 +4684,14 @@ function installLowLevelToolSeams(lowLevel, ctx, annotationTool, known, warnOnce
|
|
|
4616
4684
|
if (listed === null) return result;
|
|
4617
4685
|
const tools = toolInfos(listed, skipTool);
|
|
4618
4686
|
learn(tools);
|
|
4619
|
-
|
|
4620
|
-
|
|
4687
|
+
takeReportNameIfListed(tools);
|
|
4688
|
+
readToolList(tools, ctx, true, skipNote);
|
|
4689
|
+
const request = args[0];
|
|
4690
|
+
const cursor = isRecord(request) && isRecord(request.params) ? request.params.cursor : void 0;
|
|
4691
|
+
if (isRecord(request) && isWholeList(cursor, result.nextCursor)) {
|
|
4692
|
+
ctx.surfaceState.servedList(request, new Set(tools.map((tool) => tool.name)));
|
|
4693
|
+
}
|
|
4694
|
+
const firstPage = cursor === void 0 || cursor === null;
|
|
4621
4695
|
return servedToolList(result, listed, ctx, firstPage && reportTool2 ? listedReportTool : void 0);
|
|
4622
4696
|
} catch (err) {
|
|
4623
4697
|
stderrLine(`baton: tools/list capture failed; serving the vendor's own result: ${printable(err)}`);
|
|
@@ -4681,7 +4755,8 @@ function toolInfos(tools, skip) {
|
|
|
4681
4755
|
try {
|
|
4682
4756
|
name = isRecord(tool) ? tool.name : void 0;
|
|
4683
4757
|
if (typeof name !== "string") continue;
|
|
4684
|
-
|
|
4758
|
+
const { description, inputSchema: inputSchema2, outputSchema } = tool;
|
|
4759
|
+
infos.push({ name, description, inputSchema: inputSchema2, outputSchema });
|
|
4685
4760
|
} catch (err) {
|
|
4686
4761
|
if (typeof name === "string") skip(name, err);
|
|
4687
4762
|
}
|
|
@@ -4689,11 +4764,16 @@ function toolInfos(tools, skip) {
|
|
|
4689
4764
|
return infos;
|
|
4690
4765
|
}
|
|
4691
4766
|
function readToolList(tools, ctx, surface, skip) {
|
|
4692
|
-
for (const { name, inputSchema: inputSchema2, description } of tools) {
|
|
4767
|
+
for (const { name, inputSchema: inputSchema2, description, outputSchema } of tools) {
|
|
4693
4768
|
try {
|
|
4694
4769
|
const schema = isRecord(inputSchema2) ? inputSchema2 : null;
|
|
4695
4770
|
if (surface) {
|
|
4696
|
-
ctx.surfaceState.noteTool(
|
|
4771
|
+
ctx.surfaceState.noteTool(
|
|
4772
|
+
name,
|
|
4773
|
+
schema ?? EMPTY_OBJECT_JSON_SCHEMA,
|
|
4774
|
+
typeof description === "string" ? description : void 0,
|
|
4775
|
+
isRecord(outputSchema) ? outputSchema : void 0
|
|
4776
|
+
);
|
|
4697
4777
|
}
|
|
4698
4778
|
const dispositions = declaredIntentParams(schema);
|
|
4699
4779
|
if (dispositions[USER_GOAL_PARAM_NAME] === "native") ctx.dropSubagentClause(name);
|
|
@@ -4729,7 +4809,7 @@ function installLifecycleSeam(lowLevel, ctx, spec) {
|
|
|
4729
4809
|
const requestParams = request?.params ?? {};
|
|
4730
4810
|
const extra = args[1];
|
|
4731
4811
|
const opened = await openLifecycleCall(ctx, spec, requestParams, extra);
|
|
4732
|
-
const fire = async (schema, payload) => {
|
|
4812
|
+
const fire = async (schema, payload, unscrubbed = {}) => {
|
|
4733
4813
|
if (opened === null) return;
|
|
4734
4814
|
await emit(
|
|
4735
4815
|
ctx.sink,
|
|
@@ -4737,7 +4817,7 @@ function installLifecycleSeam(lowLevel, ctx, spec) {
|
|
|
4737
4817
|
...opened.common,
|
|
4738
4818
|
sequence_number: ctx.counter.nextFor(opened.session),
|
|
4739
4819
|
captured_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4740
|
-
payload: scrubLifecyclePayload(ctx, { ...opened.subject, ...payload })
|
|
4820
|
+
payload: { ...scrubLifecyclePayload(ctx, { ...opened.subject, ...payload }), ...unscrubbed }
|
|
4741
4821
|
})
|
|
4742
4822
|
);
|
|
4743
4823
|
};
|
|
@@ -4748,10 +4828,15 @@ function installLifecycleSeam(lowLevel, ctx, spec) {
|
|
|
4748
4828
|
const served = await handler(...args);
|
|
4749
4829
|
if (isInputRequired(served)) return served;
|
|
4750
4830
|
const result = opened !== null && spec.rewriteResult !== void 0 ? spec.rewriteResult(ctx, served, opened.caller) : served;
|
|
4751
|
-
|
|
4752
|
-
|
|
4753
|
-
|
|
4754
|
-
|
|
4831
|
+
const duration = elapsed();
|
|
4832
|
+
await fire(
|
|
4833
|
+
spec.schemas.end,
|
|
4834
|
+
{
|
|
4835
|
+
...spec.countKey === void 0 ? {} : { count: countOf(result, spec.countKey) },
|
|
4836
|
+
duration_ms: duration
|
|
4837
|
+
},
|
|
4838
|
+
await spec.endFields?.(ctx, request, served)
|
|
4839
|
+
);
|
|
4755
4840
|
return result;
|
|
4756
4841
|
} catch (err) {
|
|
4757
4842
|
await fire(spec.schemas.error, {
|
|
@@ -4871,7 +4956,8 @@ var LIFECYCLE_SPECS = [
|
|
|
4871
4956
|
},
|
|
4872
4957
|
countKey: "tools",
|
|
4873
4958
|
startParams: NO_PARAMS,
|
|
4874
|
-
rewriteResult: (ctx, result, caller) => ctx.perCaller?.toolsFor(result, caller) ?? result
|
|
4959
|
+
rewriteResult: (ctx, result, caller) => ctx.perCaller?.toolsFor(result, caller) ?? result,
|
|
4960
|
+
endFields: listedSurfaceFields
|
|
4875
4961
|
}
|
|
4876
4962
|
];
|
|
4877
4963
|
function installLifecycleSeams(lowLevel, ctx) {
|
|
@@ -5115,6 +5201,8 @@ function wireEntry(name, entry, ctx) {
|
|
|
5115
5201
|
}
|
|
5116
5202
|
if (u.paramsSchema !== void 0) {
|
|
5117
5203
|
captureAndInject(nameRef.current, entry, ctx);
|
|
5204
|
+
} else if (u.outputSchema !== void 0) {
|
|
5205
|
+
ctx.surfaceState.setOutputSchema(nameRef.current, ctx.vendorOutputJsonSchema(entry));
|
|
5118
5206
|
}
|
|
5119
5207
|
if (typeof u.enabled === "boolean") {
|
|
5120
5208
|
ctx.surfaceState.setToolEnabled(nameRef.current, u.enabled);
|
|
@@ -5240,7 +5328,7 @@ function install(server, supplied, resolved, { sentSurfaces, warned: warned4, co
|
|
|
5240
5328
|
const counter2 = new ServerCounter(sharedCounter, fallbackSessionId);
|
|
5241
5329
|
const tenantId = resolveTenantId(config.tenantId, config.vendorId);
|
|
5242
5330
|
const serverMeta = buildServerMeta(lowLevel);
|
|
5243
|
-
const surfaceState = new SurfaceState(serverMeta, sentSurfaces);
|
|
5331
|
+
const surfaceState = new SurfaceState(serverMeta, sentSurfaces, shape === "mcpServer");
|
|
5244
5332
|
const emitSurface = async (sessionId, digest, snapshot) => {
|
|
5245
5333
|
await emit(
|
|
5246
5334
|
sink,
|
|
@@ -5300,6 +5388,15 @@ function install(server, supplied, resolved, { sentSurfaces, warned: warned4, co
|
|
|
5300
5388
|
return EMPTY_OBJECT_JSON_SCHEMA;
|
|
5301
5389
|
}
|
|
5302
5390
|
};
|
|
5391
|
+
const vendorOutputJsonSchema = (entry) => {
|
|
5392
|
+
try {
|
|
5393
|
+
const tool = entry;
|
|
5394
|
+
if (!isV2Server) return toolOutputJsonSchema(tool.outputSchema);
|
|
5395
|
+
return isRecord(tool.outputSchemaJson) ? tool.outputSchemaJson : void 0;
|
|
5396
|
+
} catch {
|
|
5397
|
+
return void 0;
|
|
5398
|
+
}
|
|
5399
|
+
};
|
|
5303
5400
|
installValidationProbe(server);
|
|
5304
5401
|
const ctx = {
|
|
5305
5402
|
sink,
|
|
@@ -5319,6 +5416,7 @@ function install(server, supplied, resolved, { sentSurfaces, warned: warned4, co
|
|
|
5319
5416
|
captureSettings: config.captureSettings,
|
|
5320
5417
|
perCaller: void 0,
|
|
5321
5418
|
vendorToolJsonSchema,
|
|
5419
|
+
vendorOutputJsonSchema,
|
|
5322
5420
|
bustSchemaMemo,
|
|
5323
5421
|
dropSubagentClause,
|
|
5324
5422
|
servedInstructions: () => lowLevel._instructions,
|
|
@@ -5807,7 +5905,7 @@ var Serving = class {
|
|
|
5807
5905
|
annotationToolName: report?.tool.name ?? "",
|
|
5808
5906
|
injectsGoal: (name) => known.dispositions.get(name)?.[USER_GOAL_PARAM_NAME] === "injected"
|
|
5809
5907
|
});
|
|
5810
|
-
const whole =
|
|
5908
|
+
const whole = isWholeList(request.params.cursor, result.nextCursor) ? surface : null;
|
|
5811
5909
|
return {
|
|
5812
5910
|
answer: { ...answer, result: listed },
|
|
5813
5911
|
surface: whole,
|