@skybridge/test 2.0.0-alpha.deed804 → 2.0.0-beta.0459c30
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
CHANGED
|
@@ -6,7 +6,7 @@ check.
|
|
|
6
6
|
|
|
7
7
|
Add the `evals` option to the Skybridge Vite plugin so `expect.chat` exists,
|
|
8
8
|
then write scenarios with vitest's own `it` and `expect`. Pass the app itself
|
|
9
|
-
to `start`: it is served in-process, dialing `app.
|
|
9
|
+
to `start`: it is served in-process, dialing an in-process handler built on `app.createServerInstance()`, and
|
|
10
10
|
the tool names and argument shapes come from the app value, so no type
|
|
11
11
|
parameter is needed.
|
|
12
12
|
|
|
@@ -1,20 +1,17 @@
|
|
|
1
|
+
import { type Server } from "@modelcontextprotocol/server";
|
|
1
2
|
import type { LanguageModel } from "ai";
|
|
2
3
|
import { Chat } from "./chat.js";
|
|
3
4
|
/**
|
|
4
5
|
* The minimum a Skybridge app has to expose to be served in-process: the
|
|
5
|
-
* `$types` marker the assertions infer tool names from, and the
|
|
6
|
-
* the session is
|
|
7
|
-
* no runtime dependency on `skybridge`.
|
|
6
|
+
* `$types` marker the assertions infer tool names from, and the per-request
|
|
7
|
+
* server builder the session's handler is built on. Structural on purpose, so
|
|
8
|
+
* this package needs no runtime dependency on `skybridge`.
|
|
8
9
|
*/
|
|
9
10
|
export interface EvalApp {
|
|
10
11
|
readonly $types: {
|
|
11
12
|
readonly tools: object;
|
|
12
13
|
};
|
|
13
|
-
|
|
14
|
-
fetch: (request: Request, options?: {
|
|
15
|
-
authInfo?: EvalIdentity;
|
|
16
|
-
}) => Promise<Response>;
|
|
17
|
-
};
|
|
14
|
+
createServerInstance(): Promise<Server>;
|
|
18
15
|
}
|
|
19
16
|
/**
|
|
20
17
|
* The identity an in-process session claims, handed to the app as the
|
|
@@ -38,14 +35,13 @@ interface StartOptions {
|
|
|
38
35
|
}
|
|
39
36
|
/**
|
|
40
37
|
* Opens a fresh MCP session and conversation against the app under test. The
|
|
41
|
-
* app is served in-process
|
|
38
|
+
* app is served in-process by a handler built on `app.createServerInstance`
|
|
39
|
+
* for this conversation alone, and both are closed when the current test
|
|
42
40
|
* finishes, so scenarios never leak sessions and never write teardown, and
|
|
43
41
|
* tests that run concurrently cannot close each other's sessions.
|
|
44
42
|
*
|
|
45
43
|
* The assertions are inferred from the app value itself, so `expect.chat` gets
|
|
46
|
-
* the project's tool names and argument shapes with no type parameter.
|
|
47
|
-
* session talks straight to `app.fetchHandler`, which never closes: the
|
|
48
|
-
* handler is memoized on the app and shared by every test.
|
|
44
|
+
* the project's tool names and argument shapes with no type parameter.
|
|
49
45
|
*
|
|
50
46
|
* `authInfo` claims an identity for the session: the app's per-tool scheme and
|
|
51
47
|
* scope enforcement runs against it for real, only token verification is
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-registry.d.ts","sourceRoot":"","sources":["../src/session-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AAExC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC;;;;;GAKG;AACH,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,MAAM,EAAE;QAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAC5C,
|
|
1
|
+
{"version":3,"file":"session-registry.d.ts","sourceRoot":"","sources":["../src/session-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAC7E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AAExC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC;;;;;GAKG;AACH,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,MAAM,EAAE;QAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAC5C,oBAAoB,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;CACzC;AAED;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AAED,UAAU,YAAY;IACpB,uDAAuD;IACvD,KAAK,EAAE,aAAa,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAUD;;;;;;;;;;;;;GAaG;AACH,wBAAsB,KAAK,CAAC,GAAG,SAAS,OAAO,EAC7C,OAAO,EAAE,YAAY,GAAG;IAAE,GAAG,EAAE,GAAG,CAAC;IAAC,QAAQ,CAAC,EAAE,YAAY,CAAA;CAAE,GAC5D,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAwBpB"}
|
package/dist/session-registry.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createMcpHandler } from "@modelcontextprotocol/server";
|
|
1
2
|
import { inject, onTestFinished } from "vitest";
|
|
2
3
|
import { Chat } from "./chat.js";
|
|
3
4
|
function sharedDefaults() {
|
|
@@ -10,14 +11,13 @@ function sharedDefaults() {
|
|
|
10
11
|
}
|
|
11
12
|
/**
|
|
12
13
|
* Opens a fresh MCP session and conversation against the app under test. The
|
|
13
|
-
* app is served in-process
|
|
14
|
+
* app is served in-process by a handler built on `app.createServerInstance`
|
|
15
|
+
* for this conversation alone, and both are closed when the current test
|
|
14
16
|
* finishes, so scenarios never leak sessions and never write teardown, and
|
|
15
17
|
* tests that run concurrently cannot close each other's sessions.
|
|
16
18
|
*
|
|
17
19
|
* The assertions are inferred from the app value itself, so `expect.chat` gets
|
|
18
|
-
* the project's tool names and argument shapes with no type parameter.
|
|
19
|
-
* session talks straight to `app.fetchHandler`, which never closes: the
|
|
20
|
-
* handler is memoized on the app and shared by every test.
|
|
20
|
+
* the project's tool names and argument shapes with no type parameter.
|
|
21
21
|
*
|
|
22
22
|
* `authInfo` claims an identity for the session: the app's per-tool scheme and
|
|
23
23
|
* scope enforcement runs against it for real, only token verification is
|
|
@@ -26,13 +26,17 @@ function sharedDefaults() {
|
|
|
26
26
|
export async function start(options) {
|
|
27
27
|
const config = sharedDefaults();
|
|
28
28
|
const { app, authInfo } = options;
|
|
29
|
+
const handler = createMcpHandler(() => app.createServerInstance());
|
|
29
30
|
const chat = await Chat.open({
|
|
30
31
|
model: options.model,
|
|
31
32
|
temperature: options.temperature ?? config?.temperature,
|
|
32
33
|
systemPrompt: options.systemPrompt ?? config?.systemPrompt,
|
|
33
34
|
maxSteps: options.maxSteps ?? config?.maxSteps,
|
|
34
|
-
}, (url, init) =>
|
|
35
|
-
onTestFinished(() =>
|
|
35
|
+
}, (url, init) => handler.fetch(new Request(url, init), authInfo === undefined ? undefined : { authInfo }));
|
|
36
|
+
onTestFinished(async () => {
|
|
37
|
+
await chat.close();
|
|
38
|
+
await handler.close();
|
|
39
|
+
});
|
|
36
40
|
return chat;
|
|
37
41
|
}
|
|
38
42
|
//# sourceMappingURL=session-registry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-registry.js","sourceRoot":"","sources":["../src/session-registry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"session-registry.js","sourceRoot":"","sources":["../src/session-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAe,MAAM,8BAA8B,CAAC;AAE7E,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAmCjC,SAAS,cAAc;IACrB,IA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
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",
|
|
@@ -19,11 +19,12 @@
|
|
|
19
19
|
],
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@modelcontextprotocol/client": "^2.0.0",
|
|
22
|
-
"@
|
|
22
|
+
"@modelcontextprotocol/server": "^2.0.0"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
|
+
"@skybridge/vite-plugin": "^2.0.0-beta.0",
|
|
25
26
|
"ai": "^5.0.0",
|
|
26
|
-
"skybridge": "^2.0.0",
|
|
27
|
+
"skybridge": "^2.0.0-beta.0",
|
|
27
28
|
"vitest": "^4.1.0"
|
|
28
29
|
},
|
|
29
30
|
"devDependencies": {
|
|
@@ -32,7 +33,8 @@
|
|
|
32
33
|
"typescript": "^5.9.3",
|
|
33
34
|
"vitest": "^4.1.10",
|
|
34
35
|
"zod": "^4.4.3",
|
|
35
|
-
"skybridge": "2.0.0-
|
|
36
|
+
"@skybridge/vite-plugin": "2.0.0-beta.0459c30",
|
|
37
|
+
"skybridge": "2.0.0-beta.0459c30"
|
|
36
38
|
},
|
|
37
39
|
"engines": {
|
|
38
40
|
"node": ">=22.23.1"
|