@alexkroman1/aai-cli 0.16.0 → 0.18.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/dist/{_agent-BopNO5Bq.mjs → _agent-BN21AHsJ.mjs} +4 -4
- package/dist/_api-client-Uljj0CQi.mjs +312 -0
- package/dist/_api-client.d.ts +69 -1
- package/dist/{_bundler-DCuNHjDF.mjs → _bundler-DvZDEu2p.mjs} +67 -7
- package/dist/_bundler.d.ts +15 -0
- package/dist/_cli-common.d.ts +42 -0
- package/dist/{client-bundler-DE-AGdm7.mjs → _client-plugins-kR43nZnb.mjs} +30 -132
- package/dist/_client-plugins.d.ts +16 -0
- package/dist/{_config-mq1I5Cva.mjs → _config-Dlh8PRRp.mjs} +2 -20
- package/dist/_config.d.ts +0 -8
- package/dist/{_dev-server-B4ZiXbZj.mjs → _dev-server-C_zidzWj.mjs} +17 -12
- package/dist/_dev-session-ticket.d.ts +3 -0
- package/dist/_dev-tunnel.d.ts +20 -2
- package/dist/_dotenv-file.d.ts +6 -0
- package/dist/_init.d.ts +2 -11
- package/dist/_output.d.ts +47 -20
- package/dist/_safe-write.d.ts +38 -0
- package/dist/{_server-common-CVXIeWrY.mjs → _server-common-C6j67AcZ.mjs} +37 -2
- package/dist/_server-common.d.ts +16 -0
- package/dist/{_slug-api-BnmTHtjd.mjs → _slug-api-B9cptz7Q.mjs} +3 -2
- package/dist/_start-affinity.d.ts +70 -0
- package/dist/_start-log.d.ts +39 -0
- package/dist/_start-router.d.ts +85 -0
- package/dist/_start-run.d.ts +101 -0
- package/dist/_start-worker.d.ts +61 -0
- package/dist/_start-workers-BNdOnTal.mjs +529 -0
- package/dist/_start-workers.d.ts +262 -0
- package/dist/_studio-zympBLlD.mjs +140 -0
- package/dist/_studio.d.ts +14 -0
- package/dist/_target-bundle.d.ts +4 -0
- package/dist/{_templates-BVMVsQh0.mjs → _templates-ChZuhW66.mjs} +110 -8
- package/dist/_templates.d.ts +20 -1
- package/dist/{_typecheck-gate-CcX2gLJZ.mjs → _typecheck-gate-BNF5cboL.mjs} +2 -2
- package/dist/_ui-C0RufoYZ.mjs +147 -0
- package/dist/_ui.d.ts +14 -3
- package/dist/_utils-ChU85MEg.mjs +486 -0
- package/dist/_utils.d.ts +28 -0
- package/dist/_vendor-openers.d.ts +87 -0
- package/dist/{_vitest-runner-CKI8_K1b.mjs → _vitest-runner-tzyto9IU.mjs} +7 -3
- package/dist/_vitest-runner.d.ts +8 -1
- package/dist/{build-BnXLgfk-.mjs → build-BHgd-QYb.mjs} +13 -10
- package/dist/build.d.ts +21 -0
- package/dist/cli-workflow.d.ts +7 -0
- package/dist/cli.d.ts +16 -0
- package/dist/cli.mjs +243 -70
- package/dist/client-bundler-CImhqcp2.mjs +133 -0
- package/dist/client-bundler.mjs +1 -1
- package/dist/{console-Bp1kSqz_.mjs → console-DwycgRkC.mjs} +4 -5
- package/dist/delete-ZcA3J_3o.mjs +75 -0
- package/dist/delete.d.ts +10 -1
- package/dist/{deploy-eWDoiwvn.mjs → deploy-CkfkiZE3.mjs} +9 -9
- package/dist/{dev-CxZsZsOL.mjs → dev-BX9g6qcf.mjs} +81 -18
- package/dist/{eval-Dl8o91yC.mjs → eval-CUKvfxRq.mjs} +4 -4
- package/dist/{init-CidslZZz.mjs → init-B9Uw76-_.mjs} +62 -32
- package/dist/{login-oJdBWu2B.mjs → login-Ct73CqU1.mjs} +30 -6
- package/dist/login.d.ts +2 -0
- package/dist/{logs-CkmFdSbr.mjs → logs-BBsUy96d.mjs} +59 -14
- package/dist/logs.d.ts +4 -1
- package/dist/project-config.mjs +1 -1
- package/dist/scaffold/CLAUDE.md +72 -55
- package/dist/scaffold/agent-guide/AGENT-API.md +46 -33
- package/dist/scaffold/agent-guide/HOSTING.md +11 -0
- package/dist/scaffold/agent-guide/TESTING-EVALS.md +105 -36
- package/dist/scaffold/agent-guide/TOOLS.md +189 -33
- package/dist/scaffold/agent-guide/UI.md +111 -39
- package/dist/scaffold/agent-guide/WORKFLOWS.md +234 -160
- package/dist/scaffold/package.json +4 -4
- package/dist/{secret-DPdPEet2.mjs → secret-CKjHRrVX.mjs} +112 -35
- package/dist/start.d.ts +14 -14
- package/dist/start.mjs +840 -40
- package/dist/{studio-COjK25Rl.mjs → studio-U6DvBNAx.mjs} +123 -35
- package/dist/studio.d.ts +1 -0
- package/dist/templates/applicant-screening-agent/agent.eval.test.ts +23 -52
- package/dist/templates/applicant-screening-agent/agent.test.ts +821 -826
- package/dist/templates/applicant-screening-agent/agent.ts +1 -6
- package/dist/templates/applicant-screening-agent/client.tsx +1 -19
- package/dist/templates/applicant-screening-agent/shared.ts +8 -18
- package/dist/templates/applicant-screening-agent/tools/candidate_details.ts +24 -27
- package/dist/templates/applicant-screening-agent/tools/proceed_to_emails.ts +75 -82
- package/dist/templates/applicant-screening-agent/tools/read_email.ts +24 -24
- package/dist/templates/applicant-screening-agent/tools/rescore_with_feedback.ts +92 -99
- package/dist/templates/applicant-screening-agent/tools/screen_candidates.ts +72 -83
- package/dist/templates/applicant-screening-agent/tools/screening_status.ts +21 -29
- package/dist/templates/call-audit-workflow/agent.eval.test.ts +14 -19
- package/dist/templates/call-audit-workflow/agent.test.ts +275 -169
- package/dist/templates/call-audit-workflow/agent.ts +12 -30
- package/dist/templates/call-audit-workflow/client.tsx +9 -27
- package/dist/templates/call-audit-workflow/guards.test.ts +24 -71
- package/dist/templates/call-audit-workflow/workflows/audit.ts +24 -52
- package/dist/templates/call-audit-workflow/workflows/ingest.ts +32 -59
- package/dist/templates/call-audit-workflow/workflows/media.ts +4 -44
- package/dist/templates/call-audit-workflow/workflows/summarize.ts +72 -107
- package/dist/templates/code-interpreter-agent/agent.eval.test.ts +3 -2
- package/dist/templates/code-interpreter-agent/agent.test.ts +4 -17
- package/dist/templates/code-interpreter-agent/agent.ts +1 -1
- package/dist/templates/coding-agent/agent.test.ts +17 -12
- package/dist/templates/coding-agent/agent.ts +1 -1
- package/dist/templates/custom-pipeline-agent/agent.test.ts +6 -14
- package/dist/templates/custom-pipeline-agent/agent.ts +1 -1
- package/dist/templates/custom-pipeline-agent/modes.test.ts +0 -1
- package/dist/templates/custom-pipeline-agent/stages.test.ts +4 -8
- package/dist/templates/document-redline-workflow/agent.test.ts +88 -221
- package/dist/templates/document-redline-workflow/agent.ts +22 -32
- package/dist/templates/document-redline-workflow/client.tsx +46 -88
- package/dist/templates/document-redline-workflow/workflows/prompts.ts +0 -3
- package/dist/templates/document-redline-workflow/workflows/redline.ts +33 -50
- package/dist/templates/emergency-dispatch-agent/agent.eval.test.ts +22 -71
- package/dist/templates/emergency-dispatch-agent/agent.test.ts +466 -495
- package/dist/templates/emergency-dispatch-agent/agent.ts +27 -43
- package/dist/templates/emergency-dispatch-agent/client.tsx +85 -119
- package/dist/templates/emergency-dispatch-agent/shared.ts +51 -88
- package/dist/templates/emergency-dispatch-agent/tools/incident_add_note.ts +11 -17
- package/dist/templates/emergency-dispatch-agent/tools/incident_create.ts +21 -30
- package/dist/templates/emergency-dispatch-agent/tools/incident_escalate.ts +60 -63
- package/dist/templates/emergency-dispatch-agent/tools/incident_get.ts +6 -15
- package/dist/templates/emergency-dispatch-agent/tools/incident_triage.ts +40 -53
- package/dist/templates/emergency-dispatch-agent/tools/incident_update_status.ts +41 -47
- package/dist/templates/emergency-dispatch-agent/tools/ops_dashboard.ts +2 -2
- package/dist/templates/emergency-dispatch-agent/tools/ops_protocols.ts +1 -1
- package/dist/templates/emergency-dispatch-agent/tools/ops_run_scenario.ts +13 -10
- package/dist/templates/emergency-dispatch-agent/tools/resources_dispatch.ts +42 -51
- package/dist/templates/emergency-dispatch-agent/tools/resources_update_status.ts +40 -41
- package/dist/templates/entertainment-picks-agent/agent.eval.test.ts +14 -42
- package/dist/templates/entertainment-picks-agent/agent.test.ts +174 -221
- package/dist/templates/entertainment-picks-agent/agent.ts +1 -6
- package/dist/templates/entertainment-picks-agent/client.tsx +1 -12
- package/dist/templates/entertainment-picks-agent/shared.ts +12 -6
- package/dist/templates/entertainment-picks-agent/tools/recommend.ts +2 -2
- package/dist/templates/entertainment-picks-agent/tools/revisit.ts +1 -0
- package/dist/templates/executive-inbox-agent/agent.eval.test.ts +15 -22
- package/dist/templates/executive-inbox-agent/agent.test.ts +515 -527
- package/dist/templates/executive-inbox-agent/agent.ts +4 -8
- package/dist/templates/executive-inbox-agent/calendar.test.ts +23 -22
- package/dist/templates/executive-inbox-agent/client.tsx +1 -23
- package/dist/templates/executive-inbox-agent/review.ts +125 -113
- package/dist/templates/executive-inbox-agent/shared.ts +3 -0
- package/dist/templates/executive-inbox-agent/tools/ask_question.ts +6 -6
- package/dist/templates/executive-inbox-agent/tools/draft_reply.ts +16 -18
- package/dist/templates/executive-inbox-agent/tools/inbox_status.ts +1 -0
- package/dist/templates/executive-inbox-agent/tools/meeting_assistant.ts +20 -20
- package/dist/templates/executive-inbox-agent/tools/new_email.ts +17 -21
- package/dist/templates/executive-inbox-agent/tools/open_email.ts +72 -74
- package/dist/templates/executive-inbox-agent/tools/review_memory.ts +1 -0
- package/dist/templates/executive-inbox-agent/tools/send_calendar_invite.ts +19 -20
- package/dist/templates/executive-inbox-agent/tools/triage_inbox.ts +53 -50
- package/dist/templates/front-desk-agent/agent.eval.test.ts +22 -14
- package/dist/templates/front-desk-agent/agent.test.ts +139 -125
- package/dist/templates/front-desk-agent/agent.ts +4 -7
- package/dist/templates/front-desk-agent/shared.ts +88 -74
- package/dist/templates/front-door-agent/agent.eval.test.ts +61 -0
- package/dist/templates/front-door-agent/agent.test.ts +393 -0
- package/dist/templates/front-door-agent/agent.ts +35 -0
- package/dist/templates/front-door-agent/client.tsx +250 -0
- package/dist/templates/front-door-agent/routes.ts +91 -0
- package/dist/templates/front-door-agent/shared.ts +35 -0
- package/dist/templates/front-door-agent/system-prompt.md +12 -0
- package/dist/templates/front-door-agent/tools/leave_message.ts +39 -0
- package/dist/templates/front-door-agent/tools/link_phone.ts +49 -0
- package/dist/templates/front-door-agent/workflows/announce.ts +38 -0
- package/dist/templates/front-door-agent/workflows/digest.ts +53 -0
- package/dist/templates/front-door-agent/workflows/pair.ts +28 -0
- package/dist/templates/home-assistant-agent/agent.eval.test.ts +5 -9
- package/dist/templates/home-assistant-agent/agent.test.ts +513 -399
- package/dist/templates/home-assistant-agent/agent.ts +8 -5
- package/dist/templates/home-assistant-agent/client.tsx +50 -18
- package/dist/templates/home-assistant-agent/tools/cancel_reminders.ts +1 -0
- package/dist/templates/home-assistant-agent/tools/remind_me.ts +2 -1
- package/dist/templates/hotel-reception-agent/agent.eval.test.ts +27 -52
- package/dist/templates/hotel-reception-agent/agent.test.ts +980 -964
- package/dist/templates/hotel-reception-agent/agent.ts +8 -21
- package/dist/templates/hotel-reception-agent/booking.ts +2 -2
- package/dist/templates/hotel-reception-agent/client.tsx +5 -20
- package/dist/templates/hotel-reception-agent/concierge.ts +2 -0
- package/dist/templates/hotel-reception-agent/desk-seams.test.ts +285 -275
- package/dist/templates/hotel-reception-agent/desk.ts +45 -12
- package/dist/templates/hotel-reception-agent/hotel.ts +6 -6
- package/dist/templates/hotel-reception-agent/restaurant.ts +3 -4
- package/dist/templates/hotel-reception-agent/session.ts +14 -30
- package/dist/templates/hotel-reception-agent/shared.ts +33 -46
- package/dist/templates/hotel-reception-agent/tools/abandon_booking.ts +14 -15
- package/dist/templates/hotel-reception-agent/tools/add_to_waitlist.ts +1 -0
- package/dist/templates/hotel-reception-agent/tools/book_airport_car.ts +1 -0
- package/dist/templates/hotel-reception-agent/tools/cancel_restaurant_reservation.ts +2 -2
- package/dist/templates/hotel-reception-agent/tools/cancel_room_booking.ts +13 -10
- package/dist/templates/hotel-reception-agent/tools/choose_room.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/confirm_booking.ts +6 -7
- package/dist/templates/hotel-reception-agent/tools/dispatch_emergency.ts +1 -0
- package/dist/templates/hotel-reception-agent/tools/dispute_charge.ts +5 -4
- package/dist/templates/hotel-reception-agent/tools/flag_late_arrival.ts +6 -5
- package/dist/templates/hotel-reception-agent/tools/lookup_booking.ts +3 -4
- package/dist/templates/hotel-reception-agent/tools/lookup_invoice.ts +4 -4
- package/dist/templates/hotel-reception-agent/tools/modify_restaurant_reservation.ts +1 -0
- package/dist/templates/hotel-reception-agent/tools/record_card.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/record_followup.ts +1 -0
- package/dist/templates/hotel-reception-agent/tools/record_group_inquiry.ts +1 -0
- package/dist/templates/hotel-reception-agent/tools/record_guest_details.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/reinstate_booking.ts +1 -0
- package/dist/templates/hotel-reception-agent/tools/request_flight_reconfirmation.ts +1 -0
- package/dist/templates/hotel-reception-agent/tools/resend_confirmation.ts +4 -4
- package/dist/templates/hotel-reception-agent/tools/reserve_table.ts +1 -0
- package/dist/templates/hotel-reception-agent/tools/resolve_room_conflict.ts +4 -3
- package/dist/templates/hotel-reception-agent/tools/schedule_wakeup_call.ts +1 -0
- package/dist/templates/hotel-reception-agent/tools/set_do_not_disturb.ts +1 -0
- package/dist/templates/hotel-reception-agent/tools/set_extras.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/set_stay.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/start_booking_modification.ts +30 -32
- package/dist/templates/hotel-reception-agent/tools/start_room_booking.ts +22 -25
- package/dist/templates/hotel-reception-agent/tools/take_guest_message.ts +1 -0
- package/dist/templates/hotel-reception-agent/tools/update_card.ts +5 -4
- package/dist/templates/hotel-reception-agent/tools/verify_booking.ts +23 -13
- package/dist/templates/kitchen-coach-agent/agent.eval.test.ts +38 -0
- package/dist/templates/kitchen-coach-agent/agent.test.ts +204 -0
- package/dist/templates/kitchen-coach-agent/agent.ts +22 -0
- package/dist/templates/kitchen-coach-agent/client.tsx +232 -0
- package/dist/templates/kitchen-coach-agent/history.ts +37 -0
- package/dist/templates/kitchen-coach-agent/shared.ts +131 -0
- package/dist/templates/kitchen-coach-agent/system-prompt.md +17 -0
- package/dist/templates/kitchen-coach-agent/tools/get_kitchen.ts +17 -0
- package/dist/templates/kitchen-coach-agent/tools/scale_amount.ts +31 -0
- package/dist/templates/kitchen-coach-agent/tools/start_timer.ts +24 -0
- package/dist/templates/link-digest-workflow/agent.eval.test.ts +16 -40
- package/dist/templates/link-digest-workflow/agent.test.ts +84 -164
- package/dist/templates/link-digest-workflow/agent.ts +27 -42
- package/dist/templates/link-digest-workflow/api-client.ts +3 -2
- package/dist/templates/link-digest-workflow/client.tsx +5 -5
- package/dist/templates/link-digest-workflow/workflows/digest.ts +53 -95
- package/dist/templates/medication-safety-agent/agent.eval.test.ts +10 -30
- package/dist/templates/medication-safety-agent/agent.test.ts +16 -46
- package/dist/templates/medication-safety-agent/agent.ts +1 -4
- package/dist/templates/medication-safety-agent/tools/check_drug_interaction.ts +13 -10
- package/dist/templates/meeting-recap-agent/agent.eval.test.ts +238 -396
- package/dist/templates/meeting-recap-agent/agent.test.ts +414 -1073
- package/dist/templates/meeting-recap-agent/agent.ts +26 -67
- package/dist/templates/meeting-recap-agent/system-prompt.md +1 -0
- package/dist/templates/meeting-recap-agent/tools/keep_transcript.ts +10 -12
- package/dist/templates/meeting-recap-agent/tools/request_recap.ts +9 -20
- package/dist/templates/meeting-recap-agent/workflows/recap.ts +224 -547
- package/dist/templates/outbound-call-agent/agent.eval.test.ts +10 -12
- package/dist/templates/outbound-call-agent/agent.test.ts +419 -453
- package/dist/templates/outbound-call-agent/agent.ts +57 -62
- package/dist/templates/outbound-call-agent/api.ts +53 -68
- package/dist/templates/outbound-call-agent/client.tsx +105 -176
- package/dist/templates/outbound-call-agent/shared.ts +10 -39
- package/dist/templates/outbound-call-agent/system-prompt.md +3 -4
- package/dist/templates/outbound-call-agent/tools/end_call.ts +15 -12
- package/dist/templates/outbound-call-agent/tools/press_keys.ts +8 -13
- package/dist/templates/outbound-call-agent/workflows/call.ts +94 -63
- package/dist/templates/pizza-ordering-agent/agent.eval.test.ts +18 -54
- package/dist/templates/pizza-ordering-agent/agent.test.ts +205 -244
- package/dist/templates/pizza-ordering-agent/agent.ts +5 -12
- package/dist/templates/pizza-ordering-agent/client.tsx +3 -14
- package/dist/templates/pizza-ordering-agent/shared.ts +31 -36
- package/dist/templates/pizza-ordering-agent/tools/add_pizza.ts +1 -0
- package/dist/templates/pizza-ordering-agent/tools/place_order.ts +5 -2
- package/dist/templates/pizza-ordering-agent/tools/remove_pizza.ts +1 -0
- package/dist/templates/pizza-ordering-agent/tools/update_pizza.ts +2 -3
- package/dist/templates/pizza-ordering-agent/tools/view_order.ts +7 -3
- package/dist/templates/podcast-digest-workflow/agent.test.ts +53 -102
- package/dist/templates/podcast-digest-workflow/agent.ts +11 -17
- package/dist/templates/podcast-digest-workflow/client.tsx +29 -51
- package/dist/templates/podcast-digest-workflow/workflows/digest.ts +24 -26
- package/dist/templates/push-to-talk-agent/agent.eval.test.ts +13 -14
- package/dist/templates/push-to-talk-agent/agent.test.ts +30 -23
- package/dist/templates/push-to-talk-agent/agent.ts +1 -5
- package/dist/templates/push-to-talk-agent/client.tsx +1 -11
- package/dist/templates/push-to-talk-agent/shared.ts +12 -6
- package/dist/templates/push-to-talk-agent/tools/list_notes.ts +1 -0
- package/dist/templates/push-to-talk-agent/tools/save_note.ts +1 -0
- package/dist/templates/quickstart-agent/agent.eval.test.ts +0 -10
- package/dist/templates/quickstart-agent/agent.test.ts +18 -30
- package/dist/templates/quickstart-agent/agent.ts +3 -4
- package/dist/templates/research-handoff-agent/agent.eval.test.ts +161 -290
- package/dist/templates/research-handoff-agent/agent.test.ts +133 -471
- package/dist/templates/research-handoff-agent/agent.ts +26 -86
- package/dist/templates/research-handoff-agent/system-prompt.md +1 -0
- package/dist/templates/research-handoff-agent/tools/file_it_now.ts +8 -21
- package/dist/templates/research-handoff-agent/tools/request_research.ts +7 -16
- package/dist/templates/research-handoff-agent/workflows/research.ts +88 -40
- package/dist/templates/research-planner-agent/agent.eval.test.ts +15 -40
- package/dist/templates/research-planner-agent/agent.test.ts +415 -464
- package/dist/templates/research-planner-agent/agent.ts +3 -8
- package/dist/templates/research-planner-agent/client.tsx +1 -14
- package/dist/templates/research-planner-agent/procedure.ts +9 -3
- package/dist/templates/research-planner-agent/shared.ts +30 -33
- package/dist/templates/research-planner-agent/tools/plan_status.ts +7 -15
- package/dist/templates/research-planner-agent/tools/revise_plan.ts +29 -36
- package/dist/templates/research-planner-agent/tools/start_plan.ts +25 -39
- package/dist/templates/research-planner-agent/tools/work_next_step.ts +25 -42
- package/dist/templates/retail-orders-agent/agent.eval.test.ts +14 -34
- package/dist/templates/retail-orders-agent/agent.test.ts +1079 -1073
- package/dist/templates/retail-orders-agent/agent.ts +25 -78
- package/dist/templates/retail-orders-agent/client.tsx +120 -168
- package/dist/templates/retail-orders-agent/pending.test.ts +7 -14
- package/dist/templates/retail-orders-agent/registry.test.ts +93 -192
- package/dist/templates/retail-orders-agent/shared.test.ts +1 -1
- package/dist/templates/retail-orders-agent/shared.ts +10 -20
- package/dist/templates/retail-orders-agent/store.test.ts +46 -128
- package/dist/templates/retail-orders-agent/store.ts +42 -175
- package/dist/templates/retail-orders-agent/tools/cancel_change.ts +3 -6
- package/dist/templates/retail-orders-agent/tools/cancel_pending_order.ts +3 -4
- package/dist/templates/retail-orders-agent/tools/confirm_change.ts +4 -6
- package/dist/templates/retail-orders-agent/tools/exchange_delivered_order_items.ts +3 -4
- package/dist/templates/retail-orders-agent/tools/find_user_id_by_email.ts +3 -4
- package/dist/templates/retail-orders-agent/tools/find_user_id_by_name_zip.ts +3 -4
- package/dist/templates/retail-orders-agent/tools/get_item_details.ts +3 -4
- package/dist/templates/retail-orders-agent/tools/get_order_details.ts +3 -4
- package/dist/templates/retail-orders-agent/tools/get_product_details.ts +3 -4
- package/dist/templates/retail-orders-agent/tools/get_user_details.ts +3 -4
- package/dist/templates/retail-orders-agent/tools/list_all_product_types.ts +3 -8
- package/dist/templates/retail-orders-agent/tools/modify_pending_order_address.ts +3 -4
- package/dist/templates/retail-orders-agent/tools/modify_pending_order_items.ts +3 -4
- package/dist/templates/retail-orders-agent/tools/modify_pending_order_payment.ts +3 -4
- package/dist/templates/retail-orders-agent/tools/modify_user_address.ts +3 -4
- package/dist/templates/retail-orders-agent/tools/return_delivered_order_items.ts +3 -4
- package/dist/templates/retail-orders-agent/tools/transfer_to_human_agents.ts +3 -4
- package/dist/templates/roadside-assistance-agent/agent.eval.test.ts +22 -25
- package/dist/templates/roadside-assistance-agent/agent.test.ts +453 -490
- package/dist/templates/roadside-assistance-agent/agent.ts +28 -60
- package/dist/templates/roadside-assistance-agent/call.ts +16 -22
- package/dist/templates/roadside-assistance-agent/shared.ts +24 -54
- package/dist/templates/roadside-assistance-agent/tools/acknowledge_disclosure.ts +29 -37
- package/dist/templates/roadside-assistance-agent/tools/dispatch_truck.ts +44 -70
- package/dist/templates/roadside-assistance-agent/tools/job_status.ts +16 -24
- package/dist/templates/roadside-assistance-agent/tools/lookup_coverage.ts +39 -51
- package/dist/templates/roadside-assistance-agent/tools/report_location.ts +34 -33
- package/dist/templates/roadside-assistance-agent/tools/service_disclosure.ts +18 -39
- package/dist/templates/roadside-assistance-agent/yard.test.ts +22 -19
- package/dist/templates/roadside-assistance-agent/yard.ts +3 -3
- package/dist/templates/spoken-summary-workflow/agent.eval.test.ts +38 -40
- package/dist/templates/spoken-summary-workflow/agent.test.ts +129 -279
- package/dist/templates/spoken-summary-workflow/agent.ts +15 -40
- package/dist/templates/spoken-summary-workflow/client.tsx +13 -25
- package/dist/templates/spoken-summary-workflow/workflows/summarize.ts +52 -92
- package/dist/templates/tabletop-rpg-agent/agent.eval.test.ts +31 -74
- package/dist/templates/tabletop-rpg-agent/agent.test.ts +756 -774
- package/dist/templates/tabletop-rpg-agent/agent.ts +9 -46
- package/dist/templates/tabletop-rpg-agent/client.tsx +13 -21
- package/dist/templates/tabletop-rpg-agent/shared.ts +40 -99
- package/dist/templates/tabletop-rpg-agent/tools/action_roll.ts +67 -83
- package/dist/templates/tabletop-rpg-agent/tools/burn_momentum.ts +65 -88
- package/dist/templates/tabletop-rpg-agent/tools/check_state.ts +8 -27
- package/dist/templates/tabletop-rpg-agent/tools/setup_character.ts +18 -36
- package/dist/templates/tabletop-rpg-agent/tools/update_state.ts +101 -111
- package/dist/templates/technical-support-agent/agent.eval.test.ts +31 -72
- package/dist/templates/technical-support-agent/agent.test.ts +231 -260
- package/dist/templates/technical-support-agent/agent.ts +4 -10
- package/dist/templates/technical-support-agent/client.tsx +4 -18
- package/dist/templates/technical-support-agent/shared.ts +15 -25
- package/dist/templates/technical-support-agent/tools/answer_question.ts +46 -56
- package/dist/templates/technical-support-agent/tools/list_topics.ts +1 -0
- package/dist/templates/technical-support-agent/tools/log_ticket.ts +8 -5
- package/dist/templates/text-adventure-agent/agent.eval.test.ts +37 -126
- package/dist/templates/text-adventure-agent/agent.test.ts +197 -368
- package/dist/templates/text-adventure-agent/agent.ts +15 -65
- package/dist/templates/text-adventure-agent/client.tsx +38 -98
- package/dist/templates/text-adventure-agent/shared.ts +31 -143
- package/dist/templates/text-adventure-agent/tools/game_state_drop.ts +6 -12
- package/dist/templates/text-adventure-agent/tools/game_state_get.ts +4 -11
- package/dist/templates/text-adventure-agent/tools/game_state_move.ts +0 -2
- package/dist/templates/text-adventure-agent/tools/game_state_restart.ts +1 -3
- package/dist/templates/text-adventure-agent/tools/game_state_score.ts +5 -7
- package/dist/templates/topic-briefing-agent/agent.eval.test.ts +12 -50
- package/dist/templates/topic-briefing-agent/agent.test.ts +478 -476
- package/dist/templates/topic-briefing-agent/agent.ts +3 -3
- package/dist/templates/topic-briefing-agent/shared.ts +11 -16
- package/dist/templates/topic-briefing-agent/slack.ts +12 -4
- package/dist/templates/topic-briefing-agent/tools/briefing_so_far.ts +10 -17
- package/dist/templates/topic-briefing-agent/tools/research_topic.ts +21 -24
- package/dist/templates/topic-briefing-agent/tools/send_briefing.ts +13 -14
- package/dist/templates/topic-briefing-agent/tools/verify_claim.ts +16 -13
- package/dist/templates/transcription-workflow/agent.test.ts +114 -259
- package/dist/templates/transcription-workflow/agent.ts +6 -9
- package/dist/templates/transcription-workflow/client.tsx +100 -258
- package/dist/templates/transcription-workflow/recover.test.ts +6 -136
- package/dist/templates/transcription-workflow/recover.ts +14 -97
- package/dist/templates/transcription-workflow/run-panel.tsx +71 -8
- package/dist/templates/transcription-workflow/workflows/batch.ts +28 -159
- package/dist/templates/transcription-workflow/workflows/normalize.ts +50 -86
- package/dist/templates/transcription-workflow/workflows/stream.ts +2 -2
- package/dist/templates/transcription-workflow/workflows/transcribe.ts +16 -23
- package/dist/templates/travel-concierge-agent/agent.eval.test.ts +7 -25
- package/dist/templates/travel-concierge-agent/agent.test.ts +505 -517
- package/dist/templates/travel-concierge-agent/agent.ts +22 -46
- package/dist/templates/travel-concierge-agent/client.tsx +1 -22
- package/dist/templates/travel-concierge-agent/routing.ts +29 -31
- package/dist/templates/travel-concierge-agent/shared.ts +63 -152
- package/dist/templates/travel-concierge-agent/tools/book_car_rental.ts +8 -9
- package/dist/templates/travel-concierge-agent/tools/book_excursion.ts +8 -8
- package/dist/templates/travel-concierge-agent/tools/book_hotel.ts +9 -6
- package/dist/templates/travel-concierge-agent/tools/cancel_ticket.ts +10 -10
- package/dist/templates/travel-concierge-agent/tools/search_car_rentals.ts +3 -2
- package/dist/templates/travel-concierge-agent/tools/search_excursions.ts +3 -2
- package/dist/templates/travel-concierge-agent/tools/search_flights.ts +4 -3
- package/dist/templates/travel-concierge-agent/tools/search_hotels.ts +3 -2
- package/dist/templates/travel-concierge-agent/tools/update_ticket.ts +13 -8
- package/dist/templates/web-research-agent/agent.test.ts +21 -32
- package/dist/templates/web-research-agent/agent.ts +3 -4
- package/dist/templates/word-game-agent/agent.eval.test.ts +47 -67
- package/dist/templates/word-game-agent/agent.test.ts +369 -382
- package/dist/templates/word-game-agent/agent.ts +2 -5
- package/dist/templates/word-game-agent/client.tsx +1 -8
- package/dist/templates/word-game-agent/game.ts +15 -27
- package/dist/templates/word-game-agent/shared.ts +36 -20
- package/dist/templates/word-game-agent/tools/final_score.ts +14 -13
- package/dist/templates/word-game-agent/tools/relay_description.ts +90 -66
- package/dist/templates/word-game-agent/tools/repeat_word.ts +11 -10
- package/dist/templates/word-game-agent/tools/skip_word.ts +17 -21
- package/dist/templates/word-game-agent/tools/start_game.ts +26 -30
- package/dist/{test-XufelYGW.mjs → test-CW5cw5fy.mjs} +3 -4
- package/dist/typecheck.mjs +1 -1
- package/dist/worker-bundler-D8uCzpYP.mjs +335 -0
- package/dist/worker-bundler.d.ts +39 -0
- package/dist/worker-bundler.mjs +2 -155
- package/dist/{workflow-CDUlTD5B.mjs → workflow-5gOZMB2M.mjs} +66 -19
- package/package.json +4 -4
- package/dist/_output-DBP9Op_d.mjs +0 -120
- package/dist/_studio-B5m4jBTD.mjs +0 -256
- package/dist/_ui-Coe0zwmm.mjs +0 -102
- package/dist/_utils-BVLdBvdT.mjs +0 -186
- package/dist/delete-DwXCHzTl.mjs +0 -55
- package/dist/templates/document-redline-workflow/form.ts +0 -74
- package/dist/templates/emergency-dispatch-agent/events.ts +0 -48
- package/dist/templates/hotel-reception-agent/events.ts +0 -80
- package/dist/templates/meeting-recap-agent/shared.ts +0 -44
- package/dist/templates/meeting-recap-agent/tools/cancel_recap.ts +0 -25
- package/dist/templates/meeting-recap-agent/tools/recap_progress.ts +0 -24
- package/dist/templates/meeting-recap-agent/tools/recap_status.ts +0 -45
- package/dist/templates/meeting-recap-agent/workflows/tokens.ts +0 -47
- package/dist/templates/outbound-call-agent/call-params.ts +0 -109
- package/dist/templates/outbound-call-agent/live-calls.ts +0 -80
- package/dist/templates/outbound-call-agent/workflows/tokens.ts +0 -16
- package/dist/templates/research-handoff-agent/shared.ts +0 -41
- package/dist/templates/research-handoff-agent/tools/research_progress.ts +0 -23
- package/dist/templates/research-handoff-agent/tools/research_status.ts +0 -73
- package/dist/templates/research-handoff-agent/workflows/review.ts +0 -43
- package/dist/templates/roadside-assistance-agent/events.ts +0 -92
- package/dist/templates/spoken-summary-workflow/workflows/transcribe.ts +0 -137
- package/dist/templates/transcription-workflow/total-latency.tsx +0 -170
- package/dist/templates/travel-concierge-agent/call-events.ts +0 -80
|
@@ -1,15 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
import { c as fileExists, s as errorMessage$1 } from "./_utils-BVLdBvdT.mjs";
|
|
4
|
-
import { n as withPreservedNodeEnv, r as devSourceViteConfig, t as DEDUPED_PEERS } from "./_vite-env-BiyJ0GQH.mjs";
|
|
2
|
+
import { C as CliError } from "./_utils-ChU85MEg.mjs";
|
|
5
3
|
import { createRequire } from "node:module";
|
|
6
|
-
import { existsSync
|
|
4
|
+
import { existsSync } from "node:fs";
|
|
7
5
|
import path from "node:path";
|
|
8
6
|
import { pathToFileURL } from "node:url";
|
|
9
|
-
import { omitUndefined } from "@alexkroman1/aai/utils";
|
|
10
|
-
import fs from "node:fs/promises";
|
|
11
|
-
import { isTextAssetPath, requestPath } from "@alexkroman1/aai/internal";
|
|
12
|
-
import { build, mergeConfig } from "vite";
|
|
13
7
|
//#region src/_client-plugins.ts
|
|
14
8
|
/**
|
|
15
9
|
* The client build's default Vite plugins, for a project with no
|
|
@@ -67,6 +61,32 @@ const CLIENT_PLUGIN_PACKAGES = {
|
|
|
67
61
|
react: "@vitejs/plugin-react",
|
|
68
62
|
tailwind: "@tailwindcss/vite"
|
|
69
63
|
};
|
|
64
|
+
/**
|
|
65
|
+
* Everything a `client.tsx` needs that a headless project does not, by the
|
|
66
|
+
* manifest field the scaffold declares it under: `aai init` removes all of
|
|
67
|
+
* these from a project with no `client.tsx` (`stripClientDependencies`,
|
|
68
|
+
* `_init.ts`), and the `client_plugins_missing` hint names them all — it used
|
|
69
|
+
* to name the two plugins only, and an author who installed exactly those then
|
|
70
|
+
* met a raw "failed to resolve `@alexkroman1/aai-ui/styles.css`".
|
|
71
|
+
*
|
|
72
|
+
* `vite` itself is NOT here: it is the test runner's base and the source of the
|
|
73
|
+
* `vite/client` types `@alexkroman1/aai/tsconfig` names, so a headless project
|
|
74
|
+
* needs it too.
|
|
75
|
+
*/
|
|
76
|
+
const CLIENT_ONLY_DEPENDENCIES = {
|
|
77
|
+
dependencies: [
|
|
78
|
+
"@alexkroman1/aai-ui",
|
|
79
|
+
"react",
|
|
80
|
+
"react-dom",
|
|
81
|
+
"tailwindcss"
|
|
82
|
+
],
|
|
83
|
+
devDependencies: [
|
|
84
|
+
CLIENT_PLUGIN_PACKAGES.tailwind,
|
|
85
|
+
"@types/react",
|
|
86
|
+
"@types/react-dom",
|
|
87
|
+
CLIENT_PLUGIN_PACKAGES.react
|
|
88
|
+
]
|
|
89
|
+
};
|
|
70
90
|
/** Whether the project declares its own Vite config (which then wins). */
|
|
71
91
|
function hasViteConfig(cwd) {
|
|
72
92
|
return VITE_CONFIG_FILES.some((name) => existsSync(path.join(cwd, name)));
|
|
@@ -111,131 +131,9 @@ async function defaultClientPlugins(cwd) {
|
|
|
111
131
|
const [react, tailwind] = await Promise.all([loadFactory(cwd, CLIENT_PLUGIN_PACKAGES.react), loadFactory(cwd, CLIENT_PLUGIN_PACKAGES.tailwind)]);
|
|
112
132
|
if (react === void 0 || tailwind === void 0) {
|
|
113
133
|
const missing = [...react === void 0 ? [CLIENT_PLUGIN_PACKAGES.react] : [], ...tailwind === void 0 ? [CLIENT_PLUGIN_PACKAGES.tailwind] : []];
|
|
114
|
-
throw new CliError("client_plugins_missing", `client.tsx needs ${missing.join(" and ")} to build, and ${cwd} does not have ${missing.length === 1 ? "it" : "them"}.`, `Install ${missing.length === 1 ? "it" : "them"} as a devDependency (\`npm i -D ${missing.join(" ")}\`), or add a vite.config.ts that declares the plugins you want
|
|
134
|
+
throw new CliError("client_plugins_missing", `client.tsx needs ${missing.join(" and ")} to build, and ${cwd} does not have ${missing.length === 1 ? "it" : "them"}.`, `Install ${missing.length === 1 ? "it" : "them"} as a devDependency (\`npm i -D ${missing.join(" ")}\`), or add a vite.config.ts that declares the plugins you want. A project scaffolded without a client.tsx had every client-only package removed, and a client.tsx needs them all: \`npm i ${CLIENT_ONLY_DEPENDENCIES.dependencies.join(" ")}\` and \`npm i -D ${CLIENT_ONLY_DEPENDENCIES.devDependencies.join(" ")}\`.`);
|
|
115
135
|
}
|
|
116
136
|
return [react({ exclude: REACT_REFRESH_EXCLUDE }), tailwind()];
|
|
117
137
|
}
|
|
118
138
|
//#endregion
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Default index.html for agents with a custom client.tsx but no index.html.
|
|
122
|
-
* Used by both the dev server (Vite HMR) and the production bundler.
|
|
123
|
-
* Users can override by placing their own index.html in the project root.
|
|
124
|
-
*/
|
|
125
|
-
const DEFAULT_HTML = `<!DOCTYPE html>
|
|
126
|
-
<html lang="en">
|
|
127
|
-
<head>
|
|
128
|
-
<meta charset="UTF-8" />
|
|
129
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
|
|
130
|
-
<title>aai</title>
|
|
131
|
-
<link rel="icon" href="./favicon.ico" />
|
|
132
|
-
<style>html, body { background: #FAFAFA; margin: 0; }</style>
|
|
133
|
-
</head>
|
|
134
|
-
<body>
|
|
135
|
-
<main id="app"></main>
|
|
136
|
-
<script type="module" src="./client.tsx"><\/script>
|
|
137
|
-
</body>
|
|
138
|
-
</html>`;
|
|
139
|
-
/**
|
|
140
|
-
* Vite plugin that serves a fallback index.html in dev mode when one doesn't
|
|
141
|
-
* exist on disk. No-op if index.html exists (user override).
|
|
142
|
-
*/
|
|
143
|
-
function fallbackHtmlPlugin(root) {
|
|
144
|
-
const htmlExists = existsSync(path.join(root, "index.html"));
|
|
145
|
-
return {
|
|
146
|
-
name: "aai-fallback-html",
|
|
147
|
-
configureServer(server) {
|
|
148
|
-
if (htmlExists) return;
|
|
149
|
-
server.middlewares.use((req, res, next) => {
|
|
150
|
-
const pathname = requestPath(req.url);
|
|
151
|
-
if (pathname === "/" || pathname === "/index.html") {
|
|
152
|
-
server.transformIndexHtml("/", DEFAULT_HTML, req.originalUrl).then((html) => {
|
|
153
|
-
res.setHeader("Content-Type", "text/html");
|
|
154
|
-
res.end(html);
|
|
155
|
-
}).catch(next);
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
next();
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* Write a temporary index.html for Vite build (HTML must be on disk for build).
|
|
165
|
-
* Returns a cleanup function to remove it. No-op if index.html already exists.
|
|
166
|
-
*/
|
|
167
|
-
function writeTempHtml(root) {
|
|
168
|
-
const htmlPath = path.join(root, "index.html");
|
|
169
|
-
if (existsSync(htmlPath)) return () => {};
|
|
170
|
-
const cleanup = () => {
|
|
171
|
-
try {
|
|
172
|
-
unlinkSync(htmlPath);
|
|
173
|
-
} catch {}
|
|
174
|
-
};
|
|
175
|
-
try {
|
|
176
|
-
writeFileSync(htmlPath, DEFAULT_HTML);
|
|
177
|
-
} catch (err) {
|
|
178
|
-
cleanup();
|
|
179
|
-
throw new Error(`Failed to write a temporary index.html at ${htmlPath} for the client build — is the project directory writable? (${errorMessage$1(err)})`, { cause: err });
|
|
180
|
-
}
|
|
181
|
-
return cleanup;
|
|
182
|
-
}
|
|
183
|
-
//#endregion
|
|
184
|
-
//#region src/client-bundler.ts
|
|
185
|
-
const DEFAULT_OUT_DIR = ".aai/client";
|
|
186
|
-
/**
|
|
187
|
-
* Build the client SPA with Vite if `client.tsx` exists.
|
|
188
|
-
* Returns a map of relative file paths to string contents for deploy,
|
|
189
|
-
* or `{}` when the project has no `client.tsx`.
|
|
190
|
-
*
|
|
191
|
-
* @internal — build hook for aai-server/the studio; not a supported public
|
|
192
|
-
* API and not covered by semver.
|
|
193
|
-
*/
|
|
194
|
-
async function buildClient(cwd, options = {}) {
|
|
195
|
-
const clientEntry = path.join(cwd, "client.tsx");
|
|
196
|
-
if (!await fileExists(clientEntry)) return {};
|
|
197
|
-
const plugins = options.plugins ?? (options.configFile === false ? void 0 : await defaultClientPlugins(cwd));
|
|
198
|
-
const outDir = options.outDir ?? DEFAULT_OUT_DIR;
|
|
199
|
-
const viteBuild = options.viteBuild ?? build;
|
|
200
|
-
const clientDir = path.join(cwd, outDir);
|
|
201
|
-
let cleanupHtml = () => {};
|
|
202
|
-
try {
|
|
203
|
-
cleanupHtml = writeTempHtml(cwd);
|
|
204
|
-
await withPreservedNodeEnv(() => viteBuild(mergeConfig(devSourceViteConfig(), {
|
|
205
|
-
root: cwd,
|
|
206
|
-
base: "./",
|
|
207
|
-
logLevel: "silent",
|
|
208
|
-
...options.configFile === false && { configFile: false },
|
|
209
|
-
...omitUndefined({ plugins }),
|
|
210
|
-
resolve: { dedupe: DEDUPED_PEERS },
|
|
211
|
-
build: {
|
|
212
|
-
outDir,
|
|
213
|
-
emptyOutDir: true
|
|
214
|
-
}
|
|
215
|
-
})));
|
|
216
|
-
} finally {
|
|
217
|
-
cleanupHtml();
|
|
218
|
-
}
|
|
219
|
-
return readClientDir(clientDir);
|
|
220
|
-
}
|
|
221
|
-
/** Read a built client directory into an in-memory deploy payload. */
|
|
222
|
-
async function readClientDir(clientDir) {
|
|
223
|
-
const files = {};
|
|
224
|
-
let entries;
|
|
225
|
-
try {
|
|
226
|
-
entries = await fs.readdir(clientDir, {
|
|
227
|
-
recursive: true,
|
|
228
|
-
withFileTypes: true
|
|
229
|
-
});
|
|
230
|
-
} catch (err) {
|
|
231
|
-
throw new Error(`Client build produced no output at ${clientDir}: ${errorMessage$1(err)}`, { cause: err });
|
|
232
|
-
}
|
|
233
|
-
await Promise.all(entries.filter((entry) => entry.isFile()).map(async (entry) => {
|
|
234
|
-
const abs = path.join(entry.parentPath, entry.name);
|
|
235
|
-
const rel = path.relative(clientDir, abs).split(path.sep).join("/");
|
|
236
|
-
files[rel] = isTextAssetPath(rel) ? await fs.readFile(abs, "utf-8") : (await fs.readFile(abs)).toString("base64");
|
|
237
|
-
}));
|
|
238
|
-
return files;
|
|
239
|
-
}
|
|
240
|
-
//#endregion
|
|
241
|
-
export { fallbackHtmlPlugin as n, defaultClientPlugins as r, buildClient as t };
|
|
139
|
+
export { defaultClientPlugins as n, CLIENT_ONLY_DEPENDENCIES as t };
|
|
@@ -44,6 +44,22 @@ export declare const CLIENT_PLUGIN_PACKAGES: {
|
|
|
44
44
|
readonly react: "@vitejs/plugin-react";
|
|
45
45
|
readonly tailwind: "@tailwindcss/vite";
|
|
46
46
|
};
|
|
47
|
+
/**
|
|
48
|
+
* Everything a `client.tsx` needs that a headless project does not, by the
|
|
49
|
+
* manifest field the scaffold declares it under: `aai init` removes all of
|
|
50
|
+
* these from a project with no `client.tsx` (`stripClientDependencies`,
|
|
51
|
+
* `_init.ts`), and the `client_plugins_missing` hint names them all — it used
|
|
52
|
+
* to name the two plugins only, and an author who installed exactly those then
|
|
53
|
+
* met a raw "failed to resolve `@alexkroman1/aai-ui/styles.css`".
|
|
54
|
+
*
|
|
55
|
+
* `vite` itself is NOT here: it is the test runner's base and the source of the
|
|
56
|
+
* `vite/client` types `@alexkroman1/aai/tsconfig` names, so a headless project
|
|
57
|
+
* needs it too.
|
|
58
|
+
*/
|
|
59
|
+
export declare const CLIENT_ONLY_DEPENDENCIES: {
|
|
60
|
+
readonly dependencies: readonly ["@alexkroman1/aai-ui", "react", "react-dom", "tailwindcss"];
|
|
61
|
+
readonly devDependencies: readonly ["@tailwindcss/vite", "@types/react", "@types/react-dom", "@vitejs/plugin-react"];
|
|
62
|
+
};
|
|
47
63
|
/** Whether the project declares its own Vite config (which then wins). */
|
|
48
64
|
export declare function hasViteConfig(cwd: string): boolean;
|
|
49
65
|
/**
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
import { d as readJson, s as errorMessage, u as isEexist, v as writeJson } from "./_utils-BVLdBvdT.mjs";
|
|
2
|
+
import { C as CliError, S as writeJson, m as readJson, s as errorMessage, u as isEexist, v as serverOrigin } from "./_utils-ChU85MEg.mjs";
|
|
4
3
|
import { mkdtempSync } from "node:fs";
|
|
5
4
|
import path from "node:path";
|
|
6
5
|
import fs from "node:fs/promises";
|
|
@@ -92,23 +91,6 @@ async function updateProjectConfig(agentDir, patch) {
|
|
|
92
91
|
await writeProjectConfig(agentDir, merged);
|
|
93
92
|
return merged;
|
|
94
93
|
}
|
|
95
|
-
/**
|
|
96
|
-
* Origin of `url`, or `null` when it is not an absolute http(s) URL.
|
|
97
|
-
*
|
|
98
|
-
* Non-HTTP schemes are rejected rather than returned: `new URL()` yields the
|
|
99
|
-
* opaque origin `"null"` for them, which would otherwise flow on as if it
|
|
100
|
-
* were a real origin.
|
|
101
|
-
*/
|
|
102
|
-
function serverOrigin(url) {
|
|
103
|
-
let parsed;
|
|
104
|
-
try {
|
|
105
|
-
parsed = new URL(url);
|
|
106
|
-
} catch {
|
|
107
|
-
return null;
|
|
108
|
-
}
|
|
109
|
-
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") return null;
|
|
110
|
-
return parsed.origin;
|
|
111
|
-
}
|
|
112
94
|
/** Bounded so a stuck lock degrades to the old racy write, never a hang. */
|
|
113
95
|
const CONFIG_LOCK_TIMEOUT_MS = 2e3;
|
|
114
96
|
const CONFIG_LOCK_RETRY_MS = 20;
|
|
@@ -260,4 +242,4 @@ async function ensureApiKey(configDir, use = "platform") {
|
|
|
260
242
|
throw new CliError("not_logged_in", "You're not logged in.", "Run `aai login` to link your account. Non-interactive setups can point AAI_CONFIG_DIR at a config dir holding a logged-in key.");
|
|
261
243
|
}
|
|
262
244
|
//#endregion
|
|
263
|
-
export {
|
|
245
|
+
export { updateGlobalConfig as a, writeProjectConfig as c, readProjectConfig as i, ensureApiKey as n, updateProjectConfig as o, readGlobalConfig as r, writeGlobalConfig as s, approveServer as t };
|
package/dist/_config.d.ts
CHANGED
|
@@ -46,14 +46,6 @@ export type GlobalConfig = {
|
|
|
46
46
|
*/
|
|
47
47
|
approvedServers?: string[];
|
|
48
48
|
};
|
|
49
|
-
/**
|
|
50
|
-
* Origin of `url`, or `null` when it is not an absolute http(s) URL.
|
|
51
|
-
*
|
|
52
|
-
* Non-HTTP schemes are rejected rather than returned: `new URL()` yields the
|
|
53
|
-
* opaque origin `"null"` for them, which would otherwise flow on as if it
|
|
54
|
-
* were a real origin.
|
|
55
|
-
*/
|
|
56
|
-
export declare function serverOrigin(url: string): string | null;
|
|
57
49
|
/**
|
|
58
50
|
* Apply `update` to the global config under the cross-process lock, re-reading
|
|
59
51
|
* inside it so the merge is against current contents rather than a snapshot
|
|
@@ -1,27 +1,28 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { n as
|
|
2
|
+
import { a as errorCode, s as errorMessage$1 } from "./_utils-ChU85MEg.mjs";
|
|
3
|
+
import { t as defaultUi } from "./_ui-C0RufoYZ.mjs";
|
|
4
|
+
import { n as defaultClientPlugins } from "./_client-plugins-kR43nZnb.mjs";
|
|
5
|
+
import { n as fallbackHtmlPlugin } from "./client-bundler-CImhqcp2.mjs";
|
|
5
6
|
import { r as devSourceViteConfig, t as DEDUPED_PEERS } from "./_vite-env-BiyJ0GQH.mjs";
|
|
6
|
-
import { buildWorker } from "./worker-bundler.mjs";
|
|
7
|
+
import { t as buildWorker } from "./worker-bundler-D8uCzpYP.mjs";
|
|
7
8
|
import { typecheckProject } from "./typecheck.mjs";
|
|
8
|
-
import { n as ensureApiKey } from "./_config-
|
|
9
|
+
import { n as ensureApiKey } from "./_config-Dlh8PRRp.mjs";
|
|
9
10
|
import { t as resolveDenoRunCode } from "./_run-code-deno-C0AtfHeH.mjs";
|
|
10
|
-
import {
|
|
11
|
-
import { n as createWorkerEvaluator } from "./_bundler-
|
|
11
|
+
import { a as resolveServerEnv } from "./_server-common-C6j67AcZ.mjs";
|
|
12
|
+
import { n as createWorkerEvaluator } from "./_bundler-DvZDEu2p.mjs";
|
|
12
13
|
import { i as hostModeEnv, n as devBindHost, r as devWatchEnabled, t as createDevLogger } from "./_dev-env-D9Uy5wNt.mjs";
|
|
13
14
|
import { existsSync, statSync } from "node:fs";
|
|
14
15
|
import path from "node:path";
|
|
15
16
|
import { omitUndefined, plural } from "@alexkroman1/aai/utils";
|
|
16
|
-
import { agentRequiredEnv, createCoalescingRunner, frontDoorOf, parseWsUpgradeParams, requestPath, sleep } from "@alexkroman1/aai/internal";
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
17
|
+
import { agentRequiredEnv, createCoalescingRunner, frontDoorOf, parseWsUpgradeParams, requestPath, sleep, toolUiMap } from "@alexkroman1/aai/internal";
|
|
18
|
+
import { isBlankSecret } from "@alexkroman1/aai/host-internal";
|
|
19
|
+
import { DEFAULT_LISTEN_HOST, createMemoryJournal, createRuntime, createServerForRuntime, ensureSessionStateSchema, ensureWorkflowJournalSchema } from "@alexkroman1/aai-runtime";
|
|
20
|
+
import { SERVER_ROUTES, WORKFLOW_DATA_DIR_ENV, handleWorkflowRequest, isPathInside, publishClientInboxDefaults, publishStepEnv, requiredProviderEnvVars, withHostCredentialFallback } from "@alexkroman1/aai-runtime/internal";
|
|
19
21
|
import { defaultClientDir } from "@alexkroman1/aai-ui/client-dir";
|
|
20
22
|
import { watch } from "chokidar";
|
|
21
23
|
import getPort, { portNumbers } from "get-port";
|
|
22
24
|
import { agentConfigWarnings } from "@alexkroman1/aai/manifest";
|
|
23
25
|
import { assign, createActor, fromPromise, setup, waitFor } from "xstate";
|
|
24
|
-
import { isBlankSecret } from "@alexkroman1/aai/host-internal";
|
|
25
26
|
import { CLIENT_CONFIG_PATH, buildClientConfig } from "@alexkroman1/aai/protocol";
|
|
26
27
|
import { SESSION_SECRET_ENV, createSessionAuth, createSessionToken, verifySessionToken } from "@alexkroman1/aai-runtime/auth";
|
|
27
28
|
import pDebounce from "p-debounce";
|
|
@@ -856,17 +857,21 @@ async function startDevServer(opts, seams = {}) {
|
|
|
856
857
|
};
|
|
857
858
|
const serverEnv = hostModeEnv(providerEnv);
|
|
858
859
|
const page = frontDoorOf(agentDef.mode);
|
|
860
|
+
const tools = toolUiMap(agentDef);
|
|
859
861
|
const ticketing = devSessionTicketing(serverEnv, {
|
|
860
862
|
name: agentDef.name,
|
|
861
863
|
greeting: agentDef.greeting,
|
|
862
|
-
page
|
|
864
|
+
page,
|
|
865
|
+
tools
|
|
863
866
|
});
|
|
864
867
|
return serve(runtimeOptions, (runtime) => ({
|
|
865
868
|
name: agentDef.name,
|
|
866
869
|
env: serverEnv,
|
|
867
870
|
...omitUndefined({ auth: ticketing?.auth }),
|
|
871
|
+
logger: devLogger,
|
|
868
872
|
hostBaseAgent: agentDef,
|
|
869
873
|
greeting: agentDef.greeting,
|
|
874
|
+
tools,
|
|
870
875
|
page,
|
|
871
876
|
...omitUndefined({ telephony: agentDef.telephony }),
|
|
872
877
|
request: (req, res, url, method) => ticketing?.clientConfig(req, res, url, method) ?? handleWorkflowRequest(req, res, url, method, {
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
* with the same secret.
|
|
27
27
|
*/
|
|
28
28
|
import type http from "node:http";
|
|
29
|
+
import type { ToolUi } from "@alexkroman1/aai";
|
|
29
30
|
import { type SessionAuth, type SessionIdentity } from "@alexkroman1/aai-runtime/auth";
|
|
30
31
|
/** The identity every dev-minted ticket names. */
|
|
31
32
|
export declare const DEV_TICKET_SUB = "aai-dev";
|
|
@@ -34,6 +35,8 @@ export type DevClientConfigSource = {
|
|
|
34
35
|
name: string;
|
|
35
36
|
greeting?: string | undefined;
|
|
36
37
|
page?: "voice" | "static" | undefined;
|
|
38
|
+
/** Each tool's declared icon and label — see `ToolDef.ui`. */
|
|
39
|
+
tools?: Record<string, ToolUi> | undefined;
|
|
37
40
|
};
|
|
38
41
|
/** The part of an `http.ServerResponse` the `client-config` answer writes. */
|
|
39
42
|
export type ClientConfigResponse = {
|
package/dist/_dev-tunnel.d.ts
CHANGED
|
@@ -53,7 +53,7 @@ export type SpawnFn = {
|
|
|
53
53
|
(command: string, options: SpawnOptions): TunnelChild;
|
|
54
54
|
};
|
|
55
55
|
/** The part of a `ChildProcess` this module touches — all a fake has to be. */
|
|
56
|
-
export type TunnelChild = Pick<ChildProcess, "stdout" | "stderr" | "exitCode" | "signalCode" | "kill"> & {
|
|
56
|
+
export type TunnelChild = Pick<ChildProcess, "stdout" | "stderr" | "exitCode" | "signalCode" | "kill" | "pid"> & {
|
|
57
57
|
once(event: "exit", listener: (code: number | null) => void): unknown;
|
|
58
58
|
once(event: "error", listener: (err: NodeJS.ErrnoException) => void): unknown;
|
|
59
59
|
};
|
|
@@ -78,13 +78,31 @@ export declare function startQuickTunnel(opts: {
|
|
|
78
78
|
timeoutMs?: number | undefined;
|
|
79
79
|
spawn?: SpawnFn | undefined;
|
|
80
80
|
}): Promise<QuickTunnel>;
|
|
81
|
+
/** How long the startup run of the hook may take before it is stopped. */
|
|
82
|
+
export declare const HOOK_STARTUP_TIMEOUT_MS = 60000;
|
|
83
|
+
/** How long a stopped hook gets between SIGTERM and SIGKILL. */
|
|
84
|
+
export declare const HOOK_KILL_GRACE_MS = 2000;
|
|
85
|
+
/** Signal a process GROUP — the seam a spec replaces to watch the signals. */
|
|
86
|
+
export type KillGroupFn = (pgid: number, signal: NodeJS.Signals) => void;
|
|
81
87
|
/**
|
|
82
88
|
* Run the `--on-public-url` hook through the shell with `PUBLIC_URL` (and its
|
|
83
89
|
* alias `AAI_PUBLIC_URL`) set to `url` — empty on the shutdown run. Resolves
|
|
84
|
-
* with the exit code
|
|
90
|
+
* with the exit code, or `null` when it was stopped — past `timeoutMs`, or on
|
|
91
|
+
* `signal`; output is inherited, so the hook speaks for itself.
|
|
92
|
+
*
|
|
93
|
+
* **The hook is its own process GROUP, and stopping it signals the group**
|
|
94
|
+
* (SIGTERM, then SIGKILL after `killGraceMs`). `shell: true` is `sh -c`, so
|
|
95
|
+
* signalling the child signalled only the shell: a hook that ran
|
|
96
|
+
* `./publish.sh` (or anything not `exec`ed) left its real process running
|
|
97
|
+
* past the timeout and past `aai dev`'s exit. Detached for the same reason —
|
|
98
|
+
* the group must not be the terminal's, whose Ctrl-C would reach the hook
|
|
99
|
+
* before `aai dev` had decided what to do with it.
|
|
85
100
|
*/
|
|
86
101
|
export declare function runPublicUrlHook(command: string, url: string, opts: {
|
|
87
102
|
cwd: string;
|
|
88
103
|
timeoutMs?: number | undefined;
|
|
104
|
+
signal?: AbortSignal | undefined;
|
|
89
105
|
spawn?: SpawnFn | undefined;
|
|
106
|
+
killGroup?: KillGroupFn | undefined;
|
|
107
|
+
killGraceMs?: number | undefined;
|
|
90
108
|
}): Promise<number | null>;
|
package/dist/_dotenv-file.d.ts
CHANGED
|
@@ -15,7 +15,13 @@
|
|
|
15
15
|
* - **An existing assignment is replaced in place**, the LAST one when there
|
|
16
16
|
* are several (the one `parseEnv` honours), with any continuation lines of
|
|
17
17
|
* a multi-line quoted value; the others are left alone.
|
|
18
|
+
* - **Only TOP-LEVEL assignments are matched** — a `KEY=` line inside another
|
|
19
|
+
* key's multi-line quoted value is that value's text, not an assignment.
|
|
18
20
|
* - **A new key is appended.**
|
|
21
|
+
* - **Every edit is checked by the parser**: unless the result parses to the
|
|
22
|
+
* old entries with exactly this one changed, the file is refused untouched.
|
|
23
|
+
* - **A symlinked `.env` is refused**: the atomic rename would replace the
|
|
24
|
+
* link with a regular file holding a copy of its target.
|
|
19
25
|
* - **The file keeps its mode**; a new one is created `0600`, since it exists
|
|
20
26
|
* to hold credentials.
|
|
21
27
|
*/
|
package/dist/_init.d.ts
CHANGED
|
@@ -43,16 +43,6 @@ export type InitOptions = {
|
|
|
43
43
|
};
|
|
44
44
|
/** Rewrite workspace deps to link: paths so pnpm links to local source. */
|
|
45
45
|
export declare function patchPackageJsonForWorkspace(targetDir: string): Promise<void>;
|
|
46
|
-
/**
|
|
47
|
-
* The scaffold's dependencies that exist only to build a `client.tsx`: the UI
|
|
48
|
-
* kit, React, and the two Vite plugins the CLI loads from the project when it
|
|
49
|
-
* has no `vite.config.*` (`_client-plugins.ts`).
|
|
50
|
-
*
|
|
51
|
-
* `vite` itself is NOT here: it is the test runner's base and the source of the
|
|
52
|
-
* `vite/client` types `@alexkroman1/aai/tsconfig` names, so a headless project
|
|
53
|
-
* needs it too.
|
|
54
|
-
*/
|
|
55
|
-
export declare const CLIENT_ONLY_DEPENDENCIES: readonly ["@alexkroman1/aai-ui", "@tailwindcss/vite", "@types/react", "@types/react-dom", "@vitejs/plugin-react", "react", "react-dom", "tailwindcss"];
|
|
56
46
|
/**
|
|
57
47
|
* Drop {@link CLIENT_ONLY_DEPENDENCIES} from a project with no `client.tsx`.
|
|
58
48
|
*
|
|
@@ -60,7 +50,8 @@ export declare const CLIENT_ONLY_DEPENDENCIES: readonly ["@alexkroman1/aai-ui",
|
|
|
60
50
|
* served the prebuilt default UI by the CLI and bundles no React of its own,
|
|
61
51
|
* so installing a UI toolchain it never builds only costs install time and
|
|
62
52
|
* `node_modules`. Adding a `client.tsx` later means adding these back; the
|
|
63
|
-
* CLI's `client_plugins_missing` failure names the
|
|
53
|
+
* CLI's `client_plugins_missing` failure names them all (the list is declared
|
|
54
|
+
* beside that hint, in `_client-plugins.ts`, so the two cannot drift).
|
|
64
55
|
*/
|
|
65
56
|
export declare function stripClientDependencies(targetDir: string): Promise<void>;
|
|
66
57
|
export declare function runInit(opts: InitOptions): Promise<void>;
|
package/dist/_output.d.ts
CHANGED
|
@@ -17,42 +17,69 @@ export declare function getOutputMode(args: {
|
|
|
17
17
|
json?: boolean | undefined;
|
|
18
18
|
}, isTTY?: boolean): OutputMode;
|
|
19
19
|
/**
|
|
20
|
-
*
|
|
20
|
+
* Make text that came from somewhere else safe to put on a terminal.
|
|
21
|
+
*
|
|
22
|
+
* Server- and agent-supplied strings (an `aai list` project name, an error
|
|
23
|
+
* body, a log line) reach the terminal through this CLI, and a raw one can do
|
|
24
|
+
* anything the terminal can: OSC 52 writes the clipboard, `ESC [2J` clears the
|
|
25
|
+
* screen, OSC 8 disguises a link, OSC 0 retitles the window, `ESC c` resets it.
|
|
26
|
+
* So EVERY escape sequence is removed — CSI, OSC, the other string forms and
|
|
27
|
+
* the two-byte ones — except SGR colour when `keepSgr` (our own `styleText`
|
|
28
|
+
* output is SGR), and every other C0/C1 control but `\n` and `\t` is rendered
|
|
29
|
+
* visibly as `\xNN` rather than passed through. `\r\n` becomes `\n`.
|
|
30
|
+
*
|
|
31
|
+
* A hand-written walk rather than a regex: Biome's `noControlCharactersInRegex`
|
|
32
|
+
* refuses the pattern (see `aai-runtime`'s `typed-json-escape.ts` for the same
|
|
33
|
+
* call).
|
|
34
|
+
*/
|
|
35
|
+
export declare function sanitizeTerminalText(text: string, opts: {
|
|
36
|
+
keepSgr: boolean;
|
|
37
|
+
}): string;
|
|
38
|
+
/**
|
|
39
|
+
* {@link sanitizeTerminalText} with colour removed too — for human text that
|
|
40
|
+
* is not headed for a styled terminal (a JSON result's sentences).
|
|
21
41
|
*
|
|
22
42
|
* A bundler colours its own diagnostics unconditionally, so `aai build`'s
|
|
23
43
|
* failure reached the JSON envelope as per-character SGR pairs — illegible in a
|
|
24
44
|
* CI log and meaningless to a `jq` consumer, which is the audience JSON mode
|
|
25
45
|
* has.
|
|
26
|
-
*
|
|
27
|
-
* The raw half is `node:util`'s, not a local CSI regex. A/B'd on Node 26: the
|
|
28
|
-
* two agree on every SGR pair and cursor move the hand-built pattern was
|
|
29
|
-
* written for, and the builtin ALSO strips OSC-8 hyperlinks (`ESC ] 8 ;; url`)
|
|
30
|
-
* and charset selects (`ESC ( B`), which that pattern left in the envelope — so
|
|
31
|
-
* its claim to cover what a diagnostic arrives wearing was the incomplete part.
|
|
32
|
-
* The JSON-escaped half has no builtin and stays.
|
|
33
46
|
*/
|
|
34
47
|
export declare function stripAnsi(text: string): string;
|
|
35
48
|
/**
|
|
36
|
-
*
|
|
37
|
-
* flushed.
|
|
49
|
+
* The JSON result line for `result`, newline-terminated.
|
|
38
50
|
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
51
|
+
* Only the HUMAN-TEXT fields are cleaned (`error`, `hint`, `data.warnings`),
|
|
52
|
+
* by {@link stripAnsi}: they are sentences a `jq -r` prints to a terminal, and
|
|
53
|
+
* a diagnostic or a server's error body can carry colour or an OSC 52. DATA is
|
|
54
|
+
* emitted verbatim (JSON-escaped), since a stripped `dir` would name a
|
|
55
|
+
* directory that does not exist.
|
|
56
|
+
*/
|
|
57
|
+
export declare function resultLine(result: CommandResult<unknown>): string;
|
|
58
|
+
/**
|
|
59
|
+
* Write a machine-readable line to stdout, resolving only once it has been
|
|
60
|
+
* flushed. The line goes out VERBATIM — build it with {@link resultLine},
|
|
61
|
+
* which cleans the human-text fields and leaves data alone.
|
|
44
62
|
*
|
|
45
63
|
* Resolves (never rejects) even when the write fails: the common failure is
|
|
46
|
-
* EPIPE — the consumer closed the pipe (`aai … --json | head -1`) — and
|
|
47
|
-
*
|
|
48
|
-
* Stream-level `'error'` events are handled by {@link installStdoutGuard}.
|
|
64
|
+
* EPIPE — the consumer closed the pipe (`aai … --json | head -1`) — and the
|
|
65
|
+
* exit code owed then is {@link installStdoutGuard}'s to deliver.
|
|
49
66
|
*/
|
|
50
67
|
export declare function writeLine(line: string): Promise<void>;
|
|
68
|
+
/**
|
|
69
|
+
* Record the exit code this run owes, BEFORE writing the output that settles
|
|
70
|
+
* it — `runCommand` from its result, `--help` and `--version` as 0 — so a
|
|
71
|
+
* reader that has already gone (EPIPE) still gets the right code from
|
|
72
|
+
* {@link installStdoutGuard}. Module state rather than `process.exitCode`,
|
|
73
|
+
* which a spec running `runCommand` in the test process would inherit.
|
|
74
|
+
*/
|
|
75
|
+
export declare function oweExitCode(code: number | undefined): void;
|
|
51
76
|
/**
|
|
52
77
|
* Install an `'error'` listener on stdout so a broken pipe doesn't crash the
|
|
53
78
|
* CLI with an unhandled `'error'` event. EPIPE (consumer went away, e.g.
|
|
54
|
-
* `aai … --json | head -1`) exits quietly
|
|
55
|
-
*
|
|
79
|
+
* `aai … --json | head -1`) exits quietly WITH THE CODE THE RUN OWES — what
|
|
80
|
+
* {@link oweExitCode} last recorded, else 1 (nothing has succeeded yet), so a
|
|
81
|
+
* failure still fails under `pipefail`. Anything else is reported on stderr
|
|
82
|
+
* and exits 1.
|
|
56
83
|
*/
|
|
57
84
|
export declare function installStdoutGuard(stream?: NodeJS.EventEmitter): void;
|
|
58
85
|
/** Create an ok result. */
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Writing into a directory the CLI does not own — a `--force` pull, an
|
|
3
|
+
* `aai init` into a directory that already has things in it — without
|
|
4
|
+
* writing THROUGH a symlink into somewhere else.
|
|
5
|
+
*
|
|
6
|
+
* Both commands decide where a file goes by joining a relative path onto a
|
|
7
|
+
* target directory, and a lexical containment check (`isPathInside`) cannot
|
|
8
|
+
* see what is on disk: `agent.ts -> ../outside/victim.txt`, a `tools/` that is
|
|
9
|
+
* a link to another tree, or a DANGLING `.gitignore -> ~/x` (an existence
|
|
10
|
+
* probe that reads through it sees ENOENT, and the write that follows creates
|
|
11
|
+
* the link's target) all pass it. So every target is screened with `lstat`,
|
|
12
|
+
* component by component, before anything is written, and the write itself
|
|
13
|
+
* opens with `O_NOFOLLOW` so the last component cannot be swapped for a link
|
|
14
|
+
* in between.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Refuse `rel` under `root` when any EXISTING part of it is a symlink, or
|
|
18
|
+
* when what exists disagrees with the shape the write needs (a file where a
|
|
19
|
+
* parent directory must go, a directory where the file must go).
|
|
20
|
+
*
|
|
21
|
+
* `root` itself is not screened: it is the directory the user named, and a
|
|
22
|
+
* symlinked project directory is an ordinary thing to have. Everything below
|
|
23
|
+
* it is the write's own business. The walk stops at the first component that
|
|
24
|
+
* does not exist — nothing below it can be a link yet.
|
|
25
|
+
*/
|
|
26
|
+
export declare function refuseUnsafeTarget(root: string, rel: string): Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Write `content` at `abs`, creating parents, refusing to follow a symlink at
|
|
29
|
+
* the file itself. `exclusive` refuses an existing file (EEXIST) instead of
|
|
30
|
+
* replacing it; `mode` is the CREATE mode — what a fresh `.env` is born with.
|
|
31
|
+
*
|
|
32
|
+
* Call {@link refuseUnsafeTarget} first: this guards only the last component,
|
|
33
|
+
* because `mkdir -p` and `open` both follow a link in a parent.
|
|
34
|
+
*/
|
|
35
|
+
export declare function writeFileNoFollow(abs: string, content: string, opts?: {
|
|
36
|
+
exclusive?: boolean | undefined;
|
|
37
|
+
mode?: number | undefined;
|
|
38
|
+
}): Promise<void>;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { a as errorCode } from "./_utils-
|
|
2
|
+
import { C as CliError, a as errorCode, d as lstatOrNull } from "./_utils-ChU85MEg.mjs";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { parseEnv } from "node:util";
|
|
5
5
|
import fs from "node:fs/promises";
|
|
6
|
+
import { isPathInside } from "@alexkroman1/aai-runtime/internal";
|
|
6
7
|
//#region src/_server-common.ts
|
|
7
8
|
/**
|
|
8
9
|
* One dotenv file's entries, or `{}` when it is not there.
|
|
@@ -80,6 +81,40 @@ async function resolveServerEnv(cwd, baseEnv, files = [".env"]) {
|
|
|
80
81
|
return env;
|
|
81
82
|
}
|
|
82
83
|
/**
|
|
84
|
+
* The values WRITTEN in the project's dotenv `files` — never the shell's —
|
|
85
|
+
* for a caller that UPLOADS them (`aai publish`'s secret sync).
|
|
86
|
+
*
|
|
87
|
+
* {@link resolveServerEnv}'s shell-wins rule is right for a process that runs
|
|
88
|
+
* here and wrong for one that sends: there a repo's `.env` chooses the KEYS and
|
|
89
|
+
* the shell supplies the VALUES, so a cloned project declaring `GITHUB_TOKEN=`
|
|
90
|
+
* had the user's exported token stored as its agent's secret. Here the file is
|
|
91
|
+
* the whole answer; empty values are dropped as there.
|
|
92
|
+
*
|
|
93
|
+
* A dotenv file that is a SYMLINK out of the project is refused, naming it:
|
|
94
|
+
* `.env -> ~/.aws/credentials` is a committed link (git stores symlinks), and
|
|
95
|
+
* following it uploaded the AWS keys. A link that stays inside the project
|
|
96
|
+
* (`.env -> .env.production`) is fine.
|
|
97
|
+
*/
|
|
98
|
+
async function readUploadableEnv(cwd, files = [".env"]) {
|
|
99
|
+
const env = {};
|
|
100
|
+
for (const file of files) {
|
|
101
|
+
const full = path.join(cwd, file);
|
|
102
|
+
await assertInsideProject(cwd, full);
|
|
103
|
+
for (const [key, val] of Object.entries(await readDotenv(full))) if (val === "") delete env[key];
|
|
104
|
+
else env[key] = val;
|
|
105
|
+
}
|
|
106
|
+
return env;
|
|
107
|
+
}
|
|
108
|
+
/** Refuse `file` when it is a symlink whose real path leaves `cwd`. */
|
|
109
|
+
async function assertInsideProject(cwd, file) {
|
|
110
|
+
if (!(await lstatOrNull(file))?.isSymbolicLink()) return;
|
|
111
|
+
const [root, real] = await Promise.all([fs.realpath(cwd), fs.realpath(file).catch((err) => {
|
|
112
|
+
if (errorCode(err) === "ENOENT") return;
|
|
113
|
+
throw err;
|
|
114
|
+
})]);
|
|
115
|
+
if (real !== void 0 && !isPathInside(root, real)) throw new CliError("unsafe_env_file", `${file} is a symlink to ${real}, outside the project — its contents will not be uploaded as secrets.`, "Replace the link with a regular .env holding only this agent's secrets.");
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
83
118
|
* Every variable name the dotenv `files` DECLARE, whether or not they carry a
|
|
84
119
|
* value.
|
|
85
120
|
*
|
|
@@ -111,4 +146,4 @@ async function declaredEnvNames(cwd, files = [".env"]) {
|
|
|
111
146
|
return [...names].sort();
|
|
112
147
|
}
|
|
113
148
|
//#endregion
|
|
114
|
-
export { resolveServerEnv as i, DEPLOY_ENV_FILES as n, declaredEnvNames as r, DEPLOY_ENV_DECLARATION_FILE as t };
|
|
149
|
+
export { resolveServerEnv as a, readUploadableEnv as i, DEPLOY_ENV_FILES as n, declaredEnvNames as r, DEPLOY_ENV_DECLARATION_FILE as t };
|
package/dist/_server-common.d.ts
CHANGED
|
@@ -47,6 +47,22 @@ export declare const DEPLOY_ENV_FILES: readonly [".env.example", ".env"];
|
|
|
47
47
|
* DEPLOYMENT reads, and its own doc says why the two differ.
|
|
48
48
|
*/
|
|
49
49
|
export declare function resolveServerEnv(cwd?: string, baseEnv?: Record<string, string | undefined>, files?: readonly string[]): Promise<Record<string, string>>;
|
|
50
|
+
/**
|
|
51
|
+
* The values WRITTEN in the project's dotenv `files` — never the shell's —
|
|
52
|
+
* for a caller that UPLOADS them (`aai publish`'s secret sync).
|
|
53
|
+
*
|
|
54
|
+
* {@link resolveServerEnv}'s shell-wins rule is right for a process that runs
|
|
55
|
+
* here and wrong for one that sends: there a repo's `.env` chooses the KEYS and
|
|
56
|
+
* the shell supplies the VALUES, so a cloned project declaring `GITHUB_TOKEN=`
|
|
57
|
+
* had the user's exported token stored as its agent's secret. Here the file is
|
|
58
|
+
* the whole answer; empty values are dropped as there.
|
|
59
|
+
*
|
|
60
|
+
* A dotenv file that is a SYMLINK out of the project is refused, naming it:
|
|
61
|
+
* `.env -> ~/.aws/credentials` is a committed link (git stores symlinks), and
|
|
62
|
+
* following it uploaded the AWS keys. A link that stays inside the project
|
|
63
|
+
* (`.env -> .env.production`) is fine.
|
|
64
|
+
*/
|
|
65
|
+
export declare function readUploadableEnv(cwd: string, files?: readonly string[]): Promise<Record<string, string>>;
|
|
50
66
|
/**
|
|
51
67
|
* Every variable name the dotenv `files` DECLARE, whether or not they carry a
|
|
52
68
|
* value.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { n as getServerInfo } from "./_agent-
|
|
3
|
-
import {
|
|
2
|
+
import { n as getServerInfo } from "./_agent-BN21AHsJ.mjs";
|
|
3
|
+
import { a as apiRequest, n as HINT_NOT_DEPLOYED } from "./_api-client-Uljj0CQi.mjs";
|
|
4
|
+
import { u as studioProjectApiUrl } from "./_studio-zympBLlD.mjs";
|
|
4
5
|
//#region src/_slug-api.ts
|
|
5
6
|
/**
|
|
6
7
|
* Authenticated request against a deployed agent's slug-scoped resource
|