@alexkroman1/aai-cli 0.17.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-D6VSQbYW.mjs → _dev-server-C_zidzWj.mjs} +15 -10
- 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-tVBjfKyR.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-CT_QHHZL.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 +44 -34
- 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/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 -123
- 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 +48 -9
- 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 -1070
- 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 +89 -62
- 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 +131 -457
- 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 +19 -30
- 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 -73
- 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
|
@@ -3,11 +3,10 @@
|
|
|
3
3
|
* Specs for the transcription desk's declaration, its WAV arithmetic, and its
|
|
4
4
|
* steps.
|
|
5
5
|
*
|
|
6
|
-
* A step is an ordinary exported async function, so its
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* no ffmpeg. The other two normalize the recording first and this repo's test
|
|
6
|
+
* A step is an ordinary exported async function, so its `FatalError` guards,
|
|
7
|
+
* its HTTP handling and its merge are all testable directly. **And one of the
|
|
8
|
+
* three bodies IS driven**, on the real replay engine — `transcribeBatch`, in
|
|
9
|
+
* the last block, which is the flow that reaches no ffmpeg. The other two normalize the recording first and this repo's test
|
|
11
10
|
* environment has no ffmpeg, so their durability stays `aai-cli`'s
|
|
12
11
|
* `dev-workflow.scenario.test.ts`'s. Saying which of the three is covered is
|
|
13
12
|
* the point: a body test dressed up as a durability test would be the worse
|
|
@@ -20,19 +19,26 @@
|
|
|
20
19
|
|
|
21
20
|
import { readdir } from "node:fs/promises";
|
|
22
21
|
import { tmpdir } from "node:os";
|
|
23
|
-
import {
|
|
22
|
+
import {
|
|
23
|
+
stepReadUpload,
|
|
24
|
+
TRANSCRIBE_DURABLY_STEPS,
|
|
25
|
+
type UploadRange,
|
|
26
|
+
WAV_HEADER_BYTES,
|
|
27
|
+
} from "@alexkroman1/aai/step";
|
|
24
28
|
import { DEFAULT_RETRY_DELAY_MS, FatalError, RetryableError } from "@alexkroman1/aai/step-errors";
|
|
25
|
-
import {
|
|
29
|
+
import {
|
|
30
|
+
createWorkflowContext,
|
|
31
|
+
runWorkflow,
|
|
32
|
+
type StubTranscribeOptions,
|
|
33
|
+
} from "@alexkroman1/aai-runtime/testing";
|
|
26
34
|
import {
|
|
27
35
|
installStubReporter,
|
|
28
|
-
installStubStepFetch,
|
|
29
|
-
installStubTranscribe,
|
|
30
36
|
installStubUploads,
|
|
37
|
+
installStubWorld,
|
|
31
38
|
} from "@alexkroman1/aai-runtime/testing/vitest";
|
|
32
39
|
import { beforeEach, describe, expect, test, vi } from "vitest";
|
|
33
40
|
import { z } from "zod";
|
|
34
41
|
import agentDef, { transcribe, transcribeBatch, transcribeStream } from "./agent.ts";
|
|
35
|
-
import { createJob, pollTranscript, uploadToProvider } from "./workflows/batch.ts";
|
|
36
42
|
import {
|
|
37
43
|
downsampleSegment,
|
|
38
44
|
NORMALIZED_CHANNELS,
|
|
@@ -156,23 +162,6 @@ function wavFile(
|
|
|
156
162
|
}
|
|
157
163
|
|
|
158
164
|
describe("the agent declares its three workflows", () => {
|
|
159
|
-
test("under the names the REST route resolves them by", () => {
|
|
160
|
-
// The page starts a run by these strings, so a rename is a runtime 400 rather
|
|
161
|
-
// than a compile error — which is what makes pinning them worth a test.
|
|
162
|
-
// `arrayContaining` rather than an exact key list: a fourth desk of your own
|
|
163
|
-
// is an invited edit and must not redden a test you did not write. These
|
|
164
|
-
// three NAMES stay pinned, deliberately — the page starts a run by each
|
|
165
|
-
// string, so renaming one is a runtime 400 rather than a compile error, and
|
|
166
|
-
// this is the only thing that says so. Rename here and in `client.tsx`
|
|
167
|
-
// together.
|
|
168
|
-
expect(Object.keys(agentDef.workflows ?? {})).toEqual(
|
|
169
|
-
expect.arrayContaining(["transcribe", "transcribeStream", "transcribeBatch"]),
|
|
170
|
-
);
|
|
171
|
-
expect(agentDef.workflows?.transcribe).toBe(transcribe);
|
|
172
|
-
expect(agentDef.workflows?.transcribeStream).toBe(transcribeStream);
|
|
173
|
-
expect(agentDef.workflows?.transcribeBatch).toBe(transcribeBatch);
|
|
174
|
-
});
|
|
175
|
-
|
|
176
165
|
test("all three take `recording` as an UPLOAD, which is what makes one picker serve them", () => {
|
|
177
166
|
// There is no second kind of declaration: `recording` carries an upload id in
|
|
178
167
|
// every flow, and the streaming one differs only in that the CLIENT chose the id
|
|
@@ -192,12 +181,6 @@ describe("the agent declares its three workflows", () => {
|
|
|
192
181
|
// and this line is what tells you you are on the wrong one.
|
|
193
182
|
expect(Object.keys(agentDef.tools ?? {})).toEqual([]);
|
|
194
183
|
});
|
|
195
|
-
|
|
196
|
-
test("declaring the key its steps read, so a deploy checks for it", () => {
|
|
197
|
-
// Without this a missing credential is discovered by the first run, minutes
|
|
198
|
-
// after the deploy reported success.
|
|
199
|
-
expect(agentDef.requiredEnv).toContain("ASSEMBLYAI_API_KEY");
|
|
200
|
-
});
|
|
201
184
|
});
|
|
202
185
|
|
|
203
186
|
describe("the input schema", () => {
|
|
@@ -759,34 +742,24 @@ describe("transcribeSegment", () => {
|
|
|
759
742
|
const FORMAT: WavFormat = { ...MONO_16K, dataStart: 44, dataEnd: 44 + 320_000 };
|
|
760
743
|
const SEGMENT = { index: 0, start: 44, end: 44 + 32_000, startMs: 0, endMs: 1000 };
|
|
761
744
|
|
|
762
|
-
beforeEach(() => {
|
|
763
|
-
// `stepEnv` falls back to the process env when no host has published one,
|
|
764
|
-
// which is exactly the case a spec is: there is no agent env in this
|
|
765
|
-
// process. `unstubEnvs` clears it before the next test.
|
|
766
|
-
vi.stubEnv("ASSEMBLYAI_API_KEY", "sk-test");
|
|
767
|
-
});
|
|
768
|
-
|
|
769
745
|
/**
|
|
770
|
-
* Publishes
|
|
771
|
-
*
|
|
772
|
-
*
|
|
773
|
-
*
|
|
774
|
-
* published `stepFetch` rather than `vi.stubGlobal("fetch", …)`, because the
|
|
775
|
-
* step calls `stepFetch`, which reaches a published slot rather than the global
|
|
776
|
-
* (see `sdk/step-fetch.ts` for why it has to: HTTP/1.1, so a batch of segments
|
|
777
|
-
* gets a socket each instead of N streams on one connection). Stubbing the
|
|
778
|
-
* global still passes, because an unpublished slot falls back to it, and would
|
|
779
|
-
* be asserting against a path production does not take.
|
|
780
|
-
*
|
|
781
|
-
* A refusal is staged as a STATUS, which is what makes the classification specs
|
|
782
|
-
* below a test of the SDK's reading of it rather than of an error a fake minted.
|
|
746
|
+
* Publishes `bytes` of recording and answers the sync endpoint, with the
|
|
747
|
+
* credential the step reads seeded. A refusal is staged as a STATUS, which is
|
|
748
|
+
* what makes the classification specs below a test of the SDK's reading of
|
|
749
|
+
* it rather than of an error a fake minted.
|
|
783
750
|
*/
|
|
751
|
+
function world(bytes: number, transcribe: StubTranscribeOptions = { text: "hello there" }) {
|
|
752
|
+
return installStubWorld({
|
|
753
|
+
uploads: { files: { [UPLOAD_ID]: { bytes: new Uint8Array(bytes), name: "standup.wav" } } },
|
|
754
|
+
transcribe,
|
|
755
|
+
});
|
|
756
|
+
}
|
|
757
|
+
|
|
784
758
|
function stubProvider(failure?: { status: number; message: string; retryAfterSeconds?: number }) {
|
|
785
|
-
|
|
786
|
-
return installStubTranscribe({
|
|
759
|
+
return world(FORMAT.dataEnd, {
|
|
787
760
|
text: "hello there",
|
|
788
761
|
failure: failure === undefined ? undefined : { leg: "sync", ...failure },
|
|
789
|
-
}).
|
|
762
|
+
}).provider;
|
|
790
763
|
}
|
|
791
764
|
|
|
792
765
|
test("sends the segment as a WAV named after its index", async () => {
|
|
@@ -830,8 +803,7 @@ describe("transcribeSegment", () => {
|
|
|
830
803
|
dataStart: 44,
|
|
831
804
|
dataEnd: 44 + 192_000,
|
|
832
805
|
};
|
|
833
|
-
|
|
834
|
-
const calls = installStubTranscribe({ text: "hello there" }).calls;
|
|
806
|
+
const calls = world(stereo.dataEnd).provider;
|
|
835
807
|
|
|
836
808
|
await transcribeSegment(UPLOAD_ID, stereo, {
|
|
837
809
|
index: 0,
|
|
@@ -871,8 +843,7 @@ describe("transcribeSegment", () => {
|
|
|
871
843
|
dataStart: 44,
|
|
872
844
|
dataEnd: 44 + 96_000,
|
|
873
845
|
};
|
|
874
|
-
|
|
875
|
-
installStubTranscribe({ text: "never reached" });
|
|
846
|
+
world(wide.dataEnd, { text: "never reached" });
|
|
876
847
|
|
|
877
848
|
await expect(
|
|
878
849
|
transcribeSegment(UPLOAD_ID, wide, {
|
|
@@ -899,8 +870,7 @@ describe("transcribeSegment", () => {
|
|
|
899
870
|
dataStart: 44,
|
|
900
871
|
dataEnd: 44 + 24_000,
|
|
901
872
|
};
|
|
902
|
-
|
|
903
|
-
installStubTranscribe({ text: "never reached" });
|
|
873
|
+
world(narrow.dataEnd, { text: "never reached" });
|
|
904
874
|
|
|
905
875
|
await expect(
|
|
906
876
|
transcribeSegment(UPLOAD_ID, narrow, {
|
|
@@ -918,8 +888,8 @@ describe("transcribeSegment", () => {
|
|
|
918
888
|
// page stitches whatever has arrived, so the transcript renders growing
|
|
919
889
|
// instead of appearing when the last segment does. The reporter is the SDK's
|
|
920
890
|
// published slot, which is the same seam `stepReport()` goes through.
|
|
921
|
-
const reported = installStubReporter();
|
|
922
891
|
stubProvider();
|
|
892
|
+
const reported = installStubReporter();
|
|
923
893
|
|
|
924
894
|
await transcribeSegment(UPLOAD_ID, FORMAT, SEGMENT);
|
|
925
895
|
|
|
@@ -936,9 +906,15 @@ describe("transcribeSegment", () => {
|
|
|
936
906
|
expect(reported.lines.some((line) => line.startsWith("Transcribing"))).toBe(true);
|
|
937
907
|
});
|
|
938
908
|
|
|
939
|
-
test("fails FATALLY with no API key rather than retrying
|
|
909
|
+
test("fails FATALLY with no API key rather than retrying", async () => {
|
|
940
910
|
vi.stubEnv("ASSEMBLYAI_API_KEY", "");
|
|
941
|
-
|
|
911
|
+
installStubWorld({
|
|
912
|
+
uploads: {
|
|
913
|
+
files: { [UPLOAD_ID]: { bytes: new Uint8Array(FORMAT.dataEnd), name: "standup.wav" } },
|
|
914
|
+
},
|
|
915
|
+
transcribe: { text: "hello there" },
|
|
916
|
+
apiKey: false,
|
|
917
|
+
});
|
|
942
918
|
await expect(transcribeSegment(UPLOAD_ID, FORMAT, SEGMENT)).rejects.toThrow(
|
|
943
919
|
/ASSEMBLYAI_API_KEY/,
|
|
944
920
|
);
|
|
@@ -986,16 +962,11 @@ describe("transcribeSegment", () => {
|
|
|
986
962
|
);
|
|
987
963
|
});
|
|
988
964
|
|
|
989
|
-
test("is raised on
|
|
990
|
-
// The policy is an argument to `ctx.step
|
|
991
|
-
//
|
|
992
|
-
//
|
|
993
|
-
//
|
|
994
|
-
// ffmpeg, no bytes.
|
|
995
|
-
//
|
|
996
|
-
// `transcribeStreamFlow`'s own `transcribeSegment` call carries the same
|
|
997
|
-
// budget and is asserted with that flow, not here — this drives only
|
|
998
|
-
// `transcribeFlow`.
|
|
965
|
+
test("is raised on the one I/O step, and on nothing else", async () => {
|
|
966
|
+
// The policy is an argument to `ctx.step`, so it is observable only at the
|
|
967
|
+
// CALL. `runSteps: false` with a skeleton of results: no provider, no
|
|
968
|
+
// ffmpeg, no bytes. The fan-out waits out a rate limit with `maxWaits`
|
|
969
|
+
// instead of a raised budget.
|
|
999
970
|
const ctx = createWorkflowContext({
|
|
1000
971
|
runSteps: false,
|
|
1001
972
|
results: {
|
|
@@ -1017,22 +988,23 @@ describe("transcribeSegment", () => {
|
|
|
1017
988
|
});
|
|
1018
989
|
await transcribeFlow({ recording: UPLOAD_ID }, ctx);
|
|
1019
990
|
|
|
1020
|
-
const
|
|
1021
|
-
expect(segments.length).toBeGreaterThan(0);
|
|
991
|
+
const budgets = new Map(ctx.steps.map((step) => [step.name, step.maxAttempts]));
|
|
1022
992
|
// The EXACT budget, not `toBeGreaterThan(3)`: the value is a literal at the
|
|
1023
993
|
// call site, so a typo'd `maxAttempts: 4` is what this should catch.
|
|
1024
|
-
for (const step of segments) expect(step.maxAttempts).toBe(6);
|
|
1025
|
-
// The OTHER raised step, whose assertion the migration dropped along with
|
|
1026
|
-
// the `normalizeRecording.maxRetries` property it used to read.
|
|
1027
|
-
const budgets = new Map(ctx.steps.map((step) => [step.name, step.maxAttempts]));
|
|
1028
994
|
expect(budgets.get("normalizeRecording")).toBe(6);
|
|
1029
|
-
// And the
|
|
995
|
+
// And the three that take the default, which is the other half of the claim.
|
|
1030
996
|
// Asserted as PRESENT-with-no-budget rather than as `get(…) === undefined`,
|
|
1031
997
|
// which a step the body never reached at all would also satisfy.
|
|
1032
|
-
for (const name of ["mergeTranscript", "splitRecording"]) {
|
|
998
|
+
for (const name of ["mergeTranscript", "splitRecording", "transcribeSegment"]) {
|
|
1033
999
|
expect(budgets.has(name)).toBe(true);
|
|
1034
1000
|
expect(budgets.get(name)).toBeUndefined();
|
|
1035
1001
|
}
|
|
1002
|
+
// The segment step's rate limit is a WAIT budget — on that step alone.
|
|
1003
|
+
const waits = new Map(ctx.steps.map((step) => [step.name, step.maxWaits]));
|
|
1004
|
+
expect(waits.get("transcribeSegment")).toBe(3);
|
|
1005
|
+
for (const name of ["normalizeRecording", "mergeTranscript", "splitRecording"]) {
|
|
1006
|
+
expect(waits.get(name)).toBeUndefined();
|
|
1007
|
+
}
|
|
1036
1008
|
});
|
|
1037
1009
|
});
|
|
1038
1010
|
|
|
@@ -1243,141 +1215,6 @@ describe("the streaming flow", () => {
|
|
|
1243
1215
|
* is terminal, the file is streamed rather than buffered) rather than about
|
|
1244
1216
|
* arithmetic this flow does not do.
|
|
1245
1217
|
*/
|
|
1246
|
-
describe("the async flow", () => {
|
|
1247
|
-
beforeEach(() => {
|
|
1248
|
-
vi.stubEnv("ASSEMBLYAI_API_KEY", "sk-test");
|
|
1249
|
-
});
|
|
1250
|
-
|
|
1251
|
-
/**
|
|
1252
|
-
* Answer the async API, recording what was sent.
|
|
1253
|
-
*
|
|
1254
|
-
* `installStubTranscribe` routes the three legs off the SDK's own endpoint
|
|
1255
|
-
* constants — so a spec cannot pass because the fake and the step agree on a
|
|
1256
|
-
* typo — and it restores itself when the test ends.
|
|
1257
|
-
*/
|
|
1258
|
-
function stubBatch(options: Parameters<typeof installStubTranscribe>[0] = {}) {
|
|
1259
|
-
return installStubTranscribe({ audioUrl: "https://cdn.example/abc", ...options }).calls;
|
|
1260
|
-
}
|
|
1261
|
-
|
|
1262
|
-
test("uploadToProvider streams the file and answers with the provider's URL", async () => {
|
|
1263
|
-
publishRecording(new Uint8Array(5000), "standup.wav");
|
|
1264
|
-
const calls = stubBatch();
|
|
1265
|
-
await expect(uploadToProvider(UPLOAD_ID)).resolves.toEqual({
|
|
1266
|
-
audioUrl: "https://cdn.example/abc",
|
|
1267
|
-
});
|
|
1268
|
-
expect(calls.map((one) => one.url)).toEqual(["https://api.assemblyai.com/v2/upload"]);
|
|
1269
|
-
});
|
|
1270
|
-
|
|
1271
|
-
test("the file is STREAMED, so a step never holds a whole recording", async () => {
|
|
1272
|
-
publishRecording(new Uint8Array(5000), "standup.wav");
|
|
1273
|
-
const calls = stubBatch();
|
|
1274
|
-
await uploadToProvider(UPLOAD_ID);
|
|
1275
|
-
// The fake drains a streaming body into bytes, so what this asserts is that
|
|
1276
|
-
// every byte went out — the streaming is what keeps a gigabyte off the heap, and
|
|
1277
|
-
// the bytes arriving intact is what says the windowing is right.
|
|
1278
|
-
const sent = calls[0]?.body;
|
|
1279
|
-
expect(sent).toBeInstanceOf(Uint8Array);
|
|
1280
|
-
expect(sent instanceof Uint8Array ? sent.length : -1).toBe(5000);
|
|
1281
|
-
});
|
|
1282
|
-
|
|
1283
|
-
test("the upload is a SEPARATE step, so a failed submit does not re-send the file", async () => {
|
|
1284
|
-
// Found by running it: as one step, a 400 on the create call retried the whole
|
|
1285
|
-
// thing five times and re-uploaded 24 MB on each attempt. The split is what makes
|
|
1286
|
-
// a retry of the cheap half cost the cheap half.
|
|
1287
|
-
publishRecording(new Uint8Array(5000));
|
|
1288
|
-
const calls = stubBatch({ failure: { leg: "submit", status: 400, message: "bad field" } });
|
|
1289
|
-
await expect(createJob("https://cdn.example/abc")).rejects.toBeInstanceOf(FatalError);
|
|
1290
|
-
// One call, and it is not the upload.
|
|
1291
|
-
expect(calls).toHaveLength(1);
|
|
1292
|
-
expect(calls[0]?.url).toBe("https://api.assemblyai.com/v2/transcript");
|
|
1293
|
-
});
|
|
1294
|
-
|
|
1295
|
-
test("createJob asks for `speech_models`, plural — the singular field is a 400", async () => {
|
|
1296
|
-
publishRecording(new Uint8Array(10));
|
|
1297
|
-
const calls = stubBatch({ jobIdPrefix: "tr_" });
|
|
1298
|
-
await expect(createJob("https://cdn.example/abc")).resolves.toEqual({ id: "tr_1" });
|
|
1299
|
-
const sent = JSON.parse(String(calls[0]?.body)) as Record<string, unknown>;
|
|
1300
|
-
// The async API deprecated `speech_model` and answers 400 for any current model
|
|
1301
|
-
// name passed to it — which is how the first live run of this flow failed. The
|
|
1302
|
-
// STREAMING API still uses the singular field, so neither is "the" spelling.
|
|
1303
|
-
expect(sent).toMatchObject({ speech_models: ["universal-3-5-pro"] });
|
|
1304
|
-
expect(sent.speech_model).toBeUndefined();
|
|
1305
|
-
});
|
|
1306
|
-
|
|
1307
|
-
test("a job the provider gave up on is TERMINAL, not polled forever", async () => {
|
|
1308
|
-
publishRecording(new Uint8Array(10));
|
|
1309
|
-
stubBatch({ jobError: "audio too quiet" });
|
|
1310
|
-
// The provider has decided; no number of polls changes it, so this must not come
|
|
1311
|
-
// back as "not done yet".
|
|
1312
|
-
await expect(pollTranscript(UPLOAD_ID, "tr_1", STARTED_AT)).rejects.toBeInstanceOf(FatalError);
|
|
1313
|
-
});
|
|
1314
|
-
|
|
1315
|
-
test("pollTranscript answers `done` on completed and not before", async () => {
|
|
1316
|
-
publishRecording(new Uint8Array(10));
|
|
1317
|
-
stubBatch({ pendingPolls: 1 });
|
|
1318
|
-
await expect(pollTranscript(UPLOAD_ID, "tr_1", STARTED_AT)).resolves.toEqual({ done: false });
|
|
1319
|
-
});
|
|
1320
|
-
|
|
1321
|
-
test("an unknown status is NOT done, so a new one cannot end a run early", async () => {
|
|
1322
|
-
publishRecording(new Uint8Array(10));
|
|
1323
|
-
// Raw rather than `stubTranscribe`: a body with no status at all is not a
|
|
1324
|
-
// shape the fake can stage, and it is the whole point of this spec.
|
|
1325
|
-
installStubStepFetch(() => ({ body: {} }));
|
|
1326
|
-
await expect(pollTranscript(UPLOAD_ID, "tr_1", STARTED_AT)).resolves.toMatchObject({
|
|
1327
|
-
done: false,
|
|
1328
|
-
});
|
|
1329
|
-
});
|
|
1330
|
-
|
|
1331
|
-
test("a completed poll carries the transcript — ONE request, not two", async () => {
|
|
1332
|
-
publishRecording(new Uint8Array(10), "standup.wav");
|
|
1333
|
-
// It used to poll for a status and then fetch the identical URL again for the
|
|
1334
|
-
// text the poll already had in its hand.
|
|
1335
|
-
const calls = stubBatch({ text: " hello there ", durationSec: 12.5 });
|
|
1336
|
-
await expect(pollTranscript(UPLOAD_ID, "tr_1", STARTED_AT)).resolves.toMatchObject({
|
|
1337
|
-
done: true,
|
|
1338
|
-
transcript: {
|
|
1339
|
-
source: "standup.wav",
|
|
1340
|
-
// Not a fudge: the async API transcribed the recording in one piece, which is
|
|
1341
|
-
// the difference this flow is here to show.
|
|
1342
|
-
segments: 1,
|
|
1343
|
-
durationMs: 12_500,
|
|
1344
|
-
words: 2,
|
|
1345
|
-
transcript: "hello there",
|
|
1346
|
-
},
|
|
1347
|
-
});
|
|
1348
|
-
expect(calls).toHaveLength(1);
|
|
1349
|
-
});
|
|
1350
|
-
|
|
1351
|
-
test("a rate limit is RETRYABLE, so a busy minute does not fail the run", async () => {
|
|
1352
|
-
publishRecording(new Uint8Array(10));
|
|
1353
|
-
stubBatch({ failure: { leg: "poll", status: 429, message: "slow down" } });
|
|
1354
|
-
await expect(pollTranscript(UPLOAD_ID, "tr_1", STARTED_AT)).rejects.toBeInstanceOf(
|
|
1355
|
-
RetryableError,
|
|
1356
|
-
);
|
|
1357
|
-
});
|
|
1358
|
-
|
|
1359
|
-
test("all three flows report the same SHAPE, which is what lets one page render any", async () => {
|
|
1360
|
-
publishRecording(new Uint8Array(10), "standup.wav");
|
|
1361
|
-
stubBatch({ text: "hi", durationSec: 1 });
|
|
1362
|
-
const progress = await pollTranscript(UPLOAD_ID, "tr_1", STARTED_AT);
|
|
1363
|
-
if (!progress.done) return expect.fail("the stub reports a completed job");
|
|
1364
|
-
const batched = progress.transcript;
|
|
1365
|
-
// One key set, so the page's summary line renders every flow's output. A field on
|
|
1366
|
-
// one flow and not the others is a panel that shows it for some runs and not
|
|
1367
|
-
// others, with nothing saying why.
|
|
1368
|
-
expect(Object.keys(batched).sort()).toEqual([
|
|
1369
|
-
"durationMs",
|
|
1370
|
-
"elapsedMs",
|
|
1371
|
-
"segments",
|
|
1372
|
-
"source",
|
|
1373
|
-
"transcript",
|
|
1374
|
-
"words",
|
|
1375
|
-
]);
|
|
1376
|
-
// And the wall clock really is measured from what it was handed.
|
|
1377
|
-
expect(batched.elapsedMs).toBeGreaterThan(0);
|
|
1378
|
-
});
|
|
1379
|
-
});
|
|
1380
|
-
|
|
1381
1218
|
describe("normalizing the recording", () => {
|
|
1382
1219
|
/**
|
|
1383
1220
|
* The CONVERSION is not driven here, and the reason is the tier rather than the
|
|
@@ -1665,7 +1502,8 @@ describe("the conversion, up to the spawn", () => {
|
|
|
1665
1502
|
// The `finally`, on the path that matters: a guest's disk is small, and a step
|
|
1666
1503
|
// that leaked a directory per failed run would fill it.
|
|
1667
1504
|
vi.stubEnv("AAI_FFPROBE_PATH", "/nonexistent/aai-test/ffprobe");
|
|
1668
|
-
|
|
1505
|
+
// `transcodeUpload`'s own temp directory, under the SDK's prefix.
|
|
1506
|
+
const leaked = (names: string[]) => names.filter((n) => n.startsWith("aai-step-"));
|
|
1669
1507
|
const before = leaked(await readdir(tmpdir()));
|
|
1670
1508
|
publishRecording(new Uint8Array([0, 0, 0, 0x20, 0x66, 0x74, 0x79, 0x70]), "standup.m4a");
|
|
1671
1509
|
installStubReporter();
|
|
@@ -1944,36 +1782,35 @@ describe("nextPollDelay", () => {
|
|
|
1944
1782
|
*/
|
|
1945
1783
|
describe("the batch run is DURABLE", () => {
|
|
1946
1784
|
const INPUT = { recording: UPLOAD_ID };
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1785
|
+
const { upload, submit, poll } = TRANSCRIBE_DURABLY_STEPS;
|
|
1786
|
+
|
|
1787
|
+
/** The store holding the recording, and the async API answering for it. */
|
|
1788
|
+
function world(transcribe: StubTranscribeOptions) {
|
|
1789
|
+
return installStubWorld({
|
|
1790
|
+
uploads: { files: { [UPLOAD_ID]: { bytes: new Uint8Array(4096), name: "standup.wav" } } },
|
|
1791
|
+
transcribe,
|
|
1792
|
+
}).provider;
|
|
1793
|
+
}
|
|
1955
1794
|
|
|
1956
1795
|
test("parks on the poll cadence with the upload already journaled", async () => {
|
|
1957
|
-
const
|
|
1796
|
+
const calls = world({ pendingPolls: 1, text: "We shipped it." });
|
|
1958
1797
|
const started = Date.now();
|
|
1959
|
-
const run = await runWorkflow(
|
|
1798
|
+
const run = await runWorkflow(agentDef, "transcribeBatch", INPUT);
|
|
1960
1799
|
|
|
1961
1800
|
expect(run.status).toBe("running");
|
|
1962
1801
|
expect(run.wakeAt).toBeGreaterThan(started);
|
|
1963
|
-
expect(run.steps.map((step) => step.key)).toEqual(
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
]);
|
|
1968
|
-
// The clock the body read alongside the upload is journaled too, in its own
|
|
1802
|
+
expect(new Set(run.steps.map((step) => step.key))).toEqual(
|
|
1803
|
+
new Set([`${upload}#0`, `${submit}#0`, `${poll}#0`]),
|
|
1804
|
+
);
|
|
1805
|
+
// The clock the body read ahead of the upload is journaled too, in its own
|
|
1969
1806
|
// reserved key space — `run.reads`, not `run.steps`.
|
|
1970
1807
|
expect(run.reads.map((read) => read.key)).toEqual(["now!0"]);
|
|
1971
|
-
expect(
|
|
1808
|
+
expect(calls.filter((call) => call.leg === "upload")).toHaveLength(1);
|
|
1972
1809
|
});
|
|
1973
1810
|
|
|
1974
1811
|
test("resumes past the poll without moving the recording again", async () => {
|
|
1975
|
-
const
|
|
1976
|
-
const run = await runWorkflow(
|
|
1812
|
+
const calls = world({ pendingPolls: 1, text: "We shipped it.", durationSec: 12.5 });
|
|
1813
|
+
const run = await runWorkflow(agentDef, "transcribeBatch", INPUT);
|
|
1977
1814
|
await run.advanceSleep();
|
|
1978
1815
|
|
|
1979
1816
|
expect(run.status).toBe("completed");
|
|
@@ -1982,52 +1819,70 @@ describe("the batch run is DURABLE", () => {
|
|
|
1982
1819
|
// ONE, which is the difference this flow exists to show against the two
|
|
1983
1820
|
// that segment.
|
|
1984
1821
|
segments: 1,
|
|
1822
|
+
// The FILENAME, off the journaled upload step.
|
|
1985
1823
|
source: "standup.wav",
|
|
1824
|
+
durationMs: 12_500,
|
|
1825
|
+
words: 3,
|
|
1986
1826
|
});
|
|
1987
1827
|
expect(run.deliveries).toBe(2);
|
|
1988
1828
|
// The whole recording crossed the wire once, on the first walk.
|
|
1989
|
-
expect(
|
|
1990
|
-
expect(
|
|
1829
|
+
expect(calls.filter((call) => call.leg === "upload")).toHaveLength(1);
|
|
1830
|
+
expect(calls.filter((call) => call.leg === "submit")).toHaveLength(1);
|
|
1831
|
+
});
|
|
1832
|
+
|
|
1833
|
+
test("all three flows report the same SHAPE, which is what lets one page render any", async () => {
|
|
1834
|
+
world({ text: "hi", durationSec: 1 });
|
|
1835
|
+
const run = await runWorkflow(agentDef, "transcribeBatch", INPUT);
|
|
1836
|
+
|
|
1837
|
+
expect(run.status).toBe("completed");
|
|
1838
|
+
// One key set, so the page's summary line renders every flow's output. A field on
|
|
1839
|
+
// one flow and not the others is a panel that shows it for some runs and not
|
|
1840
|
+
// others, with nothing saying why.
|
|
1841
|
+
expect(Object.keys(run.output as Transcript).sort()).toEqual([
|
|
1842
|
+
"durationMs",
|
|
1843
|
+
"elapsedMs",
|
|
1844
|
+
"segments",
|
|
1845
|
+
"source",
|
|
1846
|
+
"transcript",
|
|
1847
|
+
"words",
|
|
1848
|
+
]);
|
|
1991
1849
|
});
|
|
1992
1850
|
|
|
1993
1851
|
test("reports the elapsed from the run's OWN start, not the resuming walk's", async () => {
|
|
1994
|
-
//
|
|
1995
|
-
//
|
|
1996
|
-
//
|
|
1997
|
-
|
|
1998
|
-
const
|
|
1999
|
-
const run = await runWorkflow(transcribeBatch, INPUT, { name: "transcribeBatch" });
|
|
1852
|
+
// `ctx.now()` is journaled under its own key at each end, so the second
|
|
1853
|
+
// walk re-reads the first walk's instant — and `elapsedMs` therefore counts
|
|
1854
|
+
// the whole run rather than the delivery it finished on.
|
|
1855
|
+
const calls = world({ pendingPolls: 1, text: "We shipped it." });
|
|
1856
|
+
const run = await runWorkflow(agentDef, "transcribeBatch", INPUT);
|
|
2000
1857
|
await run.advanceSleep();
|
|
2001
1858
|
|
|
2002
1859
|
expect(run.status).toBe("completed");
|
|
1860
|
+
expect(run.reads.map((read) => read.key)).toEqual(["now!0", "now!1"]);
|
|
2003
1861
|
// A journaled clock cannot go backwards across a resume, and a re-read one
|
|
2004
1862
|
// routinely would — the second walk starts later than the first.
|
|
2005
|
-
expect(run.output
|
|
2006
|
-
expect(
|
|
1863
|
+
expect((run.output as Transcript).elapsedMs).toBeGreaterThanOrEqual(0);
|
|
1864
|
+
expect(calls.filter((call) => call.leg === "poll")).toHaveLength(2);
|
|
2007
1865
|
});
|
|
2008
1866
|
|
|
2009
1867
|
test("a worker that dies before the job is created re-uploads, because nothing settled", async () => {
|
|
2010
1868
|
// The other side of exactly-once, and the honest one: a step whose entry was
|
|
2011
1869
|
// never written IS re-run, because the journal is what makes a step skippable
|
|
2012
1870
|
// and a crashed one left none.
|
|
2013
|
-
const
|
|
2014
|
-
const run = await runWorkflow(transcribeBatch, INPUT, {
|
|
2015
|
-
name: "transcribeBatch",
|
|
2016
|
-
crashAt: "createJob",
|
|
2017
|
-
});
|
|
1871
|
+
const calls = world({ text: "We shipped it." });
|
|
1872
|
+
const run = await runWorkflow(agentDef, "transcribeBatch", INPUT, { crashAt: submit });
|
|
2018
1873
|
|
|
2019
1874
|
expect(run.crashed).toBe(true);
|
|
2020
|
-
expect(run.steps.map((step) => step.name)).toEqual([
|
|
2021
|
-
// The clock the body read
|
|
2022
|
-
//
|
|
1875
|
+
expect(run.steps.map((step) => step.name)).toEqual([upload]);
|
|
1876
|
+
// The clock the body read ahead of the upload survived the crash with it,
|
|
1877
|
+
// which is what makes the resumed run's elapsed the WHOLE run's.
|
|
2023
1878
|
expect(run.reads.map((read) => read.key)).toEqual(["now!0"]);
|
|
2024
|
-
expect(
|
|
1879
|
+
expect(calls.filter((call) => call.leg === "submit")).toHaveLength(0);
|
|
2025
1880
|
|
|
2026
1881
|
await run.restart();
|
|
2027
1882
|
expect(run.status).toBe("completed");
|
|
2028
1883
|
// The upload SURVIVED — it settled before the crash — and only the job
|
|
2029
1884
|
// creation was re-issued.
|
|
2030
|
-
expect(
|
|
2031
|
-
expect(
|
|
1885
|
+
expect(calls.filter((call) => call.leg === "upload")).toHaveLength(1);
|
|
1886
|
+
expect(calls.filter((call) => call.leg === "submit")).toHaveLength(1);
|
|
2032
1887
|
});
|
|
2033
1888
|
});
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
* ## What it needs
|
|
15
15
|
*
|
|
16
16
|
* - **`ASSEMBLYAI_API_KEY` in the agent env** — `.env` under `aai dev`,
|
|
17
|
-
* `aai secret put ASSEMBLYAI_API_KEY` once deployed. `
|
|
18
|
-
*
|
|
19
|
-
*
|
|
17
|
+
* `aai secret put ASSEMBLYAI_API_KEY` once deployed. It is `workflowApp()`'s
|
|
18
|
+
* default `requiredEnv`, so a deploy checks for it rather than letting the
|
|
19
|
+
* first run find out.
|
|
20
20
|
* - **No database.** This used to ask for a `DATABASE_URL` and no longer does:
|
|
21
21
|
* an upload's record is a platform row and its bytes are platform storage, so
|
|
22
22
|
* the form below and every step that reads back what it stored work on a
|
|
@@ -164,8 +164,8 @@ export const transcribeStream = workflow({
|
|
|
164
164
|
* everything the other two spend code on, plus formats they refuse: the async API
|
|
165
165
|
* takes compressed audio, so an m4a off a phone works where a WAV-only cut does not.
|
|
166
166
|
*
|
|
167
|
-
* `workflows/batch.ts` carries the rest
|
|
168
|
-
*
|
|
167
|
+
* `workflows/batch.ts` carries the rest: it is `transcribeUploadDurably`
|
|
168
|
+
* (`@alexkroman1/aai/step`) and a clock read at each end.
|
|
169
169
|
*/
|
|
170
170
|
export const transcribeBatch = workflow({
|
|
171
171
|
description: "Transcribe a recording through the async API, polling until it is done",
|
|
@@ -180,9 +180,6 @@ export default workflowApp({
|
|
|
180
180
|
name: "Transcription Desk",
|
|
181
181
|
// The listing line. It names all THREE routes because choosing between them
|
|
182
182
|
// is the product.
|
|
183
|
-
|
|
183
|
+
listing: "Transcribes a recording three ways: chunked, streaming while it uploads, or batch",
|
|
184
184
|
workflows: { transcribe, transcribeStream, transcribeBatch },
|
|
185
|
-
// Checked at deploy time, so a missing key is a warning naming it rather than
|
|
186
|
-
// a run that fails on its second step.
|
|
187
|
-
requiredEnv: ["ASSEMBLYAI_API_KEY"],
|
|
188
185
|
});
|