@alexkroman1/aai-cli 0.17.0 → 0.18.1
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/dist/{_agent-BopNO5Bq.mjs → _agent-BN21AHsJ.mjs} +4 -4
- package/dist/_api-client-Uljj0CQi.mjs +312 -0
- package/dist/_api-client.d.ts +69 -1
- package/dist/{_bundler-DCuNHjDF.mjs → _bundler-DvZDEu2p.mjs} +67 -7
- package/dist/_bundler.d.ts +15 -0
- package/dist/_cli-common.d.ts +42 -0
- package/dist/{client-bundler-DE-AGdm7.mjs → _client-plugins-kR43nZnb.mjs} +30 -132
- package/dist/_client-plugins.d.ts +16 -0
- package/dist/{_config-mq1I5Cva.mjs → _config-Dlh8PRRp.mjs} +2 -20
- package/dist/_config.d.ts +0 -8
- package/dist/{_dev-server-D6VSQbYW.mjs → _dev-server-C_zidzWj.mjs} +15 -10
- package/dist/_dev-session-ticket.d.ts +3 -0
- package/dist/_dev-tunnel.d.ts +20 -2
- package/dist/_dotenv-file.d.ts +6 -0
- package/dist/_init.d.ts +2 -11
- package/dist/_output.d.ts +47 -20
- package/dist/_safe-write.d.ts +38 -0
- package/dist/{_server-common-CVXIeWrY.mjs → _server-common-C6j67AcZ.mjs} +37 -2
- package/dist/_server-common.d.ts +16 -0
- package/dist/{_slug-api-BnmTHtjd.mjs → _slug-api-B9cptz7Q.mjs} +3 -2
- package/dist/_start-affinity.d.ts +70 -0
- package/dist/_start-log.d.ts +39 -0
- package/dist/_start-router.d.ts +85 -0
- package/dist/_start-run.d.ts +101 -0
- package/dist/_start-worker.d.ts +61 -0
- package/dist/_start-workers-BNdOnTal.mjs +529 -0
- package/dist/_start-workers.d.ts +262 -0
- package/dist/_studio-zympBLlD.mjs +140 -0
- package/dist/_studio.d.ts +14 -0
- package/dist/_target-bundle.d.ts +4 -0
- package/dist/{_templates-BVMVsQh0.mjs → _templates-ChZuhW66.mjs} +110 -8
- package/dist/_templates.d.ts +20 -1
- package/dist/{_typecheck-gate-CcX2gLJZ.mjs → _typecheck-gate-BNF5cboL.mjs} +2 -2
- package/dist/_ui-C0RufoYZ.mjs +147 -0
- package/dist/_ui.d.ts +14 -3
- package/dist/_utils-ChU85MEg.mjs +486 -0
- package/dist/_utils.d.ts +28 -0
- package/dist/_vendor-openers.d.ts +87 -0
- package/dist/{_vitest-runner-CKI8_K1b.mjs → _vitest-runner-tzyto9IU.mjs} +7 -3
- package/dist/_vitest-runner.d.ts +8 -1
- package/dist/{build-BnXLgfk-.mjs → build-BHgd-QYb.mjs} +13 -10
- package/dist/build.d.ts +21 -0
- package/dist/cli-workflow.d.ts +7 -0
- package/dist/cli.d.ts +16 -0
- package/dist/cli.mjs +243 -70
- package/dist/client-bundler-CImhqcp2.mjs +133 -0
- package/dist/client-bundler.mjs +1 -1
- package/dist/{console-tVBjfKyR.mjs → console-DwycgRkC.mjs} +4 -5
- package/dist/delete-ZcA3J_3o.mjs +75 -0
- package/dist/delete.d.ts +10 -1
- package/dist/{deploy-eWDoiwvn.mjs → deploy-CkfkiZE3.mjs} +9 -9
- package/dist/{dev-CT_QHHZL.mjs → dev-BX9g6qcf.mjs} +81 -18
- package/dist/{eval-Dl8o91yC.mjs → eval-CUKvfxRq.mjs} +4 -4
- package/dist/{init-CidslZZz.mjs → init-B9Uw76-_.mjs} +62 -32
- package/dist/{login-oJdBWu2B.mjs → login-Ct73CqU1.mjs} +30 -6
- package/dist/login.d.ts +2 -0
- package/dist/{logs-CkmFdSbr.mjs → logs-BBsUy96d.mjs} +59 -14
- package/dist/logs.d.ts +4 -1
- package/dist/project-config.mjs +1 -1
- package/dist/scaffold/CLAUDE.md +72 -55
- package/dist/scaffold/agent-guide/AGENT-API.md +44 -34
- package/dist/scaffold/agent-guide/HOSTING.md +11 -0
- package/dist/scaffold/agent-guide/TESTING-EVALS.md +105 -36
- package/dist/scaffold/agent-guide/TOOLS.md +189 -33
- package/dist/scaffold/agent-guide/UI.md +111 -39
- package/dist/scaffold/agent-guide/WORKFLOWS.md +234 -160
- package/dist/scaffold/package.json +4 -4
- package/dist/{secret-DPdPEet2.mjs → secret-CKjHRrVX.mjs} +112 -35
- package/dist/start.d.ts +14 -14
- package/dist/start.mjs +840 -40
- package/dist/{studio-COjK25Rl.mjs → studio-U6DvBNAx.mjs} +123 -35
- package/dist/studio.d.ts +1 -0
- package/dist/templates/applicant-screening-agent/agent.eval.test.ts +23 -52
- package/dist/templates/applicant-screening-agent/agent.test.ts +821 -826
- package/dist/templates/applicant-screening-agent/agent.ts +1 -6
- package/dist/templates/applicant-screening-agent/client.tsx +1 -19
- package/dist/templates/applicant-screening-agent/shared.ts +8 -18
- package/dist/templates/applicant-screening-agent/tools/candidate_details.ts +24 -27
- package/dist/templates/applicant-screening-agent/tools/proceed_to_emails.ts +75 -82
- package/dist/templates/applicant-screening-agent/tools/read_email.ts +24 -24
- package/dist/templates/applicant-screening-agent/tools/rescore_with_feedback.ts +92 -99
- package/dist/templates/applicant-screening-agent/tools/screen_candidates.ts +72 -83
- package/dist/templates/applicant-screening-agent/tools/screening_status.ts +21 -29
- package/dist/templates/call-audit-workflow/agent.eval.test.ts +14 -19
- package/dist/templates/call-audit-workflow/agent.test.ts +275 -169
- package/dist/templates/call-audit-workflow/agent.ts +12 -30
- package/dist/templates/call-audit-workflow/client.tsx +9 -27
- package/dist/templates/call-audit-workflow/guards.test.ts +24 -71
- package/dist/templates/call-audit-workflow/workflows/audit.ts +24 -52
- package/dist/templates/call-audit-workflow/workflows/ingest.ts +32 -59
- package/dist/templates/call-audit-workflow/workflows/media.ts +4 -44
- package/dist/templates/call-audit-workflow/workflows/summarize.ts +72 -107
- package/dist/templates/code-interpreter-agent/agent.eval.test.ts +3 -2
- package/dist/templates/code-interpreter-agent/agent.test.ts +4 -17
- package/dist/templates/code-interpreter-agent/agent.ts +1 -1
- package/dist/templates/coding-agent/agent.test.ts +17 -12
- package/dist/templates/coding-agent/agent.ts +1 -1
- package/dist/templates/custom-pipeline-agent/agent.test.ts +6 -14
- package/dist/templates/custom-pipeline-agent/agent.ts +1 -1
- package/dist/templates/custom-pipeline-agent/modes.test.ts +0 -1
- package/dist/templates/document-redline-workflow/agent.test.ts +88 -221
- package/dist/templates/document-redline-workflow/agent.ts +22 -32
- package/dist/templates/document-redline-workflow/client.tsx +46 -88
- package/dist/templates/document-redline-workflow/workflows/prompts.ts +0 -3
- package/dist/templates/document-redline-workflow/workflows/redline.ts +33 -50
- package/dist/templates/emergency-dispatch-agent/agent.eval.test.ts +22 -71
- package/dist/templates/emergency-dispatch-agent/agent.test.ts +466 -495
- package/dist/templates/emergency-dispatch-agent/agent.ts +27 -43
- package/dist/templates/emergency-dispatch-agent/client.tsx +85 -119
- package/dist/templates/emergency-dispatch-agent/shared.ts +51 -88
- package/dist/templates/emergency-dispatch-agent/tools/incident_add_note.ts +11 -17
- package/dist/templates/emergency-dispatch-agent/tools/incident_create.ts +21 -30
- package/dist/templates/emergency-dispatch-agent/tools/incident_escalate.ts +60 -63
- package/dist/templates/emergency-dispatch-agent/tools/incident_get.ts +6 -15
- package/dist/templates/emergency-dispatch-agent/tools/incident_triage.ts +40 -53
- package/dist/templates/emergency-dispatch-agent/tools/incident_update_status.ts +41 -47
- package/dist/templates/emergency-dispatch-agent/tools/ops_dashboard.ts +2 -2
- package/dist/templates/emergency-dispatch-agent/tools/ops_protocols.ts +1 -1
- package/dist/templates/emergency-dispatch-agent/tools/ops_run_scenario.ts +13 -10
- package/dist/templates/emergency-dispatch-agent/tools/resources_dispatch.ts +42 -51
- package/dist/templates/emergency-dispatch-agent/tools/resources_update_status.ts +40 -41
- package/dist/templates/entertainment-picks-agent/agent.eval.test.ts +14 -42
- package/dist/templates/entertainment-picks-agent/agent.test.ts +174 -221
- package/dist/templates/entertainment-picks-agent/agent.ts +1 -6
- package/dist/templates/entertainment-picks-agent/client.tsx +1 -12
- package/dist/templates/entertainment-picks-agent/shared.ts +12 -6
- package/dist/templates/entertainment-picks-agent/tools/recommend.ts +2 -2
- package/dist/templates/entertainment-picks-agent/tools/revisit.ts +1 -0
- package/dist/templates/executive-inbox-agent/agent.eval.test.ts +15 -22
- package/dist/templates/executive-inbox-agent/agent.test.ts +515 -527
- package/dist/templates/executive-inbox-agent/agent.ts +4 -8
- package/dist/templates/executive-inbox-agent/calendar.test.ts +23 -22
- package/dist/templates/executive-inbox-agent/client.tsx +1 -23
- package/dist/templates/executive-inbox-agent/review.ts +125 -113
- package/dist/templates/executive-inbox-agent/shared.ts +3 -0
- package/dist/templates/executive-inbox-agent/tools/ask_question.ts +6 -6
- package/dist/templates/executive-inbox-agent/tools/draft_reply.ts +16 -18
- package/dist/templates/executive-inbox-agent/tools/inbox_status.ts +1 -0
- package/dist/templates/executive-inbox-agent/tools/meeting_assistant.ts +20 -20
- package/dist/templates/executive-inbox-agent/tools/new_email.ts +17 -21
- package/dist/templates/executive-inbox-agent/tools/open_email.ts +72 -74
- package/dist/templates/executive-inbox-agent/tools/review_memory.ts +1 -0
- package/dist/templates/executive-inbox-agent/tools/send_calendar_invite.ts +19 -20
- package/dist/templates/executive-inbox-agent/tools/triage_inbox.ts +53 -50
- package/dist/templates/front-desk-agent/agent.eval.test.ts +22 -14
- package/dist/templates/front-desk-agent/agent.test.ts +139 -123
- package/dist/templates/front-desk-agent/agent.ts +4 -7
- package/dist/templates/front-desk-agent/shared.ts +88 -74
- package/dist/templates/front-door-agent/agent.eval.test.ts +61 -0
- package/dist/templates/front-door-agent/agent.test.ts +393 -0
- package/dist/templates/front-door-agent/agent.ts +35 -0
- package/dist/templates/front-door-agent/client.tsx +250 -0
- package/dist/templates/front-door-agent/routes.ts +91 -0
- package/dist/templates/front-door-agent/shared.ts +35 -0
- package/dist/templates/front-door-agent/system-prompt.md +12 -0
- package/dist/templates/front-door-agent/tools/leave_message.ts +39 -0
- package/dist/templates/front-door-agent/tools/link_phone.ts +49 -0
- package/dist/templates/front-door-agent/workflows/announce.ts +38 -0
- package/dist/templates/front-door-agent/workflows/digest.ts +53 -0
- package/dist/templates/front-door-agent/workflows/pair.ts +28 -0
- package/dist/templates/home-assistant-agent/agent.eval.test.ts +5 -9
- package/dist/templates/home-assistant-agent/agent.test.ts +513 -399
- package/dist/templates/home-assistant-agent/agent.ts +8 -5
- package/dist/templates/home-assistant-agent/client.tsx +48 -9
- package/dist/templates/home-assistant-agent/tools/cancel_reminders.ts +1 -0
- package/dist/templates/home-assistant-agent/tools/remind_me.ts +2 -1
- package/dist/templates/hotel-reception-agent/agent.eval.test.ts +27 -52
- package/dist/templates/hotel-reception-agent/agent.test.ts +980 -964
- package/dist/templates/hotel-reception-agent/agent.ts +8 -21
- package/dist/templates/hotel-reception-agent/booking.ts +2 -2
- package/dist/templates/hotel-reception-agent/client.tsx +5 -20
- package/dist/templates/hotel-reception-agent/concierge.ts +2 -0
- package/dist/templates/hotel-reception-agent/desk-seams.test.ts +285 -275
- package/dist/templates/hotel-reception-agent/desk.ts +45 -12
- package/dist/templates/hotel-reception-agent/hotel.ts +6 -6
- package/dist/templates/hotel-reception-agent/restaurant.ts +3 -4
- package/dist/templates/hotel-reception-agent/session.ts +14 -30
- package/dist/templates/hotel-reception-agent/shared.ts +33 -46
- package/dist/templates/hotel-reception-agent/tools/abandon_booking.ts +14 -15
- package/dist/templates/hotel-reception-agent/tools/add_to_waitlist.ts +1 -0
- package/dist/templates/hotel-reception-agent/tools/book_airport_car.ts +1 -0
- package/dist/templates/hotel-reception-agent/tools/cancel_restaurant_reservation.ts +2 -2
- package/dist/templates/hotel-reception-agent/tools/cancel_room_booking.ts +13 -10
- package/dist/templates/hotel-reception-agent/tools/choose_room.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/confirm_booking.ts +6 -7
- package/dist/templates/hotel-reception-agent/tools/dispatch_emergency.ts +1 -0
- package/dist/templates/hotel-reception-agent/tools/dispute_charge.ts +5 -4
- package/dist/templates/hotel-reception-agent/tools/flag_late_arrival.ts +6 -5
- package/dist/templates/hotel-reception-agent/tools/lookup_booking.ts +3 -4
- package/dist/templates/hotel-reception-agent/tools/lookup_invoice.ts +4 -4
- package/dist/templates/hotel-reception-agent/tools/modify_restaurant_reservation.ts +1 -0
- package/dist/templates/hotel-reception-agent/tools/record_card.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/record_followup.ts +1 -0
- package/dist/templates/hotel-reception-agent/tools/record_group_inquiry.ts +1 -0
- package/dist/templates/hotel-reception-agent/tools/record_guest_details.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/reinstate_booking.ts +1 -0
- package/dist/templates/hotel-reception-agent/tools/request_flight_reconfirmation.ts +1 -0
- package/dist/templates/hotel-reception-agent/tools/resend_confirmation.ts +4 -4
- package/dist/templates/hotel-reception-agent/tools/reserve_table.ts +1 -0
- package/dist/templates/hotel-reception-agent/tools/resolve_room_conflict.ts +4 -3
- package/dist/templates/hotel-reception-agent/tools/schedule_wakeup_call.ts +1 -0
- package/dist/templates/hotel-reception-agent/tools/set_do_not_disturb.ts +1 -0
- package/dist/templates/hotel-reception-agent/tools/set_extras.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/set_stay.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/start_booking_modification.ts +30 -32
- package/dist/templates/hotel-reception-agent/tools/start_room_booking.ts +22 -25
- package/dist/templates/hotel-reception-agent/tools/take_guest_message.ts +1 -0
- package/dist/templates/hotel-reception-agent/tools/update_card.ts +5 -4
- package/dist/templates/hotel-reception-agent/tools/verify_booking.ts +23 -13
- package/dist/templates/kitchen-coach-agent/agent.eval.test.ts +38 -0
- package/dist/templates/kitchen-coach-agent/agent.test.ts +204 -0
- package/dist/templates/kitchen-coach-agent/agent.ts +22 -0
- package/dist/templates/kitchen-coach-agent/client.tsx +232 -0
- package/dist/templates/kitchen-coach-agent/history.ts +37 -0
- package/dist/templates/kitchen-coach-agent/shared.ts +131 -0
- package/dist/templates/kitchen-coach-agent/system-prompt.md +17 -0
- package/dist/templates/kitchen-coach-agent/tools/get_kitchen.ts +17 -0
- package/dist/templates/kitchen-coach-agent/tools/scale_amount.ts +31 -0
- package/dist/templates/kitchen-coach-agent/tools/start_timer.ts +24 -0
- package/dist/templates/link-digest-workflow/agent.eval.test.ts +16 -40
- package/dist/templates/link-digest-workflow/agent.test.ts +84 -164
- package/dist/templates/link-digest-workflow/agent.ts +27 -42
- package/dist/templates/link-digest-workflow/api-client.ts +3 -2
- package/dist/templates/link-digest-workflow/client.tsx +5 -5
- package/dist/templates/link-digest-workflow/workflows/digest.ts +53 -95
- package/dist/templates/medication-safety-agent/agent.eval.test.ts +10 -30
- package/dist/templates/medication-safety-agent/agent.test.ts +16 -46
- package/dist/templates/medication-safety-agent/agent.ts +1 -4
- package/dist/templates/medication-safety-agent/tools/check_drug_interaction.ts +13 -10
- package/dist/templates/meeting-recap-agent/agent.eval.test.ts +238 -396
- package/dist/templates/meeting-recap-agent/agent.test.ts +414 -1070
- package/dist/templates/meeting-recap-agent/agent.ts +26 -67
- package/dist/templates/meeting-recap-agent/system-prompt.md +1 -0
- package/dist/templates/meeting-recap-agent/tools/keep_transcript.ts +10 -12
- package/dist/templates/meeting-recap-agent/tools/request_recap.ts +9 -20
- package/dist/templates/meeting-recap-agent/workflows/recap.ts +224 -547
- package/dist/templates/outbound-call-agent/agent.eval.test.ts +10 -12
- package/dist/templates/outbound-call-agent/agent.test.ts +419 -453
- package/dist/templates/outbound-call-agent/agent.ts +57 -62
- package/dist/templates/outbound-call-agent/api.ts +53 -68
- package/dist/templates/outbound-call-agent/client.tsx +105 -176
- package/dist/templates/outbound-call-agent/shared.ts +10 -39
- package/dist/templates/outbound-call-agent/system-prompt.md +3 -4
- package/dist/templates/outbound-call-agent/tools/end_call.ts +15 -12
- package/dist/templates/outbound-call-agent/tools/press_keys.ts +8 -13
- package/dist/templates/outbound-call-agent/workflows/call.ts +89 -62
- package/dist/templates/pizza-ordering-agent/agent.eval.test.ts +18 -54
- package/dist/templates/pizza-ordering-agent/agent.test.ts +205 -244
- package/dist/templates/pizza-ordering-agent/agent.ts +5 -12
- package/dist/templates/pizza-ordering-agent/client.tsx +3 -14
- package/dist/templates/pizza-ordering-agent/shared.ts +31 -36
- package/dist/templates/pizza-ordering-agent/tools/add_pizza.ts +1 -0
- package/dist/templates/pizza-ordering-agent/tools/place_order.ts +5 -2
- package/dist/templates/pizza-ordering-agent/tools/remove_pizza.ts +1 -0
- package/dist/templates/pizza-ordering-agent/tools/update_pizza.ts +2 -3
- package/dist/templates/pizza-ordering-agent/tools/view_order.ts +7 -3
- package/dist/templates/podcast-digest-workflow/agent.test.ts +53 -102
- package/dist/templates/podcast-digest-workflow/agent.ts +11 -17
- package/dist/templates/podcast-digest-workflow/client.tsx +29 -51
- package/dist/templates/podcast-digest-workflow/workflows/digest.ts +24 -26
- package/dist/templates/push-to-talk-agent/agent.eval.test.ts +13 -14
- package/dist/templates/push-to-talk-agent/agent.test.ts +30 -23
- package/dist/templates/push-to-talk-agent/agent.ts +1 -5
- package/dist/templates/push-to-talk-agent/client.tsx +1 -11
- package/dist/templates/push-to-talk-agent/shared.ts +12 -6
- package/dist/templates/push-to-talk-agent/tools/list_notes.ts +1 -0
- package/dist/templates/push-to-talk-agent/tools/save_note.ts +1 -0
- package/dist/templates/quickstart-agent/agent.eval.test.ts +0 -10
- package/dist/templates/quickstart-agent/agent.test.ts +18 -30
- package/dist/templates/quickstart-agent/agent.ts +3 -4
- package/dist/templates/research-handoff-agent/agent.eval.test.ts +161 -290
- package/dist/templates/research-handoff-agent/agent.test.ts +131 -457
- package/dist/templates/research-handoff-agent/agent.ts +26 -86
- package/dist/templates/research-handoff-agent/system-prompt.md +1 -0
- package/dist/templates/research-handoff-agent/tools/file_it_now.ts +8 -21
- package/dist/templates/research-handoff-agent/tools/request_research.ts +7 -16
- package/dist/templates/research-handoff-agent/workflows/research.ts +88 -40
- package/dist/templates/research-planner-agent/agent.eval.test.ts +15 -40
- package/dist/templates/research-planner-agent/agent.test.ts +415 -464
- package/dist/templates/research-planner-agent/agent.ts +3 -8
- package/dist/templates/research-planner-agent/client.tsx +1 -14
- package/dist/templates/research-planner-agent/procedure.ts +9 -3
- package/dist/templates/research-planner-agent/shared.ts +30 -33
- package/dist/templates/research-planner-agent/tools/plan_status.ts +7 -15
- package/dist/templates/research-planner-agent/tools/revise_plan.ts +29 -36
- package/dist/templates/research-planner-agent/tools/start_plan.ts +25 -39
- package/dist/templates/research-planner-agent/tools/work_next_step.ts +25 -42
- package/dist/templates/retail-orders-agent/agent.eval.test.ts +14 -34
- package/dist/templates/retail-orders-agent/agent.test.ts +1079 -1073
- package/dist/templates/retail-orders-agent/agent.ts +25 -78
- package/dist/templates/retail-orders-agent/client.tsx +120 -168
- package/dist/templates/retail-orders-agent/pending.test.ts +7 -14
- package/dist/templates/retail-orders-agent/registry.test.ts +93 -192
- package/dist/templates/retail-orders-agent/shared.test.ts +1 -1
- package/dist/templates/retail-orders-agent/shared.ts +10 -20
- package/dist/templates/retail-orders-agent/store.test.ts +46 -128
- package/dist/templates/retail-orders-agent/store.ts +42 -175
- package/dist/templates/retail-orders-agent/tools/cancel_change.ts +3 -6
- package/dist/templates/retail-orders-agent/tools/cancel_pending_order.ts +3 -4
- package/dist/templates/retail-orders-agent/tools/confirm_change.ts +4 -6
- package/dist/templates/retail-orders-agent/tools/exchange_delivered_order_items.ts +3 -4
- package/dist/templates/retail-orders-agent/tools/find_user_id_by_email.ts +3 -4
- package/dist/templates/retail-orders-agent/tools/find_user_id_by_name_zip.ts +3 -4
- package/dist/templates/retail-orders-agent/tools/get_item_details.ts +3 -4
- package/dist/templates/retail-orders-agent/tools/get_order_details.ts +3 -4
- package/dist/templates/retail-orders-agent/tools/get_product_details.ts +3 -4
- package/dist/templates/retail-orders-agent/tools/get_user_details.ts +3 -4
- package/dist/templates/retail-orders-agent/tools/list_all_product_types.ts +3 -8
- package/dist/templates/retail-orders-agent/tools/modify_pending_order_address.ts +3 -4
- package/dist/templates/retail-orders-agent/tools/modify_pending_order_items.ts +3 -4
- package/dist/templates/retail-orders-agent/tools/modify_pending_order_payment.ts +3 -4
- package/dist/templates/retail-orders-agent/tools/modify_user_address.ts +3 -4
- package/dist/templates/retail-orders-agent/tools/return_delivered_order_items.ts +3 -4
- package/dist/templates/retail-orders-agent/tools/transfer_to_human_agents.ts +3 -4
- package/dist/templates/roadside-assistance-agent/agent.eval.test.ts +22 -25
- package/dist/templates/roadside-assistance-agent/agent.test.ts +453 -490
- package/dist/templates/roadside-assistance-agent/agent.ts +28 -60
- package/dist/templates/roadside-assistance-agent/call.ts +16 -22
- package/dist/templates/roadside-assistance-agent/shared.ts +24 -54
- package/dist/templates/roadside-assistance-agent/tools/acknowledge_disclosure.ts +29 -37
- package/dist/templates/roadside-assistance-agent/tools/dispatch_truck.ts +44 -70
- package/dist/templates/roadside-assistance-agent/tools/job_status.ts +16 -24
- package/dist/templates/roadside-assistance-agent/tools/lookup_coverage.ts +39 -51
- package/dist/templates/roadside-assistance-agent/tools/report_location.ts +34 -33
- package/dist/templates/roadside-assistance-agent/tools/service_disclosure.ts +18 -39
- package/dist/templates/roadside-assistance-agent/yard.test.ts +22 -19
- package/dist/templates/roadside-assistance-agent/yard.ts +3 -3
- package/dist/templates/spoken-summary-workflow/agent.eval.test.ts +38 -40
- package/dist/templates/spoken-summary-workflow/agent.test.ts +129 -279
- package/dist/templates/spoken-summary-workflow/agent.ts +15 -40
- package/dist/templates/spoken-summary-workflow/client.tsx +13 -25
- package/dist/templates/spoken-summary-workflow/workflows/summarize.ts +52 -92
- package/dist/templates/tabletop-rpg-agent/agent.eval.test.ts +31 -74
- package/dist/templates/tabletop-rpg-agent/agent.test.ts +756 -774
- package/dist/templates/tabletop-rpg-agent/agent.ts +9 -46
- package/dist/templates/tabletop-rpg-agent/client.tsx +13 -21
- package/dist/templates/tabletop-rpg-agent/shared.ts +40 -99
- package/dist/templates/tabletop-rpg-agent/tools/action_roll.ts +67 -83
- package/dist/templates/tabletop-rpg-agent/tools/burn_momentum.ts +65 -88
- package/dist/templates/tabletop-rpg-agent/tools/check_state.ts +8 -27
- package/dist/templates/tabletop-rpg-agent/tools/setup_character.ts +18 -36
- package/dist/templates/tabletop-rpg-agent/tools/update_state.ts +101 -111
- package/dist/templates/technical-support-agent/agent.eval.test.ts +31 -72
- package/dist/templates/technical-support-agent/agent.test.ts +231 -260
- package/dist/templates/technical-support-agent/agent.ts +4 -10
- package/dist/templates/technical-support-agent/client.tsx +4 -18
- package/dist/templates/technical-support-agent/shared.ts +15 -25
- package/dist/templates/technical-support-agent/tools/answer_question.ts +46 -56
- package/dist/templates/technical-support-agent/tools/list_topics.ts +1 -0
- package/dist/templates/technical-support-agent/tools/log_ticket.ts +8 -5
- package/dist/templates/text-adventure-agent/agent.eval.test.ts +37 -126
- package/dist/templates/text-adventure-agent/agent.test.ts +197 -368
- package/dist/templates/text-adventure-agent/agent.ts +15 -65
- package/dist/templates/text-adventure-agent/client.tsx +38 -98
- package/dist/templates/text-adventure-agent/shared.ts +31 -143
- package/dist/templates/text-adventure-agent/tools/game_state_drop.ts +6 -12
- package/dist/templates/text-adventure-agent/tools/game_state_get.ts +4 -11
- package/dist/templates/text-adventure-agent/tools/game_state_move.ts +0 -2
- package/dist/templates/text-adventure-agent/tools/game_state_restart.ts +1 -3
- package/dist/templates/text-adventure-agent/tools/game_state_score.ts +5 -7
- package/dist/templates/topic-briefing-agent/agent.eval.test.ts +12 -50
- package/dist/templates/topic-briefing-agent/agent.test.ts +478 -476
- package/dist/templates/topic-briefing-agent/agent.ts +3 -3
- package/dist/templates/topic-briefing-agent/shared.ts +11 -16
- package/dist/templates/topic-briefing-agent/slack.ts +12 -4
- package/dist/templates/topic-briefing-agent/tools/briefing_so_far.ts +10 -17
- package/dist/templates/topic-briefing-agent/tools/research_topic.ts +21 -24
- package/dist/templates/topic-briefing-agent/tools/send_briefing.ts +13 -14
- package/dist/templates/topic-briefing-agent/tools/verify_claim.ts +16 -13
- package/dist/templates/transcription-workflow/agent.test.ts +114 -259
- package/dist/templates/transcription-workflow/agent.ts +6 -9
- package/dist/templates/transcription-workflow/client.tsx +100 -258
- package/dist/templates/transcription-workflow/recover.test.ts +6 -136
- package/dist/templates/transcription-workflow/recover.ts +14 -97
- package/dist/templates/transcription-workflow/run-panel.tsx +71 -8
- package/dist/templates/transcription-workflow/workflows/batch.ts +28 -159
- package/dist/templates/transcription-workflow/workflows/normalize.ts +50 -86
- package/dist/templates/transcription-workflow/workflows/stream.ts +2 -2
- package/dist/templates/transcription-workflow/workflows/transcribe.ts +16 -23
- package/dist/templates/travel-concierge-agent/agent.eval.test.ts +7 -25
- package/dist/templates/travel-concierge-agent/agent.test.ts +505 -517
- package/dist/templates/travel-concierge-agent/agent.ts +22 -46
- package/dist/templates/travel-concierge-agent/client.tsx +1 -22
- package/dist/templates/travel-concierge-agent/routing.ts +29 -31
- package/dist/templates/travel-concierge-agent/shared.ts +63 -152
- package/dist/templates/travel-concierge-agent/tools/book_car_rental.ts +8 -9
- package/dist/templates/travel-concierge-agent/tools/book_excursion.ts +8 -8
- package/dist/templates/travel-concierge-agent/tools/book_hotel.ts +9 -6
- package/dist/templates/travel-concierge-agent/tools/cancel_ticket.ts +10 -10
- package/dist/templates/travel-concierge-agent/tools/search_car_rentals.ts +3 -2
- package/dist/templates/travel-concierge-agent/tools/search_excursions.ts +3 -2
- package/dist/templates/travel-concierge-agent/tools/search_flights.ts +4 -3
- package/dist/templates/travel-concierge-agent/tools/search_hotels.ts +3 -2
- package/dist/templates/travel-concierge-agent/tools/update_ticket.ts +13 -8
- package/dist/templates/web-research-agent/agent.test.ts +19 -30
- package/dist/templates/web-research-agent/agent.ts +3 -4
- package/dist/templates/word-game-agent/agent.eval.test.ts +47 -67
- package/dist/templates/word-game-agent/agent.test.ts +369 -382
- package/dist/templates/word-game-agent/agent.ts +2 -5
- package/dist/templates/word-game-agent/client.tsx +1 -8
- package/dist/templates/word-game-agent/game.ts +15 -27
- package/dist/templates/word-game-agent/shared.ts +36 -20
- package/dist/templates/word-game-agent/tools/final_score.ts +14 -13
- package/dist/templates/word-game-agent/tools/relay_description.ts +90 -66
- package/dist/templates/word-game-agent/tools/repeat_word.ts +11 -10
- package/dist/templates/word-game-agent/tools/skip_word.ts +17 -21
- package/dist/templates/word-game-agent/tools/start_game.ts +26 -30
- package/dist/{test-XufelYGW.mjs → test-CW5cw5fy.mjs} +3 -4
- package/dist/typecheck.mjs +1 -1
- package/dist/worker-bundler-D8uCzpYP.mjs +335 -0
- package/dist/worker-bundler.d.ts +39 -0
- package/dist/worker-bundler.mjs +2 -155
- package/dist/{workflow-CDUlTD5B.mjs → workflow-5gOZMB2M.mjs} +66 -19
- package/package.json +4 -4
- package/dist/_output-DBP9Op_d.mjs +0 -120
- package/dist/_studio-B5m4jBTD.mjs +0 -256
- package/dist/_ui-Coe0zwmm.mjs +0 -102
- package/dist/_utils-BVLdBvdT.mjs +0 -186
- package/dist/delete-DwXCHzTl.mjs +0 -55
- package/dist/templates/document-redline-workflow/form.ts +0 -73
- package/dist/templates/emergency-dispatch-agent/events.ts +0 -48
- package/dist/templates/hotel-reception-agent/events.ts +0 -80
- package/dist/templates/meeting-recap-agent/shared.ts +0 -44
- package/dist/templates/meeting-recap-agent/tools/cancel_recap.ts +0 -25
- package/dist/templates/meeting-recap-agent/tools/recap_progress.ts +0 -24
- package/dist/templates/meeting-recap-agent/tools/recap_status.ts +0 -45
- package/dist/templates/meeting-recap-agent/workflows/tokens.ts +0 -47
- package/dist/templates/outbound-call-agent/call-params.ts +0 -109
- package/dist/templates/outbound-call-agent/live-calls.ts +0 -80
- package/dist/templates/outbound-call-agent/workflows/tokens.ts +0 -16
- package/dist/templates/research-handoff-agent/shared.ts +0 -41
- package/dist/templates/research-handoff-agent/tools/research_progress.ts +0 -23
- package/dist/templates/research-handoff-agent/tools/research_status.ts +0 -73
- package/dist/templates/research-handoff-agent/workflows/review.ts +0 -43
- package/dist/templates/roadside-assistance-agent/events.ts +0 -92
- package/dist/templates/spoken-summary-workflow/workflows/transcribe.ts +0 -137
- package/dist/templates/transcription-workflow/total-latency.tsx +0 -170
- package/dist/templates/travel-concierge-agent/call-events.ts +0 -80
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
/** The def a DEPLOYED agent runs: authored, plus what `tools/` and the prompt add. */
|
|
2
2
|
import agentDef from "virtual:aai/agent";
|
|
3
|
-
import type {
|
|
3
|
+
import type { ToolContext, ToolDef } from "@alexkroman1/aai";
|
|
4
4
|
import { isToolFailure } from "@alexkroman1/aai";
|
|
5
5
|
import {
|
|
6
6
|
createToolContext,
|
|
7
7
|
expectDialogOk,
|
|
8
8
|
expectDialogRefused,
|
|
9
|
+
expectSlotContract,
|
|
9
10
|
expectToolOk,
|
|
10
|
-
|
|
11
|
+
fireEvent,
|
|
12
|
+
sessionEvent,
|
|
11
13
|
toolInputIssues,
|
|
12
|
-
|
|
14
|
+
toolNameOf,
|
|
13
15
|
} from "@alexkroman1/aai-runtime/testing";
|
|
16
|
+
import { describeAgent } from "@alexkroman1/aai-runtime/testing/vitest";
|
|
14
17
|
import { describe, expect, test } from "vitest";
|
|
15
18
|
import { luhnOk, validateCard } from "./card.ts";
|
|
16
19
|
import { deskFlow } from "./desk.ts";
|
|
@@ -31,1091 +34,1104 @@ import {
|
|
|
31
34
|
TODAY,
|
|
32
35
|
} from "./records.ts";
|
|
33
36
|
import { hotelSlot } from "./session.ts";
|
|
34
|
-
import { deskView } from "./shared.ts";
|
|
37
|
+
import { deskView, emptyHotelState } from "./shared.ts";
|
|
38
|
+
import abandonBooking from "./tools/abandon_booking.ts";
|
|
35
39
|
import bookAirportCar from "./tools/book_airport_car.ts";
|
|
36
40
|
import bookBusinessCenter from "./tools/book_business_center.ts";
|
|
37
41
|
import bookSpaAppointment from "./tools/book_spa_appointment.ts";
|
|
38
42
|
import bookTour from "./tools/book_tour.ts";
|
|
43
|
+
import cancelRestaurantReservation from "./tools/cancel_restaurant_reservation.ts";
|
|
39
44
|
import cancelRoomBooking from "./tools/cancel_room_booking.ts";
|
|
40
45
|
import checkRestaurantAvailability from "./tools/check_restaurant_availability.ts";
|
|
41
46
|
import checkRoomAvailability from "./tools/check_room_availability.ts";
|
|
47
|
+
import chooseRoom from "./tools/choose_room.ts";
|
|
48
|
+
import confirmBooking from "./tools/confirm_booking.ts";
|
|
42
49
|
import dispatchEmergency from "./tools/dispatch_emergency.ts";
|
|
43
50
|
import disputeCharge from "./tools/dispute_charge.ts";
|
|
51
|
+
import flagLateArrival from "./tools/flag_late_arrival.ts";
|
|
44
52
|
import lookupBooking from "./tools/lookup_booking.ts";
|
|
45
53
|
import lookupInvoice from "./tools/lookup_invoice.ts";
|
|
46
54
|
import lookupPolicy from "./tools/lookup_policy.ts";
|
|
55
|
+
import lookupRestaurantReservation from "./tools/lookup_restaurant_reservation.ts";
|
|
47
56
|
import modifyRestaurantReservation from "./tools/modify_restaurant_reservation.ts";
|
|
57
|
+
import orderFlowers from "./tools/order_flowers.ts";
|
|
58
|
+
import recordCard from "./tools/record_card.ts";
|
|
48
59
|
import recordFollowup from "./tools/record_followup.ts";
|
|
60
|
+
import recordGroupInquiry from "./tools/record_group_inquiry.ts";
|
|
61
|
+
import recordGuestDetails from "./tools/record_guest_details.ts";
|
|
49
62
|
import reinstateBooking from "./tools/reinstate_booking.ts";
|
|
63
|
+
import requestFlightReconfirmation from "./tools/request_flight_reconfirmation.ts";
|
|
50
64
|
import resendConfirmation from "./tools/resend_confirmation.ts";
|
|
51
65
|
import reserveTable from "./tools/reserve_table.ts";
|
|
52
66
|
import resolveRoomConflict from "./tools/resolve_room_conflict.ts";
|
|
53
67
|
import scheduleWakeupCall from "./tools/schedule_wakeup_call.ts";
|
|
68
|
+
import setExtras from "./tools/set_extras.ts";
|
|
69
|
+
import setStay from "./tools/set_stay.ts";
|
|
70
|
+
import startBookingModification from "./tools/start_booking_modification.ts";
|
|
71
|
+
import startRoomBooking from "./tools/start_room_booking.ts";
|
|
54
72
|
import takeGuestMessage from "./tools/take_guest_message.ts";
|
|
55
73
|
import transferCall from "./tools/transfer_call.ts";
|
|
56
74
|
import updateCard from "./tools/update_card.ts";
|
|
57
75
|
import verifyBooking from "./tools/verify_booking.ts";
|
|
58
76
|
|
|
59
|
-
|
|
77
|
+
describeAgent(agentDef, (run) => {
|
|
78
|
+
// ─── Harness ─────────────────────────────────────────────────────────────────
|
|
60
79
|
|
|
61
|
-
/**
|
|
62
|
-
const
|
|
80
|
+
/** What the runtime offers the desk dialog when the caller says something. */
|
|
81
|
+
const HEARD_SOMETHING = sessionEvent("userTranscript.committed", { text: "yes, that's right" });
|
|
63
82
|
|
|
64
|
-
/**
|
|
65
|
-
const
|
|
66
|
-
type: "userTranscript.committed",
|
|
67
|
-
text: "yes, that's right",
|
|
68
|
-
meta: { id: "evt_1", at: 0 },
|
|
69
|
-
};
|
|
83
|
+
/** And when they hang up. */
|
|
84
|
+
const CALLER_GONE = sessionEvent("session.timedOut");
|
|
70
85
|
|
|
71
|
-
/**
|
|
72
|
-
const
|
|
86
|
+
/** Where the call is, without going through a tool. */
|
|
87
|
+
const at = (ctx: ToolContext) => deskFlow.position(ctx).state;
|
|
73
88
|
|
|
74
|
-
/**
|
|
75
|
-
const
|
|
89
|
+
/** The caller answers — their next committed turn is what discharges an owed read-back. */
|
|
90
|
+
const callerAnswers = (ctx: ToolContext) => deskFlow.receive(ctx, HEARD_SOMETHING).state;
|
|
76
91
|
|
|
77
|
-
/**
|
|
78
|
-
const
|
|
92
|
+
/** A context `n` caller turns in — what the idempotency guards read. */
|
|
93
|
+
const withCallerTurns = (n: number) => createToolContext({ turn: n });
|
|
79
94
|
|
|
80
|
-
/**
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
role: "user" as const,
|
|
85
|
-
content: `turn ${i}`,
|
|
86
|
-
})),
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
/** Verify as a seeded guest, the way the model has to. */
|
|
90
|
-
async function verify(ctx: ToolContext, lastName: string, confirmationCode: string) {
|
|
91
|
-
return expectToolOk(await runTool(verifyBooking, { lastName, confirmationCode }, ctx));
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
const A_CARD = {
|
|
95
|
-
cardNumber: "4532 0000 0001 4471",
|
|
96
|
-
expiryMonth: 12,
|
|
97
|
-
expiryYear: 29,
|
|
98
|
-
securityCode: "321",
|
|
99
|
-
cardholderName: "Maria Whitfield",
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
/** Walk a fresh call through a whole new booking up to the read-back. */
|
|
103
|
-
async function bookUpToReadBack(ctx: ToolContext) {
|
|
104
|
-
expectDialogOk(await run("start_room_booking", ctx));
|
|
105
|
-
expectDialogOk(
|
|
106
|
-
await run("set_stay", { checkIn: "2026-07-14", checkOut: "2026-07-17", guests: 2 }, ctx),
|
|
107
|
-
);
|
|
108
|
-
expectDialogOk(await run("choose_room", { roomType: "queen_2beds", view: "garden" }, ctx));
|
|
109
|
-
expectDialogOk(
|
|
110
|
-
await run(
|
|
111
|
-
"set_extras",
|
|
112
|
-
{ breakfast: false, valet: false, lateCheckout: false, pets: false },
|
|
113
|
-
ctx,
|
|
114
|
-
),
|
|
115
|
-
);
|
|
116
|
-
expectDialogOk(
|
|
117
|
-
await run(
|
|
118
|
-
"record_guest_details",
|
|
119
|
-
{
|
|
120
|
-
firstName: "Maria",
|
|
121
|
-
lastName: "Whitfield",
|
|
122
|
-
email: "Maria.Whitfield@gmail.com",
|
|
123
|
-
phone: "123-555-0170",
|
|
124
|
-
},
|
|
125
|
-
ctx,
|
|
126
|
-
),
|
|
127
|
-
);
|
|
128
|
-
expectDialogOk(await run("record_card", A_CARD, ctx));
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// ─── 1. Records: money, dates, codes ─────────────────────────────────────────
|
|
132
|
-
|
|
133
|
-
describe("records.ts", () => {
|
|
134
|
-
test("a stay is priced once, with tax, and the line items add up to the total", () => {
|
|
135
|
-
const priced = computeInvoice(24_000, 2, ["breakfast"]);
|
|
136
|
-
expect(priced).toMatchObject({ subtotal: 53_000, taxes: 6360, total: 59_360 });
|
|
137
|
-
expect(priced.lineItems.reduce((sum, li) => sum + li.amount, 0)).toBe(priced.total);
|
|
138
|
-
expect(priced.lineItems.map((li) => li.label)).toEqual([
|
|
139
|
-
"Room (2 nights)",
|
|
140
|
-
"Breakfast (2 nights)",
|
|
141
|
-
`Tax (${PRICING.taxRatePct}%)`,
|
|
142
|
-
]);
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
test("money and codes are spoken the way a phone needs them", () => {
|
|
146
|
-
expect(speakUsd(24_000)).toBe("240 dollars");
|
|
147
|
-
expect(speakUsd(24_050)).toBe("240 dollars and 50 cents");
|
|
148
|
-
// The dash is the WORD "dash", not four more letters.
|
|
149
|
-
expect(speakCode("HTL-AB12")).toBe("H, T, L, dash, A, B, 1, 2");
|
|
150
|
-
});
|
|
95
|
+
/** Verify as a seeded guest, the way the model has to. */
|
|
96
|
+
async function verify(ctx: ToolContext, lastName: string, confirmationCode: string) {
|
|
97
|
+
return expectToolOk(await run(verifyBooking, { lastName, confirmationCode }, ctx));
|
|
98
|
+
}
|
|
151
99
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
expect(isIsoDate("2026-02-30")).toBe(false);
|
|
160
|
-
expect(isIsoDate("2026-06-08")).toBe(true);
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
test("every date a tool takes is refused by its SCHEMA, before the body runs", async () => {
|
|
164
|
-
// The rule used to be ten hand-written `if (!isIsoDate(...)) return
|
|
165
|
-
// toolFailure(...)` lines, so it reached the model only by failing and each
|
|
166
|
-
// tool worded it differently. `isoDate` declares it on the field, which is
|
|
167
|
-
// what `executeToolCall` validates against before it calls `execute` —
|
|
168
|
-
// asserted through `toolInputIssues`, which is the SDK's reader for exactly
|
|
169
|
-
// this: `toolRunner` deliberately passes arguments straight through, so a
|
|
170
|
-
// tool driven through it never meets its own schema.
|
|
171
|
-
const dated: [string, Record<string, unknown>][] = [
|
|
172
|
-
["check_restaurant_availability", { partySize: 2 }],
|
|
173
|
-
["check_room_availability", { checkIn: "2026-06-09", guests: 2 }],
|
|
174
|
-
["schedule_wakeup_call", { room: "412", time: "07:00" }],
|
|
175
|
-
];
|
|
176
|
-
for (const [name, rest] of dated) {
|
|
177
|
-
const field = name === "check_room_availability" ? "checkOut" : "date";
|
|
178
|
-
for (const value of ["2026-02-30", "next tuesday"]) {
|
|
179
|
-
const issues = await toolInputIssues(agentDef, name, { ...rest, [field]: value });
|
|
180
|
-
expect(JSON.stringify(issues), `${name} accepted ${value}`).toMatch(/YYYY-MM-DD/);
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
});
|
|
100
|
+
const A_CARD = {
|
|
101
|
+
cardNumber: "4532 0000 0001 4471",
|
|
102
|
+
expiryMonth: 12,
|
|
103
|
+
expiryYear: 29,
|
|
104
|
+
securityCode: "321",
|
|
105
|
+
cardholderName: "Maria Whitfield",
|
|
106
|
+
};
|
|
184
107
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
108
|
+
/** Walk a fresh call through a whole new booking up to the read-back. */
|
|
109
|
+
async function bookUpToReadBack(ctx: ToolContext) {
|
|
110
|
+
expectDialogOk(await run(startRoomBooking, ctx));
|
|
111
|
+
expectDialogOk(
|
|
112
|
+
await run(setStay, { checkIn: "2026-07-14", checkOut: "2026-07-17", guests: 2 }, ctx),
|
|
113
|
+
);
|
|
114
|
+
expectDialogOk(await run(chooseRoom, { roomType: "queen_2beds", view: "garden" }, ctx));
|
|
115
|
+
expectDialogOk(
|
|
116
|
+
await run(
|
|
117
|
+
setExtras,
|
|
118
|
+
{ breakfast: false, valet: false, lateCheckout: false, pets: false },
|
|
119
|
+
ctx,
|
|
120
|
+
),
|
|
121
|
+
);
|
|
122
|
+
expectDialogOk(
|
|
123
|
+
await run(
|
|
124
|
+
recordGuestDetails,
|
|
125
|
+
{
|
|
126
|
+
firstName: "Maria",
|
|
127
|
+
lastName: "Whitfield",
|
|
128
|
+
email: "Maria.Whitfield@gmail.com",
|
|
129
|
+
phone: "123-555-0170",
|
|
130
|
+
},
|
|
131
|
+
ctx,
|
|
132
|
+
),
|
|
133
|
+
);
|
|
134
|
+
expectDialogOk(await run(recordCard, A_CARD, ctx));
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// ─── 1. Records: money, dates, codes ─────────────────────────────────────────
|
|
138
|
+
|
|
139
|
+
describe("records.ts", () => {
|
|
140
|
+
test("a stay is priced once, with tax, and the line items add up to the total", () => {
|
|
141
|
+
const priced = computeInvoice(24_000, 2, ["breakfast"]);
|
|
142
|
+
expect(priced).toMatchObject({ subtotal: 53_000, taxes: 6360, total: 59_360 });
|
|
143
|
+
expect(priced.lineItems.reduce((sum, li) => sum + li.amount, 0)).toBe(priced.total);
|
|
144
|
+
expect(priced.lineItems.map((li) => li.label)).toEqual([
|
|
145
|
+
"Room (2 nights)",
|
|
146
|
+
"Breakfast (2 nights)",
|
|
147
|
+
`Tax (${PRICING.taxRatePct}%)`,
|
|
148
|
+
]);
|
|
201
149
|
});
|
|
202
|
-
|
|
203
|
-
|
|
150
|
+
|
|
151
|
+
test("money and codes are spoken the way a phone needs them", () => {
|
|
152
|
+
expect(speakUsd(24_000)).toBe("240 dollars");
|
|
153
|
+
expect(speakUsd(24_050)).toBe("240 dollars and 50 cents");
|
|
154
|
+
// The dash is the WORD "dash", not four more letters.
|
|
155
|
+
expect(speakCode("HTL-AB12")).toBe("H, T, L, dash, A, B, 1, 2");
|
|
204
156
|
});
|
|
205
|
-
});
|
|
206
|
-
});
|
|
207
157
|
|
|
208
|
-
|
|
158
|
+
test("dates: TODAY is the simulation pin, and the helpers agree with the calendar", () => {
|
|
159
|
+
expect(TODAY).toBe("2026-06-08");
|
|
160
|
+
expect(spokenDate(TODAY)).toBe("Monday, June 8");
|
|
161
|
+
expect(addDays(TODAY, 25)).toBe("2026-07-03");
|
|
162
|
+
expect(daysBetween("2026-07-14", "2026-07-17")).toBe(3);
|
|
163
|
+
expect(spokenTime("19:30")).toBe("7:30 PM");
|
|
164
|
+
expect(spokenTime("21:00")).toBe("9 PM");
|
|
165
|
+
expect(isIsoDate("2026-02-30")).toBe(false);
|
|
166
|
+
expect(isIsoDate("2026-06-08")).toBe(true);
|
|
167
|
+
});
|
|
209
168
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
169
|
+
test("every date a tool takes is refused by its SCHEMA, before the body runs", async () => {
|
|
170
|
+
// The rule used to be ten hand-written `if (!isIsoDate(...)) return
|
|
171
|
+
// toolFailure(...)` lines, so it reached the model only by failing and each
|
|
172
|
+
// tool worded it differently. `isoDate` declares it on the field, which is
|
|
173
|
+
// what `executeToolCall` validates against before it calls `execute` —
|
|
174
|
+
// asserted through `toolInputIssues`, which is the SDK's reader for exactly
|
|
175
|
+
// this: `toolRunner` deliberately passes arguments straight through, so a
|
|
176
|
+
// tool driven through it never meets its own schema.
|
|
177
|
+
const dated: [ToolDef, string, Record<string, unknown>][] = [
|
|
178
|
+
[checkRestaurantAvailability, "date", { partySize: 2 }],
|
|
179
|
+
[checkRoomAvailability, "checkOut", { checkIn: "2026-06-09", guests: 2 }],
|
|
180
|
+
[scheduleWakeupCall, "date", { room: "412", time: "07:00" }],
|
|
181
|
+
];
|
|
182
|
+
for (const [def, field, rest] of dated) {
|
|
183
|
+
for (const value of ["2026-02-30", "next tuesday"]) {
|
|
184
|
+
const issues = await toolInputIssues(def, { ...rest, [field]: value });
|
|
185
|
+
expect(JSON.stringify(issues), `${toolNameOf(def)} accepted ${value}`).toMatch(
|
|
186
|
+
/YYYY-MM-DD/,
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
217
190
|
});
|
|
218
|
-
expect(tonight).toEqual([{ type: "queen_2beds", view: "garden", nightlyRate: 22_000 }]);
|
|
219
|
-
});
|
|
220
191
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
guests: 2,
|
|
227
|
-
}),
|
|
228
|
-
);
|
|
229
|
-
expect(empty.available).toBe(false);
|
|
230
|
-
expect(empty.message).toMatch(/add_to_waitlist/);
|
|
231
|
-
const open = expectToolOk(
|
|
232
|
-
await runTool(checkRoomAvailability, {
|
|
233
|
-
checkIn: "2026-07-14",
|
|
234
|
-
checkOut: "2026-07-17",
|
|
235
|
-
guests: 2,
|
|
236
|
-
}),
|
|
237
|
-
);
|
|
238
|
-
expect(open.available).toBe(true);
|
|
239
|
-
expect(open.options).toContain("queen 2beds, garden view: 220 dollars/night");
|
|
240
|
-
});
|
|
192
|
+
test("a minted code carries no character a caller could mishear as another", () => {
|
|
193
|
+
for (let i = 0; i < 50; i++)
|
|
194
|
+
expect(mintCode("HTL")).toMatch(/^HTL-[ABCDEFGHJKMNPQRSTUVWXYZ2-9]{4}$/);
|
|
195
|
+
expect(mintCode("X", new Set())).not.toBe(mintCode("X", new Set()));
|
|
196
|
+
});
|
|
241
197
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
198
|
+
test("the card check is Luhn, and every refusal names one field", () => {
|
|
199
|
+
expect(luhnOk("4532000000014471")).toBe(true);
|
|
200
|
+
expect(luhnOk("4532000000014472")).toBe(false);
|
|
201
|
+
const ok = validateCard(A_CARD);
|
|
202
|
+
expect(ok).toMatchObject({ last4: "4471", issuer: "Visa", expiry: "12/29" });
|
|
203
|
+
expect(validateCard({ ...A_CARD, cardNumber: "4532 0000 0001 4472" })).toMatchObject({
|
|
204
|
+
error: expect.stringContaining("one digit is likely off"),
|
|
205
|
+
});
|
|
206
|
+
expect(validateCard({ ...A_CARD, expiryYear: 2025 })).toMatchObject({
|
|
207
|
+
error: expect.stringContaining("expired"),
|
|
208
|
+
});
|
|
209
|
+
expect(validateCard({ ...A_CARD, securityCode: "12" })).toMatchObject({
|
|
210
|
+
error: expect.stringContaining("3 or 4 digits"),
|
|
211
|
+
});
|
|
250
212
|
});
|
|
251
|
-
// The pre-first-tool-call frame the client renders is the same function.
|
|
252
|
-
expect(hotelSlot.projected()).toEqual(view);
|
|
253
213
|
});
|
|
254
|
-
});
|
|
255
214
|
|
|
256
|
-
// ───
|
|
257
|
-
|
|
258
|
-
describe("verification", () => {
|
|
259
|
-
test("every booking tool refuses until verify_booking has run, naming it", async () => {
|
|
260
|
-
const ctx = createToolContext();
|
|
261
|
-
for (const name of [
|
|
262
|
-
"lookup_booking",
|
|
263
|
-
"lookup_invoice",
|
|
264
|
-
"cancel_room_booking",
|
|
265
|
-
"resolve_room_conflict",
|
|
266
|
-
]) {
|
|
267
|
-
const refused = await run(name, ctx);
|
|
268
|
-
expect(isToolFailure(refused) && refused.error).toMatch(/verify_booking/);
|
|
269
|
-
}
|
|
270
|
-
expect(isToolFailure(await run("flag_late_arrival", { note: "around 1 AM" }, ctx))).toBe(true);
|
|
271
|
-
});
|
|
215
|
+
// ─── 2. The seed's scenarios are the spec's ──────────────────────────────────
|
|
272
216
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
217
|
+
describe("the seeded hotel", () => {
|
|
218
|
+
test("tonight, the only free room is the garden queen the seed keeps for Robert Klein", () => {
|
|
219
|
+
const ctx = createToolContext();
|
|
220
|
+
const tonight = listRoomOptions(hotelSlot.get(ctx), {
|
|
221
|
+
checkIn: TODAY,
|
|
222
|
+
checkOut: addDays(TODAY, 1),
|
|
223
|
+
guests: 2,
|
|
224
|
+
});
|
|
225
|
+
expect(tonight).toEqual([{ type: "queen_2beds", view: "garden", nightlyRate: 22_000 }]);
|
|
226
|
+
});
|
|
277
227
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
228
|
+
test("Friday July 3 is sold out, and the desk says so rather than inventing a room", async () => {
|
|
229
|
+
const empty = expectToolOk(
|
|
230
|
+
await run(checkRoomAvailability, {
|
|
231
|
+
checkIn: "2026-07-03",
|
|
232
|
+
checkOut: "2026-07-04",
|
|
233
|
+
guests: 2,
|
|
234
|
+
}),
|
|
235
|
+
);
|
|
236
|
+
expect(empty.available).toBe(false);
|
|
237
|
+
expect(empty.message).toMatch(/add_to_waitlist/);
|
|
238
|
+
const open = expectToolOk(
|
|
239
|
+
await run(checkRoomAvailability, {
|
|
240
|
+
checkIn: "2026-07-14",
|
|
241
|
+
checkOut: "2026-07-17",
|
|
242
|
+
guests: 2,
|
|
243
|
+
}),
|
|
244
|
+
);
|
|
245
|
+
expect(open.available).toBe(true);
|
|
246
|
+
expect(open.options).toContain("queen 2beds, garden view: 220 dollars/night");
|
|
247
|
+
});
|
|
281
248
|
|
|
282
|
-
|
|
283
|
-
|
|
249
|
+
test("the projection counts the house from the same records the tools read", () => {
|
|
250
|
+
const view = deskView(hotelSlot.get(createToolContext()));
|
|
251
|
+
expect(view).toMatchObject({
|
|
252
|
+
verified: null,
|
|
253
|
+
draft: null,
|
|
254
|
+
ledger: [],
|
|
255
|
+
inHouse: 13,
|
|
256
|
+
arrivingToday: 5,
|
|
257
|
+
});
|
|
258
|
+
// What the slot projects before a tool has run is the EMPTY frame — the
|
|
259
|
+
// one `client.tsx` builds for itself — never the seed.
|
|
260
|
+
expect(hotelSlot.projected()).toEqual(deskView(emptyHotelState()));
|
|
261
|
+
expect(hotelSlot.projected()).toMatchObject({ inHouse: 0, arrivingToday: 0 });
|
|
262
|
+
// The same claim as the slot's contract, with the other two invariants:
|
|
263
|
+
// the frame is the view of `empty()`, a session's writes stay its own, and
|
|
264
|
+
// the log cap keeps the newest forty lines.
|
|
265
|
+
expectSlotContract(hotelSlot, {
|
|
266
|
+
write: (draft) => {
|
|
267
|
+
draft.log.push("probe");
|
|
268
|
+
},
|
|
269
|
+
});
|
|
270
|
+
});
|
|
284
271
|
});
|
|
285
272
|
|
|
286
|
-
|
|
287
|
-
const ctx = createToolContext();
|
|
288
|
-
const first = await run(
|
|
289
|
-
"verify_booking",
|
|
290
|
-
{ lastName: "Smith", confirmationCode: "HTL-0000" },
|
|
291
|
-
ctx,
|
|
292
|
-
);
|
|
293
|
-
expect(isToolFailure(first) && first.error).toMatch(/Attempt 1 of 3/);
|
|
294
|
-
await run("verify_booking", { lastName: "Smith", confirmationCode: "HTL-0000" }, ctx);
|
|
295
|
-
const third = await run(
|
|
296
|
-
"verify_booking",
|
|
297
|
-
{ lastName: "Smith", confirmationCode: "HTL-0000" },
|
|
298
|
-
ctx,
|
|
299
|
-
);
|
|
300
|
-
expect(isToolFailure(third) && third.error).toMatch(/verification_help/);
|
|
301
|
-
expect(hotelSlot.get(ctx).verifiedCode).toBeNull();
|
|
302
|
-
});
|
|
273
|
+
// ─── 3. Verification is the tools' job ───────────────────────────────────────
|
|
303
274
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
275
|
+
describe("verification", () => {
|
|
276
|
+
test("every booking tool refuses until verify_booking has run, naming it", async () => {
|
|
277
|
+
const ctx = createToolContext();
|
|
278
|
+
for (const tool of [lookupBooking, lookupInvoice, cancelRoomBooking, resolveRoomConflict]) {
|
|
279
|
+
const refused = await run(tool, ctx);
|
|
280
|
+
expect(isToolFailure(refused) && refused.error).toMatch(/verify_booking/);
|
|
281
|
+
}
|
|
282
|
+
expect(isToolFailure(await run(flagLateArrival, { note: "around 1 AM" }, ctx))).toBe(true);
|
|
308
283
|
});
|
|
309
|
-
expect(isToolFailure(refused) && refused.error).toMatch(/reinstate_booking/);
|
|
310
|
-
});
|
|
311
|
-
});
|
|
312
|
-
|
|
313
|
-
// ─── 4. The booking flow ─────────────────────────────────────────────────────
|
|
314
|
-
|
|
315
|
-
describe("the booking dialog", () => {
|
|
316
|
-
test("a fresh call is at the desk, and every booking tool refuses there", async () => {
|
|
317
|
-
const ctx = createToolContext();
|
|
318
|
-
expect(at(ctx)).toBe("desk");
|
|
319
|
-
for (const call of [
|
|
320
|
-
run("set_stay", { checkIn: "2026-07-14", checkOut: "2026-07-17", guests: 2 }, ctx),
|
|
321
|
-
run("choose_room", { roomType: "king" }, ctx),
|
|
322
|
-
run("confirm_booking", ctx),
|
|
323
|
-
]) {
|
|
324
|
-
const refused = expectDialogRefused(await call, "desk");
|
|
325
|
-
expect(refused.error).toMatch(/start_room_booking/);
|
|
326
|
-
}
|
|
327
|
-
expect(hotelSlot.get(ctx).draft).toBeNull();
|
|
328
|
-
});
|
|
329
284
|
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
// The options have not been offered, so a room cannot be picked yet.
|
|
335
|
-
expectDialogRefused(await run("choose_room", { roomType: "queen_2beds" }, ctx), "booking.stay");
|
|
285
|
+
test("last name plus code, or last name plus the card's last four — and nothing else", async () => {
|
|
286
|
+
const byCode = createToolContext();
|
|
287
|
+
expect((await verify(byCode, "Smith", "h t l dash a b 1 2")).code).toBe("HTL-AB12");
|
|
288
|
+
expect(hotelSlot.get(byCode).verifiedCode).toBe("HTL-AB12");
|
|
336
289
|
|
|
337
|
-
|
|
338
|
-
await run(
|
|
339
|
-
|
|
340
|
-
expect(stay.state).toBe("booking.room");
|
|
341
|
-
expect(stay.result.options).toContain("garden view");
|
|
290
|
+
const byCard = createToolContext();
|
|
291
|
+
expectToolOk(await run(verifyBooking, { lastName: "smith", cardLast4: "4242" }, byCard));
|
|
292
|
+
expect(hotelSlot.get(byCard).verifiedCode).toBe("HTL-AB12");
|
|
342
293
|
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
);
|
|
346
|
-
expect(room.state).toBe("booking.extras");
|
|
347
|
-
expect(room.result.extrasToOffer).toContain("breakfast: adds 75 dollars");
|
|
348
|
-
// No total exists before the extras are answered.
|
|
349
|
-
expect(hotelSlot.get(ctx).draft?.quotedTotal).toBeNull();
|
|
350
|
-
expectDialogRefused(await run("confirm_booking", ctx), "booking.extras");
|
|
294
|
+
const nothing = await run(verifyBooking, { lastName: "Smith" });
|
|
295
|
+
expect(isToolFailure(nothing) && nothing.error).toMatch(/PLUS/);
|
|
296
|
+
});
|
|
351
297
|
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
298
|
+
test("three strikes, and the refusal routes to a verification_help followup", async () => {
|
|
299
|
+
const ctx = createToolContext();
|
|
300
|
+
const first = await run(
|
|
301
|
+
verifyBooking,
|
|
302
|
+
{ lastName: "Smith", confirmationCode: "HTL-0000" },
|
|
356
303
|
ctx,
|
|
357
|
-
)
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
const named = expectDialogOk(
|
|
364
|
-
await run("record_guest_details", { firstName: "Maria", lastName: "Whitfield" }, ctx),
|
|
365
|
-
);
|
|
366
|
-
expect(named.state).toBe("booking.details");
|
|
367
|
-
const contact = expectDialogOk(
|
|
368
|
-
await run(
|
|
369
|
-
"record_guest_details",
|
|
370
|
-
{ email: "Maria.Whitfield@gmail.com", phone: "123-555-0170" },
|
|
304
|
+
);
|
|
305
|
+
expect(isToolFailure(first) && first.error).toMatch(/Attempt 1 of 3/);
|
|
306
|
+
await run(verifyBooking, { lastName: "Smith", confirmationCode: "HTL-0000" }, ctx);
|
|
307
|
+
const third = await run(
|
|
308
|
+
verifyBooking,
|
|
309
|
+
{ lastName: "Smith", confirmationCode: "HTL-0000" },
|
|
371
310
|
ctx,
|
|
372
|
-
)
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
expect(hotelSlot.get(ctx).draft).toMatchObject({
|
|
376
|
-
email: "maria.whitfield@gmail.com",
|
|
377
|
-
phone: "1235550170",
|
|
311
|
+
);
|
|
312
|
+
expect(isToolFailure(third) && third.error).toMatch(/verification_help/);
|
|
313
|
+
expect(hotelSlot.get(ctx).verifiedCode).toBeNull();
|
|
378
314
|
});
|
|
379
315
|
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
316
|
+
test("a cancelled booking does not verify, and the refusal names the one flow that takes it", async () => {
|
|
317
|
+
const refused = await run(verifyBooking, {
|
|
318
|
+
lastName: "Wagner",
|
|
319
|
+
confirmationCode: "HTL-FW77",
|
|
320
|
+
});
|
|
321
|
+
expect(isToolFailure(refused) && refused.error).toMatch(/reinstate_booking/);
|
|
322
|
+
});
|
|
384
323
|
});
|
|
385
324
|
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
room: "205",
|
|
402
|
-
total: "739 dollars and 20 cents",
|
|
325
|
+
// ─── 4. The booking flow ─────────────────────────────────────────────────────
|
|
326
|
+
|
|
327
|
+
describe("the booking dialog", () => {
|
|
328
|
+
test("a fresh call is at the desk, and every booking tool refuses there", async () => {
|
|
329
|
+
const ctx = createToolContext();
|
|
330
|
+
expect(at(ctx)).toBe("desk");
|
|
331
|
+
for (const call of [
|
|
332
|
+
run(setStay, { checkIn: "2026-07-14", checkOut: "2026-07-17", guests: 2 }, ctx),
|
|
333
|
+
run(chooseRoom, { roomType: "king" }, ctx),
|
|
334
|
+
run(confirmBooking, ctx),
|
|
335
|
+
]) {
|
|
336
|
+
const refused = expectDialogRefused(await call, "desk");
|
|
337
|
+
expect(refused.error).toMatch(/start_room_booking/);
|
|
338
|
+
}
|
|
339
|
+
expect(hotelSlot.get(ctx).draft).toBeNull();
|
|
403
340
|
});
|
|
404
341
|
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
342
|
+
test("each recording tool lands the flow on the step the draft says is next", async () => {
|
|
343
|
+
const ctx = createToolContext();
|
|
344
|
+
expectDialogOk(await run(startRoomBooking, ctx));
|
|
345
|
+
expect(at(ctx)).toBe("booking.stay");
|
|
346
|
+
// The options have not been offered, so a room cannot be picked yet.
|
|
347
|
+
expectDialogRefused(await run(chooseRoom, { roomType: "queen_2beds" }, ctx), "booking.stay");
|
|
348
|
+
|
|
349
|
+
const stay = expectDialogOk(
|
|
350
|
+
await run(setStay, { checkIn: "2026-07-14", checkOut: "2026-07-17", guests: 2 }, ctx),
|
|
351
|
+
);
|
|
352
|
+
expect(stay.state).toBe("booking.room");
|
|
353
|
+
expect(stay.result.options).toContain("garden view");
|
|
354
|
+
|
|
355
|
+
const room = expectDialogOk(
|
|
356
|
+
await run(chooseRoom, { roomType: "queen_2beds", view: "garden" }, ctx),
|
|
357
|
+
);
|
|
358
|
+
expect(room.state).toBe("booking.extras");
|
|
359
|
+
expect(room.result.extrasToOffer).toContain("breakfast: adds 75 dollars");
|
|
360
|
+
// No total exists before the extras are answered.
|
|
361
|
+
expect(hotelSlot.get(ctx).draft?.quotedTotal).toBeNull();
|
|
362
|
+
expectDialogRefused(await run(confirmBooking, ctx), "booking.extras");
|
|
363
|
+
|
|
364
|
+
const extras = expectDialogOk(
|
|
365
|
+
await run(
|
|
366
|
+
setExtras,
|
|
367
|
+
{ breakfast: false, valet: false, lateCheckout: false, pets: false },
|
|
368
|
+
ctx,
|
|
369
|
+
),
|
|
370
|
+
);
|
|
371
|
+
expect(extras.state).toBe("booking.details");
|
|
372
|
+
expect(extras.result.total).toBe("739 dollars and 20 cents including tax");
|
|
373
|
+
|
|
374
|
+
// A partial detail is stored the moment it is given, and the flow stays put.
|
|
375
|
+
const named = expectDialogOk(
|
|
376
|
+
await run(recordGuestDetails, { firstName: "Maria", lastName: "Whitfield" }, ctx),
|
|
377
|
+
);
|
|
378
|
+
expect(named.state).toBe("booking.details");
|
|
379
|
+
const contact = expectDialogOk(
|
|
380
|
+
await run(
|
|
381
|
+
recordGuestDetails,
|
|
382
|
+
{ email: "Maria.Whitfield@gmail.com", phone: "123-555-0170" },
|
|
383
|
+
ctx,
|
|
384
|
+
),
|
|
385
|
+
);
|
|
386
|
+
expect(contact.state).toBe("booking.card");
|
|
387
|
+
expect(hotelSlot.get(ctx).draft).toMatchObject({
|
|
388
|
+
email: "maria.whitfield@gmail.com",
|
|
389
|
+
phone: "1235550170",
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
const card = expectDialogOk(await run(recordCard, A_CARD, ctx));
|
|
393
|
+
expect(card.state).toBe("booking.readBack");
|
|
394
|
+
// Only the last four ever reached the slot.
|
|
395
|
+
expect(JSON.stringify(hotelSlot.get(ctx))).not.toContain("4532");
|
|
412
396
|
});
|
|
413
|
-
expect(hotel.invoices.find((i) => i.bookingCode === done.result.code)?.total).toBe(73_920);
|
|
414
|
-
expect(hotel.draft).toBeNull();
|
|
415
|
-
});
|
|
416
|
-
|
|
417
|
-
test("a correction after the read-back re-arms it", async () => {
|
|
418
|
-
const ctx = createToolContext();
|
|
419
|
-
await bookUpToReadBack(ctx);
|
|
420
|
-
callerAnswers(ctx);
|
|
421
|
-
// One more night: the garden queen is still free, so the pick survives and
|
|
422
|
-
// the flow goes back to the read-back rather than to the offer.
|
|
423
|
-
const redated = expectDialogOk(
|
|
424
|
-
await run("set_stay", { checkIn: "2026-07-14", checkOut: "2026-07-18", guests: 2 }, ctx),
|
|
425
|
-
);
|
|
426
|
-
expect(redated.state).toBe("booking.readBack");
|
|
427
|
-
expect(hotelSlot.get(ctx).draft?.roomType).toBe("queen_2beds");
|
|
428
|
-
expectDialogRefused(await run("confirm_booking", ctx), "booking.readBack");
|
|
429
|
-
});
|
|
430
397
|
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
await run(
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
await run(
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
);
|
|
459
|
-
expect(isToolFailure(refused) && refused.error).toMatch(/sold out/);
|
|
460
|
-
expect(hotelSlot.get(ctx).draft?.checkIn).toBeNull();
|
|
461
|
-
expect(at(ctx)).toBe("booking.stay");
|
|
462
|
-
});
|
|
463
|
-
|
|
464
|
-
test("a room in a view the type does not have is refused with where the view IS", async () => {
|
|
465
|
-
const ctx = createToolContext();
|
|
466
|
-
expectDialogOk(await run("start_room_booking", ctx));
|
|
467
|
-
expectDialogOk(
|
|
468
|
-
await run("set_stay", { checkIn: "2026-07-14", checkOut: "2026-07-17", guests: 2 }, ctx),
|
|
469
|
-
);
|
|
470
|
-
const refused = await run("choose_room", { roomType: "king", view: "garden" }, ctx);
|
|
471
|
-
expect(isToolFailure(refused) && refused.error).toMatch(/garden view IS open as a queen 2beds/);
|
|
472
|
-
});
|
|
398
|
+
test("the read-back is OWED: confirm refuses until the caller has answered it", async () => {
|
|
399
|
+
const ctx = createToolContext();
|
|
400
|
+
await bookUpToReadBack(ctx);
|
|
401
|
+
expect(at(ctx)).toBe("booking.readBack");
|
|
402
|
+
const early = expectDialogRefused(await run(confirmBooking, ctx), "booking.readBack");
|
|
403
|
+
expect(early.error).toMatch(/WAIT|answered/);
|
|
404
|
+
expect(hotelSlot.get(ctx).bookings.some((b) => b.lastName === "Whitfield")).toBe(false);
|
|
405
|
+
|
|
406
|
+
expect(callerAnswers(ctx)).toBe("booking.agreeing");
|
|
407
|
+
const done = expectDialogOk(await run(confirmBooking, ctx));
|
|
408
|
+
expect(done.state).toBe("desk");
|
|
409
|
+
expect(done.result).toMatchObject({
|
|
410
|
+
outcome: "booked",
|
|
411
|
+
room: "205",
|
|
412
|
+
total: "739 dollars and 20 cents",
|
|
413
|
+
});
|
|
414
|
+
|
|
415
|
+
const hotel = hotelSlot.get(ctx);
|
|
416
|
+
const booking = hotel.bookings.find((b) => b.code === done.result.code);
|
|
417
|
+
expect(booking).toMatchObject({
|
|
418
|
+
roomId: "205",
|
|
419
|
+
total: 73_920,
|
|
420
|
+
cardLast4: "4471",
|
|
421
|
+
status: "confirmed",
|
|
422
|
+
});
|
|
423
|
+
expect(hotel.invoices.find((i) => i.bookingCode === done.result.code)?.total).toBe(73_920);
|
|
424
|
+
expect(hotel.draft).toBeNull();
|
|
425
|
+
});
|
|
473
426
|
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
427
|
+
test("a correction after the read-back re-arms it", async () => {
|
|
428
|
+
const ctx = createToolContext();
|
|
429
|
+
await bookUpToReadBack(ctx);
|
|
430
|
+
callerAnswers(ctx);
|
|
431
|
+
// One more night: the garden queen is still free, so the pick survives and
|
|
432
|
+
// the flow goes back to the read-back rather than to the offer.
|
|
433
|
+
const redated = expectDialogOk(
|
|
434
|
+
await run(setStay, { checkIn: "2026-07-14", checkOut: "2026-07-18", guests: 2 }, ctx),
|
|
435
|
+
);
|
|
436
|
+
expect(redated.state).toBe("booking.readBack");
|
|
437
|
+
expect(hotelSlot.get(ctx).draft?.roomType).toBe("queen_2beds");
|
|
438
|
+
expectDialogRefused(await run(confirmBooking, ctx), "booking.readBack");
|
|
439
|
+
});
|
|
483
440
|
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
441
|
+
test("a re-dated pick that dies re-opens the OFFER, and the caller's turn closes it", async () => {
|
|
442
|
+
const ctx = createToolContext();
|
|
443
|
+
expectDialogOk(await run(startRoomBooking, ctx));
|
|
444
|
+
expectDialogOk(
|
|
445
|
+
await run(setStay, { checkIn: "2026-06-15", checkOut: "2026-06-16", guests: 2 }, ctx),
|
|
446
|
+
);
|
|
447
|
+
expectDialogOk(await run(chooseRoom, { roomType: "penthouse" }, ctx));
|
|
448
|
+
// The penthouse is occupied through June 12.
|
|
449
|
+
const moved = expectDialogOk(
|
|
450
|
+
await run(setStay, { checkIn: "2026-06-10", checkOut: "2026-06-11", guests: 2 }, ctx),
|
|
451
|
+
);
|
|
452
|
+
expect(moved.result.next).toBe("OFFER");
|
|
453
|
+
expect(moved.state).toBe("booking.offering");
|
|
454
|
+
expect(hotelSlot.get(ctx).draft?.roomType).toBeNull();
|
|
455
|
+
// Closed until the options have been spoken and the caller has answered.
|
|
456
|
+
expectDialogRefused(await run(chooseRoom, { roomType: "king" }, ctx), "booking.offering");
|
|
457
|
+
expect(callerAnswers(ctx)).toBe("booking.room");
|
|
458
|
+
expectDialogOk(await run(chooseRoom, { roomType: "king" }, ctx));
|
|
459
|
+
});
|
|
494
460
|
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
expectDialogOk(await run("start_room_booking", later));
|
|
508
|
-
});
|
|
461
|
+
test("sold-out dates are refused and NOT recorded", async () => {
|
|
462
|
+
const ctx = createToolContext();
|
|
463
|
+
expectDialogOk(await run(startRoomBooking, ctx));
|
|
464
|
+
const refused = await run(
|
|
465
|
+
setStay,
|
|
466
|
+
{ checkIn: "2026-07-03", checkOut: "2026-07-04", guests: 2 },
|
|
467
|
+
ctx,
|
|
468
|
+
);
|
|
469
|
+
expect(isToolFailure(refused) && refused.error).toMatch(/sold out/);
|
|
470
|
+
expect(hotelSlot.get(ctx).draft?.checkIn).toBeNull();
|
|
471
|
+
expect(at(ctx)).toBe("booking.stay");
|
|
472
|
+
});
|
|
509
473
|
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
474
|
+
test("a room in a view the type does not have is refused with where the view IS", async () => {
|
|
475
|
+
const ctx = createToolContext();
|
|
476
|
+
expectDialogOk(await run(startRoomBooking, ctx));
|
|
477
|
+
expectDialogOk(
|
|
478
|
+
await run(setStay, { checkIn: "2026-07-14", checkOut: "2026-07-17", guests: 2 }, ctx),
|
|
479
|
+
);
|
|
480
|
+
const refused = await run(chooseRoom, { roomType: "king", view: "garden" }, ctx);
|
|
481
|
+
expect(isToolFailure(refused) && refused.error).toMatch(
|
|
482
|
+
/garden view IS open as a queen 2beds/,
|
|
483
|
+
);
|
|
484
|
+
});
|
|
518
485
|
|
|
519
|
-
|
|
486
|
+
test("a bad card bounces one field and leaves the flow where it was", async () => {
|
|
487
|
+
const ctx = createToolContext();
|
|
488
|
+
await bookUpToReadBack(ctx);
|
|
489
|
+
// Re-record with a misheard digit: refused, and the recorded card stays.
|
|
490
|
+
const refused = await run(recordCard, { ...A_CARD, cardNumber: "4532 0000 0001 4472" }, ctx);
|
|
491
|
+
expect(isToolFailure(refused) && refused.error).toMatch(/one digit is likely off/);
|
|
492
|
+
expect(hotelSlot.get(ctx).draft?.cardLast4).toBe("4471");
|
|
493
|
+
expect(at(ctx)).toBe("booking.readBack");
|
|
494
|
+
});
|
|
520
495
|
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
expect(loaded.result.loaded.room).toBe("king, city view, room 201");
|
|
530
|
-
expect(loaded.result.loaded.total).toBe("537 dollars and 60 cents");
|
|
496
|
+
test("abandoning writes nothing and returns to the desk", async () => {
|
|
497
|
+
const ctx = createToolContext();
|
|
498
|
+
await bookUpToReadBack(ctx);
|
|
499
|
+
const gone = expectDialogOk(await run(abandonBooking, { reason: "changed their mind" }, ctx));
|
|
500
|
+
expect(gone.state).toBe("desk");
|
|
501
|
+
expect(hotelSlot.get(ctx).draft).toBeNull();
|
|
502
|
+
expect(hotelSlot.get(ctx).bookings.some((b) => b.lastName === "Whitfield")).toBe(false);
|
|
503
|
+
});
|
|
531
504
|
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
505
|
+
test("the double-booking guard: no second flow until the caller has spoken again", async () => {
|
|
506
|
+
const ctx = withCallerTurns(4);
|
|
507
|
+
await bookUpToReadBack(ctx);
|
|
508
|
+
callerAnswers(ctx);
|
|
509
|
+
expectDialogOk(await run(confirmBooking, ctx));
|
|
510
|
+
// Same history, so the model — not the caller — is asking for a second room.
|
|
511
|
+
const again = await run(startRoomBooking, ctx);
|
|
512
|
+
expect(isToolFailure(again) && again.error).toMatch(/already complete/);
|
|
513
|
+
expect(at(ctx)).toBe("desk");
|
|
514
|
+
// One more caller turn and a real second room is legal.
|
|
515
|
+
const later = withCallerTurns(5);
|
|
516
|
+
hotelSlot.set(later, hotelSlot.snapshot(ctx));
|
|
517
|
+
expectDialogOk(await run(startRoomBooking, later));
|
|
518
|
+
});
|
|
535
519
|
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
}>(await run("confirm_booking", ctx));
|
|
547
|
-
expect(done.result).toMatchObject({ outcome: "updated", changed: ["room"], room: "205" });
|
|
548
|
-
// 537.60 → 492.80, the difference refunded, and the model is handed the number.
|
|
549
|
-
expect(done.result.message).toContain("44 dollars and 80 cents refunded");
|
|
550
|
-
const booking = hotelSlot.get(ctx).bookings.find((b) => b.code === "HTL-RK20");
|
|
551
|
-
expect(booking).toMatchObject({ roomId: "205", total: 49_280 });
|
|
552
|
-
// Still verified as the same guest, on the post-modify booking.
|
|
553
|
-
expect(hotelSlot.get(ctx).verifiedCode).toBe("HTL-RK20");
|
|
520
|
+
test("a hang-up ends the call, and nothing books after it", async () => {
|
|
521
|
+
const ctx = createToolContext();
|
|
522
|
+
await bookUpToReadBack(ctx);
|
|
523
|
+
await fireEvent(agentDef, CALLER_GONE, ctx);
|
|
524
|
+
expect(deskFlow.position(ctx).state).toBe("hungUp");
|
|
525
|
+
expect(isToolFailure(await run(confirmBooking, ctx))).toBe(true);
|
|
526
|
+
expect(isToolFailure(await run(startRoomBooking, ctx))).toBe(true);
|
|
527
|
+
// And the lead is on the ledger: `hungUp`'s `onEnter` (desk-seams.test.ts).
|
|
528
|
+
expect(hotelSlot.get(ctx).tickets.at(-1)?.details.kind).toBe("abandoned_booking");
|
|
529
|
+
});
|
|
554
530
|
});
|
|
555
531
|
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
await
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
532
|
+
// ─── 5. Modifying a booking ──────────────────────────────────────────────────
|
|
533
|
+
|
|
534
|
+
describe("modifying a booking", () => {
|
|
535
|
+
test("Robert Klein's garden view is a room MOVE, and the refusal is the fix", async () => {
|
|
536
|
+
const ctx = createToolContext();
|
|
537
|
+
await verify(ctx, "Klein", "HTL-RK20");
|
|
538
|
+
const loaded = expectDialogOk(await run(startBookingModification, ctx));
|
|
539
|
+
expect(loaded.state).toBe("booking.editing");
|
|
540
|
+
expect(loaded.result.loaded.room).toBe("king, city view, room 201");
|
|
541
|
+
expect(loaded.result.loaded.total).toBe("537 dollars and 60 cents");
|
|
542
|
+
|
|
543
|
+
// A garden king has never existed; the garden view IS open as a queen.
|
|
544
|
+
const refused = await run(chooseRoom, { roomType: "king", view: "garden" }, ctx);
|
|
545
|
+
expect(isToolFailure(refused) && refused.error).toMatch(
|
|
546
|
+
/garden view IS open as a queen 2beds/,
|
|
547
|
+
);
|
|
548
|
+
|
|
549
|
+
const picked = expectDialogOk(
|
|
550
|
+
await run(chooseRoom, { roomType: "queen_2beds", view: "garden" }, ctx),
|
|
551
|
+
);
|
|
552
|
+
expect(picked.state).toBe("booking.readBack");
|
|
553
|
+
expect(callerAnswers(ctx)).toBe("booking.agreeing");
|
|
554
|
+
const done = expectDialogOk(await run(confirmBooking, ctx));
|
|
555
|
+
expect(done.result).toMatchObject({ outcome: "updated", changed: ["room"], room: "205" });
|
|
556
|
+
// 537.60 → 492.80, the difference refunded, and the model is handed the number.
|
|
557
|
+
expect(done.result.message).toContain("44 dollars and 80 cents refunded");
|
|
558
|
+
const booking = hotelSlot.get(ctx).bookings.find((b) => b.code === "HTL-RK20");
|
|
559
|
+
expect(booking).toMatchObject({ roomId: "205", total: 49_280 });
|
|
560
|
+
// Still verified as the same guest, on the post-modify booking.
|
|
561
|
+
expect(hotelSlot.get(ctx).verifiedCode).toBe("HTL-RK20");
|
|
573
562
|
});
|
|
574
|
-
});
|
|
575
563
|
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
564
|
+
test("a date-only change keeps the room the guest already has", async () => {
|
|
565
|
+
const ctx = createToolContext();
|
|
566
|
+
await verify(ctx, "Smith", "HTL-AB12");
|
|
567
|
+
expectDialogOk(await run(startBookingModification, ctx));
|
|
568
|
+
const stay = expectDialogOk(
|
|
569
|
+
await run(setStay, { checkIn: "2026-06-13", checkOut: "2026-06-16", guests: 2 }, ctx),
|
|
570
|
+
);
|
|
571
|
+
expect(stay.state).toBe("booking.readBack");
|
|
572
|
+
callerAnswers(ctx);
|
|
573
|
+
const done = expectDialogOk(await run(confirmBooking, ctx));
|
|
574
|
+
expect(done.result.changed).toEqual(["stay"]);
|
|
575
|
+
expect(done.result.room).toBe("203");
|
|
576
|
+
expect(hotelSlot.get(ctx).bookings.find((b) => b.code === "HTL-AB12")).toMatchObject({
|
|
577
|
+
checkOut: "2026-06-16",
|
|
578
|
+
total: 89_040,
|
|
579
|
+
});
|
|
580
|
+
});
|
|
581
|
+
|
|
582
|
+
test("a modification that changes nothing is closed as unchanged, and a cancellation is refused mid-flow", async () => {
|
|
583
|
+
const ctx = createToolContext();
|
|
584
|
+
await verify(ctx, "Smith", "HTL-AB12");
|
|
585
|
+
expectDialogOk(await run(startBookingModification, ctx));
|
|
586
|
+
// The caller pivots to cancelling: the desk's tools are still legal, but
|
|
587
|
+
// the model is told to close the flow first — which abandon_booking does.
|
|
588
|
+
expectDialogOk(await run(abandonBooking, { reason: "wants to cancel instead" }, ctx));
|
|
589
|
+
expect(at(ctx)).toBe("desk");
|
|
590
|
+
expect(hotelSlot.get(ctx).bookings.find((b) => b.code === "HTL-AB12")?.status).toBe(
|
|
591
|
+
"confirmed",
|
|
592
|
+
);
|
|
593
|
+
});
|
|
588
594
|
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
595
|
+
test("the unmodifiable: a cancelled or past booking", async () => {
|
|
596
|
+
const ctx = createToolContext();
|
|
597
|
+
await verify(ctx, "Lee", "HTL-GH78");
|
|
598
|
+
const past = await run(startBookingModification, ctx);
|
|
599
|
+
expect(isToolFailure(past) && past.error).toMatch(/already ended/);
|
|
600
|
+
});
|
|
594
601
|
});
|
|
595
|
-
});
|
|
596
602
|
|
|
597
|
-
// ─── 6. Cancelling and reinstating ───────────────────────────────────────────
|
|
603
|
+
// ─── 6. Cancelling and reinstating ───────────────────────────────────────────
|
|
604
|
+
|
|
605
|
+
describe("cancelling", () => {
|
|
606
|
+
test("outside the window the whole total comes back; inside it one night is kept", async () => {
|
|
607
|
+
const outside = createToolContext();
|
|
608
|
+
await verify(outside, "Smith", "HTL-AB12");
|
|
609
|
+
const full = expectToolOk(await run(cancelRoomBooking, outside));
|
|
610
|
+
expect(full).toMatchObject({ withinWindow: false, forfeit: 0, refund: 59_360 });
|
|
611
|
+
expect(hotelSlot.get(outside).bookings.find((b) => b.code === "HTL-AB12")?.status).toBe(
|
|
612
|
+
"cancelled",
|
|
613
|
+
);
|
|
614
|
+
expect(hotelSlot.get(outside).verifiedCode).toBeNull();
|
|
615
|
+
|
|
616
|
+
const inside = createToolContext();
|
|
617
|
+
await verify(inside, "Sato", "HTL-BN23");
|
|
618
|
+
const partial = expectToolOk(await run(cancelRoomBooking, inside));
|
|
619
|
+
// Room 204 is 220 a night; the forfeit is that rate, never a model's arithmetic.
|
|
620
|
+
expect(partial).toMatchObject({
|
|
621
|
+
withinWindow: true,
|
|
622
|
+
forfeit: 22_000,
|
|
623
|
+
refund: 54_880 - 22_000,
|
|
624
|
+
});
|
|
625
|
+
expect(partial.message).toContain("one room-night (220 dollars) is forfeited");
|
|
626
|
+
});
|
|
598
627
|
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
);
|
|
608
|
-
expect(hotelSlot.get(outside).verifiedCode).toBeNull();
|
|
609
|
-
|
|
610
|
-
const inside = createToolContext();
|
|
611
|
-
await verify(inside, "Sato", "HTL-BN23");
|
|
612
|
-
const partial = expectToolOk(await runTool(cancelRoomBooking, inside));
|
|
613
|
-
// Room 204 is 220 a night; the forfeit is that rate, never a model's arithmetic.
|
|
614
|
-
expect(partial).toMatchObject({ withinWindow: true, forfeit: 22_000, refund: 54_880 - 22_000 });
|
|
615
|
-
expect(partial.message).toContain("one room-night (220 dollars) is forfeited");
|
|
616
|
-
});
|
|
628
|
+
test("a cancel re-invoked with no caller turn since re-surfaces the outcome", async () => {
|
|
629
|
+
const ctx = withCallerTurns(2);
|
|
630
|
+
await verify(ctx, "Smith", "HTL-AB12");
|
|
631
|
+
expectToolOk(await run(cancelRoomBooking, ctx));
|
|
632
|
+
const again = expectToolOk(await run(cancelRoomBooking, ctx));
|
|
633
|
+
expect(again.alreadyCancelled).toBe(true);
|
|
634
|
+
expect(again.message).toContain("refund the full 593 dollars and 60 cents");
|
|
635
|
+
});
|
|
617
636
|
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
637
|
+
test("reinstating brings a cancelled booking back only while its room is free", async () => {
|
|
638
|
+
const ctx = createToolContext();
|
|
639
|
+
const back = expectToolOk(
|
|
640
|
+
await run(reinstateBooking, { lastName: "Wagner", confirmationCode: "htl fw77" }, ctx),
|
|
641
|
+
);
|
|
642
|
+
expect(back).toMatchObject({ reinstated: true, code: "HTL-FW77" });
|
|
643
|
+
expect(hotelSlot.get(ctx).bookings.find((b) => b.code === "HTL-FW77")?.status).toBe(
|
|
644
|
+
"confirmed",
|
|
645
|
+
);
|
|
646
|
+
expect(hotelSlot.get(ctx).verifiedCode).toBe("HTL-FW77");
|
|
647
|
+
// Already active: a no-op that says so.
|
|
648
|
+
const noop = expectToolOk(
|
|
649
|
+
await run(reinstateBooking, { lastName: "Wagner", confirmationCode: "HTL-FW77" }, ctx),
|
|
650
|
+
);
|
|
651
|
+
expect(noop.reinstated).toBe(false);
|
|
652
|
+
});
|
|
625
653
|
});
|
|
626
654
|
|
|
627
|
-
|
|
628
|
-
const ctx = createToolContext();
|
|
629
|
-
const back = expectToolOk(
|
|
630
|
-
await runTool(reinstateBooking, { lastName: "Wagner", confirmationCode: "htl fw77" }, ctx),
|
|
631
|
-
);
|
|
632
|
-
expect(back).toMatchObject({ reinstated: true, code: "HTL-FW77" });
|
|
633
|
-
expect(hotelSlot.get(ctx).bookings.find((b) => b.code === "HTL-FW77")?.status).toBe(
|
|
634
|
-
"confirmed",
|
|
635
|
-
);
|
|
636
|
-
expect(hotelSlot.get(ctx).verifiedCode).toBe("HTL-FW77");
|
|
637
|
-
// Already active: a no-op that says so.
|
|
638
|
-
const noop = expectToolOk(
|
|
639
|
-
await runTool(reinstateBooking, { lastName: "Wagner", confirmationCode: "HTL-FW77" }, ctx),
|
|
640
|
-
);
|
|
641
|
-
expect(noop.reinstated).toBe(false);
|
|
642
|
-
});
|
|
643
|
-
});
|
|
655
|
+
// ─── 7. Disputes ─────────────────────────────────────────────────────────────
|
|
644
656
|
|
|
645
|
-
|
|
657
|
+
describe("disputes", () => {
|
|
658
|
+
test("the policy table decides the refund, and the refund moves the invoice", async () => {
|
|
659
|
+
const ctx = createToolContext();
|
|
660
|
+
await verify(ctx, "Lee", "HTL-GH78");
|
|
661
|
+
const invoice = expectToolOk(await run(lookupInvoice, ctx));
|
|
662
|
+
expect(invoice.lineItems.map((li) => li.label)).toContain("Late checkout");
|
|
646
663
|
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
664
|
+
const filed = expectToolOk(
|
|
665
|
+
await run(
|
|
666
|
+
disputeCharge,
|
|
667
|
+
{
|
|
668
|
+
category: "late_checkout_fee",
|
|
669
|
+
lineItemLabel: "late checkout",
|
|
670
|
+
callerNote: "Front desk said a 1 PM checkout would be fine.",
|
|
671
|
+
acceptsOfferedResolution: true,
|
|
672
|
+
},
|
|
673
|
+
ctx,
|
|
674
|
+
),
|
|
675
|
+
);
|
|
676
|
+
expect(filed).toMatchObject({ outcome: "goodwill_waived", refund: PRICING.lateCheckout });
|
|
677
|
+
expect(filed.say).toContain("Waived as a one-time courtesy - 40 dollars back");
|
|
678
|
+
const live = hotelSlot.get(ctx).invoices.find((i) => i.bookingCode === "HTL-GH78");
|
|
679
|
+
// 672.00 less the 40.00 already waived in the seed, less this one.
|
|
680
|
+
expect(live?.total).toBe(67_200 - PRICING.lateCheckout - PRICING.lateCheckout);
|
|
681
|
+
});
|
|
653
682
|
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
});
|
|
683
|
+
test("a no-show is explained, never refunded, and escalates only when the caller pushes", async () => {
|
|
684
|
+
const ctx = createToolContext();
|
|
685
|
+
await verify(ctx, "Richardson", "HTL-NS44");
|
|
686
|
+
const pushed = expectToolOk(
|
|
687
|
+
await run(
|
|
688
|
+
disputeCharge,
|
|
689
|
+
{
|
|
690
|
+
category: "no_show",
|
|
691
|
+
lineItemLabel: "Room (2 nights)",
|
|
692
|
+
callerNote: "Never showed up.",
|
|
693
|
+
acceptsOfferedResolution: false,
|
|
694
|
+
},
|
|
695
|
+
ctx,
|
|
696
|
+
),
|
|
697
|
+
);
|
|
698
|
+
expect(pushed).toMatchObject({ outcome: "escalated_to_manager", refund: 0 });
|
|
699
|
+
});
|
|
672
700
|
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
await runTool(
|
|
701
|
+
test("a line item that is not on the invoice is refused with the lines that are", async () => {
|
|
702
|
+
const ctx = createToolContext();
|
|
703
|
+
await verify(ctx, "Lee", "HTL-GH78");
|
|
704
|
+
const refused = await run(
|
|
678
705
|
disputeCharge,
|
|
679
706
|
{
|
|
680
|
-
category: "
|
|
681
|
-
lineItemLabel: "
|
|
682
|
-
callerNote: "
|
|
707
|
+
category: "minibar",
|
|
708
|
+
lineItemLabel: "Minibar",
|
|
709
|
+
callerNote: "?",
|
|
683
710
|
acceptsOfferedResolution: false,
|
|
684
711
|
},
|
|
685
712
|
ctx,
|
|
686
|
-
)
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
await verify(ctx, "Lee", "HTL-GH78");
|
|
694
|
-
const refused = await run(
|
|
695
|
-
"dispute_charge",
|
|
696
|
-
{
|
|
697
|
-
category: "minibar",
|
|
698
|
-
lineItemLabel: "Minibar",
|
|
699
|
-
callerNote: "?",
|
|
700
|
-
acceptsOfferedResolution: false,
|
|
701
|
-
},
|
|
702
|
-
ctx,
|
|
703
|
-
);
|
|
704
|
-
// `resolveOne`'s refusal, and it carries the AMOUNTS as well as the labels —
|
|
705
|
-
// which is what the desk has to read back for the caller to pick one.
|
|
706
|
-
expect(isToolFailure(refused) && refused.error).toMatch(
|
|
707
|
-
/Room \(2 nights\) \(560 dollars\); Late checkout \(40 dollars\)/,
|
|
708
|
-
);
|
|
709
|
-
});
|
|
713
|
+
);
|
|
714
|
+
// `resolveOne`'s refusal, and it carries the AMOUNTS as well as the labels —
|
|
715
|
+
// which is what the desk has to read back for the caller to pick one.
|
|
716
|
+
expect(isToolFailure(refused) && refused.error).toMatch(
|
|
717
|
+
/Room \(2 nights\) \(560 dollars\); Late checkout \(40 dollars\)/,
|
|
718
|
+
);
|
|
719
|
+
});
|
|
710
720
|
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
721
|
+
test("the outcome table, branch by branch", () => {
|
|
722
|
+
const lines = [{ label: "Minibar", amount: 1800 }];
|
|
723
|
+
expect(
|
|
724
|
+
resolveDisputeOutcome(DISPUTE_POLICIES.minibar, 1800, "Minibar", lines, false),
|
|
725
|
+
).toEqual({
|
|
726
|
+
outcome: "auto_refunded",
|
|
727
|
+
refund: 1800,
|
|
728
|
+
});
|
|
729
|
+
expect(
|
|
730
|
+
resolveDisputeOutcome(DISPUTE_POLICIES.minibar, 9000, "Minibar", lines, false).outcome,
|
|
731
|
+
).toBe("escalated_to_manager");
|
|
732
|
+
expect(
|
|
733
|
+
resolveDisputeOutcome(DISPUTE_POLICIES.damage_cleaning, 5000, "Pet fee", lines, true)
|
|
734
|
+
.outcome,
|
|
735
|
+
).toBe("explained_no_action");
|
|
736
|
+
const doubled = [
|
|
737
|
+
{ label: "Room (3 nights)", amount: 66_000 },
|
|
738
|
+
{ label: "Room (3 nights)", amount: 66_000 },
|
|
739
|
+
];
|
|
740
|
+
expect(
|
|
741
|
+
resolveDisputeOutcome(
|
|
742
|
+
DISPUTE_POLICIES.double_charge_billing_error,
|
|
743
|
+
66_000,
|
|
744
|
+
"Room (3 nights)",
|
|
745
|
+
doubled,
|
|
746
|
+
false,
|
|
747
|
+
),
|
|
748
|
+
).toEqual({ outcome: "auto_refunded", refund: 66_000 });
|
|
749
|
+
expect(
|
|
750
|
+
resolveDisputeOutcome(
|
|
751
|
+
DISPUTE_POLICIES.double_charge_billing_error,
|
|
752
|
+
66_000,
|
|
753
|
+
"Room (3 nights)",
|
|
754
|
+
lines,
|
|
755
|
+
false,
|
|
756
|
+
).outcome,
|
|
757
|
+
).toBe("accounting_ticket_opened");
|
|
716
758
|
});
|
|
717
|
-
expect(
|
|
718
|
-
resolveDisputeOutcome(DISPUTE_POLICIES.minibar, 9000, "Minibar", lines, false).outcome,
|
|
719
|
-
).toBe("escalated_to_manager");
|
|
720
|
-
expect(
|
|
721
|
-
resolveDisputeOutcome(DISPUTE_POLICIES.damage_cleaning, 5000, "Pet fee", lines, true).outcome,
|
|
722
|
-
).toBe("explained_no_action");
|
|
723
|
-
const doubled = [
|
|
724
|
-
{ label: "Room (3 nights)", amount: 66_000 },
|
|
725
|
-
{ label: "Room (3 nights)", amount: 66_000 },
|
|
726
|
-
];
|
|
727
|
-
expect(
|
|
728
|
-
resolveDisputeOutcome(
|
|
729
|
-
DISPUTE_POLICIES.double_charge_billing_error,
|
|
730
|
-
66_000,
|
|
731
|
-
"Room (3 nights)",
|
|
732
|
-
doubled,
|
|
733
|
-
false,
|
|
734
|
-
),
|
|
735
|
-
).toEqual({ outcome: "auto_refunded", refund: 66_000 });
|
|
736
|
-
expect(
|
|
737
|
-
resolveDisputeOutcome(
|
|
738
|
-
DISPUTE_POLICIES.double_charge_billing_error,
|
|
739
|
-
66_000,
|
|
740
|
-
"Room (3 nights)",
|
|
741
|
-
lines,
|
|
742
|
-
false,
|
|
743
|
-
).outcome,
|
|
744
|
-
).toBe("accounting_ticket_opened");
|
|
745
759
|
});
|
|
746
|
-
});
|
|
747
760
|
|
|
748
|
-
// ─── 8. Room conflicts: the two seeded double-bookings ───────────────────────
|
|
749
|
-
|
|
750
|
-
describe("room conflicts", () => {
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
+
// ─── 8. Room conflicts: the two seeded double-bookings ───────────────────────
|
|
762
|
+
|
|
763
|
+
describe("room conflicts", () => {
|
|
764
|
+
test("Kenji Tanaka is WALKED: the house is full tonight, and 301 is his again tomorrow", async () => {
|
|
765
|
+
const ctx = createToolContext();
|
|
766
|
+
await verify(ctx, "Tanaka", "HTL-RT88");
|
|
767
|
+
const looked = expectToolOk(await run(lookupBooking, ctx));
|
|
768
|
+
expect(looked.WARNING).toMatch(/double-booked/);
|
|
769
|
+
const resolved = expectToolOk(await run(resolveRoomConflict, ctx));
|
|
770
|
+
expect(resolved).toMatchObject({
|
|
771
|
+
resolved: "walked",
|
|
772
|
+
partnerHotel: "the Harbor House",
|
|
773
|
+
returnDate: "Tuesday, June 9",
|
|
774
|
+
});
|
|
775
|
+
expect(hotelSlot.get(ctx).tickets.some((t) => t.kind === "walk")).toBe(true);
|
|
776
|
+
// The booking itself is untouched: same room, same total.
|
|
777
|
+
expect(hotelSlot.get(ctx).bookings.find((b) => b.code === "HTL-RT88")?.roomId).toBe("301");
|
|
761
778
|
});
|
|
762
|
-
expect(hotelSlot.get(ctx).tickets.some((t) => t.kind === "walk")).toBe(true);
|
|
763
|
-
// The booking itself is untouched: same room, same total.
|
|
764
|
-
expect(hotelSlot.get(ctx).bookings.find((b) => b.code === "HTL-RT88")?.roomId).toBe("301");
|
|
765
|
-
});
|
|
766
779
|
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
780
|
+
test("Tom Whelan is UPGRADED: the only room at or above his rate is a suite, at his total", async () => {
|
|
781
|
+
const ctx = createToolContext();
|
|
782
|
+
await verify(ctx, "Whelan", "HTL-TW55");
|
|
783
|
+
const before = hotelSlot.get(ctx).bookings.find((b) => b.code === "HTL-TW55")?.total;
|
|
784
|
+
const resolved = expectToolOk(await run(resolveRoomConflict, ctx));
|
|
785
|
+
expect(resolved).toMatchObject({ resolved: "moved", roomType: "suite", upgraded: true });
|
|
786
|
+
const after = hotelSlot.get(ctx).bookings.find((b) => b.code === "HTL-TW55");
|
|
787
|
+
expect(after?.roomId).toBe(resolved.room);
|
|
788
|
+
expect(after?.total).toBe(before);
|
|
789
|
+
// And the lookup no longer warns.
|
|
790
|
+
expect(expectToolOk(await run(lookupBooking, ctx)).WARNING).toBeUndefined();
|
|
791
|
+
});
|
|
779
792
|
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
793
|
+
test("a booking with no conflict has nothing to resolve", async () => {
|
|
794
|
+
const ctx = createToolContext();
|
|
795
|
+
await verify(ctx, "Klein", "HTL-RK20");
|
|
796
|
+
const refused = await run(resolveRoomConflict, ctx);
|
|
797
|
+
expect(isToolFailure(refused) && refused.error).toMatch(/no room conflict/);
|
|
798
|
+
});
|
|
785
799
|
});
|
|
786
|
-
});
|
|
787
800
|
|
|
788
|
-
// ─── 9. Guest privacy ────────────────────────────────────────────────────────
|
|
789
|
-
|
|
790
|
-
describe("taking a message", () => {
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
801
|
+
// ─── 9. Guest privacy ────────────────────────────────────────────────────────
|
|
802
|
+
|
|
803
|
+
describe("taking a message", () => {
|
|
804
|
+
test("the result for an in-house guest and for a stranger are indistinguishable", async () => {
|
|
805
|
+
const ctx = createToolContext();
|
|
806
|
+
const args = {
|
|
807
|
+
callerName: "Mark Ellis",
|
|
808
|
+
callerPhone: "415 555 0100",
|
|
809
|
+
message: "Dinner is at eight.",
|
|
810
|
+
};
|
|
811
|
+
const guest = expectToolOk(
|
|
812
|
+
await run(takeGuestMessage, { ...args, recipient: "Jonathan Pierce" }, ctx),
|
|
813
|
+
);
|
|
814
|
+
const stranger = expectToolOk(
|
|
815
|
+
await run(takeGuestMessage, { ...args, recipient: "Nobody Here" }, ctx),
|
|
816
|
+
);
|
|
817
|
+
const shape = (r: Record<string, unknown>) => Object.keys(r).sort();
|
|
818
|
+
expect(shape(guest)).toEqual(shape(stranger));
|
|
819
|
+
for (const result of [guest, stranger]) {
|
|
820
|
+
// Neither the verdict nor the room number the ledger knows reaches the model.
|
|
821
|
+
expect(JSON.stringify(result)).not.toMatch(/delivered|undeliverable|303/);
|
|
822
|
+
}
|
|
823
|
+
// The desk's ledger knows; the model never did.
|
|
824
|
+
const statuses = hotelSlot
|
|
825
|
+
.get(ctx)
|
|
826
|
+
.tickets.filter((t) => t.kind === "guest_message")
|
|
827
|
+
.map((t) => t.details.status);
|
|
828
|
+
expect(statuses).toEqual(["delivered", "undeliverable"]);
|
|
829
|
+
});
|
|
817
830
|
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
831
|
+
test("a first name alone is refused — a message needs the full name to reach anyone", async () => {
|
|
832
|
+
const refused = await run(takeGuestMessage, {
|
|
833
|
+
recipient: "Jonathan",
|
|
834
|
+
callerName: "Mark",
|
|
835
|
+
callerPhone: "415 555 0100",
|
|
836
|
+
message: "hi",
|
|
837
|
+
});
|
|
838
|
+
expect(isToolFailure(refused) && refused.error).toMatch(/last name/);
|
|
824
839
|
});
|
|
825
|
-
expect(isToolFailure(refused) && refused.error).toMatch(/last name/);
|
|
826
840
|
});
|
|
827
|
-
});
|
|
828
841
|
|
|
829
|
-
// ─── 10. The restaurant ──────────────────────────────────────────────────────
|
|
830
|
-
|
|
831
|
-
describe("the restaurant", () => {
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
842
|
+
// ─── 10. The restaurant ──────────────────────────────────────────────────────
|
|
843
|
+
|
|
844
|
+
describe("the restaurant", () => {
|
|
845
|
+
test("open slots come from the tables that seat the party and are not already taken", async () => {
|
|
846
|
+
const open = expectToolOk(
|
|
847
|
+
await run(checkRestaurantAvailability, { date: TODAY, partySize: 4 }),
|
|
848
|
+
);
|
|
849
|
+
expect(open.open).toContain("7 PM");
|
|
850
|
+
const six = expectToolOk(
|
|
851
|
+
await run(checkRestaurantAvailability, { date: TODAY, partySize: 6 }),
|
|
852
|
+
);
|
|
853
|
+
// The one six-top is García's at 7:30 tonight.
|
|
854
|
+
expect(six.open).not.toContain("7:30 PM");
|
|
855
|
+
expect(six.open).toContain("7 PM");
|
|
856
|
+
});
|
|
844
857
|
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
858
|
+
test("a table is booked in one call, and the refusals carry the open times or the transfer", async () => {
|
|
859
|
+
const ctx = createToolContext();
|
|
860
|
+
const args = {
|
|
861
|
+
date: TODAY,
|
|
862
|
+
time: "19:00",
|
|
863
|
+
partySize: 4,
|
|
864
|
+
firstName: "Ana",
|
|
865
|
+
lastName: "Reyes",
|
|
866
|
+
phone: "415 555 0199",
|
|
867
|
+
};
|
|
868
|
+
const booked = expectToolOk(await run(reserveTable, args, ctx));
|
|
869
|
+
expect(booked.code).toMatch(/^RES-/);
|
|
870
|
+
expect(booked.time).toBe("7 PM");
|
|
871
|
+
|
|
872
|
+
const odd = await run(reserveTable, { ...args, time: "19:15" }, ctx);
|
|
873
|
+
expect(isToolFailure(odd) && odd.error).toMatch(/5:30 PM/);
|
|
874
|
+
const big = await run(reserveTable, { ...args, partySize: 8 }, ctx);
|
|
875
|
+
expect(isToolFailure(big) && big.error).toMatch(/transfer_call/);
|
|
876
|
+
const past = await run(reserveTable, { ...args, date: "2026-06-01" }, ctx);
|
|
877
|
+
expect(isToolFailure(past)).toBe(true);
|
|
878
|
+
});
|
|
866
879
|
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
880
|
+
test("moving a reservation keeps its table when that table is still free", async () => {
|
|
881
|
+
const ctx = createToolContext();
|
|
882
|
+
const moved = expectToolOk(
|
|
883
|
+
await run(
|
|
884
|
+
modifyRestaurantReservation,
|
|
885
|
+
{ lastName: "Bennett", confirmationCode: "RES-JK90", newDate: TODAY, newTime: "19:30" },
|
|
886
|
+
ctx,
|
|
887
|
+
),
|
|
888
|
+
);
|
|
889
|
+
expect(moved).toMatchObject({ code: "RES-JK90", time: "7:30 PM", partySize: 4 });
|
|
890
|
+
const reservation = hotelSlot.get(ctx).reservations.find((r) => r.code === "RES-JK90");
|
|
891
|
+
expect(reservation).toMatchObject({ tableId: 3, time: "19:30" });
|
|
879
892
|
|
|
880
|
-
|
|
881
|
-
await run(
|
|
882
|
-
"cancel_restaurant_reservation",
|
|
883
|
-
{ lastName: "Bennett", confirmationCode: "res jk90" },
|
|
884
|
-
ctx,
|
|
885
|
-
),
|
|
886
|
-
);
|
|
887
|
-
expect(cancelled).toMatchObject({ cancelled: true });
|
|
888
|
-
expect(
|
|
889
|
-
isToolFailure(
|
|
893
|
+
const cancelled = expectToolOk(
|
|
890
894
|
await run(
|
|
891
|
-
|
|
892
|
-
{ lastName: "Bennett", confirmationCode: "
|
|
895
|
+
cancelRestaurantReservation,
|
|
896
|
+
{ lastName: "Bennett", confirmationCode: "res jk90" },
|
|
893
897
|
ctx,
|
|
894
898
|
),
|
|
895
|
-
)
|
|
896
|
-
|
|
899
|
+
);
|
|
900
|
+
expect(cancelled).toMatchObject({ cancelled: true });
|
|
901
|
+
expect(
|
|
902
|
+
isToolFailure(
|
|
903
|
+
await run(
|
|
904
|
+
lookupRestaurantReservation,
|
|
905
|
+
{ lastName: "Bennett", confirmationCode: "RES-JK90" },
|
|
906
|
+
ctx,
|
|
907
|
+
),
|
|
908
|
+
),
|
|
909
|
+
).toBe(true);
|
|
910
|
+
});
|
|
897
911
|
});
|
|
898
|
-
});
|
|
899
912
|
|
|
900
|
-
// ─── 11. Services and the ledger ─────────────────────────────────────────────
|
|
913
|
+
// ─── 11. Services and the ledger ─────────────────────────────────────────────
|
|
901
914
|
|
|
902
|
-
describe("services", () => {
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
915
|
+
describe("services", () => {
|
|
916
|
+
test("an emergency is dispatched with no verification, and the direction matches the kind", async () => {
|
|
917
|
+
const ctx = createToolContext();
|
|
918
|
+
const sent = expectToolOk(
|
|
919
|
+
await run(
|
|
920
|
+
dispatchEmergency,
|
|
921
|
+
{ room: "room 401", kind: "medical", situation: "guest collapsed" },
|
|
922
|
+
ctx,
|
|
923
|
+
),
|
|
924
|
+
);
|
|
925
|
+
expect(sent).toMatchObject({ dispatched: true, room: "401" });
|
|
926
|
+
expect(sent.next).toMatch(/9-1-1/);
|
|
927
|
+
expect(hotelSlot.get(ctx).tickets[0]?.kind).toBe("emergency");
|
|
928
|
+
const badRoom = await run(
|
|
907
929
|
dispatchEmergency,
|
|
908
|
-
{ room: "
|
|
909
|
-
ctx,
|
|
910
|
-
),
|
|
911
|
-
);
|
|
912
|
-
expect(sent).toMatchObject({ dispatched: true, room: "401" });
|
|
913
|
-
expect(sent.next).toMatch(/9-1-1/);
|
|
914
|
-
expect(hotelSlot.get(ctx).tickets[0]?.kind).toBe("emergency");
|
|
915
|
-
const badRoom = await run(
|
|
916
|
-
"dispatch_emergency",
|
|
917
|
-
{ room: "999", kind: "fire", situation: "smoke" },
|
|
918
|
-
ctx,
|
|
919
|
-
);
|
|
920
|
-
expect(isToolFailure(badRoom) && badRoom.error).toMatch(/no such room/);
|
|
921
|
-
});
|
|
922
|
-
|
|
923
|
-
test("a wake-up call is set, a followup is recorded, and each is a ledger line with a reference", async () => {
|
|
924
|
-
const ctx = createToolContext();
|
|
925
|
-
const wake = expectToolOk(
|
|
926
|
-
await runTool(
|
|
927
|
-
scheduleWakeupCall,
|
|
928
|
-
{ room: "304", guestName: "Frank Adler", date: addDays(TODAY, 1), time: "04:45" },
|
|
929
|
-
ctx,
|
|
930
|
-
),
|
|
931
|
-
);
|
|
932
|
-
expect(wake.reference).toMatch(/^WUC-/);
|
|
933
|
-
expect(wake.when).toBe("Tuesday, June 9 at 4:45 AM");
|
|
934
|
-
const followup = expectToolOk(
|
|
935
|
-
await runTool(
|
|
936
|
-
recordFollowup,
|
|
937
|
-
{
|
|
938
|
-
kind: "housekeeping",
|
|
939
|
-
callerName: "Priya Nair",
|
|
940
|
-
callerPhone: "202",
|
|
941
|
-
summary: "Two more towels to room 202.",
|
|
942
|
-
},
|
|
930
|
+
{ room: "999", kind: "fire", situation: "smoke" },
|
|
943
931
|
ctx,
|
|
944
|
-
)
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
expect(followup.next).toContain("Two more towels");
|
|
948
|
-
expect(deskView(hotelSlot.get(ctx)).ledger.map((t) => t.kind)).toEqual([
|
|
949
|
-
"followup",
|
|
950
|
-
"wakeup_call",
|
|
951
|
-
]);
|
|
952
|
-
});
|
|
932
|
+
);
|
|
933
|
+
expect(isToolFailure(badRoom) && badRoom.error).toMatch(/no such room/);
|
|
934
|
+
});
|
|
953
935
|
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
936
|
+
test("a wake-up call is set, a followup is recorded, and each is a ledger line with a reference", async () => {
|
|
937
|
+
const ctx = createToolContext();
|
|
938
|
+
const wake = expectToolOk(
|
|
939
|
+
await run(
|
|
940
|
+
scheduleWakeupCall,
|
|
941
|
+
{ room: "304", guestName: "Frank Adler", date: addDays(TODAY, 1), time: "04:45" },
|
|
942
|
+
ctx,
|
|
943
|
+
),
|
|
944
|
+
);
|
|
945
|
+
expect(wake.reference).toMatch(/^WUC-/);
|
|
946
|
+
expect(wake.when).toBe("Tuesday, June 9 at 4:45 AM");
|
|
947
|
+
const followup = expectToolOk(
|
|
948
|
+
await run(
|
|
949
|
+
recordFollowup,
|
|
950
|
+
{
|
|
951
|
+
kind: "housekeeping",
|
|
952
|
+
callerName: "Priya Nair",
|
|
953
|
+
callerPhone: "202",
|
|
954
|
+
summary: "Two more towels to room 202.",
|
|
955
|
+
},
|
|
956
|
+
ctx,
|
|
957
|
+
),
|
|
958
|
+
);
|
|
959
|
+
expect(followup.reference).toMatch(/^FUP-/);
|
|
960
|
+
expect(followup.next).toContain("Two more towels");
|
|
961
|
+
expect(deskView(hotelSlot.get(ctx)).ledger.map((t) => t.kind)).toEqual([
|
|
962
|
+
"followup",
|
|
963
|
+
"wakeup_call",
|
|
964
|
+
]);
|
|
965
|
+
});
|
|
970
966
|
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
)
|
|
985
|
-
|
|
986
|
-
expect(tour.total).toBe("220 dollars");
|
|
987
|
-
expect(tour.reference).toMatch(/^TUR-/);
|
|
988
|
-
const tooMany = await run("book_tour", {
|
|
989
|
-
tour: "private_city",
|
|
990
|
-
date: addDays(TODAY, 2),
|
|
991
|
-
partySize: 5,
|
|
992
|
-
guestName: "x",
|
|
993
|
-
guestPhone: "1",
|
|
967
|
+
test("a transfer happens exactly once per department", async () => {
|
|
968
|
+
const ctx = createToolContext();
|
|
969
|
+
const first = expectToolOk(
|
|
970
|
+
await run(
|
|
971
|
+
transferCall,
|
|
972
|
+
{ destination: "restaurant", summary: "party of ten, private room" },
|
|
973
|
+
ctx,
|
|
974
|
+
),
|
|
975
|
+
);
|
|
976
|
+
const second = expectToolOk(
|
|
977
|
+
await run(transferCall, { destination: "restaurant", summary: "again" }, ctx),
|
|
978
|
+
);
|
|
979
|
+
expect(first.alreadyTransferred).toBe(false);
|
|
980
|
+
expect(second.alreadyTransferred).toBe(true);
|
|
981
|
+
expect(hotelSlot.get(ctx).tickets.filter((t) => t.kind === "transfer")).toHaveLength(1);
|
|
994
982
|
});
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
983
|
+
|
|
984
|
+
test("the catalogs price a booking and refuse past its caps", async () => {
|
|
985
|
+
const ctx = createToolContext();
|
|
986
|
+
const tour = expectToolOk(
|
|
987
|
+
await run(
|
|
988
|
+
bookTour,
|
|
989
|
+
{
|
|
990
|
+
tour: "full_day_city",
|
|
991
|
+
date: addDays(TODAY, 2),
|
|
992
|
+
partySize: 2,
|
|
993
|
+
guestName: "Sofía García",
|
|
994
|
+
guestPhone: "415 555 0107",
|
|
995
|
+
},
|
|
996
|
+
ctx,
|
|
997
|
+
),
|
|
998
|
+
);
|
|
999
|
+
expect(tour.total).toBe("220 dollars");
|
|
1000
|
+
expect(tour.reference).toMatch(/^TUR-/);
|
|
1001
|
+
const tooMany = await run(bookTour, {
|
|
1002
|
+
tour: "private_city",
|
|
1003
|
+
date: addDays(TODAY, 2),
|
|
1004
|
+
partySize: 5,
|
|
1005
|
+
guestName: "x",
|
|
1006
|
+
guestPhone: "1",
|
|
1007
|
+
});
|
|
1008
|
+
expect(isToolFailure(tooMany) && tooMany.error).toMatch(/at most 4/);
|
|
1009
|
+
const past = await run(orderFlowers, {
|
|
1010
|
+
arrangement: "roses",
|
|
1011
|
+
date: "2026-06-01",
|
|
1012
|
+
deliverTo: "401",
|
|
1013
|
+
cardMessage: "Happy anniversary",
|
|
1014
|
+
guestName: "x",
|
|
1015
|
+
guestPhone: "1",
|
|
1016
|
+
});
|
|
1017
|
+
expect(isToolFailure(past) && past.error).toMatch(/in the past/);
|
|
1018
|
+
const spa = expectToolOk(
|
|
1019
|
+
await run(
|
|
1020
|
+
bookSpaAppointment,
|
|
1021
|
+
{
|
|
1022
|
+
service: "deep_tissue_massage",
|
|
1023
|
+
date: addDays(TODAY, 1),
|
|
1024
|
+
time: "10:00",
|
|
1025
|
+
partySize: 2,
|
|
1026
|
+
guestName: "x",
|
|
1027
|
+
guestPhone: "1",
|
|
1028
|
+
},
|
|
1029
|
+
ctx,
|
|
1030
|
+
),
|
|
1031
|
+
);
|
|
1032
|
+
expect(spa.total).toBe("280 dollars");
|
|
1033
|
+
const biz = expectToolOk(
|
|
1034
|
+
await run(
|
|
1035
|
+
bookBusinessCenter,
|
|
1036
|
+
{
|
|
1037
|
+
service: "meeting_room",
|
|
1038
|
+
date: addDays(TODAY, 1),
|
|
1039
|
+
time: "09:00",
|
|
1040
|
+
durationHours: 3,
|
|
1041
|
+
guestName: "x",
|
|
1042
|
+
guestPhone: "1",
|
|
1043
|
+
},
|
|
1044
|
+
ctx,
|
|
1045
|
+
),
|
|
1046
|
+
);
|
|
1047
|
+
expect(biz.total).toBe("120 dollars");
|
|
1003
1048
|
});
|
|
1004
|
-
expect(isToolFailure(past) && past.error).toMatch(/in the past/);
|
|
1005
|
-
const spa = expectToolOk(
|
|
1006
|
-
await runTool(
|
|
1007
|
-
bookSpaAppointment,
|
|
1008
|
-
{
|
|
1009
|
-
service: "deep_tissue_massage",
|
|
1010
|
-
date: addDays(TODAY, 1),
|
|
1011
|
-
time: "10:00",
|
|
1012
|
-
partySize: 2,
|
|
1013
|
-
guestName: "x",
|
|
1014
|
-
guestPhone: "1",
|
|
1015
|
-
},
|
|
1016
|
-
ctx,
|
|
1017
|
-
),
|
|
1018
|
-
);
|
|
1019
|
-
expect(spa.total).toBe("280 dollars");
|
|
1020
|
-
const biz = expectToolOk(
|
|
1021
|
-
await runTool(
|
|
1022
|
-
bookBusinessCenter,
|
|
1023
|
-
{
|
|
1024
|
-
service: "meeting_room",
|
|
1025
|
-
date: addDays(TODAY, 1),
|
|
1026
|
-
time: "09:00",
|
|
1027
|
-
durationHours: 3,
|
|
1028
|
-
guestName: "x",
|
|
1029
|
-
guestPhone: "1",
|
|
1030
|
-
},
|
|
1031
|
-
ctx,
|
|
1032
|
-
),
|
|
1033
|
-
);
|
|
1034
|
-
expect(biz.total).toBe("120 dollars");
|
|
1035
|
-
});
|
|
1036
1049
|
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
).toBeDefined();
|
|
1045
|
-
});
|
|
1050
|
+
test("the policy book renders the catalogs, so a price lives in one place", async () => {
|
|
1051
|
+
const tours = expectToolOk(await run(lookupPolicy, { topic: "tours" }));
|
|
1052
|
+
expect(tours.policy).toContain("Half-day city highlights");
|
|
1053
|
+
expect(tours.policy).toContain("65 dollars per person");
|
|
1054
|
+
expect(POLICIES.spa.body).toContain("140 dollars per person");
|
|
1055
|
+
expect(await toolInputIssues(lookupPolicy, { topic: "not_a_topic" })).toBeDefined();
|
|
1056
|
+
});
|
|
1046
1057
|
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1058
|
+
test("a group under fifteen is not a group, and a car with five is not the hotel car", async () => {
|
|
1059
|
+
expect(
|
|
1060
|
+
await toolInputIssues(recordGroupInquiry, {
|
|
1061
|
+
company: "Acme",
|
|
1062
|
+
contactName: "A",
|
|
1063
|
+
contactPhone: "1",
|
|
1064
|
+
partySize: 10,
|
|
1065
|
+
shareType: "twin",
|
|
1066
|
+
checkIn: addDays(TODAY, 30),
|
|
1067
|
+
nights: 2,
|
|
1068
|
+
}),
|
|
1069
|
+
).toBeDefined();
|
|
1070
|
+
expect(
|
|
1071
|
+
await toolInputIssues(bookAirportCar, {
|
|
1072
|
+
room: "401",
|
|
1073
|
+
pickupDate: addDays(TODAY, 1),
|
|
1074
|
+
pickupTime: "06:00",
|
|
1075
|
+
passengers: 5,
|
|
1076
|
+
}),
|
|
1077
|
+
).toBeDefined();
|
|
1078
|
+
const car = expectToolOk(
|
|
1079
|
+
await run(bookAirportCar, {
|
|
1080
|
+
room: "401",
|
|
1081
|
+
pickupDate: addDays(TODAY, 1),
|
|
1082
|
+
pickupTime: "06:00",
|
|
1083
|
+
passengers: 3,
|
|
1084
|
+
}),
|
|
1085
|
+
);
|
|
1086
|
+
expect(car.total).toBe("85 dollars");
|
|
1087
|
+
});
|
|
1077
1088
|
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1089
|
+
test("a flight reference is normalized the way a caller spells one", async () => {
|
|
1090
|
+
const ctx = createToolContext();
|
|
1091
|
+
expectToolOk(
|
|
1092
|
+
await run(
|
|
1093
|
+
requestFlightReconfirmation,
|
|
1094
|
+
{
|
|
1095
|
+
room: "304",
|
|
1096
|
+
airline: "Iberia",
|
|
1097
|
+
flightNumber: "ib 6174",
|
|
1098
|
+
flightDate: addDays(TODAY, 3),
|
|
1099
|
+
bookingReference: "x 7 q - 9 2 k",
|
|
1100
|
+
seatCheck: true,
|
|
1101
|
+
},
|
|
1102
|
+
ctx,
|
|
1103
|
+
),
|
|
1104
|
+
);
|
|
1105
|
+
expect(hotelSlot.get(ctx).tickets[0]?.details).toMatchObject({
|
|
1106
|
+
flightNumber: "IB6174",
|
|
1107
|
+
bookingReference: "X7Q92K",
|
|
1108
|
+
});
|
|
1097
1109
|
});
|
|
1098
|
-
});
|
|
1099
1110
|
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1111
|
+
test("the verified guest's extras: a late arrival, a re-sent folio, a new card", async () => {
|
|
1112
|
+
const ctx = createToolContext();
|
|
1113
|
+
await verify(ctx, "Smith", "HTL-AB12");
|
|
1114
|
+
expectToolOk(await run(flagLateArrival, { note: "around 1 AM" }, ctx));
|
|
1115
|
+
expect(hotelSlot.get(ctx).bookings.find((b) => b.code === "HTL-AB12")?.lateArrivalNote).toBe(
|
|
1116
|
+
"around 1 AM",
|
|
1117
|
+
);
|
|
1118
|
+
const sent = expectToolOk(await run(resendConfirmation, { kind: "folio" }, ctx));
|
|
1119
|
+
expect(sent.to).toBe("eleanor.smith@gmail.com");
|
|
1120
|
+
const card = expectToolOk(await run(updateCard, A_CARD, ctx));
|
|
1121
|
+
expect(card.cardLast4).toBe("4471");
|
|
1122
|
+
expect(hotelSlot.get(ctx).bookings.find((b) => b.code === "HTL-AB12")?.cardLast4).toBe(
|
|
1123
|
+
"4471",
|
|
1124
|
+
);
|
|
1125
|
+
});
|
|
1113
1126
|
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1127
|
+
test("two contexts never share a hotel", async () => {
|
|
1128
|
+
const a = createToolContext();
|
|
1129
|
+
const b = createToolContext();
|
|
1130
|
+
await verify(a, "Smith", "HTL-AB12");
|
|
1131
|
+
expectToolOk(await run(cancelRoomBooking, a));
|
|
1132
|
+
expect(hotelSlot.get(b).bookings.find((x) => x.code === "HTL-AB12")?.status).toBe(
|
|
1133
|
+
"confirmed",
|
|
1134
|
+
);
|
|
1135
|
+
});
|
|
1120
1136
|
});
|
|
1121
1137
|
});
|