@alexkroman1/aai-cli 0.12.3 → 0.14.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-B6v31ROV.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 +35 -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-GoEXEVpA.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 +54 -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-BnmTHtjd.mjs +68 -0
- package/dist/_slug-api.d.ts +61 -0
- package/dist/_stop-server.d.ts +17 -0
- package/dist/_studio-B5m4jBTD.mjs +256 -0
- package/dist/_studio-commands.d.ts +73 -0
- package/dist/_studio.d.ts +92 -0
- package/dist/_target-bundle.d.ts +141 -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-BVMVsQh0.mjs +139 -0
- package/dist/_templates.d.ts +89 -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-CKhanHVv.mjs +588 -0
- package/dist/build.d.ts +146 -0
- package/dist/cli-workflow.d.ts +17 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.mjs +1092 -195
- package/dist/client-bundler-DZ_Zoznn.mjs +241 -0
- package/dist/client-bundler.d.ts +38 -0
- package/dist/client-bundler.mjs +3 -0
- package/dist/console-Dxq26Adz.mjs +447 -0
- package/dist/console.d.ts +70 -0
- package/dist/delete-DwXCHzTl.mjs +55 -0
- package/dist/delete.d.ts +26 -0
- package/dist/deploy-CbA8Ibiu.mjs +97 -0
- package/dist/deploy.d.ts +25 -0
- package/dist/dev-BWBDbUEb.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-CidslZZz.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-CnPK-Prw.mjs +102 -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 +139 -0
- package/dist/scaffold/agent-guide/PIPELINE-TUNING.md +232 -0
- package/dist/scaffold/agent-guide/PROVIDERS.md +140 -0
- package/dist/scaffold/agent-guide/TESTING-EVALS.md +158 -0
- package/dist/scaffold/agent-guide/TOOLS.md +627 -0
- package/dist/scaffold/agent-guide/UI.md +292 -0
- package/dist/scaffold/agent-guide/WORKFLOWS.md +803 -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-DPdPEet2.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-COjK25Rl.mjs +208 -0
- package/dist/studio.d.ts +56 -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 +251 -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 +512 -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 +646 -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 +329 -0
- package/dist/templates/medication-safety-agent/agent.ts +62 -0
- package/dist/templates/medication-safety-agent/fda.test.ts +129 -0
- package/dist/templates/medication-safety-agent/fda.ts +166 -0
- package/dist/templates/medication-safety-agent/system-prompt.md +26 -0
- package/dist/templates/medication-safety-agent/tools/check_drug_interaction.ts +70 -0
- package/dist/templates/medication-safety-agent/tools/medication_lookup.ts +46 -0
- package/dist/templates/meeting-recap-agent/agent.eval.test.ts +459 -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 +348 -0
- package/dist/templates/research-handoff-agent/agent.test.ts +818 -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 +640 -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 +356 -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 +2033 -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 +219 -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 +182 -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 +490 -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,317 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The durable half of the redline desk: write, critique, revise — in a loop
|
|
3
|
+
* whose length the CRITIC decides.
|
|
4
|
+
*
|
|
5
|
+
* The rules a workflow body lives under are spelled out in
|
|
6
|
+
* `research-handoff-agent/workflows/research.ts` and `link-digest-workflow/workflows/digest.ts`:
|
|
7
|
+
* the body is replayed from the top on every resume, so it holds no live handle
|
|
8
|
+
* and makes no undurable decision, and a step's arguments and result cross a
|
|
9
|
+
* queue. Read those first. What THIS one adds is the shape neither of them has:
|
|
10
|
+
* **a loop whose exit is decided at run time**.
|
|
11
|
+
*
|
|
12
|
+
* ## A journaled result is what makes a data-dependent loop legal
|
|
13
|
+
*
|
|
14
|
+
* `transcription-workflow` derives its fan-out's WIDTH from a step's journaled
|
|
15
|
+
* result, and its module doc gives the rule. This is the same rule spent on a
|
|
16
|
+
* different thing: `critique` returns a verdict, the body breaks on it, and a
|
|
17
|
+
* replay reads that verdict back out of the journal and takes the same branch.
|
|
18
|
+
* Deciding it any other way — a clock, a random draw, a re-read of something
|
|
19
|
+
* outside the run — would let a replay diverge. A step is identified by its
|
|
20
|
+
* NAME plus the number of times that name has been reached in this run, so a
|
|
21
|
+
* branch that takes a different path on replay reads a journal entry that was
|
|
22
|
+
* written for a different call, rather than producing a slightly different essay.
|
|
23
|
+
*
|
|
24
|
+
* ## Two ways in, and only one of them needs a journal to be safe
|
|
25
|
+
*
|
|
26
|
+
* A run either writes its first draft or is handed one — `redline` is a word
|
|
27
|
+
* about marking up prose somebody already has, and the loop under it is
|
|
28
|
+
* critique-and-revise either way. The branch is on the INPUT, which is journaled
|
|
29
|
+
* once at `start()` and identical on every walk, so it costs nothing to make it
|
|
30
|
+
* replay-stable. Contrast the loop's exit, above: that one is decided at run
|
|
31
|
+
* time and therefore has to be decided on a STEP'S RESULT. The two sit ten lines
|
|
32
|
+
* apart in {@link redlineFlow} as the cheap case and the paid one.
|
|
33
|
+
*
|
|
34
|
+
* ## Why durability earns its keep here, specifically
|
|
35
|
+
*
|
|
36
|
+
* A three-round redline is up to seven model calls in sequence, each of them
|
|
37
|
+
* long-form. That is minutes, not seconds — nobody is going to sit on a phone
|
|
38
|
+
* for it, which is why this is a workflow app rather than a voice agent — and
|
|
39
|
+
* it is exactly the work you do not want to redo: a rate limit in round three
|
|
40
|
+
* replays rounds one and two from the journal for free and re-issues only the
|
|
41
|
+
* call that failed. Each stage is its own step for that reason, not because
|
|
42
|
+
* three functions read more tidily than one.
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
import type { WorkflowContext } from "@alexkroman1/aai";
|
|
46
|
+
import { stepGenerate, stepGenerateJson, stepReport } from "@alexkroman1/aai/step";
|
|
47
|
+
import { FatalError, orFail } from "@alexkroman1/aai/step-errors";
|
|
48
|
+
import { countWords } from "@alexkroman1/aai/utils";
|
|
49
|
+
import { z } from "zod";
|
|
50
|
+
import { CRITIC_SYSTEM, REVISER_SYSTEM, WRITER_SYSTEM } from "./prompts.ts";
|
|
51
|
+
|
|
52
|
+
/** Shortest brief worth writing from. Below this the piece would be invention. */
|
|
53
|
+
export const MIN_BRIEF_CHARS = 20;
|
|
54
|
+
|
|
55
|
+
/** Shortest attached draft worth redlining. Below this there is nothing to grade
|
|
56
|
+
* — the critic would be writing the piece, which is the one thing its prompt
|
|
57
|
+
* says not to do. */
|
|
58
|
+
export const MIN_DRAFT_CHARS = 200;
|
|
59
|
+
|
|
60
|
+
/** Longest attached draft the desk will take. Past this the critique stops being
|
|
61
|
+
* about the piece and starts being about what fitted in the context window. */
|
|
62
|
+
export const MAX_DRAFT_CHARS = 20_000;
|
|
63
|
+
|
|
64
|
+
/** Notes one critique may return — their prompt asks for three at most. */
|
|
65
|
+
export const MAX_NOTES = 3;
|
|
66
|
+
|
|
67
|
+
/** A draft the author already had, as the page reads it off the file they chose. */
|
|
68
|
+
export interface AttachedDraft {
|
|
69
|
+
/** What the file was called. The run narrates it, and the output carries it. */
|
|
70
|
+
name: string;
|
|
71
|
+
text: string;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** What the form collects, once the page has mapped its fields. */
|
|
75
|
+
export interface RedlineInput {
|
|
76
|
+
brief: string;
|
|
77
|
+
audience: string;
|
|
78
|
+
/** Critique-and-revise rounds this run may spend. Their `should_continue` cap. */
|
|
79
|
+
rounds: number;
|
|
80
|
+
/** Points the piece must cover. An ARRAY, which is why the page writes that
|
|
81
|
+
* field by hand — `<WorkflowFields>` renders scalars only. */
|
|
82
|
+
mustCover: string[];
|
|
83
|
+
/** A draft to mark up instead of writing one. Absent for the ordinary run.
|
|
84
|
+
* An OBJECT for the same reason `mustCover` is an array: it is the other
|
|
85
|
+
* property `<WorkflowFields>` renders nothing for, so the page owns its
|
|
86
|
+
* control — a `<FileField read="text">` — and maps it on submit. */
|
|
87
|
+
source?: AttachedDraft | undefined;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export interface Critique {
|
|
91
|
+
verdict: "ship" | "revise";
|
|
92
|
+
/** 1–10, for the page. Nothing branches on it — the verdict is the decision. */
|
|
93
|
+
score: number;
|
|
94
|
+
notes: string[];
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* What the critic is asked to reply with, as something that CHECKS.
|
|
99
|
+
*
|
|
100
|
+
* `stepGenerateJson` validates against this, so a reply that missed is a plain
|
|
101
|
+
* throw and therefore a retry — where the hand-written `isCritique` guard this
|
|
102
|
+
* replaces had to restate every field's type by hand. The VERDICT is strict
|
|
103
|
+
* because the body branches on it; the score is deliberately not, and is
|
|
104
|
+
* clamped at the call site instead (see `critiqueDraft`).
|
|
105
|
+
*/
|
|
106
|
+
const CritiqueReply = z.object({
|
|
107
|
+
verdict: z.enum(["ship", "revise"]),
|
|
108
|
+
score: z.number(),
|
|
109
|
+
notes: z.array(z.string()),
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
/** One round, as the page renders it and the journal records it. */
|
|
113
|
+
export interface Round {
|
|
114
|
+
round: number;
|
|
115
|
+
critique: Critique;
|
|
116
|
+
/** Absent on the round that shipped: nothing was revised after it. */
|
|
117
|
+
revisedWords?: number;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Write a first draft — or take the one that came attached — then critique and
|
|
122
|
+
* revise until the critic ships it or the rounds run out.
|
|
123
|
+
*
|
|
124
|
+
* Whatever this returns is what a completed run reports as `output`, so it is
|
|
125
|
+
* the page's render model — and `WorkflowOutputOf<typeof redline>` in
|
|
126
|
+
* `client.tsx` is that type, derived rather than restated.
|
|
127
|
+
*/
|
|
128
|
+
export async function redlineFlow(input: RedlineInput, ctx: WorkflowContext) {
|
|
129
|
+
// The `maxAttempts` below were `maxRetries` properties on the functions
|
|
130
|
+
// (3, 5, 3 — retries AFTER the first attempt, so 4, 6, 4 in all). The policy
|
|
131
|
+
// is an argument to the CALL now, which is where it belongs: the same function
|
|
132
|
+
// called from two places may deserve different patience.
|
|
133
|
+
//
|
|
134
|
+
// Which of the two ways in this run took is a branch on the INPUT, which is
|
|
135
|
+
// replay-stable for free: the input is journaled once at `start()` and is the
|
|
136
|
+
// same object on every walk. That is the cheap end of the rule the loop below
|
|
137
|
+
// spends properly — a branch on anything that is not already durable has to
|
|
138
|
+
// read a STEP'S RESULT, which is what the critic's verdict is.
|
|
139
|
+
const source = input.source;
|
|
140
|
+
let draft = source
|
|
141
|
+
? // One attempt: this step performs no I/O and its only failure is fatal, so
|
|
142
|
+
// a second walk through it would throw the identical error.
|
|
143
|
+
await ctx.step("acceptDraft", () => acceptDraft(source), { maxAttempts: 1 })
|
|
144
|
+
: await ctx.step("writeDraft", () => writeDraft(input), { maxAttempts: 4 });
|
|
145
|
+
const rounds: Round[] = [];
|
|
146
|
+
let shipped = false;
|
|
147
|
+
|
|
148
|
+
for (let round = 1; round <= input.rounds; round++) {
|
|
149
|
+
// ONE call site in a loop, which is exactly what `(name, occurrence)` step
|
|
150
|
+
// identity is for: this is `critiqueDraft#0`, `critiqueDraft#1`, … so each
|
|
151
|
+
// round journals separately and a resume replays the rounds already done.
|
|
152
|
+
const critique = await ctx.step("critiqueDraft", () => critiqueDraft(draft, input, round), {
|
|
153
|
+
maxAttempts: 6,
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
if (critique.verdict === "ship") {
|
|
157
|
+
// The break is decided by a STEP'S JOURNALED RESULT, which is what makes
|
|
158
|
+
// it replay-stable — see the module doc.
|
|
159
|
+
rounds.push({ round, critique });
|
|
160
|
+
shipped = true;
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
draft = await ctx.step("reviseDraft", () => reviseDraft(draft, critique, input, round), {
|
|
165
|
+
maxAttempts: 4,
|
|
166
|
+
});
|
|
167
|
+
rounds.push({ round, critique, revisedWords: countWords(draft) });
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
return {
|
|
171
|
+
draft,
|
|
172
|
+
words: countWords(draft),
|
|
173
|
+
roundsRun: rounds.length,
|
|
174
|
+
/** True when the CRITIC stopped the loop, false when the budget did. */
|
|
175
|
+
shipped,
|
|
176
|
+
/** The attached file this run marked up, or `undefined` when the desk wrote
|
|
177
|
+
* the first draft itself. The page says which, because "three rounds" reads
|
|
178
|
+
* very differently over somebody's own prose. */
|
|
179
|
+
source: source?.name,
|
|
180
|
+
rounds,
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* The other way in: a draft the author already had.
|
|
186
|
+
*
|
|
187
|
+
* Not a model call and not a fetch — the text arrived in the run's input, read
|
|
188
|
+
* off the chosen file by `<FileField read="text">` in the browser. It is still a
|
|
189
|
+
* STEP, for the two things a step is: its result is journaled, so every walk
|
|
190
|
+
* starts the loop from the same prose, and its failure is CLASSIFIED. A file of
|
|
191
|
+
* twenty thousand spaces passes the schema's `.min()`, which counts characters,
|
|
192
|
+
* and arrives here as nothing to grade — the same gap `writeDraft` guards, and
|
|
193
|
+
* fatal for the same reason.
|
|
194
|
+
*/
|
|
195
|
+
export async function acceptDraft(source: AttachedDraft): Promise<string> {
|
|
196
|
+
const text = source.text.trim();
|
|
197
|
+
if (text.length < MIN_DRAFT_CHARS) {
|
|
198
|
+
throw new FatalError(
|
|
199
|
+
`${source.name} holds ${text.length} characters of prose — too little to redline. ` +
|
|
200
|
+
`Attach at least ${MIN_DRAFT_CHARS}, or leave the file off and let the desk write it.`,
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
await stepReport(`Redlining ${source.name} rather than writing a first draft.`);
|
|
204
|
+
return text;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/** Their `generation_node`, first pass. */
|
|
208
|
+
export async function writeDraft(input: RedlineInput): Promise<string> {
|
|
209
|
+
if (input.brief.trim().length < MIN_BRIEF_CHARS) {
|
|
210
|
+
// Fatal rather than retryable: the same brief is the same brief on every
|
|
211
|
+
// attempt, and four more model calls will not make it longer.
|
|
212
|
+
//
|
|
213
|
+
// Not redundant with the schema's `.min(20)`, which counts CHARACTERS: a
|
|
214
|
+
// brief of twenty spaces passes validation at `start()` and arrives here
|
|
215
|
+
// as nothing to write from.
|
|
216
|
+
throw new FatalError(
|
|
217
|
+
`The brief is too short to write from — give at least ${MIN_BRIEF_CHARS} characters of it.`,
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
await stepReport(`Writing the first draft for ${input.audience}.`);
|
|
222
|
+
// No empty-reply guard here or in `reviseDraft`, and that is not an omission:
|
|
223
|
+
// `stepGenerate` already refuses an empty completion, as a RETRYABLE
|
|
224
|
+
// `StepGenerateError` — which is the right answer, and one a hand-written
|
|
225
|
+
// check would have to re-derive.
|
|
226
|
+
const draft = await orFail(stepGenerate)(briefBlock(input), { system: WRITER_SYSTEM });
|
|
227
|
+
return draft.trim();
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Their `reflection_node`: grade the draft against its brief.
|
|
232
|
+
*
|
|
233
|
+
* Its own step rather than part of the revision, because the two fail
|
|
234
|
+
* differently and because this one's RESULT is what the body branches on — a
|
|
235
|
+
* revision folded into the same step would put the decision and the expensive
|
|
236
|
+
* rewrite behind one journal entry.
|
|
237
|
+
*/
|
|
238
|
+
export async function critiqueDraft(
|
|
239
|
+
draft: string,
|
|
240
|
+
input: RedlineInput,
|
|
241
|
+
round: number,
|
|
242
|
+
): Promise<Critique> {
|
|
243
|
+
await stepReport(`Round ${round}: reading it back critically.`);
|
|
244
|
+
// `stepGenerateJson` owns the fence, the parse, the non-object case and the
|
|
245
|
+
// shape — and throws PLAINLY when any of them misses, unlike the fatal one
|
|
246
|
+
// above: a model that answered with prose may well obey on the next attempt.
|
|
247
|
+
const parsed = await orFail(stepGenerateJson)(
|
|
248
|
+
`${briefBlock(input)}\n\nThe submission:\n${draft}`,
|
|
249
|
+
{
|
|
250
|
+
schema: CritiqueReply,
|
|
251
|
+
system: CRITIC_SYSTEM,
|
|
252
|
+
},
|
|
253
|
+
);
|
|
254
|
+
|
|
255
|
+
const critique: Critique = {
|
|
256
|
+
verdict: parsed.verdict,
|
|
257
|
+
// The SCORE is still clamped here rather than in the schema: a model that
|
|
258
|
+
// answered 11 has still answered, and the number is worth keeping at the
|
|
259
|
+
// edge of the range rather than costing a whole retry.
|
|
260
|
+
score: clampScore(parsed.score),
|
|
261
|
+
notes: parsed.notes.slice(0, MAX_NOTES),
|
|
262
|
+
};
|
|
263
|
+
await stepReport(
|
|
264
|
+
critique.verdict === "ship"
|
|
265
|
+
? `Round ${round}: the critic would ship it (${critique.score}/10).`
|
|
266
|
+
: `Round ${round}: ${critique.notes.length} note(s) to address (${critique.score}/10).`,
|
|
267
|
+
);
|
|
268
|
+
return critique;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/** Their generation node re-entered with the critique. */
|
|
272
|
+
export async function reviseDraft(
|
|
273
|
+
draft: string,
|
|
274
|
+
critique: Critique,
|
|
275
|
+
input: RedlineInput,
|
|
276
|
+
round: number,
|
|
277
|
+
): Promise<string> {
|
|
278
|
+
await stepReport(`Round ${round}: revising.`);
|
|
279
|
+
const revised = await orFail(stepGenerate)(
|
|
280
|
+
[
|
|
281
|
+
briefBlock(input),
|
|
282
|
+
`Your current draft:\n${draft}`,
|
|
283
|
+
`The critique:\n${critique.notes.map((note, index) => `${index + 1}. ${note}`).join("\n")}`,
|
|
284
|
+
].join("\n\n"),
|
|
285
|
+
{ system: REVISER_SYSTEM },
|
|
286
|
+
);
|
|
287
|
+
return revised.trim();
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
// ---- Pure helpers -----------------------------------------------------------
|
|
291
|
+
|
|
292
|
+
/** The brief as every stage restates it, so the three cannot drift apart. */
|
|
293
|
+
export function briefBlock(input: RedlineInput): string {
|
|
294
|
+
const must =
|
|
295
|
+
input.mustCover.length > 0
|
|
296
|
+
? `Must cover:\n${input.mustCover.map((point) => `- ${point}`).join("\n")}`
|
|
297
|
+
: "Must cover: nothing specific was named.";
|
|
298
|
+
return [`Brief: ${input.brief}`, `Audience: ${input.audience}`, must].join("\n\n");
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/** Scores arrive from a model, so they arrive out of range often enough. */
|
|
302
|
+
export function clampScore(score: number): number {
|
|
303
|
+
if (!Number.isFinite(score)) return 0;
|
|
304
|
+
return Math.min(10, Math.max(1, Math.round(score)));
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
// ---- The model call ---------------------------------------------------------
|
|
308
|
+
//
|
|
309
|
+
// There is no local `ask()` any more, and its absence is the point. The SDK
|
|
310
|
+
// classifies the gateway's failure (`StepGenerateError.retryable`) and stops
|
|
311
|
+
// there — whether a terminal failure should burn the step's remaining attempts
|
|
312
|
+
// is the caller's call — so `orFail(stepGenerate)` and
|
|
313
|
+
// `orFail(stepGenerateJson)` (`@alexkroman1/aai/step-errors`) are that call
|
|
314
|
+
// made one way: terminal stays terminal, and a rate limit becomes a
|
|
315
|
+
// `RetryableError` carrying the delay the gateway itself named, which beats
|
|
316
|
+
// `RetryableError`'s own one-second default. Three templates each wrapped the
|
|
317
|
+
// raw `/step` call to say that; the wrapper is a suffix on the import now.
|
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The def a DEPLOYED agent runs: authored, plus what `tools/` declares, plus
|
|
3
|
+
* what `system-prompt.md` says.
|
|
4
|
+
*
|
|
5
|
+
* BOTH wrappers are load-bearing and neither is applied by `agent()` — they are
|
|
6
|
+
* applied by the BUILD (`aai build` enumerates `tools/` and resolves the prompt
|
|
7
|
+
* file), so an eval driving the raw default export would measure a twelve-tool
|
|
8
|
+
* desk with no tools and the FRAMEWORK DEFAULT prompt. For this template that
|
|
9
|
+
* is the whole subject: "location is always the first priority", the radio
|
|
10
|
+
* style and "never leave a critical incident without a resource" are all in
|
|
11
|
+
* that file.
|
|
12
|
+
*
|
|
13
|
+
* The glob is written here rather than reached for from a shared helper because
|
|
14
|
+
* this file SHIPS — it is what a scaffolded project runs.
|
|
15
|
+
*/
|
|
16
|
+
import dispatchAgent from "virtual:aai/agent";
|
|
17
|
+
import type { SessionEvent } from "@alexkroman1/aai";
|
|
18
|
+
// An EVAL: does the desk actually behave? Run it with `aai eval`.
|
|
19
|
+
//
|
|
20
|
+
// `agent.test.ts` drives each tool directly. What it cannot ask is whether the
|
|
21
|
+
// AGENT — a model, reading this system prompt, holding these twelve tools —
|
|
22
|
+
// works the call in the right ORDER, which for a dispatch desk is the whole
|
|
23
|
+
// product. Four claims, each one a MECHANISM this template is built out of:
|
|
24
|
+
//
|
|
25
|
+
// 1. nothing can be dispatched before a call has been logged,
|
|
26
|
+
// 2. a 911 call is logged, scored, and the flow moves to triaging,
|
|
27
|
+
// 3. units really roll, and the position follows them to monitoring,
|
|
28
|
+
// 4. a unit already on a call is not sent to a second one.
|
|
29
|
+
//
|
|
30
|
+
// So every assertion reads the mechanism's own output — the dialog gate's
|
|
31
|
+
// refusal, the tool result, and the dashboard the browser is sent — rather
|
|
32
|
+
// than judging the sentence the model chose to say.
|
|
33
|
+
//
|
|
34
|
+
// What no eval here can see: anything below the audio boundary. Whether a
|
|
35
|
+
// dispatcher reading a callsign in bursts lands as one turn is a property of
|
|
36
|
+
// endpointing, and these fake speech stages remove it.
|
|
37
|
+
import {
|
|
38
|
+
describeEval,
|
|
39
|
+
dialogRefusalPattern,
|
|
40
|
+
dialogResultSchema,
|
|
41
|
+
type EvalSession,
|
|
42
|
+
lastStateIn,
|
|
43
|
+
toolNames,
|
|
44
|
+
toolResultIn,
|
|
45
|
+
turnCalling,
|
|
46
|
+
} from "@alexkroman1/aai-runtime/testing/vitest";
|
|
47
|
+
import { expect } from "vitest";
|
|
48
|
+
import { z } from "zod";
|
|
49
|
+
|
|
50
|
+
/** The six tools gated on `working` — the ones that refuse until something has
|
|
51
|
+
* been logged. Listed here so ADDING an ungated mutating tool is a deliberate
|
|
52
|
+
* edit to this file rather than a silent gap. */
|
|
53
|
+
const GATED_TOOLS = new Set([
|
|
54
|
+
"incident_triage",
|
|
55
|
+
"incident_add_note",
|
|
56
|
+
"incident_escalate",
|
|
57
|
+
"incident_update_status",
|
|
58
|
+
"resources_dispatch",
|
|
59
|
+
"resources_update_status",
|
|
60
|
+
]);
|
|
61
|
+
|
|
62
|
+
/** The first incident of a session. `createIncident` counts from 1 per slot,
|
|
63
|
+
* and a slot is per session, so this id is deterministic. */
|
|
64
|
+
const FIRST_INCIDENT = "INC-0001";
|
|
65
|
+
/** The second, for the case that logs two. */
|
|
66
|
+
const SECOND_INCIDENT = "INC-0002";
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* What the BROWSER is sent, as this eval reads it.
|
|
70
|
+
*
|
|
71
|
+
* Parsed rather than cast: `state.updated` carries `unknown`, and a schema that
|
|
72
|
+
* stops matching is a loud failure naming the field where a cast would hand the
|
|
73
|
+
* assertions `undefined` and fail three lines later. It names only the fields
|
|
74
|
+
* asserted below, so `dashboardView` may grow without touching this.
|
|
75
|
+
*/
|
|
76
|
+
const ProjectedDashboard = z.object({
|
|
77
|
+
systemAlertLevel: z.string(),
|
|
78
|
+
incidents: z.array(
|
|
79
|
+
z.object({
|
|
80
|
+
id: z.string(),
|
|
81
|
+
severity: z.string(),
|
|
82
|
+
status: z.string(),
|
|
83
|
+
location: z.string(),
|
|
84
|
+
}),
|
|
85
|
+
),
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* The three tool results asserted below, as SHAPES rather than as substrings of
|
|
90
|
+
* their own JSON.
|
|
91
|
+
*
|
|
92
|
+
* These were `toMatch(/"newStatus":"resolved"/)` over the serialized result, and
|
|
93
|
+
* one went as far as pinning adjacent key ORDER
|
|
94
|
+
* (`/"callsign":"Medic-1","reason":"Currently dispatched"/`). Nothing in this
|
|
95
|
+
* template is about serialization: a reordered field, a renamed sibling key or a
|
|
96
|
+
* pretty-print would have broken tests that were never about any of that.
|
|
97
|
+
*
|
|
98
|
+
* `incident_create` is ungated and SPREADS its position, so `state` sits beside
|
|
99
|
+
* its own fields; the other two are `callFlow.tool`s, so the SDK wraps them and
|
|
100
|
+
* `dialogResultSchema` is that wrapper.
|
|
101
|
+
*/
|
|
102
|
+
const Created = z.object({
|
|
103
|
+
recommendedSeverity: z.string(),
|
|
104
|
+
recommendedType: z.string(),
|
|
105
|
+
state: z.string(),
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
const Dispatch = dialogResultSchema(
|
|
109
|
+
z.object({
|
|
110
|
+
dispatched: z.array(z.object({ callsign: z.string() })),
|
|
111
|
+
failed: z.array(z.object({ callsign: z.string(), reason: z.string() })).optional(),
|
|
112
|
+
}),
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
const StatusChange = dialogResultSchema(
|
|
116
|
+
z.object({ newStatus: z.string(), timeline: z.array(z.string()) }),
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* The latest dashboard the session pushed, or undefined if it pushed none.
|
|
121
|
+
*
|
|
122
|
+
* `lastStateIn` is the SDK's reader, and the schema is what it is worth passing:
|
|
123
|
+
* a frame that stopped matching FAILS naming the field, where the cast this
|
|
124
|
+
* replaced would have handed the assertions `undefined`.
|
|
125
|
+
*/
|
|
126
|
+
const dashboard = (events: readonly SessionEvent[]) =>
|
|
127
|
+
lastStateIn(events, "dispatch", ProjectedDashboard);
|
|
128
|
+
|
|
129
|
+
/** One incident as the browser sees it. */
|
|
130
|
+
const boardEntry = (events: readonly SessionEvent[], id: string) =>
|
|
131
|
+
dashboard(events)?.incidents.find((i) => i.id === id);
|
|
132
|
+
|
|
133
|
+
/** Every call to `tool` across the whole shift. */
|
|
134
|
+
const callsTo = (session: EvalSession, tool: string) =>
|
|
135
|
+
session.toolCalls().filter((c) => c.name === tool);
|
|
136
|
+
|
|
137
|
+
/** The 911 call all four cases open with — "cardiac arrest" is what
|
|
138
|
+
* `recommendSeverity` reads as critical and `recommendType` as medical. */
|
|
139
|
+
const THE_CALL =
|
|
140
|
+
"Take this call: 400 Oak Street, cardiac arrest, CPR in progress. " +
|
|
141
|
+
"Caller is Jane Doe, callback five five five, zero one zero one.";
|
|
142
|
+
|
|
143
|
+
/** The scripted turn that logs it. */
|
|
144
|
+
const LOG_TURN = [
|
|
145
|
+
{
|
|
146
|
+
tool: "incident_create",
|
|
147
|
+
args: {
|
|
148
|
+
location: "400 Oak Street",
|
|
149
|
+
description: "Cardiac arrest, CPR in progress",
|
|
150
|
+
callerName: "Jane Doe",
|
|
151
|
+
callerPhone: "555-0101",
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
"Copy — logged as a priority one. Confirming severity and getting units rolling.",
|
|
155
|
+
] as const;
|
|
156
|
+
|
|
157
|
+
describeEval(dispatchAgent, (test) => {
|
|
158
|
+
test(
|
|
159
|
+
"refuses a unit's radio call while nothing is logged on the shift",
|
|
160
|
+
async ({ session }) => {
|
|
161
|
+
// A unit radioing in is not an emergency, so it gives the desk nothing to
|
|
162
|
+
// log — which is what makes the gate the only thing that can answer.
|
|
163
|
+
// Measured live: a DISPATCH order does not, because a competent model logs
|
|
164
|
+
// the call first and then legitimately reaches the gated tools from
|
|
165
|
+
// `working`, and a case that read that as a gate failure would be wrong.
|
|
166
|
+
const turn = await session.say("Medic-1 just radioed in — mark them available.");
|
|
167
|
+
|
|
168
|
+
// Every gated call the model made while the shift was still in standby
|
|
169
|
+
// has to have been refused, and the refusal has to say where the shift
|
|
170
|
+
// actually is. The `incident_create` guard is the lesson above, kept:
|
|
171
|
+
// anything issued AFTER a call was logged is in `working` and legal.
|
|
172
|
+
const logged = turn.toolCalls.findIndex((c) => c.name === "incident_create");
|
|
173
|
+
for (const [index, call] of turn.toolCalls.entries()) {
|
|
174
|
+
if (!GATED_TOOLS.has(call.name)) continue;
|
|
175
|
+
if (logged !== -1 && index > logged) continue;
|
|
176
|
+
expect(call.result).toMatch(dialogRefusalPattern("standby"));
|
|
177
|
+
}
|
|
178
|
+
// Nothing was logged, so the board the browser holds is still empty.
|
|
179
|
+
expect(dashboard(session.events())?.incidents ?? []).toEqual([]);
|
|
180
|
+
// And it said so rather than pretending the unit had been updated.
|
|
181
|
+
expect(turn.text).toMatch(/nothing|no incident|not logged|standby|call|log/i);
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
stubReply: [
|
|
185
|
+
{ tool: "resources_update_status", args: { callsign: "Medic-1", status: "available" } },
|
|
186
|
+
"Nothing is logged on this shift yet — give me a call and I'll open it.",
|
|
187
|
+
],
|
|
188
|
+
},
|
|
189
|
+
);
|
|
190
|
+
|
|
191
|
+
test(
|
|
192
|
+
"logs a 911 call, scores it, and moves the shift to triaging",
|
|
193
|
+
async ({ session }) => {
|
|
194
|
+
const turn = await session.say(THE_CALL);
|
|
195
|
+
|
|
196
|
+
const logged = turn.toolCalls.find((c) => c.name === "incident_create");
|
|
197
|
+
expect(logged?.args.location).toMatch(/oak/i);
|
|
198
|
+
const created = toolResultIn(turn.toolCalls, "incident_create", Created);
|
|
199
|
+
// The recommendation is the desk's own scoring, not the model's opinion:
|
|
200
|
+
// `recommendSeverity` reads "cardiac arrest" and `recommendType` reads
|
|
201
|
+
// "cardiac". A model that paraphrased the emergency away would show up
|
|
202
|
+
// here rather than in a sentence nobody checks.
|
|
203
|
+
expect(created).toMatchObject({
|
|
204
|
+
recommendedSeverity: "critical",
|
|
205
|
+
recommendedType: "medical",
|
|
206
|
+
});
|
|
207
|
+
// `incident_create` is ungated and SPREADS the position it landed in, so
|
|
208
|
+
// the model reads "confirm the severity and type" as part of this result.
|
|
209
|
+
expect(created.state).toBe("working.triaging");
|
|
210
|
+
// And the board the browser holds has it, at the severity the desk chose.
|
|
211
|
+
expect(boardEntry(session.events(), FIRST_INCIDENT)).toMatchObject({
|
|
212
|
+
severity: "critical",
|
|
213
|
+
location: "400 Oak Street",
|
|
214
|
+
});
|
|
215
|
+
},
|
|
216
|
+
{ stubReply: [...LOG_TURN] },
|
|
217
|
+
);
|
|
218
|
+
|
|
219
|
+
test(
|
|
220
|
+
"rolls units on a logged incident and follows them to monitoring",
|
|
221
|
+
async ({ session }) => {
|
|
222
|
+
const turns = await session.sayAll([THE_CALL, "Dispatch the recommended units now."]);
|
|
223
|
+
|
|
224
|
+
// The turn the dispatch fired in, whichever one that turned out to be:
|
|
225
|
+
// how many turns a desk spends getting there is the model's business, so
|
|
226
|
+
// a case pinned to turn two is a flake with a misleading name. A shift
|
|
227
|
+
// that never dispatched at all fails HERE, with every turn's tool list in
|
|
228
|
+
// the message, rather than as an `undefined` three assertions later.
|
|
229
|
+
const dispatching = turnCalling(turns, "resources_dispatch");
|
|
230
|
+
const rolled = toolResultIn(dispatching.toolCalls, "resources_dispatch", Dispatch);
|
|
231
|
+
// Units really assigned — `dispatched` is empty when every requested
|
|
232
|
+
// callsign was busy, which is the case the fourth test owns.
|
|
233
|
+
expect(rolled.result.dispatched.length).toBeGreaterThan(0);
|
|
234
|
+
// `sendFrom` only fires when something rolled, so this is the position
|
|
235
|
+
// moving BECAUSE of the dispatch rather than alongside it.
|
|
236
|
+
expect(rolled.state).toBe("working.monitoring");
|
|
237
|
+
// The board agrees: the incident is dispatched, not merely triaged.
|
|
238
|
+
expect(boardEntry(session.events(), FIRST_INCIDENT)?.status).toBe("dispatched");
|
|
239
|
+
// And the order is the one the desk's flow requires: log, then dispatch.
|
|
240
|
+
const names = toolNames(session.toolCalls());
|
|
241
|
+
expect(names.indexOf("resources_dispatch")).toBeGreaterThan(names.indexOf("incident_create"));
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
stubReply: [
|
|
245
|
+
...LOG_TURN,
|
|
246
|
+
{ tool: "resources_dispatch", args: { incidentId: FIRST_INCIDENT, autoDispatch: true } },
|
|
247
|
+
"Medic-1 is rolling priority one, ETA under five.",
|
|
248
|
+
],
|
|
249
|
+
},
|
|
250
|
+
);
|
|
251
|
+
|
|
252
|
+
test(
|
|
253
|
+
"closing an incident releases the units that were on it",
|
|
254
|
+
async ({ session }) => {
|
|
255
|
+
await session.sayAll([
|
|
256
|
+
THE_CALL,
|
|
257
|
+
"Dispatch the recommended units, emergency priority.",
|
|
258
|
+
"Units report the patient is transported and they're clear. Close it out.",
|
|
259
|
+
]);
|
|
260
|
+
|
|
261
|
+
const closed = callsTo(session, "incident_update_status").filter(
|
|
262
|
+
(c) => c.args.status === "resolved",
|
|
263
|
+
);
|
|
264
|
+
expect(closed).toHaveLength(1);
|
|
265
|
+
// The release is the DESK's, not the model's: `resolved` is the one status
|
|
266
|
+
// that detaches every unit still assigned to this incident and says so on
|
|
267
|
+
// the incident's own timeline. A model cannot route around it, which is
|
|
268
|
+
// what makes this the claim worth asserting live. (The BUSY-unit refusal
|
|
269
|
+
// an earlier draft tried to assert here is the case below: a competent
|
|
270
|
+
// dispatcher checks availability first and never triggers it, so it is
|
|
271
|
+
// `{ scripted: true }` rather than weakened into this one.)
|
|
272
|
+
const resolved = toolResultIn(closed.slice(0, 1), "incident_update_status", StatusChange);
|
|
273
|
+
expect(resolved.result.newStatus).toBe("resolved");
|
|
274
|
+
// On the incident's TIMELINE, which is where the desk writes it — the
|
|
275
|
+
// regex this replaces matched the sentence anywhere in the JSON without
|
|
276
|
+
// saying which field was supposed to carry it.
|
|
277
|
+
expect(resolved.result.timeline).toContainEqual(
|
|
278
|
+
expect.stringContaining("All resources released"),
|
|
279
|
+
);
|
|
280
|
+
// The board agrees, which is the half a browser would show.
|
|
281
|
+
expect(boardEntry(session.events(), FIRST_INCIDENT)?.status).toBe("resolved");
|
|
282
|
+
// And the shift ran in the order the flow requires.
|
|
283
|
+
const names = toolNames(session.toolCalls());
|
|
284
|
+
expect(names.indexOf("incident_create")).toBeGreaterThanOrEqual(0);
|
|
285
|
+
expect(names.indexOf("resources_dispatch")).toBeGreaterThan(names.indexOf("incident_create"));
|
|
286
|
+
expect(names.lastIndexOf("incident_update_status")).toBeGreaterThan(
|
|
287
|
+
names.indexOf("resources_dispatch"),
|
|
288
|
+
);
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
stubReply: [
|
|
292
|
+
...LOG_TURN,
|
|
293
|
+
{
|
|
294
|
+
tool: "resources_dispatch",
|
|
295
|
+
args: { incidentId: FIRST_INCIDENT, autoDispatch: true, priority: "emergency" },
|
|
296
|
+
},
|
|
297
|
+
"Medic-1 rolling priority one to 400 Oak Street.",
|
|
298
|
+
{
|
|
299
|
+
tool: "incident_update_status",
|
|
300
|
+
args: { incidentId: FIRST_INCIDENT, status: "resolved", notes: "Patient transported" },
|
|
301
|
+
},
|
|
302
|
+
"Copy — Oak Street is closed and the units are clear.",
|
|
303
|
+
],
|
|
304
|
+
},
|
|
305
|
+
);
|
|
306
|
+
|
|
307
|
+
test(
|
|
308
|
+
"a unit already rolling is not sent to a second call",
|
|
309
|
+
async ({ session }) => {
|
|
310
|
+
await session.sayAll([
|
|
311
|
+
THE_CALL,
|
|
312
|
+
"Send Medic-1 to Oak Street.",
|
|
313
|
+
"New call: 12 Pine Lane, chest pains. Log it.",
|
|
314
|
+
"Send Medic-1 to Pine Lane as well.",
|
|
315
|
+
]);
|
|
316
|
+
|
|
317
|
+
const dispatches = callsTo(session, "resources_dispatch");
|
|
318
|
+
// The second request is the subject, so both have to have gone out.
|
|
319
|
+
expect(dispatches).toHaveLength(2);
|
|
320
|
+
const [first, second] = dispatches;
|
|
321
|
+
// Medic-1 really rolled the first time — otherwise the refusal below is
|
|
322
|
+
// about a unit that was never busy.
|
|
323
|
+
const firstRoll = toolResultIn(first ? [first] : [], "resources_dispatch", Dispatch);
|
|
324
|
+
expect(firstRoll.result.dispatched.map((r) => r.callsign)).toContain("Medic-1");
|
|
325
|
+
expect(firstRoll.state).toBe("working.monitoring");
|
|
326
|
+
// And the second time the desk REFUSED rather than double-booking it:
|
|
327
|
+
// `failed` carries the reason and `dispatched` is empty. The unit is
|
|
328
|
+
// committed to ONE incident, which is the property a dispatch desk is
|
|
329
|
+
// useless without and which no prompt can carry.
|
|
330
|
+
const secondRoll = toolResultIn(second ? [second] : [], "resources_dispatch", Dispatch);
|
|
331
|
+
expect(secondRoll.result.dispatched).toEqual([]);
|
|
332
|
+
expect(secondRoll.result.failed).toContainEqual({
|
|
333
|
+
callsign: "Medic-1",
|
|
334
|
+
reason: "Currently dispatched",
|
|
335
|
+
});
|
|
336
|
+
// `sendFrom` only fires when something rolled, so the call did NOT
|
|
337
|
+
// advance: logging Pine Lane put it back at `triaging`, and a dispatch
|
|
338
|
+
// that dispatched nothing leaves it there.
|
|
339
|
+
expect(secondRoll.state).toBe("working.triaging");
|
|
340
|
+
// The board agrees on both halves — the second incident never reached
|
|
341
|
+
// `dispatched`, and the first one still holds the unit.
|
|
342
|
+
expect(boardEntry(session.events(), SECOND_INCIDENT)?.status).not.toBe("dispatched");
|
|
343
|
+
expect(boardEntry(session.events(), FIRST_INCIDENT)?.status).toBe("dispatched");
|
|
344
|
+
},
|
|
345
|
+
// Scripted only. `resources_get_available` is in this desk's tool list and
|
|
346
|
+
// the prompt tells it to check capacity, so a live model looks first and
|
|
347
|
+
// never asks for a busy unit — which is the right behaviour and leaves the
|
|
348
|
+
// refusal unobserved. Forcing the call is the only way to see the guard
|
|
349
|
+
// itself, and a case that "accepts either" would assert nothing live.
|
|
350
|
+
{
|
|
351
|
+
scripted: true,
|
|
352
|
+
stubReply: [
|
|
353
|
+
...LOG_TURN,
|
|
354
|
+
{
|
|
355
|
+
tool: "resources_dispatch",
|
|
356
|
+
args: { incidentId: FIRST_INCIDENT, callsigns: ["Medic-1"], priority: "emergency" },
|
|
357
|
+
},
|
|
358
|
+
"Medic-1 is rolling to 400 Oak Street.",
|
|
359
|
+
{
|
|
360
|
+
tool: "incident_create",
|
|
361
|
+
args: { location: "12 Pine Lane", description: "Chest pains" },
|
|
362
|
+
},
|
|
363
|
+
"Logged as a second incident.",
|
|
364
|
+
{
|
|
365
|
+
tool: "resources_dispatch",
|
|
366
|
+
args: { incidentId: SECOND_INCIDENT, callsigns: ["Medic-1"], priority: "priority" },
|
|
367
|
+
},
|
|
368
|
+
"Medic-1 is already committed to Oak Street — I'll find you another unit.",
|
|
369
|
+
],
|
|
370
|
+
},
|
|
371
|
+
);
|
|
372
|
+
});
|