@alexkroman1/aai-cli 15.1.0 → 16.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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,95 @@
|
|
|
1
|
+
import { toolFailure } from "@alexkroman1/aai";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { digitsOf, normalizeCode, speakCode, spokenDate } from "../records.ts";
|
|
4
|
+
import { hotelSlot, note } from "../shared.ts";
|
|
5
|
+
|
|
6
|
+
/** Failed lookups before a human takes over — their `_attempts >= 3`. */
|
|
7
|
+
export const MAX_VERIFY_ATTEMPTS = 3;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Verify the caller against a booking — their `VerifyBookingTask`, whose two
|
|
11
|
+
* tools were `lookup_by_code` and `lookup_by_card` and whose instructions named
|
|
12
|
+
* the ONLY two paths: last name plus code, or last name plus the card's last
|
|
13
|
+
* four. Email is not a verification field and is not accepted here.
|
|
14
|
+
*
|
|
15
|
+
* Success fills `verifiedCode`, which every booking tool reads through
|
|
16
|
+
* `requireVerified` — so the desk verifies once per call, and a tool that
|
|
17
|
+
* needs a verified booking refuses with the sentence naming this one. Their
|
|
18
|
+
* three-strike rule is the counter: past it the result says to stop trying and
|
|
19
|
+
* record a `verification_help` followup for a manager.
|
|
20
|
+
*/
|
|
21
|
+
export default hotelSlot.updateTool({
|
|
22
|
+
description:
|
|
23
|
+
"Verify the caller against their room booking: last name plus confirmation code (HTL-XXXX), " +
|
|
24
|
+
"or last name plus the last four digits of the card on file. Call it BEFORE any lookup, " +
|
|
25
|
+
"change, dispute or cancellation - never vet these details in conversation first, and never " +
|
|
26
|
+
"ask for an email to verify. Cancelled bookings verify only through reinstate_booking.",
|
|
27
|
+
inputSchema: z.object({
|
|
28
|
+
lastName: z.string().min(1),
|
|
29
|
+
confirmationCode: z
|
|
30
|
+
.string()
|
|
31
|
+
.optional()
|
|
32
|
+
.describe("As the caller read it, e.g. 'H T L dash A B 1 2'"),
|
|
33
|
+
cardLast4: z.string().optional().describe("The last four digits of the card on file"),
|
|
34
|
+
}),
|
|
35
|
+
execute({ lastName, confirmationCode, cardLast4 }, hotel) {
|
|
36
|
+
const wantedName = lastName.trim().toLowerCase();
|
|
37
|
+
const code = confirmationCode === undefined ? null : normalizeCode(confirmationCode);
|
|
38
|
+
const digits = cardLast4 === undefined ? null : digitsOf(cardLast4);
|
|
39
|
+
if (code === null && digits === null) {
|
|
40
|
+
return toolFailure(
|
|
41
|
+
"verification needs the last name PLUS a confirmation code or the card's last four digits",
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
if (digits !== null && digits.length !== 4) {
|
|
45
|
+
return toolFailure(
|
|
46
|
+
"the last 4 digits should be exactly 4 digits - ask the caller to repeat them",
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
const match = hotel.bookings.find(
|
|
50
|
+
(b) =>
|
|
51
|
+
b.status === "confirmed" &&
|
|
52
|
+
b.lastName.toLowerCase() === wantedName &&
|
|
53
|
+
(code === null || normalizeCode(b.code) === code) &&
|
|
54
|
+
(digits === null || b.cardLast4 === digits),
|
|
55
|
+
);
|
|
56
|
+
if (match === undefined) {
|
|
57
|
+
hotel.verifyAttempts += 1;
|
|
58
|
+
const cancelled = hotel.bookings.some(
|
|
59
|
+
(b) =>
|
|
60
|
+
b.status === "cancelled" &&
|
|
61
|
+
b.lastName.toLowerCase() === wantedName &&
|
|
62
|
+
(code === null || normalizeCode(b.code) === code),
|
|
63
|
+
);
|
|
64
|
+
if (hotel.verifyAttempts >= MAX_VERIFY_ATTEMPTS) {
|
|
65
|
+
return toolFailure(
|
|
66
|
+
`verification failed ${hotel.verifyAttempts} times - don't keep trying. Apologize, then call ` +
|
|
67
|
+
'record_followup with kind "verification_help" so a manager can follow up.',
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
if (cancelled) {
|
|
71
|
+
return toolFailure(
|
|
72
|
+
"that booking was already cancelled. Ask if the caller meant a different reservation - or, " +
|
|
73
|
+
"if they want it back, reinstate_booking is the tool that verifies against a cancelled one.",
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
return toolFailure(
|
|
77
|
+
`No confirmed booking found via ${code === null ? "card" : "code"} for that last name. Politely ask the ` +
|
|
78
|
+
`caller to repeat, or offer the other path (${code === null ? "the confirmation code" : "the card's last four"}). ` +
|
|
79
|
+
`Attempt ${hotel.verifyAttempts} of ${MAX_VERIFY_ATTEMPTS}.`,
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
hotel.verifiedCode = match.code;
|
|
83
|
+
hotel.verifyAttempts = 0;
|
|
84
|
+
note(hotel, `Verified ${match.code} (${match.lastName})`);
|
|
85
|
+
return {
|
|
86
|
+
verified: true,
|
|
87
|
+
code: match.code,
|
|
88
|
+
spokenCode: speakCode(match.code),
|
|
89
|
+
guest: `${match.firstName} ${match.lastName}`,
|
|
90
|
+
checkIn: spokenDate(match.checkIn),
|
|
91
|
+
checkOut: spokenDate(match.checkOut),
|
|
92
|
+
next: "The caller is verified for this call. Continue with what they asked for - the booking tools no longer need to verify.",
|
|
93
|
+
};
|
|
94
|
+
},
|
|
95
|
+
});
|
|
@@ -34,7 +34,7 @@ import { type EvalTurn, toolResultIn } from "@alexkroman1/aai-runtime/eval";
|
|
|
34
34
|
import { describeEval } from "@alexkroman1/aai-runtime/eval/vitest";
|
|
35
35
|
import { expect } from "vitest";
|
|
36
36
|
import { z } from "zod";
|
|
37
|
-
import { DEFAULT_GAME_STATE } from "./shared.ts";
|
|
37
|
+
import { DEFAULT_GAME_STATE, rankFor } from "./shared.ts";
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
40
|
* What each of the three tools this file drives answers, off the wire.
|
|
@@ -47,9 +47,11 @@ import { DEFAULT_GAME_STATE } from "./shared.ts";
|
|
|
47
47
|
*/
|
|
48
48
|
const Carried = z.object({ inventory: z.array(z.string()) });
|
|
49
49
|
const Restarted = z.object({ restarted: z.boolean() });
|
|
50
|
+
const Scored = z.object({ score: z.number(), rank: z.string() });
|
|
50
51
|
const Status = z.object({
|
|
51
52
|
inventory: z.array(z.string()),
|
|
52
53
|
score: z.number(),
|
|
54
|
+
rank: z.string(),
|
|
53
55
|
moves: z.number(),
|
|
54
56
|
currentRoom: z.string(),
|
|
55
57
|
});
|
|
@@ -130,6 +132,36 @@ describeEval(agentDef, (test) => {
|
|
|
130
132
|
},
|
|
131
133
|
);
|
|
132
134
|
|
|
135
|
+
test(
|
|
136
|
+
"the rank the score earned is still the player's rank a turn later",
|
|
137
|
+
async ({ session }) => {
|
|
138
|
+
const scored = await session.say(
|
|
139
|
+
"I set the golden chalice down on the stone pedestal. That must be worth something.",
|
|
140
|
+
);
|
|
141
|
+
const earned = answerOf(scored, "game_state_score", Scored);
|
|
142
|
+
// Whatever the model awarded — a live run picks its own number — the rank
|
|
143
|
+
// that came back is the one the ladder says that score earns. The tool
|
|
144
|
+
// computes it from `rankFor` because the slot's `after` hook has not run
|
|
145
|
+
// when its result is built; if it read `game.rank` instead, this is the
|
|
146
|
+
// assertion that would catch the promotion arriving one call late.
|
|
147
|
+
expect(earned.rank).toBe(rankFor(earned.score));
|
|
148
|
+
|
|
149
|
+
// And the SECOND turn is the only place the hook's write can be seen: the
|
|
150
|
+
// field nothing assigns is read back off a later turn's state.
|
|
151
|
+
const later = answerOf(await session.say("What is my score?"), "game_state_get", Status);
|
|
152
|
+
expect(later.score).toBe(earned.score);
|
|
153
|
+
expect(later.rank).toBe(earned.rank);
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
stubReply: [
|
|
157
|
+
{ tool: "game_state_score", args: { value: 30 } },
|
|
158
|
+
"The chalice settles onto the pedestal with a satisfying weight.",
|
|
159
|
+
{ tool: "game_state_get" },
|
|
160
|
+
"Thirty points, which makes you an Amateur Adventurer.",
|
|
161
|
+
],
|
|
162
|
+
},
|
|
163
|
+
);
|
|
164
|
+
|
|
133
165
|
test(
|
|
134
166
|
"a restart is narrated, not merely recorded",
|
|
135
167
|
async ({ session }) => {
|
|
@@ -1,13 +1,39 @@
|
|
|
1
1
|
/** The def a DEPLOYED agent runs: authored, plus what `tools/` declares. */
|
|
2
2
|
import agentDef from "virtual:aai/agent";
|
|
3
|
-
import {
|
|
3
|
+
import { createSeededRandom, type RandomSource, type SessionEventContext } from "@alexkroman1/aai";
|
|
4
|
+
import { createToolContext, parseToolInput, toolOf, toolRunner } from "@alexkroman1/aai/testing";
|
|
5
|
+
import { isToolFailure } from "@alexkroman1/aai/utils";
|
|
4
6
|
import { describe, expect, test } from "vitest";
|
|
5
7
|
|
|
6
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
DEFAULT_GAME_STATE,
|
|
10
|
+
gameSlot,
|
|
11
|
+
gameStatus,
|
|
12
|
+
MAX_HISTORY,
|
|
13
|
+
REPORTED_HISTORY,
|
|
14
|
+
rankFor,
|
|
15
|
+
SCAVENGER_FLAG,
|
|
16
|
+
statusLine,
|
|
17
|
+
} from "./shared.ts";
|
|
7
18
|
|
|
8
19
|
/** A tool by the name the model calls it by, bound to this agent. */
|
|
9
20
|
const run = toolRunner(agentDef);
|
|
10
21
|
|
|
22
|
+
/**
|
|
23
|
+
* What a tool answered, or a throw naming the refusal.
|
|
24
|
+
*
|
|
25
|
+
* NOT `expectToolOk`: that one unwraps a `dialog()` envelope (`{ result, state,
|
|
26
|
+
* done }`) and throws on a plain tool's own return value, so it does not fit an
|
|
27
|
+
* agent with no dialog. What carries over is the reason it exists — a cast
|
|
28
|
+
* reads `undefined` off a `ToolFailure` and dies three assertions later, with
|
|
29
|
+
* the sentence the tool wrote thrown away. `game_state_drop` can refuse now, so
|
|
30
|
+
* every unwrap in this file goes through the guard rather than through `as`.
|
|
31
|
+
*/
|
|
32
|
+
const ok = <T>(result: unknown): T => {
|
|
33
|
+
if (isToolFailure(result)) throw new Error(`tool refused: ${result.error}`);
|
|
34
|
+
return result as T;
|
|
35
|
+
};
|
|
36
|
+
|
|
11
37
|
/**
|
|
12
38
|
* What the player said, delivered the way the RUNTIME delivers it.
|
|
13
39
|
*
|
|
@@ -16,17 +42,18 @@ const run = toolRunner(agentDef);
|
|
|
16
42
|
* than trusting the wiring: `moves` and `history` are now maintained by
|
|
17
43
|
* something the model never calls, so nothing else in this file would notice if
|
|
18
44
|
* the hook stopped running.
|
|
45
|
+
*
|
|
46
|
+
* `SessionEventContext`, not `ToolContext`, because that is what the runtime
|
|
47
|
+
* hands a hook: the session id, the env and the slots, and nothing that could
|
|
48
|
+
* speak. A `TestToolContext` satisfies it, so the same `ctx` drives the tools
|
|
49
|
+
* below.
|
|
19
50
|
*/
|
|
20
|
-
const say = (text: string, ctx:
|
|
51
|
+
const say = (text: string, ctx: SessionEventContext) =>
|
|
21
52
|
agentDef.events?.["user-transcript.committed"]?.(
|
|
22
53
|
{ type: "user-transcript.committed", text, meta: { id: "evt_1", at: 0 } },
|
|
23
54
|
ctx,
|
|
24
55
|
);
|
|
25
56
|
|
|
26
|
-
/** Each context owns its OWN slot store, which is what makes two playthroughs
|
|
27
|
-
* independent by construction. */
|
|
28
|
-
const makeCtx = () => createToolContext();
|
|
29
|
-
|
|
30
57
|
// ─── The frozen-vs-draft contract ────────────────────────────────────────────
|
|
31
58
|
//
|
|
32
59
|
// This whole block exists because the template shipped without it and two tools
|
|
@@ -38,37 +65,37 @@ const makeCtx = () => createToolContext();
|
|
|
38
65
|
|
|
39
66
|
describe("the mutating tools actually mutate", () => {
|
|
40
67
|
test("game_state_take adds to the inventory and does not double an item", async () => {
|
|
41
|
-
const ctx =
|
|
68
|
+
const ctx = createToolContext();
|
|
42
69
|
|
|
43
|
-
const first =
|
|
44
|
-
|
|
45
|
-
|
|
70
|
+
const first = ok<{ inventory: string[] }>(
|
|
71
|
+
await run("game_state_take", { value: "lantern" }, ctx),
|
|
72
|
+
);
|
|
46
73
|
expect(first.inventory).toEqual(["lantern"]);
|
|
47
74
|
// The stored value, not the one the body returned — a body handed a frozen
|
|
48
75
|
// value would have thrown, and a body handed a copy nothing stores would
|
|
49
76
|
// report success here and leave the slot empty.
|
|
50
77
|
expect(gameSlot.get(ctx).inventory).toEqual(["lantern"]);
|
|
51
78
|
|
|
52
|
-
const again =
|
|
53
|
-
|
|
54
|
-
|
|
79
|
+
const again = ok<{ inventory: string[] }>(
|
|
80
|
+
await run("game_state_take", { value: "lantern" }, ctx),
|
|
81
|
+
);
|
|
55
82
|
expect(again.inventory).toEqual(["lantern"]);
|
|
56
83
|
});
|
|
57
84
|
|
|
58
85
|
test("game_state_flag records a flag, and a second flag joins the first", async () => {
|
|
59
|
-
const ctx =
|
|
86
|
+
const ctx = createToolContext();
|
|
60
87
|
|
|
61
88
|
await run("game_state_flag", { value: "gate_opened" }, ctx);
|
|
62
|
-
const both =
|
|
63
|
-
|
|
64
|
-
|
|
89
|
+
const both = ok<{ flags: Record<string, boolean> }>(
|
|
90
|
+
await run("game_state_flag", { value: "rope_cut" }, ctx),
|
|
91
|
+
);
|
|
65
92
|
|
|
66
93
|
expect(both.flags).toEqual({ gate_opened: true, rope_cut: true });
|
|
67
94
|
expect(gameSlot.get(ctx).flags).toEqual({ gate_opened: true, rope_cut: true });
|
|
68
95
|
});
|
|
69
96
|
|
|
70
97
|
test("what a READ is handed is frozen, which is why the two above are updateTool", async () => {
|
|
71
|
-
const ctx =
|
|
98
|
+
const ctx = createToolContext();
|
|
72
99
|
await run("game_state_take", { value: "lantern" }, ctx);
|
|
73
100
|
|
|
74
101
|
const game = gameSlot.get(ctx);
|
|
@@ -82,28 +109,28 @@ describe("the mutating tools actually mutate", () => {
|
|
|
82
109
|
// ─── The rest of the eight ───────────────────────────────────────────────────
|
|
83
110
|
|
|
84
111
|
describe("the adventure's tools", () => {
|
|
85
|
-
test("drop removes an item and
|
|
86
|
-
const ctx =
|
|
112
|
+
test("drop removes an item, and refuses one the player never took", async () => {
|
|
113
|
+
const ctx = createToolContext();
|
|
87
114
|
await run("game_state_take", { value: "lantern" }, ctx);
|
|
88
115
|
await run("game_state_take", { value: "rope" }, ctx);
|
|
89
116
|
|
|
90
|
-
const dropped =
|
|
91
|
-
|
|
92
|
-
|
|
117
|
+
const dropped = ok<{ inventory: string[] }>(
|
|
118
|
+
await run("game_state_drop", { value: "lantern" }, ctx),
|
|
119
|
+
);
|
|
93
120
|
expect(dropped.inventory).toEqual(["rope"]);
|
|
94
121
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
};
|
|
98
|
-
expect(
|
|
122
|
+
// A `ToolFailure`, not a silent no-op reporting the unchanged inventory:
|
|
123
|
+
// the narrator is told the sentence rather than being left to diff a list.
|
|
124
|
+
const refused = await run("game_state_drop", { value: "sword" }, ctx);
|
|
125
|
+
expect(isToolFailure(refused) && refused.error).toMatch(/not carrying sword/);
|
|
126
|
+
expect(gameSlot.get(ctx).inventory).toEqual(["rope"]);
|
|
99
127
|
});
|
|
100
128
|
|
|
101
129
|
test("move sets the room and reports the turn count without touching it", async () => {
|
|
102
|
-
const ctx =
|
|
103
|
-
const moved =
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
};
|
|
130
|
+
const ctx = createToolContext();
|
|
131
|
+
const moved = ok<{ currentRoom: string; moves: number }>(
|
|
132
|
+
await run("game_state_move", { value: "Echo Chamber" }, ctx),
|
|
133
|
+
);
|
|
107
134
|
// `moves` is 0 because nobody has SAID anything — see `recordTurn`. It is
|
|
108
135
|
// still reported, because it is what the narrator wants back.
|
|
109
136
|
expect(moved).toEqual({ currentRoom: "Echo Chamber", moves: 0 });
|
|
@@ -111,14 +138,14 @@ describe("the adventure's tools", () => {
|
|
|
111
138
|
});
|
|
112
139
|
|
|
113
140
|
test("score accumulates rather than replacing", async () => {
|
|
114
|
-
const ctx =
|
|
141
|
+
const ctx = createToolContext();
|
|
115
142
|
await run("game_state_score", { value: 10 }, ctx);
|
|
116
|
-
const total = (await run("game_state_score", { value: 5 }, ctx))
|
|
143
|
+
const total = ok<{ score: number }>(await run("game_state_score", { value: 5 }, ctx));
|
|
117
144
|
expect(total.score).toBe(15);
|
|
118
145
|
});
|
|
119
146
|
|
|
120
147
|
test("what the player SAYS logs the command and counts the turn", async () => {
|
|
121
|
-
const ctx =
|
|
148
|
+
const ctx = createToolContext();
|
|
122
149
|
for (let i = 1; i <= REPORTED_HISTORY + 2; i++) say(`command ${i}`, ctx);
|
|
123
150
|
say("look", ctx);
|
|
124
151
|
|
|
@@ -128,16 +155,15 @@ describe("the adventure's tools", () => {
|
|
|
128
155
|
|
|
129
156
|
// And the narrator reads it back through the ordinary state tool — the hook
|
|
130
157
|
// writes, the model reads, and the two never have to agree about who counts.
|
|
131
|
-
const read =
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
};
|
|
158
|
+
const read = ok<{ moves: number; recentHistory: string[] }>(
|
|
159
|
+
await run("game_state_get", {}, ctx),
|
|
160
|
+
);
|
|
135
161
|
expect(read.moves).toBe(REPORTED_HISTORY + 3);
|
|
136
162
|
expect(read.recentHistory).toHaveLength(REPORTED_HISTORY);
|
|
137
163
|
});
|
|
138
164
|
|
|
139
165
|
test("a turn is counted once, even when the narrator also moves the player", async () => {
|
|
140
|
-
const ctx =
|
|
166
|
+
const ctx = createToolContext();
|
|
141
167
|
say("go north", ctx);
|
|
142
168
|
await run("game_state_move", { value: "Echo Chamber" }, ctx);
|
|
143
169
|
|
|
@@ -150,7 +176,7 @@ describe("the adventure's tools", () => {
|
|
|
150
176
|
});
|
|
151
177
|
|
|
152
178
|
test("the history is capped, so a long playthrough does not grow without bound", () => {
|
|
153
|
-
const ctx =
|
|
179
|
+
const ctx = createToolContext();
|
|
154
180
|
for (let i = 0; i < MAX_HISTORY + 10; i++) say(`command ${i}`, ctx);
|
|
155
181
|
|
|
156
182
|
const game = gameSlot.get(ctx);
|
|
@@ -161,7 +187,7 @@ describe("the adventure's tools", () => {
|
|
|
161
187
|
});
|
|
162
188
|
|
|
163
189
|
test("get reports the whole board, with the history trimmed to what a narrator reads", async () => {
|
|
164
|
-
const ctx =
|
|
190
|
+
const ctx = createToolContext();
|
|
165
191
|
await run("game_state_take", { value: "lantern" }, ctx);
|
|
166
192
|
await run("game_state_flag", { value: "gate_opened" }, ctx);
|
|
167
193
|
await run("game_state_move", { value: "Echo Chamber" }, ctx);
|
|
@@ -170,27 +196,156 @@ describe("the adventure's tools", () => {
|
|
|
170
196
|
|
|
171
197
|
expect(await run("game_state_get", ctx)).toEqual({
|
|
172
198
|
currentRoom: "Echo Chamber",
|
|
173
|
-
inventory: ["lantern"],
|
|
174
199
|
score: 7,
|
|
200
|
+
rank: "Beginner",
|
|
175
201
|
moves: REPORTED_HISTORY + 3,
|
|
202
|
+
inventory: ["lantern"],
|
|
176
203
|
flags: { gate_opened: true },
|
|
177
204
|
recentHistory: Array.from({ length: REPORTED_HISTORY }, (_, i) => `command ${i + 3}`),
|
|
178
205
|
});
|
|
179
206
|
});
|
|
180
207
|
|
|
181
208
|
test("restart replaces the whole game, and the fresh room is the one the greeting describes", async () => {
|
|
182
|
-
const ctx =
|
|
209
|
+
const ctx = createToolContext();
|
|
183
210
|
await run("game_state_take", { value: "lantern" }, ctx);
|
|
184
211
|
await run("game_state_score", { value: 30 }, ctx);
|
|
185
212
|
await run("game_state_move", { value: "Echo Chamber" }, ctx);
|
|
186
213
|
|
|
187
|
-
const restarted =
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
};
|
|
214
|
+
const restarted = ok<{ restarted: boolean; currentRoom: string }>(
|
|
215
|
+
await run("game_state_restart", ctx),
|
|
216
|
+
);
|
|
191
217
|
expect(restarted).toEqual({ restarted: true, currentRoom: DEFAULT_GAME_STATE.currentRoom });
|
|
192
218
|
expect(gameSlot.get(ctx)).toEqual(DEFAULT_GAME_STATE);
|
|
193
219
|
});
|
|
220
|
+
|
|
221
|
+
test("the schemas say what a spoken argument has to be turned into", async () => {
|
|
222
|
+
// Points are a NUMBER: the model has to turn what it heard into one, and a
|
|
223
|
+
// schema that took a string would let "ten" reach `game.score +=`.
|
|
224
|
+
expect(await parseToolInput(agentDef, "game_state_score", { value: 10 })).toEqual({
|
|
225
|
+
value: 10,
|
|
226
|
+
});
|
|
227
|
+
await expect(parseToolInput(agentDef, "game_state_score", { value: "ten" })).rejects.toThrow();
|
|
228
|
+
|
|
229
|
+
// And the read takes nothing at all, which is what makes the two-argument
|
|
230
|
+
// `run("game_state_get", ctx)` form above legal.
|
|
231
|
+
expect(toolOf(agentDef, "game_state_get").inputSchema).toBeUndefined();
|
|
232
|
+
});
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
// ─── The rank is DERIVED, and the scavenger is a DIE ROLL ────────────────────
|
|
236
|
+
|
|
237
|
+
describe("what the game works out for itself", () => {
|
|
238
|
+
test("the rank follows the score, and no tool writes it", async () => {
|
|
239
|
+
const ctx = createToolContext();
|
|
240
|
+
expect(gameSlot.get(ctx).rank).toBe("Beginner");
|
|
241
|
+
|
|
242
|
+
// The tool that carried the player over the threshold reports the rank it
|
|
243
|
+
// EARNED, not the one it had. `after` runs after the body, so a result
|
|
244
|
+
// built from `game.rank` would announce this promotion one call late — the
|
|
245
|
+
// whole reason `rankFor` is a predicate the writer can call.
|
|
246
|
+
const scored = ok<{ score: number; rank: string }>(
|
|
247
|
+
await run("game_state_score", { value: 30 }, ctx),
|
|
248
|
+
);
|
|
249
|
+
expect(scored).toEqual({ score: 30, rank: "Amateur Adventurer" });
|
|
250
|
+
expect(gameSlot.get(ctx).rank).toBe("Amateur Adventurer");
|
|
251
|
+
|
|
252
|
+
// And the hook owns the write, so any later mutation leaves it consistent —
|
|
253
|
+
// including one that has nothing to do with the score.
|
|
254
|
+
await run("game_state_take", { value: "chalice" }, ctx);
|
|
255
|
+
expect(gameSlot.get(ctx).rank).toBe(rankFor(gameSlot.get(ctx).score));
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
test("rankFor is a ladder, and the bottom rung is what a fresh game starts on", () => {
|
|
259
|
+
expect(rankFor(0)).toBe("Beginner");
|
|
260
|
+
expect(rankFor(24)).toBe("Beginner");
|
|
261
|
+
expect(rankFor(25)).toBe("Amateur Adventurer");
|
|
262
|
+
expect(rankFor(999)).toBe("Wizard");
|
|
263
|
+
expect(DEFAULT_GAME_STATE.rank).toBe(rankFor(DEFAULT_GAME_STATE.score));
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
test("the scavenger's threshold is a number the spec can state", async () => {
|
|
267
|
+
const always = createToolContext({ random: () => 0 });
|
|
268
|
+
await run("game_state_take", { value: "scarab" }, always);
|
|
269
|
+
const taken = ok<{ takenByScavenger: boolean }>(
|
|
270
|
+
await run("game_state_drop", { value: "scarab" }, always),
|
|
271
|
+
);
|
|
272
|
+
expect(taken.takenByScavenger).toBe(true);
|
|
273
|
+
expect(gameSlot.get(always).flags[SCAVENGER_FLAG]).toBe(true);
|
|
274
|
+
|
|
275
|
+
// A source that returns exactly 1 is outside `Math.random`'s contract and
|
|
276
|
+
// well inside what a stub does — the comparison has to leave it out.
|
|
277
|
+
const never = createToolContext({ random: () => 1 });
|
|
278
|
+
await run("game_state_take", { value: "scarab" }, never);
|
|
279
|
+
const kept = ok<{ takenByScavenger: boolean }>(
|
|
280
|
+
await run("game_state_drop", { value: "scarab" }, never),
|
|
281
|
+
);
|
|
282
|
+
expect(kept.takenByScavenger).toBe(false);
|
|
283
|
+
expect(gameSlot.get(never).flags[SCAVENGER_FLAG]).toBeUndefined();
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
test("one seed is one adventure: the same stream robs the player the same way", async () => {
|
|
287
|
+
// A SEEDED source rather than a constant one. `() => 0.5` looks like the
|
|
288
|
+
// simplest deterministic stub and is degenerate — every draw identical, so
|
|
289
|
+
// the scavenger either never appears or always does, and nothing about the
|
|
290
|
+
// mechanic is under test. `createSeededRandom` is a real stream that
|
|
291
|
+
// repeats, which is what makes "the same seed plays the same game" an
|
|
292
|
+
// assertion rather than a hope.
|
|
293
|
+
const drops = 12;
|
|
294
|
+
const playthrough = async (random: RandomSource): Promise<boolean[]> => {
|
|
295
|
+
const ctx = createToolContext({ random });
|
|
296
|
+
const struck: boolean[] = [];
|
|
297
|
+
for (let i = 0; i < drops; i++) {
|
|
298
|
+
await run("game_state_take", { value: `treasure ${i}` }, ctx);
|
|
299
|
+
const dropped = ok<{ takenByScavenger: boolean }>(
|
|
300
|
+
await run("game_state_drop", { value: `treasure ${i}` }, ctx),
|
|
301
|
+
);
|
|
302
|
+
struck.push(dropped.takenByScavenger);
|
|
303
|
+
}
|
|
304
|
+
return struck;
|
|
305
|
+
};
|
|
306
|
+
|
|
307
|
+
const first = await playthrough(createSeededRandom(7));
|
|
308
|
+
expect(await playthrough(createSeededRandom(7))).toEqual(first);
|
|
309
|
+
// Both outcomes really occur, so the assertion above is about a stream and
|
|
310
|
+
// not about a constant that never trips the threshold.
|
|
311
|
+
expect([...new Set(first)].sort()).toEqual([false, true]);
|
|
312
|
+
expect(await playthrough(createSeededRandom(8))).not.toEqual(first);
|
|
313
|
+
});
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
// ─── One status line, two readers ────────────────────────────────────────────
|
|
317
|
+
|
|
318
|
+
describe("the status line", () => {
|
|
319
|
+
test("the opening frame agrees with the greeting, before anything is stored", () => {
|
|
320
|
+
// What a client renders on a session that has not touched the slot: the
|
|
321
|
+
// projection calls the slot's own `create()`, so the CRT's top bar shows
|
|
322
|
+
// the cave mouth the greeting describes rather than an empty frame.
|
|
323
|
+
expect(gameStatus()).toEqual({
|
|
324
|
+
currentRoom: DEFAULT_GAME_STATE.currentRoom,
|
|
325
|
+
score: 0,
|
|
326
|
+
rank: "Beginner",
|
|
327
|
+
moves: 0,
|
|
328
|
+
});
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
test("the narrator and the screen are told the same four things", async () => {
|
|
332
|
+
const ctx = createToolContext();
|
|
333
|
+
say("go down to the hall", ctx);
|
|
334
|
+
await run("game_state_move", { value: "Echoing Hall" }, ctx);
|
|
335
|
+
await run("game_state_score", { value: 60 }, ctx);
|
|
336
|
+
|
|
337
|
+
const board = ok<Record<string, unknown>>(await run("game_state_get", ctx));
|
|
338
|
+
const bar = statusLine(gameSlot.get(ctx));
|
|
339
|
+
|
|
340
|
+
expect(bar).toEqual({
|
|
341
|
+
currentRoom: "Echoing Hall",
|
|
342
|
+
score: 60,
|
|
343
|
+
rank: "Novice Adventurer",
|
|
344
|
+
moves: 1,
|
|
345
|
+
});
|
|
346
|
+
// `game_state_get` spreads the same helper, so the two cannot drift.
|
|
347
|
+
expect(board).toMatchObject(bar);
|
|
348
|
+
});
|
|
194
349
|
});
|
|
195
350
|
|
|
196
351
|
describe("the game is per context", () => {
|
|
@@ -200,8 +355,8 @@ describe("the game is per context", () => {
|
|
|
200
355
|
// detached slot store, so the isolation is per CONTEXT — two distinct
|
|
201
356
|
// session ids would prove nothing extra, and `sessionSlot` could stop
|
|
202
357
|
// keying by session with this still passing.
|
|
203
|
-
const one =
|
|
204
|
-
const two =
|
|
358
|
+
const one = createToolContext();
|
|
359
|
+
const two = createToolContext();
|
|
205
360
|
|
|
206
361
|
await run("game_state_take", { value: "lantern" }, one);
|
|
207
362
|
await run("game_state_move", { value: "Echo Chamber" }, one);
|
|
@@ -213,7 +368,7 @@ describe("the game is per context", () => {
|
|
|
213
368
|
});
|
|
214
369
|
|
|
215
370
|
test("the module-level default is cloned, so no session can edit the next one's start", async () => {
|
|
216
|
-
const ctx =
|
|
371
|
+
const ctx = createToolContext();
|
|
217
372
|
await run("game_state_take", { value: "lantern" }, ctx);
|
|
218
373
|
expect(DEFAULT_GAME_STATE.inventory).toEqual([]);
|
|
219
374
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { agent } from "@alexkroman1/aai";
|
|
2
|
-
import {
|
|
2
|
+
import { gameStatus, recordTurn } from "./shared.ts";
|
|
3
3
|
|
|
4
4
|
export default agent({
|
|
5
5
|
name: "Cavern Adventure",
|
|
@@ -8,6 +8,18 @@ export default agent({
|
|
|
8
8
|
// A narrator wants a narrative voice; everything else stays on the
|
|
9
9
|
// default all-AssemblyAI pipeline.
|
|
10
10
|
voice: "paul",
|
|
11
|
+
/**
|
|
12
|
+
* The status line, pushed to the CRT's top bar — where you are, your score,
|
|
13
|
+
* your rank and the turn count, the four facts the printed games put across
|
|
14
|
+
* the top of the screen.
|
|
15
|
+
*
|
|
16
|
+
* The client used to COUNT the turns itself, by reducing over the message
|
|
17
|
+
* list for `role === "user"`, which is a different number from the one the
|
|
18
|
+
* game keeps: a barge-in, a session resumed mid-adventure or a turn the
|
|
19
|
+
* runtime merges all move the two apart, and the one on screen was never the
|
|
20
|
+
* one the narrator was told. `syncState` sends the game's own.
|
|
21
|
+
*/
|
|
22
|
+
syncState: gameStatus,
|
|
11
23
|
// The opening scene here must agree with DEFAULT_GAME_STATE.currentRoom
|
|
12
24
|
// (shared.ts) and the world map in system-prompt.md.
|
|
13
25
|
greeting:
|
|
@@ -29,7 +41,6 @@ export default agent({
|
|
|
29
41
|
* reads the result on its next `game_state_get`.
|
|
30
42
|
*/
|
|
31
43
|
events: {
|
|
32
|
-
"user-transcript.committed": (event, ctx) =>
|
|
33
|
-
gameSlot.update(ctx, (game) => recordTurn(game, event.text)),
|
|
44
|
+
"user-transcript.committed": (event, ctx) => recordTurn(ctx, event.text),
|
|
34
45
|
},
|
|
35
46
|
});
|