@alexkroman1/aai-cli 0.17.0 → 0.18.1
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
|
@@ -1,15 +1,15 @@
|
|
|
1
|
+
import agentDef from "virtual:aai/agent";
|
|
1
2
|
import type { DelegateOptions, SpeakerDef } from "@alexkroman1/aai";
|
|
2
|
-
import { DELEGATE_TOOL_NAME, isToolFailure } from "@alexkroman1/aai";
|
|
3
|
+
import { DELEGATE_TOOL_NAME, instructionOf, isToolFailure } from "@alexkroman1/aai";
|
|
3
4
|
import {
|
|
4
5
|
createToolContext,
|
|
6
|
+
expectSlotContract,
|
|
5
7
|
expectToolOk,
|
|
6
|
-
runTool,
|
|
7
8
|
type StubDelegateCall,
|
|
8
9
|
stubDelegate,
|
|
9
10
|
toolOf,
|
|
10
|
-
toolRunner,
|
|
11
11
|
} from "@alexkroman1/aai-runtime/testing";
|
|
12
|
-
import { installStubStepFetch } from "@alexkroman1/aai-runtime/testing/vitest";
|
|
12
|
+
import { describeAgent, installStubStepFetch } from "@alexkroman1/aai-runtime/testing/vitest";
|
|
13
13
|
import { describe, expect, test } from "vitest";
|
|
14
14
|
import authoredAgent from "./agent.ts";
|
|
15
15
|
import type { AngleWork } from "./shared.ts";
|
|
@@ -23,25 +23,21 @@ import {
|
|
|
23
23
|
factChecker,
|
|
24
24
|
findByAngle,
|
|
25
25
|
MAX_ANGLES,
|
|
26
|
-
MAX_FINDINGS,
|
|
27
26
|
MAX_RESEARCH_STEPS,
|
|
28
27
|
researcher,
|
|
29
28
|
VerdictSchema,
|
|
30
29
|
} from "./shared.ts";
|
|
31
30
|
import { briefingChannel, briefingMessage, DESTINATION_ENV } from "./slack.ts";
|
|
32
31
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
/** The def a DEPLOYED agent runs: authored, plus what `tools/` declares. */
|
|
37
|
-
import agentDef from "virtual:aai/agent";
|
|
32
|
+
// The tool FILES: each default export is the object `agentDef` registers, so
|
|
33
|
+
// `run(researchTopic, …)` is typed by the def — arguments and result.
|
|
38
34
|
import briefingSoFar from "./tools/briefing_so_far.ts";
|
|
39
35
|
import researchTopic from "./tools/research_topic.ts";
|
|
40
36
|
import sendBriefing from "./tools/send_briefing.ts";
|
|
41
37
|
import verifyClaim from "./tools/verify_claim.ts";
|
|
42
38
|
|
|
43
|
-
|
|
44
|
-
const
|
|
39
|
+
/** A finding whose cost is irrelevant to the case at hand. */
|
|
40
|
+
const NO_WORK: AngleWork = { searches: 0, reads: 0 };
|
|
45
41
|
|
|
46
42
|
/**
|
|
47
43
|
* The desk's two subagents, faked.
|
|
@@ -82,570 +78,576 @@ function scriptedDesk(
|
|
|
82
78
|
return { ctx, desk: ctx.desk };
|
|
83
79
|
}
|
|
84
80
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
test("gives the checker a tighter budget than the researcher", () => {
|
|
98
|
-
expect(factChecker.maxSteps).toBeLessThan(MAX_RESEARCH_STEPS);
|
|
99
|
-
});
|
|
81
|
+
describeAgent(agentDef, (run) => {
|
|
82
|
+
describe("the desk itself", () => {
|
|
83
|
+
test("has no web tools of its own — everything goes through a subagent", () => {
|
|
84
|
+
// Stated as the claim the test's name makes, rather than as "no builtins at
|
|
85
|
+
// all": giving the desk `run_code` is a reasonable edit, and it does not
|
|
86
|
+
// put the web in front of the desk.
|
|
87
|
+
expect(authoredAgent.builtinTools ?? []).not.toContain("web_search");
|
|
88
|
+
expect(authoredAgent.builtinTools ?? []).not.toContain("visit_webpage");
|
|
89
|
+
// And the subagents do, which is the split the template exists to show.
|
|
90
|
+
expect(researcher.builtinTools).toContain("web_search");
|
|
91
|
+
expect(factChecker.builtinTools).toContain("web_search");
|
|
92
|
+
});
|
|
100
93
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
// which quietly is not, is a bill nobody can read.
|
|
105
|
-
for (const one of [factChecker, explainer, counterpoint]) {
|
|
106
|
-
expect(one.llm, one.name).toMatchObject({ options: { model: CHEAP_MODEL } });
|
|
107
|
-
}
|
|
108
|
-
// The researcher reads whole pages and stays on the agent's own model.
|
|
109
|
-
expect(researcher.llm).toBeUndefined();
|
|
110
|
-
});
|
|
94
|
+
test("gives the checker a tighter budget than the researcher", () => {
|
|
95
|
+
expect(factChecker.maxSteps).toBeLessThan(MAX_RESEARCH_STEPS);
|
|
96
|
+
});
|
|
111
97
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
98
|
+
test("runs the three NARROW subagents somewhere cheaper, and the researcher on the default", () => {
|
|
99
|
+
// The other half of the budget split, and the reason `CHEAP_MODEL` is one
|
|
100
|
+
// constant: three subagents that were each meant to be cheap, one of
|
|
101
|
+
// which quietly is not, is a bill nobody can read.
|
|
102
|
+
for (const one of [factChecker, explainer, counterpoint]) {
|
|
103
|
+
expect(one.llm, one.name).toMatchObject({ options: { model: CHEAP_MODEL } });
|
|
104
|
+
}
|
|
105
|
+
// The researcher reads whole pages and stays on the agent's own model.
|
|
106
|
+
expect(researcher.llm).toBeUndefined();
|
|
107
|
+
});
|
|
122
108
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
// The only thing the router reads. `agent()` refuses a roster without it;
|
|
134
|
-
// asserted here too because the template is what an author copies.
|
|
135
|
-
expect(one.description, one.name).toBeTruthy();
|
|
136
|
-
}
|
|
137
|
-
});
|
|
109
|
+
test("declares what every subagent's final message has to be", () => {
|
|
110
|
+
// The rule that decides whether delegation works at all, and it is a FIELD
|
|
111
|
+
// rather than a paragraph somebody remembered to write: the desk reads the
|
|
112
|
+
// final message and nothing else. A subagent added here without one is the
|
|
113
|
+
// regression this catches.
|
|
114
|
+
for (const one of [researcher, factChecker, explainer, counterpoint]) {
|
|
115
|
+
expect(one.expectedOutput, one.name).toBeTruthy();
|
|
116
|
+
}
|
|
117
|
+
expect(researcher.expectedOutput).toMatch(/only this/);
|
|
118
|
+
});
|
|
138
119
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
120
|
+
test("puts on the roster exactly the subagents chosen by what the caller ASKED", () => {
|
|
121
|
+
// The two tools name their own subagent, so those two must NOT be on the
|
|
122
|
+
// roster: a subagent reachable both ways gives the model a second, worse
|
|
123
|
+
// route to a tool that does real work around the delegation.
|
|
124
|
+
expect(authoredAgent.roster?.delegates.map((one) => one.name)).toEqual([
|
|
125
|
+
"explainer",
|
|
126
|
+
"counterpoint",
|
|
127
|
+
]);
|
|
128
|
+
expect(authoredAgent.roster?.speaking).toEqual([]);
|
|
129
|
+
for (const one of authoredAgent.roster?.list ?? []) {
|
|
130
|
+
// The only thing the router reads. `agent()` refuses a roster without it;
|
|
131
|
+
// asserted here too because the template is what an author copies.
|
|
132
|
+
expect(one.description, one.name).toBeTruthy();
|
|
133
|
+
}
|
|
134
|
+
});
|
|
146
135
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
expect(
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
// confirmation, which `tools/verify_claim.ts` would then read out as one.
|
|
154
|
-
// It is not a judgement call any more — it does not parse.
|
|
155
|
-
expect(VerdictSchema.safeParse({ verdict: "probably", detail: "why" }).success).toBe(false);
|
|
156
|
-
expect(VerdictSchema.safeParse({ verdict: "confirmed" }).success).toBe(false);
|
|
136
|
+
test("publishes the roster as one delegate tool listing both subagents", () => {
|
|
137
|
+
const delegate = toolOf(agentDef, DELEGATE_TOOL_NAME);
|
|
138
|
+
expect(delegate).toBeDefined();
|
|
139
|
+
expect(delegate?.description).toContain("explainer:");
|
|
140
|
+
expect(delegate?.description).toContain("counterpoint:");
|
|
141
|
+
});
|
|
157
142
|
});
|
|
158
143
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
144
|
+
describe("the fact-checker's schema", () => {
|
|
145
|
+
test("admits exactly the three verdicts the desk can act on", () => {
|
|
146
|
+
for (const verdict of ["confirmed", "contradicted", "unclear"]) {
|
|
147
|
+
expect(VerdictSchema.safeParse({ verdict, detail: "why" }).success).toBe(true);
|
|
148
|
+
}
|
|
149
|
+
// The failure this exists for: a hedge the desk cannot tell from a
|
|
150
|
+
// confirmation, which `tools/verify_claim.ts` would then read out as one.
|
|
151
|
+
// It is not a judgement call any more — it does not parse.
|
|
152
|
+
expect(VerdictSchema.safeParse({ verdict: "probably", detail: "why" }).success).toBe(false);
|
|
153
|
+
expect(VerdictSchema.safeParse({ verdict: "confirmed" }).success).toBe(false);
|
|
154
|
+
});
|
|
166
155
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
{ topic: "home batteries", angles: ["price trend", "install lead times"] },
|
|
174
|
-
ctx,
|
|
175
|
-
);
|
|
176
|
-
|
|
177
|
-
expect(subagents.calls).toHaveLength(2);
|
|
178
|
-
expect(subagents.calls.map((call) => call.subagent.name)).toEqual(["researcher", "researcher"]);
|
|
179
|
-
expect(subagents.calls.map((call) => call.task)).toEqual(["price trend", "install lead times"]);
|
|
180
|
-
// The subagent has not heard the call, so the topic rides in `context`.
|
|
181
|
-
expect(subagents.calls[0]?.options.context).toContain("home batteries");
|
|
156
|
+
test("the checker declares it, so the runtime is what enforces it", () => {
|
|
157
|
+
expect(factChecker.schema).toBe(VerdictSchema);
|
|
158
|
+
// And the guardrail it replaced is gone: a guardrail is for the judgement a
|
|
159
|
+
// shape cannot express, and a three-word enum was never that.
|
|
160
|
+
expect(factChecker.guardrail).toBeUndefined();
|
|
161
|
+
});
|
|
182
162
|
});
|
|
183
163
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
164
|
+
describe("research_topic", () => {
|
|
165
|
+
test("fans every angle out as its own run, each with a self-contained task", async () => {
|
|
166
|
+
const { ctx, desk: subagents } = scriptedDesk();
|
|
167
|
+
|
|
168
|
+
await run(
|
|
169
|
+
researchTopic,
|
|
170
|
+
{ topic: "home batteries", angles: ["price trend", "install lead times"] },
|
|
171
|
+
ctx,
|
|
172
|
+
);
|
|
173
|
+
|
|
174
|
+
expect(subagents.calls).toHaveLength(2);
|
|
175
|
+
expect(subagents.calls.map((call) => call.subagent.name)).toEqual([
|
|
176
|
+
"researcher",
|
|
177
|
+
"researcher",
|
|
178
|
+
]);
|
|
179
|
+
expect(subagents.calls.map((call) => call.task)).toEqual([
|
|
180
|
+
"price trend",
|
|
181
|
+
"install lead times",
|
|
182
|
+
]);
|
|
183
|
+
// The subagent has not heard the call, so the topic rides in `context`.
|
|
184
|
+
expect(subagents.calls[0]?.options.context).toContain("home batteries");
|
|
195
185
|
});
|
|
196
|
-
// The fake answers synchronously, so `inFlight` is only ever 1 unless the
|
|
197
|
-
// tool really did start every run before awaiting any — which is the claim.
|
|
198
|
-
// Parameters ANNOTATED rather than inferred: `DelegateFn` is overloaded
|
|
199
|
-
// (a subagent with a `schema` answers with a parsed `object`), and a bare
|
|
200
|
-
// arrow has no single signature to contextually type itself against.
|
|
201
|
-
const delegate = ((sub: SpeakerDef, options: DelegateOptions) =>
|
|
202
|
-
model.delegate(sub, options).finally(() => {
|
|
203
|
-
inFlight -= 1;
|
|
204
|
-
})) as typeof model.delegate;
|
|
205
|
-
|
|
206
|
-
await run(
|
|
207
|
-
"research_topic",
|
|
208
|
-
{ topic: "t", angles: ["a", "b", "c"] },
|
|
209
|
-
createToolContext({ delegate }),
|
|
210
|
-
);
|
|
211
|
-
|
|
212
|
-
expect(peak).toBe(3);
|
|
213
|
-
});
|
|
214
186
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
187
|
+
test("starts the runs concurrently rather than one after another", async () => {
|
|
188
|
+
let inFlight = 0;
|
|
189
|
+
let peak = 0;
|
|
190
|
+
const model = stubDelegate({
|
|
191
|
+
routes: {
|
|
192
|
+
researcher: () => {
|
|
193
|
+
inFlight += 1;
|
|
194
|
+
peak = Math.max(peak, inFlight);
|
|
195
|
+
return "found";
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
});
|
|
199
|
+
// The fake answers synchronously, so `inFlight` is only ever 1 unless the
|
|
200
|
+
// tool really did start every run before awaiting any — which is the claim.
|
|
201
|
+
// Parameters ANNOTATED rather than inferred: `DelegateFn` is overloaded
|
|
202
|
+
// (a subagent with a `schema` answers with a parsed `object`), and a bare
|
|
203
|
+
// arrow has no single signature to contextually type itself against.
|
|
204
|
+
const delegate = ((sub: SpeakerDef, options: DelegateOptions) =>
|
|
205
|
+
model.delegate(sub, options).finally(() => {
|
|
206
|
+
inFlight -= 1;
|
|
207
|
+
})) as typeof model.delegate;
|
|
208
|
+
|
|
209
|
+
await run(
|
|
210
|
+
researchTopic,
|
|
211
|
+
{ topic: "t", angles: ["a", "b", "c"] },
|
|
212
|
+
createToolContext({ delegate }),
|
|
213
|
+
);
|
|
214
|
+
|
|
215
|
+
expect(peak).toBe(3);
|
|
218
216
|
});
|
|
219
217
|
|
|
220
|
-
|
|
218
|
+
test("records what each angle concluded, and only that", async () => {
|
|
219
|
+
const { ctx } = scriptedDesk({
|
|
220
|
+
research: (call) => ({ text: `Answer to ${call.task}.`, searches: 3 }),
|
|
221
|
+
});
|
|
221
222
|
|
|
222
|
-
|
|
223
|
-
{ angle: "a", summary: "Answer to a.", work: { searches: 3, reads: 0 } },
|
|
224
|
-
]);
|
|
225
|
-
const board = briefingSlot.get(ctx);
|
|
226
|
-
expect(board.topic).toBe("t");
|
|
227
|
-
expect(board.findings).toEqual(result.findings);
|
|
228
|
-
});
|
|
223
|
+
const result = expectToolOk(await run(researchTopic, { topic: "t", angles: ["a"] }, ctx));
|
|
229
224
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
},
|
|
237
|
-
},
|
|
225
|
+
expect(result.findings).toEqual([
|
|
226
|
+
{ angle: "a", summary: "Answer to a.", work: { searches: 3, reads: 0 } },
|
|
227
|
+
]);
|
|
228
|
+
const board = briefingSlot.get(ctx);
|
|
229
|
+
expect(board.topic).toBe("t");
|
|
230
|
+
expect(board.findings).toEqual(result.findings);
|
|
238
231
|
});
|
|
239
|
-
const ctx = createToolContext({ delegate: model.delegate });
|
|
240
232
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
233
|
+
test("one failed angle does not sink the briefing", async () => {
|
|
234
|
+
const model = stubDelegate({
|
|
235
|
+
routes: {
|
|
236
|
+
researcher: (call) => {
|
|
237
|
+
if (call.task === "b") throw new Error("provider is having a day");
|
|
238
|
+
return `Answer to ${call.task}.`;
|
|
239
|
+
},
|
|
240
|
+
},
|
|
241
|
+
});
|
|
242
|
+
const ctx = createToolContext({ delegate: model.delegate });
|
|
244
243
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
expect(result.message).toMatch(/could not get to/);
|
|
249
|
-
expect(briefingSlot.get(ctx).findings).toHaveLength(2);
|
|
250
|
-
});
|
|
244
|
+
const result = expectToolOk(
|
|
245
|
+
await run(researchTopic, { topic: "t", angles: ["a", "b", "c"] }, ctx),
|
|
246
|
+
);
|
|
251
247
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
},
|
|
258
|
-
},
|
|
248
|
+
expect(result.findings.map((one) => one.angle)).toEqual(["a", "c"]);
|
|
249
|
+
expect(result.failed).toEqual([{ angle: "b", error: "provider is having a day" }]);
|
|
250
|
+
// And the desk is told to say so rather than quietly reporting two angles.
|
|
251
|
+
expect(instructionOf(result)).toMatch(/could not get to/);
|
|
252
|
+
expect(briefingSlot.get(ctx).findings).toHaveLength(2);
|
|
259
253
|
});
|
|
260
254
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
255
|
+
test("fails as a tool when every angle fails, quoting the first reason", async () => {
|
|
256
|
+
const model = stubDelegate({
|
|
257
|
+
routes: {
|
|
258
|
+
researcher: () => {
|
|
259
|
+
throw new Error("gateway said no");
|
|
260
|
+
},
|
|
261
|
+
},
|
|
262
|
+
});
|
|
269
263
|
|
|
270
|
-
|
|
271
|
-
|
|
264
|
+
const result = await run(
|
|
265
|
+
researchTopic,
|
|
266
|
+
{ topic: "t", angles: ["a", "b"] },
|
|
267
|
+
createToolContext({ delegate: model.delegate }),
|
|
268
|
+
);
|
|
272
269
|
|
|
273
|
-
|
|
270
|
+
expect(result).toEqual({ error: expect.stringContaining("gateway said no") });
|
|
271
|
+
});
|
|
274
272
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
});
|
|
273
|
+
test("refuses a call whose angles are all blank, without spending a subagent", async () => {
|
|
274
|
+
const { ctx, desk: subagents } = scriptedDesk();
|
|
278
275
|
|
|
279
|
-
|
|
280
|
-
const schema = agentDef.tools.research_topic?.inputSchema;
|
|
281
|
-
const tooMany = { topic: "t", angles: Array.from({ length: MAX_ANGLES + 1 }, () => "a") };
|
|
282
|
-
expect(schema?.["~standard"].validate(tooMany)).toMatchObject({ issues: expect.anything() });
|
|
283
|
-
});
|
|
284
|
-
});
|
|
276
|
+
const result = await run(researchTopic, { topic: "t", angles: [" "] }, ctx);
|
|
285
277
|
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
const { ctx, desk: subagents } = scriptedDesk({
|
|
289
|
-
check: '{"verdict": "contradicted", "detail": "The figure is 12%."}',
|
|
278
|
+
expect(result).toEqual({ error: expect.stringContaining("No angles") });
|
|
279
|
+
expect(subagents.calls).toEqual([]);
|
|
290
280
|
});
|
|
291
281
|
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
expect(result.detail).toBe("The figure is 12%.");
|
|
298
|
-
expect(result.checkedAgainst).toBeNull();
|
|
282
|
+
test("accepts at most MAX_ANGLES angles", () => {
|
|
283
|
+
const schema = agentDef.tools.research_topic?.inputSchema;
|
|
284
|
+
const tooMany = { topic: "t", angles: Array.from({ length: MAX_ANGLES + 1 }, () => "a") };
|
|
285
|
+
expect(schema?.["~standard"].validate(tooMany)).toMatchObject({ issues: expect.anything() });
|
|
286
|
+
});
|
|
299
287
|
});
|
|
300
288
|
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
angle: "install lead times",
|
|
306
|
-
summary: "Installers quote eight weeks.",
|
|
307
|
-
work: { searches: 2, reads: 1 },
|
|
289
|
+
describe("verify_claim", () => {
|
|
290
|
+
test("asks the fact-checker, not the researcher", async () => {
|
|
291
|
+
const { ctx, desk: subagents } = scriptedDesk({
|
|
292
|
+
check: '{"verdict": "contradicted", "detail": "The figure is 12%."}',
|
|
308
293
|
});
|
|
294
|
+
|
|
295
|
+
const result = expectToolOk(await run(verifyClaim, { claim: "The figure is 40%." }, ctx));
|
|
296
|
+
|
|
297
|
+
expect(subagents.calls.map((call) => call.subagent.name)).toEqual(["fact-checker"]);
|
|
298
|
+
// The WORD the desk branches on, parsed — not a sentence it must read one out of.
|
|
299
|
+
expect(result.verdict).toBe("contradicted");
|
|
300
|
+
expect(result.detail).toBe("The figure is 12%.");
|
|
301
|
+
expect(result.checkedAgainst).toBeNull();
|
|
309
302
|
});
|
|
310
303
|
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
304
|
+
test("quotes the finding a claim came from, so the checker can see the source", async () => {
|
|
305
|
+
const { ctx, desk: subagents } = scriptedDesk();
|
|
306
|
+
briefingSlot.update(ctx, (board) => {
|
|
307
|
+
board.findings.push({
|
|
308
|
+
angle: "install lead times",
|
|
309
|
+
summary: "Installers quote eight weeks.",
|
|
310
|
+
work: { searches: 2, reads: 1 },
|
|
311
|
+
});
|
|
312
|
+
});
|
|
314
313
|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
314
|
+
const result = expectToolOk(
|
|
315
|
+
await run(verifyClaim, { claim: "Installs take eight weeks.", about: "lead times" }, ctx),
|
|
316
|
+
);
|
|
318
317
|
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
// and the complaint says why. The scripted text is well-formed here because
|
|
322
|
-
// `stubDelegate` parses it — what makes this the UNACCEPTED case is the
|
|
323
|
-
// staged `complaint`.
|
|
324
|
-
const model = stubDelegate({
|
|
325
|
-
routes: {
|
|
326
|
-
"fact-checker": {
|
|
327
|
-
text: '{"verdict": "unclear", "detail": "Nothing conclusive."}',
|
|
328
|
-
complaint: "no verdict word",
|
|
329
|
-
},
|
|
330
|
-
},
|
|
318
|
+
expect(subagents.calls[0]?.options.context).toContain("Installers quote eight weeks.");
|
|
319
|
+
expect(result.checkedAgainst).toBe("install lead times");
|
|
331
320
|
});
|
|
332
321
|
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
expect(result.unusable).toBe("no verdict word");
|
|
347
|
-
expect(result.message).toContain("unresolved");
|
|
348
|
-
});
|
|
322
|
+
test("tells the desk not to act on a verdict the schema never accepted", async () => {
|
|
323
|
+
// A run the runtime could not parse after its retries: `accepted` is false
|
|
324
|
+
// and the complaint says why. The scripted text is well-formed here because
|
|
325
|
+
// `stubDelegate` parses it — what makes this the UNACCEPTED case is the
|
|
326
|
+
// staged `complaint`.
|
|
327
|
+
const model = stubDelegate({
|
|
328
|
+
routes: {
|
|
329
|
+
"fact-checker": {
|
|
330
|
+
text: '{"verdict": "unclear", "detail": "Nothing conclusive."}',
|
|
331
|
+
complaint: "no verdict word",
|
|
332
|
+
},
|
|
333
|
+
},
|
|
334
|
+
});
|
|
349
335
|
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
336
|
+
const result = expectToolOk(
|
|
337
|
+
await run(
|
|
338
|
+
verifyClaim,
|
|
339
|
+
{ claim: "Prices fell." },
|
|
340
|
+
createToolContext({ delegate: model.delegate }),
|
|
341
|
+
),
|
|
342
|
+
);
|
|
343
|
+
|
|
344
|
+
// Not a tool failure: there IS an answer, and the desk is on a live call.
|
|
345
|
+
// What changes is the instruction — the desk must not round a hedge up to a
|
|
346
|
+
// confirmation, which is exactly what it would have done before. `verdict`
|
|
347
|
+
// is null rather than a word, so there is nothing to round.
|
|
348
|
+
expect(result.verdict).toBeNull();
|
|
349
|
+
expect(result.unusable).toBe("no verdict word");
|
|
350
|
+
expect(instructionOf(result)).toContain("unresolved");
|
|
353
351
|
});
|
|
354
352
|
|
|
355
|
-
|
|
353
|
+
test("carries no `unusable` when the verdict was accepted", async () => {
|
|
354
|
+
const { ctx } = scriptedDesk({
|
|
355
|
+
check: '{"verdict": "confirmed", "detail": "Two sources say so."}',
|
|
356
|
+
});
|
|
356
357
|
|
|
357
|
-
|
|
358
|
-
expect(result.message).toContain("correct what you told them earlier");
|
|
359
|
-
});
|
|
358
|
+
const result = expectToolOk(await run(verifyClaim, { claim: "Prices fell." }, ctx));
|
|
360
359
|
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
routes: {
|
|
364
|
-
"fact-checker": () => {
|
|
365
|
-
throw new Error("checker timed out");
|
|
366
|
-
},
|
|
367
|
-
},
|
|
360
|
+
expect(result.unusable).toBeUndefined();
|
|
361
|
+
expect(instructionOf(result)).toContain("correct what you told them earlier");
|
|
368
362
|
});
|
|
369
363
|
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
test("refuses a blank claim without spending a subagent", async () => {
|
|
380
|
-
const { ctx, desk: subagents } = scriptedDesk();
|
|
381
|
-
const result = await run("verify_claim", { claim: " " }, ctx);
|
|
382
|
-
expect(result).toEqual({ error: expect.stringContaining("Nothing to check") });
|
|
383
|
-
expect(subagents.calls).toEqual([]);
|
|
384
|
-
});
|
|
385
|
-
});
|
|
364
|
+
test("reports a failed check as a tool failure the model can recover from", async () => {
|
|
365
|
+
const model = stubDelegate({
|
|
366
|
+
routes: {
|
|
367
|
+
"fact-checker": () => {
|
|
368
|
+
throw new Error("checker timed out");
|
|
369
|
+
},
|
|
370
|
+
},
|
|
371
|
+
});
|
|
386
372
|
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
});
|
|
373
|
+
const result = await run(
|
|
374
|
+
verifyClaim,
|
|
375
|
+
{ claim: "Something." },
|
|
376
|
+
createToolContext({ delegate: model.delegate }),
|
|
377
|
+
);
|
|
393
378
|
|
|
394
|
-
|
|
395
|
-
const ctx = createToolContext();
|
|
396
|
-
briefingSlot.update(ctx, (board) => {
|
|
397
|
-
board.topic = "t";
|
|
398
|
-
board.findings.push({ angle: "a", summary: "A.", work: { searches: 2, reads: 1 } });
|
|
399
|
-
board.findings.push({ angle: "b", summary: "B.", work: { searches: 3, reads: 0 } });
|
|
379
|
+
expect(result).toEqual({ error: expect.stringContaining("checker timed out") });
|
|
400
380
|
});
|
|
401
381
|
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
describe("the brief a subagent is sent", () => {
|
|
409
|
-
test("carries the topic, because the subagent has not heard the call", () => {
|
|
410
|
-
expect(angleBrief("home batteries", "price trend")).toEqual({
|
|
411
|
-
task: "price trend",
|
|
412
|
-
context: expect.stringContaining("home batteries"),
|
|
382
|
+
test("refuses a blank claim without spending a subagent", async () => {
|
|
383
|
+
const { ctx, desk: subagents } = scriptedDesk();
|
|
384
|
+
const result = await run(verifyClaim, { claim: " " }, ctx);
|
|
385
|
+
expect(result).toEqual({ error: expect.stringContaining("Nothing to check") });
|
|
386
|
+
expect(subagents.calls).toEqual([]);
|
|
413
387
|
});
|
|
414
388
|
});
|
|
415
|
-
});
|
|
416
389
|
|
|
417
|
-
describe("
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
]),
|
|
425
|
-
).toEqual({ searches: 2, reads: 1 });
|
|
426
|
-
});
|
|
390
|
+
describe("briefing_so_far", () => {
|
|
391
|
+
test("says so when there is nothing yet, and spends no subagent", async () => {
|
|
392
|
+
const ctx = createToolContext();
|
|
393
|
+
const result = await run(briefingSoFar, ctx);
|
|
394
|
+
expect(result.findings).toEqual([]);
|
|
395
|
+
expect(instructionOf(result)).toContain("ask what they want");
|
|
396
|
+
});
|
|
427
397
|
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
});
|
|
398
|
+
test("adds the lookups up across every angle", async () => {
|
|
399
|
+
const ctx = createToolContext();
|
|
400
|
+
briefingSlot.update(ctx, (board) => {
|
|
401
|
+
board.topic = "t";
|
|
402
|
+
board.findings.push({ angle: "a", summary: "A.", work: { searches: 2, reads: 1 } });
|
|
403
|
+
board.findings.push({ angle: "b", summary: "B.", work: { searches: 3, reads: 0 } });
|
|
404
|
+
});
|
|
433
405
|
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
for (let index = 0; index < MAX_FINDINGS + 3; index++) {
|
|
439
|
-
board.findings.push({ angle: `angle ${index}`, summary: "s", work: NO_WORK });
|
|
440
|
-
}
|
|
406
|
+
const result = await run(briefingSoFar, ctx);
|
|
407
|
+
if (!("totalSearches" in result)) throw new Error("expected a board with findings");
|
|
408
|
+
expect(result.totalSearches).toBe(5);
|
|
409
|
+
expect(result.totalReads).toBe(1);
|
|
441
410
|
});
|
|
442
|
-
const board = briefingSlot.get(ctx);
|
|
443
|
-
expect(board.findings).toHaveLength(MAX_FINDINGS);
|
|
444
|
-
expect(board.findings[0]?.angle).toBe("angle 3");
|
|
445
411
|
});
|
|
446
412
|
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
413
|
+
describe("the brief a subagent is sent", () => {
|
|
414
|
+
test("carries the topic, because the subagent has not heard the call", () => {
|
|
415
|
+
expect(angleBrief("home batteries", "price trend")).toEqual({
|
|
416
|
+
task: "price trend",
|
|
417
|
+
context: expect.stringContaining("home batteries"),
|
|
418
|
+
});
|
|
451
419
|
});
|
|
452
|
-
const board = briefingSlot.get(ctx);
|
|
453
|
-
const found = findByAngle(board, "lead times");
|
|
454
|
-
expect(isToolFailure(found) ? found : found.angle).toBe("install lead times");
|
|
455
420
|
});
|
|
456
421
|
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
422
|
+
describe("countWork", () => {
|
|
423
|
+
test("tells searches from page reads", () => {
|
|
424
|
+
expect(
|
|
425
|
+
countWork([
|
|
426
|
+
{ name: "web_search", input: {} },
|
|
427
|
+
{ name: "visit_webpage", input: {} },
|
|
428
|
+
{ name: "web_search", input: {} },
|
|
429
|
+
]),
|
|
430
|
+
).toEqual({ searches: 2, reads: 1 });
|
|
466
431
|
});
|
|
467
|
-
const found = findByAngle(briefingSlot.get(ctx), "lead times");
|
|
468
|
-
expect(isToolFailure(found)).toBe(true);
|
|
469
|
-
expect(isToolFailure(found) && found.error).toContain("install lead times");
|
|
470
|
-
expect(isToolFailure(found) && found.error).toContain("battery lead times");
|
|
471
|
-
});
|
|
472
432
|
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
board.findings.push({ angle: "install lead times", summary: "s", work: NO_WORK });
|
|
433
|
+
test("counts a tool it does not recognise as neither", () => {
|
|
434
|
+
// A researcher that gains a third tool must not silently inflate "searches".
|
|
435
|
+
expect(countWork([{ name: "think", input: {} }])).toEqual({ searches: 0, reads: 0 });
|
|
477
436
|
});
|
|
478
|
-
const board = briefingSlot.get(ctx);
|
|
479
|
-
const missing = findByAngle(board, "battery chemistry");
|
|
480
|
-
expect(isToolFailure(missing) && missing.error).toContain("install lead times");
|
|
481
|
-
const blank = findByAngle(board, " ");
|
|
482
|
-
expect(isToolFailure(blank) && blank.error).toContain("which angle");
|
|
483
437
|
});
|
|
484
|
-
});
|
|
485
438
|
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
439
|
+
describe("the board", () => {
|
|
440
|
+
test("is per session, and holds MAX_FINDINGS, dropping the oldest", () => {
|
|
441
|
+
expectSlotContract(briefingSlot, {
|
|
442
|
+
write: (board) => {
|
|
443
|
+
board.topic = "t";
|
|
444
|
+
},
|
|
445
|
+
});
|
|
446
|
+
});
|
|
490
447
|
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
work: { searches: 2, reads: 1 },
|
|
448
|
+
test("finds an angle from a loose mention, and nothing from a blank one", () => {
|
|
449
|
+
const ctx = createToolContext();
|
|
450
|
+
briefingSlot.update(ctx, (board) => {
|
|
451
|
+
board.findings.push({ angle: "install lead times", summary: "s", work: NO_WORK });
|
|
452
|
+
});
|
|
453
|
+
const board = briefingSlot.get(ctx);
|
|
454
|
+
const found = findByAngle(board, "lead times");
|
|
455
|
+
expect(isToolFailure(found) ? found : found.angle).toBe("install lead times");
|
|
500
456
|
});
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
457
|
+
|
|
458
|
+
test("an angle the caller could mean two ways is ASKED about, not guessed", () => {
|
|
459
|
+
// What the `.find()` this replaced did: it took the first angle whose text
|
|
460
|
+
// overlapped in either direction, so board order decided which of these the
|
|
461
|
+
// claim got checked against — and it answered `undefined` for "nothing
|
|
462
|
+
// matches" and "several do" alike.
|
|
463
|
+
const ctx = createToolContext();
|
|
464
|
+
briefingSlot.update(ctx, (board) => {
|
|
465
|
+
board.findings.push({ angle: "install lead times", summary: "s", work: NO_WORK });
|
|
466
|
+
board.findings.push({ angle: "battery lead times", summary: "s", work: NO_WORK });
|
|
467
|
+
});
|
|
468
|
+
const found = findByAngle(briefingSlot.get(ctx), "lead times");
|
|
469
|
+
expect(isToolFailure(found)).toBe(true);
|
|
470
|
+
expect(isToolFailure(found) && found.error).toContain("install lead times");
|
|
471
|
+
expect(isToolFailure(found) && found.error).toContain("battery lead times");
|
|
505
472
|
});
|
|
506
|
-
});
|
|
507
|
-
return ctx;
|
|
508
|
-
}
|
|
509
473
|
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
expect(message.heading).toBe("Briefing: home batteries");
|
|
522
|
-
expect(message.sections).toEqual([
|
|
523
|
-
{ title: "price trend", body: "Pack prices fell 14% year on year." },
|
|
524
|
-
{ title: "install lead times", body: "Installers quote eight weeks." },
|
|
525
|
-
]);
|
|
474
|
+
test("an angle on nothing, and a blank one, each say so", () => {
|
|
475
|
+
const ctx = createToolContext();
|
|
476
|
+
briefingSlot.update(ctx, (board) => {
|
|
477
|
+
board.findings.push({ angle: "install lead times", summary: "s", work: NO_WORK });
|
|
478
|
+
});
|
|
479
|
+
const board = briefingSlot.get(ctx);
|
|
480
|
+
const missing = findByAngle(board, "battery chemistry");
|
|
481
|
+
expect(isToolFailure(missing) && missing.error).toContain("install lead times");
|
|
482
|
+
const blank = findByAngle(board, " ");
|
|
483
|
+
expect(isToolFailure(blank) && blank.error).toContain("which angle");
|
|
484
|
+
});
|
|
526
485
|
});
|
|
527
486
|
|
|
528
|
-
|
|
529
|
-
const message = briefingMessage(briefingSlot.get(deskWithBoard()));
|
|
487
|
+
// ---- Sending it on ----------------------------------------------------------
|
|
530
488
|
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
expect(message.text).toBe("Briefing on home batteries: 2 angles");
|
|
534
|
-
// The same two numbers `briefing_so_far` reads back, from the same helper.
|
|
535
|
-
expect(message.subtitle).toBe("5 searches, 1 page read");
|
|
536
|
-
});
|
|
489
|
+
/** A destination that really is Slack's, which is what the guard checks. */
|
|
490
|
+
const WEBHOOK = "https://hooks.slack.com/services/T00/B00/xxxxxxxx";
|
|
537
491
|
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
// forever.
|
|
542
|
-
const ctx = createToolContext();
|
|
492
|
+
/** A context with a board on it and a channel configured. */
|
|
493
|
+
function deskWithBoard(env: Record<string, string> = { [DESTINATION_ENV]: WEBHOOK }) {
|
|
494
|
+
const ctx = createToolContext({ env });
|
|
543
495
|
briefingSlot.update(ctx, (board) => {
|
|
544
|
-
board.
|
|
496
|
+
board.topic = "home batteries";
|
|
497
|
+
board.findings.push({
|
|
498
|
+
angle: "price trend",
|
|
499
|
+
summary: "Pack prices fell 14% year on year.",
|
|
500
|
+
work: { searches: 2, reads: 1 },
|
|
501
|
+
});
|
|
502
|
+
board.findings.push({
|
|
503
|
+
angle: "install lead times",
|
|
504
|
+
summary: "Installers quote eight weeks.",
|
|
505
|
+
work: { searches: 3, reads: 0 },
|
|
506
|
+
});
|
|
507
|
+
});
|
|
508
|
+
return ctx;
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
describe("the briefing as a channel message", () => {
|
|
512
|
+
/**
|
|
513
|
+
* What is left to assert here once the channel owns the wire: the MESSAGE,
|
|
514
|
+
* not the payload. Slack's two webhook shapes, the Block Kit assembly and the
|
|
515
|
+
* mrkdwn escaping are `@alexkroman1/aai/channels`' and are covered by its own
|
|
516
|
+
* specs — a template asserting them again would pin the SDK's rendering from
|
|
517
|
+
* the outside.
|
|
518
|
+
*/
|
|
519
|
+
test("carries every angle as its own section, in the order they were researched", () => {
|
|
520
|
+
const message = briefingMessage(briefingSlot.get(deskWithBoard()));
|
|
521
|
+
|
|
522
|
+
expect(message.heading).toBe("Briefing: home batteries");
|
|
523
|
+
expect(message.sections).toEqual([
|
|
524
|
+
{ title: "price trend", body: "Pack prices fell 14% year on year." },
|
|
525
|
+
{ title: "install lead times", body: "Installers quote eight weeks." },
|
|
526
|
+
]);
|
|
545
527
|
});
|
|
546
528
|
|
|
547
|
-
|
|
529
|
+
test("says how many angles in the notification line and what they cost in the subtitle", () => {
|
|
530
|
+
const message = briefingMessage(briefingSlot.get(deskWithBoard()));
|
|
548
531
|
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
532
|
+
// The notification line is the WHOLE message on a Slack workflow trigger,
|
|
533
|
+
// so it has to stand on its own.
|
|
534
|
+
expect(message.text).toBe("Briefing on home batteries: 2 angles");
|
|
535
|
+
// The same two numbers `briefing_so_far` reads back, from the same helper.
|
|
536
|
+
expect(message.subtitle).toBe("5 searches, 1 page read");
|
|
537
|
+
});
|
|
553
538
|
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
});
|
|
539
|
+
test("still names something when the board carries findings and no topic", () => {
|
|
540
|
+
// Reachable: a tool can push to the board without setting `topic`, and a
|
|
541
|
+
// heading reading "Briefing: null" is the kind of thing a channel keeps
|
|
542
|
+
// forever.
|
|
543
|
+
const ctx = createToolContext();
|
|
544
|
+
briefingSlot.update(ctx, (board) => {
|
|
545
|
+
board.findings.push({ angle: "a", summary: "A.", work: NO_WORK });
|
|
546
|
+
});
|
|
562
547
|
|
|
563
|
-
|
|
564
|
-
test("posts the board to the configured channel and reports what went", async () => {
|
|
565
|
-
// `installStubStepFetch`, not a stubbed global: a channel posts through the
|
|
566
|
-
// SDK's own `stepFetch` slot, and stubbing the global would test a path
|
|
567
|
-
// production does not take.
|
|
568
|
-
const posted = installStubStepFetch(() => ({ body: "ok" }));
|
|
548
|
+
const message = briefingMessage(briefingSlot.get(ctx));
|
|
569
549
|
|
|
570
|
-
|
|
550
|
+
expect(message.heading).toBe("Briefing: an unnamed subject");
|
|
551
|
+
expect(message.text).toBe("Briefing on an unnamed subject: 1 angle");
|
|
552
|
+
expect(message.subtitle).toBe("0 searches, 0 pages read");
|
|
553
|
+
});
|
|
571
554
|
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
555
|
+
test("refuses a destination that is not Slack, before anything is posted", () => {
|
|
556
|
+
// A security boundary rather than a typo check: the value is the target of
|
|
557
|
+
// a POST carrying everything the desk was told.
|
|
558
|
+
const refused = briefingChannel("https://example.test/collect");
|
|
559
|
+
expect(isToolFailure(refused) && refused.error).toContain(DESTINATION_ENV);
|
|
560
|
+
expect(briefingChannel(WEBHOOK)).toMatchObject({ kind: "slack" });
|
|
561
|
+
});
|
|
577
562
|
});
|
|
578
563
|
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
564
|
+
describe("send_briefing", () => {
|
|
565
|
+
test("posts the board to the configured channel and reports what went", async () => {
|
|
566
|
+
// `installStubStepFetch`, not a stubbed global: a channel posts through the
|
|
567
|
+
// SDK's own `stepFetch` slot, and stubbing the global would test a path
|
|
568
|
+
// production does not take.
|
|
569
|
+
const posted = installStubStepFetch(() => ({ body: "ok" }));
|
|
582
570
|
|
|
583
|
-
|
|
571
|
+
const result = expectToolOk(await run(sendBriefing, deskWithBoard()));
|
|
584
572
|
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
573
|
+
expect(posted.calls).toHaveLength(1);
|
|
574
|
+
expect(posted.calls[0]?.url).toBe(WEBHOOK);
|
|
575
|
+
expect(posted.calls[0]?.method).toBe("POST");
|
|
576
|
+
expect(result).toMatchObject({ sent: 2, topic: "home batteries" });
|
|
577
|
+
expect(instructionOf(result)).toMatch(/in writing/);
|
|
578
|
+
});
|
|
588
579
|
|
|
589
|
-
|
|
590
|
-
|
|
580
|
+
test("spends no request on an empty board", async () => {
|
|
581
|
+
const posted = installStubStepFetch(() => ({ body: "ok" }));
|
|
582
|
+
const ctx = createToolContext({ env: { [DESTINATION_ENV]: WEBHOOK } });
|
|
591
583
|
|
|
592
|
-
|
|
584
|
+
const result = await run(sendBriefing, ctx);
|
|
593
585
|
|
|
594
|
-
|
|
595
|
-
|
|
586
|
+
expect(result).toEqual({ error: expect.stringContaining("nothing to send") });
|
|
587
|
+
expect(posted.calls).toEqual([]);
|
|
588
|
+
});
|
|
596
589
|
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
// revoked webhook answers identically on every attempt, and promising the
|
|
600
|
-
// caller another go is a promise the desk cannot keep.
|
|
601
|
-
installStubStepFetch(() => ({ status: 403, body: { error: "invalid_token" } }));
|
|
590
|
+
test("offers to try again when Slack is having a bad minute", async () => {
|
|
591
|
+
installStubStepFetch(() => ({ status: 503, body: { error: "server_error" } }));
|
|
602
592
|
|
|
603
|
-
|
|
593
|
+
const result = await run(sendBriefing, deskWithBoard());
|
|
604
594
|
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
595
|
+
expect(isToolFailure(result) && result.error).toMatch(/try again/);
|
|
596
|
+
});
|
|
597
|
+
|
|
598
|
+
test("does NOT offer a retry for a refusal that will answer the same way forever", async () => {
|
|
599
|
+
// The 4xx/5xx split is the whole reason this goes through a channel: a
|
|
600
|
+
// revoked webhook answers identically on every attempt, and promising the
|
|
601
|
+
// caller another go is a promise the desk cannot keep.
|
|
602
|
+
installStubStepFetch(() => ({ status: 403, body: { error: "invalid_token" } }));
|
|
603
|
+
|
|
604
|
+
const result = await run(sendBriefing, deskWithBoard());
|
|
608
605
|
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
// channel cannot say whether a retry would help, so neither does the desk.
|
|
612
|
-
installStubStepFetch(() => {
|
|
613
|
-
throw new Error("connection reset");
|
|
606
|
+
expect(isToolFailure(result) && result.error).toMatch(/will not help/);
|
|
607
|
+
expect(isToolFailure(result) && result.error).not.toMatch(/try again/);
|
|
614
608
|
});
|
|
615
609
|
|
|
616
|
-
|
|
610
|
+
test("reports a connection that never got there as itself", async () => {
|
|
611
|
+
// Not a `ChannelDeliveryError`: there was no response to classify. The
|
|
612
|
+
// channel cannot say whether a retry would help, so neither does the desk.
|
|
613
|
+
installStubStepFetch(() => {
|
|
614
|
+
throw new Error("connection reset");
|
|
615
|
+
});
|
|
617
616
|
|
|
618
|
-
|
|
619
|
-
expect(isToolFailure(result) && result.error).toContain("connection reset");
|
|
620
|
-
});
|
|
617
|
+
const result = await run(sendBriefing, deskWithBoard());
|
|
621
618
|
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
const posted = installStubStepFetch(() => ({ body: "ok" }));
|
|
619
|
+
expect(isToolFailure(result) && result.error).toMatch(/did not send/);
|
|
620
|
+
expect(isToolFailure(result) && result.error).toContain("connection reset");
|
|
621
|
+
});
|
|
626
622
|
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
623
|
+
test("names the missing variable when no channel is configured", async () => {
|
|
624
|
+
// The one deliberate throw in this template: a missing credential is not
|
|
625
|
+
// something the call can recover from, and the message is the fix.
|
|
626
|
+
const posted = installStubStepFetch(() => ({ body: "ok" }));
|
|
630
627
|
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
628
|
+
await expect(run(sendBriefing, deskWithBoard({}))).rejects.toThrow(DESTINATION_ENV);
|
|
629
|
+
expect(posted.calls).toEqual([]);
|
|
630
|
+
});
|
|
631
|
+
|
|
632
|
+
test("declares onError, so a missing webhook is FATAL rather than something to retry", () => {
|
|
633
|
+
// Without it the runtime hands every throw to the model as this call's
|
|
634
|
+
// result, and the desk re-calls `send_briefing` against a variable that is
|
|
635
|
+
// still unset — burning the reply's step budget on a deploy fault. The
|
|
636
|
+
// handler re-throws, which is how a tool says "stop, this cannot work".
|
|
637
|
+
const sender = toolOf(agentDef, "send_briefing");
|
|
638
|
+
expect(sender.onError).toBeDefined();
|
|
639
|
+
const cause = new Error(`Missing required environment variable: ${DESTINATION_ENV}`);
|
|
640
|
+
expect(() => sender.onError?.(cause, createToolContext())).toThrow(cause);
|
|
641
|
+
});
|
|
641
642
|
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
643
|
+
test("refuses a configured destination that is not Slack, without posting", async () => {
|
|
644
|
+
const posted = installStubStepFetch(() => ({ body: "ok" }));
|
|
645
|
+
const ctx = deskWithBoard({ [DESTINATION_ENV]: "https://example.test/collect" });
|
|
645
646
|
|
|
646
|
-
|
|
647
|
+
const result = await run(sendBriefing, ctx);
|
|
647
648
|
|
|
648
|
-
|
|
649
|
-
|
|
649
|
+
expect(isToolFailure(result) && result.error).toContain(DESTINATION_ENV);
|
|
650
|
+
expect(posted.calls).toEqual([]);
|
|
651
|
+
});
|
|
650
652
|
});
|
|
651
653
|
});
|