@alexkroman1/aai-cli 16.1.0 → 18.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/_console-audio.d.ts +17 -0
- package/dist/_console-session.d.ts +70 -0
- package/dist/_deno-target.d.ts +15 -14
- package/dist/_dev-env.d.ts +19 -13
- package/dist/{_dev-server-D1wKiA0_.mjs → _dev-server-Dtp4aAlo.mjs} +26 -18
- package/dist/_dev-server.d.ts +5 -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-DXadVNsL.mjs +135 -0
- package/dist/_templates.d.ts +11 -34
- 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 +40 -16
- package/dist/console-BsyE3DyB.mjs +422 -0
- package/dist/console.d.ts +37 -0
- package/dist/{deploy-lldQyJVj.mjs → deploy-B68-x7xM.mjs} +12 -4
- package/dist/deploy.d.ts +9 -0
- package/dist/{dev-Du8pCWFq.mjs → dev-BGWU2zPP.mjs} +1 -1
- package/dist/dev.d.ts +1 -1
- package/dist/{eval-Ducmkt1n.mjs → eval-DB07kTxO.mjs} +1 -1
- package/dist/init-CbOhyNYe.mjs +559 -0
- package/dist/init.d.ts +43 -3
- package/dist/scaffold/CLAUDE.md +161 -166
- package/dist/scaffold/package.json +6 -6
- package/dist/scaffold/vite.config.ts +29 -1
- package/dist/start.d.ts +3 -3
- package/dist/{studio-It7SRfUN.mjs → studio-BRJsw7lr.mjs} +19 -9
- package/dist/templates/applicant-screening-agent/agent.eval.test.ts +20 -6
- package/dist/templates/applicant-screening-agent/agent.test.ts +17 -13
- package/dist/templates/applicant-screening-agent/agent.ts +28 -0
- package/dist/templates/applicant-screening-agent/crews.ts +4 -4
- 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.test.ts +2 -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 +3 -2
- package/dist/templates/custom-pipeline-agent/modes.test.ts +4 -4
- package/dist/templates/custom-pipeline-agent/stages.test.ts +75 -83
- package/dist/templates/document-redline-workflow/agent.ts +2 -0
- package/dist/templates/emergency-dispatch-agent/agent.eval.test.ts +1 -1
- 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 +9 -2
- 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.test.ts +35 -25
- package/dist/templates/executive-inbox-agent/agent.ts +1 -0
- package/dist/templates/executive-inbox-agent/calendar.test.ts +13 -7
- package/dist/templates/executive-inbox-agent/meeting.ts +3 -3
- 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/front-desk-agent/agent.eval.test.ts +174 -0
- package/dist/templates/front-desk-agent/agent.test.ts +150 -0
- package/dist/templates/front-desk-agent/agent.ts +22 -0
- package/dist/templates/front-desk-agent/shared.ts +234 -0
- package/dist/templates/front-desk-agent/system-prompt.md +13 -0
- package/dist/templates/front-desk-agent/tools/verify_account.ts +41 -0
- package/dist/templates/hotel-reception-agent/agent.eval.test.ts +85 -21
- package/dist/templates/hotel-reception-agent/agent.test.ts +3 -3
- 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 +3 -3
- 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 +57 -4
- 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.eval.test.ts +68 -2
- package/dist/templates/pizza-ordering-agent/agent.ts +3 -0
- package/dist/templates/podcast-digest-workflow/agent.ts +4 -0
- package/dist/templates/push-to-talk-agent/agent.eval.test.ts +74 -0
- package/dist/templates/push-to-talk-agent/agent.test.ts +61 -0
- package/dist/templates/push-to-talk-agent/agent.ts +22 -0
- package/dist/templates/push-to-talk-agent/client.tsx +124 -0
- package/dist/templates/push-to-talk-agent/shared.ts +34 -0
- package/dist/templates/push-to-talk-agent/system-prompt.md +11 -0
- package/dist/templates/push-to-talk-agent/tools/list_notes.ts +15 -0
- package/dist/templates/push-to-talk-agent/tools/save_note.ts +26 -0
- package/dist/templates/quickstart-agent/agent.eval.test.ts +91 -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.eval.test.ts +1 -1
- package/dist/templates/research-handoff-agent/agent.test.ts +34 -26
- 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.test.ts +26 -16
- 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.eval.test.ts +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 +124 -5
- package/dist/templates/roadside-assistance-agent/agent.test.ts +39 -7
- 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 +29 -23
- 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 +7 -6
- 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 +61 -36
- package/dist/templates/topic-briefing-agent/agent.ts +4 -1
- package/dist/templates/topic-briefing-agent/shared.ts +19 -18
- 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.eval.test.ts +9 -7
- package/dist/templates/travel-concierge-agent/agent.test.ts +1 -2
- 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.test.ts +3 -1
- 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/_templates-CuP74F8D.mjs +0 -291
- package/dist/init-CY4NAXAA.mjs +0 -183
- package/dist/test-PHHv0Vj6.mjs +0 -83
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// Copyright 2026 the AAI authors. MIT license.
|
|
2
|
+
/**
|
|
3
|
+
* The session's hotel: the seeded factory, the slot it fills, and the
|
|
4
|
+
* projection both ends read.
|
|
5
|
+
*
|
|
6
|
+
* **This module exists to keep `seed.ts` out of the browser bundle**, and it is
|
|
7
|
+
* the same split `retail-orders-agent` makes for the same reason. A slot's
|
|
8
|
+
* factory is a live reference held by the slot object, so nothing can shake it
|
|
9
|
+
* out: any module that reaches `hotelSlot` reaches {@link createHotelState},
|
|
10
|
+
* which reaches `seedHotel`, which is 18.5 KB of seeded bookings on top of
|
|
11
|
+
* `records.ts`. While all three lived in `shared.ts` — the module `client.tsx`
|
|
12
|
+
* imports for its view — every one of those bytes shipped to the page. Measured
|
|
13
|
+
* before this split: all 43 of `seed.ts`'s guest phone numbers were present in
|
|
14
|
+
* the built client bundle.
|
|
15
|
+
*
|
|
16
|
+
* So the rule this file enforces is a layering one: `shared.ts` holds the
|
|
17
|
+
* SHAPES and the pure {@link deskView}, both halves import it freely, and it
|
|
18
|
+
* reaches no seed. Everything that touches seeded data lives here, and the
|
|
19
|
+
* browser never imports this module.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import { sessionSlot } from "@alexkroman1/aai";
|
|
23
|
+
import { TODAY } from "./records.ts";
|
|
24
|
+
import { seedHotel } from "./seed.ts";
|
|
25
|
+
import { deskView, emptyHotelState, type HotelState } from "./shared.ts";
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* A pristine hotel per session, seeded around {@link TODAY}.
|
|
29
|
+
*
|
|
30
|
+
* Built on top of `emptyHotelState()` so the SHAPE is declared once, in
|
|
31
|
+
* `shared.ts`, where the browser's pre-first-call fallback can reach it without
|
|
32
|
+
* reaching the seed.
|
|
33
|
+
*/
|
|
34
|
+
export function createHotelState(): HotelState {
|
|
35
|
+
return { ...emptyHotelState(), ...seedHotel(TODAY) };
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* The session's hotel, as one typed slot.
|
|
40
|
+
*
|
|
41
|
+
* No `after` hook: nothing stored here is derived from anything else stored
|
|
42
|
+
* here. An invoice is written beside its booking by the one function that
|
|
43
|
+
* prices a stay, and a refund decrements the invoice where the dispute is filed.
|
|
44
|
+
* The call log is the one append-only list, and its bound is declared on the
|
|
45
|
+
* slot so it holds whatever path writes it.
|
|
46
|
+
*/
|
|
47
|
+
export const hotelSlot = sessionSlot("hotel", createHotelState, { caps: { log: 40 } });
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* The projection `syncState` pushes.
|
|
51
|
+
*
|
|
52
|
+
* `client.tsx` deliberately does NOT import this — see the note there. It
|
|
53
|
+
* derives its own empty frame from `deskView` instead, because taking the
|
|
54
|
+
* projection would take the slot, and the slot takes the seed.
|
|
55
|
+
*/
|
|
56
|
+
export const deskProjection = hotelSlot.projection(deskView);
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
*
|
|
14
14
|
* | hotel_receptionist | here |
|
|
15
15
|
* | --- | --- |
|
|
16
|
-
* | `HotelDB` over apsw/SQLite, seeded by `fake_data/seed.py` | {@link HotelState}, one `sessionSlot` seeded from `seed.ts` per session |
|
|
16
|
+
* | `HotelDB` over apsw/SQLite, seeded by `fake_data/seed.py` | {@link HotelState}, one `sessionSlot` (in `session.ts`) seeded from `seed.ts` per session |
|
|
17
17
|
* | `Userdata` (verified booking, turn counters, transferred_to) | the same fields on {@link HotelState} |
|
|
18
18
|
* | `VerifyBookingTask` (last name + code, or + card last four; three strikes) | `tools/verify_booking.ts` + {@link requireVerified}, checked by every booking tool |
|
|
19
19
|
* | `BookRoomTask` + `ModifyBookingTask` (one `AgentTask` each, `_step()` derived from captured values) | ONE `booking` dialog in `desk.ts`, `nextStep` in `booking.ts`, a `mode` on the draft |
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
* | `record_followup`, `take_guest_message`, `dispatch_emergency`, … (write-only tables) | {@link Ticket}s on the slot, rendered by `client.tsx` |
|
|
29
29
|
* | a caller who rings off mid-booking (their `abandoned_booking` followup) | `events.ts`, on `agent({ events })` — the one write no tool can make |
|
|
30
30
|
* | `HOTEL_TODAY=2026-06-08` (the simulation pin) | {@link TODAY}, fixed |
|
|
31
|
-
* | `ui_view.py` (SQLite changesets streamed to the playground) | `
|
|
31
|
+
* | `ui_view.py` (SQLite changesets streamed to the playground) | `deskView`, pushed by `syncState` via `session.ts`'s `deskProjection` |
|
|
32
32
|
*
|
|
33
33
|
* **The LLM never owns a money value**, which is their README's first
|
|
34
34
|
* sentence and this port's too: every total comes out of {@link computeInvoice},
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
*/
|
|
53
53
|
|
|
54
54
|
import type { DeepReadonly, Message, ToolFailure } from "@alexkroman1/aai";
|
|
55
|
-
import {
|
|
55
|
+
import { toolFailure } from "@alexkroman1/aai";
|
|
56
56
|
import {
|
|
57
57
|
type Dispute,
|
|
58
58
|
type GuestHistory,
|
|
@@ -73,7 +73,6 @@ import {
|
|
|
73
73
|
type TransferDestination,
|
|
74
74
|
usd,
|
|
75
75
|
} from "./records.ts";
|
|
76
|
-
import { seedHotel } from "./seed.ts";
|
|
77
76
|
|
|
78
77
|
// ─── The booking draft ───────────────────────────────────────────────────────
|
|
79
78
|
|
|
@@ -161,10 +160,24 @@ export interface HotelState {
|
|
|
161
160
|
log: string[];
|
|
162
161
|
}
|
|
163
162
|
|
|
164
|
-
/**
|
|
165
|
-
|
|
163
|
+
/**
|
|
164
|
+
* The hotel's shape with nothing in it — no seed.
|
|
165
|
+
*
|
|
166
|
+
* `session.ts`'s {@link createHotelState} builds the real seeded state on top
|
|
167
|
+
* of this, so the shape is declared once. It lives HERE, apart from that,
|
|
168
|
+
* because `client.tsx` needs a `HotelState` for its pre-first-call fallback and
|
|
169
|
+
* must not import `session.ts`: that module pulls `seed.ts`, which would then
|
|
170
|
+
* land in the browser bundle.
|
|
171
|
+
*/
|
|
172
|
+
export function emptyHotelState(): HotelState {
|
|
166
173
|
return {
|
|
167
|
-
|
|
174
|
+
rooms: [],
|
|
175
|
+
tables: [],
|
|
176
|
+
bookings: [],
|
|
177
|
+
reservations: [],
|
|
178
|
+
invoices: [],
|
|
179
|
+
disputes: [],
|
|
180
|
+
guestHistory: [],
|
|
168
181
|
tickets: [],
|
|
169
182
|
verifiedCode: null,
|
|
170
183
|
verifyAttempts: 0,
|
|
@@ -176,17 +189,6 @@ export function createHotelState(): HotelState {
|
|
|
176
189
|
};
|
|
177
190
|
}
|
|
178
191
|
|
|
179
|
-
/**
|
|
180
|
-
* The session's hotel, as one typed slot.
|
|
181
|
-
*
|
|
182
|
-
* No `after` hook: nothing stored here is derived from anything else stored
|
|
183
|
-
* here. An invoice is written beside its booking by the one function that
|
|
184
|
-
* prices a stay, and a refund decrements the invoice where the dispute is filed.
|
|
185
|
-
* The call log is the one append-only list, and its bound is declared on the
|
|
186
|
-
* slot so it holds whatever path writes it.
|
|
187
|
-
*/
|
|
188
|
-
export const hotelSlot = sessionSlot("hotel", createHotelState, { caps: { log: 40 } });
|
|
189
|
-
|
|
190
192
|
/** The hotel as a READ hands it out: deep-frozen, and typed to say so. */
|
|
191
193
|
export type FrozenHotelState = DeepReadonly<HotelState>;
|
|
192
194
|
|
|
@@ -349,6 +351,3 @@ function bookingCounts(state: FrozenHotelState): { inHouse: number; arrivingToda
|
|
|
349
351
|
}
|
|
350
352
|
return { inHouse, arrivingToday };
|
|
351
353
|
}
|
|
352
|
-
|
|
353
|
-
/** The projection BOTH ends use: `syncState` on the agent, `useAgentState` in the client. */
|
|
354
|
-
export const deskProjection = hotelSlot.projection(deskView);
|
|
@@ -45,7 +45,7 @@ Don't narrate what you're about to do, what you just did, or any errors. A real
|
|
|
45
45
|
- Browse without booking: check_room_availability, check_restaurant_availability, lookup_booking, lookup_restaurant_reservation. None of these change anything.
|
|
46
46
|
- A returning guest ("I've stayed before"): lookup_guest_history, and offer to set up what they liked before. Only surface preferences the lookup returns.
|
|
47
47
|
- Sold out: be honest, offer the nights either side, and offer the waitlist (add_to_waitlist) - nothing is held.
|
|
48
|
-
- Caller wants a room: start_room_booking - the call IS your response. Don't ask for name, email, phone or card without the flow running; it is the only path that creates a booking. Inside the flow, follow the status each tool returns: set_stay, choose_room, set_extras, record_guest_details, record_card, the read-back, then confirm_booking once the caller agrees. Two rooms in one call is start_room_booking twice.
|
|
48
|
+
- Caller wants a room: start_room_booking - the call IS your response. Don't ask for name, email, phone or card without the flow running; it is the only path that creates a booking. Inside the flow, follow the status each tool returns, in this order and never ahead of it: set_stay, choose_room, set_extras, record_guest_details, record_card, the read-back, then confirm_booking once the caller agrees. Each of those steps takes the values the caller has ALREADY given - the dates and party size they opened with go straight into set_stay rather than being asked for again, which is what stops this feeling like a form. What you must not do is skip a step to use them: set_stay before start_room_booking has opened the flow is refused, and there is nothing to record into. Two rooms in one call is start_room_booking twice.
|
|
49
49
|
- Changes to an existing booking (dates, room type, view, extras, party size): verify, then start_booking_modification. A guest whose room isn't the view or type they booked is a room MOVE through that flow, not a callback - only fall back to a manager followup if no matching room exists. Cancel via cancel_room_booking (abandon_booking first if a modification is open). Late arrival: flag_late_arrival.
|
|
50
50
|
- Wake-up call: schedule_wakeup_call sets it - never a followup note. Do-not-disturb: set_do_not_disturb, and say an emergency still gets through.
|
|
51
51
|
- Concierge: tours, spa, business centre, flowers - lookup_policy first to present the catalog, let the caller pick, then book_tour / book_spa_appointment / book_business_center / order_flowers. Flight reconfirmation: request_flight_reconfirmation - never claim the flight is confirmed. Ride to the airport: book_airport_car (departures only).
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { deskFlow, IN_BOOKING } from "../desk.ts";
|
|
3
|
-
import { hotelSlot
|
|
3
|
+
import { hotelSlot } from "../session.ts";
|
|
4
|
+
import { note } from "../shared.ts";
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Their `give_up`, on every task: end the flow without making the booking, or
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { toolFailure } from "@alexkroman1/aai";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { isoDate, MAX_PARTY_SIZE, speakCode, spokenDate } from "../records.ts";
|
|
4
|
-
import {
|
|
4
|
+
import { hotelSlot } from "../session.ts";
|
|
5
|
+
import { addTicket } from "../shared.ts";
|
|
5
6
|
|
|
6
7
|
/** Their `add_to_waitlist`: for dates the hotel is sold out on. Holds nothing. */
|
|
7
8
|
export default hotelSlot.updateTool({
|
|
@@ -11,7 +11,8 @@ import {
|
|
|
11
11
|
spokenTime,
|
|
12
12
|
TODAY,
|
|
13
13
|
} from "../records.ts";
|
|
14
|
-
import {
|
|
14
|
+
import { hotelSlot } from "../session.ts";
|
|
15
|
+
import { addTicket } from "../shared.ts";
|
|
15
16
|
|
|
16
17
|
/** Their `book_airport_car`: the hotel car, hotel-to-airport only, charged to the room. */
|
|
17
18
|
export default hotelSlot.updateTool({
|
|
@@ -2,7 +2,8 @@ import { toolFailure } from "@alexkroman1/aai";
|
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { spokenDate, spokenTime } from "../records.ts";
|
|
4
4
|
import { findReservation } from "../restaurant.ts";
|
|
5
|
-
import { hotelSlot
|
|
5
|
+
import { hotelSlot } from "../session.ts";
|
|
6
|
+
import { note } from "../shared.ts";
|
|
6
7
|
|
|
7
8
|
/** Their `cancel_restaurant_reservation`: last name + RES code, no card, no email. */
|
|
8
9
|
export default hotelSlot.updateTool({
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { isToolFailure, toolFailure } from "@alexkroman1/aai";
|
|
2
2
|
import { cancelBooking } from "../hotel.ts";
|
|
3
3
|
import { daysBetween, PRICING, speakUsd, TODAY } from "../records.ts";
|
|
4
|
-
import {
|
|
4
|
+
import { hotelSlot } from "../session.ts";
|
|
5
|
+
import { callerTurns, requireVerified } from "../shared.ts";
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Cancel the verified booking and say what comes back — their
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { isoDate, MAX_PARTY_SIZE, spokenDate, spokenTime } from "../records.ts";
|
|
3
3
|
import { openDinnerSlots } from "../restaurant.ts";
|
|
4
|
-
import { hotelSlot } from "../
|
|
4
|
+
import { hotelSlot } from "../session.ts";
|
|
5
5
|
|
|
6
6
|
/** Their `check_restaurant_availability`: the open slots for a date and party. */
|
|
7
7
|
export default hotelSlot.tool({
|
|
@@ -2,7 +2,7 @@ import { toolFailure } from "@alexkroman1/aai";
|
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { describeRoomOptions, listRoomOptions } from "../hotel.ts";
|
|
4
4
|
import { isoDate, MAX_PARTY_SIZE, ROOM_TYPES, spokenDate } from "../records.ts";
|
|
5
|
-
import { hotelSlot } from "../
|
|
5
|
+
import { hotelSlot } from "../session.ts";
|
|
6
6
|
|
|
7
7
|
/** Their `check_room_availability`: read-only browsing, never a booking. */
|
|
8
8
|
export default hotelSlot.tool({
|
|
@@ -4,7 +4,7 @@ import { bookingStatus, nextStep, requote } from "../booking.ts";
|
|
|
4
4
|
import { AFTER_STAY, deskFlow } from "../desk.ts";
|
|
5
5
|
import { describeRoomOptions, listRoomOptions } from "../hotel.ts";
|
|
6
6
|
import { daysBetween, describeExtras, ROOM_TYPES, ROOM_VIEWS, speakUsd } from "../records.ts";
|
|
7
|
-
import { hotelSlot } from "../
|
|
7
|
+
import { hotelSlot } from "../session.ts";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Record the room type (and view) the caller picked from the options `set_stay`
|
|
@@ -4,7 +4,8 @@ import { bookingStatus, changedFields, nextStep } from "../booking.ts";
|
|
|
4
4
|
import { deskFlow } from "../desk.ts";
|
|
5
5
|
import { bookRoom, updateBooking } from "../hotel.ts";
|
|
6
6
|
import { speakCode, speakUsd } from "../records.ts";
|
|
7
|
-
import {
|
|
7
|
+
import { hotelSlot } from "../session.ts";
|
|
8
|
+
import { bookingByCode, callerTurns, note } from "../shared.ts";
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Finalize the booking — their `confirm_booking` and `confirm_changes`, one
|
|
@@ -2,7 +2,8 @@ import { isToolFailure, toolFailure } from "@alexkroman1/aai";
|
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { requireRoom } from "../hotel.ts";
|
|
4
4
|
import { EMERGENCY_KINDS, type EmergencyKind } from "../records.ts";
|
|
5
|
-
import {
|
|
5
|
+
import { hotelSlot } from "../session.ts";
|
|
6
|
+
import { addTicket } from "../shared.ts";
|
|
6
7
|
|
|
7
8
|
/** What the caller is told to do THEMSELVES, per kind — never a substitute for sending hotel people. */
|
|
8
9
|
const DIRECTION: Record<EmergencyKind, string> = {
|
|
@@ -8,7 +8,8 @@ import {
|
|
|
8
8
|
} from "../disputes.ts";
|
|
9
9
|
import { invoiceFor } from "../hotel.ts";
|
|
10
10
|
import { DISPUTE_CATEGORIES, mintCode } from "../records.ts";
|
|
11
|
-
import { hotelSlot
|
|
11
|
+
import { hotelSlot } from "../session.ts";
|
|
12
|
+
import { note, requireVerified, takenCodes } from "../shared.ts";
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* Handle a dispute on a line item — their `dispute_charge`.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { isToolFailure, toolFailure } from "@alexkroman1/aai";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
import { hotelSlot
|
|
3
|
+
import { hotelSlot } from "../session.ts";
|
|
4
|
+
import { note, requireVerified } from "../shared.ts";
|
|
4
5
|
|
|
5
6
|
/** Their `flag_late_arrival`: a note on the booking so the desk holds the room. */
|
|
6
7
|
export default hotelSlot.updateTool({
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { isToolFailure } from "@alexkroman1/aai";
|
|
2
2
|
import { roomConflict } from "../hotel.ts";
|
|
3
3
|
import { daysBetween, speakUsd, spokenDate } from "../records.ts";
|
|
4
|
-
import { hotelSlot
|
|
4
|
+
import { hotelSlot } from "../session.ts";
|
|
5
|
+
import { requireVerified } from "../shared.ts";
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Read-only lookup of the verified booking — their `lookup_booking`, including
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { isToolFailure, toolFailure } from "@alexkroman1/aai";
|
|
2
2
|
import { invoiceFor } from "../hotel.ts";
|
|
3
3
|
import { speakUsd } from "../records.ts";
|
|
4
|
-
import { hotelSlot
|
|
4
|
+
import { hotelSlot } from "../session.ts";
|
|
5
|
+
import { requireVerified } from "../shared.ts";
|
|
5
6
|
|
|
6
7
|
/** Their `lookup_invoice`: the verified booking's line items, read back. */
|
|
7
8
|
export default hotelSlot.tool({
|
|
@@ -2,7 +2,7 @@ import { toolFailure } from "@alexkroman1/aai";
|
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { spokenDate, spokenTime } from "../records.ts";
|
|
4
4
|
import { findReservation } from "../restaurant.ts";
|
|
5
|
-
import { hotelSlot } from "../
|
|
5
|
+
import { hotelSlot } from "../session.ts";
|
|
6
6
|
|
|
7
7
|
/** Their `lookup_restaurant_reservation`: restaurants verify with last name + RES code. */
|
|
8
8
|
export default hotelSlot.tool({
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
TODAY,
|
|
13
13
|
} from "../records.ts";
|
|
14
14
|
import { findReservation, modifyReservation, openDinnerSlots } from "../restaurant.ts";
|
|
15
|
-
import { hotelSlot } from "../
|
|
15
|
+
import { hotelSlot } from "../session.ts";
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* Move a reservation — their `modify_restaurant_reservation`, one step, same
|
|
@@ -3,7 +3,7 @@ import { z } from "zod";
|
|
|
3
3
|
import { bookingStatus, nextStep } from "../booking.ts";
|
|
4
4
|
import { validateCard } from "../card.ts";
|
|
5
5
|
import { AFTER_DETAILS, deskFlow } from "../desk.ts";
|
|
6
|
-
import { hotelSlot } from "../
|
|
6
|
+
import { hotelSlot } from "../session.ts";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Take the card for a new booking — their `GetCardTask`, whose four recording
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { digitsOf, FOLLOWUP_KINDS, speakCode } from "../records.ts";
|
|
3
|
-
import {
|
|
3
|
+
import { hotelSlot } from "../session.ts";
|
|
4
|
+
import { addTicket } from "../shared.ts";
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Capture something for a human to follow up on — their `record_followup`, the
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { digitsOf, isoDate, speakCode } from "../records.ts";
|
|
3
|
-
import {
|
|
3
|
+
import { hotelSlot } from "../session.ts";
|
|
4
|
+
import { addTicket } from "../shared.ts";
|
|
4
5
|
|
|
5
6
|
/** Their `record_group_inquiry`: fifteen or more guests is a block, never a booking. */
|
|
6
7
|
export default hotelSlot.updateTool({
|
|
@@ -3,7 +3,7 @@ import { z } from "zod";
|
|
|
3
3
|
import { bookingStatus, nextStep } from "../booking.ts";
|
|
4
4
|
import { AFTER_EXTRAS, deskFlow } from "../desk.ts";
|
|
5
5
|
import { digitsOf } from "../records.ts";
|
|
6
|
-
import { hotelSlot } from "../
|
|
6
|
+
import { hotelSlot } from "../session.ts";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Record the guest's name, email and phone — their three `beta.workflows`
|
|
@@ -2,7 +2,7 @@ import { isToolFailure, toolFailure } from "@alexkroman1/aai";
|
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { reinstateBooking } from "../hotel.ts";
|
|
4
4
|
import { normalizeCode, speakCode, speakUsd, spokenDate, TODAY } from "../records.ts";
|
|
5
|
-
import { hotelSlot } from "../
|
|
5
|
+
import { hotelSlot } from "../session.ts";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Bring back a cancelled booking — their `reinstate_booking`, the one flow that
|
|
@@ -2,7 +2,8 @@ import { isToolFailure } from "@alexkroman1/aai";
|
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { requireRoom } from "../hotel.ts";
|
|
4
4
|
import { isoDate, speakCode } from "../records.ts";
|
|
5
|
-
import {
|
|
5
|
+
import { hotelSlot } from "../session.ts";
|
|
6
|
+
import { addTicket } from "../shared.ts";
|
|
6
7
|
|
|
7
8
|
/** Their `request_flight_reconfirmation`: the concierge calls the carrier and rings the room. */
|
|
8
9
|
export default hotelSlot.updateTool({
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { isToolFailure } from "@alexkroman1/aai";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
import {
|
|
3
|
+
import { hotelSlot } from "../session.ts";
|
|
4
|
+
import { addTicket, requireVerified } from "../shared.ts";
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Re-send a document to the email ON FILE — their `resend_confirmation` over
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
TODAY,
|
|
12
12
|
} from "../records.ts";
|
|
13
13
|
import { openDinnerSlots, reserveTable } from "../restaurant.ts";
|
|
14
|
-
import { hotelSlot } from "../
|
|
14
|
+
import { hotelSlot } from "../session.ts";
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* Book a table — their `BookRestaurantTask`, collapsed to one call.
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { isToolFailure } from "@alexkroman1/aai";
|
|
2
2
|
import { resolveRoomConflict } from "../hotel.ts";
|
|
3
3
|
import { spokenDate } from "../records.ts";
|
|
4
|
-
import { hotelSlot
|
|
4
|
+
import { hotelSlot } from "../session.ts";
|
|
5
|
+
import { requireVerified } from "../shared.ts";
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Fix a double-booked room on the verified booking — their
|
|
@@ -2,7 +2,8 @@ import { isToolFailure, toolFailure } from "@alexkroman1/aai";
|
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { requireRoom } from "../hotel.ts";
|
|
4
4
|
import { clockTime, isoDate, speakCode, spokenDate, spokenTime, TODAY } from "../records.ts";
|
|
5
|
-
import {
|
|
5
|
+
import { hotelSlot } from "../session.ts";
|
|
6
|
+
import { addTicket } from "../shared.ts";
|
|
6
7
|
|
|
7
8
|
/** Their `schedule_wakeup_call`: it actually sets the call — never a followup note instead. */
|
|
8
9
|
export default hotelSlot.updateTool({
|
|
@@ -2,7 +2,8 @@ import { isToolFailure } from "@alexkroman1/aai";
|
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { requireRoom } from "../hotel.ts";
|
|
4
4
|
import { speakCode } from "../records.ts";
|
|
5
|
-
import {
|
|
5
|
+
import { hotelSlot } from "../session.ts";
|
|
6
|
+
import { addTicket } from "../shared.ts";
|
|
6
7
|
|
|
7
8
|
/** Their `set_do_not_disturb`: a standing hold on a room's calls and messages. */
|
|
8
9
|
export default hotelSlot.updateTool({
|
|
@@ -3,7 +3,7 @@ import { z } from "zod";
|
|
|
3
3
|
import { bookingStatus, nextStep, requote } from "../booking.ts";
|
|
4
4
|
import { AFTER_ROOM, deskFlow } from "../desk.ts";
|
|
5
5
|
import { type RoomExtra, speakUsd } from "../records.ts";
|
|
6
|
-
import { hotelSlot } from "../
|
|
6
|
+
import { hotelSlot } from "../session.ts";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Record the caller's answer on each extra — their `set_extras`.
|
|
@@ -4,7 +4,8 @@ import { bookingStatus, nextStep, requote } from "../booking.ts";
|
|
|
4
4
|
import { deskFlow, IN_BOOKING } from "../desk.ts";
|
|
5
5
|
import { describeRoomOptions, listRoomOptions } from "../hotel.ts";
|
|
6
6
|
import { daysBetween, isoDate, MAX_PARTY_SIZE, spokenDate, TODAY } from "../records.ts";
|
|
7
|
-
import {
|
|
7
|
+
import { hotelSlot } from "../session.ts";
|
|
8
|
+
import { bookingByCode } from "../shared.ts";
|
|
8
9
|
|
|
9
10
|
const MAX_NIGHTS = 30;
|
|
10
11
|
|
|
@@ -4,7 +4,8 @@ import { draftForModification } from "../booking.ts";
|
|
|
4
4
|
import { deskFlow } from "../desk.ts";
|
|
5
5
|
import { requireFloorPlanRoom } from "../hotel.ts";
|
|
6
6
|
import { speakUsd, spokenDate, TODAY } from "../records.ts";
|
|
7
|
-
import { hotelSlot
|
|
7
|
+
import { hotelSlot } from "../session.ts";
|
|
8
|
+
import { requireVerified } from "../shared.ts";
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Open the modification flow on the verified booking — their
|
|
@@ -3,7 +3,8 @@ import { z } from "zod";
|
|
|
3
3
|
import { bookingStatus, draftForNewBooking } from "../booking.ts";
|
|
4
4
|
import { deskFlow } from "../desk.ts";
|
|
5
5
|
import { speakCode } from "../records.ts";
|
|
6
|
-
import {
|
|
6
|
+
import { hotelSlot } from "../session.ts";
|
|
7
|
+
import { callerTurns } from "../shared.ts";
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Open the room-booking flow — their `start_room_booking`, which `await`ed a
|
|
@@ -2,7 +2,8 @@ import { toolFailure } from "@alexkroman1/aai";
|
|
|
2
2
|
import { countWords } from "@alexkroman1/aai/utils";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { digitsOf, speakCode, TODAY } from "../records.ts";
|
|
5
|
-
import {
|
|
5
|
+
import { hotelSlot } from "../session.ts";
|
|
6
|
+
import { addTicket } from "../shared.ts";
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Take a message for someone who may be a guest — their `take_guest_message`.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { TRANSFER_DESTINATIONS } from "../records.ts";
|
|
3
|
-
import {
|
|
3
|
+
import { hotelSlot } from "../session.ts";
|
|
4
|
+
import { addTicket } from "../shared.ts";
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Transfer the caller to a DEPARTMENT — their `transfer_call`, a stub that
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { isToolFailure, toolFailure } from "@alexkroman1/aai";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { validateCard } from "../card.ts";
|
|
4
|
-
import { hotelSlot
|
|
4
|
+
import { hotelSlot } from "../session.ts";
|
|
5
|
+
import { note, requireVerified } from "../shared.ts";
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Replace the card on file — their `start_card_update`, which verified and then
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { toolFailure } from "@alexkroman1/aai";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { digitsOf, normalizeCode, speakCode, spokenDate } from "../records.ts";
|
|
4
|
-
import { hotelSlot
|
|
4
|
+
import { hotelSlot } from "../session.ts";
|
|
5
|
+
import { note } from "../shared.ts";
|
|
5
6
|
|
|
6
7
|
/** Failed lookups before a human takes over — their `_attempts >= 3`. */
|
|
7
8
|
export const MAX_VERIFY_ATTEMPTS = 3;
|
|
@@ -135,7 +135,22 @@ describeWorkflowEval(agentDef, (test) => {
|
|
|
135
135
|
const url = mode === "live" ? await servePage(ARTICLE_HTML) : "https://example.test/otters";
|
|
136
136
|
if (mode === "stub") scriptBothLegs(ARTICLE_HTML);
|
|
137
137
|
|
|
138
|
-
|
|
138
|
+
// Run TWICE at most, and only for a reply that came back the wrong SHAPE.
|
|
139
|
+
//
|
|
140
|
+
// The digest step asks its call site for six attempts precisely because a
|
|
141
|
+
// model that answers with prose, or with JSON it truncated, may well obey
|
|
142
|
+
// the next time — `stepGenerateJsonOrFail` throws retryably for exactly
|
|
143
|
+
// that. This harness has no retry to give it (`maxAttempts: 1`, and the eval
|
|
144
|
+
// engine says so in as many words), so a live run here spends the step's
|
|
145
|
+
// whole reliability budget on one draw and a single malformed reply failed
|
|
146
|
+
// the case: "Expected JSON from the model, got: {"headline"…". That is the
|
|
147
|
+
// harness being thinner than production, not the flow being wrong, so the
|
|
148
|
+
// retry is restored HERE — narrowly, on the one error the deployed run
|
|
149
|
+
// would ride out, and never on a `FatalError`, which must still fail once.
|
|
150
|
+
let run = await app.run(digest, { url });
|
|
151
|
+
if (mode === "live" && /Expected JSON from the model/.test(run.error ?? "")) {
|
|
152
|
+
run = await app.run(digest, { url });
|
|
153
|
+
}
|
|
139
154
|
|
|
140
155
|
// The error FIRST, so a failed run names its own reason instead of reporting
|
|
141
156
|
// "expected 'failed' to be 'completed'".
|
|
@@ -87,6 +87,11 @@ export const digest = workflow({
|
|
|
87
87
|
|
|
88
88
|
export default workflowApp({
|
|
89
89
|
name: "Link Digest",
|
|
90
|
+
// TWO descriptions, two readers, and they are deliberately not one sentence.
|
|
91
|
+
// This one says what the APP is, for a registry page or the studio's picker.
|
|
92
|
+
// The one on `digest` above says what a RUN does and is served as JSON Schema
|
|
93
|
+
// on `GET /workflows`, which is what lets a page render a form for it.
|
|
94
|
+
description: "Turns a pasted link into a headline and three points",
|
|
90
95
|
// The whole product. A workflow app is an agent whose work happens here.
|
|
91
96
|
workflows: { digest },
|
|
92
97
|
// Checked at deploy time. A workflow app declares no providers, so this is the
|