create-curb 1.30.0-preview.11 → 1.30.0-preview.13

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/RELEASE_NOTES.md CHANGED
@@ -1,6 +1,7 @@
1
1
 
2
2
  ### Added
3
3
 
4
+ - Curb test --live, --dry and --max-tokens, and per-scenario reply store results (#179)
4
5
  - Curb check reads scenarios, instruction text and mcp.tools.json (#178)
5
6
  - Curb test answers each model request it has seen before from a reply store (#177)
6
7
  - Hermetic test runs, and curb mcp snapshot (#176)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-curb",
3
- "version": "1.30.0-preview.11",
3
+ "version": "1.30.0-preview.13",
4
4
  "description": "Create a Curb voice agent with one command. Voice agents your coding agent can build and improve.",
5
5
  "keywords": [
6
6
  "curb",
@@ -27,10 +27,10 @@ const LAST_HOUR = 16;
27
27
  const SERVICES = ["haircut", "coloring", "styling", "manicure"] as const;
28
28
 
29
29
  const pad = (n: number) => String(n).padStart(2, "0");
30
- const hours = Array.from({ length: LAST_HOUR - FIRST_HOUR + 1 }, (_, i) => `${pad(FIRST_HOUR + i)}:00`);
30
+ export const hours = Array.from({ length: LAST_HOUR - FIRST_HOUR + 1 }, (_, i) => `${pad(FIRST_HOUR + i)}:00`);
31
31
 
32
32
  /** The studio is closed on weekends: an ISO date (YYYY-MM-DD) is open on weekdays only. */
33
- const isOpenDay = (date: string) => {
33
+ export const isOpenDay = (date: string) => {
34
34
  const day = new Date(`${date}T00:00:00Z`).getUTCDay();
35
35
  return day !== 0 && day !== 6;
36
36
  };
@@ -1,4 +1,5 @@
1
1
  import { personas, scenario } from "curb/testing";
2
+ import { bookingFakes } from "./fakes.js";
2
3
 
3
4
  /**
4
5
  * A simulated caller with a goal: `curb test` plays the caller on a second model, and a judge
@@ -6,8 +7,7 @@ import { personas, scenario } from "curb/testing";
6
7
  * more patient and clearer than the people who really call.
7
8
  *
8
9
  * The checks say what must be true when the call is over, not which way the agent took there:
9
- * Lena may offer slots in one question or in three. Either way one haircut for Alex is in the
10
- * calendar at the end.
10
+ * Lena may offer slots in one question or in three. Either way she books one haircut for Alex.
11
11
  */
12
12
  export default scenario({
13
13
  name: "books a haircut on a bad line",
@@ -22,11 +22,17 @@ export default scenario({
22
22
  // a scripted scenario needs neither: the same words run once and must pass.
23
23
  runs: 3,
24
24
  minPassRate: 0.66,
25
- // Every run runs the agent's tools for real. Here they only change this call's own calendar.
26
- // A tool that writes to a real calendar gets a fake:
27
- // fakes: { book_appointment: { ok: true, message: "Booked as B-1." } }
25
+ // A fake answers in place of each tool, so no run reaches a real booking system.
26
+ fakes: bookingFakes,
28
27
  // A judge answers each sentence with yes, no or unknown, and quotes the turn that shows it.
29
28
  expectations: ["The agent says the appointment is booked only after its book_appointment call succeeded."],
30
- // The agent's state at the end of the call: one haircut for Alex, and nothing else.
31
- expect: ({ stateMatches }) => [stateMatches("lena", { appointments: [{ service: "haircut", name: /alex/i }] })],
29
+ // One haircut for Alex. A fake books nothing for real, so the checks read the calls: the
30
+ // booking that succeeded, and that it was the only one.
31
+ expect: ({ called, check, transcript }) => {
32
+ const booked = transcript.flatMap((turn) => turn.toolCalls).filter((call) => call.name === "book_appointment" && call.ok);
33
+ return [
34
+ called("book_appointment", { service: "haircut", name: /alex/i }),
35
+ check("booked exactly once", booked.length === 1, `book_appointment succeeded ${booked.length} times`),
36
+ ];
37
+ },
32
38
  });
@@ -0,0 +1,25 @@
1
+ import { hours, isOpenDay } from "./agent.js";
2
+ import { isPersonName } from "./calendar.js";
3
+
4
+ /**
5
+ * The fakes this agent's scenarios share. `curb test --hermetic` (the CI workflow) runs no tool
6
+ * without a fake, so a test never reaches a real booking system. Each fake answers the way the
7
+ * real tool does on an empty calendar, with the same checks of the name, the day and the time;
8
+ * replace them with what your tests need.
9
+ */
10
+ export const bookingFakes = {
11
+ list_free_slots: (input: Record<string, unknown>) => {
12
+ const date = String(input.date);
13
+ if (!isOpenDay(date)) return { ok: true, message: `Closed on ${date}: no free slots.` };
14
+ return { ok: true, message: `Free on ${date}: ${hours.join(", ")}.` };
15
+ },
16
+ book_appointment: (input: Record<string, unknown>) => {
17
+ if (!isPersonName(String(input.name))) {
18
+ return { ok: false, message: `"${String(input.name)}" is not a name. Ask the caller for their name, then book with it.` };
19
+ }
20
+ if (!isOpenDay(String(input.date)) || !hours.includes(String(input.time))) {
21
+ return { ok: false, message: "That is outside opening hours. Offer another slot from list_free_slots." };
22
+ }
23
+ return { ok: true, message: "Booked as B-1. Read the day, time and booking number back to the caller." };
24
+ },
25
+ };
@@ -1,18 +1,21 @@
1
1
  import { scenario } from "curb/testing";
2
+ import { bookingFakes } from "./fakes.js";
2
3
 
3
4
  /**
4
5
  * Scripted caller lines: the same words on every run, so this is a gate. It runs once and must
5
6
  * pass. Keep one of these for every path that must never break.
6
7
  *
7
8
  * The price list exists only in the services skill, so a reply that states the price shows the
8
- * skill was read: no check needs to name the tool.
9
+ * skill was read: no check needs to name the tool. The fakes keep a stray booking off any real
10
+ * calendar.
9
11
  */
10
12
  export default scenario({
11
13
  name: "answers a price question without booking",
12
14
  turns: ["Hi, what does a haircut cost?", "Okay, thanks. I will think about it."],
13
- expect: ({ said, stateMatches }) => [
15
+ fakes: bookingFakes,
16
+ expect: ({ said, notCalled }) => [
14
17
  said(/38|thirty[- ]eight/i),
15
18
  // A question about prices books nothing.
16
- stateMatches("lena", { appointments: [] }),
19
+ notCalled("book_appointment"),
17
20
  ],
18
21
  });
@@ -8,6 +8,23 @@ name: curb test
8
8
  # Without that secret the job fails on a pull request from this repository and on a run started
9
9
  # by hand, so a missing key never passes as green. A pull request from a fork gets no secrets, so
10
10
  # the scenarios are skipped there and only `curb check` runs.
11
+ #
12
+ # The reply store keeps every model reply the scenarios got, by the exact request, in
13
+ # ~/.cache/curb/replies, so a scenario whose requests did not change gets its replies from there
14
+ # and calls no model: a rerun with no change makes no model call at all, and a change pays only
15
+ # from the turn it touched. A CI job starts with an empty store; keep it between runs one of
16
+ # two ways:
17
+ #
18
+ # - The Actions cache, off until the repository variable CURB_REPLY_CACHE is "true" (Settings >
19
+ # Secrets and variables > Actions > Variables). Any run in this repository can read what the
20
+ # default branch cached, a pull request from a fork that edits this workflow too. The store
21
+ # keeps each request only as a hash, but its replies hold the agent's answers with the
22
+ # arguments of every tool it called, what the simulated callers said and the judge's verdicts,
23
+ # and a reply can repeat what its request held (a tool result, a line of the prompt). Turn it
24
+ # on only when all of that is made-up test data you would publish.
25
+ # - A remote reply store that asks for a token (docs: reply-store.md, "Sharing a store"): set
26
+ # the variable CURB_REPLY_STORE_URL and the secret CURB_REPLY_STORE_TOKEN. A fork gets no
27
+ # secrets, so it cannot read it. Use this when the replies hold anything private.
11
28
 
12
29
  on:
13
30
  pull_request:
@@ -26,6 +43,8 @@ jobs:
26
43
  timeout-minutes: 30
27
44
  env:
28
45
  KUGELAUDIO_API_KEY: ${{ secrets.KUGELAUDIO_API_KEY }}
46
+ CURB_REPLY_STORE_URL: ${{ vars.CURB_REPLY_STORE_URL }}
47
+ CURB_REPLY_STORE_TOKEN: ${{ secrets.CURB_REPLY_STORE_TOKEN }}
29
48
  # CPU binaries ship in npm; this skips a download the tests do not need.
30
49
  ONNXRUNTIME_NODE_INSTALL: skip
31
50
  steps:
@@ -42,12 +61,31 @@ jobs:
42
61
  node-version: 22
43
62
  - run: npm ci
44
63
  - run: npx curb check
64
+ # restore-keys brings back the newest store this branch or the base branch saved.
65
+ - name: Restore the reply store
66
+ if: vars.CURB_REPLY_CACHE == 'true' && env.KUGELAUDIO_API_KEY != ''
67
+ uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
68
+ with:
69
+ path: ~/.cache/curb/replies
70
+ key: curb-replies-${{ github.run_id }}-${{ github.run_attempt }}
71
+ restore-keys: curb-replies-
45
72
  # Each scenario says how often it runs and how many runs must pass (runs, minPassRate).
46
- # The report lands in the job summary.
47
- - name: npx curb test
73
+ # The report lands in the job summary, with each scenario's replies: stored, or live from
74
+ # the turn where a request changed. --hermetic runs no tool without a fake: a scenario that
75
+ # calls a tool it does not fake fails, so no test reaches a real system. Give a new tool a
76
+ # fake in every scenario that may call it.
77
+ - name: npx curb test --hermetic
48
78
  if: env.KUGELAUDIO_API_KEY != ''
49
- run: npx curb test
79
+ run: npx curb test --hermetic
50
80
  # To take the simulated caller and the judge off the agent's provider, run them on OpenAI
51
81
  # with OPENAI_API_KEY as a repository secret: replace the run line above with these two.
52
82
  # env: { OPENAI_API_KEY: "${{ secrets.OPENAI_API_KEY }}" }
53
- # run: npx curb test --caller-model openai:gpt-5.4-mini --judge-model openai:gpt-5.4-mini
83
+ # run: npx curb test --hermetic --caller-model openai:gpt-5.4-mini --judge-model openai:gpt-5.4-mini
84
+ # A new key on every run, so each run saves the replies it added, also when a scenario
85
+ # failed: a stored reply is kept whether or not the test passed.
86
+ - name: Save the reply store
87
+ if: always() && vars.CURB_REPLY_CACHE == 'true' && env.KUGELAUDIO_API_KEY != ''
88
+ uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
89
+ with:
90
+ path: ~/.cache/curb/replies
91
+ key: curb-replies-${{ github.run_id }}-${{ github.run_attempt }}
@@ -73,7 +73,9 @@ A fault in Curb itself is reported as `reporting-a-bug.md` says, with the person
73
73
  `error` says nothing about the agent (the provider failed, or the simulated caller went
74
74
  wrong). After changing an `expect` or an expectation, `npx curb test --rejudge latest`
75
75
  checks the saved conversations again without running the agent. Keep one scenario per
76
- flow that matters, and fake every tool that books, sends or deletes (`testing.md`).
76
+ flow that matters. CI runs `npx curb test --hermetic`, where a scenario that calls a tool
77
+ without a fake fails: give every tool a scenario may call a fake there, and check the call
78
+ (`called`, `notCalled`) instead of the state the real tool would have changed (`testing.md`).
77
79
  When the ready-made checks do not cover what the team needs, build on the same functions
78
80
  (`testing-foundation.md`, "Build your own tests").
79
81
 
@@ -119,13 +121,16 @@ what really happened.
119
121
  src/agent/agent.tsx the agent, where every conversation starts: <Agent llm stt tts>,
120
122
  system prompt, skills index, tools every skill has, store
121
123
  src/agent/<name>/skill.tsx one folder per skill, opened when needed; nested folders are sub-skills
122
- src/agent/*.scenario.ts conversations `curb test` plays: a caller, and what must hold afterwards
124
+ src/agent/<name>/tools.ts a skill's tools as defineTool values, imported by the skill and its tests
125
+ src/agent/**/*.scenario.ts conversations `curb test` plays: a caller, and what must hold afterwards;
126
+ one in a skill's folder (<name>/<name>.scenario.ts) can start inside it
123
127
  context/*.md knowledge a skill reads with <Text src="file.md" />
124
128
  .env other providers' keys, an optional KUGELAUDIO_API_KEY; never commit it
125
129
  .data/conversations.jsonl every preview conversation: tool calls, inputs, results
126
130
  .curb/test-runs/ every `curb test` run with its conversations, for --rejudge (format: test-runs.md)
127
131
  .github/workflows/ curb-test.yml runs check and test on each pull request; it needs
128
- KUGELAUDIO_API_KEY as a repository secret
132
+ KUGELAUDIO_API_KEY as a repository secret, and keeps the reply store
133
+ once the repository opts in (comments at its top)
129
134
  ```
130
135
 
131
136
  ## Rules
@@ -48,9 +48,20 @@ model plays. `npx curb test --runs 3` plays each three times and reports how oft
48
48
  it passed, what a judge found and how the agent talks. Text tests do not cover audio, timing or
49
49
  interruptions: listen to a call in `npm run dev` for those.
50
50
 
51
- `.github/workflows/curb-test.yml` runs `curb check` and `curb test` on every pull request, and
52
- fails until the repository has `KUGELAUDIO_API_KEY` as a secret (Settings > Secrets and variables >
53
- Actions). Details: `node_modules/curb/docs/agent-guide/testing.md`.
51
+ `src/agent/calendar/calendar.scenario.ts` is a skill test: it starts inside the calendar skill
52
+ with a fixed date, fakes the skill's one tool, and is `hermetic`, so a tool it did not fake stops
53
+ the run instead of running. `npx curb test` keeps every model reply in a reply store, so a second
54
+ run with nothing changed answers from it and calls no model.
55
+
56
+ `.github/workflows/curb-test.yml` runs `curb check` and `curb test --hermetic` on every pull
57
+ request: every scenario fakes the tools it calls and checks the calls, so no test reaches a real
58
+ system. Give a new tool a fake in each scenario that may call it. The workflow fails until the
59
+ repository has `KUGELAUDIO_API_KEY` as a secret (Settings > Secrets and variables > Actions). It
60
+ keeps the reply store between runs only when you turn that on: with the repository variable
61
+ `CURB_REPLY_CACHE` set to `true` it uses the Actions cache, which any run in the repository can
62
+ read, a fork's pull request too, so do that only when the scenarios hold made-up data. For
63
+ anything private, use a remote reply store with a token (`CURB_REPLY_STORE_URL` and the secret
64
+ `CURB_REPLY_STORE_TOKEN`). Details: `node_modules/curb/docs/agent-guide/testing.md`.
54
65
 
55
66
  ## Deploy to KugelAudio
56
67
 
@@ -186,6 +186,7 @@ export function App() {
186
186
  You can:
187
187
  - keep the user's task list,
188
188
  - remember what they tell you about themselves,
189
+ - read their calendar,
189
190
  - explain how you are built.
190
191
 
191
192
  The task list changes only through its tools: call add_task, complete_task or remove_task first, and say a task is added or done only after the tool answered.
@@ -198,6 +199,7 @@ export function App() {
198
199
  {/* Each link's routing description is the target skill's meta.description. */}
199
200
  <Skills>
200
201
  <Skill path="/about-you">About you</Skill>
202
+ <Skill path="/calendar">Calendar</Skill>
201
203
  <Skill path="/how-this-works">How this works</Skill>
202
204
  </Skills>
203
205
  <DayPlanner />
@@ -0,0 +1,33 @@
1
+ import { fake, scenario } from "curb/testing";
2
+ import * as Calendar from "./skill.js";
3
+ import { listEvents } from "./tools.js";
4
+
5
+ /**
6
+ * A skill test: the call starts inside the calendar skill, so it needs no conversation to get
7
+ * there, and its one turn is typed text. Short tests like this are cheap to keep: `curb test`
8
+ * answers an unchanged request from its reply store, so this one calls a model again only after
9
+ * something it sends has changed (the skill, its tool, the agent's prompt).
10
+ *
11
+ * The skill, the tool and the info key are values TypeScript checks: a renamed tool, a fake
12
+ * result of the wrong shape or an info key the skill does not declare fails `curb check`.
13
+ */
14
+ export default scenario({
15
+ name: "reads the day's calendar",
16
+ start: { skills: [Calendar], info: { "user.name": "Sam" } },
17
+ spoken: false,
18
+ // Every tool call needs a fake: a call of a tool without one ends the run as an error before
19
+ // the tool runs, so this test never reaches a real calendar.
20
+ hermetic: true,
21
+ // The date the agent sees. 2026-10-30 is a Friday.
22
+ now: "2026-10-30T08:00:00Z",
23
+ turns: ["What's in my calendar today?"],
24
+ // TypeScript checks the result against what list_events returns.
25
+ fakes: [
26
+ fake(listEvents, {
27
+ ok: true,
28
+ message: "1 event(s) on 2026-10-30.",
29
+ data: { day: "2026-10-30", events: [{ time: "09:30", title: "Team stand-up" }] },
30
+ }),
31
+ ],
32
+ expect: ({ called, said, opened }) => [called(listEvents, { day: "2026-10-30" }), said(/stand-up/i), opened(Calendar)],
33
+ });
@@ -0,0 +1,29 @@
1
+ import { Instruction, Text, Tool, useAgentInfo, z, type SkillMeta } from "curb";
2
+ import { listEvents } from "./tools.js";
3
+
4
+ export const meta = {
5
+ title: "Calendar",
6
+ description: "Use when the user asks what is in their calendar, or when a meeting or appointment is.",
7
+ // The call info this skill reads. A host sets it before the call (set_info), a test in
8
+ // `start.info`; TypeScript checks both against this schema.
9
+ info: z.object({ "user.name": z.string().optional() }),
10
+ } satisfies SkillMeta;
11
+
12
+ /**
13
+ * A skill with its tools in tools.ts next to it, and a short test of its own in
14
+ * calendar.scenario.ts that starts the call inside this skill.
15
+ */
16
+ export default function Calendar() {
17
+ const info = useAgentInfo(meta);
18
+
19
+ return (
20
+ <>
21
+ <Instruction>{`
22
+ Look the day up with ${listEvents.name} before you say what is in the calendar, and name
23
+ each event with its time. The calendar is read-only: you cannot add or move events.
24
+ `}</Instruction>
25
+ {info["user.name"] ? <Text>{`This is ${info["user.name"]}'s calendar.`}</Text> : null}
26
+ <Tool {...listEvents} />
27
+ </>
28
+ );
29
+ }
@@ -0,0 +1,41 @@
1
+ import { defineTool, z } from "curb";
2
+
3
+ /**
4
+ * The calendar skill's tools, as values. The skill renders them with <Tool {...listEvents} />,
5
+ * an instruction names one as {listEvents.name}, and a test imports the same value: a renamed
6
+ * tool or a misspelled name fails `curb check` instead of a call.
7
+ */
8
+
9
+ export type CalendarEvent = { time: string; title: string };
10
+
11
+ const at = (hour: number, minute: number) => `${String(hour).padStart(2, "0")}:${String(minute).padStart(2, "0")}`;
12
+
13
+ /**
14
+ * Sample events, the same every weekday and none at the weekend. Replace this with a call to
15
+ * your calendar's API: a test fakes the tool, so it never reaches the real calendar.
16
+ */
17
+ function eventsOn(day: string): CalendarEvent[] {
18
+ const weekday = new Date(`${day}T12:00:00Z`).getUTCDay();
19
+ if (weekday === 0 || weekday === 6) return [];
20
+ return [
21
+ { time: at(9, 30), title: "Team stand-up" },
22
+ { time: at(14, 0), title: "Review the quarterly budget" },
23
+ ];
24
+ }
25
+
26
+ export const listEvents = defineTool({
27
+ name: "list_events",
28
+ description: "List the events in the user's calendar on one day.",
29
+ schema: z.object({
30
+ day: z.string().regex(/^\d{4}-\d{2}-\d{2}$/).describe("The day as YYYY-MM-DD. Work it out from today's date in your context."),
31
+ }),
32
+ // What this returns is the type a test's fake of the tool is checked against.
33
+ onSubmit: async ({ day }) => {
34
+ const events = eventsOn(day);
35
+ return {
36
+ ok: true as const,
37
+ message: events.length === 0 ? `Nothing in the calendar on ${day}.` : `${events.length} event(s) on ${day}.`,
38
+ data: { day, events },
39
+ };
40
+ },
41
+ });
@@ -27,6 +27,7 @@ export default function HowThisWorks() {
27
27
  - src/agent/agent.tsx is where every conversation starts: Juno's prompt, her task list and its tools are in her context from the first turn.
28
28
  - Each folder under src/agent/ is a skill: instructions and tools the model reads on demand. Reading this skill is how this answer came about.
29
29
  - The user's profile is the markdown file context/about-you.md, read by a Text component.
30
+ - The calendar skill keeps its tool in src/agent/calendar/tools.ts, and its own short test in calendar.scenario.ts starts the call inside that skill.
30
31
  - Tasks and remembered notes are shared React state: a tool call updates the store, the tree re-renders, and the model's context changes. Tasks on the list right now: ${tasks.length}. Remembered notes: ${notes.length}.
31
32
  - Wrapping up the day is gated structurally: the wrap_up_day tool does not exist in the model's context until a task is done.
32
33
  - Everything editable lives in src/agent/ and context/, and changes hot-reload into the running conversation.
@@ -1,5 +1,4 @@
1
1
  import { personas, scenario } from "curb/testing";
2
- import type { Task } from "./agent.js";
3
2
 
4
3
  /**
5
4
  * A simulated caller with a goal: `curb test` plays the caller on a second model, and a judge
@@ -22,14 +21,16 @@ export default scenario({
22
21
  // a scripted scenario needs neither: the same words run once and must pass.
23
22
  runs: 3,
24
23
  minPassRate: 0.66,
24
+ // `curb test --hermetic` (the CI workflow) runs no tool without a fake. A fake answers in
25
+ // place of the tool, so the checks below read the calls, not the list.
26
+ fakes: {
27
+ add_task: { ok: true },
28
+ complete_task: { ok: true },
29
+ remove_task: { ok: true, message: "Removed from the list." },
30
+ remember: { ok: true },
31
+ },
25
32
  // A judge answers each sentence with yes, no or unknown, and quotes the turn that shows it.
26
33
  expectations: ["The agent says a task is on the list only after its add_task call for that task succeeded."],
27
- // The agent's state at the end of the call: each of the three tasks is on the list, once.
28
- expect: ({ state, check }) => {
29
- const titles = state<{ tasks: Task[] }>("juno").tasks.map((task) => task.title);
30
- const listed = `the list holds: ${titles.join(", ") || "nothing"}`;
31
- return ["milk", "dentist", "invoice"].map((word) =>
32
- check(`one task about the ${word} is on the list`, titles.filter((title) => title.includes(word)).length === 1, listed),
33
- );
34
- },
34
+ // Each of the three tasks was added.
35
+ expect: ({ called }) => ["milk", "dentist", "invoice"].map((word) => called("add_task", { title: new RegExp(word, "i") })),
35
36
  });
@@ -1,12 +1,12 @@
1
1
  import { scenario } from "curb/testing";
2
- import type { Task } from "./agent.js";
3
2
 
4
3
  /**
5
4
  * Scripted caller lines: the same words on every run, so this is a gate. It runs once and must
6
5
  * pass. Keep one of these for every path that must never break.
7
6
  *
8
- * The task list changes only through its tools, so its state at the end says whether the right
9
- * tools ran: no check needs to name them.
7
+ * `curb test --hermetic` (the CI workflow) runs no tool without a fake, so this test fakes the
8
+ * list's tools and checks the calls the agent made: a fake answers in place of the tool, so the
9
+ * list itself stays empty. Each fake answers the way the real tool does.
10
10
  */
11
11
  export default scenario({
12
12
  name: "keeps the task list",
@@ -15,13 +15,18 @@ export default scenario({
15
15
  "I've called the dentist, that one is done.",
16
16
  "What is still open on my list?",
17
17
  ],
18
- expect: ({ state, check, transcript }) => {
19
- const { tasks } = state<{ tasks: Task[] }>("juno");
20
- const listed = JSON.stringify(tasks);
18
+ fakes: {
19
+ add_task: { ok: true },
20
+ complete_task: (input) => ({ ok: true, message: `Marked "${String(input.title)}" done.` }),
21
+ remove_task: { ok: true, message: "Removed from the list." },
22
+ },
23
+ expect: ({ called, notCalled, check, transcript }) => {
21
24
  const last = transcript[transcript.length - 1];
22
25
  return [
23
- check("the milk is on the list and still open", tasks.some((task) => task.title.includes("milk") && !task.done), listed),
24
- check("the dentist call is on the list and done", tasks.some((task) => task.title.includes("dentist") && task.done), listed),
26
+ called("add_task", { title: /milk/i }),
27
+ called("add_task", { title: /dentist/i }),
28
+ called("complete_task", { title: /dentist/i }),
29
+ notCalled("remove_task"),
25
30
  check("the last reply names the milk", /milk/i.test(last.reply), last.reply),
26
31
  ];
27
32
  },
@@ -1,4 +1,5 @@
1
1
  import { personas, scenario } from "curb/testing";
2
+ import { supportFakes } from "./fakes.js";
2
3
 
3
4
  /**
4
5
  * A simulated caller with a goal: `curb test` plays the caller on a second model, and a judge
@@ -7,7 +8,7 @@ import { personas, scenario } from "curb/testing";
7
8
  *
8
9
  * The checks say what must be true when the call is over, not which way the agent took there:
9
10
  * Mara may look the order up first or open the ticket straight from the number the caller
10
- * read out. Either way one ticket for the damage exists at the end.
11
+ * read out. Either way the agent opens one ticket for the damage.
11
12
  */
12
13
  export default scenario({
13
14
  name: "opens a ticket for a damaged item",
@@ -22,12 +23,11 @@ export default scenario({
22
23
  // a scripted scenario needs neither: the same words run once and must pass.
23
24
  runs: 3,
24
25
  minPassRate: 0.66,
25
- // Every run runs the agent's tools for real. Here find_order reads sample data and the others
26
- // only change this call's own state. A tool that writes to a real system gets a fake:
27
- // fakes: { open_ticket: { ok: true, message: "Ticket T-1 opened." } }
26
+ // A fake answers in place of each tool, so no run reaches a real order system or ticket queue.
27
+ fakes: supportFakes,
28
28
  // A judge answers each sentence with yes, no or unknown, and quotes the turn that shows it.
29
29
  expectations: ["The agent says a ticket is open only after its open_ticket call succeeded."],
30
- // The agent's state at the end of the call: one ticket about the damage, and nothing else.
31
- // (The returns policy files a damaged item under "damaged" or "return".)
32
- expect: ({ stateMatches }) => [stateMatches("mara", { tickets: [{ category: /^(damaged|return)$/ }] })],
30
+ // One ticket about the damage. (The returns policy files a damaged item under "damaged" or
31
+ // "return".) A fake opens no real ticket, so the check reads the call.
32
+ expect: ({ called }) => [called("open_ticket", { category: /^(damaged|return)$/ })],
33
33
  });
@@ -0,0 +1,17 @@
1
+ import { ORDERS } from "./agent.js";
2
+
3
+ /**
4
+ * The fakes this agent's scenarios share. `curb test --hermetic` (the CI workflow) runs no tool
5
+ * without a fake, so a test never reaches a real order system or ticket queue. Each fake answers
6
+ * the way the real tool does; replace the sample orders with what your tests need.
7
+ */
8
+ export const supportFakes = {
9
+ find_order: (input: Record<string, unknown>) => {
10
+ const id = String(input.orderId ?? "").trim().toLowerCase();
11
+ const order = ORDERS.find((o) => o.id.toLowerCase() === id);
12
+ if (!order) return { ok: false, message: `No order ${String(input.orderId)}. Ask the caller to read the number again.` };
13
+ const carrier = order.carrier ? ` with ${order.carrier}` : "";
14
+ return { ok: true, message: `${order.id}: ${order.item}, ${order.status}${carrier}.` };
15
+ },
16
+ open_ticket: { ok: true, message: "Ticket T-1 opened. Tell the caller a colleague replies by email." },
17
+ };
@@ -1,18 +1,20 @@
1
1
  import { scenario } from "curb/testing";
2
+ import { supportFakes } from "./fakes.js";
2
3
 
3
4
  /**
4
5
  * Scripted caller lines: the same words on every run, so this is a gate. It runs once and must
5
6
  * pass. Keep one of these for every path that must never break.
6
7
  *
7
8
  * An order's status exists only in find_order's answer, so a reply that states it shows the
8
- * lookup ran: no check needs to name the tool.
9
+ * lookup ran. The fake of find_order answers from the same sample orders the tool reads.
9
10
  */
10
11
  export default scenario({
11
12
  name: "tells where an order is",
12
13
  turns: ["Hi, where is my order NW-1002?", "Great, thanks. That is all."],
13
- expect: ({ said, stateMatches }) => [
14
+ fakes: supportFakes,
15
+ expect: ({ said, notCalled }) => [
14
16
  said(/shipped|on (its|the) way|ParcelPost/i),
15
17
  // Asking about an order opens no ticket.
16
- stateMatches("mara", { tickets: [] }),
18
+ notCalled("open_ticket"),
17
19
  ],
18
20
  });