@alexkroman1/aai-cli 16.1.0 → 17.0.0
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 +2 -1
- package/dist/{_build-target-ClEEuUuW.mjs → _build-target-C08aM-Es.mjs} +504 -43
- package/dist/_build-target.d.ts +98 -19
- package/dist/_deno-target.d.ts +15 -14
- package/dist/_dev-env.d.ts +19 -13
- package/dist/{_dev-server-D1wKiA0_.mjs → _dev-server-CLU9xjH5.mjs} +25 -17
- package/dist/_dev-server.d.ts +4 -3
- package/dist/_init.d.ts +39 -0
- package/dist/_modal-target.d.ts +11 -6
- package/dist/_preflight-CnW9QiE7.mjs +116 -0
- package/dist/_preflight.d.ts +110 -5
- package/dist/_target-bundle.d.ts +112 -0
- package/dist/_target-entry.d.ts +81 -0
- package/dist/{_templates-CuP74F8D.mjs → _templates-IMeKMVIj.mjs} +1 -1
- package/dist/{_vitest-runner-BiAMIir1.mjs → _vitest-runner-CZNGj0ZC.mjs} +21 -16
- package/dist/_vitest-runner.d.ts +35 -23
- package/dist/{build-O6BT51x_.mjs → build-DrQTSc2R.mjs} +128 -293
- package/dist/build.d.ts +34 -4
- package/dist/cli.mjs +20 -16
- package/dist/{deploy-lldQyJVj.mjs → deploy-B68-x7xM.mjs} +12 -4
- package/dist/deploy.d.ts +9 -0
- package/dist/{dev-Du8pCWFq.mjs → dev-ChsrNHpK.mjs} +1 -1
- package/dist/dev.d.ts +1 -1
- package/dist/{eval-Ducmkt1n.mjs → eval-DB07kTxO.mjs} +1 -1
- package/dist/init-W-4k-lCF.mjs +559 -0
- package/dist/init.d.ts +43 -3
- package/dist/scaffold/CLAUDE.md +51 -64
- package/dist/scaffold/package.json +6 -6
- package/dist/scaffold/vite.config.ts +29 -1
- package/dist/{studio-It7SRfUN.mjs → studio-DEAJGBXa.mjs} +19 -9
- package/dist/templates/applicant-screening-agent/agent.eval.test.ts +20 -6
- package/dist/templates/applicant-screening-agent/agent.ts +28 -0
- package/dist/templates/applicant-screening-agent/shared.ts +11 -11
- package/dist/templates/call-audit-workflow/agent.ts +2 -0
- package/dist/templates/code-interpreter-agent/agent.eval.test.ts +3 -2
- package/dist/templates/code-interpreter-agent/agent.ts +1 -0
- package/dist/templates/coding-agent/agent.eval.test.ts +136 -0
- package/dist/templates/coding-agent/agent.test.ts +109 -0
- package/dist/templates/coding-agent/agent.ts +45 -0
- package/dist/templates/coding-agent/chat.ts +63 -0
- package/dist/templates/coding-agent/shared.ts +46 -0
- package/dist/templates/coding-agent/system-prompt.md +32 -0
- package/dist/templates/coding-agent/tools/bash.ts +6 -0
- package/dist/templates/coding-agent/tools/delete_file.ts +6 -0
- package/dist/templates/coding-agent/tools/edit_file.ts +6 -0
- package/dist/templates/coding-agent/tools/glob.ts +6 -0
- package/dist/templates/coding-agent/tools/grep.ts +6 -0
- package/dist/templates/coding-agent/tools/list_files.ts +6 -0
- package/dist/templates/coding-agent/tools/read_file.ts +6 -0
- package/dist/templates/coding-agent/tools/todo_write.ts +6 -0
- package/dist/templates/coding-agent/tools/write_file.ts +6 -0
- package/dist/templates/custom-pipeline-agent/agent.ts +1 -0
- package/dist/templates/document-redline-workflow/agent.ts +2 -0
- package/dist/templates/emergency-dispatch-agent/agent.test.ts +103 -0
- package/dist/templates/emergency-dispatch-agent/agent.ts +15 -0
- package/dist/templates/emergency-dispatch-agent/guardrails.ts +105 -0
- package/dist/templates/emergency-dispatch-agent/system-prompt.md +1 -0
- package/dist/templates/entertainment-picks-agent/agent.eval.test.ts +8 -1
- package/dist/templates/entertainment-picks-agent/agent.ts +1 -0
- package/dist/templates/entertainment-picks-agent/system-prompt.md +6 -0
- package/dist/templates/entertainment-picks-agent/tools/revisit.ts +7 -0
- package/dist/templates/executive-inbox-agent/agent.eval.test.ts +84 -23
- package/dist/templates/executive-inbox-agent/agent.ts +1 -0
- package/dist/templates/executive-inbox-agent/meeting.ts +1 -1
- package/dist/templates/executive-inbox-agent/prompts.ts +3 -1
- package/dist/templates/executive-inbox-agent/system-prompt.md +3 -3
- package/dist/templates/executive-inbox-agent/tools/meeting_assistant.ts +3 -3
- package/dist/templates/executive-inbox-agent/tools/open_email.ts +8 -16
- package/dist/templates/hotel-reception-agent/agent.eval.test.ts +85 -21
- package/dist/templates/hotel-reception-agent/agent.test.ts +2 -1
- package/dist/templates/hotel-reception-agent/agent.ts +6 -3
- package/dist/templates/hotel-reception-agent/client.tsx +14 -2
- package/dist/templates/hotel-reception-agent/concierge.ts +2 -1
- package/dist/templates/hotel-reception-agent/desk-seams.test.ts +2 -1
- package/dist/templates/hotel-reception-agent/disputes.ts +9 -11
- package/dist/templates/hotel-reception-agent/events.ts +2 -1
- package/dist/templates/hotel-reception-agent/session.ts +56 -0
- package/dist/templates/hotel-reception-agent/shared.ts +20 -21
- package/dist/templates/hotel-reception-agent/system-prompt.md +1 -1
- package/dist/templates/hotel-reception-agent/tools/abandon_booking.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/add_to_waitlist.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/book_airport_car.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/cancel_restaurant_reservation.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/cancel_room_booking.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/check_restaurant_availability.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/check_room_availability.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/choose_room.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/confirm_booking.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/dispatch_emergency.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/dispute_charge.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/flag_late_arrival.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/lookup_booking.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/lookup_guest_history.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/lookup_invoice.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/lookup_restaurant_reservation.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/modify_restaurant_reservation.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/record_card.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/record_followup.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/record_group_inquiry.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/record_guest_details.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/reinstate_booking.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/request_flight_reconfirmation.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/resend_confirmation.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/reserve_table.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/resolve_room_conflict.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/schedule_wakeup_call.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/set_do_not_disturb.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/set_extras.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/set_stay.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/start_booking_modification.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/start_room_booking.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/take_guest_message.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/transfer_call.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/update_card.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/verify_booking.ts +2 -1
- package/dist/templates/link-digest-workflow/agent.eval.test.ts +16 -1
- package/dist/templates/link-digest-workflow/agent.ts +5 -0
- package/dist/templates/medication-safety-agent/agent.test.ts +54 -0
- package/dist/templates/medication-safety-agent/agent.ts +48 -1
- package/dist/templates/meeting-recap-agent/agent.test.ts +2 -2
- package/dist/templates/meeting-recap-agent/agent.ts +4 -0
- package/dist/templates/pizza-ordering-agent/agent.ts +3 -0
- package/dist/templates/podcast-digest-workflow/agent.ts +4 -0
- package/dist/templates/quickstart-agent/agent.eval.test.ts +39 -3
- package/dist/templates/quickstart-agent/agent.test.ts +22 -0
- package/dist/templates/quickstart-agent/agent.ts +18 -2
- package/dist/templates/quickstart-agent/system-prompt.md +8 -0
- package/dist/templates/quickstart-agent/tools/get_weather.ts +59 -0
- package/dist/templates/research-handoff-agent/agent.ts +4 -0
- package/dist/templates/research-planner-agent/agent.eval.test.ts +24 -2
- package/dist/templates/research-planner-agent/agent.ts +3 -0
- package/dist/templates/research-planner-agent/system-prompt.md +1 -1
- package/dist/templates/retail-orders-agent/agent.ts +32 -3
- package/dist/templates/retail-orders-agent/keyterms.ts +154 -0
- package/dist/templates/retail-orders-agent/resolve.ts +18 -3
- package/dist/templates/roadside-assistance-agent/agent.eval.test.ts +37 -5
- package/dist/templates/roadside-assistance-agent/agent.test.ts +38 -6
- package/dist/templates/roadside-assistance-agent/agent.ts +4 -0
- package/dist/templates/roadside-assistance-agent/shared.ts +12 -0
- package/dist/templates/roadside-assistance-agent/tools/acknowledge_disclosure.ts +14 -0
- package/dist/templates/roadside-assistance-agent/tools/lookup_coverage.ts +11 -0
- package/dist/templates/roadside-assistance-agent/tools/service_disclosure.ts +17 -11
- package/dist/templates/roadside-assistance-agent/yard.test.ts +4 -0
- package/dist/templates/spoken-summary-workflow/agent.ts +4 -0
- package/dist/templates/tabletop-rpg-agent/agent.eval.test.ts +6 -0
- package/dist/templates/tabletop-rpg-agent/agent.test.ts +125 -1
- package/dist/templates/tabletop-rpg-agent/agent.ts +30 -1
- package/dist/templates/tabletop-rpg-agent/shared.ts +81 -0
- package/dist/templates/tabletop-rpg-agent/system-prompt.md +1 -1
- package/dist/templates/tabletop-rpg-agent/tools/check_state.ts +16 -7
- package/dist/templates/technical-support-agent/agent.test.ts +3 -3
- package/dist/templates/technical-support-agent/agent.ts +5 -1
- package/dist/templates/technical-support-agent/knowledge.ts +165 -0
- package/dist/templates/technical-support-agent/nodes.ts +3 -2
- package/dist/templates/technical-support-agent/procedure.ts +4 -3
- package/dist/templates/technical-support-agent/shared.ts +10 -146
- package/dist/templates/technical-support-agent/tools/list_topics.ts +2 -1
- package/dist/templates/text-adventure-agent/agent.eval.test.ts +39 -6
- package/dist/templates/text-adventure-agent/agent.test.ts +79 -1
- package/dist/templates/text-adventure-agent/agent.ts +30 -1
- package/dist/templates/text-adventure-agent/shared.ts +37 -0
- package/dist/templates/text-adventure-agent/system-prompt.md +9 -2
- package/dist/templates/topic-briefing-agent/agent.eval.test.ts +18 -4
- package/dist/templates/topic-briefing-agent/agent.test.ts +23 -11
- package/dist/templates/topic-briefing-agent/agent.ts +4 -1
- package/dist/templates/topic-briefing-agent/shared.ts +10 -10
- package/dist/templates/topic-briefing-agent/system-prompt.md +13 -8
- package/dist/templates/topic-briefing-agent/tools/send_briefing.ts +43 -5
- package/dist/templates/transcription-workflow/agent.ts +3 -0
- package/dist/templates/travel-concierge-agent/agent.ts +4 -0
- package/dist/templates/web-research-agent/agent.eval.test.ts +31 -5
- package/dist/templates/web-research-agent/agent.test.ts +16 -0
- package/dist/templates/web-research-agent/agent.ts +30 -0
- package/dist/templates/web-research-agent/system-prompt.md +8 -2
- package/dist/templates/word-game-agent/agent.eval.test.ts +79 -18
- package/dist/templates/word-game-agent/agent.ts +20 -0
- package/dist/test-CjKPQ9_B.mjs +102 -0
- package/dist/test.d.ts +37 -12
- package/package.json +5 -5
- package/dist/_init-Bp1CjRrU.mjs +0 -199
- package/dist/_preflight-CcAR577V.mjs +0 -46
- package/dist/init-CY4NAXAA.mjs +0 -183
- package/dist/test-PHHv0Vj6.mjs +0 -83
|
@@ -32,6 +32,7 @@ import {
|
|
|
32
32
|
createVmRunCode,
|
|
33
33
|
customEventsIn,
|
|
34
34
|
describeTurn,
|
|
35
|
+
expectCalled,
|
|
35
36
|
lastStateIn,
|
|
36
37
|
runCodeIn,
|
|
37
38
|
runCodeOutput,
|
|
@@ -133,6 +134,12 @@ describeEval(
|
|
|
133
134
|
await session.say("I want something cozy to watch tonight.");
|
|
134
135
|
const turn = await session.say("Now give me something spooky to read.");
|
|
135
136
|
|
|
137
|
+
// `expectCalled` first, because "the host named something out of its own
|
|
138
|
+
// head and ended the turn" is how this case actually fails — the night's
|
|
139
|
+
// log stays empty and `revisit` has nothing to find. It reports the
|
|
140
|
+
// sentence spoken in place of the call, where `expected [] to deeply
|
|
141
|
+
// equal [ 'recommend' ]` reported neither.
|
|
142
|
+
expectCalled(turn, "recommend");
|
|
136
143
|
expect(toolNames(turn.toolCalls)).toEqual(["recommend"]);
|
|
137
144
|
expect(turn.toolCalls[0]!.args).toEqual({ category: "book", mood: "spooky" });
|
|
138
145
|
|
|
@@ -229,7 +236,7 @@ describeEval(
|
|
|
229
236
|
// about a companion that talked its way through the sum instead, and it
|
|
230
237
|
// names a cancelled reply, which is the usual reason a turn reached for
|
|
231
238
|
// nothing.
|
|
232
|
-
|
|
239
|
+
expectCalled(turn, "run_code");
|
|
233
240
|
// The recipe is the prompt's, and it is two constants: a 90-minute cycle
|
|
234
241
|
// plus the 15 minutes it takes to fall asleep. Arithmetic done in the
|
|
235
242
|
// model's head has neither of them anywhere in the code. `runCodeIn`
|
|
@@ -3,6 +3,7 @@ import { nightProjection } from "./shared.ts";
|
|
|
3
3
|
|
|
4
4
|
export default agent({
|
|
5
5
|
name: "Night Owl",
|
|
6
|
+
description: "Recommends films, music and books for the evening, and works out when to go to bed",
|
|
6
7
|
// The night's recommendation log, pushed to the client after every tool
|
|
7
8
|
// call. The page renders `useAgentState(nightProjection)` and keeps no copy
|
|
8
9
|
// of its own, so a reload resumes with the list intact.
|
|
@@ -2,6 +2,12 @@ You are Night Owl, a cozy evening companion. You help people wind down,
|
|
|
2
2
|
recommend entertainment, and share interesting facts about the night sky. Keep
|
|
3
3
|
your tone warm and relaxed. Use short, conversational responses.
|
|
4
4
|
|
|
5
|
+
Every recommendation goes through the recommend tool — call it, then say what
|
|
6
|
+
it gave you. Naming something out of your own head instead leaves the night's
|
|
7
|
+
log empty, so the sidebar shows nothing and revisit has nothing to find later.
|
|
8
|
+
Call it before you speak: saying the title first ends your turn and the pick is
|
|
9
|
+
never recorded.
|
|
10
|
+
|
|
5
11
|
When someone asks about something you already recommended tonight, look it up
|
|
6
12
|
with revisit and pass along their own words — never recall it from memory.
|
|
7
13
|
|
|
@@ -43,6 +43,13 @@ export default nightSlot.tool({
|
|
|
43
43
|
// Two words the listener can name, scored independently: "the spooky
|
|
44
44
|
// books" beats a spooky MOVIE and a cozy BOOK, and "the spooky ones"
|
|
45
45
|
// ties them — which is a refusal that asks, not a coin flip.
|
|
46
|
+
//
|
|
47
|
+
// A hand-written scorer where four sibling templates use `resolveOne`'s
|
|
48
|
+
// built-in `match`, and deliberately: a listener says "books" where the
|
|
49
|
+
// field says `book`, and the built-in matches whole WORDS on both sides
|
|
50
|
+
// with no stemming, so the plural would score nothing and every category
|
|
51
|
+
// would tie. Substring containment against two NAMED fields is the
|
|
52
|
+
// domain fact here, which is exactly what `score` is kept for.
|
|
46
53
|
score: (rec, text) =>
|
|
47
54
|
(text.includes(rec.mood) ? 1 : 0) + (text.includes(rec.category) ? 1 : 0),
|
|
48
55
|
}),
|
|
@@ -23,8 +23,10 @@
|
|
|
23
23
|
import agentDef from "virtual:aai/agent";
|
|
24
24
|
import { dialogRefusalPattern } from "@alexkroman1/aai/testing";
|
|
25
25
|
import {
|
|
26
|
+
describeToolCalls,
|
|
26
27
|
describeTurn,
|
|
27
28
|
type EvalSession,
|
|
29
|
+
expectCalled,
|
|
28
30
|
lastStateIn,
|
|
29
31
|
statesIn,
|
|
30
32
|
toolCallsInTurns,
|
|
@@ -70,17 +72,37 @@ const DRAFT =
|
|
|
70
72
|
describeEval(agentDef, (test) => {
|
|
71
73
|
test(
|
|
72
74
|
"the call opens with a triage, and a triage sends nothing",
|
|
73
|
-
async ({ session }) => {
|
|
75
|
+
async ({ session, mode }) => {
|
|
74
76
|
const turn = await session.say("Morning. What came in?");
|
|
75
|
-
|
|
76
|
-
// Their `route_after_triage
|
|
77
|
+
expectCalled(turn, "triage_inbox");
|
|
78
|
+
// Their `route_after_triage` routed EVERY email: nothing is left
|
|
79
|
+
// `untriaged`. `open` is allowed because a desk that went on to open the
|
|
80
|
+
// first one has still triaged all eight, and whether it opens unprompted
|
|
81
|
+
// is the next case's business rather than this one's.
|
|
77
82
|
const view = latest(session);
|
|
78
|
-
expect(view?.emails
|
|
79
|
-
expect(
|
|
80
|
-
|
|
81
|
-
|
|
83
|
+
expect(view?.emails).toHaveLength(TRIAGE_SCRIPT.length);
|
|
84
|
+
expect(
|
|
85
|
+
view?.emails.every((e) => e.status !== "untriaged"),
|
|
86
|
+
describeTurn(turn),
|
|
87
|
+
).toBe(true);
|
|
88
|
+
// The exact split is the TRIAGE model's judgment — one verdict per email,
|
|
89
|
+
// eight of them — so it is pinned only where `TRIAGE_SCRIPT` determines
|
|
90
|
+
// it. Live it drifts: a run that filed nothing failed this case on "expected
|
|
91
|
+
// [] to have a length of 2", which reads as broken routing rather than as
|
|
92
|
+
// a model that found every email worth answering.
|
|
93
|
+
if (mode === "stub") {
|
|
94
|
+
expect(view?.emails.filter((e) => e.status === "closed")).toHaveLength(2);
|
|
95
|
+
expect(view?.emails.filter((e) => e.status === "queued")).toHaveLength(6);
|
|
96
|
+
}
|
|
97
|
+
// THE claim, and the one this case is named for: reading the inbox sent
|
|
98
|
+
// nothing. Live, that is all it asserts.
|
|
82
99
|
expect(view?.sent).toEqual([]);
|
|
83
100
|
expect(toolNames(turn.toolCalls)).not.toContain("accept");
|
|
101
|
+
// A triage is not a proposal — true of the SCRIPT, which runs `triage_inbox`
|
|
102
|
+
// and stops. A live desk that opened the first email as well has staged a
|
|
103
|
+
// proposal and still sent nothing, so pinning this live measured its
|
|
104
|
+
// helpfulness rather than the gate.
|
|
105
|
+
if (mode === "stub") expect(view?.proposal).toBeNull();
|
|
84
106
|
},
|
|
85
107
|
{
|
|
86
108
|
stubReply: [
|
|
@@ -94,18 +116,37 @@ describeEval(agentDef, (test) => {
|
|
|
94
116
|
test(
|
|
95
117
|
"a draft is staged and read back, and nothing is sent before a yes",
|
|
96
118
|
async ({ session }) => {
|
|
97
|
-
|
|
119
|
+
// Two turns, and the second only repeats the instruction the first
|
|
120
|
+
// carried. The desk opens the email and then usually SPEAKS — one tool
|
|
121
|
+
// per reply is the live model's median — so reading both calls out of a
|
|
122
|
+
// single turn measured that rather than the gate. Nothing below cares
|
|
123
|
+
// which turn the staging landed in: the claim is that staging produced a
|
|
124
|
+
// READ-BACK and not a receipt, and that nothing was sent without a yes.
|
|
125
|
+
//
|
|
126
|
+
// The nudge is worded twice over. "Go ahead and draft that reply" reads as
|
|
127
|
+
// APPROVAL to a live model, which answered it with `accept` — passing the
|
|
128
|
+
// chain and failing the one assertion this case exists for. "Draft it, but
|
|
129
|
+
// do not send anything yet" fixed that and cost the other half: the desk
|
|
130
|
+
// heard the negation and did nothing at all, and a bare "write that reply
|
|
131
|
+
// for me" was no better. What works is an instruction to ACT that names
|
|
132
|
+
// the reply AND its content while saying nothing about sending — there is
|
|
133
|
+
// no yes in it to mishear, and nothing to read as "wait".
|
|
134
|
+
const turns = await session.sayAll([
|
|
98
135
|
"Open the one from Dana at Northwind and reply that yes, inference stays inside their VPC.",
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
136
|
+
"Write the reply now — say yes, it stays inside their VPC.",
|
|
137
|
+
]);
|
|
138
|
+
const calls = toolCallsInTurns(turns);
|
|
139
|
+
const names = toolNames(calls);
|
|
140
|
+
// Across BOTH turns, and named: "expected [ 'open_email' ] to include
|
|
141
|
+
// 'draft_reply'" said nothing about what the desk did instead.
|
|
142
|
+
expectCalled(turns, "open_email", "draft_reply");
|
|
103
143
|
// The staging tool answered with the read-back, not a receipt.
|
|
104
|
-
const staged =
|
|
144
|
+
const staged = calls.find((call) => call.name === "draft_reply");
|
|
105
145
|
expect(staged?.result).toMatch(/awaitingDecision/);
|
|
106
146
|
expect(staged?.result).toMatch(/Nothing has been sent/);
|
|
107
|
-
// The assistant asks; it does not decide. An `accept` in
|
|
108
|
-
// the
|
|
147
|
+
// The assistant asks; it does not decide. An `accept` anywhere in here is
|
|
148
|
+
// the agent confirming on its own initiative — neither utterance was a
|
|
149
|
+
// yes to SEND, only an instruction to draft.
|
|
109
150
|
expect(names).not.toContain("accept");
|
|
110
151
|
// THE claim: through every frame, nothing went out.
|
|
111
152
|
for (const view of frames(session)) expect(view.sent).toEqual([]);
|
|
@@ -117,6 +158,7 @@ describeEval(agentDef, (test) => {
|
|
|
117
158
|
{
|
|
118
159
|
stubReply: [
|
|
119
160
|
{ tool: "open_email", args: { which: "m2" } },
|
|
161
|
+
"Dana is asking whether inference stays inside their VPC.",
|
|
120
162
|
{ tool: "draft_reply", args: { content: DRAFT } },
|
|
121
163
|
"Here's the draft: Dana, it stays inside your VPC, models included. Send it?",
|
|
122
164
|
],
|
|
@@ -145,8 +187,14 @@ describeEval(agentDef, (test) => {
|
|
|
145
187
|
test(
|
|
146
188
|
"the executive's yes is the only thing that sends",
|
|
147
189
|
async ({ session }) => {
|
|
190
|
+
// Three turns: the request, an instruction to draft, THEN the yes. The
|
|
191
|
+
// middle one exists because the desk reliably opens the email and speaks
|
|
192
|
+
// rather than chaining the staging into the same reply, which left this
|
|
193
|
+
// case failing on a draft that had not happened yet rather than on the
|
|
194
|
+
// gate it is here to measure. The yes is still the only send.
|
|
148
195
|
const turns = await session.sayAll([
|
|
149
196
|
"Open Dana's email from Northwind and reply that inference stays inside their VPC.",
|
|
197
|
+
"Write the reply now — say inference stays inside their VPC.",
|
|
150
198
|
"Yes. Send it.",
|
|
151
199
|
]);
|
|
152
200
|
const calls = toolCallsInTurns(turns);
|
|
@@ -154,7 +202,11 @@ describeEval(agentDef, (test) => {
|
|
|
154
202
|
// Staged first, sent second, once each — reversed, or a send with nothing
|
|
155
203
|
// staged, is the regression this template's whole shape exists to prevent.
|
|
156
204
|
expect(names.indexOf("draft_reply"), describeTurn(turns[0]!)).toBeGreaterThanOrEqual(0);
|
|
157
|
-
|
|
205
|
+
// Named across BOTH turns: "expected -1 to be greater than 2" says a send
|
|
206
|
+
// never happened and nothing about what the desk did with the yes instead.
|
|
207
|
+
expect(names.lastIndexOf("accept"), describeToolCalls(calls)).toBeGreaterThan(
|
|
208
|
+
names.indexOf("draft_reply"),
|
|
209
|
+
);
|
|
158
210
|
const sent = calls.filter(
|
|
159
211
|
(call) => call.name === "accept" && /"sent"/.test(call.result ?? ""),
|
|
160
212
|
);
|
|
@@ -172,6 +224,7 @@ describeEval(agentDef, (test) => {
|
|
|
172
224
|
{
|
|
173
225
|
stubReply: [
|
|
174
226
|
{ tool: "open_email", args: { which: "m2" } },
|
|
227
|
+
"Dana wants to know whether inference stays inside their VPC.",
|
|
175
228
|
{ tool: "draft_reply", args: { content: DRAFT } },
|
|
176
229
|
"Here's the draft — it stays inside your VPC. Send it?",
|
|
177
230
|
{ tool: "accept" },
|
|
@@ -186,7 +239,7 @@ describeEval(agentDef, (test) => {
|
|
|
186
239
|
async ({ session }) => {
|
|
187
240
|
const turn = await session.say("Open the Docusign one.");
|
|
188
241
|
const names = toolNames(turn.toolCalls);
|
|
189
|
-
|
|
242
|
+
expectCalled(turn, "open_email");
|
|
190
243
|
// Their `notify` route halts for the human with nothing drafted.
|
|
191
244
|
expect(names).not.toContain("draft_reply");
|
|
192
245
|
const view = latest(session);
|
|
@@ -207,11 +260,19 @@ describeEval(agentDef, (test) => {
|
|
|
207
260
|
"a scheduling request goes through the meeting assistant before any draft",
|
|
208
261
|
async ({ session }) => {
|
|
209
262
|
const scheduling = INBOX.find((e) => e.id === "m4");
|
|
210
|
-
|
|
263
|
+
// Two turns, and the second NAMES the action. "Yes, go ahead" left this a
|
|
264
|
+
// coin toss (measured 1/2 over repeats) because it authorises without
|
|
265
|
+
// saying what to do; naming the calendar is what a caller answering
|
|
266
|
+
// "shall I check?" actually says. The judgement being
|
|
267
|
+
// measured is that the CALENDAR is consulted before a time is written
|
|
268
|
+
// down — an ordering claim, and the ordering holds across the pair.
|
|
269
|
+
const turns = await session.sayAll([
|
|
211
270
|
`Open the one from Sam Reyes, "${scheduling?.subject}", and sort out a time with him.`,
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
271
|
+
"Check my calendar and find us a slot.",
|
|
272
|
+
]);
|
|
273
|
+
const calls = toolCallsInTurns(turns);
|
|
274
|
+
const names = toolNames(calls);
|
|
275
|
+
expectCalled(turns, "meeting_assistant");
|
|
215
276
|
// The calendar is consulted before a time is ever written down: the brief
|
|
216
277
|
// says never to guess free time, and a draft or an invite that came first
|
|
217
278
|
// would have.
|
|
@@ -220,8 +281,8 @@ describeEval(agentDef, (test) => {
|
|
|
220
281
|
const at = names.indexOf(later);
|
|
221
282
|
if (at >= 0) expect(at).toBeGreaterThan(checked);
|
|
222
283
|
}
|
|
223
|
-
// And the
|
|
224
|
-
const report =
|
|
284
|
+
// And the subagent's report is what came back — not a calendar dump.
|
|
285
|
+
const report = calls.find((call) => call.name === "meeting_assistant");
|
|
225
286
|
expect(report?.result).toMatch(/availability/);
|
|
226
287
|
expect(latest(session)?.sent).toEqual([]);
|
|
227
288
|
},
|
|
@@ -35,6 +35,7 @@ import systemPrompt from "./system-prompt.md?raw";
|
|
|
35
35
|
*/
|
|
36
36
|
export default agent({
|
|
37
37
|
name: "Executive Assistant",
|
|
38
|
+
description: "Triages an executive's inbox by phone and drafts the replies for their approval",
|
|
38
39
|
// The voice rules in the file, plus who the principal is — their
|
|
39
40
|
// `config.yaml`'s `full_name`, `name`, `background` and `timezone`, rendered
|
|
40
41
|
// from the one place `inbox.ts` declares them so the prompt cannot name a
|
|
@@ -118,7 +118,7 @@ export const meetingAssistant = subagent({
|
|
|
118
118
|
});
|
|
119
119
|
|
|
120
120
|
/**
|
|
121
|
-
* Their `find_meeting_time`: hand the thread to the
|
|
121
|
+
* Their `find_meeting_time`: hand the thread to the subagent and return what
|
|
122
122
|
* it concluded, plus what the wait cost — the sentence the caller was owed
|
|
123
123
|
* while the line was quiet.
|
|
124
124
|
*
|
|
@@ -135,7 +135,9 @@ export function draftingBrief(exec: Executive, memory: Memory): string {
|
|
|
135
135
|
text.trim() === "" ? [] : [`${label}: ${text.trim()}`];
|
|
136
136
|
return [
|
|
137
137
|
`You are ${exec.fullName}'s executive assistant, helping ${exec.name} respond to this email. ${exec.background}`,
|
|
138
|
-
"Choose ONE tool
|
|
138
|
+
"Choose ONE tool and CALL IT NOW, in this same turn, before you say anything to " +
|
|
139
|
+
`${exec.name}. Speaking ends your turn: a sentence promising to check the calendar or ` +
|
|
140
|
+
"draft a reply, with no tool behind it, is a promise you never keep.",
|
|
139
141
|
`ask_question — when you lack information only ${exec.name} has. Never draft with a placeholder for a name, an email or a fact; ask instead. Never ask ${exec.name} when they are free — that is meeting_assistant's job.`,
|
|
140
142
|
`draft_reply — when you have enough to respond. Write as ${exec.name}, never as an assistant. Add a new recipient only when ${exec.name} asked for it and you know the address; never invent one.`,
|
|
141
143
|
`meeting_assistant — when a legitimate sender is trying to schedule a meeting. It reads ${exec.name}'s calendar and answers with the free slots. Not for a meeting already booked.`,
|
|
@@ -2,13 +2,13 @@ You are an executive assistant on a phone call with the person you work for. You
|
|
|
2
2
|
|
|
3
3
|
How a call runs:
|
|
4
4
|
|
|
5
|
-
- Start with `triage_inbox`.
|
|
6
|
-
- `open_email` hands you the thread and a brief. The brief is how to handle that email — read it and follow it.
|
|
5
|
+
- Start with `triage_inbox`. If they have already named an email or said what they want done with one, `open_email` it in the SAME turn and carry out their instruction before you speak — "I'll open the one from Dana" is not opening it, and your turn ends the moment you say it. If they only asked what came in, say how many need them and how many are just worth knowing about, and let them steer. Never summarise an email you have not opened.
|
|
6
|
+
- `open_email` hands you the thread and a brief. The brief is how to handle that email — read it and follow it. ACT FIRST, then talk: call `draft_reply`, `ask_question`, `meeting_assistant`, `send_calendar_invite`, `new_email` or `ignore`, and only then give the executive the gist and what you have staged. Speaking ends your turn, so a sentence before the tool means the tool never runs and they are left holding a promise.
|
|
7
7
|
- **A draft is staged, never sent.** `draft_reply` and `new_email` rewrite your text in the executive's voice and hand it back for you to read aloud. Read it in full, then ask: send it, change something, or skip it? The same for a calendar invite.
|
|
8
8
|
- **Their answer is exactly one tool.** A clear yes is `accept` — the only tool that sends anything. A dictated replacement is `edit`. Feedback, instructions, or the answer to a question you asked is `respond`, after which you draft again. A skip is `ignore`.
|
|
9
9
|
- Never call `accept` on your own initiative, never claim something was sent before `accept` has answered, and never say what a draft says before the tool that staged it has answered — anything you would say before that is invented.
|
|
10
10
|
- When an email is only worth knowing about, tell them about it in a sentence and ask if they want to do anything. Instructions are `respond`; "no, move on" is `ignore`.
|
|
11
|
-
- For anything about free time or booking a meeting, ask `meeting_assistant` — never guess the calendar and never ask the executive when they are free.
|
|
11
|
+
- For anything about free time or booking a meeting, ask `meeting_assistant` — never guess the calendar and never ask the executive when they are free. Call it before you say anything about the calendar: "I'll check when you're free" with no answer behind it ends your turn and checks nothing.
|
|
12
12
|
- When they correct you — a different tone, a person to loop in, how long meetings should be — the tool that takes their words also learns from them. Say what you noted in one clause and carry on; `review_memory` reads it all back if they ask.
|
|
13
13
|
- When one email is settled, `open_email` the next without being asked, until `inbox_status` says nothing is queued.
|
|
14
14
|
|
|
@@ -6,16 +6,16 @@ import { threadText } from "../prompts.ts";
|
|
|
6
6
|
import { assistantSlot, DRAFTING, openEmail, reviewFlow } from "../shared.ts";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* Their `MeetingAssistant` → `find_meeting_time`: a
|
|
9
|
+
* Their `MeetingAssistant` → `find_meeting_time`: a subagent reads the
|
|
10
10
|
* calendar and reports the free slots, and the report comes back as this
|
|
11
11
|
* tool's result — their `ToolMessage` back into `draft_response`. The
|
|
12
|
-
*
|
|
12
|
+
* subagent lives in `../meeting.ts`, so the calendar lookups never
|
|
13
13
|
* reach this conversation; what does is one dense sentence.
|
|
14
14
|
*
|
|
15
15
|
* No `send`: the call stays in `drafting`, because knowing the free slots is
|
|
16
16
|
* not yet a proposal. `draft_reply` or `send_calendar_invite` comes next.
|
|
17
17
|
*
|
|
18
|
-
* A report the
|
|
18
|
+
* A report the subagent's guardrail never accepted is handed on anyway, with
|
|
19
19
|
* `usable: false` and a different `next` — the desk is on a live call and there
|
|
20
20
|
* IS an answer, so a `ToolFailure` would throw away the one thing it learned.
|
|
21
21
|
*/
|
|
@@ -22,28 +22,20 @@ import {
|
|
|
22
22
|
similarExamples,
|
|
23
23
|
} from "../shared.ts";
|
|
24
24
|
|
|
25
|
-
/**
|
|
26
|
-
* Words too common in a subject line to be what the executive meant — "the
|
|
27
|
-
* Northwind one" is about Northwind. Six of them, kept short deliberately: a
|
|
28
|
-
* longer list starts deciding which real words do not count.
|
|
29
|
-
*/
|
|
30
|
-
const FILLER = new Set(["the", "that", "one", "your", "with", "for"]);
|
|
31
|
-
|
|
32
|
-
const wordsIn = (text: string) =>
|
|
33
|
-
(text.toLowerCase().match(/[a-z0-9]{3,}/g) ?? []).filter((word) => !FILLER.has(word));
|
|
34
|
-
|
|
35
25
|
/**
|
|
36
26
|
* How the executive refers to an email when they are not reading an id: by who
|
|
37
|
-
* sent it and what it is about.
|
|
38
|
-
*
|
|
27
|
+
* sent it and what it is about.
|
|
28
|
+
*
|
|
29
|
+
* `match` is `resolveOne`'s own word overlap — the filler list and the
|
|
30
|
+
* three-character floor this template used to declare here are the SDK's now,
|
|
31
|
+
* along with the tokenizer; four templates had written four different versions
|
|
32
|
+
* of them. What stays is the domain part: the SENDER and SUBJECT only, because a
|
|
33
|
+
* body match on "meeting" would tie half the inbox.
|
|
39
34
|
*/
|
|
40
35
|
const BY_WHAT_IT_IS: ResolveOneOptions<DeepReadonly<InboxEmail>> = {
|
|
41
36
|
label: "email",
|
|
42
37
|
describe: (email) => `${email.id}: "${email.subject}" from ${email.from}`,
|
|
43
|
-
|
|
44
|
-
const said = new Set(wordsIn(spoken));
|
|
45
|
-
return wordsIn(`${email.from} ${email.subject}`).filter((word) => said.has(word)).length;
|
|
46
|
-
},
|
|
38
|
+
match: (email) => `${email.from} ${email.subject}`,
|
|
47
39
|
};
|
|
48
40
|
|
|
49
41
|
/**
|
|
@@ -15,7 +15,15 @@ import agentDef from "virtual:aai/agent";
|
|
|
15
15
|
// a script names — so a stub run proves the wiring and proves nothing about
|
|
16
16
|
// what the agent chose.
|
|
17
17
|
import { dialogResultSchema } from "@alexkroman1/aai/testing";
|
|
18
|
-
import {
|
|
18
|
+
import {
|
|
19
|
+
describeToolCalls,
|
|
20
|
+
expectCalled,
|
|
21
|
+
lastStateIn,
|
|
22
|
+
lastToolResultIn,
|
|
23
|
+
toolCallsInTurns,
|
|
24
|
+
toolNames,
|
|
25
|
+
toolResultIn,
|
|
26
|
+
} from "@alexkroman1/aai-runtime/eval";
|
|
19
27
|
import { describeEval } from "@alexkroman1/aai-runtime/eval/vitest";
|
|
20
28
|
import { expect } from "vitest";
|
|
21
29
|
import { z } from "zod";
|
|
@@ -30,22 +38,44 @@ describeEval(agentDef, (test) => {
|
|
|
30
38
|
test(
|
|
31
39
|
"a caller who wants a room gets the booking flow, not a form",
|
|
32
40
|
async ({ session }) => {
|
|
33
|
-
|
|
41
|
+
// Two turns, and the second says nothing new. A live model opens the flow
|
|
42
|
+
// and then usually SPEAKS — one tool per reply is its median — so reading
|
|
43
|
+
// both calls out of one turn measured its verbosity rather than its
|
|
44
|
+
// routing. What this case claims is the ORDER (the flow before any
|
|
45
|
+
// detail) and that the stay it records is the one the caller ALREADY
|
|
46
|
+
// gave, which the argument assertions below pin without either call
|
|
47
|
+
// having to land on the same breath.
|
|
48
|
+
const turns = await session.sayAll([
|
|
34
49
|
"Hi, I'd like to book a room for July fourteenth to the seventeenth, two adults.",
|
|
35
|
-
|
|
50
|
+
"That's right, go ahead.",
|
|
51
|
+
]);
|
|
52
|
+
const calls = toolCallsInTurns(turns);
|
|
36
53
|
|
|
37
54
|
// The flow first — never name, email or card before it is running — and
|
|
38
55
|
// then the dates the caller already gave, recorded rather than re-asked.
|
|
39
|
-
const names = toolNames(
|
|
40
|
-
expect(names[0]).toBe("start_room_booking");
|
|
41
|
-
|
|
56
|
+
const names = toolNames(calls);
|
|
57
|
+
expect(names[0], describeToolCalls(calls)).toBe("start_room_booking");
|
|
58
|
+
expectCalled(turns, "set_stay");
|
|
42
59
|
expect(names).not.toContain("record_guest_details");
|
|
43
60
|
expect(names).not.toContain("record_card");
|
|
44
61
|
|
|
62
|
+
// RECORDED, not re-asked: the dates and the party size in the call's
|
|
63
|
+
// arguments are the ones from the opening utterance, so a desk that
|
|
64
|
+
// asked for them again would have to have been told again to get here.
|
|
65
|
+
// The year is whatever the quick facts resolve "July fourteenth" to, so
|
|
66
|
+
// only the month and day are pinned.
|
|
67
|
+
const staySent = calls.find((call) => call.name === "set_stay");
|
|
68
|
+
expect(String(staySent?.args.checkIn), describeToolCalls(calls)).toMatch(/-07-14$/);
|
|
69
|
+
expect(String(staySent?.args.checkOut)).toMatch(/-07-17$/);
|
|
70
|
+
expect(staySent?.args.guests).toBe(2);
|
|
71
|
+
|
|
45
72
|
// The stay landed the flow on the room step, and the options the caller
|
|
46
73
|
// is about to be OFFERED came out of the same call.
|
|
47
|
-
|
|
48
|
-
|
|
74
|
+
// `lastToolResultIn` over a multi-turn scope: a desk that recorded the
|
|
75
|
+
// stay and then corrected it has called this twice, and the SETTLED one is
|
|
76
|
+
// what the caller was offered. `toolResultIn` refuses the scope outright.
|
|
77
|
+
const stay = lastToolResultIn(
|
|
78
|
+
calls,
|
|
49
79
|
"set_stay",
|
|
50
80
|
dialogResultSchema(z.object({ options: z.string() })),
|
|
51
81
|
);
|
|
@@ -55,6 +85,7 @@ describeEval(agentDef, (test) => {
|
|
|
55
85
|
{
|
|
56
86
|
stubReply: [
|
|
57
87
|
{ tool: "start_room_booking" },
|
|
88
|
+
"Let me get that stay down for you.",
|
|
58
89
|
{ tool: "set_stay", args: { checkIn: "2026-07-14", checkOut: "2026-07-17", guests: 2 } },
|
|
59
90
|
"Queen, king, suite or penthouse?",
|
|
60
91
|
],
|
|
@@ -64,13 +95,31 @@ describeEval(agentDef, (test) => {
|
|
|
64
95
|
test(
|
|
65
96
|
"a cancellation is verified by a tool, then cancelled by a tool, and the refund is the tool's",
|
|
66
97
|
async ({ session }) => {
|
|
67
|
-
|
|
98
|
+
// Across two turns, because a desk that verifies and then confirms before
|
|
99
|
+
// it cancels is the realistic call and the better one. The claim is the
|
|
100
|
+
// ORDER — verified before cancelled, once each, nothing else touching the
|
|
101
|
+
// booking — and that the refund figure is the TOOL's rather than a number
|
|
102
|
+
// the model composed. None of that needs both calls in one reply, which is
|
|
103
|
+
// more than the live model's one-tool-per-reply median reliably gives.
|
|
104
|
+
const turns = await session.sayAll([
|
|
68
105
|
"I need to cancel my booking. Smith, and the code is H T L dash A B one two.",
|
|
106
|
+
"Yes, cancel it please.",
|
|
107
|
+
]);
|
|
108
|
+
const calls = toolCallsInTurns(turns);
|
|
109
|
+
const names = toolNames(calls);
|
|
110
|
+
expectCalled(turns, "verify_booking", "cancel_room_booking");
|
|
111
|
+
// Once each, and in that order.
|
|
112
|
+
expect(names.filter((n) => n === "verify_booking")).toHaveLength(1);
|
|
113
|
+
expect(names.filter((n) => n === "cancel_room_booking")).toHaveLength(1);
|
|
114
|
+
expect(names.indexOf("verify_booking")).toBeLessThan(names.indexOf("cancel_room_booking"));
|
|
115
|
+
// And nothing ELSE moved the booking on the way through.
|
|
116
|
+
expect(names.filter((n) => n !== "verify_booking" && n !== "cancel_room_booking")).toEqual(
|
|
117
|
+
[],
|
|
69
118
|
);
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const cancelled =
|
|
73
|
-
|
|
119
|
+
// The settled cancellation. Exactly-once is asserted above, on its own,
|
|
120
|
+
// so this read does not also have to carry it.
|
|
121
|
+
const cancelled = lastToolResultIn(
|
|
122
|
+
calls,
|
|
74
123
|
"cancel_room_booking",
|
|
75
124
|
z.object({ cancelled: z.literal(true), withinWindow: z.boolean(), refund: z.number() }),
|
|
76
125
|
);
|
|
@@ -79,12 +128,13 @@ describeEval(agentDef, (test) => {
|
|
|
79
128
|
expect(cancelled.refund).toBe(59_360);
|
|
80
129
|
|
|
81
130
|
// And the screen shows it: the verification was cleared by the cancel.
|
|
82
|
-
const desk = lastStateIn(
|
|
131
|
+
const desk = lastStateIn(session.events(), ProjectedDesk);
|
|
83
132
|
expect(desk?.verified).toBeNull();
|
|
84
133
|
},
|
|
85
134
|
{
|
|
86
135
|
stubReply: [
|
|
87
136
|
{ tool: "verify_booking", args: { lastName: "Smith", confirmationCode: "HTL-AB12" } },
|
|
137
|
+
"I have the booking — five nights, checking in Friday. Shall I cancel it?",
|
|
88
138
|
{ tool: "cancel_room_booking" },
|
|
89
139
|
"That's cancelled, and the full amount goes back to your card.",
|
|
90
140
|
],
|
|
@@ -94,17 +144,30 @@ describeEval(agentDef, (test) => {
|
|
|
94
144
|
test(
|
|
95
145
|
"asked whether someone is staying here, the desk takes a message and reveals nothing",
|
|
96
146
|
async ({ session }) => {
|
|
97
|
-
|
|
98
|
-
|
|
147
|
+
// A third turn, naming the recipient again. The desk is told not to invent
|
|
148
|
+
// a value the caller has not given, so wanting to hear who the message is
|
|
149
|
+
// FOR before it records one is the prompt being obeyed — and it left this
|
|
150
|
+
// case reading "no call to take_guest_message; this scope called: no
|
|
151
|
+
// tools", which reads as the privacy gate having failed when it had not.
|
|
152
|
+
// The claim is what the desk NEVER does (look anyone up) and that the
|
|
153
|
+
// receipt says nothing about presence; neither depends on the turn.
|
|
154
|
+
const turns = await session.sayAll([
|
|
155
|
+
"Is Jonathan Pierce staying with you? Can you put me through to his room?",
|
|
99
156
|
"Fine, take a message then. It's Mark Ellis, four one five, five five five, oh one hundred. Tell him dinner is at eight.",
|
|
100
|
-
|
|
157
|
+
"Record it now please. It is for Jonathan Pierce, from Mark Ellis on four one five, " +
|
|
158
|
+
"five five five, oh one hundred, and the message is that dinner is at eight.",
|
|
159
|
+
]);
|
|
160
|
+
const calls = toolCallsInTurns(turns);
|
|
101
161
|
|
|
102
162
|
// No lookup of any kind — there is nothing to look up that the caller may
|
|
103
163
|
// be told — and the message tool's result carries no word about presence.
|
|
104
164
|
const names = toolNames(session.toolCalls());
|
|
105
|
-
expect(
|
|
106
|
-
|
|
107
|
-
|
|
165
|
+
expect(
|
|
166
|
+
names.filter((n) => n !== "take_guest_message"),
|
|
167
|
+
describeToolCalls(calls),
|
|
168
|
+
).toEqual([]);
|
|
169
|
+
const taken = lastToolResultIn(
|
|
170
|
+
calls,
|
|
108
171
|
"take_guest_message",
|
|
109
172
|
z
|
|
110
173
|
.object({ recorded: z.literal(true), reference: z.string() })
|
|
@@ -121,11 +184,12 @@ describeEval(agentDef, (test) => {
|
|
|
121
184
|
),
|
|
122
185
|
);
|
|
123
186
|
expect(JSON.stringify(taken)).not.toMatch(/delivered|undeliverable|303/);
|
|
124
|
-
expect(
|
|
187
|
+
expect(turns.at(-1)?.completed).toBe(true);
|
|
125
188
|
},
|
|
126
189
|
{
|
|
127
190
|
stubReply: [
|
|
128
191
|
"I can't share whether anyone is staying with us, but I can take a message that gets passed along if we can.",
|
|
192
|
+
"Of course — who should it go to?",
|
|
129
193
|
{
|
|
130
194
|
tool: "take_guest_message",
|
|
131
195
|
args: {
|
|
@@ -29,7 +29,8 @@ import {
|
|
|
29
29
|
spokenTime,
|
|
30
30
|
TODAY,
|
|
31
31
|
} from "./records.ts";
|
|
32
|
-
import { deskProjection,
|
|
32
|
+
import { deskProjection, hotelSlot } from "./session.ts";
|
|
33
|
+
import { deskView } from "./shared.ts";
|
|
33
34
|
|
|
34
35
|
// ─── Harness ─────────────────────────────────────────────────────────────────
|
|
35
36
|
|
|
@@ -2,14 +2,15 @@ import { agent } from "@alexkroman1/aai";
|
|
|
2
2
|
import { DIALOGS } from "./desk.ts";
|
|
3
3
|
import { DESK_EVENTS } from "./events.ts";
|
|
4
4
|
import { PRICING, spokenDate, TODAY, usd } from "./records.ts";
|
|
5
|
-
import { deskProjection } from "./
|
|
5
|
+
import { deskProjection } from "./session.ts";
|
|
6
6
|
import systemPrompt from "./system-prompt.md?raw";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* A boutique hotel's front desk, on the phone — LiveKit Agents'
|
|
10
10
|
* `hotel_receptionist` example as a voice agent. `shared.ts` carries the
|
|
11
|
-
* attribution and the their-name → our-name table; `
|
|
12
|
-
*
|
|
11
|
+
* attribution and the their-name → our-name table; `session.ts` holds the slot
|
|
12
|
+
* and the seeded factory, kept out of the browser's reach; `desk.ts` is the
|
|
13
|
+
* booking flow and the reason this template needs `dialogs`.
|
|
13
14
|
*
|
|
14
15
|
* Forty-one tools, and the interesting property is how few of them the model
|
|
15
16
|
* can call WRONG: every booking tool refuses until `verify_booking` has filled
|
|
@@ -20,6 +21,8 @@ import systemPrompt from "./system-prompt.md?raw";
|
|
|
20
21
|
*/
|
|
21
22
|
export default agent({
|
|
22
23
|
name: "The Harborlight Hotel",
|
|
24
|
+
description:
|
|
25
|
+
"Takes a hotel front desk's calls: room bookings, restaurant tables, folios and concierge requests",
|
|
23
26
|
// The receptionist's own screen: who is verified, what is being booked, and
|
|
24
27
|
// the ledger of everything this call wrote — their SQLite changeset stream.
|
|
25
28
|
syncState: deskProjection,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "@alexkroman1/aai-ui/styles.css";
|
|
2
2
|
import { mountClient, useAgentState } from "@alexkroman1/aai-ui";
|
|
3
3
|
import type { ReactNode } from "react";
|
|
4
|
-
import { type DeskView,
|
|
4
|
+
import { type DeskView, deskView, emptyHotelState } from "./shared.ts";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* The receptionist's screen — their `ui_view.py`, which streamed SQLite
|
|
@@ -51,8 +51,20 @@ const KIND_LABELS: Record<DeskView["ledger"][number]["kind"], string> = {
|
|
|
51
51
|
walk: "Walk",
|
|
52
52
|
};
|
|
53
53
|
|
|
54
|
+
// The desk before the first tool call, derived from the projection itself so a
|
|
55
|
+
// new DeskView field can't miss the pre-first-call render.
|
|
56
|
+
//
|
|
57
|
+
// **This template does NOT pass its projection to `useAgentState`**, and the
|
|
58
|
+
// reason is the browser bundle rather than style: that overload derives the
|
|
59
|
+
// empty frame by calling the projection, which calls the slot's `create()` —
|
|
60
|
+
// and this slot's factory lives in `session.ts` and pulls `seed.ts`, so
|
|
61
|
+
// importing it here would ship every seeded booking to the browser.
|
|
62
|
+
// `emptyHotelState()` is the same shape without the seed. Reach for the
|
|
63
|
+
// projection overload everywhere the factory is cheap.
|
|
64
|
+
const EMPTY_VIEW: DeskView = deskView(emptyHotelState());
|
|
65
|
+
|
|
54
66
|
function DeskSidebar() {
|
|
55
|
-
const desk = useAgentState(
|
|
67
|
+
const desk = useAgentState<DeskView>(EMPTY_VIEW);
|
|
56
68
|
return (
|
|
57
69
|
<div className="flex flex-col gap-6 p-4 text-aai-text">
|
|
58
70
|
<Section title="Tonight">
|
|
@@ -22,7 +22,8 @@ import {
|
|
|
22
22
|
type Ticket,
|
|
23
23
|
TODAY,
|
|
24
24
|
} from "./records.ts";
|
|
25
|
-
import {
|
|
25
|
+
import { hotelSlot } from "./session.ts";
|
|
26
|
+
import { addTicket } from "./shared.ts";
|
|
26
27
|
|
|
27
28
|
export interface CatalogBookingSpec<P extends z.ZodObject> {
|
|
28
29
|
description: string;
|