@alexkroman1/aai-cli 16.0.1 → 17.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 +3 -2
- package/dist/{_build-target-55dJisQ-.mjs → _build-target-C08aM-Es.mjs} +511 -41
- package/dist/_build-target.d.ts +109 -2
- package/dist/_deno-target.d.ts +15 -14
- package/dist/_dev-env.d.ts +19 -13
- package/dist/{_dev-server-BzWB6-4y.mjs → _dev-server-CLU9xjH5.mjs} +27 -19
- package/dist/_dev-server.d.ts +4 -3
- package/dist/_dev-vite-config.d.ts +1 -1
- package/dist/_init.d.ts +39 -0
- package/dist/_modal-target.d.ts +11 -6
- package/dist/_preflight-CnW9QiE7.mjs +116 -0
- package/dist/_preflight.d.ts +110 -5
- package/dist/{_server-common-De0haHr9.mjs → _server-common-DAcv1nC5.mjs} +46 -2
- package/dist/_server-common.d.ts +39 -0
- package/dist/_target-bundle.d.ts +112 -0
- package/dist/_target-entry.d.ts +81 -0
- package/dist/{_templates-CuP74F8D.mjs → _templates-IMeKMVIj.mjs} +1 -1
- package/dist/{_vitest-runner-AVR9VtXh.mjs → _vitest-runner-CZNGj0ZC.mjs} +22 -17
- package/dist/_vitest-runner.d.ts +36 -24
- package/dist/{_workflow-determinism-CvpqMpdh.mjs → _workflow-determinism-CLxFQ5ox.mjs} +1 -1
- package/dist/_workflow-determinism.d.ts +1 -1
- package/dist/{build-ButI2IKc.mjs → build-DrQTSc2R.mjs} +187 -289
- package/dist/build.d.ts +88 -2
- package/dist/cli.mjs +20 -16
- package/dist/{deploy-CGqPU5U-.mjs → deploy-B68-x7xM.mjs} +14 -6
- package/dist/deploy.d.ts +9 -0
- package/dist/{dev-kodAY23K.mjs → dev-ChsrNHpK.mjs} +1 -1
- package/dist/dev.d.ts +1 -1
- package/dist/{eval-DvoSz7SZ.mjs → eval-DB07kTxO.mjs} +2 -2
- package/dist/init-W-4k-lCF.mjs +559 -0
- package/dist/init.d.ts +43 -3
- package/dist/scaffold/CLAUDE.md +87 -100
- package/dist/scaffold/package.json +6 -6
- package/dist/scaffold/vite.config.ts +29 -1
- package/dist/start.mjs +1 -1
- package/dist/{studio-CtRBVVFR.mjs → studio-DEAJGBXa.mjs} +20 -10
- package/dist/templates/{hiring-desk → applicant-screening-agent}/agent.eval.test.ts +20 -6
- package/dist/templates/{hiring-desk → applicant-screening-agent}/agent.ts +28 -0
- package/dist/templates/{hiring-desk → applicant-screening-agent}/crews.ts +1 -1
- package/dist/templates/{hiring-desk → applicant-screening-agent}/shared.ts +11 -11
- package/dist/templates/{hiring-desk → applicant-screening-agent}/tools/screening_status.ts +1 -1
- package/dist/templates/{call-audit → call-audit-workflow}/agent.ts +4 -2
- package/dist/templates/{call-audit → call-audit-workflow}/client.tsx +3 -3
- package/dist/templates/{call-audit → call-audit-workflow}/guards.test.ts +2 -2
- package/dist/templates/{call-audit → call-audit-workflow}/workflows/summarize.ts +1 -1
- package/dist/templates/{code-interpreter → code-interpreter-agent}/agent.eval.test.ts +3 -2
- package/dist/templates/{code-interpreter → code-interpreter-agent}/agent.test.ts +1 -1
- package/dist/templates/{code-interpreter → code-interpreter-agent}/agent.ts +1 -0
- package/dist/templates/coding-agent/agent.eval.test.ts +136 -0
- package/dist/templates/coding-agent/agent.test.ts +109 -0
- package/dist/templates/coding-agent/agent.ts +45 -0
- package/dist/templates/coding-agent/chat.ts +63 -0
- package/dist/templates/coding-agent/shared.ts +46 -0
- package/dist/templates/coding-agent/system-prompt.md +32 -0
- package/dist/templates/coding-agent/tools/bash.ts +6 -0
- package/dist/templates/coding-agent/tools/delete_file.ts +6 -0
- package/dist/templates/coding-agent/tools/edit_file.ts +6 -0
- package/dist/templates/coding-agent/tools/glob.ts +6 -0
- package/dist/templates/coding-agent/tools/grep.ts +6 -0
- package/dist/templates/coding-agent/tools/list_files.ts +6 -0
- package/dist/templates/coding-agent/tools/read_file.ts +6 -0
- package/dist/templates/coding-agent/tools/todo_write.ts +6 -0
- package/dist/templates/coding-agent/tools/write_file.ts +6 -0
- package/dist/templates/{pipeline-simple → custom-pipeline-agent}/agent.test.ts +2 -2
- package/dist/templates/{pipeline-simple → custom-pipeline-agent}/agent.ts +2 -1
- package/dist/templates/{pipeline-simple → custom-pipeline-agent}/modes.test.ts +1 -1
- package/dist/templates/{redline → document-redline-workflow}/agent.ts +4 -2
- package/dist/templates/{redline → document-redline-workflow}/client.tsx +1 -1
- package/dist/templates/{redline → document-redline-workflow}/workflows/redline.ts +1 -1
- package/dist/templates/{dispatch-center → emergency-dispatch-agent}/agent.test.ts +104 -1
- package/dist/templates/{dispatch-center → emergency-dispatch-agent}/agent.ts +15 -0
- package/dist/templates/{dispatch-center → emergency-dispatch-agent}/events.ts +1 -1
- package/dist/templates/emergency-dispatch-agent/guardrails.ts +105 -0
- package/dist/templates/{dispatch-center → emergency-dispatch-agent}/system-prompt.md +1 -0
- package/dist/templates/{dispatch-center → emergency-dispatch-agent}/tools/incident_create.ts +1 -1
- package/dist/templates/{night-owl → entertainment-picks-agent}/agent.eval.test.ts +8 -1
- package/dist/templates/{night-owl → entertainment-picks-agent}/agent.test.ts +1 -1
- package/dist/templates/{night-owl → entertainment-picks-agent}/agent.ts +1 -0
- package/dist/templates/{night-owl → entertainment-picks-agent}/client.tsx +1 -1
- package/dist/templates/{night-owl → entertainment-picks-agent}/system-prompt.md +6 -0
- package/dist/templates/{night-owl → entertainment-picks-agent}/tools/revisit.ts +7 -0
- package/dist/templates/{executive-assistant → executive-inbox-agent}/agent.eval.test.ts +84 -23
- package/dist/templates/{executive-assistant → executive-inbox-agent}/agent.ts +1 -0
- package/dist/templates/{executive-assistant → executive-inbox-agent}/meeting.ts +2 -2
- package/dist/templates/{executive-assistant → executive-inbox-agent}/prompts.ts +3 -1
- package/dist/templates/{executive-assistant → executive-inbox-agent}/shared.ts +2 -2
- package/dist/templates/{executive-assistant → executive-inbox-agent}/system-prompt.md +3 -3
- package/dist/templates/{executive-assistant → executive-inbox-agent}/tools/meeting_assistant.ts +3 -3
- package/dist/templates/{executive-assistant → executive-inbox-agent}/tools/open_email.ts +8 -16
- package/dist/templates/{executive-assistant → executive-inbox-agent}/tools/send_calendar_invite.ts +1 -1
- package/dist/templates/{hotel-desk → hotel-reception-agent}/agent.eval.test.ts +85 -21
- package/dist/templates/{hotel-desk → hotel-reception-agent}/agent.test.ts +2 -1
- package/dist/templates/{hotel-desk → hotel-reception-agent}/agent.ts +6 -3
- package/dist/templates/{hotel-desk → hotel-reception-agent}/client.tsx +14 -2
- package/dist/templates/{hotel-desk → hotel-reception-agent}/concierge.ts +3 -2
- package/dist/templates/{hotel-desk → hotel-reception-agent}/desk-seams.test.ts +2 -1
- package/dist/templates/{hotel-desk → hotel-reception-agent}/disputes.ts +9 -11
- package/dist/templates/{hotel-desk → hotel-reception-agent}/events.ts +2 -1
- package/dist/templates/hotel-reception-agent/session.ts +56 -0
- package/dist/templates/{hotel-desk → hotel-reception-agent}/shared.ts +21 -22
- package/dist/templates/{hotel-desk → hotel-reception-agent}/system-prompt.md +1 -1
- package/dist/templates/{hotel-desk → hotel-reception-agent}/tools/abandon_booking.ts +2 -1
- package/dist/templates/{hotel-desk → hotel-reception-agent}/tools/add_to_waitlist.ts +2 -1
- package/dist/templates/{hotel-desk → hotel-reception-agent}/tools/book_airport_car.ts +2 -1
- package/dist/templates/{hotel-desk → hotel-reception-agent}/tools/cancel_restaurant_reservation.ts +2 -1
- package/dist/templates/{hotel-desk → hotel-reception-agent}/tools/cancel_room_booking.ts +2 -1
- package/dist/templates/{hotel-desk → hotel-reception-agent}/tools/check_restaurant_availability.ts +1 -1
- package/dist/templates/{hotel-desk → hotel-reception-agent}/tools/check_room_availability.ts +1 -1
- package/dist/templates/{hotel-desk → hotel-reception-agent}/tools/choose_room.ts +1 -1
- package/dist/templates/{hotel-desk → hotel-reception-agent}/tools/confirm_booking.ts +2 -1
- package/dist/templates/{hotel-desk → hotel-reception-agent}/tools/dispatch_emergency.ts +2 -1
- package/dist/templates/{hotel-desk → hotel-reception-agent}/tools/dispute_charge.ts +2 -1
- package/dist/templates/{hotel-desk → hotel-reception-agent}/tools/flag_late_arrival.ts +2 -1
- package/dist/templates/{hotel-desk → hotel-reception-agent}/tools/lookup_booking.ts +2 -1
- package/dist/templates/{hotel-desk → hotel-reception-agent}/tools/lookup_guest_history.ts +1 -1
- package/dist/templates/{hotel-desk → hotel-reception-agent}/tools/lookup_invoice.ts +2 -1
- package/dist/templates/{hotel-desk → hotel-reception-agent}/tools/lookup_restaurant_reservation.ts +1 -1
- package/dist/templates/{hotel-desk → hotel-reception-agent}/tools/modify_restaurant_reservation.ts +1 -1
- package/dist/templates/{hotel-desk → hotel-reception-agent}/tools/record_card.ts +1 -1
- package/dist/templates/{hotel-desk → hotel-reception-agent}/tools/record_followup.ts +2 -1
- package/dist/templates/{hotel-desk → hotel-reception-agent}/tools/record_group_inquiry.ts +2 -1
- package/dist/templates/{hotel-desk → hotel-reception-agent}/tools/record_guest_details.ts +1 -1
- package/dist/templates/{hotel-desk → hotel-reception-agent}/tools/reinstate_booking.ts +1 -1
- package/dist/templates/{hotel-desk → hotel-reception-agent}/tools/request_flight_reconfirmation.ts +2 -1
- package/dist/templates/{hotel-desk → hotel-reception-agent}/tools/resend_confirmation.ts +2 -1
- package/dist/templates/{hotel-desk → hotel-reception-agent}/tools/reserve_table.ts +1 -1
- package/dist/templates/{hotel-desk → hotel-reception-agent}/tools/resolve_room_conflict.ts +2 -1
- package/dist/templates/{hotel-desk → hotel-reception-agent}/tools/schedule_wakeup_call.ts +2 -1
- package/dist/templates/{hotel-desk → hotel-reception-agent}/tools/set_do_not_disturb.ts +2 -1
- package/dist/templates/{hotel-desk → hotel-reception-agent}/tools/set_extras.ts +1 -1
- package/dist/templates/{hotel-desk → hotel-reception-agent}/tools/set_stay.ts +2 -1
- package/dist/templates/{hotel-desk → hotel-reception-agent}/tools/start_booking_modification.ts +2 -1
- package/dist/templates/{hotel-desk → hotel-reception-agent}/tools/start_room_booking.ts +2 -1
- package/dist/templates/{hotel-desk → hotel-reception-agent}/tools/take_guest_message.ts +2 -1
- package/dist/templates/{hotel-desk → hotel-reception-agent}/tools/transfer_call.ts +2 -1
- package/dist/templates/{hotel-desk → hotel-reception-agent}/tools/update_card.ts +2 -1
- package/dist/templates/{hotel-desk → hotel-reception-agent}/tools/verify_booking.ts +2 -1
- package/dist/templates/{link-digest → link-digest-workflow}/agent.eval.test.ts +16 -1
- package/dist/templates/{link-digest → link-digest-workflow}/agent.test.ts +2 -2
- package/dist/templates/{link-digest → link-digest-workflow}/agent.ts +8 -3
- package/dist/templates/{link-digest → link-digest-workflow}/client.tsx +2 -2
- package/dist/templates/{link-digest → link-digest-workflow}/workflows/digest.ts +1 -1
- package/dist/templates/{health-assistant → medication-safety-agent}/agent.test.ts +55 -1
- package/dist/templates/medication-safety-agent/agent.ts +62 -0
- package/dist/templates/{recap-workflow → meeting-recap-agent}/agent.test.ts +4 -4
- package/dist/templates/{recap-workflow → meeting-recap-agent}/agent.ts +5 -1
- package/dist/templates/{recap-workflow → meeting-recap-agent}/workflows/recap.ts +3 -3
- package/dist/templates/{pizza-ordering → pizza-ordering-agent}/agent.ts +3 -0
- package/dist/templates/{podcast-digest → podcast-digest-workflow}/agent.eval.test.ts +1 -1
- package/dist/templates/{podcast-digest → podcast-digest-workflow}/agent.test.ts +1 -1
- package/dist/templates/{podcast-digest → podcast-digest-workflow}/agent.ts +6 -2
- package/dist/templates/{podcast-digest → podcast-digest-workflow}/client.tsx +3 -3
- package/dist/templates/{podcast-digest → podcast-digest-workflow}/workflows/digest.ts +1 -1
- package/dist/templates/{simple → quickstart-agent}/agent.eval.test.ts +39 -3
- package/dist/templates/{simple → quickstart-agent}/agent.test.ts +25 -3
- package/dist/templates/quickstart-agent/agent.ts +24 -0
- package/dist/templates/quickstart-agent/system-prompt.md +8 -0
- package/dist/templates/quickstart-agent/tools/get_weather.ts +59 -0
- package/dist/templates/{research-workflow → research-handoff-agent}/agent.test.ts +1 -1
- package/dist/templates/{research-workflow → research-handoff-agent}/agent.ts +5 -1
- package/dist/templates/{research-workflow → research-handoff-agent}/workflows/filing.ts +1 -1
- package/dist/templates/{research-workflow → research-handoff-agent}/workflows/research.ts +1 -1
- package/dist/templates/{research-workflow → research-handoff-agent}/workflows/review.ts +1 -1
- package/dist/templates/{plan-and-execute → research-planner-agent}/agent.eval.test.ts +24 -2
- package/dist/templates/{plan-and-execute → research-planner-agent}/agent.ts +3 -0
- package/dist/templates/{plan-and-execute → research-planner-agent}/shared.ts +1 -1
- package/dist/templates/{plan-and-execute → research-planner-agent}/system-prompt.md +1 -1
- package/dist/templates/{retail → retail-orders-agent}/agent.ts +32 -3
- package/dist/templates/retail-orders-agent/keyterms.ts +154 -0
- package/dist/templates/{retail → retail-orders-agent}/pending.ts +2 -2
- package/dist/templates/{retail → retail-orders-agent}/resolve.ts +18 -3
- package/dist/templates/{retail → retail-orders-agent}/shared.ts +1 -1
- package/dist/templates/{retail → retail-orders-agent}/store.ts +3 -3
- package/dist/templates/{roadside-assist → roadside-assistance-agent}/agent.eval.test.ts +37 -5
- package/dist/templates/{roadside-assist → roadside-assistance-agent}/agent.test.ts +38 -6
- package/dist/templates/{roadside-assist → roadside-assistance-agent}/agent.ts +5 -1
- package/dist/templates/{roadside-assist → roadside-assistance-agent}/call.ts +1 -1
- package/dist/templates/{roadside-assist → roadside-assistance-agent}/shared.ts +15 -3
- package/dist/templates/{roadside-assist → roadside-assistance-agent}/tools/acknowledge_disclosure.ts +14 -0
- package/dist/templates/{roadside-assist → roadside-assistance-agent}/tools/dispatch_truck.ts +1 -1
- package/dist/templates/{roadside-assist → roadside-assistance-agent}/tools/lookup_coverage.ts +11 -0
- package/dist/templates/{roadside-assist → roadside-assistance-agent}/tools/service_disclosure.ts +17 -11
- package/dist/templates/{roadside-assist → roadside-assistance-agent}/yard.test.ts +4 -0
- package/dist/templates/{spoken-summary → spoken-summary-workflow}/agent.test.ts +1 -1
- package/dist/templates/{spoken-summary → spoken-summary-workflow}/agent.ts +5 -1
- package/dist/templates/{spoken-summary → spoken-summary-workflow}/client.tsx +1 -1
- package/dist/templates/{spoken-summary → spoken-summary-workflow}/workflows/summarize.ts +1 -1
- package/dist/templates/{solo-rpg → tabletop-rpg-agent}/agent.eval.test.ts +6 -0
- package/dist/templates/{solo-rpg → tabletop-rpg-agent}/agent.test.ts +125 -1
- package/dist/templates/tabletop-rpg-agent/agent.ts +58 -0
- package/dist/templates/{solo-rpg → tabletop-rpg-agent}/shared.ts +84 -3
- package/dist/templates/{solo-rpg → tabletop-rpg-agent}/system-prompt.md +1 -1
- package/dist/templates/tabletop-rpg-agent/tools/check_state.ts +37 -0
- package/dist/templates/{support-line → technical-support-agent}/agent.test.ts +3 -3
- package/dist/templates/{support-line → technical-support-agent}/agent.ts +5 -1
- package/dist/templates/technical-support-agent/knowledge.ts +165 -0
- package/dist/templates/{support-line → technical-support-agent}/nodes.ts +3 -2
- package/dist/templates/{support-line → technical-support-agent}/procedure.ts +4 -3
- package/dist/templates/technical-support-agent/shared.ts +145 -0
- package/dist/templates/{support-line → technical-support-agent}/tools/list_topics.ts +2 -1
- package/dist/templates/{infocom-adventure → text-adventure-agent}/agent.eval.test.ts +39 -6
- package/dist/templates/{infocom-adventure → text-adventure-agent}/agent.test.ts +79 -1
- package/dist/templates/{infocom-adventure → text-adventure-agent}/agent.ts +30 -1
- package/dist/templates/{infocom-adventure → text-adventure-agent}/client.tsx +2 -2
- package/dist/templates/{infocom-adventure → text-adventure-agent}/shared.ts +37 -0
- package/dist/templates/{infocom-adventure → text-adventure-agent}/system-prompt.md +9 -2
- package/dist/templates/{briefing-desk → topic-briefing-agent}/agent.eval.test.ts +21 -7
- package/dist/templates/{briefing-desk → topic-briefing-agent}/agent.test.ts +23 -11
- package/dist/templates/{briefing-desk → topic-briefing-agent}/agent.ts +5 -2
- package/dist/templates/{briefing-desk → topic-briefing-agent}/shared.ts +11 -11
- package/dist/templates/{briefing-desk → topic-briefing-agent}/slack.ts +1 -1
- package/dist/templates/{briefing-desk → topic-briefing-agent}/system-prompt.md +13 -8
- package/dist/templates/{briefing-desk → topic-briefing-agent}/tools/send_briefing.ts +43 -5
- package/dist/templates/transcription-workflow/agent.test.ts +1 -1
- package/dist/templates/transcription-workflow/agent.ts +4 -1
- package/dist/templates/transcription-workflow/client.tsx +1 -1
- package/dist/templates/transcription-workflow/workflows/batch.ts +2 -2
- package/dist/templates/transcription-workflow/workflows/transcribe.ts +1 -1
- package/dist/templates/{travel-concierge → travel-concierge-agent}/agent.ts +4 -0
- package/dist/templates/{travel-concierge → travel-concierge-agent}/shared.ts +1 -1
- package/dist/templates/{web-researcher → web-research-agent}/agent.eval.test.ts +32 -6
- package/dist/templates/{web-researcher → web-research-agent}/agent.test.ts +17 -1
- package/dist/templates/{web-researcher → web-research-agent}/agent.ts +31 -1
- package/dist/templates/{web-researcher → web-research-agent}/system-prompt.md +8 -2
- package/dist/templates/{word-wrangler → word-game-agent}/agent.eval.test.ts +79 -18
- package/dist/templates/{word-wrangler → word-game-agent}/agent.ts +20 -0
- package/dist/templates/{word-wrangler → word-game-agent}/game.ts +1 -1
- package/dist/templates/{word-wrangler → word-game-agent}/shared.ts +1 -1
- package/dist/test-CjKPQ9_B.mjs +102 -0
- package/dist/test.d.ts +37 -12
- package/package.json +5 -5
- package/dist/_init-BzQbV8Zh.mjs +0 -199
- package/dist/_preflight-CcAR577V.mjs +0 -46
- package/dist/init-D363Ls5u.mjs +0 -183
- package/dist/templates/health-assistant/agent.ts +0 -15
- package/dist/templates/simple/agent.ts +0 -8
- package/dist/templates/solo-rpg/agent.ts +0 -29
- package/dist/templates/solo-rpg/tools/check_state.ts +0 -28
- package/dist/templates/support-line/shared.ts +0 -281
- package/dist/test-Cllnx81G.mjs +0 -83
- /package/dist/templates/{hiring-desk → applicant-screening-agent}/agent.test.ts +0 -0
- /package/dist/templates/{hiring-desk → applicant-screening-agent}/client.tsx +0 -0
- /package/dist/templates/{hiring-desk → applicant-screening-agent}/leads.json +0 -0
- /package/dist/templates/{hiring-desk → applicant-screening-agent}/screening-lock.test.ts +0 -0
- /package/dist/templates/{hiring-desk → applicant-screening-agent}/screening-lock.ts +0 -0
- /package/dist/templates/{hiring-desk → applicant-screening-agent}/system-prompt.md +0 -0
- /package/dist/templates/{hiring-desk → applicant-screening-agent}/tools/candidate_details.ts +0 -0
- /package/dist/templates/{hiring-desk → applicant-screening-agent}/tools/proceed_to_emails.ts +0 -0
- /package/dist/templates/{hiring-desk → applicant-screening-agent}/tools/read_email.ts +0 -0
- /package/dist/templates/{hiring-desk → applicant-screening-agent}/tools/rescore_with_feedback.ts +0 -0
- /package/dist/templates/{hiring-desk → applicant-screening-agent}/tools/screen_candidates.ts +0 -0
- /package/dist/templates/{call-audit → call-audit-workflow}/agent.eval.test.ts +0 -0
- /package/dist/templates/{call-audit → call-audit-workflow}/agent.test.ts +0 -0
- /package/dist/templates/{call-audit → call-audit-workflow}/workflows/audit.ts +0 -0
- /package/dist/templates/{call-audit → call-audit-workflow}/workflows/ingest.ts +0 -0
- /package/dist/templates/{call-audit → call-audit-workflow}/workflows/media.ts +0 -0
- /package/dist/templates/{call-audit → call-audit-workflow}/workflows/sync-api.ts +0 -0
- /package/dist/templates/{code-interpreter → code-interpreter-agent}/system-prompt.md +0 -0
- /package/dist/templates/{pipeline-simple → custom-pipeline-agent}/agent.eval.test.ts +0 -0
- /package/dist/templates/{pipeline-simple → custom-pipeline-agent}/stages.test.ts +0 -0
- /package/dist/templates/{redline → document-redline-workflow}/agent.eval.test.ts +0 -0
- /package/dist/templates/{redline → document-redline-workflow}/agent.test.ts +0 -0
- /package/dist/templates/{redline → document-redline-workflow}/form.ts +0 -0
- /package/dist/templates/{redline → document-redline-workflow}/workflows/prompts.ts +0 -0
- /package/dist/templates/{dispatch-center → emergency-dispatch-agent}/agent.eval.test.ts +0 -0
- /package/dist/templates/{dispatch-center → emergency-dispatch-agent}/client.tsx +0 -0
- /package/dist/templates/{dispatch-center → emergency-dispatch-agent}/shared.ts +0 -0
- /package/dist/templates/{dispatch-center → emergency-dispatch-agent}/tools/incident_add_note.ts +0 -0
- /package/dist/templates/{dispatch-center → emergency-dispatch-agent}/tools/incident_escalate.ts +0 -0
- /package/dist/templates/{dispatch-center → emergency-dispatch-agent}/tools/incident_get.ts +0 -0
- /package/dist/templates/{dispatch-center → emergency-dispatch-agent}/tools/incident_triage.ts +0 -0
- /package/dist/templates/{dispatch-center → emergency-dispatch-agent}/tools/incident_update_status.ts +0 -0
- /package/dist/templates/{dispatch-center → emergency-dispatch-agent}/tools/ops_dashboard.ts +0 -0
- /package/dist/templates/{dispatch-center → emergency-dispatch-agent}/tools/ops_protocols.ts +0 -0
- /package/dist/templates/{dispatch-center → emergency-dispatch-agent}/tools/ops_run_scenario.ts +0 -0
- /package/dist/templates/{dispatch-center → emergency-dispatch-agent}/tools/resources_dispatch.ts +0 -0
- /package/dist/templates/{dispatch-center → emergency-dispatch-agent}/tools/resources_get_available.ts +0 -0
- /package/dist/templates/{dispatch-center → emergency-dispatch-agent}/tools/resources_update_status.ts +0 -0
- /package/dist/templates/{night-owl → entertainment-picks-agent}/shared.ts +0 -0
- /package/dist/templates/{night-owl → entertainment-picks-agent}/tools/recommend.ts +0 -0
- /package/dist/templates/{executive-assistant → executive-inbox-agent}/agent.test.ts +0 -0
- /package/dist/templates/{executive-assistant → executive-inbox-agent}/calendar.test.ts +0 -0
- /package/dist/templates/{executive-assistant → executive-inbox-agent}/client.tsx +0 -0
- /package/dist/templates/{executive-assistant → executive-inbox-agent}/inbox.ts +0 -0
- /package/dist/templates/{executive-assistant → executive-inbox-agent}/nodes.ts +0 -0
- /package/dist/templates/{executive-assistant → executive-inbox-agent}/review.ts +0 -0
- /package/dist/templates/{executive-assistant → executive-inbox-agent}/tools/accept.ts +0 -0
- /package/dist/templates/{executive-assistant → executive-inbox-agent}/tools/ask_question.ts +0 -0
- /package/dist/templates/{executive-assistant → executive-inbox-agent}/tools/draft_reply.ts +0 -0
- /package/dist/templates/{executive-assistant → executive-inbox-agent}/tools/edit.ts +0 -0
- /package/dist/templates/{executive-assistant → executive-inbox-agent}/tools/ignore.ts +0 -0
- /package/dist/templates/{executive-assistant → executive-inbox-agent}/tools/inbox_status.ts +0 -0
- /package/dist/templates/{executive-assistant → executive-inbox-agent}/tools/new_email.ts +0 -0
- /package/dist/templates/{executive-assistant → executive-inbox-agent}/tools/respond.ts +0 -0
- /package/dist/templates/{executive-assistant → executive-inbox-agent}/tools/review_memory.ts +0 -0
- /package/dist/templates/{executive-assistant → executive-inbox-agent}/tools/triage_inbox.ts +0 -0
- /package/dist/templates/{hotel-desk → hotel-reception-agent}/booking.ts +0 -0
- /package/dist/templates/{hotel-desk → hotel-reception-agent}/card.ts +0 -0
- /package/dist/templates/{hotel-desk → hotel-reception-agent}/catalogs.ts +0 -0
- /package/dist/templates/{hotel-desk → hotel-reception-agent}/desk.ts +0 -0
- /package/dist/templates/{hotel-desk → hotel-reception-agent}/hotel.ts +0 -0
- /package/dist/templates/{hotel-desk → hotel-reception-agent}/policies.ts +0 -0
- /package/dist/templates/{hotel-desk → hotel-reception-agent}/records.ts +0 -0
- /package/dist/templates/{hotel-desk → hotel-reception-agent}/restaurant.ts +0 -0
- /package/dist/templates/{hotel-desk → hotel-reception-agent}/seed.ts +0 -0
- /package/dist/templates/{hotel-desk → hotel-reception-agent}/tools/book_business_center.ts +0 -0
- /package/dist/templates/{hotel-desk → hotel-reception-agent}/tools/book_spa_appointment.ts +0 -0
- /package/dist/templates/{hotel-desk → hotel-reception-agent}/tools/book_tour.ts +0 -0
- /package/dist/templates/{hotel-desk → hotel-reception-agent}/tools/lookup_policy.ts +0 -0
- /package/dist/templates/{hotel-desk → hotel-reception-agent}/tools/order_flowers.ts +0 -0
- /package/dist/templates/{link-digest → link-digest-workflow}/api-client.ts +0 -0
- /package/dist/templates/{health-assistant → medication-safety-agent}/agent.eval.test.ts +0 -0
- /package/dist/templates/{health-assistant → medication-safety-agent}/fda.test.ts +0 -0
- /package/dist/templates/{health-assistant → medication-safety-agent}/fda.ts +0 -0
- /package/dist/templates/{health-assistant → medication-safety-agent}/system-prompt.md +0 -0
- /package/dist/templates/{health-assistant → medication-safety-agent}/tools/check_drug_interaction.ts +0 -0
- /package/dist/templates/{health-assistant → medication-safety-agent}/tools/medication_lookup.ts +0 -0
- /package/dist/templates/{recap-workflow → meeting-recap-agent}/agent.eval.test.ts +0 -0
- /package/dist/templates/{recap-workflow → meeting-recap-agent}/shared.ts +0 -0
- /package/dist/templates/{recap-workflow → meeting-recap-agent}/tools/cancel_recap.ts +0 -0
- /package/dist/templates/{recap-workflow → meeting-recap-agent}/tools/keep_transcript.ts +0 -0
- /package/dist/templates/{recap-workflow → meeting-recap-agent}/tools/recap_progress.ts +0 -0
- /package/dist/templates/{recap-workflow → meeting-recap-agent}/tools/recap_status.ts +0 -0
- /package/dist/templates/{recap-workflow → meeting-recap-agent}/tools/request_recap.ts +0 -0
- /package/dist/templates/{recap-workflow → meeting-recap-agent}/workflows/tokens.ts +0 -0
- /package/dist/templates/{pizza-ordering → pizza-ordering-agent}/agent.eval.test.ts +0 -0
- /package/dist/templates/{pizza-ordering → pizza-ordering-agent}/agent.test.ts +0 -0
- /package/dist/templates/{pizza-ordering → pizza-ordering-agent}/client.tsx +0 -0
- /package/dist/templates/{pizza-ordering → pizza-ordering-agent}/shared.ts +0 -0
- /package/dist/templates/{pizza-ordering → pizza-ordering-agent}/system-prompt.md +0 -0
- /package/dist/templates/{pizza-ordering → pizza-ordering-agent}/tools/add_pizza.ts +0 -0
- /package/dist/templates/{pizza-ordering → pizza-ordering-agent}/tools/place_order.ts +0 -0
- /package/dist/templates/{pizza-ordering → pizza-ordering-agent}/tools/remove_pizza.ts +0 -0
- /package/dist/templates/{pizza-ordering → pizza-ordering-agent}/tools/set_customer_name.ts +0 -0
- /package/dist/templates/{pizza-ordering → pizza-ordering-agent}/tools/update_pizza.ts +0 -0
- /package/dist/templates/{pizza-ordering → pizza-ordering-agent}/tools/view_order.ts +0 -0
- /package/dist/templates/{podcast-digest → podcast-digest-workflow}/workflows/feeds.ts +0 -0
- /package/dist/templates/{podcast-digest → podcast-digest-workflow}/workflows/slack.ts +0 -0
- /package/dist/templates/{research-workflow → research-handoff-agent}/agent.eval.test.ts +0 -0
- /package/dist/templates/{research-workflow → research-handoff-agent}/shared.ts +0 -0
- /package/dist/templates/{research-workflow → research-handoff-agent}/tools/file_it_now.ts +0 -0
- /package/dist/templates/{research-workflow → research-handoff-agent}/tools/request_research.ts +0 -0
- /package/dist/templates/{research-workflow → research-handoff-agent}/tools/research_progress.ts +0 -0
- /package/dist/templates/{research-workflow → research-handoff-agent}/tools/research_status.ts +0 -0
- /package/dist/templates/{research-workflow → research-handoff-agent}/workflows/notes.ts +0 -0
- /package/dist/templates/{research-workflow → research-handoff-agent}/workflows/prompts.ts +0 -0
- /package/dist/templates/{plan-and-execute → research-planner-agent}/agent.test.ts +0 -0
- /package/dist/templates/{plan-and-execute → research-planner-agent}/client.tsx +0 -0
- /package/dist/templates/{plan-and-execute → research-planner-agent}/procedure.ts +0 -0
- /package/dist/templates/{plan-and-execute → research-planner-agent}/prompts.ts +0 -0
- /package/dist/templates/{plan-and-execute → research-planner-agent}/tools/plan_status.ts +0 -0
- /package/dist/templates/{plan-and-execute → research-planner-agent}/tools/revise_plan.ts +0 -0
- /package/dist/templates/{plan-and-execute → research-planner-agent}/tools/start_plan.ts +0 -0
- /package/dist/templates/{plan-and-execute → research-planner-agent}/tools/work_next_step.ts +0 -0
- /package/dist/templates/{retail → retail-orders-agent}/address.ts +0 -0
- /package/dist/templates/{retail → retail-orders-agent}/agent.eval.test.ts +0 -0
- /package/dist/templates/{retail → retail-orders-agent}/agent.test.ts +0 -0
- /package/dist/templates/{retail → retail-orders-agent}/authenticate.ts +0 -0
- /package/dist/templates/{retail → retail-orders-agent}/cancel.ts +0 -0
- /package/dist/templates/{retail → retail-orders-agent}/client.tsx +0 -0
- /package/dist/templates/{retail → retail-orders-agent}/payment.ts +0 -0
- /package/dist/templates/{retail → retail-orders-agent}/pending.test.ts +0 -0
- /package/dist/templates/{retail → retail-orders-agent}/refund.ts +0 -0
- /package/dist/templates/{retail → retail-orders-agent}/registry.test.ts +0 -0
- /package/dist/templates/{retail → retail-orders-agent}/resolve.test.ts +0 -0
- /package/dist/templates/{retail → retail-orders-agent}/returns.ts +0 -0
- /package/dist/templates/{retail → retail-orders-agent}/seed.json +0 -0
- /package/dist/templates/{retail → retail-orders-agent}/seed.test.ts +0 -0
- /package/dist/templates/{retail → retail-orders-agent}/shared.test.ts +0 -0
- /package/dist/templates/{retail → retail-orders-agent}/store.test.ts +0 -0
- /package/dist/templates/{retail → retail-orders-agent}/swap.test.ts +0 -0
- /package/dist/templates/{retail → retail-orders-agent}/swap.ts +0 -0
- /package/dist/templates/{retail → retail-orders-agent}/system-prompt.md +0 -0
- /package/dist/templates/{retail → retail-orders-agent}/tools/cancel_change.ts +0 -0
- /package/dist/templates/{retail → retail-orders-agent}/tools/cancel_pending_order.ts +0 -0
- /package/dist/templates/{retail → retail-orders-agent}/tools/confirm_change.ts +0 -0
- /package/dist/templates/{retail → retail-orders-agent}/tools/exchange_delivered_order_items.ts +0 -0
- /package/dist/templates/{retail → retail-orders-agent}/tools/find_user_id_by_email.ts +0 -0
- /package/dist/templates/{retail → retail-orders-agent}/tools/find_user_id_by_name_zip.ts +0 -0
- /package/dist/templates/{retail → retail-orders-agent}/tools/get_item_details.ts +0 -0
- /package/dist/templates/{retail → retail-orders-agent}/tools/get_order_details.ts +0 -0
- /package/dist/templates/{retail → retail-orders-agent}/tools/get_product_details.ts +0 -0
- /package/dist/templates/{retail → retail-orders-agent}/tools/get_user_details.ts +0 -0
- /package/dist/templates/{retail → retail-orders-agent}/tools/list_all_product_types.ts +0 -0
- /package/dist/templates/{retail → retail-orders-agent}/tools/modify_pending_order_address.ts +0 -0
- /package/dist/templates/{retail → retail-orders-agent}/tools/modify_pending_order_items.ts +0 -0
- /package/dist/templates/{retail → retail-orders-agent}/tools/modify_pending_order_payment.ts +0 -0
- /package/dist/templates/{retail → retail-orders-agent}/tools/modify_user_address.ts +0 -0
- /package/dist/templates/{retail → retail-orders-agent}/tools/return_delivered_order_items.ts +0 -0
- /package/dist/templates/{retail → retail-orders-agent}/tools/transfer_to_human_agents.ts +0 -0
- /package/dist/templates/{roadside-assist → roadside-assistance-agent}/events.ts +0 -0
- /package/dist/templates/{roadside-assist → roadside-assistance-agent}/system-prompt.md +0 -0
- /package/dist/templates/{roadside-assist → roadside-assistance-agent}/tools/job_status.ts +0 -0
- /package/dist/templates/{roadside-assist → roadside-assistance-agent}/tools/report_location.ts +0 -0
- /package/dist/templates/{roadside-assist → roadside-assistance-agent}/yard.ts +0 -0
- /package/dist/templates/{spoken-summary → spoken-summary-workflow}/agent.eval.test.ts +0 -0
- /package/dist/templates/{spoken-summary → spoken-summary-workflow}/workflows/transcribe.ts +0 -0
- /package/dist/templates/{solo-rpg → tabletop-rpg-agent}/client.tsx +0 -0
- /package/dist/templates/{solo-rpg → tabletop-rpg-agent}/tools/action_roll.ts +0 -0
- /package/dist/templates/{solo-rpg → tabletop-rpg-agent}/tools/burn_momentum.ts +0 -0
- /package/dist/templates/{solo-rpg → tabletop-rpg-agent}/tools/oracle.ts +0 -0
- /package/dist/templates/{solo-rpg → tabletop-rpg-agent}/tools/setup_character.ts +0 -0
- /package/dist/templates/{solo-rpg → tabletop-rpg-agent}/tools/update_state.ts +0 -0
- /package/dist/templates/{support-line → technical-support-agent}/agent.eval.test.ts +0 -0
- /package/dist/templates/{support-line → technical-support-agent}/client.tsx +0 -0
- /package/dist/templates/{support-line → technical-support-agent}/knowledge.json +0 -0
- /package/dist/templates/{support-line → technical-support-agent}/prompts.ts +0 -0
- /package/dist/templates/{support-line → technical-support-agent}/system-prompt.md +0 -0
- /package/dist/templates/{support-line → technical-support-agent}/tools/answer_question.ts +0 -0
- /package/dist/templates/{support-line → technical-support-agent}/tools/log_ticket.ts +0 -0
- /package/dist/templates/{infocom-adventure → text-adventure-agent}/tools/game_state_drop.ts +0 -0
- /package/dist/templates/{infocom-adventure → text-adventure-agent}/tools/game_state_flag.ts +0 -0
- /package/dist/templates/{infocom-adventure → text-adventure-agent}/tools/game_state_get.ts +0 -0
- /package/dist/templates/{infocom-adventure → text-adventure-agent}/tools/game_state_move.ts +0 -0
- /package/dist/templates/{infocom-adventure → text-adventure-agent}/tools/game_state_restart.ts +0 -0
- /package/dist/templates/{infocom-adventure → text-adventure-agent}/tools/game_state_score.ts +0 -0
- /package/dist/templates/{infocom-adventure → text-adventure-agent}/tools/game_state_take.ts +0 -0
- /package/dist/templates/{briefing-desk → topic-briefing-agent}/tools/briefing_so_far.ts +0 -0
- /package/dist/templates/{briefing-desk → topic-briefing-agent}/tools/research_topic.ts +0 -0
- /package/dist/templates/{briefing-desk → topic-briefing-agent}/tools/verify_claim.ts +0 -0
- /package/dist/templates/{travel-concierge → travel-concierge-agent}/agent.eval.test.ts +0 -0
- /package/dist/templates/{travel-concierge → travel-concierge-agent}/agent.test.ts +0 -0
- /package/dist/templates/{travel-concierge → travel-concierge-agent}/call-events.ts +0 -0
- /package/dist/templates/{travel-concierge → travel-concierge-agent}/client.tsx +0 -0
- /package/dist/templates/{travel-concierge → travel-concierge-agent}/routing.ts +0 -0
- /package/dist/templates/{travel-concierge → travel-concierge-agent}/system-prompt.md +0 -0
- /package/dist/templates/{travel-concierge → travel-concierge-agent}/tools/book_car_rental.ts +0 -0
- /package/dist/templates/{travel-concierge → travel-concierge-agent}/tools/book_excursion.ts +0 -0
- /package/dist/templates/{travel-concierge → travel-concierge-agent}/tools/book_hotel.ts +0 -0
- /package/dist/templates/{travel-concierge → travel-concierge-agent}/tools/cancel_action.ts +0 -0
- /package/dist/templates/{travel-concierge → travel-concierge-agent}/tools/cancel_ticket.ts +0 -0
- /package/dist/templates/{travel-concierge → travel-concierge-agent}/tools/complete_or_escalate.ts +0 -0
- /package/dist/templates/{travel-concierge → travel-concierge-agent}/tools/confirm_action.ts +0 -0
- /package/dist/templates/{travel-concierge → travel-concierge-agent}/tools/lookup_booking.ts +0 -0
- /package/dist/templates/{travel-concierge → travel-concierge-agent}/tools/search_car_rentals.ts +0 -0
- /package/dist/templates/{travel-concierge → travel-concierge-agent}/tools/search_excursions.ts +0 -0
- /package/dist/templates/{travel-concierge → travel-concierge-agent}/tools/search_flights.ts +0 -0
- /package/dist/templates/{travel-concierge → travel-concierge-agent}/tools/search_hotels.ts +0 -0
- /package/dist/templates/{travel-concierge → travel-concierge-agent}/tools/to_car_rental_assistant.ts +0 -0
- /package/dist/templates/{travel-concierge → travel-concierge-agent}/tools/to_excursion_assistant.ts +0 -0
- /package/dist/templates/{travel-concierge → travel-concierge-agent}/tools/to_flight_assistant.ts +0 -0
- /package/dist/templates/{travel-concierge → travel-concierge-agent}/tools/to_hotel_assistant.ts +0 -0
- /package/dist/templates/{travel-concierge → travel-concierge-agent}/tools/update_ticket.ts +0 -0
- /package/dist/templates/{word-wrangler → word-game-agent}/agent.test.ts +0 -0
- /package/dist/templates/{word-wrangler → word-game-agent}/client.tsx +0 -0
- /package/dist/templates/{word-wrangler → word-game-agent}/guess.ts +0 -0
- /package/dist/templates/{word-wrangler → word-game-agent}/player.ts +0 -0
- /package/dist/templates/{word-wrangler → word-game-agent}/system-prompt.md +0 -0
- /package/dist/templates/{word-wrangler → word-game-agent}/tools/final_score.ts +0 -0
- /package/dist/templates/{word-wrangler → word-game-agent}/tools/relay_description.ts +0 -0
- /package/dist/templates/{word-wrangler → word-game-agent}/tools/repeat_word.ts +0 -0
- /package/dist/templates/{word-wrangler → word-game-agent}/tools/skip_word.ts +0 -0
- /package/dist/templates/{word-wrangler → word-game-agent}/tools/start_game.ts +0 -0
- /package/dist/templates/{word-wrangler → word-game-agent}/words.ts +0 -0
package/README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# @alexkroman1/aai-cli
|
|
2
2
|
|
|
3
|
-
The `aai` command — scaffold, run, test, and publish
|
|
3
|
+
The `aai` command — scaffold, run, test, and publish voice agents built with
|
|
4
|
+
the AssemblyAI Agent SDK.
|
|
4
5
|
|
|
5
6
|
```sh
|
|
6
7
|
npm i -g @alexkroman1/aai-cli
|
|
@@ -33,7 +34,7 @@ when stdout is not a TTY). `aai <command> --help` shows flags.
|
|
|
33
34
|
## Typical flow
|
|
34
35
|
|
|
35
36
|
```sh
|
|
36
|
-
aai init my-agent --template pizza-ordering
|
|
37
|
+
aai init my-agent --template pizza-ordering-agent
|
|
37
38
|
cd my-agent
|
|
38
39
|
# put ASSEMBLYAI_API_KEY=... in .env
|
|
39
40
|
aai dev # talk to it at the printed URL
|
|
@@ -60,6 +60,90 @@ for (const name of ["SIGINT", "SIGTERM"]) {
|
|
|
60
60
|
}
|
|
61
61
|
`;
|
|
62
62
|
//#endregion
|
|
63
|
+
//#region src/_target-entry.ts
|
|
64
|
+
/**
|
|
65
|
+
* The LONG-LIVED entry — one source, and every runtime that can run it.
|
|
66
|
+
*
|
|
67
|
+
* A leaf beside `_target-drain.ts` (the signal handler both long-lived entries
|
|
68
|
+
* carry), `_target-output.ts` (the directory they share) and
|
|
69
|
+
* `_target-bundle.ts` (the bundle every target's entry goes through): each is a
|
|
70
|
+
* thing more than one host needs and no host owns.
|
|
71
|
+
*
|
|
72
|
+
* ## Why the entry is shared, when it deliberately was not
|
|
73
|
+
*
|
|
74
|
+
* Both long-lived entries do the same four things — build the server, bind a
|
|
75
|
+
* port, bind it on `0.0.0.0`, drain on a signal — and the argument for keeping
|
|
76
|
+
* two copies was the port: `MODAL_ENTRY_SOURCE`'s own doc records it as "the
|
|
77
|
+
* two read the port from different runtimes, and a shared entry would be a
|
|
78
|
+
* template with a hole where that goes".
|
|
79
|
+
*
|
|
80
|
+
* That is true only if a runtime's env is read one runtime's way. It was: the
|
|
81
|
+
* Deno entry read `globalThis.Deno?.env.get("PORT")` and nothing else, and the
|
|
82
|
+
* Modal entry read `process.env.PORT` and nothing else — so each emitted
|
|
83
|
+
* artifact was pinned to its host by ONE expression, and running the Deno
|
|
84
|
+
* directory under `node` or `bun` bound the default port no matter what the
|
|
85
|
+
* host had set. Nobody decided that; it fell out of which global was in reach
|
|
86
|
+
* when each file was written.
|
|
87
|
+
*
|
|
88
|
+
* {@link RUNTIME_PORT_SOURCE} reads BOTH, so the artifact is portable and the
|
|
89
|
+
* hole in the template closes. What is left per host is a comment and a
|
|
90
|
+
* default, which is what {@link longLivedEntrySource} takes.
|
|
91
|
+
*
|
|
92
|
+
* ## Why portability is a property worth spending a module on
|
|
93
|
+
*
|
|
94
|
+
* A self-contained emit is a directory with no `node_modules`, no toolchain and
|
|
95
|
+
* one file to run — which is exactly what a container image carries, and the
|
|
96
|
+
* runtime in that image is the operator's choice, not ours. `deno`, `node` and
|
|
97
|
+
* `bun` all run this file; `_target-runtimes.scenario.test.ts` boots the emit
|
|
98
|
+
* under each of the three and dials a real session on it, because nothing else
|
|
99
|
+
* here can tell you that the same bundle serves on all three rather than only
|
|
100
|
+
* on the one host whose target emitted it.
|
|
101
|
+
*/
|
|
102
|
+
/**
|
|
103
|
+
* The port expression every long-lived entry uses, reading whichever runtime
|
|
104
|
+
* it finds itself in.
|
|
105
|
+
*
|
|
106
|
+
* `globalThis.Deno?.env` rather than `Deno.env`, and the optional chain is
|
|
107
|
+
* load-bearing twice over: this file is bundled by a Node-side build and read
|
|
108
|
+
* by Node tooling (its own specs included), where a bare `Deno` is a
|
|
109
|
+
* `ReferenceError` — and under Node and Bun the chain is what falls through to
|
|
110
|
+
* `process.env` instead of throwing.
|
|
111
|
+
*
|
|
112
|
+
* `process.env` second rather than first, because Deno's `process` shim reads
|
|
113
|
+
* the same variables and asking Deno for them Deno's way is what keeps the
|
|
114
|
+
* Deno arm honest — a host that grants no env permission fails on the first
|
|
115
|
+
* read either way.
|
|
116
|
+
*
|
|
117
|
+
* `process` itself needs no guard and deliberately gets none: it is a global in
|
|
118
|
+
* all three runtimes, which is what lets {@link TARGET_DRAIN_SOURCE} be the
|
|
119
|
+
* identical text in every entry rather than a template with a hole in it.
|
|
120
|
+
*/
|
|
121
|
+
const RUNTIME_PORT_SOURCE = "globalThis.Deno?.env.get(\"PORT\") ?? process.env.PORT";
|
|
122
|
+
/**
|
|
123
|
+
* The entry a long-lived host runs, bundled into that target's entry file.
|
|
124
|
+
*
|
|
125
|
+
* `0.0.0.0`, not `AgentServer.listen`'s loopback default: every host here
|
|
126
|
+
* reaches the process from outside it, so a loopback bind answers nothing while
|
|
127
|
+
* looking healthy.
|
|
128
|
+
*
|
|
129
|
+
* `import.meta.dirname` rather than `process.cwd()`: the artifacts are copied
|
|
130
|
+
* in BESIDE this file (see `_target-output.ts`) and the working directory
|
|
131
|
+
* belongs to the platform.
|
|
132
|
+
*/
|
|
133
|
+
function longLivedEntrySource(entry) {
|
|
134
|
+
const note = entry.hostNote.map((line) => `// ${line}\n`).join("");
|
|
135
|
+
const drainNote = entry.drainNote === void 0 ? "" : `// ${entry.drainNote}\n`;
|
|
136
|
+
return `// Generated by \`aai build --target ${entry.target}\` — do not edit, and do not commit.
|
|
137
|
+
${note}// See @alexkroman1/aai-cli/start.
|
|
138
|
+
import { createProjectServer } from "@alexkroman1/aai-cli/start";
|
|
139
|
+
|
|
140
|
+
const server = await createProjectServer({ cwd: import.meta.dirname });
|
|
141
|
+
|
|
142
|
+
await server.listen(Number(${RUNTIME_PORT_SOURCE} ?? ${entry.defaultPort}), "0.0.0.0");
|
|
143
|
+
|
|
144
|
+
${drainNote}${TARGET_DRAIN_SOURCE}`;
|
|
145
|
+
}
|
|
146
|
+
//#endregion
|
|
63
147
|
//#region src/_deno-target.ts
|
|
64
148
|
/**
|
|
65
149
|
* The **Deno Deploy** target — a self-contained directory under `.aai/deno/`.
|
|
@@ -69,7 +153,7 @@ for (const name of ["SIGINT", "SIGTERM"]) {
|
|
|
69
153
|
* it goes and what goes in it.
|
|
70
154
|
*
|
|
71
155
|
* Deno and Modal are the two LONG-LIVED targets: each entry binds a port and
|
|
72
|
-
* each drains on a signal (
|
|
156
|
+
* each drains on a signal (`TARGET_DRAIN_SOURCE`), which is what makes
|
|
73
157
|
* them the pair that also shares `_target-output.ts`.
|
|
74
158
|
*/
|
|
75
159
|
/**
|
|
@@ -87,6 +171,14 @@ const DENO_ENTRY_FILE = "server.mjs";
|
|
|
87
171
|
/** Deno's own project file inside {@link DENO_OUTPUT_DIR}. */
|
|
88
172
|
const DENO_CONFIG_FILE = "deno.json";
|
|
89
173
|
/**
|
|
174
|
+
* The port the entry binds when the host set no `PORT`.
|
|
175
|
+
*
|
|
176
|
+
* Deploy sets one, so this is what a bare `deno task start` on a laptop gets —
|
|
177
|
+
* the same number the Modal entry defaults to, because a reader who has run
|
|
178
|
+
* one emit should not have to look up the other.
|
|
179
|
+
*/
|
|
180
|
+
const DENO_PORT = 8e3;
|
|
181
|
+
/**
|
|
90
182
|
* The `deno.json` written beside the entry, so the output DESCRIBES how to run
|
|
91
183
|
* itself.
|
|
92
184
|
*
|
|
@@ -119,30 +211,18 @@ const DENO_CONFIG_SOURCE = `${JSON.stringify({ tasks: { start: `deno run -A ./${
|
|
|
119
211
|
* `aai start` run. Verified against a live deployment with real speech: 74
|
|
120
212
|
* audio frames back, transcript and reply intact.
|
|
121
213
|
*
|
|
122
|
-
*
|
|
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.
|
|
214
|
+
* ## The body is SHARED, and only these three lines are Deno's
|
|
131
215
|
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
216
|
+
* {@link longLivedEntrySource} carries the bind, the `0.0.0.0`, the
|
|
217
|
+
* `import.meta.dirname` and the drain — see that module for why the port read
|
|
218
|
+
* is no longer Deno's own, which is what left this artifact runnable only under
|
|
219
|
+
* Deno for as long as it read `globalThis.Deno.env` and nothing else.
|
|
135
220
|
*/
|
|
136
|
-
const DENO_ENTRY_SOURCE =
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
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}`;
|
|
221
|
+
const DENO_ENTRY_SOURCE = longLivedEntrySource({
|
|
222
|
+
target: "deno",
|
|
223
|
+
hostNote: ["Deno Deploy runs this as a long-lived process and expects it to listen."],
|
|
224
|
+
defaultPort: DENO_PORT
|
|
225
|
+
});
|
|
146
226
|
//#endregion
|
|
147
227
|
//#region src/_modal-target.ts
|
|
148
228
|
/**
|
|
@@ -191,14 +271,19 @@ const MODAL_PORT = 8e3;
|
|
|
191
271
|
* `aai start` shape rather than the serverless one — `listen()`, `0.0.0.0`
|
|
192
272
|
* (the proxy reaches this from outside the process), and artifacts resolved
|
|
193
273
|
* from {@link MODAL_ENTRY_FILE}'s own directory rather than from a working
|
|
194
|
-
* directory the platform owns.
|
|
195
|
-
*
|
|
196
|
-
*
|
|
197
|
-
*
|
|
274
|
+
* directory the platform owns.
|
|
275
|
+
*
|
|
276
|
+
* ## The entry IS shared with Deno's now
|
|
277
|
+
*
|
|
278
|
+
* It was not, on the reading that the two read the port from different
|
|
279
|
+
* runtimes and a shared entry would be a template with a hole where that goes.
|
|
280
|
+
* `RUNTIME_PORT_SOURCE` reads both runtimes, so the hole closed — and the
|
|
281
|
+
* copy cost more than duplication: it is what made each artifact runnable only
|
|
282
|
+
* under the runtime whose host emitted it. See `_target-entry.ts`.
|
|
198
283
|
*
|
|
199
284
|
* ## The drain is SHARED, and Modal supplies its other half
|
|
200
285
|
*
|
|
201
|
-
* The `SIGINT`/`SIGTERM` body is
|
|
286
|
+
* The `SIGINT`/`SIGTERM` body is `TARGET_DRAIN_SOURCE`, the same text the
|
|
202
287
|
* Deno entry carries — it used to live here alone, on the reading that Modal
|
|
203
288
|
* stops containers and Deno Deploy does not, which is not true of either.
|
|
204
289
|
*
|
|
@@ -208,18 +293,287 @@ const MODAL_PORT = 8e3;
|
|
|
208
293
|
* platform's own deploy learned that when orphaned guest sandboxes billed ~20
|
|
209
294
|
* minutes each on every release (see `run_node` in `scripts/modal_image.py`).
|
|
210
295
|
*/
|
|
211
|
-
const MODAL_ENTRY_SOURCE =
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
296
|
+
const MODAL_ENTRY_SOURCE = longLivedEntrySource({
|
|
297
|
+
target: "modal",
|
|
298
|
+
hostNote: ["Modal runs this as a long-lived process behind `@modal.web_server`, which", "proxies HTTP and WebSocket traffic to the port it binds."],
|
|
299
|
+
defaultPort: MODAL_PORT,
|
|
300
|
+
drainNote: "app.py forwards the container's stop signal here and waits for this process."
|
|
301
|
+
});
|
|
302
|
+
//#endregion
|
|
303
|
+
//#region src/_modal-app.ts
|
|
304
|
+
/**
|
|
305
|
+
* The Modal app definition `aai build --target modal` emits — `app.py`.
|
|
306
|
+
*
|
|
307
|
+
* ## Why this target is a generated PYTHON file
|
|
308
|
+
*
|
|
309
|
+
* Every other target emits the host's expected entry shape and lets the host
|
|
310
|
+
* hold the rest: Vercel reads a routing table it already understands, Deno
|
|
311
|
+
* Deploy takes a directory and an entrypoint. Modal has no such descriptor.
|
|
312
|
+
* Its deploy unit is a Python module — `modal.App`, an image recipe, and a
|
|
313
|
+
* decorated function — and `modal deploy` runs that module rather than reading
|
|
314
|
+
* a manifest out of it. So the "preset" for Modal is the module itself, which
|
|
315
|
+
* is why this is the one target whose emit generates code in another language.
|
|
316
|
+
*
|
|
317
|
+
* ## The knobs are DEPLOY-TIME ENV, not edits to this file
|
|
318
|
+
*
|
|
319
|
+
* The awkward consequence is that Modal's policy — how many containers, how
|
|
320
|
+
* much CPU, which secret — lives in Python arguments rather than in a platform
|
|
321
|
+
* dashboard. A generated file carrying policy is a file people edit, and this
|
|
322
|
+
* one is overwritten by the next `aai build`, so "do not edit" would be a lie
|
|
323
|
+
* the first time somebody wanted a warm container.
|
|
324
|
+
*
|
|
325
|
+
* Four knobs are therefore read from the environment at deploy time
|
|
326
|
+
* ({@link MODAL_ENV_KNOBS}), which keeps the project committing nothing
|
|
327
|
+
* host-specific — the property `_build-target.ts` opens by defending:
|
|
328
|
+
*
|
|
329
|
+
* ```sh
|
|
330
|
+
* AAI_MODAL_MIN_CONTAINERS=1 modal deploy .aai/modal/app.py
|
|
331
|
+
* ```
|
|
332
|
+
*
|
|
333
|
+
* The rest — cpu, memory, timeout, concurrency — stays a documented constant
|
|
334
|
+
* in the emitted file. Those are the numbers a reader needs to SEE to trust
|
|
335
|
+
* the deployment, and regenerating restates the default, which is the same
|
|
336
|
+
* contract every other generated artifact here has.
|
|
337
|
+
*/
|
|
338
|
+
/**
|
|
339
|
+
* The Node major the emitted image may not go below — the SDK's own `engines`
|
|
340
|
+
* floor.
|
|
341
|
+
*
|
|
342
|
+
* The tag otherwise tracks the Node running the build, so the bundle runs on
|
|
343
|
+
* the runtime it was bundled for. Modal pulls any tag that exists on Docker
|
|
344
|
+
* Hub, so there is nothing to clamp from ABOVE — unlike `vercelNodeRuntime`,
|
|
345
|
+
* whose platform publishes a fixed list. The floor is the half that matters:
|
|
346
|
+
* npm does not enforce `engines` by default, so a build on Node 22 would
|
|
347
|
+
* otherwise emit a `node:22-slim` image in which the SDK genuinely does not
|
|
348
|
+
* run, and the failure would arrive as a crash-looping container.
|
|
349
|
+
*/
|
|
350
|
+
const MODAL_NODE_MAJOR_FLOOR = 24;
|
|
351
|
+
/**
|
|
352
|
+
* The Python `add_python` layers beside Node.
|
|
353
|
+
*
|
|
354
|
+
* Matches `scripts/modal_image.py`, which is the same arrangement one layer up:
|
|
355
|
+
* the container entrypoint is Modal's own Python runtime, and it spawns node.
|
|
356
|
+
*/
|
|
357
|
+
const MODAL_ADD_PYTHON = "3.13";
|
|
358
|
+
/** What a name sanitizes to when nothing usable survives — see {@link modalAppName}. */
|
|
359
|
+
const MODAL_FALLBACK_APP_NAME = "aai-agent";
|
|
360
|
+
/**
|
|
361
|
+
* Modal caps a resource name at 64 characters. Truncated rather than refused:
|
|
362
|
+
* the name is cosmetic (it appears in the app's URL), and failing a build over
|
|
363
|
+
* a long agent name would be the target's first impression.
|
|
364
|
+
*/
|
|
365
|
+
const MODAL_NAME_MAX = 64;
|
|
366
|
+
/**
|
|
367
|
+
* An agent name as a Modal app name.
|
|
368
|
+
*
|
|
369
|
+
* Modal accepts a narrow character set here and the name reaches a hostname —
|
|
370
|
+
* a deployed function is served at `<workspace>--<app>-<function>.modal.run` —
|
|
371
|
+
* so anything outside `[a-z0-9-]` becomes a dash rather than being passed
|
|
372
|
+
* through and rejected by the platform. Agent names are free text
|
|
373
|
+
* (`define({ name: "Retail Support Bot" })`), which is why this is a mapping
|
|
374
|
+
* and not a validation.
|
|
375
|
+
*
|
|
376
|
+
* Collapsed and trimmed, because `--` is what a hostname reader sees as the
|
|
377
|
+
* workspace separator, and a leading or trailing dash is not a legal label.
|
|
378
|
+
*/
|
|
379
|
+
function modalAppName(agentName) {
|
|
380
|
+
const slug = agentName.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, MODAL_NAME_MAX).replace(/-+$/g, "");
|
|
381
|
+
return slug === "" ? MODAL_FALLBACK_APP_NAME : slug;
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* The Modal Secret the deployment reads its env from.
|
|
385
|
+
*
|
|
386
|
+
* `-env` rather than the app name alone: the secret holds exactly what
|
|
387
|
+
* `.env.example` declares, and a name that says so makes
|
|
388
|
+
* `modal secret create <name> …` self-explaining. Derived rather than
|
|
389
|
+
* configured, so the emitted file and the command in its docstring cannot name
|
|
390
|
+
* two different secrets.
|
|
391
|
+
*/
|
|
392
|
+
function modalSecretName(appName) {
|
|
393
|
+
return `${appName}-env`.slice(0, MODAL_NAME_MAX);
|
|
394
|
+
}
|
|
395
|
+
/** `node:<major>-slim` for the Node running this build, floored at the SDK's minimum. */
|
|
396
|
+
function modalNodeImageTag(version = process.versions.node) {
|
|
397
|
+
const major = Number.parseInt(version.split(".")[0] ?? "", 10);
|
|
398
|
+
return `node:${Number.isNaN(major) || major < MODAL_NODE_MAJOR_FLOOR ? MODAL_NODE_MAJOR_FLOOR : major}-slim`;
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* Render `app.py` for this agent.
|
|
402
|
+
*
|
|
403
|
+
* Every number the platform needs appears ONCE and is interpolated, so the
|
|
404
|
+
* emitted file cannot disagree with itself or with the entry beside it — see
|
|
405
|
+
* {@link MODAL_PORT} for the failure that motivates it.
|
|
406
|
+
*/
|
|
407
|
+
function modalAppSource(options) {
|
|
408
|
+
const app = modalAppName(options.name);
|
|
409
|
+
const secret = modalSecretName(app);
|
|
410
|
+
const image = options.nodeImage ?? modalNodeImageTag();
|
|
411
|
+
return `# Generated by \`aai build --target modal\` — do not edit, and do not commit.
|
|
412
|
+
"""Deploys this agent to Modal.
|
|
216
413
|
|
|
217
|
-
|
|
414
|
+
modal secret create ${secret} ASSEMBLYAI_API_KEY=... # once
|
|
415
|
+
modal deploy .aai/modal/${MODAL_APP_FILE}
|
|
416
|
+
|
|
417
|
+
Everything this serves is in THIS directory. \`${MODAL_ENTRY_FILE}\` is a bundle
|
|
418
|
+
with no imports left to resolve, so the image installs nothing, carries no
|
|
419
|
+
lockfile and needs no node_modules.
|
|
420
|
+
|
|
421
|
+
Policy is read from the environment at DEPLOY time rather than edited here,
|
|
422
|
+
because \`aai build --target modal\` overwrites this file:
|
|
423
|
+
|
|
424
|
+
AAI_MODAL_APP app name (default: ${app})
|
|
425
|
+
AAI_MODAL_SECRET secret holding the agent env (default: ${secret})
|
|
426
|
+
AAI_MODAL_MIN_CONTAINERS warm floor (default: 0, i.e. scales to zero)
|
|
427
|
+
AAI_MODAL_MAX_CONTAINERS autoscaler ceiling (default: 10)
|
|
428
|
+
"""
|
|
429
|
+
|
|
430
|
+
import atexit
|
|
431
|
+
import contextlib
|
|
432
|
+
import os
|
|
433
|
+
import signal
|
|
434
|
+
import subprocess
|
|
435
|
+
from pathlib import Path
|
|
436
|
+
|
|
437
|
+
import modal
|
|
438
|
+
|
|
439
|
+
# This file's OWN directory, never the shell's. \`modal deploy\` resolves a
|
|
440
|
+
# relative local path against the directory it was invoked FROM, so an
|
|
441
|
+
# \`add_local_dir(".")\` here would upload the project root or nothing at all,
|
|
442
|
+
# depending on where the deploy was run.
|
|
443
|
+
HERE = Path(__file__).parent
|
|
444
|
+
|
|
445
|
+
# Bound to \`@modal.web_server\` and baked into the image env from this one
|
|
446
|
+
# place. The proxy routes to the port it is told about, and a node process
|
|
447
|
+
# reading a different number listens where nothing is routed — a deployment
|
|
448
|
+
# that builds, starts, reports healthy and answers no request.
|
|
449
|
+
PORT = ${MODAL_PORT}
|
|
450
|
+
|
|
451
|
+
# The node server, spawned by \`server()\` below.
|
|
452
|
+
ENTRY = "${MODAL_ENTRY_FILE}"
|
|
453
|
+
|
|
454
|
+
APP_NAME = os.environ.get("AAI_MODAL_APP", "${app}")
|
|
455
|
+
SECRET_NAME = os.environ.get("AAI_MODAL_SECRET", "${secret}")
|
|
456
|
+
MIN_CONTAINERS = int(os.environ.get("AAI_MODAL_MIN_CONTAINERS", "0"))
|
|
457
|
+
MAX_CONTAINERS = int(os.environ.get("AAI_MODAL_MAX_CONTAINERS", "10"))
|
|
458
|
+
|
|
459
|
+
# How long a container stop waits for node to close its sessions before the
|
|
460
|
+
# force-kill. Modal's own SIGKILL backstop still bounds the real grace period,
|
|
461
|
+
# so this is headroom rather than a budget the shutdown spends.
|
|
462
|
+
NODE_STOP_TIMEOUT_SECS = 30
|
|
463
|
+
|
|
464
|
+
image = (
|
|
465
|
+
# \`add_python\` layers Modal's own Python beside Node: the container
|
|
466
|
+
# entrypoint is that Python runtime, and it spawns node. The Node major
|
|
467
|
+
# tracks the one this was BUILT with, so the bundle runs on the runtime it
|
|
468
|
+
# was bundled for.
|
|
469
|
+
modal.Image.from_registry("${image}", add_python="${MODAL_ADD_PYTHON}")
|
|
470
|
+
.env({"NODE_ENV": "production", "PORT": str(PORT)})
|
|
471
|
+
# \`copy=True\` puts these files in an image LAYER. The default mounts them
|
|
472
|
+
# at container start instead, which re-uploads the browser client on every
|
|
473
|
+
# cold start and makes the boot slower the larger the UI gets.
|
|
474
|
+
.add_local_dir(
|
|
475
|
+
HERE,
|
|
476
|
+
remote_path="/app",
|
|
477
|
+
copy=True,
|
|
478
|
+
ignore=["${MODAL_APP_FILE}", "__pycache__"],
|
|
479
|
+
)
|
|
480
|
+
)
|
|
481
|
+
|
|
482
|
+
app = modal.App(APP_NAME)
|
|
483
|
+
|
|
484
|
+
|
|
485
|
+
def _run_node(entry: str, env: dict[str, str]) -> subprocess.Popen:
|
|
486
|
+
"""Spawn the node server and hand container stop signals to it.
|
|
218
487
|
|
|
219
|
-
|
|
488
|
+
Modal stops a container by signalling THIS Python process, and a child
|
|
489
|
+
spawned with a bare Popen receives nothing of its own — so the node
|
|
490
|
+
server's SIGTERM handler, the thing that closes live voice sessions, would
|
|
491
|
+
never run on a scale-in or a redeploy. Every call in progress would just
|
|
492
|
+
lose its socket.
|
|
220
493
|
|
|
221
|
-
|
|
222
|
-
|
|
494
|
+
Two hooks, because neither alone is reliable: \`signal.signal\` only works on
|
|
495
|
+
the main thread and Modal may call this off it, while the atexit fallback
|
|
496
|
+
catches the runtime handling the signal itself and exiting normally. Both
|
|
497
|
+
funnel into one memoized stop(), and the node handler is idempotent, so
|
|
498
|
+
double delivery is harmless.
|
|
499
|
+
"""
|
|
500
|
+
proc = subprocess.Popen(["node", entry], cwd="/app", env=env)
|
|
501
|
+
stopped = False
|
|
502
|
+
|
|
503
|
+
def stop() -> None:
|
|
504
|
+
nonlocal stopped
|
|
505
|
+
if stopped or proc.poll() is not None:
|
|
506
|
+
return
|
|
507
|
+
stopped = True
|
|
508
|
+
with contextlib.suppress(ProcessLookupError):
|
|
509
|
+
proc.send_signal(signal.SIGTERM)
|
|
510
|
+
with contextlib.suppress(subprocess.TimeoutExpired):
|
|
511
|
+
proc.wait(timeout=NODE_STOP_TIMEOUT_SECS)
|
|
512
|
+
if proc.poll() is None:
|
|
513
|
+
proc.kill()
|
|
514
|
+
|
|
515
|
+
def forward(signum: int) -> None:
|
|
516
|
+
previous = signal.getsignal(signum)
|
|
517
|
+
|
|
518
|
+
def handler(sig: int, frame: object) -> None:
|
|
519
|
+
stop()
|
|
520
|
+
if callable(previous):
|
|
521
|
+
previous(sig, frame)
|
|
522
|
+
elif previous == signal.SIG_DFL:
|
|
523
|
+
# Re-deliver with the default disposition so this runtime still
|
|
524
|
+
# dies the way the platform expects.
|
|
525
|
+
signal.signal(sig, signal.SIG_DFL)
|
|
526
|
+
os.kill(os.getpid(), sig)
|
|
527
|
+
|
|
528
|
+
signal.signal(signum, handler)
|
|
529
|
+
|
|
530
|
+
for signum in (signal.SIGTERM, signal.SIGINT):
|
|
531
|
+
with contextlib.suppress(ValueError): # not the main thread
|
|
532
|
+
forward(signum)
|
|
533
|
+
|
|
534
|
+
atexit.register(stop)
|
|
535
|
+
return proc
|
|
536
|
+
|
|
537
|
+
|
|
538
|
+
@app.function(
|
|
539
|
+
image=image,
|
|
540
|
+
# Values live in a Modal Secret; the \`.env.example\` beside this file
|
|
541
|
+
# DECLARES which names reach \`ctx.env\`. Deploy FAILS when the secret does
|
|
542
|
+
# not exist, which is the right time to hear about it — the alternative is
|
|
543
|
+
# a container that starts and has no provider credential.
|
|
544
|
+
secrets=[modal.Secret.from_name(SECRET_NAME)],
|
|
545
|
+
# An audio pipeline is not a burstable workload: STT framing, the LLM turn
|
|
546
|
+
# and TTS playback all run in this process.
|
|
547
|
+
cpu=1,
|
|
548
|
+
memory=1024,
|
|
549
|
+
min_containers=MIN_CONTAINERS,
|
|
550
|
+
max_containers=MAX_CONTAINERS,
|
|
551
|
+
# Hold a container after the last call rather than paying a cold start on
|
|
552
|
+
# the next one.
|
|
553
|
+
scaledown_window=300,
|
|
554
|
+
# Bounds ONE input, and a WebSocket is one input for as long as the call
|
|
555
|
+
# lasts — so this is the longest single call this deployment will carry.
|
|
556
|
+
timeout=3600,
|
|
557
|
+
)
|
|
558
|
+
# Without this a container serves ONE input at a time, and a voice call holds
|
|
559
|
+
# its input until the caller hangs up: the second caller would wait out the
|
|
560
|
+
# first, and every asset request for the browser client would queue behind
|
|
561
|
+
# whichever call is in progress. \`target_inputs\` is the scale-out set point,
|
|
562
|
+
# under the cap, so a container is joined by another before it saturates.
|
|
563
|
+
@modal.concurrent(max_inputs=50, target_inputs=25)
|
|
564
|
+
@modal.web_server(port=PORT, startup_timeout=180)
|
|
565
|
+
def server() -> None:
|
|
566
|
+
env = os.environ.copy()
|
|
567
|
+
# Modal points this at an in-container Unix socket serving its own Python
|
|
568
|
+
# task runtime. The \`modal\` JS SDK prefers that variable over the public
|
|
569
|
+
# endpoint, so anything in node that talks to Modal would dial a socket
|
|
570
|
+
# that does not answer it.
|
|
571
|
+
env.pop("MODAL_SERVER_URL", None)
|
|
572
|
+
# _run_node, not a bare Popen, so the container's stop signal reaches node
|
|
573
|
+
# and live sessions are closed rather than dropped.
|
|
574
|
+
_run_node(ENTRY, env)
|
|
575
|
+
`;
|
|
576
|
+
}
|
|
223
577
|
//#endregion
|
|
224
578
|
//#region src/_vercel-target.ts
|
|
225
579
|
/**
|
|
@@ -515,6 +869,44 @@ const VERCEL_BUILD_CONFIG_SOURCE = `${JSON.stringify({
|
|
|
515
869
|
* way — this module reads each host's output directory, and no host module
|
|
516
870
|
* reads this one — so a fourth target is a fourth file plus two lines here.
|
|
517
871
|
*/
|
|
872
|
+
/**
|
|
873
|
+
* What a {@link DeployStep} puts where a variable NAME goes.
|
|
874
|
+
*
|
|
875
|
+
* Angle brackets rather than a `$NAME` or `%s`: the string is printed for a
|
|
876
|
+
* human to adapt as often as it is substituted into, and both of the other two
|
|
877
|
+
* are shell-significant enough to be mistaken for something to type literally.
|
|
878
|
+
*/
|
|
879
|
+
const SECRET_NAME_PLACEHOLDER = "<NAME>";
|
|
880
|
+
/**
|
|
881
|
+
* The placeholders {@link resolveDeploySteps} FILLS, and the ones it leaves.
|
|
882
|
+
*
|
|
883
|
+
* The line between them is who KNOWS the value at build time, and it is worth
|
|
884
|
+
* stating because it is the same line `.env.example` draws: this build knows
|
|
885
|
+
* every declared variable name and the agent's own name, so leaving those as
|
|
886
|
+
* placeholders would be withholding something it could have printed. It knows
|
|
887
|
+
* nothing about the reader's account — an org, an app that may not exist yet —
|
|
888
|
+
* or about a secret's VALUE, which is the whole point of declarations shipping
|
|
889
|
+
* while values do not.
|
|
890
|
+
*
|
|
891
|
+
* So {@link SECRET_NAME_PLACEHOLDER} and {@link MODAL_SECRET_PLACEHOLDER} are
|
|
892
|
+
* substituted, and these three survive into the printed command as prompts for
|
|
893
|
+
* the reader to fill.
|
|
894
|
+
*/
|
|
895
|
+
const ORG_PLACEHOLDER = "<ORG>";
|
|
896
|
+
/** @see ORG_PLACEHOLDER */
|
|
897
|
+
const APP_PLACEHOLDER = "<APP>";
|
|
898
|
+
/** @see ORG_PLACEHOLDER */
|
|
899
|
+
const SECRET_VALUE_PLACEHOLDER = "<value>";
|
|
900
|
+
/**
|
|
901
|
+
* Where Modal's derived secret name goes — see {@link modalSecretName}.
|
|
902
|
+
*
|
|
903
|
+
* Substituted rather than left for the reader, because `app.py` DERIVES that
|
|
904
|
+
* name from the agent's own and a reader who invents one gets a deploy that
|
|
905
|
+
* fails on `Secret.from_name`. The emitted file's docstring already prints the
|
|
906
|
+
* resolved name; this is the same string reaching the same reader one surface
|
|
907
|
+
* earlier.
|
|
908
|
+
*/
|
|
909
|
+
const MODAL_SECRET_PLACEHOLDER = "<secret>";
|
|
518
910
|
/** The targets `aai build --target` accepts. */
|
|
519
911
|
const BUILD_TARGETS = [
|
|
520
912
|
"node",
|
|
@@ -632,18 +1024,96 @@ const TARGET_OUTPUTS = {
|
|
|
632
1024
|
node: { preview: "aai start" },
|
|
633
1025
|
vercel: {
|
|
634
1026
|
dir: VERCEL_OUTPUT_DIR,
|
|
635
|
-
deploy:
|
|
1027
|
+
deploy: [
|
|
1028
|
+
{
|
|
1029
|
+
when: "build",
|
|
1030
|
+
run: "aai build --target vercel"
|
|
1031
|
+
},
|
|
1032
|
+
{
|
|
1033
|
+
when: "perSecret",
|
|
1034
|
+
run: `vercel env add ${SECRET_NAME_PLACEHOLDER} production`
|
|
1035
|
+
},
|
|
1036
|
+
{
|
|
1037
|
+
when: "each",
|
|
1038
|
+
run: "vercel deploy --prebuilt"
|
|
1039
|
+
}
|
|
1040
|
+
]
|
|
636
1041
|
},
|
|
637
1042
|
deno: {
|
|
638
1043
|
dir: DENO_OUTPUT_DIR,
|
|
639
1044
|
preview: `cd ${DENO_OUTPUT_DIR} && deno task start`,
|
|
640
|
-
deploy:
|
|
1045
|
+
deploy: [
|
|
1046
|
+
{
|
|
1047
|
+
when: "build",
|
|
1048
|
+
run: "aai build --target deno"
|
|
1049
|
+
},
|
|
1050
|
+
{
|
|
1051
|
+
when: "once",
|
|
1052
|
+
run: `deno deploy create --source local --region us --runtime-mode dynamic --entrypoint ${DENO_ENTRY_FILE} --do-not-use-detected-build-config --org ${ORG_PLACEHOLDER} --app ${APP_PLACEHOLDER}`
|
|
1053
|
+
},
|
|
1054
|
+
{
|
|
1055
|
+
when: "perSecret",
|
|
1056
|
+
run: `deno deploy env add ${SECRET_NAME_PLACEHOLDER} ${SECRET_VALUE_PLACEHOLDER} --org ${ORG_PLACEHOLDER} --app ${APP_PLACEHOLDER}`
|
|
1057
|
+
},
|
|
1058
|
+
{
|
|
1059
|
+
when: "each",
|
|
1060
|
+
run: `cd ${DENO_OUTPUT_DIR} && deno deploy --prod --org ${ORG_PLACEHOLDER} --app ${APP_PLACEHOLDER}`
|
|
1061
|
+
}
|
|
1062
|
+
]
|
|
641
1063
|
},
|
|
642
1064
|
modal: {
|
|
643
1065
|
dir: MODAL_OUTPUT_DIR,
|
|
644
1066
|
preview: `modal serve ${path.join(MODAL_OUTPUT_DIR, MODAL_APP_FILE)}`,
|
|
645
|
-
deploy:
|
|
1067
|
+
deploy: [
|
|
1068
|
+
{
|
|
1069
|
+
when: "build",
|
|
1070
|
+
run: "aai build --target modal"
|
|
1071
|
+
},
|
|
1072
|
+
{
|
|
1073
|
+
when: "perSecret",
|
|
1074
|
+
run: `modal secret create ${MODAL_SECRET_PLACEHOLDER} ${SECRET_NAME_PLACEHOLDER}=${SECRET_VALUE_PLACEHOLDER}`
|
|
1075
|
+
},
|
|
1076
|
+
{
|
|
1077
|
+
when: "each",
|
|
1078
|
+
run: `modal deploy ${path.join(MODAL_OUTPUT_DIR, MODAL_APP_FILE)}`
|
|
1079
|
+
}
|
|
1080
|
+
]
|
|
646
1081
|
}
|
|
647
1082
|
};
|
|
1083
|
+
/**
|
|
1084
|
+
* The sequence a reader should actually run: placeholders this build can fill
|
|
1085
|
+
* FILLED, and the `perSecret` step expanded once per variable that needs one.
|
|
1086
|
+
*
|
|
1087
|
+
* Resolved here rather than at the log site so the `--json` result and the
|
|
1088
|
+
* printed lines cannot disagree — the defect that produced this whole shape was
|
|
1089
|
+
* a deploy instruction that lived as a string at one call site and was wrong.
|
|
1090
|
+
*
|
|
1091
|
+
* With nothing missing, the `perSecret` step is kept ONCE in placeholder form
|
|
1092
|
+
* rather than dropped, and that is deliberate: `missingDeployEnv` reads the
|
|
1093
|
+
* BUILD's environment, which says nothing about what the host has (its own doc
|
|
1094
|
+
* makes this point), so an empty `missing` means "your shell had these", not
|
|
1095
|
+
* "the platform does". Dropping the step there would quietly promise a host is
|
|
1096
|
+
* configured when nobody has configured it.
|
|
1097
|
+
*/
|
|
1098
|
+
function resolveDeploySteps(target, options) {
|
|
1099
|
+
const steps = TARGET_OUTPUTS[target].deploy;
|
|
1100
|
+
if (steps === void 0) return [];
|
|
1101
|
+
const secret = modalSecretName(modalAppName(options.agentName));
|
|
1102
|
+
const fill = (run) => run.replaceAll(MODAL_SECRET_PLACEHOLDER, secret);
|
|
1103
|
+
return steps.flatMap((step) => {
|
|
1104
|
+
if (step.when !== "perSecret") return [{
|
|
1105
|
+
...step,
|
|
1106
|
+
run: fill(step.run)
|
|
1107
|
+
}];
|
|
1108
|
+
if (options.missingEnv.length === 0) return [{
|
|
1109
|
+
...step,
|
|
1110
|
+
run: fill(step.run)
|
|
1111
|
+
}];
|
|
1112
|
+
return options.missingEnv.map((name) => ({
|
|
1113
|
+
when: step.when,
|
|
1114
|
+
run: fill(step.run).replaceAll(SECRET_NAME_PLACEHOLDER, name)
|
|
1115
|
+
}));
|
|
1116
|
+
});
|
|
1117
|
+
}
|
|
648
1118
|
//#endregion
|
|
649
|
-
export {
|
|
1119
|
+
export { DENO_CONFIG_FILE as _, resolveDeploySteps as a, DENO_ENTRY_SOURCE as b, VERCEL_FUNCTION_DIR as c, vercelFunctionConfigSource as d, modalAppSource as f, MODAL_OUTPUT_DIR as g, MODAL_ENTRY_SOURCE as h, resolveBuildTarget as i, VERCEL_OUTPUT_DIR as l, MODAL_ENTRY_FILE as m, SECRET_NAME_PLACEHOLDER as n, VERCEL_BUILD_CONFIG_SOURCE as o, MODAL_APP_FILE as p, TARGET_OUTPUTS as r, VERCEL_ENTRY_SOURCE as s, BUILD_TARGETS as t, VERCEL_STATIC_DIR as u, DENO_CONFIG_SOURCE as v, DENO_OUTPUT_DIR as x, DENO_ENTRY_FILE as y };
|