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
|
@@ -3953,7 +3953,7 @@ var require_core = __commonJS({
|
|
|
3953
3953
|
constructor(opts = {}) {
|
|
3954
3954
|
this.schemas = {};
|
|
3955
3955
|
this.refs = {};
|
|
3956
|
-
this.formats =
|
|
3956
|
+
this.formats = /* @__PURE__ */ Object.create(null);
|
|
3957
3957
|
this._compilations = /* @__PURE__ */ new Set();
|
|
3958
3958
|
this._loading = {};
|
|
3959
3959
|
this._cache = /* @__PURE__ */ new Map();
|
|
@@ -4734,6 +4734,7 @@ var require_pattern = __commonJS({
|
|
|
4734
4734
|
"use strict";
|
|
4735
4735
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4736
4736
|
var code_1 = require_code2();
|
|
4737
|
+
var util_1 = require_util();
|
|
4737
4738
|
var codegen_1 = require_codegen();
|
|
4738
4739
|
var error49 = {
|
|
4739
4740
|
message: ({ schemaCode }) => (0, codegen_1.str)`must match pattern "${schemaCode}"`,
|
|
@@ -4746,10 +4747,18 @@ var require_pattern = __commonJS({
|
|
|
4746
4747
|
$data: true,
|
|
4747
4748
|
error: error49,
|
|
4748
4749
|
code(cxt) {
|
|
4749
|
-
const { data, $data, schema, schemaCode, it } = cxt;
|
|
4750
|
+
const { gen, data, $data, schema, schemaCode, it } = cxt;
|
|
4750
4751
|
const u = it.opts.unicodeRegExp ? "u" : "";
|
|
4751
|
-
|
|
4752
|
-
|
|
4752
|
+
if ($data) {
|
|
4753
|
+
const { regExp } = it.opts.code;
|
|
4754
|
+
const regExpCode = regExp.code === "new RegExp" ? (0, codegen_1._)`new RegExp` : (0, util_1.useFunc)(gen, regExp);
|
|
4755
|
+
const valid = gen.let("valid");
|
|
4756
|
+
gen.try(() => gen.assign(valid, (0, codegen_1._)`${regExpCode}(${schemaCode}, ${u}).test(${data})`), () => gen.assign(valid, false));
|
|
4757
|
+
cxt.fail$data((0, codegen_1._)`!${valid}`);
|
|
4758
|
+
} else {
|
|
4759
|
+
const regExp = (0, code_1.usePattern)(cxt, schema);
|
|
4760
|
+
cxt.fail$data((0, codegen_1._)`!${regExp}.test(${data})`);
|
|
4761
|
+
}
|
|
4753
4762
|
}
|
|
4754
4763
|
};
|
|
4755
4764
|
exports.default = def;
|
|
@@ -7703,7 +7712,7 @@ var init_config = __esm({
|
|
|
7703
7712
|
DEFAULT_CONFIG = {
|
|
7704
7713
|
runtime: "auto",
|
|
7705
7714
|
images_dir: "",
|
|
7706
|
-
// Default sandbox image
|
|
7715
|
+
// Default sandbox image is expected to include python3 + basic build tools (git/make/g++).
|
|
7707
7716
|
// Note: pip/venv are not included by default in Debian; users may still need a
|
|
7708
7717
|
// custom image for richer Python workflows.
|
|
7709
7718
|
image: "docker.io/library/node:20-bookworm",
|
|
@@ -9186,6 +9195,7 @@ var require_constants2 = __commonJS({
|
|
|
9186
9195
|
var path = __require("path");
|
|
9187
9196
|
var WIN_SLASH = "\\\\/";
|
|
9188
9197
|
var WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
9198
|
+
var DEFAULT_MAX_EXTGLOB_RECURSION = 0;
|
|
9189
9199
|
var DOT_LITERAL = "\\.";
|
|
9190
9200
|
var PLUS_LITERAL = "\\+";
|
|
9191
9201
|
var QMARK_LITERAL = "\\?";
|
|
@@ -9233,6 +9243,7 @@ var require_constants2 = __commonJS({
|
|
|
9233
9243
|
END_ANCHOR: `(?:[${WIN_SLASH}]|$)`
|
|
9234
9244
|
};
|
|
9235
9245
|
var POSIX_REGEX_SOURCE = {
|
|
9246
|
+
__proto__: null,
|
|
9236
9247
|
alnum: "a-zA-Z0-9",
|
|
9237
9248
|
alpha: "a-zA-Z",
|
|
9238
9249
|
ascii: "\\x00-\\x7F",
|
|
@@ -9249,6 +9260,7 @@ var require_constants2 = __commonJS({
|
|
|
9249
9260
|
xdigit: "A-Fa-f0-9"
|
|
9250
9261
|
};
|
|
9251
9262
|
module.exports = {
|
|
9263
|
+
DEFAULT_MAX_EXTGLOB_RECURSION,
|
|
9252
9264
|
MAX_LENGTH: 1024 * 64,
|
|
9253
9265
|
POSIX_REGEX_SOURCE,
|
|
9254
9266
|
// regular expressions
|
|
@@ -9260,6 +9272,7 @@ var require_constants2 = __commonJS({
|
|
|
9260
9272
|
REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
|
|
9261
9273
|
// Replace globs with equivalent patterns to reduce parsing time.
|
|
9262
9274
|
REPLACEMENTS: {
|
|
9275
|
+
__proto__: null,
|
|
9263
9276
|
"***": "*",
|
|
9264
9277
|
"**/**": "**",
|
|
9265
9278
|
"**/**/**": "**"
|
|
@@ -9796,6 +9809,213 @@ var require_parse2 = __commonJS({
|
|
|
9796
9809
|
var syntaxError = (type, char) => {
|
|
9797
9810
|
return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
|
|
9798
9811
|
};
|
|
9812
|
+
var splitTopLevel = (input) => {
|
|
9813
|
+
const parts = [];
|
|
9814
|
+
let bracket = 0;
|
|
9815
|
+
let paren = 0;
|
|
9816
|
+
let quote = 0;
|
|
9817
|
+
let value = "";
|
|
9818
|
+
let escaped = false;
|
|
9819
|
+
for (const ch of input) {
|
|
9820
|
+
if (escaped === true) {
|
|
9821
|
+
value += ch;
|
|
9822
|
+
escaped = false;
|
|
9823
|
+
continue;
|
|
9824
|
+
}
|
|
9825
|
+
if (ch === "\\") {
|
|
9826
|
+
value += ch;
|
|
9827
|
+
escaped = true;
|
|
9828
|
+
continue;
|
|
9829
|
+
}
|
|
9830
|
+
if (ch === '"') {
|
|
9831
|
+
quote = quote === 1 ? 0 : 1;
|
|
9832
|
+
value += ch;
|
|
9833
|
+
continue;
|
|
9834
|
+
}
|
|
9835
|
+
if (quote === 0) {
|
|
9836
|
+
if (ch === "[") {
|
|
9837
|
+
bracket++;
|
|
9838
|
+
} else if (ch === "]" && bracket > 0) {
|
|
9839
|
+
bracket--;
|
|
9840
|
+
} else if (bracket === 0) {
|
|
9841
|
+
if (ch === "(") {
|
|
9842
|
+
paren++;
|
|
9843
|
+
} else if (ch === ")" && paren > 0) {
|
|
9844
|
+
paren--;
|
|
9845
|
+
} else if (ch === "|" && paren === 0) {
|
|
9846
|
+
parts.push(value);
|
|
9847
|
+
value = "";
|
|
9848
|
+
continue;
|
|
9849
|
+
}
|
|
9850
|
+
}
|
|
9851
|
+
}
|
|
9852
|
+
value += ch;
|
|
9853
|
+
}
|
|
9854
|
+
parts.push(value);
|
|
9855
|
+
return parts;
|
|
9856
|
+
};
|
|
9857
|
+
var isPlainBranch = (branch) => {
|
|
9858
|
+
let escaped = false;
|
|
9859
|
+
for (const ch of branch) {
|
|
9860
|
+
if (escaped === true) {
|
|
9861
|
+
escaped = false;
|
|
9862
|
+
continue;
|
|
9863
|
+
}
|
|
9864
|
+
if (ch === "\\") {
|
|
9865
|
+
escaped = true;
|
|
9866
|
+
continue;
|
|
9867
|
+
}
|
|
9868
|
+
if (/[?*+@!()[\]{}]/.test(ch)) {
|
|
9869
|
+
return false;
|
|
9870
|
+
}
|
|
9871
|
+
}
|
|
9872
|
+
return true;
|
|
9873
|
+
};
|
|
9874
|
+
var normalizeSimpleBranch = (branch) => {
|
|
9875
|
+
let value = branch.trim();
|
|
9876
|
+
let changed = true;
|
|
9877
|
+
while (changed === true) {
|
|
9878
|
+
changed = false;
|
|
9879
|
+
if (/^@\([^\\()[\]{}|]+\)$/.test(value)) {
|
|
9880
|
+
value = value.slice(2, -1);
|
|
9881
|
+
changed = true;
|
|
9882
|
+
}
|
|
9883
|
+
}
|
|
9884
|
+
if (!isPlainBranch(value)) {
|
|
9885
|
+
return;
|
|
9886
|
+
}
|
|
9887
|
+
return value.replace(/\\(.)/g, "$1");
|
|
9888
|
+
};
|
|
9889
|
+
var hasRepeatedCharPrefixOverlap = (branches) => {
|
|
9890
|
+
const values = branches.map(normalizeSimpleBranch).filter(Boolean);
|
|
9891
|
+
for (let i = 0; i < values.length; i++) {
|
|
9892
|
+
for (let j = i + 1; j < values.length; j++) {
|
|
9893
|
+
const a = values[i];
|
|
9894
|
+
const b = values[j];
|
|
9895
|
+
const char = a[0];
|
|
9896
|
+
if (!char || a !== char.repeat(a.length) || b !== char.repeat(b.length)) {
|
|
9897
|
+
continue;
|
|
9898
|
+
}
|
|
9899
|
+
if (a === b || a.startsWith(b) || b.startsWith(a)) {
|
|
9900
|
+
return true;
|
|
9901
|
+
}
|
|
9902
|
+
}
|
|
9903
|
+
}
|
|
9904
|
+
return false;
|
|
9905
|
+
};
|
|
9906
|
+
var parseRepeatedExtglob = (pattern, requireEnd = true) => {
|
|
9907
|
+
if (pattern[0] !== "+" && pattern[0] !== "*" || pattern[1] !== "(") {
|
|
9908
|
+
return;
|
|
9909
|
+
}
|
|
9910
|
+
let bracket = 0;
|
|
9911
|
+
let paren = 0;
|
|
9912
|
+
let quote = 0;
|
|
9913
|
+
let escaped = false;
|
|
9914
|
+
for (let i = 1; i < pattern.length; i++) {
|
|
9915
|
+
const ch = pattern[i];
|
|
9916
|
+
if (escaped === true) {
|
|
9917
|
+
escaped = false;
|
|
9918
|
+
continue;
|
|
9919
|
+
}
|
|
9920
|
+
if (ch === "\\") {
|
|
9921
|
+
escaped = true;
|
|
9922
|
+
continue;
|
|
9923
|
+
}
|
|
9924
|
+
if (ch === '"') {
|
|
9925
|
+
quote = quote === 1 ? 0 : 1;
|
|
9926
|
+
continue;
|
|
9927
|
+
}
|
|
9928
|
+
if (quote === 1) {
|
|
9929
|
+
continue;
|
|
9930
|
+
}
|
|
9931
|
+
if (ch === "[") {
|
|
9932
|
+
bracket++;
|
|
9933
|
+
continue;
|
|
9934
|
+
}
|
|
9935
|
+
if (ch === "]" && bracket > 0) {
|
|
9936
|
+
bracket--;
|
|
9937
|
+
continue;
|
|
9938
|
+
}
|
|
9939
|
+
if (bracket > 0) {
|
|
9940
|
+
continue;
|
|
9941
|
+
}
|
|
9942
|
+
if (ch === "(") {
|
|
9943
|
+
paren++;
|
|
9944
|
+
continue;
|
|
9945
|
+
}
|
|
9946
|
+
if (ch === ")") {
|
|
9947
|
+
paren--;
|
|
9948
|
+
if (paren === 0) {
|
|
9949
|
+
if (requireEnd === true && i !== pattern.length - 1) {
|
|
9950
|
+
return;
|
|
9951
|
+
}
|
|
9952
|
+
return {
|
|
9953
|
+
type: pattern[0],
|
|
9954
|
+
body: pattern.slice(2, i),
|
|
9955
|
+
end: i
|
|
9956
|
+
};
|
|
9957
|
+
}
|
|
9958
|
+
}
|
|
9959
|
+
}
|
|
9960
|
+
};
|
|
9961
|
+
var getStarExtglobSequenceOutput = (pattern) => {
|
|
9962
|
+
let index = 0;
|
|
9963
|
+
const chars = [];
|
|
9964
|
+
while (index < pattern.length) {
|
|
9965
|
+
const match = parseRepeatedExtglob(pattern.slice(index), false);
|
|
9966
|
+
if (!match || match.type !== "*") {
|
|
9967
|
+
return;
|
|
9968
|
+
}
|
|
9969
|
+
const branches = splitTopLevel(match.body).map((branch2) => branch2.trim());
|
|
9970
|
+
if (branches.length !== 1) {
|
|
9971
|
+
return;
|
|
9972
|
+
}
|
|
9973
|
+
const branch = normalizeSimpleBranch(branches[0]);
|
|
9974
|
+
if (!branch || branch.length !== 1) {
|
|
9975
|
+
return;
|
|
9976
|
+
}
|
|
9977
|
+
chars.push(branch);
|
|
9978
|
+
index += match.end + 1;
|
|
9979
|
+
}
|
|
9980
|
+
if (chars.length < 1) {
|
|
9981
|
+
return;
|
|
9982
|
+
}
|
|
9983
|
+
const source = chars.length === 1 ? utils.escapeRegex(chars[0]) : `[${chars.map((ch) => utils.escapeRegex(ch)).join("")}]`;
|
|
9984
|
+
return `${source}*`;
|
|
9985
|
+
};
|
|
9986
|
+
var repeatedExtglobRecursion = (pattern) => {
|
|
9987
|
+
let depth = 0;
|
|
9988
|
+
let value = pattern.trim();
|
|
9989
|
+
let match = parseRepeatedExtglob(value);
|
|
9990
|
+
while (match) {
|
|
9991
|
+
depth++;
|
|
9992
|
+
value = match.body.trim();
|
|
9993
|
+
match = parseRepeatedExtglob(value);
|
|
9994
|
+
}
|
|
9995
|
+
return depth;
|
|
9996
|
+
};
|
|
9997
|
+
var analyzeRepeatedExtglob = (body, options) => {
|
|
9998
|
+
if (options.maxExtglobRecursion === false) {
|
|
9999
|
+
return { risky: false };
|
|
10000
|
+
}
|
|
10001
|
+
const max = typeof options.maxExtglobRecursion === "number" ? options.maxExtglobRecursion : constants.DEFAULT_MAX_EXTGLOB_RECURSION;
|
|
10002
|
+
const branches = splitTopLevel(body).map((branch) => branch.trim());
|
|
10003
|
+
if (branches.length > 1) {
|
|
10004
|
+
if (branches.some((branch) => branch === "") || branches.some((branch) => /^[*?]+$/.test(branch)) || hasRepeatedCharPrefixOverlap(branches)) {
|
|
10005
|
+
return { risky: true };
|
|
10006
|
+
}
|
|
10007
|
+
}
|
|
10008
|
+
for (const branch of branches) {
|
|
10009
|
+
const safeOutput = getStarExtglobSequenceOutput(branch);
|
|
10010
|
+
if (safeOutput) {
|
|
10011
|
+
return { risky: true, safeOutput };
|
|
10012
|
+
}
|
|
10013
|
+
if (repeatedExtglobRecursion(branch) > max) {
|
|
10014
|
+
return { risky: true };
|
|
10015
|
+
}
|
|
10016
|
+
}
|
|
10017
|
+
return { risky: false };
|
|
10018
|
+
};
|
|
9799
10019
|
var parse3 = (input, options) => {
|
|
9800
10020
|
if (typeof input !== "string") {
|
|
9801
10021
|
throw new TypeError("Expected a string");
|
|
@@ -9927,6 +10147,8 @@ var require_parse2 = __commonJS({
|
|
|
9927
10147
|
token.prev = prev;
|
|
9928
10148
|
token.parens = state.parens;
|
|
9929
10149
|
token.output = state.output;
|
|
10150
|
+
token.startIndex = state.index;
|
|
10151
|
+
token.tokensIndex = tokens.length;
|
|
9930
10152
|
const output = (opts.capture ? "(" : "") + token.open;
|
|
9931
10153
|
increment("parens");
|
|
9932
10154
|
push({ type, value: value2, output: state.output ? "" : ONE_CHAR });
|
|
@@ -9934,6 +10156,26 @@ var require_parse2 = __commonJS({
|
|
|
9934
10156
|
extglobs.push(token);
|
|
9935
10157
|
};
|
|
9936
10158
|
const extglobClose = (token) => {
|
|
10159
|
+
const literal2 = input.slice(token.startIndex, state.index + 1);
|
|
10160
|
+
const body = input.slice(token.startIndex + 2, state.index);
|
|
10161
|
+
const analysis = analyzeRepeatedExtglob(body, opts);
|
|
10162
|
+
if ((token.type === "plus" || token.type === "star") && analysis.risky) {
|
|
10163
|
+
const safeOutput = analysis.safeOutput ? (token.output ? "" : ONE_CHAR) + (opts.capture ? `(${analysis.safeOutput})` : analysis.safeOutput) : void 0;
|
|
10164
|
+
const open = tokens[token.tokensIndex];
|
|
10165
|
+
open.type = "text";
|
|
10166
|
+
open.value = literal2;
|
|
10167
|
+
open.output = safeOutput || utils.escapeRegex(literal2);
|
|
10168
|
+
for (let i = token.tokensIndex + 1; i < tokens.length; i++) {
|
|
10169
|
+
tokens[i].value = "";
|
|
10170
|
+
tokens[i].output = "";
|
|
10171
|
+
delete tokens[i].suffix;
|
|
10172
|
+
}
|
|
10173
|
+
state.output = token.output + open.output;
|
|
10174
|
+
state.backtrack = true;
|
|
10175
|
+
push({ type: "paren", extglob: true, value, output: "" });
|
|
10176
|
+
decrement("parens");
|
|
10177
|
+
return;
|
|
10178
|
+
}
|
|
9937
10179
|
let output = token.close + (opts.capture ? ")" : "");
|
|
9938
10180
|
let rest;
|
|
9939
10181
|
if (token.type === "negate") {
|
|
@@ -31157,10 +31399,9 @@ var ProgressTokenSchema = union([string2(), number2().int()]);
|
|
|
31157
31399
|
var CursorSchema = string2();
|
|
31158
31400
|
var TaskCreationParamsSchema = looseObject({
|
|
31159
31401
|
/**
|
|
31160
|
-
*
|
|
31161
|
-
* If null, the task has unlimited lifetime until manually cleaned up.
|
|
31402
|
+
* Requested duration in milliseconds to retain task from creation.
|
|
31162
31403
|
*/
|
|
31163
|
-
ttl:
|
|
31404
|
+
ttl: number2().optional(),
|
|
31164
31405
|
/**
|
|
31165
31406
|
* Time in milliseconds to wait between task status requests.
|
|
31166
31407
|
*/
|
|
@@ -31460,7 +31701,11 @@ var ClientCapabilitiesSchema = object2({
|
|
|
31460
31701
|
/**
|
|
31461
31702
|
* Present if the client supports task creation.
|
|
31462
31703
|
*/
|
|
31463
|
-
tasks: ClientTasksCapabilitySchema.optional()
|
|
31704
|
+
tasks: ClientTasksCapabilitySchema.optional(),
|
|
31705
|
+
/**
|
|
31706
|
+
* Extensions that the client supports. Keys are extension identifiers (vendor-prefix/extension-name).
|
|
31707
|
+
*/
|
|
31708
|
+
extensions: record(string2(), AssertObjectSchema).optional()
|
|
31464
31709
|
});
|
|
31465
31710
|
var InitializeRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
31466
31711
|
/**
|
|
@@ -31521,7 +31766,11 @@ var ServerCapabilitiesSchema = object2({
|
|
|
31521
31766
|
/**
|
|
31522
31767
|
* Present if the server supports task creation.
|
|
31523
31768
|
*/
|
|
31524
|
-
tasks: ServerTasksCapabilitySchema.optional()
|
|
31769
|
+
tasks: ServerTasksCapabilitySchema.optional(),
|
|
31770
|
+
/**
|
|
31771
|
+
* Extensions that the server supports. Keys are extension identifiers (vendor-prefix/extension-name).
|
|
31772
|
+
*/
|
|
31773
|
+
extensions: record(string2(), AssertObjectSchema).optional()
|
|
31525
31774
|
});
|
|
31526
31775
|
var InitializeResultSchema = ResultSchema.extend({
|
|
31527
31776
|
/**
|
|
@@ -31713,6 +31962,12 @@ var ResourceSchema = object2({
|
|
|
31713
31962
|
* The MIME type of this resource, if known.
|
|
31714
31963
|
*/
|
|
31715
31964
|
mimeType: optional(string2()),
|
|
31965
|
+
/**
|
|
31966
|
+
* The size of the raw resource content, in bytes (i.e., before base64 encoding or any tokenization), if known.
|
|
31967
|
+
*
|
|
31968
|
+
* This can be used by Hosts to display file sizes and estimate context window usage.
|
|
31969
|
+
*/
|
|
31970
|
+
size: optional(number2()),
|
|
31716
31971
|
/**
|
|
31717
31972
|
* Optional annotations for the client.
|
|
31718
31973
|
*/
|
|
@@ -34208,6 +34463,10 @@ var Protocol = class {
|
|
|
34208
34463
|
this._progressHandlers.clear();
|
|
34209
34464
|
this._taskProgressTokens.clear();
|
|
34210
34465
|
this._pendingDebouncedNotifications.clear();
|
|
34466
|
+
for (const info2 of this._timeoutInfo.values()) {
|
|
34467
|
+
clearTimeout(info2.timeoutId);
|
|
34468
|
+
}
|
|
34469
|
+
this._timeoutInfo.clear();
|
|
34211
34470
|
for (const controller of this._requestHandlerAbortControllers.values()) {
|
|
34212
34471
|
controller.abort();
|
|
34213
34472
|
}
|
|
@@ -34338,7 +34597,9 @@ var Protocol = class {
|
|
|
34338
34597
|
await capturedTransport?.send(errorResponse);
|
|
34339
34598
|
}
|
|
34340
34599
|
}).catch((error49) => this._onerror(new Error(`Failed to send response: ${error49}`))).finally(() => {
|
|
34341
|
-
this._requestHandlerAbortControllers.
|
|
34600
|
+
if (this._requestHandlerAbortControllers.get(request.id) === abortController) {
|
|
34601
|
+
this._requestHandlerAbortControllers.delete(request.id);
|
|
34602
|
+
}
|
|
34342
34603
|
});
|
|
34343
34604
|
}
|
|
34344
34605
|
_onprogress(notification) {
|
|
@@ -35034,6 +35295,147 @@ var ExperimentalServerTasks = class {
|
|
|
35034
35295
|
requestStream(request, resultSchema, options) {
|
|
35035
35296
|
return this._server.requestStream(request, resultSchema, options);
|
|
35036
35297
|
}
|
|
35298
|
+
/**
|
|
35299
|
+
* Sends a sampling request and returns an AsyncGenerator that yields response messages.
|
|
35300
|
+
* The generator is guaranteed to end with either a 'result' or 'error' message.
|
|
35301
|
+
*
|
|
35302
|
+
* For task-augmented requests, yields 'taskCreated' and 'taskStatus' messages
|
|
35303
|
+
* before the final result.
|
|
35304
|
+
*
|
|
35305
|
+
* @example
|
|
35306
|
+
* ```typescript
|
|
35307
|
+
* const stream = server.experimental.tasks.createMessageStream({
|
|
35308
|
+
* messages: [{ role: 'user', content: { type: 'text', text: 'Hello' } }],
|
|
35309
|
+
* maxTokens: 100
|
|
35310
|
+
* }, {
|
|
35311
|
+
* onprogress: (progress) => {
|
|
35312
|
+
* // Handle streaming tokens via progress notifications
|
|
35313
|
+
* console.log('Progress:', progress.message);
|
|
35314
|
+
* }
|
|
35315
|
+
* });
|
|
35316
|
+
*
|
|
35317
|
+
* for await (const message of stream) {
|
|
35318
|
+
* switch (message.type) {
|
|
35319
|
+
* case 'taskCreated':
|
|
35320
|
+
* console.log('Task created:', message.task.taskId);
|
|
35321
|
+
* break;
|
|
35322
|
+
* case 'taskStatus':
|
|
35323
|
+
* console.log('Task status:', message.task.status);
|
|
35324
|
+
* break;
|
|
35325
|
+
* case 'result':
|
|
35326
|
+
* console.log('Final result:', message.result);
|
|
35327
|
+
* break;
|
|
35328
|
+
* case 'error':
|
|
35329
|
+
* console.error('Error:', message.error);
|
|
35330
|
+
* break;
|
|
35331
|
+
* }
|
|
35332
|
+
* }
|
|
35333
|
+
* ```
|
|
35334
|
+
*
|
|
35335
|
+
* @param params - The sampling request parameters
|
|
35336
|
+
* @param options - Optional request options (timeout, signal, task creation params, onprogress, etc.)
|
|
35337
|
+
* @returns AsyncGenerator that yields ResponseMessage objects
|
|
35338
|
+
*
|
|
35339
|
+
* @experimental
|
|
35340
|
+
*/
|
|
35341
|
+
createMessageStream(params, options) {
|
|
35342
|
+
const clientCapabilities = this._server.getClientCapabilities();
|
|
35343
|
+
if ((params.tools || params.toolChoice) && !clientCapabilities?.sampling?.tools) {
|
|
35344
|
+
throw new Error("Client does not support sampling tools capability.");
|
|
35345
|
+
}
|
|
35346
|
+
if (params.messages.length > 0) {
|
|
35347
|
+
const lastMessage = params.messages[params.messages.length - 1];
|
|
35348
|
+
const lastContent = Array.isArray(lastMessage.content) ? lastMessage.content : [lastMessage.content];
|
|
35349
|
+
const hasToolResults = lastContent.some((c) => c.type === "tool_result");
|
|
35350
|
+
const previousMessage = params.messages.length > 1 ? params.messages[params.messages.length - 2] : void 0;
|
|
35351
|
+
const previousContent = previousMessage ? Array.isArray(previousMessage.content) ? previousMessage.content : [previousMessage.content] : [];
|
|
35352
|
+
const hasPreviousToolUse = previousContent.some((c) => c.type === "tool_use");
|
|
35353
|
+
if (hasToolResults) {
|
|
35354
|
+
if (lastContent.some((c) => c.type !== "tool_result")) {
|
|
35355
|
+
throw new Error("The last message must contain only tool_result content if any is present");
|
|
35356
|
+
}
|
|
35357
|
+
if (!hasPreviousToolUse) {
|
|
35358
|
+
throw new Error("tool_result blocks are not matching any tool_use from the previous message");
|
|
35359
|
+
}
|
|
35360
|
+
}
|
|
35361
|
+
if (hasPreviousToolUse) {
|
|
35362
|
+
const toolUseIds = new Set(previousContent.filter((c) => c.type === "tool_use").map((c) => c.id));
|
|
35363
|
+
const toolResultIds = new Set(lastContent.filter((c) => c.type === "tool_result").map((c) => c.toolUseId));
|
|
35364
|
+
if (toolUseIds.size !== toolResultIds.size || ![...toolUseIds].every((id) => toolResultIds.has(id))) {
|
|
35365
|
+
throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match");
|
|
35366
|
+
}
|
|
35367
|
+
}
|
|
35368
|
+
}
|
|
35369
|
+
return this.requestStream({
|
|
35370
|
+
method: "sampling/createMessage",
|
|
35371
|
+
params
|
|
35372
|
+
}, CreateMessageResultSchema, options);
|
|
35373
|
+
}
|
|
35374
|
+
/**
|
|
35375
|
+
* Sends an elicitation request and returns an AsyncGenerator that yields response messages.
|
|
35376
|
+
* The generator is guaranteed to end with either a 'result' or 'error' message.
|
|
35377
|
+
*
|
|
35378
|
+
* For task-augmented requests (especially URL-based elicitation), yields 'taskCreated'
|
|
35379
|
+
* and 'taskStatus' messages before the final result.
|
|
35380
|
+
*
|
|
35381
|
+
* @example
|
|
35382
|
+
* ```typescript
|
|
35383
|
+
* const stream = server.experimental.tasks.elicitInputStream({
|
|
35384
|
+
* mode: 'url',
|
|
35385
|
+
* message: 'Please authenticate',
|
|
35386
|
+
* elicitationId: 'auth-123',
|
|
35387
|
+
* url: 'https://example.com/auth'
|
|
35388
|
+
* }, {
|
|
35389
|
+
* task: { ttl: 300000 } // Task-augmented for long-running auth flow
|
|
35390
|
+
* });
|
|
35391
|
+
*
|
|
35392
|
+
* for await (const message of stream) {
|
|
35393
|
+
* switch (message.type) {
|
|
35394
|
+
* case 'taskCreated':
|
|
35395
|
+
* console.log('Task created:', message.task.taskId);
|
|
35396
|
+
* break;
|
|
35397
|
+
* case 'taskStatus':
|
|
35398
|
+
* console.log('Task status:', message.task.status);
|
|
35399
|
+
* break;
|
|
35400
|
+
* case 'result':
|
|
35401
|
+
* console.log('User action:', message.result.action);
|
|
35402
|
+
* break;
|
|
35403
|
+
* case 'error':
|
|
35404
|
+
* console.error('Error:', message.error);
|
|
35405
|
+
* break;
|
|
35406
|
+
* }
|
|
35407
|
+
* }
|
|
35408
|
+
* ```
|
|
35409
|
+
*
|
|
35410
|
+
* @param params - The elicitation request parameters
|
|
35411
|
+
* @param options - Optional request options (timeout, signal, task creation params, etc.)
|
|
35412
|
+
* @returns AsyncGenerator that yields ResponseMessage objects
|
|
35413
|
+
*
|
|
35414
|
+
* @experimental
|
|
35415
|
+
*/
|
|
35416
|
+
elicitInputStream(params, options) {
|
|
35417
|
+
const clientCapabilities = this._server.getClientCapabilities();
|
|
35418
|
+
const mode = params.mode ?? "form";
|
|
35419
|
+
switch (mode) {
|
|
35420
|
+
case "url": {
|
|
35421
|
+
if (!clientCapabilities?.elicitation?.url) {
|
|
35422
|
+
throw new Error("Client does not support url elicitation.");
|
|
35423
|
+
}
|
|
35424
|
+
break;
|
|
35425
|
+
}
|
|
35426
|
+
case "form": {
|
|
35427
|
+
if (!clientCapabilities?.elicitation?.form) {
|
|
35428
|
+
throw new Error("Client does not support form elicitation.");
|
|
35429
|
+
}
|
|
35430
|
+
break;
|
|
35431
|
+
}
|
|
35432
|
+
}
|
|
35433
|
+
const normalizedParams = mode === "form" && params.mode === void 0 ? { ...params, mode: "form" } : params;
|
|
35434
|
+
return this.requestStream({
|
|
35435
|
+
method: "elicitation/create",
|
|
35436
|
+
params: normalizedParams
|
|
35437
|
+
}, ElicitResultSchema, options);
|
|
35438
|
+
}
|
|
35037
35439
|
/**
|
|
35038
35440
|
* Gets the current status of a task.
|
|
35039
35441
|
*
|
|
@@ -36210,6 +36612,9 @@ var McpServer = class {
|
|
|
36210
36612
|
annotations = rest.shift();
|
|
36211
36613
|
}
|
|
36212
36614
|
} else if (typeof firstArg === "object" && firstArg !== null) {
|
|
36615
|
+
if (Object.values(firstArg).some((v) => typeof v === "object" && v !== null)) {
|
|
36616
|
+
throw new Error(`Tool ${name} expected a Zod schema or ToolAnnotations, but received an unrecognized object`);
|
|
36617
|
+
}
|
|
36213
36618
|
annotations = rest.shift();
|
|
36214
36619
|
}
|
|
36215
36620
|
}
|
|
@@ -36328,6 +36733,9 @@ function getZodSchemaObject(schema) {
|
|
|
36328
36733
|
if (isZodRawShapeCompat(schema)) {
|
|
36329
36734
|
return objectFromShape(schema);
|
|
36330
36735
|
}
|
|
36736
|
+
if (!isZodSchemaInstance(schema)) {
|
|
36737
|
+
throw new Error("inputSchema must be a Zod schema or raw shape, received an unrecognized object");
|
|
36738
|
+
}
|
|
36331
36739
|
return schema;
|
|
36332
36740
|
}
|
|
36333
36741
|
function promptArgumentsFromSchema(schema) {
|