@skybridge/test 0.0.0-dev.7aada9d → 0.0.0-dev.7cd4271
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 +126 -0
- package/dist/chat.d.ts +28 -30
- package/dist/chat.d.ts.map +1 -1
- package/dist/chat.js +150 -30
- package/dist/chat.js.map +1 -1
- package/dist/eval-middlewares.d.ts +13 -0
- package/dist/eval-middlewares.d.ts.map +1 -0
- package/dist/eval-middlewares.js +18 -0
- package/dist/eval-middlewares.js.map +1 -0
- package/dist/index.d.ts +3 -4
- 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 +14 -0
- package/dist/input-files.d.ts.map +1 -0
- package/dist/input-files.js +126 -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/middleware/list-tools.d.ts +4 -0
- package/dist/middleware/list-tools.d.ts.map +1 -0
- package/dist/middleware/list-tools.js +67 -0
- package/dist/middleware/list-tools.js.map +1 -0
- package/dist/middleware/resolve-files.d.ts +4 -0
- package/dist/middleware/resolve-files.d.ts.map +1 -0
- package/dist/middleware/resolve-files.js +13 -0
- package/dist/middleware/resolve-files.js.map +1 -0
- package/dist/middleware/stub-tool.d.ts +4 -0
- package/dist/middleware/stub-tool.d.ts.map +1 -0
- package/dist/middleware/stub-tool.js +16 -0
- package/dist/middleware/stub-tool.js.map +1 -0
- package/dist/session-registry.d.ts +53 -9
- package/dist/session-registry.d.ts.map +1 -1
- package/dist/session-registry.js +60 -20
- package/dist/session-registry.js.map +1 -1
- package/package.json +15 -13
- package/dist/config.d.ts +0 -40
- 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 -39
- 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 -76
- 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/telemetry.d.ts +0 -10
- package/dist/telemetry.d.ts.map +0 -1
- package/dist/telemetry.js +0 -77
- package/dist/telemetry.js.map +0 -1
package/README.md
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# @skybridge/test
|
|
2
|
+
|
|
3
|
+
Evals for [Skybridge](https://skybridge.tech) MCP Apps: they answer whether a
|
|
4
|
+
prompt reaches the right tool with the right arguments, which no unit test can
|
|
5
|
+
check.
|
|
6
|
+
|
|
7
|
+
Add the `evals` option to the Skybridge Vite plugin so `expect.chat` exists,
|
|
8
|
+
then write scenarios with vitest's own `it` and `expect`. Pass the app itself
|
|
9
|
+
to `start`: it is served in-process, using your exported app, and
|
|
10
|
+
the tool names and argument shapes come from the app value, so no type
|
|
11
|
+
parameter is needed.
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { anthropic } from "@ai-sdk/anthropic";
|
|
15
|
+
import { expect, it } from "vitest";
|
|
16
|
+
import { start } from "@skybridge/test";
|
|
17
|
+
import { app } from "../src/server.js";
|
|
18
|
+
|
|
19
|
+
it("finds products by category", async () => {
|
|
20
|
+
const chat = await start({ app, model: anthropic("claude-sonnet-4-5") });
|
|
21
|
+
await chat.send("I am looking for ski goggles");
|
|
22
|
+
|
|
23
|
+
expect.chat(chat).toHaveCalledToolWith("search-products", {
|
|
24
|
+
category: "goggles",
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
There is no child process and no server to boot, so the evals run anywhere
|
|
30
|
+
vitest does. The caveat is that they bypass the Express layer, so nothing
|
|
31
|
+
verifies a bearer token; pass `authInfo` to claim an identity.
|
|
32
|
+
|
|
33
|
+
## Authenticated evals
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
const chat = await start({
|
|
37
|
+
app,
|
|
38
|
+
model: anthropic("claude-sonnet-4-5"),
|
|
39
|
+
authInfo: {
|
|
40
|
+
token: "eval-token",
|
|
41
|
+
clientId: "eval-client",
|
|
42
|
+
scopes: ["checkout"],
|
|
43
|
+
extra: { sub: "user_123", email: "ada@example.com" },
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
`authInfo` injects a claimed identity: the app's own scheme and scope
|
|
49
|
+
enforcement runs for real, in-band challenges included, and only token
|
|
50
|
+
signature verification is skipped. Omit it to eval the anonymous path, which is
|
|
51
|
+
how you assert that a protected tool challenges instead of running.
|
|
52
|
+
|
|
53
|
+
## Choosing a model
|
|
54
|
+
|
|
55
|
+
`start` takes any AI SDK model instance, so the provider and its credentials
|
|
56
|
+
are the project's own. Install the provider package you want alongside `ai`.
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
import { anthropic } from "@ai-sdk/anthropic";
|
|
60
|
+
import { start } from "@skybridge/test";
|
|
61
|
+
|
|
62
|
+
const chat = await start({ app, model: anthropic("claude-sonnet-4-5") });
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
A local runtime or a company gateway works the same way, through the AI SDK's
|
|
66
|
+
own `createOpenAICompatible` or `customProvider`.
|
|
67
|
+
|
|
68
|
+
```ts
|
|
69
|
+
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
|
|
70
|
+
|
|
71
|
+
const ollama = createOpenAICompatible({
|
|
72
|
+
name: "ollama",
|
|
73
|
+
baseURL: "http://localhost:11434/v1",
|
|
74
|
+
});
|
|
75
|
+
const chat = await start({ app, model: ollama("llama3.1") });
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
The plugin's `evals` option also carries the defaults every conversation starts
|
|
79
|
+
from, so a project can set them once instead of per scenario.
|
|
80
|
+
|
|
81
|
+
```ts
|
|
82
|
+
skybridge({ evals: { temperature: 0, maxSteps: 6 } });
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Matchers
|
|
86
|
+
|
|
87
|
+
Assertions on what the assistant said work the same way, though model prose
|
|
88
|
+
varies between runs, so keep them loose.
|
|
89
|
+
|
|
90
|
+
```ts
|
|
91
|
+
expect.chat(chat).toHaveSaid("in stock");
|
|
92
|
+
expect.chat(chat).not.toHaveSaid("refund");
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
See the [documentation](https://docs.skybridge.tech) for setup and the full
|
|
96
|
+
matcher list.
|
|
97
|
+
|
|
98
|
+
## Input files
|
|
99
|
+
|
|
100
|
+
`chat.send` also accepts AI SDK `UserContent`. Attach a `FilePart` and use the same object in `expect.inputFile` to check which file a tool received:
|
|
101
|
+
|
|
102
|
+
```ts
|
|
103
|
+
import { readFile } from "node:fs/promises";
|
|
104
|
+
import type { FilePart } from "ai";
|
|
105
|
+
|
|
106
|
+
const portrait: FilePart = {
|
|
107
|
+
type: "file",
|
|
108
|
+
mediaType: "image/png",
|
|
109
|
+
filename: "photo.png",
|
|
110
|
+
data: await readFile(new URL("./fixtures/photo.png", import.meta.url)),
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
await chat.send([{ type: "text", text: "Resize this photo" }, portrait]);
|
|
114
|
+
|
|
115
|
+
expect.chat(chat).toHaveCalledToolWith("image_crop_and_resize", {
|
|
116
|
+
file: expect.inputFile(portrait),
|
|
117
|
+
});
|
|
118
|
+
expect.chat(chat).toHaveCalledToolOnce("asset_openai_file_upload", {
|
|
119
|
+
files: [expect.inputFile(portrait)],
|
|
120
|
+
});
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
`file` and `files` must be listed in their tools' `_meta["openai/fileParams"]`.
|
|
124
|
+
Misplaced file matchers throw immediately, including nested matchers and `.not`.
|
|
125
|
+
Declare file parameters with `FileRef` and list their names in `_meta["openai/fileParams"]`. Optional, nullable, and array forms are supported. Your handler or stub receives the attached file; downloads remain available until the conversation closes.
|
|
126
|
+
See [Evals](https://docs.skybridge.tech/test/evals) for how files reach the model and the tool.
|
package/dist/chat.d.ts
CHANGED
|
@@ -1,51 +1,49 @@
|
|
|
1
|
-
import { type LanguageModel } from "ai";
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
*/
|
|
7
|
-
export type ToolCall<App> = {
|
|
8
|
-
[Name in ToolNames<App>]: {
|
|
9
|
-
name: Name;
|
|
10
|
-
arguments: ToolInput<App, Name>;
|
|
11
|
-
invalid?: boolean;
|
|
12
|
-
};
|
|
13
|
-
}[ToolNames<App>];
|
|
14
|
-
/**
|
|
15
|
-
* How the host is configured. `model` is an AI SDK model instance, so the
|
|
16
|
-
* provider and its credentials are chosen by the project rather than by a
|
|
17
|
-
* base URL the runner has to know about.
|
|
18
|
-
*/
|
|
19
|
-
export interface HostConfig {
|
|
1
|
+
import { type LanguageModel, type UserContent } from "ai";
|
|
2
|
+
import { EvalMiddlewares } from "./eval-middlewares.js";
|
|
3
|
+
import type { ToolCall, Turn } from "./matchers/types.js";
|
|
4
|
+
import type { ToolStubs } from "./session-registry.js";
|
|
5
|
+
interface HostConfig {
|
|
20
6
|
model: LanguageModel;
|
|
21
7
|
temperature?: number;
|
|
22
8
|
systemPrompt?: string;
|
|
23
9
|
maxSteps?: number;
|
|
24
10
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
11
|
+
/**
|
|
12
|
+
* A `fetch` replacement the transport dials instead of the network. Mirrors the
|
|
13
|
+
* MCP client's own `fetch` option so an in-process app can serve the session.
|
|
14
|
+
*/
|
|
15
|
+
export type TransportFetch = (url: string | URL, init?: RequestInit) => Promise<Response>;
|
|
30
16
|
/**
|
|
31
17
|
* One conversation against one MCP session. A scenario asserts on
|
|
32
18
|
* {@link Chat.toolCalls}, the sequence of calls the model made.
|
|
33
19
|
*/
|
|
34
20
|
export declare class Chat<App = unknown> {
|
|
21
|
+
private readonly middleware;
|
|
22
|
+
private readonly dispose;
|
|
23
|
+
/** Type-only anchor so `expect.chat` infers `App` from the conversation. */
|
|
24
|
+
readonly $app: App;
|
|
25
|
+
/** Everything that happened, in the order it happened. */
|
|
26
|
+
readonly turns: Turn<App>[];
|
|
35
27
|
/** Every call the model made, in order, as it crossed the wire. */
|
|
36
|
-
|
|
28
|
+
get toolCalls(): ToolCall<App>[];
|
|
29
|
+
/** What the assistant said, one entry per turn, intermediate ones included. */
|
|
30
|
+
get assistantTurns(): string[];
|
|
37
31
|
private readonly messages;
|
|
32
|
+
private readonly failures;
|
|
38
33
|
private readonly client;
|
|
39
34
|
private readonly transport;
|
|
40
35
|
private readonly host;
|
|
41
36
|
private tools;
|
|
37
|
+
private closePromise?;
|
|
38
|
+
private legacyStubs?;
|
|
39
|
+
/** The model the conversation runs on, and the judge's default. */
|
|
40
|
+
get model(): LanguageModel;
|
|
42
41
|
private constructor();
|
|
43
|
-
static open<App>(
|
|
44
|
-
/**
|
|
45
|
-
|
|
46
|
-
/** Takes a turn and returns the model's answer. */
|
|
47
|
-
send(prompt: string): Promise<string>;
|
|
42
|
+
static open<App>(host: HostConfig, fetchImpl: TransportFetch, middlewareOrStubs: EvalMiddlewares | ToolStubs, dispose?: () => Promise<void>): Promise<Chat<App>>;
|
|
43
|
+
/** Takes a turn. Assert on the result with `expect.chat`. */
|
|
44
|
+
send(content: UserContent): Promise<void>;
|
|
48
45
|
close(): Promise<void>;
|
|
46
|
+
private failureFor;
|
|
49
47
|
private toolSet;
|
|
50
48
|
}
|
|
51
49
|
export {};
|
package/dist/chat.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../src/chat.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../src/chat.ts"],"names":[],"mappings":"AAOA,OAAO,EAKL,KAAK,aAAa,EAGlB,KAAK,WAAW,EACjB,MAAM,IAAI,CAAC;AACZ,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,OAAO,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAEvD,UAAU,UAAU;IAClB,KAAK,EAAE,aAAa,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAaD;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,CAC3B,GAAG,EAAE,MAAM,GAAG,GAAG,EACjB,IAAI,CAAC,EAAE,WAAW,KACf,OAAO,CAAC,QAAQ,CAAC,CAAC;AAEvB;;;GAGG;AACH,qBAAa,IAAI,CAAC,GAAG,GAAG,OAAO;IAuC3B,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,OAAO;IAvC1B,4EAA4E;IAC5E,SAAiB,IAAI,EAAE,GAAG,CAAC;IAE3B,0DAA0D;IAC1D,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,CAAM;IAEjC,mEAAmE;IACnE,IAAI,SAAS,IAAI,QAAQ,CAAC,GAAG,CAAC,EAAE,CAI/B;IAED,+EAA+E;IAC/E,IAAI,cAAc,IAAI,MAAM,EAAE,CAI7B;IAED,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAsB;IAC/C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA6B;IACtD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAgC;IAC1D,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAa;IAClC,OAAO,CAAC,KAAK,CAAc;IAC3B,OAAO,CAAC,YAAY,CAAC,CAAgB;IACrC,OAAO,CAAC,WAAW,CAAC,CAAY;IAEhC,mEAAmE;IACnE,IAAI,KAAK,IAAI,aAAa,CAEzB;IAED,OAAO;WAYM,IAAI,CAAC,GAAG,EACnB,IAAI,EAAE,UAAU,EAChB,SAAS,EAAE,cAAc,EACzB,iBAAiB,EAAE,eAAe,GAAG,SAAS,EAC9C,OAAO,GAAE,MAAM,OAAO,CAAC,IAAI,CAAkB,GAC5C,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAkCrB,6DAA6D;IACvD,IAAI,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAsD/C,KAAK;IAeL,OAAO,CAAC,UAAU;IAalB,OAAO,CAAC,OAAO;CAkEhB"}
|
package/dist/chat.js
CHANGED
|
@@ -1,32 +1,71 @@
|
|
|
1
|
-
import { Client } from "@modelcontextprotocol/
|
|
2
|
-
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
|
1
|
+
import { Client, fromJsonSchema, StreamableHTTPClientTransport, } from "@modelcontextprotocol/client";
|
|
3
2
|
import { dynamicTool, generateText, jsonSchema, stepCountIs, } from "ai";
|
|
3
|
+
import { EvalMiddlewares } from "./eval-middlewares.js";
|
|
4
|
+
import { registerFileParameters } from "./matchers/matchers.js";
|
|
4
5
|
const DEFAULT_MAX_STEPS = 8;
|
|
6
|
+
const IN_PROCESS_URL = "http://in-process.skybridge.test/mcp";
|
|
7
|
+
function outputOf(results, toolCallId) {
|
|
8
|
+
return results.find((result) => result.toolCallId === toolCallId)?.output;
|
|
9
|
+
}
|
|
5
10
|
/**
|
|
6
11
|
* One conversation against one MCP session. A scenario asserts on
|
|
7
12
|
* {@link Chat.toolCalls}, the sequence of calls the model made.
|
|
8
13
|
*/
|
|
9
14
|
export class Chat {
|
|
15
|
+
middleware;
|
|
16
|
+
dispose;
|
|
17
|
+
/** Everything that happened, in the order it happened. */
|
|
18
|
+
turns = [];
|
|
10
19
|
/** Every call the model made, in order, as it crossed the wire. */
|
|
11
|
-
toolCalls
|
|
20
|
+
get toolCalls() {
|
|
21
|
+
return this.turns
|
|
22
|
+
.filter((turn) => turn.role === "tool")
|
|
23
|
+
.map((turn) => turn.call);
|
|
24
|
+
}
|
|
25
|
+
/** What the assistant said, one entry per turn, intermediate ones included. */
|
|
26
|
+
get assistantTurns() {
|
|
27
|
+
return this.turns
|
|
28
|
+
.filter((turn) => turn.role === "assistant")
|
|
29
|
+
.map((turn) => turn.text);
|
|
30
|
+
}
|
|
12
31
|
messages = [];
|
|
32
|
+
failures = new Map();
|
|
13
33
|
client;
|
|
14
34
|
transport;
|
|
15
35
|
host;
|
|
16
36
|
tools = [];
|
|
17
|
-
|
|
37
|
+
closePromise;
|
|
38
|
+
legacyStubs;
|
|
39
|
+
/** The model the conversation runs on, and the judge's default. */
|
|
40
|
+
get model() {
|
|
41
|
+
return this.host.model;
|
|
42
|
+
}
|
|
43
|
+
constructor(client, transport, host, middleware, dispose) {
|
|
44
|
+
this.middleware = middleware;
|
|
45
|
+
this.dispose = dispose;
|
|
18
46
|
this.client = client;
|
|
19
47
|
this.transport = transport;
|
|
20
48
|
this.host = host;
|
|
21
49
|
}
|
|
22
|
-
static async open(
|
|
50
|
+
static async open(host, fetchImpl, middlewareOrStubs, dispose = async () => { }) {
|
|
51
|
+
const middleware = middlewareOrStubs instanceof EvalMiddlewares
|
|
52
|
+
? middlewareOrStubs
|
|
53
|
+
: new EvalMiddlewares();
|
|
23
54
|
const client = new Client({ name: "skybridge-eval", version: "0" });
|
|
24
|
-
const transport = new StreamableHTTPClientTransport(new URL(
|
|
25
|
-
|
|
26
|
-
const chat = new Chat(client, transport, host);
|
|
55
|
+
const transport = new StreamableHTTPClientTransport(new URL(IN_PROCESS_URL), { fetch: fetchImpl });
|
|
56
|
+
const chat = new Chat(client, transport, host, middleware, dispose);
|
|
27
57
|
try {
|
|
58
|
+
await client.connect(transport);
|
|
28
59
|
const { tools } = await client.listTools();
|
|
29
60
|
chat.tools = tools;
|
|
61
|
+
if (!(middlewareOrStubs instanceof EvalMiddlewares)) {
|
|
62
|
+
chat.legacyStubs = middlewareOrStubs;
|
|
63
|
+
const unknown = Object.keys(middlewareOrStubs).filter((name) => !tools.some((tool) => tool.name === name));
|
|
64
|
+
if (unknown.length) {
|
|
65
|
+
throw new Error(`the app exposes no tool named ${unknown.map((name) => `"${name}"`).join(", ")}, so the stub would never run`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
registerFileParameters(chat, middleware.fileParams);
|
|
30
69
|
}
|
|
31
70
|
catch (error) {
|
|
32
71
|
await transport.close();
|
|
@@ -34,16 +73,29 @@ export class Chat {
|
|
|
34
73
|
}
|
|
35
74
|
return chat;
|
|
36
75
|
}
|
|
37
|
-
/**
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
this.
|
|
76
|
+
/** Takes a turn. Assert on the result with `expect.chat`. */
|
|
77
|
+
async send(content) {
|
|
78
|
+
if (this.closePromise) {
|
|
79
|
+
throw new Error("The conversation is closed");
|
|
80
|
+
}
|
|
81
|
+
const prepared = await this.middleware.files.prepare(content);
|
|
82
|
+
this.middleware.inputs.clear();
|
|
83
|
+
this.failures.clear();
|
|
84
|
+
this.messages.push({ role: "user", content: prepared });
|
|
85
|
+
this.turns.push({
|
|
86
|
+
role: "user",
|
|
87
|
+
text: typeof prepared === "string"
|
|
88
|
+
? prepared
|
|
89
|
+
: prepared
|
|
90
|
+
.filter((part) => part.type === "text")
|
|
91
|
+
.map((part) => part.text)
|
|
92
|
+
.join("\n"),
|
|
93
|
+
});
|
|
44
94
|
const result = await generateText({
|
|
45
95
|
model: this.host.model,
|
|
46
|
-
|
|
96
|
+
...(this.host.temperature === undefined
|
|
97
|
+
? {}
|
|
98
|
+
: { temperature: this.host.temperature }),
|
|
47
99
|
...(this.host.systemPrompt === undefined
|
|
48
100
|
? {}
|
|
49
101
|
: { system: this.host.systemPrompt }),
|
|
@@ -52,34 +104,102 @@ export class Chat {
|
|
|
52
104
|
stopWhen: stepCountIs(this.host.maxSteps ?? DEFAULT_MAX_STEPS),
|
|
53
105
|
});
|
|
54
106
|
for (const step of result.steps) {
|
|
107
|
+
if (step.text !== "") {
|
|
108
|
+
this.turns.push({ role: "assistant", text: step.text });
|
|
109
|
+
}
|
|
55
110
|
for (const call of step.toolCalls) {
|
|
56
|
-
this.
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
111
|
+
this.turns.push({
|
|
112
|
+
role: "tool",
|
|
113
|
+
call: {
|
|
114
|
+
name: call.toolName,
|
|
115
|
+
arguments: this.middleware.inputs.get(call.toolCallId) ??
|
|
116
|
+
(call.input ?? {}),
|
|
117
|
+
...this.failureFor(call),
|
|
118
|
+
},
|
|
119
|
+
result: outputOf(step.toolResults, call.toolCallId),
|
|
60
120
|
});
|
|
61
121
|
}
|
|
62
122
|
}
|
|
63
123
|
this.messages.push(...result.response.messages);
|
|
64
|
-
return result.text;
|
|
65
124
|
}
|
|
66
|
-
|
|
67
|
-
|
|
125
|
+
close() {
|
|
126
|
+
this.closePromise ??= (async () => {
|
|
127
|
+
try {
|
|
128
|
+
await this.transport.close();
|
|
129
|
+
}
|
|
130
|
+
finally {
|
|
131
|
+
try {
|
|
132
|
+
await this.middleware.files.close();
|
|
133
|
+
}
|
|
134
|
+
finally {
|
|
135
|
+
await this.dispose();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
})();
|
|
139
|
+
return this.closePromise;
|
|
140
|
+
}
|
|
141
|
+
failureFor(call) {
|
|
142
|
+
const reported = this.failures.get(call.toolCallId);
|
|
143
|
+
if (reported !== undefined) {
|
|
144
|
+
return { failed: reported };
|
|
145
|
+
}
|
|
146
|
+
if (call.invalid === true) {
|
|
147
|
+
return { failed: "the model's arguments could not be parsed" };
|
|
148
|
+
}
|
|
149
|
+
return {};
|
|
68
150
|
}
|
|
69
151
|
toolSet() {
|
|
70
152
|
const entries = this.tools.map((definition) => {
|
|
71
153
|
const { $schema: _ignored, ...parameters } = definition.inputSchema;
|
|
154
|
+
const schema = fromJsonSchema(parameters);
|
|
72
155
|
return [
|
|
73
156
|
definition.name,
|
|
74
157
|
dynamicTool({
|
|
75
158
|
description: definition.description ?? "",
|
|
76
|
-
inputSchema: jsonSchema(parameters
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
159
|
+
inputSchema: jsonSchema(parameters, {
|
|
160
|
+
validate: async (input) => {
|
|
161
|
+
const result = await schema["~standard"].validate(input);
|
|
162
|
+
return result.issues
|
|
163
|
+
? {
|
|
164
|
+
success: false,
|
|
165
|
+
error: new Error(JSON.stringify(result.issues)),
|
|
166
|
+
}
|
|
167
|
+
: { success: true, value: result.value };
|
|
168
|
+
},
|
|
169
|
+
}),
|
|
170
|
+
execute: async (input, { toolCallId }) => {
|
|
171
|
+
const stubbed = await this.legacyStubs?.[definition.name]?.((input ?? {}));
|
|
172
|
+
if (stubbed !== undefined) {
|
|
173
|
+
return {
|
|
174
|
+
content: [
|
|
175
|
+
{
|
|
176
|
+
type: "text",
|
|
177
|
+
text: typeof stubbed === "string"
|
|
178
|
+
? stubbed
|
|
179
|
+
: JSON.stringify(stubbed),
|
|
180
|
+
},
|
|
181
|
+
],
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
let result;
|
|
185
|
+
try {
|
|
186
|
+
result = await this.client.callTool({
|
|
187
|
+
name: definition.name,
|
|
188
|
+
arguments: (input ?? {}),
|
|
189
|
+
_meta: { "skybridge/evalToolCallId": toolCallId },
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
catch (error) {
|
|
193
|
+
this.failures.set(toolCallId, `the tool call failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
194
|
+
throw error;
|
|
195
|
+
}
|
|
196
|
+
if (result.isError === true) {
|
|
197
|
+
this.failures.set(toolCallId, `the tool returned an error: ${JSON.stringify(result.content)}`);
|
|
198
|
+
}
|
|
199
|
+
return {
|
|
200
|
+
content: result.content,
|
|
201
|
+
structuredContent: result.structuredContent,
|
|
202
|
+
};
|
|
83
203
|
},
|
|
84
204
|
}),
|
|
85
205
|
];
|
package/dist/chat.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat.js","sourceRoot":"","sources":["../src/chat.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"chat.js","sourceRoot":"","sources":["../src/chat.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,cAAc,EAEd,6BAA6B,GAE9B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,WAAW,EACX,YAAY,EAEZ,UAAU,EAGV,WAAW,GAEZ,MAAM,IAAI,CAAC;AACZ,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAWhE,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAE5B,MAAM,cAAc,GAAG,sCAAsC,CAAC;AAE9D,SAAS,QAAQ,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AS,EAAE,CAAC,KAAK,IAAI,EAAE,CAA4B;gCACnD,KAAK,EAAE,EAAE,0BAA0B,EAAE,UAAU,EAAE;6BAClD,CAAC,CAAC;wBACL,CAAC;wBAAC,OAAO,KAAK,EAAE,CAAC;4BACf,IAAI,CAAC,QAAQ,CAAC,GAAG,CACf,UAAU,EACV,yBAAyB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAClF,CAAC;4BACF,MAAM,KAAK,CAAC;wBACd,CAAC;wBACD,IAAI,MAAM,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;4BAC5B,IAAI,CAAC,QAAQ,CAAC,GAAG,CACf,UAAU,EACV,+BAA+B,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAChE,CAAC;wBACJ,CAAC;wBACD,OAAO;4BACL,OAAO,EAAE,MAAM,CAAC,OAAO;4BACvB,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;yBAC5C,CAAC;oBACJ,CAAC;iBACF,CAAC;aACM,CAAC;QACb,CAAC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC;CACF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { McpMiddlewareFn } from "skybridge/server";
|
|
2
|
+
import { InputFiles } from "./input-files.js";
|
|
3
|
+
import type { ToolStubs } from "./session-registry.js";
|
|
4
|
+
export declare class EvalMiddlewares {
|
|
5
|
+
readonly files: InputFiles;
|
|
6
|
+
readonly inputs: Map<string, Record<string, unknown>>;
|
|
7
|
+
readonly fileParams: Map<string, string[]>;
|
|
8
|
+
readonly listTools: McpMiddlewareFn;
|
|
9
|
+
readonly resolveFiles: McpMiddlewareFn;
|
|
10
|
+
readonly stubTool: McpMiddlewareFn;
|
|
11
|
+
constructor(stubs?: ToolStubs);
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=eval-middlewares.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eval-middlewares.d.ts","sourceRoot":"","sources":["../src/eval-middlewares.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAI9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAEvD,qBAAa,eAAe;IAC1B,QAAQ,CAAC,KAAK,aAAoB;IAClC,QAAQ,CAAC,MAAM,uCAA8C;IAC7D,QAAQ,CAAC,UAAU,wBAA+B;IAClD,QAAQ,CAAC,SAAS,EAAE,eAAe,CAAC;IACpC,QAAQ,CAAC,YAAY,EAAE,eAAe,CAAC;IACvC,QAAQ,CAAC,QAAQ,EAAE,eAAe,CAAC;gBAEvB,KAAK,GAAE,SAAc;CASlC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { InputFiles } from "./input-files.js";
|
|
2
|
+
import { createListToolsMiddleware } from "./middleware/list-tools.js";
|
|
3
|
+
import { createResolveFilesMiddleware } from "./middleware/resolve-files.js";
|
|
4
|
+
import { createStubToolMiddleware } from "./middleware/stub-tool.js";
|
|
5
|
+
export class EvalMiddlewares {
|
|
6
|
+
files = new InputFiles();
|
|
7
|
+
inputs = new Map();
|
|
8
|
+
fileParams = new Map();
|
|
9
|
+
listTools;
|
|
10
|
+
resolveFiles;
|
|
11
|
+
stubTool;
|
|
12
|
+
constructor(stubs = {}) {
|
|
13
|
+
this.listTools = createListToolsMiddleware(this.fileParams, stubs);
|
|
14
|
+
this.resolveFiles = createResolveFilesMiddleware(this.files, this.fileParams, this.inputs);
|
|
15
|
+
this.stubTool = createStubToolMiddleware(stubs);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=eval-middlewares.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eval-middlewares.js","sourceRoot":"","sources":["../src/eval-middlewares.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,EAAE,4BAA4B,EAAE,MAAM,+BAA+B,CAAC;AAC7E,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAGrE,MAAM,OAAO,eAAe;IACjB,KAAK,GAAG,IAAI,UAAU,EAAE,CAAC;IACzB,MAAM,GAAG,IAAI,GAAG,EAAmC,CAAC;IACpD,UAAU,GAAG,IAAI,GAAG,EAAoB,CAAC;IACzC,SAAS,CAAkB;IAC3B,YAAY,CAAkB;IAC9B,QAAQ,CAAkB;IAEnC,YAAY,QAAmB,EAAE;QAC/B,IAAI,CAAC,SAAS,GAAG,yBAAyB,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;QACnE,IAAI,CAAC,YAAY,GAAG,4BAA4B,CAC9C,IAAI,CAAC,KAAK,EACV,IAAI,CAAC,UAAU,EACf,IAAI,CAAC,MAAM,CACZ,CAAC;QACF,IAAI,CAAC,QAAQ,GAAG,wBAAwB,CAAC,KAAK,CAAC,CAAC;IAClD,CAAC;CACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
export type { Chat
|
|
2
|
-
export type {
|
|
3
|
-
export type {
|
|
4
|
-
export { defineEvalModel } from "./model.js";
|
|
1
|
+
export type { Chat } from "./chat.js";
|
|
2
|
+
export type { ChatAssertion, ChatMatchers, Judgment, JudgmentOptions, Verdict, } from "./matchers/index.js";
|
|
3
|
+
export type { EvalApp, EvalIdentity, ToolStubs, } from "./session-registry.js";
|
|
5
4
|
export { start } from "./session-registry.js";
|
|
6
5
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACtC,YAAY,EACV,aAAa,EACb,YAAY,EACZ,QAAQ,EACR,eAAe,EACf,OAAO,GACR,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EACV,OAAO,EACP,YAAY,EACZ,SAAS,GACV,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { UserContent } from "ai";
|
|
2
|
+
export declare class InputFiles {
|
|
3
|
+
private closed;
|
|
4
|
+
private listening?;
|
|
5
|
+
private readonly files;
|
|
6
|
+
private readonly paths;
|
|
7
|
+
private readonly server;
|
|
8
|
+
prepare(content: UserContent): Promise<UserContent>;
|
|
9
|
+
rewrite(input: Record<string, unknown>, fields: string[]): Promise<{
|
|
10
|
+
[x: string]: unknown;
|
|
11
|
+
}>;
|
|
12
|
+
close(): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=input-files.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input-files.d.ts","sourceRoot":"","sources":["../src/input-files.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAY,WAAW,EAAE,MAAM,IAAI,CAAC;AAkChD,qBAAa,UAAU;IACrB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,SAAS,CAAC,CAAgB;IAClC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAGlB;IACJ,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA8B;IACpD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAQpB;IAEG,OAAO,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;IAyCnD,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE;;;IAkCxD,KAAK;CASZ"}
|