@skybridge/test 2.0.0-beta.68a71cb → 2.0.0-beta.dd3cba3
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
|
|
@@ -44,8 +41,8 @@ interface StartOptions {
|
|
|
44
41
|
*
|
|
45
42
|
* The assertions are inferred from the app value itself, so `expect.chat` gets
|
|
46
43
|
* the project's tool names and argument shapes with no type parameter. The
|
|
47
|
-
* session talks
|
|
48
|
-
*
|
|
44
|
+
* session talks to an in-process handler built on `app.createServerInstance`,
|
|
45
|
+
* which never closes: it is memoized per app and shared by every test.
|
|
49
46
|
*
|
|
50
47
|
* `authInfo` claims an identity for the session: the app's per-tool scheme and
|
|
51
48
|
* 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,EAGL,KAAK,MAAM,EACZ,MAAM,8BAA8B,CAAC;AACtC,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;AAaD;;;;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;;;;;;;;;;;;;;GAcG;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,CAoBpB"}
|
package/dist/session-registry.js
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
|
+
import { createMcpHandler, } from "@modelcontextprotocol/server";
|
|
1
2
|
import { inject, onTestFinished } from "vitest";
|
|
2
3
|
import { Chat } from "./chat.js";
|
|
4
|
+
const handlers = new WeakMap();
|
|
5
|
+
function getHandler(app) {
|
|
6
|
+
let handler = handlers.get(app);
|
|
7
|
+
if (!handler) {
|
|
8
|
+
handler = createMcpHandler(() => app.createServerInstance());
|
|
9
|
+
handlers.set(app, handler);
|
|
10
|
+
}
|
|
11
|
+
return handler;
|
|
12
|
+
}
|
|
3
13
|
function sharedDefaults() {
|
|
4
14
|
try {
|
|
5
15
|
return inject("skybridgeEvals");
|
|
@@ -16,8 +26,8 @@ function sharedDefaults() {
|
|
|
16
26
|
*
|
|
17
27
|
* The assertions are inferred from the app value itself, so `expect.chat` gets
|
|
18
28
|
* the project's tool names and argument shapes with no type parameter. The
|
|
19
|
-
* session talks
|
|
20
|
-
*
|
|
29
|
+
* session talks to an in-process handler built on `app.createServerInstance`,
|
|
30
|
+
* which never closes: it is memoized per app and shared by every test.
|
|
21
31
|
*
|
|
22
32
|
* `authInfo` claims an identity for the session: the app's per-tool scheme and
|
|
23
33
|
* scope enforcement runs against it for real, only token verification is
|
|
@@ -31,7 +41,7 @@ export async function start(options) {
|
|
|
31
41
|
temperature: options.temperature ?? config?.temperature,
|
|
32
42
|
systemPrompt: options.systemPrompt ?? config?.systemPrompt,
|
|
33
43
|
maxSteps: options.maxSteps ?? config?.maxSteps,
|
|
34
|
-
}, (url, init) => app.
|
|
44
|
+
}, (url, init) => getHandler(app).fetch(new Request(url, init), authInfo === undefined ? undefined : { authInfo }));
|
|
35
45
|
onTestFinished(() => chat.close());
|
|
36
46
|
return chat;
|
|
37
47
|
}
|
|
@@ -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,EACL,gBAAgB,GAGjB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAajC,MAAM,QAAQ,GAAG,IAAI,OAAO,EAA2B,CAAC;AAExD,SAAS,UAAU,CAAC,GAAY;IAC9B,IAAI,OAAO,GAAG,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAChC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,GAAG,gBAAgB,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,oBAAoB,EAAE,CAAC,CAAC;QAC7D,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC7B,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAwBD,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;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,KAAK,UAAU,KAAK,CACzB,OAA6D;IAE7D,MAAM,MAAM,GAAG,cAAc,EAAE,CAAC;IAChC,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IAElC,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,CAC1B;QACE,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,WAAW,EAAE,OAAO,CAAC,WAAW,IAAI,MAAM,EAAE,WAAW;QACvD,YAAY,EAAE,OAAO,CAAC,YAAY,IAAI,MAAM,EAAE,YAAY;QAC1D,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,MAAM,EAAE,QAAQ;KAC/C,EACD,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CACZ,UAAU,CAAC,GAAG,CAAC,CAAC,KAAK,CACnB,IAAI,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,EACtB,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAClD,CACJ,CAAC;IAEF,cAAc,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;IACnC,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skybridge/test",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.dd3cba3",
|
|
4
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-beta.
|
|
36
|
+
"@skybridge/vite-plugin": "2.0.0-beta.dd3cba3",
|
|
37
|
+
"skybridge": "2.0.0-beta.dd3cba3"
|
|
36
38
|
},
|
|
37
39
|
"engines": {
|
|
38
40
|
"node": ">=22.23.1"
|