@alexkroman1/aai-cli 0.17.0 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{_agent-BopNO5Bq.mjs → _agent-BN21AHsJ.mjs} +4 -4
- package/dist/_api-client-Uljj0CQi.mjs +312 -0
- package/dist/_api-client.d.ts +69 -1
- package/dist/{_bundler-DCuNHjDF.mjs → _bundler-DvZDEu2p.mjs} +67 -7
- package/dist/_bundler.d.ts +15 -0
- package/dist/_cli-common.d.ts +42 -0
- package/dist/{client-bundler-DE-AGdm7.mjs → _client-plugins-kR43nZnb.mjs} +30 -132
- package/dist/_client-plugins.d.ts +16 -0
- package/dist/{_config-mq1I5Cva.mjs → _config-Dlh8PRRp.mjs} +2 -20
- package/dist/_config.d.ts +0 -8
- package/dist/{_dev-server-D6VSQbYW.mjs → _dev-server-C_zidzWj.mjs} +15 -10
- package/dist/_dev-session-ticket.d.ts +3 -0
- package/dist/_dev-tunnel.d.ts +20 -2
- package/dist/_dotenv-file.d.ts +6 -0
- package/dist/_init.d.ts +2 -11
- package/dist/_output.d.ts +47 -20
- package/dist/_safe-write.d.ts +38 -0
- package/dist/{_server-common-CVXIeWrY.mjs → _server-common-C6j67AcZ.mjs} +37 -2
- package/dist/_server-common.d.ts +16 -0
- package/dist/{_slug-api-BnmTHtjd.mjs → _slug-api-B9cptz7Q.mjs} +3 -2
- package/dist/_start-affinity.d.ts +70 -0
- package/dist/_start-log.d.ts +39 -0
- package/dist/_start-router.d.ts +85 -0
- package/dist/_start-run.d.ts +101 -0
- package/dist/_start-worker.d.ts +61 -0
- package/dist/_start-workers-BNdOnTal.mjs +529 -0
- package/dist/_start-workers.d.ts +262 -0
- package/dist/_studio-zympBLlD.mjs +140 -0
- package/dist/_studio.d.ts +14 -0
- package/dist/_target-bundle.d.ts +4 -0
- package/dist/{_templates-BVMVsQh0.mjs → _templates-ChZuhW66.mjs} +110 -8
- package/dist/_templates.d.ts +20 -1
- package/dist/{_typecheck-gate-CcX2gLJZ.mjs → _typecheck-gate-BNF5cboL.mjs} +2 -2
- package/dist/_ui-C0RufoYZ.mjs +147 -0
- package/dist/_ui.d.ts +14 -3
- package/dist/_utils-ChU85MEg.mjs +486 -0
- package/dist/_utils.d.ts +28 -0
- package/dist/_vendor-openers.d.ts +87 -0
- package/dist/{_vitest-runner-CKI8_K1b.mjs → _vitest-runner-tzyto9IU.mjs} +7 -3
- package/dist/_vitest-runner.d.ts +8 -1
- package/dist/{build-BnXLgfk-.mjs → build-BHgd-QYb.mjs} +13 -10
- package/dist/build.d.ts +21 -0
- package/dist/cli-workflow.d.ts +7 -0
- package/dist/cli.d.ts +16 -0
- package/dist/cli.mjs +243 -70
- package/dist/client-bundler-CImhqcp2.mjs +133 -0
- package/dist/client-bundler.mjs +1 -1
- package/dist/{console-tVBjfKyR.mjs → console-DwycgRkC.mjs} +4 -5
- package/dist/delete-ZcA3J_3o.mjs +75 -0
- package/dist/delete.d.ts +10 -1
- package/dist/{deploy-eWDoiwvn.mjs → deploy-CkfkiZE3.mjs} +9 -9
- package/dist/{dev-CT_QHHZL.mjs → dev-BX9g6qcf.mjs} +81 -18
- package/dist/{eval-Dl8o91yC.mjs → eval-CUKvfxRq.mjs} +4 -4
- package/dist/{init-CidslZZz.mjs → init-B9Uw76-_.mjs} +62 -32
- package/dist/{login-oJdBWu2B.mjs → login-Ct73CqU1.mjs} +30 -6
- package/dist/login.d.ts +2 -0
- package/dist/{logs-CkmFdSbr.mjs → logs-BBsUy96d.mjs} +59 -14
- package/dist/logs.d.ts +4 -1
- package/dist/project-config.mjs +1 -1
- package/dist/scaffold/CLAUDE.md +72 -55
- package/dist/scaffold/agent-guide/AGENT-API.md +44 -34
- package/dist/scaffold/agent-guide/HOSTING.md +11 -0
- package/dist/scaffold/agent-guide/TESTING-EVALS.md +105 -36
- package/dist/scaffold/agent-guide/TOOLS.md +189 -33
- package/dist/scaffold/agent-guide/UI.md +111 -39
- package/dist/scaffold/agent-guide/WORKFLOWS.md +234 -160
- package/dist/scaffold/package.json +4 -4
- package/dist/{secret-DPdPEet2.mjs → secret-CKjHRrVX.mjs} +112 -35
- package/dist/start.d.ts +14 -14
- package/dist/start.mjs +840 -40
- package/dist/{studio-COjK25Rl.mjs → studio-U6DvBNAx.mjs} +123 -35
- package/dist/studio.d.ts +1 -0
- package/dist/templates/applicant-screening-agent/agent.eval.test.ts +23 -52
- package/dist/templates/applicant-screening-agent/agent.test.ts +821 -826
- package/dist/templates/applicant-screening-agent/agent.ts +1 -6
- package/dist/templates/applicant-screening-agent/client.tsx +1 -19
- package/dist/templates/applicant-screening-agent/shared.ts +8 -18
- package/dist/templates/applicant-screening-agent/tools/candidate_details.ts +24 -27
- package/dist/templates/applicant-screening-agent/tools/proceed_to_emails.ts +75 -82
- package/dist/templates/applicant-screening-agent/tools/read_email.ts +24 -24
- package/dist/templates/applicant-screening-agent/tools/rescore_with_feedback.ts +92 -99
- package/dist/templates/applicant-screening-agent/tools/screen_candidates.ts +72 -83
- package/dist/templates/applicant-screening-agent/tools/screening_status.ts +21 -29
- package/dist/templates/call-audit-workflow/agent.eval.test.ts +14 -19
- package/dist/templates/call-audit-workflow/agent.test.ts +275 -169
- package/dist/templates/call-audit-workflow/agent.ts +12 -30
- package/dist/templates/call-audit-workflow/client.tsx +9 -27
- package/dist/templates/call-audit-workflow/guards.test.ts +24 -71
- package/dist/templates/call-audit-workflow/workflows/audit.ts +24 -52
- package/dist/templates/call-audit-workflow/workflows/ingest.ts +32 -59
- package/dist/templates/call-audit-workflow/workflows/media.ts +4 -44
- package/dist/templates/call-audit-workflow/workflows/summarize.ts +72 -107
- package/dist/templates/code-interpreter-agent/agent.eval.test.ts +3 -2
- package/dist/templates/code-interpreter-agent/agent.test.ts +4 -17
- package/dist/templates/code-interpreter-agent/agent.ts +1 -1
- package/dist/templates/coding-agent/agent.test.ts +17 -12
- package/dist/templates/coding-agent/agent.ts +1 -1
- package/dist/templates/custom-pipeline-agent/agent.test.ts +6 -14
- package/dist/templates/custom-pipeline-agent/agent.ts +1 -1
- package/dist/templates/custom-pipeline-agent/modes.test.ts +0 -1
- package/dist/templates/document-redline-workflow/agent.test.ts +88 -221
- package/dist/templates/document-redline-workflow/agent.ts +22 -32
- package/dist/templates/document-redline-workflow/client.tsx +46 -88
- package/dist/templates/document-redline-workflow/workflows/prompts.ts +0 -3
- package/dist/templates/document-redline-workflow/workflows/redline.ts +33 -50
- package/dist/templates/emergency-dispatch-agent/agent.eval.test.ts +22 -71
- package/dist/templates/emergency-dispatch-agent/agent.test.ts +466 -495
- package/dist/templates/emergency-dispatch-agent/agent.ts +27 -43
- package/dist/templates/emergency-dispatch-agent/client.tsx +85 -119
- package/dist/templates/emergency-dispatch-agent/shared.ts +51 -88
- package/dist/templates/emergency-dispatch-agent/tools/incident_add_note.ts +11 -17
- package/dist/templates/emergency-dispatch-agent/tools/incident_create.ts +21 -30
- package/dist/templates/emergency-dispatch-agent/tools/incident_escalate.ts +60 -63
- package/dist/templates/emergency-dispatch-agent/tools/incident_get.ts +6 -15
- package/dist/templates/emergency-dispatch-agent/tools/incident_triage.ts +40 -53
- package/dist/templates/emergency-dispatch-agent/tools/incident_update_status.ts +41 -47
- package/dist/templates/emergency-dispatch-agent/tools/ops_dashboard.ts +2 -2
- package/dist/templates/emergency-dispatch-agent/tools/ops_protocols.ts +1 -1
- package/dist/templates/emergency-dispatch-agent/tools/ops_run_scenario.ts +13 -10
- package/dist/templates/emergency-dispatch-agent/tools/resources_dispatch.ts +42 -51
- package/dist/templates/emergency-dispatch-agent/tools/resources_update_status.ts +40 -41
- package/dist/templates/entertainment-picks-agent/agent.eval.test.ts +14 -42
- package/dist/templates/entertainment-picks-agent/agent.test.ts +174 -221
- package/dist/templates/entertainment-picks-agent/agent.ts +1 -6
- package/dist/templates/entertainment-picks-agent/client.tsx +1 -12
- package/dist/templates/entertainment-picks-agent/shared.ts +12 -6
- package/dist/templates/entertainment-picks-agent/tools/recommend.ts +2 -2
- package/dist/templates/entertainment-picks-agent/tools/revisit.ts +1 -0
- package/dist/templates/executive-inbox-agent/agent.eval.test.ts +15 -22
- package/dist/templates/executive-inbox-agent/agent.test.ts +515 -527
- package/dist/templates/executive-inbox-agent/agent.ts +4 -8
- package/dist/templates/executive-inbox-agent/calendar.test.ts +23 -22
- package/dist/templates/executive-inbox-agent/client.tsx +1 -23
- package/dist/templates/executive-inbox-agent/review.ts +125 -113
- package/dist/templates/executive-inbox-agent/shared.ts +3 -0
- package/dist/templates/executive-inbox-agent/tools/ask_question.ts +6 -6
- package/dist/templates/executive-inbox-agent/tools/draft_reply.ts +16 -18
- package/dist/templates/executive-inbox-agent/tools/inbox_status.ts +1 -0
- package/dist/templates/executive-inbox-agent/tools/meeting_assistant.ts +20 -20
- package/dist/templates/executive-inbox-agent/tools/new_email.ts +17 -21
- package/dist/templates/executive-inbox-agent/tools/open_email.ts +72 -74
- package/dist/templates/executive-inbox-agent/tools/review_memory.ts +1 -0
- package/dist/templates/executive-inbox-agent/tools/send_calendar_invite.ts +19 -20
- package/dist/templates/executive-inbox-agent/tools/triage_inbox.ts +53 -50
- package/dist/templates/front-desk-agent/agent.eval.test.ts +22 -14
- package/dist/templates/front-desk-agent/agent.test.ts +139 -123
- package/dist/templates/front-desk-agent/agent.ts +4 -7
- package/dist/templates/front-desk-agent/shared.ts +88 -74
- package/dist/templates/front-door-agent/agent.eval.test.ts +61 -0
- package/dist/templates/front-door-agent/agent.test.ts +393 -0
- package/dist/templates/front-door-agent/agent.ts +35 -0
- package/dist/templates/front-door-agent/client.tsx +250 -0
- package/dist/templates/front-door-agent/routes.ts +91 -0
- package/dist/templates/front-door-agent/shared.ts +35 -0
- package/dist/templates/front-door-agent/system-prompt.md +12 -0
- package/dist/templates/front-door-agent/tools/leave_message.ts +39 -0
- package/dist/templates/front-door-agent/tools/link_phone.ts +49 -0
- package/dist/templates/front-door-agent/workflows/announce.ts +38 -0
- package/dist/templates/front-door-agent/workflows/digest.ts +53 -0
- package/dist/templates/front-door-agent/workflows/pair.ts +28 -0
- package/dist/templates/home-assistant-agent/agent.eval.test.ts +5 -9
- package/dist/templates/home-assistant-agent/agent.test.ts +513 -399
- package/dist/templates/home-assistant-agent/agent.ts +8 -5
- package/dist/templates/home-assistant-agent/client.tsx +48 -9
- package/dist/templates/home-assistant-agent/tools/cancel_reminders.ts +1 -0
- package/dist/templates/home-assistant-agent/tools/remind_me.ts +2 -1
- package/dist/templates/hotel-reception-agent/agent.eval.test.ts +27 -52
- package/dist/templates/hotel-reception-agent/agent.test.ts +980 -964
- package/dist/templates/hotel-reception-agent/agent.ts +8 -21
- package/dist/templates/hotel-reception-agent/booking.ts +2 -2
- package/dist/templates/hotel-reception-agent/client.tsx +5 -20
- package/dist/templates/hotel-reception-agent/concierge.ts +2 -0
- package/dist/templates/hotel-reception-agent/desk-seams.test.ts +285 -275
- package/dist/templates/hotel-reception-agent/desk.ts +45 -12
- package/dist/templates/hotel-reception-agent/hotel.ts +6 -6
- package/dist/templates/hotel-reception-agent/restaurant.ts +3 -4
- package/dist/templates/hotel-reception-agent/session.ts +14 -30
- package/dist/templates/hotel-reception-agent/shared.ts +33 -46
- package/dist/templates/hotel-reception-agent/tools/abandon_booking.ts +14 -15
- package/dist/templates/hotel-reception-agent/tools/add_to_waitlist.ts +1 -0
- package/dist/templates/hotel-reception-agent/tools/book_airport_car.ts +1 -0
- package/dist/templates/hotel-reception-agent/tools/cancel_restaurant_reservation.ts +2 -2
- package/dist/templates/hotel-reception-agent/tools/cancel_room_booking.ts +13 -10
- package/dist/templates/hotel-reception-agent/tools/choose_room.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/confirm_booking.ts +6 -7
- package/dist/templates/hotel-reception-agent/tools/dispatch_emergency.ts +1 -0
- package/dist/templates/hotel-reception-agent/tools/dispute_charge.ts +5 -4
- package/dist/templates/hotel-reception-agent/tools/flag_late_arrival.ts +6 -5
- package/dist/templates/hotel-reception-agent/tools/lookup_booking.ts +3 -4
- package/dist/templates/hotel-reception-agent/tools/lookup_invoice.ts +4 -4
- package/dist/templates/hotel-reception-agent/tools/modify_restaurant_reservation.ts +1 -0
- package/dist/templates/hotel-reception-agent/tools/record_card.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/record_followup.ts +1 -0
- package/dist/templates/hotel-reception-agent/tools/record_group_inquiry.ts +1 -0
- package/dist/templates/hotel-reception-agent/tools/record_guest_details.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/reinstate_booking.ts +1 -0
- package/dist/templates/hotel-reception-agent/tools/request_flight_reconfirmation.ts +1 -0
- package/dist/templates/hotel-reception-agent/tools/resend_confirmation.ts +4 -4
- package/dist/templates/hotel-reception-agent/tools/reserve_table.ts +1 -0
- package/dist/templates/hotel-reception-agent/tools/resolve_room_conflict.ts +4 -3
- package/dist/templates/hotel-reception-agent/tools/schedule_wakeup_call.ts +1 -0
- package/dist/templates/hotel-reception-agent/tools/set_do_not_disturb.ts +1 -0
- package/dist/templates/hotel-reception-agent/tools/set_extras.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/set_stay.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/start_booking_modification.ts +30 -32
- package/dist/templates/hotel-reception-agent/tools/start_room_booking.ts +22 -25
- package/dist/templates/hotel-reception-agent/tools/take_guest_message.ts +1 -0
- package/dist/templates/hotel-reception-agent/tools/update_card.ts +5 -4
- package/dist/templates/hotel-reception-agent/tools/verify_booking.ts +23 -13
- package/dist/templates/kitchen-coach-agent/agent.eval.test.ts +38 -0
- package/dist/templates/kitchen-coach-agent/agent.test.ts +204 -0
- package/dist/templates/kitchen-coach-agent/agent.ts +22 -0
- package/dist/templates/kitchen-coach-agent/client.tsx +232 -0
- package/dist/templates/kitchen-coach-agent/history.ts +37 -0
- package/dist/templates/kitchen-coach-agent/shared.ts +131 -0
- package/dist/templates/kitchen-coach-agent/system-prompt.md +17 -0
- package/dist/templates/kitchen-coach-agent/tools/get_kitchen.ts +17 -0
- package/dist/templates/kitchen-coach-agent/tools/scale_amount.ts +31 -0
- package/dist/templates/kitchen-coach-agent/tools/start_timer.ts +24 -0
- package/dist/templates/link-digest-workflow/agent.eval.test.ts +16 -40
- package/dist/templates/link-digest-workflow/agent.test.ts +84 -164
- package/dist/templates/link-digest-workflow/agent.ts +27 -42
- package/dist/templates/link-digest-workflow/api-client.ts +3 -2
- package/dist/templates/link-digest-workflow/client.tsx +5 -5
- package/dist/templates/link-digest-workflow/workflows/digest.ts +53 -95
- package/dist/templates/medication-safety-agent/agent.eval.test.ts +10 -30
- package/dist/templates/medication-safety-agent/agent.test.ts +16 -46
- package/dist/templates/medication-safety-agent/agent.ts +1 -4
- package/dist/templates/medication-safety-agent/tools/check_drug_interaction.ts +13 -10
- package/dist/templates/meeting-recap-agent/agent.eval.test.ts +238 -396
- package/dist/templates/meeting-recap-agent/agent.test.ts +414 -1070
- package/dist/templates/meeting-recap-agent/agent.ts +26 -67
- package/dist/templates/meeting-recap-agent/system-prompt.md +1 -0
- package/dist/templates/meeting-recap-agent/tools/keep_transcript.ts +10 -12
- package/dist/templates/meeting-recap-agent/tools/request_recap.ts +9 -20
- package/dist/templates/meeting-recap-agent/workflows/recap.ts +224 -547
- package/dist/templates/outbound-call-agent/agent.eval.test.ts +10 -12
- package/dist/templates/outbound-call-agent/agent.test.ts +419 -453
- package/dist/templates/outbound-call-agent/agent.ts +57 -62
- package/dist/templates/outbound-call-agent/api.ts +53 -68
- package/dist/templates/outbound-call-agent/client.tsx +105 -176
- package/dist/templates/outbound-call-agent/shared.ts +10 -39
- package/dist/templates/outbound-call-agent/system-prompt.md +3 -4
- package/dist/templates/outbound-call-agent/tools/end_call.ts +15 -12
- package/dist/templates/outbound-call-agent/tools/press_keys.ts +8 -13
- package/dist/templates/outbound-call-agent/workflows/call.ts +89 -62
- package/dist/templates/pizza-ordering-agent/agent.eval.test.ts +18 -54
- package/dist/templates/pizza-ordering-agent/agent.test.ts +205 -244
- package/dist/templates/pizza-ordering-agent/agent.ts +5 -12
- package/dist/templates/pizza-ordering-agent/client.tsx +3 -14
- package/dist/templates/pizza-ordering-agent/shared.ts +31 -36
- package/dist/templates/pizza-ordering-agent/tools/add_pizza.ts +1 -0
- package/dist/templates/pizza-ordering-agent/tools/place_order.ts +5 -2
- package/dist/templates/pizza-ordering-agent/tools/remove_pizza.ts +1 -0
- package/dist/templates/pizza-ordering-agent/tools/update_pizza.ts +2 -3
- package/dist/templates/pizza-ordering-agent/tools/view_order.ts +7 -3
- package/dist/templates/podcast-digest-workflow/agent.test.ts +53 -102
- package/dist/templates/podcast-digest-workflow/agent.ts +11 -17
- package/dist/templates/podcast-digest-workflow/client.tsx +29 -51
- package/dist/templates/podcast-digest-workflow/workflows/digest.ts +24 -26
- package/dist/templates/push-to-talk-agent/agent.eval.test.ts +13 -14
- package/dist/templates/push-to-talk-agent/agent.test.ts +30 -23
- package/dist/templates/push-to-talk-agent/agent.ts +1 -5
- package/dist/templates/push-to-talk-agent/client.tsx +1 -11
- package/dist/templates/push-to-talk-agent/shared.ts +12 -6
- package/dist/templates/push-to-talk-agent/tools/list_notes.ts +1 -0
- package/dist/templates/push-to-talk-agent/tools/save_note.ts +1 -0
- package/dist/templates/quickstart-agent/agent.eval.test.ts +0 -10
- package/dist/templates/quickstart-agent/agent.test.ts +18 -30
- package/dist/templates/quickstart-agent/agent.ts +3 -4
- package/dist/templates/research-handoff-agent/agent.eval.test.ts +161 -290
- package/dist/templates/research-handoff-agent/agent.test.ts +131 -457
- package/dist/templates/research-handoff-agent/agent.ts +26 -86
- package/dist/templates/research-handoff-agent/system-prompt.md +1 -0
- package/dist/templates/research-handoff-agent/tools/file_it_now.ts +8 -21
- package/dist/templates/research-handoff-agent/tools/request_research.ts +7 -16
- package/dist/templates/research-handoff-agent/workflows/research.ts +88 -40
- package/dist/templates/research-planner-agent/agent.eval.test.ts +15 -40
- package/dist/templates/research-planner-agent/agent.test.ts +415 -464
- package/dist/templates/research-planner-agent/agent.ts +3 -8
- package/dist/templates/research-planner-agent/client.tsx +1 -14
- package/dist/templates/research-planner-agent/procedure.ts +9 -3
- package/dist/templates/research-planner-agent/shared.ts +30 -33
- package/dist/templates/research-planner-agent/tools/plan_status.ts +7 -15
- package/dist/templates/research-planner-agent/tools/revise_plan.ts +29 -36
- package/dist/templates/research-planner-agent/tools/start_plan.ts +25 -39
- package/dist/templates/research-planner-agent/tools/work_next_step.ts +25 -42
- package/dist/templates/retail-orders-agent/agent.eval.test.ts +14 -34
- package/dist/templates/retail-orders-agent/agent.test.ts +1079 -1073
- package/dist/templates/retail-orders-agent/agent.ts +25 -78
- package/dist/templates/retail-orders-agent/client.tsx +120 -168
- package/dist/templates/retail-orders-agent/pending.test.ts +7 -14
- package/dist/templates/retail-orders-agent/registry.test.ts +93 -192
- package/dist/templates/retail-orders-agent/shared.test.ts +1 -1
- package/dist/templates/retail-orders-agent/shared.ts +10 -20
- package/dist/templates/retail-orders-agent/store.test.ts +46 -128
- package/dist/templates/retail-orders-agent/store.ts +42 -175
- package/dist/templates/retail-orders-agent/tools/cancel_change.ts +3 -6
- package/dist/templates/retail-orders-agent/tools/cancel_pending_order.ts +3 -4
- package/dist/templates/retail-orders-agent/tools/confirm_change.ts +4 -6
- package/dist/templates/retail-orders-agent/tools/exchange_delivered_order_items.ts +3 -4
- package/dist/templates/retail-orders-agent/tools/find_user_id_by_email.ts +3 -4
- package/dist/templates/retail-orders-agent/tools/find_user_id_by_name_zip.ts +3 -4
- package/dist/templates/retail-orders-agent/tools/get_item_details.ts +3 -4
- package/dist/templates/retail-orders-agent/tools/get_order_details.ts +3 -4
- package/dist/templates/retail-orders-agent/tools/get_product_details.ts +3 -4
- package/dist/templates/retail-orders-agent/tools/get_user_details.ts +3 -4
- package/dist/templates/retail-orders-agent/tools/list_all_product_types.ts +3 -8
- package/dist/templates/retail-orders-agent/tools/modify_pending_order_address.ts +3 -4
- package/dist/templates/retail-orders-agent/tools/modify_pending_order_items.ts +3 -4
- package/dist/templates/retail-orders-agent/tools/modify_pending_order_payment.ts +3 -4
- package/dist/templates/retail-orders-agent/tools/modify_user_address.ts +3 -4
- package/dist/templates/retail-orders-agent/tools/return_delivered_order_items.ts +3 -4
- package/dist/templates/retail-orders-agent/tools/transfer_to_human_agents.ts +3 -4
- package/dist/templates/roadside-assistance-agent/agent.eval.test.ts +22 -25
- package/dist/templates/roadside-assistance-agent/agent.test.ts +453 -490
- package/dist/templates/roadside-assistance-agent/agent.ts +28 -60
- package/dist/templates/roadside-assistance-agent/call.ts +16 -22
- package/dist/templates/roadside-assistance-agent/shared.ts +24 -54
- package/dist/templates/roadside-assistance-agent/tools/acknowledge_disclosure.ts +29 -37
- package/dist/templates/roadside-assistance-agent/tools/dispatch_truck.ts +44 -70
- package/dist/templates/roadside-assistance-agent/tools/job_status.ts +16 -24
- package/dist/templates/roadside-assistance-agent/tools/lookup_coverage.ts +39 -51
- package/dist/templates/roadside-assistance-agent/tools/report_location.ts +34 -33
- package/dist/templates/roadside-assistance-agent/tools/service_disclosure.ts +18 -39
- package/dist/templates/roadside-assistance-agent/yard.test.ts +22 -19
- package/dist/templates/roadside-assistance-agent/yard.ts +3 -3
- package/dist/templates/spoken-summary-workflow/agent.eval.test.ts +38 -40
- package/dist/templates/spoken-summary-workflow/agent.test.ts +129 -279
- package/dist/templates/spoken-summary-workflow/agent.ts +15 -40
- package/dist/templates/spoken-summary-workflow/client.tsx +13 -25
- package/dist/templates/spoken-summary-workflow/workflows/summarize.ts +52 -92
- package/dist/templates/tabletop-rpg-agent/agent.eval.test.ts +31 -74
- package/dist/templates/tabletop-rpg-agent/agent.test.ts +756 -774
- package/dist/templates/tabletop-rpg-agent/agent.ts +9 -46
- package/dist/templates/tabletop-rpg-agent/client.tsx +13 -21
- package/dist/templates/tabletop-rpg-agent/shared.ts +40 -99
- package/dist/templates/tabletop-rpg-agent/tools/action_roll.ts +67 -83
- package/dist/templates/tabletop-rpg-agent/tools/burn_momentum.ts +65 -88
- package/dist/templates/tabletop-rpg-agent/tools/check_state.ts +8 -27
- package/dist/templates/tabletop-rpg-agent/tools/setup_character.ts +18 -36
- package/dist/templates/tabletop-rpg-agent/tools/update_state.ts +101 -111
- package/dist/templates/technical-support-agent/agent.eval.test.ts +31 -72
- package/dist/templates/technical-support-agent/agent.test.ts +231 -260
- package/dist/templates/technical-support-agent/agent.ts +4 -10
- package/dist/templates/technical-support-agent/client.tsx +4 -18
- package/dist/templates/technical-support-agent/shared.ts +15 -25
- package/dist/templates/technical-support-agent/tools/answer_question.ts +46 -56
- package/dist/templates/technical-support-agent/tools/list_topics.ts +1 -0
- package/dist/templates/technical-support-agent/tools/log_ticket.ts +8 -5
- package/dist/templates/text-adventure-agent/agent.eval.test.ts +37 -126
- package/dist/templates/text-adventure-agent/agent.test.ts +197 -368
- package/dist/templates/text-adventure-agent/agent.ts +15 -65
- package/dist/templates/text-adventure-agent/client.tsx +38 -98
- package/dist/templates/text-adventure-agent/shared.ts +31 -143
- package/dist/templates/text-adventure-agent/tools/game_state_drop.ts +6 -12
- package/dist/templates/text-adventure-agent/tools/game_state_get.ts +4 -11
- package/dist/templates/text-adventure-agent/tools/game_state_move.ts +0 -2
- package/dist/templates/text-adventure-agent/tools/game_state_restart.ts +1 -3
- package/dist/templates/text-adventure-agent/tools/game_state_score.ts +5 -7
- package/dist/templates/topic-briefing-agent/agent.eval.test.ts +12 -50
- package/dist/templates/topic-briefing-agent/agent.test.ts +478 -476
- package/dist/templates/topic-briefing-agent/agent.ts +3 -3
- package/dist/templates/topic-briefing-agent/shared.ts +11 -16
- package/dist/templates/topic-briefing-agent/slack.ts +12 -4
- package/dist/templates/topic-briefing-agent/tools/briefing_so_far.ts +10 -17
- package/dist/templates/topic-briefing-agent/tools/research_topic.ts +21 -24
- package/dist/templates/topic-briefing-agent/tools/send_briefing.ts +13 -14
- package/dist/templates/topic-briefing-agent/tools/verify_claim.ts +16 -13
- package/dist/templates/transcription-workflow/agent.test.ts +114 -259
- package/dist/templates/transcription-workflow/agent.ts +6 -9
- package/dist/templates/transcription-workflow/client.tsx +100 -258
- package/dist/templates/transcription-workflow/recover.test.ts +6 -136
- package/dist/templates/transcription-workflow/recover.ts +14 -97
- package/dist/templates/transcription-workflow/run-panel.tsx +71 -8
- package/dist/templates/transcription-workflow/workflows/batch.ts +28 -159
- package/dist/templates/transcription-workflow/workflows/normalize.ts +50 -86
- package/dist/templates/transcription-workflow/workflows/stream.ts +2 -2
- package/dist/templates/transcription-workflow/workflows/transcribe.ts +16 -23
- package/dist/templates/travel-concierge-agent/agent.eval.test.ts +7 -25
- package/dist/templates/travel-concierge-agent/agent.test.ts +505 -517
- package/dist/templates/travel-concierge-agent/agent.ts +22 -46
- package/dist/templates/travel-concierge-agent/client.tsx +1 -22
- package/dist/templates/travel-concierge-agent/routing.ts +29 -31
- package/dist/templates/travel-concierge-agent/shared.ts +63 -152
- package/dist/templates/travel-concierge-agent/tools/book_car_rental.ts +8 -9
- package/dist/templates/travel-concierge-agent/tools/book_excursion.ts +8 -8
- package/dist/templates/travel-concierge-agent/tools/book_hotel.ts +9 -6
- package/dist/templates/travel-concierge-agent/tools/cancel_ticket.ts +10 -10
- package/dist/templates/travel-concierge-agent/tools/search_car_rentals.ts +3 -2
- package/dist/templates/travel-concierge-agent/tools/search_excursions.ts +3 -2
- package/dist/templates/travel-concierge-agent/tools/search_flights.ts +4 -3
- package/dist/templates/travel-concierge-agent/tools/search_hotels.ts +3 -2
- package/dist/templates/travel-concierge-agent/tools/update_ticket.ts +13 -8
- package/dist/templates/web-research-agent/agent.test.ts +19 -30
- package/dist/templates/web-research-agent/agent.ts +3 -4
- package/dist/templates/word-game-agent/agent.eval.test.ts +47 -67
- package/dist/templates/word-game-agent/agent.test.ts +369 -382
- package/dist/templates/word-game-agent/agent.ts +2 -5
- package/dist/templates/word-game-agent/client.tsx +1 -8
- package/dist/templates/word-game-agent/game.ts +15 -27
- package/dist/templates/word-game-agent/shared.ts +36 -20
- package/dist/templates/word-game-agent/tools/final_score.ts +14 -13
- package/dist/templates/word-game-agent/tools/relay_description.ts +90 -66
- package/dist/templates/word-game-agent/tools/repeat_word.ts +11 -10
- package/dist/templates/word-game-agent/tools/skip_word.ts +17 -21
- package/dist/templates/word-game-agent/tools/start_game.ts +26 -30
- package/dist/{test-XufelYGW.mjs → test-CW5cw5fy.mjs} +3 -4
- package/dist/typecheck.mjs +1 -1
- package/dist/worker-bundler-D8uCzpYP.mjs +335 -0
- package/dist/worker-bundler.d.ts +39 -0
- package/dist/worker-bundler.mjs +2 -155
- package/dist/{workflow-CDUlTD5B.mjs → workflow-5gOZMB2M.mjs} +66 -19
- package/package.json +4 -4
- package/dist/_output-DBP9Op_d.mjs +0 -120
- package/dist/_studio-B5m4jBTD.mjs +0 -256
- package/dist/_ui-Coe0zwmm.mjs +0 -102
- package/dist/_utils-BVLdBvdT.mjs +0 -186
- package/dist/delete-DwXCHzTl.mjs +0 -55
- package/dist/templates/document-redline-workflow/form.ts +0 -73
- package/dist/templates/emergency-dispatch-agent/events.ts +0 -48
- package/dist/templates/hotel-reception-agent/events.ts +0 -80
- package/dist/templates/meeting-recap-agent/shared.ts +0 -44
- package/dist/templates/meeting-recap-agent/tools/cancel_recap.ts +0 -25
- package/dist/templates/meeting-recap-agent/tools/recap_progress.ts +0 -24
- package/dist/templates/meeting-recap-agent/tools/recap_status.ts +0 -45
- package/dist/templates/meeting-recap-agent/workflows/tokens.ts +0 -47
- package/dist/templates/outbound-call-agent/call-params.ts +0 -109
- package/dist/templates/outbound-call-agent/live-calls.ts +0 -80
- package/dist/templates/outbound-call-agent/workflows/tokens.ts +0 -16
- package/dist/templates/research-handoff-agent/shared.ts +0 -41
- package/dist/templates/research-handoff-agent/tools/research_progress.ts +0 -23
- package/dist/templates/research-handoff-agent/tools/research_status.ts +0 -73
- package/dist/templates/research-handoff-agent/workflows/review.ts +0 -43
- package/dist/templates/roadside-assistance-agent/events.ts +0 -92
- package/dist/templates/spoken-summary-workflow/workflows/transcribe.ts +0 -137
- package/dist/templates/transcription-workflow/total-latency.tsx +0 -170
- package/dist/templates/travel-concierge-agent/call-events.ts +0 -80
|
@@ -8,10 +8,10 @@ replay engine, crashes, signals — is "Testing a workflow body" in
|
|
|
8
8
|
|
|
9
9
|
**A test file imports testing names from two doors, and only those two:**
|
|
10
10
|
|
|
11
|
-
| Import from | For
|
|
12
|
-
| ----------------------------------------- |
|
|
13
|
-
| `@alexkroman1/aai-runtime/testing` | everything that installs nothing — `
|
|
14
|
-
| `@alexkroman1/aai-runtime/testing/vitest` | everything that installs or restores (`installStubGateway`, `
|
|
11
|
+
| Import from | For |
|
|
12
|
+
| ----------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
|
|
13
|
+
| `@alexkroman1/aai-runtime/testing` | everything that installs nothing — `createToolContext`, `expectToolOk`, `expectSlotContract`, `fireEvent`, the stubs, `runWorkflow` |
|
|
14
|
+
| `@alexkroman1/aai-runtime/testing/vitest` | everything that installs or restores (`installStubGateway`, `installStubWorld`, …), `describeAgent` and the eval suites |
|
|
15
15
|
|
|
16
16
|
`vitest.config.ts` is the one exception: it imports `defineAgentTestConfig` from
|
|
17
17
|
`@alexkroman1/aai/testing/vite`. (The helpers are declared in
|
|
@@ -42,42 +42,68 @@ plugin that serves it; a scaffolded project already has it. For a runner that is
|
|
|
42
42
|
not vitest, `deployedAgent` on `@alexkroman1/aai-runtime/testing` is the same
|
|
43
43
|
thing written out.
|
|
44
44
|
|
|
45
|
-
**
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
45
|
+
**Open the suite with `describeAgent(agentDef, (run) => …)`**: a `describe`
|
|
46
|
+
named after the agent whose first case is "is deployable" (`expectDeployable`; a
|
|
47
|
+
config the platform refuses is a spec measuring nothing), handed the agent's
|
|
48
|
+
typed runner. **A tool is reached by its DEF, never by its name string.**
|
|
49
|
+
`run(toolDef, args, ctx?)` is typed end to end: handed the def, the arguments
|
|
50
|
+
are checked and the result is what `execute` returns — no `as` cast — and the
|
|
51
|
+
def is resolved in the agent's table by identity, so a dialog gate or a roster
|
|
52
|
+
still refuses it as it would the model. The def is the tool file's default
|
|
53
|
+
export (`import placeOrder from "./tools/place_order.ts"`); for a roster tool it
|
|
54
|
+
is the speaker's `tools` entry (`billing.tools.lookup_invoice` — keep the map in
|
|
55
|
+
a named const so it stays typed); for a tool the roster minted (`handoff`,
|
|
56
|
+
`delegate`) it is `toolOf(agentDef, HANDOFF_TOOL_NAME)`; for a builtin it is
|
|
57
|
+
`builtinTool("workflow_cancel")` from `@alexkroman1/aai/tools`, which no
|
|
58
|
+
`toolRunner` runs (the runtime merges builtins in at session start) but every
|
|
59
|
+
eval reader takes. A string in the tool position is a compile error. **The
|
|
60
|
+
schema is asked through the same def**: `parseToolInput(def, value)` answers the
|
|
61
|
+
parsed input typed as `execute` receives it (a dropped default is a compile
|
|
62
|
+
error in the spec that reads it) and `toolInputIssues(def, value)` the issues or
|
|
63
|
+
`undefined` — no agent, since validation is the schema's alone and the gate runs
|
|
64
|
+
only on a call. **Unwrap a result that may be a refusal with
|
|
65
|
+
`expectToolOk(result)`**, which subtracts the `ToolFailure` arm (and a gated
|
|
66
|
+
tool's envelope) and throws quoting the refusal; `expectDialogRefused(result)`
|
|
67
|
+
asserts a gate HELD. Do not copy an `ok<T>()` helper into a spec, and do not
|
|
68
|
+
claim a result's type — `expectToolOk<T>(…)` takes no claim; the def already
|
|
69
|
+
types it.
|
|
52
70
|
|
|
53
|
-
```ts
|
|
54
|
-
import
|
|
55
|
-
import { expectToolOk
|
|
71
|
+
```ts no-check
|
|
72
|
+
import agentDef from "virtual:aai/agent";
|
|
73
|
+
import { expectToolOk } from "@alexkroman1/aai-runtime/testing";
|
|
74
|
+
import { describeAgent } from "@alexkroman1/aai-runtime/testing/vitest";
|
|
56
75
|
import { expect, test } from "vitest";
|
|
57
|
-
import
|
|
76
|
+
import placeOrder from "./tools/place_order.ts";
|
|
58
77
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
test("places the order", async () => {
|
|
67
|
-
const order = expectToolOk(await runTool(placeOrder, { item: "pizza" }));
|
|
68
|
-
expect(order.id).toBe("ord_1");
|
|
78
|
+
describeAgent(agentDef, (run) => {
|
|
79
|
+
test("places the order", async () => {
|
|
80
|
+
const order = expectToolOk(await run(placeOrder, { item: "pizza" }));
|
|
81
|
+
expect(order.id).toBe("ord_1");
|
|
82
|
+
});
|
|
69
83
|
});
|
|
70
84
|
```
|
|
71
85
|
|
|
72
|
-
`expectDeployable(agentDef)`
|
|
73
|
-
`
|
|
74
|
-
|
|
86
|
+
`expectDeployable(agentDef)` on its own returns a `DeployedConfig` (`name`,
|
|
87
|
+
`systemPrompt`, `mode`, `builtinTools`, …) to assert on. **A slot's contract is
|
|
88
|
+
one call**: `expectSlotContract(slot, { write, caps })` asserts the projected
|
|
89
|
+
default agrees with the view, that two sessions never share a value (`write`
|
|
90
|
+
proves it through one of them) and that each cap keeps the NEWEST entries.
|
|
75
91
|
|
|
76
92
|
**A hand-built `ctx` is `createToolContext()`** — every field inert, `send`
|
|
77
|
-
recorded on `ctx.sent`, a real slot store, a fresh `sessionId` per call
|
|
78
|
-
`
|
|
79
|
-
`{
|
|
80
|
-
|
|
93
|
+
recorded on `ctx.sent`, a real slot store, a fresh `sessionId` per call,
|
|
94
|
+
`turn: 0` and `now: Date.now` unless pinned
|
|
95
|
+
(`createToolContext({ turn: 3, now: () => 1_700_000_000_000 })` makes "on the
|
|
96
|
+
third turn" and an opening-hours check exact). Its `generate` and `delegate`
|
|
97
|
+
take a SCRIPT (`{ reply }` for every call, `{ routes }` keyed by system prompt
|
|
98
|
+
or subagent name) and hand the fake back on `ctx.model` and `ctx.desk`, whose
|
|
99
|
+
`calls` a spec asserts on.
|
|
100
|
+
|
|
101
|
+
**An `events` handler is driven with `fireEvent`**:
|
|
102
|
+
`await fireEvent(agentDef, sessionEvent("userTranscript.committed", { text }), ctx)`
|
|
103
|
+
dispatches the typed handler then `"*"`, the way the session does — except that
|
|
104
|
+
a throw propagates and an async handler is awaited, since the spec is reading
|
|
105
|
+
the outcome. `sessionEvent(type, fields, meta?)` builds the event with its
|
|
106
|
+
envelope, and a field the event does not have is a compile error.
|
|
81
107
|
|
|
82
108
|
```ts
|
|
83
109
|
import { createToolContext } from "@alexkroman1/aai-runtime/testing";
|
|
@@ -102,7 +128,15 @@ its feature needs. **A fake that fills a process-wide slot is INSTALLED** from
|
|
|
102
128
|
restores it afterwards: `installStubGateway(replies)` answers a step's model
|
|
103
129
|
calls (`stepGenerate`, `stepGenerateJson`) and returns the calls it saw. Call it
|
|
104
130
|
by its own name — do not alias it to `stubGateway`, which is the non-installing
|
|
105
|
-
builder it wraps.
|
|
131
|
+
builder it wraps. **It also seeds `ASSEMBLYAI_API_KEY`** for the test, so a spec
|
|
132
|
+
never writes `vi.stubEnv` for it; the one spec whose subject is the missing-key
|
|
133
|
+
refusal passes `apiKey: false`, which ensures there is NO key for that test even
|
|
134
|
+
when the shell exports one. A workflow that calls a model AND fetches a page AND
|
|
135
|
+
transcribes installs them all at once:
|
|
136
|
+
`installStubWorld({ model, pages, transcribe, speech, uploads })` (with
|
|
137
|
+
`uploads: { files, writable }`) composes the seams in the one order that works
|
|
138
|
+
and hands back every fake's call log (`world.model`, `world.provider`,
|
|
139
|
+
`world.reported`, …).
|
|
106
140
|
|
|
107
141
|
## Evals: `agent.eval.test.ts`
|
|
108
142
|
|
|
@@ -112,10 +146,22 @@ an eval's harness needs — `describeEval`, the readers and claims,
|
|
|
112
146
|
`evalSimulation`, and stubs like `stubGatewayRoute` — is on
|
|
113
147
|
`@alexkroman1/aai-runtime/testing/vitest`:
|
|
114
148
|
|
|
115
|
-
```ts
|
|
149
|
+
```ts
|
|
150
|
+
// file: tools/look_up.ts
|
|
151
|
+
import { tool } from "@alexkroman1/aai";
|
|
152
|
+
import { z } from "zod";
|
|
153
|
+
|
|
154
|
+
export default tool({
|
|
155
|
+
description: "Look an order up",
|
|
156
|
+
inputSchema: z.object({ orderId: z.string() }),
|
|
157
|
+
execute: ({ orderId }) => ({ orderId, status: "shipped" }),
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
// file: agent.eval.test.ts
|
|
161
|
+
import agentDef from "virtual:aai/agent";
|
|
116
162
|
import { describeEval, expectCalled } from "@alexkroman1/aai-runtime/testing/vitest";
|
|
117
163
|
import { expect } from "vitest";
|
|
118
|
-
import
|
|
164
|
+
import lookUp from "./tools/look_up.ts";
|
|
119
165
|
|
|
120
166
|
describeEval(agentDef, (test) => {
|
|
121
167
|
test(
|
|
@@ -123,7 +169,10 @@ describeEval(agentDef, (test) => {
|
|
|
123
169
|
async ({ session }) => {
|
|
124
170
|
// `say()` returns THAT turn — the reply, its tool calls, its events.
|
|
125
171
|
const turn = await session.say("where is order W1234?");
|
|
126
|
-
|
|
172
|
+
// A claim takes the tool's DEF, never its name string: the file's default
|
|
173
|
+
// export (`builtinTool("run_code")` for a builtin), matched by the name the
|
|
174
|
+
// agent registered it under, so a renamed file fails here by name.
|
|
175
|
+
expectCalled(turn, lookUp);
|
|
127
176
|
expect(turn.text).toMatch(/shipped/i);
|
|
128
177
|
},
|
|
129
178
|
// What a SCRIPTED model answers with when there is no key (below).
|
|
@@ -186,6 +235,26 @@ The `outbound-call-agent` template walks a three-level tree this way.
|
|
|
186
235
|
`fetch`, refusing the rest: `ctx.network`. `workflows` takes a client or
|
|
187
236
|
per-case factory: `ctx.workflowClient`. A failure prints the conversation.
|
|
188
237
|
|
|
238
|
+
**Read what a turn did through the DEF, not a schema you restate.**
|
|
239
|
+
`toolResultIn(turn.toolCalls, placeOrder)` is typed by the tool's `execute` and
|
|
240
|
+
throws naming what WAS called when the tool was not (exactly once;
|
|
241
|
+
`toolResultsIn` for several; `lastToolResultIn` for the settled last;
|
|
242
|
+
`toolArgsIn` for what the model asked); `turnCalling(turns, def)` is the turn a
|
|
243
|
+
`sayAll` call reached it in. The def is the same one `run` takes — a file's
|
|
244
|
+
default export, a speaker's `tools` entry, `toolOf(agentDef, name)` for a minted
|
|
245
|
+
tool, `builtinTool(name)` for a builtin — and the readers take no name string.
|
|
246
|
+
`lastStateIn(session.events(), slot.projected)` is the frame the page saw, typed
|
|
247
|
+
by the projection and checked against its default keys, so a field the view
|
|
248
|
+
gained or lost fails here instead of being cast past;
|
|
249
|
+
`customEventsIn(events, "order.progress")` is typed by `ClientEventMap`. **An
|
|
250
|
+
agent that hands off to a run** declares its step HTTP on the suite —
|
|
251
|
+
`describeEval(agentDef, define, { steps: { routes, hold: "first" } })` — and the
|
|
252
|
+
harness installs the step fetch per case, parks the first answered request so
|
|
253
|
+
the run is observably in flight (`ctx.steps.held`, `release()`), and releases
|
|
254
|
+
and settles every run when the case ends. `evalRunOf(turn, def)` is the id of
|
|
255
|
+
the one run that turn started, read off the session's record of
|
|
256
|
+
`ctx.workflows.start` rather than parsed out of the tool's answer.
|
|
257
|
+
|
|
189
258
|
No eval can see anything below the audio boundary — when the agent decides you
|
|
190
259
|
stopped talking, barge-in, two sentences merging into one turn. Those need
|
|
191
260
|
`pnpm dev` and your own voice.
|
|
@@ -14,14 +14,27 @@ import { z } from "zod";
|
|
|
14
14
|
|
|
15
15
|
const myTool = tool({
|
|
16
16
|
description: string; // shown to LLM — decides when to call
|
|
17
|
-
inputSchema?: z.ZodObject; // Zod schema (omit for no-
|
|
17
|
+
inputSchema?: z.ZodObject; // Zod schema (omit it for a no-argument tool)
|
|
18
18
|
execute(args, ctx): unknown; // sync or async
|
|
19
|
+
ui?: { icon?, label? }; // how a page shows this tool's calls — served to the
|
|
20
|
+
// client with the declaration, so no page-side map
|
|
21
|
+
messages?: ToolMessagesInput; // what to SAY while it runs (PIPELINE-TUNING.md)
|
|
22
|
+
effect?: "read" | "write"; // "write" = a WRITE (see below)
|
|
19
23
|
});
|
|
20
24
|
```
|
|
21
25
|
|
|
22
26
|
`execute` may call `fetch` directly — tool code reaches external APIs the same
|
|
23
27
|
way in `aai dev` and deployed.
|
|
24
28
|
|
|
29
|
+
**Mark every write `effect: "write"`** — a tool that books, orders, cancels,
|
|
30
|
+
sends, dispatches, deletes, changes an account, or files a ticket or request
|
|
31
|
+
someone else will act on. Lookups, calculations and cart or draft steps that a
|
|
32
|
+
later tool confirms stay unmarked. An MCP tool is a write unless its server
|
|
33
|
+
marks it `readOnlyHint: true` (MCP's own default). In a voice pipeline a
|
|
34
|
+
declared write runs only on a caller turn that did not start while the agent was
|
|
35
|
+
talking: an "uh-huh" spoken over "Shall I cancel it?" is the caller listening,
|
|
36
|
+
not agreeing, and the model is told to ask again instead.
|
|
37
|
+
|
|
25
38
|
### `ctx` (ToolContext)
|
|
26
39
|
|
|
27
40
|
```ts no-check
|
|
@@ -35,6 +48,12 @@ ctx.slots: SlotStore // where sessionSlot() keeps this
|
|
|
35
48
|
// reach for the slot, never this (see "Session state")
|
|
36
49
|
ctx.messages: readonly Message[] // conversation history [{role, content}]
|
|
37
50
|
ctx.sessionId: string // unique session ID
|
|
51
|
+
ctx.turn: number // user turns committed so far (1 during the first
|
|
52
|
+
// reply) — "ask once, on turn three" is a compare,
|
|
53
|
+
// not a counter kept in a slot
|
|
54
|
+
ctx.now(): number // epoch ms; ctx.random: a RandomSource. Both are
|
|
55
|
+
// what Date.now()/Math.random() would answer, and
|
|
56
|
+
// a spec pins them: createToolContext({ now, random })
|
|
38
57
|
ctx.send(event, data): void // push custom event to browser client (dropped over 64 KB JSON);
|
|
39
58
|
// typed per event by ClientEventMap (below), else `unknown`
|
|
40
59
|
ctx.generate(opts): Promise<{ text, object? }> // one-shot LLM call (host-side)
|
|
@@ -101,7 +120,9 @@ the next push just reports the next line.
|
|
|
101
120
|
### Session state
|
|
102
121
|
|
|
103
122
|
**A `sessionSlot` is the only way to keep state across a session's tool calls**,
|
|
104
|
-
and it is one declaration in a shared module
|
|
123
|
+
and it is one declaration in a shared module. The default is a plain value
|
|
124
|
+
(cloned per session) or a factory; `sync: true` shows the slot's `view` to the
|
|
125
|
+
client with nothing declared on `agent()`:
|
|
105
126
|
|
|
106
127
|
```ts
|
|
107
128
|
// shared.ts — the one place the shape is written down.
|
|
@@ -109,7 +130,18 @@ import { sessionSlot } from "@alexkroman1/aai";
|
|
|
109
130
|
|
|
110
131
|
export type Incident = { id: string; status: "open" | "closed" };
|
|
111
132
|
|
|
112
|
-
export const incidentSlot = sessionSlot(
|
|
133
|
+
export const incidentSlot = sessionSlot(
|
|
134
|
+
"incidents",
|
|
135
|
+
{ items: [] as Incident[], open: 0 },
|
|
136
|
+
{
|
|
137
|
+
// Runs on EVERY store, the default included, so a derived field is never stale.
|
|
138
|
+
after: (s) => {
|
|
139
|
+
s.open = s.items.filter((i) => i.status === "open").length;
|
|
140
|
+
},
|
|
141
|
+
view: (s) => ({ open: s.open }),
|
|
142
|
+
sync: true,
|
|
143
|
+
},
|
|
144
|
+
);
|
|
113
145
|
```
|
|
114
146
|
|
|
115
147
|
```ts no-check
|
|
@@ -138,37 +170,94 @@ export default incidentSlot.updateTool({
|
|
|
138
170
|
});
|
|
139
171
|
```
|
|
140
172
|
|
|
141
|
-
|
|
173
|
+
Five rules, and each is an error rather than advice if you get it wrong:
|
|
142
174
|
|
|
143
175
|
- **`tool` reads, `updateTool` writes.** What a read is handed is FROZEN, so
|
|
144
176
|
mutating it throws instead of quietly going nowhere.
|
|
145
177
|
- **A write is SYNCHRONOUS.** The value you mutate is stored the moment your
|
|
146
|
-
body returns, so an `updateTool` body may not `await`.
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
178
|
+
body returns, so an `updateTool` body may not `await`. The await goes in
|
|
179
|
+
`prepare`, which runs on the frozen value first and hands what it produced to
|
|
180
|
+
`execute` as the THIRD argument, ahead of `ctx`; `require` is the precondition
|
|
181
|
+
(`ToolFailure | undefined` off the frozen value), checked before `prepare` and
|
|
182
|
+
again right before the window; `report` completes the result from what was
|
|
183
|
+
actually STORED, after `after` and `caps`:
|
|
184
|
+
|
|
185
|
+
```ts
|
|
186
|
+
import { sessionSlot, toolFailure } from "@alexkroman1/aai";
|
|
187
|
+
import { z } from "zod";
|
|
188
|
+
|
|
189
|
+
const cartSlot = sessionSlot("cart", { items: [] as string[], total: 0 });
|
|
190
|
+
|
|
191
|
+
export default cartSlot.updateTool({
|
|
192
|
+
description: "Price the cart",
|
|
193
|
+
inputSchema: z.object({ sku: z.string() }),
|
|
194
|
+
require: (cart) => (cart.items.length === 0 ? toolFailure("The cart is empty.") : undefined),
|
|
195
|
+
prepare: async ({ sku }, _cart, ctx) =>
|
|
196
|
+
Number((await ctx.generate({ prompt: `price ${sku}` })).text),
|
|
197
|
+
execute: (_args, cart, price) => {
|
|
198
|
+
cart.total = price;
|
|
154
199
|
return { total: cart.total };
|
|
155
|
-
}
|
|
156
|
-
|
|
200
|
+
},
|
|
201
|
+
report: (stored, partial) => ({ ...partial, items: stored.items.length }),
|
|
202
|
+
});
|
|
157
203
|
```
|
|
158
204
|
|
|
205
|
+
A `ToolFailure` from `require` or `prepare` is the tool's whole result and
|
|
206
|
+
opens no window; one RETURNED from `execute`, `report` or `commit` stores
|
|
207
|
+
nothing, like a throw — a body that mutated the draft and then declined has
|
|
208
|
+
declined. From inside a plain `tool()` the same shape is
|
|
209
|
+
`slot.transact(ctx, { require?, prepare, commit })`.
|
|
210
|
+
|
|
211
|
+
- **Report from the stored value, never the draft.** A count read off the draft
|
|
212
|
+
is the count before a cap trimmed it, and a field `after` computes is not on
|
|
213
|
+
the draft when the body returns — `report` is the one reading that cannot
|
|
214
|
+
disagree with the next `get`.
|
|
159
215
|
- **Hold plain data.** Objects, arrays, strings, numbers, booleans and null. A
|
|
160
|
-
`Map`, a `Set`, a `Date
|
|
161
|
-
|
|
216
|
+
`Map`, a `Set`, a `Date`, a function or a class instance is refused with the
|
|
217
|
+
slot and the field named — at declaration for a plain default, on the store
|
|
218
|
+
otherwise — because none of them survives being stored.
|
|
162
219
|
- **State is STORED on the platform**, so a crash or a redeploy no longer loses
|
|
163
220
|
it — the platform keeps a session's slots on its own database and there is
|
|
164
221
|
nothing to enable. Under `aai dev` it lives in memory for the life of the
|
|
165
222
|
process unless you set a `DATABASE_URL` in `.env`. You write the same code
|
|
166
223
|
either way; that is the reason for the rules above.
|
|
167
224
|
|
|
168
|
-
There is nothing to declare on `agent()` — the slot owns its
|
|
169
|
-
`
|
|
170
|
-
|
|
171
|
-
|
|
225
|
+
There is nothing to declare on `agent()` — the slot owns its default, and
|
|
226
|
+
`sync: true` registers its projection (the slot must be declared in a module
|
|
227
|
+
`agent.ts` imports, such as `shared.ts`); `agent({ syncState })` is not a field.
|
|
228
|
+
**A SEEDED slot declares `empty`** —
|
|
229
|
+
`sessionSlot("catalog", loadSeed, { view, empty: () => ({ items: [] }) })` — so
|
|
230
|
+
the frame a page renders before its first push is the empty shape rather than
|
|
231
|
+
the seed shipped to the browser. `SlotValueOf<typeof slot>` and
|
|
232
|
+
`SlotDraftOf<typeof slot>` type a helper's parameter as the frozen value or the
|
|
233
|
+
draft without restating the shape. `slot.snapshot(ctx)` returns a mutable deep
|
|
234
|
+
copy of the value — what a spec hands `slot.set`, instead of
|
|
235
|
+
`structuredClone(slot.get(ctx))` and a cast.
|
|
236
|
+
|
|
237
|
+
### A sentence the model should follow THIS time — `withInstruction`
|
|
238
|
+
|
|
239
|
+
A tool often knows, once it has the answer, how the model should treat it: "read
|
|
240
|
+
the plan back in one breath", "ask which of these two before going on".
|
|
241
|
+
`withInstruction(value, "…")` rides that sentence on the result under a reserved
|
|
242
|
+
key; the model reads it beside the result, and the page, the history and a later
|
|
243
|
+
tool read the value alone. It works on a `toolFailure(...)` too. **Per OUTCOME,
|
|
244
|
+
not per tool**: a sentence that is the same on every call belongs in
|
|
245
|
+
`description`.
|
|
246
|
+
|
|
247
|
+
```ts
|
|
248
|
+
import { tool, withInstruction } from "@alexkroman1/aai";
|
|
249
|
+
import { z } from "zod";
|
|
250
|
+
|
|
251
|
+
export default tool({
|
|
252
|
+
description: "Draft the day's plan",
|
|
253
|
+
inputSchema: z.object({ goals: z.array(z.string()) }),
|
|
254
|
+
execute: ({ goals }) =>
|
|
255
|
+
withInstruction(
|
|
256
|
+
{ steps: goals.map((goal, i) => `${i + 1}. ${goal}`) },
|
|
257
|
+
"Read the plan back in one breath, then ask whether to start.",
|
|
258
|
+
),
|
|
259
|
+
});
|
|
260
|
+
```
|
|
172
261
|
|
|
173
262
|
**`verbatimModuleSyntax` applies to every type you import** — `ToolContext`,
|
|
174
263
|
`ToolDef`, `Message`, provider types. A plain `import { ToolContext }` fails;
|
|
@@ -219,12 +308,61 @@ export const checkout = dialog("checkout", {
|
|
|
219
308
|
});
|
|
220
309
|
```
|
|
221
310
|
|
|
222
|
-
A tool declared with `checkout.tool({
|
|
223
|
-
|
|
224
|
-
can recover from — the gate is enforced at EXECUTION rather
|
|
225
|
-
prompt. The states and events are inferred from the spec, so
|
|
226
|
-
is a compile error.
|
|
227
|
-
|
|
311
|
+
A tool declared with `checkout.tool({ when: "paying", send: … })` is REFUSED
|
|
312
|
+
outside the states `when` names, and the refusal reaches the model as a
|
|
313
|
+
`ToolFailure` it can recover from — the gate is enforced at EXECUTION rather
|
|
314
|
+
than hoped for in a prompt. The states and events are inferred from the spec, so
|
|
315
|
+
a misspelled `send` is a compile error. **A slot tool takes the same gate**:
|
|
316
|
+
`orderSlot.updateTool({ dialog: checkout, when, send, … })` runs the refusal,
|
|
317
|
+
then `require`/`prepare`, the window, `report`, and the transition — nothing is
|
|
318
|
+
sent on a `ToolFailure`.
|
|
319
|
+
|
|
320
|
+
```ts
|
|
321
|
+
import { dialog, sessionSlot } from "@alexkroman1/aai";
|
|
322
|
+
import { z } from "zod";
|
|
323
|
+
|
|
324
|
+
const scratch = sessionSlot("scratch", { notes: [] as string[] });
|
|
325
|
+
const orderSlot = sessionSlot("order", { items: [] as string[], paid: false });
|
|
326
|
+
|
|
327
|
+
const checkout = dialog("checkout", {
|
|
328
|
+
initial: "collecting",
|
|
329
|
+
states: {
|
|
330
|
+
collecting: { instruction: "Take the order.", on: { CONFIRMED: "paying" } },
|
|
331
|
+
paying: {
|
|
332
|
+
instruction: "Take payment with pay. Do not add items now.",
|
|
333
|
+
// Runs inside the move, when the dialog ENTERS the state: may write other
|
|
334
|
+
// slots, never this dialog. Not on a resume, a fresh session or a reset.
|
|
335
|
+
onEnter: (ctx) => scratch.reset(ctx),
|
|
336
|
+
on: { PAID: "done", DECLINED: "collecting" },
|
|
337
|
+
},
|
|
338
|
+
done: { instruction: "Read back the order number and say goodbye." },
|
|
339
|
+
},
|
|
340
|
+
});
|
|
341
|
+
|
|
342
|
+
export default orderSlot.updateTool({
|
|
343
|
+
description: "Take payment",
|
|
344
|
+
dialog: checkout,
|
|
345
|
+
when: "paying",
|
|
346
|
+
inputSchema: z.object({ approved: z.boolean() }),
|
|
347
|
+
execute: ({ approved }, order) => {
|
|
348
|
+
order.paid = approved;
|
|
349
|
+
return { paid: approved, next: approved ? ("PAID" as const) : ("DECLINED" as const) };
|
|
350
|
+
},
|
|
351
|
+
// A field holding the event type (or undefined to stay put). The function
|
|
352
|
+
// form `sendFrom: (result) => …` and the second argument
|
|
353
|
+
// `checkout.tool(def, { sendFrom })` are the same transition; write any of
|
|
354
|
+
// them in any order.
|
|
355
|
+
sendFrom: "next",
|
|
356
|
+
});
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
**`when` is optional**: omitted, the tool is legal in every state, never
|
|
360
|
+
refuses, and still answers the `{ ...position, result }` envelope and honours
|
|
361
|
+
`send`/`sendFrom` — the shape of a tool that reports where the conversation is,
|
|
362
|
+
or restarts it (`reset: true` restarts the dialog once `require`/`prepare` have
|
|
363
|
+
passed, right before the body; its `send` goes to the restarted dialog). An
|
|
364
|
+
event the current state does not declare is a no-op, not an error.
|
|
365
|
+
`emergency-dispatch-agent` and `tabletop-rpg-agent` are the worked examples.
|
|
228
366
|
|
|
229
367
|
**`procedure()` runs a flow YOU drive, with no model in the loop.** Where a
|
|
230
368
|
dialog constrains a conversation, a procedure is an algorithm with branches,
|
|
@@ -380,9 +518,9 @@ inputSchema: z.void(), // ✗
|
|
|
380
518
|
inputSchema: z.object({ q: z.string() }).optional(), // ✗ ZodOptional
|
|
381
519
|
```
|
|
382
520
|
|
|
383
|
-
For a tool with no arguments write `tool({ description, execute })
|
|
384
|
-
|
|
385
|
-
|
|
521
|
+
For a tool with no arguments write `tool({ description, execute })` — omit the
|
|
522
|
+
field; `args` is then `Record<string, never>`. To make an individual argument
|
|
523
|
+
optional, put `.optional()` on the FIELD, never on the object:
|
|
386
524
|
`z.object({ notes: z.string().optional() })`.
|
|
387
525
|
|
|
388
526
|
**Do not annotate `execute`'s return type.** Nothing needs it — the result is
|
|
@@ -458,6 +596,23 @@ templates whose entire content was `snake_case_name: camelCaseImport`, and
|
|
|
458
596
|
forgetting one line was **silent** — the file compiled, every check passed, and
|
|
459
597
|
the tool simply never reached the model.
|
|
460
598
|
|
|
599
|
+
### Starting a run from a tool
|
|
600
|
+
|
|
601
|
+
`ctx.workflows.start(def, input)` starts a durable run and resolves its id as
|
|
602
|
+
soon as the run EXISTS; the turn answers while it works (`WORKFLOWS.md` has the
|
|
603
|
+
body side). Its `key` defaults to `"session"` — the session id — so a later
|
|
604
|
+
turn, or a later CALL from the same session, reads it back with
|
|
605
|
+
`ctx.workflows.latest(def)` (the newest run) or `live(def)` (the newest one
|
|
606
|
+
still in flight) with no key spelled on either side. **Declare the status tools
|
|
607
|
+
rather than writing them**:
|
|
608
|
+
`builtinTools: ["think", "workflow_status", "workflow_progress", "workflow_cancel"]`
|
|
609
|
+
gives the model those three over every declared workflow, keyed the same way;
|
|
610
|
+
`describeRun(run)` and `cancelNote` on the workflow def supply the sentences
|
|
611
|
+
they speak. A run parked on `ctx.waitForSignal("approval")` is answered from a
|
|
612
|
+
tool with `ctx.workflows.signalRun(def, "session", "approval", payload)` — the
|
|
613
|
+
token is derived on both sides, and a signal that lands before the body reaches
|
|
614
|
+
its wait is held for it.
|
|
615
|
+
|
|
461
616
|
## Built-in tools
|
|
462
617
|
|
|
463
618
|
Enable via `builtinTools` in `agent()`. **Omitted, only `think` is on**; the
|
|
@@ -621,7 +776,8 @@ before it calls rather than as a refusal after. `isIsoDate` refuses
|
|
|
621
776
|
`2026-02-30`; `addDays`/`daysBetween` compute in UTC — never turn a `YYYY-MM-DD`
|
|
622
777
|
into a `Date` in local time.
|
|
623
778
|
|
|
624
|
-
**Never call `Math.random()` in a tool** — use `ctx.random
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
779
|
+
**Never call `Math.random()` or `Date.now()` in a tool** — use `ctx.random` and
|
|
780
|
+
`ctx.now()`, which a test can pin, so a dice roll, a minted code or an
|
|
781
|
+
opening-hours check is something a spec can assert. `randomInt`, `pickOne` and
|
|
782
|
+
`shuffled` take the source last. A WORKFLOW body wants its own journaled
|
|
783
|
+
`ctx.random()` / `ctx.now()` instead.
|