create-curb 1.25.0-preview.1 → 1.25.0-preview.10
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 +3 -3
- package/RELEASE_NOTES.md +12 -0
- package/package.json +2 -2
- package/templates/booking/README.md +12 -0
- package/templates/booking/src/agent/agent.tsx +7 -2
- package/templates/booking/src/agent/books-a-haircut.scenario.ts +32 -0
- package/templates/booking/src/agent/calendar.ts +12 -0
- package/templates/booking/src/agent/prices.scenario.ts +18 -0
- package/templates/default/.github/workflows/curb-test.yml +53 -0
- package/templates/default/AGENTS.md +42 -11
- package/templates/default/README.md +13 -0
- package/templates/default/src/agent/plan-the-day.scenario.ts +35 -0
- package/templates/default/src/agent/task-list.scenario.ts +28 -0
- package/templates/support/README.md +12 -0
- package/templates/support/src/agent/damaged-item.scenario.ts +33 -0
- package/templates/support/src/agent/order-status.scenario.ts +18 -0
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<div align="center">
|
|
2
|
-
<a href="https://curbjs.com"><img alt="Curb" src="https://curbjs.com/og.png?v=
|
|
2
|
+
<a href="https://curbjs.com"><img alt="Curb" src="https://curbjs.com/og.png?v=3" width="360"></a>
|
|
3
3
|
<h1>create-curb.js</h1>
|
|
4
|
-
<p><strong>
|
|
5
|
-
<p>
|
|
4
|
+
<p><strong>Voice agents your coding agent can build and improve.</strong></p>
|
|
5
|
+
<p>Describe the agent you want. Your coding agent builds it, talks to it, and improves it. Run it on your own servers, or let KugelAudio host it.</p>
|
|
6
6
|
<a href="https://www.npmjs.com/package/create-curb.js"><img alt="npm version" src="https://img.shields.io/npm/v/create-curb.js.svg?style=for-the-badge&labelColor=000000"></a>
|
|
7
7
|
<a href="https://curbjs.com/docs/installation/"><img alt="Node.js version" src="https://img.shields.io/node/v/create-curb.js.svg?style=for-the-badge&labelColor=000000"></a>
|
|
8
8
|
<a href="https://www.apache.org/licenses/LICENSE-2.0"><img alt="License" src="https://img.shields.io/npm/l/create-curb.js.svg?style=for-the-badge&labelColor=000000"></a>
|
package/RELEASE_NOTES.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
|
|
2
2
|
### Added
|
|
3
3
|
|
|
4
|
+
- Curb review simulates calls on an agent that has none yet (#136)
|
|
5
|
+
- Curb test says whether a change helped, and curb review drafts from real calls (#135)
|
|
6
|
+
- Scenarios define their own findings, ask the judge, and check across runs (#133)
|
|
7
|
+
- Curb/testing is a foundation in three layers, and curb test is built on it (#132)
|
|
8
|
+
- Curb review groups the problems of many calls into patterns (#131)
|
|
9
|
+
- Curb test reports pass rates over repeated runs, judge findings and saved runs (#130)
|
|
4
10
|
- Embed the development preview in a host page (#123)
|
|
5
11
|
|
|
12
|
+
|
|
13
|
+
### Fixed
|
|
14
|
+
|
|
15
|
+
- No hang-up in the greeting, timeouts fail fast, --runs repeats scripted scenarios (#134)
|
|
16
|
+
- A goodbye the model also wrote as text is heard once (#129)
|
|
17
|
+
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-curb",
|
|
3
|
-
"version": "1.25.0-preview.
|
|
4
|
-
"description": "Create a Curb voice agent with one command.
|
|
3
|
+
"version": "1.25.0-preview.10",
|
|
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",
|
|
7
7
|
"curb.js",
|
|
@@ -14,6 +14,7 @@ npx curb login # sign in in the browser; Curb uses your login
|
|
|
14
14
|
npm run dev # preview, chat and voice on http://127.0.0.1:4000
|
|
15
15
|
npx curb check # types, render and warnings
|
|
16
16
|
npx curb say "Hello" # one caller turn in the terminal, no browser
|
|
17
|
+
npx curb test # the conversations in src/agent/*.scenario.ts, pass or fail
|
|
17
18
|
```
|
|
18
19
|
|
|
19
20
|
## Try it
|
|
@@ -29,6 +30,17 @@ npx curb say "Hello" # one caller turn in the terminal, no browser
|
|
|
29
30
|
- `src/agent/<name>/skill.tsx`: one folder per skill, opened only when the conversation needs it.
|
|
30
31
|
- `context/`: markdown the skills read. Edit it and the agent's answers change live.
|
|
31
32
|
|
|
33
|
+
## Test it
|
|
34
|
+
|
|
35
|
+
`src/agent/*.scenario.ts` holds conversations that `npx curb test` plays in text: one with
|
|
36
|
+
scripted caller lines, which must always pass, and one with a simulated caller that a second
|
|
37
|
+
model plays. `npx curb test --runs 3` plays each three times and reports how often
|
|
38
|
+
it passed, what a judge found and how the agent talks. Text tests do not cover audio, timing or
|
|
39
|
+
interruptions: listen to a call in `npm run dev` for those.
|
|
40
|
+
|
|
41
|
+
`.github/workflows/curb-test.yml` runs `curb check` and `curb test` on every pull request, and
|
|
42
|
+
fails until the repository has `KUGELAUDIO_API_KEY` as a secret (Settings > Secrets and variables > Actions).
|
|
43
|
+
|
|
32
44
|
## Deploy to KugelAudio
|
|
33
45
|
|
|
34
46
|
```bash
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
z,
|
|
12
12
|
} from "curb";
|
|
13
13
|
import { kugelaudio } from "curb/providers";
|
|
14
|
-
import { type Appointment, addAppointment, removeAppointment } from "./calendar.js";
|
|
14
|
+
import { type Appointment, addAppointment, isPersonName, removeAppointment } from "./calendar.js";
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* Lena, the booking agent of Birch Street Studio, a made-up hair and beauty studio. This file is
|
|
@@ -63,7 +63,7 @@ const bookSchema = z.object({
|
|
|
63
63
|
service: z.enum(SERVICES).describe("The service the caller wants."),
|
|
64
64
|
date: z.iso.date().describe("The day, as YYYY-MM-DD."),
|
|
65
65
|
time: z.string().regex(/^\d{2}:00$/).describe("The start time on the hour, 24-hour HH:00, one of the free slots."),
|
|
66
|
-
name: z.string().min(1).describe("The caller's name, as they said it."),
|
|
66
|
+
name: z.string().min(1).describe("The caller's name, as they said it. Ask for it first if they have not said it."),
|
|
67
67
|
});
|
|
68
68
|
|
|
69
69
|
const cancelSchema = z.object({
|
|
@@ -108,6 +108,11 @@ function Calendar() {
|
|
|
108
108
|
name="book_appointment"
|
|
109
109
|
description="Book an appointment in a free slot. Call it only after the caller confirmed service, day, time and name."
|
|
110
110
|
onSubmit={(input) => {
|
|
111
|
+
// Structural, like the slot checks below: the model cannot book under a stand-in
|
|
112
|
+
// for a name it never asked for.
|
|
113
|
+
if (!isPersonName(input.name)) {
|
|
114
|
+
return { ok: false, message: `"${input.name}" is not a name. Ask the caller for their name, then book with it.` };
|
|
115
|
+
}
|
|
111
116
|
if (!isOpenDay(input.date) || !hours.includes(input.time)) {
|
|
112
117
|
return { ok: false, message: "That is outside opening hours. Offer another slot from list_free_slots." };
|
|
113
118
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { personas, scenario } from "curb/testing";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A simulated caller with a goal: `curb test` plays the caller on a second model, and a judge
|
|
5
|
+
* reads the finished call. The persona makes the caller harder than the default one, who is
|
|
6
|
+
* more patient and clearer than the people who really call.
|
|
7
|
+
*
|
|
8
|
+
* 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.
|
|
11
|
+
*/
|
|
12
|
+
export default scenario({
|
|
13
|
+
name: "books a haircut on a bad line",
|
|
14
|
+
caller: {
|
|
15
|
+
goal: "Book a haircut on the next day the studio is open, at a free time the agent offers.",
|
|
16
|
+
knows: "Your name is Alex Example. You want a haircut. Any free time of day suits you.",
|
|
17
|
+
...personas.hardOfHearing,
|
|
18
|
+
},
|
|
19
|
+
// A model does not answer the same way twice, so this scenario runs three times and passes
|
|
20
|
+
// when two of the three do. The report still shows the rate and marks it flaky when a run
|
|
21
|
+
// failed. Raise minPassRate toward 1 (every run) once it passes every time for a while;
|
|
22
|
+
// a scripted scenario needs neither: the same words run once and must pass.
|
|
23
|
+
runs: 3,
|
|
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." } }
|
|
28
|
+
// A judge answers each sentence with yes, no or unknown, and quotes the turn that shows it.
|
|
29
|
+
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 }] })],
|
|
32
|
+
});
|
|
@@ -15,6 +15,18 @@ export function addAppointment(book: Book, appointment: Omit<Appointment, "id">)
|
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
+
/** What a model writes into a name field when the caller never said their name. */
|
|
19
|
+
const PLACEHOLDER_NAMES = ["caller", "the caller", "customer", "client", "user", "guest", "unknown", "anonymous", "name", "none", "na", "tbd"];
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Whether `name` is a name a person gave, not a word that stands in for one: a booking under
|
|
23
|
+
* "Caller" is one nobody can be greeted by when they arrive.
|
|
24
|
+
*/
|
|
25
|
+
export function isPersonName(name: string): boolean {
|
|
26
|
+
const letters = name.toLowerCase().replace(/[^\p{L}\s]/gu, "").replace(/\s+/g, " ").trim();
|
|
27
|
+
return letters !== "" && !PLACEHOLDER_NAMES.includes(letters);
|
|
28
|
+
}
|
|
29
|
+
|
|
18
30
|
export function removeAppointment(book: Book, id: string) {
|
|
19
31
|
return {
|
|
20
32
|
book: { ...book, appointments: book.appointments.filter((a) => a.id !== id) },
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { scenario } from "curb/testing";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Scripted caller lines: the same words on every run, so this is a gate. It runs once and must
|
|
5
|
+
* pass. Keep one of these for every path that must never break.
|
|
6
|
+
*
|
|
7
|
+
* 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
|
+
*/
|
|
10
|
+
export default scenario({
|
|
11
|
+
name: "answers a price question without booking",
|
|
12
|
+
turns: ["Hi, what does a haircut cost?", "Okay, thanks. I will think about it."],
|
|
13
|
+
expect: ({ said, stateMatches }) => [
|
|
14
|
+
said(/38|thirty[- ]eight/i),
|
|
15
|
+
// A question about prices books nothing.
|
|
16
|
+
stateMatches("lena", { appointments: [] }),
|
|
17
|
+
],
|
|
18
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
name: curb test
|
|
2
|
+
|
|
3
|
+
# Runs the agent's checks and its conversation scenarios on every pull request. The scenarios
|
|
4
|
+
# call the agent's LLM, so the job needs KUGELAUDIO_API_KEY as a repository secret (Settings >
|
|
5
|
+
# Secrets and variables > Actions), an API key from the KugelAudio dashboard. An agent on
|
|
6
|
+
# another provider needs that provider's key here instead, under the name its .env uses.
|
|
7
|
+
#
|
|
8
|
+
# Without that secret the job fails on a pull request from this repository and on a run started
|
|
9
|
+
# by hand, so a missing key never passes as green. A pull request from a fork gets no secrets, so
|
|
10
|
+
# the scenarios are skipped there and only `curb check` runs.
|
|
11
|
+
|
|
12
|
+
on:
|
|
13
|
+
pull_request:
|
|
14
|
+
workflow_dispatch:
|
|
15
|
+
|
|
16
|
+
permissions:
|
|
17
|
+
contents: read
|
|
18
|
+
|
|
19
|
+
concurrency:
|
|
20
|
+
group: curb-test-${{ github.ref }}
|
|
21
|
+
cancel-in-progress: true
|
|
22
|
+
|
|
23
|
+
jobs:
|
|
24
|
+
test:
|
|
25
|
+
runs-on: ubuntu-latest
|
|
26
|
+
timeout-minutes: 30
|
|
27
|
+
env:
|
|
28
|
+
KUGELAUDIO_API_KEY: ${{ secrets.KUGELAUDIO_API_KEY }}
|
|
29
|
+
# CPU binaries ship in npm; this skips a download the tests do not need.
|
|
30
|
+
ONNXRUNTIME_NODE_INSTALL: skip
|
|
31
|
+
steps:
|
|
32
|
+
- name: The API key secret is set
|
|
33
|
+
if: env.KUGELAUDIO_API_KEY == '' && (github.event_name == 'workflow_dispatch' || github.event.pull_request.head.repo.full_name == github.repository)
|
|
34
|
+
run: |
|
|
35
|
+
echo "::error::KUGELAUDIO_API_KEY is not set, so curb test cannot run the scenarios. Add it as a repository secret: Settings > Secrets and variables > Actions."
|
|
36
|
+
exit 1
|
|
37
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
38
|
+
with:
|
|
39
|
+
persist-credentials: false
|
|
40
|
+
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
|
|
41
|
+
with:
|
|
42
|
+
node-version: 22
|
|
43
|
+
- run: npm ci
|
|
44
|
+
- run: npx curb check
|
|
45
|
+
# 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
|
|
48
|
+
if: env.KUGELAUDIO_API_KEY != ''
|
|
49
|
+
run: npx curb test
|
|
50
|
+
# To take the simulated caller and the judge off the agent's provider, run them on OpenAI
|
|
51
|
+
# with OPENAI_API_KEY as a repository secret: replace the run line above with these two.
|
|
52
|
+
# 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
|
|
@@ -51,8 +51,8 @@ A new project is created with `npm create curb.js my-agent`, and you then work i
|
|
|
51
51
|
The full guide ships in `node_modules/curb/docs/agent-guide/`: read `README.md` first, then
|
|
52
52
|
`what-the-model-receives.md`, `agents-and-skills.md`, `tools.md`, `state.md` and `testing.md`.
|
|
53
53
|
There is one page per task, such as `human-handoff.md` and `confirmations.md`;
|
|
54
|
-
`api-reference.md` leads to every export, and `improve-from-calls.md` is the way to
|
|
55
|
-
agent from
|
|
54
|
+
`api-reference.md` leads to every export, and `improve-from-calls.md` is the way to make the
|
|
55
|
+
agent better, from simulated calls or from calls that went wrong.
|
|
56
56
|
A fault in Curb itself is reported as `reporting-a-bug.md` says, with the person's yes first.
|
|
57
57
|
|
|
58
58
|
## Verify every change
|
|
@@ -62,18 +62,45 @@ A fault in Curb itself is reported as `reporting-a-bug.md` says, with the person
|
|
|
62
62
|
2. `npx curb say "<what the caller says>"`: one spoken turn, headless. It prints the reply,
|
|
63
63
|
each tool call and the context it changed. The next `curb say` continues the
|
|
64
64
|
conversation; `npx curb say --new "<first line>"` starts over (do that after a code change).
|
|
65
|
-
3. `npx curb test
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
3. `npx curb test --runs 3`: plays every `src/**/*.scenario.ts` conversation headlessly, in
|
|
66
|
+
text, three times each, because a model does not answer the same way twice. A scenario
|
|
67
|
+
with scripted caller lines is a gate: every run must pass. One with a simulated caller is
|
|
68
|
+
read by its pass rate, not one run. The scenarios this project starts with pass when two
|
|
69
|
+
of three runs do (`minPassRate: 0.66`); raise that toward 1 once one passes every time. Then read what the report found: each `find` line
|
|
70
|
+
names a turn and quotes it, the transcript of every failed run is printed, and the `Style`
|
|
71
|
+
lines say how long the replies are and how often they repeat. A scenario marked flaky
|
|
72
|
+
passed on some runs only: fix the agent, do not rerun until it passes. A run marked
|
|
73
|
+
`error` says nothing about the agent (the provider failed, or the simulated caller went
|
|
74
|
+
wrong). After changing an `expect` or an expectation, `npx curb test --rejudge latest`
|
|
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`).
|
|
77
|
+
When the ready-made checks do not cover what the team needs, build on the same functions
|
|
78
|
+
(`testing-foundation.md`, "Build your own tests").
|
|
68
79
|
|
|
69
80
|
4. `npm run dev`: the browser preview with chat and voice on http://127.0.0.1:4000. Open it in the person's own browser yourself (`open http://127.0.0.1:4000` on macOS, `xdg-open` on Linux, `start` on Windows): a browser built into an app, like the Claude app's Browser pane, blocks the microphone, so a call there fails.
|
|
70
81
|
|
|
71
|
-
**To
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
82
|
+
**To make the agent better, run this loop.** It works on a new agent and after go-live:
|
|
83
|
+
|
|
84
|
+
1. `npx curb review`. With no recorded conversations yet it plays 20 simulated calls, with
|
|
85
|
+
callers written from the agent's prompt, skills and tools, and reviews them; once the preview
|
|
86
|
+
has conversations it reviews its last 20, and `npx curb review <calls.jsonl>` reviews an export
|
|
87
|
+
of the dashboard's Calls page. It prints the problems that come back most, each with quotes
|
|
88
|
+
and a scenario to add.
|
|
89
|
+
2. Take the top pattern, and read its quoted turns before you believe its title.
|
|
90
|
+
3. Add its drafted scenario as `src/agent/<name>.scenario.ts`, inside `scenario({ ... })`.
|
|
91
|
+
4. `npx curb test <name> --runs 5` and see it fail. A scenario that passes does not reproduce the
|
|
92
|
+
problem: sharpen its caller until it fails.
|
|
93
|
+
5. Fix the agent (its prompt, a skill, a tool or its state), never the scenario.
|
|
94
|
+
6. `npx curb test <name> --runs 5` again and read the `Since` lines: `better` means the fix
|
|
95
|
+
helped beyond chance, `no clear change` that it has not yet. Then `npx curb test` for the rest.
|
|
96
|
+
7. Commit, and start again at 1.
|
|
97
|
+
|
|
98
|
+
A review of 20 simulated calls is some 300 to 400 LLM requests and takes a few minutes; each test
|
|
99
|
+
run of one scenario is five conversations. To fix one call that went wrong, read it with
|
|
100
|
+
`npx curb conversations` (`--last <n>`, `--id <id>`, `--json`: every tool call with its input
|
|
101
|
+
and result), or for the hosted agent with the `kugelaudio` MCP server's `agent_list_calls`,
|
|
102
|
+
`agent_get_call` and `agent_get_call_timeline`, then fix it and keep it as a scenario
|
|
103
|
+
(`improve-from-calls.md`).
|
|
77
104
|
|
|
78
105
|
## The preview
|
|
79
106
|
|
|
@@ -89,9 +116,13 @@ what really happened.
|
|
|
89
116
|
src/agent/agent.tsx the agent, where every conversation starts: <Agent llm stt tts>,
|
|
90
117
|
system prompt, skills index, tools every skill has, store
|
|
91
118
|
src/agent/<name>/skill.tsx one folder per skill, opened when needed; nested folders are sub-skills
|
|
119
|
+
src/agent/*.scenario.ts conversations `curb test` plays: a caller, and what must hold afterwards
|
|
92
120
|
context/*.md knowledge a skill reads with <Text src="file.md" />
|
|
93
121
|
.env other providers' keys, an optional KUGELAUDIO_API_KEY; never commit it
|
|
94
122
|
.data/conversations.jsonl every preview conversation: tool calls, inputs, results
|
|
123
|
+
.curb/test-runs/ every `curb test` run with its conversations, for --rejudge
|
|
124
|
+
.github/workflows/ curb-test.yml runs check and test on each pull request; it needs
|
|
125
|
+
KUGELAUDIO_API_KEY as a repository secret
|
|
95
126
|
```
|
|
96
127
|
|
|
97
128
|
## Rules
|
|
@@ -17,6 +17,7 @@ npx curb login # sign in in the browser; Curb uses your login
|
|
|
17
17
|
npm run dev # preview, chat and voice on http://127.0.0.1:4000
|
|
18
18
|
npx curb check # types, render and warnings
|
|
19
19
|
npx curb say "Hallo" # one caller turn in the terminal, no browser
|
|
20
|
+
npx curb test # the conversations in src/agent/*.scenario.ts, pass or fail
|
|
20
21
|
```
|
|
21
22
|
|
|
22
23
|
## Meet Juno
|
|
@@ -39,6 +40,18 @@ Type or talk in the preview:
|
|
|
39
40
|
needs it.
|
|
40
41
|
- `context/`: markdown the skills read.
|
|
41
42
|
|
|
43
|
+
## Test it
|
|
44
|
+
|
|
45
|
+
`src/agent/*.scenario.ts` holds conversations that `npx curb test` plays in text: one with
|
|
46
|
+
scripted caller lines, which must always pass, and one with a simulated caller that a second
|
|
47
|
+
model plays. `npx curb test --runs 3` plays each three times and reports how often
|
|
48
|
+
it passed, what a judge found and how the agent talks. Text tests do not cover audio, timing or
|
|
49
|
+
interruptions: listen to a call in `npm run dev` for those.
|
|
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`.
|
|
54
|
+
|
|
42
55
|
## Deploy to KugelAudio
|
|
43
56
|
|
|
44
57
|
Hosted deploys accept this project, which installs Curb from npm. To run it on your own servers
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { personas, scenario } from "curb/testing";
|
|
2
|
+
import type { Task } from "./agent.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A simulated caller with a goal: `curb test` plays the caller on a second model, and a judge
|
|
6
|
+
* reads the finished call. The persona makes the caller harder than the default one, who is
|
|
7
|
+
* more patient and clearer than the people who really call.
|
|
8
|
+
*
|
|
9
|
+
* The checks say what must be true when the call is over, not which way the agent took there:
|
|
10
|
+
* a model that asks one question more, or adds the tasks in another order, still passes.
|
|
11
|
+
*/
|
|
12
|
+
export default scenario({
|
|
13
|
+
name: "plans the day with a talkative caller",
|
|
14
|
+
caller: {
|
|
15
|
+
goal: "Get three tasks onto your list: buy milk, call the dentist, send the invoice.",
|
|
16
|
+
knows: "Your tasks for today: buy milk, call the dentist, send the invoice.",
|
|
17
|
+
...personas.talkative,
|
|
18
|
+
},
|
|
19
|
+
// A model does not answer the same way twice, so this scenario runs three times and passes
|
|
20
|
+
// when two of the three do. The report still shows the rate and marks it flaky when a run
|
|
21
|
+
// failed. Raise minPassRate toward 1 (every run) once it passes every time for a while;
|
|
22
|
+
// a scripted scenario needs neither: the same words run once and must pass.
|
|
23
|
+
runs: 3,
|
|
24
|
+
minPassRate: 0.66,
|
|
25
|
+
// A judge answers each sentence with yes, no or unknown, and quotes the turn that shows it.
|
|
26
|
+
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
|
+
},
|
|
35
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { scenario } from "curb/testing";
|
|
2
|
+
import type { Task } from "./agent.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Scripted caller lines: the same words on every run, so this is a gate. It runs once and must
|
|
6
|
+
* pass. Keep one of these for every path that must never break.
|
|
7
|
+
*
|
|
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.
|
|
10
|
+
*/
|
|
11
|
+
export default scenario({
|
|
12
|
+
name: "keeps the task list",
|
|
13
|
+
turns: [
|
|
14
|
+
"Put buy milk and call the dentist on my list.",
|
|
15
|
+
"I've called the dentist, that one is done.",
|
|
16
|
+
"What is still open on my list?",
|
|
17
|
+
],
|
|
18
|
+
expect: ({ state, check, transcript }) => {
|
|
19
|
+
const { tasks } = state<{ tasks: Task[] }>("juno");
|
|
20
|
+
const listed = JSON.stringify(tasks);
|
|
21
|
+
const last = transcript[transcript.length - 1];
|
|
22
|
+
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),
|
|
25
|
+
check("the last reply names the milk", /milk/i.test(last.reply), last.reply),
|
|
26
|
+
];
|
|
27
|
+
},
|
|
28
|
+
});
|
|
@@ -14,6 +14,7 @@ npx curb login # sign in in the browser; Curb uses your login
|
|
|
14
14
|
npm run dev # preview, chat and voice on http://127.0.0.1:4000
|
|
15
15
|
npx curb check # types, render and warnings
|
|
16
16
|
npx curb say "Hello" # one caller turn in the terminal, no browser
|
|
17
|
+
npx curb test # the conversations in src/agent/*.scenario.ts, pass or fail
|
|
17
18
|
```
|
|
18
19
|
|
|
19
20
|
## Try it
|
|
@@ -29,6 +30,17 @@ npx curb say "Hello" # one caller turn in the terminal, no browser
|
|
|
29
30
|
- `src/agent/<name>/skill.tsx`: one folder per skill, opened only when the conversation needs it.
|
|
30
31
|
- `context/`: markdown the skills read. Edit it and the agent's answers change live.
|
|
31
32
|
|
|
33
|
+
## Test it
|
|
34
|
+
|
|
35
|
+
`src/agent/*.scenario.ts` holds conversations that `npx curb test` plays in text: one with
|
|
36
|
+
scripted caller lines, which must always pass, and one with a simulated caller that a second
|
|
37
|
+
model plays. `npx curb test --runs 3` plays each three times and reports how often
|
|
38
|
+
it passed, what a judge found and how the agent talks. Text tests do not cover audio, timing or
|
|
39
|
+
interruptions: listen to a call in `npm run dev` for those.
|
|
40
|
+
|
|
41
|
+
`.github/workflows/curb-test.yml` runs `curb check` and `curb test` on every pull request, and
|
|
42
|
+
fails until the repository has `KUGELAUDIO_API_KEY` as a secret (Settings > Secrets and variables > Actions).
|
|
43
|
+
|
|
32
44
|
## Deploy to KugelAudio
|
|
33
45
|
|
|
34
46
|
```bash
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { personas, scenario } from "curb/testing";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A simulated caller with a goal: `curb test` plays the caller on a second model, and a judge
|
|
5
|
+
* reads the finished call. The persona makes the caller harder than the default one, who is
|
|
6
|
+
* more patient and clearer than the people who really call.
|
|
7
|
+
*
|
|
8
|
+
* The checks say what must be true when the call is over, not which way the agent took there:
|
|
9
|
+
* 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
|
+
*/
|
|
12
|
+
export default scenario({
|
|
13
|
+
name: "opens a ticket for a damaged item",
|
|
14
|
+
caller: {
|
|
15
|
+
goal: "Report that the backpack from your order arrived with a torn shoulder strap, and get a support ticket opened for it.",
|
|
16
|
+
knows: "Your order number is NW-1001. The trail backpack arrived with a torn shoulder strap. Your name is Sam Example.",
|
|
17
|
+
...personas.rushed,
|
|
18
|
+
},
|
|
19
|
+
// A model does not answer the same way twice, so this scenario runs three times and passes
|
|
20
|
+
// when two of the three do. The report still shows the rate and marks it flaky when a run
|
|
21
|
+
// failed. Raise minPassRate toward 1 (every run) once it passes every time for a while;
|
|
22
|
+
// a scripted scenario needs neither: the same words run once and must pass.
|
|
23
|
+
runs: 3,
|
|
24
|
+
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." } }
|
|
28
|
+
// A judge answers each sentence with yes, no or unknown, and quotes the turn that shows it.
|
|
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)$/ }] })],
|
|
33
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { scenario } from "curb/testing";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Scripted caller lines: the same words on every run, so this is a gate. It runs once and must
|
|
5
|
+
* pass. Keep one of these for every path that must never break.
|
|
6
|
+
*
|
|
7
|
+
* 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
|
+
*/
|
|
10
|
+
export default scenario({
|
|
11
|
+
name: "tells where an order is",
|
|
12
|
+
turns: ["Hi, where is my order NW-1002?", "Great, thanks. That is all."],
|
|
13
|
+
expect: ({ said, stateMatches }) => [
|
|
14
|
+
said(/shipped|on (its|the) way|ParcelPost/i),
|
|
15
|
+
// Asking about an order opens no ticket.
|
|
16
|
+
stateMatches("mara", { tickets: [] }),
|
|
17
|
+
],
|
|
18
|
+
});
|