@alexkroman1/aai-cli 15.0.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 +14 -20
- package/dist/{dev-Bx9gYBHM.mjs → dev-kodAY23K.mjs} +7 -1
- package/dist/{eval-B3I7FqN9.mjs → eval-DvoSz7SZ.mjs} +1 -1
- package/dist/{init-CFyusRbq.mjs → init-D363Ls5u.mjs} +13 -39
- package/dist/init.d.ts +5 -10
- 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
|
@@ -1,36 +1,81 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
/** The def a DEPLOYED agent runs: authored, plus what `tools/` declares. */
|
|
2
|
+
import agentDef from "virtual:aai/agent";
|
|
3
|
+
import type { InferToolInput, RandomSource, SlotHolder } from "@alexkroman1/aai";
|
|
4
|
+
import { createSeededRandom, isToolFailure } from "@alexkroman1/aai";
|
|
5
|
+
import {
|
|
6
|
+
createToolContext,
|
|
7
|
+
expectDialogRefused,
|
|
8
|
+
expectToolOk,
|
|
9
|
+
parseToolInput,
|
|
10
|
+
toolInputIssues,
|
|
11
|
+
toolRunner,
|
|
12
|
+
} from "@alexkroman1/aai/testing";
|
|
13
|
+
import { describe, expect, test } from "vitest";
|
|
5
14
|
import {
|
|
6
15
|
applyConsequences,
|
|
7
16
|
DEFAULT_STATE,
|
|
17
|
+
findClock,
|
|
8
18
|
type GameState,
|
|
9
19
|
gameSlot,
|
|
20
|
+
gameView,
|
|
10
21
|
inCrisis,
|
|
11
22
|
isGameOver,
|
|
23
|
+
MAX_LOG_ENTRIES,
|
|
12
24
|
MAX_NPCS,
|
|
13
25
|
MIN_MOMENTUM,
|
|
14
26
|
makeNpc,
|
|
15
27
|
rollAction,
|
|
16
28
|
storyFlow,
|
|
17
29
|
} from "./shared.ts";
|
|
18
|
-
import
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
import type setupCharacter from "./tools/setup_character.ts";
|
|
31
|
+
|
|
32
|
+
// ── Harness ──────────────────────────────────────────────────────────────────
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* A tool by the NAME the model calls it by, bound to this agent.
|
|
36
|
+
*
|
|
37
|
+
* The lookup, its "no such tool" message and the args-or-context shape are all
|
|
38
|
+
* `toolRunner`'s (`@alexkroman1/aai/testing`); what is local is only which agent
|
|
39
|
+
* it runs against. It replaces both the direct `tools/*.ts` imports and a local
|
|
40
|
+
* `callNoArgs<R>(def, ctx)` that cast its way past `ToolDef["execute"]`'s first
|
|
41
|
+
* parameter — a tool declaring no `inputSchema` types that as a shape no object
|
|
42
|
+
* literal satisfies, and `runTool` takes the context in the arguments' place for
|
|
43
|
+
* exactly that case. Driving by name is also the half a direct `.execute` call
|
|
44
|
+
* cannot check: a renamed `tools/` file is what the MODEL would stop finding.
|
|
45
|
+
*/
|
|
46
|
+
const run = toolRunner(agentDef);
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The dice `rollAction` draws, in the order it draws them: d1, d2 (d6), then
|
|
50
|
+
* c1, c2 (d10).
|
|
51
|
+
*
|
|
52
|
+
* `randomInt(sides, random)` is `Math.floor(random() * sides)`, so a face is
|
|
53
|
+
* produced by returning `(face - 0.5) / sides`. This used to be
|
|
54
|
+
* `vi.spyOn(Math, "random")` — a GLOBAL patch every other test in the file then
|
|
55
|
+
* had to be trusted not to depend on, and one the teardown had to remember to
|
|
56
|
+
* restore. The dice are a PARAMETER (`rollAction`'s fourth), which is the same
|
|
57
|
+
* seam `ctx.random` gives a tool, so nothing here touches the process.
|
|
58
|
+
*/
|
|
59
|
+
function dice(...faces: readonly [number, number, number, number]): RandomSource {
|
|
60
|
+
const sides = [6, 6, 10, 10] as const;
|
|
61
|
+
let draw = 0;
|
|
62
|
+
return () => {
|
|
63
|
+
const face = faces[draw] ?? 1;
|
|
64
|
+
const side = sides[draw] ?? 6;
|
|
65
|
+
draw++;
|
|
66
|
+
return (face - 0.5) / side;
|
|
67
|
+
};
|
|
32
68
|
}
|
|
33
69
|
|
|
70
|
+
/**
|
|
71
|
+
* Every field `setup_character` requires, pinned to the tool's OWN schema.
|
|
72
|
+
*
|
|
73
|
+
* `satisfies InferToolInput<typeof setupCharacter>` rather than a bare literal:
|
|
74
|
+
* a required field added to that schema, or an enum member renamed under one of
|
|
75
|
+
* these values, is a compile error HERE — where the alternative is a spec that
|
|
76
|
+
* still passes while the shape it seeds no longer exists. The import is
|
|
77
|
+
* type-only, so nothing about the runner's by-name lookup is undone by it.
|
|
78
|
+
*/
|
|
34
79
|
const SETUP_ARGS = {
|
|
35
80
|
genre: "dark_fantasy",
|
|
36
81
|
tone: "dark_gritty",
|
|
@@ -40,14 +85,43 @@ const SETUP_ARGS = {
|
|
|
40
85
|
settingDescription: "A city of fog and iron.",
|
|
41
86
|
startingLocation: "The Docks",
|
|
42
87
|
locationDesc: "Rotting piers under gaslight.",
|
|
43
|
-
timeOfDay: "night"
|
|
88
|
+
timeOfDay: "night",
|
|
44
89
|
openingSituation: "A body washes ashore bearing your family crest.",
|
|
45
90
|
npc1Name: "Mira",
|
|
46
91
|
npc1Desc: "A wary informant",
|
|
47
|
-
npc1Disposition: "distrustful"
|
|
92
|
+
npc1Disposition: "distrustful",
|
|
48
93
|
npc1Agenda: "Pay off her debts",
|
|
49
94
|
threatClockName: "The Syndicate Closes In",
|
|
50
95
|
threatClockDesc: "Assassins find the player",
|
|
96
|
+
} satisfies InferToolInput<typeof setupCharacter>;
|
|
97
|
+
|
|
98
|
+
const SWING = {
|
|
99
|
+
move: "clash",
|
|
100
|
+
stat: "iron",
|
|
101
|
+
position: "risky",
|
|
102
|
+
effect: "standard",
|
|
103
|
+
purpose: "swing",
|
|
104
|
+
} as const;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* What the two ungated tools answer with.
|
|
108
|
+
*
|
|
109
|
+
* A plain `tool()` returns its own value, so there is no envelope to unwrap and
|
|
110
|
+
* `expectToolOk` would (correctly) refuse one. The by-name lookup is a STRING,
|
|
111
|
+
* so the author's return type cannot be recovered from it — the SDK says so in
|
|
112
|
+
* `expectToolOk`'s own doc — and naming the fields a spec reads is the honest
|
|
113
|
+
* substitute. Only what is asserted below is listed.
|
|
114
|
+
*/
|
|
115
|
+
type Answered = {
|
|
116
|
+
state: string;
|
|
117
|
+
instruction?: string;
|
|
118
|
+
done: boolean;
|
|
119
|
+
initialized: boolean;
|
|
120
|
+
playerName: string;
|
|
121
|
+
gameOver: boolean;
|
|
122
|
+
health: number;
|
|
123
|
+
momentum: number;
|
|
124
|
+
chaosFactor: number;
|
|
51
125
|
};
|
|
52
126
|
|
|
53
127
|
function playingState(): GameState {
|
|
@@ -67,45 +141,31 @@ function playingState(): GameState {
|
|
|
67
141
|
}
|
|
68
142
|
|
|
69
143
|
/**
|
|
70
|
-
* Seed a
|
|
144
|
+
* Seed a session with a mid-game campaign AND the matching flow position.
|
|
71
145
|
*
|
|
72
|
-
* Writing the slot alone is
|
|
73
|
-
* `burn_momentum`
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
146
|
+
* Writing the slot alone is not enough: `action_roll`, `update_state` and
|
|
147
|
+
* `burn_momentum` gate on `storyFlow`, so a campaign installed behind the
|
|
148
|
+
* machine's back leaves every one of them refusing. That is the point of the
|
|
149
|
+
* gate, and it is what this helper exists to satisfy honestly — through the
|
|
150
|
+
* flow's own event, not by writing its snapshot.
|
|
151
|
+
*
|
|
152
|
+
* Typed `SlotHolder` rather than `ToolContext`, which is what both calls below
|
|
153
|
+
* really take: this seeds a session's SLOTS, and needs nothing else a tool body
|
|
154
|
+
* is handed.
|
|
77
155
|
*/
|
|
78
|
-
function seedPlaying(ctx:
|
|
156
|
+
function seedPlaying(ctx: SlotHolder, state: GameState = playingState()): GameState {
|
|
79
157
|
gameSlot.set(ctx, state);
|
|
80
158
|
storyFlow.send(ctx, { type: "SETUP" });
|
|
81
159
|
return state;
|
|
82
160
|
}
|
|
83
161
|
|
|
84
|
-
/**
|
|
85
|
-
* Call a tool that declares no `inputSchema`.
|
|
86
|
-
*
|
|
87
|
-
* `ToolDef["execute"]`'s first parameter is derived from the schema, so a tool
|
|
88
|
-
* with none types it as a shape no object literal satisfies — and nine call
|
|
89
|
-
* sites here had each cast their way past it. This is the one narrowing they all
|
|
90
|
-
* wanted: `check_state` and `burn_momentum` really do take no arguments, and a
|
|
91
|
-
* helper says that once where a cast per call site said nothing.
|
|
92
|
-
*
|
|
93
|
-
* It is generic in `R` because the three tool builders thread their result type
|
|
94
|
-
* out now, so the ARGUMENT is the only thing here that needs laundering — where
|
|
95
|
-
* every call site used to follow this one with a second cast of its own to
|
|
96
|
-
* recover a return type the erasure had thrown away.
|
|
97
|
-
*/
|
|
98
|
-
function callNoArgs<R>(def: ToolDef<ToolInputSchema, R>, ctx: ToolContext): Promise<Awaited<R>> {
|
|
99
|
-
return Promise.resolve((def.execute as (args: unknown, c: ToolContext) => R)({}, ctx));
|
|
100
|
-
}
|
|
101
|
-
|
|
102
162
|
// ── setup_character ──────────────────────────────────────────────────────────
|
|
103
163
|
|
|
104
164
|
describe("setup_character", () => {
|
|
105
165
|
test("running setup twice starts fresh: no duplicate ids, no stale resources, truthful return", async () => {
|
|
106
|
-
const ctx =
|
|
166
|
+
const ctx = createToolContext();
|
|
107
167
|
|
|
108
|
-
await
|
|
168
|
+
await run("setup_character", SETUP_ARGS, ctx);
|
|
109
169
|
|
|
110
170
|
// Simulate a played, damaged game between setups.
|
|
111
171
|
gameSlot.update(ctx, (played) => {
|
|
@@ -115,10 +175,11 @@ describe("setup_character", () => {
|
|
|
115
175
|
played.sceneCount = 42;
|
|
116
176
|
});
|
|
117
177
|
|
|
118
|
-
const result = (await
|
|
178
|
+
const result = (await run(
|
|
179
|
+
"setup_character",
|
|
119
180
|
{ ...SETUP_ARGS, playerName: "Luna" },
|
|
120
181
|
ctx,
|
|
121
|
-
)) as
|
|
182
|
+
)) as Answered;
|
|
122
183
|
|
|
123
184
|
const state = gameSlot.get(ctx);
|
|
124
185
|
expect(state.npcs).toHaveLength(1);
|
|
@@ -140,8 +201,8 @@ describe("setup_character", () => {
|
|
|
140
201
|
});
|
|
141
202
|
|
|
142
203
|
test("stats are a permutation of [3,2,2,1,1] with the archetype's stat at 3", async () => {
|
|
143
|
-
const ctx =
|
|
144
|
-
await
|
|
204
|
+
const ctx = createToolContext();
|
|
205
|
+
await run("setup_character", SETUP_ARGS, ctx);
|
|
145
206
|
const state = gameSlot.get(ctx);
|
|
146
207
|
const stats = [state.edge, state.heart, state.iron, state.shadow, state.wits];
|
|
147
208
|
expect([...stats].sort()).toEqual([1, 1, 2, 2, 3]);
|
|
@@ -155,8 +216,8 @@ describe("setup_character", () => {
|
|
|
155
216
|
// detached slot store, so the isolation is per CONTEXT — two distinct
|
|
156
217
|
// session ids would prove nothing extra, and `sessionSlot` could stop
|
|
157
218
|
// keying by session with this still passing.
|
|
158
|
-
await
|
|
159
|
-
const other = await
|
|
219
|
+
await run("setup_character", SETUP_ARGS, createToolContext());
|
|
220
|
+
const other = (await run("check_state", createToolContext())) as Answered;
|
|
160
221
|
expect(other.initialized).toBe(false);
|
|
161
222
|
});
|
|
162
223
|
});
|
|
@@ -243,7 +304,7 @@ describe("applyConsequences MISS matrix", () => {
|
|
|
243
304
|
// ── burn_momentum ────────────────────────────────────────────────────────────
|
|
244
305
|
|
|
245
306
|
describe("burn_momentum", () => {
|
|
246
|
-
function seedRolledState(momentum: number, ctx:
|
|
307
|
+
function seedRolledState(momentum: number, ctx: SlotHolder) {
|
|
247
308
|
const state = playingState();
|
|
248
309
|
// A MISS was applied: health -2, momentum -2, clock +1.
|
|
249
310
|
state.health = 3;
|
|
@@ -285,10 +346,12 @@ describe("burn_momentum", () => {
|
|
|
285
346
|
}
|
|
286
347
|
|
|
287
348
|
test("a legal burn reverts the miss's consequences, upgrades, and resets momentum", async () => {
|
|
288
|
-
const ctx =
|
|
349
|
+
const ctx = createToolContext();
|
|
289
350
|
seedRolledState(8, ctx); // 8 beats both dice (3, 5)
|
|
290
351
|
|
|
291
|
-
const result = expectToolOk<
|
|
352
|
+
const result = expectToolOk<{ burned: boolean; newResultCode: string }>(
|
|
353
|
+
await run("burn_momentum", ctx),
|
|
354
|
+
);
|
|
292
355
|
expect(result.burned).toBe(true);
|
|
293
356
|
expect(result.newResultCode).toBe("STRONG_HIT");
|
|
294
357
|
|
|
@@ -300,48 +363,50 @@ describe("burn_momentum", () => {
|
|
|
300
363
|
});
|
|
301
364
|
|
|
302
365
|
test("momentum beating only one die upgrades a MISS to WEAK_HIT", async () => {
|
|
303
|
-
const ctx =
|
|
366
|
+
const ctx = createToolContext();
|
|
304
367
|
seedRolledState(4, ctx); // beats 3, not 5
|
|
305
|
-
const result = expectToolOk<{ newResultCode: string }>(await
|
|
368
|
+
const result = expectToolOk<{ newResultCode: string }>(await run("burn_momentum", ctx));
|
|
306
369
|
expect(result.newResultCode).toBe("WEAK_HIT");
|
|
307
370
|
});
|
|
308
371
|
|
|
309
372
|
test("burn is refused with no roll standing, insufficient momentum, or a strong hit", async () => {
|
|
310
|
-
const ctx =
|
|
373
|
+
const ctx = createToolContext();
|
|
311
374
|
|
|
312
|
-
// No roll yet — and this refusal is
|
|
375
|
+
// No roll yet — and this refusal is the FLOW's rather than a null check
|
|
313
376
|
// inside the body: nothing has rolled, so the game is in
|
|
314
|
-
// `playing.awaitingRoll` and this tool is not available there.
|
|
315
|
-
//
|
|
377
|
+
// `playing.awaitingRoll` and this tool is not available there.
|
|
378
|
+
// `expectDialogRefused` is the SDK's reader for that: it pins the STATE the
|
|
379
|
+
// refusal names against the sentence `dialog()` writes, and throws naming
|
|
380
|
+
// where the dialog actually landed if the call SUCCEEDED — where an
|
|
381
|
+
// `isToolFailure(...) && ...` expression let a success through as a `false`
|
|
382
|
+
// that merely failed the next matcher.
|
|
316
383
|
seedPlaying(ctx);
|
|
317
|
-
|
|
318
|
-
//
|
|
319
|
-
|
|
320
|
-
expect(
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
//
|
|
324
|
-
//
|
|
384
|
+
const outOfState = expectDialogRefused(await run("burn_momentum", ctx), "playing.awaitingRoll");
|
|
385
|
+
// The state's own instruction rides in the refusal, which is what the model
|
|
386
|
+
// recovers from.
|
|
387
|
+
expect(outOfState.error).toContain("action_roll");
|
|
388
|
+
|
|
389
|
+
// The two below are DATA rules — the momentum is too low, the roll was
|
|
390
|
+
// already a strong hit — so they stay in the body, the tool really runs,
|
|
391
|
+
// and what comes back is the body's own `toolFailure(...)` rather than the
|
|
392
|
+
// gate's sentence. `isToolFailure` is the right reader for exactly that
|
|
393
|
+
// difference.
|
|
325
394
|
seedRolledState(2, ctx);
|
|
326
|
-
|
|
327
|
-
expect(isToolFailure(
|
|
395
|
+
let refused = await run("burn_momentum", ctx);
|
|
396
|
+
expect(isToolFailure(refused) && refused.error).toMatch(/not high enough/);
|
|
328
397
|
|
|
329
|
-
// Strong hits cannot be upgraded
|
|
330
398
|
seedRolledState(8, ctx);
|
|
331
399
|
gameSlot.update(ctx, (state) => {
|
|
332
400
|
state.lastRoll!.result = "STRONG_HIT";
|
|
333
401
|
});
|
|
334
|
-
|
|
335
|
-
expect(isToolFailure(
|
|
402
|
+
refused = await run("burn_momentum", ctx);
|
|
403
|
+
expect(isToolFailure(refused) && refused.error).toMatch(/already a Strong Hit/);
|
|
336
404
|
});
|
|
337
405
|
|
|
338
406
|
test("action_roll persists the roll so burn needs no dice arguments", async () => {
|
|
339
|
-
const ctx =
|
|
407
|
+
const ctx = createToolContext();
|
|
340
408
|
seedPlaying(ctx);
|
|
341
|
-
await
|
|
342
|
-
{ move: "clash", stat: "iron", position: "risky", effect: "standard", purpose: "attack" },
|
|
343
|
-
ctx,
|
|
344
|
-
);
|
|
409
|
+
await run("action_roll", SWING, ctx);
|
|
345
410
|
const state = gameSlot.get(ctx);
|
|
346
411
|
expect(state.lastRoll).not.toBeNull();
|
|
347
412
|
expect(state.lastRoll?.move).toBe("clash");
|
|
@@ -352,43 +417,77 @@ describe("burn_momentum", () => {
|
|
|
352
417
|
// ── rollAction dice boundaries ───────────────────────────────────────────────
|
|
353
418
|
|
|
354
419
|
describe("rollAction", () => {
|
|
355
|
-
// Math.random call order inside rollAction: d1, d2, c1, c2.
|
|
356
|
-
function mockDice(d1: number, d2: number, c1: number, c2: number) {
|
|
357
|
-
const spy = vi.spyOn(Math, "random");
|
|
358
|
-
for (const [value, sides] of [
|
|
359
|
-
[d1, 6],
|
|
360
|
-
[d2, 6],
|
|
361
|
-
[c1, 10],
|
|
362
|
-
[c2, 10],
|
|
363
|
-
] as const) {
|
|
364
|
-
spy.mockReturnValueOnce((value - 0.5) / sides);
|
|
365
|
-
}
|
|
366
|
-
return spy;
|
|
367
|
-
}
|
|
368
|
-
|
|
369
420
|
test("tying a challenge die is NOT a beat — equal on both dice is a MISS with match", () => {
|
|
370
|
-
|
|
371
|
-
const roll = rollAction("wits", 2, "face_danger");
|
|
421
|
+
// action score 3+3+2 = 8 vs 8, 8
|
|
422
|
+
const roll = rollAction("wits", 2, "face_danger", dice(3, 3, 8, 8));
|
|
372
423
|
expect(roll.actionScore).toBe(8);
|
|
373
424
|
expect(roll.result).toBe("MISS");
|
|
374
425
|
expect(roll.match).toBe(true);
|
|
375
426
|
});
|
|
376
427
|
|
|
377
428
|
test("action score caps at 10 even when dice + stat exceed it", () => {
|
|
378
|
-
|
|
379
|
-
const roll = rollAction("iron", 4, "clash");
|
|
429
|
+
const roll = rollAction("iron", 4, "clash", dice(6, 6, 1, 1)); // 6+6+4 = 16 → 10
|
|
380
430
|
expect(roll.actionScore).toBe(10);
|
|
381
431
|
expect(roll.result).toBe("STRONG_HIT");
|
|
382
432
|
});
|
|
383
433
|
|
|
384
434
|
test("beating exactly one die is a WEAK_HIT", () => {
|
|
385
|
-
|
|
386
|
-
const roll = rollAction("edge", 2, "face_danger");
|
|
435
|
+
const roll = rollAction("edge", 2, "face_danger", dice(4, 2, 5, 9)); // 8: beats 5, not 9
|
|
387
436
|
expect(roll.result).toBe("WEAK_HIT");
|
|
388
437
|
expect(roll.match).toBe(false);
|
|
389
438
|
});
|
|
390
439
|
});
|
|
391
440
|
|
|
441
|
+
// ── a scene is a function of its random source ───────────────────────────────
|
|
442
|
+
|
|
443
|
+
describe("action_roll draws everything from ctx.random", () => {
|
|
444
|
+
/** One roll from a fresh session whose randomness is `createSeededRandom(seed)`. */
|
|
445
|
+
async function playOneScene(seed: number) {
|
|
446
|
+
const ctx = createToolContext({ random: createSeededRandom(seed) });
|
|
447
|
+
seedPlaying(ctx);
|
|
448
|
+
return expectToolOk<Record<string, unknown>>(await run("action_roll", SWING, ctx));
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
test("every draw a roll makes comes off the context's source", async () => {
|
|
452
|
+
// The DETERMINISTIC half, and the one that names the defect: a roll draws
|
|
453
|
+
// five times — d1, d2, c1, c2, and then the chaos check's own d10 (a sixth
|
|
454
|
+
// when the interrupt lands and its type is picked). The fifth used to reach
|
|
455
|
+
// `Math.random`, because `checkChaosInterrupt`'s source parameter was simply
|
|
456
|
+
// omitted at the call, so the count was four.
|
|
457
|
+
let draws = 0;
|
|
458
|
+
const seeded = createSeededRandom(2026);
|
|
459
|
+
const ctx = createToolContext({
|
|
460
|
+
random: () => {
|
|
461
|
+
draws++;
|
|
462
|
+
return seeded();
|
|
463
|
+
},
|
|
464
|
+
});
|
|
465
|
+
seedPlaying(ctx);
|
|
466
|
+
|
|
467
|
+
expectToolOk(await run("action_roll", SWING, ctx));
|
|
468
|
+
expect(draws).toBeGreaterThanOrEqual(5);
|
|
469
|
+
});
|
|
470
|
+
|
|
471
|
+
test("the same seed replays the same scene, chaos interrupt included", async () => {
|
|
472
|
+
// The property a player would notice, over the WHOLE result rather than the
|
|
473
|
+
// dice: with the missing source above, this comparison disagreed on
|
|
474
|
+
// `chaosInterrupt` for roughly three runs in five — intermittently, and only
|
|
475
|
+
// ever on the field nobody looks at. A seeded campaign replays or it does
|
|
476
|
+
// not.
|
|
477
|
+
expect(await playOneScene(2026)).toEqual(await playOneScene(2026));
|
|
478
|
+
});
|
|
479
|
+
|
|
480
|
+
test("a different seed is a different scene", async () => {
|
|
481
|
+
// The other half, and the reason `createSeededRandom` rather than a
|
|
482
|
+
// constant source: `() => 0.5` is deterministic and degenerate, and every
|
|
483
|
+
// roll under it would be identical. Compared on the dice alone, since two
|
|
484
|
+
// seeds may legitimately agree on a derived label.
|
|
485
|
+
const a = await playOneScene(1);
|
|
486
|
+
const b = await playOneScene(99);
|
|
487
|
+
expect([a.actionDice, a.challengeDice]).not.toEqual([b.actionDice, b.challengeDice]);
|
|
488
|
+
});
|
|
489
|
+
});
|
|
490
|
+
|
|
392
491
|
// ── oracle ───────────────────────────────────────────────────────────────────
|
|
393
492
|
//
|
|
394
493
|
// `chaos_check` is the one oracle branch that WRITES: `checkChaosInterrupt`
|
|
@@ -401,19 +500,23 @@ describe("rollAction", () => {
|
|
|
401
500
|
// private copy would pass every check on its own return value.
|
|
402
501
|
|
|
403
502
|
describe("oracle", () => {
|
|
404
|
-
/**
|
|
405
|
-
|
|
406
|
-
|
|
503
|
+
/**
|
|
504
|
+
* A context whose `d(sides)` rolls `value`.
|
|
505
|
+
*
|
|
506
|
+
* `ctx.random` is the seam, so the dice a scene is resolved on are an
|
|
507
|
+
* argument to the tool rather than a property of the process.
|
|
508
|
+
*/
|
|
509
|
+
function rolling(value: number, sides: number) {
|
|
510
|
+
return createToolContext({ random: () => (value - 0.5) / sides });
|
|
407
511
|
}
|
|
408
512
|
|
|
409
513
|
test("a chaos interrupt that LANDS lowers the stored chaos factor", async () => {
|
|
410
|
-
const ctx =
|
|
514
|
+
const ctx = rolling(1, 10);
|
|
411
515
|
const state = playingState();
|
|
412
516
|
state.chaosFactor = 9; // threshold 6 — a roll of 1 lands
|
|
413
517
|
seedPlaying(ctx, state);
|
|
414
|
-
mockRoll(1, 10);
|
|
415
518
|
|
|
416
|
-
const result = (await oracle
|
|
519
|
+
const result = (await run("oracle", { type: "chaos_check" }, ctx)) as {
|
|
417
520
|
interrupted: boolean;
|
|
418
521
|
interruptType: string | null;
|
|
419
522
|
chaosFactor: number;
|
|
@@ -427,12 +530,12 @@ describe("oracle", () => {
|
|
|
427
530
|
});
|
|
428
531
|
|
|
429
532
|
test("the chaos factor floors at 3, where no roll is taken at all", async () => {
|
|
430
|
-
const ctx =
|
|
533
|
+
const ctx = createToolContext();
|
|
431
534
|
const state = playingState();
|
|
432
535
|
state.chaosFactor = 3; // threshold 0 — `checkChaosInterrupt` returns early
|
|
433
536
|
seedPlaying(ctx, state);
|
|
434
537
|
|
|
435
|
-
const result = (await oracle
|
|
538
|
+
const result = (await run("oracle", { type: "chaos_check" }, ctx)) as {
|
|
436
539
|
interrupted: boolean;
|
|
437
540
|
chaosFactor: number;
|
|
438
541
|
};
|
|
@@ -441,13 +544,12 @@ describe("oracle", () => {
|
|
|
441
544
|
});
|
|
442
545
|
|
|
443
546
|
test("a chaos check that MISSES changes nothing", async () => {
|
|
444
|
-
const ctx =
|
|
547
|
+
const ctx = rolling(10, 10); // past the threshold
|
|
445
548
|
const state = playingState();
|
|
446
549
|
state.chaosFactor = 5; // threshold 2
|
|
447
550
|
seedPlaying(ctx, state);
|
|
448
|
-
mockRoll(10, 10); // past the threshold
|
|
449
551
|
|
|
450
|
-
const result = (await oracle
|
|
552
|
+
const result = (await run("oracle", { type: "chaos_check" }, ctx)) as {
|
|
451
553
|
interrupted: boolean;
|
|
452
554
|
chaosFactor: number;
|
|
453
555
|
};
|
|
@@ -457,15 +559,14 @@ describe("oracle", () => {
|
|
|
457
559
|
});
|
|
458
560
|
|
|
459
561
|
test("a chaos check on an untouched session starts from the default factor", async () => {
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
const result = (await oracle
|
|
562
|
+
// DEFAULT_STATE.chaosFactor is 5, so threshold 2 — a roll of 1 lands.
|
|
563
|
+
const ctx = rolling(1, 10);
|
|
564
|
+
const result = (await run("oracle", { type: "chaos_check" }, ctx)) as { chaosFactor: number };
|
|
463
565
|
expect(result.chaosFactor).toBe(DEFAULT_STATE.chaosFactor - 1);
|
|
464
566
|
expect(gameSlot.get(ctx).chaosFactor).toBe(DEFAULT_STATE.chaosFactor - 1);
|
|
465
567
|
});
|
|
466
568
|
|
|
467
569
|
test("yes_no maps the d6 onto its three answers", async () => {
|
|
468
|
-
const ctx = makeCtx();
|
|
469
570
|
for (const [roll, answer] of [
|
|
470
571
|
[1, "No"],
|
|
471
572
|
[2, "No"],
|
|
@@ -474,8 +575,7 @@ describe("oracle", () => {
|
|
|
474
575
|
[5, "Yes"],
|
|
475
576
|
[6, "Yes"],
|
|
476
577
|
] as const) {
|
|
477
|
-
|
|
478
|
-
const result = (await oracle.execute({ type: "yes_no" }, ctx)) as {
|
|
578
|
+
const result = (await run("oracle", { type: "yes_no" }, rolling(roll, 6))) as {
|
|
479
579
|
roll: number;
|
|
480
580
|
answer: string;
|
|
481
581
|
};
|
|
@@ -484,13 +584,13 @@ describe("oracle", () => {
|
|
|
484
584
|
});
|
|
485
585
|
|
|
486
586
|
test("the four inspiration branches answer without touching the game", async () => {
|
|
487
|
-
const ctx =
|
|
587
|
+
const ctx = createToolContext();
|
|
488
588
|
seedPlaying(ctx);
|
|
489
589
|
const before = structuredClone(gameSlot.get(ctx));
|
|
490
590
|
|
|
491
|
-
const reaction = (await oracle
|
|
492
|
-
const twist = (await oracle
|
|
493
|
-
const theme = (await oracle
|
|
591
|
+
const reaction = (await run("oracle", { type: "npc_reaction" }, ctx)) as { reaction: string };
|
|
592
|
+
const twist = (await run("oracle", { type: "scene_twist" }, ctx)) as { twist: string };
|
|
593
|
+
const theme = (await run("oracle", { type: "action_theme" }, ctx)) as {
|
|
494
594
|
action: string;
|
|
495
595
|
theme: string;
|
|
496
596
|
seed: string;
|
|
@@ -505,16 +605,45 @@ describe("oracle", () => {
|
|
|
505
605
|
});
|
|
506
606
|
});
|
|
507
607
|
|
|
608
|
+
// ── which clock the player meant ─────────────────────────────────────────────
|
|
609
|
+
|
|
610
|
+
describe("findClock", () => {
|
|
611
|
+
// Deliberately ordered so the two rules disagree: "The First Light" contains
|
|
612
|
+
// an ordinal word and sits SECOND.
|
|
613
|
+
const clocks = [
|
|
614
|
+
{ id: "clock_1", name: "The Syndicate Closes In" },
|
|
615
|
+
{ id: "clock_2", name: "The First Light" },
|
|
616
|
+
];
|
|
617
|
+
|
|
618
|
+
test("an exact name wins over the ordinal it happens to contain", () => {
|
|
619
|
+
// Resolving the ordinal first would answer `clock_1` here, silently
|
|
620
|
+
// retargeting a clock the player named outright.
|
|
621
|
+
expect(findClock(clocks, "The First Light")?.id).toBe("clock_2");
|
|
622
|
+
expect(findClock(clocks, " the first light ")?.id).toBe("clock_2");
|
|
623
|
+
});
|
|
624
|
+
|
|
625
|
+
test("an ordinal picks by the position the sidebar renders", () => {
|
|
626
|
+
expect(findClock(clocks, "the second clock")?.id).toBe("clock_2");
|
|
627
|
+
expect(findClock(clocks, "the 1st one")?.id).toBe("clock_1");
|
|
628
|
+
});
|
|
629
|
+
|
|
630
|
+
test("neither a name nor an ordinal resolves to nothing", () => {
|
|
631
|
+
expect(findClock(clocks, "The Reckoning")).toBeUndefined();
|
|
632
|
+
// An ordinal past the end is not a wrap-around.
|
|
633
|
+
expect(findClock(clocks, "the ninth clock")).toBeUndefined();
|
|
634
|
+
});
|
|
635
|
+
});
|
|
636
|
+
|
|
508
637
|
// ── update_state: clocks, caps, validation ───────────────────────────────────
|
|
509
638
|
|
|
510
639
|
describe("update_state", () => {
|
|
511
640
|
test("clock ids never collide after a removal (max-scan, not length+1)", async () => {
|
|
512
|
-
const ctx =
|
|
641
|
+
const ctx = createToolContext();
|
|
513
642
|
seedPlaying(ctx); // has clock_1
|
|
514
643
|
|
|
515
|
-
await
|
|
516
|
-
await
|
|
517
|
-
await
|
|
644
|
+
await run("update_state", { addClockName: "Second" }, ctx); // clock_2
|
|
645
|
+
await run("update_state", { removeClockName: "Doom" }, ctx); // removes clock_1
|
|
646
|
+
await run("update_state", { addClockName: "Third" }, ctx);
|
|
518
647
|
|
|
519
648
|
const state = gameSlot.get(ctx);
|
|
520
649
|
const ids = state.clocks.map((c) => c.id);
|
|
@@ -523,19 +652,65 @@ describe("update_state", () => {
|
|
|
523
652
|
});
|
|
524
653
|
|
|
525
654
|
test("advancing a clock to full reports its trigger event", async () => {
|
|
526
|
-
const ctx =
|
|
655
|
+
const ctx = createToolContext();
|
|
527
656
|
const state = playingState();
|
|
528
657
|
state.clocks[0]!.filled = 3; // 3 of 4
|
|
529
658
|
seedPlaying(ctx, state);
|
|
530
659
|
|
|
531
660
|
const result = expectToolOk<{ clockEvents: { clock: string; trigger: string }[] }>(
|
|
532
|
-
await
|
|
661
|
+
await run("update_state", { advanceClockName: "Doom" }, ctx),
|
|
533
662
|
);
|
|
534
663
|
expect(result.clockEvents).toEqual([{ clock: "Doom", trigger: "The doom arrives" }]);
|
|
535
664
|
});
|
|
536
665
|
|
|
666
|
+
test("a clock can be advanced by the ordinal the player used", async () => {
|
|
667
|
+
const ctx = createToolContext();
|
|
668
|
+
const state = playingState();
|
|
669
|
+
state.clocks.push({
|
|
670
|
+
id: "clock_2",
|
|
671
|
+
name: "The Long Night",
|
|
672
|
+
clockType: "progress",
|
|
673
|
+
segments: 2,
|
|
674
|
+
filled: 1,
|
|
675
|
+
triggerDescription: "Dawn breaks",
|
|
676
|
+
});
|
|
677
|
+
seedPlaying(ctx, state);
|
|
678
|
+
|
|
679
|
+
const result = expectToolOk<{ clockEvents: { clock: string; trigger: string }[] }>(
|
|
680
|
+
await run("update_state", { advanceClockName: "the second one" }, ctx),
|
|
681
|
+
);
|
|
682
|
+
expect(result.clockEvents).toEqual([{ clock: "The Long Night", trigger: "Dawn breaks" }]);
|
|
683
|
+
expect(gameSlot.get(ctx).clocks[1]?.filled).toBe(2);
|
|
684
|
+
});
|
|
685
|
+
|
|
686
|
+
test("removing by ordinal drops exactly that clock", async () => {
|
|
687
|
+
const ctx = createToolContext();
|
|
688
|
+
const state = playingState();
|
|
689
|
+
state.clocks.push({
|
|
690
|
+
id: "clock_2",
|
|
691
|
+
name: "The Long Night",
|
|
692
|
+
clockType: "progress",
|
|
693
|
+
segments: 2,
|
|
694
|
+
filled: 0,
|
|
695
|
+
triggerDescription: "Dawn breaks",
|
|
696
|
+
});
|
|
697
|
+
seedPlaying(ctx, state);
|
|
698
|
+
|
|
699
|
+
expectToolOk(await run("update_state", { removeClockName: "the first clock" }, ctx));
|
|
700
|
+
expect(gameSlot.get(ctx).clocks.map((c) => c.id)).toEqual(["clock_2"]);
|
|
701
|
+
});
|
|
702
|
+
|
|
703
|
+
test("a clock nobody has warns instead of silently doing nothing", async () => {
|
|
704
|
+
const ctx = createToolContext();
|
|
705
|
+
seedPlaying(ctx);
|
|
706
|
+
const result = expectToolOk<{ warnings?: string[] }>(
|
|
707
|
+
await run("update_state", { advanceClockName: "The Reckoning" }, ctx),
|
|
708
|
+
);
|
|
709
|
+
expect(result.warnings?.[0]).toMatch(/No clock matching/);
|
|
710
|
+
});
|
|
711
|
+
|
|
537
712
|
test("NPC count is capped at MAX_NPCS with a warning", async () => {
|
|
538
|
-
const ctx =
|
|
713
|
+
const ctx = createToolContext();
|
|
539
714
|
const state = playingState();
|
|
540
715
|
while (state.npcs.length < MAX_NPCS) {
|
|
541
716
|
state.npcs.push(makeNpc({ id: `npc_${state.npcs.length + 1}`, name: "Extra" }));
|
|
@@ -543,24 +718,56 @@ describe("update_state", () => {
|
|
|
543
718
|
seedPlaying(ctx, state);
|
|
544
719
|
|
|
545
720
|
const result = expectToolOk<{ warnings?: string[] }>(
|
|
546
|
-
await
|
|
721
|
+
await run("update_state", { addNpcName: "One Too Many" }, ctx),
|
|
547
722
|
);
|
|
548
723
|
expect(result.warnings?.[0]).toMatch(/NPC limit/);
|
|
549
724
|
const after = gameSlot.get(ctx);
|
|
550
725
|
expect(after.npcs).toHaveLength(MAX_NPCS);
|
|
551
726
|
});
|
|
552
727
|
|
|
553
|
-
test("
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
728
|
+
test("the chronicle is capped by the SLOT, keeping the newest entries", async () => {
|
|
729
|
+
// The bound is declared as `caps` on `gameSlot` and enforced by nothing in
|
|
730
|
+
// this tool, which is exactly why it is worth a test: `update_state` pushes
|
|
731
|
+
// unconditionally, so a dropped `caps` key would leave the log growing into
|
|
732
|
+
// every `syncState` frame with nothing red.
|
|
733
|
+
const ctx = createToolContext();
|
|
734
|
+
seedPlaying(ctx);
|
|
735
|
+
for (let i = 1; i <= MAX_LOG_ENTRIES + 5; i++) {
|
|
736
|
+
await run("update_state", { logEntry: `scene ${i}` }, ctx);
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
const log = gameSlot.get(ctx).sessionLog;
|
|
740
|
+
expect(log).toHaveLength(MAX_LOG_ENTRIES);
|
|
741
|
+
expect(log[0]?.summary).toBe("scene 6");
|
|
742
|
+
expect(log.at(-1)?.summary).toBe(`scene ${MAX_LOG_ENTRIES + 5}`);
|
|
743
|
+
});
|
|
744
|
+
|
|
745
|
+
test("the input schema rejects out-of-range and malformed values", async () => {
|
|
746
|
+
// `toolInputIssues` / `parseToolInput` (`@alexkroman1/aai/testing`) rather
|
|
747
|
+
// than reaching for `inputSchema!["~standard"]` — the reach eighteen sites
|
|
748
|
+
// across ten templates had re-derived. They also take the tool by NAME, so
|
|
749
|
+
// this asks the agent's own registry the same question the runner above
|
|
750
|
+
// does, and the rejection reports WHICH field failed instead of "it threw".
|
|
751
|
+
for (const bad of [
|
|
752
|
+
{ addClockSegments: 1 }, // below min
|
|
753
|
+
{ addClockSegments: 13 }, // above max
|
|
754
|
+
{ addClockSegments: 2.5 }, // non-integer
|
|
755
|
+
{ updateNpcBond: 5 }, // above MAX_BOND
|
|
756
|
+
{ updateNpcBond: -1 },
|
|
757
|
+
{ timeOfDay: "noonish" }, // not a phase
|
|
758
|
+
]) {
|
|
759
|
+
expect
|
|
760
|
+
.soft(await toolInputIssues(agentDef, "update_state", bad), JSON.stringify(bad))
|
|
761
|
+
.toBeDefined();
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
await expect(
|
|
765
|
+
parseToolInput(agentDef, "update_state", {
|
|
766
|
+
addClockSegments: 6,
|
|
767
|
+
updateNpcBond: 4,
|
|
768
|
+
timeOfDay: "night",
|
|
769
|
+
}),
|
|
770
|
+
).resolves.toMatchObject({ addClockSegments: 6, timeOfDay: "night" });
|
|
564
771
|
});
|
|
565
772
|
});
|
|
566
773
|
|
|
@@ -573,26 +780,19 @@ describe("update_state", () => {
|
|
|
573
780
|
|
|
574
781
|
describe("the story flow", () => {
|
|
575
782
|
test("a fresh session is awaiting setup, and the play tools refuse there", async () => {
|
|
576
|
-
const ctx =
|
|
783
|
+
const ctx = createToolContext();
|
|
577
784
|
expect(storyFlow.position(ctx).state).toBe("awaitingSetup");
|
|
578
785
|
|
|
579
786
|
// All of these used to RUN before a character existed: `action_roll` rolled
|
|
580
787
|
// 2d6 against the stats of nobody and applied consequences to a game that was
|
|
581
|
-
// not there.
|
|
582
|
-
// slot `load_game` would later restore over a real one — both are gone with
|
|
583
|
-
// `ctx.db`.)
|
|
788
|
+
// not there.
|
|
584
789
|
for (const call of [
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
),
|
|
589
|
-
updateState.execute({ location: "Nowhere" }, ctx),
|
|
590
|
-
callNoArgs(burnMomentum, ctx),
|
|
790
|
+
run("action_roll", SWING, ctx),
|
|
791
|
+
run("update_state", { location: "Nowhere" }, ctx),
|
|
792
|
+
run("burn_momentum", ctx),
|
|
591
793
|
]) {
|
|
592
|
-
const refusal = await call;
|
|
593
|
-
expect(
|
|
594
|
-
expect(isToolFailure(refusal) && refusal.error).toMatch(/awaitingSetup/);
|
|
595
|
-
expect(isToolFailure(refusal) && refusal.error).toMatch(/setup_character/);
|
|
794
|
+
const refusal = expectDialogRefused(await call, "awaitingSetup");
|
|
795
|
+
expect(refusal.error).toContain("setup_character");
|
|
596
796
|
}
|
|
597
797
|
|
|
598
798
|
// And nothing ran.
|
|
@@ -600,32 +800,27 @@ describe("the story flow", () => {
|
|
|
600
800
|
});
|
|
601
801
|
|
|
602
802
|
test("setup opens play, a roll leaves one standing, and settling closes the window", async () => {
|
|
603
|
-
const ctx =
|
|
803
|
+
const ctx = createToolContext();
|
|
604
804
|
// `state`/`instruction`, not `at`/`next`: the ungated tools spread the
|
|
605
805
|
// `DialogPosition` verbatim now, so they report their position under the
|
|
606
806
|
// same keys every gated tool's result carries — which is what the system
|
|
607
807
|
// prompt already claimed.
|
|
608
|
-
const created = await
|
|
808
|
+
const created = (await run("setup_character", SETUP_ARGS, ctx)) as Answered;
|
|
609
809
|
expect(created.state).toBe("playing.awaitingRoll");
|
|
610
810
|
expect(created.instruction).toMatch(/action_roll/);
|
|
611
811
|
|
|
612
|
-
expectToolOk(
|
|
613
|
-
await actionRoll.execute(
|
|
614
|
-
{ move: "clash", stat: "iron", position: "risky", effect: "standard", purpose: "swing" },
|
|
615
|
-
ctx,
|
|
616
|
-
),
|
|
617
|
-
);
|
|
812
|
+
expectToolOk(await run("action_roll", SWING, ctx));
|
|
618
813
|
expect(storyFlow.position(ctx).state).toBe("playing.rollResolved");
|
|
619
814
|
|
|
620
815
|
// Moving the scene on SPENDS the roll: the burn window is closed.
|
|
621
|
-
expectToolOk(await
|
|
816
|
+
expectToolOk(await run("update_state", { location: "The Bridge" }, ctx));
|
|
622
817
|
expect(storyFlow.position(ctx).state).toBe("playing.awaitingRoll");
|
|
623
|
-
|
|
818
|
+
expectDialogRefused(await run("burn_momentum", ctx), "playing.awaitingRoll");
|
|
624
819
|
});
|
|
625
820
|
|
|
626
821
|
test("check_state reports the position and is legal before setup", async () => {
|
|
627
|
-
const ctx =
|
|
628
|
-
const before = await
|
|
822
|
+
const ctx = createToolContext();
|
|
823
|
+
const before = (await run("check_state", ctx)) as Answered;
|
|
629
824
|
expect(before.state).toBe("awaitingSetup");
|
|
630
825
|
expect(before.instruction).toMatch(/setup_character/);
|
|
631
826
|
expect(before.done).toBe(false);
|
|
@@ -633,7 +828,7 @@ describe("the story flow", () => {
|
|
|
633
828
|
});
|
|
634
829
|
|
|
635
830
|
test("a game over is terminal: nothing rolls, and setup starts a new story", async () => {
|
|
636
|
-
const ctx =
|
|
831
|
+
const ctx = createToolContext();
|
|
637
832
|
const dead = playingState();
|
|
638
833
|
dead.health = 0;
|
|
639
834
|
dead.spirit = 0;
|
|
@@ -644,23 +839,55 @@ describe("the story flow", () => {
|
|
|
644
839
|
// act on it, so a player could keep rolling after both tracks emptied. The
|
|
645
840
|
// WRITE is `gameSlot`'s `after` hook; this tool no longer calls it, which
|
|
646
841
|
// is the point of moving it there.
|
|
647
|
-
expectToolOk(await
|
|
842
|
+
expectToolOk(await run("update_state", { health: 0, spirit: 0 }, ctx));
|
|
648
843
|
const at = storyFlow.position(ctx);
|
|
649
844
|
expect(at.state).toBe("gameOver");
|
|
650
845
|
expect(at.done).toBe(true);
|
|
651
846
|
|
|
652
|
-
|
|
653
|
-
{ move: "clash", stat: "iron", position: "risky", effect: "standard", purpose: "swing" },
|
|
654
|
-
ctx,
|
|
655
|
-
);
|
|
656
|
-
expect(isToolFailure(refused)).toBe(true);
|
|
657
|
-
expect(isToolFailure(refused) && refused.error).toMatch(/gameOver/);
|
|
847
|
+
expectDialogRefused(await run("action_roll", SWING, ctx), "gameOver");
|
|
658
848
|
|
|
659
849
|
// Starting over is legal from anywhere, the ending included.
|
|
660
|
-
const restarted = await
|
|
850
|
+
const restarted = (await run("setup_character", SETUP_ARGS, ctx)) as Answered;
|
|
661
851
|
expect(restarted.state).toBe("playing.awaitingRoll");
|
|
662
852
|
});
|
|
663
853
|
|
|
854
|
+
test("the projection withholds the plot the player has not reached", () => {
|
|
855
|
+
const game: GameState = {
|
|
856
|
+
...structuredClone(DEFAULT_STATE),
|
|
857
|
+
backstory: "SPOILER backstory",
|
|
858
|
+
playerWishes: "SPOILER wishes",
|
|
859
|
+
contentLines: "SPOILER lines",
|
|
860
|
+
settingTone: "SPOILER tone",
|
|
861
|
+
settingArchetype: "SPOILER archetype",
|
|
862
|
+
settingDescription: "SPOILER description",
|
|
863
|
+
storyBlueprint: {
|
|
864
|
+
structureType: "3act",
|
|
865
|
+
centralConflict: "c",
|
|
866
|
+
antagonistForce: "a",
|
|
867
|
+
thematicThread: "t",
|
|
868
|
+
currentAct: 1,
|
|
869
|
+
storyComplete: false,
|
|
870
|
+
acts: [
|
|
871
|
+
{ phase: "setup", title: "One", goal: "g1", mood: "m1", transitionTrigger: "SPOILER1" },
|
|
872
|
+
{ phase: "turn", title: "Two", goal: "g2", mood: "m2", transitionTrigger: "SPOILER2" },
|
|
873
|
+
],
|
|
874
|
+
},
|
|
875
|
+
};
|
|
876
|
+
|
|
877
|
+
const view = gameView(game);
|
|
878
|
+
// The sidebar needs how far along and which phase, and nothing else about
|
|
879
|
+
// the arc: an act's goal, mood and transition trigger are the twists the
|
|
880
|
+
// player has not reached, and slot state is otherwise server-side, so this
|
|
881
|
+
// projection is the only thing standing between them and devtools.
|
|
882
|
+
expect(view.storyArc).toEqual({
|
|
883
|
+
currentAct: 1,
|
|
884
|
+
totalActs: 2,
|
|
885
|
+
phase: "setup",
|
|
886
|
+
storyComplete: false,
|
|
887
|
+
});
|
|
888
|
+
expect(JSON.stringify(view)).not.toMatch(/SPOILER/);
|
|
889
|
+
});
|
|
890
|
+
|
|
664
891
|
// Two resume tests stood here — a saved game reopening in play, and one saved
|
|
665
892
|
// after the ending reopening as over. Both drove `save_game`/`load_game`, which
|
|
666
893
|
// are gone with `ctx.db`. What they proved about the FLOW (a resumed position is
|