@alexkroman1/aai-cli 15.0.0 → 16.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -5
- package/bin.mjs +12 -3
- package/dist/_build-target-55dJisQ-.mjs +649 -0
- package/dist/_build-target.d.ts +105 -108
- package/dist/_deno-output.d.ts +23 -0
- package/dist/_deno-target.d.ts +73 -0
- package/dist/{_init-Bsi3DZNJ.mjs → _init-BzQbV8Zh.mjs} +3 -1
- package/dist/_modal-app.d.ts +77 -0
- package/dist/_modal-output.d.ts +31 -0
- package/dist/_modal-target.d.ts +64 -0
- package/dist/_target-bundle.d.ts +27 -0
- package/dist/_target-drain.d.ts +44 -0
- package/dist/_target-output.d.ts +63 -0
- package/dist/{_templates-CIlJ3Vay.mjs → _templates-CuP74F8D.mjs} +94 -4
- package/dist/_templates.d.ts +14 -1
- package/dist/_vercel-output.d.ts +4 -19
- package/dist/_vercel-target.d.ts +169 -0
- package/dist/{test-D032V2cA.mjs → _vitest-runner-AVR9VtXh.mjs} +28 -68
- package/dist/_vitest-runner.d.ts +154 -0
- package/dist/build-ButI2IKc.mjs +689 -0
- package/dist/build.d.ts +11 -0
- package/dist/cli.mjs +14 -20
- package/dist/{dev-Bx9gYBHM.mjs → dev-kodAY23K.mjs} +7 -1
- package/dist/{eval-B3I7FqN9.mjs → eval-DvoSz7SZ.mjs} +1 -1
- package/dist/{init-CFyusRbq.mjs → init-D363Ls5u.mjs} +13 -39
- package/dist/init.d.ts +5 -10
- package/dist/scaffold/CLAUDE.md +185 -35
- package/dist/scaffold/package.json +4 -4
- package/dist/start.mjs +3 -1
- package/dist/{studio-C_zuRC_z.mjs → studio-CtRBVVFR.mjs} +1 -1
- package/dist/templates/briefing-desk/agent.eval.test.ts +34 -6
- package/dist/templates/briefing-desk/agent.test.ts +347 -55
- package/dist/templates/briefing-desk/agent.ts +12 -0
- package/dist/templates/briefing-desk/shared.ts +220 -31
- package/dist/templates/briefing-desk/slack.ts +108 -0
- package/dist/templates/briefing-desk/system-prompt.md +12 -2
- package/dist/templates/briefing-desk/tools/briefing_so_far.ts +15 -7
- package/dist/templates/briefing-desk/tools/research_topic.ts +20 -28
- package/dist/templates/briefing-desk/tools/send_briefing.ts +77 -0
- package/dist/templates/briefing-desk/tools/verify_claim.ts +60 -14
- package/dist/templates/call-audit/agent.eval.test.ts +5 -0
- package/dist/templates/call-audit/agent.test.ts +6 -1
- package/dist/templates/call-audit/agent.ts +10 -23
- package/dist/templates/call-audit/client.tsx +30 -55
- package/dist/templates/call-audit/guards.test.ts +233 -0
- package/dist/templates/call-audit/workflows/audit.ts +95 -16
- package/dist/templates/call-audit/workflows/ingest.ts +107 -88
- package/dist/templates/call-audit/workflows/media.ts +98 -7
- package/dist/templates/call-audit/workflows/summarize.ts +35 -31
- package/dist/templates/call-audit/workflows/sync-api.ts +15 -6
- package/dist/templates/code-interpreter/agent.eval.test.ts +104 -56
- package/dist/templates/code-interpreter/agent.test.ts +44 -56
- package/dist/templates/code-interpreter/system-prompt.md +1 -1
- package/dist/templates/dispatch-center/agent.eval.test.ts +61 -24
- package/dist/templates/dispatch-center/agent.test.ts +253 -48
- package/dist/templates/dispatch-center/agent.ts +28 -1
- package/dist/templates/dispatch-center/client.tsx +126 -201
- package/dist/templates/dispatch-center/events.ts +48 -0
- package/dist/templates/dispatch-center/shared.ts +42 -1
- package/dist/templates/dispatch-center/tools/incident_create.ts +3 -2
- package/dist/templates/dispatch-center/tools/incident_escalate.ts +2 -1
- package/dist/templates/dispatch-center/tools/ops_dashboard.ts +35 -15
- package/dist/templates/dispatch-center/tools/ops_run_scenario.ts +3 -1
- package/dist/templates/dispatch-center/tools/resources_dispatch.ts +2 -2
- package/dist/templates/executive-assistant/agent.eval.test.ts +233 -0
- package/dist/templates/executive-assistant/agent.test.ts +672 -0
- package/dist/templates/executive-assistant/agent.ts +50 -0
- package/dist/templates/executive-assistant/calendar.test.ts +198 -0
- package/dist/templates/executive-assistant/client.tsx +195 -0
- package/dist/templates/executive-assistant/inbox.ts +233 -0
- package/dist/templates/executive-assistant/meeting.ts +138 -0
- package/dist/templates/executive-assistant/nodes.ts +152 -0
- package/dist/templates/executive-assistant/prompts.ts +331 -0
- package/dist/templates/executive-assistant/review.ts +425 -0
- package/dist/templates/executive-assistant/shared.ts +490 -0
- package/dist/templates/executive-assistant/system-prompt.md +15 -0
- package/dist/templates/executive-assistant/tools/accept.ts +10 -0
- package/dist/templates/executive-assistant/tools/ask_question.ts +30 -0
- package/dist/templates/executive-assistant/tools/draft_reply.ts +67 -0
- package/dist/templates/executive-assistant/tools/edit.ts +10 -0
- package/dist/templates/executive-assistant/tools/ignore.ts +10 -0
- package/dist/templates/executive-assistant/tools/inbox_status.ts +27 -0
- package/dist/templates/executive-assistant/tools/meeting_assistant.ts +52 -0
- package/dist/templates/executive-assistant/tools/new_email.ts +50 -0
- package/dist/templates/executive-assistant/tools/open_email.ts +165 -0
- package/dist/templates/executive-assistant/tools/respond.ts +10 -0
- package/dist/templates/executive-assistant/tools/review_memory.ts +22 -0
- package/dist/templates/executive-assistant/tools/send_calendar_invite.ts +68 -0
- package/dist/templates/executive-assistant/tools/triage_inbox.ts +75 -0
- package/dist/templates/health-assistant/agent.test.ts +134 -15
- package/dist/templates/health-assistant/agent.ts +8 -1
- package/dist/templates/health-assistant/fda.test.ts +130 -0
- package/dist/templates/health-assistant/fda.ts +75 -16
- package/dist/templates/health-assistant/system-prompt.md +9 -0
- package/dist/templates/health-assistant/tools/check_drug_interaction.ts +5 -2
- package/dist/templates/health-assistant/tools/medication_lookup.ts +16 -11
- package/dist/templates/hiring-desk/agent.eval.test.ts +242 -0
- package/dist/templates/hiring-desk/agent.test.ts +1021 -0
- package/dist/templates/hiring-desk/agent.ts +38 -0
- package/dist/templates/hiring-desk/client.tsx +154 -0
- package/dist/templates/hiring-desk/crews.ts +432 -0
- package/dist/templates/hiring-desk/leads.json +86 -0
- package/dist/templates/hiring-desk/screening-lock.test.ts +77 -0
- package/dist/templates/hiring-desk/screening-lock.ts +51 -0
- package/dist/templates/hiring-desk/shared.ts +480 -0
- package/dist/templates/hiring-desk/system-prompt.md +21 -0
- package/dist/templates/hiring-desk/tools/candidate_details.ts +49 -0
- package/dist/templates/hiring-desk/tools/proceed_to_emails.ts +127 -0
- package/dist/templates/hiring-desk/tools/read_email.ts +50 -0
- package/dist/templates/hiring-desk/tools/rescore_with_feedback.ts +140 -0
- package/dist/templates/hiring-desk/tools/screen_candidates.ts +128 -0
- package/dist/templates/hiring-desk/tools/screening_status.ts +51 -0
- package/dist/templates/hotel-desk/agent.eval.test.ts +177 -0
- package/dist/templates/hotel-desk/agent.test.ts +1128 -0
- package/dist/templates/hotel-desk/agent.ts +63 -0
- package/dist/templates/hotel-desk/booking.ts +159 -0
- package/dist/templates/hotel-desk/card.ts +92 -0
- package/dist/templates/hotel-desk/catalogs.ts +219 -0
- package/dist/templates/hotel-desk/client.tsx +137 -0
- package/dist/templates/hotel-desk/concierge.ts +99 -0
- package/dist/templates/hotel-desk/desk-seams.test.ts +334 -0
- package/dist/templates/hotel-desk/desk.ts +224 -0
- package/dist/templates/hotel-desk/disputes.ts +216 -0
- package/dist/templates/hotel-desk/events.ts +79 -0
- package/dist/templates/hotel-desk/hotel.ts +412 -0
- package/dist/templates/hotel-desk/policies.ts +209 -0
- package/dist/templates/hotel-desk/records.ts +384 -0
- package/dist/templates/hotel-desk/restaurant.ts +147 -0
- package/dist/templates/hotel-desk/seed.ts +955 -0
- package/dist/templates/hotel-desk/shared.ts +354 -0
- package/dist/templates/hotel-desk/system-prompt.md +76 -0
- package/dist/templates/hotel-desk/tools/abandon_booking.ts +30 -0
- package/dist/templates/hotel-desk/tools/add_to_waitlist.ts +41 -0
- package/dist/templates/hotel-desk/tools/book_airport_car.ts +57 -0
- package/dist/templates/hotel-desk/tools/book_business_center.ts +44 -0
- package/dist/templates/hotel-desk/tools/book_spa_appointment.ts +39 -0
- package/dist/templates/hotel-desk/tools/book_tour.ts +35 -0
- package/dist/templates/hotel-desk/tools/cancel_restaurant_reservation.ts +25 -0
- package/dist/templates/hotel-desk/tools/cancel_room_booking.ts +63 -0
- package/dist/templates/hotel-desk/tools/check_restaurant_availability.ts +24 -0
- package/dist/templates/hotel-desk/tools/check_room_availability.ts +40 -0
- package/dist/templates/hotel-desk/tools/choose_room.ts +93 -0
- package/dist/templates/hotel-desk/tools/confirm_booking.ts +153 -0
- package/dist/templates/hotel-desk/tools/dispatch_emergency.ts +61 -0
- package/dist/templates/hotel-desk/tools/dispute_charge.ts +90 -0
- package/dist/templates/hotel-desk/tools/flag_late_arrival.ts +26 -0
- package/dist/templates/hotel-desk/tools/lookup_booking.ts +48 -0
- package/dist/templates/hotel-desk/tools/lookup_guest_history.ts +28 -0
- package/dist/templates/hotel-desk/tools/lookup_invoice.ts +26 -0
- package/dist/templates/hotel-desk/tools/lookup_policy.ts +20 -0
- package/dist/templates/hotel-desk/tools/lookup_restaurant_reservation.ts +27 -0
- package/dist/templates/hotel-desk/tools/modify_restaurant_reservation.ts +75 -0
- package/dist/templates/hotel-desk/tools/order_flowers.ts +40 -0
- package/dist/templates/hotel-desk/tools/record_card.ts +46 -0
- package/dist/templates/hotel-desk/tools/record_followup.ts +50 -0
- package/dist/templates/hotel-desk/tools/record_group_inquiry.ts +44 -0
- package/dist/templates/hotel-desk/tools/record_guest_details.ts +71 -0
- package/dist/templates/hotel-desk/tools/reinstate_booking.ts +65 -0
- package/dist/templates/hotel-desk/tools/request_flight_reconfirmation.ts +54 -0
- package/dist/templates/hotel-desk/tools/resend_confirmation.ts +39 -0
- package/dist/templates/hotel-desk/tools/reserve_table.ts +87 -0
- package/dist/templates/hotel-desk/tools/resolve_room_conflict.ts +48 -0
- package/dist/templates/hotel-desk/tools/schedule_wakeup_call.ts +48 -0
- package/dist/templates/hotel-desk/tools/set_do_not_disturb.ts +28 -0
- package/dist/templates/hotel-desk/tools/set_extras.ts +51 -0
- package/dist/templates/hotel-desk/tools/set_stay.ts +97 -0
- package/dist/templates/hotel-desk/tools/start_booking_modification.ts +57 -0
- package/dist/templates/hotel-desk/tools/start_room_booking.ts +49 -0
- package/dist/templates/hotel-desk/tools/take_guest_message.ts +71 -0
- package/dist/templates/hotel-desk/tools/transfer_call.ts +47 -0
- package/dist/templates/hotel-desk/tools/update_card.ts +45 -0
- package/dist/templates/hotel-desk/tools/verify_booking.ts +95 -0
- package/dist/templates/infocom-adventure/agent.eval.test.ts +33 -1
- package/dist/templates/infocom-adventure/agent.test.ts +207 -52
- package/dist/templates/infocom-adventure/agent.ts +14 -3
- package/dist/templates/infocom-adventure/client.tsx +138 -176
- package/dist/templates/infocom-adventure/shared.ts +126 -6
- package/dist/templates/infocom-adventure/system-prompt.md +4 -4
- package/dist/templates/infocom-adventure/tools/game_state_drop.ts +20 -4
- package/dist/templates/infocom-adventure/tools/game_state_get.ts +6 -5
- package/dist/templates/infocom-adventure/tools/game_state_score.ts +9 -3
- package/dist/templates/link-digest/agent.eval.test.ts +8 -0
- package/dist/templates/link-digest/agent.test.ts +285 -29
- package/dist/templates/link-digest/agent.ts +9 -0
- package/dist/templates/link-digest/api-client.ts +144 -0
- package/dist/templates/link-digest/client.tsx +11 -30
- package/dist/templates/link-digest/workflows/digest.ts +72 -24
- package/dist/templates/night-owl/agent.eval.test.ts +55 -40
- package/dist/templates/night-owl/agent.test.ts +146 -12
- package/dist/templates/night-owl/client.tsx +50 -17
- package/dist/templates/night-owl/shared.ts +33 -2
- package/dist/templates/night-owl/system-prompt.md +3 -0
- package/dist/templates/night-owl/tools/recommend.ts +4 -1
- package/dist/templates/night-owl/tools/revisit.ts +49 -0
- package/dist/templates/pipeline-simple/agent.eval.test.ts +7 -6
- package/dist/templates/pipeline-simple/agent.test.ts +48 -91
- package/dist/templates/pipeline-simple/modes.test.ts +151 -0
- package/dist/templates/pipeline-simple/stages.test.ts +332 -0
- package/dist/templates/pizza-ordering/agent.test.ts +94 -38
- package/dist/templates/pizza-ordering/client.tsx +10 -5
- package/dist/templates/pizza-ordering/shared.ts +65 -6
- package/dist/templates/pizza-ordering/tools/add_pizza.ts +2 -7
- package/dist/templates/pizza-ordering/tools/place_order.ts +9 -6
- package/dist/templates/pizza-ordering/tools/remove_pizza.ts +6 -11
- package/dist/templates/pizza-ordering/tools/update_pizza.ts +8 -9
- package/dist/templates/pizza-ordering/tools/view_order.ts +2 -3
- package/dist/templates/plan-and-execute/agent.eval.test.ts +14 -6
- package/dist/templates/plan-and-execute/agent.test.ts +300 -113
- package/dist/templates/plan-and-execute/client.tsx +18 -7
- package/dist/templates/plan-and-execute/procedure.ts +162 -64
- package/dist/templates/plan-and-execute/prompts.ts +51 -15
- package/dist/templates/plan-and-execute/shared.ts +151 -45
- package/dist/templates/plan-and-execute/tools/plan_status.ts +15 -6
- package/dist/templates/plan-and-execute/tools/revise_plan.ts +2 -2
- package/dist/templates/plan-and-execute/tools/start_plan.ts +2 -2
- package/dist/templates/plan-and-execute/tools/work_next_step.ts +15 -13
- package/dist/templates/podcast-digest/agent.eval.test.ts +12 -7
- package/dist/templates/podcast-digest/agent.test.ts +126 -51
- package/dist/templates/podcast-digest/client.tsx +104 -68
- package/dist/templates/podcast-digest/workflows/digest.ts +71 -48
- package/dist/templates/podcast-digest/workflows/feeds.ts +5 -7
- package/dist/templates/podcast-digest/workflows/slack.ts +82 -17
- package/dist/templates/recap-workflow/agent.eval.test.ts +193 -209
- package/dist/templates/recap-workflow/agent.test.ts +207 -26
- package/dist/templates/recap-workflow/tools/recap_status.ts +2 -2
- package/dist/templates/recap-workflow/workflows/recap.ts +39 -28
- package/dist/templates/redline/agent.eval.test.ts +40 -3
- package/dist/templates/redline/agent.test.ts +216 -6
- package/dist/templates/redline/agent.ts +54 -34
- package/dist/templates/redline/client.tsx +82 -126
- package/dist/templates/redline/form.ts +74 -0
- package/dist/templates/redline/workflows/prompts.ts +3 -3
- package/dist/templates/redline/workflows/redline.ts +73 -4
- package/dist/templates/research-workflow/agent.eval.test.ts +152 -150
- package/dist/templates/research-workflow/agent.test.ts +436 -126
- package/dist/templates/research-workflow/agent.ts +20 -5
- package/dist/templates/research-workflow/tools/file_it_now.ts +11 -1
- package/dist/templates/research-workflow/tools/research_status.ts +39 -4
- package/dist/templates/research-workflow/workflows/filing.ts +164 -0
- package/dist/templates/research-workflow/workflows/notes.ts +69 -0
- package/dist/templates/research-workflow/workflows/prompts.ts +45 -31
- package/dist/templates/research-workflow/workflows/research.ts +227 -280
- package/dist/templates/research-workflow/workflows/review.ts +43 -0
- package/dist/templates/retail/address.ts +29 -35
- package/dist/templates/retail/agent.eval.test.ts +36 -16
- package/dist/templates/retail/agent.test.ts +104 -26
- package/dist/templates/retail/agent.ts +12 -0
- package/dist/templates/retail/cancel.ts +39 -42
- package/dist/templates/retail/client.tsx +111 -176
- package/dist/templates/retail/payment.ts +38 -43
- package/dist/templates/retail/pending.test.ts +16 -8
- package/dist/templates/retail/registry.test.ts +108 -49
- package/dist/templates/retail/resolve.test.ts +2 -63
- package/dist/templates/retail/resolve.ts +16 -56
- package/dist/templates/retail/returns.ts +53 -54
- package/dist/templates/retail/seed.test.ts +2 -1
- package/dist/templates/retail/shared.ts +58 -14
- package/dist/templates/retail/store.test.ts +40 -29
- package/dist/templates/retail/store.ts +60 -23
- package/dist/templates/retail/swap.ts +78 -81
- package/dist/templates/retail/tools/find_user_id_by_name_zip.ts +2 -1
- package/dist/templates/roadside-assist/agent.eval.test.ts +164 -0
- package/dist/templates/roadside-assist/agent.test.ts +617 -0
- package/dist/templates/roadside-assist/agent.ts +85 -0
- package/dist/templates/roadside-assist/call.ts +237 -0
- package/dist/templates/roadside-assist/events.ts +92 -0
- package/dist/templates/roadside-assist/shared.ts +334 -0
- package/dist/templates/roadside-assist/system-prompt.md +37 -0
- package/dist/templates/roadside-assist/tools/acknowledge_disclosure.ts +47 -0
- package/dist/templates/roadside-assist/tools/dispatch_truck.ts +148 -0
- package/dist/templates/roadside-assist/tools/job_status.ts +38 -0
- package/dist/templates/roadside-assist/tools/lookup_coverage.ts +72 -0
- package/dist/templates/roadside-assist/tools/report_location.ts +79 -0
- package/dist/templates/roadside-assist/tools/service_disclosure.ts +45 -0
- package/dist/templates/roadside-assist/yard.test.ts +158 -0
- package/dist/templates/roadside-assist/yard.ts +183 -0
- package/dist/templates/simple/agent.eval.test.ts +4 -1
- package/dist/templates/simple/agent.test.ts +54 -31
- package/dist/templates/solo-rpg/agent.eval.test.ts +19 -11
- package/dist/templates/solo-rpg/agent.test.ts +402 -175
- package/dist/templates/solo-rpg/agent.ts +14 -3
- package/dist/templates/solo-rpg/client.tsx +10 -10
- package/dist/templates/solo-rpg/shared.ts +198 -79
- package/dist/templates/solo-rpg/tools/action_roll.ts +7 -3
- package/dist/templates/solo-rpg/tools/burn_momentum.ts +16 -8
- package/dist/templates/solo-rpg/tools/oracle.ts +7 -7
- package/dist/templates/solo-rpg/tools/setup_character.ts +5 -5
- package/dist/templates/solo-rpg/tools/update_state.ts +29 -18
- package/dist/templates/spoken-summary/agent.test.ts +70 -15
- package/dist/templates/spoken-summary/agent.ts +25 -21
- package/dist/templates/spoken-summary/client.tsx +68 -88
- package/dist/templates/spoken-summary/workflows/summarize.ts +26 -8
- package/dist/templates/support-line/agent.test.ts +167 -36
- package/dist/templates/support-line/client.tsx +21 -9
- package/dist/templates/support-line/nodes.ts +74 -32
- package/dist/templates/support-line/procedure.ts +66 -21
- package/dist/templates/support-line/prompts.ts +9 -0
- package/dist/templates/support-line/shared.ts +55 -17
- package/dist/templates/support-line/tools/answer_question.ts +14 -14
- package/dist/templates/transcription-workflow/agent.test.ts +135 -13
- package/dist/templates/transcription-workflow/client.tsx +30 -23
- package/dist/templates/transcription-workflow/recover.test.ts +93 -12
- package/dist/templates/transcription-workflow/recover.ts +29 -5
- package/dist/templates/transcription-workflow/run-panel.tsx +40 -51
- package/dist/templates/transcription-workflow/workflows/normalize.ts +125 -24
- package/dist/templates/transcription-workflow/workflows/stream.ts +4 -1
- package/dist/templates/transcription-workflow/workflows/transcribe.ts +7 -5
- package/dist/templates/transcription-workflow/workflows/wav.ts +42 -117
- package/dist/templates/travel-concierge/agent.eval.test.ts +6 -4
- package/dist/templates/travel-concierge/agent.test.ts +209 -40
- package/dist/templates/travel-concierge/agent.ts +24 -4
- package/dist/templates/travel-concierge/call-events.ts +80 -0
- package/dist/templates/travel-concierge/client.tsx +3 -2
- package/dist/templates/travel-concierge/routing.ts +5 -7
- package/dist/templates/travel-concierge/shared.ts +202 -41
- package/dist/templates/travel-concierge/tools/book_car_rental.ts +2 -4
- package/dist/templates/travel-concierge/tools/book_excursion.ts +2 -4
- package/dist/templates/travel-concierge/tools/book_hotel.ts +2 -4
- package/dist/templates/travel-concierge/tools/cancel_ticket.ts +6 -4
- package/dist/templates/travel-concierge/tools/search_car_rentals.ts +3 -5
- package/dist/templates/travel-concierge/tools/search_excursions.ts +3 -5
- package/dist/templates/travel-concierge/tools/search_flights.ts +20 -9
- package/dist/templates/travel-concierge/tools/search_hotels.ts +3 -5
- package/dist/templates/travel-concierge/tools/update_ticket.ts +2 -4
- package/dist/templates/web-researcher/agent.eval.test.ts +3 -6
- package/dist/templates/web-researcher/agent.test.ts +102 -65
- package/dist/templates/web-researcher/agent.ts +93 -1
- package/dist/templates/web-researcher/system-prompt.md +7 -1
- package/dist/templates/word-wrangler/agent.eval.test.ts +157 -0
- package/dist/templates/word-wrangler/agent.test.ts +432 -0
- package/dist/templates/word-wrangler/agent.ts +35 -0
- package/dist/templates/word-wrangler/client.tsx +211 -0
- package/dist/templates/word-wrangler/game.ts +107 -0
- package/dist/templates/word-wrangler/guess.ts +63 -0
- package/dist/templates/word-wrangler/player.ts +68 -0
- package/dist/templates/word-wrangler/shared.ts +263 -0
- package/dist/templates/word-wrangler/system-prompt.md +15 -0
- package/dist/templates/word-wrangler/tools/final_score.ts +37 -0
- package/dist/templates/word-wrangler/tools/relay_description.ts +137 -0
- package/dist/templates/word-wrangler/tools/repeat_word.ts +19 -0
- package/dist/templates/word-wrangler/tools/skip_word.ts +31 -0
- package/dist/templates/word-wrangler/tools/start_game.ts +47 -0
- package/dist/templates/word-wrangler/words.ts +278 -0
- package/dist/test-Cllnx81G.mjs +83 -0
- package/dist/test.d.ts +9 -114
- package/package.json +5 -5
- package/dist/build-BhEaxBPu.mjs +0 -481
- package/dist/templates/embedded-assets/agent.eval.test.ts +0 -130
- package/dist/templates/embedded-assets/agent.test.ts +0 -79
- package/dist/templates/embedded-assets/agent.ts +0 -7
- package/dist/templates/embedded-assets/knowledge.json +0 -20
- package/dist/templates/embedded-assets/shared.ts +0 -17
- package/dist/templates/embedded-assets/system-prompt.md +0 -13
- package/dist/templates/embedded-assets/tools/list_topics.ts +0 -9
- package/dist/templates/embedded-assets/tools/search_knowledge.ts +0 -26
- package/dist/templates/math-buddy/agent.eval.test.ts +0 -128
- package/dist/templates/math-buddy/agent.test.ts +0 -126
- package/dist/templates/math-buddy/agent.ts +0 -15
- package/dist/templates/math-buddy/system-prompt.md +0 -12
- package/dist/templates/personal-finance/agent.eval.test.ts +0 -149
- package/dist/templates/personal-finance/agent.test.ts +0 -127
- package/dist/templates/personal-finance/agent.ts +0 -8
- package/dist/templates/personal-finance/system-prompt.md +0 -21
package/dist/test.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `aai test` — run agent tests via vitest.
|
|
3
|
+
*
|
|
4
|
+
* The launcher is `_vitest-runner.ts`, shared with `aai eval` and `aai build`'s
|
|
5
|
+
* pre-build gate. What is here is the COMMAND: which files the test tier runs,
|
|
6
|
+
* and the verdict over the ones a run did not cover.
|
|
3
7
|
*/
|
|
4
8
|
import { type CommandResult } from "./_output.ts";
|
|
5
9
|
/**
|
|
@@ -21,123 +25,14 @@ type TestData = {
|
|
|
21
25
|
complete: boolean;
|
|
22
26
|
};
|
|
23
27
|
/**
|
|
24
|
-
*
|
|
25
|
-
* npx resolution overhead (and its potential network fetch of vitest).
|
|
28
|
+
* The files `aai test` runs, in preference order.
|
|
26
29
|
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* `
|
|
30
|
+
* The tier's filenames belong to the command, not to the runner — `aai eval`
|
|
31
|
+
* declares `EVAL_FILES` the same way one module over, and neither names the
|
|
32
|
+
* other's. `aai build` imports this one because its pre-build gate runs the
|
|
33
|
+
* TEST tier.
|
|
30
34
|
*/
|
|
31
|
-
export declare function resolveVitestCommand(cwd: string, resolve?: (id: string) => string): {
|
|
32
|
-
cmd: string;
|
|
33
|
-
args: string[];
|
|
34
|
-
};
|
|
35
|
-
/** The files `aai test` runs, in preference order. */
|
|
36
35
|
export declare const TEST_FILES: readonly ["agent.test.ts", "agent.test.js"];
|
|
37
|
-
/** Which files to run, and how — see {@link runVitest}. */
|
|
38
|
-
export type VitestRunOptions = {
|
|
39
|
-
/** File names to look for in the project root, in preference order. */
|
|
40
|
-
readonly candidates: readonly string[];
|
|
41
|
-
/** Extra vitest CLI arguments, inserted before the file names. */
|
|
42
|
-
readonly extraArgs?: readonly string[];
|
|
43
|
-
/**
|
|
44
|
-
* Variables to add to the child's environment. Absent leaves the child with
|
|
45
|
-
* the parent's env untouched, which is what `aai test` wants; `aai eval`
|
|
46
|
-
* passes the project's `.env` so an eval can reach the provider key the same
|
|
47
|
-
* way a session under `aai dev` does.
|
|
48
|
-
*/
|
|
49
|
-
readonly env?: Record<string, string>;
|
|
50
|
-
/**
|
|
51
|
-
* Run EVERY non-eval spec in the project rather than the first candidate.
|
|
52
|
-
*
|
|
53
|
-
* The opt-in half of the narrowing documented on {@link unrunSpecFiles}: the
|
|
54
|
-
* default stays one file, and this is how a caller says "I want the whole
|
|
55
|
-
* suite" without the command having to guess. Still a filter list rather than
|
|
56
|
-
* an include glob, so the eval tier stays disjoint by construction.
|
|
57
|
-
*/
|
|
58
|
-
readonly all?: boolean;
|
|
59
|
-
/**
|
|
60
|
-
* Whether THIS function announces the specs it did not run.
|
|
61
|
-
*
|
|
62
|
-
* Default TRUE, and the default is the point: the caller most in need of the
|
|
63
|
-
* notice is the one that does not know it is narrowing. `aai build` runs this
|
|
64
|
-
* as its pre-build gate and reports nothing of its own, so a build gated on
|
|
65
|
-
* one file out of eight said so nowhere. `aai test` and `aai eval` pass
|
|
66
|
-
* `false` — the first because it reports the same set itself, in its result
|
|
67
|
-
* as well as its output, and the second because "did not run" is a claim
|
|
68
|
-
* about the TEST tier and every unit spec in the project would be named
|
|
69
|
-
* falsely by an eval run.
|
|
70
|
-
*/
|
|
71
|
-
readonly announceUnrun?: boolean;
|
|
72
|
-
};
|
|
73
|
-
/**
|
|
74
|
-
* Run vitest over `candidates` (or, with `all`, the whole project) in the given
|
|
75
|
-
* project directory.
|
|
76
|
-
*
|
|
77
|
-
* Returns the FILES it ran, or `false` if there was nothing to run. Throws on
|
|
78
|
-
* failure.
|
|
79
|
-
*
|
|
80
|
-
* A vitest FILTER, not an include glob: each argument is matched as a substring
|
|
81
|
-
* against the paths vitest's own include globs already found, which is why the
|
|
82
|
-
* candidates are named `*.test.ts` — `agent.test.ts` cannot match
|
|
83
|
-
* `agent.eval.test.ts` and vice versa, so the two commands stay disjoint
|
|
84
|
-
* without either one having to exclude the other's file. That holds for the
|
|
85
|
-
* `all` list too: it is built from {@link projectSpecFiles}, which drops the
|
|
86
|
-
* eval tier by infix.
|
|
87
|
-
*/
|
|
88
|
-
export declare function runVitest(cwd: string, opts?: VitestRunOptions): string[] | false;
|
|
89
|
-
/**
|
|
90
|
-
* Classify a {@link runVitest} failure. execaSync throws an ENOENT-coded
|
|
91
|
-
* error when the binary itself couldn't be spawned (infrastructure problem)
|
|
92
|
-
* and an exit-code error when vitest ran and the tests failed.
|
|
93
|
-
*/
|
|
94
|
-
export declare function classifyVitestError(err: unknown,
|
|
95
|
-
/** What failed, for the message — `aai eval` runs the same runner. */
|
|
96
|
-
label?: string): {
|
|
97
|
-
code: "spawn_failed" | "test_failed";
|
|
98
|
-
message: string;
|
|
99
|
-
};
|
|
100
|
-
/**
|
|
101
|
-
* Every spec file in the project that belongs to the TEST tier.
|
|
102
|
-
*
|
|
103
|
-
* Eval files are excluded by the `.eval.` INFIX — the tier convention — rather
|
|
104
|
-
* than by a filename list, which is what keeps this module from importing
|
|
105
|
-
* `eval.ts`, which imports this one.
|
|
106
|
-
*/
|
|
107
|
-
export declare function projectSpecFiles(cwd: string): string[];
|
|
108
|
-
/**
|
|
109
|
-
* Spec files in the project that a run over `ran` did NOT cover.
|
|
110
|
-
*
|
|
111
|
-
* `runVitest` passes the candidate filename as a vitest FILTER, which is what
|
|
112
|
-
* keeps `test` and `eval` disjoint without either excluding the other's file —
|
|
113
|
-
* see its doc. The cost is that every other `*.test.ts` in the project is
|
|
114
|
-
* skipped, and the skip was SILENT: the shipped `retail` template carries seven
|
|
115
|
-
* of them, so `aai test` there ran 1 file / 67 tests, printed "Tests passed",
|
|
116
|
-
* and left 211 of the project's 278 tests unrun with nothing saying so.
|
|
117
|
-
*
|
|
118
|
-
* The narrow default STANDS — which files `aai test` runs is a documented
|
|
119
|
-
* contract (the scaffold guide says "Run agent.test.ts via vitest"), and running
|
|
120
|
-
* a project's other specs by default could reach ones that are slow or want
|
|
121
|
-
* credentials. What does not stand is a GREEN VERDICT over the difference: this
|
|
122
|
-
* set is what {@link executeTest} refuses to call a pass, what it puts in its
|
|
123
|
-
* result for a script to read, and what `--all` opts into running.
|
|
124
|
-
*/
|
|
125
|
-
export declare function unrunSpecFiles(cwd: string, ran: RanSpecs): string[];
|
|
126
|
-
/**
|
|
127
|
-
* What a caller reports as covered: one filename, a list of them, or `false`
|
|
128
|
-
* for a run that found nothing to point vitest at.
|
|
129
|
-
*/
|
|
130
|
-
export type RanSpecs = string | readonly string[] | false;
|
|
131
|
-
/**
|
|
132
|
-
* Warn, once, naming the spec files this run did not cover.
|
|
133
|
-
*
|
|
134
|
-
* This is the notice for a caller whose own result says nothing about the
|
|
135
|
-
* narrowing — today that is `aai build`'s pre-build gate, which ran one file
|
|
136
|
-
* out of eight and printed "Build complete". `aai test` does not use it: an
|
|
137
|
-
* incomplete run is a FAILURE there, and the failure's own message is the
|
|
138
|
-
* report.
|
|
139
|
-
*/
|
|
140
|
-
export declare function warnUnrunSpecs(cwd: string, ran: RanSpecs): void;
|
|
141
36
|
/** What `aai test` was asked to cover. */
|
|
142
37
|
export type TestOptions = {
|
|
143
38
|
/** Run every non-eval spec in the project rather than `agent.test.ts` alone. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alexkroman1/aai-cli",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "16.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -57,16 +57,16 @@
|
|
|
57
57
|
"p-timeout": "^7.0.1",
|
|
58
58
|
"vite": "^8.2.2",
|
|
59
59
|
"zod": "^4.5.4",
|
|
60
|
-
"@alexkroman1/aai": "
|
|
61
|
-
"@alexkroman1/aai-runtime": "
|
|
62
|
-
"@alexkroman1/aai-ui": "
|
|
60
|
+
"@alexkroman1/aai": "16.0.0",
|
|
61
|
+
"@alexkroman1/aai-runtime": "16.0.0",
|
|
62
|
+
"@alexkroman1/aai-ui": "16.0.0"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"playwright": "^1.62.1",
|
|
66
66
|
"tsdown": "^0.22.14",
|
|
67
67
|
"verdaccio": "^6.10.1",
|
|
68
68
|
"vitest": "^4.1.11",
|
|
69
|
-
"aai-templates": "0.
|
|
69
|
+
"aai-templates": "0.4.0"
|
|
70
70
|
},
|
|
71
71
|
"peerDependencies": {
|
|
72
72
|
"vitest": "^4.1.10"
|
package/dist/build-BhEaxBPu.mjs
DELETED
|
@@ -1,481 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { a as ok, t as CliError } from "./_output-DBP9Op_d.mjs";
|
|
3
|
-
import { n as log, r as notify } from "./_ui-DCt4qZrk.mjs";
|
|
4
|
-
import { n as withPreservedNodeEnv } from "./_vite-env-kejF0p2L.mjs";
|
|
5
|
-
import { n as WORKER_ARTIFACT_REL, t as CLIENT_ARTIFACT_REL } from "./_artifacts-BJOYGQPp.mjs";
|
|
6
|
-
import { r as evalWorkerBundle, t as buildAgentBundle } from "./_bundler-DM0d0M7m.mjs";
|
|
7
|
-
import { assertTypechecks } from "./_typecheck-gate-U3jcil8L.mjs";
|
|
8
|
-
import { n as scanWorkflowDeterminism, t as determinismWarnings } from "./_workflow-determinism-CvpqMpdh.mjs";
|
|
9
|
-
import { TEST_FILES, classifyVitestError, runVitest } from "./test-D032V2cA.mjs";
|
|
10
|
-
import path from "node:path";
|
|
11
|
-
import fs from "node:fs/promises";
|
|
12
|
-
import { invariant } from "@alexkroman1/aai/internal";
|
|
13
|
-
import { build } from "vite";
|
|
14
|
-
import { defaultClientDir } from "@alexkroman1/aai-ui/client-dir";
|
|
15
|
-
import { agentConfigWarnings } from "@alexkroman1/aai/manifest";
|
|
16
|
-
import { DEFAULT_SYSTEM_PROMPT } from "@alexkroman1/aai";
|
|
17
|
-
//#region src/_build-target.ts
|
|
18
|
-
/**
|
|
19
|
-
* Deployment TARGETS — what `aai build` emits beside the worker so a host can
|
|
20
|
-
* run this project without the project holding anything host-specific.
|
|
21
|
-
*
|
|
22
|
-
* ## Why a target rather than a file in the scaffold
|
|
23
|
-
*
|
|
24
|
-
* Every host wants a different entry shape: Vercel wants a module whose default
|
|
25
|
-
* export is an `http.Server` it binds itself, a container wants a long-lived
|
|
26
|
-
* process, another platform wants something else again. Committing one of those
|
|
27
|
-
* to the scaffold makes every project assert a fact that is load-bearing on
|
|
28
|
-
* exactly one host — the same objection that removed `server.mjs`.
|
|
29
|
-
*
|
|
30
|
-
* Nitro is the worked precedent: one codebase, a preset per provider, and the
|
|
31
|
-
* preset EMITS the host's expected shape into the build directory. `node-server`
|
|
32
|
-
* is its default and Vercel/Netlify/Cloudflare are detected from the CI
|
|
33
|
-
* environment with no configuration. Next does the same narrower thing with
|
|
34
|
-
* `output: "standalone"` — it generates a `server.js` rather than asking anyone
|
|
35
|
-
* to write one. Either way the user's repository contains no host file, which is
|
|
36
|
-
* the property to preserve here.
|
|
37
|
-
*
|
|
38
|
-
* ## Auto-detection, and why it is safe
|
|
39
|
-
*
|
|
40
|
-
* A target is chosen with `--target`, or detected from the environment when the
|
|
41
|
-
* flag is absent. Detection reads the variables the hosts set on their own build
|
|
42
|
-
* containers ({@link TARGET_ENV_MARKERS}), so it only ever fires where the build
|
|
43
|
-
* is genuinely running on that host — a laptop sets none of them and gets
|
|
44
|
-
* {@link DEFAULT_BUILD_TARGET}, which emits nothing extra and is what every
|
|
45
|
-
* existing project already does.
|
|
46
|
-
*/
|
|
47
|
-
/** The targets `aai build --target` accepts. */
|
|
48
|
-
const BUILD_TARGETS = ["node", "vercel"];
|
|
49
|
-
/**
|
|
50
|
-
* What a build with no `--target` and no host environment produces: the worker
|
|
51
|
-
* and the client, and nothing else.
|
|
52
|
-
*
|
|
53
|
-
* `node` rather than a `"none"` sentinel because it NAMES the deployment it
|
|
54
|
-
* serves — a long-lived process running `aai start` — which is what every
|
|
55
|
-
* container platform wants and what the scaffold's own `start` script runs.
|
|
56
|
-
*/
|
|
57
|
-
const DEFAULT_BUILD_TARGET = "node";
|
|
58
|
-
/**
|
|
59
|
-
* The environment variable each host sets on its own build container.
|
|
60
|
-
*
|
|
61
|
-
* `VERCEL` is set for every Vercel build and deployment. Detection is per host
|
|
62
|
-
* rather than a single "am I in CI" test, because a GitHub Action building a
|
|
63
|
-
* container image is CI too and wants the default.
|
|
64
|
-
*/
|
|
65
|
-
const TARGET_ENV_MARKERS = { VERCEL: "vercel" };
|
|
66
|
-
function isBuildTarget(value) {
|
|
67
|
-
return BUILD_TARGETS.includes(value);
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Resolve the target for this build: an explicit flag wins, then the
|
|
71
|
-
* environment, then {@link DEFAULT_BUILD_TARGET}.
|
|
72
|
-
*
|
|
73
|
-
* An unrecognised `--target` is REFUSED naming what is accepted, rather than
|
|
74
|
-
* falling back to the default — a typo'd target that silently built the default
|
|
75
|
-
* would deploy a project missing the entry its host needs, and the failure would
|
|
76
|
-
* arrive as a 404 from the platform rather than as an error from the build.
|
|
77
|
-
*/
|
|
78
|
-
function resolveBuildTarget(explicit, env = process.env) {
|
|
79
|
-
if (explicit !== void 0) {
|
|
80
|
-
if (!isBuildTarget(explicit)) throw new Error(`Unknown build target "${explicit}". Accepted: ${BUILD_TARGETS.join(", ")}.`);
|
|
81
|
-
return explicit;
|
|
82
|
-
}
|
|
83
|
-
for (const [marker, target] of Object.entries(TARGET_ENV_MARKERS)) if (env[marker]) return target;
|
|
84
|
-
return DEFAULT_BUILD_TARGET;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Where a PREBUILT Vercel deployment lives, relative to the project root.
|
|
88
|
-
*
|
|
89
|
-
* The Build Output API rather than an `api/` entry plus a `vercel.json`, and
|
|
90
|
-
* the reason is ORDERING. Vercel reads `vercel.json` and decides what to build
|
|
91
|
-
* BEFORE it runs the build command, so a `vercel.json` that the build WRITES
|
|
92
|
-
* configures the NEXT deployment and not this one — a clean clone deploys with
|
|
93
|
-
* no rewrite and no function at all. The `api/` shape only ever appeared to
|
|
94
|
-
* work because a previous local `aai build --target vercel` had left both
|
|
95
|
-
* files in the working tree, which is a property of one laptop rather than of
|
|
96
|
-
* the repository. `.vercel/output/` is read AFTER the build command; it is the
|
|
97
|
-
* only place a build can describe its own deployment.
|
|
98
|
-
*
|
|
99
|
-
* Two more things fall out of owning the directory, both of which the `api/`
|
|
100
|
-
* shape got wrong and could not fix. The function bundle is ASSEMBLED here
|
|
101
|
-
* rather than traced, so `.aai/worker.mjs` — loaded through a dynamic
|
|
102
|
-
* `import(pathToFileURL(...))` that no static tracer can follow — and
|
|
103
|
-
* `.env.example` — the file that DECLARES which variables become `ctx.env` —
|
|
104
|
-
* are present because they were copied in. And the built client is served by
|
|
105
|
-
* the CDN out of `static/` instead of through the function.
|
|
106
|
-
*
|
|
107
|
-
* Nitro's vercel preset is the worked precedent and lands in exactly here:
|
|
108
|
-
* `output.dir = {{rootDir}}/.vercel/output`, `serverDir` a `.func` under it.
|
|
109
|
-
*
|
|
110
|
-
* @see https://vercel.com/docs/build-output-api/v3
|
|
111
|
-
*/
|
|
112
|
-
const VERCEL_OUTPUT_DIR = path.join(".vercel", "output");
|
|
113
|
-
/**
|
|
114
|
-
* The one function every request that is not a static file reaches.
|
|
115
|
-
*
|
|
116
|
-
* The Build Output API derives a function's ROUTE from its path, so the
|
|
117
|
-
* directory name IS a URL and must not collide with one the static output
|
|
118
|
-
* claims. **`index.func` collides**, which a deployment is the only way to
|
|
119
|
-
* find out: it is served at `/index`, and Vercel's directory index resolves
|
|
120
|
-
* `/` to the extensionless `/index` — so the function won `/`, every other
|
|
121
|
-
* asset came off the CDN correctly, and the home page 500'd on a deployment
|
|
122
|
-
* whose static output was perfect. Measured on a real preview:
|
|
123
|
-
* `/favicon.ico`, `/index.html` and both hashed `/assets/*` returned 200
|
|
124
|
-
* while `/` and `/index` did not.
|
|
125
|
-
*
|
|
126
|
-
* `__server` is Nitro's answer to the same problem (`__server.func`) and the
|
|
127
|
-
* reason is this one: a double-underscore prefix is not a path any bundler
|
|
128
|
-
* emits, so no static file can ever take the name.
|
|
129
|
-
*/
|
|
130
|
-
const VERCEL_FUNCTION_DIR = path.join(VERCEL_OUTPUT_DIR, "functions", "__server.func");
|
|
131
|
-
/**
|
|
132
|
-
* The route {@link VERCEL_FUNCTION_DIR} is served at — its directory name
|
|
133
|
-
* without `.func`, which is how the Build Output API names a function.
|
|
134
|
-
*/
|
|
135
|
-
const VERCEL_FUNCTION_ROUTE = "/__server";
|
|
136
|
-
/** Static assets the Vercel CDN serves directly, never reaching the function. */
|
|
137
|
-
const VERCEL_STATIC_DIR = path.join(VERCEL_OUTPUT_DIR, "static");
|
|
138
|
-
/**
|
|
139
|
-
* Node versions Vercel offers. A build on anything newer picks the newest of
|
|
140
|
-
* these rather than naming a runtime the platform will reject.
|
|
141
|
-
*
|
|
142
|
-
* @see https://vercel.com/docs/functions/runtimes/node-js/node-js-versions
|
|
143
|
-
*/
|
|
144
|
-
const SUPPORTED_NODE_MAJORS = [
|
|
145
|
-
20,
|
|
146
|
-
22,
|
|
147
|
-
24
|
|
148
|
-
];
|
|
149
|
-
/** `nodejs<major>.x` for the Node running this build, clamped to what Vercel offers. */
|
|
150
|
-
function vercelNodeRuntime(version = process.versions.node) {
|
|
151
|
-
const major = Number.parseInt(version.split(".")[0] ?? "", 10);
|
|
152
|
-
return `nodejs${Number.isNaN(major) ? 22 : SUPPORTED_NODE_MAJORS.findLast((v) => v <= major) ?? SUPPORTED_NODE_MAJORS[0]}.x`;
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* The Vercel function entry, emitted into {@link VERCEL_FUNCTION_DIR}.
|
|
156
|
-
*
|
|
157
|
-
* ## Why a `(req, res)` handler and not `export default server`
|
|
158
|
-
*
|
|
159
|
-
* `export default <http.Server>` is what Vercel's own `@vercel/node` BUILDER
|
|
160
|
-
* accepts, and it is the shape the previous `api/index.mjs` used. The Build
|
|
161
|
-
* Output API has no builder in the path: `launcherType: "Nodejs"` invokes the
|
|
162
|
-
* module's default export as a request handler, so the server never gets
|
|
163
|
-
* bound and there is nothing to raise an `upgrade` event on it.
|
|
164
|
-
*
|
|
165
|
-
* ## How a WebSocket survives that
|
|
166
|
-
*
|
|
167
|
-
* Vercel hands a Node function the raw upgrade through its PER-REQUEST
|
|
168
|
-
* context — `globalThis[Symbol.for("@vercel/request-context")].get()
|
|
169
|
-
* .upgradeWebSocket()` returns the `{ req, socket, head }` triple — rather
|
|
170
|
-
* than as an event. Nitro reaches it through `crossws/adapters/vercel`; here
|
|
171
|
-
* the adapter is three lines, because {@link AgentServer.node} is a real
|
|
172
|
-
* `http.Server` that already has both an `upgrade` and a `request` listener
|
|
173
|
-
* registered. Re-emitting onto it is the whole translation, and it means the
|
|
174
|
-
* deployed path through `server.ts` is the same one `aai dev` and `aai start`
|
|
175
|
-
* take — no second WebSocket entry point to keep in step.
|
|
176
|
-
*
|
|
177
|
-
* The `204` afterwards is what the launcher needs to consider the invocation
|
|
178
|
-
* finished; the socket the agent is now talking on is not this `res`.
|
|
179
|
-
*
|
|
180
|
-
* ## `import.meta.dirname`, not `process.cwd()`
|
|
181
|
-
*
|
|
182
|
-
* The function's working directory belongs to the platform, but `.aai/` and
|
|
183
|
-
* `.env.example` were copied in BESIDE this file. Resolving from the module
|
|
184
|
-
* keeps that a fact about the bundle rather than about how Vercel happens to
|
|
185
|
-
* invoke it.
|
|
186
|
-
*/
|
|
187
|
-
const VERCEL_ENTRY_SOURCE = `// Generated by \`aai build --target vercel\` — do not edit, and do not commit.
|
|
188
|
-
// Vercel invokes this handler per request and delivers a WebSocket upgrade
|
|
189
|
-
// through its request context. See @alexkroman1/aai-cli/start.
|
|
190
|
-
import { createProjectServer } from "@alexkroman1/aai-cli/start";
|
|
191
|
-
|
|
192
|
-
const server = (await createProjectServer({ cwd: import.meta.dirname })).node;
|
|
193
|
-
|
|
194
|
-
const REQUEST_CONTEXT = Symbol.for("@vercel/request-context");
|
|
195
|
-
|
|
196
|
-
export default function handler(req, res) {
|
|
197
|
-
if (req.method === "GET" && req.headers.upgrade?.toLowerCase() === "websocket") {
|
|
198
|
-
const upgrade = globalThis[REQUEST_CONTEXT]?.get?.()?.upgradeWebSocket?.();
|
|
199
|
-
if (upgrade) {
|
|
200
|
-
server.emit("upgrade", upgrade.req, upgrade.socket, upgrade.head);
|
|
201
|
-
if (!res.headersSent && !res.writableEnded) {
|
|
202
|
-
res.statusCode = 204;
|
|
203
|
-
res.end();
|
|
204
|
-
}
|
|
205
|
-
return;
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
server.emit("request", req, res);
|
|
209
|
-
}
|
|
210
|
-
`;
|
|
211
|
-
/**
|
|
212
|
-
* `.vc-config.json` — how the platform runs {@link VERCEL_ENTRY_SOURCE}.
|
|
213
|
-
*
|
|
214
|
-
* `supportsResponseStreaming` is not optional here: an agent streams TTS audio
|
|
215
|
-
* and SSE workflow events, and without it the platform buffers a response to
|
|
216
|
-
* completion, which for a stream that ends when the call does means it never
|
|
217
|
-
* arrives. `shouldAddHelpers` stays off — the entry speaks `node:http`, and
|
|
218
|
-
* the helpers exist to bolt Express-shaped sugar onto a handler that does not.
|
|
219
|
-
*/
|
|
220
|
-
function vercelFunctionConfigSource(runtime = vercelNodeRuntime()) {
|
|
221
|
-
return `${JSON.stringify({
|
|
222
|
-
runtime,
|
|
223
|
-
handler: "index.mjs",
|
|
224
|
-
launcherType: "Nodejs",
|
|
225
|
-
shouldAddHelpers: false,
|
|
226
|
-
supportsResponseStreaming: true
|
|
227
|
-
}, null, 2)}\n`;
|
|
228
|
-
}
|
|
229
|
-
/**
|
|
230
|
-
* `config.json` — the routing table, and the reason static assets stop paying
|
|
231
|
-
* for a function invocation.
|
|
232
|
-
*
|
|
233
|
-
* `{ "handle": "filesystem" }` serves anything present in
|
|
234
|
-
* {@link VERCEL_STATIC_DIR} from the CDN and only then falls through, so the
|
|
235
|
-
* client bundle, its assets and the worklets are edge-served while
|
|
236
|
-
* `/client-config`, `/websocket`, `/workflows/*` and the webhook route reach
|
|
237
|
-
* the agent. The `api/` shape routed EVERY request through the function, which
|
|
238
|
-
* this file's earlier revision noted as deliberate and "not what makes a
|
|
239
|
-
* deployment work or not" — true of correctness, false of cost, and free here
|
|
240
|
-
* because the Build Output API already separates the two directories.
|
|
241
|
-
*/
|
|
242
|
-
const VERCEL_BUILD_CONFIG_SOURCE = `${JSON.stringify({
|
|
243
|
-
version: 3,
|
|
244
|
-
routes: [{ handle: "filesystem" }, {
|
|
245
|
-
src: "/(.*)",
|
|
246
|
-
dest: VERCEL_FUNCTION_ROUTE
|
|
247
|
-
}]
|
|
248
|
-
}, null, 2)}\n`;
|
|
249
|
-
//#endregion
|
|
250
|
-
//#region src/_vercel-output.ts
|
|
251
|
-
/**
|
|
252
|
-
* Assemble a PREBUILT Vercel deployment — `.vercel/output/` — from what
|
|
253
|
-
* `aai build` just produced.
|
|
254
|
-
*
|
|
255
|
-
* The argument for the Build Output API over an `api/` entry is in
|
|
256
|
-
* `_build-target.ts` at {@link VERCEL_OUTPUT_DIR}; what this module adds is the
|
|
257
|
-
* consequence of it. A `.func` directory is a directory WE fill, so every file
|
|
258
|
-
* the server reads at runtime is present because it was copied in, and nothing
|
|
259
|
-
* depends on a static tracer following a path it structurally cannot:
|
|
260
|
-
*
|
|
261
|
-
* - **`.aai/worker.mjs`** is loaded through `import(pathToFileURL(...))`
|
|
262
|
-
* (`start.ts`), which `@vercel/nft` cannot resolve. Under the `api/` shape
|
|
263
|
-
* the build was green and the function 500'd on its first request with
|
|
264
|
-
* "No built agent at .aai/worker.mjs".
|
|
265
|
-
* - **`.env.example`** is not documentation here. `resolveServerEnv` treats it
|
|
266
|
-
* as the DECLARATION of which variables become `ctx.env` (see
|
|
267
|
-
* `DEPLOY_ENV_FILES`), so a function without it hands every tool an empty
|
|
268
|
-
* env while the Vercel project has the values set — a failure that looks
|
|
269
|
-
* like a credential problem and is a packaging one.
|
|
270
|
-
* - **The client** is copied to `static/`, where the CDN serves it, and also
|
|
271
|
-
* beside the worker, so `resolveClientDir` finds a real directory rather
|
|
272
|
-
* than reaching into a `node_modules` that the bundle replaced.
|
|
273
|
-
*
|
|
274
|
-
* The entry is BUNDLED rather than shipped with a `node_modules`. Same call as
|
|
275
|
-
* the worker (`ssr: { noExternal: true }`, `root: cwd`), so it resolves the
|
|
276
|
-
* project's own installed SDK and pulls the runtime, `ws` and `pg` in with it
|
|
277
|
-
* — which is already the arrangement a deployed worker runs under, and it is
|
|
278
|
-
* what makes the function independent of whether the host's install left a
|
|
279
|
-
* usable, hoisted `node_modules` behind.
|
|
280
|
-
*/
|
|
281
|
-
/**
|
|
282
|
-
* Files copied verbatim into the function, each one read at RUNTIME by a path
|
|
283
|
-
* no bundler can see. A missing one is skipped rather than fatal.
|
|
284
|
-
*
|
|
285
|
-
* **`.env` is deliberately NOT here.** `resolveServerEnv` reads
|
|
286
|
-
* {@link DEPLOY_ENV_FILES} — `.env.example` then `.env` — but only the first is
|
|
287
|
-
* a DECLARATION; the second holds a developer's own keys, and copying it would
|
|
288
|
-
* bake them into a deployment artifact and let them silently win over the
|
|
289
|
-
* values set in the Vercel project. Declarations ship, values come from the
|
|
290
|
-
* platform environment. Verified by building the `simple` template: a local
|
|
291
|
-
* `.env` with live credentials landed in the function until this list dropped
|
|
292
|
-
* it.
|
|
293
|
-
*/
|
|
294
|
-
const RUNTIME_FILES = [WORKER_ARTIFACT_REL, ".env.example"];
|
|
295
|
-
/**
|
|
296
|
-
* Write `.vercel/output/` for this project.
|
|
297
|
-
*
|
|
298
|
-
* The directory is REMOVED first. It is not addressed by content, so a
|
|
299
|
-
* function or a static asset left by an earlier build with a different shape
|
|
300
|
-
* would be deployed alongside this one — and `vercel deploy --prebuilt`
|
|
301
|
-
* uploads whatever is there.
|
|
302
|
-
*/
|
|
303
|
-
async function emitVercelOutput(cwd, options = {}) {
|
|
304
|
-
const outputDir = path.join(cwd, VERCEL_OUTPUT_DIR);
|
|
305
|
-
const functionDir = path.join(cwd, VERCEL_FUNCTION_DIR);
|
|
306
|
-
const staticDir = path.join(cwd, VERCEL_STATIC_DIR);
|
|
307
|
-
await fs.rm(outputDir, {
|
|
308
|
-
recursive: true,
|
|
309
|
-
force: true
|
|
310
|
-
});
|
|
311
|
-
await fs.mkdir(functionDir, { recursive: true });
|
|
312
|
-
await fs.writeFile(path.join(outputDir, "config.json"), VERCEL_BUILD_CONFIG_SOURCE, "utf-8");
|
|
313
|
-
await fs.writeFile(path.join(functionDir, ".vc-config.json"), vercelFunctionConfigSource(), "utf-8");
|
|
314
|
-
const bundle = options.bundle ?? bundleEntry;
|
|
315
|
-
await fs.writeFile(path.join(functionDir, "index.mjs"), await bundle(cwd), "utf-8");
|
|
316
|
-
for (const rel of RUNTIME_FILES) {
|
|
317
|
-
const from = path.join(cwd, rel);
|
|
318
|
-
if (!await exists(from)) continue;
|
|
319
|
-
const to = path.join(functionDir, rel);
|
|
320
|
-
await fs.mkdir(path.dirname(to), { recursive: true });
|
|
321
|
-
await fs.copyFile(from, to);
|
|
322
|
-
}
|
|
323
|
-
const clientSource = await exists(path.join(cwd, CLIENT_ARTIFACT_REL, "index.html")) ? path.join(cwd, CLIENT_ARTIFACT_REL) : defaultClientDir();
|
|
324
|
-
await fs.cp(clientSource, staticDir, { recursive: true });
|
|
325
|
-
await fs.cp(clientSource, path.join(functionDir, CLIENT_ARTIFACT_REL), { recursive: true });
|
|
326
|
-
}
|
|
327
|
-
/**
|
|
328
|
-
* Bundle {@link VERCEL_ENTRY_SOURCE} and everything it imports into one ESM
|
|
329
|
-
* file.
|
|
330
|
-
*
|
|
331
|
-
* The entry is written INTO the project rather than a temp directory, because
|
|
332
|
-
* that is what makes `@alexkroman1/aai-cli/start` resolve against the user's
|
|
333
|
-
* install — the deployed server is then the version their lockfile pins, which
|
|
334
|
-
* is the same guarantee `aai publish` gives. Removed in a `finally`: a build
|
|
335
|
-
* that throws must not leave a file that looks authored.
|
|
336
|
-
*/
|
|
337
|
-
async function bundleEntry(cwd) {
|
|
338
|
-
const entryPath = path.join(cwd, ".aai", "vercel-entry.mjs");
|
|
339
|
-
await fs.mkdir(path.dirname(entryPath), { recursive: true });
|
|
340
|
-
await fs.writeFile(entryPath, VERCEL_ENTRY_SOURCE, "utf-8");
|
|
341
|
-
let result;
|
|
342
|
-
try {
|
|
343
|
-
result = await withPreservedNodeEnv(() => build({
|
|
344
|
-
root: cwd,
|
|
345
|
-
logLevel: "silent",
|
|
346
|
-
configFile: false,
|
|
347
|
-
ssr: { noExternal: true },
|
|
348
|
-
build: {
|
|
349
|
-
ssr: true,
|
|
350
|
-
lib: {
|
|
351
|
-
entry: entryPath,
|
|
352
|
-
formats: ["es"],
|
|
353
|
-
fileName: "index"
|
|
354
|
-
},
|
|
355
|
-
target: "node20",
|
|
356
|
-
minify: false,
|
|
357
|
-
write: false,
|
|
358
|
-
rollupOptions: { output: {
|
|
359
|
-
entryFileNames: "[name].mjs",
|
|
360
|
-
codeSplitting: false
|
|
361
|
-
} }
|
|
362
|
-
}
|
|
363
|
-
}));
|
|
364
|
-
} finally {
|
|
365
|
-
await fs.rm(entryPath, { force: true }).catch(() => void 0);
|
|
366
|
-
}
|
|
367
|
-
const output = Array.isArray(result) ? result[0] : result;
|
|
368
|
-
invariant(output !== void 0, "vercel.entry.output");
|
|
369
|
-
const chunk = output.output.find((o) => o.type === "chunk" && o.isEntry);
|
|
370
|
-
invariant(chunk !== void 0, "vercel.entry.chunk", () => ({ kinds: output.output.map((o) => o.type) }));
|
|
371
|
-
return chunk.code;
|
|
372
|
-
}
|
|
373
|
-
async function exists(target) {
|
|
374
|
-
return await fs.stat(target).then(() => true, () => false);
|
|
375
|
-
}
|
|
376
|
-
//#endregion
|
|
377
|
-
//#region src/build.ts
|
|
378
|
-
/**
|
|
379
|
-
* `aai build` — bundle the agent without deploying, behind the same gates
|
|
380
|
-
* deploy runs (tests, then typecheck), so the command previews the deploy
|
|
381
|
-
* artifact and its failures alike.
|
|
382
|
-
*
|
|
383
|
-
* It also LEAVES that artifact on disk, at {@link WORKER_ARTIFACT_REL}, which is
|
|
384
|
-
* what makes self-hosting work: `aai start` loads the built worker rather than
|
|
385
|
-
* `agent.ts`, because a tool is discovered by the bundler enumerating `tools/`
|
|
386
|
-
* and no un-bundled loader can see that directory. See `start.ts` and
|
|
387
|
-
* "Self-hosting is the scaffold's default" in `packages/aai-cli/CLAUDE.md`.
|
|
388
|
-
*
|
|
389
|
-
* `--target` decides what else it emits — see `_build-target.ts`.
|
|
390
|
-
*/
|
|
391
|
-
/**
|
|
392
|
-
* The prose slot, named by convention. Mirrors `worker-bundler.ts`'s constant of
|
|
393
|
-
* the same name — the two cannot share one without an import cycle
|
|
394
|
-
* (`build.ts` → `_bundler.ts` → `worker-bundler.ts`), so `_build.test.ts` pins
|
|
395
|
-
* the pair end to end instead: a build whose prompt really came from the file
|
|
396
|
-
* has to report the file.
|
|
397
|
-
*/
|
|
398
|
-
const SYSTEM_PROMPT_FILE = "system-prompt.md";
|
|
399
|
-
/** What {@link systemPromptSource} reports when nothing declared a prompt. */
|
|
400
|
-
const FRAMEWORK_DEFAULT_PROMPT_SOURCE = "the framework default (DEFAULT_SYSTEM_PROMPT)";
|
|
401
|
-
/**
|
|
402
|
-
* Which of the three possible authors of this agent's system prompt actually
|
|
403
|
-
* wrote the one in the bundle.
|
|
404
|
-
*
|
|
405
|
-
* `aai build` reported `name` and `workerBytes` and nothing about the prompt,
|
|
406
|
-
* and the prompt is the one field that can change COMPLETELY without any
|
|
407
|
-
* config changing: deleting `system-prompt.md` swaps in
|
|
408
|
-
* `DEFAULT_SYSTEM_PROMPT` — a total personality change — with exit 0 and no
|
|
409
|
-
* line anywhere. `withSystemPrompt` refuses the case where a file exists and
|
|
410
|
-
* nothing reads it; it cannot refuse a file that is simply GONE, because that
|
|
411
|
-
* is what an agent with no file legitimately looks like. So this is a report
|
|
412
|
-
* rather than a check.
|
|
413
|
-
*
|
|
414
|
-
* Decided by comparing VALUES against the built agent's resolved prompt, which
|
|
415
|
-
* is the same method `withSystemPrompt` uses and for the same reason — the
|
|
416
|
-
* alternative asks the bundler's module graph a question, and the author may
|
|
417
|
-
* have imported the file and composed it, which is neither "the file" nor
|
|
418
|
-
* "agent.ts" alone.
|
|
419
|
-
*/
|
|
420
|
-
async function systemPromptSource(cwd, resolved) {
|
|
421
|
-
if (resolved === DEFAULT_SYSTEM_PROMPT) return FRAMEWORK_DEFAULT_PROMPT_SOURCE;
|
|
422
|
-
const trimmed = (await fs.readFile(path.join(cwd, SYSTEM_PROMPT_FILE), "utf-8").catch(() => void 0))?.trim();
|
|
423
|
-
if (trimmed === void 0 || trimmed === "" || !resolved.includes(trimmed)) return "agent.ts";
|
|
424
|
-
return resolved.trim() === trimmed ? SYSTEM_PROMPT_FILE : `agent.ts (composing ${SYSTEM_PROMPT_FILE})`;
|
|
425
|
-
}
|
|
426
|
-
/**
|
|
427
|
-
* Map a {@link runVitest} failure to a CliError — distinguishing a real test
|
|
428
|
-
* failure (test_failed) from the runner not spawning (spawn_failed) instead
|
|
429
|
-
* of a generic command_failed.
|
|
430
|
-
*/
|
|
431
|
-
function testGateError(err) {
|
|
432
|
-
const { code, message } = classifyVitestError(err);
|
|
433
|
-
return new CliError(code, message, "Re-run with --skipTests to build without tests", { cause: err });
|
|
434
|
-
}
|
|
435
|
-
async function executeBuild(opts) {
|
|
436
|
-
const { cwd } = opts;
|
|
437
|
-
const target = resolveBuildTarget(opts.target);
|
|
438
|
-
if (!opts.skipTests) try {
|
|
439
|
-
runVitest(cwd, {
|
|
440
|
-
candidates: TEST_FILES,
|
|
441
|
-
all: true
|
|
442
|
-
});
|
|
443
|
-
} catch (err) {
|
|
444
|
-
throw testGateError(err);
|
|
445
|
-
}
|
|
446
|
-
await assertTypechecks(cwd, { skip: opts.skipTypecheck });
|
|
447
|
-
const bundle = await buildAgentBundle(cwd, { minify: true });
|
|
448
|
-
const agentDef = await evalWorkerBundle(bundle.worker);
|
|
449
|
-
for (const warning of agentConfigWarnings(agentDef)) notify("warn", warning);
|
|
450
|
-
for (const warning of determinismWarnings(await scanWorkflowDeterminism(cwd))) notify("warn", warning);
|
|
451
|
-
const worker = path.join(cwd, WORKER_ARTIFACT_REL);
|
|
452
|
-
await fs.mkdir(path.dirname(worker), { recursive: true });
|
|
453
|
-
await fs.writeFile(worker, bundle.worker, "utf-8");
|
|
454
|
-
await emitTargetFiles(cwd, target);
|
|
455
|
-
const systemPrompt = await systemPromptSource(cwd, agentDef.systemPrompt);
|
|
456
|
-
log.info(`System prompt: ${systemPrompt}`);
|
|
457
|
-
log.success("Build complete");
|
|
458
|
-
return ok({
|
|
459
|
-
name: agentDef.name,
|
|
460
|
-
workerBytes: bundle.worker.length,
|
|
461
|
-
worker,
|
|
462
|
-
systemPrompt,
|
|
463
|
-
target
|
|
464
|
-
});
|
|
465
|
-
}
|
|
466
|
-
/**
|
|
467
|
-
* Write what a target needs, if it needs anything.
|
|
468
|
-
*
|
|
469
|
-
* `node` writes nothing: a long-lived process runs `aai start`, which needs no
|
|
470
|
-
* generated file. `vercel` writes a complete prebuilt deployment under
|
|
471
|
-
* `.vercel/output/` — see `_vercel-output.ts`, and `VERCEL_OUTPUT_DIR` in
|
|
472
|
-
* `_build-target.ts` for why that directory and not an `api/` entry beside a
|
|
473
|
-
* generated `vercel.json`.
|
|
474
|
-
*/
|
|
475
|
-
async function emitTargetFiles(cwd, target) {
|
|
476
|
-
if (target === "node") return;
|
|
477
|
-
await emitVercelOutput(cwd);
|
|
478
|
-
log.info(`Target ${target}: wrote ${VERCEL_OUTPUT_DIR}`);
|
|
479
|
-
}
|
|
480
|
-
//#endregion
|
|
481
|
-
export { executeBuild };
|