@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.
Files changed (363) hide show
  1. package/README.md +8 -5
  2. package/bin.mjs +12 -3
  3. package/dist/_build-target-55dJisQ-.mjs +649 -0
  4. package/dist/_build-target.d.ts +105 -108
  5. package/dist/_deno-output.d.ts +23 -0
  6. package/dist/_deno-target.d.ts +73 -0
  7. package/dist/{_init-Bsi3DZNJ.mjs → _init-BzQbV8Zh.mjs} +3 -1
  8. package/dist/_modal-app.d.ts +77 -0
  9. package/dist/_modal-output.d.ts +31 -0
  10. package/dist/_modal-target.d.ts +64 -0
  11. package/dist/_target-bundle.d.ts +27 -0
  12. package/dist/_target-drain.d.ts +44 -0
  13. package/dist/_target-output.d.ts +63 -0
  14. package/dist/{_templates-CIlJ3Vay.mjs → _templates-CuP74F8D.mjs} +94 -4
  15. package/dist/_templates.d.ts +14 -1
  16. package/dist/_vercel-output.d.ts +4 -19
  17. package/dist/_vercel-target.d.ts +169 -0
  18. package/dist/{test-D032V2cA.mjs → _vitest-runner-AVR9VtXh.mjs} +28 -68
  19. package/dist/_vitest-runner.d.ts +154 -0
  20. package/dist/build-ButI2IKc.mjs +689 -0
  21. package/dist/build.d.ts +11 -0
  22. package/dist/cli.mjs +14 -20
  23. package/dist/{dev-Bx9gYBHM.mjs → dev-kodAY23K.mjs} +7 -1
  24. package/dist/{eval-B3I7FqN9.mjs → eval-DvoSz7SZ.mjs} +1 -1
  25. package/dist/{init-CFyusRbq.mjs → init-D363Ls5u.mjs} +13 -39
  26. package/dist/init.d.ts +5 -10
  27. package/dist/scaffold/CLAUDE.md +185 -35
  28. package/dist/scaffold/package.json +4 -4
  29. package/dist/start.mjs +3 -1
  30. package/dist/{studio-C_zuRC_z.mjs → studio-CtRBVVFR.mjs} +1 -1
  31. package/dist/templates/briefing-desk/agent.eval.test.ts +34 -6
  32. package/dist/templates/briefing-desk/agent.test.ts +347 -55
  33. package/dist/templates/briefing-desk/agent.ts +12 -0
  34. package/dist/templates/briefing-desk/shared.ts +220 -31
  35. package/dist/templates/briefing-desk/slack.ts +108 -0
  36. package/dist/templates/briefing-desk/system-prompt.md +12 -2
  37. package/dist/templates/briefing-desk/tools/briefing_so_far.ts +15 -7
  38. package/dist/templates/briefing-desk/tools/research_topic.ts +20 -28
  39. package/dist/templates/briefing-desk/tools/send_briefing.ts +77 -0
  40. package/dist/templates/briefing-desk/tools/verify_claim.ts +60 -14
  41. package/dist/templates/call-audit/agent.eval.test.ts +5 -0
  42. package/dist/templates/call-audit/agent.test.ts +6 -1
  43. package/dist/templates/call-audit/agent.ts +10 -23
  44. package/dist/templates/call-audit/client.tsx +30 -55
  45. package/dist/templates/call-audit/guards.test.ts +233 -0
  46. package/dist/templates/call-audit/workflows/audit.ts +95 -16
  47. package/dist/templates/call-audit/workflows/ingest.ts +107 -88
  48. package/dist/templates/call-audit/workflows/media.ts +98 -7
  49. package/dist/templates/call-audit/workflows/summarize.ts +35 -31
  50. package/dist/templates/call-audit/workflows/sync-api.ts +15 -6
  51. package/dist/templates/code-interpreter/agent.eval.test.ts +104 -56
  52. package/dist/templates/code-interpreter/agent.test.ts +44 -56
  53. package/dist/templates/code-interpreter/system-prompt.md +1 -1
  54. package/dist/templates/dispatch-center/agent.eval.test.ts +61 -24
  55. package/dist/templates/dispatch-center/agent.test.ts +253 -48
  56. package/dist/templates/dispatch-center/agent.ts +28 -1
  57. package/dist/templates/dispatch-center/client.tsx +126 -201
  58. package/dist/templates/dispatch-center/events.ts +48 -0
  59. package/dist/templates/dispatch-center/shared.ts +42 -1
  60. package/dist/templates/dispatch-center/tools/incident_create.ts +3 -2
  61. package/dist/templates/dispatch-center/tools/incident_escalate.ts +2 -1
  62. package/dist/templates/dispatch-center/tools/ops_dashboard.ts +35 -15
  63. package/dist/templates/dispatch-center/tools/ops_run_scenario.ts +3 -1
  64. package/dist/templates/dispatch-center/tools/resources_dispatch.ts +2 -2
  65. package/dist/templates/executive-assistant/agent.eval.test.ts +233 -0
  66. package/dist/templates/executive-assistant/agent.test.ts +672 -0
  67. package/dist/templates/executive-assistant/agent.ts +50 -0
  68. package/dist/templates/executive-assistant/calendar.test.ts +198 -0
  69. package/dist/templates/executive-assistant/client.tsx +195 -0
  70. package/dist/templates/executive-assistant/inbox.ts +233 -0
  71. package/dist/templates/executive-assistant/meeting.ts +138 -0
  72. package/dist/templates/executive-assistant/nodes.ts +152 -0
  73. package/dist/templates/executive-assistant/prompts.ts +331 -0
  74. package/dist/templates/executive-assistant/review.ts +425 -0
  75. package/dist/templates/executive-assistant/shared.ts +490 -0
  76. package/dist/templates/executive-assistant/system-prompt.md +15 -0
  77. package/dist/templates/executive-assistant/tools/accept.ts +10 -0
  78. package/dist/templates/executive-assistant/tools/ask_question.ts +30 -0
  79. package/dist/templates/executive-assistant/tools/draft_reply.ts +67 -0
  80. package/dist/templates/executive-assistant/tools/edit.ts +10 -0
  81. package/dist/templates/executive-assistant/tools/ignore.ts +10 -0
  82. package/dist/templates/executive-assistant/tools/inbox_status.ts +27 -0
  83. package/dist/templates/executive-assistant/tools/meeting_assistant.ts +52 -0
  84. package/dist/templates/executive-assistant/tools/new_email.ts +50 -0
  85. package/dist/templates/executive-assistant/tools/open_email.ts +165 -0
  86. package/dist/templates/executive-assistant/tools/respond.ts +10 -0
  87. package/dist/templates/executive-assistant/tools/review_memory.ts +22 -0
  88. package/dist/templates/executive-assistant/tools/send_calendar_invite.ts +68 -0
  89. package/dist/templates/executive-assistant/tools/triage_inbox.ts +75 -0
  90. package/dist/templates/health-assistant/agent.test.ts +134 -15
  91. package/dist/templates/health-assistant/agent.ts +8 -1
  92. package/dist/templates/health-assistant/fda.test.ts +130 -0
  93. package/dist/templates/health-assistant/fda.ts +75 -16
  94. package/dist/templates/health-assistant/system-prompt.md +9 -0
  95. package/dist/templates/health-assistant/tools/check_drug_interaction.ts +5 -2
  96. package/dist/templates/health-assistant/tools/medication_lookup.ts +16 -11
  97. package/dist/templates/hiring-desk/agent.eval.test.ts +242 -0
  98. package/dist/templates/hiring-desk/agent.test.ts +1021 -0
  99. package/dist/templates/hiring-desk/agent.ts +38 -0
  100. package/dist/templates/hiring-desk/client.tsx +154 -0
  101. package/dist/templates/hiring-desk/crews.ts +432 -0
  102. package/dist/templates/hiring-desk/leads.json +86 -0
  103. package/dist/templates/hiring-desk/screening-lock.test.ts +77 -0
  104. package/dist/templates/hiring-desk/screening-lock.ts +51 -0
  105. package/dist/templates/hiring-desk/shared.ts +480 -0
  106. package/dist/templates/hiring-desk/system-prompt.md +21 -0
  107. package/dist/templates/hiring-desk/tools/candidate_details.ts +49 -0
  108. package/dist/templates/hiring-desk/tools/proceed_to_emails.ts +127 -0
  109. package/dist/templates/hiring-desk/tools/read_email.ts +50 -0
  110. package/dist/templates/hiring-desk/tools/rescore_with_feedback.ts +140 -0
  111. package/dist/templates/hiring-desk/tools/screen_candidates.ts +128 -0
  112. package/dist/templates/hiring-desk/tools/screening_status.ts +51 -0
  113. package/dist/templates/hotel-desk/agent.eval.test.ts +177 -0
  114. package/dist/templates/hotel-desk/agent.test.ts +1128 -0
  115. package/dist/templates/hotel-desk/agent.ts +63 -0
  116. package/dist/templates/hotel-desk/booking.ts +159 -0
  117. package/dist/templates/hotel-desk/card.ts +92 -0
  118. package/dist/templates/hotel-desk/catalogs.ts +219 -0
  119. package/dist/templates/hotel-desk/client.tsx +137 -0
  120. package/dist/templates/hotel-desk/concierge.ts +99 -0
  121. package/dist/templates/hotel-desk/desk-seams.test.ts +334 -0
  122. package/dist/templates/hotel-desk/desk.ts +224 -0
  123. package/dist/templates/hotel-desk/disputes.ts +216 -0
  124. package/dist/templates/hotel-desk/events.ts +79 -0
  125. package/dist/templates/hotel-desk/hotel.ts +412 -0
  126. package/dist/templates/hotel-desk/policies.ts +209 -0
  127. package/dist/templates/hotel-desk/records.ts +384 -0
  128. package/dist/templates/hotel-desk/restaurant.ts +147 -0
  129. package/dist/templates/hotel-desk/seed.ts +955 -0
  130. package/dist/templates/hotel-desk/shared.ts +354 -0
  131. package/dist/templates/hotel-desk/system-prompt.md +76 -0
  132. package/dist/templates/hotel-desk/tools/abandon_booking.ts +30 -0
  133. package/dist/templates/hotel-desk/tools/add_to_waitlist.ts +41 -0
  134. package/dist/templates/hotel-desk/tools/book_airport_car.ts +57 -0
  135. package/dist/templates/hotel-desk/tools/book_business_center.ts +44 -0
  136. package/dist/templates/hotel-desk/tools/book_spa_appointment.ts +39 -0
  137. package/dist/templates/hotel-desk/tools/book_tour.ts +35 -0
  138. package/dist/templates/hotel-desk/tools/cancel_restaurant_reservation.ts +25 -0
  139. package/dist/templates/hotel-desk/tools/cancel_room_booking.ts +63 -0
  140. package/dist/templates/hotel-desk/tools/check_restaurant_availability.ts +24 -0
  141. package/dist/templates/hotel-desk/tools/check_room_availability.ts +40 -0
  142. package/dist/templates/hotel-desk/tools/choose_room.ts +93 -0
  143. package/dist/templates/hotel-desk/tools/confirm_booking.ts +153 -0
  144. package/dist/templates/hotel-desk/tools/dispatch_emergency.ts +61 -0
  145. package/dist/templates/hotel-desk/tools/dispute_charge.ts +90 -0
  146. package/dist/templates/hotel-desk/tools/flag_late_arrival.ts +26 -0
  147. package/dist/templates/hotel-desk/tools/lookup_booking.ts +48 -0
  148. package/dist/templates/hotel-desk/tools/lookup_guest_history.ts +28 -0
  149. package/dist/templates/hotel-desk/tools/lookup_invoice.ts +26 -0
  150. package/dist/templates/hotel-desk/tools/lookup_policy.ts +20 -0
  151. package/dist/templates/hotel-desk/tools/lookup_restaurant_reservation.ts +27 -0
  152. package/dist/templates/hotel-desk/tools/modify_restaurant_reservation.ts +75 -0
  153. package/dist/templates/hotel-desk/tools/order_flowers.ts +40 -0
  154. package/dist/templates/hotel-desk/tools/record_card.ts +46 -0
  155. package/dist/templates/hotel-desk/tools/record_followup.ts +50 -0
  156. package/dist/templates/hotel-desk/tools/record_group_inquiry.ts +44 -0
  157. package/dist/templates/hotel-desk/tools/record_guest_details.ts +71 -0
  158. package/dist/templates/hotel-desk/tools/reinstate_booking.ts +65 -0
  159. package/dist/templates/hotel-desk/tools/request_flight_reconfirmation.ts +54 -0
  160. package/dist/templates/hotel-desk/tools/resend_confirmation.ts +39 -0
  161. package/dist/templates/hotel-desk/tools/reserve_table.ts +87 -0
  162. package/dist/templates/hotel-desk/tools/resolve_room_conflict.ts +48 -0
  163. package/dist/templates/hotel-desk/tools/schedule_wakeup_call.ts +48 -0
  164. package/dist/templates/hotel-desk/tools/set_do_not_disturb.ts +28 -0
  165. package/dist/templates/hotel-desk/tools/set_extras.ts +51 -0
  166. package/dist/templates/hotel-desk/tools/set_stay.ts +97 -0
  167. package/dist/templates/hotel-desk/tools/start_booking_modification.ts +57 -0
  168. package/dist/templates/hotel-desk/tools/start_room_booking.ts +49 -0
  169. package/dist/templates/hotel-desk/tools/take_guest_message.ts +71 -0
  170. package/dist/templates/hotel-desk/tools/transfer_call.ts +47 -0
  171. package/dist/templates/hotel-desk/tools/update_card.ts +45 -0
  172. package/dist/templates/hotel-desk/tools/verify_booking.ts +95 -0
  173. package/dist/templates/infocom-adventure/agent.eval.test.ts +33 -1
  174. package/dist/templates/infocom-adventure/agent.test.ts +207 -52
  175. package/dist/templates/infocom-adventure/agent.ts +14 -3
  176. package/dist/templates/infocom-adventure/client.tsx +138 -176
  177. package/dist/templates/infocom-adventure/shared.ts +126 -6
  178. package/dist/templates/infocom-adventure/system-prompt.md +4 -4
  179. package/dist/templates/infocom-adventure/tools/game_state_drop.ts +20 -4
  180. package/dist/templates/infocom-adventure/tools/game_state_get.ts +6 -5
  181. package/dist/templates/infocom-adventure/tools/game_state_score.ts +9 -3
  182. package/dist/templates/link-digest/agent.eval.test.ts +8 -0
  183. package/dist/templates/link-digest/agent.test.ts +285 -29
  184. package/dist/templates/link-digest/agent.ts +9 -0
  185. package/dist/templates/link-digest/api-client.ts +144 -0
  186. package/dist/templates/link-digest/client.tsx +11 -30
  187. package/dist/templates/link-digest/workflows/digest.ts +72 -24
  188. package/dist/templates/night-owl/agent.eval.test.ts +55 -40
  189. package/dist/templates/night-owl/agent.test.ts +146 -12
  190. package/dist/templates/night-owl/client.tsx +50 -17
  191. package/dist/templates/night-owl/shared.ts +33 -2
  192. package/dist/templates/night-owl/system-prompt.md +3 -0
  193. package/dist/templates/night-owl/tools/recommend.ts +4 -1
  194. package/dist/templates/night-owl/tools/revisit.ts +49 -0
  195. package/dist/templates/pipeline-simple/agent.eval.test.ts +7 -6
  196. package/dist/templates/pipeline-simple/agent.test.ts +48 -91
  197. package/dist/templates/pipeline-simple/modes.test.ts +151 -0
  198. package/dist/templates/pipeline-simple/stages.test.ts +332 -0
  199. package/dist/templates/pizza-ordering/agent.test.ts +94 -38
  200. package/dist/templates/pizza-ordering/client.tsx +10 -5
  201. package/dist/templates/pizza-ordering/shared.ts +65 -6
  202. package/dist/templates/pizza-ordering/tools/add_pizza.ts +2 -7
  203. package/dist/templates/pizza-ordering/tools/place_order.ts +9 -6
  204. package/dist/templates/pizza-ordering/tools/remove_pizza.ts +6 -11
  205. package/dist/templates/pizza-ordering/tools/update_pizza.ts +8 -9
  206. package/dist/templates/pizza-ordering/tools/view_order.ts +2 -3
  207. package/dist/templates/plan-and-execute/agent.eval.test.ts +14 -6
  208. package/dist/templates/plan-and-execute/agent.test.ts +300 -113
  209. package/dist/templates/plan-and-execute/client.tsx +18 -7
  210. package/dist/templates/plan-and-execute/procedure.ts +162 -64
  211. package/dist/templates/plan-and-execute/prompts.ts +51 -15
  212. package/dist/templates/plan-and-execute/shared.ts +151 -45
  213. package/dist/templates/plan-and-execute/tools/plan_status.ts +15 -6
  214. package/dist/templates/plan-and-execute/tools/revise_plan.ts +2 -2
  215. package/dist/templates/plan-and-execute/tools/start_plan.ts +2 -2
  216. package/dist/templates/plan-and-execute/tools/work_next_step.ts +15 -13
  217. package/dist/templates/podcast-digest/agent.eval.test.ts +12 -7
  218. package/dist/templates/podcast-digest/agent.test.ts +126 -51
  219. package/dist/templates/podcast-digest/client.tsx +104 -68
  220. package/dist/templates/podcast-digest/workflows/digest.ts +71 -48
  221. package/dist/templates/podcast-digest/workflows/feeds.ts +5 -7
  222. package/dist/templates/podcast-digest/workflows/slack.ts +82 -17
  223. package/dist/templates/recap-workflow/agent.eval.test.ts +193 -209
  224. package/dist/templates/recap-workflow/agent.test.ts +207 -26
  225. package/dist/templates/recap-workflow/tools/recap_status.ts +2 -2
  226. package/dist/templates/recap-workflow/workflows/recap.ts +39 -28
  227. package/dist/templates/redline/agent.eval.test.ts +40 -3
  228. package/dist/templates/redline/agent.test.ts +216 -6
  229. package/dist/templates/redline/agent.ts +54 -34
  230. package/dist/templates/redline/client.tsx +82 -126
  231. package/dist/templates/redline/form.ts +74 -0
  232. package/dist/templates/redline/workflows/prompts.ts +3 -3
  233. package/dist/templates/redline/workflows/redline.ts +73 -4
  234. package/dist/templates/research-workflow/agent.eval.test.ts +152 -150
  235. package/dist/templates/research-workflow/agent.test.ts +436 -126
  236. package/dist/templates/research-workflow/agent.ts +20 -5
  237. package/dist/templates/research-workflow/tools/file_it_now.ts +11 -1
  238. package/dist/templates/research-workflow/tools/research_status.ts +39 -4
  239. package/dist/templates/research-workflow/workflows/filing.ts +164 -0
  240. package/dist/templates/research-workflow/workflows/notes.ts +69 -0
  241. package/dist/templates/research-workflow/workflows/prompts.ts +45 -31
  242. package/dist/templates/research-workflow/workflows/research.ts +227 -280
  243. package/dist/templates/research-workflow/workflows/review.ts +43 -0
  244. package/dist/templates/retail/address.ts +29 -35
  245. package/dist/templates/retail/agent.eval.test.ts +36 -16
  246. package/dist/templates/retail/agent.test.ts +104 -26
  247. package/dist/templates/retail/agent.ts +12 -0
  248. package/dist/templates/retail/cancel.ts +39 -42
  249. package/dist/templates/retail/client.tsx +111 -176
  250. package/dist/templates/retail/payment.ts +38 -43
  251. package/dist/templates/retail/pending.test.ts +16 -8
  252. package/dist/templates/retail/registry.test.ts +108 -49
  253. package/dist/templates/retail/resolve.test.ts +2 -63
  254. package/dist/templates/retail/resolve.ts +16 -56
  255. package/dist/templates/retail/returns.ts +53 -54
  256. package/dist/templates/retail/seed.test.ts +2 -1
  257. package/dist/templates/retail/shared.ts +58 -14
  258. package/dist/templates/retail/store.test.ts +40 -29
  259. package/dist/templates/retail/store.ts +60 -23
  260. package/dist/templates/retail/swap.ts +78 -81
  261. package/dist/templates/retail/tools/find_user_id_by_name_zip.ts +2 -1
  262. package/dist/templates/roadside-assist/agent.eval.test.ts +164 -0
  263. package/dist/templates/roadside-assist/agent.test.ts +617 -0
  264. package/dist/templates/roadside-assist/agent.ts +85 -0
  265. package/dist/templates/roadside-assist/call.ts +237 -0
  266. package/dist/templates/roadside-assist/events.ts +92 -0
  267. package/dist/templates/roadside-assist/shared.ts +334 -0
  268. package/dist/templates/roadside-assist/system-prompt.md +37 -0
  269. package/dist/templates/roadside-assist/tools/acknowledge_disclosure.ts +47 -0
  270. package/dist/templates/roadside-assist/tools/dispatch_truck.ts +148 -0
  271. package/dist/templates/roadside-assist/tools/job_status.ts +38 -0
  272. package/dist/templates/roadside-assist/tools/lookup_coverage.ts +72 -0
  273. package/dist/templates/roadside-assist/tools/report_location.ts +79 -0
  274. package/dist/templates/roadside-assist/tools/service_disclosure.ts +45 -0
  275. package/dist/templates/roadside-assist/yard.test.ts +158 -0
  276. package/dist/templates/roadside-assist/yard.ts +183 -0
  277. package/dist/templates/simple/agent.eval.test.ts +4 -1
  278. package/dist/templates/simple/agent.test.ts +54 -31
  279. package/dist/templates/solo-rpg/agent.eval.test.ts +19 -11
  280. package/dist/templates/solo-rpg/agent.test.ts +402 -175
  281. package/dist/templates/solo-rpg/agent.ts +14 -3
  282. package/dist/templates/solo-rpg/client.tsx +10 -10
  283. package/dist/templates/solo-rpg/shared.ts +198 -79
  284. package/dist/templates/solo-rpg/tools/action_roll.ts +7 -3
  285. package/dist/templates/solo-rpg/tools/burn_momentum.ts +16 -8
  286. package/dist/templates/solo-rpg/tools/oracle.ts +7 -7
  287. package/dist/templates/solo-rpg/tools/setup_character.ts +5 -5
  288. package/dist/templates/solo-rpg/tools/update_state.ts +29 -18
  289. package/dist/templates/spoken-summary/agent.test.ts +70 -15
  290. package/dist/templates/spoken-summary/agent.ts +25 -21
  291. package/dist/templates/spoken-summary/client.tsx +68 -88
  292. package/dist/templates/spoken-summary/workflows/summarize.ts +26 -8
  293. package/dist/templates/support-line/agent.test.ts +167 -36
  294. package/dist/templates/support-line/client.tsx +21 -9
  295. package/dist/templates/support-line/nodes.ts +74 -32
  296. package/dist/templates/support-line/procedure.ts +66 -21
  297. package/dist/templates/support-line/prompts.ts +9 -0
  298. package/dist/templates/support-line/shared.ts +55 -17
  299. package/dist/templates/support-line/tools/answer_question.ts +14 -14
  300. package/dist/templates/transcription-workflow/agent.test.ts +135 -13
  301. package/dist/templates/transcription-workflow/client.tsx +30 -23
  302. package/dist/templates/transcription-workflow/recover.test.ts +93 -12
  303. package/dist/templates/transcription-workflow/recover.ts +29 -5
  304. package/dist/templates/transcription-workflow/run-panel.tsx +40 -51
  305. package/dist/templates/transcription-workflow/workflows/normalize.ts +125 -24
  306. package/dist/templates/transcription-workflow/workflows/stream.ts +4 -1
  307. package/dist/templates/transcription-workflow/workflows/transcribe.ts +7 -5
  308. package/dist/templates/transcription-workflow/workflows/wav.ts +42 -117
  309. package/dist/templates/travel-concierge/agent.eval.test.ts +6 -4
  310. package/dist/templates/travel-concierge/agent.test.ts +209 -40
  311. package/dist/templates/travel-concierge/agent.ts +24 -4
  312. package/dist/templates/travel-concierge/call-events.ts +80 -0
  313. package/dist/templates/travel-concierge/client.tsx +3 -2
  314. package/dist/templates/travel-concierge/routing.ts +5 -7
  315. package/dist/templates/travel-concierge/shared.ts +202 -41
  316. package/dist/templates/travel-concierge/tools/book_car_rental.ts +2 -4
  317. package/dist/templates/travel-concierge/tools/book_excursion.ts +2 -4
  318. package/dist/templates/travel-concierge/tools/book_hotel.ts +2 -4
  319. package/dist/templates/travel-concierge/tools/cancel_ticket.ts +6 -4
  320. package/dist/templates/travel-concierge/tools/search_car_rentals.ts +3 -5
  321. package/dist/templates/travel-concierge/tools/search_excursions.ts +3 -5
  322. package/dist/templates/travel-concierge/tools/search_flights.ts +20 -9
  323. package/dist/templates/travel-concierge/tools/search_hotels.ts +3 -5
  324. package/dist/templates/travel-concierge/tools/update_ticket.ts +2 -4
  325. package/dist/templates/web-researcher/agent.eval.test.ts +3 -6
  326. package/dist/templates/web-researcher/agent.test.ts +102 -65
  327. package/dist/templates/web-researcher/agent.ts +93 -1
  328. package/dist/templates/web-researcher/system-prompt.md +7 -1
  329. package/dist/templates/word-wrangler/agent.eval.test.ts +157 -0
  330. package/dist/templates/word-wrangler/agent.test.ts +432 -0
  331. package/dist/templates/word-wrangler/agent.ts +35 -0
  332. package/dist/templates/word-wrangler/client.tsx +211 -0
  333. package/dist/templates/word-wrangler/game.ts +107 -0
  334. package/dist/templates/word-wrangler/guess.ts +63 -0
  335. package/dist/templates/word-wrangler/player.ts +68 -0
  336. package/dist/templates/word-wrangler/shared.ts +263 -0
  337. package/dist/templates/word-wrangler/system-prompt.md +15 -0
  338. package/dist/templates/word-wrangler/tools/final_score.ts +37 -0
  339. package/dist/templates/word-wrangler/tools/relay_description.ts +137 -0
  340. package/dist/templates/word-wrangler/tools/repeat_word.ts +19 -0
  341. package/dist/templates/word-wrangler/tools/skip_word.ts +31 -0
  342. package/dist/templates/word-wrangler/tools/start_game.ts +47 -0
  343. package/dist/templates/word-wrangler/words.ts +278 -0
  344. package/dist/test-Cllnx81G.mjs +83 -0
  345. package/dist/test.d.ts +9 -114
  346. package/package.json +5 -5
  347. package/dist/build-BhEaxBPu.mjs +0 -481
  348. package/dist/templates/embedded-assets/agent.eval.test.ts +0 -130
  349. package/dist/templates/embedded-assets/agent.test.ts +0 -79
  350. package/dist/templates/embedded-assets/agent.ts +0 -7
  351. package/dist/templates/embedded-assets/knowledge.json +0 -20
  352. package/dist/templates/embedded-assets/shared.ts +0 -17
  353. package/dist/templates/embedded-assets/system-prompt.md +0 -13
  354. package/dist/templates/embedded-assets/tools/list_topics.ts +0 -9
  355. package/dist/templates/embedded-assets/tools/search_knowledge.ts +0 -26
  356. package/dist/templates/math-buddy/agent.eval.test.ts +0 -128
  357. package/dist/templates/math-buddy/agent.test.ts +0 -126
  358. package/dist/templates/math-buddy/agent.ts +0 -15
  359. package/dist/templates/math-buddy/system-prompt.md +0 -12
  360. package/dist/templates/personal-finance/agent.eval.test.ts +0 -149
  361. package/dist/templates/personal-finance/agent.test.ts +0 -127
  362. package/dist/templates/personal-finance/agent.ts +0 -8
  363. package/dist/templates/personal-finance/system-prompt.md +0 -21
@@ -0,0 +1,649 @@
1
+ #!/usr/bin/env node
2
+ import path from "node:path";
3
+ //#region src/_target-drain.ts
4
+ /**
5
+ * The one entry-source fragment the LONG-LIVED targets share.
6
+ *
7
+ * A leaf beside `_target-output.ts` (the directory the same two targets share)
8
+ * and `_target-bundle.ts` (the bundle every target's entry goes through): each
9
+ * is a thing more than one host needs and no host owns.
10
+ */
11
+ /**
12
+ * The signal drain both LONG-LIVED entries carry, interpolated into each.
13
+ *
14
+ * ## Why every long-lived host needs one
15
+ *
16
+ * A host that runs a process stops that process — on a scale-in, on a redeploy,
17
+ * on an instance being moved — and for a voice agent that is a live call. Left
18
+ * to the default disposition the process dies with its sockets open: the caller
19
+ * hears nothing more, the STT and TTS connections are dropped rather than
20
+ * closed, and nothing downstream is told the session ended. `server.close()`
21
+ * shuts the runtime down with the process, so sessions END.
22
+ *
23
+ * The Deno entry did NOT have this and the Modal entry did, which was a gap
24
+ * rather than a decision: Deno Deploy stops a deployment on exactly the same
25
+ * events. Nitro has no such asymmetry — every one of its long-lived presets
26
+ * (`node-server`, `deno-server`, `bun`) serves through srvx, which closes on
27
+ * `SIGINT`/`SIGTERM`, and `setupCloseHooks` hangs the framework's own `close`
28
+ * hooks off that one path. This is the same property with our own two hosts
29
+ * spelled out, which is why it is ONE constant: the next long-lived target
30
+ * must not get to rediscover it.
31
+ *
32
+ * ## Two things in the body that are not incidental
33
+ *
34
+ * The listeners are SYNCHRONOUS for the reason `executeStart` documents: an
35
+ * `async` listener hands its promise to `process`, which discards it, so a
36
+ * failed shutdown would surface as an unhandled rejection rather than a
37
+ * non-zero exit.
38
+ *
39
+ * Registration is GUARDED, because signal support is a property of the host
40
+ * rather than of the runtime. Deno delivers `process.on("SIGTERM")` through
41
+ * `Deno.addSignalListener`, which THROWS where the platform has no signal to
42
+ * deliver — an isolate-based Deploy, or a Windows `SIGTERM` — and a throw at
43
+ * the top level of the entry is a deployment that does not boot at all. A host
44
+ * that cannot signal us is a host we have nothing to drain on, so failing to
45
+ * register is not a failure.
46
+ */
47
+ const TARGET_DRAIN_SOURCE = `// The host stops this process on every scale-in and every redeploy; closing the
48
+ // server ends live sessions instead of dropping their sockets.
49
+ for (const name of ["SIGINT", "SIGTERM"]) {
50
+ try {
51
+ process.once(name, () => {
52
+ server.close().then(
53
+ () => process.exit(0),
54
+ () => process.exit(1),
55
+ );
56
+ });
57
+ } catch {
58
+ // No signal support on this host — nothing will ever arrive to drain on.
59
+ }
60
+ }
61
+ `;
62
+ //#endregion
63
+ //#region src/_deno-target.ts
64
+ /**
65
+ * The **Deno Deploy** target — a self-contained directory under `.aai/deno/`.
66
+ *
67
+ * One module per host, for the reason `_vercel-target.ts` opens with. What
68
+ * assembles the directory is `_deno-output.ts`; what this file holds is where
69
+ * it goes and what goes in it.
70
+ *
71
+ * Deno and Modal are the two LONG-LIVED targets: each entry binds a port and
72
+ * each drains on a signal ({@link TARGET_DRAIN_SOURCE}), which is what makes
73
+ * them the pair that also shares `_target-output.ts`.
74
+ */
75
+ /**
76
+ * Where a self-contained Deno deployment is emitted, relative to the project.
77
+ *
78
+ * A DIRECTORY to deploy rather than files scattered through the project, and
79
+ * `deno deploy` from inside it uploads exactly this and nothing else. That
80
+ * matters more here than it does on Vercel: Deploy uploads the working
81
+ * directory, so an emit into the project root would ship `node_modules`, the
82
+ * source, and the developer's `.env` alongside the thing meant to run.
83
+ */
84
+ const DENO_OUTPUT_DIR = path.join(".aai", "deno");
85
+ /** The bundled entry inside {@link DENO_OUTPUT_DIR}, and Deploy's entrypoint. */
86
+ const DENO_ENTRY_FILE = "server.mjs";
87
+ /** Deno's own project file inside {@link DENO_OUTPUT_DIR}. */
88
+ const DENO_CONFIG_FILE = "deno.json";
89
+ /**
90
+ * The `deno.json` written beside the entry, so the output DESCRIBES how to run
91
+ * itself.
92
+ *
93
+ * Without it every command against this directory has to re-supply the
94
+ * entrypoint — `deno deploy --entrypoint server.mjs`, `deno run -A server.mjs`
95
+ * — which is a fact about the emit that the emit already knows and the user has
96
+ * to remember. Nitro's `deno-server` preset writes the same file for the same
97
+ * reason (its `compiled` hook, a `tasks.start`), and its own test suite then
98
+ * runs a bare `deno task start`.
99
+ *
100
+ * `-A` rather than a narrowed permission set, and that is deliberate: the
101
+ * server binds a port, reads the client directory and the worker off disk, and
102
+ * reads the environment, so an enumerated list here would be a second
103
+ * declaration of the runtime's needs that drifts the first time one changes.
104
+ * Deno Deploy grants its own permissions regardless; this file is what makes
105
+ * the directory runnable BY HAND, which is how a failed deployment gets
106
+ * diagnosed.
107
+ */
108
+ const DENO_CONFIG_SOURCE = `${JSON.stringify({ tasks: { start: `deno run -A ./${DENO_ENTRY_FILE}` } }, null, 2)}\n`;
109
+ /**
110
+ * The Deno entry, bundled into {@link DENO_ENTRY_FILE}.
111
+ *
112
+ * ## Why this BINDS, where the Vercel entry does not
113
+ *
114
+ * Deno Deploy runs a long-lived process and expects it to listen, which is the
115
+ * ordinary `aai start` shape rather than the serverless one — so this is the
116
+ * only target whose entry calls `listen()`. There is no `(req, res)` adapter
117
+ * and no upgrade translation: `node:http` and the `ws` server path both work
118
+ * on Deno, so the session reaches the same `AgentServer` that `aai dev` and
119
+ * `aai start` run. Verified against a live deployment with real speech: 74
120
+ * audio frames back, transcript and reply intact.
121
+ *
122
+ * `0.0.0.0`, not the loopback default: the platform reaches this from outside
123
+ * the process, so binding loopback answers nothing.
124
+ *
125
+ * `import.meta.dirname` rather than `process.cwd()` — the artifacts are copied
126
+ * in BESIDE this file, and the working directory belongs to the platform.
127
+ *
128
+ * `globalThis.Deno?.env` rather than `Deno.env`: this file is bundled by a
129
+ * Node-side build and is read by Node tooling (its own spec included), where a
130
+ * bare `Deno` is a `ReferenceError` at parse-adjacent evaluation time.
131
+ *
132
+ * `process` needs no such guard and deliberately gets none: it is a global in
133
+ * Deno as well as in Node, so {@link TARGET_DRAIN_SOURCE} is the identical text
134
+ * in both long-lived entries rather than a template with a hole in it.
135
+ */
136
+ const DENO_ENTRY_SOURCE = `// Generated by \`aai build --target deno\` — do not edit, and do not commit.
137
+ // Deno Deploy runs this as a long-lived process and expects it to listen.
138
+ // See @alexkroman1/aai-cli/start.
139
+ import { createProjectServer } from "@alexkroman1/aai-cli/start";
140
+
141
+ const server = await createProjectServer({ cwd: import.meta.dirname });
142
+
143
+ await server.listen(Number(globalThis.Deno?.env.get("PORT") ?? 8000), "0.0.0.0");
144
+
145
+ ${TARGET_DRAIN_SOURCE}`;
146
+ //#endregion
147
+ //#region src/_modal-target.ts
148
+ /**
149
+ * The **Modal** target — a self-contained directory under `.aai/modal/`, plus
150
+ * the `app.py` that deploys it.
151
+ *
152
+ * One module per host, for the reason `_vercel-target.ts` opens with. This file
153
+ * holds where the directory goes and the node entry inside it; `_modal-app.ts`
154
+ * generates the Python module beside it, and `_modal-output.ts` assembles both.
155
+ *
156
+ * The long-lived half of the pair described in `_deno-target.ts`.
157
+ */
158
+ /**
159
+ * Where a self-contained Modal deployment is emitted, relative to the project.
160
+ *
161
+ * A directory, for the reason `_deno-target.ts`'s `DENO_OUTPUT_DIR` is one and
162
+ * then some: the
163
+ * emitted `app.py` hands this path to Modal's `add_local_dir`, which uploads
164
+ * the tree wholesale into the image. Pointed at the project root that would
165
+ * bake `node_modules`, the source and the developer's `.env` into a container
166
+ * image — and an image layer is not something you can un-push.
167
+ */
168
+ const MODAL_OUTPUT_DIR = path.join(".aai", "modal");
169
+ /** The bundled server inside {@link MODAL_OUTPUT_DIR}, spawned by `app.py`. */
170
+ const MODAL_ENTRY_FILE = "server.mjs";
171
+ /** The Modal app definition inside {@link MODAL_OUTPUT_DIR} — what `modal deploy` reads. */
172
+ const MODAL_APP_FILE = "app.py";
173
+ /**
174
+ * The port the node process binds and Modal proxies to.
175
+ *
176
+ * ONE constant, interpolated into both files the emit writes, because the two
177
+ * halves cannot be allowed to disagree: `@modal.web_server(port=…)` is how the
178
+ * platform learns where to route, and a node process reading a different number
179
+ * from its environment listens where nothing is routed. The symptom is a
180
+ * deployment that builds, starts, reports healthy, and answers no request —
181
+ * Modal's proxy simply never connects.
182
+ */
183
+ const MODAL_PORT = 8e3;
184
+ /**
185
+ * The Modal entry, bundled into {@link MODAL_ENTRY_FILE}.
186
+ *
187
+ * ## The same binding shape as Deno, for a different host
188
+ *
189
+ * `@modal.web_server` runs a container command and proxies HTTP *and*
190
+ * WebSocket traffic to a port that command opens, so this is the long-lived
191
+ * `aai start` shape rather than the serverless one — `listen()`, `0.0.0.0`
192
+ * (the proxy reaches this from outside the process), and artifacts resolved
193
+ * from {@link MODAL_ENTRY_FILE}'s own directory rather than from a working
194
+ * directory the platform owns. The entry is still NOT shared with
195
+ * {@link DENO_ENTRY_SOURCE} — the two read the port from different runtimes,
196
+ * and a shared entry would be a template with a hole where that goes — but the
197
+ * DRAIN below is, which is the part neither host's contract varies in.
198
+ *
199
+ * ## The drain is SHARED, and Modal supplies its other half
200
+ *
201
+ * The `SIGINT`/`SIGTERM` body is {@link TARGET_DRAIN_SOURCE}, the same text the
202
+ * Deno entry carries — it used to live here alone, on the reading that Modal
203
+ * stops containers and Deno Deploy does not, which is not true of either.
204
+ *
205
+ * What IS specific to Modal is that the signal has to REACH this process at
206
+ * all, and that half is in `app.py`: Modal signals its own Python runtime, and
207
+ * a child spawned with a bare `subprocess.Popen` receives nothing. The
208
+ * platform's own deploy learned that when orphaned guest sandboxes billed ~20
209
+ * minutes each on every release (see `run_node` in `scripts/modal_image.py`).
210
+ */
211
+ const MODAL_ENTRY_SOURCE = `// Generated by \`aai build --target modal\` — do not edit, and do not commit.
212
+ // Modal runs this as a long-lived process behind \`@modal.web_server\`, which
213
+ // proxies HTTP and WebSocket traffic to the port it binds.
214
+ // See @alexkroman1/aai-cli/start.
215
+ import { createProjectServer } from "@alexkroman1/aai-cli/start";
216
+
217
+ const server = await createProjectServer({ cwd: import.meta.dirname });
218
+
219
+ await server.listen(Number(process.env.PORT ?? ${MODAL_PORT}), "0.0.0.0");
220
+
221
+ // app.py forwards the container's stop signal here and waits for this process.
222
+ ${TARGET_DRAIN_SOURCE}`;
223
+ //#endregion
224
+ //#region src/_vercel-target.ts
225
+ /**
226
+ * The **Vercel** target — a PREBUILT deployment under `.vercel/output/`.
227
+ *
228
+ * Its own module for the reason Nitro keeps a directory per preset: a host's
229
+ * expected shape is one self-contained body of knowledge (a routing table, a
230
+ * function config, an entry in whatever shape its launcher invokes), and the
231
+ * only thing the others need from it is where its output lands. `TARGET_OUTPUTS`
232
+ * in `_build-target.ts` is that seam; `_vercel-output.ts` does the assembling.
233
+ *
234
+ * Vercel is also the one target here that is SERVERLESS. Everything in
235
+ * `_deno-target.ts` and `_modal-target.ts` is a long-lived process that binds a
236
+ * port and drains on a signal; nothing in this file binds anything, and the
237
+ * differences below all follow from that.
238
+ */
239
+ /**
240
+ * Where a PREBUILT Vercel deployment lives, relative to the project root.
241
+ *
242
+ * The Build Output API rather than an `api/` entry plus a `vercel.json`, and
243
+ * the reason is ORDERING. Vercel reads `vercel.json` and decides what to build
244
+ * BEFORE it runs the build command, so a `vercel.json` that the build WRITES
245
+ * configures the NEXT deployment and not this one — a clean clone deploys with
246
+ * no rewrite and no function at all. The `api/` shape only ever appeared to
247
+ * work because a previous local `aai build --target vercel` had left both
248
+ * files in the working tree, which is a property of one laptop rather than of
249
+ * the repository. `.vercel/output/` is read AFTER the build command; it is the
250
+ * only place a build can describe its own deployment.
251
+ *
252
+ * Two more things fall out of owning the directory, both of which the `api/`
253
+ * shape got wrong and could not fix. The function bundle is ASSEMBLED here
254
+ * rather than traced, so `.aai/worker.mjs` — loaded through a dynamic
255
+ * `import(pathToFileURL(...))` that no static tracer can follow — and
256
+ * `.env.example` — the file that DECLARES which variables become `ctx.env` —
257
+ * are present because they were copied in. And the built client is served by
258
+ * the CDN out of `static/` instead of through the function.
259
+ *
260
+ * Nitro's vercel preset is the worked precedent and lands in exactly here:
261
+ * `output.dir = {{rootDir}}/.vercel/output`, `serverDir` a `.func` under it.
262
+ *
263
+ * @see https://vercel.com/docs/build-output-api/v3
264
+ */
265
+ const VERCEL_OUTPUT_DIR = path.join(".vercel", "output");
266
+ /**
267
+ * The one function every request that is not a static file reaches.
268
+ *
269
+ * The Build Output API derives a function's ROUTE from its path, so the
270
+ * directory name IS a URL and must not collide with one the static output
271
+ * claims. **`index.func` collides**, which a deployment is the only way to
272
+ * find out: it is served at `/index`, and Vercel's directory index resolves
273
+ * `/` to the extensionless `/index` — so the function won `/`, every other
274
+ * asset came off the CDN correctly, and the home page 500'd on a deployment
275
+ * whose static output was perfect. Measured on a real preview:
276
+ * `/favicon.ico`, `/index.html` and both hashed `/assets/*` returned 200
277
+ * while `/` and `/index` did not.
278
+ *
279
+ * `__server` is Nitro's answer to the same problem (`__server.func`) and the
280
+ * reason is this one: a double-underscore prefix is not a path any bundler
281
+ * emits, so no static file can ever take the name.
282
+ */
283
+ const VERCEL_FUNCTION_DIR = path.join(VERCEL_OUTPUT_DIR, "functions", "__server.func");
284
+ /**
285
+ * The route {@link VERCEL_FUNCTION_DIR} is served at — its directory name
286
+ * without `.func`, which is how the Build Output API names a function.
287
+ */
288
+ const VERCEL_FUNCTION_ROUTE = "/__server";
289
+ /** Static assets the Vercel CDN serves directly, never reaching the function. */
290
+ const VERCEL_STATIC_DIR = path.join(VERCEL_OUTPUT_DIR, "static");
291
+ /**
292
+ * Node versions Vercel offers. A build on anything newer picks the newest of
293
+ * these rather than naming a runtime the platform will reject.
294
+ *
295
+ * @see https://vercel.com/docs/functions/runtimes/node-js/node-js-versions
296
+ */
297
+ const SUPPORTED_NODE_MAJORS = [
298
+ 20,
299
+ 22,
300
+ 24
301
+ ];
302
+ /**
303
+ * What an unparsable `process.versions.node` is treated as. A build that cannot
304
+ * say which Node it is still has to name SOME runtime, and the current LTS is
305
+ * the least surprising one to land on.
306
+ */
307
+ const UNKNOWN_NODE_MAJOR = 22;
308
+ /**
309
+ * `nodejs<major>.x` for the Node running this build, resolved to what Vercel
310
+ * offers — the SMALLEST offered major that is at least this one, and the
311
+ * newest offered when the build is newer than all of them.
312
+ *
313
+ * **Rounding UP is the load-bearing half**, and it used to round down. The
314
+ * bundle in the function was produced by, and resolved its dependencies for,
315
+ * the Node running the build; placing it on an OLDER major is how a
316
+ * `node:`-builtin API that shipped in 23 becomes a runtime `TypeError` in a
317
+ * deployed function that built clean. A build on Node 23 named `nodejs22.x`
318
+ * for exactly that reason. Rounding up cannot produce that failure — Node
319
+ * majors do not remove APIs on the schedule they add them — so the direction
320
+ * that can only be wrong cosmetically is the one to take. It is also what
321
+ * Nitro's `resolveVercelRuntime` does (`find(v => v >= systemNodeVersion)`)
322
+ * over this same list.
323
+ *
324
+ * Above the list there is nothing to round up TO, so a build on Node 26 is
325
+ * clamped to the newest Vercel offers rather than naming a runtime the
326
+ * deployment would be rejected for.
327
+ */
328
+ function vercelNodeRuntime(version = process.versions.node) {
329
+ const parsed = Number.parseInt(version.split(".")[0] ?? "", 10);
330
+ const major = Number.isNaN(parsed) ? UNKNOWN_NODE_MAJOR : parsed;
331
+ return `nodejs${SUPPORTED_NODE_MAJORS.find((v) => v >= major) ?? Math.max(...SUPPORTED_NODE_MAJORS)}.x`;
332
+ }
333
+ /**
334
+ * The Vercel function entry, emitted into {@link VERCEL_FUNCTION_DIR}.
335
+ *
336
+ * ## Why a `(req, res)` handler and not `export default server`
337
+ *
338
+ * `export default <http.Server>` is what Vercel's own `@vercel/node` BUILDER
339
+ * accepts, and it is the shape the previous `api/index.mjs` used. The Build
340
+ * Output API has no builder in the path: `launcherType: "Nodejs"` invokes the
341
+ * module's default export as a request handler, so the server never gets
342
+ * bound and there is nothing to raise an `upgrade` event on it.
343
+ *
344
+ * ## How a WebSocket survives that
345
+ *
346
+ * Vercel hands a Node function the raw upgrade through its PER-REQUEST
347
+ * context — `globalThis[Symbol.for("@vercel/request-context")].get()
348
+ * .upgradeWebSocket()` returns the `{ req, socket, head }` triple — rather
349
+ * than as an event. Nitro reaches it through `crossws/adapters/vercel`; here
350
+ * the adapter is three lines, because {@link AgentServer.node} is a real
351
+ * `http.Server` that already has both an `upgrade` and a `request` listener
352
+ * registered. Re-emitting onto it is the whole translation, and it means the
353
+ * deployed path through `server.ts` is the same one `aai dev` and `aai start`
354
+ * take — no second WebSocket entry point to keep in step.
355
+ *
356
+ * The `204` afterwards is what the launcher needs to consider the invocation
357
+ * finished; the socket the agent is now talking on is not this `res`.
358
+ *
359
+ * ## `import.meta.dirname`, not `process.cwd()`
360
+ *
361
+ * The function's working directory belongs to the platform, but `.aai/` and
362
+ * `.env.example` were copied in BESIDE this file. Resolving from the module
363
+ * keeps that a fact about the bundle rather than about how Vercel happens to
364
+ * invoke it.
365
+ */
366
+ const VERCEL_ENTRY_SOURCE = `// Generated by \`aai build --target vercel\` — do not edit, and do not commit.
367
+ // Vercel invokes this handler per request and delivers a WebSocket upgrade
368
+ // through its request context. See @alexkroman1/aai-cli/start.
369
+ import { createProjectServer } from "@alexkroman1/aai-cli/start";
370
+
371
+ const server = (await createProjectServer({ cwd: import.meta.dirname })).node;
372
+
373
+ const REQUEST_CONTEXT = Symbol.for("@vercel/request-context");
374
+
375
+ export default function handler(req, res) {
376
+ if (req.method === "GET" && req.headers.upgrade?.toLowerCase() === "websocket") {
377
+ const upgrade = globalThis[REQUEST_CONTEXT]?.get?.()?.upgradeWebSocket?.();
378
+ if (upgrade) {
379
+ server.emit("upgrade", upgrade.req, upgrade.socket, upgrade.head);
380
+ if (!res.headersSent && !res.writableEnded) {
381
+ res.statusCode = 204;
382
+ res.end();
383
+ }
384
+ return;
385
+ }
386
+ }
387
+ server.emit("request", req, res);
388
+ }
389
+ `;
390
+ /**
391
+ * `.vc-config.json` — how the platform runs {@link VERCEL_ENTRY_SOURCE}.
392
+ *
393
+ * `supportsResponseStreaming` is not optional here: an agent streams TTS audio
394
+ * and SSE workflow events, and without it the platform buffers a response to
395
+ * completion, which for a stream that ends when the call does means it never
396
+ * arrives. `shouldAddHelpers` stays off — the entry speaks `node:http`, and
397
+ * the helpers exist to bolt Express-shaped sugar onto a handler that does not.
398
+ */
399
+ function vercelFunctionConfigSource(runtime = vercelNodeRuntime()) {
400
+ return `${JSON.stringify({
401
+ runtime,
402
+ handler: "index.mjs",
403
+ launcherType: "Nodejs",
404
+ shouldAddHelpers: false,
405
+ supportsResponseStreaming: true
406
+ }, null, 2)}\n`;
407
+ }
408
+ /**
409
+ * The client's CONTENT-ADDRESSED directory — Vite's default `build.assetsDir`,
410
+ * which neither `client-bundler.ts` nor `aai-ui`'s own default-client build
411
+ * overrides. Everything under it carries a content hash in its filename.
412
+ *
413
+ * Named here because two routes below depend on that property and on nothing
414
+ * else: a file whose name changes with its bytes can be cached forever, and a
415
+ * MISS under such a name can never be answered by anything.
416
+ */
417
+ const CLIENT_ASSETS_DIR = "assets";
418
+ /**
419
+ * `config.json` — the routing table, and the reason static assets stop paying
420
+ * for a function invocation.
421
+ *
422
+ * `{ "handle": "filesystem" }` serves anything present in
423
+ * {@link VERCEL_STATIC_DIR} from the CDN and only then falls through, so the
424
+ * client bundle, its assets and the worklets are edge-served while
425
+ * `/client-config`, `/websocket`, `/workflows/*` and the webhook route reach
426
+ * the agent. The `api/` shape routed EVERY request through the function, which
427
+ * this file's earlier revision noted as deliberate and "not what makes a
428
+ * deployment work or not" — true of correctness, false of cost, and free here
429
+ * because the Build Output API already separates the two directories.
430
+ *
431
+ * ## The two rules AROUND `filesystem`, and why a filesystem hit is not enough
432
+ *
433
+ * Both come from Nitro's `getPublicAssetRoutes`, which brackets its own
434
+ * `handle: filesystem` the same way, and both are about
435
+ * {@link CLIENT_ASSETS_DIR} rather than about static files in general.
436
+ *
437
+ * **Before** it, a `cache-control` rule with `continue: true`. Serving a
438
+ * content-hashed bundle from the CDN with no explicit freshness leaves it on
439
+ * Vercel's default, so every client re-validates every asset on every load —
440
+ * a round trip per file for bytes that CANNOT change, since a change produces
441
+ * a different filename. `continue: true` is what keeps this a header rule and
442
+ * not a terminal one: the request goes on to `filesystem` and is served there.
443
+ *
444
+ * **After** it, a terminal `404` for the same prefix. A miss under a hashed
445
+ * name is a stale `index.html` asking for a bundle this deployment does not
446
+ * have, and there is no version of that request the agent can answer — so
447
+ * falling through to the function buys an invocation to produce the 404 the
448
+ * CDN could have. Nitro's reason is the sharper one and applies here too: the
449
+ * immutable header above is already attached, and letting a DYNAMIC response
450
+ * inherit it would cache a 404 for a year. `no-store` is what takes it back.
451
+ *
452
+ * Everything outside {@link CLIENT_ASSETS_DIR} still falls through, which is
453
+ * what keeps `/`, `/favicon.ico` and every agent route working.
454
+ */
455
+ const VERCEL_BUILD_CONFIG_SOURCE = `${JSON.stringify({
456
+ version: 3,
457
+ routes: [
458
+ {
459
+ src: `/${CLIENT_ASSETS_DIR}/(.*)`,
460
+ headers: { "cache-control": `public, max-age=31536000, immutable` },
461
+ continue: true
462
+ },
463
+ { handle: "filesystem" },
464
+ {
465
+ src: `/${CLIENT_ASSETS_DIR}/(.*)`,
466
+ status: 404,
467
+ headers: { "cache-control": "no-store" },
468
+ continue: false
469
+ },
470
+ {
471
+ src: "/(.*)",
472
+ dest: VERCEL_FUNCTION_ROUTE
473
+ }
474
+ ]
475
+ }, null, 2)}\n`;
476
+ //#endregion
477
+ //#region src/_build-target.ts
478
+ /**
479
+ * Deployment TARGETS — what `aai build` emits beside the worker so a host can
480
+ * run this project without the project holding anything host-specific.
481
+ *
482
+ * ## Why a target rather than a file in the scaffold
483
+ *
484
+ * Every host wants a different entry shape: Vercel wants a module whose default
485
+ * export is an `http.Server` it binds itself, a container wants a long-lived
486
+ * process, another platform wants something else again. Committing one of those
487
+ * to the scaffold makes every project assert a fact that is load-bearing on
488
+ * exactly one host — the same objection that removed `server.mjs`.
489
+ *
490
+ * Nitro is the worked precedent: one codebase, a preset per provider, and the
491
+ * preset EMITS the host's expected shape into the build directory. `node-server`
492
+ * is its default and Vercel/Netlify/Cloudflare are detected from the CI
493
+ * environment with no configuration. Next does the same narrower thing with
494
+ * `output: "standalone"` — it generates a `server.js` rather than asking anyone
495
+ * to write one. Either way the user's repository contains no host file, which is
496
+ * the property to preserve here.
497
+ *
498
+ * ## Auto-detection, and why it is safe
499
+ *
500
+ * A target is chosen with `--target`, or detected from the environment when the
501
+ * flag is absent. Detection reads the variables the hosts set on their own build
502
+ * containers ({@link TARGET_ENV_MARKERS}), so it only ever fires where the build
503
+ * is genuinely running on that host — a laptop sets none of them and gets
504
+ * {@link DEFAULT_BUILD_TARGET}, which emits nothing extra and is what every
505
+ * existing project already does.
506
+ *
507
+ * ## What is here, and what is one module over
508
+ *
509
+ * This file is the VOCABULARY: which targets exist, which one this build is,
510
+ * and — through {@link TARGET_OUTPUTS} — what each produced and how it ships.
511
+ * Each host's own constants and emitted sources live beside it, one module per
512
+ * host (`_vercel-target.ts`, `_deno-target.ts`, `_modal-target.ts`), which is
513
+ * the shape Nitro's `presets/<provider>/` has and the shape this file grew out
514
+ * of: it held all three and went over the 500-line cap. The dependency runs one
515
+ * way — this module reads each host's output directory, and no host module
516
+ * reads this one — so a fourth target is a fourth file plus two lines here.
517
+ */
518
+ /** The targets `aai build --target` accepts. */
519
+ const BUILD_TARGETS = [
520
+ "node",
521
+ "vercel",
522
+ "deno",
523
+ "modal"
524
+ ];
525
+ /**
526
+ * What a build with no `--target` and no host environment produces: the worker
527
+ * and the client, and nothing else.
528
+ *
529
+ * `node` rather than a `"none"` sentinel because it NAMES the deployment it
530
+ * serves — a long-lived process running `aai start` — which is what every
531
+ * container platform wants and what the scaffold's own `start` script runs.
532
+ */
533
+ const DEFAULT_BUILD_TARGET = "node";
534
+ /**
535
+ * The environment variable each host sets on its own build container.
536
+ *
537
+ * `VERCEL` is set for every Vercel build and deployment. Detection is per host
538
+ * rather than a single "am I in CI" test, because a GitHub Action building a
539
+ * container image is CI too and wants the default.
540
+ *
541
+ * **Three keys for Vercel, not one**, and they are the three `std-env` tests —
542
+ * the library Nitro detects providers with, and which this file already cites
543
+ * for the Deno pair below. `VERCEL_ENV` is the variable Vercel's own docs point
544
+ * at for "which environment is this" and is present wherever `VERCEL` is;
545
+ * `NOW_BUILDER` is set on the BUILD container and predates both, so it is the
546
+ * one a legacy or a `vercel build` invocation may carry alone. Reading one key
547
+ * for a host that advertises itself with three is the same hole the Deno pair
548
+ * below was found to have, one platform generation earlier.
549
+ *
550
+ * `DENO_DEPLOY` and `DENO_DEPLOYMENT_ID` are both Deno Deploy's "you are
551
+ * running here" variables, and BOTH are listed because neither one covers both
552
+ * GENERATIONS of the platform. Deno Deploy Classic sets `DENO_DEPLOYMENT_ID`
553
+ * and `DENO_REGION` and no `DENO_DEPLOY` at all; the current platform sets
554
+ * both. So `DENO_DEPLOYMENT_ID` is the only marker present in either, and
555
+ * reading just `DENO_DEPLOY` — as this did — left Classic undetectable. That is
556
+ * why `std-env` (the library Nitro detects providers with) tests the pair as
557
+ * ONE signal, and why Nitro's Deno preset reads that one for its manifest.
558
+ *
559
+ * These are read at BUILD time, and that is reachable rather than theoretical:
560
+ * Deno Deploy's git integration runs the build on its OWN infrastructure with
561
+ * them set — its reference singles out `DENO_TIMELINE` as the one variable NOT
562
+ * set during a build — so `aai build` there resolves this target with no flag,
563
+ * the same zero-config property `VERCEL` gives.
564
+ *
565
+ * What detection cannot see is the documented LOCAL flow, and the reason is
566
+ * ORDERING rather than a missing marker: `aai build --target deno` then
567
+ * `deno deploy` from `.aai/deno/` finishes the build on the developer's own
568
+ * machine before the upload command runs at all, so there is no host
569
+ * environment left to advertise itself. Nitro has the identical hole and
570
+ * answers it the same way — its own docs pass `NITRO_PRESET=deno_deploy`
571
+ * explicitly. The flag is the path that matters; detection covers the host that
572
+ * builds FOR you.
573
+ *
574
+ * **`modal` has NO marker, and cannot**: it is the LOCAL flow above with no
575
+ * host-built alternative. Modal runs no build of its own — `modal deploy`
576
+ * uploads a directory whose build already finished — so every Modal deploy is
577
+ * the case the paragraph above says detection cannot see, and any variable
578
+ * listed here would be dead config by construction.
579
+ *
580
+ * Worse than dead, and this is the part specific to us. The two variables that
581
+ * DO appear in a Modal environment are set inside a CONTAINER
582
+ * (`MODAL_IS_REMOTE`, `MODAL_TASK_ID`), which is the wrong end — and this
583
+ * repo's own guest sandboxes ARE Modal Sandboxes, with studio Publish running
584
+ * the CLI inside one, so detecting on them would flip the platform's own build
585
+ * to this target. `MODAL_TOKEN_ID` fails the ordinary way: credentials in the
586
+ * environment are not a statement about what a build is FOR, so anyone with
587
+ * Modal creds exported would get Modal output from a Vercel build.
588
+ *
589
+ * So `modal` is reachable by its flag alone. The reachability test in
590
+ * `_build-target.test.ts` asserts every target is selectable that way, rather
591
+ * than demanding a marker per target — which reads as the same claim and is
592
+ * not, since it would force a host like this one to invent a variable no build
593
+ * ever sees.
594
+ */
595
+ const TARGET_ENV_MARKERS = {
596
+ VERCEL: "vercel",
597
+ VERCEL_ENV: "vercel",
598
+ NOW_BUILDER: "vercel",
599
+ DENO_DEPLOY: "deno",
600
+ DENO_DEPLOYMENT_ID: "deno"
601
+ };
602
+ function isBuildTarget(value) {
603
+ return BUILD_TARGETS.includes(value);
604
+ }
605
+ /**
606
+ * Resolve the target for this build: an explicit flag wins, then the
607
+ * environment, then {@link DEFAULT_BUILD_TARGET}.
608
+ *
609
+ * An unrecognised `--target` is REFUSED naming what is accepted, rather than
610
+ * falling back to the default — a typo'd target that silently built the default
611
+ * would deploy a project missing the entry its host needs, and the failure would
612
+ * arrive as a 404 from the platform rather than as an error from the build.
613
+ */
614
+ function resolveBuildTarget(explicit, env = process.env) {
615
+ if (explicit !== void 0) {
616
+ if (!isBuildTarget(explicit)) throw new Error(`Unknown build target "${explicit}". Accepted: ${BUILD_TARGETS.join(", ")}.`);
617
+ return explicit;
618
+ }
619
+ for (const [marker, target] of Object.entries(TARGET_ENV_MARKERS)) if (env[marker]) return target;
620
+ return DEFAULT_BUILD_TARGET;
621
+ }
622
+ /**
623
+ * Every target's output and commands.
624
+ *
625
+ * The two directory-shaped hosts get a `cd` rather than a path argument,
626
+ * because that is what their tooling takes: `deno deploy` uploads the WORKING
627
+ * directory (see {@link DENO_OUTPUT_DIR}), so running it from the project root
628
+ * would upload the project. Nitro's `deno-deploy` preset writes its command
629
+ * with the same `cd`.
630
+ */
631
+ const TARGET_OUTPUTS = {
632
+ node: { preview: "aai start" },
633
+ vercel: {
634
+ dir: VERCEL_OUTPUT_DIR,
635
+ deploy: "vercel deploy --prebuilt"
636
+ },
637
+ deno: {
638
+ dir: DENO_OUTPUT_DIR,
639
+ preview: `cd ${DENO_OUTPUT_DIR} && deno task start`,
640
+ deploy: `cd ${DENO_OUTPUT_DIR} && deno deploy`
641
+ },
642
+ modal: {
643
+ dir: MODAL_OUTPUT_DIR,
644
+ preview: `modal serve ${path.join(MODAL_OUTPUT_DIR, MODAL_APP_FILE)}`,
645
+ deploy: `modal deploy ${path.join(MODAL_OUTPUT_DIR, MODAL_APP_FILE)}`
646
+ }
647
+ };
648
+ //#endregion
649
+ export { DENO_ENTRY_FILE as _, VERCEL_ENTRY_SOURCE as a, VERCEL_STATIC_DIR as c, MODAL_ENTRY_FILE as d, MODAL_ENTRY_SOURCE as f, DENO_CONFIG_SOURCE as g, DENO_CONFIG_FILE as h, VERCEL_BUILD_CONFIG_SOURCE as i, vercelFunctionConfigSource as l, MODAL_PORT as m, TARGET_OUTPUTS as n, VERCEL_FUNCTION_DIR as o, MODAL_OUTPUT_DIR as p, resolveBuildTarget as r, VERCEL_OUTPUT_DIR as s, BUILD_TARGETS as t, MODAL_APP_FILE as u, DENO_ENTRY_SOURCE as v, DENO_OUTPUT_DIR as y };