@skybridge/test 0.0.0-dev.34007b8 → 0.0.0-dev.3423155
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 +105 -8
- package/dist/chat.d.ts +31 -30
- package/dist/chat.d.ts.map +1 -1
- package/dist/chat.js +104 -27
- package/dist/chat.js.map +1 -1
- package/dist/eval-middleware.d.ts +10 -0
- package/dist/eval-middleware.d.ts.map +1 -0
- package/dist/eval-middleware.js +84 -0
- package/dist/eval-middleware.js.map +1 -0
- package/dist/index.d.ts +2 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/input-files.d.ts +12 -0
- package/dist/input-files.d.ts.map +1 -0
- package/dist/input-files.js +109 -0
- package/dist/input-files.js.map +1 -0
- package/dist/matchers/index.d.ts +4 -0
- package/dist/matchers/index.d.ts.map +1 -0
- package/dist/matchers/index.js +2 -0
- package/dist/matchers/index.js.map +1 -0
- package/dist/matchers/matchers.d.ts +54 -0
- package/dist/matchers/matchers.d.ts.map +1 -0
- package/dist/matchers/matchers.js +258 -0
- package/dist/matchers/matchers.js.map +1 -0
- package/dist/matchers/types.d.ts +44 -0
- package/dist/matchers/types.d.ts.map +1 -0
- package/dist/matchers/types.js +2 -0
- package/dist/matchers/types.js.map +1 -0
- package/dist/session-registry.d.ts +66 -9
- package/dist/session-registry.d.ts.map +1 -1
- package/dist/session-registry.js +56 -20
- package/dist/session-registry.js.map +1 -1
- package/dist/tool-stubs.d.ts +4 -0
- package/dist/tool-stubs.d.ts.map +1 -0
- package/dist/tool-stubs.js +38 -0
- package/dist/tool-stubs.js.map +1 -0
- package/package.json +14 -14
- package/dist/config.d.ts +0 -13
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js +0 -2
- package/dist/config.js.map +0 -1
- package/dist/global-setup.d.ts +0 -3
- package/dist/global-setup.d.ts.map +0 -1
- package/dist/global-setup.js +0 -22
- package/dist/global-setup.js.map +0 -1
- package/dist/matchers.d.ts +0 -21
- package/dist/matchers.d.ts.map +0 -1
- package/dist/matchers.js +0 -66
- package/dist/matchers.js.map +0 -1
- package/dist/model.d.ts +0 -9
- package/dist/model.d.ts.map +0 -1
- package/dist/model.js +0 -28
- package/dist/model.js.map +0 -1
- package/dist/plugin.d.ts +0 -10
- package/dist/plugin.d.ts.map +0 -1
- package/dist/plugin.js +0 -32
- package/dist/plugin.js.map +0 -1
- package/dist/server-harness.d.ts +0 -19
- package/dist/server-harness.d.ts.map +0 -1
- package/dist/server-harness.js +0 -78
- package/dist/server-harness.js.map +0 -1
- package/dist/setup.d.ts +0 -2
- package/dist/setup.d.ts.map +0 -1
- package/dist/setup.js +0 -7
- package/dist/setup.js.map +0 -1
package/dist/session-registry.js
CHANGED
|
@@ -1,28 +1,64 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createMcpHandler } from "@modelcontextprotocol/server";
|
|
2
|
+
import { inject, onTestFinished } from "vitest";
|
|
2
3
|
import { Chat } from "./chat.js";
|
|
3
|
-
import {
|
|
4
|
-
|
|
4
|
+
import { EvalMiddleware } from "./eval-middleware.js";
|
|
5
|
+
import { installToolStubs } from "./tool-stubs.js";
|
|
6
|
+
function sharedDefaults() {
|
|
7
|
+
try {
|
|
8
|
+
return inject("skybridgeEvals");
|
|
9
|
+
}
|
|
10
|
+
catch {
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
5
14
|
/**
|
|
6
|
-
* Opens a fresh MCP session and conversation against the
|
|
7
|
-
*
|
|
8
|
-
*
|
|
15
|
+
* Opens a fresh MCP session and conversation against the app under test. The
|
|
16
|
+
* app is served in-process by a handler built on `app.createServerInstance`
|
|
17
|
+
* for this conversation alone, and both are closed when the current test
|
|
18
|
+
* finishes, so scenarios never leak sessions and never write teardown, and
|
|
19
|
+
* tests that run concurrently cannot close each other's sessions.
|
|
20
|
+
*
|
|
21
|
+
* The assertions are inferred from the app value itself, so `expect.chat` gets
|
|
22
|
+
* the project's tool names and argument shapes with no type parameter.
|
|
23
|
+
*
|
|
24
|
+
* `stubs` answers a tool from the scenario instead of the app, so a case that
|
|
25
|
+
* depends on today's date or on a live catalogue still reads the same weeks
|
|
26
|
+
* later. A stubbed call never reaches the tool handler, and still shows up in
|
|
27
|
+
* `chat.toolCalls` like any other. See {@link ToolStubs}.
|
|
9
28
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
29
|
+
* `authInfo` claims an identity for the session: the app's per-tool scheme and
|
|
30
|
+
* scope enforcement runs against it for real, only token verification is
|
|
31
|
+
* skipped. Omit it to exercise the anonymous path, challenges included.
|
|
13
32
|
*/
|
|
14
|
-
export async function start(
|
|
15
|
-
const config =
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
33
|
+
export async function start(options) {
|
|
34
|
+
const config = sharedDefaults();
|
|
35
|
+
const { app, authInfo } = options;
|
|
36
|
+
const middleware = new EvalMiddleware();
|
|
37
|
+
// The app's server and setup types are opaque here; both are forwarded unchanged.
|
|
38
|
+
const evalApp = app.withHandler((server, setupOptions, originalHandler) => {
|
|
39
|
+
middleware.install(server);
|
|
40
|
+
installToolStubs(server, (options.stubs ?? {}));
|
|
41
|
+
return originalHandler(server, setupOptions);
|
|
42
|
+
});
|
|
43
|
+
const handler = createMcpHandler(() => evalApp.createServerInstance());
|
|
44
|
+
let chat;
|
|
45
|
+
try {
|
|
46
|
+
chat = await Chat.open({
|
|
47
|
+
model: options.model,
|
|
48
|
+
temperature: options.temperature ?? config?.temperature,
|
|
49
|
+
systemPrompt: options.systemPrompt ?? config?.systemPrompt,
|
|
50
|
+
maxSteps: options.maxSteps ?? config?.maxSteps,
|
|
51
|
+
}, (url, init) => handler.fetch(new Request(url, init), authInfo === undefined ? undefined : { authInfo }), middleware);
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
await middleware.files.close();
|
|
55
|
+
await handler.close();
|
|
56
|
+
throw error;
|
|
57
|
+
}
|
|
58
|
+
onTestFinished(async () => {
|
|
59
|
+
await chat.close();
|
|
60
|
+
await handler.close();
|
|
21
61
|
});
|
|
22
|
-
opened.push(chat);
|
|
23
62
|
return chat;
|
|
24
63
|
}
|
|
25
|
-
export async function closeOpenedSessions() {
|
|
26
|
-
await Promise.all(opened.splice(0).map((chat) => chat.close()));
|
|
27
|
-
}
|
|
28
64
|
//# sourceMappingURL=session-registry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-registry.js","sourceRoot":"","sources":["../src/session-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"session-registry.js","sourceRoot":"","sources":["../src/session-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAe,MAAM,8BAA8B,CAAC;AAG7E,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,IAAI,EAAgB,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AA6CnD,SAAS,cAAc;IACrB,IAAI,CAAC;QACH,OAAO,MAAM,CAAC,gBAAgB,CAAC,CAAC;IAClC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,KAAK,UAAU,KAAK,CACzB,OAIC;IAED,MAAM,MAAM,GAAG,cAAc,EAAE,CAAC;IAChC,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IAClC,MAAM,UAAU,GAAG,IAAI,cAAc,EAAE,CAAC;IACxC,kFAAkF;IAClF,MAAM,OAAO,GACX,GACD,CAAC,WAAW,CAA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AAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-stubs.d.ts","sourceRoot":"","sources":["../src/tool-stubs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,IAAI,CAAC,SAAS,EAAE,cAAc,GAAG,eAAe,CAAC,EACzD,KAAK,EAAE,OAAO,QA0Cf"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export function installToolStubs(server, stubs) {
|
|
2
|
+
const names = Object.keys(stubs);
|
|
3
|
+
if (names.length === 0) {
|
|
4
|
+
return;
|
|
5
|
+
}
|
|
6
|
+
server.mcpMiddleware("tools/list", async (_request, _extra, next) => {
|
|
7
|
+
const result = await next();
|
|
8
|
+
const unknown = names.filter((name) => !result.tools.some((tool) => tool.name === name));
|
|
9
|
+
if (unknown.length) {
|
|
10
|
+
throw new Error(`the app exposes no tool named ${unknown.map((name) => `"${name}"`).join(", ")}, so the stub would never run`);
|
|
11
|
+
}
|
|
12
|
+
return result;
|
|
13
|
+
});
|
|
14
|
+
const registerTool = server.registerTool.bind(server);
|
|
15
|
+
server.registerTool = ((...args) => {
|
|
16
|
+
const [config, handler] = args;
|
|
17
|
+
const stub = Object.hasOwn(stubs, config.name)
|
|
18
|
+
? stubs[config.name]
|
|
19
|
+
: undefined;
|
|
20
|
+
if (!stub) {
|
|
21
|
+
return registerTool(config, handler);
|
|
22
|
+
}
|
|
23
|
+
return registerTool(config, async (input, extra) => {
|
|
24
|
+
const result = await stub(input);
|
|
25
|
+
return result === undefined
|
|
26
|
+
? handler(input, extra)
|
|
27
|
+
: {
|
|
28
|
+
content: [
|
|
29
|
+
{
|
|
30
|
+
type: "text",
|
|
31
|
+
text: typeof result === "string" ? result : JSON.stringify(result),
|
|
32
|
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C;QAC/B,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC;YAC5C,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC;YACpB,CAAC,CAAC,SAAS,CAAC;QACd,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,OAAO,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACvC,CAAC;QACD,OAAO,YAAY,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;YACjD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,CAAC;YACjC,OAAO,MAAM,KAAK,SAAS;gBACzB,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC;gBACvB,CAAC,CAAC;oBACE,OAAO,EAAE;wBACP;4BACE,IAAI,EAAE,MAAM;4BACZ,IAAI,EACF,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC;yBAC/D;qBACF;iBACF,CAAC;QACR,CAAC,CAAC,CAAC;IACL,CAAC,CAA+B,CAAC;AACnC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skybridge/test",
|
|
3
|
-
"version": "0.0.0-dev.
|
|
4
|
-
"description": "Eval runner for Skybridge MCP
|
|
3
|
+
"version": "0.0.0-dev.3423155",
|
|
4
|
+
"description": "Eval runner for Skybridge MCP Apps: does a prompt reach the right tool with the right arguments",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"repository": {
|
|
@@ -13,36 +13,36 @@
|
|
|
13
13
|
"types": "./dist/index.d.ts",
|
|
14
14
|
"default": "./dist/index.js"
|
|
15
15
|
},
|
|
16
|
-
"./
|
|
17
|
-
"types": "./dist/
|
|
18
|
-
"default": "./dist/
|
|
16
|
+
"./matchers": {
|
|
17
|
+
"types": "./dist/matchers/index.d.ts",
|
|
18
|
+
"default": "./dist/matchers/index.js"
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
21
|
"files": [
|
|
22
22
|
"dist"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@
|
|
26
|
-
"@modelcontextprotocol/
|
|
27
|
-
"ai": "^5.0.0",
|
|
28
|
-
"@skybridge/vite-plugin": "0.0.0-dev.34007b8"
|
|
25
|
+
"@modelcontextprotocol/client": "^2.0.0",
|
|
26
|
+
"@modelcontextprotocol/server": "^2.0.0"
|
|
29
27
|
},
|
|
30
28
|
"peerDependencies": {
|
|
31
|
-
"skybridge": "^
|
|
29
|
+
"@skybridge/vite-plugin": "^2.0.0",
|
|
30
|
+
"ai": "^7.0.0",
|
|
31
|
+
"skybridge": "^2.0.0",
|
|
32
32
|
"vitest": "^4.1.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@types/node": "^24.13.3",
|
|
36
|
+
"ai": "^7.0.0",
|
|
36
37
|
"typescript": "^5.9.3",
|
|
37
38
|
"vitest": "^4.1.10",
|
|
38
|
-
"
|
|
39
|
+
"zod": "^4.4.3",
|
|
40
|
+
"skybridge": "0.0.0-dev.3423155",
|
|
41
|
+
"@skybridge/vite-plugin": "0.0.0-dev.3423155"
|
|
39
42
|
},
|
|
40
43
|
"engines": {
|
|
41
44
|
"node": ">=22.23.1"
|
|
42
45
|
},
|
|
43
|
-
"publishConfig": {
|
|
44
|
-
"tag": "beta"
|
|
45
|
-
},
|
|
46
46
|
"scripts": {
|
|
47
47
|
"build": "tsc -p tsconfig.json",
|
|
48
48
|
"format": "biome check --write --error-on-warnings",
|
package/dist/config.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { EvalsOptions, ModelDescriptor } from "@skybridge/vite-plugin";
|
|
2
|
-
export type { EvalsOptions, ModelDescriptor, ModelFile, } from "@skybridge/vite-plugin";
|
|
3
|
-
/** The serializable half, the only part that crosses into the workers. */
|
|
4
|
-
export type ProvidedEvalsOptions = Omit<EvalsOptions, "model"> & {
|
|
5
|
-
model?: ModelDescriptor;
|
|
6
|
-
};
|
|
7
|
-
declare module "vitest" {
|
|
8
|
-
interface ProvidedContext {
|
|
9
|
-
skybridgeEvals: ProvidedEvalsOptions;
|
|
10
|
-
skybridgeEvalsUrl: string;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=config.d.ts.map
|
package/dist/config.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE5E,YAAY,EACV,YAAY,EACZ,eAAe,EACf,SAAS,GACV,MAAM,wBAAwB,CAAC;AAEhC,0EAA0E;AAC1E,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC,YAAY,EAAE,OAAO,CAAC,GAAG;IAC/D,KAAK,CAAC,EAAE,eAAe,CAAC;CACzB,CAAC;AAEF,OAAO,QAAQ,QAAQ,CAAC;IACtB,UAAU,eAAe;QACvB,cAAc,EAAE,oBAAoB,CAAC;QACrC,iBAAiB,EAAE,MAAM,CAAC;KAC3B;CACF"}
|
package/dist/config.js
DELETED
package/dist/config.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":""}
|
package/dist/global-setup.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"global-setup.d.ts","sourceRoot":"","sources":["../src/global-setup.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAI/C,wBAA8B,KAAK,CAAC,OAAO,EAAE,WAAW,8CAsBvD"}
|
package/dist/global-setup.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { startServer } from "./server-harness.js";
|
|
2
|
-
export default async function setup(project) {
|
|
3
|
-
const options = project.config.provide
|
|
4
|
-
?.skybridgeEvals;
|
|
5
|
-
if (options.server !== undefined) {
|
|
6
|
-
project.provide("skybridgeEvalsUrl", options.server);
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
9
|
-
if (options.project === undefined) {
|
|
10
|
-
throw new Error("The evals plugin needs either `server` or `project`");
|
|
11
|
-
}
|
|
12
|
-
const server = await startServer(options.project);
|
|
13
|
-
project.provide("skybridgeEvalsUrl", server.url);
|
|
14
|
-
return async () => {
|
|
15
|
-
const output = server.output().trim();
|
|
16
|
-
await server.stop();
|
|
17
|
-
if (output !== "") {
|
|
18
|
-
console.log(`\n--- server output ---\n${output}\n---`);
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=global-setup.js.map
|
package/dist/global-setup.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"global-setup.js","sourceRoot":"","sources":["../src/global-setup.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,KAAK,CAAC,OAAoB;IACtD,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO;QACpC,EAAE,cAAsC,CAAC;IAE3C,IAAI,OAAO,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QACjC,OAAO,CAAC,OAAO,CAAC,mBAAmB,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;QACrD,OAAO;IACT,CAAC;IACD,IAAI,OAAO,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;QAClC,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;IACzE,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAClD,OAAO,CAAC,OAAO,CAAC,mBAAmB,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;IAEjD,OAAO,KAAK,IAAI,EAAE;QAChB,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC;QACtC,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;QACpB,IAAI,MAAM,KAAK,EAAE,EAAE,CAAC;YAClB,OAAO,CAAC,GAAG,CAAC,4BAA4B,MAAM,OAAO,CAAC,CAAC;QACzD,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/matchers.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { ToolInput, ToolNames } from "skybridge/server";
|
|
2
|
-
import type { Chat } from "./chat.js";
|
|
3
|
-
/**
|
|
4
|
-
* Assertions about the tool calls a conversation produced. Kept off vitest's
|
|
5
|
-
* global `Matchers` so they never appear on unrelated `expect()` calls, and so
|
|
6
|
-
* this stays the one place later tool-call helpers are added.
|
|
7
|
-
*/
|
|
8
|
-
export interface ChatMatchers<App> {
|
|
9
|
-
toHaveCalledToolOnce<Name extends ToolNames<App>>(name: Name, args?: Partial<ToolInput<App, Name>>): void;
|
|
10
|
-
toHaveCalledToolWith<Name extends ToolNames<App>>(name: Name, args: Partial<ToolInput<App, Name>>): void;
|
|
11
|
-
toNeverHaveCalledTool<Name extends ToolNames<App>>(name: Name): void;
|
|
12
|
-
}
|
|
13
|
-
export interface ChatAssertion<App> extends ChatMatchers<App> {
|
|
14
|
-
not: ChatMatchers<App>;
|
|
15
|
-
}
|
|
16
|
-
declare module "vitest" {
|
|
17
|
-
interface ExpectStatic {
|
|
18
|
-
chat<App>(chat: Chat<App>): ChatAssertion<App>;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
//# sourceMappingURL=matchers.d.ts.map
|
package/dist/matchers.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"matchers.d.ts","sourceRoot":"","sources":["../src/matchers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7D,OAAO,KAAK,EAAE,IAAI,EAAY,MAAM,WAAW,CAAC;AAEhD;;;;GAIG;AACH,MAAM,WAAW,YAAY,CAAC,GAAG;IAC/B,oBAAoB,CAAC,IAAI,SAAS,SAAS,CAAC,GAAG,CAAC,EAC9C,IAAI,EAAE,IAAI,EACV,IAAI,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,GACnC,IAAI,CAAC;IACR,oBAAoB,CAAC,IAAI,SAAS,SAAS,CAAC,GAAG,CAAC,EAC9C,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,OAAO,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,GAClC,IAAI,CAAC;IACR,qBAAqB,CAAC,IAAI,SAAS,SAAS,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;CACtE;AAED,MAAM,WAAW,aAAa,CAAC,GAAG,CAAE,SAAQ,YAAY,CAAC,GAAG,CAAC;IAC3D,GAAG,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC;CACxB;AAED,OAAO,QAAQ,QAAQ,CAAC;IACtB,UAAU,YAAY;QACpB,IAAI,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC;KAChD;CACF"}
|
package/dist/matchers.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { expect } from "vitest";
|
|
2
|
-
function attemptedCalls(chat, name) {
|
|
3
|
-
return chat.toolCalls.filter((call) => String(call.name) === name);
|
|
4
|
-
}
|
|
5
|
-
function acceptedCalls(chat, name) {
|
|
6
|
-
return attemptedCalls(chat, name).filter((call) => call.invalid !== true);
|
|
7
|
-
}
|
|
8
|
-
function observed(chat) {
|
|
9
|
-
if (chat.toolCalls.length === 0) {
|
|
10
|
-
return " (no tool was called)";
|
|
11
|
-
}
|
|
12
|
-
return chat.toolCalls
|
|
13
|
-
.map((call, index) => ` ${index + 1}. ${String(call.name)} ${JSON.stringify(call.arguments)}${call.invalid === true ? " (arguments rejected by the tool schema)" : ""}`)
|
|
14
|
-
.join("\n");
|
|
15
|
-
}
|
|
16
|
-
function definitions(chat) {
|
|
17
|
-
return chat.toolDefinitions
|
|
18
|
-
.map((tool) => ` - ${tool.name}: ${tool.description ?? ""}\n arguments: ${JSON.stringify(tool.inputSchema)}`)
|
|
19
|
-
.join("\n");
|
|
20
|
-
}
|
|
21
|
-
function report(chat, summary) {
|
|
22
|
-
return `${summary}
|
|
23
|
-
|
|
24
|
-
Calls the model actually made:
|
|
25
|
-
${observed(chat)}
|
|
26
|
-
|
|
27
|
-
Tool definitions the model was looking at:
|
|
28
|
-
${definitions(chat)}`;
|
|
29
|
-
}
|
|
30
|
-
expect.extend({
|
|
31
|
-
toHaveCalledToolOnce(received, name, args) {
|
|
32
|
-
const matching = acceptedCalls(received, name);
|
|
33
|
-
const argsMatch = args === undefined ||
|
|
34
|
-
(matching.length === 1 &&
|
|
35
|
-
this.equals(matching[0]?.arguments, expect.objectContaining(args)));
|
|
36
|
-
const pass = matching.length === 1 && argsMatch;
|
|
37
|
-
return {
|
|
38
|
-
pass,
|
|
39
|
-
message: () => report(received, pass
|
|
40
|
-
? `Expected "${name}" not to be called exactly once.`
|
|
41
|
-
: matching.length === 1
|
|
42
|
-
? `Expected "${name}" to be called once with ${JSON.stringify(args)}, but it was called with ${JSON.stringify(matching[0]?.arguments)}.`
|
|
43
|
-
: `Expected "${name}" to be called exactly once by a call the tool schema accepted, but ${matching.length} such calls were made.`),
|
|
44
|
-
};
|
|
45
|
-
},
|
|
46
|
-
toHaveCalledToolWith(received, name, args) {
|
|
47
|
-
const pass = acceptedCalls(received, name).some((call) => this.equals(call.arguments, expect.objectContaining(args)));
|
|
48
|
-
return {
|
|
49
|
-
pass,
|
|
50
|
-
message: () => report(received, pass
|
|
51
|
-
? `Expected no call to "${name}" with ${JSON.stringify(args)}.`
|
|
52
|
-
: `Expected "${name}" to be called with ${JSON.stringify(args)}.`),
|
|
53
|
-
};
|
|
54
|
-
},
|
|
55
|
-
toNeverHaveCalledTool(received, name) {
|
|
56
|
-
const matching = attemptedCalls(received, name);
|
|
57
|
-
return {
|
|
58
|
-
pass: matching.length === 0,
|
|
59
|
-
message: () => report(received, matching.length === 0
|
|
60
|
-
? `Expected "${name}" to be called at least once.`
|
|
61
|
-
: `Expected "${name}" never to be called, but it was called ${matching.length} times.`),
|
|
62
|
-
};
|
|
63
|
-
},
|
|
64
|
-
});
|
|
65
|
-
expect.chat = ((chat) => expect(chat));
|
|
66
|
-
//# sourceMappingURL=matchers.js.map
|
package/dist/matchers.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"matchers.js","sourceRoot":"","sources":["../src/matchers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AA8BhC,SAAS,cAAc,CACrB,IAAmB,EACnB,IAAY;IAEZ,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC;AACrE,CAAC;AAED,SAAS,aAAa,CAAC,IAAmB,EAAE,IAAY;IACtD,OAAO,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,KAAK,IAAI,CAAC,CAAC;AAC5E,CAAC;AAED,SAAS,QAAQ,CAAC,IAAmB;IACnC,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAChC,OAAO,w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,QAAQ,EACR,QAAQ,CAAC,MAAM,KAAK,CAAC;gBACnB,CAAC,CAAC,aAAa,IAAI,+BAA+B;gBAClD,CAAC,CAAC,aAAa,IAAI,2CAA2C,QAAQ,CAAC,MAAM,SAAS,CACzF;SACJ,CAAC;IACJ,CAAC;CACF,CAAC,CAAC;AAEH,MAAM,CAAC,IAAI,GAAG,CAAC,CAAM,IAAe,EAAE,EAAE,CACtC,MAAM,CAAC,IAAI,CAAC,CAAkC,CAAC"}
|
package/dist/model.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { LanguageModel } from "ai";
|
|
2
|
-
import type { ModelDescriptor } from "./config.js";
|
|
3
|
-
/**
|
|
4
|
-
* Registers a model instance from a setup file. The escape hatch for providers
|
|
5
|
-
* the descriptor cannot construct, such as a company LLM gateway.
|
|
6
|
-
*/
|
|
7
|
-
export declare function defineEvalModel(model: LanguageModel): void;
|
|
8
|
-
export declare function resolveModel(descriptor: ModelDescriptor | undefined): Promise<LanguageModel>;
|
|
9
|
-
//# sourceMappingURL=model.d.ts.map
|
package/dist/model.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AACxC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAInD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAE1D;AAaD,wBAAsB,YAAY,CAChC,UAAU,EAAE,eAAe,GAAG,SAAS,GACtC,OAAO,CAAC,aAAa,CAAC,CAWxB"}
|
package/dist/model.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
let registered;
|
|
2
|
-
/**
|
|
3
|
-
* Registers a model instance from a setup file. The escape hatch for providers
|
|
4
|
-
* the descriptor cannot construct, such as a company LLM gateway.
|
|
5
|
-
*/
|
|
6
|
-
export function defineEvalModel(model) {
|
|
7
|
-
registered = model;
|
|
8
|
-
}
|
|
9
|
-
const DEFAULT_KEY_ENV = { anthropic: "ANTHROPIC_API_KEY" };
|
|
10
|
-
function requireKey(descriptor) {
|
|
11
|
-
const name = descriptor.apiKeyEnv ?? DEFAULT_KEY_ENV[descriptor.provider];
|
|
12
|
-
const key = process.env[name];
|
|
13
|
-
if (key === undefined || key === "") {
|
|
14
|
-
throw new Error(`${name} is not set`);
|
|
15
|
-
}
|
|
16
|
-
return key;
|
|
17
|
-
}
|
|
18
|
-
export async function resolveModel(descriptor) {
|
|
19
|
-
if (registered !== undefined) {
|
|
20
|
-
return registered;
|
|
21
|
-
}
|
|
22
|
-
if (descriptor === undefined) {
|
|
23
|
-
throw new Error("No model configured. Pass `model` to the evals plugin, or call defineEvalModel() from a setup file.");
|
|
24
|
-
}
|
|
25
|
-
const { createAnthropic } = await import("@ai-sdk/anthropic");
|
|
26
|
-
return createAnthropic({ apiKey: requireKey(descriptor) })(descriptor.name);
|
|
27
|
-
}
|
|
28
|
-
//# sourceMappingURL=model.js.map
|
package/dist/model.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"model.js","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAGA,IAAI,UAAqC,CAAC;AAE1C;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,KAAoB;IAClD,UAAU,GAAG,KAAK,CAAC;AACrB,CAAC;AAED,MAAM,eAAe,GAAG,EAAE,SAAS,EAAE,mBAAmB,EAAW,CAAC;AAEpE,SAAS,UAAU,CAAC,UAA2B;IAC7C,MAAM,IAAI,GAAG,UAAU,CAAC,SAAS,IAAI,eAAe,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;IAC1E,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC9B,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,EAAE,EAAE,CAAC;QACpC,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,aAAa,CAAC,CAAC;IACxC,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,UAAuC;IAEvC,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAC7B,OAAO,UAAU,CAAC;IACpB,CAAC;IACD,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CACb,qGAAqG,CACtG,CAAC;IACJ,CAAC;IACD,MAAM,EAAE,eAAe,EAAE,GAAG,MAAM,MAAM,CAAC,mBAAmB,CAAC,CAAC;IAC9D,OAAO,eAAe,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;AAC9E,CAAC"}
|
package/dist/plugin.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { Plugin } from "vitest/config";
|
|
2
|
-
import type { EvalsOptions } from "./config.js";
|
|
3
|
-
/**
|
|
4
|
-
* Wires the eval runner into vitest. Usually reached through the `evals`
|
|
5
|
-
* option of the `skybridge()` Vite plugin rather than registered directly.
|
|
6
|
-
* Everything the runner needs is configured here, so a scenario file imports
|
|
7
|
-
* nothing but `start` and its own `AppType`.
|
|
8
|
-
*/
|
|
9
|
-
export declare function evals(options: EvalsOptions): Plugin;
|
|
10
|
-
//# sourceMappingURL=plugin.d.ts.map
|
package/dist/plugin.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,KAAK,EAAE,YAAY,EAAwB,MAAM,aAAa,CAAC;AAMtE;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,OAAO,EAAE,YAAY,GAAG,MAAM,CAuBnD"}
|
package/dist/plugin.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { fileURLToPath } from "node:url";
|
|
2
|
-
function here(file) {
|
|
3
|
-
return fileURLToPath(new URL(file, import.meta.url));
|
|
4
|
-
}
|
|
5
|
-
/**
|
|
6
|
-
* Wires the eval runner into vitest. Usually reached through the `evals`
|
|
7
|
-
* option of the `skybridge()` Vite plugin rather than registered directly.
|
|
8
|
-
* Everything the runner needs is configured here, so a scenario file imports
|
|
9
|
-
* nothing but `start` and its own `AppType`.
|
|
10
|
-
*/
|
|
11
|
-
export function evals(options) {
|
|
12
|
-
const { model, ...rest } = options;
|
|
13
|
-
const provided = "file" in model ? rest : { ...rest, model };
|
|
14
|
-
const setupFiles = [here("./setup.js")];
|
|
15
|
-
if ("file" in model) {
|
|
16
|
-
setupFiles.push(model.file);
|
|
17
|
-
}
|
|
18
|
-
return {
|
|
19
|
-
name: "skybridge-evals",
|
|
20
|
-
config() {
|
|
21
|
-
return {
|
|
22
|
-
test: {
|
|
23
|
-
testTimeout: 120_000,
|
|
24
|
-
setupFiles,
|
|
25
|
-
globalSetup: [here("./global-setup.js")],
|
|
26
|
-
provide: { skybridgeEvals: provided },
|
|
27
|
-
},
|
|
28
|
-
};
|
|
29
|
-
},
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
//# sourceMappingURL=plugin.js.map
|
package/dist/plugin.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAIzC,SAAS,IAAI,CAAC,IAAY;IACxB,OAAO,aAAa,CAAC,IAAI,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AACvD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,KAAK,CAAC,OAAqB;IACzC,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;IACnC,MAAM,QAAQ,GACZ,MAAM,IAAI,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,KAAK,EAAE,CAAC;IAE9C,MAAM,UAAU,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;IACxC,IAAI,MAAM,IAAI,KAAK,EAAE,CAAC;QACpB,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;IAED,OAAO;QACL,IAAI,EAAE,iBAAiB;QACvB,MAAM;YACJ,OAAO;gBACL,IAAI,EAAE;oBACJ,WAAW,EAAE,OAAO;oBACpB,UAAU;oBACV,WAAW,EAAE,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;oBACxC,OAAO,EAAE,EAAE,cAAc,EAAE,QAAQ,EAAE;iBACtC;aACF,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/server-harness.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export interface RunningServer {
|
|
2
|
-
url: string;
|
|
3
|
-
/** Everything the server wrote to stdout/stderr, for failure reports. */
|
|
4
|
-
output: () => string;
|
|
5
|
-
stop: () => Promise<void>;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Spawns the project's server with `__PORT=0` and an IPC channel, and waits
|
|
9
|
-
* for the `skybridge:listening` message carrying the port the OS picked.
|
|
10
|
-
* Binding and reporting both happen in the child, so there is no window in
|
|
11
|
-
* which another process can steal the port.
|
|
12
|
-
*/
|
|
13
|
-
export declare function startServer({ cwd, command, env, timeoutMs, }: {
|
|
14
|
-
cwd: string;
|
|
15
|
-
command: string[];
|
|
16
|
-
env?: Record<string, string>;
|
|
17
|
-
timeoutMs?: number;
|
|
18
|
-
}): Promise<RunningServer>;
|
|
19
|
-
//# sourceMappingURL=server-harness.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"server-harness.d.ts","sourceRoot":"","sources":["../src/server-harness.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,yEAAyE;IACzE,MAAM,EAAE,MAAM,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3B;AAiBD;;;;;GAKG;AACH,wBAAsB,WAAW,CAAC,EAChC,GAAG,EACH,OAAO,EACP,GAAQ,EACR,SAAkB,GACnB,EAAE;IACD,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,OAAO,CAAC,aAAa,CAAC,CA2EzB"}
|
package/dist/server-harness.js
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { spawn } from "node:child_process";
|
|
2
|
-
import { resolve } from "node:path";
|
|
3
|
-
function hasExited(child) {
|
|
4
|
-
return child.exitCode !== null || child.signalCode !== null;
|
|
5
|
-
}
|
|
6
|
-
function isListeningMessage(message) {
|
|
7
|
-
return (typeof message === "object" &&
|
|
8
|
-
message !== null &&
|
|
9
|
-
message.type === "skybridge:listening" &&
|
|
10
|
-
typeof message.port === "number");
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Spawns the project's server with `__PORT=0` and an IPC channel, and waits
|
|
14
|
-
* for the `skybridge:listening` message carrying the port the OS picked.
|
|
15
|
-
* Binding and reporting both happen in the child, so there is no window in
|
|
16
|
-
* which another process can steal the port.
|
|
17
|
-
*/
|
|
18
|
-
export async function startServer({ cwd, command, env = {}, timeoutMs = 60_000, }) {
|
|
19
|
-
const [bin, ...args] = command;
|
|
20
|
-
if (bin === undefined) {
|
|
21
|
-
throw new Error("Empty server command");
|
|
22
|
-
}
|
|
23
|
-
const executable = bin.startsWith(".") ? resolve(cwd, bin) : bin;
|
|
24
|
-
const child = spawn(executable, args, {
|
|
25
|
-
cwd,
|
|
26
|
-
env: {
|
|
27
|
-
...process.env,
|
|
28
|
-
NODE_ENV: "production",
|
|
29
|
-
...env,
|
|
30
|
-
__PORT: "0",
|
|
31
|
-
},
|
|
32
|
-
stdio: ["ignore", "pipe", "pipe", "ipc"],
|
|
33
|
-
});
|
|
34
|
-
let captured = "";
|
|
35
|
-
const output = () => captured;
|
|
36
|
-
child.stdout?.on("data", (chunk) => {
|
|
37
|
-
captured += chunk;
|
|
38
|
-
});
|
|
39
|
-
child.stderr?.on("data", (chunk) => {
|
|
40
|
-
captured += chunk;
|
|
41
|
-
});
|
|
42
|
-
const stop = async () => {
|
|
43
|
-
if (hasExited(child)) {
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
const exited = new Promise((resolveExit) => {
|
|
47
|
-
child.once("exit", () => resolveExit());
|
|
48
|
-
});
|
|
49
|
-
child.kill("SIGTERM");
|
|
50
|
-
const forced = setTimeout(() => child.kill("SIGKILL"), 3_000);
|
|
51
|
-
await exited;
|
|
52
|
-
clearTimeout(forced);
|
|
53
|
-
};
|
|
54
|
-
const port = await new Promise((resolvePort, reject) => {
|
|
55
|
-
const timer = setTimeout(() => {
|
|
56
|
-
reject(new Error(`Server did not report its port in ${timeoutMs}ms. It must call \`server.run()\` on a skybridge version that sends the skybridge:listening readiness message.\n${output()}`));
|
|
57
|
-
}, timeoutMs);
|
|
58
|
-
child.on("message", (message) => {
|
|
59
|
-
if (isListeningMessage(message)) {
|
|
60
|
-
clearTimeout(timer);
|
|
61
|
-
resolvePort(message.port);
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
child.on("error", (error) => {
|
|
65
|
-
clearTimeout(timer);
|
|
66
|
-
reject(new Error(`Failed to spawn ${command.join(" ")}: ${error.message}`));
|
|
67
|
-
});
|
|
68
|
-
child.on("exit", () => {
|
|
69
|
-
clearTimeout(timer);
|
|
70
|
-
reject(new Error(`Server exited with code ${child.exitCode} before reporting its port:\n${output()}`));
|
|
71
|
-
});
|
|
72
|
-
}).catch(async (error) => {
|
|
73
|
-
await stop();
|
|
74
|
-
throw error;
|
|
75
|
-
});
|
|
76
|
-
return { url: `http://127.0.0.1:${port}/mcp`, output, stop };
|
|
77
|
-
}
|
|
78
|
-
//# sourceMappingURL=server-harness.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"server-harness.js","sourceRoot":"","sources":["../src/server-harness.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AASpC,SAAS,SAAS,CAAC,KAAmB;IACpC,OAAO,KAAK,CAAC,QAAQ,KAAK,IAAI,IAAI,KAAK,CAAC,UAAU,KAAK,IAAI,CAAC;AAC9D,CAAC;AAED,SAAS,kBAAkB,CACzB,OAAgB;IAEhB,OAAO,CACL,OAAO,OAAO,KAAK,QAAQ;QAC3B,OAAO,KAAK,IAAI;QACf,OAA8B,CAAC,IAAI,KAAK,qBAAqB;QAC9D,OAAQ,OAA8B,CAAC,IAAI,KAAK,QAAQ,CACzD,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,EAChC,GAAG,EACH,OAAO,EACP,GAAG,GAAG,EAAE,EACR,SAAS,GAAG,MAAM,GAMnB;IACC,MAAM,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,OAAO,CAAC;IAC/B,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;IAC1C,CAAC;IAED,MAAM,UAAU,GAAG,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,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setup.d.ts
DELETED
package/dist/setup.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":"AACA,OAAO,eAAe,CAAC"}
|
package/dist/setup.js
DELETED
package/dist/setup.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,eAAe,CAAC;AACvB,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,SAAS,CAAC,KAAK,IAAI,EAAE;IACnB,MAAM,mBAAmB,EAAE,CAAC;AAC9B,CAAC,CAAC,CAAC"}
|