@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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { agent } from "@alexkroman1/aai";
|
|
2
|
-
import { gameProjection } from "./shared.ts";
|
|
2
|
+
import { gameProjection, storyFlow } from "./shared.ts";
|
|
3
3
|
|
|
4
4
|
export default agent({
|
|
5
5
|
name: "Solo RPG",
|
|
@@ -12,7 +12,18 @@ export default agent({
|
|
|
12
12
|
// One declaration replaces a `ctx.send("game_state", state)` in every
|
|
13
13
|
// state-mutating tool — six of them, and adding a seventh meant
|
|
14
14
|
// remembering to push or watching the UI quietly fall out of sync.
|
|
15
|
-
//
|
|
16
|
-
//
|
|
15
|
+
// NOT the identity: `gameView` withholds the seven fields the sidebar never
|
|
16
|
+
// reads and every unplayed act's goal and mood with them, which is the only
|
|
17
|
+
// defence there is against a spoiler leak (see `shared.ts`). The slot's own
|
|
18
|
+
// default is what a session that has run no tool projects.
|
|
17
19
|
syncState: gameProjection,
|
|
20
|
+
|
|
21
|
+
// The flow gates the tools whether or not it is declared here. What DECLARING
|
|
22
|
+
// it buys is the other half the states were written for: the active state's
|
|
23
|
+
// `instruction` goes in front of the model on every turn, rather than only on
|
|
24
|
+
// the turns a tool result happens to carry it back. `system-prompt.md` already
|
|
25
|
+
// tells the narrator to read `instruction` as ground truth — this is what
|
|
26
|
+
// makes that true before the first tool call of a turn, and it is the field
|
|
27
|
+
// six of the other seven flow templates declare.
|
|
28
|
+
dialogs: [storyFlow],
|
|
18
29
|
});
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
MAX_RESOURCE,
|
|
11
11
|
MIN_MOMENTUM,
|
|
12
12
|
type NPC,
|
|
13
|
-
type
|
|
13
|
+
type StoryArcView,
|
|
14
14
|
type TIME_PHASES,
|
|
15
15
|
} from "./shared.ts";
|
|
16
16
|
|
|
@@ -390,11 +390,10 @@ function NpcCard({ npc }: { npc: DeepReadonly<NPC> }) {
|
|
|
390
390
|
);
|
|
391
391
|
}
|
|
392
392
|
|
|
393
|
-
function StoryArc({ story }: { story: DeepReadonly<
|
|
394
|
-
const totalActs = story.
|
|
395
|
-
const currentPhase = story.acts[story.currentAct - 1]?.phase ?? "";
|
|
393
|
+
function StoryArc({ story }: { story: DeepReadonly<StoryArcView> }) {
|
|
394
|
+
const totalActs = story.totalActs;
|
|
396
395
|
const pct = totalActs > 0 ? ((story.currentAct - 1) / totalActs) * 100 : 0;
|
|
397
|
-
const phaseLabel = PHASE_LABELS[
|
|
396
|
+
const phaseLabel = PHASE_LABELS[story.phase] || story.phase;
|
|
398
397
|
return (
|
|
399
398
|
<div style={{ marginBottom: "8px" }}>
|
|
400
399
|
<SectionHeader
|
|
@@ -460,7 +459,10 @@ function StoryArc({ story }: { story: DeepReadonly<StoryBlueprint> }) {
|
|
|
460
459
|
function Sidebar() {
|
|
461
460
|
const game = useAgentState(gameProjection);
|
|
462
461
|
return (
|
|
462
|
+
// `.aai-scroll` is the SDK's thin scrollbar; the sheet's own `.et-scroll`
|
|
463
|
+
// rules were declared here for years and applied to no element at all.
|
|
463
464
|
<div
|
|
465
|
+
className="et-sidebar aai-scroll"
|
|
464
466
|
style={{
|
|
465
467
|
height: "100%",
|
|
466
468
|
overflowY: "auto",
|
|
@@ -476,9 +478,7 @@ function Sidebar() {
|
|
|
476
478
|
.et-gold { color: ${C.accent}; text-shadow: 0 0 8px ${C.accentGlow}; }
|
|
477
479
|
.et-crisis-pulse { animation: crisisPulse 2s ease-in-out infinite; }
|
|
478
480
|
@keyframes crisisPulse { 0%,100% { opacity: 0.6; } 50% { opacity: 1; } }
|
|
479
|
-
.et-
|
|
480
|
-
.et-scroll::-webkit-scrollbar-thumb { background: ${C.borderLight}; border-radius: 3px; }
|
|
481
|
-
.et-scroll::-webkit-scrollbar-track { background: transparent; }
|
|
481
|
+
.et-sidebar { --aai-scrollbar-thumb: ${C.borderLight}; }
|
|
482
482
|
`}</style>
|
|
483
483
|
|
|
484
484
|
{/* Header */}
|
|
@@ -670,9 +670,9 @@ function Sidebar() {
|
|
|
670
670
|
</div>
|
|
671
671
|
|
|
672
672
|
{/* Story Arc */}
|
|
673
|
-
{game.
|
|
673
|
+
{game.storyArc && (
|
|
674
674
|
<div className="et-section">
|
|
675
|
-
<StoryArc story={game.
|
|
675
|
+
<StoryArc story={game.storyArc} />
|
|
676
676
|
</div>
|
|
677
677
|
)}
|
|
678
678
|
|
|
@@ -1,13 +1,24 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
type DeepReadonly,
|
|
3
|
+
dialog,
|
|
4
|
+
pickOne,
|
|
5
|
+
type RandomSource,
|
|
6
|
+
randomInt,
|
|
7
|
+
type SlotCaps,
|
|
8
|
+
sessionSlot,
|
|
9
|
+
shuffled,
|
|
10
|
+
spokenOrdinal,
|
|
11
|
+
} from "@alexkroman1/aai";
|
|
2
12
|
|
|
3
13
|
// ── Tuning Constants ─────────────────────────────────────────────────────────
|
|
4
|
-
export const MAX_SESSION_LOG = 50;
|
|
5
14
|
export const MOMENTUM_RESET = 2;
|
|
6
15
|
export const MAX_RESOURCE = 5;
|
|
7
16
|
export const MIN_MOMENTUM = -6;
|
|
8
17
|
export const MAX_BOND = 4;
|
|
9
18
|
export const MAX_NPCS = 12;
|
|
10
19
|
export const MAX_CLOCKS = 8;
|
|
20
|
+
/** How many chronicle entries the slot keeps. See {@link GAME_CAPS}. */
|
|
21
|
+
export const MAX_LOG_ENTRIES = 50;
|
|
11
22
|
export const MIN_CLOCK_SEGMENTS = 2;
|
|
12
23
|
export const MAX_CLOCK_SEGMENTS = 12;
|
|
13
24
|
export const DEFAULT_CLOCK_SEGMENTS = 6;
|
|
@@ -46,18 +57,18 @@ const SEED_WORDS = [
|
|
|
46
57
|
"coral",
|
|
47
58
|
];
|
|
48
59
|
|
|
49
|
-
/**
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
60
|
+
/**
|
|
61
|
+
* Unbiased Fisher-Yates shuffle. Returns a new array.
|
|
62
|
+
*
|
|
63
|
+
* `shuffled`'s, which is where the unbiasedness argument now lives. What every
|
|
64
|
+
* randomizing helper in this file gained is the `random` parameter: a tool
|
|
65
|
+
* passes `ctx.random`, so a spec can state the dice a scene was resolved on
|
|
66
|
+
* instead of asserting that the result was one of three strings.
|
|
67
|
+
*/
|
|
68
|
+
export const shuffle = shuffled;
|
|
58
69
|
|
|
59
|
-
export function creativitySeed(n = 3): string {
|
|
60
|
-
return shuffle(SEED_WORDS).slice(0, n).join(" ");
|
|
70
|
+
export function creativitySeed(n = 3, random?: RandomSource): string {
|
|
71
|
+
return shuffle(SEED_WORDS, random).slice(0, n).join(" ");
|
|
61
72
|
}
|
|
62
73
|
|
|
63
74
|
// ── Genres, Tones, Archetypes ────────────────────────────────────────────────
|
|
@@ -332,6 +343,19 @@ export const DEFAULT_STATE: GameState = {
|
|
|
332
343
|
// `DEFAULT_STATE` is one module-level object shared by every session in the
|
|
333
344
|
// process, so a factory without it would let one player's game show up in
|
|
334
345
|
// another's.
|
|
346
|
+
/**
|
|
347
|
+
* The bounds the slot enforces, hoisted so the number is a named constant like
|
|
348
|
+
* every other limit in this file.
|
|
349
|
+
*
|
|
350
|
+
* `SlotCaps<GameState>` is what says only an ARRAY field may appear here — the
|
|
351
|
+
* mapped type drops every scalar key, so `chaosFactor: 5` (a plausible typo for
|
|
352
|
+
* a limit that is enforced in `updateChaosFactor` instead) is a compile error
|
|
353
|
+
* rather than a cap on nothing. The session log rides in every `syncState` frame
|
|
354
|
+
* and the client renders its tail, so the slot holds the bound and
|
|
355
|
+
* `update_state` need not.
|
|
356
|
+
*/
|
|
357
|
+
const GAME_CAPS: SlotCaps<GameState> = { sessionLog: MAX_LOG_ENTRIES };
|
|
358
|
+
|
|
335
359
|
export const gameSlot = sessionSlot("game", () => structuredClone(DEFAULT_STATE), {
|
|
336
360
|
// The derived-field recalculation every mutating tool used to have to
|
|
337
361
|
// remember. It was written out by hand in `applyConsequences`,
|
|
@@ -340,14 +364,63 @@ export const gameSlot = sessionSlot("game", () => structuredClone(DEFAULT_STATE)
|
|
|
340
364
|
// `gameOver`, and `gameOver` is what the story flow's `DOWNED` transition
|
|
341
365
|
// reads. `dispatch-center`'s board is the same pattern one template over.
|
|
342
366
|
after: updateCrisisFlags,
|
|
367
|
+
caps: GAME_CAPS,
|
|
343
368
|
});
|
|
344
369
|
|
|
345
370
|
/**
|
|
346
|
-
* The
|
|
347
|
-
*
|
|
348
|
-
*
|
|
371
|
+
* The story arc as the CLIENT needs it: how far along, which phase, and whether
|
|
372
|
+
* the story has finished.
|
|
373
|
+
*
|
|
374
|
+
* NOT the acts. Each `StoryAct` carries a `goal`, a `mood` and a
|
|
375
|
+
* `transitionTrigger` — the twists the player has not reached — and the sidebar
|
|
376
|
+
* renders none of them.
|
|
349
377
|
*/
|
|
350
|
-
export
|
|
378
|
+
export interface StoryArcView {
|
|
379
|
+
currentAct: number;
|
|
380
|
+
totalActs: number;
|
|
381
|
+
phase: string;
|
|
382
|
+
storyComplete: boolean;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* What the browser is sent, which is NOT the whole campaign.
|
|
387
|
+
*
|
|
388
|
+
* This was `gameSlot.projection((game) => game)`, argued as "this campaign IS
|
|
389
|
+
* what the client renders, so there is nothing to trim". It isn't: the sidebar
|
|
390
|
+
* reads 26 of ~35 fields and touches none of the seven dropped here, and of the
|
|
391
|
+
* blueprint it uses only the act COUNT and the current act's phase — so every
|
|
392
|
+
* unplayed act's goal and mood rode in every `syncState` frame. The projection
|
|
393
|
+
* seam is the only defence there is, since slot state is otherwise server-side,
|
|
394
|
+
* and a spoiler leak is invisible in the UI and permanent once someone opens
|
|
395
|
+
* devtools.
|
|
396
|
+
*/
|
|
397
|
+
export function gameView(game: FrozenGameState) {
|
|
398
|
+
const {
|
|
399
|
+
settingTone,
|
|
400
|
+
settingArchetype,
|
|
401
|
+
settingDescription,
|
|
402
|
+
backstory,
|
|
403
|
+
playerWishes,
|
|
404
|
+
contentLines,
|
|
405
|
+
lastRoll,
|
|
406
|
+
storyBlueprint,
|
|
407
|
+
...shown
|
|
408
|
+
} = game;
|
|
409
|
+
return {
|
|
410
|
+
...shown,
|
|
411
|
+
storyArc: storyBlueprint
|
|
412
|
+
? {
|
|
413
|
+
currentAct: storyBlueprint.currentAct,
|
|
414
|
+
totalActs: storyBlueprint.acts.length,
|
|
415
|
+
phase: storyBlueprint.acts[storyBlueprint.currentAct - 1]?.phase ?? "",
|
|
416
|
+
storyComplete: storyBlueprint.storyComplete,
|
|
417
|
+
}
|
|
418
|
+
: null,
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
/** The projection BOTH ends use: `syncState` on the agent, `useAgentState` in the client. */
|
|
423
|
+
export const gameProjection = gameSlot.projection(gameView);
|
|
351
424
|
|
|
352
425
|
// ── The story, as a machine ──────────────────────────────────────────────────
|
|
353
426
|
|
|
@@ -463,12 +536,20 @@ export type FrozenGameState = DeepReadonly<GameState>;
|
|
|
463
536
|
// supported pattern, just not one a shipped template can demonstrate.
|
|
464
537
|
|
|
465
538
|
// ── Helpers ──────────────────────────────────────────────────────────────────
|
|
466
|
-
|
|
467
|
-
|
|
539
|
+
/** One die of `sides`, 1-based. */
|
|
540
|
+
export function d(sides: number, random?: RandomSource): number {
|
|
541
|
+
return randomInt(sides, random) + 1;
|
|
468
542
|
}
|
|
469
543
|
|
|
470
|
-
|
|
471
|
-
|
|
544
|
+
/**
|
|
545
|
+
* One item of a NON-EMPTY list.
|
|
546
|
+
*
|
|
547
|
+
* `pickOne` answers `T | undefined` because a list can be empty; every list
|
|
548
|
+
* this game picks from is a module-level constant that is not, so the assertion
|
|
549
|
+
* is made once here rather than at ten call sites.
|
|
550
|
+
*/
|
|
551
|
+
export function pick<T>(arr: readonly T[], random?: RandomSource): T {
|
|
552
|
+
return pickOne(arr, random) as T;
|
|
472
553
|
}
|
|
473
554
|
|
|
474
555
|
/**
|
|
@@ -504,6 +585,36 @@ export function makeNpc(opts: {
|
|
|
504
585
|
};
|
|
505
586
|
}
|
|
506
587
|
|
|
588
|
+
/**
|
|
589
|
+
* The clock the player meant, by name or by the POSITION they can see.
|
|
590
|
+
*
|
|
591
|
+
* Clocks are a rendered LIST — `client.tsx` draws them in order — so "advance
|
|
592
|
+
* the second clock" is a referent the player has in front of them, and it is
|
|
593
|
+
* the one a phone call produces most often: a clock is named things like "The
|
|
594
|
+
* Syndicate Closes In", and reading that back word-perfect is exactly what
|
|
595
|
+
* speech is worst at. `spokenOrdinal` is the SDK's reader for that ("the second
|
|
596
|
+
* one", "the 2nd clock" → index 1), which replaces the exact `c.name === arg`
|
|
597
|
+
* equality both branches of `update_state` used to do.
|
|
598
|
+
*
|
|
599
|
+
* **Name first, ordinal second, and the order is the safety property.** A clock
|
|
600
|
+
* genuinely called "The First Light" contains an ordinal word, so resolving the
|
|
601
|
+
* ordinal first would silently retarget it at whatever is at index 0. An exact
|
|
602
|
+
* name always wins; the ordinal is only consulted when nothing was named.
|
|
603
|
+
*
|
|
604
|
+
* Generic over the clock's own type — as `dispatch-center`'s `findIncident` is —
|
|
605
|
+
* so one lookup serves an `updateTool` draft and a frozen read alike.
|
|
606
|
+
*/
|
|
607
|
+
export function findClock<C extends { id: string; name: string }>(
|
|
608
|
+
clocks: readonly C[],
|
|
609
|
+
spoken: string,
|
|
610
|
+
): C | undefined {
|
|
611
|
+
const wanted = spoken.trim().toLowerCase();
|
|
612
|
+
const named = clocks.find((c) => c.name.trim().toLowerCase() === wanted);
|
|
613
|
+
if (named) return named;
|
|
614
|
+
const index = spokenOrdinal(spoken);
|
|
615
|
+
return index === undefined ? undefined : clocks[index];
|
|
616
|
+
}
|
|
617
|
+
|
|
507
618
|
export function clockSummary(c: DeepReadonly<Clock>) {
|
|
508
619
|
return {
|
|
509
620
|
id: c.id,
|
|
@@ -522,33 +633,18 @@ export function clockSummary(c: DeepReadonly<Clock>) {
|
|
|
522
633
|
* content boundaries (contentLines) so they survive past the setup turn.
|
|
523
634
|
*/
|
|
524
635
|
export function stateSummary(state: FrozenGameState) {
|
|
636
|
+
// The scalars go through UNCHANGED, so they are spread rather than re-listed:
|
|
637
|
+
// what the names pulled out below do to them is the whole content of this
|
|
638
|
+
// function, and it was buried in twenty-six lines of `x: state.x`. A field
|
|
639
|
+
// added to `GameState` now reaches the model without a second edit here.
|
|
640
|
+
//
|
|
641
|
+
// `lastRoll` is destructured to WITHHOLD it — the dice are narrated by the
|
|
642
|
+
// tool that rolled them, not inspected; `crisisMode` and `gameOver` are
|
|
643
|
+
// pulled out because the stored flags are stale here and recomputed below.
|
|
644
|
+
const { npcs, clocks, storyBlueprint, sessionLog, lastRoll, crisisMode, gameOver, ...scalars } =
|
|
645
|
+
state;
|
|
525
646
|
return {
|
|
526
|
-
|
|
527
|
-
settingGenre: state.settingGenre,
|
|
528
|
-
settingTone: state.settingTone,
|
|
529
|
-
settingArchetype: state.settingArchetype,
|
|
530
|
-
settingDescription: state.settingDescription,
|
|
531
|
-
playerName: state.playerName,
|
|
532
|
-
characterConcept: state.characterConcept,
|
|
533
|
-
backstory: state.backstory,
|
|
534
|
-
playerWishes: state.playerWishes,
|
|
535
|
-
contentLines: state.contentLines,
|
|
536
|
-
kidMode: state.kidMode,
|
|
537
|
-
edge: state.edge,
|
|
538
|
-
heart: state.heart,
|
|
539
|
-
iron: state.iron,
|
|
540
|
-
shadow: state.shadow,
|
|
541
|
-
wits: state.wits,
|
|
542
|
-
health: state.health,
|
|
543
|
-
spirit: state.spirit,
|
|
544
|
-
supply: state.supply,
|
|
545
|
-
momentum: state.momentum,
|
|
546
|
-
maxMomentum: state.maxMomentum,
|
|
547
|
-
sceneCount: state.sceneCount,
|
|
548
|
-
currentLocation: state.currentLocation,
|
|
549
|
-
currentSceneContext: state.currentSceneContext,
|
|
550
|
-
timeOfDay: state.timeOfDay,
|
|
551
|
-
chaosFactor: state.chaosFactor,
|
|
647
|
+
...scalars,
|
|
552
648
|
// DERIVED here rather than copied off the state: `after` restores the
|
|
553
649
|
// stored flags only once the calling body has returned, so a summary built
|
|
554
650
|
// inside that body would report the tracks it just emptied as survivable.
|
|
@@ -556,34 +652,53 @@ export function stateSummary(state: FrozenGameState) {
|
|
|
556
652
|
gameOver: isGameOver(state),
|
|
557
653
|
// NPCs go to the LLM whole (nothing withheld) — copied so a mutation of
|
|
558
654
|
// the summary can't reach live state.
|
|
559
|
-
npcs:
|
|
560
|
-
clocks:
|
|
561
|
-
storyBlueprint:
|
|
655
|
+
npcs: npcs.filter((n) => n.status !== "deceased").map((n) => ({ ...n })),
|
|
656
|
+
clocks: clocks.map(clockSummary),
|
|
657
|
+
storyBlueprint: storyBlueprint
|
|
562
658
|
? {
|
|
563
|
-
structureType:
|
|
564
|
-
currentAct:
|
|
565
|
-
totalActs:
|
|
566
|
-
centralConflict:
|
|
567
|
-
thematicThread:
|
|
568
|
-
storyComplete:
|
|
569
|
-
currentPhase:
|
|
659
|
+
structureType: storyBlueprint.structureType,
|
|
660
|
+
currentAct: storyBlueprint.currentAct,
|
|
661
|
+
totalActs: storyBlueprint.acts.length,
|
|
662
|
+
centralConflict: storyBlueprint.centralConflict,
|
|
663
|
+
thematicThread: storyBlueprint.thematicThread,
|
|
664
|
+
storyComplete: storyBlueprint.storyComplete,
|
|
665
|
+
currentPhase: storyBlueprint.acts[storyBlueprint.currentAct - 1]?.phase,
|
|
570
666
|
}
|
|
571
667
|
: null,
|
|
572
|
-
recentLog:
|
|
668
|
+
recentLog: sessionLog.slice(-5),
|
|
573
669
|
};
|
|
574
670
|
}
|
|
575
671
|
|
|
576
672
|
// ── Dice System ──────────────────────────────────────────────────────────────
|
|
577
|
-
export
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
673
|
+
export type RollOutcome = "STRONG_HIT" | "WEAK_HIT" | "MISS";
|
|
674
|
+
|
|
675
|
+
/**
|
|
676
|
+
* The game's central rule: a score beats both challenge dice, one of them, or
|
|
677
|
+
* neither. Written ONCE — burning momentum is "re-resolve with momentum as the
|
|
678
|
+
* score", so both callers ask the same function rather than each spelling the
|
|
679
|
+
* ladder out.
|
|
680
|
+
*/
|
|
681
|
+
export function resolveRoll(score: number, c1: number, c2: number): RollOutcome {
|
|
682
|
+
if (score > c1 && score > c2) return "STRONG_HIT";
|
|
683
|
+
if (score > c1 || score > c2) return "WEAK_HIT";
|
|
684
|
+
return "MISS";
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
/** How good an outcome is, for comparing two of them. */
|
|
688
|
+
const OUTCOME_RANK: Record<RollOutcome, number> = { MISS: 0, WEAK_HIT: 1, STRONG_HIT: 2 };
|
|
689
|
+
|
|
690
|
+
export function rollAction(
|
|
691
|
+
statName: string,
|
|
692
|
+
statValue: number,
|
|
693
|
+
move: string,
|
|
694
|
+
random?: RandomSource,
|
|
695
|
+
) {
|
|
696
|
+
const d1 = d(6, random),
|
|
697
|
+
d2 = d(6, random);
|
|
698
|
+
const c1 = d(10, random),
|
|
699
|
+
c2 = d(10, random);
|
|
582
700
|
const actionScore = Math.min(d1 + d2 + statValue, 10);
|
|
583
|
-
|
|
584
|
-
if (actionScore > c1 && actionScore > c2) result = "STRONG_HIT";
|
|
585
|
-
else if (actionScore > c1 || actionScore > c2) result = "WEAK_HIT";
|
|
586
|
-
else result = "MISS";
|
|
701
|
+
const result = resolveRoll(actionScore, c1, c2);
|
|
587
702
|
const match = c1 === c2;
|
|
588
703
|
return { d1, d2, c1, c2, statName, statValue, actionScore, result, move, match };
|
|
589
704
|
}
|
|
@@ -596,13 +711,13 @@ export function updateChaosFactor(game: GameState, result: string) {
|
|
|
596
711
|
else if (result === "STRONG_HIT") game.chaosFactor = Math.max(3, game.chaosFactor - 1);
|
|
597
712
|
}
|
|
598
713
|
|
|
599
|
-
export function checkChaosInterrupt(game: GameState): string | null {
|
|
714
|
+
export function checkChaosInterrupt(game: GameState, random?: RandomSource): string | null {
|
|
600
715
|
const threshold = game.chaosFactor - 3;
|
|
601
716
|
if (threshold <= 0) return null;
|
|
602
|
-
const roll = d(10);
|
|
717
|
+
const roll = d(10, random);
|
|
603
718
|
if (roll <= threshold) {
|
|
604
719
|
game.chaosFactor = Math.max(3, game.chaosFactor - 1);
|
|
605
|
-
return pick(CHAOS_INTERRUPT_TYPES);
|
|
720
|
+
return pick(CHAOS_INTERRUPT_TYPES, random);
|
|
606
721
|
}
|
|
607
722
|
return null;
|
|
608
723
|
}
|
|
@@ -795,18 +910,19 @@ export function revertConsequences(game: GameState, deltas: ConsequenceDeltas):
|
|
|
795
910
|
}
|
|
796
911
|
|
|
797
912
|
// ── Momentum Burn ────────────────────────────────────────────────────────────
|
|
913
|
+
/**
|
|
914
|
+
* Burning momentum re-resolves the roll with momentum standing in for the action
|
|
915
|
+
* score. It is offered only when that IMPROVES the outcome — which is what the
|
|
916
|
+
* rank comparison says, where four flat `if`s said it as a truth table.
|
|
917
|
+
*/
|
|
798
918
|
export function canBurnMomentum(
|
|
799
919
|
game: GameState,
|
|
800
920
|
roll: Pick<RollResult, "result" | "c1" | "c2">,
|
|
801
921
|
): "STRONG_HIT" | "WEAK_HIT" | null {
|
|
802
922
|
if (game.momentum <= 0) return null;
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
return "WEAK_HIT";
|
|
807
|
-
if (roll.result === "WEAK_HIT" && game.momentum > roll.c1 && game.momentum > roll.c2)
|
|
808
|
-
return "STRONG_HIT";
|
|
809
|
-
return null;
|
|
923
|
+
const upgraded = resolveRoll(game.momentum, roll.c1, roll.c2);
|
|
924
|
+
if (OUTCOME_RANK[upgraded] <= OUTCOME_RANK[roll.result]) return null;
|
|
925
|
+
return upgraded === "MISS" ? null : upgraded;
|
|
810
926
|
}
|
|
811
927
|
|
|
812
928
|
// ── Kishotenketsu Probability ────────────────────────────────────────────────
|
|
@@ -820,9 +936,12 @@ const KISHOTENKETSU_PROB: Record<string, number> = {
|
|
|
820
936
|
absurd_grotesque: 0.2,
|
|
821
937
|
};
|
|
822
938
|
|
|
823
|
-
export function chooseStoryStructure(
|
|
939
|
+
export function chooseStoryStructure(
|
|
940
|
+
tone: string,
|
|
941
|
+
random: RandomSource = Math.random,
|
|
942
|
+
): "3act" | "kishotenketsu" {
|
|
824
943
|
const prob = KISHOTENKETSU_PROB[tone] ?? 0.1;
|
|
825
|
-
return
|
|
944
|
+
return random() < prob ? "kishotenketsu" : "3act";
|
|
826
945
|
}
|
|
827
946
|
|
|
828
947
|
export const RESULT_LABELS: Record<string, string> = {
|
|
@@ -38,7 +38,7 @@ export default storyFlow.tool({
|
|
|
38
38
|
execute: (args, ctx) =>
|
|
39
39
|
gameSlot.update(ctx, (state) => {
|
|
40
40
|
const statValue = state[args.stat];
|
|
41
|
-
const roll = rollAction(args.stat, statValue, args.move);
|
|
41
|
+
const roll = rollAction(args.stat, statValue, args.move, ctx.random);
|
|
42
42
|
|
|
43
43
|
// Apply consequences
|
|
44
44
|
const { consequences, clockEvents, deltas } = applyConsequences(
|
|
@@ -62,8 +62,12 @@ export default storyFlow.tool({
|
|
|
62
62
|
// Update chaos factor
|
|
63
63
|
updateChaosFactor(state, roll.result);
|
|
64
64
|
|
|
65
|
-
// Check for chaos interrupt
|
|
66
|
-
|
|
65
|
+
// Check for chaos interrupt. `ctx.random` here as everywhere else in this
|
|
66
|
+
// body: the parameter is optional and falls back to `Math.random`, so
|
|
67
|
+
// omitting it took ONE of a roll's five draws off the seam and out of the
|
|
68
|
+
// process — a scene resolved from a seeded context was reproducible in its
|
|
69
|
+
// dice and not in its interrupt.
|
|
70
|
+
const interrupt = checkChaosInterrupt(state, ctx.random);
|
|
67
71
|
|
|
68
72
|
// Increment scene count
|
|
69
73
|
state.sceneCount++;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { toolFailure } from "@alexkroman1/aai/utils";
|
|
1
2
|
import {
|
|
2
3
|
applyConsequences,
|
|
3
4
|
canBurnMomentum,
|
|
@@ -23,6 +24,14 @@ import {
|
|
|
23
24
|
* the roll was already a Strong Hit, and whether the momentum beats the
|
|
24
25
|
* challenge dice. Those are the rules of the game; the gate is the shape of the
|
|
25
26
|
* turn.
|
|
27
|
+
*
|
|
28
|
+
* Each of them answers `toolFailure(…)` (`@alexkroman1/aai/utils` — the subpath
|
|
29
|
+
* that owns the failure vocabulary, and the one that stays free of zod). A bare
|
|
30
|
+
* `{ error: "…" }` literal is structurally the same value, which is exactly why
|
|
31
|
+
* it was worth replacing: it made "this arm is a FAILURE" a coincidence of
|
|
32
|
+
* spelling rather than a call, and `sendFrom` below is typed
|
|
33
|
+
* `Exclude<R, ToolFailure>` — so what subtracts these three arms from the
|
|
34
|
+
* transition's argument now has a name at the site that produces them.
|
|
26
35
|
*/
|
|
27
36
|
export default storyFlow.tool({
|
|
28
37
|
description:
|
|
@@ -35,19 +44,18 @@ export default storyFlow.tool({
|
|
|
35
44
|
// a roll is standing and nothing recorded one — which no code path
|
|
36
45
|
// produces: `action_roll` writes `lastRoll` and sends `ROLLED` in the same
|
|
37
46
|
// call. Reported rather than thrown, mid-game.
|
|
38
|
-
if (!last) return
|
|
47
|
+
if (!last) return toolFailure("No recent action roll to upgrade. Roll first.");
|
|
39
48
|
if (last.result === "STRONG_HIT") {
|
|
40
|
-
return
|
|
49
|
+
return toolFailure("The last roll was already a Strong Hit. Nothing to upgrade.");
|
|
41
50
|
}
|
|
42
51
|
|
|
43
52
|
const upgrade = canBurnMomentum(state, last);
|
|
44
53
|
if (!upgrade) {
|
|
45
|
-
return
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
};
|
|
54
|
+
return toolFailure(
|
|
55
|
+
state.momentum <= 0
|
|
56
|
+
? "Momentum is 0 or negative. Cannot burn."
|
|
57
|
+
: "Momentum not high enough to improve the result.",
|
|
58
|
+
);
|
|
51
59
|
}
|
|
52
60
|
|
|
53
61
|
const previousMomentum = state.momentum;
|
|
@@ -212,7 +212,7 @@ export default tool({
|
|
|
212
212
|
}),
|
|
213
213
|
execute(args, ctx) {
|
|
214
214
|
if (args.type === "yes_no") {
|
|
215
|
-
const roll = d(6);
|
|
215
|
+
const roll = d(6, ctx.random);
|
|
216
216
|
const answer = roll <= 2 ? "No" : roll <= 4 ? "Yes, but with a complication" : "Yes";
|
|
217
217
|
return { type: "yes_no", roll, answer };
|
|
218
218
|
}
|
|
@@ -226,7 +226,7 @@ export default tool({
|
|
|
226
226
|
// `update` rather than becoming `gameSlot.updateTool` — the other four
|
|
227
227
|
// read nothing and store nothing.
|
|
228
228
|
return gameSlot.update(ctx, (game) => {
|
|
229
|
-
const interrupt = checkChaosInterrupt(game);
|
|
229
|
+
const interrupt = checkChaosInterrupt(game, ctx.random);
|
|
230
230
|
return {
|
|
231
231
|
type: "chaos_check",
|
|
232
232
|
chaosFactor: game.chaosFactor,
|
|
@@ -237,19 +237,19 @@ export default tool({
|
|
|
237
237
|
}
|
|
238
238
|
|
|
239
239
|
if (args.type === "npc_reaction") {
|
|
240
|
-
return { type: "npc_reaction", reaction: pick(REACTIONS) };
|
|
240
|
+
return { type: "npc_reaction", reaction: pick(REACTIONS, ctx.random) };
|
|
241
241
|
}
|
|
242
242
|
|
|
243
243
|
if (args.type === "scene_twist") {
|
|
244
|
-
return { type: "scene_twist", twist: pick(TWISTS) };
|
|
244
|
+
return { type: "scene_twist", twist: pick(TWISTS, ctx.random) };
|
|
245
245
|
}
|
|
246
246
|
|
|
247
247
|
// action_theme (default)
|
|
248
248
|
return {
|
|
249
249
|
type: "action_theme",
|
|
250
|
-
action: pick(ACTIONS),
|
|
251
|
-
theme: pick(THEMES),
|
|
252
|
-
seed: creativitySeed(),
|
|
250
|
+
action: pick(ACTIONS, ctx.random),
|
|
251
|
+
theme: pick(THEMES, ctx.random),
|
|
252
|
+
seed: creativitySeed(3, ctx.random),
|
|
253
253
|
};
|
|
254
254
|
},
|
|
255
255
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { tool } from "@alexkroman1/aai";
|
|
1
|
+
import { randomInt, tool } from "@alexkroman1/aai";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import {
|
|
4
4
|
ARCHETYPES,
|
|
@@ -85,7 +85,7 @@ export default tool({
|
|
|
85
85
|
state.kidMode = args.kidMode ?? false;
|
|
86
86
|
|
|
87
87
|
// Generate stats: one at 3, two at 2, two at 1 (total = 7)
|
|
88
|
-
const statValues = shuffle([3, 2, 2, 1, 1]);
|
|
88
|
+
const statValues = shuffle([3, 2, 2, 1, 1], ctx.random);
|
|
89
89
|
const archetypeBias: Record<string, number> = {
|
|
90
90
|
outsider_loner: 0,
|
|
91
91
|
investigator: 4,
|
|
@@ -97,7 +97,7 @@ export default tool({
|
|
|
97
97
|
inventor: 4,
|
|
98
98
|
artist: 1,
|
|
99
99
|
};
|
|
100
|
-
const biasIdx = archetypeBias[args.archetype] ??
|
|
100
|
+
const biasIdx = archetypeBias[args.archetype] ?? randomInt(5, ctx.random);
|
|
101
101
|
const highIdx = statValues.indexOf(3);
|
|
102
102
|
if (highIdx !== biasIdx) {
|
|
103
103
|
[statValues[highIdx], statValues[biasIdx]] = [statValues[biasIdx]!, statValues[highIdx]!];
|
|
@@ -135,7 +135,7 @@ export default tool({
|
|
|
135
135
|
});
|
|
136
136
|
|
|
137
137
|
// Story blueprint
|
|
138
|
-
const structure = chooseStoryStructure(args.tone);
|
|
138
|
+
const structure = chooseStoryStructure(args.tone, ctx.random);
|
|
139
139
|
state.storyBlueprint = {
|
|
140
140
|
structureType: structure,
|
|
141
141
|
centralConflict: args.openingSituation,
|
|
@@ -218,7 +218,7 @@ export default tool({
|
|
|
218
218
|
toneLabel: TONES[args.tone as keyof typeof TONES] || args.tone,
|
|
219
219
|
archetypeLabel: ARCHETYPES[args.archetype as keyof typeof ARCHETYPES] || args.archetype,
|
|
220
220
|
openingSituation: args.openingSituation,
|
|
221
|
-
creativitySeed: creativitySeed(),
|
|
221
|
+
creativitySeed: creativitySeed(3, ctx.random),
|
|
222
222
|
// The position spread verbatim — the same keys every gated tool reports.
|
|
223
223
|
...at,
|
|
224
224
|
// The real saved state — never hardcoded values
|