@alexkroman1/aai-cli 15.1.0 → 16.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -5
- package/bin.mjs +12 -3
- package/dist/_build-target-55dJisQ-.mjs +649 -0
- package/dist/_build-target.d.ts +105 -108
- package/dist/_deno-output.d.ts +23 -0
- package/dist/_deno-target.d.ts +73 -0
- package/dist/{_init-Bsi3DZNJ.mjs → _init-BzQbV8Zh.mjs} +3 -1
- package/dist/_modal-app.d.ts +77 -0
- package/dist/_modal-output.d.ts +31 -0
- package/dist/_modal-target.d.ts +64 -0
- package/dist/_target-bundle.d.ts +27 -0
- package/dist/_target-drain.d.ts +44 -0
- package/dist/_target-output.d.ts +63 -0
- package/dist/{_templates-CIlJ3Vay.mjs → _templates-CuP74F8D.mjs} +94 -4
- package/dist/_templates.d.ts +14 -1
- package/dist/_vercel-output.d.ts +4 -19
- package/dist/_vercel-target.d.ts +169 -0
- package/dist/{test-D032V2cA.mjs → _vitest-runner-AVR9VtXh.mjs} +28 -68
- package/dist/_vitest-runner.d.ts +154 -0
- package/dist/build-ButI2IKc.mjs +689 -0
- package/dist/build.d.ts +11 -0
- package/dist/cli.mjs +12 -11
- package/dist/{dev-Bx9gYBHM.mjs → dev-kodAY23K.mjs} +7 -1
- package/dist/{eval-B3I7FqN9.mjs → eval-DvoSz7SZ.mjs} +1 -1
- package/dist/{init-CQbj3ycf.mjs → init-D363Ls5u.mjs} +2 -2
- package/dist/scaffold/CLAUDE.md +185 -35
- package/dist/scaffold/package.json +4 -4
- package/dist/start.mjs +3 -1
- package/dist/{studio-C_zuRC_z.mjs → studio-CtRBVVFR.mjs} +1 -1
- package/dist/templates/briefing-desk/agent.eval.test.ts +34 -6
- package/dist/templates/briefing-desk/agent.test.ts +347 -55
- package/dist/templates/briefing-desk/agent.ts +12 -0
- package/dist/templates/briefing-desk/shared.ts +220 -31
- package/dist/templates/briefing-desk/slack.ts +108 -0
- package/dist/templates/briefing-desk/system-prompt.md +12 -2
- package/dist/templates/briefing-desk/tools/briefing_so_far.ts +15 -7
- package/dist/templates/briefing-desk/tools/research_topic.ts +20 -28
- package/dist/templates/briefing-desk/tools/send_briefing.ts +77 -0
- package/dist/templates/briefing-desk/tools/verify_claim.ts +60 -14
- package/dist/templates/call-audit/agent.eval.test.ts +5 -0
- package/dist/templates/call-audit/agent.test.ts +6 -1
- package/dist/templates/call-audit/agent.ts +10 -23
- package/dist/templates/call-audit/client.tsx +30 -55
- package/dist/templates/call-audit/guards.test.ts +233 -0
- package/dist/templates/call-audit/workflows/audit.ts +95 -16
- package/dist/templates/call-audit/workflows/ingest.ts +107 -88
- package/dist/templates/call-audit/workflows/media.ts +98 -7
- package/dist/templates/call-audit/workflows/summarize.ts +35 -31
- package/dist/templates/call-audit/workflows/sync-api.ts +15 -6
- package/dist/templates/code-interpreter/agent.eval.test.ts +104 -56
- package/dist/templates/code-interpreter/agent.test.ts +44 -56
- package/dist/templates/code-interpreter/system-prompt.md +1 -1
- package/dist/templates/dispatch-center/agent.eval.test.ts +61 -24
- package/dist/templates/dispatch-center/agent.test.ts +253 -48
- package/dist/templates/dispatch-center/agent.ts +28 -1
- package/dist/templates/dispatch-center/client.tsx +126 -201
- package/dist/templates/dispatch-center/events.ts +48 -0
- package/dist/templates/dispatch-center/shared.ts +42 -1
- package/dist/templates/dispatch-center/tools/incident_create.ts +3 -2
- package/dist/templates/dispatch-center/tools/incident_escalate.ts +2 -1
- package/dist/templates/dispatch-center/tools/ops_dashboard.ts +35 -15
- package/dist/templates/dispatch-center/tools/ops_run_scenario.ts +3 -1
- package/dist/templates/dispatch-center/tools/resources_dispatch.ts +2 -2
- package/dist/templates/executive-assistant/agent.eval.test.ts +233 -0
- package/dist/templates/executive-assistant/agent.test.ts +672 -0
- package/dist/templates/executive-assistant/agent.ts +50 -0
- package/dist/templates/executive-assistant/calendar.test.ts +198 -0
- package/dist/templates/executive-assistant/client.tsx +195 -0
- package/dist/templates/executive-assistant/inbox.ts +233 -0
- package/dist/templates/executive-assistant/meeting.ts +138 -0
- package/dist/templates/executive-assistant/nodes.ts +152 -0
- package/dist/templates/executive-assistant/prompts.ts +331 -0
- package/dist/templates/executive-assistant/review.ts +425 -0
- package/dist/templates/executive-assistant/shared.ts +490 -0
- package/dist/templates/executive-assistant/system-prompt.md +15 -0
- package/dist/templates/executive-assistant/tools/accept.ts +10 -0
- package/dist/templates/executive-assistant/tools/ask_question.ts +30 -0
- package/dist/templates/executive-assistant/tools/draft_reply.ts +67 -0
- package/dist/templates/executive-assistant/tools/edit.ts +10 -0
- package/dist/templates/executive-assistant/tools/ignore.ts +10 -0
- package/dist/templates/executive-assistant/tools/inbox_status.ts +27 -0
- package/dist/templates/executive-assistant/tools/meeting_assistant.ts +52 -0
- package/dist/templates/executive-assistant/tools/new_email.ts +50 -0
- package/dist/templates/executive-assistant/tools/open_email.ts +165 -0
- package/dist/templates/executive-assistant/tools/respond.ts +10 -0
- package/dist/templates/executive-assistant/tools/review_memory.ts +22 -0
- package/dist/templates/executive-assistant/tools/send_calendar_invite.ts +68 -0
- package/dist/templates/executive-assistant/tools/triage_inbox.ts +75 -0
- package/dist/templates/health-assistant/agent.test.ts +134 -15
- package/dist/templates/health-assistant/agent.ts +8 -1
- package/dist/templates/health-assistant/fda.test.ts +130 -0
- package/dist/templates/health-assistant/fda.ts +75 -16
- package/dist/templates/health-assistant/system-prompt.md +9 -0
- package/dist/templates/health-assistant/tools/check_drug_interaction.ts +5 -2
- package/dist/templates/health-assistant/tools/medication_lookup.ts +16 -11
- package/dist/templates/hiring-desk/agent.eval.test.ts +242 -0
- package/dist/templates/hiring-desk/agent.test.ts +1021 -0
- package/dist/templates/hiring-desk/agent.ts +38 -0
- package/dist/templates/hiring-desk/client.tsx +154 -0
- package/dist/templates/hiring-desk/crews.ts +432 -0
- package/dist/templates/hiring-desk/leads.json +86 -0
- package/dist/templates/hiring-desk/screening-lock.test.ts +77 -0
- package/dist/templates/hiring-desk/screening-lock.ts +51 -0
- package/dist/templates/hiring-desk/shared.ts +480 -0
- package/dist/templates/hiring-desk/system-prompt.md +21 -0
- package/dist/templates/hiring-desk/tools/candidate_details.ts +49 -0
- package/dist/templates/hiring-desk/tools/proceed_to_emails.ts +127 -0
- package/dist/templates/hiring-desk/tools/read_email.ts +50 -0
- package/dist/templates/hiring-desk/tools/rescore_with_feedback.ts +140 -0
- package/dist/templates/hiring-desk/tools/screen_candidates.ts +128 -0
- package/dist/templates/hiring-desk/tools/screening_status.ts +51 -0
- package/dist/templates/hotel-desk/agent.eval.test.ts +177 -0
- package/dist/templates/hotel-desk/agent.test.ts +1128 -0
- package/dist/templates/hotel-desk/agent.ts +63 -0
- package/dist/templates/hotel-desk/booking.ts +159 -0
- package/dist/templates/hotel-desk/card.ts +92 -0
- package/dist/templates/hotel-desk/catalogs.ts +219 -0
- package/dist/templates/hotel-desk/client.tsx +137 -0
- package/dist/templates/hotel-desk/concierge.ts +99 -0
- package/dist/templates/hotel-desk/desk-seams.test.ts +334 -0
- package/dist/templates/hotel-desk/desk.ts +224 -0
- package/dist/templates/hotel-desk/disputes.ts +216 -0
- package/dist/templates/hotel-desk/events.ts +79 -0
- package/dist/templates/hotel-desk/hotel.ts +412 -0
- package/dist/templates/hotel-desk/policies.ts +209 -0
- package/dist/templates/hotel-desk/records.ts +384 -0
- package/dist/templates/hotel-desk/restaurant.ts +147 -0
- package/dist/templates/hotel-desk/seed.ts +955 -0
- package/dist/templates/hotel-desk/shared.ts +354 -0
- package/dist/templates/hotel-desk/system-prompt.md +76 -0
- package/dist/templates/hotel-desk/tools/abandon_booking.ts +30 -0
- package/dist/templates/hotel-desk/tools/add_to_waitlist.ts +41 -0
- package/dist/templates/hotel-desk/tools/book_airport_car.ts +57 -0
- package/dist/templates/hotel-desk/tools/book_business_center.ts +44 -0
- package/dist/templates/hotel-desk/tools/book_spa_appointment.ts +39 -0
- package/dist/templates/hotel-desk/tools/book_tour.ts +35 -0
- package/dist/templates/hotel-desk/tools/cancel_restaurant_reservation.ts +25 -0
- package/dist/templates/hotel-desk/tools/cancel_room_booking.ts +63 -0
- package/dist/templates/hotel-desk/tools/check_restaurant_availability.ts +24 -0
- package/dist/templates/hotel-desk/tools/check_room_availability.ts +40 -0
- package/dist/templates/hotel-desk/tools/choose_room.ts +93 -0
- package/dist/templates/hotel-desk/tools/confirm_booking.ts +153 -0
- package/dist/templates/hotel-desk/tools/dispatch_emergency.ts +61 -0
- package/dist/templates/hotel-desk/tools/dispute_charge.ts +90 -0
- package/dist/templates/hotel-desk/tools/flag_late_arrival.ts +26 -0
- package/dist/templates/hotel-desk/tools/lookup_booking.ts +48 -0
- package/dist/templates/hotel-desk/tools/lookup_guest_history.ts +28 -0
- package/dist/templates/hotel-desk/tools/lookup_invoice.ts +26 -0
- package/dist/templates/hotel-desk/tools/lookup_policy.ts +20 -0
- package/dist/templates/hotel-desk/tools/lookup_restaurant_reservation.ts +27 -0
- package/dist/templates/hotel-desk/tools/modify_restaurant_reservation.ts +75 -0
- package/dist/templates/hotel-desk/tools/order_flowers.ts +40 -0
- package/dist/templates/hotel-desk/tools/record_card.ts +46 -0
- package/dist/templates/hotel-desk/tools/record_followup.ts +50 -0
- package/dist/templates/hotel-desk/tools/record_group_inquiry.ts +44 -0
- package/dist/templates/hotel-desk/tools/record_guest_details.ts +71 -0
- package/dist/templates/hotel-desk/tools/reinstate_booking.ts +65 -0
- package/dist/templates/hotel-desk/tools/request_flight_reconfirmation.ts +54 -0
- package/dist/templates/hotel-desk/tools/resend_confirmation.ts +39 -0
- package/dist/templates/hotel-desk/tools/reserve_table.ts +87 -0
- package/dist/templates/hotel-desk/tools/resolve_room_conflict.ts +48 -0
- package/dist/templates/hotel-desk/tools/schedule_wakeup_call.ts +48 -0
- package/dist/templates/hotel-desk/tools/set_do_not_disturb.ts +28 -0
- package/dist/templates/hotel-desk/tools/set_extras.ts +51 -0
- package/dist/templates/hotel-desk/tools/set_stay.ts +97 -0
- package/dist/templates/hotel-desk/tools/start_booking_modification.ts +57 -0
- package/dist/templates/hotel-desk/tools/start_room_booking.ts +49 -0
- package/dist/templates/hotel-desk/tools/take_guest_message.ts +71 -0
- package/dist/templates/hotel-desk/tools/transfer_call.ts +47 -0
- package/dist/templates/hotel-desk/tools/update_card.ts +45 -0
- package/dist/templates/hotel-desk/tools/verify_booking.ts +95 -0
- package/dist/templates/infocom-adventure/agent.eval.test.ts +33 -1
- package/dist/templates/infocom-adventure/agent.test.ts +207 -52
- package/dist/templates/infocom-adventure/agent.ts +14 -3
- package/dist/templates/infocom-adventure/client.tsx +138 -176
- package/dist/templates/infocom-adventure/shared.ts +126 -6
- package/dist/templates/infocom-adventure/system-prompt.md +4 -4
- package/dist/templates/infocom-adventure/tools/game_state_drop.ts +20 -4
- package/dist/templates/infocom-adventure/tools/game_state_get.ts +6 -5
- package/dist/templates/infocom-adventure/tools/game_state_score.ts +9 -3
- package/dist/templates/link-digest/agent.eval.test.ts +8 -0
- package/dist/templates/link-digest/agent.test.ts +285 -29
- package/dist/templates/link-digest/agent.ts +9 -0
- package/dist/templates/link-digest/api-client.ts +144 -0
- package/dist/templates/link-digest/client.tsx +11 -30
- package/dist/templates/link-digest/workflows/digest.ts +72 -24
- package/dist/templates/night-owl/agent.eval.test.ts +55 -40
- package/dist/templates/night-owl/agent.test.ts +146 -12
- package/dist/templates/night-owl/client.tsx +50 -17
- package/dist/templates/night-owl/shared.ts +33 -2
- package/dist/templates/night-owl/system-prompt.md +3 -0
- package/dist/templates/night-owl/tools/recommend.ts +4 -1
- package/dist/templates/night-owl/tools/revisit.ts +49 -0
- package/dist/templates/pipeline-simple/agent.eval.test.ts +7 -6
- package/dist/templates/pipeline-simple/agent.test.ts +48 -91
- package/dist/templates/pipeline-simple/modes.test.ts +151 -0
- package/dist/templates/pipeline-simple/stages.test.ts +332 -0
- package/dist/templates/pizza-ordering/agent.test.ts +94 -38
- package/dist/templates/pizza-ordering/client.tsx +10 -5
- package/dist/templates/pizza-ordering/shared.ts +65 -6
- package/dist/templates/pizza-ordering/tools/add_pizza.ts +2 -7
- package/dist/templates/pizza-ordering/tools/place_order.ts +9 -6
- package/dist/templates/pizza-ordering/tools/remove_pizza.ts +6 -11
- package/dist/templates/pizza-ordering/tools/update_pizza.ts +8 -9
- package/dist/templates/pizza-ordering/tools/view_order.ts +2 -3
- package/dist/templates/plan-and-execute/agent.eval.test.ts +14 -6
- package/dist/templates/plan-and-execute/agent.test.ts +300 -113
- package/dist/templates/plan-and-execute/client.tsx +18 -7
- package/dist/templates/plan-and-execute/procedure.ts +162 -64
- package/dist/templates/plan-and-execute/prompts.ts +51 -15
- package/dist/templates/plan-and-execute/shared.ts +151 -45
- package/dist/templates/plan-and-execute/tools/plan_status.ts +15 -6
- package/dist/templates/plan-and-execute/tools/revise_plan.ts +2 -2
- package/dist/templates/plan-and-execute/tools/start_plan.ts +2 -2
- package/dist/templates/plan-and-execute/tools/work_next_step.ts +15 -13
- package/dist/templates/podcast-digest/agent.eval.test.ts +12 -7
- package/dist/templates/podcast-digest/agent.test.ts +126 -51
- package/dist/templates/podcast-digest/client.tsx +104 -68
- package/dist/templates/podcast-digest/workflows/digest.ts +71 -48
- package/dist/templates/podcast-digest/workflows/feeds.ts +5 -7
- package/dist/templates/podcast-digest/workflows/slack.ts +82 -17
- package/dist/templates/recap-workflow/agent.eval.test.ts +193 -209
- package/dist/templates/recap-workflow/agent.test.ts +207 -26
- package/dist/templates/recap-workflow/tools/recap_status.ts +2 -2
- package/dist/templates/recap-workflow/workflows/recap.ts +39 -28
- package/dist/templates/redline/agent.eval.test.ts +40 -3
- package/dist/templates/redline/agent.test.ts +216 -6
- package/dist/templates/redline/agent.ts +54 -34
- package/dist/templates/redline/client.tsx +82 -126
- package/dist/templates/redline/form.ts +74 -0
- package/dist/templates/redline/workflows/prompts.ts +3 -3
- package/dist/templates/redline/workflows/redline.ts +73 -4
- package/dist/templates/research-workflow/agent.eval.test.ts +152 -150
- package/dist/templates/research-workflow/agent.test.ts +436 -126
- package/dist/templates/research-workflow/agent.ts +20 -5
- package/dist/templates/research-workflow/tools/file_it_now.ts +11 -1
- package/dist/templates/research-workflow/tools/research_status.ts +39 -4
- package/dist/templates/research-workflow/workflows/filing.ts +164 -0
- package/dist/templates/research-workflow/workflows/notes.ts +69 -0
- package/dist/templates/research-workflow/workflows/prompts.ts +45 -31
- package/dist/templates/research-workflow/workflows/research.ts +227 -280
- package/dist/templates/research-workflow/workflows/review.ts +43 -0
- package/dist/templates/retail/address.ts +29 -35
- package/dist/templates/retail/agent.eval.test.ts +36 -16
- package/dist/templates/retail/agent.test.ts +104 -26
- package/dist/templates/retail/agent.ts +12 -0
- package/dist/templates/retail/cancel.ts +39 -42
- package/dist/templates/retail/client.tsx +111 -176
- package/dist/templates/retail/payment.ts +38 -43
- package/dist/templates/retail/pending.test.ts +16 -8
- package/dist/templates/retail/registry.test.ts +108 -49
- package/dist/templates/retail/resolve.test.ts +2 -63
- package/dist/templates/retail/resolve.ts +16 -56
- package/dist/templates/retail/returns.ts +53 -54
- package/dist/templates/retail/seed.test.ts +2 -1
- package/dist/templates/retail/shared.ts +58 -14
- package/dist/templates/retail/store.test.ts +40 -29
- package/dist/templates/retail/store.ts +60 -23
- package/dist/templates/retail/swap.ts +78 -81
- package/dist/templates/retail/tools/find_user_id_by_name_zip.ts +2 -1
- package/dist/templates/roadside-assist/agent.eval.test.ts +164 -0
- package/dist/templates/roadside-assist/agent.test.ts +617 -0
- package/dist/templates/roadside-assist/agent.ts +85 -0
- package/dist/templates/roadside-assist/call.ts +237 -0
- package/dist/templates/roadside-assist/events.ts +92 -0
- package/dist/templates/roadside-assist/shared.ts +334 -0
- package/dist/templates/roadside-assist/system-prompt.md +37 -0
- package/dist/templates/roadside-assist/tools/acknowledge_disclosure.ts +47 -0
- package/dist/templates/roadside-assist/tools/dispatch_truck.ts +148 -0
- package/dist/templates/roadside-assist/tools/job_status.ts +38 -0
- package/dist/templates/roadside-assist/tools/lookup_coverage.ts +72 -0
- package/dist/templates/roadside-assist/tools/report_location.ts +79 -0
- package/dist/templates/roadside-assist/tools/service_disclosure.ts +45 -0
- package/dist/templates/roadside-assist/yard.test.ts +158 -0
- package/dist/templates/roadside-assist/yard.ts +183 -0
- package/dist/templates/simple/agent.eval.test.ts +4 -1
- package/dist/templates/simple/agent.test.ts +54 -31
- package/dist/templates/solo-rpg/agent.eval.test.ts +19 -11
- package/dist/templates/solo-rpg/agent.test.ts +402 -175
- package/dist/templates/solo-rpg/agent.ts +14 -3
- package/dist/templates/solo-rpg/client.tsx +10 -10
- package/dist/templates/solo-rpg/shared.ts +198 -79
- package/dist/templates/solo-rpg/tools/action_roll.ts +7 -3
- package/dist/templates/solo-rpg/tools/burn_momentum.ts +16 -8
- package/dist/templates/solo-rpg/tools/oracle.ts +7 -7
- package/dist/templates/solo-rpg/tools/setup_character.ts +5 -5
- package/dist/templates/solo-rpg/tools/update_state.ts +29 -18
- package/dist/templates/spoken-summary/agent.test.ts +70 -15
- package/dist/templates/spoken-summary/agent.ts +25 -21
- package/dist/templates/spoken-summary/client.tsx +68 -88
- package/dist/templates/spoken-summary/workflows/summarize.ts +26 -8
- package/dist/templates/support-line/agent.test.ts +167 -36
- package/dist/templates/support-line/client.tsx +21 -9
- package/dist/templates/support-line/nodes.ts +74 -32
- package/dist/templates/support-line/procedure.ts +66 -21
- package/dist/templates/support-line/prompts.ts +9 -0
- package/dist/templates/support-line/shared.ts +55 -17
- package/dist/templates/support-line/tools/answer_question.ts +14 -14
- package/dist/templates/transcription-workflow/agent.test.ts +135 -13
- package/dist/templates/transcription-workflow/client.tsx +30 -23
- package/dist/templates/transcription-workflow/recover.test.ts +93 -12
- package/dist/templates/transcription-workflow/recover.ts +29 -5
- package/dist/templates/transcription-workflow/run-panel.tsx +40 -51
- package/dist/templates/transcription-workflow/workflows/normalize.ts +125 -24
- package/dist/templates/transcription-workflow/workflows/stream.ts +4 -1
- package/dist/templates/transcription-workflow/workflows/transcribe.ts +7 -5
- package/dist/templates/transcription-workflow/workflows/wav.ts +42 -117
- package/dist/templates/travel-concierge/agent.eval.test.ts +6 -4
- package/dist/templates/travel-concierge/agent.test.ts +209 -40
- package/dist/templates/travel-concierge/agent.ts +24 -4
- package/dist/templates/travel-concierge/call-events.ts +80 -0
- package/dist/templates/travel-concierge/client.tsx +3 -2
- package/dist/templates/travel-concierge/routing.ts +5 -7
- package/dist/templates/travel-concierge/shared.ts +202 -41
- package/dist/templates/travel-concierge/tools/book_car_rental.ts +2 -4
- package/dist/templates/travel-concierge/tools/book_excursion.ts +2 -4
- package/dist/templates/travel-concierge/tools/book_hotel.ts +2 -4
- package/dist/templates/travel-concierge/tools/cancel_ticket.ts +6 -4
- package/dist/templates/travel-concierge/tools/search_car_rentals.ts +3 -5
- package/dist/templates/travel-concierge/tools/search_excursions.ts +3 -5
- package/dist/templates/travel-concierge/tools/search_flights.ts +20 -9
- package/dist/templates/travel-concierge/tools/search_hotels.ts +3 -5
- package/dist/templates/travel-concierge/tools/update_ticket.ts +2 -4
- package/dist/templates/web-researcher/agent.eval.test.ts +3 -6
- package/dist/templates/web-researcher/agent.test.ts +102 -65
- package/dist/templates/web-researcher/agent.ts +93 -1
- package/dist/templates/web-researcher/system-prompt.md +7 -1
- package/dist/templates/word-wrangler/agent.eval.test.ts +157 -0
- package/dist/templates/word-wrangler/agent.test.ts +432 -0
- package/dist/templates/word-wrangler/agent.ts +35 -0
- package/dist/templates/word-wrangler/client.tsx +211 -0
- package/dist/templates/word-wrangler/game.ts +107 -0
- package/dist/templates/word-wrangler/guess.ts +63 -0
- package/dist/templates/word-wrangler/player.ts +68 -0
- package/dist/templates/word-wrangler/shared.ts +263 -0
- package/dist/templates/word-wrangler/system-prompt.md +15 -0
- package/dist/templates/word-wrangler/tools/final_score.ts +37 -0
- package/dist/templates/word-wrangler/tools/relay_description.ts +137 -0
- package/dist/templates/word-wrangler/tools/repeat_word.ts +19 -0
- package/dist/templates/word-wrangler/tools/skip_word.ts +31 -0
- package/dist/templates/word-wrangler/tools/start_game.ts +47 -0
- package/dist/templates/word-wrangler/words.ts +278 -0
- package/dist/test-Cllnx81G.mjs +83 -0
- package/dist/test.d.ts +9 -114
- package/package.json +5 -5
- package/dist/build-BhEaxBPu.mjs +0 -481
- package/dist/templates/embedded-assets/agent.eval.test.ts +0 -130
- package/dist/templates/embedded-assets/agent.test.ts +0 -79
- package/dist/templates/embedded-assets/agent.ts +0 -7
- package/dist/templates/embedded-assets/knowledge.json +0 -20
- package/dist/templates/embedded-assets/shared.ts +0 -17
- package/dist/templates/embedded-assets/system-prompt.md +0 -13
- package/dist/templates/embedded-assets/tools/list_topics.ts +0 -9
- package/dist/templates/embedded-assets/tools/search_knowledge.ts +0 -26
- package/dist/templates/math-buddy/agent.eval.test.ts +0 -128
- package/dist/templates/math-buddy/agent.test.ts +0 -126
- package/dist/templates/math-buddy/agent.ts +0 -15
- package/dist/templates/math-buddy/system-prompt.md +0 -12
- package/dist/templates/personal-finance/agent.eval.test.ts +0 -149
- package/dist/templates/personal-finance/agent.test.ts +0 -127
- package/dist/templates/personal-finance/agent.ts +0 -8
- package/dist/templates/personal-finance/system-prompt.md +0 -21
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { TelephonyAccess } from "@alexkroman1/aai";
|
|
2
|
+
import { agent } from "@alexkroman1/aai";
|
|
3
|
+
import { DIALOGS } from "./call.ts";
|
|
4
|
+
import { DESK_EVENTS } from "./events.ts";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Who may put a call on this agent.
|
|
8
|
+
*
|
|
9
|
+
* **This is the one template where declaring it is not a detail**: a roadside
|
|
10
|
+
* desk is reached by a stranded person on a phone, not by a browser tab, and
|
|
11
|
+
* `WS /phone` is not served at all unless an agent asks for it. `true` would
|
|
12
|
+
* admit every carrier the runtime ships a codec for; the list is the honest
|
|
13
|
+
* shape for a desk whose numbers are with known carriers, and it is an
|
|
14
|
+
* ALLOW-LIST — adding a third carrier's number without adding it here is a
|
|
15
|
+
* refused upgrade rather than a call that half works.
|
|
16
|
+
*
|
|
17
|
+
* Typed {@link TelephonyAccess} because the field takes a boolean OR a list and
|
|
18
|
+
* the annotation is what says which of the two this is. What it is NOT is a
|
|
19
|
+
* claim about credentials: a carrier does not sign the WebSocket upgrade, and
|
|
20
|
+
* its webhook signature is checked where the webhook lands.
|
|
21
|
+
*/
|
|
22
|
+
const PHONE_LINE: TelephonyAccess = ["twilio", "telnyx"];
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* A roadside-assistance line: find the caller, price the call, read them the
|
|
26
|
+
* fee, send a truck.
|
|
27
|
+
*
|
|
28
|
+
* It exists to be the worked example of a `dialog()` describing a CALL rather
|
|
29
|
+
* than a form. Every other flow template gates tools and moves on tool results;
|
|
30
|
+
* this one also needs the things that only happen when no tool is running — a
|
|
31
|
+
* caller who has gone quiet, a phase that must not be interrupted, a
|
|
32
|
+
* verification step that has to give up on its own — and all of those arrive
|
|
33
|
+
* through the one field below.
|
|
34
|
+
*
|
|
35
|
+
* Read `call.ts` first: it is the whole template. `shared.ts` is the rate card,
|
|
36
|
+
* the fleet and the session slot, and it is deliberately boring. Two smaller
|
|
37
|
+
* files carry what is NOT a fact about one call: `yard.ts` is the depot's own
|
|
38
|
+
* board, which every session shares and which a keyed lock is what keeps
|
|
39
|
+
* honest, and `events.ts` is the desk's log of the two outcomes no tool sees.
|
|
40
|
+
*/
|
|
41
|
+
export default agent({
|
|
42
|
+
name: "Roadside Assist",
|
|
43
|
+
|
|
44
|
+
// No provider spread: pipeline mode is the default and every stage is filled
|
|
45
|
+
// from the all-AssemblyAI pipeline at parse time.
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* **This is what wires the dialog to the session, and it is not a
|
|
49
|
+
* formality.** Without this line `roadsideCall` still gates its tools and
|
|
50
|
+
* still moves on `send` — and none of the five things this template is about
|
|
51
|
+
* would happen: `@session.timed-out` and `@user-transcript.committed` would
|
|
52
|
+
* reach nothing, the two `timeout` deadlines would never be armed, the active
|
|
53
|
+
* state's `instruction` would reach the model only on turns that happened to
|
|
54
|
+
* call a tool, and `bargeIn`, `toolChoice` and `temperature` would be
|
|
55
|
+
* declarations nothing read.
|
|
56
|
+
*
|
|
57
|
+
* The three knobs are a PIPELINE property. On either speech-to-speech
|
|
58
|
+
* transport the service owns turn-taking and assembles its own requests, so
|
|
59
|
+
* the runtime warns rather than pretending; the instruction, the deadlines
|
|
60
|
+
* and the session events work on every transport.
|
|
61
|
+
*/
|
|
62
|
+
dialogs: DIALOGS,
|
|
63
|
+
|
|
64
|
+
telephony: PHONE_LINE,
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* The desk's own record of what happened, for the two outcomes no tool sees.
|
|
68
|
+
*
|
|
69
|
+
* The pairing with `dialogs` above is the point: `@session.timed-out` MOVES
|
|
70
|
+
* the dialog to `abandoned`, and this WRITES the line saying so. A handler
|
|
71
|
+
* cannot change what the agent does — that is what keeps the event stream a
|
|
72
|
+
* log rather than a second control path — and a transition writes nothing to
|
|
73
|
+
* the slot, so a call that ends badly needs both. See `events.ts`.
|
|
74
|
+
*/
|
|
75
|
+
events: DESK_EVENTS,
|
|
76
|
+
|
|
77
|
+
// No `syncState` and no `client.tsx`: what a caller of this line can see is
|
|
78
|
+
// the phone. The state worth rendering would be the POSITION rather than the
|
|
79
|
+
// slot, and `roadsideCall.projection((at) => at)` is how a custom chrome
|
|
80
|
+
// would take it — see `dispatch-center` for a template that does.
|
|
81
|
+
|
|
82
|
+
greeting:
|
|
83
|
+
"Roadside assistance, you've reached the dispatch desk. First things first — are you " +
|
|
84
|
+
"somewhere safe, out of traffic? And whereabouts are you?",
|
|
85
|
+
});
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import type { AnyDialog, DialogBargeIn, DialogTimeoutSpec } from "@alexkroman1/aai";
|
|
2
|
+
import { dialog } from "@alexkroman1/aai";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Where a roadside call IS, as a dialog — and the one place in this template
|
|
6
|
+
* where the conversation itself is the subject.
|
|
7
|
+
*
|
|
8
|
+
* `shared.ts` holds the vehicle, the policy and the truck. None of those is a
|
|
9
|
+
* position: a caller can be covered and unlocated, or located and unverified,
|
|
10
|
+
* and asking the data which of those is true is how a call ends up asking for
|
|
11
|
+
* the policy number twice. What a position says is which of the four things
|
|
12
|
+
* this desk does is in front of the agent right now.
|
|
13
|
+
*
|
|
14
|
+
* Five phases, and each one is here because a real roadside call needs
|
|
15
|
+
* something from the SDK that a prompt cannot carry:
|
|
16
|
+
*
|
|
17
|
+
* | state | what it needs | what carries it |
|
|
18
|
+
* | --- | --- | --- |
|
|
19
|
+
* | `onCall.locating` | a caller who has gone quiet gets re-prompted, and a talkative one does not | `timeout` + a self transition on `@user-transcript.committed` |
|
|
20
|
+
* | `onCall.quiet` | the re-prompt is a different instruction, not a louder one | `instruction` |
|
|
21
|
+
* | `onCall.verifying` | do not invent a policy, and give up after two minutes | `temperature` + `timeout` |
|
|
22
|
+
* | `onCall.disclosure` | the fee disclosure is delivered IN FULL | `bargeIn: "off"` |
|
|
23
|
+
* | `onCall.dispatching` | do not promise a truck without sending one | `toolChoice` |
|
|
24
|
+
* | `abandoned` | nothing acts on a call whose caller is gone | `final: true` |
|
|
25
|
+
*
|
|
26
|
+
* All six of those reach a session only because `agent({ dialogs })` lists this
|
|
27
|
+
* dialog — see {@link DIALOGS}. An undeclared dialog still gates its tools and
|
|
28
|
+
* still moves on `send`; what it does not get is a clock, a session event, or a
|
|
29
|
+
* knob, because every one of those happens when no tool is running.
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
// ─── The two deadlines ───────────────────────────────────────────────────────
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The silence ladder's first rung.
|
|
36
|
+
*
|
|
37
|
+
* The clock runs from the dialog's last MOVE, and `onCall.locating` declares a
|
|
38
|
+
* self transition on `@user-transcript.committed` — so every committed turn is
|
|
39
|
+
* a move, re-arms this window, and only real silence ever reaches it. That is
|
|
40
|
+
* what makes the number a SILENCE budget rather than a call budget: a caller
|
|
41
|
+
* who is talking us through what happened can take as long as they like.
|
|
42
|
+
*
|
|
43
|
+
* Twelve seconds is chosen against what restarts it. A COMMITTED turn is the
|
|
44
|
+
* event, not a partial, so a caller in the middle of one long sentence can
|
|
45
|
+
* reach this deadline while still speaking — which is exactly why `QUIET` leads
|
|
46
|
+
* to a nudge rather than to anything irreversible.
|
|
47
|
+
*/
|
|
48
|
+
const SILENCE_LADDER: DialogTimeoutSpec = { afterMs: 12_000, send: "QUIET" };
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* The verification deadline — and the shape the ladder above is NOT.
|
|
52
|
+
*
|
|
53
|
+
* `onCall.verifying` declares no transition on anything the caller says, so
|
|
54
|
+
* nothing the caller says extends this window: it is wall clock from the moment
|
|
55
|
+
* the phase began. That is the point. A caller who cannot find their card will
|
|
56
|
+
* talk the whole two minutes, and a deadline they could extend by talking is a
|
|
57
|
+
* deadline that never fires on the only call that needs it.
|
|
58
|
+
*
|
|
59
|
+
* What it fires is `UNVERIFIED`, which moves the call ON to the disclosure at
|
|
60
|
+
* the non-member rate rather than ending it. A stranded caller still needs a
|
|
61
|
+
* truck; what they have run out of is the discount.
|
|
62
|
+
*/
|
|
63
|
+
const VERIFICATION_DEADLINE: DialogTimeoutSpec = { afterMs: 120_000, send: "UNVERIFIED" };
|
|
64
|
+
|
|
65
|
+
// ─── The one knob that is a legal requirement ────────────────────────────────
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* The agent finishes the disclosure, whatever the caller does over the top of
|
|
69
|
+
* it.
|
|
70
|
+
*
|
|
71
|
+
* `"off"` is an unreachable word threshold rather than a deaf agent: the caller
|
|
72
|
+
* is still transcribed, still opens the speaking edge, and is still answered as
|
|
73
|
+
* soon as the disclosure ends. What it removes is the barge-in — the agent will
|
|
74
|
+
* not stop mid-sentence — and this is the case where that is obviously right
|
|
75
|
+
* rather than a preference. A fee disclosure that was cut off after nine words
|
|
76
|
+
* was not read, and "the caller interrupted" is not a defence anyone has ever
|
|
77
|
+
* won with.
|
|
78
|
+
*
|
|
79
|
+
* A named constant because the argument is the interesting part; inline it is
|
|
80
|
+
* two characters that read like a whim.
|
|
81
|
+
*/
|
|
82
|
+
const UNINTERRUPTIBLE: DialogBargeIn = "off";
|
|
83
|
+
|
|
84
|
+
// ─── The call ────────────────────────────────────────────────────────────────
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* `as const` is load-bearing: the event union is synthesized from the `on` keys,
|
|
88
|
+
* so widening them to `string` gives every `send` below nothing to check
|
|
89
|
+
* against. It is also why this is not annotated `DialogSpec` — an annotation
|
|
90
|
+
* would widen those keys to `string` and take the union with it. A spec that
|
|
91
|
+
* wants the shape reads it the other way, walking the exported literal AS
|
|
92
|
+
* `DialogStateSpec`; `agent.test.ts` does exactly that, which is how the knob
|
|
93
|
+
* audit below reaches `abandoned` and any state added after it.
|
|
94
|
+
*
|
|
95
|
+
* **The hang-up is declared ONCE, on the parent.** Being in a state is being in
|
|
96
|
+
* all of them, so `@session.timed-out` on `onCall` reaches all five phases —
|
|
97
|
+
* where the same line repeated five times is five chances for the sixth phase
|
|
98
|
+
* to be added without it. The contrast with `@user-transcript.committed` is the
|
|
99
|
+
* lesson: that one is declared on ONE state, because only the silence ladder
|
|
100
|
+
* cares that the caller said something, and hoisting it would silently turn the
|
|
101
|
+
* verification deadline into one a talkative caller can extend forever.
|
|
102
|
+
*/
|
|
103
|
+
export const CALL_SPEC = {
|
|
104
|
+
initial: "onCall",
|
|
105
|
+
states: {
|
|
106
|
+
onCall: {
|
|
107
|
+
initial: "locating",
|
|
108
|
+
on: { "@session.timed-out": "abandoned" },
|
|
109
|
+
states: {
|
|
110
|
+
locating: {
|
|
111
|
+
instruction:
|
|
112
|
+
"You do not know where this caller is or what they are driving. Get both, plus " +
|
|
113
|
+
"what went wrong, and whether they are somewhere they can safely wait — then call " +
|
|
114
|
+
"report_location. If they are in a live traffic lane or hurt, that comes first: " +
|
|
115
|
+
"tell them to call emergency services and stay out of the roadway.",
|
|
116
|
+
// A stranded caller correcting an address must be able to cut in on
|
|
117
|
+
// the first word, so this phase is MORE interruptible than the
|
|
118
|
+
// agent's own default. It costs the occasional false start on a
|
|
119
|
+
// single-word STT partial, which on a phase made of short questions
|
|
120
|
+
// is the cheaper of the two mistakes.
|
|
121
|
+
bargeIn: { minWords: 1 },
|
|
122
|
+
timeout: SILENCE_LADDER,
|
|
123
|
+
on: {
|
|
124
|
+
// A self transition, and the whole silence ladder rests on it: it
|
|
125
|
+
// is a MOVE, so it re-arms the deadline above. Nothing else here
|
|
126
|
+
// extends it.
|
|
127
|
+
"@user-transcript.committed": "locating",
|
|
128
|
+
QUIET: "quiet",
|
|
129
|
+
LOCATED: "verifying",
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
quiet: {
|
|
133
|
+
instruction:
|
|
134
|
+
"The caller has said nothing for a while. They may have put the phone down, be " +
|
|
135
|
+
"standing outside the car, or be on a bad line. Say one short sentence — ask if " +
|
|
136
|
+
"they are still there and whether they are safe — and then wait. Do not repeat " +
|
|
137
|
+
"the whole question, and do not start over.",
|
|
138
|
+
on: {
|
|
139
|
+
// Hearing anything at all puts the call back on the ladder's first
|
|
140
|
+
// rung, which re-arms the window from that moment.
|
|
141
|
+
"@user-transcript.committed": "locating",
|
|
142
|
+
LOCATED: "verifying",
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
verifying: {
|
|
146
|
+
instruction:
|
|
147
|
+
"You know where they are and what is wrong. Now find out what they are covered " +
|
|
148
|
+
"for: ask for the policy number on their card, or the phone number the plan is " +
|
|
149
|
+
"under, and call lookup_coverage with it. Never tell a caller they are covered " +
|
|
150
|
+
"because it sounds likely — the lookup is the only thing that knows.",
|
|
151
|
+
// Reading a policy number back and matching it against what the
|
|
152
|
+
// caller said is transcription, not composition. The low temperature
|
|
153
|
+
// is aimed at the one failure this phase has: a model that smooths
|
|
154
|
+
// `RS-8802` into `RS-8002` because it reads better.
|
|
155
|
+
temperature: 0.2,
|
|
156
|
+
timeout: VERIFICATION_DEADLINE,
|
|
157
|
+
on: { VERIFIED: "disclosure", UNVERIFIED: "disclosure" },
|
|
158
|
+
},
|
|
159
|
+
disclosure: {
|
|
160
|
+
instruction:
|
|
161
|
+
"Before any truck moves, the caller has to hear the service-fee disclosure. Call " +
|
|
162
|
+
"service_disclosure, read back exactly what it gives you — all of it, in those " +
|
|
163
|
+
"words, without summarising — and then ask whether they want to go ahead. Call " +
|
|
164
|
+
"acknowledge_disclosure with what they answered.",
|
|
165
|
+
bargeIn: UNINTERRUPTIBLE,
|
|
166
|
+
on: { DISCLOSED: "dispatching" },
|
|
167
|
+
},
|
|
168
|
+
dispatching: {
|
|
169
|
+
instruction:
|
|
170
|
+
"They have heard the fee and agreed to it. Send the truck with dispatch_truck, " +
|
|
171
|
+
"then tell them the callsign, the ETA and the total. If they ask again later, " +
|
|
172
|
+
"give them the same job and the same number.",
|
|
173
|
+
// The failure this pin exists for is an agent that says "I'm getting
|
|
174
|
+
// someone out to you" and calls nothing. Safe HERE and nowhere else
|
|
175
|
+
// in this dialog: `dispatch_truck` needs nothing the caller has not
|
|
176
|
+
// already said, and it answers with the job it already created rather
|
|
177
|
+
// than rolling a second truck — so a pinned step that fires again on
|
|
178
|
+
// a later turn costs one idempotent call and changes nothing. A pin
|
|
179
|
+
// on `verifying`, where the tool needs a policy number the caller may
|
|
180
|
+
// not have given yet, would force the model to invent one.
|
|
181
|
+
toolChoice: { type: "tool", toolName: "dispatch_truck" },
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
abandoned: {
|
|
186
|
+
final: true,
|
|
187
|
+
instruction:
|
|
188
|
+
"The caller is gone. Do nothing further on this call — no dispatch, no lookup, no " +
|
|
189
|
+
"callback promise.",
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
} as const;
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* The call's position, on its own slot key beside `roadsideSlot`.
|
|
196
|
+
*
|
|
197
|
+
* A final state delivers no events, so there is no way out of `abandoned` and
|
|
198
|
+
* no `on` map pretending there is: a session that reaches it refuses every
|
|
199
|
+
* gated tool for the rest of its life, which is the guarantee that a truck
|
|
200
|
+
* cannot be dispatched to a caller who hung up two minutes ago. Starting over
|
|
201
|
+
* is `roadsideCall.reset`, not an event.
|
|
202
|
+
*/
|
|
203
|
+
export const roadsideCall = dialog("call", CALL_SPEC);
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* What `agent({ dialogs })` is handed.
|
|
207
|
+
*
|
|
208
|
+
* Typed as `readonly AnyDialog[]` rather than left to inference, because that
|
|
209
|
+
* erasure is the reason the field can hold more than one dialog at all: two
|
|
210
|
+
* dialogs have different event unions by construction, so the only type an
|
|
211
|
+
* array of them has is the one with `E` erased. Writing it here is also where a
|
|
212
|
+
* second dialog would be added, which is a better place to find out than the
|
|
213
|
+
* `agent()` call.
|
|
214
|
+
*/
|
|
215
|
+
export const DIALOGS: readonly AnyDialog[] = [roadsideCall];
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Both rungs of the silence ladder, for the one tool that ends it.
|
|
219
|
+
*
|
|
220
|
+
* `report_location` is legal in `onCall.locating` and in `onCall.quiet`: a
|
|
221
|
+
* caller who finally speaks after the nudge is giving us the address, and a
|
|
222
|
+
* gate that refused them there would be refusing the call's whole purpose one
|
|
223
|
+
* beat after asking for it.
|
|
224
|
+
*/
|
|
225
|
+
export const LOCATING = ["onCall.locating", "onCall.quiet"] as const;
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Every state a caller is still on the line in — i.e. everything but the final
|
|
229
|
+
* one.
|
|
230
|
+
*
|
|
231
|
+
* `"onCall"` matches all five of its children, which is what makes a read legal
|
|
232
|
+
* throughout the call and refused the moment it ends. The same shape as
|
|
233
|
+
* `retail`'s `BEFORE_TRANSFER`, and the same reason: "needs no phase in
|
|
234
|
+
* particular" and "is still legal after the caller is gone" were never the same
|
|
235
|
+
* claim.
|
|
236
|
+
*/
|
|
237
|
+
export const ON_THE_LINE = "onCall";
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
SessionEventContext,
|
|
3
|
+
SessionEventHandler,
|
|
4
|
+
SessionEventHandlers,
|
|
5
|
+
SessionEventType,
|
|
6
|
+
} from "@alexkroman1/aai";
|
|
7
|
+
import { roadsideSlot } from "./shared.ts";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The two things that happen to a roadside call which no tool can write down.
|
|
11
|
+
*
|
|
12
|
+
* The desk's log is the record of what happened on this call, and every line in
|
|
13
|
+
* it so far was written by a tool — which means the log has nothing to say about
|
|
14
|
+
* the two outcomes that involve no tool at all: the caller hanging up, and the
|
|
15
|
+
* line itself failing. Both arrive as SESSION EVENTS, and an `events` handler is
|
|
16
|
+
* how an agent observes its own stream.
|
|
17
|
+
*
|
|
18
|
+
* This is the second half of what `agent({ dialogs })` already does with
|
|
19
|
+
* `@session.timed-out`. The dialog MOVES on a hang-up (to the final `abandoned`
|
|
20
|
+
* state, which refuses every tool for the rest of the session); a handler
|
|
21
|
+
* RECORDS it. Neither can do the other's job — a handler cannot change what the
|
|
22
|
+
* agent says or does, by design, and a dialog transition writes nothing to the
|
|
23
|
+
* slot — and the split is why both exist for one event.
|
|
24
|
+
*
|
|
25
|
+
* Three properties of a handler that this file depends on, all the SDK's:
|
|
26
|
+
* a handler is OBSERVE-ONLY, a throw in one is non-fatal (a failing audit hook
|
|
27
|
+
* must not end a phone call), and delivery is at-least-once. Nothing here is
|
|
28
|
+
* non-idempotent — a duplicate line in a call log is not a duplicate truck —
|
|
29
|
+
* so the last one costs nothing to accept.
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Every session event the desk writes a line for.
|
|
34
|
+
*
|
|
35
|
+
* `satisfies readonly SessionEventType[]` rather than a bare `as const`: a name
|
|
36
|
+
* that is not a wire event type fails HERE, at three characters of type
|
|
37
|
+
* annotation, instead of becoming a handler key the runtime never calls. That
|
|
38
|
+
* failure is otherwise invisible — an unmatched key is not an error, it is a
|
|
39
|
+
* hook that quietly never fires — and `agent.test.ts` pins the roster against
|
|
40
|
+
* what {@link DESK_EVENTS} actually declares.
|
|
41
|
+
*/
|
|
42
|
+
export const LOGGED_EVENTS = [
|
|
43
|
+
"session.timed-out",
|
|
44
|
+
"error.reported",
|
|
45
|
+
] as const satisfies readonly SessionEventType[];
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* One line in the desk's own record of the call.
|
|
49
|
+
*
|
|
50
|
+
* Takes {@link SessionEventContext} — which is what a handler is handed, and is
|
|
51
|
+
* NOT a `ToolContext`: there is no `generate`, no `delegate`, no `send`, and
|
|
52
|
+
* nothing here could speak to the caller if it wanted to. What it does carry is
|
|
53
|
+
* `slots`, which is all a slot write needs.
|
|
54
|
+
*/
|
|
55
|
+
function note(ctx: SessionEventContext, line: string): void {
|
|
56
|
+
roadsideSlot.update(ctx, (state) => {
|
|
57
|
+
state.log.push(line);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* The caller is gone.
|
|
63
|
+
*
|
|
64
|
+
* Typed with the WIDE {@link SessionEventHandler} because it reads nothing off
|
|
65
|
+
* the event — a handler that accepts any session event is assignable to any
|
|
66
|
+
* key, which is the contravariance a mapped handler table gives for free. Its
|
|
67
|
+
* neighbour below is written inline for the opposite reason: it reads `code`
|
|
68
|
+
* and `message`, so it needs the narrowing the key provides.
|
|
69
|
+
*/
|
|
70
|
+
const noteHangUp: SessionEventHandler = (_event, ctx) => {
|
|
71
|
+
note(ctx, "Caller gone — no dispatch, no lookup, no callback promised.");
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* What `agent({ events })` is handed.
|
|
76
|
+
*
|
|
77
|
+
* Annotated rather than inferred, and the annotation is what does the work:
|
|
78
|
+
* the mapped type narrows each handler's `event` to the one wire event its key
|
|
79
|
+
* names, so the `error.reported` handler below reads `code` and `message`
|
|
80
|
+
* without a guard and could not read a field belonging to another event.
|
|
81
|
+
*/
|
|
82
|
+
export const DESK_EVENTS: SessionEventHandlers = {
|
|
83
|
+
"session.timed-out": noteHangUp,
|
|
84
|
+
// Not always fatal — a turn-level STT failure is one the session survives —
|
|
85
|
+
// so the line says which it was. A caller who was cut off mid-disclosure and
|
|
86
|
+
// one whose transcription hiccuped are the same silence on a recording and
|
|
87
|
+
// very different things to answer a complaint with.
|
|
88
|
+
"error.reported": (event, ctx) => {
|
|
89
|
+
const how = event.fatal ? "call dropped" : "recovered";
|
|
90
|
+
note(ctx, `Line trouble (${event.code}, ${how}): ${event.message}`);
|
|
91
|
+
},
|
|
92
|
+
};
|