@alexkroman1/aai-cli 15.1.0 → 16.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -5
- package/bin.mjs +12 -3
- package/dist/_build-target-55dJisQ-.mjs +649 -0
- package/dist/_build-target.d.ts +105 -108
- package/dist/_deno-output.d.ts +23 -0
- package/dist/_deno-target.d.ts +73 -0
- package/dist/{_init-Bsi3DZNJ.mjs → _init-BzQbV8Zh.mjs} +3 -1
- package/dist/_modal-app.d.ts +77 -0
- package/dist/_modal-output.d.ts +31 -0
- package/dist/_modal-target.d.ts +64 -0
- package/dist/_target-bundle.d.ts +27 -0
- package/dist/_target-drain.d.ts +44 -0
- package/dist/_target-output.d.ts +63 -0
- package/dist/{_templates-CIlJ3Vay.mjs → _templates-CuP74F8D.mjs} +94 -4
- package/dist/_templates.d.ts +14 -1
- package/dist/_vercel-output.d.ts +4 -19
- package/dist/_vercel-target.d.ts +169 -0
- package/dist/{test-D032V2cA.mjs → _vitest-runner-AVR9VtXh.mjs} +28 -68
- package/dist/_vitest-runner.d.ts +154 -0
- package/dist/build-ButI2IKc.mjs +689 -0
- package/dist/build.d.ts +11 -0
- package/dist/cli.mjs +12 -11
- package/dist/{dev-Bx9gYBHM.mjs → dev-kodAY23K.mjs} +7 -1
- package/dist/{eval-B3I7FqN9.mjs → eval-DvoSz7SZ.mjs} +1 -1
- package/dist/{init-CQbj3ycf.mjs → init-D363Ls5u.mjs} +2 -2
- package/dist/scaffold/CLAUDE.md +185 -35
- package/dist/scaffold/package.json +4 -4
- package/dist/start.mjs +3 -1
- package/dist/{studio-C_zuRC_z.mjs → studio-CtRBVVFR.mjs} +1 -1
- package/dist/templates/briefing-desk/agent.eval.test.ts +34 -6
- package/dist/templates/briefing-desk/agent.test.ts +347 -55
- package/dist/templates/briefing-desk/agent.ts +12 -0
- package/dist/templates/briefing-desk/shared.ts +220 -31
- package/dist/templates/briefing-desk/slack.ts +108 -0
- package/dist/templates/briefing-desk/system-prompt.md +12 -2
- package/dist/templates/briefing-desk/tools/briefing_so_far.ts +15 -7
- package/dist/templates/briefing-desk/tools/research_topic.ts +20 -28
- package/dist/templates/briefing-desk/tools/send_briefing.ts +77 -0
- package/dist/templates/briefing-desk/tools/verify_claim.ts +60 -14
- package/dist/templates/call-audit/agent.eval.test.ts +5 -0
- package/dist/templates/call-audit/agent.test.ts +6 -1
- package/dist/templates/call-audit/agent.ts +10 -23
- package/dist/templates/call-audit/client.tsx +30 -55
- package/dist/templates/call-audit/guards.test.ts +233 -0
- package/dist/templates/call-audit/workflows/audit.ts +95 -16
- package/dist/templates/call-audit/workflows/ingest.ts +107 -88
- package/dist/templates/call-audit/workflows/media.ts +98 -7
- package/dist/templates/call-audit/workflows/summarize.ts +35 -31
- package/dist/templates/call-audit/workflows/sync-api.ts +15 -6
- package/dist/templates/code-interpreter/agent.eval.test.ts +104 -56
- package/dist/templates/code-interpreter/agent.test.ts +44 -56
- package/dist/templates/code-interpreter/system-prompt.md +1 -1
- package/dist/templates/dispatch-center/agent.eval.test.ts +61 -24
- package/dist/templates/dispatch-center/agent.test.ts +253 -48
- package/dist/templates/dispatch-center/agent.ts +28 -1
- package/dist/templates/dispatch-center/client.tsx +126 -201
- package/dist/templates/dispatch-center/events.ts +48 -0
- package/dist/templates/dispatch-center/shared.ts +42 -1
- package/dist/templates/dispatch-center/tools/incident_create.ts +3 -2
- package/dist/templates/dispatch-center/tools/incident_escalate.ts +2 -1
- package/dist/templates/dispatch-center/tools/ops_dashboard.ts +35 -15
- package/dist/templates/dispatch-center/tools/ops_run_scenario.ts +3 -1
- package/dist/templates/dispatch-center/tools/resources_dispatch.ts +2 -2
- package/dist/templates/executive-assistant/agent.eval.test.ts +233 -0
- package/dist/templates/executive-assistant/agent.test.ts +672 -0
- package/dist/templates/executive-assistant/agent.ts +50 -0
- package/dist/templates/executive-assistant/calendar.test.ts +198 -0
- package/dist/templates/executive-assistant/client.tsx +195 -0
- package/dist/templates/executive-assistant/inbox.ts +233 -0
- package/dist/templates/executive-assistant/meeting.ts +138 -0
- package/dist/templates/executive-assistant/nodes.ts +152 -0
- package/dist/templates/executive-assistant/prompts.ts +331 -0
- package/dist/templates/executive-assistant/review.ts +425 -0
- package/dist/templates/executive-assistant/shared.ts +490 -0
- package/dist/templates/executive-assistant/system-prompt.md +15 -0
- package/dist/templates/executive-assistant/tools/accept.ts +10 -0
- package/dist/templates/executive-assistant/tools/ask_question.ts +30 -0
- package/dist/templates/executive-assistant/tools/draft_reply.ts +67 -0
- package/dist/templates/executive-assistant/tools/edit.ts +10 -0
- package/dist/templates/executive-assistant/tools/ignore.ts +10 -0
- package/dist/templates/executive-assistant/tools/inbox_status.ts +27 -0
- package/dist/templates/executive-assistant/tools/meeting_assistant.ts +52 -0
- package/dist/templates/executive-assistant/tools/new_email.ts +50 -0
- package/dist/templates/executive-assistant/tools/open_email.ts +165 -0
- package/dist/templates/executive-assistant/tools/respond.ts +10 -0
- package/dist/templates/executive-assistant/tools/review_memory.ts +22 -0
- package/dist/templates/executive-assistant/tools/send_calendar_invite.ts +68 -0
- package/dist/templates/executive-assistant/tools/triage_inbox.ts +75 -0
- package/dist/templates/health-assistant/agent.test.ts +134 -15
- package/dist/templates/health-assistant/agent.ts +8 -1
- package/dist/templates/health-assistant/fda.test.ts +130 -0
- package/dist/templates/health-assistant/fda.ts +75 -16
- package/dist/templates/health-assistant/system-prompt.md +9 -0
- package/dist/templates/health-assistant/tools/check_drug_interaction.ts +5 -2
- package/dist/templates/health-assistant/tools/medication_lookup.ts +16 -11
- package/dist/templates/hiring-desk/agent.eval.test.ts +242 -0
- package/dist/templates/hiring-desk/agent.test.ts +1021 -0
- package/dist/templates/hiring-desk/agent.ts +38 -0
- package/dist/templates/hiring-desk/client.tsx +154 -0
- package/dist/templates/hiring-desk/crews.ts +432 -0
- package/dist/templates/hiring-desk/leads.json +86 -0
- package/dist/templates/hiring-desk/screening-lock.test.ts +77 -0
- package/dist/templates/hiring-desk/screening-lock.ts +51 -0
- package/dist/templates/hiring-desk/shared.ts +480 -0
- package/dist/templates/hiring-desk/system-prompt.md +21 -0
- package/dist/templates/hiring-desk/tools/candidate_details.ts +49 -0
- package/dist/templates/hiring-desk/tools/proceed_to_emails.ts +127 -0
- package/dist/templates/hiring-desk/tools/read_email.ts +50 -0
- package/dist/templates/hiring-desk/tools/rescore_with_feedback.ts +140 -0
- package/dist/templates/hiring-desk/tools/screen_candidates.ts +128 -0
- package/dist/templates/hiring-desk/tools/screening_status.ts +51 -0
- package/dist/templates/hotel-desk/agent.eval.test.ts +177 -0
- package/dist/templates/hotel-desk/agent.test.ts +1128 -0
- package/dist/templates/hotel-desk/agent.ts +63 -0
- package/dist/templates/hotel-desk/booking.ts +159 -0
- package/dist/templates/hotel-desk/card.ts +92 -0
- package/dist/templates/hotel-desk/catalogs.ts +219 -0
- package/dist/templates/hotel-desk/client.tsx +137 -0
- package/dist/templates/hotel-desk/concierge.ts +99 -0
- package/dist/templates/hotel-desk/desk-seams.test.ts +334 -0
- package/dist/templates/hotel-desk/desk.ts +224 -0
- package/dist/templates/hotel-desk/disputes.ts +216 -0
- package/dist/templates/hotel-desk/events.ts +79 -0
- package/dist/templates/hotel-desk/hotel.ts +412 -0
- package/dist/templates/hotel-desk/policies.ts +209 -0
- package/dist/templates/hotel-desk/records.ts +384 -0
- package/dist/templates/hotel-desk/restaurant.ts +147 -0
- package/dist/templates/hotel-desk/seed.ts +955 -0
- package/dist/templates/hotel-desk/shared.ts +354 -0
- package/dist/templates/hotel-desk/system-prompt.md +76 -0
- package/dist/templates/hotel-desk/tools/abandon_booking.ts +30 -0
- package/dist/templates/hotel-desk/tools/add_to_waitlist.ts +41 -0
- package/dist/templates/hotel-desk/tools/book_airport_car.ts +57 -0
- package/dist/templates/hotel-desk/tools/book_business_center.ts +44 -0
- package/dist/templates/hotel-desk/tools/book_spa_appointment.ts +39 -0
- package/dist/templates/hotel-desk/tools/book_tour.ts +35 -0
- package/dist/templates/hotel-desk/tools/cancel_restaurant_reservation.ts +25 -0
- package/dist/templates/hotel-desk/tools/cancel_room_booking.ts +63 -0
- package/dist/templates/hotel-desk/tools/check_restaurant_availability.ts +24 -0
- package/dist/templates/hotel-desk/tools/check_room_availability.ts +40 -0
- package/dist/templates/hotel-desk/tools/choose_room.ts +93 -0
- package/dist/templates/hotel-desk/tools/confirm_booking.ts +153 -0
- package/dist/templates/hotel-desk/tools/dispatch_emergency.ts +61 -0
- package/dist/templates/hotel-desk/tools/dispute_charge.ts +90 -0
- package/dist/templates/hotel-desk/tools/flag_late_arrival.ts +26 -0
- package/dist/templates/hotel-desk/tools/lookup_booking.ts +48 -0
- package/dist/templates/hotel-desk/tools/lookup_guest_history.ts +28 -0
- package/dist/templates/hotel-desk/tools/lookup_invoice.ts +26 -0
- package/dist/templates/hotel-desk/tools/lookup_policy.ts +20 -0
- package/dist/templates/hotel-desk/tools/lookup_restaurant_reservation.ts +27 -0
- package/dist/templates/hotel-desk/tools/modify_restaurant_reservation.ts +75 -0
- package/dist/templates/hotel-desk/tools/order_flowers.ts +40 -0
- package/dist/templates/hotel-desk/tools/record_card.ts +46 -0
- package/dist/templates/hotel-desk/tools/record_followup.ts +50 -0
- package/dist/templates/hotel-desk/tools/record_group_inquiry.ts +44 -0
- package/dist/templates/hotel-desk/tools/record_guest_details.ts +71 -0
- package/dist/templates/hotel-desk/tools/reinstate_booking.ts +65 -0
- package/dist/templates/hotel-desk/tools/request_flight_reconfirmation.ts +54 -0
- package/dist/templates/hotel-desk/tools/resend_confirmation.ts +39 -0
- package/dist/templates/hotel-desk/tools/reserve_table.ts +87 -0
- package/dist/templates/hotel-desk/tools/resolve_room_conflict.ts +48 -0
- package/dist/templates/hotel-desk/tools/schedule_wakeup_call.ts +48 -0
- package/dist/templates/hotel-desk/tools/set_do_not_disturb.ts +28 -0
- package/dist/templates/hotel-desk/tools/set_extras.ts +51 -0
- package/dist/templates/hotel-desk/tools/set_stay.ts +97 -0
- package/dist/templates/hotel-desk/tools/start_booking_modification.ts +57 -0
- package/dist/templates/hotel-desk/tools/start_room_booking.ts +49 -0
- package/dist/templates/hotel-desk/tools/take_guest_message.ts +71 -0
- package/dist/templates/hotel-desk/tools/transfer_call.ts +47 -0
- package/dist/templates/hotel-desk/tools/update_card.ts +45 -0
- package/dist/templates/hotel-desk/tools/verify_booking.ts +95 -0
- package/dist/templates/infocom-adventure/agent.eval.test.ts +33 -1
- package/dist/templates/infocom-adventure/agent.test.ts +207 -52
- package/dist/templates/infocom-adventure/agent.ts +14 -3
- package/dist/templates/infocom-adventure/client.tsx +138 -176
- package/dist/templates/infocom-adventure/shared.ts +126 -6
- package/dist/templates/infocom-adventure/system-prompt.md +4 -4
- package/dist/templates/infocom-adventure/tools/game_state_drop.ts +20 -4
- package/dist/templates/infocom-adventure/tools/game_state_get.ts +6 -5
- package/dist/templates/infocom-adventure/tools/game_state_score.ts +9 -3
- package/dist/templates/link-digest/agent.eval.test.ts +8 -0
- package/dist/templates/link-digest/agent.test.ts +285 -29
- package/dist/templates/link-digest/agent.ts +9 -0
- package/dist/templates/link-digest/api-client.ts +144 -0
- package/dist/templates/link-digest/client.tsx +11 -30
- package/dist/templates/link-digest/workflows/digest.ts +72 -24
- package/dist/templates/night-owl/agent.eval.test.ts +55 -40
- package/dist/templates/night-owl/agent.test.ts +146 -12
- package/dist/templates/night-owl/client.tsx +50 -17
- package/dist/templates/night-owl/shared.ts +33 -2
- package/dist/templates/night-owl/system-prompt.md +3 -0
- package/dist/templates/night-owl/tools/recommend.ts +4 -1
- package/dist/templates/night-owl/tools/revisit.ts +49 -0
- package/dist/templates/pipeline-simple/agent.eval.test.ts +7 -6
- package/dist/templates/pipeline-simple/agent.test.ts +48 -91
- package/dist/templates/pipeline-simple/modes.test.ts +151 -0
- package/dist/templates/pipeline-simple/stages.test.ts +332 -0
- package/dist/templates/pizza-ordering/agent.test.ts +94 -38
- package/dist/templates/pizza-ordering/client.tsx +10 -5
- package/dist/templates/pizza-ordering/shared.ts +65 -6
- package/dist/templates/pizza-ordering/tools/add_pizza.ts +2 -7
- package/dist/templates/pizza-ordering/tools/place_order.ts +9 -6
- package/dist/templates/pizza-ordering/tools/remove_pizza.ts +6 -11
- package/dist/templates/pizza-ordering/tools/update_pizza.ts +8 -9
- package/dist/templates/pizza-ordering/tools/view_order.ts +2 -3
- package/dist/templates/plan-and-execute/agent.eval.test.ts +14 -6
- package/dist/templates/plan-and-execute/agent.test.ts +300 -113
- package/dist/templates/plan-and-execute/client.tsx +18 -7
- package/dist/templates/plan-and-execute/procedure.ts +162 -64
- package/dist/templates/plan-and-execute/prompts.ts +51 -15
- package/dist/templates/plan-and-execute/shared.ts +151 -45
- package/dist/templates/plan-and-execute/tools/plan_status.ts +15 -6
- package/dist/templates/plan-and-execute/tools/revise_plan.ts +2 -2
- package/dist/templates/plan-and-execute/tools/start_plan.ts +2 -2
- package/dist/templates/plan-and-execute/tools/work_next_step.ts +15 -13
- package/dist/templates/podcast-digest/agent.eval.test.ts +12 -7
- package/dist/templates/podcast-digest/agent.test.ts +126 -51
- package/dist/templates/podcast-digest/client.tsx +104 -68
- package/dist/templates/podcast-digest/workflows/digest.ts +71 -48
- package/dist/templates/podcast-digest/workflows/feeds.ts +5 -7
- package/dist/templates/podcast-digest/workflows/slack.ts +82 -17
- package/dist/templates/recap-workflow/agent.eval.test.ts +193 -209
- package/dist/templates/recap-workflow/agent.test.ts +207 -26
- package/dist/templates/recap-workflow/tools/recap_status.ts +2 -2
- package/dist/templates/recap-workflow/workflows/recap.ts +39 -28
- package/dist/templates/redline/agent.eval.test.ts +40 -3
- package/dist/templates/redline/agent.test.ts +216 -6
- package/dist/templates/redline/agent.ts +54 -34
- package/dist/templates/redline/client.tsx +82 -126
- package/dist/templates/redline/form.ts +74 -0
- package/dist/templates/redline/workflows/prompts.ts +3 -3
- package/dist/templates/redline/workflows/redline.ts +73 -4
- package/dist/templates/research-workflow/agent.eval.test.ts +152 -150
- package/dist/templates/research-workflow/agent.test.ts +436 -126
- package/dist/templates/research-workflow/agent.ts +20 -5
- package/dist/templates/research-workflow/tools/file_it_now.ts +11 -1
- package/dist/templates/research-workflow/tools/research_status.ts +39 -4
- package/dist/templates/research-workflow/workflows/filing.ts +164 -0
- package/dist/templates/research-workflow/workflows/notes.ts +69 -0
- package/dist/templates/research-workflow/workflows/prompts.ts +45 -31
- package/dist/templates/research-workflow/workflows/research.ts +227 -280
- package/dist/templates/research-workflow/workflows/review.ts +43 -0
- package/dist/templates/retail/address.ts +29 -35
- package/dist/templates/retail/agent.eval.test.ts +36 -16
- package/dist/templates/retail/agent.test.ts +104 -26
- package/dist/templates/retail/agent.ts +12 -0
- package/dist/templates/retail/cancel.ts +39 -42
- package/dist/templates/retail/client.tsx +111 -176
- package/dist/templates/retail/payment.ts +38 -43
- package/dist/templates/retail/pending.test.ts +16 -8
- package/dist/templates/retail/registry.test.ts +108 -49
- package/dist/templates/retail/resolve.test.ts +2 -63
- package/dist/templates/retail/resolve.ts +16 -56
- package/dist/templates/retail/returns.ts +53 -54
- package/dist/templates/retail/seed.test.ts +2 -1
- package/dist/templates/retail/shared.ts +58 -14
- package/dist/templates/retail/store.test.ts +40 -29
- package/dist/templates/retail/store.ts +60 -23
- package/dist/templates/retail/swap.ts +78 -81
- package/dist/templates/retail/tools/find_user_id_by_name_zip.ts +2 -1
- package/dist/templates/roadside-assist/agent.eval.test.ts +164 -0
- package/dist/templates/roadside-assist/agent.test.ts +617 -0
- package/dist/templates/roadside-assist/agent.ts +85 -0
- package/dist/templates/roadside-assist/call.ts +237 -0
- package/dist/templates/roadside-assist/events.ts +92 -0
- package/dist/templates/roadside-assist/shared.ts +334 -0
- package/dist/templates/roadside-assist/system-prompt.md +37 -0
- package/dist/templates/roadside-assist/tools/acknowledge_disclosure.ts +47 -0
- package/dist/templates/roadside-assist/tools/dispatch_truck.ts +148 -0
- package/dist/templates/roadside-assist/tools/job_status.ts +38 -0
- package/dist/templates/roadside-assist/tools/lookup_coverage.ts +72 -0
- package/dist/templates/roadside-assist/tools/report_location.ts +79 -0
- package/dist/templates/roadside-assist/tools/service_disclosure.ts +45 -0
- package/dist/templates/roadside-assist/yard.test.ts +158 -0
- package/dist/templates/roadside-assist/yard.ts +183 -0
- package/dist/templates/simple/agent.eval.test.ts +4 -1
- package/dist/templates/simple/agent.test.ts +54 -31
- package/dist/templates/solo-rpg/agent.eval.test.ts +19 -11
- package/dist/templates/solo-rpg/agent.test.ts +402 -175
- package/dist/templates/solo-rpg/agent.ts +14 -3
- package/dist/templates/solo-rpg/client.tsx +10 -10
- package/dist/templates/solo-rpg/shared.ts +198 -79
- package/dist/templates/solo-rpg/tools/action_roll.ts +7 -3
- package/dist/templates/solo-rpg/tools/burn_momentum.ts +16 -8
- package/dist/templates/solo-rpg/tools/oracle.ts +7 -7
- package/dist/templates/solo-rpg/tools/setup_character.ts +5 -5
- package/dist/templates/solo-rpg/tools/update_state.ts +29 -18
- package/dist/templates/spoken-summary/agent.test.ts +70 -15
- package/dist/templates/spoken-summary/agent.ts +25 -21
- package/dist/templates/spoken-summary/client.tsx +68 -88
- package/dist/templates/spoken-summary/workflows/summarize.ts +26 -8
- package/dist/templates/support-line/agent.test.ts +167 -36
- package/dist/templates/support-line/client.tsx +21 -9
- package/dist/templates/support-line/nodes.ts +74 -32
- package/dist/templates/support-line/procedure.ts +66 -21
- package/dist/templates/support-line/prompts.ts +9 -0
- package/dist/templates/support-line/shared.ts +55 -17
- package/dist/templates/support-line/tools/answer_question.ts +14 -14
- package/dist/templates/transcription-workflow/agent.test.ts +135 -13
- package/dist/templates/transcription-workflow/client.tsx +30 -23
- package/dist/templates/transcription-workflow/recover.test.ts +93 -12
- package/dist/templates/transcription-workflow/recover.ts +29 -5
- package/dist/templates/transcription-workflow/run-panel.tsx +40 -51
- package/dist/templates/transcription-workflow/workflows/normalize.ts +125 -24
- package/dist/templates/transcription-workflow/workflows/stream.ts +4 -1
- package/dist/templates/transcription-workflow/workflows/transcribe.ts +7 -5
- package/dist/templates/transcription-workflow/workflows/wav.ts +42 -117
- package/dist/templates/travel-concierge/agent.eval.test.ts +6 -4
- package/dist/templates/travel-concierge/agent.test.ts +209 -40
- package/dist/templates/travel-concierge/agent.ts +24 -4
- package/dist/templates/travel-concierge/call-events.ts +80 -0
- package/dist/templates/travel-concierge/client.tsx +3 -2
- package/dist/templates/travel-concierge/routing.ts +5 -7
- package/dist/templates/travel-concierge/shared.ts +202 -41
- package/dist/templates/travel-concierge/tools/book_car_rental.ts +2 -4
- package/dist/templates/travel-concierge/tools/book_excursion.ts +2 -4
- package/dist/templates/travel-concierge/tools/book_hotel.ts +2 -4
- package/dist/templates/travel-concierge/tools/cancel_ticket.ts +6 -4
- package/dist/templates/travel-concierge/tools/search_car_rentals.ts +3 -5
- package/dist/templates/travel-concierge/tools/search_excursions.ts +3 -5
- package/dist/templates/travel-concierge/tools/search_flights.ts +20 -9
- package/dist/templates/travel-concierge/tools/search_hotels.ts +3 -5
- package/dist/templates/travel-concierge/tools/update_ticket.ts +2 -4
- package/dist/templates/web-researcher/agent.eval.test.ts +3 -6
- package/dist/templates/web-researcher/agent.test.ts +102 -65
- package/dist/templates/web-researcher/agent.ts +93 -1
- package/dist/templates/web-researcher/system-prompt.md +7 -1
- package/dist/templates/word-wrangler/agent.eval.test.ts +157 -0
- package/dist/templates/word-wrangler/agent.test.ts +432 -0
- package/dist/templates/word-wrangler/agent.ts +35 -0
- package/dist/templates/word-wrangler/client.tsx +211 -0
- package/dist/templates/word-wrangler/game.ts +107 -0
- package/dist/templates/word-wrangler/guess.ts +63 -0
- package/dist/templates/word-wrangler/player.ts +68 -0
- package/dist/templates/word-wrangler/shared.ts +263 -0
- package/dist/templates/word-wrangler/system-prompt.md +15 -0
- package/dist/templates/word-wrangler/tools/final_score.ts +37 -0
- package/dist/templates/word-wrangler/tools/relay_description.ts +137 -0
- package/dist/templates/word-wrangler/tools/repeat_word.ts +19 -0
- package/dist/templates/word-wrangler/tools/skip_word.ts +31 -0
- package/dist/templates/word-wrangler/tools/start_game.ts +47 -0
- package/dist/templates/word-wrangler/words.ts +278 -0
- package/dist/test-Cllnx81G.mjs +83 -0
- package/dist/test.d.ts +9 -114
- package/package.json +5 -5
- package/dist/build-BhEaxBPu.mjs +0 -481
- package/dist/templates/embedded-assets/agent.eval.test.ts +0 -130
- package/dist/templates/embedded-assets/agent.test.ts +0 -79
- package/dist/templates/embedded-assets/agent.ts +0 -7
- package/dist/templates/embedded-assets/knowledge.json +0 -20
- package/dist/templates/embedded-assets/shared.ts +0 -17
- package/dist/templates/embedded-assets/system-prompt.md +0 -13
- package/dist/templates/embedded-assets/tools/list_topics.ts +0 -9
- package/dist/templates/embedded-assets/tools/search_knowledge.ts +0 -26
- package/dist/templates/math-buddy/agent.eval.test.ts +0 -128
- package/dist/templates/math-buddy/agent.test.ts +0 -126
- package/dist/templates/math-buddy/agent.ts +0 -15
- package/dist/templates/math-buddy/system-prompt.md +0 -12
- package/dist/templates/personal-finance/agent.eval.test.ts +0 -149
- package/dist/templates/personal-finance/agent.test.ts +0 -127
- package/dist/templates/personal-finance/agent.ts +0 -8
- package/dist/templates/personal-finance/system-prompt.md +0 -21
package/dist/_build-target.d.ts
CHANGED
|
@@ -26,9 +26,20 @@
|
|
|
26
26
|
* is genuinely running on that host — a laptop sets none of them and gets
|
|
27
27
|
* {@link DEFAULT_BUILD_TARGET}, which emits nothing extra and is what every
|
|
28
28
|
* existing project already does.
|
|
29
|
+
*
|
|
30
|
+
* ## What is here, and what is one module over
|
|
31
|
+
*
|
|
32
|
+
* This file is the VOCABULARY: which targets exist, which one this build is,
|
|
33
|
+
* and — through {@link TARGET_OUTPUTS} — what each produced and how it ships.
|
|
34
|
+
* Each host's own constants and emitted sources live beside it, one module per
|
|
35
|
+
* host (`_vercel-target.ts`, `_deno-target.ts`, `_modal-target.ts`), which is
|
|
36
|
+
* the shape Nitro's `presets/<provider>/` has and the shape this file grew out
|
|
37
|
+
* of: it held all three and went over the 500-line cap. The dependency runs one
|
|
38
|
+
* way — this module reads each host's output directory, and no host module
|
|
39
|
+
* reads this one — so a fourth target is a fourth file plus two lines here.
|
|
29
40
|
*/
|
|
30
41
|
/** The targets `aai build --target` accepts. */
|
|
31
|
-
export declare const BUILD_TARGETS: readonly ["node", "vercel"];
|
|
42
|
+
export declare const BUILD_TARGETS: readonly ["node", "vercel", "deno", "modal"];
|
|
32
43
|
export type BuildTarget = (typeof BUILD_TARGETS)[number];
|
|
33
44
|
/**
|
|
34
45
|
* What a build with no `--target` and no host environment produces: the worker
|
|
@@ -45,6 +56,60 @@ export declare const DEFAULT_BUILD_TARGET: BuildTarget;
|
|
|
45
56
|
* `VERCEL` is set for every Vercel build and deployment. Detection is per host
|
|
46
57
|
* rather than a single "am I in CI" test, because a GitHub Action building a
|
|
47
58
|
* container image is CI too and wants the default.
|
|
59
|
+
*
|
|
60
|
+
* **Three keys for Vercel, not one**, and they are the three `std-env` tests —
|
|
61
|
+
* the library Nitro detects providers with, and which this file already cites
|
|
62
|
+
* for the Deno pair below. `VERCEL_ENV` is the variable Vercel's own docs point
|
|
63
|
+
* at for "which environment is this" and is present wherever `VERCEL` is;
|
|
64
|
+
* `NOW_BUILDER` is set on the BUILD container and predates both, so it is the
|
|
65
|
+
* one a legacy or a `vercel build` invocation may carry alone. Reading one key
|
|
66
|
+
* for a host that advertises itself with three is the same hole the Deno pair
|
|
67
|
+
* below was found to have, one platform generation earlier.
|
|
68
|
+
*
|
|
69
|
+
* `DENO_DEPLOY` and `DENO_DEPLOYMENT_ID` are both Deno Deploy's "you are
|
|
70
|
+
* running here" variables, and BOTH are listed because neither one covers both
|
|
71
|
+
* GENERATIONS of the platform. Deno Deploy Classic sets `DENO_DEPLOYMENT_ID`
|
|
72
|
+
* and `DENO_REGION` and no `DENO_DEPLOY` at all; the current platform sets
|
|
73
|
+
* both. So `DENO_DEPLOYMENT_ID` is the only marker present in either, and
|
|
74
|
+
* reading just `DENO_DEPLOY` — as this did — left Classic undetectable. That is
|
|
75
|
+
* why `std-env` (the library Nitro detects providers with) tests the pair as
|
|
76
|
+
* ONE signal, and why Nitro's Deno preset reads that one for its manifest.
|
|
77
|
+
*
|
|
78
|
+
* These are read at BUILD time, and that is reachable rather than theoretical:
|
|
79
|
+
* Deno Deploy's git integration runs the build on its OWN infrastructure with
|
|
80
|
+
* them set — its reference singles out `DENO_TIMELINE` as the one variable NOT
|
|
81
|
+
* set during a build — so `aai build` there resolves this target with no flag,
|
|
82
|
+
* the same zero-config property `VERCEL` gives.
|
|
83
|
+
*
|
|
84
|
+
* What detection cannot see is the documented LOCAL flow, and the reason is
|
|
85
|
+
* ORDERING rather than a missing marker: `aai build --target deno` then
|
|
86
|
+
* `deno deploy` from `.aai/deno/` finishes the build on the developer's own
|
|
87
|
+
* machine before the upload command runs at all, so there is no host
|
|
88
|
+
* environment left to advertise itself. Nitro has the identical hole and
|
|
89
|
+
* answers it the same way — its own docs pass `NITRO_PRESET=deno_deploy`
|
|
90
|
+
* explicitly. The flag is the path that matters; detection covers the host that
|
|
91
|
+
* builds FOR you.
|
|
92
|
+
*
|
|
93
|
+
* **`modal` has NO marker, and cannot**: it is the LOCAL flow above with no
|
|
94
|
+
* host-built alternative. Modal runs no build of its own — `modal deploy`
|
|
95
|
+
* uploads a directory whose build already finished — so every Modal deploy is
|
|
96
|
+
* the case the paragraph above says detection cannot see, and any variable
|
|
97
|
+
* listed here would be dead config by construction.
|
|
98
|
+
*
|
|
99
|
+
* Worse than dead, and this is the part specific to us. The two variables that
|
|
100
|
+
* DO appear in a Modal environment are set inside a CONTAINER
|
|
101
|
+
* (`MODAL_IS_REMOTE`, `MODAL_TASK_ID`), which is the wrong end — and this
|
|
102
|
+
* repo's own guest sandboxes ARE Modal Sandboxes, with studio Publish running
|
|
103
|
+
* the CLI inside one, so detecting on them would flip the platform's own build
|
|
104
|
+
* to this target. `MODAL_TOKEN_ID` fails the ordinary way: credentials in the
|
|
105
|
+
* environment are not a statement about what a build is FOR, so anyone with
|
|
106
|
+
* Modal creds exported would get Modal output from a Vercel build.
|
|
107
|
+
*
|
|
108
|
+
* So `modal` is reachable by its flag alone. The reachability test in
|
|
109
|
+
* `_build-target.test.ts` asserts every target is selectable that way, rather
|
|
110
|
+
* than demanding a marker per target — which reads as the same claim and is
|
|
111
|
+
* not, since it would force a host like this one to invent a variable no build
|
|
112
|
+
* ever sees.
|
|
48
113
|
*/
|
|
49
114
|
export declare const TARGET_ENV_MARKERS: Readonly<Record<string, BuildTarget>>;
|
|
50
115
|
export declare function isBuildTarget(value: string): value is BuildTarget;
|
|
@@ -59,114 +124,46 @@ export declare function isBuildTarget(value: string): value is BuildTarget;
|
|
|
59
124
|
*/
|
|
60
125
|
export declare function resolveBuildTarget(explicit: string | undefined, env?: Record<string, string | undefined>): BuildTarget;
|
|
61
126
|
/**
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
* `import(pathToFileURL(...))` that no static tracer can follow — and
|
|
78
|
-
* `.env.example` — the file that DECLARES which variables become `ctx.env` —
|
|
79
|
-
* are present because they were copied in. And the built client is served by
|
|
80
|
-
* the CDN out of `static/` instead of through the function.
|
|
81
|
-
*
|
|
82
|
-
* Nitro's vercel preset is the worked precedent and lands in exactly here:
|
|
83
|
-
* `output.dir = {{rootDir}}/.vercel/output`, `serverDir` a `.func` under it.
|
|
84
|
-
*
|
|
85
|
-
* @see https://vercel.com/docs/build-output-api/v3
|
|
86
|
-
*/
|
|
87
|
-
export declare const VERCEL_OUTPUT_DIR: string;
|
|
88
|
-
/**
|
|
89
|
-
* The one function every request that is not a static file reaches.
|
|
90
|
-
*
|
|
91
|
-
* The Build Output API derives a function's ROUTE from its path, so the
|
|
92
|
-
* directory name IS a URL and must not collide with one the static output
|
|
93
|
-
* claims. **`index.func` collides**, which a deployment is the only way to
|
|
94
|
-
* find out: it is served at `/index`, and Vercel's directory index resolves
|
|
95
|
-
* `/` to the extensionless `/index` — so the function won `/`, every other
|
|
96
|
-
* asset came off the CDN correctly, and the home page 500'd on a deployment
|
|
97
|
-
* whose static output was perfect. Measured on a real preview:
|
|
98
|
-
* `/favicon.ico`, `/index.html` and both hashed `/assets/*` returned 200
|
|
99
|
-
* while `/` and `/index` did not.
|
|
100
|
-
*
|
|
101
|
-
* `__server` is Nitro's answer to the same problem (`__server.func`) and the
|
|
102
|
-
* reason is this one: a double-underscore prefix is not a path any bundler
|
|
103
|
-
* emits, so no static file can ever take the name.
|
|
104
|
-
*/
|
|
105
|
-
export declare const VERCEL_FUNCTION_DIR: string;
|
|
106
|
-
/**
|
|
107
|
-
* The route {@link VERCEL_FUNCTION_DIR} is served at — its directory name
|
|
108
|
-
* without `.func`, which is how the Build Output API names a function.
|
|
109
|
-
*/
|
|
110
|
-
export declare const VERCEL_FUNCTION_ROUTE = "/__server";
|
|
111
|
-
/** Static assets the Vercel CDN serves directly, never reaching the function. */
|
|
112
|
-
export declare const VERCEL_STATIC_DIR: string;
|
|
113
|
-
/** `nodejs<major>.x` for the Node running this build, clamped to what Vercel offers. */
|
|
114
|
-
export declare function vercelNodeRuntime(version?: string): string;
|
|
115
|
-
/**
|
|
116
|
-
* The Vercel function entry, emitted into {@link VERCEL_FUNCTION_DIR}.
|
|
117
|
-
*
|
|
118
|
-
* ## Why a `(req, res)` handler and not `export default server`
|
|
119
|
-
*
|
|
120
|
-
* `export default <http.Server>` is what Vercel's own `@vercel/node` BUILDER
|
|
121
|
-
* accepts, and it is the shape the previous `api/index.mjs` used. The Build
|
|
122
|
-
* Output API has no builder in the path: `launcherType: "Nodejs"` invokes the
|
|
123
|
-
* module's default export as a request handler, so the server never gets
|
|
124
|
-
* bound and there is nothing to raise an `upgrade` event on it.
|
|
125
|
-
*
|
|
126
|
-
* ## How a WebSocket survives that
|
|
127
|
-
*
|
|
128
|
-
* Vercel hands a Node function the raw upgrade through its PER-REQUEST
|
|
129
|
-
* context — `globalThis[Symbol.for("@vercel/request-context")].get()
|
|
130
|
-
* .upgradeWebSocket()` returns the `{ req, socket, head }` triple — rather
|
|
131
|
-
* than as an event. Nitro reaches it through `crossws/adapters/vercel`; here
|
|
132
|
-
* the adapter is three lines, because {@link AgentServer.node} is a real
|
|
133
|
-
* `http.Server` that already has both an `upgrade` and a `request` listener
|
|
134
|
-
* registered. Re-emitting onto it is the whole translation, and it means the
|
|
135
|
-
* deployed path through `server.ts` is the same one `aai dev` and `aai start`
|
|
136
|
-
* take — no second WebSocket entry point to keep in step.
|
|
137
|
-
*
|
|
138
|
-
* The `204` afterwards is what the launcher needs to consider the invocation
|
|
139
|
-
* finished; the socket the agent is now talking on is not this `res`.
|
|
140
|
-
*
|
|
141
|
-
* ## `import.meta.dirname`, not `process.cwd()`
|
|
142
|
-
*
|
|
143
|
-
* The function's working directory belongs to the platform, but `.aai/` and
|
|
144
|
-
* `.env.example` were copied in BESIDE this file. Resolving from the module
|
|
145
|
-
* keeps that a fact about the bundle rather than about how Vercel happens to
|
|
146
|
-
* invoke it.
|
|
127
|
+
* What one target's emit produces, and the commands that run it.
|
|
128
|
+
*
|
|
129
|
+
* Nitro's presets each carry a `commands: { preview, deploy }` pair, which it
|
|
130
|
+
* writes into the build output's own `nitro.json` and prints after a build
|
|
131
|
+
* ("You can deploy this build using …"). The reason to copy that shape rather
|
|
132
|
+
* than keep the strings at the log site is what it fixes here: the Vercel
|
|
133
|
+
* target printed the DIRECTORY it wrote and never the command that ships it, so
|
|
134
|
+
* the one target reachable with no flag at all was also the one that told you
|
|
135
|
+
* nothing about what to do next. A target that emits an artifact nobody knows
|
|
136
|
+
* how to deploy has emitted nothing.
|
|
137
|
+
*
|
|
138
|
+
* Data rather than a `case` arm per target for the ordinary reason: this is a
|
|
139
|
+
* total record over {@link BuildTarget}, so a new target cannot be added
|
|
140
|
+
* without answering both questions, where a `log.info` inside a switch can be
|
|
141
|
+
* — and was — simply left out.
|
|
147
142
|
*/
|
|
148
|
-
export
|
|
143
|
+
export interface TargetOutput {
|
|
144
|
+
/**
|
|
145
|
+
* Where the emit lands, relative to the project root. Absent for a target
|
|
146
|
+
* that writes nothing beyond the worker and the client.
|
|
147
|
+
*/
|
|
148
|
+
readonly dir?: string;
|
|
149
|
+
/**
|
|
150
|
+
* Run this deployment locally, the way the host runs it. Absent where there
|
|
151
|
+
* is no honest answer: Vercel's function is invoked by a platform launcher
|
|
152
|
+
* that nothing local reproduces, and offering `vercel dev` — which rebuilds
|
|
153
|
+
* from source and ignores `.vercel/output/` — would be pointing a user at a
|
|
154
|
+
* different program than the one they just built.
|
|
155
|
+
*/
|
|
156
|
+
readonly preview?: string;
|
|
157
|
+
/** Ship what was just emitted. */
|
|
158
|
+
readonly deploy?: string;
|
|
159
|
+
}
|
|
149
160
|
/**
|
|
150
|
-
*
|
|
161
|
+
* Every target's output and commands.
|
|
151
162
|
*
|
|
152
|
-
*
|
|
153
|
-
*
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
* the
|
|
157
|
-
*/
|
|
158
|
-
export declare function vercelFunctionConfigSource(runtime?: string): string;
|
|
159
|
-
/**
|
|
160
|
-
* `config.json` — the routing table, and the reason static assets stop paying
|
|
161
|
-
* for a function invocation.
|
|
162
|
-
*
|
|
163
|
-
* `{ "handle": "filesystem" }` serves anything present in
|
|
164
|
-
* {@link VERCEL_STATIC_DIR} from the CDN and only then falls through, so the
|
|
165
|
-
* client bundle, its assets and the worklets are edge-served while
|
|
166
|
-
* `/client-config`, `/websocket`, `/workflows/*` and the webhook route reach
|
|
167
|
-
* the agent. The `api/` shape routed EVERY request through the function, which
|
|
168
|
-
* this file's earlier revision noted as deliberate and "not what makes a
|
|
169
|
-
* deployment work or not" — true of correctness, false of cost, and free here
|
|
170
|
-
* because the Build Output API already separates the two directories.
|
|
163
|
+
* The two directory-shaped hosts get a `cd` rather than a path argument,
|
|
164
|
+
* because that is what their tooling takes: `deno deploy` uploads the WORKING
|
|
165
|
+
* directory (see {@link DENO_OUTPUT_DIR}), so running it from the project root
|
|
166
|
+
* would upload the project. Nitro's `deno-deploy` preset writes its command
|
|
167
|
+
* with the same `cd`.
|
|
171
168
|
*/
|
|
172
|
-
export declare const
|
|
169
|
+
export declare const TARGET_OUTPUTS: Readonly<Record<BuildTarget, TargetOutput>>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Assemble a self-contained Deno Deploy directory — `.aai/deno/`.
|
|
3
|
+
*
|
|
4
|
+
* The assembly is `_target-output.ts`, shared with the Modal emit: both hosts
|
|
5
|
+
* upload a directory and run one file in it with no install step, so the set of
|
|
6
|
+
* runtime files that have to travel is the same set, and that module's doc
|
|
7
|
+
* carries which three and the deployment failure that found each.
|
|
8
|
+
*
|
|
9
|
+
* Deno's own half is two files. The ENTRY it bundles — see `DENO_ENTRY_SOURCE`
|
|
10
|
+
* — and a **`deno.json`** beside it (see {@link DENO_CONFIG_SOURCE}), so the
|
|
11
|
+
* directory describes how to run itself and no command against it has to
|
|
12
|
+
* re-supply `--entrypoint`.
|
|
13
|
+
*
|
|
14
|
+
* That second file is also the answer to "why is this not just the shared
|
|
15
|
+
* emit": both self-contained targets need a way to say what to RUN, and the two
|
|
16
|
+
* hosts take it differently — Deno reads a config it already understands, while
|
|
17
|
+
* Modal has no descriptor at all and needs a generated Python module.
|
|
18
|
+
*/
|
|
19
|
+
import { type EmitSelfContainedOptions } from "./_target-output.ts";
|
|
20
|
+
/** Options for {@link emitDenoOutput}. */
|
|
21
|
+
export type EmitDenoOutputOptions = EmitSelfContainedOptions;
|
|
22
|
+
/** Write `.aai/deno/` for this project. */
|
|
23
|
+
export declare function emitDenoOutput(cwd: string, options?: EmitDenoOutputOptions): Promise<void>;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The **Deno Deploy** target — a self-contained directory under `.aai/deno/`.
|
|
3
|
+
*
|
|
4
|
+
* One module per host, for the reason `_vercel-target.ts` opens with. What
|
|
5
|
+
* assembles the directory is `_deno-output.ts`; what this file holds is where
|
|
6
|
+
* it goes and what goes in it.
|
|
7
|
+
*
|
|
8
|
+
* Deno and Modal are the two LONG-LIVED targets: each entry binds a port and
|
|
9
|
+
* each drains on a signal ({@link TARGET_DRAIN_SOURCE}), which is what makes
|
|
10
|
+
* them the pair that also shares `_target-output.ts`.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Where a self-contained Deno deployment is emitted, relative to the project.
|
|
14
|
+
*
|
|
15
|
+
* A DIRECTORY to deploy rather than files scattered through the project, and
|
|
16
|
+
* `deno deploy` from inside it uploads exactly this and nothing else. That
|
|
17
|
+
* matters more here than it does on Vercel: Deploy uploads the working
|
|
18
|
+
* directory, so an emit into the project root would ship `node_modules`, the
|
|
19
|
+
* source, and the developer's `.env` alongside the thing meant to run.
|
|
20
|
+
*/
|
|
21
|
+
export declare const DENO_OUTPUT_DIR: string;
|
|
22
|
+
/** The bundled entry inside {@link DENO_OUTPUT_DIR}, and Deploy's entrypoint. */
|
|
23
|
+
export declare const DENO_ENTRY_FILE = "server.mjs";
|
|
24
|
+
/** Deno's own project file inside {@link DENO_OUTPUT_DIR}. */
|
|
25
|
+
export declare const DENO_CONFIG_FILE = "deno.json";
|
|
26
|
+
/**
|
|
27
|
+
* The `deno.json` written beside the entry, so the output DESCRIBES how to run
|
|
28
|
+
* itself.
|
|
29
|
+
*
|
|
30
|
+
* Without it every command against this directory has to re-supply the
|
|
31
|
+
* entrypoint — `deno deploy --entrypoint server.mjs`, `deno run -A server.mjs`
|
|
32
|
+
* — which is a fact about the emit that the emit already knows and the user has
|
|
33
|
+
* to remember. Nitro's `deno-server` preset writes the same file for the same
|
|
34
|
+
* reason (its `compiled` hook, a `tasks.start`), and its own test suite then
|
|
35
|
+
* runs a bare `deno task start`.
|
|
36
|
+
*
|
|
37
|
+
* `-A` rather than a narrowed permission set, and that is deliberate: the
|
|
38
|
+
* server binds a port, reads the client directory and the worker off disk, and
|
|
39
|
+
* reads the environment, so an enumerated list here would be a second
|
|
40
|
+
* declaration of the runtime's needs that drifts the first time one changes.
|
|
41
|
+
* Deno Deploy grants its own permissions regardless; this file is what makes
|
|
42
|
+
* the directory runnable BY HAND, which is how a failed deployment gets
|
|
43
|
+
* diagnosed.
|
|
44
|
+
*/
|
|
45
|
+
export declare const DENO_CONFIG_SOURCE: string;
|
|
46
|
+
/**
|
|
47
|
+
* The Deno entry, bundled into {@link DENO_ENTRY_FILE}.
|
|
48
|
+
*
|
|
49
|
+
* ## Why this BINDS, where the Vercel entry does not
|
|
50
|
+
*
|
|
51
|
+
* Deno Deploy runs a long-lived process and expects it to listen, which is the
|
|
52
|
+
* ordinary `aai start` shape rather than the serverless one — so this is the
|
|
53
|
+
* only target whose entry calls `listen()`. There is no `(req, res)` adapter
|
|
54
|
+
* and no upgrade translation: `node:http` and the `ws` server path both work
|
|
55
|
+
* on Deno, so the session reaches the same `AgentServer` that `aai dev` and
|
|
56
|
+
* `aai start` run. Verified against a live deployment with real speech: 74
|
|
57
|
+
* audio frames back, transcript and reply intact.
|
|
58
|
+
*
|
|
59
|
+
* `0.0.0.0`, not the loopback default: the platform reaches this from outside
|
|
60
|
+
* the process, so binding loopback answers nothing.
|
|
61
|
+
*
|
|
62
|
+
* `import.meta.dirname` rather than `process.cwd()` — the artifacts are copied
|
|
63
|
+
* in BESIDE this file, and the working directory belongs to the platform.
|
|
64
|
+
*
|
|
65
|
+
* `globalThis.Deno?.env` rather than `Deno.env`: this file is bundled by a
|
|
66
|
+
* Node-side build and is read by Node tooling (its own spec included), where a
|
|
67
|
+
* bare `Deno` is a `ReferenceError` at parse-adjacent evaluation time.
|
|
68
|
+
*
|
|
69
|
+
* `process` needs no such guard and deliberately gets none: it is a global in
|
|
70
|
+
* Deno as well as in Node, so {@link TARGET_DRAIN_SOURCE} is the identical text
|
|
71
|
+
* in both long-lived entries rather than a template with a hole in it.
|
|
72
|
+
*/
|
|
73
|
+
export declare const DENO_ENTRY_SOURCE = "// Generated by `aai build --target deno` \u2014 do not edit, and do not commit.\n// Deno Deploy runs this as a long-lived process and expects it to listen.\n// See @alexkroman1/aai-cli/start.\nimport { createProjectServer } from \"@alexkroman1/aai-cli/start\";\n\nconst server = await createProjectServer({ cwd: import.meta.dirname });\n\nawait server.listen(Number(globalThis.Deno?.env.get(\"PORT\") ?? 8000), \"0.0.0.0\");\n\n// The host stops this process on every scale-in and every redeploy; closing the\n// server ends live sessions instead of dropping their sockets.\nfor (const name of [\"SIGINT\", \"SIGTERM\"]) {\n try {\n process.once(name, () => {\n server.close().then(\n () => process.exit(0),\n () => process.exit(1),\n );\n });\n } catch {\n // No signal support on this host \u2014 nothing will ever arrive to drain on.\n }\n}\n";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { d as readJson, g as writeJson, i as compareCodeUnits, u as isEexist } from "./_utils-D5JGcjiW.mjs";
|
|
3
3
|
import { r as isDevMode, t as getMonorepoRoot } from "./_agent-BzUeqOdj.mjs";
|
|
4
|
-
import { REPO_URL, downloadAndMergeTemplate } from "./_templates-
|
|
4
|
+
import { REPO_URL, downloadAndMergeTemplate } from "./_templates-CuP74F8D.mjs";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import fs from "node:fs/promises";
|
|
7
7
|
//#region src/_init.ts
|
|
@@ -35,6 +35,8 @@ npm run dev # Run locally on http://localhost:3000 (opens browser)
|
|
|
35
35
|
The \`aai\` CLI is a devDependency of this project, so it lives in
|
|
36
36
|
\`node_modules/.bin\` rather than on your \`PATH\`. Run it through npm
|
|
37
37
|
(\`npm run dev\`, \`npm test\`, \`npm run build\`) or with \`npx aai <command>\`.
|
|
38
|
+
Installing it globally (\`npm i -g @alexkroman1/aai-cli\`) also works, and is
|
|
39
|
+
what the project docs assume.
|
|
38
40
|
|
|
39
41
|
### The one key local development needs
|
|
40
42
|
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Modal app definition `aai build --target modal` emits — `app.py`.
|
|
3
|
+
*
|
|
4
|
+
* ## Why this target is a generated PYTHON file
|
|
5
|
+
*
|
|
6
|
+
* Every other target emits the host's expected entry shape and lets the host
|
|
7
|
+
* hold the rest: Vercel reads a routing table it already understands, Deno
|
|
8
|
+
* Deploy takes a directory and an entrypoint. Modal has no such descriptor.
|
|
9
|
+
* Its deploy unit is a Python module — `modal.App`, an image recipe, and a
|
|
10
|
+
* decorated function — and `modal deploy` runs that module rather than reading
|
|
11
|
+
* a manifest out of it. So the "preset" for Modal is the module itself, which
|
|
12
|
+
* is why this is the one target whose emit generates code in another language.
|
|
13
|
+
*
|
|
14
|
+
* ## The knobs are DEPLOY-TIME ENV, not edits to this file
|
|
15
|
+
*
|
|
16
|
+
* The awkward consequence is that Modal's policy — how many containers, how
|
|
17
|
+
* much CPU, which secret — lives in Python arguments rather than in a platform
|
|
18
|
+
* dashboard. A generated file carrying policy is a file people edit, and this
|
|
19
|
+
* one is overwritten by the next `aai build`, so "do not edit" would be a lie
|
|
20
|
+
* the first time somebody wanted a warm container.
|
|
21
|
+
*
|
|
22
|
+
* Four knobs are therefore read from the environment at deploy time
|
|
23
|
+
* ({@link MODAL_ENV_KNOBS}), which keeps the project committing nothing
|
|
24
|
+
* host-specific — the property `_build-target.ts` opens by defending:
|
|
25
|
+
*
|
|
26
|
+
* ```sh
|
|
27
|
+
* AAI_MODAL_MIN_CONTAINERS=1 modal deploy .aai/modal/app.py
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* The rest — cpu, memory, timeout, concurrency — stays a documented constant
|
|
31
|
+
* in the emitted file. Those are the numbers a reader needs to SEE to trust
|
|
32
|
+
* the deployment, and regenerating restates the default, which is the same
|
|
33
|
+
* contract every other generated artifact here has.
|
|
34
|
+
*/
|
|
35
|
+
/** The deploy-time knobs the emitted app reads, documented in its own docstring. */
|
|
36
|
+
export declare const MODAL_ENV_KNOBS: readonly ["AAI_MODAL_APP", "AAI_MODAL_SECRET", "AAI_MODAL_MIN_CONTAINERS", "AAI_MODAL_MAX_CONTAINERS"];
|
|
37
|
+
/**
|
|
38
|
+
* An agent name as a Modal app name.
|
|
39
|
+
*
|
|
40
|
+
* Modal accepts a narrow character set here and the name reaches a hostname —
|
|
41
|
+
* a deployed function is served at `<workspace>--<app>-<function>.modal.run` —
|
|
42
|
+
* so anything outside `[a-z0-9-]` becomes a dash rather than being passed
|
|
43
|
+
* through and rejected by the platform. Agent names are free text
|
|
44
|
+
* (`define({ name: "Retail Support Bot" })`), which is why this is a mapping
|
|
45
|
+
* and not a validation.
|
|
46
|
+
*
|
|
47
|
+
* Collapsed and trimmed, because `--` is what a hostname reader sees as the
|
|
48
|
+
* workspace separator, and a leading or trailing dash is not a legal label.
|
|
49
|
+
*/
|
|
50
|
+
export declare function modalAppName(agentName: string): string;
|
|
51
|
+
/**
|
|
52
|
+
* The Modal Secret the deployment reads its env from.
|
|
53
|
+
*
|
|
54
|
+
* `-env` rather than the app name alone: the secret holds exactly what
|
|
55
|
+
* `.env.example` declares, and a name that says so makes
|
|
56
|
+
* `modal secret create <name> …` self-explaining. Derived rather than
|
|
57
|
+
* configured, so the emitted file and the command in its docstring cannot name
|
|
58
|
+
* two different secrets.
|
|
59
|
+
*/
|
|
60
|
+
export declare function modalSecretName(appName: string): string;
|
|
61
|
+
/** `node:<major>-slim` for the Node running this build, floored at the SDK's minimum. */
|
|
62
|
+
export declare function modalNodeImageTag(version?: string): string;
|
|
63
|
+
/** Options for {@link modalAppSource}. */
|
|
64
|
+
export interface ModalAppSourceOptions {
|
|
65
|
+
/** The agent's name, as declared in `agent.ts`. */
|
|
66
|
+
name: string;
|
|
67
|
+
/** Base image tag. Defaults to {@link modalNodeImageTag} for the running Node. */
|
|
68
|
+
nodeImage?: string | undefined;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Render `app.py` for this agent.
|
|
72
|
+
*
|
|
73
|
+
* Every number the platform needs appears ONCE and is interpolated, so the
|
|
74
|
+
* emitted file cannot disagree with itself or with the entry beside it — see
|
|
75
|
+
* {@link MODAL_PORT} for the failure that motivates it.
|
|
76
|
+
*/
|
|
77
|
+
export declare function modalAppSource(options: ModalAppSourceOptions): string;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Assemble a self-contained Modal deployment directory — `.aai/modal/`.
|
|
3
|
+
*
|
|
4
|
+
* The runtime files are `_target-output.ts`, shared with the Deno emit for the
|
|
5
|
+
* reason that module's doc gives: neither host installs anything, so both need
|
|
6
|
+
* the same three files carried in beside the bundled entry.
|
|
7
|
+
*
|
|
8
|
+
* Modal's own half is the fourth file, `app.py`. It is what makes this target
|
|
9
|
+
* different in kind from the other two — Vercel and Deno are each pointed at a
|
|
10
|
+
* directory and work out the rest, while `modal deploy` RUNS a Python module
|
|
11
|
+
* that declares the image, the app and the function. See `_modal-app.ts`.
|
|
12
|
+
*
|
|
13
|
+
* The `app.py` is written LAST, after the directory it describes exists. That
|
|
14
|
+
* ordering has no failure to point at yet; it is here because the file's
|
|
15
|
+
* `add_local_dir(HERE, …)` is a claim about this directory's contents, and a
|
|
16
|
+
* half-assembled directory is a worse thing to hand a user than a missing one.
|
|
17
|
+
*/
|
|
18
|
+
import { type EmitSelfContainedOptions } from "./_target-output.ts";
|
|
19
|
+
/** Options for {@link emitModalOutput}. */
|
|
20
|
+
export interface EmitModalOutputOptions extends EmitSelfContainedOptions {
|
|
21
|
+
/**
|
|
22
|
+
* The agent's name, which becomes the Modal app name and its secret's.
|
|
23
|
+
*
|
|
24
|
+
* Passed in rather than re-read from the built worker: `executeBuild` has
|
|
25
|
+
* already evaluated the bundle to report the name, and loading it twice would
|
|
26
|
+
* make the emit depend on a second evaluation of the user's own code.
|
|
27
|
+
*/
|
|
28
|
+
name: string;
|
|
29
|
+
}
|
|
30
|
+
/** Write `.aai/modal/` for this project. */
|
|
31
|
+
export declare function emitModalOutput(cwd: string, options: EmitModalOutputOptions): Promise<void>;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The **Modal** target — a self-contained directory under `.aai/modal/`, plus
|
|
3
|
+
* the `app.py` that deploys it.
|
|
4
|
+
*
|
|
5
|
+
* One module per host, for the reason `_vercel-target.ts` opens with. This file
|
|
6
|
+
* holds where the directory goes and the node entry inside it; `_modal-app.ts`
|
|
7
|
+
* generates the Python module beside it, and `_modal-output.ts` assembles both.
|
|
8
|
+
*
|
|
9
|
+
* The long-lived half of the pair described in `_deno-target.ts`.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Where a self-contained Modal deployment is emitted, relative to the project.
|
|
13
|
+
*
|
|
14
|
+
* A directory, for the reason `_deno-target.ts`'s `DENO_OUTPUT_DIR` is one and
|
|
15
|
+
* then some: the
|
|
16
|
+
* emitted `app.py` hands this path to Modal's `add_local_dir`, which uploads
|
|
17
|
+
* the tree wholesale into the image. Pointed at the project root that would
|
|
18
|
+
* bake `node_modules`, the source and the developer's `.env` into a container
|
|
19
|
+
* image — and an image layer is not something you can un-push.
|
|
20
|
+
*/
|
|
21
|
+
export declare const MODAL_OUTPUT_DIR: string;
|
|
22
|
+
/** The bundled server inside {@link MODAL_OUTPUT_DIR}, spawned by `app.py`. */
|
|
23
|
+
export declare const MODAL_ENTRY_FILE = "server.mjs";
|
|
24
|
+
/** The Modal app definition inside {@link MODAL_OUTPUT_DIR} — what `modal deploy` reads. */
|
|
25
|
+
export declare const MODAL_APP_FILE = "app.py";
|
|
26
|
+
/**
|
|
27
|
+
* The port the node process binds and Modal proxies to.
|
|
28
|
+
*
|
|
29
|
+
* ONE constant, interpolated into both files the emit writes, because the two
|
|
30
|
+
* halves cannot be allowed to disagree: `@modal.web_server(port=…)` is how the
|
|
31
|
+
* platform learns where to route, and a node process reading a different number
|
|
32
|
+
* from its environment listens where nothing is routed. The symptom is a
|
|
33
|
+
* deployment that builds, starts, reports healthy, and answers no request —
|
|
34
|
+
* Modal's proxy simply never connects.
|
|
35
|
+
*/
|
|
36
|
+
export declare const MODAL_PORT = 8000;
|
|
37
|
+
/**
|
|
38
|
+
* The Modal entry, bundled into {@link MODAL_ENTRY_FILE}.
|
|
39
|
+
*
|
|
40
|
+
* ## The same binding shape as Deno, for a different host
|
|
41
|
+
*
|
|
42
|
+
* `@modal.web_server` runs a container command and proxies HTTP *and*
|
|
43
|
+
* WebSocket traffic to a port that command opens, so this is the long-lived
|
|
44
|
+
* `aai start` shape rather than the serverless one — `listen()`, `0.0.0.0`
|
|
45
|
+
* (the proxy reaches this from outside the process), and artifacts resolved
|
|
46
|
+
* from {@link MODAL_ENTRY_FILE}'s own directory rather than from a working
|
|
47
|
+
* directory the platform owns. The entry is still NOT shared with
|
|
48
|
+
* {@link DENO_ENTRY_SOURCE} — the two read the port from different runtimes,
|
|
49
|
+
* and a shared entry would be a template with a hole where that goes — but the
|
|
50
|
+
* DRAIN below is, which is the part neither host's contract varies in.
|
|
51
|
+
*
|
|
52
|
+
* ## The drain is SHARED, and Modal supplies its other half
|
|
53
|
+
*
|
|
54
|
+
* The `SIGINT`/`SIGTERM` body is {@link TARGET_DRAIN_SOURCE}, the same text the
|
|
55
|
+
* Deno entry carries — it used to live here alone, on the reading that Modal
|
|
56
|
+
* stops containers and Deno Deploy does not, which is not true of either.
|
|
57
|
+
*
|
|
58
|
+
* What IS specific to Modal is that the signal has to REACH this process at
|
|
59
|
+
* all, and that half is in `app.py`: Modal signals its own Python runtime, and
|
|
60
|
+
* a child spawned with a bare `subprocess.Popen` receives nothing. The
|
|
61
|
+
* platform's own deploy learned that when orphaned guest sandboxes billed ~20
|
|
62
|
+
* minutes each on every release (see `run_node` in `scripts/modal_image.py`).
|
|
63
|
+
*/
|
|
64
|
+
export declare const MODAL_ENTRY_SOURCE = "// Generated by `aai build --target modal` \u2014 do not edit, and do not commit.\n// Modal runs this as a long-lived process behind `@modal.web_server`, which\n// proxies HTTP and WebSocket traffic to the port it binds.\n// See @alexkroman1/aai-cli/start.\nimport { createProjectServer } from \"@alexkroman1/aai-cli/start\";\n\nconst server = await createProjectServer({ cwd: import.meta.dirname });\n\nawait server.listen(Number(process.env.PORT ?? 8000), \"0.0.0.0\");\n\n// app.py forwards the container's stop signal here and waits for this process.\n// The host stops this process on every scale-in and every redeploy; closing the\n// server ends live sessions instead of dropping their sockets.\nfor (const name of [\"SIGINT\", \"SIGTERM\"]) {\n try {\n process.once(name, () => {\n server.close().then(\n () => process.exit(0),\n () => process.exit(1),\n );\n });\n } catch {\n // No signal support on this host \u2014 nothing will ever arrive to drain on.\n }\n}\n";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bundling a deployment target's ENTRY into one self-contained ESM file.
|
|
3
|
+
*
|
|
4
|
+
* Shared by every target that emits one, because the reason is the same at
|
|
5
|
+
* each: the entry imports `@alexkroman1/aai-cli/start`, and what a host does
|
|
6
|
+
* with the module graph behind that import differs in ways that are all bad.
|
|
7
|
+
*
|
|
8
|
+
* - **Vercel** traces it with `@vercel/nft`, which cannot follow the dynamic
|
|
9
|
+
* `import(pathToFileURL(...))` that loads the worker.
|
|
10
|
+
* - **Deno Deploy** caches the dependency graph of the PACKAGE rather than of
|
|
11
|
+
* the import, and `@alexkroman1/aai-cli`'s dependencies are a build
|
|
12
|
+
* toolchain — vite, rolldown and the rest. Measured: the build exceeded its
|
|
13
|
+
* 1024 MiB memory limit at "Caching dependencies for the entrypoint" before
|
|
14
|
+
* it reached any code of ours.
|
|
15
|
+
*
|
|
16
|
+
* A bundle removes the question. The host resolves nothing, installs nothing,
|
|
17
|
+
* and what runs is what the project's own lockfile pinned.
|
|
18
|
+
*
|
|
19
|
+
* The entry is written INTO the project rather than a temp directory, because
|
|
20
|
+
* that is what makes `@alexkroman1/aai-cli/start` resolve against the user's
|
|
21
|
+
* install. Removed in a `finally`: a build that throws must not leave a file
|
|
22
|
+
* that looks authored.
|
|
23
|
+
*/
|
|
24
|
+
/** Bundle `source` as if it were a module in `cwd`, and answer the code. */
|
|
25
|
+
export declare function bundleTargetEntry(cwd: string, source: string, name: string): Promise<string>;
|
|
26
|
+
/** Whether a path exists — the check every emit makes of an optional file. */
|
|
27
|
+
export declare function targetPathExists(target: string): Promise<boolean>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one entry-source fragment the LONG-LIVED targets share.
|
|
3
|
+
*
|
|
4
|
+
* A leaf beside `_target-output.ts` (the directory the same two targets share)
|
|
5
|
+
* and `_target-bundle.ts` (the bundle every target's entry goes through): each
|
|
6
|
+
* is a thing more than one host needs and no host owns.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* The signal drain both LONG-LIVED entries carry, interpolated into each.
|
|
10
|
+
*
|
|
11
|
+
* ## Why every long-lived host needs one
|
|
12
|
+
*
|
|
13
|
+
* A host that runs a process stops that process — on a scale-in, on a redeploy,
|
|
14
|
+
* on an instance being moved — and for a voice agent that is a live call. Left
|
|
15
|
+
* to the default disposition the process dies with its sockets open: the caller
|
|
16
|
+
* hears nothing more, the STT and TTS connections are dropped rather than
|
|
17
|
+
* closed, and nothing downstream is told the session ended. `server.close()`
|
|
18
|
+
* shuts the runtime down with the process, so sessions END.
|
|
19
|
+
*
|
|
20
|
+
* The Deno entry did NOT have this and the Modal entry did, which was a gap
|
|
21
|
+
* rather than a decision: Deno Deploy stops a deployment on exactly the same
|
|
22
|
+
* events. Nitro has no such asymmetry — every one of its long-lived presets
|
|
23
|
+
* (`node-server`, `deno-server`, `bun`) serves through srvx, which closes on
|
|
24
|
+
* `SIGINT`/`SIGTERM`, and `setupCloseHooks` hangs the framework's own `close`
|
|
25
|
+
* hooks off that one path. This is the same property with our own two hosts
|
|
26
|
+
* spelled out, which is why it is ONE constant: the next long-lived target
|
|
27
|
+
* must not get to rediscover it.
|
|
28
|
+
*
|
|
29
|
+
* ## Two things in the body that are not incidental
|
|
30
|
+
*
|
|
31
|
+
* The listeners are SYNCHRONOUS for the reason `executeStart` documents: an
|
|
32
|
+
* `async` listener hands its promise to `process`, which discards it, so a
|
|
33
|
+
* failed shutdown would surface as an unhandled rejection rather than a
|
|
34
|
+
* non-zero exit.
|
|
35
|
+
*
|
|
36
|
+
* Registration is GUARDED, because signal support is a property of the host
|
|
37
|
+
* rather than of the runtime. Deno delivers `process.on("SIGTERM")` through
|
|
38
|
+
* `Deno.addSignalListener`, which THROWS where the platform has no signal to
|
|
39
|
+
* deliver — an isolate-based Deploy, or a Windows `SIGTERM` — and a throw at
|
|
40
|
+
* the top level of the entry is a deployment that does not boot at all. A host
|
|
41
|
+
* that cannot signal us is a host we have nothing to drain on, so failing to
|
|
42
|
+
* register is not a failure.
|
|
43
|
+
*/
|
|
44
|
+
export declare const TARGET_DRAIN_SOURCE = "// The host stops this process on every scale-in and every redeploy; closing the\n// server ends live sessions instead of dropping their sockets.\nfor (const name of [\"SIGINT\", \"SIGTERM\"]) {\n try {\n process.once(name, () => {\n server.close().then(\n () => process.exit(0),\n () => process.exit(1),\n );\n });\n } catch {\n // No signal support on this host \u2014 nothing will ever arrive to drain on.\n }\n}\n";
|