labgate 0.5.45 → 0.5.47
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 +2 -0
- package/dist/cli.js +2 -1
- package/dist/cli.js.map +1 -1
- package/dist/lib/config.d.ts +1 -1
- package/dist/lib/config.js +1 -1
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/container.d.ts +4 -0
- package/dist/lib/container.js +157 -16
- package/dist/lib/container.js.map +1 -1
- package/dist/lib/init.js +1 -1
- package/dist/lib/ui.html +1 -12
- package/dist/lib/ui.js +3 -0
- package/dist/lib/ui.js.map +1 -1
- package/dist/mcp-bundles/cluster-mcp.bundle.mjs +185 -10
- package/dist/mcp-bundles/dataset-mcp.bundle.mjs +186 -11
- package/dist/mcp-bundles/display-mcp.bundle.mjs +186 -11
- package/dist/mcp-bundles/explorer-mcp.bundle.mjs +419 -11
- package/dist/mcp-bundles/results-mcp.bundle.mjs +186 -11
- package/dist/mcp-bundles/slurm-mcp.bundle.mjs +186 -11
- package/package.json +12 -1
|
@@ -3943,7 +3943,7 @@ var require_core = __commonJS({
|
|
|
3943
3943
|
constructor(opts = {}) {
|
|
3944
3944
|
this.schemas = {};
|
|
3945
3945
|
this.refs = {};
|
|
3946
|
-
this.formats =
|
|
3946
|
+
this.formats = /* @__PURE__ */ Object.create(null);
|
|
3947
3947
|
this._compilations = /* @__PURE__ */ new Set();
|
|
3948
3948
|
this._loading = {};
|
|
3949
3949
|
this._cache = /* @__PURE__ */ new Map();
|
|
@@ -4724,6 +4724,7 @@ var require_pattern = __commonJS({
|
|
|
4724
4724
|
"use strict";
|
|
4725
4725
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4726
4726
|
var code_1 = require_code2();
|
|
4727
|
+
var util_1 = require_util();
|
|
4727
4728
|
var codegen_1 = require_codegen();
|
|
4728
4729
|
var error48 = {
|
|
4729
4730
|
message: ({ schemaCode }) => (0, codegen_1.str)`must match pattern "${schemaCode}"`,
|
|
@@ -4736,10 +4737,18 @@ var require_pattern = __commonJS({
|
|
|
4736
4737
|
$data: true,
|
|
4737
4738
|
error: error48,
|
|
4738
4739
|
code(cxt) {
|
|
4739
|
-
const { data, $data, schema, schemaCode, it } = cxt;
|
|
4740
|
+
const { gen, data, $data, schema, schemaCode, it } = cxt;
|
|
4740
4741
|
const u = it.opts.unicodeRegExp ? "u" : "";
|
|
4741
|
-
|
|
4742
|
-
|
|
4742
|
+
if ($data) {
|
|
4743
|
+
const { regExp } = it.opts.code;
|
|
4744
|
+
const regExpCode = regExp.code === "new RegExp" ? (0, codegen_1._)`new RegExp` : (0, util_1.useFunc)(gen, regExp);
|
|
4745
|
+
const valid = gen.let("valid");
|
|
4746
|
+
gen.try(() => gen.assign(valid, (0, codegen_1._)`${regExpCode}(${schemaCode}, ${u}).test(${data})`), () => gen.assign(valid, false));
|
|
4747
|
+
cxt.fail$data((0, codegen_1._)`!${valid}`);
|
|
4748
|
+
} else {
|
|
4749
|
+
const regExp = (0, code_1.usePattern)(cxt, schema);
|
|
4750
|
+
cxt.fail$data((0, codegen_1._)`!${regExp}.test(${data})`);
|
|
4751
|
+
}
|
|
4743
4752
|
}
|
|
4744
4753
|
};
|
|
4745
4754
|
exports.default = def;
|
|
@@ -24635,10 +24644,9 @@ var ProgressTokenSchema = union([string2(), number2().int()]);
|
|
|
24635
24644
|
var CursorSchema = string2();
|
|
24636
24645
|
var TaskCreationParamsSchema = looseObject({
|
|
24637
24646
|
/**
|
|
24638
|
-
*
|
|
24639
|
-
* If null, the task has unlimited lifetime until manually cleaned up.
|
|
24647
|
+
* Requested duration in milliseconds to retain task from creation.
|
|
24640
24648
|
*/
|
|
24641
|
-
ttl:
|
|
24649
|
+
ttl: number2().optional(),
|
|
24642
24650
|
/**
|
|
24643
24651
|
* Time in milliseconds to wait between task status requests.
|
|
24644
24652
|
*/
|
|
@@ -24938,7 +24946,11 @@ var ClientCapabilitiesSchema = object2({
|
|
|
24938
24946
|
/**
|
|
24939
24947
|
* Present if the client supports task creation.
|
|
24940
24948
|
*/
|
|
24941
|
-
tasks: ClientTasksCapabilitySchema.optional()
|
|
24949
|
+
tasks: ClientTasksCapabilitySchema.optional(),
|
|
24950
|
+
/**
|
|
24951
|
+
* Extensions that the client supports. Keys are extension identifiers (vendor-prefix/extension-name).
|
|
24952
|
+
*/
|
|
24953
|
+
extensions: record(string2(), AssertObjectSchema).optional()
|
|
24942
24954
|
});
|
|
24943
24955
|
var InitializeRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
24944
24956
|
/**
|
|
@@ -24999,7 +25011,11 @@ var ServerCapabilitiesSchema = object2({
|
|
|
24999
25011
|
/**
|
|
25000
25012
|
* Present if the server supports task creation.
|
|
25001
25013
|
*/
|
|
25002
|
-
tasks: ServerTasksCapabilitySchema.optional()
|
|
25014
|
+
tasks: ServerTasksCapabilitySchema.optional(),
|
|
25015
|
+
/**
|
|
25016
|
+
* Extensions that the server supports. Keys are extension identifiers (vendor-prefix/extension-name).
|
|
25017
|
+
*/
|
|
25018
|
+
extensions: record(string2(), AssertObjectSchema).optional()
|
|
25003
25019
|
});
|
|
25004
25020
|
var InitializeResultSchema = ResultSchema.extend({
|
|
25005
25021
|
/**
|
|
@@ -25191,6 +25207,12 @@ var ResourceSchema = object2({
|
|
|
25191
25207
|
* The MIME type of this resource, if known.
|
|
25192
25208
|
*/
|
|
25193
25209
|
mimeType: optional(string2()),
|
|
25210
|
+
/**
|
|
25211
|
+
* The size of the raw resource content, in bytes (i.e., before base64 encoding or any tokenization), if known.
|
|
25212
|
+
*
|
|
25213
|
+
* This can be used by Hosts to display file sizes and estimate context window usage.
|
|
25214
|
+
*/
|
|
25215
|
+
size: optional(number2()),
|
|
25194
25216
|
/**
|
|
25195
25217
|
* Optional annotations for the client.
|
|
25196
25218
|
*/
|
|
@@ -27686,6 +27708,10 @@ var Protocol = class {
|
|
|
27686
27708
|
this._progressHandlers.clear();
|
|
27687
27709
|
this._taskProgressTokens.clear();
|
|
27688
27710
|
this._pendingDebouncedNotifications.clear();
|
|
27711
|
+
for (const info of this._timeoutInfo.values()) {
|
|
27712
|
+
clearTimeout(info.timeoutId);
|
|
27713
|
+
}
|
|
27714
|
+
this._timeoutInfo.clear();
|
|
27689
27715
|
for (const controller of this._requestHandlerAbortControllers.values()) {
|
|
27690
27716
|
controller.abort();
|
|
27691
27717
|
}
|
|
@@ -27816,7 +27842,9 @@ var Protocol = class {
|
|
|
27816
27842
|
await capturedTransport?.send(errorResponse);
|
|
27817
27843
|
}
|
|
27818
27844
|
}).catch((error48) => this._onerror(new Error(`Failed to send response: ${error48}`))).finally(() => {
|
|
27819
|
-
this._requestHandlerAbortControllers.
|
|
27845
|
+
if (this._requestHandlerAbortControllers.get(request.id) === abortController) {
|
|
27846
|
+
this._requestHandlerAbortControllers.delete(request.id);
|
|
27847
|
+
}
|
|
27820
27848
|
});
|
|
27821
27849
|
}
|
|
27822
27850
|
_onprogress(notification) {
|
|
@@ -28512,6 +28540,147 @@ var ExperimentalServerTasks = class {
|
|
|
28512
28540
|
requestStream(request, resultSchema, options) {
|
|
28513
28541
|
return this._server.requestStream(request, resultSchema, options);
|
|
28514
28542
|
}
|
|
28543
|
+
/**
|
|
28544
|
+
* Sends a sampling request and returns an AsyncGenerator that yields response messages.
|
|
28545
|
+
* The generator is guaranteed to end with either a 'result' or 'error' message.
|
|
28546
|
+
*
|
|
28547
|
+
* For task-augmented requests, yields 'taskCreated' and 'taskStatus' messages
|
|
28548
|
+
* before the final result.
|
|
28549
|
+
*
|
|
28550
|
+
* @example
|
|
28551
|
+
* ```typescript
|
|
28552
|
+
* const stream = server.experimental.tasks.createMessageStream({
|
|
28553
|
+
* messages: [{ role: 'user', content: { type: 'text', text: 'Hello' } }],
|
|
28554
|
+
* maxTokens: 100
|
|
28555
|
+
* }, {
|
|
28556
|
+
* onprogress: (progress) => {
|
|
28557
|
+
* // Handle streaming tokens via progress notifications
|
|
28558
|
+
* console.log('Progress:', progress.message);
|
|
28559
|
+
* }
|
|
28560
|
+
* });
|
|
28561
|
+
*
|
|
28562
|
+
* for await (const message of stream) {
|
|
28563
|
+
* switch (message.type) {
|
|
28564
|
+
* case 'taskCreated':
|
|
28565
|
+
* console.log('Task created:', message.task.taskId);
|
|
28566
|
+
* break;
|
|
28567
|
+
* case 'taskStatus':
|
|
28568
|
+
* console.log('Task status:', message.task.status);
|
|
28569
|
+
* break;
|
|
28570
|
+
* case 'result':
|
|
28571
|
+
* console.log('Final result:', message.result);
|
|
28572
|
+
* break;
|
|
28573
|
+
* case 'error':
|
|
28574
|
+
* console.error('Error:', message.error);
|
|
28575
|
+
* break;
|
|
28576
|
+
* }
|
|
28577
|
+
* }
|
|
28578
|
+
* ```
|
|
28579
|
+
*
|
|
28580
|
+
* @param params - The sampling request parameters
|
|
28581
|
+
* @param options - Optional request options (timeout, signal, task creation params, onprogress, etc.)
|
|
28582
|
+
* @returns AsyncGenerator that yields ResponseMessage objects
|
|
28583
|
+
*
|
|
28584
|
+
* @experimental
|
|
28585
|
+
*/
|
|
28586
|
+
createMessageStream(params, options) {
|
|
28587
|
+
const clientCapabilities = this._server.getClientCapabilities();
|
|
28588
|
+
if ((params.tools || params.toolChoice) && !clientCapabilities?.sampling?.tools) {
|
|
28589
|
+
throw new Error("Client does not support sampling tools capability.");
|
|
28590
|
+
}
|
|
28591
|
+
if (params.messages.length > 0) {
|
|
28592
|
+
const lastMessage = params.messages[params.messages.length - 1];
|
|
28593
|
+
const lastContent = Array.isArray(lastMessage.content) ? lastMessage.content : [lastMessage.content];
|
|
28594
|
+
const hasToolResults = lastContent.some((c) => c.type === "tool_result");
|
|
28595
|
+
const previousMessage = params.messages.length > 1 ? params.messages[params.messages.length - 2] : void 0;
|
|
28596
|
+
const previousContent = previousMessage ? Array.isArray(previousMessage.content) ? previousMessage.content : [previousMessage.content] : [];
|
|
28597
|
+
const hasPreviousToolUse = previousContent.some((c) => c.type === "tool_use");
|
|
28598
|
+
if (hasToolResults) {
|
|
28599
|
+
if (lastContent.some((c) => c.type !== "tool_result")) {
|
|
28600
|
+
throw new Error("The last message must contain only tool_result content if any is present");
|
|
28601
|
+
}
|
|
28602
|
+
if (!hasPreviousToolUse) {
|
|
28603
|
+
throw new Error("tool_result blocks are not matching any tool_use from the previous message");
|
|
28604
|
+
}
|
|
28605
|
+
}
|
|
28606
|
+
if (hasPreviousToolUse) {
|
|
28607
|
+
const toolUseIds = new Set(previousContent.filter((c) => c.type === "tool_use").map((c) => c.id));
|
|
28608
|
+
const toolResultIds = new Set(lastContent.filter((c) => c.type === "tool_result").map((c) => c.toolUseId));
|
|
28609
|
+
if (toolUseIds.size !== toolResultIds.size || ![...toolUseIds].every((id) => toolResultIds.has(id))) {
|
|
28610
|
+
throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match");
|
|
28611
|
+
}
|
|
28612
|
+
}
|
|
28613
|
+
}
|
|
28614
|
+
return this.requestStream({
|
|
28615
|
+
method: "sampling/createMessage",
|
|
28616
|
+
params
|
|
28617
|
+
}, CreateMessageResultSchema, options);
|
|
28618
|
+
}
|
|
28619
|
+
/**
|
|
28620
|
+
* Sends an elicitation request and returns an AsyncGenerator that yields response messages.
|
|
28621
|
+
* The generator is guaranteed to end with either a 'result' or 'error' message.
|
|
28622
|
+
*
|
|
28623
|
+
* For task-augmented requests (especially URL-based elicitation), yields 'taskCreated'
|
|
28624
|
+
* and 'taskStatus' messages before the final result.
|
|
28625
|
+
*
|
|
28626
|
+
* @example
|
|
28627
|
+
* ```typescript
|
|
28628
|
+
* const stream = server.experimental.tasks.elicitInputStream({
|
|
28629
|
+
* mode: 'url',
|
|
28630
|
+
* message: 'Please authenticate',
|
|
28631
|
+
* elicitationId: 'auth-123',
|
|
28632
|
+
* url: 'https://example.com/auth'
|
|
28633
|
+
* }, {
|
|
28634
|
+
* task: { ttl: 300000 } // Task-augmented for long-running auth flow
|
|
28635
|
+
* });
|
|
28636
|
+
*
|
|
28637
|
+
* for await (const message of stream) {
|
|
28638
|
+
* switch (message.type) {
|
|
28639
|
+
* case 'taskCreated':
|
|
28640
|
+
* console.log('Task created:', message.task.taskId);
|
|
28641
|
+
* break;
|
|
28642
|
+
* case 'taskStatus':
|
|
28643
|
+
* console.log('Task status:', message.task.status);
|
|
28644
|
+
* break;
|
|
28645
|
+
* case 'result':
|
|
28646
|
+
* console.log('User action:', message.result.action);
|
|
28647
|
+
* break;
|
|
28648
|
+
* case 'error':
|
|
28649
|
+
* console.error('Error:', message.error);
|
|
28650
|
+
* break;
|
|
28651
|
+
* }
|
|
28652
|
+
* }
|
|
28653
|
+
* ```
|
|
28654
|
+
*
|
|
28655
|
+
* @param params - The elicitation request parameters
|
|
28656
|
+
* @param options - Optional request options (timeout, signal, task creation params, etc.)
|
|
28657
|
+
* @returns AsyncGenerator that yields ResponseMessage objects
|
|
28658
|
+
*
|
|
28659
|
+
* @experimental
|
|
28660
|
+
*/
|
|
28661
|
+
elicitInputStream(params, options) {
|
|
28662
|
+
const clientCapabilities = this._server.getClientCapabilities();
|
|
28663
|
+
const mode = params.mode ?? "form";
|
|
28664
|
+
switch (mode) {
|
|
28665
|
+
case "url": {
|
|
28666
|
+
if (!clientCapabilities?.elicitation?.url) {
|
|
28667
|
+
throw new Error("Client does not support url elicitation.");
|
|
28668
|
+
}
|
|
28669
|
+
break;
|
|
28670
|
+
}
|
|
28671
|
+
case "form": {
|
|
28672
|
+
if (!clientCapabilities?.elicitation?.form) {
|
|
28673
|
+
throw new Error("Client does not support form elicitation.");
|
|
28674
|
+
}
|
|
28675
|
+
break;
|
|
28676
|
+
}
|
|
28677
|
+
}
|
|
28678
|
+
const normalizedParams = mode === "form" && params.mode === void 0 ? { ...params, mode: "form" } : params;
|
|
28679
|
+
return this.requestStream({
|
|
28680
|
+
method: "elicitation/create",
|
|
28681
|
+
params: normalizedParams
|
|
28682
|
+
}, ElicitResultSchema, options);
|
|
28683
|
+
}
|
|
28515
28684
|
/**
|
|
28516
28685
|
* Gets the current status of a task.
|
|
28517
28686
|
*
|
|
@@ -29688,6 +29857,9 @@ var McpServer = class {
|
|
|
29688
29857
|
annotations = rest.shift();
|
|
29689
29858
|
}
|
|
29690
29859
|
} else if (typeof firstArg === "object" && firstArg !== null) {
|
|
29860
|
+
if (Object.values(firstArg).some((v) => typeof v === "object" && v !== null)) {
|
|
29861
|
+
throw new Error(`Tool ${name} expected a Zod schema or ToolAnnotations, but received an unrecognized object`);
|
|
29862
|
+
}
|
|
29691
29863
|
annotations = rest.shift();
|
|
29692
29864
|
}
|
|
29693
29865
|
}
|
|
@@ -29806,6 +29978,9 @@ function getZodSchemaObject(schema) {
|
|
|
29806
29978
|
if (isZodRawShapeCompat(schema)) {
|
|
29807
29979
|
return objectFromShape(schema);
|
|
29808
29980
|
}
|
|
29981
|
+
if (!isZodSchemaInstance(schema)) {
|
|
29982
|
+
throw new Error("inputSchema must be a Zod schema or raw shape, received an unrecognized object");
|
|
29983
|
+
}
|
|
29809
29984
|
return schema;
|
|
29810
29985
|
}
|
|
29811
29986
|
function promptArgumentsFromSchema(schema) {
|
|
@@ -3943,7 +3943,7 @@ var require_core = __commonJS({
|
|
|
3943
3943
|
constructor(opts = {}) {
|
|
3944
3944
|
this.schemas = {};
|
|
3945
3945
|
this.refs = {};
|
|
3946
|
-
this.formats =
|
|
3946
|
+
this.formats = /* @__PURE__ */ Object.create(null);
|
|
3947
3947
|
this._compilations = /* @__PURE__ */ new Set();
|
|
3948
3948
|
this._loading = {};
|
|
3949
3949
|
this._cache = /* @__PURE__ */ new Map();
|
|
@@ -4724,6 +4724,7 @@ var require_pattern = __commonJS({
|
|
|
4724
4724
|
"use strict";
|
|
4725
4725
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4726
4726
|
var code_1 = require_code2();
|
|
4727
|
+
var util_1 = require_util();
|
|
4727
4728
|
var codegen_1 = require_codegen();
|
|
4728
4729
|
var error48 = {
|
|
4729
4730
|
message: ({ schemaCode }) => (0, codegen_1.str)`must match pattern "${schemaCode}"`,
|
|
@@ -4736,10 +4737,18 @@ var require_pattern = __commonJS({
|
|
|
4736
4737
|
$data: true,
|
|
4737
4738
|
error: error48,
|
|
4738
4739
|
code(cxt) {
|
|
4739
|
-
const { data, $data, schema, schemaCode, it } = cxt;
|
|
4740
|
+
const { gen, data, $data, schema, schemaCode, it } = cxt;
|
|
4740
4741
|
const u = it.opts.unicodeRegExp ? "u" : "";
|
|
4741
|
-
|
|
4742
|
-
|
|
4742
|
+
if ($data) {
|
|
4743
|
+
const { regExp } = it.opts.code;
|
|
4744
|
+
const regExpCode = regExp.code === "new RegExp" ? (0, codegen_1._)`new RegExp` : (0, util_1.useFunc)(gen, regExp);
|
|
4745
|
+
const valid = gen.let("valid");
|
|
4746
|
+
gen.try(() => gen.assign(valid, (0, codegen_1._)`${regExpCode}(${schemaCode}, ${u}).test(${data})`), () => gen.assign(valid, false));
|
|
4747
|
+
cxt.fail$data((0, codegen_1._)`!${valid}`);
|
|
4748
|
+
} else {
|
|
4749
|
+
const regExp = (0, code_1.usePattern)(cxt, schema);
|
|
4750
|
+
cxt.fail$data((0, codegen_1._)`!${regExp}.test(${data})`);
|
|
4751
|
+
}
|
|
4743
4752
|
}
|
|
4744
4753
|
};
|
|
4745
4754
|
exports.default = def;
|
|
@@ -24631,10 +24640,9 @@ var ProgressTokenSchema = union([string2(), number2().int()]);
|
|
|
24631
24640
|
var CursorSchema = string2();
|
|
24632
24641
|
var TaskCreationParamsSchema = looseObject({
|
|
24633
24642
|
/**
|
|
24634
|
-
*
|
|
24635
|
-
* If null, the task has unlimited lifetime until manually cleaned up.
|
|
24643
|
+
* Requested duration in milliseconds to retain task from creation.
|
|
24636
24644
|
*/
|
|
24637
|
-
ttl:
|
|
24645
|
+
ttl: number2().optional(),
|
|
24638
24646
|
/**
|
|
24639
24647
|
* Time in milliseconds to wait between task status requests.
|
|
24640
24648
|
*/
|
|
@@ -24934,7 +24942,11 @@ var ClientCapabilitiesSchema = object2({
|
|
|
24934
24942
|
/**
|
|
24935
24943
|
* Present if the client supports task creation.
|
|
24936
24944
|
*/
|
|
24937
|
-
tasks: ClientTasksCapabilitySchema.optional()
|
|
24945
|
+
tasks: ClientTasksCapabilitySchema.optional(),
|
|
24946
|
+
/**
|
|
24947
|
+
* Extensions that the client supports. Keys are extension identifiers (vendor-prefix/extension-name).
|
|
24948
|
+
*/
|
|
24949
|
+
extensions: record(string2(), AssertObjectSchema).optional()
|
|
24938
24950
|
});
|
|
24939
24951
|
var InitializeRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
24940
24952
|
/**
|
|
@@ -24995,7 +25007,11 @@ var ServerCapabilitiesSchema = object2({
|
|
|
24995
25007
|
/**
|
|
24996
25008
|
* Present if the server supports task creation.
|
|
24997
25009
|
*/
|
|
24998
|
-
tasks: ServerTasksCapabilitySchema.optional()
|
|
25010
|
+
tasks: ServerTasksCapabilitySchema.optional(),
|
|
25011
|
+
/**
|
|
25012
|
+
* Extensions that the server supports. Keys are extension identifiers (vendor-prefix/extension-name).
|
|
25013
|
+
*/
|
|
25014
|
+
extensions: record(string2(), AssertObjectSchema).optional()
|
|
24999
25015
|
});
|
|
25000
25016
|
var InitializeResultSchema = ResultSchema.extend({
|
|
25001
25017
|
/**
|
|
@@ -25187,6 +25203,12 @@ var ResourceSchema = object2({
|
|
|
25187
25203
|
* The MIME type of this resource, if known.
|
|
25188
25204
|
*/
|
|
25189
25205
|
mimeType: optional(string2()),
|
|
25206
|
+
/**
|
|
25207
|
+
* The size of the raw resource content, in bytes (i.e., before base64 encoding or any tokenization), if known.
|
|
25208
|
+
*
|
|
25209
|
+
* This can be used by Hosts to display file sizes and estimate context window usage.
|
|
25210
|
+
*/
|
|
25211
|
+
size: optional(number2()),
|
|
25190
25212
|
/**
|
|
25191
25213
|
* Optional annotations for the client.
|
|
25192
25214
|
*/
|
|
@@ -27682,6 +27704,10 @@ var Protocol = class {
|
|
|
27682
27704
|
this._progressHandlers.clear();
|
|
27683
27705
|
this._taskProgressTokens.clear();
|
|
27684
27706
|
this._pendingDebouncedNotifications.clear();
|
|
27707
|
+
for (const info of this._timeoutInfo.values()) {
|
|
27708
|
+
clearTimeout(info.timeoutId);
|
|
27709
|
+
}
|
|
27710
|
+
this._timeoutInfo.clear();
|
|
27685
27711
|
for (const controller of this._requestHandlerAbortControllers.values()) {
|
|
27686
27712
|
controller.abort();
|
|
27687
27713
|
}
|
|
@@ -27812,7 +27838,9 @@ var Protocol = class {
|
|
|
27812
27838
|
await capturedTransport?.send(errorResponse);
|
|
27813
27839
|
}
|
|
27814
27840
|
}).catch((error48) => this._onerror(new Error(`Failed to send response: ${error48}`))).finally(() => {
|
|
27815
|
-
this._requestHandlerAbortControllers.
|
|
27841
|
+
if (this._requestHandlerAbortControllers.get(request.id) === abortController) {
|
|
27842
|
+
this._requestHandlerAbortControllers.delete(request.id);
|
|
27843
|
+
}
|
|
27816
27844
|
});
|
|
27817
27845
|
}
|
|
27818
27846
|
_onprogress(notification) {
|
|
@@ -28508,6 +28536,147 @@ var ExperimentalServerTasks = class {
|
|
|
28508
28536
|
requestStream(request, resultSchema, options) {
|
|
28509
28537
|
return this._server.requestStream(request, resultSchema, options);
|
|
28510
28538
|
}
|
|
28539
|
+
/**
|
|
28540
|
+
* Sends a sampling request and returns an AsyncGenerator that yields response messages.
|
|
28541
|
+
* The generator is guaranteed to end with either a 'result' or 'error' message.
|
|
28542
|
+
*
|
|
28543
|
+
* For task-augmented requests, yields 'taskCreated' and 'taskStatus' messages
|
|
28544
|
+
* before the final result.
|
|
28545
|
+
*
|
|
28546
|
+
* @example
|
|
28547
|
+
* ```typescript
|
|
28548
|
+
* const stream = server.experimental.tasks.createMessageStream({
|
|
28549
|
+
* messages: [{ role: 'user', content: { type: 'text', text: 'Hello' } }],
|
|
28550
|
+
* maxTokens: 100
|
|
28551
|
+
* }, {
|
|
28552
|
+
* onprogress: (progress) => {
|
|
28553
|
+
* // Handle streaming tokens via progress notifications
|
|
28554
|
+
* console.log('Progress:', progress.message);
|
|
28555
|
+
* }
|
|
28556
|
+
* });
|
|
28557
|
+
*
|
|
28558
|
+
* for await (const message of stream) {
|
|
28559
|
+
* switch (message.type) {
|
|
28560
|
+
* case 'taskCreated':
|
|
28561
|
+
* console.log('Task created:', message.task.taskId);
|
|
28562
|
+
* break;
|
|
28563
|
+
* case 'taskStatus':
|
|
28564
|
+
* console.log('Task status:', message.task.status);
|
|
28565
|
+
* break;
|
|
28566
|
+
* case 'result':
|
|
28567
|
+
* console.log('Final result:', message.result);
|
|
28568
|
+
* break;
|
|
28569
|
+
* case 'error':
|
|
28570
|
+
* console.error('Error:', message.error);
|
|
28571
|
+
* break;
|
|
28572
|
+
* }
|
|
28573
|
+
* }
|
|
28574
|
+
* ```
|
|
28575
|
+
*
|
|
28576
|
+
* @param params - The sampling request parameters
|
|
28577
|
+
* @param options - Optional request options (timeout, signal, task creation params, onprogress, etc.)
|
|
28578
|
+
* @returns AsyncGenerator that yields ResponseMessage objects
|
|
28579
|
+
*
|
|
28580
|
+
* @experimental
|
|
28581
|
+
*/
|
|
28582
|
+
createMessageStream(params, options) {
|
|
28583
|
+
const clientCapabilities = this._server.getClientCapabilities();
|
|
28584
|
+
if ((params.tools || params.toolChoice) && !clientCapabilities?.sampling?.tools) {
|
|
28585
|
+
throw new Error("Client does not support sampling tools capability.");
|
|
28586
|
+
}
|
|
28587
|
+
if (params.messages.length > 0) {
|
|
28588
|
+
const lastMessage = params.messages[params.messages.length - 1];
|
|
28589
|
+
const lastContent = Array.isArray(lastMessage.content) ? lastMessage.content : [lastMessage.content];
|
|
28590
|
+
const hasToolResults = lastContent.some((c) => c.type === "tool_result");
|
|
28591
|
+
const previousMessage = params.messages.length > 1 ? params.messages[params.messages.length - 2] : void 0;
|
|
28592
|
+
const previousContent = previousMessage ? Array.isArray(previousMessage.content) ? previousMessage.content : [previousMessage.content] : [];
|
|
28593
|
+
const hasPreviousToolUse = previousContent.some((c) => c.type === "tool_use");
|
|
28594
|
+
if (hasToolResults) {
|
|
28595
|
+
if (lastContent.some((c) => c.type !== "tool_result")) {
|
|
28596
|
+
throw new Error("The last message must contain only tool_result content if any is present");
|
|
28597
|
+
}
|
|
28598
|
+
if (!hasPreviousToolUse) {
|
|
28599
|
+
throw new Error("tool_result blocks are not matching any tool_use from the previous message");
|
|
28600
|
+
}
|
|
28601
|
+
}
|
|
28602
|
+
if (hasPreviousToolUse) {
|
|
28603
|
+
const toolUseIds = new Set(previousContent.filter((c) => c.type === "tool_use").map((c) => c.id));
|
|
28604
|
+
const toolResultIds = new Set(lastContent.filter((c) => c.type === "tool_result").map((c) => c.toolUseId));
|
|
28605
|
+
if (toolUseIds.size !== toolResultIds.size || ![...toolUseIds].every((id) => toolResultIds.has(id))) {
|
|
28606
|
+
throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match");
|
|
28607
|
+
}
|
|
28608
|
+
}
|
|
28609
|
+
}
|
|
28610
|
+
return this.requestStream({
|
|
28611
|
+
method: "sampling/createMessage",
|
|
28612
|
+
params
|
|
28613
|
+
}, CreateMessageResultSchema, options);
|
|
28614
|
+
}
|
|
28615
|
+
/**
|
|
28616
|
+
* Sends an elicitation request and returns an AsyncGenerator that yields response messages.
|
|
28617
|
+
* The generator is guaranteed to end with either a 'result' or 'error' message.
|
|
28618
|
+
*
|
|
28619
|
+
* For task-augmented requests (especially URL-based elicitation), yields 'taskCreated'
|
|
28620
|
+
* and 'taskStatus' messages before the final result.
|
|
28621
|
+
*
|
|
28622
|
+
* @example
|
|
28623
|
+
* ```typescript
|
|
28624
|
+
* const stream = server.experimental.tasks.elicitInputStream({
|
|
28625
|
+
* mode: 'url',
|
|
28626
|
+
* message: 'Please authenticate',
|
|
28627
|
+
* elicitationId: 'auth-123',
|
|
28628
|
+
* url: 'https://example.com/auth'
|
|
28629
|
+
* }, {
|
|
28630
|
+
* task: { ttl: 300000 } // Task-augmented for long-running auth flow
|
|
28631
|
+
* });
|
|
28632
|
+
*
|
|
28633
|
+
* for await (const message of stream) {
|
|
28634
|
+
* switch (message.type) {
|
|
28635
|
+
* case 'taskCreated':
|
|
28636
|
+
* console.log('Task created:', message.task.taskId);
|
|
28637
|
+
* break;
|
|
28638
|
+
* case 'taskStatus':
|
|
28639
|
+
* console.log('Task status:', message.task.status);
|
|
28640
|
+
* break;
|
|
28641
|
+
* case 'result':
|
|
28642
|
+
* console.log('User action:', message.result.action);
|
|
28643
|
+
* break;
|
|
28644
|
+
* case 'error':
|
|
28645
|
+
* console.error('Error:', message.error);
|
|
28646
|
+
* break;
|
|
28647
|
+
* }
|
|
28648
|
+
* }
|
|
28649
|
+
* ```
|
|
28650
|
+
*
|
|
28651
|
+
* @param params - The elicitation request parameters
|
|
28652
|
+
* @param options - Optional request options (timeout, signal, task creation params, etc.)
|
|
28653
|
+
* @returns AsyncGenerator that yields ResponseMessage objects
|
|
28654
|
+
*
|
|
28655
|
+
* @experimental
|
|
28656
|
+
*/
|
|
28657
|
+
elicitInputStream(params, options) {
|
|
28658
|
+
const clientCapabilities = this._server.getClientCapabilities();
|
|
28659
|
+
const mode = params.mode ?? "form";
|
|
28660
|
+
switch (mode) {
|
|
28661
|
+
case "url": {
|
|
28662
|
+
if (!clientCapabilities?.elicitation?.url) {
|
|
28663
|
+
throw new Error("Client does not support url elicitation.");
|
|
28664
|
+
}
|
|
28665
|
+
break;
|
|
28666
|
+
}
|
|
28667
|
+
case "form": {
|
|
28668
|
+
if (!clientCapabilities?.elicitation?.form) {
|
|
28669
|
+
throw new Error("Client does not support form elicitation.");
|
|
28670
|
+
}
|
|
28671
|
+
break;
|
|
28672
|
+
}
|
|
28673
|
+
}
|
|
28674
|
+
const normalizedParams = mode === "form" && params.mode === void 0 ? { ...params, mode: "form" } : params;
|
|
28675
|
+
return this.requestStream({
|
|
28676
|
+
method: "elicitation/create",
|
|
28677
|
+
params: normalizedParams
|
|
28678
|
+
}, ElicitResultSchema, options);
|
|
28679
|
+
}
|
|
28511
28680
|
/**
|
|
28512
28681
|
* Gets the current status of a task.
|
|
28513
28682
|
*
|
|
@@ -29684,6 +29853,9 @@ var McpServer = class {
|
|
|
29684
29853
|
annotations = rest.shift();
|
|
29685
29854
|
}
|
|
29686
29855
|
} else if (typeof firstArg === "object" && firstArg !== null) {
|
|
29856
|
+
if (Object.values(firstArg).some((v) => typeof v === "object" && v !== null)) {
|
|
29857
|
+
throw new Error(`Tool ${name} expected a Zod schema or ToolAnnotations, but received an unrecognized object`);
|
|
29858
|
+
}
|
|
29687
29859
|
annotations = rest.shift();
|
|
29688
29860
|
}
|
|
29689
29861
|
}
|
|
@@ -29802,6 +29974,9 @@ function getZodSchemaObject(schema) {
|
|
|
29802
29974
|
if (isZodRawShapeCompat(schema)) {
|
|
29803
29975
|
return objectFromShape(schema);
|
|
29804
29976
|
}
|
|
29977
|
+
if (!isZodSchemaInstance(schema)) {
|
|
29978
|
+
throw new Error("inputSchema must be a Zod schema or raw shape, received an unrecognized object");
|
|
29979
|
+
}
|
|
29805
29980
|
return schema;
|
|
29806
29981
|
}
|
|
29807
29982
|
function promptArgumentsFromSchema(schema) {
|
|
@@ -29945,7 +30120,7 @@ import { homedir } from "os";
|
|
|
29945
30120
|
var DEFAULT_CONFIG = {
|
|
29946
30121
|
runtime: "auto",
|
|
29947
30122
|
images_dir: "",
|
|
29948
|
-
// Default sandbox image
|
|
30123
|
+
// Default sandbox image is expected to include python3 + basic build tools (git/make/g++).
|
|
29949
30124
|
// Note: pip/venv are not included by default in Debian; users may still need a
|
|
29950
30125
|
// custom image for richer Python workflows.
|
|
29951
30126
|
image: "docker.io/library/node:20-bookworm",
|