@alexkroman1/aai-cli 0.12.3 → 0.13.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 +69 -0
- package/bin.mjs +58 -0
- package/dist/_agent-BopNO5Bq.mjs +152 -0
- package/dist/_agent.d.ts +83 -0
- package/dist/_api-client.d.ts +92 -0
- package/dist/_artifacts-BJOYGQPp.mjs +21 -0
- package/dist/_artifacts.d.ts +16 -0
- package/dist/_build-target-C08aM-Es.mjs +1119 -0
- package/dist/_build-target.d.ts +276 -0
- package/dist/_bundler-CgBw5Bcu.mjs +102 -0
- package/dist/_bundler.d.ts +60 -0
- package/dist/_cli-common.d.ts +173 -0
- package/dist/_client-plugins.d.ts +57 -0
- package/dist/_config-mq1I5Cva.mjs +263 -0
- package/dist/_config.d.ts +122 -0
- package/dist/_console-audio.d.ts +17 -0
- package/dist/_console-session.d.ts +70 -0
- package/dist/_default-html.d.ts +33 -0
- package/dist/_deno-output.d.ts +23 -0
- package/dist/_deno-target.d.ts +74 -0
- package/dist/_deploy.d.ts +22 -0
- package/dist/_dev-agent-env.d.ts +27 -0
- package/dist/_dev-env-D9Uy5wNt.mjs +89 -0
- package/dist/_dev-env.d.ts +77 -0
- package/dist/_dev-restart.d.ts +64 -0
- package/dist/_dev-server-BNq5OnUJ.mjs +737 -0
- package/dist/_dev-server.d.ts +89 -0
- package/dist/_dev-session-ticket.d.ts +63 -0
- package/dist/_dev-source.d.ts +55 -0
- package/dist/_dev-tunnel.d.ts +90 -0
- package/dist/_dev-typecheck.d.ts +38 -0
- package/dist/_dev-vite-config.d.ts +100 -0
- package/dist/_dev-watch.d.ts +35 -0
- package/dist/_dotenv-file.d.ts +45 -0
- package/dist/_e2e-test-utils.d.ts +120 -0
- package/dist/_fault-mode.d.ts +194 -0
- package/dist/_help.d.ts +31 -0
- package/dist/_init.d.ts +66 -0
- package/dist/_mock-api.d.ts +22 -0
- package/dist/_mock-registry.d.ts +17 -0
- package/dist/_modal-app.d.ts +77 -0
- package/dist/_modal-output.d.ts +31 -0
- package/dist/_modal-target.d.ts +69 -0
- package/dist/_output-DBP9Op_d.mjs +120 -0
- package/dist/_output.d.ts +74 -0
- package/dist/_preflight-Bv6Ct4ss.mjs +149 -0
- package/dist/_preflight.d.ts +170 -0
- package/dist/_resource-commands.d.ts +22 -0
- package/dist/_run-code-deno-C0AtfHeH.mjs +268 -0
- package/dist/_run-code-deno.d.ts +130 -0
- package/dist/_server-common-CVXIeWrY.mjs +114 -0
- package/dist/_server-common.d.ts +75 -0
- package/dist/_slug-api-DJuwYZ6T.mjs +68 -0
- package/dist/_slug-api.d.ts +61 -0
- package/dist/_stop-server.d.ts +17 -0
- package/dist/_studio-BH05zugt.mjs +251 -0
- package/dist/_studio-commands.d.ts +73 -0
- package/dist/_studio.d.ts +80 -0
- package/dist/_target-bundle.d.ts +139 -0
- package/dist/_target-drain.d.ts +44 -0
- package/dist/_target-entry.d.ts +81 -0
- package/dist/_target-output.d.ts +63 -0
- package/dist/_templates-Bv-rd0SO.mjs +135 -0
- package/dist/_templates.d.ts +82 -0
- package/dist/_typecheck-gate-CcX2gLJZ.mjs +19 -0
- package/dist/_typecheck-gate.d.ts +11 -0
- package/dist/_ui-Coe0zwmm.mjs +102 -0
- package/dist/_ui.d.ts +90 -0
- package/dist/_utils-BVLdBvdT.mjs +186 -0
- package/dist/_utils.d.ts +126 -0
- package/dist/_vercel-output.d.ts +48 -0
- package/dist/_vercel-target.d.ts +169 -0
- package/dist/_vite-env-BiyJ0GQH.mjs +105 -0
- package/dist/_vite-env.d.ts +38 -0
- package/dist/_vitest-runner-CKI8_K1b.mjs +207 -0
- package/dist/_vitest-runner.d.ts +182 -0
- package/dist/_workflow-determinism-CLxFQ5ox.mjs +198 -0
- package/dist/_workflow-determinism.d.ts +118 -0
- package/dist/build-B37oBfEv.mjs +592 -0
- package/dist/build.d.ts +146 -0
- package/dist/cli-workflow.d.ts +10 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.mjs +1063 -198
- package/dist/client-bundler-D4SeZJ8E.mjs +240 -0
- package/dist/client-bundler.d.ts +32 -0
- package/dist/client-bundler.mjs +3 -0
- package/dist/console-D6OOjjeJ.mjs +443 -0
- package/dist/console.d.ts +70 -0
- package/dist/delete-Br0EOH0g.mjs +55 -0
- package/dist/delete.d.ts +25 -0
- package/dist/deploy-CLUH5cv2.mjs +97 -0
- package/dist/deploy.d.ts +25 -0
- package/dist/dev-ZVuyPLUk.mjs +274 -0
- package/dist/dev.d.ts +34 -0
- package/dist/eval-Dl8o91yC.mjs +74 -0
- package/dist/eval.d.ts +46 -0
- package/dist/init-x3FsKl2q.mjs +609 -0
- package/dist/init.d.ts +101 -0
- package/dist/login-oJdBWu2B.mjs +166 -0
- package/dist/login.d.ts +54 -0
- package/dist/logs-BfRq1HX9.mjs +80 -0
- package/dist/logs.d.ts +65 -0
- package/dist/project-config.d.ts +23 -0
- package/dist/project-config.mjs +3 -0
- package/dist/scaffold/.env.example +51 -0
- package/dist/scaffold/CLAUDE.md +390 -0
- package/dist/scaffold/agent-guide/AGENT-API.md +223 -0
- package/dist/scaffold/agent-guide/HOSTING.md +140 -0
- package/dist/scaffold/agent-guide/PIPELINE-TUNING.md +235 -0
- package/dist/scaffold/agent-guide/PROVIDERS.md +143 -0
- package/dist/scaffold/agent-guide/TESTING-EVALS.md +158 -0
- package/dist/scaffold/agent-guide/TOOLS.md +628 -0
- package/dist/scaffold/agent-guide/UI.md +291 -0
- package/dist/scaffold/agent-guide/WORKFLOWS.md +801 -0
- package/dist/scaffold/package.json +38 -0
- package/dist/scaffold/pnpm-workspace.yaml +45 -0
- package/dist/scaffold/tsconfig.json +3 -0
- package/dist/scaffold/vitest.config.ts +8 -0
- package/dist/secret-Db1UWLSZ.mjs +300 -0
- package/dist/secret.d.ts +70 -0
- package/dist/start.d.ts +112 -0
- package/dist/start.mjs +183 -0
- package/dist/studio-DAoJApzD.mjs +209 -0
- package/dist/studio.d.ts +55 -0
- package/dist/templates/applicant-screening-agent/agent.eval.test.ts +258 -0
- package/dist/templates/applicant-screening-agent/agent.test.ts +987 -0
- package/dist/templates/applicant-screening-agent/agent.ts +66 -0
- package/dist/templates/applicant-screening-agent/client.tsx +154 -0
- package/dist/templates/applicant-screening-agent/crews.ts +432 -0
- package/dist/templates/applicant-screening-agent/leads.json +86 -0
- package/dist/templates/applicant-screening-agent/screening-lock.test.ts +77 -0
- package/dist/templates/applicant-screening-agent/screening-lock.ts +51 -0
- package/dist/templates/applicant-screening-agent/shared.ts +483 -0
- package/dist/templates/applicant-screening-agent/system-prompt.md +21 -0
- package/dist/templates/applicant-screening-agent/tools/candidate_details.ts +49 -0
- package/dist/templates/applicant-screening-agent/tools/proceed_to_emails.ts +127 -0
- package/dist/templates/applicant-screening-agent/tools/read_email.ts +50 -0
- package/dist/templates/applicant-screening-agent/tools/rescore_with_feedback.ts +140 -0
- package/dist/templates/applicant-screening-agent/tools/screen_candidates.ts +128 -0
- package/dist/templates/applicant-screening-agent/tools/screening_status.ts +51 -0
- package/dist/templates/call-audit-workflow/agent.eval.test.ts +492 -0
- package/dist/templates/call-audit-workflow/agent.test.ts +1032 -0
- package/dist/templates/call-audit-workflow/agent.ts +161 -0
- package/dist/templates/call-audit-workflow/client.tsx +236 -0
- package/dist/templates/call-audit-workflow/guards.test.ts +233 -0
- package/dist/templates/call-audit-workflow/workflows/audit.ts +391 -0
- package/dist/templates/call-audit-workflow/workflows/ingest.ts +279 -0
- package/dist/templates/call-audit-workflow/workflows/media.ts +729 -0
- package/dist/templates/call-audit-workflow/workflows/summarize.ts +201 -0
- package/dist/templates/call-audit-workflow/workflows/sync-api.ts +54 -0
- package/dist/templates/code-interpreter-agent/agent.eval.test.ts +195 -0
- package/dist/templates/code-interpreter-agent/agent.test.ts +91 -0
- package/dist/templates/code-interpreter-agent/agent.ts +9 -0
- package/dist/templates/code-interpreter-agent/system-prompt.md +18 -0
- package/dist/templates/coding-agent/agent.eval.test.ts +135 -0
- package/dist/templates/coding-agent/agent.test.ts +109 -0
- package/dist/templates/coding-agent/agent.ts +45 -0
- package/dist/templates/coding-agent/chat.ts +63 -0
- package/dist/templates/coding-agent/shared.ts +46 -0
- package/dist/templates/coding-agent/system-prompt.md +32 -0
- package/dist/templates/coding-agent/tools/bash.ts +6 -0
- package/dist/templates/coding-agent/tools/delete_file.ts +6 -0
- package/dist/templates/coding-agent/tools/edit_file.ts +6 -0
- package/dist/templates/coding-agent/tools/glob.ts +6 -0
- package/dist/templates/coding-agent/tools/grep.ts +6 -0
- package/dist/templates/coding-agent/tools/list_files.ts +6 -0
- package/dist/templates/coding-agent/tools/read_file.ts +6 -0
- package/dist/templates/coding-agent/tools/todo_write.ts +6 -0
- package/dist/templates/coding-agent/tools/write_file.ts +6 -0
- package/dist/templates/custom-pipeline-agent/agent.eval.test.ts +79 -0
- package/dist/templates/custom-pipeline-agent/agent.test.ts +79 -0
- package/dist/templates/custom-pipeline-agent/agent.ts +13 -0
- package/dist/templates/custom-pipeline-agent/modes.test.ts +162 -0
- package/dist/templates/custom-pipeline-agent/stages.test.ts +330 -0
- package/dist/templates/document-redline-workflow/agent.eval.test.ts +254 -0
- package/dist/templates/document-redline-workflow/agent.test.ts +552 -0
- package/dist/templates/document-redline-workflow/agent.ts +112 -0
- package/dist/templates/document-redline-workflow/client.tsx +224 -0
- package/dist/templates/document-redline-workflow/form.ts +74 -0
- package/dist/templates/document-redline-workflow/workflows/prompts.ts +68 -0
- package/dist/templates/document-redline-workflow/workflows/redline.ts +317 -0
- package/dist/templates/emergency-dispatch-agent/agent.eval.test.ts +372 -0
- package/dist/templates/emergency-dispatch-agent/agent.test.ts +576 -0
- package/dist/templates/emergency-dispatch-agent/agent.ts +63 -0
- package/dist/templates/emergency-dispatch-agent/client.tsx +453 -0
- package/dist/templates/emergency-dispatch-agent/events.ts +48 -0
- package/dist/templates/emergency-dispatch-agent/guardrails.ts +105 -0
- package/dist/templates/emergency-dispatch-agent/shared.ts +768 -0
- package/dist/templates/emergency-dispatch-agent/system-prompt.md +42 -0
- package/dist/templates/emergency-dispatch-agent/tools/incident_add_note.ts +28 -0
- package/dist/templates/emergency-dispatch-agent/tools/incident_create.ts +95 -0
- package/dist/templates/emergency-dispatch-agent/tools/incident_escalate.ts +96 -0
- package/dist/templates/emergency-dispatch-agent/tools/incident_get.ts +40 -0
- package/dist/templates/emergency-dispatch-agent/tools/incident_triage.ts +90 -0
- package/dist/templates/emergency-dispatch-agent/tools/incident_update_status.ts +75 -0
- package/dist/templates/emergency-dispatch-agent/tools/ops_dashboard.ts +72 -0
- package/dist/templates/emergency-dispatch-agent/tools/ops_protocols.ts +27 -0
- package/dist/templates/emergency-dispatch-agent/tools/ops_run_scenario.ts +154 -0
- package/dist/templates/emergency-dispatch-agent/tools/resources_dispatch.ts +112 -0
- package/dist/templates/emergency-dispatch-agent/tools/resources_get_available.ts +34 -0
- package/dist/templates/emergency-dispatch-agent/tools/resources_update_status.ts +63 -0
- package/dist/templates/entertainment-picks-agent/agent.eval.test.ts +281 -0
- package/dist/templates/entertainment-picks-agent/agent.test.ts +260 -0
- package/dist/templates/entertainment-picks-agent/agent.ts +14 -0
- package/dist/templates/entertainment-picks-agent/client.tsx +169 -0
- package/dist/templates/entertainment-picks-agent/shared.ts +50 -0
- package/dist/templates/entertainment-picks-agent/system-prompt.md +19 -0
- package/dist/templates/entertainment-picks-agent/tools/recommend.ts +79 -0
- package/dist/templates/entertainment-picks-agent/tools/revisit.ts +56 -0
- package/dist/templates/executive-inbox-agent/agent.eval.test.ts +296 -0
- package/dist/templates/executive-inbox-agent/agent.test.ts +682 -0
- package/dist/templates/executive-inbox-agent/agent.ts +51 -0
- package/dist/templates/executive-inbox-agent/calendar.test.ts +203 -0
- package/dist/templates/executive-inbox-agent/client.tsx +195 -0
- package/dist/templates/executive-inbox-agent/inbox.ts +233 -0
- package/dist/templates/executive-inbox-agent/meeting.ts +138 -0
- package/dist/templates/executive-inbox-agent/nodes.ts +148 -0
- package/dist/templates/executive-inbox-agent/prompts.ts +333 -0
- package/dist/templates/executive-inbox-agent/review.ts +425 -0
- package/dist/templates/executive-inbox-agent/shared.ts +486 -0
- package/dist/templates/executive-inbox-agent/system-prompt.md +15 -0
- package/dist/templates/executive-inbox-agent/tools/accept.ts +10 -0
- package/dist/templates/executive-inbox-agent/tools/ask_question.ts +30 -0
- package/dist/templates/executive-inbox-agent/tools/draft_reply.ts +67 -0
- package/dist/templates/executive-inbox-agent/tools/edit.ts +10 -0
- package/dist/templates/executive-inbox-agent/tools/ignore.ts +10 -0
- package/dist/templates/executive-inbox-agent/tools/inbox_status.ts +27 -0
- package/dist/templates/executive-inbox-agent/tools/meeting_assistant.ts +52 -0
- package/dist/templates/executive-inbox-agent/tools/new_email.ts +50 -0
- package/dist/templates/executive-inbox-agent/tools/open_email.ts +157 -0
- package/dist/templates/executive-inbox-agent/tools/respond.ts +10 -0
- package/dist/templates/executive-inbox-agent/tools/review_memory.ts +22 -0
- package/dist/templates/executive-inbox-agent/tools/send_calendar_invite.ts +68 -0
- package/dist/templates/executive-inbox-agent/tools/triage_inbox.ts +75 -0
- package/dist/templates/front-desk-agent/agent.eval.test.ts +177 -0
- package/dist/templates/front-desk-agent/agent.test.ts +155 -0
- package/dist/templates/front-desk-agent/agent.ts +22 -0
- package/dist/templates/front-desk-agent/shared.ts +239 -0
- package/dist/templates/front-desk-agent/system-prompt.md +13 -0
- package/dist/templates/front-desk-agent/tools/verify_account.ts +41 -0
- package/dist/templates/home-assistant-agent/agent.eval.test.ts +176 -0
- package/dist/templates/home-assistant-agent/agent.test.ts +513 -0
- package/dist/templates/home-assistant-agent/agent.ts +37 -0
- package/dist/templates/home-assistant-agent/client.tsx +176 -0
- package/dist/templates/home-assistant-agent/ring.tsx +55 -0
- package/dist/templates/home-assistant-agent/shared.ts +130 -0
- package/dist/templates/home-assistant-agent/system-prompt.md +43 -0
- package/dist/templates/home-assistant-agent/tools/cancel_reminders.ts +16 -0
- package/dist/templates/home-assistant-agent/tools/deep_research.ts +55 -0
- package/dist/templates/home-assistant-agent/tools/remind_me.ts +53 -0
- package/dist/templates/home-assistant-agent/tools/stop.ts +25 -0
- package/dist/templates/home-assistant-agent/use-speaker.ts +98 -0
- package/dist/templates/home-assistant-agent/workflows/remind.ts +25 -0
- package/dist/templates/home-assistant-agent/workflows/research-prompts.ts +41 -0
- package/dist/templates/home-assistant-agent/workflows/research.ts +110 -0
- package/dist/templates/home-assistant-agent/workflows/text.ts +30 -0
- package/dist/templates/hotel-reception-agent/agent.eval.test.ts +241 -0
- package/dist/templates/hotel-reception-agent/agent.test.ts +1121 -0
- package/dist/templates/hotel-reception-agent/agent.ts +66 -0
- package/dist/templates/hotel-reception-agent/booking.ts +159 -0
- package/dist/templates/hotel-reception-agent/card.ts +92 -0
- package/dist/templates/hotel-reception-agent/catalogs.ts +219 -0
- package/dist/templates/hotel-reception-agent/client.tsx +150 -0
- package/dist/templates/hotel-reception-agent/concierge.ts +104 -0
- package/dist/templates/hotel-reception-agent/desk-seams.test.ts +339 -0
- package/dist/templates/hotel-reception-agent/desk.ts +220 -0
- package/dist/templates/hotel-reception-agent/disputes.ts +214 -0
- package/dist/templates/hotel-reception-agent/events.ts +80 -0
- package/dist/templates/hotel-reception-agent/hotel.ts +412 -0
- package/dist/templates/hotel-reception-agent/policies.ts +209 -0
- package/dist/templates/hotel-reception-agent/records.ts +384 -0
- package/dist/templates/hotel-reception-agent/restaurant.ts +147 -0
- package/dist/templates/hotel-reception-agent/seed.ts +955 -0
- package/dist/templates/hotel-reception-agent/session.ts +50 -0
- package/dist/templates/hotel-reception-agent/shared.ts +353 -0
- package/dist/templates/hotel-reception-agent/system-prompt.md +76 -0
- package/dist/templates/hotel-reception-agent/tools/abandon_booking.ts +31 -0
- package/dist/templates/hotel-reception-agent/tools/add_to_waitlist.ts +42 -0
- package/dist/templates/hotel-reception-agent/tools/book_airport_car.ts +58 -0
- package/dist/templates/hotel-reception-agent/tools/book_business_center.ts +44 -0
- package/dist/templates/hotel-reception-agent/tools/book_spa_appointment.ts +39 -0
- package/dist/templates/hotel-reception-agent/tools/book_tour.ts +35 -0
- package/dist/templates/hotel-reception-agent/tools/cancel_restaurant_reservation.ts +26 -0
- package/dist/templates/hotel-reception-agent/tools/cancel_room_booking.ts +64 -0
- package/dist/templates/hotel-reception-agent/tools/check_restaurant_availability.ts +24 -0
- package/dist/templates/hotel-reception-agent/tools/check_room_availability.ts +40 -0
- package/dist/templates/hotel-reception-agent/tools/choose_room.ts +93 -0
- package/dist/templates/hotel-reception-agent/tools/confirm_booking.ts +154 -0
- package/dist/templates/hotel-reception-agent/tools/dispatch_emergency.ts +62 -0
- package/dist/templates/hotel-reception-agent/tools/dispute_charge.ts +91 -0
- package/dist/templates/hotel-reception-agent/tools/flag_late_arrival.ts +27 -0
- package/dist/templates/hotel-reception-agent/tools/lookup_booking.ts +49 -0
- package/dist/templates/hotel-reception-agent/tools/lookup_guest_history.ts +28 -0
- package/dist/templates/hotel-reception-agent/tools/lookup_invoice.ts +27 -0
- package/dist/templates/hotel-reception-agent/tools/lookup_policy.ts +20 -0
- package/dist/templates/hotel-reception-agent/tools/lookup_restaurant_reservation.ts +27 -0
- package/dist/templates/hotel-reception-agent/tools/modify_restaurant_reservation.ts +75 -0
- package/dist/templates/hotel-reception-agent/tools/order_flowers.ts +40 -0
- package/dist/templates/hotel-reception-agent/tools/record_card.ts +46 -0
- package/dist/templates/hotel-reception-agent/tools/record_followup.ts +51 -0
- package/dist/templates/hotel-reception-agent/tools/record_group_inquiry.ts +45 -0
- package/dist/templates/hotel-reception-agent/tools/record_guest_details.ts +71 -0
- package/dist/templates/hotel-reception-agent/tools/reinstate_booking.ts +65 -0
- package/dist/templates/hotel-reception-agent/tools/request_flight_reconfirmation.ts +55 -0
- package/dist/templates/hotel-reception-agent/tools/resend_confirmation.ts +40 -0
- package/dist/templates/hotel-reception-agent/tools/reserve_table.ts +87 -0
- package/dist/templates/hotel-reception-agent/tools/resolve_room_conflict.ts +49 -0
- package/dist/templates/hotel-reception-agent/tools/schedule_wakeup_call.ts +49 -0
- package/dist/templates/hotel-reception-agent/tools/set_do_not_disturb.ts +29 -0
- package/dist/templates/hotel-reception-agent/tools/set_extras.ts +51 -0
- package/dist/templates/hotel-reception-agent/tools/set_stay.ts +98 -0
- package/dist/templates/hotel-reception-agent/tools/start_booking_modification.ts +58 -0
- package/dist/templates/hotel-reception-agent/tools/start_room_booking.ts +50 -0
- package/dist/templates/hotel-reception-agent/tools/take_guest_message.ts +72 -0
- package/dist/templates/hotel-reception-agent/tools/transfer_call.ts +48 -0
- package/dist/templates/hotel-reception-agent/tools/update_card.ts +46 -0
- package/dist/templates/hotel-reception-agent/tools/verify_booking.ts +96 -0
- package/dist/templates/link-digest-workflow/agent.eval.test.ts +231 -0
- package/dist/templates/link-digest-workflow/agent.test.ts +647 -0
- package/dist/templates/link-digest-workflow/agent.ts +100 -0
- package/dist/templates/link-digest-workflow/api-client.ts +144 -0
- package/dist/templates/link-digest-workflow/client.tsx +231 -0
- package/dist/templates/link-digest-workflow/workflows/digest.ts +334 -0
- package/dist/templates/medication-safety-agent/agent.eval.test.ts +182 -0
- package/dist/templates/medication-safety-agent/agent.test.ts +332 -0
- package/dist/templates/medication-safety-agent/agent.ts +62 -0
- package/dist/templates/medication-safety-agent/fda.test.ts +130 -0
- package/dist/templates/medication-safety-agent/fda.ts +159 -0
- package/dist/templates/medication-safety-agent/system-prompt.md +26 -0
- package/dist/templates/medication-safety-agent/tools/check_drug_interaction.ts +62 -0
- package/dist/templates/medication-safety-agent/tools/medication_lookup.ts +36 -0
- package/dist/templates/meeting-recap-agent/agent.eval.test.ts +446 -0
- package/dist/templates/meeting-recap-agent/agent.test.ts +1408 -0
- package/dist/templates/meeting-recap-agent/agent.ts +104 -0
- package/dist/templates/meeting-recap-agent/shared.ts +44 -0
- package/dist/templates/meeting-recap-agent/tools/cancel_recap.ts +23 -0
- package/dist/templates/meeting-recap-agent/tools/keep_transcript.ts +31 -0
- package/dist/templates/meeting-recap-agent/tools/recap_progress.ts +24 -0
- package/dist/templates/meeting-recap-agent/tools/recap_status.ts +45 -0
- package/dist/templates/meeting-recap-agent/tools/request_recap.ts +44 -0
- package/dist/templates/meeting-recap-agent/workflows/recap.ts +838 -0
- package/dist/templates/meeting-recap-agent/workflows/tokens.ts +47 -0
- package/dist/templates/pizza-ordering-agent/agent.eval.test.ts +228 -0
- package/dist/templates/pizza-ordering-agent/agent.test.ts +299 -0
- package/dist/templates/pizza-ordering-agent/agent.ts +24 -0
- package/dist/templates/pizza-ordering-agent/client.tsx +104 -0
- package/dist/templates/pizza-ordering-agent/shared.ts +225 -0
- package/dist/templates/pizza-ordering-agent/system-prompt.md +23 -0
- package/dist/templates/pizza-ordering-agent/tools/add_pizza.ts +27 -0
- package/dist/templates/pizza-ordering-agent/tools/place_order.ts +26 -0
- package/dist/templates/pizza-ordering-agent/tools/remove_pizza.ts +18 -0
- package/dist/templates/pizza-ordering-agent/tools/set_customer_name.ts +13 -0
- package/dist/templates/pizza-ordering-agent/tools/update_pizza.ts +28 -0
- package/dist/templates/pizza-ordering-agent/tools/view_order.ts +21 -0
- package/dist/templates/podcast-digest-workflow/agent.eval.test.ts +421 -0
- package/dist/templates/podcast-digest-workflow/agent.test.ts +1225 -0
- package/dist/templates/podcast-digest-workflow/agent.ts +143 -0
- package/dist/templates/podcast-digest-workflow/client.tsx +259 -0
- package/dist/templates/podcast-digest-workflow/workflows/digest.ts +499 -0
- package/dist/templates/podcast-digest-workflow/workflows/feeds.ts +575 -0
- package/dist/templates/podcast-digest-workflow/workflows/slack.ts +153 -0
- package/dist/templates/push-to-talk-agent/agent.eval.test.ts +78 -0
- package/dist/templates/push-to-talk-agent/agent.test.ts +63 -0
- package/dist/templates/push-to-talk-agent/agent.ts +22 -0
- package/dist/templates/push-to-talk-agent/client.tsx +124 -0
- package/dist/templates/push-to-talk-agent/shared.ts +28 -0
- package/dist/templates/push-to-talk-agent/system-prompt.md +11 -0
- package/dist/templates/push-to-talk-agent/tools/list_notes.ts +15 -0
- package/dist/templates/push-to-talk-agent/tools/save_note.ts +26 -0
- package/dist/templates/quickstart-agent/agent.eval.test.ts +148 -0
- package/dist/templates/quickstart-agent/agent.test.ts +96 -0
- package/dist/templates/quickstart-agent/agent.ts +25 -0
- package/dist/templates/quickstart-agent/system-prompt.md +8 -0
- package/dist/templates/quickstart-agent/tools/get_weather.ts +59 -0
- package/dist/templates/research-handoff-agent/agent.eval.test.ts +341 -0
- package/dist/templates/research-handoff-agent/agent.test.ts +831 -0
- package/dist/templates/research-handoff-agent/agent.ts +118 -0
- package/dist/templates/research-handoff-agent/shared.ts +41 -0
- package/dist/templates/research-handoff-agent/tools/file_it_now.ts +32 -0
- package/dist/templates/research-handoff-agent/tools/request_research.ts +33 -0
- package/dist/templates/research-handoff-agent/tools/research_progress.ts +23 -0
- package/dist/templates/research-handoff-agent/tools/research_status.ts +73 -0
- package/dist/templates/research-handoff-agent/workflows/filing.ts +164 -0
- package/dist/templates/research-handoff-agent/workflows/prompts.ts +46 -0
- package/dist/templates/research-handoff-agent/workflows/research.ts +100 -0
- package/dist/templates/research-handoff-agent/workflows/review.ts +43 -0
- package/dist/templates/research-planner-agent/agent.eval.test.ts +241 -0
- package/dist/templates/research-planner-agent/agent.test.ts +635 -0
- package/dist/templates/research-planner-agent/agent.ts +26 -0
- package/dist/templates/research-planner-agent/client.tsx +120 -0
- package/dist/templates/research-planner-agent/procedure.ts +287 -0
- package/dist/templates/research-planner-agent/prompts.ts +153 -0
- package/dist/templates/research-planner-agent/shared.ts +327 -0
- package/dist/templates/research-planner-agent/system-prompt.md +18 -0
- package/dist/templates/research-planner-agent/tools/plan_status.ts +41 -0
- package/dist/templates/research-planner-agent/tools/revise_plan.ts +71 -0
- package/dist/templates/research-planner-agent/tools/start_plan.ts +62 -0
- package/dist/templates/research-planner-agent/tools/work_next_step.ts +177 -0
- package/dist/templates/retail-orders-agent/address.ts +109 -0
- package/dist/templates/retail-orders-agent/agent.eval.test.ts +305 -0
- package/dist/templates/retail-orders-agent/agent.test.ts +1260 -0
- package/dist/templates/retail-orders-agent/agent.ts +103 -0
- package/dist/templates/retail-orders-agent/authenticate.ts +34 -0
- package/dist/templates/retail-orders-agent/cancel.ts +114 -0
- package/dist/templates/retail-orders-agent/client.tsx +579 -0
- package/dist/templates/retail-orders-agent/keyterms.ts +154 -0
- package/dist/templates/retail-orders-agent/payment.ts +103 -0
- package/dist/templates/retail-orders-agent/pending.test.ts +204 -0
- package/dist/templates/retail-orders-agent/pending.ts +137 -0
- package/dist/templates/retail-orders-agent/refund.ts +19 -0
- package/dist/templates/retail-orders-agent/registry.test.ts +446 -0
- package/dist/templates/retail-orders-agent/resolve.test.ts +100 -0
- package/dist/templates/retail-orders-agent/resolve.ts +114 -0
- package/dist/templates/retail-orders-agent/returns.ts +101 -0
- package/dist/templates/retail-orders-agent/seed.json +4260 -0
- package/dist/templates/retail-orders-agent/seed.test.ts +233 -0
- package/dist/templates/retail-orders-agent/shared.test.ts +240 -0
- package/dist/templates/retail-orders-agent/shared.ts +547 -0
- package/dist/templates/retail-orders-agent/store.test.ts +331 -0
- package/dist/templates/retail-orders-agent/store.ts +485 -0
- package/dist/templates/retail-orders-agent/swap.test.ts +189 -0
- package/dist/templates/retail-orders-agent/swap.ts +358 -0
- package/dist/templates/retail-orders-agent/system-prompt.md +152 -0
- package/dist/templates/retail-orders-agent/tools/cancel_change.ts +33 -0
- package/dist/templates/retail-orders-agent/tools/cancel_pending_order.ts +31 -0
- package/dist/templates/retail-orders-agent/tools/confirm_change.ts +42 -0
- package/dist/templates/retail-orders-agent/tools/exchange_delivered_order_items.ts +47 -0
- package/dist/templates/retail-orders-agent/tools/find_user_id_by_email.ts +31 -0
- package/dist/templates/retail-orders-agent/tools/find_user_id_by_name_zip.ts +36 -0
- package/dist/templates/retail-orders-agent/tools/get_item_details.ts +27 -0
- package/dist/templates/retail-orders-agent/tools/get_order_details.ts +37 -0
- package/dist/templates/retail-orders-agent/tools/get_product_details.ts +30 -0
- package/dist/templates/retail-orders-agent/tools/get_user_details.ts +37 -0
- package/dist/templates/retail-orders-agent/tools/list_all_product_types.ts +22 -0
- package/dist/templates/retail-orders-agent/tools/modify_pending_order_address.ts +27 -0
- package/dist/templates/retail-orders-agent/tools/modify_pending_order_items.ts +48 -0
- package/dist/templates/retail-orders-agent/tools/modify_pending_order_payment.ts +32 -0
- package/dist/templates/retail-orders-agent/tools/modify_user_address.ts +26 -0
- package/dist/templates/retail-orders-agent/tools/return_delivered_order_items.ts +37 -0
- package/dist/templates/retail-orders-agent/tools/transfer_to_human_agents.ts +28 -0
- package/dist/templates/roadside-assistance-agent/agent.eval.test.ts +283 -0
- package/dist/templates/roadside-assistance-agent/agent.test.ts +650 -0
- package/dist/templates/roadside-assistance-agent/agent.ts +89 -0
- package/dist/templates/roadside-assistance-agent/call.ts +232 -0
- package/dist/templates/roadside-assistance-agent/events.ts +92 -0
- package/dist/templates/roadside-assistance-agent/shared.ts +346 -0
- package/dist/templates/roadside-assistance-agent/system-prompt.md +37 -0
- package/dist/templates/roadside-assistance-agent/tools/acknowledge_disclosure.ts +61 -0
- package/dist/templates/roadside-assistance-agent/tools/dispatch_truck.ts +149 -0
- package/dist/templates/roadside-assistance-agent/tools/job_status.ts +38 -0
- package/dist/templates/roadside-assistance-agent/tools/lookup_coverage.ts +83 -0
- package/dist/templates/roadside-assistance-agent/tools/report_location.ts +79 -0
- package/dist/templates/roadside-assistance-agent/tools/service_disclosure.ts +51 -0
- package/dist/templates/roadside-assistance-agent/yard.test.ts +162 -0
- package/dist/templates/roadside-assistance-agent/yard.ts +183 -0
- package/dist/templates/spoken-summary-workflow/agent.eval.test.ts +354 -0
- package/dist/templates/spoken-summary-workflow/agent.test.ts +493 -0
- package/dist/templates/spoken-summary-workflow/agent.ts +164 -0
- package/dist/templates/spoken-summary-workflow/client.tsx +220 -0
- package/dist/templates/spoken-summary-workflow/workflows/summarize.ts +260 -0
- package/dist/templates/spoken-summary-workflow/workflows/transcribe.ts +137 -0
- package/dist/templates/tabletop-rpg-agent/agent.eval.test.ts +314 -0
- package/dist/templates/tabletop-rpg-agent/agent.test.ts +1000 -0
- package/dist/templates/tabletop-rpg-agent/agent.ts +58 -0
- package/dist/templates/tabletop-rpg-agent/client.tsx +814 -0
- package/dist/templates/tabletop-rpg-agent/shared.ts +1028 -0
- package/dist/templates/tabletop-rpg-agent/system-prompt.md +116 -0
- package/dist/templates/tabletop-rpg-agent/tools/action_roll.ts +119 -0
- package/dist/templates/tabletop-rpg-agent/tools/burn_momentum.ts +110 -0
- package/dist/templates/tabletop-rpg-agent/tools/check_state.ts +37 -0
- package/dist/templates/tabletop-rpg-agent/tools/oracle.ts +255 -0
- package/dist/templates/tabletop-rpg-agent/tools/setup_character.ts +228 -0
- package/dist/templates/tabletop-rpg-agent/tools/update_state.ts +194 -0
- package/dist/templates/technical-support-agent/agent.eval.test.ts +260 -0
- package/dist/templates/technical-support-agent/agent.test.ts +424 -0
- package/dist/templates/technical-support-agent/agent.ts +39 -0
- package/dist/templates/technical-support-agent/client.tsx +132 -0
- package/dist/templates/technical-support-agent/knowledge.json +65 -0
- package/dist/templates/technical-support-agent/knowledge.ts +165 -0
- package/dist/templates/technical-support-agent/nodes.ts +143 -0
- package/dist/templates/technical-support-agent/procedure.ts +453 -0
- package/dist/templates/technical-support-agent/prompts.ts +102 -0
- package/dist/templates/technical-support-agent/shared.ts +128 -0
- package/dist/templates/technical-support-agent/system-prompt.md +18 -0
- package/dist/templates/technical-support-agent/tools/answer_question.ts +134 -0
- package/dist/templates/technical-support-agent/tools/list_topics.ts +23 -0
- package/dist/templates/technical-support-agent/tools/log_ticket.ts +30 -0
- package/dist/templates/text-adventure-agent/agent.eval.test.ts +222 -0
- package/dist/templates/text-adventure-agent/agent.test.ts +429 -0
- package/dist/templates/text-adventure-agent/agent.ts +76 -0
- package/dist/templates/text-adventure-agent/client.tsx +359 -0
- package/dist/templates/text-adventure-agent/shared.ts +210 -0
- package/dist/templates/text-adventure-agent/system-prompt.md +50 -0
- package/dist/templates/text-adventure-agent/tools/game_state_drop.ts +29 -0
- package/dist/templates/text-adventure-agent/tools/game_state_flag.ts +13 -0
- package/dist/templates/text-adventure-agent/tools/game_state_get.ts +17 -0
- package/dist/templates/text-adventure-agent/tools/game_state_move.ts +15 -0
- package/dist/templates/text-adventure-agent/tools/game_state_restart.ts +13 -0
- package/dist/templates/text-adventure-agent/tools/game_state_score.ts +19 -0
- package/dist/templates/text-adventure-agent/tools/game_state_take.ts +13 -0
- package/dist/templates/topic-briefing-agent/agent.eval.test.ts +202 -0
- package/dist/templates/topic-briefing-agent/agent.test.ts +651 -0
- package/dist/templates/topic-briefing-agent/agent.ts +45 -0
- package/dist/templates/topic-briefing-agent/shared.ts +392 -0
- package/dist/templates/topic-briefing-agent/slack.ts +108 -0
- package/dist/templates/topic-briefing-agent/system-prompt.md +54 -0
- package/dist/templates/topic-briefing-agent/tools/briefing_so_far.ts +43 -0
- package/dist/templates/topic-briefing-agent/tools/research_topic.ts +80 -0
- package/dist/templates/topic-briefing-agent/tools/send_briefing.ts +115 -0
- package/dist/templates/topic-briefing-agent/tools/verify_claim.ts +123 -0
- package/dist/templates/transcription-workflow/agent.eval.test.ts +237 -0
- package/dist/templates/transcription-workflow/agent.test.ts +2032 -0
- package/dist/templates/transcription-workflow/agent.ts +188 -0
- package/dist/templates/transcription-workflow/client.tsx +511 -0
- package/dist/templates/transcription-workflow/recover.test.ts +222 -0
- package/dist/templates/transcription-workflow/recover.ts +154 -0
- package/dist/templates/transcription-workflow/run-panel.tsx +212 -0
- package/dist/templates/transcription-workflow/total-latency.tsx +170 -0
- package/dist/templates/transcription-workflow/workflows/batch.ts +189 -0
- package/dist/templates/transcription-workflow/workflows/downsample.ts +273 -0
- package/dist/templates/transcription-workflow/workflows/normalize.ts +385 -0
- package/dist/templates/transcription-workflow/workflows/stitch.ts +122 -0
- package/dist/templates/transcription-workflow/workflows/stream.ts +690 -0
- package/dist/templates/transcription-workflow/workflows/sync-api.ts +81 -0
- package/dist/templates/transcription-workflow/workflows/transcribe.ts +479 -0
- package/dist/templates/transcription-workflow/workflows/wav.ts +250 -0
- package/dist/templates/travel-concierge-agent/agent.eval.test.ts +300 -0
- package/dist/templates/travel-concierge-agent/agent.test.ts +601 -0
- package/dist/templates/travel-concierge-agent/agent.ts +62 -0
- package/dist/templates/travel-concierge-agent/call-events.ts +80 -0
- package/dist/templates/travel-concierge-agent/client.tsx +146 -0
- package/dist/templates/travel-concierge-agent/routing.ts +170 -0
- package/dist/templates/travel-concierge-agent/shared.ts +862 -0
- package/dist/templates/travel-concierge-agent/system-prompt.md +30 -0
- package/dist/templates/travel-concierge-agent/tools/book_car_rental.ts +21 -0
- package/dist/templates/travel-concierge-agent/tools/book_excursion.ts +19 -0
- package/dist/templates/travel-concierge-agent/tools/book_hotel.ts +21 -0
- package/dist/templates/travel-concierge-agent/tools/cancel_action.ts +9 -0
- package/dist/templates/travel-concierge-agent/tools/cancel_ticket.ts +21 -0
- package/dist/templates/travel-concierge-agent/tools/complete_or_escalate.ts +9 -0
- package/dist/templates/travel-concierge-agent/tools/confirm_action.ts +9 -0
- package/dist/templates/travel-concierge-agent/tools/lookup_booking.ts +36 -0
- package/dist/templates/travel-concierge-agent/tools/search_car_rentals.ts +36 -0
- package/dist/templates/travel-concierge-agent/tools/search_excursions.ts +40 -0
- package/dist/templates/travel-concierge-agent/tools/search_flights.ts +58 -0
- package/dist/templates/travel-concierge-agent/tools/search_hotels.ts +39 -0
- package/dist/templates/travel-concierge-agent/tools/to_car_rental_assistant.ts +11 -0
- package/dist/templates/travel-concierge-agent/tools/to_excursion_assistant.ts +11 -0
- package/dist/templates/travel-concierge-agent/tools/to_flight_assistant.ts +11 -0
- package/dist/templates/travel-concierge-agent/tools/to_hotel_assistant.ts +11 -0
- package/dist/templates/travel-concierge-agent/tools/update_ticket.ts +23 -0
- package/dist/templates/web-research-agent/agent.eval.test.ts +144 -0
- package/dist/templates/web-research-agent/agent.test.ts +181 -0
- package/dist/templates/web-research-agent/agent.ts +128 -0
- package/dist/templates/web-research-agent/system-prompt.md +33 -0
- package/dist/templates/word-game-agent/agent.eval.test.ts +222 -0
- package/dist/templates/word-game-agent/agent.test.ts +484 -0
- package/dist/templates/word-game-agent/agent.ts +55 -0
- package/dist/templates/word-game-agent/client.tsx +211 -0
- package/dist/templates/word-game-agent/game.ts +133 -0
- package/dist/templates/word-game-agent/guess.ts +63 -0
- package/dist/templates/word-game-agent/player.ts +67 -0
- package/dist/templates/word-game-agent/shared.ts +249 -0
- package/dist/templates/word-game-agent/system-prompt.md +15 -0
- package/dist/templates/word-game-agent/tools/final_score.ts +37 -0
- package/dist/templates/word-game-agent/tools/relay_description.ts +137 -0
- package/dist/templates/word-game-agent/tools/repeat_word.ts +19 -0
- package/dist/templates/word-game-agent/tools/skip_word.ts +31 -0
- package/dist/templates/word-game-agent/tools/start_game.ts +52 -0
- package/dist/templates/word-game-agent/words.ts +278 -0
- package/dist/test-XufelYGW.mjs +104 -0
- package/dist/test.d.ts +81 -0
- package/dist/typecheck.d.ts +44 -0
- package/dist/typecheck.mjs +185 -0
- package/dist/worker-bundler.d.ts +37 -0
- package/dist/worker-bundler.mjs +156 -0
- package/dist/workflow-CDUlTD5B.mjs +239 -0
- package/dist/workflow.d.ts +76 -0
- package/package.json +74 -28
- package/dist/_api-client-H4MFOr8j.mjs +0 -35
- package/dist/_bundler-DQtFVeww.mjs +0 -125
- package/dist/_discover-DzsMlg3G.mjs +0 -218
- package/dist/_init-CbMs9S2O.mjs +0 -56
- package/dist/_templates-BDkbj3TM.mjs +0 -72
- package/dist/_ui-DWGXImbO.mjs +0 -30
- package/dist/delete-CalIL6Pg.mjs +0 -34
- package/dist/deploy-CLs8gLHV.mjs +0 -53
- package/dist/dev-DEZKrw8v.mjs +0 -18
- package/dist/init-CNuntiij.mjs +0 -114
- package/dist/secret-xmLQ96Yz.mjs +0 -46
- package/dist/test-yqHGZPF3.mjs +0 -44
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { tool, toolFailure } from "@alexkroman1/aai";
|
|
2
|
+
import { mapSettled, partitionSettled } from "@alexkroman1/aai/step";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { briefingSlot, MAX_ANGLES, researchAngle } from "../shared.ts";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Fan a topic out across angles, one researcher subagent each, in PARALLEL.
|
|
8
|
+
*
|
|
9
|
+
* **The settled fan-out is the template's whole point.** Each angle is an
|
|
10
|
+
* independent run with its own context window, so four of them cost the caller
|
|
11
|
+
* the SLOWEST one rather than the sum — and nothing they read reaches this
|
|
12
|
+
* conversation, only what each one concluded. Running the same four angles as
|
|
13
|
+
* four `ctx.generate` calls in one loop would be slower and would put every
|
|
14
|
+
* intermediate page in the desk's own prompt.
|
|
15
|
+
*
|
|
16
|
+
* **Settled, not raced.** One angle that fails (a provider hiccup, a subagent
|
|
17
|
+
* that ran out of budget with nothing to say) must not sink a briefing whose
|
|
18
|
+
* other three came back — a caller on the phone would rather hear three answers
|
|
19
|
+
* and one apology than an error. `mapSettled` keeps each angle beside its
|
|
20
|
+
* outcome, so the failures are reported BY ANGLE and the desk can say which one
|
|
21
|
+
* is missing and offer to retry it. `Infinity` is the width `allSettled` had:
|
|
22
|
+
* `MAX_ANGLES` already bounds the fan-out at the schema.
|
|
23
|
+
*
|
|
24
|
+
* **The await comes first, then the mutation.** `slot.update`'s window is
|
|
25
|
+
* synchronous by contract, so the fan-out finishes before the board is touched
|
|
26
|
+
* and the whole write lands at once.
|
|
27
|
+
*/
|
|
28
|
+
export default tool({
|
|
29
|
+
description:
|
|
30
|
+
"Research a topic across several angles at once and report what each one " +
|
|
31
|
+
"found. Use this when the caller asks about something you would need to " +
|
|
32
|
+
"look up. Pick the angles yourself from what they said — two or three is " +
|
|
33
|
+
"usually right. Tell them you are looking it up before you call this.",
|
|
34
|
+
inputSchema: z.object({
|
|
35
|
+
topic: z.string().max(200).describe("The subject, in the caller's own terms"),
|
|
36
|
+
angles: z
|
|
37
|
+
.array(z.string().max(200))
|
|
38
|
+
.min(1)
|
|
39
|
+
.max(MAX_ANGLES)
|
|
40
|
+
.describe(
|
|
41
|
+
"The separate questions to research, one per researcher. Each must " +
|
|
42
|
+
"stand on its own: a researcher has not heard the conversation.",
|
|
43
|
+
),
|
|
44
|
+
}),
|
|
45
|
+
async execute(args, ctx) {
|
|
46
|
+
const angles = args.angles.map((angle) => angle.trim()).filter((angle) => angle.length > 0);
|
|
47
|
+
if (angles.length === 0) {
|
|
48
|
+
return toolFailure("No angles to research — say what the caller wants looked up.");
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const { ok, failed } = partitionSettled(
|
|
52
|
+
await mapSettled(angles, Number.POSITIVE_INFINITY, (angle) =>
|
|
53
|
+
researchAngle(ctx.delegate, args.topic, angle),
|
|
54
|
+
),
|
|
55
|
+
);
|
|
56
|
+
if (ok.length === 0) {
|
|
57
|
+
return toolFailure(
|
|
58
|
+
`Every angle failed. The first said: ${failed[0]?.error ?? "no reason given"}`,
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
const summaries = ok.map((one) => one.value);
|
|
62
|
+
const failures = failed.map((one) => ({ angle: one.item, error: one.error }));
|
|
63
|
+
|
|
64
|
+
return briefingSlot.update(ctx, (board) => {
|
|
65
|
+
board.topic = args.topic;
|
|
66
|
+
board.findings.push(...summaries);
|
|
67
|
+
return {
|
|
68
|
+
topic: args.topic,
|
|
69
|
+
findings: summaries,
|
|
70
|
+
failed: failures,
|
|
71
|
+
message:
|
|
72
|
+
"Give the caller the through-line first, in one or two sentences, then " +
|
|
73
|
+
"the angles. Do not read the summaries out verbatim." +
|
|
74
|
+
(failures.length > 0
|
|
75
|
+
? " Mention which angle you could not get to and offer to try it again."
|
|
76
|
+
: ""),
|
|
77
|
+
};
|
|
78
|
+
});
|
|
79
|
+
},
|
|
80
|
+
});
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import {
|
|
2
|
+
errorMessage,
|
|
3
|
+
isToolFailure,
|
|
4
|
+
requireEnv,
|
|
5
|
+
type ToolErrorHandler,
|
|
6
|
+
toolFailure,
|
|
7
|
+
} from "@alexkroman1/aai";
|
|
8
|
+
import { ChannelDeliveryError, sendToChannel } from "@alexkroman1/aai/channels";
|
|
9
|
+
import { z } from "zod";
|
|
10
|
+
import { briefingSlot } from "../shared.ts";
|
|
11
|
+
import { briefingChannel, briefingMessage, DESTINATION_ENV } from "../slack.ts";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Anything that reaches here is a deploy nobody finished or a bug in this file
|
|
15
|
+
* — see the note on the tool below — and neither is fixed by asking the model
|
|
16
|
+
* to try again, so it goes back up as a fatal failure.
|
|
17
|
+
*
|
|
18
|
+
* Named, with its type spelled, because the type is what says what the two
|
|
19
|
+
* outcomes are: RETURN a `ToolFailure` (or a string) and the model reads it and
|
|
20
|
+
* carries on; THROW and the call ends without an answer.
|
|
21
|
+
*/
|
|
22
|
+
const unfinishedDeployIsFatal: ToolErrorHandler = (err) => {
|
|
23
|
+
throw err;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Post the board to the desk's Slack channel, so the briefing outlives the
|
|
28
|
+
* call.
|
|
29
|
+
*
|
|
30
|
+
* **Read as a subagent template, this is the tool that does NOT delegate**, and
|
|
31
|
+
* that is why it is here. Everything the desk knows came back from a subagent
|
|
32
|
+
* with its own context window; what crossed into the conversation is one
|
|
33
|
+
* paragraph per angle, and those paragraphs are already on the slot. Sending
|
|
34
|
+
* them costs no model, no researcher and no second look at the web — the same
|
|
35
|
+
* argument `briefing_so_far` makes, one step further.
|
|
36
|
+
*
|
|
37
|
+
* **`slot.tool`, because it READS the board and writes nothing.** A `tool()`
|
|
38
|
+
* opening with `briefingSlot.get(ctx)` would say the same thing in code and
|
|
39
|
+
* nothing in the declaration; what a read is handed is deep-frozen, so a body
|
|
40
|
+
* that meant to mutate stops compiling here rather than failing at a caller.
|
|
41
|
+
*
|
|
42
|
+
* **The credential is `ctx.env`, through `requireEnv`, and it THROWS.** That is
|
|
43
|
+
* the one deliberate throw in this template. A missing key is not a refusal the
|
|
44
|
+
* desk can talk its way around and not something the caller did — it is a
|
|
45
|
+
* deploy nobody finished — so the SDK's own message names the variable and how
|
|
46
|
+
* to set it. Everything a call CAN recover from is a `ToolFailure` below.
|
|
47
|
+
*
|
|
48
|
+
* **And `onError` is what makes that throw mean something.** Without it the
|
|
49
|
+
* runtime hands every exception to the model as this call's result, so a
|
|
50
|
+
* webhook nobody configured reads as an ordinary hiccup: the desk apologises,
|
|
51
|
+
* calls `send_briefing` again, gets the same sentence, and spends the reply's
|
|
52
|
+
* whole `maxSteps` budget on a variable that will still be unset on the next
|
|
53
|
+
* attempt. Re-throwing declares the failure FATAL — the call rejects, the model
|
|
54
|
+
* is handed nothing to retry against, and the runtime reports it as a `tool`
|
|
55
|
+
* session error where whoever deployed this can see it.
|
|
56
|
+
*
|
|
57
|
+
* **Blanket, and only because of the shape of this body.** Every failure the
|
|
58
|
+
* desk can talk about is RETURNED above and below — the empty board, a
|
|
59
|
+
* destination that is not Slack, both halves of a `ChannelDeliveryError` — so
|
|
60
|
+
* anything that reaches `onError` here is a deploy that is not finished or a
|
|
61
|
+
* bug in this file, and neither is fixed by asking the model to try again. A
|
|
62
|
+
* tool whose body can throw for a transient reason should classify instead:
|
|
63
|
+
* return a `ToolFailure` for the recoverable throws and re-throw only the rest.
|
|
64
|
+
*/
|
|
65
|
+
export default briefingSlot.tool({
|
|
66
|
+
description:
|
|
67
|
+
"Send the briefing so far to the team's Slack channel. Use it when the caller " +
|
|
68
|
+
"asks for it in writing, or to have it passed on to someone who was not on the " +
|
|
69
|
+
"call. Tell them you are sending it before you call this.",
|
|
70
|
+
inputSchema: z.object({}),
|
|
71
|
+
async execute(_args, board, ctx) {
|
|
72
|
+
if (board.findings.length === 0) {
|
|
73
|
+
return toolFailure(
|
|
74
|
+
"There is nothing to send yet — research something first, then offer to send it.",
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const destination = briefingChannel(requireEnv(ctx, DESTINATION_ENV));
|
|
79
|
+
if (isToolFailure(destination)) return destination;
|
|
80
|
+
|
|
81
|
+
try {
|
|
82
|
+
await sendToChannel(destination, briefingMessage(board));
|
|
83
|
+
} catch (err: unknown) {
|
|
84
|
+
// The channel has already classified the refusal, which is the whole
|
|
85
|
+
// reason this is not a `fetch` and an `if (!res.ok)`: `retryable` is the
|
|
86
|
+
// 4xx/5xx split, and its message carries Slack's own advice for the half
|
|
87
|
+
// that will answer the same way forever. What is left for the desk is
|
|
88
|
+
// what to SAY, and the two are opposite — offering to try again after a
|
|
89
|
+
// revoked webhook is a promise it cannot keep.
|
|
90
|
+
if (err instanceof ChannelDeliveryError) {
|
|
91
|
+
return toolFailure(
|
|
92
|
+
err.retryable
|
|
93
|
+
? `Slack did not take the briefing: ${err.message} Tell the caller it has not ` +
|
|
94
|
+
"sent yet and offer to try again in a moment."
|
|
95
|
+
: `Slack refused the briefing: ${err.message} Tell the caller it has not sent ` +
|
|
96
|
+
"and that trying again will not help — someone has to fix the destination.",
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
return toolFailure(`The briefing did not send: ${errorMessage(err)}`);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return {
|
|
103
|
+
topic: board.topic,
|
|
104
|
+
sent: board.findings.length,
|
|
105
|
+
message:
|
|
106
|
+
"Say it has gone to the channel and how many angles went with it. Do not read " +
|
|
107
|
+
"the briefing back out — they have it in writing now.",
|
|
108
|
+
};
|
|
109
|
+
},
|
|
110
|
+
// See the note above: the only throw this body has is `requireEnv`'s, and a
|
|
111
|
+
// missing webhook is unfixable from inside the call. Re-throwing keeps the
|
|
112
|
+
// SDK's own message — which names the variable and how to set it — as the
|
|
113
|
+
// fatal error's `cause`.
|
|
114
|
+
onError: unfinishedDeployIsFatal,
|
|
115
|
+
});
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type DeepReadonly,
|
|
3
|
+
errorMessage,
|
|
4
|
+
isToolFailure,
|
|
5
|
+
omitUndefined,
|
|
6
|
+
type TypedDelegateResult,
|
|
7
|
+
toolFailure,
|
|
8
|
+
} from "@alexkroman1/aai";
|
|
9
|
+
import { z } from "zod";
|
|
10
|
+
import {
|
|
11
|
+
briefingSlot,
|
|
12
|
+
countWork,
|
|
13
|
+
type Finding,
|
|
14
|
+
factChecker,
|
|
15
|
+
findByAngle,
|
|
16
|
+
type Verdict,
|
|
17
|
+
} from "../shared.ts";
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Check one sentence against the web, on the narrower of the desk's two
|
|
21
|
+
* subagents.
|
|
22
|
+
*
|
|
23
|
+
* **Why this is a second SUBAGENT and not a second prompt.** Checking a claim
|
|
24
|
+
* needs a search and one sentence back, so it runs on a cheaper model with a
|
|
25
|
+
* third of the researcher's budget and search only — no page reads. Expressing
|
|
26
|
+
* that as `ctx.generate` would mean the desk doing the searching itself, in the
|
|
27
|
+
* conversation's own context; expressing it as one subagent with two modes
|
|
28
|
+
* would mean a run that can browse whenever the model feels like it. A
|
|
29
|
+
* capability a run does not need is one it cannot misuse.
|
|
30
|
+
*
|
|
31
|
+
* **The claim may be quoted from the board.** The caller says "check the second
|
|
32
|
+
* thing you told me", so `about` names an angle and the claim is read out of
|
|
33
|
+
* the slot — a subagent has not heard the call, and handing it "the second
|
|
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.
|
|
37
|
+
*/
|
|
38
|
+
export default briefingSlot.tool({
|
|
39
|
+
description:
|
|
40
|
+
"Check one specific factual claim against the web. Use it when the caller " +
|
|
41
|
+
"pushes back on something, or asks whether a finding is right. Pass the " +
|
|
42
|
+
"claim as a complete sentence.",
|
|
43
|
+
inputSchema: z.object({
|
|
44
|
+
claim: z
|
|
45
|
+
.string()
|
|
46
|
+
.max(400)
|
|
47
|
+
.describe("The claim to check, stated as one self-contained sentence"),
|
|
48
|
+
about: z
|
|
49
|
+
.string()
|
|
50
|
+
.max(200)
|
|
51
|
+
.optional()
|
|
52
|
+
.describe(
|
|
53
|
+
"The angle this claim came from, when the caller is pointing at " +
|
|
54
|
+
"something already on the board",
|
|
55
|
+
),
|
|
56
|
+
}),
|
|
57
|
+
async execute(args, board, ctx) {
|
|
58
|
+
const claim = args.claim.trim();
|
|
59
|
+
if (claim === "") return toolFailure("Nothing to check — say the claim in a full sentence.");
|
|
60
|
+
|
|
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
|
+
}
|
|
72
|
+
|
|
73
|
+
let verdict: Verdict | undefined;
|
|
74
|
+
let detail: string;
|
|
75
|
+
let searches: number;
|
|
76
|
+
let unusable: string | undefined;
|
|
77
|
+
try {
|
|
78
|
+
// What the checker gets of the conversation, and no more: the finding the
|
|
79
|
+
// claim came out of, so it can tell a misquote from a disagreement.
|
|
80
|
+
// Through `omitUndefined` rather than a truthiness-guarded spread — the
|
|
81
|
+
// repo's one spelling for an optional field, and the shape its own
|
|
82
|
+
// `guard-invariants` rule 22 counts as debt.
|
|
83
|
+
const context = source ? `The desk told the caller: ${source.summary}` : undefined;
|
|
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, {
|
|
90
|
+
task: claim,
|
|
91
|
+
...omitUndefined({ context }),
|
|
92
|
+
});
|
|
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;
|
|
103
|
+
} catch (err: unknown) {
|
|
104
|
+
return toolFailure(`The check did not come back: ${errorMessage(err)}`);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return {
|
|
108
|
+
claim,
|
|
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,
|
|
113
|
+
searches,
|
|
114
|
+
checkedAgainst: source?.angle ?? null,
|
|
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.",
|
|
121
|
+
};
|
|
122
|
+
},
|
|
123
|
+
});
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
// Copyright 2026 the AAI authors. MIT license.
|
|
2
|
+
// An EVAL for a WORKFLOW APP: does the run actually do the work? Run it with
|
|
3
|
+
// `aai eval`.
|
|
4
|
+
//
|
|
5
|
+
// `agent.test.ts` asserts about the declaration, drives the four steps one at a
|
|
6
|
+
// time, and covers the WAV arithmetic as pure functions. This drives the WHOLE
|
|
7
|
+
// BODY — `transcribeFlow` from the top — and what it is here to check is the one
|
|
8
|
+
// thing no per-step spec can see: that a recording is really planned, really
|
|
9
|
+
// fanned out, and really stitched back into one transcript in the right order.
|
|
10
|
+
//
|
|
11
|
+
// `describeWorkflowEval` picks the providers for you and says which it picked:
|
|
12
|
+
//
|
|
13
|
+
// * with `ASSEMBLYAI_API_KEY` — a LIVE run. The `{ live: true }` case below
|
|
14
|
+
// downloads a real four-minute news clip, converts it with a real ffmpeg,
|
|
15
|
+
// and puts four real requests through the sync endpoint. That spends money
|
|
16
|
+
// and about a minute.
|
|
17
|
+
// * without one — a SCRIPTED run: the same body, the same plan, the same
|
|
18
|
+
// stitch, with the endpoint answered in memory.
|
|
19
|
+
//
|
|
20
|
+
// Two of the three cases are SCRIPTED IN BOTH MODES, deliberately. Their claims
|
|
21
|
+
// are about the PLAN and the SEAM — which window each request got, and what the
|
|
22
|
+
// merge does where two segments overlap — and those are facts about arithmetic
|
|
23
|
+
// that a live provider can neither confirm nor deny. The live case is the one
|
|
24
|
+
// that answers "is the transcript really of the recording".
|
|
25
|
+
//
|
|
26
|
+
// WHAT NO EVAL HERE COVERS: durability. Imported through vitest with no bundler
|
|
27
|
+
// in the path, a workflow body is an ordinary async function — no
|
|
28
|
+
// journal, no replay, and no per-step retry, so the resume-after-segment-27
|
|
29
|
+
// property this template exists to demonstrate is NOT exercised here, and a
|
|
30
|
+
// rate-limited live run fails where a deployed one would have ridden it out.
|
|
31
|
+
// `aai-cli`'s `dev-workflow.scenario.test.ts` is the tier that really resumes a
|
|
32
|
+
// run.
|
|
33
|
+
import { encodeWav } from "@alexkroman1/aai/step";
|
|
34
|
+
import {
|
|
35
|
+
describeWorkflowEval,
|
|
36
|
+
installStubTranscribe,
|
|
37
|
+
installStubUploads,
|
|
38
|
+
} from "@alexkroman1/aai-runtime/testing/vitest";
|
|
39
|
+
import { expect } from "vitest";
|
|
40
|
+
import agentDef, { transcribe } from "./agent.ts";
|
|
41
|
+
import { TRANSCRIPT_STREAM } from "./workflows/stitch.ts";
|
|
42
|
+
import { SEGMENT_SECONDS } from "./workflows/wav.ts";
|
|
43
|
+
|
|
44
|
+
/** The id every case uploads under. */
|
|
45
|
+
const UPLOAD_ID = "upl_eval";
|
|
46
|
+
|
|
47
|
+
/** 16 kHz mono 16-bit — the format `normalize.ts` converts everything TO. */
|
|
48
|
+
const MONO_16K = { sampleRate: 16_000, channels: 1, bitsPerSample: 16 } as const;
|
|
49
|
+
/** Bytes one second of that format occupies. */
|
|
50
|
+
const BYTES_PER_SECOND = MONO_16K.sampleRate * MONO_16K.channels * (MONO_16K.bitsPerSample / 8);
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Long enough to force a THREE-segment fan-out, which is the shape worth
|
|
54
|
+
* driving: one segment exercises no plan, two exercise one seam, three exercise
|
|
55
|
+
* a middle segment that is neither first nor last.
|
|
56
|
+
*/
|
|
57
|
+
const SCRIPTED_SECONDS = 200;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* A real, parseable, linear-PCM WAV of silence.
|
|
61
|
+
*
|
|
62
|
+
* Silence is fine here because the scripted cases never send it anywhere: what
|
|
63
|
+
* they assert is which BYTE RANGE each request was handed, and the bytes only
|
|
64
|
+
* have to be as long as the header says. It also takes the fast path through
|
|
65
|
+
* `normalizeRecording` — `parseWav` accepts it, so no ffmpeg is involved, which
|
|
66
|
+
* is what keeps these two cases runnable with no binary on `PATH`.
|
|
67
|
+
*/
|
|
68
|
+
const SCRIPTED_WAV = encodeWav(new Uint8Array(SCRIPTED_SECONDS * BYTES_PER_SECOND), MONO_16K);
|
|
69
|
+
|
|
70
|
+
/** The public sample recording — four minutes of real speech, on a real CDN. */
|
|
71
|
+
const LIVE_RECORDING = "https://assembly.ai/wildfires.mp3";
|
|
72
|
+
|
|
73
|
+
/** Publish one in-memory upload store, writable because the converter needs one. */
|
|
74
|
+
function publish(bytes: Uint8Array, name: string, type: string) {
|
|
75
|
+
// `writable: true` is not optional for this template: `normalizeRecording`
|
|
76
|
+
// writes the CONVERTED file back as a new upload, and a read-only store would
|
|
77
|
+
// fail that step by name — which is the store telling the truth, and not what
|
|
78
|
+
// these cases are about.
|
|
79
|
+
return installStubUploads({ [UPLOAD_ID]: { bytes, name, type } }, { writable: true });
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Does this request body carry a WAV header?
|
|
84
|
+
*
|
|
85
|
+
* Scanned as BYTES rather than decoded: the body is a multipart envelope around
|
|
86
|
+
* megabytes of audio, so `String(bytes)` is a comma-joined number list — which
|
|
87
|
+
* makes the assertion pass or fail for the wrong reason and prints five
|
|
88
|
+
* megabytes of it when it fails.
|
|
89
|
+
*/
|
|
90
|
+
function carriesWavHeader(body: Uint8Array | string | undefined): boolean {
|
|
91
|
+
if (!(body instanceof Uint8Array)) return false;
|
|
92
|
+
const riff = [0x52, 0x49, 0x46, 0x46];
|
|
93
|
+
for (let at = 0; at <= body.length - riff.length; at++) {
|
|
94
|
+
if (riff.every((byte, offset) => body[at + offset] === byte)) return true;
|
|
95
|
+
}
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** The transcript chunks the run streamed, in the order they landed. */
|
|
100
|
+
function streamed(run: { emitted: readonly { namespace: string; chunk: unknown }[] }) {
|
|
101
|
+
return run.emitted
|
|
102
|
+
.filter((one) => one.namespace === TRANSCRIPT_STREAM)
|
|
103
|
+
.map((one) => one.chunk as { index: number; startMs: number; endMs: number; text: string });
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
describeWorkflowEval(agentDef, (test) => {
|
|
107
|
+
test("plans the fan-out from the header and gives each request its own window", async ({
|
|
108
|
+
app,
|
|
109
|
+
}) => {
|
|
110
|
+
// Scripted in both modes: the claim is which WINDOW each of the three
|
|
111
|
+
// requests was handed, and a live endpoint cannot answer that — it can only
|
|
112
|
+
// transcribe whatever it is sent. This is the case that catches an
|
|
113
|
+
// off-by-one in the plan, which otherwise produces audio the decoder
|
|
114
|
+
// transcribes into confident nonsense.
|
|
115
|
+
publish(SCRIPTED_WAV, "standup.wav", "audio/wav");
|
|
116
|
+
const provider = installStubTranscribe({
|
|
117
|
+
text: ["the first stretch", "the middle stretch", "the last stretch"],
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
const run = await app.run(transcribe, { recording: UPLOAD_ID });
|
|
121
|
+
|
|
122
|
+
expect(run.error).toBeUndefined();
|
|
123
|
+
expect(run.status).toBe("completed");
|
|
124
|
+
const output = run.output;
|
|
125
|
+
if (output === undefined) expect.fail("a completed run must carry an output");
|
|
126
|
+
|
|
127
|
+
// Three segments over 200 seconds at a 90-second stride, and the durations
|
|
128
|
+
// are the plan: each segment carries the 2-second OVERLAP that stops a cut
|
|
129
|
+
// landing mid-word, so they deliberately do not abut.
|
|
130
|
+
expect(output.segments).toBe(3);
|
|
131
|
+
expect(output.durationMs).toBe(SCRIPTED_SECONDS * 1000);
|
|
132
|
+
expect(streamed(run).map((chunk) => [chunk.index, chunk.startMs, chunk.endMs])).toEqual([
|
|
133
|
+
[0, 0, (SEGMENT_SECONDS + 2) * 1000],
|
|
134
|
+
[1, SEGMENT_SECONDS * 1000, (2 * SEGMENT_SECONDS + 2) * 1000],
|
|
135
|
+
[2, 2 * SEGMENT_SECONDS * 1000, SCRIPTED_SECONDS * 1000],
|
|
136
|
+
]);
|
|
137
|
+
|
|
138
|
+
// One sync request per segment, each carrying a WHOLE WAV — the endpoint
|
|
139
|
+
// decodes every request independently, so a window with no header put back
|
|
140
|
+
// on it is bytes it refuses.
|
|
141
|
+
const sync = provider.calls.filter((call) => call.leg === "sync");
|
|
142
|
+
expect(sync).toHaveLength(3);
|
|
143
|
+
expect(sync.map((call) => carriesWavHeader(call.body))).toEqual([true, true, true]);
|
|
144
|
+
// The first two segments are a full stride plus the overlap; the last is the
|
|
145
|
+
// remainder, and is therefore much smaller. A plan that ran off the end of
|
|
146
|
+
// the file would show up here as a last segment the size of the others.
|
|
147
|
+
const sizes = sync.map((call) => call.body?.length ?? 0);
|
|
148
|
+
expect(sizes[0]).toBeGreaterThan((SEGMENT_SECONDS + 1) * BYTES_PER_SECOND);
|
|
149
|
+
expect(sizes[2]).toBeLessThan(sizes[0] ?? 0);
|
|
150
|
+
|
|
151
|
+
// Stitched in INDEX order, not completion order.
|
|
152
|
+
expect(output.transcript).toBe("the first stretch the middle stretch the last stretch");
|
|
153
|
+
// Reported before the fan-out, which is what makes a long run legible.
|
|
154
|
+
expect(run.reported).toContain("Split 3:20 of audio into 3 segments.");
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
test("drops the repeated words where two segments overlap", async ({ app }) => {
|
|
158
|
+
// Scripted in both modes for the same reason: the overlap exists so a cut
|
|
159
|
+
// never lands mid-word, and what makes that free is the merge dropping ONE
|
|
160
|
+
// copy of the repeated run. A live provider cannot be asked to produce a
|
|
161
|
+
// seam on demand, and this is where a regression would be invisible — a
|
|
162
|
+
// missed seam repeats a few words, a false one DELETES speech.
|
|
163
|
+
publish(SCRIPTED_WAV, "standup.wav", "audio/wav");
|
|
164
|
+
installStubTranscribe({
|
|
165
|
+
text: [
|
|
166
|
+
"the fire moved north through the valley overnight",
|
|
167
|
+
"through the valley overnight and reached the ridge by dawn",
|
|
168
|
+
"by dawn the crews had contained it",
|
|
169
|
+
],
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
const run = await app.run(transcribe, { recording: UPLOAD_ID });
|
|
173
|
+
|
|
174
|
+
expect(run.error).toBeUndefined();
|
|
175
|
+
const transcript = run.output?.transcript ?? "";
|
|
176
|
+
expect(transcript).toBe(
|
|
177
|
+
"the fire moved north through the valley overnight and reached the ridge by dawn the crews had contained it",
|
|
178
|
+
);
|
|
179
|
+
// The repeated runs appear once each, which is the whole claim.
|
|
180
|
+
expect(transcript.match(/overnight/g)).toHaveLength(1);
|
|
181
|
+
expect(transcript.match(/by dawn/g)).toHaveLength(1);
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
test(
|
|
185
|
+
"really transcribes a real recording, end to end",
|
|
186
|
+
async ({ app }) => {
|
|
187
|
+
// LIVE ONLY, and it is the case that earns the template its name. Three
|
|
188
|
+
// separate things have to be real for it to pass: ffmpeg has to convert an
|
|
189
|
+
// MP3 into something the plan can cut, the plan has to cover the whole
|
|
190
|
+
// recording, and every segment's request has to come back with the words
|
|
191
|
+
// that are actually in it.
|
|
192
|
+
//
|
|
193
|
+
// It needs `ffmpeg` on `PATH` (or `AAI_FFMPEG_PATH`), which is what the
|
|
194
|
+
// template's own doc says a developer needs for anything that is not
|
|
195
|
+
// already a WAV. A deployed guest's image installs it.
|
|
196
|
+
const response = await fetch(LIVE_RECORDING);
|
|
197
|
+
expect(response.ok).toBe(true);
|
|
198
|
+
const mp3 = new Uint8Array(await response.arrayBuffer());
|
|
199
|
+
publish(mp3, "wildfires.mp3", "audio/mpeg");
|
|
200
|
+
|
|
201
|
+
const run = await app.run(transcribe, { recording: UPLOAD_ID });
|
|
202
|
+
|
|
203
|
+
expect(run.error).toBeUndefined();
|
|
204
|
+
expect(run.status).toBe("completed");
|
|
205
|
+
const output = run.output;
|
|
206
|
+
if (output === undefined) expect.fail("a completed run must carry an output");
|
|
207
|
+
|
|
208
|
+
// ffmpeg ran, and the run said so before spending minutes on it.
|
|
209
|
+
expect(run.reported.some((line) => line.startsWith("Converting wildfires.mp3"))).toBe(true);
|
|
210
|
+
// The FILENAME a reader sees is the one they uploaded, not the converted
|
|
211
|
+
// artifact's — `mergeTranscript` reads the ORIGINAL id for exactly this.
|
|
212
|
+
expect(output.source).toBe("wildfires.mp3");
|
|
213
|
+
|
|
214
|
+
// Four and a half minutes, so the plan really fanned out rather than
|
|
215
|
+
// sending one request.
|
|
216
|
+
expect(output.segments).toBeGreaterThanOrEqual(3);
|
|
217
|
+
expect(output.durationMs).toBeGreaterThan(250_000);
|
|
218
|
+
|
|
219
|
+
// Every segment came back with words in it, which is how "the whole
|
|
220
|
+
// recording was covered" is checked rather than assumed: a plan that ran
|
|
221
|
+
// past the end would leave a silent tail segment here.
|
|
222
|
+
const chunks = streamed(run);
|
|
223
|
+
expect(chunks).toHaveLength(output.segments);
|
|
224
|
+
for (const chunk of chunks) expect(chunk.text.length).toBeGreaterThan(0);
|
|
225
|
+
|
|
226
|
+
// And the transcript is of THIS recording — a news segment about smoke
|
|
227
|
+
// from Canadian wildfires reaching the US east coast.
|
|
228
|
+
expect(output.transcript).toMatch(/wildfire/i);
|
|
229
|
+
expect(output.transcript).toMatch(/canada/i);
|
|
230
|
+
expect(output.transcript).toMatch(/air quality/i);
|
|
231
|
+
// ~4.5 minutes of speech is several hundred words; a stitch that kept only
|
|
232
|
+
// the first segment would land far under this.
|
|
233
|
+
expect(output.words).toBeGreaterThan(400);
|
|
234
|
+
},
|
|
235
|
+
{ live: true },
|
|
236
|
+
);
|
|
237
|
+
});
|