@alexkroman1/aai-cli 15.0.0 → 16.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -5
- package/bin.mjs +12 -3
- package/dist/_build-target-55dJisQ-.mjs +649 -0
- package/dist/_build-target.d.ts +105 -108
- package/dist/_deno-output.d.ts +23 -0
- package/dist/_deno-target.d.ts +73 -0
- package/dist/{_init-Bsi3DZNJ.mjs → _init-BzQbV8Zh.mjs} +3 -1
- package/dist/_modal-app.d.ts +77 -0
- package/dist/_modal-output.d.ts +31 -0
- package/dist/_modal-target.d.ts +64 -0
- package/dist/_target-bundle.d.ts +27 -0
- package/dist/_target-drain.d.ts +44 -0
- package/dist/_target-output.d.ts +63 -0
- package/dist/{_templates-CIlJ3Vay.mjs → _templates-CuP74F8D.mjs} +94 -4
- package/dist/_templates.d.ts +14 -1
- package/dist/_vercel-output.d.ts +4 -19
- package/dist/_vercel-target.d.ts +169 -0
- package/dist/{test-D032V2cA.mjs → _vitest-runner-AVR9VtXh.mjs} +28 -68
- package/dist/_vitest-runner.d.ts +154 -0
- package/dist/build-ButI2IKc.mjs +689 -0
- package/dist/build.d.ts +11 -0
- package/dist/cli.mjs +14 -20
- package/dist/{dev-Bx9gYBHM.mjs → dev-kodAY23K.mjs} +7 -1
- package/dist/{eval-B3I7FqN9.mjs → eval-DvoSz7SZ.mjs} +1 -1
- package/dist/{init-CFyusRbq.mjs → init-D363Ls5u.mjs} +13 -39
- package/dist/init.d.ts +5 -10
- package/dist/scaffold/CLAUDE.md +185 -35
- package/dist/scaffold/package.json +4 -4
- package/dist/start.mjs +3 -1
- package/dist/{studio-C_zuRC_z.mjs → studio-CtRBVVFR.mjs} +1 -1
- package/dist/templates/briefing-desk/agent.eval.test.ts +34 -6
- package/dist/templates/briefing-desk/agent.test.ts +347 -55
- package/dist/templates/briefing-desk/agent.ts +12 -0
- package/dist/templates/briefing-desk/shared.ts +220 -31
- package/dist/templates/briefing-desk/slack.ts +108 -0
- package/dist/templates/briefing-desk/system-prompt.md +12 -2
- package/dist/templates/briefing-desk/tools/briefing_so_far.ts +15 -7
- package/dist/templates/briefing-desk/tools/research_topic.ts +20 -28
- package/dist/templates/briefing-desk/tools/send_briefing.ts +77 -0
- package/dist/templates/briefing-desk/tools/verify_claim.ts +60 -14
- package/dist/templates/call-audit/agent.eval.test.ts +5 -0
- package/dist/templates/call-audit/agent.test.ts +6 -1
- package/dist/templates/call-audit/agent.ts +10 -23
- package/dist/templates/call-audit/client.tsx +30 -55
- package/dist/templates/call-audit/guards.test.ts +233 -0
- package/dist/templates/call-audit/workflows/audit.ts +95 -16
- package/dist/templates/call-audit/workflows/ingest.ts +107 -88
- package/dist/templates/call-audit/workflows/media.ts +98 -7
- package/dist/templates/call-audit/workflows/summarize.ts +35 -31
- package/dist/templates/call-audit/workflows/sync-api.ts +15 -6
- package/dist/templates/code-interpreter/agent.eval.test.ts +104 -56
- package/dist/templates/code-interpreter/agent.test.ts +44 -56
- package/dist/templates/code-interpreter/system-prompt.md +1 -1
- package/dist/templates/dispatch-center/agent.eval.test.ts +61 -24
- package/dist/templates/dispatch-center/agent.test.ts +253 -48
- package/dist/templates/dispatch-center/agent.ts +28 -1
- package/dist/templates/dispatch-center/client.tsx +126 -201
- package/dist/templates/dispatch-center/events.ts +48 -0
- package/dist/templates/dispatch-center/shared.ts +42 -1
- package/dist/templates/dispatch-center/tools/incident_create.ts +3 -2
- package/dist/templates/dispatch-center/tools/incident_escalate.ts +2 -1
- package/dist/templates/dispatch-center/tools/ops_dashboard.ts +35 -15
- package/dist/templates/dispatch-center/tools/ops_run_scenario.ts +3 -1
- package/dist/templates/dispatch-center/tools/resources_dispatch.ts +2 -2
- package/dist/templates/executive-assistant/agent.eval.test.ts +233 -0
- package/dist/templates/executive-assistant/agent.test.ts +672 -0
- package/dist/templates/executive-assistant/agent.ts +50 -0
- package/dist/templates/executive-assistant/calendar.test.ts +198 -0
- package/dist/templates/executive-assistant/client.tsx +195 -0
- package/dist/templates/executive-assistant/inbox.ts +233 -0
- package/dist/templates/executive-assistant/meeting.ts +138 -0
- package/dist/templates/executive-assistant/nodes.ts +152 -0
- package/dist/templates/executive-assistant/prompts.ts +331 -0
- package/dist/templates/executive-assistant/review.ts +425 -0
- package/dist/templates/executive-assistant/shared.ts +490 -0
- package/dist/templates/executive-assistant/system-prompt.md +15 -0
- package/dist/templates/executive-assistant/tools/accept.ts +10 -0
- package/dist/templates/executive-assistant/tools/ask_question.ts +30 -0
- package/dist/templates/executive-assistant/tools/draft_reply.ts +67 -0
- package/dist/templates/executive-assistant/tools/edit.ts +10 -0
- package/dist/templates/executive-assistant/tools/ignore.ts +10 -0
- package/dist/templates/executive-assistant/tools/inbox_status.ts +27 -0
- package/dist/templates/executive-assistant/tools/meeting_assistant.ts +52 -0
- package/dist/templates/executive-assistant/tools/new_email.ts +50 -0
- package/dist/templates/executive-assistant/tools/open_email.ts +165 -0
- package/dist/templates/executive-assistant/tools/respond.ts +10 -0
- package/dist/templates/executive-assistant/tools/review_memory.ts +22 -0
- package/dist/templates/executive-assistant/tools/send_calendar_invite.ts +68 -0
- package/dist/templates/executive-assistant/tools/triage_inbox.ts +75 -0
- package/dist/templates/health-assistant/agent.test.ts +134 -15
- package/dist/templates/health-assistant/agent.ts +8 -1
- package/dist/templates/health-assistant/fda.test.ts +130 -0
- package/dist/templates/health-assistant/fda.ts +75 -16
- package/dist/templates/health-assistant/system-prompt.md +9 -0
- package/dist/templates/health-assistant/tools/check_drug_interaction.ts +5 -2
- package/dist/templates/health-assistant/tools/medication_lookup.ts +16 -11
- package/dist/templates/hiring-desk/agent.eval.test.ts +242 -0
- package/dist/templates/hiring-desk/agent.test.ts +1021 -0
- package/dist/templates/hiring-desk/agent.ts +38 -0
- package/dist/templates/hiring-desk/client.tsx +154 -0
- package/dist/templates/hiring-desk/crews.ts +432 -0
- package/dist/templates/hiring-desk/leads.json +86 -0
- package/dist/templates/hiring-desk/screening-lock.test.ts +77 -0
- package/dist/templates/hiring-desk/screening-lock.ts +51 -0
- package/dist/templates/hiring-desk/shared.ts +480 -0
- package/dist/templates/hiring-desk/system-prompt.md +21 -0
- package/dist/templates/hiring-desk/tools/candidate_details.ts +49 -0
- package/dist/templates/hiring-desk/tools/proceed_to_emails.ts +127 -0
- package/dist/templates/hiring-desk/tools/read_email.ts +50 -0
- package/dist/templates/hiring-desk/tools/rescore_with_feedback.ts +140 -0
- package/dist/templates/hiring-desk/tools/screen_candidates.ts +128 -0
- package/dist/templates/hiring-desk/tools/screening_status.ts +51 -0
- package/dist/templates/hotel-desk/agent.eval.test.ts +177 -0
- package/dist/templates/hotel-desk/agent.test.ts +1128 -0
- package/dist/templates/hotel-desk/agent.ts +63 -0
- package/dist/templates/hotel-desk/booking.ts +159 -0
- package/dist/templates/hotel-desk/card.ts +92 -0
- package/dist/templates/hotel-desk/catalogs.ts +219 -0
- package/dist/templates/hotel-desk/client.tsx +137 -0
- package/dist/templates/hotel-desk/concierge.ts +99 -0
- package/dist/templates/hotel-desk/desk-seams.test.ts +334 -0
- package/dist/templates/hotel-desk/desk.ts +224 -0
- package/dist/templates/hotel-desk/disputes.ts +216 -0
- package/dist/templates/hotel-desk/events.ts +79 -0
- package/dist/templates/hotel-desk/hotel.ts +412 -0
- package/dist/templates/hotel-desk/policies.ts +209 -0
- package/dist/templates/hotel-desk/records.ts +384 -0
- package/dist/templates/hotel-desk/restaurant.ts +147 -0
- package/dist/templates/hotel-desk/seed.ts +955 -0
- package/dist/templates/hotel-desk/shared.ts +354 -0
- package/dist/templates/hotel-desk/system-prompt.md +76 -0
- package/dist/templates/hotel-desk/tools/abandon_booking.ts +30 -0
- package/dist/templates/hotel-desk/tools/add_to_waitlist.ts +41 -0
- package/dist/templates/hotel-desk/tools/book_airport_car.ts +57 -0
- package/dist/templates/hotel-desk/tools/book_business_center.ts +44 -0
- package/dist/templates/hotel-desk/tools/book_spa_appointment.ts +39 -0
- package/dist/templates/hotel-desk/tools/book_tour.ts +35 -0
- package/dist/templates/hotel-desk/tools/cancel_restaurant_reservation.ts +25 -0
- package/dist/templates/hotel-desk/tools/cancel_room_booking.ts +63 -0
- package/dist/templates/hotel-desk/tools/check_restaurant_availability.ts +24 -0
- package/dist/templates/hotel-desk/tools/check_room_availability.ts +40 -0
- package/dist/templates/hotel-desk/tools/choose_room.ts +93 -0
- package/dist/templates/hotel-desk/tools/confirm_booking.ts +153 -0
- package/dist/templates/hotel-desk/tools/dispatch_emergency.ts +61 -0
- package/dist/templates/hotel-desk/tools/dispute_charge.ts +90 -0
- package/dist/templates/hotel-desk/tools/flag_late_arrival.ts +26 -0
- package/dist/templates/hotel-desk/tools/lookup_booking.ts +48 -0
- package/dist/templates/hotel-desk/tools/lookup_guest_history.ts +28 -0
- package/dist/templates/hotel-desk/tools/lookup_invoice.ts +26 -0
- package/dist/templates/hotel-desk/tools/lookup_policy.ts +20 -0
- package/dist/templates/hotel-desk/tools/lookup_restaurant_reservation.ts +27 -0
- package/dist/templates/hotel-desk/tools/modify_restaurant_reservation.ts +75 -0
- package/dist/templates/hotel-desk/tools/order_flowers.ts +40 -0
- package/dist/templates/hotel-desk/tools/record_card.ts +46 -0
- package/dist/templates/hotel-desk/tools/record_followup.ts +50 -0
- package/dist/templates/hotel-desk/tools/record_group_inquiry.ts +44 -0
- package/dist/templates/hotel-desk/tools/record_guest_details.ts +71 -0
- package/dist/templates/hotel-desk/tools/reinstate_booking.ts +65 -0
- package/dist/templates/hotel-desk/tools/request_flight_reconfirmation.ts +54 -0
- package/dist/templates/hotel-desk/tools/resend_confirmation.ts +39 -0
- package/dist/templates/hotel-desk/tools/reserve_table.ts +87 -0
- package/dist/templates/hotel-desk/tools/resolve_room_conflict.ts +48 -0
- package/dist/templates/hotel-desk/tools/schedule_wakeup_call.ts +48 -0
- package/dist/templates/hotel-desk/tools/set_do_not_disturb.ts +28 -0
- package/dist/templates/hotel-desk/tools/set_extras.ts +51 -0
- package/dist/templates/hotel-desk/tools/set_stay.ts +97 -0
- package/dist/templates/hotel-desk/tools/start_booking_modification.ts +57 -0
- package/dist/templates/hotel-desk/tools/start_room_booking.ts +49 -0
- package/dist/templates/hotel-desk/tools/take_guest_message.ts +71 -0
- package/dist/templates/hotel-desk/tools/transfer_call.ts +47 -0
- package/dist/templates/hotel-desk/tools/update_card.ts +45 -0
- package/dist/templates/hotel-desk/tools/verify_booking.ts +95 -0
- package/dist/templates/infocom-adventure/agent.eval.test.ts +33 -1
- package/dist/templates/infocom-adventure/agent.test.ts +207 -52
- package/dist/templates/infocom-adventure/agent.ts +14 -3
- package/dist/templates/infocom-adventure/client.tsx +138 -176
- package/dist/templates/infocom-adventure/shared.ts +126 -6
- package/dist/templates/infocom-adventure/system-prompt.md +4 -4
- package/dist/templates/infocom-adventure/tools/game_state_drop.ts +20 -4
- package/dist/templates/infocom-adventure/tools/game_state_get.ts +6 -5
- package/dist/templates/infocom-adventure/tools/game_state_score.ts +9 -3
- package/dist/templates/link-digest/agent.eval.test.ts +8 -0
- package/dist/templates/link-digest/agent.test.ts +285 -29
- package/dist/templates/link-digest/agent.ts +9 -0
- package/dist/templates/link-digest/api-client.ts +144 -0
- package/dist/templates/link-digest/client.tsx +11 -30
- package/dist/templates/link-digest/workflows/digest.ts +72 -24
- package/dist/templates/night-owl/agent.eval.test.ts +55 -40
- package/dist/templates/night-owl/agent.test.ts +146 -12
- package/dist/templates/night-owl/client.tsx +50 -17
- package/dist/templates/night-owl/shared.ts +33 -2
- package/dist/templates/night-owl/system-prompt.md +3 -0
- package/dist/templates/night-owl/tools/recommend.ts +4 -1
- package/dist/templates/night-owl/tools/revisit.ts +49 -0
- package/dist/templates/pipeline-simple/agent.eval.test.ts +7 -6
- package/dist/templates/pipeline-simple/agent.test.ts +48 -91
- package/dist/templates/pipeline-simple/modes.test.ts +151 -0
- package/dist/templates/pipeline-simple/stages.test.ts +332 -0
- package/dist/templates/pizza-ordering/agent.test.ts +94 -38
- package/dist/templates/pizza-ordering/client.tsx +10 -5
- package/dist/templates/pizza-ordering/shared.ts +65 -6
- package/dist/templates/pizza-ordering/tools/add_pizza.ts +2 -7
- package/dist/templates/pizza-ordering/tools/place_order.ts +9 -6
- package/dist/templates/pizza-ordering/tools/remove_pizza.ts +6 -11
- package/dist/templates/pizza-ordering/tools/update_pizza.ts +8 -9
- package/dist/templates/pizza-ordering/tools/view_order.ts +2 -3
- package/dist/templates/plan-and-execute/agent.eval.test.ts +14 -6
- package/dist/templates/plan-and-execute/agent.test.ts +300 -113
- package/dist/templates/plan-and-execute/client.tsx +18 -7
- package/dist/templates/plan-and-execute/procedure.ts +162 -64
- package/dist/templates/plan-and-execute/prompts.ts +51 -15
- package/dist/templates/plan-and-execute/shared.ts +151 -45
- package/dist/templates/plan-and-execute/tools/plan_status.ts +15 -6
- package/dist/templates/plan-and-execute/tools/revise_plan.ts +2 -2
- package/dist/templates/plan-and-execute/tools/start_plan.ts +2 -2
- package/dist/templates/plan-and-execute/tools/work_next_step.ts +15 -13
- package/dist/templates/podcast-digest/agent.eval.test.ts +12 -7
- package/dist/templates/podcast-digest/agent.test.ts +126 -51
- package/dist/templates/podcast-digest/client.tsx +104 -68
- package/dist/templates/podcast-digest/workflows/digest.ts +71 -48
- package/dist/templates/podcast-digest/workflows/feeds.ts +5 -7
- package/dist/templates/podcast-digest/workflows/slack.ts +82 -17
- package/dist/templates/recap-workflow/agent.eval.test.ts +193 -209
- package/dist/templates/recap-workflow/agent.test.ts +207 -26
- package/dist/templates/recap-workflow/tools/recap_status.ts +2 -2
- package/dist/templates/recap-workflow/workflows/recap.ts +39 -28
- package/dist/templates/redline/agent.eval.test.ts +40 -3
- package/dist/templates/redline/agent.test.ts +216 -6
- package/dist/templates/redline/agent.ts +54 -34
- package/dist/templates/redline/client.tsx +82 -126
- package/dist/templates/redline/form.ts +74 -0
- package/dist/templates/redline/workflows/prompts.ts +3 -3
- package/dist/templates/redline/workflows/redline.ts +73 -4
- package/dist/templates/research-workflow/agent.eval.test.ts +152 -150
- package/dist/templates/research-workflow/agent.test.ts +436 -126
- package/dist/templates/research-workflow/agent.ts +20 -5
- package/dist/templates/research-workflow/tools/file_it_now.ts +11 -1
- package/dist/templates/research-workflow/tools/research_status.ts +39 -4
- package/dist/templates/research-workflow/workflows/filing.ts +164 -0
- package/dist/templates/research-workflow/workflows/notes.ts +69 -0
- package/dist/templates/research-workflow/workflows/prompts.ts +45 -31
- package/dist/templates/research-workflow/workflows/research.ts +227 -280
- package/dist/templates/research-workflow/workflows/review.ts +43 -0
- package/dist/templates/retail/address.ts +29 -35
- package/dist/templates/retail/agent.eval.test.ts +36 -16
- package/dist/templates/retail/agent.test.ts +104 -26
- package/dist/templates/retail/agent.ts +12 -0
- package/dist/templates/retail/cancel.ts +39 -42
- package/dist/templates/retail/client.tsx +111 -176
- package/dist/templates/retail/payment.ts +38 -43
- package/dist/templates/retail/pending.test.ts +16 -8
- package/dist/templates/retail/registry.test.ts +108 -49
- package/dist/templates/retail/resolve.test.ts +2 -63
- package/dist/templates/retail/resolve.ts +16 -56
- package/dist/templates/retail/returns.ts +53 -54
- package/dist/templates/retail/seed.test.ts +2 -1
- package/dist/templates/retail/shared.ts +58 -14
- package/dist/templates/retail/store.test.ts +40 -29
- package/dist/templates/retail/store.ts +60 -23
- package/dist/templates/retail/swap.ts +78 -81
- package/dist/templates/retail/tools/find_user_id_by_name_zip.ts +2 -1
- package/dist/templates/roadside-assist/agent.eval.test.ts +164 -0
- package/dist/templates/roadside-assist/agent.test.ts +617 -0
- package/dist/templates/roadside-assist/agent.ts +85 -0
- package/dist/templates/roadside-assist/call.ts +237 -0
- package/dist/templates/roadside-assist/events.ts +92 -0
- package/dist/templates/roadside-assist/shared.ts +334 -0
- package/dist/templates/roadside-assist/system-prompt.md +37 -0
- package/dist/templates/roadside-assist/tools/acknowledge_disclosure.ts +47 -0
- package/dist/templates/roadside-assist/tools/dispatch_truck.ts +148 -0
- package/dist/templates/roadside-assist/tools/job_status.ts +38 -0
- package/dist/templates/roadside-assist/tools/lookup_coverage.ts +72 -0
- package/dist/templates/roadside-assist/tools/report_location.ts +79 -0
- package/dist/templates/roadside-assist/tools/service_disclosure.ts +45 -0
- package/dist/templates/roadside-assist/yard.test.ts +158 -0
- package/dist/templates/roadside-assist/yard.ts +183 -0
- package/dist/templates/simple/agent.eval.test.ts +4 -1
- package/dist/templates/simple/agent.test.ts +54 -31
- package/dist/templates/solo-rpg/agent.eval.test.ts +19 -11
- package/dist/templates/solo-rpg/agent.test.ts +402 -175
- package/dist/templates/solo-rpg/agent.ts +14 -3
- package/dist/templates/solo-rpg/client.tsx +10 -10
- package/dist/templates/solo-rpg/shared.ts +198 -79
- package/dist/templates/solo-rpg/tools/action_roll.ts +7 -3
- package/dist/templates/solo-rpg/tools/burn_momentum.ts +16 -8
- package/dist/templates/solo-rpg/tools/oracle.ts +7 -7
- package/dist/templates/solo-rpg/tools/setup_character.ts +5 -5
- package/dist/templates/solo-rpg/tools/update_state.ts +29 -18
- package/dist/templates/spoken-summary/agent.test.ts +70 -15
- package/dist/templates/spoken-summary/agent.ts +25 -21
- package/dist/templates/spoken-summary/client.tsx +68 -88
- package/dist/templates/spoken-summary/workflows/summarize.ts +26 -8
- package/dist/templates/support-line/agent.test.ts +167 -36
- package/dist/templates/support-line/client.tsx +21 -9
- package/dist/templates/support-line/nodes.ts +74 -32
- package/dist/templates/support-line/procedure.ts +66 -21
- package/dist/templates/support-line/prompts.ts +9 -0
- package/dist/templates/support-line/shared.ts +55 -17
- package/dist/templates/support-line/tools/answer_question.ts +14 -14
- package/dist/templates/transcription-workflow/agent.test.ts +135 -13
- package/dist/templates/transcription-workflow/client.tsx +30 -23
- package/dist/templates/transcription-workflow/recover.test.ts +93 -12
- package/dist/templates/transcription-workflow/recover.ts +29 -5
- package/dist/templates/transcription-workflow/run-panel.tsx +40 -51
- package/dist/templates/transcription-workflow/workflows/normalize.ts +125 -24
- package/dist/templates/transcription-workflow/workflows/stream.ts +4 -1
- package/dist/templates/transcription-workflow/workflows/transcribe.ts +7 -5
- package/dist/templates/transcription-workflow/workflows/wav.ts +42 -117
- package/dist/templates/travel-concierge/agent.eval.test.ts +6 -4
- package/dist/templates/travel-concierge/agent.test.ts +209 -40
- package/dist/templates/travel-concierge/agent.ts +24 -4
- package/dist/templates/travel-concierge/call-events.ts +80 -0
- package/dist/templates/travel-concierge/client.tsx +3 -2
- package/dist/templates/travel-concierge/routing.ts +5 -7
- package/dist/templates/travel-concierge/shared.ts +202 -41
- package/dist/templates/travel-concierge/tools/book_car_rental.ts +2 -4
- package/dist/templates/travel-concierge/tools/book_excursion.ts +2 -4
- package/dist/templates/travel-concierge/tools/book_hotel.ts +2 -4
- package/dist/templates/travel-concierge/tools/cancel_ticket.ts +6 -4
- package/dist/templates/travel-concierge/tools/search_car_rentals.ts +3 -5
- package/dist/templates/travel-concierge/tools/search_excursions.ts +3 -5
- package/dist/templates/travel-concierge/tools/search_flights.ts +20 -9
- package/dist/templates/travel-concierge/tools/search_hotels.ts +3 -5
- package/dist/templates/travel-concierge/tools/update_ticket.ts +2 -4
- package/dist/templates/web-researcher/agent.eval.test.ts +3 -6
- package/dist/templates/web-researcher/agent.test.ts +102 -65
- package/dist/templates/web-researcher/agent.ts +93 -1
- package/dist/templates/web-researcher/system-prompt.md +7 -1
- package/dist/templates/word-wrangler/agent.eval.test.ts +157 -0
- package/dist/templates/word-wrangler/agent.test.ts +432 -0
- package/dist/templates/word-wrangler/agent.ts +35 -0
- package/dist/templates/word-wrangler/client.tsx +211 -0
- package/dist/templates/word-wrangler/game.ts +107 -0
- package/dist/templates/word-wrangler/guess.ts +63 -0
- package/dist/templates/word-wrangler/player.ts +68 -0
- package/dist/templates/word-wrangler/shared.ts +263 -0
- package/dist/templates/word-wrangler/system-prompt.md +15 -0
- package/dist/templates/word-wrangler/tools/final_score.ts +37 -0
- package/dist/templates/word-wrangler/tools/relay_description.ts +137 -0
- package/dist/templates/word-wrangler/tools/repeat_word.ts +19 -0
- package/dist/templates/word-wrangler/tools/skip_word.ts +31 -0
- package/dist/templates/word-wrangler/tools/start_game.ts +47 -0
- package/dist/templates/word-wrangler/words.ts +278 -0
- package/dist/test-Cllnx81G.mjs +83 -0
- package/dist/test.d.ts +9 -114
- package/package.json +5 -5
- package/dist/build-BhEaxBPu.mjs +0 -481
- package/dist/templates/embedded-assets/agent.eval.test.ts +0 -130
- package/dist/templates/embedded-assets/agent.test.ts +0 -79
- package/dist/templates/embedded-assets/agent.ts +0 -7
- package/dist/templates/embedded-assets/knowledge.json +0 -20
- package/dist/templates/embedded-assets/shared.ts +0 -17
- package/dist/templates/embedded-assets/system-prompt.md +0 -13
- package/dist/templates/embedded-assets/tools/list_topics.ts +0 -9
- package/dist/templates/embedded-assets/tools/search_knowledge.ts +0 -26
- package/dist/templates/math-buddy/agent.eval.test.ts +0 -128
- package/dist/templates/math-buddy/agent.test.ts +0 -126
- package/dist/templates/math-buddy/agent.ts +0 -15
- package/dist/templates/math-buddy/system-prompt.md +0 -12
- package/dist/templates/personal-finance/agent.eval.test.ts +0 -149
- package/dist/templates/personal-finance/agent.test.ts +0 -127
- package/dist/templates/personal-finance/agent.ts +0 -8
- package/dist/templates/personal-finance/system-prompt.md +0 -21
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { errorMessage, isToolFailure, requireEnv, toolFailure } from "@alexkroman1/aai";
|
|
2
|
+
import { ChannelDeliveryError, sendToChannel } from "@alexkroman1/aai/channels";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { briefingSlot } from "../shared.ts";
|
|
5
|
+
import { briefingChannel, briefingMessage, DESTINATION_ENV } from "../slack.ts";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Post the board to the desk's Slack channel, so the briefing outlives the
|
|
9
|
+
* call.
|
|
10
|
+
*
|
|
11
|
+
* **Read as a subagent template, this is the tool that does NOT delegate**, and
|
|
12
|
+
* that is why it is here. Everything the desk knows came back from a subagent
|
|
13
|
+
* with its own context window; what crossed into the conversation is one
|
|
14
|
+
* paragraph per angle, and those paragraphs are already on the slot. Sending
|
|
15
|
+
* them costs no model, no researcher and no second look at the web — the same
|
|
16
|
+
* argument `briefing_so_far` makes, one step further.
|
|
17
|
+
*
|
|
18
|
+
* **`slot.tool`, because it READS the board and writes nothing.** A `tool()`
|
|
19
|
+
* opening with `briefingSlot.get(ctx)` would say the same thing in code and
|
|
20
|
+
* nothing in the declaration; what a read is handed is deep-frozen, so a body
|
|
21
|
+
* that meant to mutate stops compiling here rather than failing at a caller.
|
|
22
|
+
*
|
|
23
|
+
* **The credential is `ctx.env`, through `requireEnv`, and it THROWS.** That is
|
|
24
|
+
* the one deliberate throw in this template. A missing key is not a refusal the
|
|
25
|
+
* desk can talk its way around and not something the caller did — it is a
|
|
26
|
+
* deploy nobody finished — so the SDK's own message names the variable and how
|
|
27
|
+
* to set it, and the runtime hands that to the model rather than letting the
|
|
28
|
+
* first property access surface as a `TypeError` the caller hears as an
|
|
29
|
+
* unexplained apology. Everything a call CAN recover from is a `ToolFailure`
|
|
30
|
+
* below.
|
|
31
|
+
*/
|
|
32
|
+
export default briefingSlot.tool({
|
|
33
|
+
description:
|
|
34
|
+
"Send the briefing so far to the team's Slack channel. Use it when the caller " +
|
|
35
|
+
"asks for it in writing, or to have it passed on to someone who was not on the " +
|
|
36
|
+
"call. Tell them you are sending it before you call this.",
|
|
37
|
+
inputSchema: z.object({}),
|
|
38
|
+
async execute(_args, board, ctx) {
|
|
39
|
+
if (board.findings.length === 0) {
|
|
40
|
+
return toolFailure(
|
|
41
|
+
"There is nothing to send yet — research something first, then offer to send it.",
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const destination = briefingChannel(requireEnv(ctx, DESTINATION_ENV));
|
|
46
|
+
if (isToolFailure(destination)) return destination;
|
|
47
|
+
|
|
48
|
+
try {
|
|
49
|
+
await sendToChannel(destination, briefingMessage(board));
|
|
50
|
+
} catch (err: unknown) {
|
|
51
|
+
// The channel has already classified the refusal, which is the whole
|
|
52
|
+
// reason this is not a `fetch` and an `if (!res.ok)`: `retryable` is the
|
|
53
|
+
// 4xx/5xx split, and its message carries Slack's own advice for the half
|
|
54
|
+
// that will answer the same way forever. What is left for the desk is
|
|
55
|
+
// what to SAY, and the two are opposite — offering to try again after a
|
|
56
|
+
// revoked webhook is a promise it cannot keep.
|
|
57
|
+
if (err instanceof ChannelDeliveryError) {
|
|
58
|
+
return toolFailure(
|
|
59
|
+
err.retryable
|
|
60
|
+
? `Slack did not take the briefing: ${err.message} Tell the caller it has not ` +
|
|
61
|
+
"sent yet and offer to try again in a moment."
|
|
62
|
+
: `Slack refused the briefing: ${err.message} Tell the caller it has not sent ` +
|
|
63
|
+
"and that trying again will not help — someone has to fix the destination.",
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
return toolFailure(`The briefing did not send: ${errorMessage(err)}`);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return {
|
|
70
|
+
topic: board.topic,
|
|
71
|
+
sent: board.findings.length,
|
|
72
|
+
message:
|
|
73
|
+
"Say it has gone to the channel and how many angles went with it. Do not read " +
|
|
74
|
+
"the briefing back out — they have it in writing now.",
|
|
75
|
+
};
|
|
76
|
+
},
|
|
77
|
+
});
|
|
@@ -1,6 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
type DeepReadonly,
|
|
3
|
+
errorMessage,
|
|
4
|
+
isToolFailure,
|
|
5
|
+
omitUndefined,
|
|
6
|
+
type TypedDelegateResult,
|
|
7
|
+
toolFailure,
|
|
8
|
+
} from "@alexkroman1/aai";
|
|
2
9
|
import { z } from "zod";
|
|
3
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
briefingSlot,
|
|
12
|
+
countWork,
|
|
13
|
+
type Finding,
|
|
14
|
+
factChecker,
|
|
15
|
+
findByAngle,
|
|
16
|
+
type Verdict,
|
|
17
|
+
} from "../shared.ts";
|
|
4
18
|
|
|
5
19
|
/**
|
|
6
20
|
* Check one sentence against the web, on the narrower of the desk's two
|
|
@@ -17,9 +31,11 @@ import { briefingSlot, countWork, factChecker, findByAngle } from "../shared.ts"
|
|
|
17
31
|
* **The claim may be quoted from the board.** The caller says "check the second
|
|
18
32
|
* thing you told me", so `about` names an angle and the claim is read out of
|
|
19
33
|
* the slot — a subagent has not heard the call, and handing it "the second
|
|
20
|
-
* thing" as its task would get a confident answer about nothing.
|
|
34
|
+
* thing" as its task would get a confident answer about nothing. The board
|
|
35
|
+
* arrives through `briefingSlot.tool` rather than a `get` inside the body,
|
|
36
|
+
* which is what declares that this tool reads it and never writes.
|
|
21
37
|
*/
|
|
22
|
-
export default tool({
|
|
38
|
+
export default briefingSlot.tool({
|
|
23
39
|
description:
|
|
24
40
|
"Check one specific factual claim against the web. Use it when the caller " +
|
|
25
41
|
"pushes back on something, or asks whether a finding is right. Pass the " +
|
|
@@ -38,15 +54,26 @@ export default tool({
|
|
|
38
54
|
"something already on the board",
|
|
39
55
|
),
|
|
40
56
|
}),
|
|
41
|
-
async execute(args, ctx) {
|
|
57
|
+
async execute(args, board, ctx) {
|
|
42
58
|
const claim = args.claim.trim();
|
|
43
59
|
if (claim === "") return toolFailure("Nothing to check — say the claim in a full sentence.");
|
|
44
60
|
|
|
45
|
-
|
|
46
|
-
|
|
61
|
+
// The caller pointed at something on the board, so an AMBIGUOUS pointer is
|
|
62
|
+
// returned to the model rather than resolved by board order. Checking the
|
|
63
|
+
// claim against the wrong finding is worse than spending a turn asking
|
|
64
|
+
// which — the verdict would come back about a different conversation. A
|
|
65
|
+
// caller who named no angle is the `undefined` case and is fine.
|
|
66
|
+
let source: DeepReadonly<Finding> | undefined;
|
|
67
|
+
if (args.about !== undefined) {
|
|
68
|
+
const found = findByAngle(board, args.about);
|
|
69
|
+
if (isToolFailure(found)) return found;
|
|
70
|
+
source = found;
|
|
71
|
+
}
|
|
47
72
|
|
|
48
|
-
let verdict:
|
|
73
|
+
let verdict: Verdict | undefined;
|
|
74
|
+
let detail: string;
|
|
49
75
|
let searches: number;
|
|
76
|
+
let unusable: string | undefined;
|
|
50
77
|
try {
|
|
51
78
|
// What the checker gets of the conversation, and no more: the finding the
|
|
52
79
|
// claim came out of, so it can tell a misquote from a disagreement.
|
|
@@ -54,24 +81,43 @@ export default tool({
|
|
|
54
81
|
// repo's one spelling for an optional field, and the shape its own
|
|
55
82
|
// `guard-invariants` rule 22 counts as debt.
|
|
56
83
|
const context = source ? `The desk told the caller: ${source.summary}` : undefined;
|
|
57
|
-
|
|
84
|
+
// ANNOTATED, as `researchAngle`'s plain `DelegateResult` is, and the pair
|
|
85
|
+
// is the lesson: `factChecker` declares a `schema`, so `ctx.delegate`
|
|
86
|
+
// takes its typed overload and the reply carries a parsed `object`. A
|
|
87
|
+
// schema removed upstream lands here as a type error rather than as an
|
|
88
|
+
// `.object` that quietly went `unknown`.
|
|
89
|
+
const result: TypedDelegateResult<Verdict> = await ctx.delegate(factChecker, {
|
|
58
90
|
task: claim,
|
|
59
91
|
...omitUndefined({ context }),
|
|
60
92
|
});
|
|
61
|
-
verdict = result.text;
|
|
62
93
|
searches = countWork(result.toolCalls).searches;
|
|
94
|
+
// `object` is the parsed verdict, present exactly when the run was
|
|
95
|
+
// accepted. The checker's schema sends a mis-shaped answer back; exhausting
|
|
96
|
+
// that budget is not a failure — there IS an answer, and on a live call the
|
|
97
|
+
// desk is better off reading a hedged one and saying it is hedged than
|
|
98
|
+
// apologizing for the tooling. What it must not do is treat it as a verdict
|
|
99
|
+
// it can correct itself from, which is what `unusable` says.
|
|
100
|
+
unusable = result.accepted ? undefined : result.complaint;
|
|
101
|
+
verdict = result.accepted ? result.object : undefined;
|
|
102
|
+
detail = verdict?.detail ?? result.text;
|
|
63
103
|
} catch (err: unknown) {
|
|
64
104
|
return toolFailure(`The check did not come back: ${errorMessage(err)}`);
|
|
65
105
|
}
|
|
66
106
|
|
|
67
107
|
return {
|
|
68
108
|
claim,
|
|
69
|
-
|
|
109
|
+
// The word the desk BRANCHES on, as a word — not a sentence it has to
|
|
110
|
+
// read a word out of.
|
|
111
|
+
verdict: verdict?.verdict ?? null,
|
|
112
|
+
detail,
|
|
70
113
|
searches,
|
|
71
114
|
checkedAgainst: source?.angle ?? null,
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
"
|
|
115
|
+
...omitUndefined({ unusable }),
|
|
116
|
+
message: unusable
|
|
117
|
+
? "The checker never gave a clear verdict. Tell the caller it is unresolved " +
|
|
118
|
+
"and offer to research it properly — do not present this as confirmation."
|
|
119
|
+
: "Say the verdict plainly, in the caller's words. If it is contradicted, " +
|
|
120
|
+
"correct what you told them earlier rather than defending it.",
|
|
75
121
|
};
|
|
76
122
|
},
|
|
77
123
|
});
|
|
@@ -417,6 +417,11 @@ describeWorkflowEvalWithFfmpeg(
|
|
|
417
417
|
// The RUN's own clock, from two journaled steps rather than a body-level
|
|
418
418
|
// `Date.now()` a replay would re-read.
|
|
419
419
|
expect(output.elapsedMs).toBeGreaterThanOrEqual(0);
|
|
420
|
+
// And the DECODER's share of it. Only a case that really spawns ffmpeg can
|
|
421
|
+
// claim this is a measurement rather than a zero: `runFfmpeg` times each
|
|
422
|
+
// invocation, and three of them ran here.
|
|
423
|
+
expect(output.ffmpegMs).toBeGreaterThan(0);
|
|
424
|
+
expect(output.ffmpegMs).toBeLessThanOrEqual(output.elapsedMs);
|
|
420
425
|
});
|
|
421
426
|
|
|
422
427
|
test(
|
|
@@ -884,10 +884,11 @@ describe("the body's step policy", () => {
|
|
|
884
884
|
bytes: 60 * BYTES_PER_SECOND,
|
|
885
885
|
silences: pauses(10, 20, 30),
|
|
886
886
|
loudness: MEASURED,
|
|
887
|
+
ffmpegMs: 1200,
|
|
887
888
|
},
|
|
888
889
|
transcribeSegment: { index: 0, text: "hello" },
|
|
889
890
|
summarize: { headline: "H", risks: [], actions: [], spoken: "S." },
|
|
890
|
-
narrate: { audio: "upl_wav", durationMs: 500, bytes: 32 },
|
|
891
|
+
narrate: { audio: "upl_wav", durationMs: 500, bytes: 32, ffmpegMs: 300 },
|
|
891
892
|
},
|
|
892
893
|
});
|
|
893
894
|
|
|
@@ -928,6 +929,10 @@ describe("the body's step policy", () => {
|
|
|
928
929
|
const output = await auditFlow({ recording: UPLOAD_ID }, ctx);
|
|
929
930
|
|
|
930
931
|
expect(output.elapsedMs).toBe(3000);
|
|
932
|
+
// And the ffmpeg time is SUMMED from the two journaled step results rather
|
|
933
|
+
// than measured again — which is what makes a replay report what the passes
|
|
934
|
+
// really cost instead of zero for work it did not redo.
|
|
935
|
+
expect(output.ffmpegMs).toBe(1500);
|
|
931
936
|
// And the clock is no longer a step, which is the other half of the claim: a
|
|
932
937
|
// name here would mean the migration left one behind.
|
|
933
938
|
expect(ctx.steps.map((step) => step.name)).not.toContain("clockStart");
|
|
@@ -86,33 +86,23 @@
|
|
|
86
86
|
*/
|
|
87
87
|
|
|
88
88
|
import { workflow, workflowApp } from "@alexkroman1/aai";
|
|
89
|
-
import {
|
|
89
|
+
import { ttsVoiceIds } from "@alexkroman1/aai/tts";
|
|
90
90
|
import type { WorkflowDef } from "@alexkroman1/aai/workflow-api";
|
|
91
91
|
import { z } from "zod";
|
|
92
92
|
import { auditFlow, type CallAudit } from "./workflows/audit.ts";
|
|
93
93
|
|
|
94
94
|
/**
|
|
95
|
-
* The voices the form offers.
|
|
95
|
+
* The voices the form offers, as the tuple `z.enum` takes.
|
|
96
96
|
*
|
|
97
97
|
* READ from the SDK's catalog rather than listed, because a wrong voice id is a
|
|
98
|
-
* SILENT failure — it is a free-form string the service rejects in band after
|
|
99
|
-
* socket is open, so the synthesis simply produces nothing. Narrowed to the
|
|
100
|
-
* ones because the audit is written in the transcript's language and
|
|
101
|
-
* not translate; every voice in the catalog speaks exactly one.
|
|
98
|
+
* SILENT failure — it is a free-form string the service rejects in band after
|
|
99
|
+
* the socket is open, so the synthesis simply produces nothing. Narrowed to the
|
|
100
|
+
* English ones because the audit is written in the transcript's language and
|
|
101
|
+
* the prompt does not translate; every voice in the catalog speaks exactly one.
|
|
102
|
+
* `ttsVoiceIds` owns the derivation, including the fallback to the SDK's own
|
|
103
|
+
* default voice should the filter ever match nothing.
|
|
102
104
|
*/
|
|
103
|
-
const VOICES =
|
|
104
|
-
.filter(([, spec]) => spec.language === "en")
|
|
105
|
-
.map(([id]) => id);
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* The same list as a TUPLE, which is what `z.enum` takes.
|
|
109
|
-
*
|
|
110
|
-
* Destructured rather than cast: a `.map` produces an array, and
|
|
111
|
-
* `as [string, ...string[]]` would be a template teaching a cast. The default covers
|
|
112
|
-
* the empty case honestly — a catalog with no English voice falls back to the SDK's
|
|
113
|
-
* own default rather than rendering a picker with no options.
|
|
114
|
-
*/
|
|
115
|
-
const [FIRST_VOICE = ASSEMBLYAI_TTS_DEFAULT_VOICE, ...OTHER_VOICES] = VOICES;
|
|
105
|
+
const VOICES = ttsVoiceIds("en");
|
|
116
106
|
|
|
117
107
|
/**
|
|
118
108
|
* The run input, as its own const.
|
|
@@ -134,10 +124,7 @@ const auditInput = z.object({
|
|
|
134
124
|
// An enum, so the form renders a SELECT rather than a text box — which is the
|
|
135
125
|
// whole reason the list is derived above rather than left free-form. Optional,
|
|
136
126
|
// so the SDK's own default voice applies when nobody chooses.
|
|
137
|
-
voice: z
|
|
138
|
-
.enum([FIRST_VOICE, ...OTHER_VOICES])
|
|
139
|
-
.optional()
|
|
140
|
-
.describe("Voice to read the audit in"),
|
|
127
|
+
voice: z.enum(VOICES).optional().describe("Voice to read the audit in"),
|
|
141
128
|
});
|
|
142
129
|
|
|
143
130
|
/**
|
|
@@ -76,6 +76,7 @@ import "@alexkroman1/aai-ui/styles.css";
|
|
|
76
76
|
// already declares.
|
|
77
77
|
import { formatBytes, formatDuration } from "@alexkroman1/aai/utils";
|
|
78
78
|
import {
|
|
79
|
+
AudioResult,
|
|
79
80
|
BulletList,
|
|
80
81
|
createWorkflowApi,
|
|
81
82
|
Facts,
|
|
@@ -86,7 +87,9 @@ import {
|
|
|
86
87
|
useDownloadUrl,
|
|
87
88
|
useWorkflowSubmit,
|
|
88
89
|
WorkflowFields,
|
|
90
|
+
WorkflowPendingNote,
|
|
89
91
|
WorkflowProgress,
|
|
92
|
+
WorkflowRunError,
|
|
90
93
|
} from "@alexkroman1/aai-ui";
|
|
91
94
|
import type { audit } from "./agent.ts";
|
|
92
95
|
|
|
@@ -107,20 +110,6 @@ const WORKFLOW = "audit";
|
|
|
107
110
|
*/
|
|
108
111
|
const api = createWorkflowApi();
|
|
109
112
|
|
|
110
|
-
/**
|
|
111
|
-
* What the desk says while a run is in flight — three situations, one line
|
|
112
|
-
* each.
|
|
113
|
-
*
|
|
114
|
-
* The reload case gets its own words deliberately: somebody who did not press
|
|
115
|
-
* the button is owed an explanation for an audit appearing in front of them,
|
|
116
|
-
* and it is the line that keeps them from uploading the call again.
|
|
117
|
-
*/
|
|
118
|
-
function pendingNote(startedHere: boolean, found: boolean): string {
|
|
119
|
-
if (startedHere) return "Reloading is safe — this page will find the audit again.";
|
|
120
|
-
if (!found) return "Looking for an audit this tab started earlier…";
|
|
121
|
-
return "Still auditing a call this tab uploaded earlier — no need to send it again.";
|
|
122
|
-
}
|
|
123
|
-
|
|
124
113
|
/** One labelled number in the pipeline panel. */
|
|
125
114
|
function Stat({ label, value }: { label: string; value: string }) {
|
|
126
115
|
return (
|
|
@@ -136,8 +125,8 @@ export function App() {
|
|
|
136
125
|
// `run.output` instead of `unknown`. The reload — both halves of it — is the
|
|
137
126
|
// hook's own doing; see the module doc for why the key it mints is the one
|
|
138
127
|
// this desk wants.
|
|
139
|
-
const
|
|
140
|
-
|
|
128
|
+
const submission = useWorkflowSubmit<typeof audit>(WORKFLOW, { api });
|
|
129
|
+
const { submitForm, run, pending, upload, pauseUpload, resumeUpload, error } = submission;
|
|
141
130
|
const output = run?.status === "completed" ? run.output : undefined;
|
|
142
131
|
// `useDownloadUrl` is the SDK's: the byte route takes the agent's bearer, so the
|
|
143
132
|
// bytes have to be FETCHED and handed to the element as an object URL — and the
|
|
@@ -165,9 +154,7 @@ export function App() {
|
|
|
165
154
|
{/* `pending` covers the RUN rather than the request, and on a reload it is
|
|
166
155
|
also true while the run is being looked up by key — the stretch where
|
|
167
156
|
an empty form would invite a second 700 MB upload of the same call. */}
|
|
168
|
-
{
|
|
169
|
-
<p className="text-sm opacity-70">{pendingNote(startedHere, run !== undefined)}</p>
|
|
170
|
-
)}
|
|
157
|
+
<WorkflowPendingNote submission={submission} subject="audit" />
|
|
171
158
|
|
|
172
159
|
{/* The upload is its own wait, and the one nothing else can describe: the run
|
|
173
160
|
does not EXIST until the bytes are in, so there is no run id and nothing
|
|
@@ -179,13 +166,9 @@ export function App() {
|
|
|
179
166
|
measured, how many pauses were found. */}
|
|
180
167
|
<WorkflowProgress runId={run?.runId} api={api} />
|
|
181
168
|
|
|
182
|
-
{/*
|
|
183
|
-
|
|
184
|
-
{run
|
|
185
|
-
<p role="alert" className="text-red-600">
|
|
186
|
-
That one failed: {run.error}
|
|
187
|
-
</p>
|
|
188
|
-
)}
|
|
169
|
+
{/* Announced, the same contract `<Form>` gives the submit error: this is
|
|
170
|
+
the outcome the reader waited minutes for. */}
|
|
171
|
+
<WorkflowRunError run={run} />
|
|
189
172
|
|
|
190
173
|
{output !== undefined && (
|
|
191
174
|
<article className="flex flex-col gap-6">
|
|
@@ -209,6 +192,11 @@ export function App() {
|
|
|
209
192
|
value={output.blindCuts === 0 ? "none" : String(output.blindCuts)}
|
|
210
193
|
/>
|
|
211
194
|
<Stat label="Run time" value={formatDuration(output.elapsedMs)} />
|
|
195
|
+
{/* Beside the run time rather than inside it: the run is mostly the
|
|
196
|
+
fan-out waiting on a provider, and this is what the DECODER cost.
|
|
197
|
+
It is the one number that says whether normalizing first paid for
|
|
198
|
+
itself, which is this template's whole argument. */}
|
|
199
|
+
<Stat label="ffmpeg time" value={formatDuration(output.ffmpegMs)} />
|
|
212
200
|
</dl>
|
|
213
201
|
|
|
214
202
|
{/* Either list can come back empty — see `risks` in the schema — and
|
|
@@ -217,36 +205,23 @@ export function App() {
|
|
|
217
205
|
<BulletList title="Risks" items={output.risks} />
|
|
218
206
|
<BulletList title="Actions" items={output.actions} />
|
|
219
207
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
below this player, which is the same information a caption
|
|
236
|
-
track would carry. `spoken-summary` serves a one-cue WebVTT
|
|
237
|
-
data URL instead — worth reading for how, if a real track is
|
|
238
|
-
what a page needs. */}
|
|
239
|
-
<audio aria-label="Audit read aloud" controls src={audio.url} className="w-full" />
|
|
240
|
-
{/* `download` works on an object URL because the bytes are already in
|
|
241
|
-
the tab; it is the href that could not carry the agent's bearer,
|
|
242
|
-
not the attribute. */}
|
|
243
|
-
<a href={audio.url} download="audit.mp3" className="text-sm underline">
|
|
244
|
-
Download audit.mp3
|
|
245
|
-
</a>
|
|
246
|
-
</>
|
|
247
|
-
)}
|
|
208
|
+
{/* The SDK's player over the hook's result: the pending line, the
|
|
209
|
+
announced error, the `<audio>` and the download link (which works on
|
|
210
|
+
an object URL because the bytes are already in the tab; it was the
|
|
211
|
+
href that could not carry the agent's bearer, not the attribute).
|
|
212
|
+
No `captions`, and that is a judgement rather than an oversight:
|
|
213
|
+
the spoken text is rendered in full immediately below the player,
|
|
214
|
+
which is the same information a caption track would carry.
|
|
215
|
+
`spoken-summary` passes one instead — worth reading, if a real
|
|
216
|
+
track is what a page needs. */}
|
|
217
|
+
<AudioResult
|
|
218
|
+
download={audio}
|
|
219
|
+
filename="audit.mp3"
|
|
220
|
+
label="Audit read aloud"
|
|
221
|
+
heading={`Read aloud · ${formatDuration(output.audioDurationMs)} · ${formatBytes(output.audioBytes)}`}
|
|
222
|
+
>
|
|
248
223
|
<p className="text-sm opacity-70">{output.spoken}</p>
|
|
249
|
-
</
|
|
224
|
+
</AudioResult>
|
|
250
225
|
|
|
251
226
|
<details className="text-sm">
|
|
252
227
|
<summary className="cursor-pointer opacity-70">Transcript</summary>
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
// Copyright 2026 the AAI authors. MIT license.
|
|
2
|
+
/**
|
|
3
|
+
* The three things this desk REFUSES, and what it reports while it works.
|
|
4
|
+
*
|
|
5
|
+
* `agent.test.ts` covers what the desk decides — every ffmpeg argv, both
|
|
6
|
+
* analysis parsers, and where `planSegments` cuts. This file covers the checks
|
|
7
|
+
* standing in front of those decisions, and they are together because they share
|
|
8
|
+
* one property: **each one turns a plausible wrong ANSWER into a loud failure.**
|
|
9
|
+
* That is the failure shape this template's own module docs keep returning to —
|
|
10
|
+
* a truncated upload levelled as though it were the whole call, a plan
|
|
11
|
+
* describing audio past the end of a file, a video with no soundtrack decoded at
|
|
12
|
+
* length before ffmpeg complains about a filter graph. None of them throws on
|
|
13
|
+
* its own; every one of them produces a transcript that reads as complete.
|
|
14
|
+
*
|
|
15
|
+
* They are also the seam where a template is at its most tempting to hand-roll,
|
|
16
|
+
* so what each spec really pins is that the SDK's own verdict is READ rather
|
|
17
|
+
* than re-derived: `stepRequireCompleteUpload` already decided that a
|
|
18
|
+
* still-arriving upload is terminal, and `throwStepError` is the line that makes
|
|
19
|
+
* the engine act on it.
|
|
20
|
+
*
|
|
21
|
+
* Its own file rather than more of `agent.test.ts`, which is already the longest
|
|
22
|
+
* spec in `templates/` — the split is by subject, and `health-assistant` and
|
|
23
|
+
* `pipeline-simple` each carry a second spec for the same reason. It sits
|
|
24
|
+
* beside `agent.ts` rather than under `workflows/` because the package's vitest
|
|
25
|
+
* `include` reaches one level into `templates/`, so a spec any deeper would
|
|
26
|
+
* never run.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
import type { MediaInfo } from "@alexkroman1/aai/ffmpeg";
|
|
30
|
+
import type { StepInfo, UploadSlice } from "@alexkroman1/aai/step";
|
|
31
|
+
import { FatalError } from "@alexkroman1/aai/step-errors";
|
|
32
|
+
import { installStubReporter, installStubUploads } from "@alexkroman1/aai/testing/vitest";
|
|
33
|
+
import { omitUndefined } from "@alexkroman1/aai/utils";
|
|
34
|
+
import { beforeEach, describe, expect, test, vi } from "vitest";
|
|
35
|
+
import {
|
|
36
|
+
attemptSuffix,
|
|
37
|
+
segmentShortfall,
|
|
38
|
+
segmentWindow,
|
|
39
|
+
transcribeSegment,
|
|
40
|
+
} from "./workflows/audit.ts";
|
|
41
|
+
import { ingestRecording } from "./workflows/ingest.ts";
|
|
42
|
+
import {
|
|
43
|
+
BYTES_PER_SECOND,
|
|
44
|
+
MediaAnalysisError,
|
|
45
|
+
requireAudioStream,
|
|
46
|
+
TEMP_DIR,
|
|
47
|
+
totalFfmpegMs,
|
|
48
|
+
} from "./workflows/media.ts";
|
|
49
|
+
|
|
50
|
+
/** The id every spec below uploads under. */
|
|
51
|
+
const UPLOAD_ID = "upl_test";
|
|
52
|
+
|
|
53
|
+
/** One segment of the plan: the first second of the stored PCM. */
|
|
54
|
+
const SEGMENT = {
|
|
55
|
+
index: 0,
|
|
56
|
+
startByte: 0,
|
|
57
|
+
endByte: BYTES_PER_SECOND,
|
|
58
|
+
startMs: 0,
|
|
59
|
+
endMs: 1000,
|
|
60
|
+
cutInSpeech: false,
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
/** What `stepReadUpload` answers, with only the field the check reads. */
|
|
64
|
+
function slice(byteLength: number): Pick<UploadSlice, "bytes"> {
|
|
65
|
+
return { bytes: new Uint8Array(byteLength) };
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** What ffprobe made of a file, as `probeMedia` reports it. */
|
|
69
|
+
function probed(...kinds: string[]): MediaInfo {
|
|
70
|
+
const streams = kinds.map((kind, index) => ({ index, kind, codec: `${kind}-codec` }));
|
|
71
|
+
const audio = streams.find((stream) => stream.kind === "audio");
|
|
72
|
+
// Spread rather than `audio: …`: the repo compiles with
|
|
73
|
+
// `exactOptionalPropertyTypes`, so an OPTIONAL property may be absent but may
|
|
74
|
+
// not be present-and-undefined — which is exactly the shape `probeMedia`
|
|
75
|
+
// returns for a file with no audio track.
|
|
76
|
+
return { format: "mov,mp4,m4a", streams, ...omitUndefined({ audio }), raw: {} };
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
beforeEach(() => {
|
|
80
|
+
vi.stubEnv("ASSEMBLYAI_API_KEY", "test-key");
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
describe("an upload that is still arriving", () => {
|
|
84
|
+
test("fails the run TERMINALLY rather than re-asking six times", async () => {
|
|
85
|
+
// `UploadInfo.size` is the readable PREFIX, so a run started before the bytes
|
|
86
|
+
// are in would level part of a call and report success. The SDK already
|
|
87
|
+
// refuses that and already carries the verdict (`retryable: false`) — but a
|
|
88
|
+
// carried verdict is only read where a caller asks, and this call site sets
|
|
89
|
+
// `maxAttempts: 6`. Without `.catch(throwStepError)` in `ingest.ts` the engine
|
|
90
|
+
// would spend all six inside a millisecond on bytes that arrive on their own
|
|
91
|
+
// schedule.
|
|
92
|
+
installStubUploads({
|
|
93
|
+
[UPLOAD_ID]: { bytes: new Uint8Array(2048), name: "call.m4a", complete: false },
|
|
94
|
+
});
|
|
95
|
+
installStubReporter();
|
|
96
|
+
|
|
97
|
+
await expect(ingestRecording(UPLOAD_ID)).rejects.toBeInstanceOf(FatalError);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
test("keeps the SDK's own sentence, which is the one naming the remedy", async () => {
|
|
101
|
+
// `throwStepError` replaces no message, deliberately: what the caller has
|
|
102
|
+
// otherwise is "the step failed", where the SDK's refusal says how many bytes
|
|
103
|
+
// landed and what to do about it.
|
|
104
|
+
installStubUploads({
|
|
105
|
+
[UPLOAD_ID]: { bytes: new Uint8Array(2048), name: "call.m4a", complete: false },
|
|
106
|
+
});
|
|
107
|
+
installStubReporter();
|
|
108
|
+
|
|
109
|
+
await expect(ingestRecording(UPLOAD_ID)).rejects.toThrow(/still arriving/);
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
describe("a file with no audio track", () => {
|
|
114
|
+
test("is refused, and the complaint names what ffprobe DID find", () => {
|
|
115
|
+
// The one file the form's "anything ffmpeg can read" honestly admits and this
|
|
116
|
+
// desk cannot use. Naming the streams is what tells somebody they uploaded
|
|
117
|
+
// the silent screen recording rather than the meeting.
|
|
118
|
+
expect(() => requireAudioStream(probed("video"))).toThrow(MediaAnalysisError);
|
|
119
|
+
expect(() => requireAudioStream(probed("video"))).toThrow(/no audio track/);
|
|
120
|
+
expect(() => requireAudioStream(probed("video", "subtitle"))).toThrow(/video, subtitle/);
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
test("a file ffprobe found nothing in at all still gets a sentence", () => {
|
|
124
|
+
// `streams: []` is what a PDF dragged into the picker looks like, and
|
|
125
|
+
// `found.join(", ")` on an empty list would have produced "ffprobe found .".
|
|
126
|
+
expect(() => requireAudioStream(probed())).toThrow(/no streams at all/);
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
test("a recording WITH sound passes the track through, codec and all", () => {
|
|
130
|
+
// The happy path is the other half of the claim: the codec now comes off the
|
|
131
|
+
// track rather than off an optional chain, so `unknown` means "ffprobe named
|
|
132
|
+
// no codec" and no longer doubles as "there was nothing to name".
|
|
133
|
+
expect(requireAudioStream(probed("video", "audio")).codec).toBe("audio-codec");
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
describe("a stored file smaller than the plan", () => {
|
|
138
|
+
test("a whole window is no shortfall", () => {
|
|
139
|
+
expect(segmentShortfall(SEGMENT, slice(BYTES_PER_SECOND))).toBe(0);
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
test("a CLAMPED read is counted, because nothing else would notice it", () => {
|
|
143
|
+
// The twelve-byte bug `durationSeconds` documents, as a number: the store
|
|
144
|
+
// clamps a window to what it holds, so a plan describing audio past the end of
|
|
145
|
+
// the file produced a short slice, a shorter WAV, and a transcript missing its
|
|
146
|
+
// tail with nothing anywhere saying so.
|
|
147
|
+
expect(segmentShortfall(SEGMENT, slice(BYTES_PER_SECOND - 12))).toBe(12);
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
test("a read LONGER than asked for is not a negative shortfall", () => {
|
|
151
|
+
// Cannot happen through the store, and clamping at zero is what keeps the
|
|
152
|
+
// caller's `> 0` test honest if it ever did.
|
|
153
|
+
expect(segmentShortfall(SEGMENT, slice(BYTES_PER_SECOND + 12))).toBe(0);
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
test("the STEP refuses rather than transcribing a hole", async () => {
|
|
157
|
+
// The check driven where it lives: the store holds one second of PCM and the
|
|
158
|
+
// plan asks for one second and twelve bytes, exactly as the rounding bug
|
|
159
|
+
// produced. `stepReadUpload` clamps, so nothing throws on its own — the run
|
|
160
|
+
// used to transcribe the short slice and report success.
|
|
161
|
+
installStubUploads({
|
|
162
|
+
[UPLOAD_ID]: {
|
|
163
|
+
bytes: new Uint8Array(BYTES_PER_SECOND),
|
|
164
|
+
name: "call.pcm",
|
|
165
|
+
type: "application/octet-stream",
|
|
166
|
+
},
|
|
167
|
+
});
|
|
168
|
+
installStubReporter();
|
|
169
|
+
// No transcription stub, which is the other half of the claim: the step must
|
|
170
|
+
// fail BEFORE it spends a request on audio it knows is incomplete.
|
|
171
|
+
const overrun = { ...SEGMENT, endByte: BYTES_PER_SECOND + 12 };
|
|
172
|
+
|
|
173
|
+
await expect(transcribeSegment(UPLOAD_ID, overrun)).rejects.toBeInstanceOf(FatalError);
|
|
174
|
+
await expect(transcribeSegment(UPLOAD_ID, overrun)).rejects.toThrow(/12 byte\(s\) short/);
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
test("the window is the plan's own half-open pair, unmodified", () => {
|
|
178
|
+
// A rename rather than arithmetic: the store owns the conversion to HTTP's
|
|
179
|
+
// inclusive range, so a `- 1` here would silently drop the last sample frame
|
|
180
|
+
// of every segment.
|
|
181
|
+
expect(segmentWindow(SEGMENT)).toEqual({ start: 0, end: BYTES_PER_SECOND });
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
describe("what the run reports about ffmpeg itself", () => {
|
|
186
|
+
test("sums the passes and rounds, because a page renders it", () => {
|
|
187
|
+
// `runFfmpeg` measures with `performance.now()`, so each duration is a float
|
|
188
|
+
// and a page would otherwise print 1502.3999999999999 ms.
|
|
189
|
+
expect(totalFfmpegMs({ durationMs: 1200.4 }, { durationMs: 301.9 })).toBe(1502);
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
test("no passes is zero rather than NaN", () => {
|
|
193
|
+
expect(totalFfmpegMs()).toBe(0);
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
test("both steps materialize under ONE prefix, which is what the leak spec matches", () => {
|
|
197
|
+
// Two files write temp directories — the ingest and the narration — and each
|
|
198
|
+
// used to name the prefix itself. The spec proving nothing leaks matches
|
|
199
|
+
// directories by this string, so a rename in one file would have left the
|
|
200
|
+
// other's leaks unwatched while the test still passed.
|
|
201
|
+
expect(TEMP_DIR.prefix).toBe("aai-call-audit-");
|
|
202
|
+
});
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
describe("the progress line while a fan-out is retrying", () => {
|
|
206
|
+
/** `stepInfo()`'s answer, as the engine publishes it mid-attempt. */
|
|
207
|
+
const attempt = (n: number): StepInfo => ({
|
|
208
|
+
name: "transcribeSegment",
|
|
209
|
+
key: `transcribeSegment!${n}`,
|
|
210
|
+
attempt: n,
|
|
211
|
+
maxAttempts: 6,
|
|
212
|
+
isLastAttempt: n === 6,
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
test("says nothing on a first attempt, so an ordinary run reads as it did", () => {
|
|
216
|
+
// The eval pins the whole line — `Transcribing 0:00–1:01.` — so a suffix that
|
|
217
|
+
// appeared on attempt one would be a change to the desk's narration rather
|
|
218
|
+
// than an addition to it.
|
|
219
|
+
expect(attemptSuffix(attempt(1))).toBe("");
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
test("names the attempt and the budget once it is really retrying", () => {
|
|
223
|
+
// A thirty-segment fan-out riding out a 429 otherwise re-prints the line it
|
|
224
|
+
// already printed, which looks exactly like a run that has stalled.
|
|
225
|
+
expect(attemptSuffix(attempt(3))).toBe(" (attempt 3 of 6)");
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
test("outside a step is ORDINARY and reads as `not retrying`", () => {
|
|
229
|
+
// `stepInfo()` answers `undefined` in a body, in a tool, and in a spec driving
|
|
230
|
+
// the step directly — which is what the first attempt would have said anyway.
|
|
231
|
+
expect(attemptSuffix(undefined)).toBe("");
|
|
232
|
+
});
|
|
233
|
+
});
|