@alexkroman1/aai-cli 0.12.3 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +69 -0
- package/bin.mjs +58 -0
- package/dist/_agent-BopNO5Bq.mjs +152 -0
- package/dist/_agent.d.ts +83 -0
- package/dist/_api-client.d.ts +92 -0
- package/dist/_artifacts-BJOYGQPp.mjs +21 -0
- package/dist/_artifacts.d.ts +16 -0
- package/dist/_build-target-C08aM-Es.mjs +1119 -0
- package/dist/_build-target.d.ts +276 -0
- package/dist/_bundler-B6v31ROV.mjs +102 -0
- package/dist/_bundler.d.ts +60 -0
- package/dist/_cli-common.d.ts +173 -0
- package/dist/_client-plugins.d.ts +57 -0
- package/dist/_config-mq1I5Cva.mjs +263 -0
- package/dist/_config.d.ts +122 -0
- package/dist/_console-audio.d.ts +35 -0
- package/dist/_console-session.d.ts +70 -0
- package/dist/_default-html.d.ts +33 -0
- package/dist/_deno-output.d.ts +23 -0
- package/dist/_deno-target.d.ts +74 -0
- package/dist/_deploy.d.ts +22 -0
- package/dist/_dev-agent-env.d.ts +27 -0
- package/dist/_dev-env-D9Uy5wNt.mjs +89 -0
- package/dist/_dev-env.d.ts +77 -0
- package/dist/_dev-restart.d.ts +64 -0
- package/dist/_dev-server-GoEXEVpA.mjs +737 -0
- package/dist/_dev-server.d.ts +89 -0
- package/dist/_dev-session-ticket.d.ts +63 -0
- package/dist/_dev-source.d.ts +55 -0
- package/dist/_dev-tunnel.d.ts +90 -0
- package/dist/_dev-typecheck.d.ts +38 -0
- package/dist/_dev-vite-config.d.ts +100 -0
- package/dist/_dev-watch.d.ts +35 -0
- package/dist/_dotenv-file.d.ts +45 -0
- package/dist/_e2e-test-utils.d.ts +120 -0
- package/dist/_fault-mode.d.ts +194 -0
- package/dist/_help.d.ts +31 -0
- package/dist/_init.d.ts +66 -0
- package/dist/_mock-api.d.ts +22 -0
- package/dist/_mock-registry.d.ts +17 -0
- package/dist/_modal-app.d.ts +77 -0
- package/dist/_modal-output.d.ts +31 -0
- package/dist/_modal-target.d.ts +69 -0
- package/dist/_output-DBP9Op_d.mjs +120 -0
- package/dist/_output.d.ts +74 -0
- package/dist/_preflight-Bv6Ct4ss.mjs +149 -0
- package/dist/_preflight.d.ts +170 -0
- package/dist/_resource-commands.d.ts +54 -0
- package/dist/_run-code-deno-C0AtfHeH.mjs +268 -0
- package/dist/_run-code-deno.d.ts +130 -0
- package/dist/_server-common-CVXIeWrY.mjs +114 -0
- package/dist/_server-common.d.ts +75 -0
- package/dist/_slug-api-BnmTHtjd.mjs +68 -0
- package/dist/_slug-api.d.ts +61 -0
- package/dist/_stop-server.d.ts +17 -0
- package/dist/_studio-B5m4jBTD.mjs +256 -0
- package/dist/_studio-commands.d.ts +73 -0
- package/dist/_studio.d.ts +92 -0
- package/dist/_target-bundle.d.ts +141 -0
- package/dist/_target-drain.d.ts +44 -0
- package/dist/_target-entry.d.ts +81 -0
- package/dist/_target-output.d.ts +63 -0
- package/dist/_templates-BVMVsQh0.mjs +139 -0
- package/dist/_templates.d.ts +89 -0
- package/dist/_typecheck-gate-CcX2gLJZ.mjs +19 -0
- package/dist/_typecheck-gate.d.ts +11 -0
- package/dist/_ui-Coe0zwmm.mjs +102 -0
- package/dist/_ui.d.ts +90 -0
- package/dist/_utils-BVLdBvdT.mjs +186 -0
- package/dist/_utils.d.ts +126 -0
- package/dist/_vercel-output.d.ts +48 -0
- package/dist/_vercel-target.d.ts +169 -0
- package/dist/_vite-env-BiyJ0GQH.mjs +105 -0
- package/dist/_vite-env.d.ts +38 -0
- package/dist/_vitest-runner-CKI8_K1b.mjs +207 -0
- package/dist/_vitest-runner.d.ts +182 -0
- package/dist/_workflow-determinism-CLxFQ5ox.mjs +198 -0
- package/dist/_workflow-determinism.d.ts +118 -0
- package/dist/build-CKhanHVv.mjs +588 -0
- package/dist/build.d.ts +146 -0
- package/dist/cli-workflow.d.ts +17 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.mjs +1092 -195
- package/dist/client-bundler-DZ_Zoznn.mjs +241 -0
- package/dist/client-bundler.d.ts +38 -0
- package/dist/client-bundler.mjs +3 -0
- package/dist/console-Dxq26Adz.mjs +447 -0
- package/dist/console.d.ts +70 -0
- package/dist/delete-DwXCHzTl.mjs +55 -0
- package/dist/delete.d.ts +26 -0
- package/dist/deploy-CbA8Ibiu.mjs +97 -0
- package/dist/deploy.d.ts +25 -0
- package/dist/dev-BWBDbUEb.mjs +274 -0
- package/dist/dev.d.ts +34 -0
- package/dist/eval-Dl8o91yC.mjs +74 -0
- package/dist/eval.d.ts +46 -0
- package/dist/init-CidslZZz.mjs +609 -0
- package/dist/init.d.ts +101 -0
- package/dist/login-oJdBWu2B.mjs +166 -0
- package/dist/login.d.ts +54 -0
- package/dist/logs-CnPK-Prw.mjs +102 -0
- package/dist/logs.d.ts +65 -0
- package/dist/project-config.d.ts +23 -0
- package/dist/project-config.mjs +3 -0
- package/dist/scaffold/.env.example +51 -0
- package/dist/scaffold/CLAUDE.md +390 -0
- package/dist/scaffold/agent-guide/AGENT-API.md +223 -0
- package/dist/scaffold/agent-guide/HOSTING.md +139 -0
- package/dist/scaffold/agent-guide/PIPELINE-TUNING.md +232 -0
- package/dist/scaffold/agent-guide/PROVIDERS.md +140 -0
- package/dist/scaffold/agent-guide/TESTING-EVALS.md +158 -0
- package/dist/scaffold/agent-guide/TOOLS.md +627 -0
- package/dist/scaffold/agent-guide/UI.md +292 -0
- package/dist/scaffold/agent-guide/WORKFLOWS.md +803 -0
- package/dist/scaffold/package.json +38 -0
- package/dist/scaffold/pnpm-workspace.yaml +45 -0
- package/dist/scaffold/tsconfig.json +3 -0
- package/dist/scaffold/vitest.config.ts +8 -0
- package/dist/secret-DPdPEet2.mjs +300 -0
- package/dist/secret.d.ts +70 -0
- package/dist/start.d.ts +112 -0
- package/dist/start.mjs +183 -0
- package/dist/studio-COjK25Rl.mjs +208 -0
- package/dist/studio.d.ts +56 -0
- package/dist/templates/applicant-screening-agent/agent.eval.test.ts +258 -0
- package/dist/templates/applicant-screening-agent/agent.test.ts +987 -0
- package/dist/templates/applicant-screening-agent/agent.ts +66 -0
- package/dist/templates/applicant-screening-agent/client.tsx +154 -0
- package/dist/templates/applicant-screening-agent/crews.ts +432 -0
- package/dist/templates/applicant-screening-agent/leads.json +86 -0
- package/dist/templates/applicant-screening-agent/screening-lock.test.ts +77 -0
- package/dist/templates/applicant-screening-agent/screening-lock.ts +51 -0
- package/dist/templates/applicant-screening-agent/shared.ts +483 -0
- package/dist/templates/applicant-screening-agent/system-prompt.md +21 -0
- package/dist/templates/applicant-screening-agent/tools/candidate_details.ts +49 -0
- package/dist/templates/applicant-screening-agent/tools/proceed_to_emails.ts +127 -0
- package/dist/templates/applicant-screening-agent/tools/read_email.ts +50 -0
- package/dist/templates/applicant-screening-agent/tools/rescore_with_feedback.ts +140 -0
- package/dist/templates/applicant-screening-agent/tools/screen_candidates.ts +128 -0
- package/dist/templates/applicant-screening-agent/tools/screening_status.ts +51 -0
- package/dist/templates/call-audit-workflow/agent.eval.test.ts +492 -0
- package/dist/templates/call-audit-workflow/agent.test.ts +1032 -0
- package/dist/templates/call-audit-workflow/agent.ts +161 -0
- package/dist/templates/call-audit-workflow/client.tsx +236 -0
- package/dist/templates/call-audit-workflow/guards.test.ts +233 -0
- package/dist/templates/call-audit-workflow/workflows/audit.ts +391 -0
- package/dist/templates/call-audit-workflow/workflows/ingest.ts +279 -0
- package/dist/templates/call-audit-workflow/workflows/media.ts +729 -0
- package/dist/templates/call-audit-workflow/workflows/summarize.ts +201 -0
- package/dist/templates/call-audit-workflow/workflows/sync-api.ts +54 -0
- package/dist/templates/code-interpreter-agent/agent.eval.test.ts +195 -0
- package/dist/templates/code-interpreter-agent/agent.test.ts +91 -0
- package/dist/templates/code-interpreter-agent/agent.ts +9 -0
- package/dist/templates/code-interpreter-agent/system-prompt.md +18 -0
- package/dist/templates/coding-agent/agent.eval.test.ts +135 -0
- package/dist/templates/coding-agent/agent.test.ts +109 -0
- package/dist/templates/coding-agent/agent.ts +45 -0
- package/dist/templates/coding-agent/chat.ts +63 -0
- package/dist/templates/coding-agent/shared.ts +46 -0
- package/dist/templates/coding-agent/system-prompt.md +32 -0
- package/dist/templates/coding-agent/tools/bash.ts +6 -0
- package/dist/templates/coding-agent/tools/delete_file.ts +6 -0
- package/dist/templates/coding-agent/tools/edit_file.ts +6 -0
- package/dist/templates/coding-agent/tools/glob.ts +6 -0
- package/dist/templates/coding-agent/tools/grep.ts +6 -0
- package/dist/templates/coding-agent/tools/list_files.ts +6 -0
- package/dist/templates/coding-agent/tools/read_file.ts +6 -0
- package/dist/templates/coding-agent/tools/todo_write.ts +6 -0
- package/dist/templates/coding-agent/tools/write_file.ts +6 -0
- package/dist/templates/custom-pipeline-agent/agent.eval.test.ts +79 -0
- package/dist/templates/custom-pipeline-agent/agent.test.ts +79 -0
- package/dist/templates/custom-pipeline-agent/agent.ts +13 -0
- package/dist/templates/custom-pipeline-agent/modes.test.ts +162 -0
- package/dist/templates/custom-pipeline-agent/stages.test.ts +330 -0
- package/dist/templates/document-redline-workflow/agent.eval.test.ts +251 -0
- package/dist/templates/document-redline-workflow/agent.test.ts +552 -0
- package/dist/templates/document-redline-workflow/agent.ts +112 -0
- package/dist/templates/document-redline-workflow/client.tsx +224 -0
- package/dist/templates/document-redline-workflow/form.ts +74 -0
- package/dist/templates/document-redline-workflow/workflows/prompts.ts +68 -0
- package/dist/templates/document-redline-workflow/workflows/redline.ts +317 -0
- package/dist/templates/emergency-dispatch-agent/agent.eval.test.ts +372 -0
- package/dist/templates/emergency-dispatch-agent/agent.test.ts +576 -0
- package/dist/templates/emergency-dispatch-agent/agent.ts +63 -0
- package/dist/templates/emergency-dispatch-agent/client.tsx +453 -0
- package/dist/templates/emergency-dispatch-agent/events.ts +48 -0
- package/dist/templates/emergency-dispatch-agent/guardrails.ts +105 -0
- package/dist/templates/emergency-dispatch-agent/shared.ts +768 -0
- package/dist/templates/emergency-dispatch-agent/system-prompt.md +42 -0
- package/dist/templates/emergency-dispatch-agent/tools/incident_add_note.ts +28 -0
- package/dist/templates/emergency-dispatch-agent/tools/incident_create.ts +95 -0
- package/dist/templates/emergency-dispatch-agent/tools/incident_escalate.ts +96 -0
- package/dist/templates/emergency-dispatch-agent/tools/incident_get.ts +40 -0
- package/dist/templates/emergency-dispatch-agent/tools/incident_triage.ts +90 -0
- package/dist/templates/emergency-dispatch-agent/tools/incident_update_status.ts +75 -0
- package/dist/templates/emergency-dispatch-agent/tools/ops_dashboard.ts +72 -0
- package/dist/templates/emergency-dispatch-agent/tools/ops_protocols.ts +27 -0
- package/dist/templates/emergency-dispatch-agent/tools/ops_run_scenario.ts +154 -0
- package/dist/templates/emergency-dispatch-agent/tools/resources_dispatch.ts +112 -0
- package/dist/templates/emergency-dispatch-agent/tools/resources_get_available.ts +34 -0
- package/dist/templates/emergency-dispatch-agent/tools/resources_update_status.ts +63 -0
- package/dist/templates/entertainment-picks-agent/agent.eval.test.ts +281 -0
- package/dist/templates/entertainment-picks-agent/agent.test.ts +260 -0
- package/dist/templates/entertainment-picks-agent/agent.ts +14 -0
- package/dist/templates/entertainment-picks-agent/client.tsx +169 -0
- package/dist/templates/entertainment-picks-agent/shared.ts +50 -0
- package/dist/templates/entertainment-picks-agent/system-prompt.md +19 -0
- package/dist/templates/entertainment-picks-agent/tools/recommend.ts +79 -0
- package/dist/templates/entertainment-picks-agent/tools/revisit.ts +56 -0
- package/dist/templates/executive-inbox-agent/agent.eval.test.ts +296 -0
- package/dist/templates/executive-inbox-agent/agent.test.ts +682 -0
- package/dist/templates/executive-inbox-agent/agent.ts +51 -0
- package/dist/templates/executive-inbox-agent/calendar.test.ts +203 -0
- package/dist/templates/executive-inbox-agent/client.tsx +195 -0
- package/dist/templates/executive-inbox-agent/inbox.ts +233 -0
- package/dist/templates/executive-inbox-agent/meeting.ts +138 -0
- package/dist/templates/executive-inbox-agent/nodes.ts +148 -0
- package/dist/templates/executive-inbox-agent/prompts.ts +333 -0
- package/dist/templates/executive-inbox-agent/review.ts +425 -0
- package/dist/templates/executive-inbox-agent/shared.ts +486 -0
- package/dist/templates/executive-inbox-agent/system-prompt.md +15 -0
- package/dist/templates/executive-inbox-agent/tools/accept.ts +10 -0
- package/dist/templates/executive-inbox-agent/tools/ask_question.ts +30 -0
- package/dist/templates/executive-inbox-agent/tools/draft_reply.ts +67 -0
- package/dist/templates/executive-inbox-agent/tools/edit.ts +10 -0
- package/dist/templates/executive-inbox-agent/tools/ignore.ts +10 -0
- package/dist/templates/executive-inbox-agent/tools/inbox_status.ts +27 -0
- package/dist/templates/executive-inbox-agent/tools/meeting_assistant.ts +52 -0
- package/dist/templates/executive-inbox-agent/tools/new_email.ts +50 -0
- package/dist/templates/executive-inbox-agent/tools/open_email.ts +157 -0
- package/dist/templates/executive-inbox-agent/tools/respond.ts +10 -0
- package/dist/templates/executive-inbox-agent/tools/review_memory.ts +22 -0
- package/dist/templates/executive-inbox-agent/tools/send_calendar_invite.ts +68 -0
- package/dist/templates/executive-inbox-agent/tools/triage_inbox.ts +75 -0
- package/dist/templates/front-desk-agent/agent.eval.test.ts +177 -0
- package/dist/templates/front-desk-agent/agent.test.ts +155 -0
- package/dist/templates/front-desk-agent/agent.ts +22 -0
- package/dist/templates/front-desk-agent/shared.ts +239 -0
- package/dist/templates/front-desk-agent/system-prompt.md +13 -0
- package/dist/templates/front-desk-agent/tools/verify_account.ts +41 -0
- package/dist/templates/home-assistant-agent/agent.eval.test.ts +176 -0
- package/dist/templates/home-assistant-agent/agent.test.ts +512 -0
- package/dist/templates/home-assistant-agent/agent.ts +37 -0
- package/dist/templates/home-assistant-agent/client.tsx +176 -0
- package/dist/templates/home-assistant-agent/ring.tsx +55 -0
- package/dist/templates/home-assistant-agent/shared.ts +130 -0
- package/dist/templates/home-assistant-agent/system-prompt.md +43 -0
- package/dist/templates/home-assistant-agent/tools/cancel_reminders.ts +16 -0
- package/dist/templates/home-assistant-agent/tools/deep_research.ts +55 -0
- package/dist/templates/home-assistant-agent/tools/remind_me.ts +53 -0
- package/dist/templates/home-assistant-agent/tools/stop.ts +25 -0
- package/dist/templates/home-assistant-agent/use-speaker.ts +98 -0
- package/dist/templates/home-assistant-agent/workflows/remind.ts +25 -0
- package/dist/templates/home-assistant-agent/workflows/research-prompts.ts +41 -0
- package/dist/templates/home-assistant-agent/workflows/research.ts +110 -0
- package/dist/templates/home-assistant-agent/workflows/text.ts +30 -0
- package/dist/templates/hotel-reception-agent/agent.eval.test.ts +241 -0
- package/dist/templates/hotel-reception-agent/agent.test.ts +1121 -0
- package/dist/templates/hotel-reception-agent/agent.ts +66 -0
- package/dist/templates/hotel-reception-agent/booking.ts +159 -0
- package/dist/templates/hotel-reception-agent/card.ts +92 -0
- package/dist/templates/hotel-reception-agent/catalogs.ts +219 -0
- package/dist/templates/hotel-reception-agent/client.tsx +150 -0
- package/dist/templates/hotel-reception-agent/concierge.ts +104 -0
- package/dist/templates/hotel-reception-agent/desk-seams.test.ts +339 -0
- package/dist/templates/hotel-reception-agent/desk.ts +220 -0
- package/dist/templates/hotel-reception-agent/disputes.ts +214 -0
- package/dist/templates/hotel-reception-agent/events.ts +80 -0
- package/dist/templates/hotel-reception-agent/hotel.ts +412 -0
- package/dist/templates/hotel-reception-agent/policies.ts +209 -0
- package/dist/templates/hotel-reception-agent/records.ts +384 -0
- package/dist/templates/hotel-reception-agent/restaurant.ts +147 -0
- package/dist/templates/hotel-reception-agent/seed.ts +955 -0
- package/dist/templates/hotel-reception-agent/session.ts +50 -0
- package/dist/templates/hotel-reception-agent/shared.ts +353 -0
- package/dist/templates/hotel-reception-agent/system-prompt.md +76 -0
- package/dist/templates/hotel-reception-agent/tools/abandon_booking.ts +31 -0
- package/dist/templates/hotel-reception-agent/tools/add_to_waitlist.ts +42 -0
- package/dist/templates/hotel-reception-agent/tools/book_airport_car.ts +58 -0
- package/dist/templates/hotel-reception-agent/tools/book_business_center.ts +44 -0
- package/dist/templates/hotel-reception-agent/tools/book_spa_appointment.ts +39 -0
- package/dist/templates/hotel-reception-agent/tools/book_tour.ts +35 -0
- package/dist/templates/hotel-reception-agent/tools/cancel_restaurant_reservation.ts +26 -0
- package/dist/templates/hotel-reception-agent/tools/cancel_room_booking.ts +64 -0
- package/dist/templates/hotel-reception-agent/tools/check_restaurant_availability.ts +24 -0
- package/dist/templates/hotel-reception-agent/tools/check_room_availability.ts +40 -0
- package/dist/templates/hotel-reception-agent/tools/choose_room.ts +93 -0
- package/dist/templates/hotel-reception-agent/tools/confirm_booking.ts +154 -0
- package/dist/templates/hotel-reception-agent/tools/dispatch_emergency.ts +62 -0
- package/dist/templates/hotel-reception-agent/tools/dispute_charge.ts +91 -0
- package/dist/templates/hotel-reception-agent/tools/flag_late_arrival.ts +27 -0
- package/dist/templates/hotel-reception-agent/tools/lookup_booking.ts +49 -0
- package/dist/templates/hotel-reception-agent/tools/lookup_guest_history.ts +28 -0
- package/dist/templates/hotel-reception-agent/tools/lookup_invoice.ts +27 -0
- package/dist/templates/hotel-reception-agent/tools/lookup_policy.ts +20 -0
- package/dist/templates/hotel-reception-agent/tools/lookup_restaurant_reservation.ts +27 -0
- package/dist/templates/hotel-reception-agent/tools/modify_restaurant_reservation.ts +75 -0
- package/dist/templates/hotel-reception-agent/tools/order_flowers.ts +40 -0
- package/dist/templates/hotel-reception-agent/tools/record_card.ts +46 -0
- package/dist/templates/hotel-reception-agent/tools/record_followup.ts +51 -0
- package/dist/templates/hotel-reception-agent/tools/record_group_inquiry.ts +45 -0
- package/dist/templates/hotel-reception-agent/tools/record_guest_details.ts +71 -0
- package/dist/templates/hotel-reception-agent/tools/reinstate_booking.ts +65 -0
- package/dist/templates/hotel-reception-agent/tools/request_flight_reconfirmation.ts +55 -0
- package/dist/templates/hotel-reception-agent/tools/resend_confirmation.ts +40 -0
- package/dist/templates/hotel-reception-agent/tools/reserve_table.ts +87 -0
- package/dist/templates/hotel-reception-agent/tools/resolve_room_conflict.ts +49 -0
- package/dist/templates/hotel-reception-agent/tools/schedule_wakeup_call.ts +49 -0
- package/dist/templates/hotel-reception-agent/tools/set_do_not_disturb.ts +29 -0
- package/dist/templates/hotel-reception-agent/tools/set_extras.ts +51 -0
- package/dist/templates/hotel-reception-agent/tools/set_stay.ts +98 -0
- package/dist/templates/hotel-reception-agent/tools/start_booking_modification.ts +58 -0
- package/dist/templates/hotel-reception-agent/tools/start_room_booking.ts +50 -0
- package/dist/templates/hotel-reception-agent/tools/take_guest_message.ts +72 -0
- package/dist/templates/hotel-reception-agent/tools/transfer_call.ts +48 -0
- package/dist/templates/hotel-reception-agent/tools/update_card.ts +46 -0
- package/dist/templates/hotel-reception-agent/tools/verify_booking.ts +96 -0
- package/dist/templates/link-digest-workflow/agent.eval.test.ts +231 -0
- package/dist/templates/link-digest-workflow/agent.test.ts +646 -0
- package/dist/templates/link-digest-workflow/agent.ts +100 -0
- package/dist/templates/link-digest-workflow/api-client.ts +144 -0
- package/dist/templates/link-digest-workflow/client.tsx +231 -0
- package/dist/templates/link-digest-workflow/workflows/digest.ts +334 -0
- package/dist/templates/medication-safety-agent/agent.eval.test.ts +182 -0
- package/dist/templates/medication-safety-agent/agent.test.ts +329 -0
- package/dist/templates/medication-safety-agent/agent.ts +62 -0
- package/dist/templates/medication-safety-agent/fda.test.ts +129 -0
- package/dist/templates/medication-safety-agent/fda.ts +166 -0
- package/dist/templates/medication-safety-agent/system-prompt.md +26 -0
- package/dist/templates/medication-safety-agent/tools/check_drug_interaction.ts +70 -0
- package/dist/templates/medication-safety-agent/tools/medication_lookup.ts +46 -0
- package/dist/templates/meeting-recap-agent/agent.eval.test.ts +459 -0
- package/dist/templates/meeting-recap-agent/agent.test.ts +1408 -0
- package/dist/templates/meeting-recap-agent/agent.ts +104 -0
- package/dist/templates/meeting-recap-agent/shared.ts +44 -0
- package/dist/templates/meeting-recap-agent/tools/cancel_recap.ts +23 -0
- package/dist/templates/meeting-recap-agent/tools/keep_transcript.ts +31 -0
- package/dist/templates/meeting-recap-agent/tools/recap_progress.ts +24 -0
- package/dist/templates/meeting-recap-agent/tools/recap_status.ts +45 -0
- package/dist/templates/meeting-recap-agent/tools/request_recap.ts +44 -0
- package/dist/templates/meeting-recap-agent/workflows/recap.ts +838 -0
- package/dist/templates/meeting-recap-agent/workflows/tokens.ts +47 -0
- package/dist/templates/pizza-ordering-agent/agent.eval.test.ts +228 -0
- package/dist/templates/pizza-ordering-agent/agent.test.ts +299 -0
- package/dist/templates/pizza-ordering-agent/agent.ts +24 -0
- package/dist/templates/pizza-ordering-agent/client.tsx +104 -0
- package/dist/templates/pizza-ordering-agent/shared.ts +225 -0
- package/dist/templates/pizza-ordering-agent/system-prompt.md +23 -0
- package/dist/templates/pizza-ordering-agent/tools/add_pizza.ts +27 -0
- package/dist/templates/pizza-ordering-agent/tools/place_order.ts +26 -0
- package/dist/templates/pizza-ordering-agent/tools/remove_pizza.ts +18 -0
- package/dist/templates/pizza-ordering-agent/tools/set_customer_name.ts +13 -0
- package/dist/templates/pizza-ordering-agent/tools/update_pizza.ts +28 -0
- package/dist/templates/pizza-ordering-agent/tools/view_order.ts +21 -0
- package/dist/templates/podcast-digest-workflow/agent.eval.test.ts +421 -0
- package/dist/templates/podcast-digest-workflow/agent.test.ts +1225 -0
- package/dist/templates/podcast-digest-workflow/agent.ts +143 -0
- package/dist/templates/podcast-digest-workflow/client.tsx +259 -0
- package/dist/templates/podcast-digest-workflow/workflows/digest.ts +499 -0
- package/dist/templates/podcast-digest-workflow/workflows/feeds.ts +575 -0
- package/dist/templates/podcast-digest-workflow/workflows/slack.ts +153 -0
- package/dist/templates/push-to-talk-agent/agent.eval.test.ts +78 -0
- package/dist/templates/push-to-talk-agent/agent.test.ts +63 -0
- package/dist/templates/push-to-talk-agent/agent.ts +22 -0
- package/dist/templates/push-to-talk-agent/client.tsx +124 -0
- package/dist/templates/push-to-talk-agent/shared.ts +28 -0
- package/dist/templates/push-to-talk-agent/system-prompt.md +11 -0
- package/dist/templates/push-to-talk-agent/tools/list_notes.ts +15 -0
- package/dist/templates/push-to-talk-agent/tools/save_note.ts +26 -0
- package/dist/templates/quickstart-agent/agent.eval.test.ts +148 -0
- package/dist/templates/quickstart-agent/agent.test.ts +96 -0
- package/dist/templates/quickstart-agent/agent.ts +25 -0
- package/dist/templates/quickstart-agent/system-prompt.md +8 -0
- package/dist/templates/quickstart-agent/tools/get_weather.ts +59 -0
- package/dist/templates/research-handoff-agent/agent.eval.test.ts +348 -0
- package/dist/templates/research-handoff-agent/agent.test.ts +818 -0
- package/dist/templates/research-handoff-agent/agent.ts +118 -0
- package/dist/templates/research-handoff-agent/shared.ts +41 -0
- package/dist/templates/research-handoff-agent/tools/file_it_now.ts +32 -0
- package/dist/templates/research-handoff-agent/tools/request_research.ts +33 -0
- package/dist/templates/research-handoff-agent/tools/research_progress.ts +23 -0
- package/dist/templates/research-handoff-agent/tools/research_status.ts +73 -0
- package/dist/templates/research-handoff-agent/workflows/filing.ts +164 -0
- package/dist/templates/research-handoff-agent/workflows/prompts.ts +46 -0
- package/dist/templates/research-handoff-agent/workflows/research.ts +100 -0
- package/dist/templates/research-handoff-agent/workflows/review.ts +43 -0
- package/dist/templates/research-planner-agent/agent.eval.test.ts +241 -0
- package/dist/templates/research-planner-agent/agent.test.ts +640 -0
- package/dist/templates/research-planner-agent/agent.ts +26 -0
- package/dist/templates/research-planner-agent/client.tsx +120 -0
- package/dist/templates/research-planner-agent/procedure.ts +287 -0
- package/dist/templates/research-planner-agent/prompts.ts +153 -0
- package/dist/templates/research-planner-agent/shared.ts +356 -0
- package/dist/templates/research-planner-agent/system-prompt.md +18 -0
- package/dist/templates/research-planner-agent/tools/plan_status.ts +41 -0
- package/dist/templates/research-planner-agent/tools/revise_plan.ts +71 -0
- package/dist/templates/research-planner-agent/tools/start_plan.ts +62 -0
- package/dist/templates/research-planner-agent/tools/work_next_step.ts +177 -0
- package/dist/templates/retail-orders-agent/address.ts +109 -0
- package/dist/templates/retail-orders-agent/agent.eval.test.ts +305 -0
- package/dist/templates/retail-orders-agent/agent.test.ts +1260 -0
- package/dist/templates/retail-orders-agent/agent.ts +103 -0
- package/dist/templates/retail-orders-agent/authenticate.ts +34 -0
- package/dist/templates/retail-orders-agent/cancel.ts +114 -0
- package/dist/templates/retail-orders-agent/client.tsx +579 -0
- package/dist/templates/retail-orders-agent/keyterms.ts +154 -0
- package/dist/templates/retail-orders-agent/payment.ts +103 -0
- package/dist/templates/retail-orders-agent/pending.test.ts +204 -0
- package/dist/templates/retail-orders-agent/pending.ts +137 -0
- package/dist/templates/retail-orders-agent/refund.ts +19 -0
- package/dist/templates/retail-orders-agent/registry.test.ts +446 -0
- package/dist/templates/retail-orders-agent/resolve.test.ts +100 -0
- package/dist/templates/retail-orders-agent/resolve.ts +114 -0
- package/dist/templates/retail-orders-agent/returns.ts +101 -0
- package/dist/templates/retail-orders-agent/seed.json +4260 -0
- package/dist/templates/retail-orders-agent/seed.test.ts +233 -0
- package/dist/templates/retail-orders-agent/shared.test.ts +240 -0
- package/dist/templates/retail-orders-agent/shared.ts +547 -0
- package/dist/templates/retail-orders-agent/store.test.ts +331 -0
- package/dist/templates/retail-orders-agent/store.ts +485 -0
- package/dist/templates/retail-orders-agent/swap.test.ts +189 -0
- package/dist/templates/retail-orders-agent/swap.ts +358 -0
- package/dist/templates/retail-orders-agent/system-prompt.md +152 -0
- package/dist/templates/retail-orders-agent/tools/cancel_change.ts +33 -0
- package/dist/templates/retail-orders-agent/tools/cancel_pending_order.ts +31 -0
- package/dist/templates/retail-orders-agent/tools/confirm_change.ts +42 -0
- package/dist/templates/retail-orders-agent/tools/exchange_delivered_order_items.ts +47 -0
- package/dist/templates/retail-orders-agent/tools/find_user_id_by_email.ts +31 -0
- package/dist/templates/retail-orders-agent/tools/find_user_id_by_name_zip.ts +36 -0
- package/dist/templates/retail-orders-agent/tools/get_item_details.ts +27 -0
- package/dist/templates/retail-orders-agent/tools/get_order_details.ts +37 -0
- package/dist/templates/retail-orders-agent/tools/get_product_details.ts +30 -0
- package/dist/templates/retail-orders-agent/tools/get_user_details.ts +37 -0
- package/dist/templates/retail-orders-agent/tools/list_all_product_types.ts +22 -0
- package/dist/templates/retail-orders-agent/tools/modify_pending_order_address.ts +27 -0
- package/dist/templates/retail-orders-agent/tools/modify_pending_order_items.ts +48 -0
- package/dist/templates/retail-orders-agent/tools/modify_pending_order_payment.ts +32 -0
- package/dist/templates/retail-orders-agent/tools/modify_user_address.ts +26 -0
- package/dist/templates/retail-orders-agent/tools/return_delivered_order_items.ts +37 -0
- package/dist/templates/retail-orders-agent/tools/transfer_to_human_agents.ts +28 -0
- package/dist/templates/roadside-assistance-agent/agent.eval.test.ts +283 -0
- package/dist/templates/roadside-assistance-agent/agent.test.ts +650 -0
- package/dist/templates/roadside-assistance-agent/agent.ts +89 -0
- package/dist/templates/roadside-assistance-agent/call.ts +232 -0
- package/dist/templates/roadside-assistance-agent/events.ts +92 -0
- package/dist/templates/roadside-assistance-agent/shared.ts +346 -0
- package/dist/templates/roadside-assistance-agent/system-prompt.md +37 -0
- package/dist/templates/roadside-assistance-agent/tools/acknowledge_disclosure.ts +61 -0
- package/dist/templates/roadside-assistance-agent/tools/dispatch_truck.ts +149 -0
- package/dist/templates/roadside-assistance-agent/tools/job_status.ts +38 -0
- package/dist/templates/roadside-assistance-agent/tools/lookup_coverage.ts +83 -0
- package/dist/templates/roadside-assistance-agent/tools/report_location.ts +79 -0
- package/dist/templates/roadside-assistance-agent/tools/service_disclosure.ts +51 -0
- package/dist/templates/roadside-assistance-agent/yard.test.ts +162 -0
- package/dist/templates/roadside-assistance-agent/yard.ts +183 -0
- package/dist/templates/spoken-summary-workflow/agent.eval.test.ts +354 -0
- package/dist/templates/spoken-summary-workflow/agent.test.ts +493 -0
- package/dist/templates/spoken-summary-workflow/agent.ts +164 -0
- package/dist/templates/spoken-summary-workflow/client.tsx +220 -0
- package/dist/templates/spoken-summary-workflow/workflows/summarize.ts +260 -0
- package/dist/templates/spoken-summary-workflow/workflows/transcribe.ts +137 -0
- package/dist/templates/tabletop-rpg-agent/agent.eval.test.ts +314 -0
- package/dist/templates/tabletop-rpg-agent/agent.test.ts +1000 -0
- package/dist/templates/tabletop-rpg-agent/agent.ts +58 -0
- package/dist/templates/tabletop-rpg-agent/client.tsx +814 -0
- package/dist/templates/tabletop-rpg-agent/shared.ts +1028 -0
- package/dist/templates/tabletop-rpg-agent/system-prompt.md +116 -0
- package/dist/templates/tabletop-rpg-agent/tools/action_roll.ts +119 -0
- package/dist/templates/tabletop-rpg-agent/tools/burn_momentum.ts +110 -0
- package/dist/templates/tabletop-rpg-agent/tools/check_state.ts +37 -0
- package/dist/templates/tabletop-rpg-agent/tools/oracle.ts +255 -0
- package/dist/templates/tabletop-rpg-agent/tools/setup_character.ts +228 -0
- package/dist/templates/tabletop-rpg-agent/tools/update_state.ts +194 -0
- package/dist/templates/technical-support-agent/agent.eval.test.ts +260 -0
- package/dist/templates/technical-support-agent/agent.test.ts +424 -0
- package/dist/templates/technical-support-agent/agent.ts +39 -0
- package/dist/templates/technical-support-agent/client.tsx +132 -0
- package/dist/templates/technical-support-agent/knowledge.json +65 -0
- package/dist/templates/technical-support-agent/knowledge.ts +165 -0
- package/dist/templates/technical-support-agent/nodes.ts +143 -0
- package/dist/templates/technical-support-agent/procedure.ts +453 -0
- package/dist/templates/technical-support-agent/prompts.ts +102 -0
- package/dist/templates/technical-support-agent/shared.ts +128 -0
- package/dist/templates/technical-support-agent/system-prompt.md +18 -0
- package/dist/templates/technical-support-agent/tools/answer_question.ts +134 -0
- package/dist/templates/technical-support-agent/tools/list_topics.ts +23 -0
- package/dist/templates/technical-support-agent/tools/log_ticket.ts +30 -0
- package/dist/templates/text-adventure-agent/agent.eval.test.ts +222 -0
- package/dist/templates/text-adventure-agent/agent.test.ts +429 -0
- package/dist/templates/text-adventure-agent/agent.ts +76 -0
- package/dist/templates/text-adventure-agent/client.tsx +359 -0
- package/dist/templates/text-adventure-agent/shared.ts +210 -0
- package/dist/templates/text-adventure-agent/system-prompt.md +50 -0
- package/dist/templates/text-adventure-agent/tools/game_state_drop.ts +29 -0
- package/dist/templates/text-adventure-agent/tools/game_state_flag.ts +13 -0
- package/dist/templates/text-adventure-agent/tools/game_state_get.ts +17 -0
- package/dist/templates/text-adventure-agent/tools/game_state_move.ts +15 -0
- package/dist/templates/text-adventure-agent/tools/game_state_restart.ts +13 -0
- package/dist/templates/text-adventure-agent/tools/game_state_score.ts +19 -0
- package/dist/templates/text-adventure-agent/tools/game_state_take.ts +13 -0
- package/dist/templates/topic-briefing-agent/agent.eval.test.ts +202 -0
- package/dist/templates/topic-briefing-agent/agent.test.ts +651 -0
- package/dist/templates/topic-briefing-agent/agent.ts +45 -0
- package/dist/templates/topic-briefing-agent/shared.ts +392 -0
- package/dist/templates/topic-briefing-agent/slack.ts +108 -0
- package/dist/templates/topic-briefing-agent/system-prompt.md +54 -0
- package/dist/templates/topic-briefing-agent/tools/briefing_so_far.ts +43 -0
- package/dist/templates/topic-briefing-agent/tools/research_topic.ts +80 -0
- package/dist/templates/topic-briefing-agent/tools/send_briefing.ts +115 -0
- package/dist/templates/topic-briefing-agent/tools/verify_claim.ts +123 -0
- package/dist/templates/transcription-workflow/agent.eval.test.ts +237 -0
- package/dist/templates/transcription-workflow/agent.test.ts +2033 -0
- package/dist/templates/transcription-workflow/agent.ts +188 -0
- package/dist/templates/transcription-workflow/client.tsx +511 -0
- package/dist/templates/transcription-workflow/recover.test.ts +219 -0
- package/dist/templates/transcription-workflow/recover.ts +154 -0
- package/dist/templates/transcription-workflow/run-panel.tsx +212 -0
- package/dist/templates/transcription-workflow/total-latency.tsx +170 -0
- package/dist/templates/transcription-workflow/workflows/batch.ts +189 -0
- package/dist/templates/transcription-workflow/workflows/downsample.ts +273 -0
- package/dist/templates/transcription-workflow/workflows/normalize.ts +385 -0
- package/dist/templates/transcription-workflow/workflows/stitch.ts +122 -0
- package/dist/templates/transcription-workflow/workflows/stream.ts +690 -0
- package/dist/templates/transcription-workflow/workflows/sync-api.ts +81 -0
- package/dist/templates/transcription-workflow/workflows/transcribe.ts +479 -0
- package/dist/templates/transcription-workflow/workflows/wav.ts +250 -0
- package/dist/templates/travel-concierge-agent/agent.eval.test.ts +300 -0
- package/dist/templates/travel-concierge-agent/agent.test.ts +601 -0
- package/dist/templates/travel-concierge-agent/agent.ts +62 -0
- package/dist/templates/travel-concierge-agent/call-events.ts +80 -0
- package/dist/templates/travel-concierge-agent/client.tsx +146 -0
- package/dist/templates/travel-concierge-agent/routing.ts +170 -0
- package/dist/templates/travel-concierge-agent/shared.ts +862 -0
- package/dist/templates/travel-concierge-agent/system-prompt.md +30 -0
- package/dist/templates/travel-concierge-agent/tools/book_car_rental.ts +21 -0
- package/dist/templates/travel-concierge-agent/tools/book_excursion.ts +19 -0
- package/dist/templates/travel-concierge-agent/tools/book_hotel.ts +21 -0
- package/dist/templates/travel-concierge-agent/tools/cancel_action.ts +9 -0
- package/dist/templates/travel-concierge-agent/tools/cancel_ticket.ts +21 -0
- package/dist/templates/travel-concierge-agent/tools/complete_or_escalate.ts +9 -0
- package/dist/templates/travel-concierge-agent/tools/confirm_action.ts +9 -0
- package/dist/templates/travel-concierge-agent/tools/lookup_booking.ts +36 -0
- package/dist/templates/travel-concierge-agent/tools/search_car_rentals.ts +36 -0
- package/dist/templates/travel-concierge-agent/tools/search_excursions.ts +40 -0
- package/dist/templates/travel-concierge-agent/tools/search_flights.ts +58 -0
- package/dist/templates/travel-concierge-agent/tools/search_hotels.ts +39 -0
- package/dist/templates/travel-concierge-agent/tools/to_car_rental_assistant.ts +11 -0
- package/dist/templates/travel-concierge-agent/tools/to_excursion_assistant.ts +11 -0
- package/dist/templates/travel-concierge-agent/tools/to_flight_assistant.ts +11 -0
- package/dist/templates/travel-concierge-agent/tools/to_hotel_assistant.ts +11 -0
- package/dist/templates/travel-concierge-agent/tools/update_ticket.ts +23 -0
- package/dist/templates/web-research-agent/agent.eval.test.ts +144 -0
- package/dist/templates/web-research-agent/agent.test.ts +182 -0
- package/dist/templates/web-research-agent/agent.ts +128 -0
- package/dist/templates/web-research-agent/system-prompt.md +33 -0
- package/dist/templates/word-game-agent/agent.eval.test.ts +222 -0
- package/dist/templates/word-game-agent/agent.test.ts +490 -0
- package/dist/templates/word-game-agent/agent.ts +55 -0
- package/dist/templates/word-game-agent/client.tsx +211 -0
- package/dist/templates/word-game-agent/game.ts +133 -0
- package/dist/templates/word-game-agent/guess.ts +63 -0
- package/dist/templates/word-game-agent/player.ts +67 -0
- package/dist/templates/word-game-agent/shared.ts +249 -0
- package/dist/templates/word-game-agent/system-prompt.md +15 -0
- package/dist/templates/word-game-agent/tools/final_score.ts +37 -0
- package/dist/templates/word-game-agent/tools/relay_description.ts +137 -0
- package/dist/templates/word-game-agent/tools/repeat_word.ts +19 -0
- package/dist/templates/word-game-agent/tools/skip_word.ts +31 -0
- package/dist/templates/word-game-agent/tools/start_game.ts +52 -0
- package/dist/templates/word-game-agent/words.ts +278 -0
- package/dist/test-XufelYGW.mjs +104 -0
- package/dist/test.d.ts +81 -0
- package/dist/typecheck.d.ts +44 -0
- package/dist/typecheck.mjs +185 -0
- package/dist/worker-bundler.d.ts +37 -0
- package/dist/worker-bundler.mjs +156 -0
- package/dist/workflow-CDUlTD5B.mjs +239 -0
- package/dist/workflow.d.ts +76 -0
- package/package.json +74 -28
- package/dist/_api-client-H4MFOr8j.mjs +0 -35
- package/dist/_bundler-DQtFVeww.mjs +0 -125
- package/dist/_discover-DzsMlg3G.mjs +0 -218
- package/dist/_init-CbMs9S2O.mjs +0 -56
- package/dist/_templates-BDkbj3TM.mjs +0 -72
- package/dist/_ui-DWGXImbO.mjs +0 -30
- package/dist/delete-CalIL6Pg.mjs +0 -34
- package/dist/deploy-CLs8gLHV.mjs +0 -53
- package/dist/dev-DEZKrw8v.mjs +0 -18
- package/dist/init-CNuntiij.mjs +0 -114
- package/dist/secret-xmLQ96Yz.mjs +0 -46
- package/dist/test-yqHGZPF3.mjs +0 -44
|
@@ -0,0 +1,1121 @@
|
|
|
1
|
+
/** The def a DEPLOYED agent runs: authored, plus what `tools/` and the prompt add. */
|
|
2
|
+
import agentDef from "virtual:aai/agent";
|
|
3
|
+
import type { SessionEvent, ToolContext } from "@alexkroman1/aai";
|
|
4
|
+
import { isToolFailure } from "@alexkroman1/aai";
|
|
5
|
+
import {
|
|
6
|
+
createToolContext,
|
|
7
|
+
expectDialogOk,
|
|
8
|
+
expectDialogRefused,
|
|
9
|
+
expectToolOk,
|
|
10
|
+
runTool,
|
|
11
|
+
toolInputIssues,
|
|
12
|
+
toolRunner,
|
|
13
|
+
} from "@alexkroman1/aai-runtime/testing";
|
|
14
|
+
import { describe, expect, test } from "vitest";
|
|
15
|
+
import { luhnOk, validateCard } from "./card.ts";
|
|
16
|
+
import { deskFlow } from "./desk.ts";
|
|
17
|
+
import { DISPUTE_POLICIES, resolveDisputeOutcome } from "./disputes.ts";
|
|
18
|
+
import { listRoomOptions } from "./hotel.ts";
|
|
19
|
+
import { POLICIES } from "./policies.ts";
|
|
20
|
+
import {
|
|
21
|
+
addDays,
|
|
22
|
+
computeInvoice,
|
|
23
|
+
daysBetween,
|
|
24
|
+
isIsoDate,
|
|
25
|
+
mintCode,
|
|
26
|
+
PRICING,
|
|
27
|
+
speakCode,
|
|
28
|
+
speakUsd,
|
|
29
|
+
spokenDate,
|
|
30
|
+
spokenTime,
|
|
31
|
+
TODAY,
|
|
32
|
+
} from "./records.ts";
|
|
33
|
+
import { hotelSlot } from "./session.ts";
|
|
34
|
+
import { deskView } from "./shared.ts";
|
|
35
|
+
import bookAirportCar from "./tools/book_airport_car.ts";
|
|
36
|
+
import bookBusinessCenter from "./tools/book_business_center.ts";
|
|
37
|
+
import bookSpaAppointment from "./tools/book_spa_appointment.ts";
|
|
38
|
+
import bookTour from "./tools/book_tour.ts";
|
|
39
|
+
import cancelRoomBooking from "./tools/cancel_room_booking.ts";
|
|
40
|
+
import checkRestaurantAvailability from "./tools/check_restaurant_availability.ts";
|
|
41
|
+
import checkRoomAvailability from "./tools/check_room_availability.ts";
|
|
42
|
+
import dispatchEmergency from "./tools/dispatch_emergency.ts";
|
|
43
|
+
import disputeCharge from "./tools/dispute_charge.ts";
|
|
44
|
+
import lookupBooking from "./tools/lookup_booking.ts";
|
|
45
|
+
import lookupInvoice from "./tools/lookup_invoice.ts";
|
|
46
|
+
import lookupPolicy from "./tools/lookup_policy.ts";
|
|
47
|
+
import modifyRestaurantReservation from "./tools/modify_restaurant_reservation.ts";
|
|
48
|
+
import recordFollowup from "./tools/record_followup.ts";
|
|
49
|
+
import reinstateBooking from "./tools/reinstate_booking.ts";
|
|
50
|
+
import resendConfirmation from "./tools/resend_confirmation.ts";
|
|
51
|
+
import reserveTable from "./tools/reserve_table.ts";
|
|
52
|
+
import resolveRoomConflict from "./tools/resolve_room_conflict.ts";
|
|
53
|
+
import scheduleWakeupCall from "./tools/schedule_wakeup_call.ts";
|
|
54
|
+
import takeGuestMessage from "./tools/take_guest_message.ts";
|
|
55
|
+
import transferCall from "./tools/transfer_call.ts";
|
|
56
|
+
import updateCard from "./tools/update_card.ts";
|
|
57
|
+
import verifyBooking from "./tools/verify_booking.ts";
|
|
58
|
+
|
|
59
|
+
// ─── Harness ─────────────────────────────────────────────────────────────────
|
|
60
|
+
|
|
61
|
+
/** A tool by the name the model calls it by, bound to this agent. */
|
|
62
|
+
const run = toolRunner(agentDef);
|
|
63
|
+
|
|
64
|
+
/** What the runtime offers the desk dialog when the caller says something. */
|
|
65
|
+
const HEARD_SOMETHING: SessionEvent = {
|
|
66
|
+
type: "userTranscript.committed",
|
|
67
|
+
text: "yes, that's right",
|
|
68
|
+
meta: { id: "evt_1", at: 0 },
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/** And when they hang up. */
|
|
72
|
+
const CALLER_GONE: SessionEvent = { type: "session.timedOut", meta: { id: "evt_2", at: 0 } };
|
|
73
|
+
|
|
74
|
+
/** Where the call is, without going through a tool. */
|
|
75
|
+
const at = (ctx: ToolContext) => deskFlow.position(ctx).state;
|
|
76
|
+
|
|
77
|
+
/** The caller answers — their next committed turn is what discharges an owed read-back. */
|
|
78
|
+
const callerAnswers = (ctx: ToolContext) => deskFlow.receive(ctx, HEARD_SOMETHING).state;
|
|
79
|
+
|
|
80
|
+
/** A context whose history holds `n` caller turns — what the idempotency guards read. */
|
|
81
|
+
const withCallerTurns = (n: number) =>
|
|
82
|
+
createToolContext({
|
|
83
|
+
messages: Array.from({ length: n }, (_, i) => ({
|
|
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
|
+
});
|
|
151
|
+
|
|
152
|
+
test("dates: TODAY is the simulation pin, and the helpers agree with the calendar", () => {
|
|
153
|
+
expect(TODAY).toBe("2026-06-08");
|
|
154
|
+
expect(spokenDate(TODAY)).toBe("Monday, June 8");
|
|
155
|
+
expect(addDays(TODAY, 25)).toBe("2026-07-03");
|
|
156
|
+
expect(daysBetween("2026-07-14", "2026-07-17")).toBe(3);
|
|
157
|
+
expect(spokenTime("19:30")).toBe("7:30 PM");
|
|
158
|
+
expect(spokenTime("21:00")).toBe("9 PM");
|
|
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
|
+
});
|
|
184
|
+
|
|
185
|
+
test("a minted code carries no character a caller could mishear as another", () => {
|
|
186
|
+
for (let i = 0; i < 50; i++)
|
|
187
|
+
expect(mintCode("HTL")).toMatch(/^HTL-[ABCDEFGHJKMNPQRSTUVWXYZ2-9]{4}$/);
|
|
188
|
+
expect(mintCode("X", new Set())).not.toBe(mintCode("X", new Set()));
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
test("the card check is Luhn, and every refusal names one field", () => {
|
|
192
|
+
expect(luhnOk("4532000000014471")).toBe(true);
|
|
193
|
+
expect(luhnOk("4532000000014472")).toBe(false);
|
|
194
|
+
const ok = validateCard(A_CARD);
|
|
195
|
+
expect(ok).toMatchObject({ last4: "4471", issuer: "Visa", expiry: "12/29" });
|
|
196
|
+
expect(validateCard({ ...A_CARD, cardNumber: "4532 0000 0001 4472" })).toMatchObject({
|
|
197
|
+
error: expect.stringContaining("one digit is likely off"),
|
|
198
|
+
});
|
|
199
|
+
expect(validateCard({ ...A_CARD, expiryYear: 2025 })).toMatchObject({
|
|
200
|
+
error: expect.stringContaining("expired"),
|
|
201
|
+
});
|
|
202
|
+
expect(validateCard({ ...A_CARD, securityCode: "12" })).toMatchObject({
|
|
203
|
+
error: expect.stringContaining("3 or 4 digits"),
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
// ─── 2. The seed's scenarios are the spec's ──────────────────────────────────
|
|
209
|
+
|
|
210
|
+
describe("the seeded hotel", () => {
|
|
211
|
+
test("tonight, the only free room is the garden queen the seed keeps for Robert Klein", () => {
|
|
212
|
+
const ctx = createToolContext();
|
|
213
|
+
const tonight = listRoomOptions(hotelSlot.get(ctx), {
|
|
214
|
+
checkIn: TODAY,
|
|
215
|
+
checkOut: addDays(TODAY, 1),
|
|
216
|
+
guests: 2,
|
|
217
|
+
});
|
|
218
|
+
expect(tonight).toEqual([{ type: "queen_2beds", view: "garden", nightlyRate: 22_000 }]);
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
test("Friday July 3 is sold out, and the desk says so rather than inventing a room", async () => {
|
|
222
|
+
const empty = expectToolOk(
|
|
223
|
+
await runTool(checkRoomAvailability, {
|
|
224
|
+
checkIn: "2026-07-03",
|
|
225
|
+
checkOut: "2026-07-04",
|
|
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
|
+
});
|
|
241
|
+
|
|
242
|
+
test("the projection counts the house from the same records the tools read", () => {
|
|
243
|
+
const view = deskView(hotelSlot.get(createToolContext()));
|
|
244
|
+
expect(view).toMatchObject({
|
|
245
|
+
verified: null,
|
|
246
|
+
draft: null,
|
|
247
|
+
ledger: [],
|
|
248
|
+
inHouse: 13,
|
|
249
|
+
arrivingToday: 5,
|
|
250
|
+
});
|
|
251
|
+
// The pre-first-tool-call frame the client renders is the same function.
|
|
252
|
+
expect(hotelSlot.projected()).toEqual(view);
|
|
253
|
+
});
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
// ─── 3. Verification is the tools' job ───────────────────────────────────────
|
|
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
|
+
});
|
|
272
|
+
|
|
273
|
+
test("last name plus code, or last name plus the card's last four — and nothing else", async () => {
|
|
274
|
+
const byCode = createToolContext();
|
|
275
|
+
expect((await verify(byCode, "Smith", "h t l dash a b 1 2")).code).toBe("HTL-AB12");
|
|
276
|
+
expect(hotelSlot.get(byCode).verifiedCode).toBe("HTL-AB12");
|
|
277
|
+
|
|
278
|
+
const byCard = createToolContext();
|
|
279
|
+
expectToolOk(await run("verify_booking", { lastName: "smith", cardLast4: "4242" }, byCard));
|
|
280
|
+
expect(hotelSlot.get(byCard).verifiedCode).toBe("HTL-AB12");
|
|
281
|
+
|
|
282
|
+
const nothing = await run("verify_booking", { lastName: "Smith" });
|
|
283
|
+
expect(isToolFailure(nothing) && nothing.error).toMatch(/PLUS/);
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
test("three strikes, and the refusal routes to a verification_help followup", async () => {
|
|
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
|
+
});
|
|
303
|
+
|
|
304
|
+
test("a cancelled booking does not verify, and the refusal names the one flow that takes it", async () => {
|
|
305
|
+
const refused = await run("verify_booking", {
|
|
306
|
+
lastName: "Wagner",
|
|
307
|
+
confirmationCode: "HTL-FW77",
|
|
308
|
+
});
|
|
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
|
+
|
|
330
|
+
test("each recording tool lands the flow on the step the draft says is next", async () => {
|
|
331
|
+
const ctx = createToolContext();
|
|
332
|
+
expectDialogOk(await run("start_room_booking", ctx));
|
|
333
|
+
expect(at(ctx)).toBe("booking.stay");
|
|
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");
|
|
336
|
+
|
|
337
|
+
const stay = expectDialogOk<{ options: string; next: string }>(
|
|
338
|
+
await run("set_stay", { checkIn: "2026-07-14", checkOut: "2026-07-17", guests: 2 }, ctx),
|
|
339
|
+
);
|
|
340
|
+
expect(stay.state).toBe("booking.room");
|
|
341
|
+
expect(stay.result.options).toContain("garden view");
|
|
342
|
+
|
|
343
|
+
const room = expectDialogOk<{ extrasToOffer: string }>(
|
|
344
|
+
await run("choose_room", { roomType: "queen_2beds", view: "garden" }, ctx),
|
|
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");
|
|
351
|
+
|
|
352
|
+
const extras = expectDialogOk<{ total: string }>(
|
|
353
|
+
await run(
|
|
354
|
+
"set_extras",
|
|
355
|
+
{ breakfast: false, valet: false, lateCheckout: false, pets: false },
|
|
356
|
+
ctx,
|
|
357
|
+
),
|
|
358
|
+
);
|
|
359
|
+
expect(extras.state).toBe("booking.details");
|
|
360
|
+
expect(extras.result.total).toBe("739 dollars and 20 cents including tax");
|
|
361
|
+
|
|
362
|
+
// A partial detail is stored the moment it is given, and the flow stays put.
|
|
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" },
|
|
371
|
+
ctx,
|
|
372
|
+
),
|
|
373
|
+
);
|
|
374
|
+
expect(contact.state).toBe("booking.card");
|
|
375
|
+
expect(hotelSlot.get(ctx).draft).toMatchObject({
|
|
376
|
+
email: "maria.whitfield@gmail.com",
|
|
377
|
+
phone: "1235550170",
|
|
378
|
+
});
|
|
379
|
+
|
|
380
|
+
const card = expectDialogOk(await run("record_card", A_CARD, ctx));
|
|
381
|
+
expect(card.state).toBe("booking.readBack");
|
|
382
|
+
// Only the last four ever reached the slot.
|
|
383
|
+
expect(JSON.stringify(hotelSlot.get(ctx))).not.toContain("4532");
|
|
384
|
+
});
|
|
385
|
+
|
|
386
|
+
test("the read-back is OWED: confirm refuses until the caller has answered it", async () => {
|
|
387
|
+
const ctx = createToolContext();
|
|
388
|
+
await bookUpToReadBack(ctx);
|
|
389
|
+
expect(at(ctx)).toBe("booking.readBack");
|
|
390
|
+
const early = expectDialogRefused(await run("confirm_booking", ctx), "booking.readBack");
|
|
391
|
+
expect(early.error).toMatch(/WAIT|answered/);
|
|
392
|
+
expect(hotelSlot.get(ctx).bookings.some((b) => b.lastName === "Whitfield")).toBe(false);
|
|
393
|
+
|
|
394
|
+
expect(callerAnswers(ctx)).toBe("booking.agreeing");
|
|
395
|
+
const done = expectDialogOk<{ outcome: string; room: string; total: string; code: string }>(
|
|
396
|
+
await run("confirm_booking", ctx),
|
|
397
|
+
);
|
|
398
|
+
expect(done.state).toBe("desk");
|
|
399
|
+
expect(done.result).toMatchObject({
|
|
400
|
+
outcome: "booked",
|
|
401
|
+
room: "205",
|
|
402
|
+
total: "739 dollars and 20 cents",
|
|
403
|
+
});
|
|
404
|
+
|
|
405
|
+
const hotel = hotelSlot.get(ctx);
|
|
406
|
+
const booking = hotel.bookings.find((b) => b.code === done.result.code);
|
|
407
|
+
expect(booking).toMatchObject({
|
|
408
|
+
roomId: "205",
|
|
409
|
+
total: 73_920,
|
|
410
|
+
cardLast4: "4471",
|
|
411
|
+
status: "confirmed",
|
|
412
|
+
});
|
|
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
|
+
|
|
431
|
+
test("a re-dated pick that dies re-opens the OFFER, and the caller's turn closes it", async () => {
|
|
432
|
+
const ctx = createToolContext();
|
|
433
|
+
expectDialogOk(await run("start_room_booking", ctx));
|
|
434
|
+
expectDialogOk(
|
|
435
|
+
await run("set_stay", { checkIn: "2026-06-15", checkOut: "2026-06-16", guests: 2 }, ctx),
|
|
436
|
+
);
|
|
437
|
+
expectDialogOk(await run("choose_room", { roomType: "penthouse" }, ctx));
|
|
438
|
+
// The penthouse is occupied through June 12.
|
|
439
|
+
const moved = expectDialogOk<{ next: string }>(
|
|
440
|
+
await run("set_stay", { checkIn: "2026-06-10", checkOut: "2026-06-11", guests: 2 }, ctx),
|
|
441
|
+
);
|
|
442
|
+
expect(moved.result.next).toBe("OFFER");
|
|
443
|
+
expect(moved.state).toBe("booking.offering");
|
|
444
|
+
expect(hotelSlot.get(ctx).draft?.roomType).toBeNull();
|
|
445
|
+
// Closed until the options have been spoken and the caller has answered.
|
|
446
|
+
expectDialogRefused(await run("choose_room", { roomType: "king" }, ctx), "booking.offering");
|
|
447
|
+
expect(callerAnswers(ctx)).toBe("booking.room");
|
|
448
|
+
expectDialogOk(await run("choose_room", { roomType: "king" }, ctx));
|
|
449
|
+
});
|
|
450
|
+
|
|
451
|
+
test("sold-out dates are refused and NOT recorded", async () => {
|
|
452
|
+
const ctx = createToolContext();
|
|
453
|
+
expectDialogOk(await run("start_room_booking", ctx));
|
|
454
|
+
const refused = await run(
|
|
455
|
+
"set_stay",
|
|
456
|
+
{ checkIn: "2026-07-03", checkOut: "2026-07-04", guests: 2 },
|
|
457
|
+
ctx,
|
|
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
|
+
});
|
|
473
|
+
|
|
474
|
+
test("a bad card bounces one field and leaves the flow where it was", async () => {
|
|
475
|
+
const ctx = createToolContext();
|
|
476
|
+
await bookUpToReadBack(ctx);
|
|
477
|
+
// Re-record with a misheard digit: refused, and the recorded card stays.
|
|
478
|
+
const refused = await run("record_card", { ...A_CARD, cardNumber: "4532 0000 0001 4472" }, ctx);
|
|
479
|
+
expect(isToolFailure(refused) && refused.error).toMatch(/one digit is likely off/);
|
|
480
|
+
expect(hotelSlot.get(ctx).draft?.cardLast4).toBe("4471");
|
|
481
|
+
expect(at(ctx)).toBe("booking.readBack");
|
|
482
|
+
});
|
|
483
|
+
|
|
484
|
+
test("abandoning writes nothing and returns to the desk", async () => {
|
|
485
|
+
const ctx = createToolContext();
|
|
486
|
+
await bookUpToReadBack(ctx);
|
|
487
|
+
const gone = expectDialogOk(
|
|
488
|
+
await run("abandon_booking", { reason: "changed their mind" }, ctx),
|
|
489
|
+
);
|
|
490
|
+
expect(gone.state).toBe("desk");
|
|
491
|
+
expect(hotelSlot.get(ctx).draft).toBeNull();
|
|
492
|
+
expect(hotelSlot.get(ctx).bookings.some((b) => b.lastName === "Whitfield")).toBe(false);
|
|
493
|
+
});
|
|
494
|
+
|
|
495
|
+
test("the double-booking guard: no second flow until the caller has spoken again", async () => {
|
|
496
|
+
const ctx = withCallerTurns(4);
|
|
497
|
+
await bookUpToReadBack(ctx);
|
|
498
|
+
callerAnswers(ctx);
|
|
499
|
+
expectDialogOk(await run("confirm_booking", ctx));
|
|
500
|
+
// Same history, so the model — not the caller — is asking for a second room.
|
|
501
|
+
const again = await run("start_room_booking", ctx);
|
|
502
|
+
expect(isToolFailure(again) && again.error).toMatch(/already complete/);
|
|
503
|
+
expect(at(ctx)).toBe("desk");
|
|
504
|
+
// One more caller turn and a real second room is legal.
|
|
505
|
+
const later = withCallerTurns(5);
|
|
506
|
+
hotelSlot.set(later, hotelSlot.snapshot(ctx));
|
|
507
|
+
expectDialogOk(await run("start_room_booking", later));
|
|
508
|
+
});
|
|
509
|
+
|
|
510
|
+
test("a hang-up ends the call, and nothing books after it", async () => {
|
|
511
|
+
const ctx = createToolContext();
|
|
512
|
+
await bookUpToReadBack(ctx);
|
|
513
|
+
expect(deskFlow.receive(ctx, CALLER_GONE).state).toBe("hungUp");
|
|
514
|
+
expect(isToolFailure(await run("confirm_booking", ctx))).toBe(true);
|
|
515
|
+
expect(isToolFailure(await run("start_room_booking", ctx))).toBe(true);
|
|
516
|
+
});
|
|
517
|
+
});
|
|
518
|
+
|
|
519
|
+
// ─── 5. Modifying a booking ──────────────────────────────────────────────────
|
|
520
|
+
|
|
521
|
+
describe("modifying a booking", () => {
|
|
522
|
+
test("Robert Klein's garden view is a room MOVE, and the refusal is the fix", async () => {
|
|
523
|
+
const ctx = createToolContext();
|
|
524
|
+
await verify(ctx, "Klein", "HTL-RK20");
|
|
525
|
+
const loaded = expectDialogOk<{ loaded: { room: string; total: string } }>(
|
|
526
|
+
await run("start_booking_modification", ctx),
|
|
527
|
+
);
|
|
528
|
+
expect(loaded.state).toBe("booking.editing");
|
|
529
|
+
expect(loaded.result.loaded.room).toBe("king, city view, room 201");
|
|
530
|
+
expect(loaded.result.loaded.total).toBe("537 dollars and 60 cents");
|
|
531
|
+
|
|
532
|
+
// A garden king has never existed; the garden view IS open as a queen.
|
|
533
|
+
const refused = await run("choose_room", { roomType: "king", view: "garden" }, ctx);
|
|
534
|
+
expect(isToolFailure(refused) && refused.error).toMatch(/garden view IS open as a queen 2beds/);
|
|
535
|
+
|
|
536
|
+
const picked = expectDialogOk(
|
|
537
|
+
await run("choose_room", { roomType: "queen_2beds", view: "garden" }, ctx),
|
|
538
|
+
);
|
|
539
|
+
expect(picked.state).toBe("booking.readBack");
|
|
540
|
+
expect(callerAnswers(ctx)).toBe("booking.agreeing");
|
|
541
|
+
const done = expectDialogOk<{
|
|
542
|
+
outcome: string;
|
|
543
|
+
changed: string[];
|
|
544
|
+
room: string;
|
|
545
|
+
message: string;
|
|
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");
|
|
554
|
+
});
|
|
555
|
+
|
|
556
|
+
test("a date-only change keeps the room the guest already has", async () => {
|
|
557
|
+
const ctx = createToolContext();
|
|
558
|
+
await verify(ctx, "Smith", "HTL-AB12");
|
|
559
|
+
expectDialogOk(await run("start_booking_modification", ctx));
|
|
560
|
+
const stay = expectDialogOk(
|
|
561
|
+
await run("set_stay", { checkIn: "2026-06-13", checkOut: "2026-06-16", guests: 2 }, ctx),
|
|
562
|
+
);
|
|
563
|
+
expect(stay.state).toBe("booking.readBack");
|
|
564
|
+
callerAnswers(ctx);
|
|
565
|
+
const done = expectDialogOk<{ changed: string[]; room: string }>(
|
|
566
|
+
await run("confirm_booking", ctx),
|
|
567
|
+
);
|
|
568
|
+
expect(done.result.changed).toEqual(["stay"]);
|
|
569
|
+
expect(done.result.room).toBe("203");
|
|
570
|
+
expect(hotelSlot.get(ctx).bookings.find((b) => b.code === "HTL-AB12")).toMatchObject({
|
|
571
|
+
checkOut: "2026-06-16",
|
|
572
|
+
total: 89_040,
|
|
573
|
+
});
|
|
574
|
+
});
|
|
575
|
+
|
|
576
|
+
test("a modification that changes nothing is closed as unchanged, and a cancellation is refused mid-flow", async () => {
|
|
577
|
+
const ctx = createToolContext();
|
|
578
|
+
await verify(ctx, "Smith", "HTL-AB12");
|
|
579
|
+
expectDialogOk(await run("start_booking_modification", ctx));
|
|
580
|
+
// The caller pivots to cancelling: the desk's tools are still legal, but
|
|
581
|
+
// the model is told to close the flow first — which abandon_booking does.
|
|
582
|
+
expectDialogOk(await run("abandon_booking", { reason: "wants to cancel instead" }, ctx));
|
|
583
|
+
expect(at(ctx)).toBe("desk");
|
|
584
|
+
expect(hotelSlot.get(ctx).bookings.find((b) => b.code === "HTL-AB12")?.status).toBe(
|
|
585
|
+
"confirmed",
|
|
586
|
+
);
|
|
587
|
+
});
|
|
588
|
+
|
|
589
|
+
test("the unmodifiable: a cancelled or past booking", async () => {
|
|
590
|
+
const ctx = createToolContext();
|
|
591
|
+
await verify(ctx, "Lee", "HTL-GH78");
|
|
592
|
+
const past = await run("start_booking_modification", ctx);
|
|
593
|
+
expect(isToolFailure(past) && past.error).toMatch(/already ended/);
|
|
594
|
+
});
|
|
595
|
+
});
|
|
596
|
+
|
|
597
|
+
// ─── 6. Cancelling and reinstating ───────────────────────────────────────────
|
|
598
|
+
|
|
599
|
+
describe("cancelling", () => {
|
|
600
|
+
test("outside the window the whole total comes back; inside it one night is kept", async () => {
|
|
601
|
+
const outside = createToolContext();
|
|
602
|
+
await verify(outside, "Smith", "HTL-AB12");
|
|
603
|
+
const full = expectToolOk(await runTool(cancelRoomBooking, outside));
|
|
604
|
+
expect(full).toMatchObject({ withinWindow: false, forfeit: 0, refund: 59_360 });
|
|
605
|
+
expect(hotelSlot.get(outside).bookings.find((b) => b.code === "HTL-AB12")?.status).toBe(
|
|
606
|
+
"cancelled",
|
|
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
|
+
});
|
|
617
|
+
|
|
618
|
+
test("a cancel re-invoked with no caller turn since re-surfaces the outcome", async () => {
|
|
619
|
+
const ctx = withCallerTurns(2);
|
|
620
|
+
await verify(ctx, "Smith", "HTL-AB12");
|
|
621
|
+
expectToolOk(await run("cancel_room_booking", ctx));
|
|
622
|
+
const again = expectToolOk(await runTool(cancelRoomBooking, ctx));
|
|
623
|
+
expect(again.alreadyCancelled).toBe(true);
|
|
624
|
+
expect(again.message).toContain("refund the full 593 dollars and 60 cents");
|
|
625
|
+
});
|
|
626
|
+
|
|
627
|
+
test("reinstating brings a cancelled booking back only while its room is free", async () => {
|
|
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
|
+
});
|
|
644
|
+
|
|
645
|
+
// ─── 7. Disputes ─────────────────────────────────────────────────────────────
|
|
646
|
+
|
|
647
|
+
describe("disputes", () => {
|
|
648
|
+
test("the policy table decides the refund, and the refund moves the invoice", async () => {
|
|
649
|
+
const ctx = createToolContext();
|
|
650
|
+
await verify(ctx, "Lee", "HTL-GH78");
|
|
651
|
+
const invoice = expectToolOk(await runTool(lookupInvoice, ctx));
|
|
652
|
+
expect(invoice.lineItems.map((li) => li.label)).toContain("Late checkout");
|
|
653
|
+
|
|
654
|
+
const filed = expectToolOk(
|
|
655
|
+
await runTool(
|
|
656
|
+
disputeCharge,
|
|
657
|
+
{
|
|
658
|
+
category: "late_checkout_fee",
|
|
659
|
+
lineItemLabel: "late checkout",
|
|
660
|
+
callerNote: "Front desk said a 1 PM checkout would be fine.",
|
|
661
|
+
acceptsOfferedResolution: true,
|
|
662
|
+
},
|
|
663
|
+
ctx,
|
|
664
|
+
),
|
|
665
|
+
);
|
|
666
|
+
expect(filed).toMatchObject({ outcome: "goodwill_waived", refund: PRICING.lateCheckout });
|
|
667
|
+
expect(filed.say).toContain("Waived as a one-time courtesy - 40 dollars back");
|
|
668
|
+
const live = hotelSlot.get(ctx).invoices.find((i) => i.bookingCode === "HTL-GH78");
|
|
669
|
+
// 672.00 less the 40.00 already waived in the seed, less this one.
|
|
670
|
+
expect(live?.total).toBe(67_200 - PRICING.lateCheckout - PRICING.lateCheckout);
|
|
671
|
+
});
|
|
672
|
+
|
|
673
|
+
test("a no-show is explained, never refunded, and escalates only when the caller pushes", async () => {
|
|
674
|
+
const ctx = createToolContext();
|
|
675
|
+
await verify(ctx, "Richardson", "HTL-NS44");
|
|
676
|
+
const pushed = expectToolOk(
|
|
677
|
+
await runTool(
|
|
678
|
+
disputeCharge,
|
|
679
|
+
{
|
|
680
|
+
category: "no_show",
|
|
681
|
+
lineItemLabel: "Room (2 nights)",
|
|
682
|
+
callerNote: "Never showed up.",
|
|
683
|
+
acceptsOfferedResolution: false,
|
|
684
|
+
},
|
|
685
|
+
ctx,
|
|
686
|
+
),
|
|
687
|
+
);
|
|
688
|
+
expect(pushed).toMatchObject({ outcome: "escalated_to_manager", refund: 0 });
|
|
689
|
+
});
|
|
690
|
+
|
|
691
|
+
test("a line item that is not on the invoice is refused with the lines that are", async () => {
|
|
692
|
+
const ctx = createToolContext();
|
|
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
|
+
});
|
|
710
|
+
|
|
711
|
+
test("the outcome table, branch by branch", () => {
|
|
712
|
+
const lines = [{ label: "Minibar", amount: 1800 }];
|
|
713
|
+
expect(resolveDisputeOutcome(DISPUTE_POLICIES.minibar, 1800, "Minibar", lines, false)).toEqual({
|
|
714
|
+
outcome: "auto_refunded",
|
|
715
|
+
refund: 1800,
|
|
716
|
+
});
|
|
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
|
+
});
|
|
746
|
+
});
|
|
747
|
+
|
|
748
|
+
// ─── 8. Room conflicts: the two seeded double-bookings ───────────────────────
|
|
749
|
+
|
|
750
|
+
describe("room conflicts", () => {
|
|
751
|
+
test("Kenji Tanaka is WALKED: the house is full tonight, and 301 is his again tomorrow", async () => {
|
|
752
|
+
const ctx = createToolContext();
|
|
753
|
+
await verify(ctx, "Tanaka", "HTL-RT88");
|
|
754
|
+
const looked = expectToolOk(await runTool(lookupBooking, ctx));
|
|
755
|
+
expect(looked.WARNING).toMatch(/double-booked/);
|
|
756
|
+
const resolved = expectToolOk(await runTool(resolveRoomConflict, ctx));
|
|
757
|
+
expect(resolved).toMatchObject({
|
|
758
|
+
resolved: "walked",
|
|
759
|
+
partnerHotel: "the Harbor House",
|
|
760
|
+
returnDate: "Tuesday, June 9",
|
|
761
|
+
});
|
|
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
|
+
|
|
767
|
+
test("Tom Whelan is UPGRADED: the only room at or above his rate is a suite, at his total", async () => {
|
|
768
|
+
const ctx = createToolContext();
|
|
769
|
+
await verify(ctx, "Whelan", "HTL-TW55");
|
|
770
|
+
const before = hotelSlot.get(ctx).bookings.find((b) => b.code === "HTL-TW55")?.total;
|
|
771
|
+
const resolved = expectToolOk(await runTool(resolveRoomConflict, ctx));
|
|
772
|
+
expect(resolved).toMatchObject({ resolved: "moved", roomType: "suite", upgraded: true });
|
|
773
|
+
const after = hotelSlot.get(ctx).bookings.find((b) => b.code === "HTL-TW55");
|
|
774
|
+
expect(after?.roomId).toBe(resolved.room);
|
|
775
|
+
expect(after?.total).toBe(before);
|
|
776
|
+
// And the lookup no longer warns.
|
|
777
|
+
expect(expectToolOk(await runTool(lookupBooking, ctx)).WARNING).toBeUndefined();
|
|
778
|
+
});
|
|
779
|
+
|
|
780
|
+
test("a booking with no conflict has nothing to resolve", async () => {
|
|
781
|
+
const ctx = createToolContext();
|
|
782
|
+
await verify(ctx, "Klein", "HTL-RK20");
|
|
783
|
+
const refused = await run("resolve_room_conflict", ctx);
|
|
784
|
+
expect(isToolFailure(refused) && refused.error).toMatch(/no room conflict/);
|
|
785
|
+
});
|
|
786
|
+
});
|
|
787
|
+
|
|
788
|
+
// ─── 9. Guest privacy ────────────────────────────────────────────────────────
|
|
789
|
+
|
|
790
|
+
describe("taking a message", () => {
|
|
791
|
+
test("the result for an in-house guest and for a stranger are indistinguishable", async () => {
|
|
792
|
+
const ctx = createToolContext();
|
|
793
|
+
const args = {
|
|
794
|
+
callerName: "Mark Ellis",
|
|
795
|
+
callerPhone: "415 555 0100",
|
|
796
|
+
message: "Dinner is at eight.",
|
|
797
|
+
};
|
|
798
|
+
const guest = expectToolOk(
|
|
799
|
+
await runTool(takeGuestMessage, { ...args, recipient: "Jonathan Pierce" }, ctx),
|
|
800
|
+
);
|
|
801
|
+
const stranger = expectToolOk(
|
|
802
|
+
await runTool(takeGuestMessage, { ...args, recipient: "Nobody Here" }, ctx),
|
|
803
|
+
);
|
|
804
|
+
const shape = (r: Record<string, unknown>) => Object.keys(r).sort();
|
|
805
|
+
expect(shape(guest)).toEqual(shape(stranger));
|
|
806
|
+
for (const result of [guest, stranger]) {
|
|
807
|
+
// Neither the verdict nor the room number the ledger knows reaches the model.
|
|
808
|
+
expect(JSON.stringify(result)).not.toMatch(/delivered|undeliverable|303/);
|
|
809
|
+
}
|
|
810
|
+
// The desk's ledger knows; the model never did.
|
|
811
|
+
const statuses = hotelSlot
|
|
812
|
+
.get(ctx)
|
|
813
|
+
.tickets.filter((t) => t.kind === "guest_message")
|
|
814
|
+
.map((t) => t.details.status);
|
|
815
|
+
expect(statuses).toEqual(["delivered", "undeliverable"]);
|
|
816
|
+
});
|
|
817
|
+
|
|
818
|
+
test("a first name alone is refused — a message needs the full name to reach anyone", async () => {
|
|
819
|
+
const refused = await run("take_guest_message", {
|
|
820
|
+
recipient: "Jonathan",
|
|
821
|
+
callerName: "Mark",
|
|
822
|
+
callerPhone: "415 555 0100",
|
|
823
|
+
message: "hi",
|
|
824
|
+
});
|
|
825
|
+
expect(isToolFailure(refused) && refused.error).toMatch(/last name/);
|
|
826
|
+
});
|
|
827
|
+
});
|
|
828
|
+
|
|
829
|
+
// ─── 10. The restaurant ──────────────────────────────────────────────────────
|
|
830
|
+
|
|
831
|
+
describe("the restaurant", () => {
|
|
832
|
+
test("open slots come from the tables that seat the party and are not already taken", async () => {
|
|
833
|
+
const open = expectToolOk(
|
|
834
|
+
await runTool(checkRestaurantAvailability, { date: TODAY, partySize: 4 }),
|
|
835
|
+
);
|
|
836
|
+
expect(open.open).toContain("7 PM");
|
|
837
|
+
const six = expectToolOk(
|
|
838
|
+
await runTool(checkRestaurantAvailability, { date: TODAY, partySize: 6 }),
|
|
839
|
+
);
|
|
840
|
+
// The one six-top is García's at 7:30 tonight.
|
|
841
|
+
expect(six.open).not.toContain("7:30 PM");
|
|
842
|
+
expect(six.open).toContain("7 PM");
|
|
843
|
+
});
|
|
844
|
+
|
|
845
|
+
test("a table is booked in one call, and the refusals carry the open times or the transfer", async () => {
|
|
846
|
+
const ctx = createToolContext();
|
|
847
|
+
const args = {
|
|
848
|
+
date: TODAY,
|
|
849
|
+
time: "19:00",
|
|
850
|
+
partySize: 4,
|
|
851
|
+
firstName: "Ana",
|
|
852
|
+
lastName: "Reyes",
|
|
853
|
+
phone: "415 555 0199",
|
|
854
|
+
};
|
|
855
|
+
const booked = expectToolOk(await runTool(reserveTable, args, ctx));
|
|
856
|
+
expect(booked.code).toMatch(/^RES-/);
|
|
857
|
+
expect(booked.time).toBe("7 PM");
|
|
858
|
+
|
|
859
|
+
const odd = await run("reserve_table", { ...args, time: "19:15" }, ctx);
|
|
860
|
+
expect(isToolFailure(odd) && odd.error).toMatch(/5:30 PM/);
|
|
861
|
+
const big = await run("reserve_table", { ...args, partySize: 8 }, ctx);
|
|
862
|
+
expect(isToolFailure(big) && big.error).toMatch(/transfer_call/);
|
|
863
|
+
const past = await run("reserve_table", { ...args, date: "2026-06-01" }, ctx);
|
|
864
|
+
expect(isToolFailure(past)).toBe(true);
|
|
865
|
+
});
|
|
866
|
+
|
|
867
|
+
test("moving a reservation keeps its table when that table is still free", async () => {
|
|
868
|
+
const ctx = createToolContext();
|
|
869
|
+
const moved = expectToolOk(
|
|
870
|
+
await runTool(
|
|
871
|
+
modifyRestaurantReservation,
|
|
872
|
+
{ lastName: "Bennett", confirmationCode: "RES-JK90", newDate: TODAY, newTime: "19:30" },
|
|
873
|
+
ctx,
|
|
874
|
+
),
|
|
875
|
+
);
|
|
876
|
+
expect(moved).toMatchObject({ code: "RES-JK90", time: "7:30 PM", partySize: 4 });
|
|
877
|
+
const reservation = hotelSlot.get(ctx).reservations.find((r) => r.code === "RES-JK90");
|
|
878
|
+
expect(reservation).toMatchObject({ tableId: 3, time: "19:30" });
|
|
879
|
+
|
|
880
|
+
const cancelled = expectToolOk(
|
|
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(
|
|
890
|
+
await run(
|
|
891
|
+
"lookup_restaurant_reservation",
|
|
892
|
+
{ lastName: "Bennett", confirmationCode: "RES-JK90" },
|
|
893
|
+
ctx,
|
|
894
|
+
),
|
|
895
|
+
),
|
|
896
|
+
).toBe(true);
|
|
897
|
+
});
|
|
898
|
+
});
|
|
899
|
+
|
|
900
|
+
// ─── 11. Services and the ledger ─────────────────────────────────────────────
|
|
901
|
+
|
|
902
|
+
describe("services", () => {
|
|
903
|
+
test("an emergency is dispatched with no verification, and the direction matches the kind", async () => {
|
|
904
|
+
const ctx = createToolContext();
|
|
905
|
+
const sent = expectToolOk(
|
|
906
|
+
await runTool(
|
|
907
|
+
dispatchEmergency,
|
|
908
|
+
{ room: "room 401", kind: "medical", situation: "guest collapsed" },
|
|
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
|
+
},
|
|
943
|
+
ctx,
|
|
944
|
+
),
|
|
945
|
+
);
|
|
946
|
+
expect(followup.reference).toMatch(/^FUP-/);
|
|
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
|
+
});
|
|
953
|
+
|
|
954
|
+
test("a transfer happens exactly once per department", async () => {
|
|
955
|
+
const ctx = createToolContext();
|
|
956
|
+
const first = expectToolOk(
|
|
957
|
+
await runTool(
|
|
958
|
+
transferCall,
|
|
959
|
+
{ destination: "restaurant", summary: "party of ten, private room" },
|
|
960
|
+
ctx,
|
|
961
|
+
),
|
|
962
|
+
);
|
|
963
|
+
const second = expectToolOk(
|
|
964
|
+
await runTool(transferCall, { destination: "restaurant", summary: "again" }, ctx),
|
|
965
|
+
);
|
|
966
|
+
expect(first.alreadyTransferred).toBe(false);
|
|
967
|
+
expect(second.alreadyTransferred).toBe(true);
|
|
968
|
+
expect(hotelSlot.get(ctx).tickets.filter((t) => t.kind === "transfer")).toHaveLength(1);
|
|
969
|
+
});
|
|
970
|
+
|
|
971
|
+
test("the catalogs price a booking and refuse past its caps", async () => {
|
|
972
|
+
const ctx = createToolContext();
|
|
973
|
+
const tour = expectToolOk(
|
|
974
|
+
await runTool(
|
|
975
|
+
bookTour,
|
|
976
|
+
{
|
|
977
|
+
tour: "full_day_city",
|
|
978
|
+
date: addDays(TODAY, 2),
|
|
979
|
+
partySize: 2,
|
|
980
|
+
guestName: "Sofía García",
|
|
981
|
+
guestPhone: "415 555 0107",
|
|
982
|
+
},
|
|
983
|
+
ctx,
|
|
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",
|
|
994
|
+
});
|
|
995
|
+
expect(isToolFailure(tooMany) && tooMany.error).toMatch(/at most 4/);
|
|
996
|
+
const past = await run("order_flowers", {
|
|
997
|
+
arrangement: "roses",
|
|
998
|
+
date: "2026-06-01",
|
|
999
|
+
deliverTo: "401",
|
|
1000
|
+
cardMessage: "Happy anniversary",
|
|
1001
|
+
guestName: "x",
|
|
1002
|
+
guestPhone: "1",
|
|
1003
|
+
});
|
|
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
|
+
|
|
1037
|
+
test("the policy book renders the catalogs, so a price lives in one place", async () => {
|
|
1038
|
+
const tours = expectToolOk(await runTool(lookupPolicy, { topic: "tours" }));
|
|
1039
|
+
expect(tours.policy).toContain("Half-day city highlights");
|
|
1040
|
+
expect(tours.policy).toContain("65 dollars per person");
|
|
1041
|
+
expect(POLICIES.spa.body).toContain("140 dollars per person");
|
|
1042
|
+
expect(
|
|
1043
|
+
await toolInputIssues(agentDef, "lookup_policy", { topic: "not_a_topic" }),
|
|
1044
|
+
).toBeDefined();
|
|
1045
|
+
});
|
|
1046
|
+
|
|
1047
|
+
test("a group under fifteen is not a group, and a car with five is not the hotel car", async () => {
|
|
1048
|
+
expect(
|
|
1049
|
+
await toolInputIssues(agentDef, "record_group_inquiry", {
|
|
1050
|
+
company: "Acme",
|
|
1051
|
+
contactName: "A",
|
|
1052
|
+
contactPhone: "1",
|
|
1053
|
+
partySize: 10,
|
|
1054
|
+
shareType: "twin",
|
|
1055
|
+
checkIn: addDays(TODAY, 30),
|
|
1056
|
+
nights: 2,
|
|
1057
|
+
}),
|
|
1058
|
+
).toBeDefined();
|
|
1059
|
+
expect(
|
|
1060
|
+
await toolInputIssues(agentDef, "book_airport_car", {
|
|
1061
|
+
room: "401",
|
|
1062
|
+
pickupDate: addDays(TODAY, 1),
|
|
1063
|
+
pickupTime: "06:00",
|
|
1064
|
+
passengers: 5,
|
|
1065
|
+
}),
|
|
1066
|
+
).toBeDefined();
|
|
1067
|
+
const car = expectToolOk(
|
|
1068
|
+
await runTool(bookAirportCar, {
|
|
1069
|
+
room: "401",
|
|
1070
|
+
pickupDate: addDays(TODAY, 1),
|
|
1071
|
+
pickupTime: "06:00",
|
|
1072
|
+
passengers: 3,
|
|
1073
|
+
}),
|
|
1074
|
+
);
|
|
1075
|
+
expect(car.total).toBe("85 dollars");
|
|
1076
|
+
});
|
|
1077
|
+
|
|
1078
|
+
test("a flight reference is normalized the way a caller spells one", async () => {
|
|
1079
|
+
const ctx = createToolContext();
|
|
1080
|
+
expectToolOk(
|
|
1081
|
+
await run(
|
|
1082
|
+
"request_flight_reconfirmation",
|
|
1083
|
+
{
|
|
1084
|
+
room: "304",
|
|
1085
|
+
airline: "Iberia",
|
|
1086
|
+
flightNumber: "ib 6174",
|
|
1087
|
+
flightDate: addDays(TODAY, 3),
|
|
1088
|
+
bookingReference: "x 7 q - 9 2 k",
|
|
1089
|
+
seatCheck: true,
|
|
1090
|
+
},
|
|
1091
|
+
ctx,
|
|
1092
|
+
),
|
|
1093
|
+
);
|
|
1094
|
+
expect(hotelSlot.get(ctx).tickets[0]?.details).toMatchObject({
|
|
1095
|
+
flightNumber: "IB6174",
|
|
1096
|
+
bookingReference: "X7Q92K",
|
|
1097
|
+
});
|
|
1098
|
+
});
|
|
1099
|
+
|
|
1100
|
+
test("the verified guest's extras: a late arrival, a re-sent folio, a new card", async () => {
|
|
1101
|
+
const ctx = createToolContext();
|
|
1102
|
+
await verify(ctx, "Smith", "HTL-AB12");
|
|
1103
|
+
expectToolOk(await run("flag_late_arrival", { note: "around 1 AM" }, ctx));
|
|
1104
|
+
expect(hotelSlot.get(ctx).bookings.find((b) => b.code === "HTL-AB12")?.lateArrivalNote).toBe(
|
|
1105
|
+
"around 1 AM",
|
|
1106
|
+
);
|
|
1107
|
+
const sent = expectToolOk(await runTool(resendConfirmation, { kind: "folio" }, ctx));
|
|
1108
|
+
expect(sent.to).toBe("eleanor.smith@gmail.com");
|
|
1109
|
+
const card = expectToolOk(await runTool(updateCard, A_CARD, ctx));
|
|
1110
|
+
expect(card.cardLast4).toBe("4471");
|
|
1111
|
+
expect(hotelSlot.get(ctx).bookings.find((b) => b.code === "HTL-AB12")?.cardLast4).toBe("4471");
|
|
1112
|
+
});
|
|
1113
|
+
|
|
1114
|
+
test("two contexts never share a hotel", async () => {
|
|
1115
|
+
const a = createToolContext();
|
|
1116
|
+
const b = createToolContext();
|
|
1117
|
+
await verify(a, "Smith", "HTL-AB12");
|
|
1118
|
+
expectToolOk(await run("cancel_room_booking", a));
|
|
1119
|
+
expect(hotelSlot.get(b).bookings.find((x) => x.code === "HTL-AB12")?.status).toBe("confirmed");
|
|
1120
|
+
});
|
|
1121
|
+
});
|