@cursor/july 0.1.25 → 0.1.27
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/dist/ab.d.ts +6 -0
- package/dist/ab.d.ts.map +1 -1
- package/dist/ab.js +1 -0
- package/dist/artifacts.d.ts +34 -0
- package/dist/artifacts.d.ts.map +1 -0
- package/dist/artifacts.js +57 -0
- package/dist/bin/agent-serve.js +31 -9
- package/dist/channels/github/github-channel.d.ts +1 -1
- package/dist/channels/github/github-channel.d.ts.map +1 -1
- package/dist/channels/github/github-channel.js +14 -1
- package/dist/channels/github/types.d.ts +6 -1
- package/dist/channels/github/types.d.ts.map +1 -1
- package/dist/channels/slack/api.d.ts +2 -1
- package/dist/channels/slack/api.d.ts.map +1 -1
- package/dist/channels/slack/api.js +1 -0
- package/dist/channels/slack/cursor-account.d.ts +2 -1
- package/dist/channels/slack/cursor-account.d.ts.map +1 -1
- package/dist/channels/slack/cursor-account.js +1 -1
- package/dist/channels/slack/dispatch.d.ts +4 -1
- package/dist/channels/slack/dispatch.d.ts.map +1 -1
- package/dist/channels/slack/dispatch.js +3 -3
- package/dist/channels/slack/interactive.d.ts +2 -1
- package/dist/channels/slack/interactive.d.ts.map +1 -1
- package/dist/channels/slack/interactive.js +1 -0
- package/dist/channels/slack/slack-channel.d.ts.map +1 -1
- package/dist/channels/slack/slack-channel.js +4 -3
- package/dist/channels/slack/types.d.ts +6 -1
- package/dist/channels/slack/types.d.ts.map +1 -1
- package/dist/docs/404.html +1 -1
- package/dist/docs/ab.html +2 -2
- package/dist/docs/assets/{app.DYcC9FY-.js → app.BICLoJYF.js} +1 -1
- package/dist/docs/assets/chunks/@localSearchIndexroot.CQJytDwU.js +1 -0
- package/dist/docs/assets/chunks/{VPLocalSearchBox.o4N_knTV.js → VPLocalSearchBox.wN4Ko9dT.js} +1 -1
- package/dist/docs/assets/chunks/{theme.DQ-njyo0.js → theme.dnnTE-Co.js} +2 -2
- package/dist/docs/building-with-agents.html +2 -2
- package/dist/docs/concepts.html +2 -2
- package/dist/docs/deployment.html +2 -2
- package/dist/docs/evals.html +2 -2
- package/dist/docs/example-agents/approval-buddy.html +2 -2
- package/dist/docs/example-agents/benny.html +2 -2
- package/dist/docs/example-agents/bugbot.html +2 -2
- package/dist/docs/example-agents/codebase-wiki.html +2 -2
- package/dist/docs/example-agents/codeowners-review.html +2 -2
- package/dist/docs/example-agents/concierge.html +2 -2
- package/dist/docs/example-agents/fsd.html +2 -2
- package/dist/docs/example-agents/index.html +2 -2
- package/dist/docs/example-agents/knowledge-base.html +2 -2
- package/dist/docs/example-agents/oncall.html +2 -2
- package/dist/docs/example-agents/security-reviewer.html +2 -2
- package/dist/docs/example-agents/slack-agent.html +2 -2
- package/dist/docs/example-agents/weather-agent.html +2 -2
- package/dist/docs/guides/agent-to-agent.html +2 -2
- package/dist/docs/guides/cloud-runtime.html +2 -2
- package/dist/docs/guides/github.html +2 -2
- package/dist/docs/guides/human-in-the-loop.html +2 -2
- package/dist/docs/guides/mcp-oauth.html +2 -2
- package/dist/docs/guides/slack.html +2 -2
- package/dist/docs/guides/webhooks.html +2 -2
- package/dist/docs/hillclimbing.html +2 -2
- package/dist/docs/index.html +2 -2
- package/dist/docs/quickstart.html +2 -2
- package/dist/docs/reference/agent-config.html +2 -2
- package/dist/docs/reference/channels.html +2 -2
- package/dist/docs/reference/cli.html +2 -2
- package/dist/docs/reference/connections.html +2 -2
- package/dist/docs/reference/hooks.html +2 -2
- package/dist/docs/reference/http-api.html +2 -2
- package/dist/docs/reference/instructions.html +2 -2
- package/dist/docs/reference/playground.html +2 -2
- package/dist/docs/reference/project-layout.html +2 -2
- package/dist/docs/reference/prompt.html +2 -2
- package/dist/docs/reference/schedules.html +2 -2
- package/dist/docs/reference/sessions.html +2 -2
- package/dist/docs/reference/skills.html +2 -2
- package/dist/docs/reference/subagents.html +2 -2
- package/dist/docs/reference/tools.html +2 -2
- package/dist/docs/scaffolding-agents.html +2 -2
- package/dist/docs/storage.html +2 -2
- package/dist/docs/troubleshooting.html +2 -2
- package/dist/evals/assertions.d.ts +10 -1
- package/dist/evals/assertions.d.ts.map +1 -1
- package/dist/evals/assertions.js +12 -0
- package/dist/evals.d.ts +1 -1
- package/dist/evals.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/internal/ab-fold.d.ts.map +1 -1
- package/dist/internal/ab-fold.js +4 -0
- package/dist/internal/ab-snapshot.d.ts.map +1 -1
- package/dist/internal/ab-snapshot.js +1 -0
- package/dist/internal/artifacts-store.d.ts +45 -0
- package/dist/internal/artifacts-store.d.ts.map +1 -0
- package/dist/internal/artifacts-store.js +250 -0
- package/dist/internal/builtin-tools/artifacts.d.ts +10 -0
- package/dist/internal/builtin-tools/artifacts.d.ts.map +1 -0
- package/dist/internal/builtin-tools/artifacts.js +73 -0
- package/dist/internal/builtin-tools/index.d.ts +8 -1
- package/dist/internal/builtin-tools/index.d.ts.map +1 -1
- package/dist/internal/builtin-tools/index.js +15 -0
- package/dist/internal/cli-ax.d.ts +11 -0
- package/dist/internal/cli-ax.d.ts.map +1 -1
- package/dist/internal/cli-ax.js +80 -0
- package/dist/internal/cli-slack.d.ts.map +1 -1
- package/dist/internal/cli-slack.js +14 -6
- package/dist/internal/discovery.d.ts.map +1 -1
- package/dist/internal/discovery.js +83 -2
- package/dist/internal/distribution.d.ts.map +1 -1
- package/dist/internal/distribution.js +1 -0
- package/dist/internal/model-pricing.d.ts +49 -0
- package/dist/internal/model-pricing.d.ts.map +1 -0
- package/dist/internal/model-pricing.js +377 -0
- package/dist/internal/reminder-runner.d.ts.map +1 -1
- package/dist/internal/reminder-runner.js +1 -0
- package/dist/internal/schedule-runner.d.ts.map +1 -1
- package/dist/internal/schedule-runner.js +1 -0
- package/dist/internal/sdk-runner.d.ts.map +1 -1
- package/dist/internal/sdk-runner.js +9 -1
- package/dist/internal/server.d.ts.map +1 -1
- package/dist/internal/server.js +39 -0
- package/dist/internal/session-cost.d.ts +49 -0
- package/dist/internal/session-cost.d.ts.map +1 -0
- package/dist/internal/session-cost.js +175 -0
- package/dist/internal/session-engine.d.ts +35 -1
- package/dist/internal/session-engine.d.ts.map +1 -1
- package/dist/internal/session-engine.js +128 -7
- package/dist/internal/storage-coordinator.d.ts +15 -0
- package/dist/internal/storage-coordinator.d.ts.map +1 -1
- package/dist/internal/storage-coordinator.js +52 -0
- package/dist/internal/trajectory.d.ts +9 -1
- package/dist/internal/trajectory.d.ts.map +1 -1
- package/dist/internal/trajectory.js +32 -5
- package/dist/playground/assets/index-BDCeW4uc.js +86 -0
- package/dist/playground/assets/index-Bul1WfrB.css +1 -0
- package/dist/playground/index.html +2 -2
- package/dist/storage.d.ts +4 -0
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +4 -0
- package/dist/types.d.ts +164 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +26 -26
- package/src/ab.ts +7 -0
- package/src/bin/agent-serve.ts +30 -2
- package/src/channels/github/github-channel.ts +19 -2
- package/src/channels/github/types.ts +6 -0
- package/src/channels/slack/api.ts +3 -1
- package/src/channels/slack/cursor-account.ts +3 -1
- package/src/channels/slack/dispatch.ts +12 -1
- package/src/channels/slack/interactive.ts +3 -0
- package/src/channels/slack/slack-channel.ts +6 -0
- package/src/channels/slack/types.ts +6 -0
- package/src/internal/ab-fold.ts +4 -0
- package/src/internal/ab-snapshot.ts +1 -0
- package/src/internal/cli-ax.ts +95 -0
- package/src/internal/model-pricing.ts +426 -0
- package/src/internal/reminder-runner.ts +1 -0
- package/src/internal/schedule-runner.ts +1 -0
- package/src/internal/sdk-runner.ts +10 -2
- package/src/internal/server.ts +2 -0
- package/src/internal/session-cost.ts +231 -0
- package/src/internal/session-engine.ts +32 -1
- package/src/internal/trajectory.ts +45 -3
- package/src/types.ts +42 -2
- package/dist/channels/github/instrument.d.ts +0 -20
- package/dist/channels/github/instrument.d.ts.map +0 -1
- package/dist/docs/assets/chunks/@localSearchIndexroot.BQTzJjR_.js +0 -1
- package/dist/internal/json-dir-store.d.ts +0 -32
- package/dist/internal/json-dir-store.d.ts.map +0 -1
- package/dist/internal/json-dir-store.js +0 -100
- package/dist/playground/assets/index-CjOQ4hN9.css +0 -1
- package/dist/playground/assets/index-DqXdAFGa.js +0 -85
- package/src/bin/agent-serve.version.test.ts +0 -64
- package/src/channels/github/api.test.ts +0 -64
- package/src/channels/github/auth.test.ts +0 -105
- package/src/channels/github/cursor-account.test.ts +0 -204
- package/src/channels/github/forward.test.ts +0 -457
- package/src/channels/github/github.test.ts +0 -943
- package/src/channels/github/replay.test.ts +0 -179
- package/src/channels/slack/api.post-message.test.ts +0 -148
- package/src/channels/slack/approvals.test.ts +0 -328
- package/src/channels/slack/block-actions.test.ts +0 -452
- package/src/channels/slack/bot-mentions.test.ts +0 -267
- package/src/channels/slack/channel-watch.test.ts +0 -363
- package/src/channels/slack/cursor-account.test.ts +0 -253
- package/src/channels/slack/defaults.final-post.test.ts +0 -182
- package/src/channels/slack/dispatch.test.ts +0 -795
- package/src/channels/slack/eval-directive.test.ts +0 -273
- package/src/channels/slack/message-body.test.ts +0 -54
- package/src/channels/slack/nudge-store.test.ts +0 -143
- package/src/channels/slack/slack.test.ts +0 -391
- package/src/channels/slack/stop.test.ts +0 -23
- package/src/channels/slack/thread-context.test.ts +0 -202
- package/src/evals/assertions.test.ts +0 -617
- package/src/evals/expect.test.ts +0 -144
- package/src/evals/judge.test.ts +0 -181
- package/src/evals/loaders.test.ts +0 -132
- package/src/evals/matchers.test.ts +0 -95
- package/src/evals/reporters.test.ts +0 -303
- package/src/evals/run-facts.test.ts +0 -259
- package/src/internal/ab-snapshot.test.ts +0 -325
- package/src/internal/approval-gate.test.ts +0 -49
- package/src/internal/approvals.integration.test.ts +0 -383
- package/src/internal/artifacts-store.test.ts +0 -283
- package/src/internal/authored-loaders.test.ts +0 -31
- package/src/internal/builtin-tools/artifacts.test.ts +0 -247
- package/src/internal/builtin-tools/reminders.test.ts +0 -201
- package/src/internal/channel-route-schema.test.ts +0 -294
- package/src/internal/chat-attach.test.ts +0 -262
- package/src/internal/cli-deploy.test.ts +0 -1991
- package/src/internal/cli-docs.test.ts +0 -161
- package/src/internal/cli-mcp.test.ts +0 -789
- package/src/internal/cli-skills.test.ts +0 -133
- package/src/internal/cli-slack.test.ts +0 -1654
- package/src/internal/cloud-merge.test.ts +0 -74
- package/src/internal/cron.test.ts +0 -22
- package/src/internal/cursor/account-mcp.test.ts +0 -807
- package/src/internal/cursor/backend-client.test.ts +0 -591
- package/src/internal/cursor/credentials.test.ts +0 -351
- package/src/internal/cursor/github-credentials.test.ts +0 -136
- package/src/internal/cursor-account-mcp-auth.test.ts +0 -310
- package/src/internal/cursor-account.integration.test.ts +0 -441
- package/src/internal/cursor-event-relay.test.ts +0 -746
- package/src/internal/cursor-github-credentials.integration.test.ts +0 -271
- package/src/internal/cursor-slack-relay.test.ts +0 -525
- package/src/internal/deploy-source.test.ts +0 -111
- package/src/internal/discovery.artifact-tool.test.ts +0 -136
- package/src/internal/discovery.artifacts.test.ts +0 -119
- package/src/internal/discovery.builtin-tools.test.ts +0 -94
- package/src/internal/discovery.concurrency.test.ts +0 -60
- package/src/internal/discovery.cursor-account.test.ts +0 -133
- package/src/internal/discovery.cwd.test.ts +0 -83
- package/src/internal/discovery.hosting.test.ts +0 -80
- package/src/internal/discovery.identity.test.ts +0 -44
- package/src/internal/docs-site.test.ts +0 -66
- package/src/internal/duration.test.ts +0 -29
- package/src/internal/eval-judge-model.test.ts +0 -187
- package/src/internal/eval-run-store.cancel.test.ts +0 -142
- package/src/internal/eval-run-store.storage.test.ts +0 -211
- package/src/internal/eval-runner.http.test.ts +0 -403
- package/src/internal/eval-runner.run.test.ts +0 -928
- package/src/internal/evals-client.test.ts +0 -307
- package/src/internal/event-mapper.test.ts +0 -243
- package/src/internal/github-fanout.test.ts +0 -213
- package/src/internal/handleAgentServeTrigger.test.ts +0 -185
- package/src/internal/host-kv.test.ts +0 -82
- package/src/internal/host-platforms.test.ts +0 -126
- package/src/internal/http-channel.test.ts +0 -402
- package/src/internal/init-project.test.ts +0 -270
- package/src/internal/install-cursor-skills.test.ts +0 -262
- package/src/internal/local-env.test.ts +0 -120
- package/src/internal/log-ring.test.ts +0 -31
- package/src/internal/logs-client.test.ts +0 -350
- package/src/internal/mcp-endpoint.test.ts +0 -436
- package/src/internal/mcp-host.test.ts +0 -298
- package/src/internal/mcp-oauth.test.ts +0 -148
- package/src/internal/net.test.ts +0 -17
- package/src/internal/peer-connections.test.ts +0 -128
- package/src/internal/peer-mcp.integration.test.ts +0 -289
- package/src/internal/playground/toolchain.test.ts +0 -53
- package/src/internal/playground-cli.test.ts +0 -187
- package/src/internal/playground-proxy.test.ts +0 -376
- package/src/internal/prompt-context.integration.test.ts +0 -232
- package/src/internal/prompt-context.test.ts +0 -127
- package/src/internal/reminder-runner.test.ts +0 -390
- package/src/internal/reminder-store.test.ts +0 -53
- package/src/internal/request-headers.test.ts +0 -27
- package/src/internal/resolve-prod-target.test.ts +0 -787
- package/src/internal/resolved-connections.test.ts +0 -295
- package/src/internal/router.test.ts +0 -57
- package/src/internal/sdk-runner.test.ts +0 -290
- package/src/internal/server.artifacts.test.ts +0 -303
- package/src/internal/session-engine.artifacts.test.ts +0 -243
- package/src/internal/session-engine.coalesce.test.ts +0 -169
- package/src/internal/session-engine.concurrency.test.ts +0 -250
- package/src/internal/session-engine.host-oauth-mcp.test.ts +0 -110
- package/src/internal/session-engine.interrupt.test.ts +0 -577
- package/src/internal/session-engine.storage.test.ts +0 -547
- package/src/internal/session-urls.test.ts +0 -28
- package/src/internal/sessions-client.test.ts +0 -518
- package/src/internal/storage-coordinator.test.ts +0 -517
- package/src/internal/tool-call.test.ts +0 -458
- package/src/internal/tool-result.test.ts +0 -52
- package/src/internal/trajectory.approvals.test.ts +0 -83
- package/src/internal/trajectory.subagents.test.ts +0 -198
- package/src/internal/turn-governor.test.ts +0 -137
- package/src/internal/update-check.test.ts +0 -485
- package/src/internal/workspace.test.ts +0 -207
- package/src/storage-backends/cursor-hosted.test.ts +0 -121
|
@@ -1,211 +0,0 @@
|
|
|
1
|
-
import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises";
|
|
2
|
-
import { tmpdir } from "node:os";
|
|
3
|
-
import { join } from "node:path";
|
|
4
|
-
import { afterEach, describe, expect, it } from "vitest";
|
|
5
|
-
import type { EvalRunSnapshot } from "../evals.js";
|
|
6
|
-
import { defineStorage } from "../storage.js";
|
|
7
|
-
import { EvalRunStore } from "./eval-run-store.js";
|
|
8
|
-
import { StorageCoordinator } from "./storage-coordinator.js";
|
|
9
|
-
|
|
10
|
-
function completedRun(runId: string): EvalRunSnapshot {
|
|
11
|
-
return {
|
|
12
|
-
runId,
|
|
13
|
-
status: "completed",
|
|
14
|
-
startedAt: "2026-01-01T00:00:00.000Z",
|
|
15
|
-
finishedAt: "2026-01-01T00:00:01.000Z",
|
|
16
|
-
summary: { passed: 1, failed: 0, total: 1, done: 1 },
|
|
17
|
-
cases: [],
|
|
18
|
-
config: { maxPlaygroundRuns: 20, durableRuns: true },
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
describe("EvalRunStore defineStorage hydrate", () => {
|
|
23
|
-
let dir: string | undefined;
|
|
24
|
-
|
|
25
|
-
afterEach(async () => {
|
|
26
|
-
if (dir !== undefined) {
|
|
27
|
-
await rm(dir, { recursive: true, force: true });
|
|
28
|
-
dir = undefined;
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it("hydrates playground history from the defineStorage evals table", async () => {
|
|
33
|
-
dir = await mkdtemp(join(tmpdir(), "agent-serve-eval-storage-"));
|
|
34
|
-
await mkdir(join(dir, "evals"), { recursive: true });
|
|
35
|
-
await writeFile(
|
|
36
|
-
join(dir, "evals", "evals.config.js"),
|
|
37
|
-
"export default { maxConcurrency: 1 };\n",
|
|
38
|
-
"utf8"
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
const table = new Map<string, EvalRunSnapshot>();
|
|
42
|
-
const coordinator = new StorageCoordinator({
|
|
43
|
-
definition: defineStorage({
|
|
44
|
-
put: () => {},
|
|
45
|
-
evals: {
|
|
46
|
-
put: (run) => {
|
|
47
|
-
table.set(run.runId, run);
|
|
48
|
-
},
|
|
49
|
-
delete: (runId) => {
|
|
50
|
-
table.delete(runId);
|
|
51
|
-
},
|
|
52
|
-
list: () => [...table.values()],
|
|
53
|
-
},
|
|
54
|
-
}),
|
|
55
|
-
agentName: "test-agent",
|
|
56
|
-
projectRoot: dir,
|
|
57
|
-
logger: () => {},
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
const storage = coordinator.evalRuns();
|
|
61
|
-
expect(storage).toBeDefined();
|
|
62
|
-
storage!.save(completedRun("evalrun_from_sink"));
|
|
63
|
-
await coordinator.whenIdle();
|
|
64
|
-
|
|
65
|
-
const store = new EvalRunStore(dir, () => {}, coordinator.evalRuns());
|
|
66
|
-
await store.hydrate();
|
|
67
|
-
const listed = await store.listRuns();
|
|
68
|
-
expect(listed).toHaveLength(1);
|
|
69
|
-
expect(listed[0]?.runId).toBe("evalrun_from_sink");
|
|
70
|
-
expect(listed[0]?.status).toBe("completed");
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it("marks interrupted running batches as failed on hydrate", async () => {
|
|
74
|
-
dir = await mkdtemp(join(tmpdir(), "agent-serve-eval-storage-"));
|
|
75
|
-
await mkdir(join(dir, "evals"), { recursive: true });
|
|
76
|
-
await writeFile(
|
|
77
|
-
join(dir, "evals", "evals.config.js"),
|
|
78
|
-
"export default { maxConcurrency: 1 };\n",
|
|
79
|
-
"utf8"
|
|
80
|
-
);
|
|
81
|
-
|
|
82
|
-
const interrupted: EvalRunSnapshot = {
|
|
83
|
-
...completedRun("evalrun_interrupted"),
|
|
84
|
-
status: "running",
|
|
85
|
-
finishedAt: undefined,
|
|
86
|
-
cases: [
|
|
87
|
-
{ id: "smoke", fileId: "smoke", status: "running" },
|
|
88
|
-
{ id: "other", fileId: "other", status: "pending" },
|
|
89
|
-
],
|
|
90
|
-
};
|
|
91
|
-
const saved: EvalRunSnapshot[] = [];
|
|
92
|
-
const store = new EvalRunStore(dir, () => {}, {
|
|
93
|
-
save: (run) => {
|
|
94
|
-
saved.push(structuredClone(run));
|
|
95
|
-
},
|
|
96
|
-
delete: () => {},
|
|
97
|
-
list: async () => [interrupted],
|
|
98
|
-
});
|
|
99
|
-
await store.hydrate();
|
|
100
|
-
|
|
101
|
-
const listed = await store.listRuns();
|
|
102
|
-
expect(listed[0]?.status).toBe("failed");
|
|
103
|
-
expect(listed[0]?.cases.every((c) => c.status === "done")).toBe(true);
|
|
104
|
-
// The summary is reconciled with the repaired case rows (both cases
|
|
105
|
-
// were interrupted, so nothing passed) instead of keeping stale counts.
|
|
106
|
-
expect(listed[0]?.summary).toEqual({
|
|
107
|
-
passed: 0,
|
|
108
|
-
failed: 2,
|
|
109
|
-
scored: 0,
|
|
110
|
-
skipped: 0,
|
|
111
|
-
total: 2,
|
|
112
|
-
done: 2,
|
|
113
|
-
});
|
|
114
|
-
// The repaired snapshot was written back to storage.
|
|
115
|
-
expect(saved.map((run) => run.runId)).toContain("evalrun_interrupted");
|
|
116
|
-
expect(saved.at(-1)?.status).toBe("failed");
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
it("prunes hydrated history even when eval discovery fails", async () => {
|
|
120
|
-
dir = await mkdtemp(join(tmpdir(), "agent-serve-eval-storage-"));
|
|
121
|
-
await mkdir(join(dir, "evals"), { recursive: true });
|
|
122
|
-
// Discovery throws at hydrate time; pruning must still run with the
|
|
123
|
-
// default playground-history window (20).
|
|
124
|
-
await writeFile(
|
|
125
|
-
join(dir, "evals", "broken.eval.js"),
|
|
126
|
-
"throw new Error('boom');\n",
|
|
127
|
-
"utf8"
|
|
128
|
-
);
|
|
129
|
-
|
|
130
|
-
const stored = Array.from({ length: 25 }, (_, i) => ({
|
|
131
|
-
...completedRun(`evalrun_${String(i).padStart(2, "0")}`),
|
|
132
|
-
startedAt: `2026-01-01T00:${String(i).padStart(2, "0")}:00.000Z`,
|
|
133
|
-
}));
|
|
134
|
-
const deleted: string[] = [];
|
|
135
|
-
const store = new EvalRunStore(dir, () => {}, {
|
|
136
|
-
save: () => {},
|
|
137
|
-
delete: (runId) => {
|
|
138
|
-
deleted.push(runId);
|
|
139
|
-
},
|
|
140
|
-
list: async () => stored,
|
|
141
|
-
});
|
|
142
|
-
await store.hydrate();
|
|
143
|
-
|
|
144
|
-
const listed = await store.listRuns();
|
|
145
|
-
expect(listed).toHaveLength(20);
|
|
146
|
-
expect(deleted).toHaveLength(5);
|
|
147
|
-
// Oldest five (by startedAt) were pruned.
|
|
148
|
-
expect(deleted.sort()).toEqual([
|
|
149
|
-
"evalrun_00",
|
|
150
|
-
"evalrun_01",
|
|
151
|
-
"evalrun_02",
|
|
152
|
-
"evalrun_03",
|
|
153
|
-
"evalrun_04",
|
|
154
|
-
]);
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
it("close() durably marks an in-flight batch as interrupted", async () => {
|
|
158
|
-
dir = await mkdtemp(join(tmpdir(), "agent-serve-eval-storage-"));
|
|
159
|
-
await mkdir(join(dir, "evals"), { recursive: true });
|
|
160
|
-
await writeFile(
|
|
161
|
-
join(dir, "evals", "evals.config.js"),
|
|
162
|
-
"export default { maxConcurrency: 1 };\n",
|
|
163
|
-
"utf8"
|
|
164
|
-
);
|
|
165
|
-
|
|
166
|
-
const running: EvalRunSnapshot = {
|
|
167
|
-
...completedRun("evalrun_active"),
|
|
168
|
-
status: "running",
|
|
169
|
-
finishedAt: undefined,
|
|
170
|
-
summary: { passed: 1, failed: 0, total: 2, done: 1 },
|
|
171
|
-
cases: [
|
|
172
|
-
{ id: "done", fileId: "done", status: "done", ok: true },
|
|
173
|
-
{ id: "midway", fileId: "midway", status: "running" },
|
|
174
|
-
],
|
|
175
|
-
};
|
|
176
|
-
const saved: EvalRunSnapshot[] = [];
|
|
177
|
-
const store = new EvalRunStore(dir, () => {}, {
|
|
178
|
-
save: (run) => {
|
|
179
|
-
saved.push(structuredClone(run));
|
|
180
|
-
},
|
|
181
|
-
delete: () => {},
|
|
182
|
-
list: async () => [running],
|
|
183
|
-
});
|
|
184
|
-
await store.hydrate();
|
|
185
|
-
// hydrate already repaired it; reset to a live in-flight shape.
|
|
186
|
-
const run = (await store.listRuns())[0]!;
|
|
187
|
-
run.status = "running";
|
|
188
|
-
run.error = undefined;
|
|
189
|
-
run.cases[1]!.status = "running";
|
|
190
|
-
run.cases[1]!.ok = undefined;
|
|
191
|
-
run.cases[1]!.error = undefined;
|
|
192
|
-
(store as unknown as { activeRunId?: string }).activeRunId = run.runId;
|
|
193
|
-
saved.length = 0;
|
|
194
|
-
|
|
195
|
-
store.close();
|
|
196
|
-
|
|
197
|
-
expect(saved).toHaveLength(1);
|
|
198
|
-
expect(saved[0]?.status).toBe("failed");
|
|
199
|
-
expect(saved[0]?.summary).toEqual({
|
|
200
|
-
passed: 1,
|
|
201
|
-
failed: 1,
|
|
202
|
-
scored: 0,
|
|
203
|
-
skipped: 0,
|
|
204
|
-
total: 2,
|
|
205
|
-
done: 2,
|
|
206
|
-
});
|
|
207
|
-
// Idempotent: a second close has nothing left to write.
|
|
208
|
-
store.close();
|
|
209
|
-
expect(saved).toHaveLength(1);
|
|
210
|
-
});
|
|
211
|
-
});
|
|
@@ -1,403 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Runs the eval runner against a real HTTP agent stub.
|
|
3
|
-
*
|
|
4
|
-
* `eval-runner.run.test.ts` mocks the session transport to cover grading logic;
|
|
5
|
-
* this file keeps the transport real, so the assertions are graded from events
|
|
6
|
-
* that actually arrived over the NDJSON session stream. That is the part a mock
|
|
7
|
-
* cannot prove.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import { createServer, type Server } from "node:http";
|
|
11
|
-
import type { AddressInfo } from "node:net";
|
|
12
|
-
import { afterEach, describe, expect, it } from "vitest";
|
|
13
|
-
import type { EvalDefinition, EvalRunResult } from "../evals.js";
|
|
14
|
-
import { defineEval, includes } from "../evals.js";
|
|
15
|
-
import type { SessionEvent } from "../types.js";
|
|
16
|
-
import { expandEvalModule, runDiscoveredEvals } from "./eval-runner.js";
|
|
17
|
-
|
|
18
|
-
interface StubAgent {
|
|
19
|
-
url: string;
|
|
20
|
-
/** Messages the runner sent, in order. */
|
|
21
|
-
received: string[];
|
|
22
|
-
close(): Promise<void>;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/** One scripted turn: the events the stub streams back for that message. */
|
|
26
|
-
type TurnScript = (message: string, turnId: string) => ScriptedEvent[];
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* A scripted event without its envelope cursor; `appendTurn` fills in
|
|
30
|
-
* `sessionId` and `index`. Loosely typed on purpose: the stub composes events
|
|
31
|
-
* generically, which the `type`/`data` discriminated union cannot express.
|
|
32
|
-
*/
|
|
33
|
-
interface ScriptedEvent {
|
|
34
|
-
at: string;
|
|
35
|
-
turnId?: string;
|
|
36
|
-
type: string;
|
|
37
|
-
data: unknown;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
async function startStubAgent(script: TurnScript): Promise<StubAgent> {
|
|
41
|
-
const received: string[] = [];
|
|
42
|
-
const sessions = new Map<string, SessionEvent[]>();
|
|
43
|
-
let nextSession = 0;
|
|
44
|
-
let nextTurn = 0;
|
|
45
|
-
|
|
46
|
-
const appendTurn = (sessionId: string, message: string): void => {
|
|
47
|
-
const events = sessions.get(sessionId)!;
|
|
48
|
-
nextTurn++;
|
|
49
|
-
for (const event of script(message, `turn_${nextTurn}`)) {
|
|
50
|
-
// `index` is the monotonic per-session cursor a client reconnects with
|
|
51
|
-
// via `?startIndex=`, so it must be the event's position in this session.
|
|
52
|
-
events.push({
|
|
53
|
-
...event,
|
|
54
|
-
sessionId,
|
|
55
|
-
index: events.length,
|
|
56
|
-
} as SessionEvent);
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
const server: Server = createServer((req, res) => {
|
|
61
|
-
const url = new URL(req.url ?? "/", "http://127.0.0.1");
|
|
62
|
-
const chunks: Buffer[] = [];
|
|
63
|
-
req.on("data", (chunk: Buffer) => chunks.push(chunk));
|
|
64
|
-
req.on("end", () => {
|
|
65
|
-
const body =
|
|
66
|
-
chunks.length === 0
|
|
67
|
-
? {}
|
|
68
|
-
: (JSON.parse(Buffer.concat(chunks).toString("utf8")) as {
|
|
69
|
-
message?: string;
|
|
70
|
-
});
|
|
71
|
-
const streamMatch = /^\/v1\/session\/([^/]+)\/stream$/.exec(url.pathname);
|
|
72
|
-
if (streamMatch !== null) {
|
|
73
|
-
const events = sessions.get(streamMatch[1]!) ?? [];
|
|
74
|
-
const startIndex = Number(url.searchParams.get("startIndex") ?? "0");
|
|
75
|
-
res.writeHead(200, { "content-type": "application/x-ndjson" });
|
|
76
|
-
for (const event of events.slice(startIndex)) {
|
|
77
|
-
res.write(`${JSON.stringify(event)}\n`);
|
|
78
|
-
}
|
|
79
|
-
res.end();
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
if (url.pathname === "/v1/session") {
|
|
83
|
-
nextSession++;
|
|
84
|
-
const sessionId = `ses_${nextSession}`;
|
|
85
|
-
sessions.set(sessionId, []);
|
|
86
|
-
received.push(body.message ?? "");
|
|
87
|
-
appendTurn(sessionId, body.message ?? "");
|
|
88
|
-
res.writeHead(200, { "content-type": "application/json" });
|
|
89
|
-
res.end(
|
|
90
|
-
JSON.stringify({ ok: true, sessionId, continuationToken: "tok_1" })
|
|
91
|
-
);
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
const followUp = /^\/v1\/session\/([^/]+)$/.exec(url.pathname);
|
|
95
|
-
if (followUp !== null) {
|
|
96
|
-
received.push(body.message ?? "");
|
|
97
|
-
appendTurn(followUp[1]!, body.message ?? "");
|
|
98
|
-
res.writeHead(200, { "content-type": "application/json" });
|
|
99
|
-
res.end(JSON.stringify({ ok: true, continuationToken: "tok_2" }));
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
res.writeHead(404).end();
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
await new Promise<void>((resolve) => server.listen(0, "127.0.0.1", resolve));
|
|
107
|
-
const { port } = server.address() as AddressInfo;
|
|
108
|
-
return {
|
|
109
|
-
url: `http://127.0.0.1:${port}`,
|
|
110
|
-
received,
|
|
111
|
-
close: () =>
|
|
112
|
-
new Promise<void>((resolve) => {
|
|
113
|
-
server.close(() => resolve());
|
|
114
|
-
}),
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
function event(
|
|
119
|
-
type: string,
|
|
120
|
-
data: unknown,
|
|
121
|
-
turnId: string | undefined
|
|
122
|
-
): ScriptedEvent {
|
|
123
|
-
return { at: new Date().toISOString(), turnId, type, data };
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/** A weather turn: one completed tool call, one reply, then park. */
|
|
127
|
-
const weatherScript: TurnScript = (message, turnId) => [
|
|
128
|
-
event("message.received", { text: message }, turnId),
|
|
129
|
-
event(
|
|
130
|
-
"actions.requested",
|
|
131
|
-
{
|
|
132
|
-
calls: [
|
|
133
|
-
{
|
|
134
|
-
callId: `${turnId}_c1`,
|
|
135
|
-
toolName: "get_weather",
|
|
136
|
-
args: { city: "NYC" },
|
|
137
|
-
},
|
|
138
|
-
],
|
|
139
|
-
},
|
|
140
|
-
turnId
|
|
141
|
-
),
|
|
142
|
-
event(
|
|
143
|
-
"action.result",
|
|
144
|
-
{
|
|
145
|
-
callId: `${turnId}_c1`,
|
|
146
|
-
toolName: "get_weather",
|
|
147
|
-
output: { tempF: 72 },
|
|
148
|
-
isError: false,
|
|
149
|
-
},
|
|
150
|
-
turnId
|
|
151
|
-
),
|
|
152
|
-
event(
|
|
153
|
-
"message.completed",
|
|
154
|
-
{ text: "Sunny, 72F in NYC.", finishReason: "stop" },
|
|
155
|
-
turnId
|
|
156
|
-
),
|
|
157
|
-
event("turn.completed", {}, turnId),
|
|
158
|
-
event("session.waiting", {}, undefined),
|
|
159
|
-
];
|
|
160
|
-
|
|
161
|
-
let stub: StubAgent | undefined;
|
|
162
|
-
|
|
163
|
-
afterEach(async () => {
|
|
164
|
-
await stub?.close();
|
|
165
|
-
stub = undefined;
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
async function run(
|
|
169
|
-
definition: EvalDefinition,
|
|
170
|
-
baseUrl: string
|
|
171
|
-
): Promise<EvalRunResult[]> {
|
|
172
|
-
return runDiscoveredEvals({
|
|
173
|
-
projectRoot: "/unused",
|
|
174
|
-
baseUrl,
|
|
175
|
-
discovered: {
|
|
176
|
-
evals: expandEvalModule("http", definition).map((e) => ({
|
|
177
|
-
id: e.id,
|
|
178
|
-
fileId: "http",
|
|
179
|
-
path: "/repo/evals/http.eval.ts",
|
|
180
|
-
definition: e.definition,
|
|
181
|
-
})),
|
|
182
|
-
config: { maxConcurrency: 2 },
|
|
183
|
-
},
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
describe("runner over a real session stream", () => {
|
|
188
|
-
it("grades assertions from events that arrived over HTTP", async () => {
|
|
189
|
-
stub = await startStubAgent(weatherScript);
|
|
190
|
-
const [result] = await run(
|
|
191
|
-
defineEval({
|
|
192
|
-
async test(t) {
|
|
193
|
-
await t.send("What is the weather in NYC?");
|
|
194
|
-
t.succeeded();
|
|
195
|
-
t.calledTool("get_weather", {
|
|
196
|
-
input: { city: "NYC" },
|
|
197
|
-
output: { tempF: 72 },
|
|
198
|
-
status: "completed",
|
|
199
|
-
count: 1,
|
|
200
|
-
});
|
|
201
|
-
t.noFailedActions();
|
|
202
|
-
t.messageIncludes("Sunny");
|
|
203
|
-
t.check(t.reply, includes("72F"));
|
|
204
|
-
t.maxToolCalls(1);
|
|
205
|
-
},
|
|
206
|
-
}),
|
|
207
|
-
stub.url
|
|
208
|
-
);
|
|
209
|
-
expect(result?.verdict).toBe("passed");
|
|
210
|
-
expect(result?.assertions.every((a) => a.passed)).toBe(true);
|
|
211
|
-
expect(stub.received).toEqual(["What is the weather in NYC?"]);
|
|
212
|
-
// The transport-derived views the CLI and playground print.
|
|
213
|
-
expect(result?.tools).toEqual(["get_weather"]);
|
|
214
|
-
expect(result?.toolCalls).toEqual([
|
|
215
|
-
{
|
|
216
|
-
toolName: "get_weather",
|
|
217
|
-
args: { city: "NYC" },
|
|
218
|
-
output: { tempF: 72 },
|
|
219
|
-
isError: false,
|
|
220
|
-
},
|
|
221
|
-
]);
|
|
222
|
-
expect(result?.finalText).toBe("Sunny, 72F in NYC.");
|
|
223
|
-
expect(result?.sessionId).toBe("ses_1");
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
it("resumes the stream so a second send reads the second turn", async () => {
|
|
227
|
-
// Each turn replies with the message it received and calls a distinct tool,
|
|
228
|
-
// so a send that replayed the earlier turn would be unmistakable. The
|
|
229
|
-
// stream replays from an index and stops at the first terminal event, so
|
|
230
|
-
// this is the regression test for resuming at the right cursor.
|
|
231
|
-
stub = await startStubAgent((message, turnId) => [
|
|
232
|
-
event("message.received", { text: message }, turnId),
|
|
233
|
-
event(
|
|
234
|
-
"actions.requested",
|
|
235
|
-
{
|
|
236
|
-
calls: [
|
|
237
|
-
{ callId: `${turnId}_c1`, toolName: `tool_${message}`, args: {} },
|
|
238
|
-
],
|
|
239
|
-
},
|
|
240
|
-
turnId
|
|
241
|
-
),
|
|
242
|
-
event(
|
|
243
|
-
"action.result",
|
|
244
|
-
{
|
|
245
|
-
callId: `${turnId}_c1`,
|
|
246
|
-
toolName: `tool_${message}`,
|
|
247
|
-
output: "ok",
|
|
248
|
-
isError: false,
|
|
249
|
-
},
|
|
250
|
-
turnId
|
|
251
|
-
),
|
|
252
|
-
event(
|
|
253
|
-
"message.completed",
|
|
254
|
-
{ text: `reply to ${message}`, finishReason: "stop" },
|
|
255
|
-
turnId
|
|
256
|
-
),
|
|
257
|
-
event("turn.completed", {}, turnId),
|
|
258
|
-
event("session.waiting", {}, undefined),
|
|
259
|
-
]);
|
|
260
|
-
|
|
261
|
-
const [result] = await run(
|
|
262
|
-
defineEval({
|
|
263
|
-
async test(t) {
|
|
264
|
-
const first = await t.send("first");
|
|
265
|
-
t.check(first.message, includes("reply to first"));
|
|
266
|
-
|
|
267
|
-
const second = await t.send("second");
|
|
268
|
-
t.check(second.message, includes("reply to second"));
|
|
269
|
-
t.check(t.reply, includes("reply to second"));
|
|
270
|
-
|
|
271
|
-
// Each turn sees only its own tool call.
|
|
272
|
-
first.calledTool("tool_first", { count: 1 });
|
|
273
|
-
first.notCalledTool("tool_second");
|
|
274
|
-
second.calledTool("tool_second", { count: 1 });
|
|
275
|
-
second.notCalledTool("tool_first");
|
|
276
|
-
|
|
277
|
-
// The run sees both, exactly once each.
|
|
278
|
-
t.calledTool("tool_first", { count: 1 });
|
|
279
|
-
t.calledTool("tool_second", { count: 1 });
|
|
280
|
-
t.maxToolCalls(2);
|
|
281
|
-
t.toolOrder(["tool_first", "tool_second"]);
|
|
282
|
-
t.check(second.sessionId, includes(first.sessionId));
|
|
283
|
-
},
|
|
284
|
-
}),
|
|
285
|
-
stub.url
|
|
286
|
-
);
|
|
287
|
-
expect(result?.verdict).toBe("passed");
|
|
288
|
-
const failed = result!.assertions.filter((a) => !a.passed);
|
|
289
|
-
expect(failed).toEqual([]);
|
|
290
|
-
expect(stub.received).toEqual(["first", "second"]);
|
|
291
|
-
expect(result?.inputs).toEqual(["first", "second"]);
|
|
292
|
-
expect(result?.finalText).toBe("reply to second");
|
|
293
|
-
});
|
|
294
|
-
|
|
295
|
-
it("fails a run whose turn failed on the wire", async () => {
|
|
296
|
-
stub = await startStubAgent((message, turnId) => [
|
|
297
|
-
event("message.received", { text: message }, turnId),
|
|
298
|
-
event("turn.failed", { message: "provider unavailable" }, turnId),
|
|
299
|
-
event("session.waiting", {}, undefined),
|
|
300
|
-
]);
|
|
301
|
-
const [result] = await run(
|
|
302
|
-
defineEval({
|
|
303
|
-
async test(t) {
|
|
304
|
-
await t.send("hello");
|
|
305
|
-
t.succeeded();
|
|
306
|
-
},
|
|
307
|
-
}),
|
|
308
|
-
stub.url
|
|
309
|
-
);
|
|
310
|
-
expect(result?.verdict).toBe("failed");
|
|
311
|
-
expect(result?.assertions[0]).toMatchObject({
|
|
312
|
-
name: "succeeded",
|
|
313
|
-
passed: false,
|
|
314
|
-
detail: "provider unavailable",
|
|
315
|
-
});
|
|
316
|
-
});
|
|
317
|
-
|
|
318
|
-
it("detects a run parked on an unanswered approval request", async () => {
|
|
319
|
-
stub = await startStubAgent((message, turnId) => [
|
|
320
|
-
event("message.received", { text: message }, turnId),
|
|
321
|
-
event(
|
|
322
|
-
"actions.requested",
|
|
323
|
-
{
|
|
324
|
-
calls: [{ callId: "c1", toolName: "deploy", args: { env: "prod" } }],
|
|
325
|
-
},
|
|
326
|
-
turnId
|
|
327
|
-
),
|
|
328
|
-
event(
|
|
329
|
-
"action.approval_requested",
|
|
330
|
-
{ callId: "c1", toolName: "deploy", args: { env: "prod" } },
|
|
331
|
-
turnId
|
|
332
|
-
),
|
|
333
|
-
event("session.waiting", {}, undefined),
|
|
334
|
-
]);
|
|
335
|
-
const [result] = await run(
|
|
336
|
-
defineEval({
|
|
337
|
-
async test(t) {
|
|
338
|
-
await t.send("deploy to prod");
|
|
339
|
-
t.parked();
|
|
340
|
-
const request = t.requireInputRequest({ toolName: "deploy" });
|
|
341
|
-
t.check(request.args, includes("prod"));
|
|
342
|
-
t.calledTool("deploy", { status: "pending", count: 1 });
|
|
343
|
-
},
|
|
344
|
-
}),
|
|
345
|
-
stub.url
|
|
346
|
-
);
|
|
347
|
-
expect(result?.verdict).toBe("passed");
|
|
348
|
-
expect(result?.assertions.map((a) => a.passed)).toEqual([
|
|
349
|
-
true,
|
|
350
|
-
true,
|
|
351
|
-
true,
|
|
352
|
-
true,
|
|
353
|
-
]);
|
|
354
|
-
});
|
|
355
|
-
|
|
356
|
-
it("records a failed tool call without failing the turn", async () => {
|
|
357
|
-
stub = await startStubAgent((message, turnId) => [
|
|
358
|
-
event("message.received", { text: message }, turnId),
|
|
359
|
-
event(
|
|
360
|
-
"actions.requested",
|
|
361
|
-
{
|
|
362
|
-
calls: [
|
|
363
|
-
{ callId: "c1", toolName: "bash", args: { command: "false" } },
|
|
364
|
-
],
|
|
365
|
-
},
|
|
366
|
-
turnId
|
|
367
|
-
),
|
|
368
|
-
event(
|
|
369
|
-
"action.result",
|
|
370
|
-
{ callId: "c1", toolName: "bash", output: "exit 1", isError: true },
|
|
371
|
-
turnId
|
|
372
|
-
),
|
|
373
|
-
event(
|
|
374
|
-
"message.completed",
|
|
375
|
-
{ text: "That command failed.", finishReason: "stop" },
|
|
376
|
-
turnId
|
|
377
|
-
),
|
|
378
|
-
event("turn.completed", {}, turnId),
|
|
379
|
-
event("session.waiting", {}, undefined),
|
|
380
|
-
]);
|
|
381
|
-
const [result] = await run(
|
|
382
|
-
defineEval({
|
|
383
|
-
async test(t) {
|
|
384
|
-
await t.send("run false");
|
|
385
|
-
t.succeeded();
|
|
386
|
-
t.calledTool("bash", { status: "failed", count: 1 });
|
|
387
|
-
t.noFailedActions();
|
|
388
|
-
},
|
|
389
|
-
}),
|
|
390
|
-
stub.url
|
|
391
|
-
);
|
|
392
|
-
expect(result?.verdict).toBe("failed");
|
|
393
|
-
const byName = new Map(result!.assertions.map((a) => [a.name, a]));
|
|
394
|
-
expect(byName.get("succeeded")?.passed).toBe(true);
|
|
395
|
-
expect(
|
|
396
|
-
byName.get("calledTool(bash, {status=failed, count=1})")?.passed
|
|
397
|
-
).toBe(true);
|
|
398
|
-
expect(byName.get("noFailedActions")).toMatchObject({
|
|
399
|
-
passed: false,
|
|
400
|
-
detail: "bash",
|
|
401
|
-
});
|
|
402
|
-
});
|
|
403
|
-
});
|