@mcpjam/cli 1.1.2 → 1.1.3
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 +68 -126
- package/bin/mcpjam.js +5 -2
- package/dist/index.js +636 -1006
- package/dist/index.js.map +1 -1
- package/package.json +7 -6
package/dist/index.js
CHANGED
|
@@ -19,25 +19,24 @@ var Logger = class {
|
|
|
19
19
|
this.activeStream = null;
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
|
-
static startStream(role
|
|
22
|
+
static startStream(role) {
|
|
23
23
|
this.closeActiveStream();
|
|
24
|
-
const prefix =
|
|
24
|
+
const prefix = this.colorRole(role) + ": ";
|
|
25
25
|
process.stdout.write(prefix);
|
|
26
|
-
this.activeStream = { role
|
|
26
|
+
this.activeStream = { role };
|
|
27
27
|
}
|
|
28
28
|
static appendToStream(text) {
|
|
29
29
|
if (!this.activeStream) {
|
|
30
|
-
this.startStream("assistant"
|
|
30
|
+
this.startStream("assistant");
|
|
31
31
|
}
|
|
32
32
|
process.stdout.write(text);
|
|
33
33
|
}
|
|
34
|
-
static logLine(text
|
|
34
|
+
static logLine(text) {
|
|
35
35
|
this.closeActiveStream();
|
|
36
|
-
|
|
37
|
-
console.log(prefix + text);
|
|
36
|
+
console.log(text);
|
|
38
37
|
}
|
|
39
|
-
static logMultiline(text
|
|
40
|
-
text.split("\n").forEach((line) => this.logLine(line
|
|
38
|
+
static logMultiline(text) {
|
|
39
|
+
text.split("\n").forEach((line) => this.logLine(line));
|
|
41
40
|
}
|
|
42
41
|
static suiteIntro(options) {
|
|
43
42
|
const { testCount, startedAt } = options;
|
|
@@ -58,93 +57,85 @@ var Logger = class {
|
|
|
58
57
|
this.logLine(chalk.bold.blue(`MCPJAM CLI ${version3}`));
|
|
59
58
|
this.logLine("");
|
|
60
59
|
}
|
|
61
|
-
static
|
|
60
|
+
static initiateTestMessage(serverCount, toolCount, serverNames, testCount) {
|
|
61
|
+
this.logLine("");
|
|
62
|
+
this.logLine(chalk.bold.blue("Running tests"));
|
|
63
|
+
const serverLabel = serverCount === 1 ? "server" : "servers";
|
|
64
|
+
const serverList = serverNames.length > 0 ? serverNames.join(", ") : "none";
|
|
62
65
|
this.logLine(
|
|
63
|
-
chalk.gray(
|
|
64
|
-
`Connecting to ${serverCount} server${serverCount === 1 ? "" : "s"} and ${toolCount} tool${toolCount === 1 ? "" : "s"}`
|
|
65
|
-
)
|
|
66
|
+
`Connected to ${chalk.white.bold(serverCount)} ${serverLabel}: ${chalk.gray(serverList)}`
|
|
66
67
|
);
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
const toolLabel = toolCount === 1 ? "tool" : "tools";
|
|
69
|
+
this.logLine(`Found ${chalk.white.bold(toolCount)} total ${toolLabel}`);
|
|
70
|
+
const testLabel = testCount === 1 ? "test" : "tests";
|
|
71
|
+
this.logLine(`Running ${chalk.white.bold(testCount)} ${testLabel}`);
|
|
70
72
|
this.logLine("");
|
|
71
73
|
}
|
|
72
|
-
static
|
|
73
|
-
this.logLine(chalk.
|
|
74
|
+
static logTestGroupTitle(testNumber, testName, modelProvider, modelId) {
|
|
75
|
+
this.logLine(chalk.cyan.bold(`Test ${testNumber}: ${testName}`));
|
|
76
|
+
this.logLine(chalk.gray(`Using ${modelProvider}:${modelId}`));
|
|
77
|
+
this.logLine("");
|
|
74
78
|
}
|
|
75
79
|
static testRunStart(options) {
|
|
76
|
-
const { runNumber, totalRuns
|
|
80
|
+
const { runNumber, totalRuns } = options;
|
|
77
81
|
const parts = [`run ${runNumber}/${totalRuns}`];
|
|
78
|
-
|
|
79
|
-
parts.push(`${provider}:${model}`);
|
|
80
|
-
}
|
|
81
|
-
if (typeof temperature === "number") {
|
|
82
|
-
parts.push(`temp=${temperature}`);
|
|
83
|
-
}
|
|
84
|
-
this.logLine(chalk.gray(parts.join(" \u2022 ")), indentLevel);
|
|
82
|
+
this.logLine(chalk.cyanBright(parts.join(" \u2022 ")));
|
|
85
83
|
}
|
|
86
84
|
static conversation(options) {
|
|
87
|
-
const { messages
|
|
85
|
+
const { messages } = options;
|
|
88
86
|
this.closeActiveStream();
|
|
89
87
|
if (!messages.length) {
|
|
90
|
-
this.logLine(chalk.dim("(no messages)")
|
|
88
|
+
this.logLine(chalk.dim("(no messages)"));
|
|
91
89
|
return;
|
|
92
90
|
}
|
|
93
91
|
messages.forEach((message, index) => {
|
|
94
92
|
if (index > 0) {
|
|
95
|
-
this.
|
|
96
|
-
console.log("");
|
|
93
|
+
this.logLine("");
|
|
97
94
|
}
|
|
98
|
-
const
|
|
95
|
+
const roleLabel = this.colorRole(message.role);
|
|
99
96
|
if (message.role === "assistant") {
|
|
100
97
|
const summary = this.summarizeContent(
|
|
101
98
|
message.content
|
|
102
99
|
);
|
|
103
|
-
this.logMessageLines(
|
|
100
|
+
this.logMessageLines(roleLabel, summary.textLines);
|
|
104
101
|
summary.toolCalls.forEach((toolCall) => {
|
|
105
|
-
this.logToolCall(toolCall
|
|
102
|
+
this.logToolCall(toolCall);
|
|
106
103
|
});
|
|
107
104
|
return;
|
|
108
105
|
}
|
|
109
|
-
const
|
|
106
|
+
const formatted = this.formatMessageContent(
|
|
110
107
|
message.content
|
|
111
108
|
);
|
|
112
|
-
const lines =
|
|
113
|
-
this.logMessageLines(
|
|
109
|
+
const lines = formatted ? formatted.split("\n") : [];
|
|
110
|
+
this.logMessageLines(roleLabel, lines);
|
|
114
111
|
});
|
|
115
112
|
}
|
|
116
113
|
static toolSummary(options) {
|
|
117
|
-
const { expected, actual
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
const lines = [];
|
|
121
|
-
lines.push(
|
|
122
|
-
this.truncate(`Expected: [${expected.join(", ") || "\u2014"}]`)
|
|
123
|
-
);
|
|
124
|
-
lines.push(
|
|
125
|
-
this.truncate(`Actual: [${actual.join(", ") || "\u2014"}]`)
|
|
126
|
-
);
|
|
127
|
-
if (missing.length) {
|
|
128
|
-
lines.push(this.truncate(`Missing: ${missing.join(", ")}`));
|
|
129
|
-
}
|
|
130
|
-
if (unexpected.length) {
|
|
131
|
-
lines.push(this.truncate(`Unexpected: ${unexpected.join(", ")}`));
|
|
132
|
-
}
|
|
133
|
-
const statusText = passed ? "Status: PASS" : "Status: FAIL";
|
|
134
|
-
lines.push(statusText);
|
|
135
|
-
const borderColor = passed ? chalk.greenBright : chalk.redBright;
|
|
136
|
-
const statusColor = passed ? chalk.green : chalk.red;
|
|
137
|
-
this.renderBox(lines, {
|
|
138
|
-
borderColor,
|
|
139
|
-
statusColor,
|
|
140
|
-
indentLevel
|
|
141
|
-
});
|
|
142
|
-
return { missing, unexpected, passed };
|
|
114
|
+
const { expected, actual } = options;
|
|
115
|
+
this.logLine(`Expected: [${expected.join(", ") || "\u2014"}]`);
|
|
116
|
+
this.logLine(`Actual: [${actual.join(", ") || "\u2014"}]`);
|
|
143
117
|
}
|
|
144
118
|
static testRunResult(options) {
|
|
145
|
-
const { passed, durationMs,
|
|
119
|
+
const { passed, durationMs, usage } = options;
|
|
146
120
|
const status = passed ? chalk.green("PASS") : chalk.red("FAIL");
|
|
147
|
-
this.logLine(`${status} (${this.formatDuration(durationMs)})
|
|
121
|
+
this.logLine(`${status} (${this.formatDuration(durationMs)})`);
|
|
122
|
+
if (usage) {
|
|
123
|
+
const usageParts = [];
|
|
124
|
+
if (typeof usage.inputTokens === "number") {
|
|
125
|
+
usageParts.push(`input ${usage.inputTokens}`);
|
|
126
|
+
}
|
|
127
|
+
if (typeof usage.outputTokens === "number") {
|
|
128
|
+
usageParts.push(`output ${usage.outputTokens}`);
|
|
129
|
+
}
|
|
130
|
+
if (typeof usage.totalTokens === "number") {
|
|
131
|
+
usageParts.push(`total ${usage.totalTokens}`);
|
|
132
|
+
}
|
|
133
|
+
if (usageParts.length > 0) {
|
|
134
|
+
this.logLine(chalk.gray(`Tokens \u2022 ${usageParts.join(" \u2022 ")}`));
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
this.logLine("");
|
|
138
|
+
this.logLine("");
|
|
148
139
|
}
|
|
149
140
|
static info(message) {
|
|
150
141
|
this.logLine(chalk.blue(`\u2139 ${message}`));
|
|
@@ -278,25 +269,26 @@ var Logger = class {
|
|
|
278
269
|
static splitAndTrim(text) {
|
|
279
270
|
return text.split("\n").map((line) => line.trim()).filter((line) => line.length > 0);
|
|
280
271
|
}
|
|
281
|
-
static logMessageLines(roleLabel, lines
|
|
272
|
+
static logMessageLines(roleLabel, lines) {
|
|
282
273
|
if (!lines.length) {
|
|
283
|
-
this.logLine(`${roleLabel}
|
|
274
|
+
this.logLine(`${roleLabel}:`);
|
|
284
275
|
return;
|
|
285
276
|
}
|
|
286
|
-
this.logLine(`${roleLabel}: ${lines[0]}
|
|
277
|
+
this.logLine(`${roleLabel}: ${lines[0]}`);
|
|
287
278
|
for (let i = 1; i < lines.length; i++) {
|
|
288
|
-
this.logLine(lines[i] ?? ""
|
|
279
|
+
this.logLine(lines[i] ?? "");
|
|
289
280
|
}
|
|
290
281
|
}
|
|
291
|
-
static logToolCall(toolCall
|
|
292
|
-
const header = chalk.
|
|
293
|
-
this.logLine(header
|
|
282
|
+
static logToolCall(toolCall) {
|
|
283
|
+
const header = chalk.whiteBright(`[tool-call] ${toolCall.toolName}`);
|
|
284
|
+
this.logLine(header);
|
|
285
|
+
const jsonArgs = toolCall.args ? JSON.parse(toolCall.args) : null;
|
|
294
286
|
if (toolCall.args) {
|
|
295
|
-
this.logLine(chalk.gray(this.truncate(toolCall.args))
|
|
287
|
+
this.logLine(chalk.gray(this.truncate(toolCall.args)));
|
|
296
288
|
}
|
|
297
289
|
}
|
|
298
|
-
static beginStreamingMessage(role
|
|
299
|
-
this.startStream(role
|
|
290
|
+
static beginStreamingMessage(role) {
|
|
291
|
+
this.startStream(role);
|
|
300
292
|
}
|
|
301
293
|
static appendStreamingText(text) {
|
|
302
294
|
if (!text) {
|
|
@@ -307,50 +299,45 @@ var Logger = class {
|
|
|
307
299
|
static finishStreamingMessage() {
|
|
308
300
|
this.closeActiveStream();
|
|
309
301
|
}
|
|
310
|
-
static streamToolCall(toolName, args
|
|
302
|
+
static streamToolCall(toolName, args) {
|
|
311
303
|
const serializedArgs = args === void 0 ? void 0 : this.truncate(this.stringify(args));
|
|
312
304
|
this.closeActiveStream();
|
|
313
|
-
this.logToolCall({ toolName, args: serializedArgs }
|
|
305
|
+
this.logToolCall({ toolName, args: serializedArgs });
|
|
314
306
|
}
|
|
315
|
-
static streamToolResult(toolName, output
|
|
307
|
+
static streamToolResult(toolName, output) {
|
|
316
308
|
this.closeActiveStream();
|
|
317
|
-
const header = chalk.
|
|
318
|
-
this.logLine(header
|
|
309
|
+
const header = chalk.whiteBright(`[tool-result] ${toolName}`);
|
|
310
|
+
this.logLine(header);
|
|
319
311
|
if (output !== void 0) {
|
|
320
|
-
this.logLine(
|
|
321
|
-
chalk.gray(this.truncate(this.stringify(output))),
|
|
322
|
-
indentLevel + 1
|
|
323
|
-
);
|
|
312
|
+
this.logLine(chalk.gray(this.truncate(this.stringify(output))));
|
|
324
313
|
}
|
|
325
314
|
}
|
|
326
|
-
static streamToolError(toolName, error
|
|
315
|
+
static streamToolError(toolName, error) {
|
|
327
316
|
this.closeActiveStream();
|
|
328
|
-
const header = chalk.
|
|
329
|
-
this.logLine(header
|
|
317
|
+
const header = chalk.whiteBright(`[tool-error] ${toolName}`);
|
|
318
|
+
this.logLine(header);
|
|
330
319
|
this.logLine(
|
|
331
|
-
chalk.red(this.truncate(this.stringify(error ?? "Unknown error")))
|
|
332
|
-
indentLevel + 1
|
|
320
|
+
chalk.red(this.truncate(this.stringify(error ?? "Unknown error")))
|
|
333
321
|
);
|
|
334
322
|
}
|
|
335
323
|
static renderBox(lines, options) {
|
|
336
324
|
if (!lines.length) {
|
|
337
325
|
return;
|
|
338
326
|
}
|
|
339
|
-
const { borderColor, statusColor
|
|
327
|
+
const { borderColor, statusColor } = options;
|
|
340
328
|
const statusIndex = lines.findIndex((line) => line.startsWith("Status:"));
|
|
341
329
|
const width = lines.reduce((max, line) => Math.max(max, line.length), 0);
|
|
342
330
|
const horizontal = borderColor(`+${"-".repeat(width + 2)}+`);
|
|
343
|
-
this.logLine(horizontal
|
|
331
|
+
this.logLine(horizontal);
|
|
344
332
|
lines.forEach((line, index) => {
|
|
345
333
|
const padded = line.padEnd(width, " ");
|
|
346
334
|
const isStatusLine = index === statusIndex;
|
|
347
335
|
const colouredContent = isStatusLine ? statusColor(padded) : chalk.white(padded);
|
|
348
336
|
this.logLine(
|
|
349
|
-
`${borderColor("| ")}${colouredContent}${borderColor(" |")}
|
|
350
|
-
indentLevel
|
|
337
|
+
`${borderColor("| ")}${colouredContent}${borderColor(" |")}`
|
|
351
338
|
);
|
|
352
339
|
});
|
|
353
|
-
this.logLine(horizontal
|
|
340
|
+
this.logLine(horizontal);
|
|
354
341
|
}
|
|
355
342
|
static stringify(value) {
|
|
356
343
|
if (typeof value === "string") {
|
|
@@ -387,13 +374,13 @@ var Logger = class {
|
|
|
387
374
|
static colorRole(role) {
|
|
388
375
|
switch (role) {
|
|
389
376
|
case "user":
|
|
390
|
-
return chalk.
|
|
377
|
+
return chalk.bold.whiteBright("user");
|
|
391
378
|
case "assistant":
|
|
392
|
-
return chalk.
|
|
379
|
+
return chalk.bold.whiteBright("assistant");
|
|
393
380
|
case "tool":
|
|
394
|
-
return chalk.
|
|
381
|
+
return chalk.bold.whiteBright("tool");
|
|
395
382
|
case "system":
|
|
396
|
-
return chalk.
|
|
383
|
+
return chalk.bold.whiteBright("system");
|
|
397
384
|
default:
|
|
398
385
|
return chalk.cyan(role);
|
|
399
386
|
}
|
|
@@ -405,7 +392,7 @@ import { MCPClient } from "@mastra/mcp";
|
|
|
405
392
|
import { streamText } from "ai";
|
|
406
393
|
|
|
407
394
|
// ../node_modules/convex/dist/esm/index.js
|
|
408
|
-
var version = "1.
|
|
395
|
+
var version = "1.27.3";
|
|
409
396
|
|
|
410
397
|
// ../node_modules/convex/dist/esm/values/base64.js
|
|
411
398
|
var lookup = [];
|
|
@@ -820,477 +807,19 @@ function convexToJson(value) {
|
|
|
820
807
|
return convexToJsonInternal(value, value, "", false);
|
|
821
808
|
}
|
|
822
809
|
|
|
823
|
-
// ../node_modules/convex/dist/esm/values/
|
|
810
|
+
// ../node_modules/convex/dist/esm/values/errors.js
|
|
824
811
|
var __defProp = Object.defineProperty;
|
|
825
812
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
826
813
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
827
|
-
var BaseValidator = class {
|
|
828
|
-
constructor({ isOptional }) {
|
|
829
|
-
__publicField(this, "type");
|
|
830
|
-
__publicField(this, "fieldPaths");
|
|
831
|
-
__publicField(this, "isOptional");
|
|
832
|
-
__publicField(this, "isConvexValidator");
|
|
833
|
-
this.isOptional = isOptional;
|
|
834
|
-
this.isConvexValidator = true;
|
|
835
|
-
}
|
|
836
|
-
/** @deprecated - use isOptional instead */
|
|
837
|
-
get optional() {
|
|
838
|
-
return this.isOptional === "optional" ? true : false;
|
|
839
|
-
}
|
|
840
|
-
};
|
|
841
|
-
var VId = class _VId extends BaseValidator {
|
|
842
|
-
/**
|
|
843
|
-
* Usually you'd use `v.id(tableName)` instead.
|
|
844
|
-
*/
|
|
845
|
-
constructor({
|
|
846
|
-
isOptional,
|
|
847
|
-
tableName
|
|
848
|
-
}) {
|
|
849
|
-
super({ isOptional });
|
|
850
|
-
__publicField(this, "tableName");
|
|
851
|
-
__publicField(this, "kind", "id");
|
|
852
|
-
if (typeof tableName !== "string") {
|
|
853
|
-
throw new Error("v.id(tableName) requires a string");
|
|
854
|
-
}
|
|
855
|
-
this.tableName = tableName;
|
|
856
|
-
}
|
|
857
|
-
/** @internal */
|
|
858
|
-
get json() {
|
|
859
|
-
return { type: "id", tableName: this.tableName };
|
|
860
|
-
}
|
|
861
|
-
/** @internal */
|
|
862
|
-
asOptional() {
|
|
863
|
-
return new _VId({
|
|
864
|
-
isOptional: "optional",
|
|
865
|
-
tableName: this.tableName
|
|
866
|
-
});
|
|
867
|
-
}
|
|
868
|
-
};
|
|
869
|
-
var VFloat64 = class _VFloat64 extends BaseValidator {
|
|
870
|
-
constructor() {
|
|
871
|
-
super(...arguments);
|
|
872
|
-
__publicField(this, "kind", "float64");
|
|
873
|
-
}
|
|
874
|
-
/** @internal */
|
|
875
|
-
get json() {
|
|
876
|
-
return { type: "number" };
|
|
877
|
-
}
|
|
878
|
-
/** @internal */
|
|
879
|
-
asOptional() {
|
|
880
|
-
return new _VFloat64({
|
|
881
|
-
isOptional: "optional"
|
|
882
|
-
});
|
|
883
|
-
}
|
|
884
|
-
};
|
|
885
|
-
var VInt64 = class _VInt64 extends BaseValidator {
|
|
886
|
-
constructor() {
|
|
887
|
-
super(...arguments);
|
|
888
|
-
__publicField(this, "kind", "int64");
|
|
889
|
-
}
|
|
890
|
-
/** @internal */
|
|
891
|
-
get json() {
|
|
892
|
-
return { type: "bigint" };
|
|
893
|
-
}
|
|
894
|
-
/** @internal */
|
|
895
|
-
asOptional() {
|
|
896
|
-
return new _VInt64({ isOptional: "optional" });
|
|
897
|
-
}
|
|
898
|
-
};
|
|
899
|
-
var VBoolean = class _VBoolean extends BaseValidator {
|
|
900
|
-
constructor() {
|
|
901
|
-
super(...arguments);
|
|
902
|
-
__publicField(this, "kind", "boolean");
|
|
903
|
-
}
|
|
904
|
-
/** @internal */
|
|
905
|
-
get json() {
|
|
906
|
-
return { type: this.kind };
|
|
907
|
-
}
|
|
908
|
-
/** @internal */
|
|
909
|
-
asOptional() {
|
|
910
|
-
return new _VBoolean({
|
|
911
|
-
isOptional: "optional"
|
|
912
|
-
});
|
|
913
|
-
}
|
|
914
|
-
};
|
|
915
|
-
var VBytes = class _VBytes extends BaseValidator {
|
|
916
|
-
constructor() {
|
|
917
|
-
super(...arguments);
|
|
918
|
-
__publicField(this, "kind", "bytes");
|
|
919
|
-
}
|
|
920
|
-
/** @internal */
|
|
921
|
-
get json() {
|
|
922
|
-
return { type: this.kind };
|
|
923
|
-
}
|
|
924
|
-
/** @internal */
|
|
925
|
-
asOptional() {
|
|
926
|
-
return new _VBytes({ isOptional: "optional" });
|
|
927
|
-
}
|
|
928
|
-
};
|
|
929
|
-
var VString = class _VString extends BaseValidator {
|
|
930
|
-
constructor() {
|
|
931
|
-
super(...arguments);
|
|
932
|
-
__publicField(this, "kind", "string");
|
|
933
|
-
}
|
|
934
|
-
/** @internal */
|
|
935
|
-
get json() {
|
|
936
|
-
return { type: this.kind };
|
|
937
|
-
}
|
|
938
|
-
/** @internal */
|
|
939
|
-
asOptional() {
|
|
940
|
-
return new _VString({
|
|
941
|
-
isOptional: "optional"
|
|
942
|
-
});
|
|
943
|
-
}
|
|
944
|
-
};
|
|
945
|
-
var VNull = class _VNull extends BaseValidator {
|
|
946
|
-
constructor() {
|
|
947
|
-
super(...arguments);
|
|
948
|
-
__publicField(this, "kind", "null");
|
|
949
|
-
}
|
|
950
|
-
/** @internal */
|
|
951
|
-
get json() {
|
|
952
|
-
return { type: this.kind };
|
|
953
|
-
}
|
|
954
|
-
/** @internal */
|
|
955
|
-
asOptional() {
|
|
956
|
-
return new _VNull({ isOptional: "optional" });
|
|
957
|
-
}
|
|
958
|
-
};
|
|
959
|
-
var VAny = class _VAny extends BaseValidator {
|
|
960
|
-
constructor() {
|
|
961
|
-
super(...arguments);
|
|
962
|
-
__publicField(this, "kind", "any");
|
|
963
|
-
}
|
|
964
|
-
/** @internal */
|
|
965
|
-
get json() {
|
|
966
|
-
return {
|
|
967
|
-
type: this.kind
|
|
968
|
-
};
|
|
969
|
-
}
|
|
970
|
-
/** @internal */
|
|
971
|
-
asOptional() {
|
|
972
|
-
return new _VAny({
|
|
973
|
-
isOptional: "optional"
|
|
974
|
-
});
|
|
975
|
-
}
|
|
976
|
-
};
|
|
977
|
-
var VObject = class _VObject extends BaseValidator {
|
|
978
|
-
/**
|
|
979
|
-
* Usually you'd use `v.object({ ... })` instead.
|
|
980
|
-
*/
|
|
981
|
-
constructor({
|
|
982
|
-
isOptional,
|
|
983
|
-
fields
|
|
984
|
-
}) {
|
|
985
|
-
super({ isOptional });
|
|
986
|
-
__publicField(this, "fields");
|
|
987
|
-
__publicField(this, "kind", "object");
|
|
988
|
-
globalThis.Object.values(fields).forEach((v2) => {
|
|
989
|
-
if (!v2.isConvexValidator) {
|
|
990
|
-
throw new Error("v.object() entries must be valiators");
|
|
991
|
-
}
|
|
992
|
-
});
|
|
993
|
-
this.fields = fields;
|
|
994
|
-
}
|
|
995
|
-
/** @internal */
|
|
996
|
-
get json() {
|
|
997
|
-
return {
|
|
998
|
-
type: this.kind,
|
|
999
|
-
value: globalThis.Object.fromEntries(
|
|
1000
|
-
globalThis.Object.entries(this.fields).map(([k, v2]) => [
|
|
1001
|
-
k,
|
|
1002
|
-
{
|
|
1003
|
-
fieldType: v2.json,
|
|
1004
|
-
optional: v2.isOptional === "optional" ? true : false
|
|
1005
|
-
}
|
|
1006
|
-
])
|
|
1007
|
-
)
|
|
1008
|
-
};
|
|
1009
|
-
}
|
|
1010
|
-
/** @internal */
|
|
1011
|
-
asOptional() {
|
|
1012
|
-
return new _VObject({
|
|
1013
|
-
isOptional: "optional",
|
|
1014
|
-
fields: this.fields
|
|
1015
|
-
});
|
|
1016
|
-
}
|
|
1017
|
-
};
|
|
1018
|
-
var VLiteral = class _VLiteral extends BaseValidator {
|
|
1019
|
-
/**
|
|
1020
|
-
* Usually you'd use `v.literal(value)` instead.
|
|
1021
|
-
*/
|
|
1022
|
-
constructor({ isOptional, value }) {
|
|
1023
|
-
super({ isOptional });
|
|
1024
|
-
__publicField(this, "value");
|
|
1025
|
-
__publicField(this, "kind", "literal");
|
|
1026
|
-
if (typeof value !== "string" && typeof value !== "boolean" && typeof value !== "number" && typeof value !== "bigint") {
|
|
1027
|
-
throw new Error("v.literal(value) must be a string, number, or boolean");
|
|
1028
|
-
}
|
|
1029
|
-
this.value = value;
|
|
1030
|
-
}
|
|
1031
|
-
/** @internal */
|
|
1032
|
-
get json() {
|
|
1033
|
-
return {
|
|
1034
|
-
type: this.kind,
|
|
1035
|
-
value: convexToJson(this.value)
|
|
1036
|
-
};
|
|
1037
|
-
}
|
|
1038
|
-
/** @internal */
|
|
1039
|
-
asOptional() {
|
|
1040
|
-
return new _VLiteral({
|
|
1041
|
-
isOptional: "optional",
|
|
1042
|
-
value: this.value
|
|
1043
|
-
});
|
|
1044
|
-
}
|
|
1045
|
-
};
|
|
1046
|
-
var VArray = class _VArray extends BaseValidator {
|
|
1047
|
-
/**
|
|
1048
|
-
* Usually you'd use `v.array(element)` instead.
|
|
1049
|
-
*/
|
|
1050
|
-
constructor({
|
|
1051
|
-
isOptional,
|
|
1052
|
-
element
|
|
1053
|
-
}) {
|
|
1054
|
-
super({ isOptional });
|
|
1055
|
-
__publicField(this, "element");
|
|
1056
|
-
__publicField(this, "kind", "array");
|
|
1057
|
-
this.element = element;
|
|
1058
|
-
}
|
|
1059
|
-
/** @internal */
|
|
1060
|
-
get json() {
|
|
1061
|
-
return {
|
|
1062
|
-
type: this.kind,
|
|
1063
|
-
value: this.element.json
|
|
1064
|
-
};
|
|
1065
|
-
}
|
|
1066
|
-
/** @internal */
|
|
1067
|
-
asOptional() {
|
|
1068
|
-
return new _VArray({
|
|
1069
|
-
isOptional: "optional",
|
|
1070
|
-
element: this.element
|
|
1071
|
-
});
|
|
1072
|
-
}
|
|
1073
|
-
};
|
|
1074
|
-
var VRecord = class _VRecord extends BaseValidator {
|
|
1075
|
-
/**
|
|
1076
|
-
* Usually you'd use `v.record(key, value)` instead.
|
|
1077
|
-
*/
|
|
1078
|
-
constructor({
|
|
1079
|
-
isOptional,
|
|
1080
|
-
key,
|
|
1081
|
-
value
|
|
1082
|
-
}) {
|
|
1083
|
-
super({ isOptional });
|
|
1084
|
-
__publicField(this, "key");
|
|
1085
|
-
__publicField(this, "value");
|
|
1086
|
-
__publicField(this, "kind", "record");
|
|
1087
|
-
if (key.isOptional === "optional") {
|
|
1088
|
-
throw new Error("Record validator cannot have optional keys");
|
|
1089
|
-
}
|
|
1090
|
-
if (value.isOptional === "optional") {
|
|
1091
|
-
throw new Error("Record validator cannot have optional values");
|
|
1092
|
-
}
|
|
1093
|
-
if (!key.isConvexValidator || !value.isConvexValidator) {
|
|
1094
|
-
throw new Error("Key and value of v.record() but be validators");
|
|
1095
|
-
}
|
|
1096
|
-
this.key = key;
|
|
1097
|
-
this.value = value;
|
|
1098
|
-
}
|
|
1099
|
-
/** @internal */
|
|
1100
|
-
get json() {
|
|
1101
|
-
return {
|
|
1102
|
-
type: this.kind,
|
|
1103
|
-
// This cast is needed because TypeScript thinks the key type is too wide
|
|
1104
|
-
keys: this.key.json,
|
|
1105
|
-
values: {
|
|
1106
|
-
fieldType: this.value.json,
|
|
1107
|
-
optional: false
|
|
1108
|
-
}
|
|
1109
|
-
};
|
|
1110
|
-
}
|
|
1111
|
-
/** @internal */
|
|
1112
|
-
asOptional() {
|
|
1113
|
-
return new _VRecord({
|
|
1114
|
-
isOptional: "optional",
|
|
1115
|
-
key: this.key,
|
|
1116
|
-
value: this.value
|
|
1117
|
-
});
|
|
1118
|
-
}
|
|
1119
|
-
};
|
|
1120
|
-
var VUnion = class _VUnion extends BaseValidator {
|
|
1121
|
-
/**
|
|
1122
|
-
* Usually you'd use `v.union(...members)` instead.
|
|
1123
|
-
*/
|
|
1124
|
-
constructor({ isOptional, members }) {
|
|
1125
|
-
super({ isOptional });
|
|
1126
|
-
__publicField(this, "members");
|
|
1127
|
-
__publicField(this, "kind", "union");
|
|
1128
|
-
members.forEach((member) => {
|
|
1129
|
-
if (!member.isConvexValidator) {
|
|
1130
|
-
throw new Error("All members of v.union() must be validators");
|
|
1131
|
-
}
|
|
1132
|
-
});
|
|
1133
|
-
this.members = members;
|
|
1134
|
-
}
|
|
1135
|
-
/** @internal */
|
|
1136
|
-
get json() {
|
|
1137
|
-
return {
|
|
1138
|
-
type: this.kind,
|
|
1139
|
-
value: this.members.map((v2) => v2.json)
|
|
1140
|
-
};
|
|
1141
|
-
}
|
|
1142
|
-
/** @internal */
|
|
1143
|
-
asOptional() {
|
|
1144
|
-
return new _VUnion({
|
|
1145
|
-
isOptional: "optional",
|
|
1146
|
-
members: this.members
|
|
1147
|
-
});
|
|
1148
|
-
}
|
|
1149
|
-
};
|
|
1150
|
-
|
|
1151
|
-
// ../node_modules/convex/dist/esm/values/validator.js
|
|
1152
|
-
function isValidator(v2) {
|
|
1153
|
-
return !!v2.isConvexValidator;
|
|
1154
|
-
}
|
|
1155
|
-
var v = {
|
|
1156
|
-
/**
|
|
1157
|
-
* Validates that the value corresponds to an ID of a document in given table.
|
|
1158
|
-
* @param tableName The name of the table.
|
|
1159
|
-
*/
|
|
1160
|
-
id: (tableName) => {
|
|
1161
|
-
return new VId({
|
|
1162
|
-
isOptional: "required",
|
|
1163
|
-
tableName
|
|
1164
|
-
});
|
|
1165
|
-
},
|
|
1166
|
-
/**
|
|
1167
|
-
* Validates that the value is of type Null.
|
|
1168
|
-
*/
|
|
1169
|
-
null: () => {
|
|
1170
|
-
return new VNull({ isOptional: "required" });
|
|
1171
|
-
},
|
|
1172
|
-
/**
|
|
1173
|
-
* Validates that the value is of Convex type Float64 (Number in JS).
|
|
1174
|
-
*
|
|
1175
|
-
* Alias for `v.float64()`
|
|
1176
|
-
*/
|
|
1177
|
-
number: () => {
|
|
1178
|
-
return new VFloat64({ isOptional: "required" });
|
|
1179
|
-
},
|
|
1180
|
-
/**
|
|
1181
|
-
* Validates that the value is of Convex type Float64 (Number in JS).
|
|
1182
|
-
*/
|
|
1183
|
-
float64: () => {
|
|
1184
|
-
return new VFloat64({ isOptional: "required" });
|
|
1185
|
-
},
|
|
1186
|
-
/**
|
|
1187
|
-
* @deprecated Use `v.int64()` instead
|
|
1188
|
-
*/
|
|
1189
|
-
bigint: () => {
|
|
1190
|
-
return new VInt64({ isOptional: "required" });
|
|
1191
|
-
},
|
|
1192
|
-
/**
|
|
1193
|
-
* Validates that the value is of Convex type Int64 (BigInt in JS).
|
|
1194
|
-
*/
|
|
1195
|
-
int64: () => {
|
|
1196
|
-
return new VInt64({ isOptional: "required" });
|
|
1197
|
-
},
|
|
1198
|
-
/**
|
|
1199
|
-
* Validates that the value is of type Boolean.
|
|
1200
|
-
*/
|
|
1201
|
-
boolean: () => {
|
|
1202
|
-
return new VBoolean({ isOptional: "required" });
|
|
1203
|
-
},
|
|
1204
|
-
/**
|
|
1205
|
-
* Validates that the value is of type String.
|
|
1206
|
-
*/
|
|
1207
|
-
string: () => {
|
|
1208
|
-
return new VString({ isOptional: "required" });
|
|
1209
|
-
},
|
|
1210
|
-
/**
|
|
1211
|
-
* Validates that the value is of Convex type Bytes (constructed in JS via `ArrayBuffer`).
|
|
1212
|
-
*/
|
|
1213
|
-
bytes: () => {
|
|
1214
|
-
return new VBytes({ isOptional: "required" });
|
|
1215
|
-
},
|
|
1216
|
-
/**
|
|
1217
|
-
* Validates that the value is equal to the given literal value.
|
|
1218
|
-
* @param literal The literal value to compare against.
|
|
1219
|
-
*/
|
|
1220
|
-
literal: (literal) => {
|
|
1221
|
-
return new VLiteral({ isOptional: "required", value: literal });
|
|
1222
|
-
},
|
|
1223
|
-
/**
|
|
1224
|
-
* Validates that the value is an Array of the given element type.
|
|
1225
|
-
* @param element The validator for the elements of the array.
|
|
1226
|
-
*/
|
|
1227
|
-
array: (element) => {
|
|
1228
|
-
return new VArray({ isOptional: "required", element });
|
|
1229
|
-
},
|
|
1230
|
-
/**
|
|
1231
|
-
* Validates that the value is an Object with the given properties.
|
|
1232
|
-
* @param fields An object specifying the validator for each property.
|
|
1233
|
-
*/
|
|
1234
|
-
object: (fields) => {
|
|
1235
|
-
return new VObject({ isOptional: "required", fields });
|
|
1236
|
-
},
|
|
1237
|
-
/**
|
|
1238
|
-
* Validates that the value is a Record with keys and values that match the given types.
|
|
1239
|
-
* @param keys The validator for the keys of the record. This cannot contain string literals.
|
|
1240
|
-
* @param values The validator for the values of the record.
|
|
1241
|
-
*/
|
|
1242
|
-
record: (keys, values) => {
|
|
1243
|
-
return new VRecord({
|
|
1244
|
-
isOptional: "required",
|
|
1245
|
-
key: keys,
|
|
1246
|
-
value: values
|
|
1247
|
-
});
|
|
1248
|
-
},
|
|
1249
|
-
/**
|
|
1250
|
-
* Validates that the value matches one of the given validators.
|
|
1251
|
-
* @param members The validators to match against.
|
|
1252
|
-
*/
|
|
1253
|
-
union: (...members) => {
|
|
1254
|
-
return new VUnion({
|
|
1255
|
-
isOptional: "required",
|
|
1256
|
-
members
|
|
1257
|
-
});
|
|
1258
|
-
},
|
|
1259
|
-
/**
|
|
1260
|
-
* Does not validate the value.
|
|
1261
|
-
*/
|
|
1262
|
-
any: () => {
|
|
1263
|
-
return new VAny({ isOptional: "required" });
|
|
1264
|
-
},
|
|
1265
|
-
/**
|
|
1266
|
-
* Allows not specifying a value for a property in an Object.
|
|
1267
|
-
* @param value The property value validator to make optional.
|
|
1268
|
-
*
|
|
1269
|
-
* ```typescript
|
|
1270
|
-
* const objectWithOptionalFields = v.object({
|
|
1271
|
-
* requiredField: v.string(),
|
|
1272
|
-
* optionalField: v.optional(v.string()),
|
|
1273
|
-
* });
|
|
1274
|
-
* ```
|
|
1275
|
-
*/
|
|
1276
|
-
optional: (value) => {
|
|
1277
|
-
return value.asOptional();
|
|
1278
|
-
}
|
|
1279
|
-
};
|
|
1280
|
-
|
|
1281
|
-
// ../node_modules/convex/dist/esm/values/errors.js
|
|
1282
|
-
var __defProp2 = Object.defineProperty;
|
|
1283
|
-
var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1284
|
-
var __publicField2 = (obj, key, value) => __defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1285
814
|
var _a;
|
|
1286
815
|
var _b;
|
|
1287
816
|
var IDENTIFYING_FIELD = Symbol.for("ConvexError");
|
|
1288
817
|
var ConvexError = class extends (_b = Error, _a = IDENTIFYING_FIELD, _b) {
|
|
1289
818
|
constructor(data) {
|
|
1290
819
|
super(typeof data === "string" ? data : stringifyValueForError(data));
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
820
|
+
__publicField(this, "name", "ConvexError");
|
|
821
|
+
__publicField(this, "data");
|
|
822
|
+
__publicField(this, _a, true);
|
|
1294
823
|
this.data = data;
|
|
1295
824
|
}
|
|
1296
825
|
};
|
|
@@ -1301,9 +830,9 @@ var aBytes = arr();
|
|
|
1301
830
|
var bBytes = arr();
|
|
1302
831
|
|
|
1303
832
|
// ../node_modules/convex/dist/esm/browser/logging.js
|
|
1304
|
-
var
|
|
1305
|
-
var
|
|
1306
|
-
var
|
|
833
|
+
var __defProp2 = Object.defineProperty;
|
|
834
|
+
var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
835
|
+
var __publicField2 = (obj, key, value) => __defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1307
836
|
var INFO_COLOR = "color:rgb(0, 145, 255)";
|
|
1308
837
|
function prefix_for_source(source) {
|
|
1309
838
|
switch (source) {
|
|
@@ -1319,8 +848,8 @@ function prefix_for_source(source) {
|
|
|
1319
848
|
}
|
|
1320
849
|
var DefaultLogger = class {
|
|
1321
850
|
constructor(options) {
|
|
1322
|
-
|
|
1323
|
-
|
|
851
|
+
__publicField2(this, "_onLogLineFuncs");
|
|
852
|
+
__publicField2(this, "_verbose");
|
|
1324
853
|
this._onLogLineFuncs = {};
|
|
1325
854
|
this._verbose = options.verbose;
|
|
1326
855
|
}
|
|
@@ -1495,14 +1024,14 @@ function createApi(pathParts = []) {
|
|
|
1495
1024
|
var anyApi = createApi();
|
|
1496
1025
|
|
|
1497
1026
|
// ../node_modules/convex/dist/esm/browser/long.js
|
|
1498
|
-
var
|
|
1499
|
-
var
|
|
1500
|
-
var
|
|
1027
|
+
var __defProp3 = Object.defineProperty;
|
|
1028
|
+
var __defNormalProp3 = (obj, key, value) => key in obj ? __defProp3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1029
|
+
var __publicField3 = (obj, key, value) => __defNormalProp3(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1501
1030
|
var Long = class _Long {
|
|
1502
1031
|
constructor(low, high) {
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1032
|
+
__publicField3(this, "low");
|
|
1033
|
+
__publicField3(this, "high");
|
|
1034
|
+
__publicField3(this, "__isUnsignedLong__");
|
|
1506
1035
|
this.low = low | 0;
|
|
1507
1036
|
this.high = high | 0;
|
|
1508
1037
|
this.__isUnsignedLong__ = true;
|
|
@@ -1584,9 +1113,9 @@ import { createRequire } from "module";
|
|
|
1584
1113
|
import { resolve as nodePathResolve } from "path";
|
|
1585
1114
|
|
|
1586
1115
|
// ../node_modules/convex/dist/esm/browser/http_client.js
|
|
1587
|
-
var
|
|
1588
|
-
var
|
|
1589
|
-
var
|
|
1116
|
+
var __defProp4 = Object.defineProperty;
|
|
1117
|
+
var __defNormalProp4 = (obj, key, value) => key in obj ? __defProp4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1118
|
+
var __publicField4 = (obj, key, value) => __defNormalProp4(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1590
1119
|
var STATUS_CODE_UDF_FAILED = 560;
|
|
1591
1120
|
var specifiedFetch = void 0;
|
|
1592
1121
|
var ConvexHttpClient = class {
|
|
@@ -1609,15 +1138,15 @@ var ConvexHttpClient = class {
|
|
|
1609
1138
|
* but for short-lived clients it's convenient to specify this value here.
|
|
1610
1139
|
*/
|
|
1611
1140
|
constructor(address, options) {
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1141
|
+
__publicField4(this, "address");
|
|
1142
|
+
__publicField4(this, "auth");
|
|
1143
|
+
__publicField4(this, "adminAuth");
|
|
1144
|
+
__publicField4(this, "encodedTsPromise");
|
|
1145
|
+
__publicField4(this, "debug");
|
|
1146
|
+
__publicField4(this, "fetchOptions");
|
|
1147
|
+
__publicField4(this, "logger");
|
|
1148
|
+
__publicField4(this, "mutationQueue", []);
|
|
1149
|
+
__publicField4(this, "isProcessingQueue", false);
|
|
1621
1150
|
if (typeof options === "boolean") {
|
|
1622
1151
|
throw new Error(
|
|
1623
1152
|
"skipConvexDeploymentUrlCheck as the second argument is no longer supported. Please pass an options object, `{ skipConvexDeploymentUrlCheck: true }`."
|
|
@@ -1630,6 +1159,8 @@ var ConvexHttpClient = class {
|
|
|
1630
1159
|
this.logger = options?.logger === false ? instantiateNoopLogger({ verbose: false }) : options?.logger !== true && options?.logger ? options.logger : instantiateDefaultLogger({ verbose: false });
|
|
1631
1160
|
this.address = address;
|
|
1632
1161
|
this.debug = true;
|
|
1162
|
+
this.auth = void 0;
|
|
1163
|
+
this.adminAuth = void 0;
|
|
1633
1164
|
if (options?.auth) {
|
|
1634
1165
|
this.setAuth(options.auth);
|
|
1635
1166
|
}
|
|
@@ -2030,7 +1561,7 @@ function setDefaultWebSocketConstructor(ws) {
|
|
|
2030
1561
|
// ../node_modules/convex/dist/esm/browser/simple_client-node.js
|
|
2031
1562
|
var require2 = createRequire(nodePathResolve("."));
|
|
2032
1563
|
var __create = Object.create;
|
|
2033
|
-
var
|
|
1564
|
+
var __defProp5 = Object.defineProperty;
|
|
2034
1565
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
2035
1566
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
2036
1567
|
var __getProtoOf = Object.getPrototypeOf;
|
|
@@ -2048,7 +1579,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
2048
1579
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
2049
1580
|
for (let key of __getOwnPropNames(from))
|
|
2050
1581
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
2051
|
-
|
|
1582
|
+
__defProp5(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
2052
1583
|
}
|
|
2053
1584
|
return to;
|
|
2054
1585
|
};
|
|
@@ -2057,7 +1588,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
2057
1588
|
// file that has been converted to a CommonJS file using a Babel-
|
|
2058
1589
|
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
2059
1590
|
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
2060
|
-
isNodeMode || !mod || !mod.__esModule ?
|
|
1591
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp5(target, "default", { value: mod, enumerable: true }) : target,
|
|
2061
1592
|
mod
|
|
2062
1593
|
));
|
|
2063
1594
|
var require_stream = __commonJS({
|
|
@@ -5902,217 +5433,11 @@ var dbClient = () => {
|
|
|
5902
5433
|
return new ConvexHttpClient(convexUrl);
|
|
5903
5434
|
};
|
|
5904
5435
|
|
|
5905
|
-
// ../node_modules/convex/dist/esm/server/pagination.js
|
|
5906
|
-
var paginationOptsValidator = v.object({
|
|
5907
|
-
numItems: v.number(),
|
|
5908
|
-
cursor: v.union(v.string(), v.null()),
|
|
5909
|
-
endCursor: v.optional(v.union(v.string(), v.null())),
|
|
5910
|
-
id: v.optional(v.number()),
|
|
5911
|
-
maximumRowsRead: v.optional(v.number()),
|
|
5912
|
-
maximumBytesRead: v.optional(v.number())
|
|
5913
|
-
});
|
|
5914
|
-
|
|
5915
|
-
// ../node_modules/convex/dist/esm/server/schema.js
|
|
5916
|
-
var __defProp7 = Object.defineProperty;
|
|
5917
|
-
var __defNormalProp6 = (obj, key, value) => key in obj ? __defProp7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
5918
|
-
var __publicField6 = (obj, key, value) => __defNormalProp6(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5919
|
-
var TableDefinition = class {
|
|
5920
|
-
/**
|
|
5921
|
-
* @internal
|
|
5922
|
-
*/
|
|
5923
|
-
constructor(documentType) {
|
|
5924
|
-
__publicField6(this, "indexes");
|
|
5925
|
-
__publicField6(this, "stagedDbIndexes");
|
|
5926
|
-
__publicField6(this, "searchIndexes");
|
|
5927
|
-
__publicField6(this, "stagedSearchIndexes");
|
|
5928
|
-
__publicField6(this, "vectorIndexes");
|
|
5929
|
-
__publicField6(this, "stagedVectorIndexes");
|
|
5930
|
-
__publicField6(this, "validator");
|
|
5931
|
-
this.indexes = [];
|
|
5932
|
-
this.stagedDbIndexes = [];
|
|
5933
|
-
this.searchIndexes = [];
|
|
5934
|
-
this.stagedSearchIndexes = [];
|
|
5935
|
-
this.vectorIndexes = [];
|
|
5936
|
-
this.stagedVectorIndexes = [];
|
|
5937
|
-
this.validator = documentType;
|
|
5938
|
-
}
|
|
5939
|
-
/**
|
|
5940
|
-
* This API is experimental: it may change or disappear.
|
|
5941
|
-
*
|
|
5942
|
-
* Returns indexes defined on this table.
|
|
5943
|
-
* Intended for the advanced use cases of dynamically deciding which index to use for a query.
|
|
5944
|
-
* If you think you need this, please chime in on ths issue in the Convex JS GitHub repo.
|
|
5945
|
-
* https://github.com/get-convex/convex-js/issues/49
|
|
5946
|
-
*/
|
|
5947
|
-
" indexes"() {
|
|
5948
|
-
return this.indexes;
|
|
5949
|
-
}
|
|
5950
|
-
index(name2, indexConfig) {
|
|
5951
|
-
if (Array.isArray(indexConfig)) {
|
|
5952
|
-
this.indexes.push({
|
|
5953
|
-
indexDescriptor: name2,
|
|
5954
|
-
fields: indexConfig
|
|
5955
|
-
});
|
|
5956
|
-
} else if (indexConfig.staged) {
|
|
5957
|
-
this.stagedDbIndexes.push({
|
|
5958
|
-
indexDescriptor: name2,
|
|
5959
|
-
fields: indexConfig.fields
|
|
5960
|
-
});
|
|
5961
|
-
} else {
|
|
5962
|
-
this.indexes.push({
|
|
5963
|
-
indexDescriptor: name2,
|
|
5964
|
-
fields: indexConfig.fields
|
|
5965
|
-
});
|
|
5966
|
-
}
|
|
5967
|
-
return this;
|
|
5968
|
-
}
|
|
5969
|
-
searchIndex(name2, indexConfig) {
|
|
5970
|
-
if (indexConfig.staged) {
|
|
5971
|
-
this.stagedSearchIndexes.push({
|
|
5972
|
-
indexDescriptor: name2,
|
|
5973
|
-
searchField: indexConfig.searchField,
|
|
5974
|
-
filterFields: indexConfig.filterFields || []
|
|
5975
|
-
});
|
|
5976
|
-
} else {
|
|
5977
|
-
this.searchIndexes.push({
|
|
5978
|
-
indexDescriptor: name2,
|
|
5979
|
-
searchField: indexConfig.searchField,
|
|
5980
|
-
filterFields: indexConfig.filterFields || []
|
|
5981
|
-
});
|
|
5982
|
-
}
|
|
5983
|
-
return this;
|
|
5984
|
-
}
|
|
5985
|
-
vectorIndex(name2, indexConfig) {
|
|
5986
|
-
if (indexConfig.staged) {
|
|
5987
|
-
this.stagedVectorIndexes.push({
|
|
5988
|
-
indexDescriptor: name2,
|
|
5989
|
-
vectorField: indexConfig.vectorField,
|
|
5990
|
-
dimensions: indexConfig.dimensions,
|
|
5991
|
-
filterFields: indexConfig.filterFields || []
|
|
5992
|
-
});
|
|
5993
|
-
} else {
|
|
5994
|
-
this.vectorIndexes.push({
|
|
5995
|
-
indexDescriptor: name2,
|
|
5996
|
-
vectorField: indexConfig.vectorField,
|
|
5997
|
-
dimensions: indexConfig.dimensions,
|
|
5998
|
-
filterFields: indexConfig.filterFields || []
|
|
5999
|
-
});
|
|
6000
|
-
}
|
|
6001
|
-
return this;
|
|
6002
|
-
}
|
|
6003
|
-
/**
|
|
6004
|
-
* Work around for https://github.com/microsoft/TypeScript/issues/57035
|
|
6005
|
-
*/
|
|
6006
|
-
self() {
|
|
6007
|
-
return this;
|
|
6008
|
-
}
|
|
6009
|
-
/**
|
|
6010
|
-
* Export the contents of this definition.
|
|
6011
|
-
*
|
|
6012
|
-
* This is called internally by the Convex framework.
|
|
6013
|
-
* @internal
|
|
6014
|
-
*/
|
|
6015
|
-
export() {
|
|
6016
|
-
const documentType = this.validator.json;
|
|
6017
|
-
if (typeof documentType !== "object") {
|
|
6018
|
-
throw new Error(
|
|
6019
|
-
"Invalid validator: please make sure that the parameter of `defineTable` is valid (see https://docs.convex.dev/database/schemas)"
|
|
6020
|
-
);
|
|
6021
|
-
}
|
|
6022
|
-
return {
|
|
6023
|
-
indexes: this.indexes,
|
|
6024
|
-
stagedDbIndexes: this.stagedDbIndexes,
|
|
6025
|
-
searchIndexes: this.searchIndexes,
|
|
6026
|
-
stagedSearchIndexes: this.stagedSearchIndexes,
|
|
6027
|
-
vectorIndexes: this.vectorIndexes,
|
|
6028
|
-
stagedVectorIndexes: this.stagedVectorIndexes,
|
|
6029
|
-
documentType
|
|
6030
|
-
};
|
|
6031
|
-
}
|
|
6032
|
-
};
|
|
6033
|
-
function defineTable(documentSchema) {
|
|
6034
|
-
if (isValidator(documentSchema)) {
|
|
6035
|
-
return new TableDefinition(documentSchema);
|
|
6036
|
-
} else {
|
|
6037
|
-
return new TableDefinition(v.object(documentSchema));
|
|
6038
|
-
}
|
|
6039
|
-
}
|
|
6040
|
-
var SchemaDefinition = class {
|
|
6041
|
-
/**
|
|
6042
|
-
* @internal
|
|
6043
|
-
*/
|
|
6044
|
-
constructor(tables, options) {
|
|
6045
|
-
__publicField6(this, "tables");
|
|
6046
|
-
__publicField6(this, "strictTableNameTypes");
|
|
6047
|
-
__publicField6(this, "schemaValidation");
|
|
6048
|
-
this.tables = tables;
|
|
6049
|
-
this.schemaValidation = options?.schemaValidation === void 0 ? true : options.schemaValidation;
|
|
6050
|
-
}
|
|
6051
|
-
/**
|
|
6052
|
-
* Export the contents of this definition.
|
|
6053
|
-
*
|
|
6054
|
-
* This is called internally by the Convex framework.
|
|
6055
|
-
* @internal
|
|
6056
|
-
*/
|
|
6057
|
-
export() {
|
|
6058
|
-
return JSON.stringify({
|
|
6059
|
-
tables: Object.entries(this.tables).map(([tableName, definition]) => {
|
|
6060
|
-
const {
|
|
6061
|
-
indexes,
|
|
6062
|
-
stagedDbIndexes,
|
|
6063
|
-
searchIndexes,
|
|
6064
|
-
stagedSearchIndexes,
|
|
6065
|
-
vectorIndexes,
|
|
6066
|
-
stagedVectorIndexes,
|
|
6067
|
-
documentType
|
|
6068
|
-
} = definition.export();
|
|
6069
|
-
return {
|
|
6070
|
-
tableName,
|
|
6071
|
-
indexes,
|
|
6072
|
-
stagedDbIndexes,
|
|
6073
|
-
searchIndexes,
|
|
6074
|
-
stagedSearchIndexes,
|
|
6075
|
-
vectorIndexes,
|
|
6076
|
-
stagedVectorIndexes,
|
|
6077
|
-
documentType
|
|
6078
|
-
};
|
|
6079
|
-
}),
|
|
6080
|
-
schemaValidation: this.schemaValidation
|
|
6081
|
-
});
|
|
6082
|
-
}
|
|
6083
|
-
};
|
|
6084
|
-
function defineSchema(schema, options) {
|
|
6085
|
-
return new SchemaDefinition(schema, options);
|
|
6086
|
-
}
|
|
6087
|
-
var _systemSchema = defineSchema({
|
|
6088
|
-
_scheduled_functions: defineTable({
|
|
6089
|
-
name: v.string(),
|
|
6090
|
-
args: v.array(v.any()),
|
|
6091
|
-
scheduledTime: v.float64(),
|
|
6092
|
-
completedTime: v.optional(v.float64()),
|
|
6093
|
-
state: v.union(
|
|
6094
|
-
v.object({ kind: v.literal("pending") }),
|
|
6095
|
-
v.object({ kind: v.literal("inProgress") }),
|
|
6096
|
-
v.object({ kind: v.literal("success") }),
|
|
6097
|
-
v.object({ kind: v.literal("failed"), error: v.string() }),
|
|
6098
|
-
v.object({ kind: v.literal("canceled") })
|
|
6099
|
-
)
|
|
6100
|
-
}),
|
|
6101
|
-
_storage: defineTable({
|
|
6102
|
-
sha256: v.string(),
|
|
6103
|
-
size: v.float64(),
|
|
6104
|
-
contentType: v.optional(v.string())
|
|
6105
|
-
})
|
|
6106
|
-
});
|
|
6107
|
-
|
|
6108
|
-
// _generated/api.js
|
|
6109
|
-
var api = anyApi;
|
|
6110
|
-
|
|
6111
5436
|
// src/db/user.ts
|
|
6112
5437
|
var getUserIdFromApiKeyOrNull = async (apiKey) => {
|
|
6113
5438
|
const db = dbClient();
|
|
6114
5439
|
const user = await db.mutation(
|
|
6115
|
-
|
|
5440
|
+
"apiKeys:validateApiKeyAndReturnUserIdOrNull",
|
|
6116
5441
|
{ apiKey }
|
|
6117
5442
|
);
|
|
6118
5443
|
if (!user) {
|
|
@@ -6121,96 +5446,141 @@ var getUserIdFromApiKeyOrNull = async (apiKey) => {
|
|
|
6121
5446
|
return user;
|
|
6122
5447
|
};
|
|
6123
5448
|
|
|
6124
|
-
// src/
|
|
6125
|
-
|
|
6126
|
-
|
|
6127
|
-
|
|
6128
|
-
|
|
6129
|
-
temperature: z.number().optional(),
|
|
6130
|
-
toolChoice: z.string().optional()
|
|
6131
|
-
}).passthrough();
|
|
6132
|
-
var TestCaseSchema = z.object({
|
|
6133
|
-
title: z.string(),
|
|
6134
|
-
query: z.string(),
|
|
6135
|
-
runs: z.number().int(),
|
|
6136
|
-
model: z.string(),
|
|
6137
|
-
provider: z.string(),
|
|
6138
|
-
expectedToolCalls: z.array(z.string()),
|
|
6139
|
-
judgeRequirement: z.string().optional(),
|
|
6140
|
-
advancedConfig: AdvancedConfigSchema.optional()
|
|
6141
|
-
});
|
|
6142
|
-
function validateTestCase(value) {
|
|
5449
|
+
// src/db/tests.ts
|
|
5450
|
+
var runDbAction = async (persistence, action, payload) => {
|
|
5451
|
+
if (!persistence.enabled || !persistence.db) {
|
|
5452
|
+
return void 0;
|
|
5453
|
+
}
|
|
6143
5454
|
try {
|
|
6144
|
-
|
|
6145
|
-
|
|
6146
|
-
|
|
6147
|
-
if (error instanceof z.ZodError) {
|
|
6148
|
-
throw new Error(error.message);
|
|
6149
|
-
}
|
|
6150
|
-
throw new Error(error instanceof Error ? error.message : String(error));
|
|
5455
|
+
return await persistence.db.action(action, payload);
|
|
5456
|
+
} catch {
|
|
5457
|
+
return void 0;
|
|
6151
5458
|
}
|
|
6152
|
-
}
|
|
6153
|
-
var
|
|
6154
|
-
|
|
6155
|
-
|
|
6156
|
-
|
|
6157
|
-
|
|
5459
|
+
};
|
|
5460
|
+
var createPersistenceContext = (apiKey, configSummary, totalPlannedTests) => ({
|
|
5461
|
+
enabled: Boolean(apiKey),
|
|
5462
|
+
apiKey,
|
|
5463
|
+
db: apiKey ? dbClient() : null,
|
|
5464
|
+
configSummary,
|
|
5465
|
+
totalPlannedTests
|
|
6158
5466
|
});
|
|
6159
|
-
var
|
|
6160
|
-
|
|
6161
|
-
|
|
6162
|
-
|
|
6163
|
-
|
|
6164
|
-
|
|
6165
|
-
|
|
6166
|
-
|
|
6167
|
-
|
|
6168
|
-
|
|
6169
|
-
|
|
6170
|
-
|
|
6171
|
-
sessionId: z.custom().optional()
|
|
6172
|
-
}).strict();
|
|
6173
|
-
var MCPClientOptionsSchema = z.custom();
|
|
6174
|
-
var MastraMCPServerDefinitionSchema = z.union([
|
|
6175
|
-
StdioServerDefinitionSchema,
|
|
6176
|
-
HttpServerDefinitionSchema
|
|
6177
|
-
]);
|
|
6178
|
-
function validateAndNormalizeMCPClientConfiguration(value) {
|
|
6179
|
-
try {
|
|
6180
|
-
const envParsed = MCPClientOptionsSchema.parse(value);
|
|
6181
|
-
const normalizedServers = {};
|
|
6182
|
-
for (const [name2, server] of Object.entries(envParsed.servers)) {
|
|
6183
|
-
try {
|
|
6184
|
-
if (server && typeof server === "object" && "url" in server) {
|
|
6185
|
-
MastraMCPServerDefinitionSchema.parse(server);
|
|
6186
|
-
const urlValue = server.url;
|
|
6187
|
-
const normalizedUrl = typeof urlValue === "string" ? new URL(urlValue) : urlValue;
|
|
6188
|
-
const normalizedServer = {
|
|
6189
|
-
...server,
|
|
6190
|
-
url: normalizedUrl
|
|
6191
|
-
};
|
|
6192
|
-
normalizedServers[name2] = normalizedServer;
|
|
6193
|
-
} else {
|
|
6194
|
-
MastraMCPServerDefinitionSchema.parse(server);
|
|
6195
|
-
normalizedServers[name2] = server;
|
|
6196
|
-
}
|
|
6197
|
-
} catch (error) {
|
|
6198
|
-
if (error instanceof z.ZodError) {
|
|
6199
|
-
throw new Error(
|
|
6200
|
-
`Invalid server configuration for '${name2}': ${error.message}`
|
|
6201
|
-
);
|
|
6202
|
-
}
|
|
6203
|
-
throw new Error(`Invalid server configuration for '${name2}': ${error}`);
|
|
6204
|
-
}
|
|
5467
|
+
var ensureSuiteRecord = async (persistence) => {
|
|
5468
|
+
if (!persistence.enabled || !persistence.apiKey || persistence.testRunId) {
|
|
5469
|
+
return;
|
|
5470
|
+
}
|
|
5471
|
+
const createdId = await runDbAction(
|
|
5472
|
+
persistence,
|
|
5473
|
+
"evals:createEvalTestSuiteWithApiKey",
|
|
5474
|
+
{
|
|
5475
|
+
apiKey: persistence.apiKey,
|
|
5476
|
+
name: void 0,
|
|
5477
|
+
config: persistence.configSummary,
|
|
5478
|
+
totalTests: persistence.totalPlannedTests
|
|
6205
5479
|
}
|
|
6206
|
-
|
|
6207
|
-
|
|
6208
|
-
|
|
6209
|
-
};
|
|
6210
|
-
} catch (error) {
|
|
6211
|
-
throw new Error(error instanceof Error ? error.message : String(error));
|
|
5480
|
+
);
|
|
5481
|
+
if (createdId) {
|
|
5482
|
+
persistence.testRunId = createdId;
|
|
6212
5483
|
}
|
|
6213
|
-
}
|
|
5484
|
+
};
|
|
5485
|
+
var createTestCaseRecord = async (persistence, test, testNumber) => {
|
|
5486
|
+
if (!persistence.enabled || !persistence.apiKey) {
|
|
5487
|
+
return void 0;
|
|
5488
|
+
}
|
|
5489
|
+
const testCaseId = await runDbAction(
|
|
5490
|
+
persistence,
|
|
5491
|
+
"evals:createEvalTestCaseWithApiKey",
|
|
5492
|
+
{
|
|
5493
|
+
apiKey: persistence.apiKey,
|
|
5494
|
+
title: String(test.title ?? `Group ${testNumber}`),
|
|
5495
|
+
query: String(test.query ?? ""),
|
|
5496
|
+
provider: String(test.provider ?? ""),
|
|
5497
|
+
model: String(test.model ?? ""),
|
|
5498
|
+
runs: Number(test.runs ?? 1)
|
|
5499
|
+
}
|
|
5500
|
+
);
|
|
5501
|
+
if (!persistence.testRunId) {
|
|
5502
|
+
await ensureSuiteRecord(persistence);
|
|
5503
|
+
}
|
|
5504
|
+
return testCaseId;
|
|
5505
|
+
};
|
|
5506
|
+
var createIterationRecord = async (persistence, testCaseId, iterationNumber, startedAt) => {
|
|
5507
|
+
if (!persistence.enabled || !persistence.apiKey || !testCaseId) {
|
|
5508
|
+
return void 0;
|
|
5509
|
+
}
|
|
5510
|
+
return await runDbAction(
|
|
5511
|
+
persistence,
|
|
5512
|
+
"evals:createEvalTestIterationWithApiKey",
|
|
5513
|
+
{
|
|
5514
|
+
apiKey: persistence.apiKey,
|
|
5515
|
+
testCaseId,
|
|
5516
|
+
startedAt,
|
|
5517
|
+
iterationNumber,
|
|
5518
|
+
blob: void 0,
|
|
5519
|
+
actualToolCalls: [],
|
|
5520
|
+
tokensUsed: 0
|
|
5521
|
+
}
|
|
5522
|
+
);
|
|
5523
|
+
};
|
|
5524
|
+
var updateIterationResult = async (persistence, evalTestId, passed, toolsCalled, tokensUsed, messages) => {
|
|
5525
|
+
if (!persistence.enabled || !persistence.apiKey || !evalTestId) {
|
|
5526
|
+
return;
|
|
5527
|
+
}
|
|
5528
|
+
await runDbAction(
|
|
5529
|
+
persistence,
|
|
5530
|
+
"evals:updateEvalTestIterationResultWithApiKey",
|
|
5531
|
+
{
|
|
5532
|
+
apiKey: persistence.apiKey,
|
|
5533
|
+
testId: evalTestId,
|
|
5534
|
+
status: "completed",
|
|
5535
|
+
result: passed ? "passed" : "failed",
|
|
5536
|
+
actualToolCalls: toolsCalled,
|
|
5537
|
+
tokensUsed: tokensUsed.totalTokens ?? 0,
|
|
5538
|
+
blob: void 0,
|
|
5539
|
+
blobContent: { messages }
|
|
5540
|
+
}
|
|
5541
|
+
);
|
|
5542
|
+
};
|
|
5543
|
+
var updateTestCaseResult = async (persistence, testCaseId, passedRuns, failedRuns) => {
|
|
5544
|
+
if (!persistence.enabled || !persistence.apiKey || !testCaseId) {
|
|
5545
|
+
return;
|
|
5546
|
+
}
|
|
5547
|
+
const result = failedRuns > 0 ? "failed" : "passed";
|
|
5548
|
+
await runDbAction(persistence, "evals:updateEvalTestCaseResultWithApiKey", {
|
|
5549
|
+
apiKey: persistence.apiKey,
|
|
5550
|
+
testCaseId,
|
|
5551
|
+
result
|
|
5552
|
+
});
|
|
5553
|
+
};
|
|
5554
|
+
var markSuiteFailed = async (persistence) => {
|
|
5555
|
+
if (!persistence.enabled || !persistence.apiKey || !persistence.testRunId) {
|
|
5556
|
+
return;
|
|
5557
|
+
}
|
|
5558
|
+
await runDbAction(persistence, "evals:updateEvalTestSuiteStatusWithApiKey", {
|
|
5559
|
+
apiKey: persistence.apiKey,
|
|
5560
|
+
testRunId: persistence.testRunId,
|
|
5561
|
+
status: "running",
|
|
5562
|
+
result: "failed"
|
|
5563
|
+
});
|
|
5564
|
+
};
|
|
5565
|
+
var finalizeSuiteStatus = async (persistence, failedRuns) => {
|
|
5566
|
+
if (!persistence.enabled || !persistence.apiKey || !persistence.testRunId) {
|
|
5567
|
+
return;
|
|
5568
|
+
}
|
|
5569
|
+
await runDbAction(persistence, "evals:updateEvalTestSuiteStatusWithApiKey", {
|
|
5570
|
+
apiKey: persistence.apiKey,
|
|
5571
|
+
testRunId: persistence.testRunId,
|
|
5572
|
+
status: "completed",
|
|
5573
|
+
result: failedRuns > 0 ? "failed" : "passed",
|
|
5574
|
+
finishedAt: Date.now()
|
|
5575
|
+
});
|
|
5576
|
+
};
|
|
5577
|
+
|
|
5578
|
+
// src/utils/validators.ts
|
|
5579
|
+
import { z as z2 } from "zod";
|
|
5580
|
+
|
|
5581
|
+
// ../shared/tools.ts
|
|
5582
|
+
import { z } from "zod";
|
|
5583
|
+
import { tool } from "ai";
|
|
6214
5584
|
var fallbackInputSchema = z.object({}).passthrough();
|
|
6215
5585
|
function isZodSchema(value) {
|
|
6216
5586
|
return Boolean(
|
|
@@ -6282,17 +5652,108 @@ function convertMastraToolsToVercelTools(mastraTools) {
|
|
|
6282
5652
|
})
|
|
6283
5653
|
);
|
|
6284
5654
|
}
|
|
6285
|
-
|
|
6286
|
-
|
|
6287
|
-
|
|
6288
|
-
|
|
5655
|
+
|
|
5656
|
+
// src/utils/validators.ts
|
|
5657
|
+
var AdvancedConfigSchema = z2.object({
|
|
5658
|
+
system: z2.string().optional(),
|
|
5659
|
+
temperature: z2.number().optional(),
|
|
5660
|
+
toolChoice: z2.string().optional()
|
|
5661
|
+
}).passthrough();
|
|
5662
|
+
var TestCaseSchema = z2.object({
|
|
5663
|
+
title: z2.string(),
|
|
5664
|
+
query: z2.string(),
|
|
5665
|
+
runs: z2.number().int(),
|
|
5666
|
+
model: z2.string(),
|
|
5667
|
+
provider: z2.string(),
|
|
5668
|
+
expectedToolCalls: z2.array(z2.string()),
|
|
5669
|
+
judgeRequirement: z2.string().optional(),
|
|
5670
|
+
advancedConfig: AdvancedConfigSchema.optional()
|
|
5671
|
+
});
|
|
5672
|
+
function validateTestCase(value) {
|
|
5673
|
+
try {
|
|
5674
|
+
const result = z2.array(TestCaseSchema).parse(value);
|
|
5675
|
+
return result;
|
|
5676
|
+
} catch (error) {
|
|
5677
|
+
if (error instanceof z2.ZodError) {
|
|
5678
|
+
throw new Error(error.message);
|
|
5679
|
+
}
|
|
5680
|
+
throw new Error(error instanceof Error ? error.message : String(error));
|
|
5681
|
+
}
|
|
5682
|
+
}
|
|
5683
|
+
var BaseServerOptionsSchema = z2.object({
|
|
5684
|
+
logger: z2.custom().optional(),
|
|
5685
|
+
timeout: z2.number().optional(),
|
|
5686
|
+
capabilities: z2.custom().optional(),
|
|
5687
|
+
enableServerLogs: z2.boolean().optional()
|
|
5688
|
+
});
|
|
5689
|
+
var StdioServerDefinitionSchema = BaseServerOptionsSchema.extend({
|
|
5690
|
+
command: z2.string(),
|
|
5691
|
+
args: z2.array(z2.string()).optional(),
|
|
5692
|
+
env: z2.record(z2.string(), z2.string()).optional()
|
|
5693
|
+
}).strict();
|
|
5694
|
+
var HttpServerDefinitionSchema = BaseServerOptionsSchema.extend({
|
|
5695
|
+
// Accept either a URL object or a string URL, but we'll normalize to string
|
|
5696
|
+
url: z2.union([z2.string().url(), z2.instanceof(URL)]),
|
|
5697
|
+
requestInit: z2.custom().optional(),
|
|
5698
|
+
eventSourceInit: z2.custom().optional(),
|
|
5699
|
+
authProvider: z2.custom().optional(),
|
|
5700
|
+
reconnectionOptions: z2.custom().optional(),
|
|
5701
|
+
sessionId: z2.custom().optional()
|
|
5702
|
+
}).strict();
|
|
5703
|
+
var MCPClientOptionsSchema = z2.custom();
|
|
5704
|
+
var MastraMCPServerDefinitionSchema = z2.union([
|
|
5705
|
+
StdioServerDefinitionSchema,
|
|
5706
|
+
HttpServerDefinitionSchema
|
|
5707
|
+
]);
|
|
5708
|
+
function validateAndNormalizeMCPClientConfiguration(value) {
|
|
5709
|
+
try {
|
|
5710
|
+
const envParsed = MCPClientOptionsSchema.parse(value);
|
|
5711
|
+
const normalizedServers = {};
|
|
5712
|
+
for (const [name2, server] of Object.entries(envParsed.servers)) {
|
|
5713
|
+
try {
|
|
5714
|
+
if (server && typeof server === "object" && "url" in server) {
|
|
5715
|
+
MastraMCPServerDefinitionSchema.parse(server);
|
|
5716
|
+
server.enableServerLogs = false;
|
|
5717
|
+
const urlValue = server.url;
|
|
5718
|
+
const normalizedUrl = typeof urlValue === "string" ? new URL(urlValue) : urlValue;
|
|
5719
|
+
const normalizedServer = {
|
|
5720
|
+
...server,
|
|
5721
|
+
url: normalizedUrl
|
|
5722
|
+
};
|
|
5723
|
+
normalizedServers[name2] = normalizedServer;
|
|
5724
|
+
} else {
|
|
5725
|
+
MastraMCPServerDefinitionSchema.parse(server);
|
|
5726
|
+
server.enableServerLogs = false;
|
|
5727
|
+
normalizedServers[name2] = server;
|
|
5728
|
+
}
|
|
5729
|
+
} catch (error) {
|
|
5730
|
+
if (error instanceof z2.ZodError) {
|
|
5731
|
+
throw new Error(
|
|
5732
|
+
`Invalid server configuration for '${name2}': ${error.message}`
|
|
5733
|
+
);
|
|
5734
|
+
}
|
|
5735
|
+
throw new Error(`Invalid server configuration for '${name2}': ${error}`);
|
|
5736
|
+
}
|
|
5737
|
+
}
|
|
5738
|
+
return {
|
|
5739
|
+
...envParsed,
|
|
5740
|
+
servers: normalizedServers
|
|
5741
|
+
};
|
|
5742
|
+
} catch (error) {
|
|
5743
|
+
throw new Error(error instanceof Error ? error.message : String(error));
|
|
5744
|
+
}
|
|
5745
|
+
}
|
|
5746
|
+
var LlmsConfigSchema = z2.object({
|
|
5747
|
+
anthropic: z2.string().optional(),
|
|
5748
|
+
openai: z2.string().optional(),
|
|
5749
|
+
openrouter: z2.string().optional()
|
|
6289
5750
|
}).passthrough();
|
|
6290
5751
|
function validateLlms(value) {
|
|
6291
5752
|
try {
|
|
6292
5753
|
const result = LlmsConfigSchema.parse(value);
|
|
6293
5754
|
return result;
|
|
6294
5755
|
} catch (error) {
|
|
6295
|
-
if (error instanceof
|
|
5756
|
+
if (error instanceof z2.ZodError) {
|
|
6296
5757
|
throw new Error(`Invalid LLMs configuration: ${error.message}`);
|
|
6297
5758
|
}
|
|
6298
5759
|
throw new Error(error instanceof Error ? error.message : String(error));
|
|
@@ -6333,147 +5794,314 @@ var evaluateResults = (expectedToolCalls, toolsCalled) => {
|
|
|
6333
5794
|
};
|
|
6334
5795
|
};
|
|
6335
5796
|
|
|
5797
|
+
// src/utils/user-id.ts
|
|
5798
|
+
import { randomUUID } from "crypto";
|
|
5799
|
+
import { homedir } from "os";
|
|
5800
|
+
import { join } from "path";
|
|
5801
|
+
import { readFileSync, writeFileSync, existsSync, mkdirSync } from "fs";
|
|
5802
|
+
var CONFIG_DIR = join(homedir(), ".mcpjam");
|
|
5803
|
+
var USER_ID_FILE = join(CONFIG_DIR, "user-id.json");
|
|
5804
|
+
function getUserId() {
|
|
5805
|
+
try {
|
|
5806
|
+
if (!existsSync(CONFIG_DIR)) {
|
|
5807
|
+
mkdirSync(CONFIG_DIR, { recursive: true });
|
|
5808
|
+
}
|
|
5809
|
+
if (existsSync(USER_ID_FILE)) {
|
|
5810
|
+
const configData = readFileSync(USER_ID_FILE, "utf8");
|
|
5811
|
+
const config2 = JSON.parse(configData);
|
|
5812
|
+
if (config2.userId && typeof config2.userId === "string") {
|
|
5813
|
+
return config2.userId;
|
|
5814
|
+
}
|
|
5815
|
+
}
|
|
5816
|
+
const newUserId = randomUUID();
|
|
5817
|
+
const newConfig = {
|
|
5818
|
+
userId: newUserId,
|
|
5819
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
5820
|
+
};
|
|
5821
|
+
writeFileSync(USER_ID_FILE, JSON.stringify(newConfig, null, 2));
|
|
5822
|
+
return newUserId;
|
|
5823
|
+
} catch (error) {
|
|
5824
|
+
console.warn("Failed to persist user ID, using session-based ID:", error);
|
|
5825
|
+
return randomUUID();
|
|
5826
|
+
}
|
|
5827
|
+
}
|
|
5828
|
+
|
|
5829
|
+
// src/utils/hog.ts
|
|
5830
|
+
import { PostHog } from "posthog-node";
|
|
5831
|
+
var hogClient = new PostHog(
|
|
5832
|
+
"phc_dTOPniyUNU2kD8Jx8yHMXSqiZHM8I91uWopTMX6EBE9",
|
|
5833
|
+
{ host: "https://us.i.posthog.com" }
|
|
5834
|
+
);
|
|
5835
|
+
|
|
6336
5836
|
// src/evals/runner.ts
|
|
6337
|
-
var
|
|
6338
|
-
|
|
6339
|
-
|
|
5837
|
+
var MAX_STEPS = 20;
|
|
5838
|
+
var accumulateTokenCount = (current, increment) => {
|
|
5839
|
+
if (typeof increment !== "number" || Number.isNaN(increment)) {
|
|
5840
|
+
return current;
|
|
5841
|
+
}
|
|
5842
|
+
return (current ?? 0) + increment;
|
|
5843
|
+
};
|
|
5844
|
+
var ensureApiKeyIsValid = async (apiKey) => {
|
|
5845
|
+
if (!apiKey) {
|
|
5846
|
+
return;
|
|
6340
5847
|
}
|
|
5848
|
+
await getUserIdFromApiKeyOrNull(apiKey);
|
|
5849
|
+
};
|
|
5850
|
+
var prepareSuite = async (tests, environment, llms) => {
|
|
6341
5851
|
const mcpClientOptions = validateAndNormalizeMCPClientConfiguration(environment);
|
|
6342
5852
|
const validatedTests = validateTestCase(tests);
|
|
6343
|
-
const
|
|
5853
|
+
const validatedLlms = validateLlms(llms);
|
|
6344
5854
|
const mcpClient = new MCPClient(mcpClientOptions);
|
|
6345
5855
|
const availableTools = await mcpClient.getTools();
|
|
6346
|
-
const serverCount = Object.keys(mcpClientOptions.servers).length;
|
|
6347
|
-
const toolCount = Object.keys(availableTools).length;
|
|
6348
|
-
Logger.serverConnection(serverCount, toolCount);
|
|
6349
|
-
Logger.startTests(validatedTests.length);
|
|
6350
5856
|
const vercelTools = convertMastraToolsToVercelTools(availableTools);
|
|
6351
|
-
const
|
|
6352
|
-
|
|
6353
|
-
|
|
6354
|
-
|
|
6355
|
-
|
|
6356
|
-
|
|
6357
|
-
|
|
6358
|
-
|
|
6359
|
-
|
|
6360
|
-
|
|
6361
|
-
|
|
6362
|
-
|
|
6363
|
-
|
|
6364
|
-
|
|
6365
|
-
|
|
6366
|
-
|
|
6367
|
-
|
|
6368
|
-
|
|
6369
|
-
|
|
6370
|
-
|
|
6371
|
-
|
|
6372
|
-
|
|
6373
|
-
|
|
6374
|
-
|
|
6375
|
-
|
|
6376
|
-
|
|
6377
|
-
|
|
6378
|
-
|
|
6379
|
-
|
|
6380
|
-
|
|
6381
|
-
|
|
6382
|
-
|
|
6383
|
-
|
|
6384
|
-
|
|
6385
|
-
|
|
6386
|
-
|
|
6387
|
-
|
|
6388
|
-
|
|
6389
|
-
|
|
6390
|
-
|
|
6391
|
-
|
|
6392
|
-
|
|
6393
|
-
|
|
6394
|
-
|
|
6395
|
-
|
|
6396
|
-
|
|
6397
|
-
|
|
6398
|
-
|
|
6399
|
-
|
|
6400
|
-
|
|
6401
|
-
|
|
6402
|
-
|
|
6403
|
-
|
|
6404
|
-
|
|
6405
|
-
|
|
6406
|
-
|
|
6407
|
-
|
|
6408
|
-
|
|
6409
|
-
|
|
6410
|
-
|
|
6411
|
-
|
|
6412
|
-
|
|
6413
|
-
|
|
6414
|
-
|
|
6415
|
-
|
|
6416
|
-
|
|
5857
|
+
const serverNames = Object.keys(mcpClientOptions.servers);
|
|
5858
|
+
Logger.initiateTestMessage(
|
|
5859
|
+
serverNames.length,
|
|
5860
|
+
Object.keys(availableTools).length,
|
|
5861
|
+
serverNames,
|
|
5862
|
+
validatedTests.length
|
|
5863
|
+
);
|
|
5864
|
+
return {
|
|
5865
|
+
validatedTests,
|
|
5866
|
+
validatedLlms,
|
|
5867
|
+
vercelTools,
|
|
5868
|
+
serverNames
|
|
5869
|
+
};
|
|
5870
|
+
};
|
|
5871
|
+
var runIteration = async ({
|
|
5872
|
+
test,
|
|
5873
|
+
runIndex,
|
|
5874
|
+
totalRuns,
|
|
5875
|
+
llms,
|
|
5876
|
+
tools,
|
|
5877
|
+
persistence,
|
|
5878
|
+
testCaseId
|
|
5879
|
+
}) => {
|
|
5880
|
+
const { provider, model, advancedConfig, query } = test;
|
|
5881
|
+
const { system, temperature, toolChoice } = advancedConfig ?? {};
|
|
5882
|
+
Logger.testRunStart({
|
|
5883
|
+
runNumber: runIndex + 1,
|
|
5884
|
+
totalRuns,
|
|
5885
|
+
provider,
|
|
5886
|
+
model,
|
|
5887
|
+
temperature
|
|
5888
|
+
});
|
|
5889
|
+
if (system) {
|
|
5890
|
+
Logger.conversation({ messages: [{ role: "system", content: system }] });
|
|
5891
|
+
}
|
|
5892
|
+
const userMessage = {
|
|
5893
|
+
role: "user",
|
|
5894
|
+
content: query
|
|
5895
|
+
};
|
|
5896
|
+
Logger.conversation({ messages: [userMessage] });
|
|
5897
|
+
const messageHistory = [userMessage];
|
|
5898
|
+
const toolsCalled = [];
|
|
5899
|
+
let inputTokensUsed;
|
|
5900
|
+
let outputTokensUsed;
|
|
5901
|
+
let totalTokensUsed;
|
|
5902
|
+
let stepCount = 0;
|
|
5903
|
+
const runStartedAt = Date.now();
|
|
5904
|
+
const evalTestId = await createIterationRecord(
|
|
5905
|
+
persistence,
|
|
5906
|
+
testCaseId,
|
|
5907
|
+
runIndex + 1,
|
|
5908
|
+
runStartedAt
|
|
5909
|
+
);
|
|
5910
|
+
while (stepCount < MAX_STEPS) {
|
|
5911
|
+
let assistantStreaming = false;
|
|
5912
|
+
const streamResult = await streamText({
|
|
5913
|
+
model: createLlmModel(provider, model, llms),
|
|
5914
|
+
system,
|
|
5915
|
+
temperature,
|
|
5916
|
+
tools,
|
|
5917
|
+
toolChoice,
|
|
5918
|
+
messages: messageHistory,
|
|
5919
|
+
onChunk: async (chunk) => {
|
|
5920
|
+
switch (chunk.chunk.type) {
|
|
5921
|
+
case "text-delta":
|
|
5922
|
+
case "reasoning-delta": {
|
|
5923
|
+
if (!assistantStreaming) {
|
|
5924
|
+
Logger.beginStreamingMessage("assistant");
|
|
5925
|
+
assistantStreaming = true;
|
|
6417
5926
|
}
|
|
5927
|
+
Logger.appendStreamingText(chunk.chunk.text);
|
|
5928
|
+
break;
|
|
6418
5929
|
}
|
|
6419
|
-
|
|
6420
|
-
|
|
6421
|
-
|
|
6422
|
-
|
|
6423
|
-
|
|
6424
|
-
|
|
6425
|
-
|
|
6426
|
-
|
|
6427
|
-
|
|
6428
|
-
|
|
6429
|
-
|
|
6430
|
-
|
|
6431
|
-
|
|
6432
|
-
|
|
6433
|
-
messageHistory.push(...responseMessages);
|
|
6434
|
-
}
|
|
6435
|
-
stepCount++;
|
|
6436
|
-
const finishReason = await streamResult.finishReason;
|
|
6437
|
-
if (finishReason !== "tool-calls") {
|
|
6438
|
-
break;
|
|
5930
|
+
case "tool-call": {
|
|
5931
|
+
if (assistantStreaming) {
|
|
5932
|
+
Logger.finishStreamingMessage();
|
|
5933
|
+
assistantStreaming = false;
|
|
5934
|
+
}
|
|
5935
|
+
Logger.streamToolCall(chunk.chunk.toolName, chunk.chunk.input);
|
|
5936
|
+
break;
|
|
5937
|
+
}
|
|
5938
|
+
case "tool-result": {
|
|
5939
|
+
Logger.streamToolResult(chunk.chunk.toolName, chunk.chunk.output);
|
|
5940
|
+
break;
|
|
5941
|
+
}
|
|
5942
|
+
default:
|
|
5943
|
+
break;
|
|
6439
5944
|
}
|
|
6440
5945
|
}
|
|
5946
|
+
});
|
|
5947
|
+
await streamResult.consumeStream();
|
|
5948
|
+
if (assistantStreaming) {
|
|
6441
5949
|
Logger.finishStreamingMessage();
|
|
6442
|
-
|
|
6443
|
-
|
|
6444
|
-
|
|
6445
|
-
|
|
6446
|
-
|
|
6447
|
-
|
|
6448
|
-
|
|
6449
|
-
|
|
6450
|
-
|
|
6451
|
-
|
|
6452
|
-
|
|
6453
|
-
|
|
6454
|
-
|
|
6455
|
-
|
|
6456
|
-
|
|
6457
|
-
|
|
6458
|
-
|
|
6459
|
-
|
|
6460
|
-
|
|
6461
|
-
|
|
6462
|
-
|
|
6463
|
-
|
|
5950
|
+
assistantStreaming = false;
|
|
5951
|
+
}
|
|
5952
|
+
const stepUsage = await streamResult.usage;
|
|
5953
|
+
const cumulativeUsage = await streamResult.totalUsage;
|
|
5954
|
+
inputTokensUsed = accumulateTokenCount(
|
|
5955
|
+
inputTokensUsed,
|
|
5956
|
+
stepUsage.inputTokens
|
|
5957
|
+
);
|
|
5958
|
+
outputTokensUsed = accumulateTokenCount(
|
|
5959
|
+
outputTokensUsed,
|
|
5960
|
+
stepUsage.outputTokens
|
|
5961
|
+
);
|
|
5962
|
+
const totalTokens = stepUsage.totalTokens ?? cumulativeUsage.totalTokens;
|
|
5963
|
+
totalTokensUsed = accumulateTokenCount(totalTokensUsed, totalTokens);
|
|
5964
|
+
const toolNamesForStep = extractToolNamesAsArray(
|
|
5965
|
+
await streamResult.toolCalls
|
|
5966
|
+
);
|
|
5967
|
+
if (toolNamesForStep.length) {
|
|
5968
|
+
toolsCalled.push(...toolNamesForStep);
|
|
5969
|
+
}
|
|
5970
|
+
const responseMessages = (await streamResult.response)?.messages ?? [];
|
|
5971
|
+
if (responseMessages.length) {
|
|
5972
|
+
messageHistory.push(...responseMessages);
|
|
5973
|
+
}
|
|
5974
|
+
stepCount++;
|
|
5975
|
+
const finishReason = await streamResult.finishReason;
|
|
5976
|
+
if (finishReason !== "tool-calls") {
|
|
5977
|
+
break;
|
|
5978
|
+
}
|
|
5979
|
+
}
|
|
5980
|
+
Logger.finishStreamingMessage();
|
|
5981
|
+
const evaluation = evaluateResults(test.expectedToolCalls, toolsCalled);
|
|
5982
|
+
const usage = {
|
|
5983
|
+
inputTokens: inputTokensUsed,
|
|
5984
|
+
outputTokens: outputTokensUsed,
|
|
5985
|
+
totalTokens: totalTokensUsed
|
|
5986
|
+
};
|
|
5987
|
+
Logger.toolSummary({
|
|
5988
|
+
expected: evaluation.expectedToolCalls,
|
|
5989
|
+
actual: evaluation.toolsCalled,
|
|
5990
|
+
missing: evaluation.missing,
|
|
5991
|
+
unexpected: evaluation.unexpected,
|
|
5992
|
+
passed: evaluation.passed
|
|
5993
|
+
});
|
|
5994
|
+
Logger.testRunResult({
|
|
5995
|
+
passed: evaluation.passed,
|
|
5996
|
+
durationMs: Date.now() - runStartedAt,
|
|
5997
|
+
usage: usage.inputTokens !== void 0 || usage.outputTokens !== void 0 || usage.totalTokens !== void 0 ? usage : void 0
|
|
5998
|
+
});
|
|
5999
|
+
if (!evaluation.passed) {
|
|
6000
|
+
await markSuiteFailed(persistence);
|
|
6001
|
+
}
|
|
6002
|
+
await updateIterationResult(
|
|
6003
|
+
persistence,
|
|
6004
|
+
evalTestId,
|
|
6005
|
+
evaluation.passed,
|
|
6006
|
+
toolsCalled,
|
|
6007
|
+
usage,
|
|
6008
|
+
messageHistory
|
|
6009
|
+
);
|
|
6010
|
+
return evaluation;
|
|
6011
|
+
};
|
|
6012
|
+
var runTestCase = async ({
|
|
6013
|
+
test,
|
|
6014
|
+
testIndex,
|
|
6015
|
+
llms,
|
|
6016
|
+
tools,
|
|
6017
|
+
persistence
|
|
6018
|
+
}) => {
|
|
6019
|
+
const { runs, model, provider } = test;
|
|
6020
|
+
Logger.logTestGroupTitle(testIndex, test.title, provider, model);
|
|
6021
|
+
let passedRuns = 0;
|
|
6022
|
+
let failedRuns = 0;
|
|
6023
|
+
const testCaseId = await createTestCaseRecord(persistence, test, testIndex);
|
|
6024
|
+
for (let runIndex = 0; runIndex < runs; runIndex++) {
|
|
6025
|
+
const evaluation = await runIteration({
|
|
6026
|
+
test,
|
|
6027
|
+
runIndex,
|
|
6028
|
+
totalRuns: runs,
|
|
6029
|
+
llms,
|
|
6030
|
+
tools,
|
|
6031
|
+
persistence,
|
|
6032
|
+
testCaseId
|
|
6033
|
+
});
|
|
6034
|
+
if (evaluation.passed) {
|
|
6035
|
+
passedRuns++;
|
|
6036
|
+
} else {
|
|
6037
|
+
failedRuns++;
|
|
6464
6038
|
}
|
|
6465
6039
|
}
|
|
6040
|
+
await updateTestCaseResult(persistence, testCaseId, passedRuns, failedRuns);
|
|
6041
|
+
return { passedRuns, failedRuns };
|
|
6042
|
+
};
|
|
6043
|
+
var runEvals = async (tests, environment, llms, apiKey) => {
|
|
6044
|
+
await ensureApiKeyIsValid(apiKey);
|
|
6045
|
+
const { validatedTests, validatedLlms, vercelTools, serverNames } = await prepareSuite(tests, environment, llms);
|
|
6046
|
+
const suiteStartedAt = Date.now();
|
|
6047
|
+
const totalPlannedTests = validatedTests.reduce(
|
|
6048
|
+
(sum, current) => sum + (current?.runs ?? 0),
|
|
6049
|
+
0
|
|
6050
|
+
);
|
|
6051
|
+
const configSummary = {
|
|
6052
|
+
tests: validatedTests,
|
|
6053
|
+
environment: { servers: serverNames },
|
|
6054
|
+
llms: Object.keys(validatedLlms ?? {})
|
|
6055
|
+
};
|
|
6056
|
+
const persistence = createPersistenceContext(
|
|
6057
|
+
apiKey,
|
|
6058
|
+
configSummary,
|
|
6059
|
+
totalPlannedTests
|
|
6060
|
+
);
|
|
6061
|
+
await ensureSuiteRecord(persistence);
|
|
6062
|
+
let passedRuns = 0;
|
|
6063
|
+
let failedRuns = 0;
|
|
6064
|
+
for (let index = 0; index < validatedTests.length; index++) {
|
|
6065
|
+
const test = validatedTests[index];
|
|
6066
|
+
if (!test) {
|
|
6067
|
+
continue;
|
|
6068
|
+
}
|
|
6069
|
+
const { passedRuns: casePassed, failedRuns: caseFailed } = await runTestCase({
|
|
6070
|
+
test,
|
|
6071
|
+
testIndex: index + 1,
|
|
6072
|
+
llms: validatedLlms,
|
|
6073
|
+
tools: vercelTools,
|
|
6074
|
+
persistence
|
|
6075
|
+
});
|
|
6076
|
+
passedRuns += casePassed;
|
|
6077
|
+
failedRuns += caseFailed;
|
|
6078
|
+
}
|
|
6079
|
+
hogClient.capture({
|
|
6080
|
+
distinctId: getUserId(),
|
|
6081
|
+
event: "evals suite complete",
|
|
6082
|
+
properties: {
|
|
6083
|
+
environment: process.env.ENVIRONMENT
|
|
6084
|
+
}
|
|
6085
|
+
});
|
|
6466
6086
|
Logger.suiteComplete({
|
|
6467
6087
|
durationMs: Date.now() - suiteStartedAt,
|
|
6468
6088
|
passed: passedRuns,
|
|
6469
6089
|
failed: failedRuns
|
|
6470
6090
|
});
|
|
6091
|
+
await finalizeSuiteStatus(persistence, failedRuns);
|
|
6471
6092
|
};
|
|
6472
6093
|
|
|
6473
6094
|
// src/evals/index.ts
|
|
6474
6095
|
var evalsCommand = new Command("evals");
|
|
6475
6096
|
evalsCommand.description("Run MCP evaluations").command("run").description("Run tests against MCP servers").requiredOption("-t, --tests <file>", "Path to tests JSON file").requiredOption("-e, --environment <file>", "Path to environment JSON file").requiredOption("-l, --llms <file>", "Path to LLMs JSON file").option("-a, --api-key <key>", "Personal access key").action(async (options) => {
|
|
6476
6097
|
try {
|
|
6098
|
+
hogClient.capture({
|
|
6099
|
+
distinctId: getUserId(),
|
|
6100
|
+
event: "evals cli ran",
|
|
6101
|
+
properties: {
|
|
6102
|
+
environment: process.env.ENVIRONMENT
|
|
6103
|
+
}
|
|
6104
|
+
});
|
|
6477
6105
|
const testsContent = await readFile(resolve(options.tests), "utf8");
|
|
6478
6106
|
const testsData = JSON.parse(testsContent);
|
|
6479
6107
|
const envContent = await readFile(resolve(options.environment), "utf8");
|
|
@@ -6494,7 +6122,7 @@ import updateNotifier from "update-notifier";
|
|
|
6494
6122
|
// package.json
|
|
6495
6123
|
var package_default = {
|
|
6496
6124
|
name: "@mcpjam/cli",
|
|
6497
|
-
version: "1.1.
|
|
6125
|
+
version: "1.1.3",
|
|
6498
6126
|
type: "module",
|
|
6499
6127
|
description: "MCPJam CLI for programmatic MCP testing and evals",
|
|
6500
6128
|
license: "Apache-2.0",
|
|
@@ -6519,15 +6147,15 @@ var package_default = {
|
|
|
6519
6147
|
build: "tsup",
|
|
6520
6148
|
dev: "tsup --watch",
|
|
6521
6149
|
"build-and-test": "npm run build && npm run test",
|
|
6522
|
-
test: "node bin/mcpjam.js evals run -t examples/
|
|
6150
|
+
test: "node bin/mcpjam.js evals run -t local-examples/tests.json -e local-examples/environment.json -l local-examples/llms.json",
|
|
6523
6151
|
start: "node bin/mcpjam.js"
|
|
6524
6152
|
},
|
|
6525
6153
|
dependencies: {
|
|
6526
6154
|
"@ai-sdk/anthropic": "^2.0.17",
|
|
6527
6155
|
"@ai-sdk/openai": "^2.0.32",
|
|
6528
6156
|
"@hono/node-server": "^1.13.7",
|
|
6529
|
-
"@mastra/core": "^0.
|
|
6530
|
-
"@mastra/mcp": "^0.
|
|
6157
|
+
"@mastra/core": "^0.18.0",
|
|
6158
|
+
"@mastra/mcp": "^0.13.1",
|
|
6531
6159
|
"@modelcontextprotocol/sdk": "^1.17.3",
|
|
6532
6160
|
"@openrouter/ai-sdk-provider": "^1.2.0",
|
|
6533
6161
|
ai: "^5.0.11",
|
|
@@ -6536,9 +6164,10 @@ var package_default = {
|
|
|
6536
6164
|
commander: "^12.0.0",
|
|
6537
6165
|
dotenv: "^17.2.2",
|
|
6538
6166
|
hono: "^4.6.11",
|
|
6539
|
-
"ollama-ai-provider": "^1.
|
|
6167
|
+
"ollama-ai-provider-v2": "^1.3.1",
|
|
6168
|
+
"posthog-node": "^5.9.1",
|
|
6540
6169
|
"update-notifier": "^7.3.1",
|
|
6541
|
-
zod: "^
|
|
6170
|
+
zod: "^4.0.16"
|
|
6542
6171
|
},
|
|
6543
6172
|
devDependencies: {
|
|
6544
6173
|
"@types/node": "^20",
|
|
@@ -6553,7 +6182,8 @@ var require3 = createRequire2(import.meta.url);
|
|
|
6553
6182
|
updateNotifier({ pkg: package_default, updateCheckInterval: 0 }).notify();
|
|
6554
6183
|
var { name, version: version2 } = require3("../package.json");
|
|
6555
6184
|
updateNotifier({ pkg: { name, version: version2 } }).notify();
|
|
6556
|
-
|
|
6185
|
+
var envFile = process.env.NODE_ENV === "production" ? ".env.production" : ".env.development";
|
|
6186
|
+
config({ path: envFile });
|
|
6557
6187
|
var program = new Command2();
|
|
6558
6188
|
program.name("mcpjam").description("MCPJam CLI for programmatic MCP testing").version(version2);
|
|
6559
6189
|
program.addCommand(evalsCommand);
|