@cursor/july 0.1.22 → 0.1.24
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 +5 -5
- package/dist/bin/agent-serve.d.ts +1 -0
- package/dist/bin/agent-serve.d.ts.map +1 -1
- package/dist/bin/agent-serve.js +21 -3
- package/dist/docs/404.html +2 -2
- package/dist/docs/ab.html +3 -3
- package/dist/docs/assets/{app.BKNKMLp4.js → app.CvSGaAxk.js} +1 -1
- package/dist/docs/assets/chunks/@localSearchIndexroot.CL2Y0Zmh.js +1 -0
- package/dist/docs/assets/chunks/{VPLocalSearchBox.sOSfEZR6.js → VPLocalSearchBox.J1jJbCvs.js} +1 -1
- package/dist/docs/assets/chunks/{theme.BvCHT5lj.js → theme.C7vfzr7h.js} +2 -2
- package/dist/docs/assets/index.md.Dfv5ic9t.js +20 -0
- package/dist/docs/assets/{index.md.t0TM2Qzz.lean.js → index.md.Dfv5ic9t.lean.js} +1 -1
- package/dist/docs/assets/{reference_cli.md.DnYfr5V2.js → reference_cli.md.ccoKOoXt.js} +4 -3
- package/dist/docs/assets/{reference_cli.md.DnYfr5V2.lean.js → reference_cli.md.ccoKOoXt.lean.js} +1 -1
- package/dist/docs/building-with-agents.html +3 -3
- package/dist/docs/concepts.html +3 -3
- package/dist/docs/deployment.html +3 -3
- package/dist/docs/evals.html +3 -3
- package/dist/docs/example-agents/approval-buddy.html +3 -3
- package/dist/docs/example-agents/benny.html +3 -3
- package/dist/docs/example-agents/bugbot.html +3 -3
- package/dist/docs/example-agents/codebase-wiki.html +3 -3
- package/dist/docs/example-agents/codeowners-review.html +3 -3
- package/dist/docs/example-agents/concierge.html +3 -3
- package/dist/docs/example-agents/fsd.html +3 -3
- package/dist/docs/example-agents/index.html +3 -3
- package/dist/docs/example-agents/knowledge-base.html +3 -3
- package/dist/docs/example-agents/oncall.html +3 -3
- package/dist/docs/example-agents/security-reviewer.html +3 -3
- package/dist/docs/example-agents/slack-agent.html +3 -3
- package/dist/docs/example-agents/weather-agent.html +3 -3
- package/dist/docs/guides/agent-to-agent.html +3 -3
- package/dist/docs/guides/cloud-runtime.html +3 -3
- package/dist/docs/guides/github.html +3 -3
- package/dist/docs/guides/human-in-the-loop.html +3 -3
- package/dist/docs/guides/mcp-oauth.html +3 -3
- package/dist/docs/guides/slack.html +3 -3
- package/dist/docs/guides/webhooks.html +3 -3
- package/dist/docs/hashmap.json +1 -1
- package/dist/docs/hillclimbing.html +3 -3
- package/dist/docs/index.html +6 -6
- package/dist/docs/quickstart.html +3 -3
- package/dist/docs/reference/agent-config.html +3 -3
- package/dist/docs/reference/channels.html +3 -3
- package/dist/docs/reference/cli.html +7 -6
- package/dist/docs/reference/connections.html +3 -3
- package/dist/docs/reference/hooks.html +3 -3
- package/dist/docs/reference/http-api.html +3 -3
- package/dist/docs/reference/instructions.html +3 -3
- package/dist/docs/reference/playground.html +3 -3
- package/dist/docs/reference/project-layout.html +3 -3
- package/dist/docs/reference/prompt.html +3 -3
- package/dist/docs/reference/schedules.html +3 -3
- package/dist/docs/reference/sessions.html +3 -3
- package/dist/docs/reference/skills.html +3 -3
- package/dist/docs/reference/subagents.html +3 -3
- package/dist/docs/reference/tools.html +3 -3
- package/dist/docs/scaffolding-agents.html +3 -3
- package/dist/docs/storage.html +3 -3
- package/dist/docs/troubleshooting.html +3 -3
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/internal/cli-docs.d.ts +34 -0
- package/dist/internal/cli-docs.d.ts.map +1 -0
- package/dist/internal/cli-docs.js +162 -0
- package/dist/internal/distribution.d.ts +2 -1
- package/dist/internal/distribution.d.ts.map +1 -1
- package/dist/internal/distribution.js +3 -1
- package/dist/internal/docs-site.d.ts +4 -2
- package/dist/internal/docs-site.d.ts.map +1 -1
- package/dist/internal/docs-site.js +15 -11
- package/dist/internal/init-project.d.ts.map +1 -1
- package/dist/internal/init-project.js +19 -0
- package/dist/internal/session-engine.d.ts.map +1 -1
- package/dist/internal/session-engine.js +5 -0
- package/dist/internal/workspace.d.ts +9 -0
- package/dist/internal/workspace.d.ts.map +1 -1
- package/dist/internal/workspace.js +52 -5
- package/dist/memory.d.ts +79 -0
- package/dist/memory.d.ts.map +1 -0
- package/dist/memory.js +164 -0
- package/dist/playground/assets/index-CidizGZv.css +1 -0
- package/dist/playground/assets/index-DTG9OsPV.js +85 -0
- package/dist/playground/index.html +2 -2
- package/dist/types.d.ts +11 -0
- package/dist/types.d.ts.map +1 -1
- package/docs/README.md +8 -1
- package/docs/reference/cli.md +20 -4
- package/package.json +32 -24
- package/src/bin/agent-serve.ts +23 -3
- package/src/index.ts +2 -0
- package/src/internal/cli-docs.ts +191 -0
- package/src/internal/distribution.ts +3 -1
- package/src/internal/docs-site.ts +19 -11
- package/src/internal/init-project.ts +22 -0
- package/src/internal/session-engine.ts +5 -0
- package/src/internal/workspace.ts +81 -5
- package/src/memory.ts +215 -0
- package/src/types.ts +11 -0
- 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.YFE6WoMB.js +0 -1
- package/dist/docs/assets/index.md.t0TM2Qzz.js +0 -20
- 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-dshZQJCp.js +0 -85
- package/src/bin/agent-serve.version.test.ts +0 -62
- 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 -937
- 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 -580
- 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/authored-loaders.test.ts +0 -31
- 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-mcp.test.ts +0 -789
- package/src/internal/cli-skills.test.ts +0 -133
- package/src/internal/cli-slack.test.ts +0 -1647
- 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.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 -179
- 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 -269
- 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/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 -81
- package/src/storage-backends/cursor-hosted.test.ts +0 -121
|
@@ -1,580 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import type { SessionEvent } from "../types.js";
|
|
3
|
-
import {
|
|
4
|
-
computeVerdict,
|
|
5
|
-
createAssertions,
|
|
6
|
-
EvalAssertionRecorder,
|
|
7
|
-
EvalRequireFailure,
|
|
8
|
-
verdictFailsRun,
|
|
9
|
-
} from "./assertions.js";
|
|
10
|
-
import { equals, includes, similarity } from "./expect.js";
|
|
11
|
-
|
|
12
|
-
let sequence = 0;
|
|
13
|
-
|
|
14
|
-
function event(type: string, data: unknown, turnId = "turn_1"): SessionEvent {
|
|
15
|
-
sequence++;
|
|
16
|
-
return {
|
|
17
|
-
sessionId: "ses_1",
|
|
18
|
-
seq: sequence,
|
|
19
|
-
at: new Date(sequence * 1000).toISOString(),
|
|
20
|
-
turnId,
|
|
21
|
-
type,
|
|
22
|
-
data,
|
|
23
|
-
} as unknown as SessionEvent;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function weatherRun(): SessionEvent[] {
|
|
27
|
-
return [
|
|
28
|
-
event("message.received", { text: "weather in NYC?" }),
|
|
29
|
-
event("actions.requested", {
|
|
30
|
-
calls: [{ callId: "c1", toolName: "get_weather", args: { city: "NYC" } }],
|
|
31
|
-
}),
|
|
32
|
-
event("action.result", {
|
|
33
|
-
callId: "c1",
|
|
34
|
-
toolName: "get_weather",
|
|
35
|
-
output: { tempF: 72 },
|
|
36
|
-
isError: false,
|
|
37
|
-
}),
|
|
38
|
-
event("message.completed", { text: "Sunny, 72F", finishReason: "stop" }),
|
|
39
|
-
event("turn.completed", {}),
|
|
40
|
-
event("session.waiting", {}),
|
|
41
|
-
];
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function setup(events: SessionEvent[] = weatherRun()) {
|
|
45
|
-
const recorder = new EvalAssertionRecorder();
|
|
46
|
-
const t = createAssertions({ recorder, events: () => events });
|
|
47
|
-
return { recorder, t };
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
describe("severity handles", () => {
|
|
51
|
-
it("records gates by default and keeps the wire shape compact", () => {
|
|
52
|
-
const { recorder, t } = setup();
|
|
53
|
-
t.succeeded();
|
|
54
|
-
const [result] = recorder.results();
|
|
55
|
-
expect(result).toMatchObject({ name: "succeeded", passed: true });
|
|
56
|
-
// `gate` is the default everywhere, so it is omitted rather than repeated.
|
|
57
|
-
expect(result?.severity).toBeUndefined();
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it("demotes a gate to a tracked soft assertion", () => {
|
|
61
|
-
const { recorder, t } = setup();
|
|
62
|
-
t.calledTool("nope").soft();
|
|
63
|
-
const [result] = recorder.results();
|
|
64
|
-
expect(result?.severity).toBe("soft");
|
|
65
|
-
// The miss is still recorded honestly; being soft only means it does not
|
|
66
|
-
// decide the verdict, so the CLI shows `~` and the eval still passes.
|
|
67
|
-
expect(result?.passed).toBe(false);
|
|
68
|
-
expect(computeVerdict(recorder.results())).toBe("passed");
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
it("keeps a tracked score from failing the verdict when it has no bar", () => {
|
|
72
|
-
const { recorder, t } = setup();
|
|
73
|
-
t.check("Rainy", similarity("Sunny, 72F"));
|
|
74
|
-
expect(recorder.results()[0]?.passed).toBe(true);
|
|
75
|
-
expect(recorder.results()[0]?.score).toBeLessThan(0.5);
|
|
76
|
-
expect(computeVerdict(recorder.results())).toBe("passed");
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
it("scores an eval when a soft threshold is missed", () => {
|
|
80
|
-
const { recorder, t } = setup();
|
|
81
|
-
t.check("Rainy", similarity("Sunny, 72F")).atLeast(0.9);
|
|
82
|
-
const [result] = recorder.results();
|
|
83
|
-
expect(result?.severity).toBe("soft");
|
|
84
|
-
expect(result?.threshold).toBe(0.9);
|
|
85
|
-
expect(result?.passed).toBe(false);
|
|
86
|
-
expect(computeVerdict(recorder.results())).toBe("scored");
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it("passes a soft assertion that clears its bar", () => {
|
|
90
|
-
const { recorder, t } = setup();
|
|
91
|
-
t.check("Sunny, 72F", similarity("Sunny, 72F")).atLeast(0.9);
|
|
92
|
-
expect(recorder.results()[0]?.passed).toBe(true);
|
|
93
|
-
expect(computeVerdict(recorder.results())).toBe("passed");
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
it("promotes a score to a hard gate with .gate(threshold)", () => {
|
|
97
|
-
const { recorder, t } = setup();
|
|
98
|
-
t.check("Rainy", similarity("Sunny, 72F")).gate(0.9);
|
|
99
|
-
expect(recorder.results()[0]?.severity).toBeUndefined();
|
|
100
|
-
expect(computeVerdict(recorder.results())).toBe("failed");
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
it("converts a boolean assertion to a score when given a threshold", () => {
|
|
104
|
-
const { recorder, t } = setup();
|
|
105
|
-
t.calledTool("get_weather").gate(1);
|
|
106
|
-
expect(recorder.results()[0]?.passed).toBe(true);
|
|
107
|
-
const second = setup();
|
|
108
|
-
second.t.calledTool("missing").gate(1);
|
|
109
|
-
expect(second.recorder.results()[0]?.passed).toBe(false);
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
it("re-reads severity on the last call, so chains are order-independent", () => {
|
|
113
|
-
const { recorder, t } = setup();
|
|
114
|
-
t.check("Rainy", similarity("Sunny")).atLeast(0.9).soft();
|
|
115
|
-
// `.soft()` with no threshold keeps the 0.9 bar set by `.atLeast`.
|
|
116
|
-
expect(recorder.results()[0]?.threshold).toBe(0.9);
|
|
117
|
-
expect(computeVerdict(recorder.results())).toBe("scored");
|
|
118
|
-
});
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
describe("computeVerdict / verdictFailsRun", () => {
|
|
122
|
-
it("prefers a failed gate over a missed soft bar", () => {
|
|
123
|
-
expect(
|
|
124
|
-
computeVerdict([
|
|
125
|
-
{ name: "a", passed: false },
|
|
126
|
-
{ name: "b", passed: false, severity: "soft", threshold: 0.5 },
|
|
127
|
-
])
|
|
128
|
-
).toBe("failed");
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
it("treats an assertion with no severity as a gate", () => {
|
|
132
|
-
expect(computeVerdict([{ name: "legacy", passed: false }])).toBe("failed");
|
|
133
|
-
expect(computeVerdict([{ name: "legacy", passed: true }])).toBe("passed");
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
it("only fails the run on scored under --strict", () => {
|
|
137
|
-
expect(verdictFailsRun("scored", false)).toBe(false);
|
|
138
|
-
expect(verdictFailsRun("scored", true)).toBe(true);
|
|
139
|
-
expect(verdictFailsRun("failed", false)).toBe(true);
|
|
140
|
-
expect(verdictFailsRun("skipped", true)).toBe(false);
|
|
141
|
-
expect(verdictFailsRun("passed", true)).toBe(false);
|
|
142
|
-
});
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
describe("run-level assertions", () => {
|
|
146
|
-
it("succeeded passes a healthy run left open for the next message", () => {
|
|
147
|
-
const { recorder, t } = setup();
|
|
148
|
-
t.succeeded();
|
|
149
|
-
expect(recorder.results()[0]?.passed).toBe(true);
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
it("succeeded fails a run parked on an unanswered approval", () => {
|
|
153
|
-
const { recorder, t } = setup([
|
|
154
|
-
event("message.received", { text: "deploy" }),
|
|
155
|
-
event("actions.requested", {
|
|
156
|
-
calls: [{ callId: "c1", toolName: "deploy", args: {} }],
|
|
157
|
-
}),
|
|
158
|
-
event("action.approval_requested", { callId: "c1", toolName: "deploy" }),
|
|
159
|
-
event("session.waiting", {}),
|
|
160
|
-
]);
|
|
161
|
-
t.succeeded();
|
|
162
|
-
t.parked();
|
|
163
|
-
const [succeeded, parked] = recorder.results();
|
|
164
|
-
expect(succeeded?.passed).toBe(false);
|
|
165
|
-
expect(succeeded?.detail).toMatch(/unanswered approval/);
|
|
166
|
-
expect(parked?.passed).toBe(true);
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
it("calledTool defaults to request-based matching for compatibility", () => {
|
|
170
|
-
// A pending call still counts as "the agent used this tool".
|
|
171
|
-
const { recorder, t } = setup([
|
|
172
|
-
event("actions.requested", {
|
|
173
|
-
calls: [{ callId: "c1", toolName: "slow", args: {} }],
|
|
174
|
-
}),
|
|
175
|
-
event("turn.completed", {}),
|
|
176
|
-
]);
|
|
177
|
-
t.calledTool("slow");
|
|
178
|
-
t.calledTool("slow", { status: "completed" });
|
|
179
|
-
const [anyState, completed] = recorder.results();
|
|
180
|
-
expect(anyState?.passed).toBe(true);
|
|
181
|
-
expect(completed?.passed).toBe(false);
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
it("infers the parameter type of an inline matcher predicate", () => {
|
|
185
|
-
const { recorder, t } = setup();
|
|
186
|
-
// No annotation on `value`: the matcher union deliberately keeps its
|
|
187
|
-
// function member so this compiles under noImplicitAny.
|
|
188
|
-
t.calledTool("get_weather", {
|
|
189
|
-
input: (value) => (value as { city: string }).city === "NYC",
|
|
190
|
-
});
|
|
191
|
-
t.calledTool("get_weather", { count: (count) => count >= 1 });
|
|
192
|
-
// Nested inside an object literal, which is where a matcher predicate most
|
|
193
|
-
// often lands (`{ input: { field: predicate } }`).
|
|
194
|
-
t.calledTool("get_weather", {
|
|
195
|
-
input: { city: (value) => String(value).startsWith("NY") },
|
|
196
|
-
});
|
|
197
|
-
expect(recorder.results().map((r) => r.passed)).toEqual([true, true, true]);
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
it("narrows calledTool with input, output, and count matchers", () => {
|
|
201
|
-
const { recorder, t } = setup();
|
|
202
|
-
t.calledTool("get_weather", { input: { city: "NYC" }, count: 1 });
|
|
203
|
-
t.calledTool("get_weather", { output: { tempF: 72 } });
|
|
204
|
-
t.calledTool("get_weather", { input: { city: /^NY/ } });
|
|
205
|
-
t.calledTool("get_weather", { count: 2 });
|
|
206
|
-
const results = recorder.results();
|
|
207
|
-
expect(results.map((r) => r.passed)).toEqual([true, true, true, false]);
|
|
208
|
-
expect(results[0]?.name).toBe(
|
|
209
|
-
'calledTool(get_weather, {input={"city":"NYC"}, count=1})'
|
|
210
|
-
);
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
it("notCalledTool matches any lifecycle state", () => {
|
|
214
|
-
const { recorder, t } = setup();
|
|
215
|
-
t.notCalledTool("echo");
|
|
216
|
-
t.notCalledTool("get_weather");
|
|
217
|
-
expect(recorder.results().map((r) => r.passed)).toEqual([true, false]);
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
it("messageIncludes reads the joined assistant text", () => {
|
|
221
|
-
const { recorder, t } = setup([
|
|
222
|
-
event("message.completed", {
|
|
223
|
-
text: "part one",
|
|
224
|
-
finishReason: "tool_call",
|
|
225
|
-
}),
|
|
226
|
-
event("message.completed", { text: "part two", finishReason: "stop" }),
|
|
227
|
-
event("turn.completed", {}),
|
|
228
|
-
]);
|
|
229
|
-
t.messageIncludes("part one");
|
|
230
|
-
t.messageIncludes(/part two/);
|
|
231
|
-
t.messageIncludes("part three");
|
|
232
|
-
expect(recorder.results().map((r) => r.passed)).toEqual([
|
|
233
|
-
true,
|
|
234
|
-
true,
|
|
235
|
-
false,
|
|
236
|
-
]);
|
|
237
|
-
});
|
|
238
|
-
|
|
239
|
-
it("toolOrder allows unrelated calls between the required ones", () => {
|
|
240
|
-
const { recorder, t } = setup([
|
|
241
|
-
event("actions.requested", {
|
|
242
|
-
calls: [
|
|
243
|
-
{ callId: "a", toolName: "prepare", args: {} },
|
|
244
|
-
{ callId: "b", toolName: "unrelated", args: {} },
|
|
245
|
-
{ callId: "c", toolName: "finalize", args: {} },
|
|
246
|
-
],
|
|
247
|
-
}),
|
|
248
|
-
event("turn.completed", {}),
|
|
249
|
-
]);
|
|
250
|
-
t.toolOrder(["prepare", "finalize"]);
|
|
251
|
-
t.toolOrder(["finalize", "prepare"]);
|
|
252
|
-
const [forward, backward] = recorder.results();
|
|
253
|
-
expect(forward?.passed).toBe(true);
|
|
254
|
-
expect(backward?.passed).toBe(false);
|
|
255
|
-
expect(backward?.detail).toMatch(/missing prepare after position/);
|
|
256
|
-
});
|
|
257
|
-
|
|
258
|
-
it("usedNoTools, maxToolCalls, and noFailedActions read the whole run", () => {
|
|
259
|
-
const { recorder, t } = setup([
|
|
260
|
-
event("actions.requested", {
|
|
261
|
-
calls: [
|
|
262
|
-
{ callId: "a", toolName: "one", args: {} },
|
|
263
|
-
{ callId: "b", toolName: "two", args: {} },
|
|
264
|
-
],
|
|
265
|
-
}),
|
|
266
|
-
event("action.result", {
|
|
267
|
-
callId: "b",
|
|
268
|
-
toolName: "two",
|
|
269
|
-
output: "boom",
|
|
270
|
-
isError: true,
|
|
271
|
-
}),
|
|
272
|
-
event("turn.completed", {}),
|
|
273
|
-
]);
|
|
274
|
-
t.usedNoTools();
|
|
275
|
-
t.maxToolCalls(2);
|
|
276
|
-
t.maxToolCalls(1);
|
|
277
|
-
t.noFailedActions();
|
|
278
|
-
expect(recorder.results().map((r) => r.passed)).toEqual([
|
|
279
|
-
false,
|
|
280
|
-
true,
|
|
281
|
-
false,
|
|
282
|
-
false,
|
|
283
|
-
]);
|
|
284
|
-
expect(recorder.results()[3]?.detail).toBe("two");
|
|
285
|
-
});
|
|
286
|
-
|
|
287
|
-
it("calledSubagent matches identity, output, and status", () => {
|
|
288
|
-
const { recorder, t } = setup([
|
|
289
|
-
event("actions.requested", {
|
|
290
|
-
calls: [{ callId: "t1", toolName: "task", args: {} }],
|
|
291
|
-
}),
|
|
292
|
-
event("subagent.called", { callId: "t1", name: "research" }),
|
|
293
|
-
event("subagent.completed", { callId: "t1", name: "research" }),
|
|
294
|
-
event("action.result", {
|
|
295
|
-
callId: "t1",
|
|
296
|
-
toolName: "task",
|
|
297
|
-
output: "72F in NYC",
|
|
298
|
-
isError: false,
|
|
299
|
-
}),
|
|
300
|
-
event("turn.completed", {}),
|
|
301
|
-
]);
|
|
302
|
-
t.calledSubagent("research", { output: /72F/, status: "completed" });
|
|
303
|
-
t.calledSubagent("research", { count: 2 });
|
|
304
|
-
t.calledSubagent("other");
|
|
305
|
-
expect(recorder.results().map((r) => r.passed)).toEqual([
|
|
306
|
-
true,
|
|
307
|
-
false,
|
|
308
|
-
false,
|
|
309
|
-
]);
|
|
310
|
-
});
|
|
311
|
-
|
|
312
|
-
it("loadedSkill matches any tool call that opened the skill file", () => {
|
|
313
|
-
const { recorder, t } = setup([
|
|
314
|
-
event("actions.requested", {
|
|
315
|
-
calls: [
|
|
316
|
-
{
|
|
317
|
-
callId: "c1",
|
|
318
|
-
toolName: "read_file",
|
|
319
|
-
args: { path: ".cursor/skills/alert-investigation/SKILL.md" },
|
|
320
|
-
},
|
|
321
|
-
],
|
|
322
|
-
}),
|
|
323
|
-
event("turn.completed", {}),
|
|
324
|
-
]);
|
|
325
|
-
t.loadedSkill("alert-investigation");
|
|
326
|
-
t.loadedSkill("other-skill");
|
|
327
|
-
expect(recorder.results().map((r) => r.passed)).toEqual([true, false]);
|
|
328
|
-
});
|
|
329
|
-
});
|
|
330
|
-
|
|
331
|
-
describe("event assertions", () => {
|
|
332
|
-
it("matches presence, absence, data, and count", () => {
|
|
333
|
-
const { recorder, t } = setup();
|
|
334
|
-
t.event("turn.completed");
|
|
335
|
-
t.event("message.completed", { data: { text: /Sunny/ } });
|
|
336
|
-
t.event("message.completed", { count: 2 });
|
|
337
|
-
t.notEvent("turn.failed");
|
|
338
|
-
t.notEvent("turn.completed");
|
|
339
|
-
expect(recorder.results().map((r) => r.passed)).toEqual([
|
|
340
|
-
true,
|
|
341
|
-
true,
|
|
342
|
-
false,
|
|
343
|
-
true,
|
|
344
|
-
false,
|
|
345
|
-
]);
|
|
346
|
-
});
|
|
347
|
-
|
|
348
|
-
it("eventOrder requires matching groups in stream order", () => {
|
|
349
|
-
const { recorder, t } = setup();
|
|
350
|
-
t.eventOrder([
|
|
351
|
-
{ type: "actions.requested" },
|
|
352
|
-
{ type: "action.result" },
|
|
353
|
-
{ type: "turn.completed" },
|
|
354
|
-
]);
|
|
355
|
-
t.eventOrder([{ type: "turn.completed" }, { type: "actions.requested" }]);
|
|
356
|
-
expect(recorder.results().map((r) => r.passed)).toEqual([true, false]);
|
|
357
|
-
});
|
|
358
|
-
|
|
359
|
-
it("eventOrder honors a numeric count per group", () => {
|
|
360
|
-
const { recorder, t } = setup([
|
|
361
|
-
event("subagent.called", { callId: "a", name: "r" }),
|
|
362
|
-
event("subagent.called", { callId: "b", name: "r" }),
|
|
363
|
-
event("turn.completed", {}),
|
|
364
|
-
]);
|
|
365
|
-
t.eventOrder([
|
|
366
|
-
{ type: "subagent.called", count: 2 },
|
|
367
|
-
{ type: "turn.completed" },
|
|
368
|
-
]);
|
|
369
|
-
t.eventOrder([
|
|
370
|
-
{ type: "subagent.called", count: 3 },
|
|
371
|
-
{ type: "turn.completed" },
|
|
372
|
-
]);
|
|
373
|
-
expect(recorder.results().map((r) => r.passed)).toEqual([true, false]);
|
|
374
|
-
});
|
|
375
|
-
|
|
376
|
-
it("eventsSatisfy records a predicate throw as a failure detail", () => {
|
|
377
|
-
const { recorder, t } = setup();
|
|
378
|
-
t.eventsSatisfy("has a reply", (events) =>
|
|
379
|
-
events.some((e) => e.type === "message.completed")
|
|
380
|
-
);
|
|
381
|
-
t.eventsSatisfy("throws", () => {
|
|
382
|
-
throw new Error("bad predicate");
|
|
383
|
-
});
|
|
384
|
-
const results = recorder.results();
|
|
385
|
-
expect(results[0]?.passed).toBe(true);
|
|
386
|
-
expect(results[1]).toMatchObject({
|
|
387
|
-
passed: false,
|
|
388
|
-
detail: "bad predicate",
|
|
389
|
-
});
|
|
390
|
-
});
|
|
391
|
-
});
|
|
392
|
-
|
|
393
|
-
describe("require* lookups", () => {
|
|
394
|
-
it("requireToolCall returns the matching call", () => {
|
|
395
|
-
const { recorder, t } = setup();
|
|
396
|
-
const call = t.requireToolCall("get_weather");
|
|
397
|
-
expect(call.output).toEqual({ tempF: 72 });
|
|
398
|
-
expect(recorder.results()[0]?.passed).toBe(true);
|
|
399
|
-
});
|
|
400
|
-
|
|
401
|
-
it("requireToolCall records a gate and stops the body when nothing matches", () => {
|
|
402
|
-
const { recorder, t } = setup();
|
|
403
|
-
expect(() => t.requireToolCall("missing")).toThrow(EvalRequireFailure);
|
|
404
|
-
expect(recorder.results()[0]).toMatchObject({
|
|
405
|
-
name: "requireToolCall(missing)",
|
|
406
|
-
passed: false,
|
|
407
|
-
});
|
|
408
|
-
});
|
|
409
|
-
|
|
410
|
-
it("requireInputRequest demands exactly one pending approval", () => {
|
|
411
|
-
const { recorder, t } = setup([
|
|
412
|
-
event("actions.requested", {
|
|
413
|
-
calls: [{ callId: "c1", toolName: "deploy", args: { env: "prod" } }],
|
|
414
|
-
}),
|
|
415
|
-
event("action.approval_requested", {
|
|
416
|
-
callId: "c1",
|
|
417
|
-
toolName: "deploy",
|
|
418
|
-
args: { env: "prod" },
|
|
419
|
-
}),
|
|
420
|
-
event("session.waiting", {}),
|
|
421
|
-
]);
|
|
422
|
-
const request = t.requireInputRequest({ toolName: "deploy" });
|
|
423
|
-
expect(request.args).toEqual({ env: "prod" });
|
|
424
|
-
expect(() => t.requireInputRequest({ toolName: "other" })).toThrow(
|
|
425
|
-
EvalRequireFailure
|
|
426
|
-
);
|
|
427
|
-
expect(recorder.results()[1]?.detail).toMatch(/found 0/);
|
|
428
|
-
});
|
|
429
|
-
});
|
|
430
|
-
|
|
431
|
-
describe("turn scoping", () => {
|
|
432
|
-
it("prefixes turn assertions and narrows them to that turn's events", () => {
|
|
433
|
-
const recorder = new EvalAssertionRecorder();
|
|
434
|
-
const firstTurn = [
|
|
435
|
-
event("actions.requested", {
|
|
436
|
-
calls: [{ callId: "c1", toolName: "search", args: {} }],
|
|
437
|
-
}),
|
|
438
|
-
event("message.completed", { text: "draft", finishReason: "stop" }),
|
|
439
|
-
event("turn.completed", {}),
|
|
440
|
-
];
|
|
441
|
-
const secondTurn = [
|
|
442
|
-
event("actions.requested", {
|
|
443
|
-
calls: [{ callId: "c2", toolName: "send_email", args: {} }],
|
|
444
|
-
}),
|
|
445
|
-
event(
|
|
446
|
-
"message.completed",
|
|
447
|
-
{ text: "sent", finishReason: "stop" },
|
|
448
|
-
"turn_2"
|
|
449
|
-
),
|
|
450
|
-
event("turn.completed", {}, "turn_2"),
|
|
451
|
-
];
|
|
452
|
-
const turnOne = createAssertions({
|
|
453
|
-
recorder,
|
|
454
|
-
events: () => firstTurn,
|
|
455
|
-
scope: "turn[1]",
|
|
456
|
-
});
|
|
457
|
-
const run = createAssertions({
|
|
458
|
-
recorder,
|
|
459
|
-
events: () => [...firstTurn, ...secondTurn],
|
|
460
|
-
});
|
|
461
|
-
|
|
462
|
-
turnOne.calledTool("search");
|
|
463
|
-
turnOne.notCalledTool("send_email");
|
|
464
|
-
run.calledTool("send_email");
|
|
465
|
-
|
|
466
|
-
const results = recorder.results();
|
|
467
|
-
expect(results.map((r) => r.name)).toEqual([
|
|
468
|
-
"turn[1].calledTool(search)",
|
|
469
|
-
"turn[1].notCalledTool(send_email)",
|
|
470
|
-
"calledTool(send_email)",
|
|
471
|
-
]);
|
|
472
|
-
expect(results.map((r) => r.passed)).toEqual([true, true, true]);
|
|
473
|
-
expect(results[0]?.scope).toBe("turn[1]");
|
|
474
|
-
expect(results[2]?.scope).toBeUndefined();
|
|
475
|
-
});
|
|
476
|
-
});
|
|
477
|
-
|
|
478
|
-
describe("score", () => {
|
|
479
|
-
it("records a tracked score that does not gate until given a bar", () => {
|
|
480
|
-
const { recorder, t } = setup();
|
|
481
|
-
t.score("recall", 0.4);
|
|
482
|
-
expect(recorder.results()[0]).toMatchObject({
|
|
483
|
-
name: "score(recall)",
|
|
484
|
-
severity: "soft",
|
|
485
|
-
score: 0.4,
|
|
486
|
-
passed: true,
|
|
487
|
-
});
|
|
488
|
-
expect(computeVerdict(recorder.results())).toBe("passed");
|
|
489
|
-
});
|
|
490
|
-
|
|
491
|
-
it("marks the eval scored once the score misses its bar", () => {
|
|
492
|
-
const { recorder, t } = setup();
|
|
493
|
-
t.score("recall", 0.4).atLeast(0.6);
|
|
494
|
-
expect(recorder.results()[0]?.passed).toBe(false);
|
|
495
|
-
expect(computeVerdict(recorder.results())).toBe("scored");
|
|
496
|
-
});
|
|
497
|
-
|
|
498
|
-
it("can be promoted to a hard gate", () => {
|
|
499
|
-
const { recorder, t } = setup();
|
|
500
|
-
t.score("recall", 0.4).gate(0.6);
|
|
501
|
-
expect(computeVerdict(recorder.results())).toBe("failed");
|
|
502
|
-
});
|
|
503
|
-
|
|
504
|
-
it("fails loudly on a non-finite score rather than reporting NaN", () => {
|
|
505
|
-
const { recorder, t } = setup();
|
|
506
|
-
t.score("recall", Number.NaN);
|
|
507
|
-
expect(recorder.results()[0]).toMatchObject({
|
|
508
|
-
passed: false,
|
|
509
|
-
score: undefined,
|
|
510
|
-
detail: "score is not a finite number: NaN",
|
|
511
|
-
});
|
|
512
|
-
});
|
|
513
|
-
});
|
|
514
|
-
|
|
515
|
-
describe("check", () => {
|
|
516
|
-
it("keeps the historical assertion name so output stays stable", () => {
|
|
517
|
-
const { recorder, t } = setup();
|
|
518
|
-
t.check("Sunny, 72F", includes("Sunny"));
|
|
519
|
-
t.check(72, equals(72));
|
|
520
|
-
expect(recorder.results().map((r) => r.name)).toEqual([
|
|
521
|
-
"check(includes)",
|
|
522
|
-
"check(equals)",
|
|
523
|
-
]);
|
|
524
|
-
});
|
|
525
|
-
});
|
|
526
|
-
|
|
527
|
-
describe("recordAsync", () => {
|
|
528
|
-
it("fills the slot in when the async score settles", async () => {
|
|
529
|
-
const recorder = new EvalAssertionRecorder();
|
|
530
|
-
recorder
|
|
531
|
-
.recordAsync(
|
|
532
|
-
{ name: "judge.closedQA(x)", passed: true, severity: "soft" },
|
|
533
|
-
Promise.resolve({ passed: true, score: 0.4, detail: "N (0.40)" })
|
|
534
|
-
)
|
|
535
|
-
.atLeast(0.6);
|
|
536
|
-
await recorder.waitForPending();
|
|
537
|
-
expect(recorder.results()[0]).toMatchObject({
|
|
538
|
-
severity: "soft",
|
|
539
|
-
score: 0.4,
|
|
540
|
-
threshold: 0.6,
|
|
541
|
-
passed: false,
|
|
542
|
-
detail: "N (0.40)",
|
|
543
|
-
});
|
|
544
|
-
expect(computeVerdict(recorder.results())).toBe("scored");
|
|
545
|
-
});
|
|
546
|
-
|
|
547
|
-
it("turns a rejected score into a failed gate with the error message", async () => {
|
|
548
|
-
const recorder = new EvalAssertionRecorder();
|
|
549
|
-
recorder
|
|
550
|
-
.recordAsync(
|
|
551
|
-
{ name: "judge.factuality(x)", passed: true, severity: "soft" },
|
|
552
|
-
Promise.reject(new Error("judge reply had no choice"))
|
|
553
|
-
)
|
|
554
|
-
.atLeast(0.7);
|
|
555
|
-
await recorder.waitForPending();
|
|
556
|
-
expect(recorder.results()[0]).toMatchObject({
|
|
557
|
-
passed: false,
|
|
558
|
-
detail: "judge reply had no choice",
|
|
559
|
-
});
|
|
560
|
-
// Grading errors must not hide behind soft severity.
|
|
561
|
-
expect(recorder.results()[0]?.severity).toBeUndefined();
|
|
562
|
-
expect(computeVerdict(recorder.results())).toBe("failed");
|
|
563
|
-
});
|
|
564
|
-
|
|
565
|
-
it("waits for judges started while an earlier judge was settling", async () => {
|
|
566
|
-
const recorder = new EvalAssertionRecorder();
|
|
567
|
-
recorder.recordAsync(
|
|
568
|
-
{ name: "first", passed: true, severity: "soft" },
|
|
569
|
-
Promise.resolve({}).then(() => {
|
|
570
|
-
recorder.recordAsync(
|
|
571
|
-
{ name: "second", passed: true, severity: "soft" },
|
|
572
|
-
Promise.resolve({ score: 1 })
|
|
573
|
-
);
|
|
574
|
-
return { score: 1 };
|
|
575
|
-
})
|
|
576
|
-
);
|
|
577
|
-
await recorder.waitForPending();
|
|
578
|
-
expect(recorder.results().map((r) => r.score)).toEqual([1, 1]);
|
|
579
|
-
});
|
|
580
|
-
});
|