@alexkroman1/aai-cli 15.0.0 → 16.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -5
- package/bin.mjs +12 -3
- package/dist/_build-target-55dJisQ-.mjs +649 -0
- package/dist/_build-target.d.ts +105 -108
- package/dist/_deno-output.d.ts +23 -0
- package/dist/_deno-target.d.ts +73 -0
- package/dist/{_init-Bsi3DZNJ.mjs → _init-BzQbV8Zh.mjs} +3 -1
- package/dist/_modal-app.d.ts +77 -0
- package/dist/_modal-output.d.ts +31 -0
- package/dist/_modal-target.d.ts +64 -0
- package/dist/_target-bundle.d.ts +27 -0
- package/dist/_target-drain.d.ts +44 -0
- package/dist/_target-output.d.ts +63 -0
- package/dist/{_templates-CIlJ3Vay.mjs → _templates-CuP74F8D.mjs} +94 -4
- package/dist/_templates.d.ts +14 -1
- package/dist/_vercel-output.d.ts +4 -19
- package/dist/_vercel-target.d.ts +169 -0
- package/dist/{test-D032V2cA.mjs → _vitest-runner-AVR9VtXh.mjs} +28 -68
- package/dist/_vitest-runner.d.ts +154 -0
- package/dist/build-ButI2IKc.mjs +689 -0
- package/dist/build.d.ts +11 -0
- package/dist/cli.mjs +14 -20
- package/dist/{dev-Bx9gYBHM.mjs → dev-kodAY23K.mjs} +7 -1
- package/dist/{eval-B3I7FqN9.mjs → eval-DvoSz7SZ.mjs} +1 -1
- package/dist/{init-CFyusRbq.mjs → init-D363Ls5u.mjs} +13 -39
- package/dist/init.d.ts +5 -10
- package/dist/scaffold/CLAUDE.md +185 -35
- package/dist/scaffold/package.json +4 -4
- package/dist/start.mjs +3 -1
- package/dist/{studio-C_zuRC_z.mjs → studio-CtRBVVFR.mjs} +1 -1
- package/dist/templates/briefing-desk/agent.eval.test.ts +34 -6
- package/dist/templates/briefing-desk/agent.test.ts +347 -55
- package/dist/templates/briefing-desk/agent.ts +12 -0
- package/dist/templates/briefing-desk/shared.ts +220 -31
- package/dist/templates/briefing-desk/slack.ts +108 -0
- package/dist/templates/briefing-desk/system-prompt.md +12 -2
- package/dist/templates/briefing-desk/tools/briefing_so_far.ts +15 -7
- package/dist/templates/briefing-desk/tools/research_topic.ts +20 -28
- package/dist/templates/briefing-desk/tools/send_briefing.ts +77 -0
- package/dist/templates/briefing-desk/tools/verify_claim.ts +60 -14
- package/dist/templates/call-audit/agent.eval.test.ts +5 -0
- package/dist/templates/call-audit/agent.test.ts +6 -1
- package/dist/templates/call-audit/agent.ts +10 -23
- package/dist/templates/call-audit/client.tsx +30 -55
- package/dist/templates/call-audit/guards.test.ts +233 -0
- package/dist/templates/call-audit/workflows/audit.ts +95 -16
- package/dist/templates/call-audit/workflows/ingest.ts +107 -88
- package/dist/templates/call-audit/workflows/media.ts +98 -7
- package/dist/templates/call-audit/workflows/summarize.ts +35 -31
- package/dist/templates/call-audit/workflows/sync-api.ts +15 -6
- package/dist/templates/code-interpreter/agent.eval.test.ts +104 -56
- package/dist/templates/code-interpreter/agent.test.ts +44 -56
- package/dist/templates/code-interpreter/system-prompt.md +1 -1
- package/dist/templates/dispatch-center/agent.eval.test.ts +61 -24
- package/dist/templates/dispatch-center/agent.test.ts +253 -48
- package/dist/templates/dispatch-center/agent.ts +28 -1
- package/dist/templates/dispatch-center/client.tsx +126 -201
- package/dist/templates/dispatch-center/events.ts +48 -0
- package/dist/templates/dispatch-center/shared.ts +42 -1
- package/dist/templates/dispatch-center/tools/incident_create.ts +3 -2
- package/dist/templates/dispatch-center/tools/incident_escalate.ts +2 -1
- package/dist/templates/dispatch-center/tools/ops_dashboard.ts +35 -15
- package/dist/templates/dispatch-center/tools/ops_run_scenario.ts +3 -1
- package/dist/templates/dispatch-center/tools/resources_dispatch.ts +2 -2
- package/dist/templates/executive-assistant/agent.eval.test.ts +233 -0
- package/dist/templates/executive-assistant/agent.test.ts +672 -0
- package/dist/templates/executive-assistant/agent.ts +50 -0
- package/dist/templates/executive-assistant/calendar.test.ts +198 -0
- package/dist/templates/executive-assistant/client.tsx +195 -0
- package/dist/templates/executive-assistant/inbox.ts +233 -0
- package/dist/templates/executive-assistant/meeting.ts +138 -0
- package/dist/templates/executive-assistant/nodes.ts +152 -0
- package/dist/templates/executive-assistant/prompts.ts +331 -0
- package/dist/templates/executive-assistant/review.ts +425 -0
- package/dist/templates/executive-assistant/shared.ts +490 -0
- package/dist/templates/executive-assistant/system-prompt.md +15 -0
- package/dist/templates/executive-assistant/tools/accept.ts +10 -0
- package/dist/templates/executive-assistant/tools/ask_question.ts +30 -0
- package/dist/templates/executive-assistant/tools/draft_reply.ts +67 -0
- package/dist/templates/executive-assistant/tools/edit.ts +10 -0
- package/dist/templates/executive-assistant/tools/ignore.ts +10 -0
- package/dist/templates/executive-assistant/tools/inbox_status.ts +27 -0
- package/dist/templates/executive-assistant/tools/meeting_assistant.ts +52 -0
- package/dist/templates/executive-assistant/tools/new_email.ts +50 -0
- package/dist/templates/executive-assistant/tools/open_email.ts +165 -0
- package/dist/templates/executive-assistant/tools/respond.ts +10 -0
- package/dist/templates/executive-assistant/tools/review_memory.ts +22 -0
- package/dist/templates/executive-assistant/tools/send_calendar_invite.ts +68 -0
- package/dist/templates/executive-assistant/tools/triage_inbox.ts +75 -0
- package/dist/templates/health-assistant/agent.test.ts +134 -15
- package/dist/templates/health-assistant/agent.ts +8 -1
- package/dist/templates/health-assistant/fda.test.ts +130 -0
- package/dist/templates/health-assistant/fda.ts +75 -16
- package/dist/templates/health-assistant/system-prompt.md +9 -0
- package/dist/templates/health-assistant/tools/check_drug_interaction.ts +5 -2
- package/dist/templates/health-assistant/tools/medication_lookup.ts +16 -11
- package/dist/templates/hiring-desk/agent.eval.test.ts +242 -0
- package/dist/templates/hiring-desk/agent.test.ts +1021 -0
- package/dist/templates/hiring-desk/agent.ts +38 -0
- package/dist/templates/hiring-desk/client.tsx +154 -0
- package/dist/templates/hiring-desk/crews.ts +432 -0
- package/dist/templates/hiring-desk/leads.json +86 -0
- package/dist/templates/hiring-desk/screening-lock.test.ts +77 -0
- package/dist/templates/hiring-desk/screening-lock.ts +51 -0
- package/dist/templates/hiring-desk/shared.ts +480 -0
- package/dist/templates/hiring-desk/system-prompt.md +21 -0
- package/dist/templates/hiring-desk/tools/candidate_details.ts +49 -0
- package/dist/templates/hiring-desk/tools/proceed_to_emails.ts +127 -0
- package/dist/templates/hiring-desk/tools/read_email.ts +50 -0
- package/dist/templates/hiring-desk/tools/rescore_with_feedback.ts +140 -0
- package/dist/templates/hiring-desk/tools/screen_candidates.ts +128 -0
- package/dist/templates/hiring-desk/tools/screening_status.ts +51 -0
- package/dist/templates/hotel-desk/agent.eval.test.ts +177 -0
- package/dist/templates/hotel-desk/agent.test.ts +1128 -0
- package/dist/templates/hotel-desk/agent.ts +63 -0
- package/dist/templates/hotel-desk/booking.ts +159 -0
- package/dist/templates/hotel-desk/card.ts +92 -0
- package/dist/templates/hotel-desk/catalogs.ts +219 -0
- package/dist/templates/hotel-desk/client.tsx +137 -0
- package/dist/templates/hotel-desk/concierge.ts +99 -0
- package/dist/templates/hotel-desk/desk-seams.test.ts +334 -0
- package/dist/templates/hotel-desk/desk.ts +224 -0
- package/dist/templates/hotel-desk/disputes.ts +216 -0
- package/dist/templates/hotel-desk/events.ts +79 -0
- package/dist/templates/hotel-desk/hotel.ts +412 -0
- package/dist/templates/hotel-desk/policies.ts +209 -0
- package/dist/templates/hotel-desk/records.ts +384 -0
- package/dist/templates/hotel-desk/restaurant.ts +147 -0
- package/dist/templates/hotel-desk/seed.ts +955 -0
- package/dist/templates/hotel-desk/shared.ts +354 -0
- package/dist/templates/hotel-desk/system-prompt.md +76 -0
- package/dist/templates/hotel-desk/tools/abandon_booking.ts +30 -0
- package/dist/templates/hotel-desk/tools/add_to_waitlist.ts +41 -0
- package/dist/templates/hotel-desk/tools/book_airport_car.ts +57 -0
- package/dist/templates/hotel-desk/tools/book_business_center.ts +44 -0
- package/dist/templates/hotel-desk/tools/book_spa_appointment.ts +39 -0
- package/dist/templates/hotel-desk/tools/book_tour.ts +35 -0
- package/dist/templates/hotel-desk/tools/cancel_restaurant_reservation.ts +25 -0
- package/dist/templates/hotel-desk/tools/cancel_room_booking.ts +63 -0
- package/dist/templates/hotel-desk/tools/check_restaurant_availability.ts +24 -0
- package/dist/templates/hotel-desk/tools/check_room_availability.ts +40 -0
- package/dist/templates/hotel-desk/tools/choose_room.ts +93 -0
- package/dist/templates/hotel-desk/tools/confirm_booking.ts +153 -0
- package/dist/templates/hotel-desk/tools/dispatch_emergency.ts +61 -0
- package/dist/templates/hotel-desk/tools/dispute_charge.ts +90 -0
- package/dist/templates/hotel-desk/tools/flag_late_arrival.ts +26 -0
- package/dist/templates/hotel-desk/tools/lookup_booking.ts +48 -0
- package/dist/templates/hotel-desk/tools/lookup_guest_history.ts +28 -0
- package/dist/templates/hotel-desk/tools/lookup_invoice.ts +26 -0
- package/dist/templates/hotel-desk/tools/lookup_policy.ts +20 -0
- package/dist/templates/hotel-desk/tools/lookup_restaurant_reservation.ts +27 -0
- package/dist/templates/hotel-desk/tools/modify_restaurant_reservation.ts +75 -0
- package/dist/templates/hotel-desk/tools/order_flowers.ts +40 -0
- package/dist/templates/hotel-desk/tools/record_card.ts +46 -0
- package/dist/templates/hotel-desk/tools/record_followup.ts +50 -0
- package/dist/templates/hotel-desk/tools/record_group_inquiry.ts +44 -0
- package/dist/templates/hotel-desk/tools/record_guest_details.ts +71 -0
- package/dist/templates/hotel-desk/tools/reinstate_booking.ts +65 -0
- package/dist/templates/hotel-desk/tools/request_flight_reconfirmation.ts +54 -0
- package/dist/templates/hotel-desk/tools/resend_confirmation.ts +39 -0
- package/dist/templates/hotel-desk/tools/reserve_table.ts +87 -0
- package/dist/templates/hotel-desk/tools/resolve_room_conflict.ts +48 -0
- package/dist/templates/hotel-desk/tools/schedule_wakeup_call.ts +48 -0
- package/dist/templates/hotel-desk/tools/set_do_not_disturb.ts +28 -0
- package/dist/templates/hotel-desk/tools/set_extras.ts +51 -0
- package/dist/templates/hotel-desk/tools/set_stay.ts +97 -0
- package/dist/templates/hotel-desk/tools/start_booking_modification.ts +57 -0
- package/dist/templates/hotel-desk/tools/start_room_booking.ts +49 -0
- package/dist/templates/hotel-desk/tools/take_guest_message.ts +71 -0
- package/dist/templates/hotel-desk/tools/transfer_call.ts +47 -0
- package/dist/templates/hotel-desk/tools/update_card.ts +45 -0
- package/dist/templates/hotel-desk/tools/verify_booking.ts +95 -0
- package/dist/templates/infocom-adventure/agent.eval.test.ts +33 -1
- package/dist/templates/infocom-adventure/agent.test.ts +207 -52
- package/dist/templates/infocom-adventure/agent.ts +14 -3
- package/dist/templates/infocom-adventure/client.tsx +138 -176
- package/dist/templates/infocom-adventure/shared.ts +126 -6
- package/dist/templates/infocom-adventure/system-prompt.md +4 -4
- package/dist/templates/infocom-adventure/tools/game_state_drop.ts +20 -4
- package/dist/templates/infocom-adventure/tools/game_state_get.ts +6 -5
- package/dist/templates/infocom-adventure/tools/game_state_score.ts +9 -3
- package/dist/templates/link-digest/agent.eval.test.ts +8 -0
- package/dist/templates/link-digest/agent.test.ts +285 -29
- package/dist/templates/link-digest/agent.ts +9 -0
- package/dist/templates/link-digest/api-client.ts +144 -0
- package/dist/templates/link-digest/client.tsx +11 -30
- package/dist/templates/link-digest/workflows/digest.ts +72 -24
- package/dist/templates/night-owl/agent.eval.test.ts +55 -40
- package/dist/templates/night-owl/agent.test.ts +146 -12
- package/dist/templates/night-owl/client.tsx +50 -17
- package/dist/templates/night-owl/shared.ts +33 -2
- package/dist/templates/night-owl/system-prompt.md +3 -0
- package/dist/templates/night-owl/tools/recommend.ts +4 -1
- package/dist/templates/night-owl/tools/revisit.ts +49 -0
- package/dist/templates/pipeline-simple/agent.eval.test.ts +7 -6
- package/dist/templates/pipeline-simple/agent.test.ts +48 -91
- package/dist/templates/pipeline-simple/modes.test.ts +151 -0
- package/dist/templates/pipeline-simple/stages.test.ts +332 -0
- package/dist/templates/pizza-ordering/agent.test.ts +94 -38
- package/dist/templates/pizza-ordering/client.tsx +10 -5
- package/dist/templates/pizza-ordering/shared.ts +65 -6
- package/dist/templates/pizza-ordering/tools/add_pizza.ts +2 -7
- package/dist/templates/pizza-ordering/tools/place_order.ts +9 -6
- package/dist/templates/pizza-ordering/tools/remove_pizza.ts +6 -11
- package/dist/templates/pizza-ordering/tools/update_pizza.ts +8 -9
- package/dist/templates/pizza-ordering/tools/view_order.ts +2 -3
- package/dist/templates/plan-and-execute/agent.eval.test.ts +14 -6
- package/dist/templates/plan-and-execute/agent.test.ts +300 -113
- package/dist/templates/plan-and-execute/client.tsx +18 -7
- package/dist/templates/plan-and-execute/procedure.ts +162 -64
- package/dist/templates/plan-and-execute/prompts.ts +51 -15
- package/dist/templates/plan-and-execute/shared.ts +151 -45
- package/dist/templates/plan-and-execute/tools/plan_status.ts +15 -6
- package/dist/templates/plan-and-execute/tools/revise_plan.ts +2 -2
- package/dist/templates/plan-and-execute/tools/start_plan.ts +2 -2
- package/dist/templates/plan-and-execute/tools/work_next_step.ts +15 -13
- package/dist/templates/podcast-digest/agent.eval.test.ts +12 -7
- package/dist/templates/podcast-digest/agent.test.ts +126 -51
- package/dist/templates/podcast-digest/client.tsx +104 -68
- package/dist/templates/podcast-digest/workflows/digest.ts +71 -48
- package/dist/templates/podcast-digest/workflows/feeds.ts +5 -7
- package/dist/templates/podcast-digest/workflows/slack.ts +82 -17
- package/dist/templates/recap-workflow/agent.eval.test.ts +193 -209
- package/dist/templates/recap-workflow/agent.test.ts +207 -26
- package/dist/templates/recap-workflow/tools/recap_status.ts +2 -2
- package/dist/templates/recap-workflow/workflows/recap.ts +39 -28
- package/dist/templates/redline/agent.eval.test.ts +40 -3
- package/dist/templates/redline/agent.test.ts +216 -6
- package/dist/templates/redline/agent.ts +54 -34
- package/dist/templates/redline/client.tsx +82 -126
- package/dist/templates/redline/form.ts +74 -0
- package/dist/templates/redline/workflows/prompts.ts +3 -3
- package/dist/templates/redline/workflows/redline.ts +73 -4
- package/dist/templates/research-workflow/agent.eval.test.ts +152 -150
- package/dist/templates/research-workflow/agent.test.ts +436 -126
- package/dist/templates/research-workflow/agent.ts +20 -5
- package/dist/templates/research-workflow/tools/file_it_now.ts +11 -1
- package/dist/templates/research-workflow/tools/research_status.ts +39 -4
- package/dist/templates/research-workflow/workflows/filing.ts +164 -0
- package/dist/templates/research-workflow/workflows/notes.ts +69 -0
- package/dist/templates/research-workflow/workflows/prompts.ts +45 -31
- package/dist/templates/research-workflow/workflows/research.ts +227 -280
- package/dist/templates/research-workflow/workflows/review.ts +43 -0
- package/dist/templates/retail/address.ts +29 -35
- package/dist/templates/retail/agent.eval.test.ts +36 -16
- package/dist/templates/retail/agent.test.ts +104 -26
- package/dist/templates/retail/agent.ts +12 -0
- package/dist/templates/retail/cancel.ts +39 -42
- package/dist/templates/retail/client.tsx +111 -176
- package/dist/templates/retail/payment.ts +38 -43
- package/dist/templates/retail/pending.test.ts +16 -8
- package/dist/templates/retail/registry.test.ts +108 -49
- package/dist/templates/retail/resolve.test.ts +2 -63
- package/dist/templates/retail/resolve.ts +16 -56
- package/dist/templates/retail/returns.ts +53 -54
- package/dist/templates/retail/seed.test.ts +2 -1
- package/dist/templates/retail/shared.ts +58 -14
- package/dist/templates/retail/store.test.ts +40 -29
- package/dist/templates/retail/store.ts +60 -23
- package/dist/templates/retail/swap.ts +78 -81
- package/dist/templates/retail/tools/find_user_id_by_name_zip.ts +2 -1
- package/dist/templates/roadside-assist/agent.eval.test.ts +164 -0
- package/dist/templates/roadside-assist/agent.test.ts +617 -0
- package/dist/templates/roadside-assist/agent.ts +85 -0
- package/dist/templates/roadside-assist/call.ts +237 -0
- package/dist/templates/roadside-assist/events.ts +92 -0
- package/dist/templates/roadside-assist/shared.ts +334 -0
- package/dist/templates/roadside-assist/system-prompt.md +37 -0
- package/dist/templates/roadside-assist/tools/acknowledge_disclosure.ts +47 -0
- package/dist/templates/roadside-assist/tools/dispatch_truck.ts +148 -0
- package/dist/templates/roadside-assist/tools/job_status.ts +38 -0
- package/dist/templates/roadside-assist/tools/lookup_coverage.ts +72 -0
- package/dist/templates/roadside-assist/tools/report_location.ts +79 -0
- package/dist/templates/roadside-assist/tools/service_disclosure.ts +45 -0
- package/dist/templates/roadside-assist/yard.test.ts +158 -0
- package/dist/templates/roadside-assist/yard.ts +183 -0
- package/dist/templates/simple/agent.eval.test.ts +4 -1
- package/dist/templates/simple/agent.test.ts +54 -31
- package/dist/templates/solo-rpg/agent.eval.test.ts +19 -11
- package/dist/templates/solo-rpg/agent.test.ts +402 -175
- package/dist/templates/solo-rpg/agent.ts +14 -3
- package/dist/templates/solo-rpg/client.tsx +10 -10
- package/dist/templates/solo-rpg/shared.ts +198 -79
- package/dist/templates/solo-rpg/tools/action_roll.ts +7 -3
- package/dist/templates/solo-rpg/tools/burn_momentum.ts +16 -8
- package/dist/templates/solo-rpg/tools/oracle.ts +7 -7
- package/dist/templates/solo-rpg/tools/setup_character.ts +5 -5
- package/dist/templates/solo-rpg/tools/update_state.ts +29 -18
- package/dist/templates/spoken-summary/agent.test.ts +70 -15
- package/dist/templates/spoken-summary/agent.ts +25 -21
- package/dist/templates/spoken-summary/client.tsx +68 -88
- package/dist/templates/spoken-summary/workflows/summarize.ts +26 -8
- package/dist/templates/support-line/agent.test.ts +167 -36
- package/dist/templates/support-line/client.tsx +21 -9
- package/dist/templates/support-line/nodes.ts +74 -32
- package/dist/templates/support-line/procedure.ts +66 -21
- package/dist/templates/support-line/prompts.ts +9 -0
- package/dist/templates/support-line/shared.ts +55 -17
- package/dist/templates/support-line/tools/answer_question.ts +14 -14
- package/dist/templates/transcription-workflow/agent.test.ts +135 -13
- package/dist/templates/transcription-workflow/client.tsx +30 -23
- package/dist/templates/transcription-workflow/recover.test.ts +93 -12
- package/dist/templates/transcription-workflow/recover.ts +29 -5
- package/dist/templates/transcription-workflow/run-panel.tsx +40 -51
- package/dist/templates/transcription-workflow/workflows/normalize.ts +125 -24
- package/dist/templates/transcription-workflow/workflows/stream.ts +4 -1
- package/dist/templates/transcription-workflow/workflows/transcribe.ts +7 -5
- package/dist/templates/transcription-workflow/workflows/wav.ts +42 -117
- package/dist/templates/travel-concierge/agent.eval.test.ts +6 -4
- package/dist/templates/travel-concierge/agent.test.ts +209 -40
- package/dist/templates/travel-concierge/agent.ts +24 -4
- package/dist/templates/travel-concierge/call-events.ts +80 -0
- package/dist/templates/travel-concierge/client.tsx +3 -2
- package/dist/templates/travel-concierge/routing.ts +5 -7
- package/dist/templates/travel-concierge/shared.ts +202 -41
- package/dist/templates/travel-concierge/tools/book_car_rental.ts +2 -4
- package/dist/templates/travel-concierge/tools/book_excursion.ts +2 -4
- package/dist/templates/travel-concierge/tools/book_hotel.ts +2 -4
- package/dist/templates/travel-concierge/tools/cancel_ticket.ts +6 -4
- package/dist/templates/travel-concierge/tools/search_car_rentals.ts +3 -5
- package/dist/templates/travel-concierge/tools/search_excursions.ts +3 -5
- package/dist/templates/travel-concierge/tools/search_flights.ts +20 -9
- package/dist/templates/travel-concierge/tools/search_hotels.ts +3 -5
- package/dist/templates/travel-concierge/tools/update_ticket.ts +2 -4
- package/dist/templates/web-researcher/agent.eval.test.ts +3 -6
- package/dist/templates/web-researcher/agent.test.ts +102 -65
- package/dist/templates/web-researcher/agent.ts +93 -1
- package/dist/templates/web-researcher/system-prompt.md +7 -1
- package/dist/templates/word-wrangler/agent.eval.test.ts +157 -0
- package/dist/templates/word-wrangler/agent.test.ts +432 -0
- package/dist/templates/word-wrangler/agent.ts +35 -0
- package/dist/templates/word-wrangler/client.tsx +211 -0
- package/dist/templates/word-wrangler/game.ts +107 -0
- package/dist/templates/word-wrangler/guess.ts +63 -0
- package/dist/templates/word-wrangler/player.ts +68 -0
- package/dist/templates/word-wrangler/shared.ts +263 -0
- package/dist/templates/word-wrangler/system-prompt.md +15 -0
- package/dist/templates/word-wrangler/tools/final_score.ts +37 -0
- package/dist/templates/word-wrangler/tools/relay_description.ts +137 -0
- package/dist/templates/word-wrangler/tools/repeat_word.ts +19 -0
- package/dist/templates/word-wrangler/tools/skip_word.ts +31 -0
- package/dist/templates/word-wrangler/tools/start_game.ts +47 -0
- package/dist/templates/word-wrangler/words.ts +278 -0
- package/dist/test-Cllnx81G.mjs +83 -0
- package/dist/test.d.ts +9 -114
- package/package.json +5 -5
- package/dist/build-BhEaxBPu.mjs +0 -481
- package/dist/templates/embedded-assets/agent.eval.test.ts +0 -130
- package/dist/templates/embedded-assets/agent.test.ts +0 -79
- package/dist/templates/embedded-assets/agent.ts +0 -7
- package/dist/templates/embedded-assets/knowledge.json +0 -20
- package/dist/templates/embedded-assets/shared.ts +0 -17
- package/dist/templates/embedded-assets/system-prompt.md +0 -13
- package/dist/templates/embedded-assets/tools/list_topics.ts +0 -9
- package/dist/templates/embedded-assets/tools/search_knowledge.ts +0 -26
- package/dist/templates/math-buddy/agent.eval.test.ts +0 -128
- package/dist/templates/math-buddy/agent.test.ts +0 -126
- package/dist/templates/math-buddy/agent.ts +0 -15
- package/dist/templates/math-buddy/system-prompt.md +0 -12
- package/dist/templates/personal-finance/agent.eval.test.ts +0 -149
- package/dist/templates/personal-finance/agent.test.ts +0 -127
- package/dist/templates/personal-finance/agent.ts +0 -8
- package/dist/templates/personal-finance/system-prompt.md +0 -21
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { toolFailure } from "@alexkroman1/aai";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { EXECUTIVE } from "../inbox.ts";
|
|
4
|
+
import { findMeetingTime } from "../meeting.ts";
|
|
5
|
+
import { threadText } from "../prompts.ts";
|
|
6
|
+
import { assistantSlot, DRAFTING, openEmail, reviewFlow } from "../shared.ts";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Their `MeetingAssistant` → `find_meeting_time`: a specialist reads the
|
|
10
|
+
* calendar and reports the free slots, and the report comes back as this
|
|
11
|
+
* tool's result — their `ToolMessage` back into `draft_response`. The
|
|
12
|
+
* specialist is a subagent (`../meeting.ts`), so the calendar lookups never
|
|
13
|
+
* reach this conversation; what does is one dense sentence.
|
|
14
|
+
*
|
|
15
|
+
* No `send`: the call stays in `drafting`, because knowing the free slots is
|
|
16
|
+
* not yet a proposal. `draft_reply` or `send_calendar_invite` comes next.
|
|
17
|
+
*
|
|
18
|
+
* A report the specialist's guardrail never accepted is handed on anyway, with
|
|
19
|
+
* `usable: false` and a different `next` — the desk is on a live call and there
|
|
20
|
+
* IS an answer, so a `ToolFailure` would throw away the one thing it learned.
|
|
21
|
+
*/
|
|
22
|
+
export default reviewFlow.tool({
|
|
23
|
+
description:
|
|
24
|
+
`Ask the meeting assistant when ${EXECUTIVE.name} is free, for an email that is trying to ` +
|
|
25
|
+
"set up a meeting. It reads the calendar and answers with the open slots. Say you are " +
|
|
26
|
+
"checking the calendar before you call it — it takes a moment.",
|
|
27
|
+
when: DRAFTING,
|
|
28
|
+
inputSchema: z.object({
|
|
29
|
+
request: z
|
|
30
|
+
.string()
|
|
31
|
+
.min(1)
|
|
32
|
+
.max(300)
|
|
33
|
+
.describe("What the sender is asking for — which days, how long, any times they ruled out"),
|
|
34
|
+
}),
|
|
35
|
+
async execute(args, ctx) {
|
|
36
|
+
const email = openEmail(assistantSlot.get(ctx));
|
|
37
|
+
if (!email) return toolFailure("No email is open — call open_email first.");
|
|
38
|
+
const found = await findMeetingTime(ctx.delegate, threadText(email), args.request);
|
|
39
|
+
return assistantSlot.update(ctx, (state) => {
|
|
40
|
+
state.exchange.push(`Meeting assistant: ${found.availability}`);
|
|
41
|
+
state.log.push(`Checked the calendar (${found.lookups} lookups)`);
|
|
42
|
+
return {
|
|
43
|
+
...found,
|
|
44
|
+
next: found.usable
|
|
45
|
+
? "Offer these times in draft_reply, or send_calendar_invite if the meeting should be " +
|
|
46
|
+
"booked outright."
|
|
47
|
+
: `The assistant did not name a time, so there is nothing to offer. Ask ${EXECUTIVE.name} ` +
|
|
48
|
+
"what to do, or ask again with the days the sender suggested. Do not invent a slot.",
|
|
49
|
+
};
|
|
50
|
+
});
|
|
51
|
+
},
|
|
52
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { toolFailure } from "@alexkroman1/aai";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { EXECUTIVE } from "../inbox.ts";
|
|
4
|
+
import { rewriteDraft } from "../nodes.ts";
|
|
5
|
+
import { threadText } from "../prompts.ts";
|
|
6
|
+
import { propose } from "../review.ts";
|
|
7
|
+
import { assistantSlot, DRAFTING, openEmail, reviewFlow } from "../shared.ts";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Their `NewEmailDraft` — a fresh thread, such as the introduction the open
|
|
11
|
+
* email asked for. Declared in their drafting tool list; their `take_action`
|
|
12
|
+
* has no arm for it and routes it to `bad_tool_name`, so this is the arm the
|
|
13
|
+
* prompt describes — rewritten and staged like a reply, sent only by `accept`.
|
|
14
|
+
*/
|
|
15
|
+
export default reviewFlow.tool({
|
|
16
|
+
description:
|
|
17
|
+
`Start a NEW email thread from ${EXECUTIVE.name} — for an introduction they agreed to make, ` +
|
|
18
|
+
"or a note the open email calls for to someone not on it. Full text, their voice. Staged " +
|
|
19
|
+
"for read-back, not sent.",
|
|
20
|
+
when: DRAFTING,
|
|
21
|
+
send: { type: "PROPOSED" },
|
|
22
|
+
inputSchema: z.object({
|
|
23
|
+
recipients: z
|
|
24
|
+
.array(z.string().max(120))
|
|
25
|
+
.min(1)
|
|
26
|
+
.max(5)
|
|
27
|
+
.describe("Who it goes to — real addresses you have, never invented"),
|
|
28
|
+
content: z.string().min(1).max(4000).describe("The complete email"),
|
|
29
|
+
}),
|
|
30
|
+
async execute(args, ctx) {
|
|
31
|
+
const state = assistantSlot.get(ctx);
|
|
32
|
+
const email = openEmail(state);
|
|
33
|
+
if (!email) return toolFailure("No email is open — call open_email first.");
|
|
34
|
+
const tone = await rewriteDraft(
|
|
35
|
+
ctx.generate,
|
|
36
|
+
EXECUTIVE,
|
|
37
|
+
state.memory.rewriteInstructions,
|
|
38
|
+
args.content,
|
|
39
|
+
threadText(email),
|
|
40
|
+
);
|
|
41
|
+
return assistantSlot.update(ctx, (draft) =>
|
|
42
|
+
propose(draft, {
|
|
43
|
+
kind: "new_email",
|
|
44
|
+
content: tone.rewrittenContent,
|
|
45
|
+
recipients: [...args.recipients],
|
|
46
|
+
toneLogic: tone.toneLogic,
|
|
47
|
+
}),
|
|
48
|
+
);
|
|
49
|
+
},
|
|
50
|
+
});
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type DeepReadonly,
|
|
3
|
+
isToolFailure,
|
|
4
|
+
type ResolveOneOptions,
|
|
5
|
+
resolveOne,
|
|
6
|
+
toolFailure,
|
|
7
|
+
} from "@alexkroman1/aai";
|
|
8
|
+
import { z } from "zod";
|
|
9
|
+
import { EXECUTIVE } from "../inbox.ts";
|
|
10
|
+
import { triageEmail } from "../nodes.ts";
|
|
11
|
+
import { draftingBrief, threadText } from "../prompts.ts";
|
|
12
|
+
import { readBackFor } from "../review.ts";
|
|
13
|
+
import {
|
|
14
|
+
ALLOWED,
|
|
15
|
+
AT_INBOX,
|
|
16
|
+
assistantSlot,
|
|
17
|
+
type FrozenAssistantState,
|
|
18
|
+
findEmail,
|
|
19
|
+
type InboxEmail,
|
|
20
|
+
nextToOpen,
|
|
21
|
+
reviewFlow,
|
|
22
|
+
similarExamples,
|
|
23
|
+
} from "../shared.ts";
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Words too common in a subject line to be what the executive meant — "the
|
|
27
|
+
* Northwind one" is about Northwind. Six of them, kept short deliberately: a
|
|
28
|
+
* longer list starts deciding which real words do not count.
|
|
29
|
+
*/
|
|
30
|
+
const FILLER = new Set(["the", "that", "one", "your", "with", "for"]);
|
|
31
|
+
|
|
32
|
+
const wordsIn = (text: string) =>
|
|
33
|
+
(text.toLowerCase().match(/[a-z0-9]{3,}/g) ?? []).filter((word) => !FILLER.has(word));
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* How the executive refers to an email when they are not reading an id: by who
|
|
37
|
+
* sent it and what it is about. The SENDER and SUBJECT only — a body match on
|
|
38
|
+
* "meeting" would tie half the inbox.
|
|
39
|
+
*/
|
|
40
|
+
const BY_WHAT_IT_IS: ResolveOneOptions<DeepReadonly<InboxEmail>> = {
|
|
41
|
+
label: "email",
|
|
42
|
+
describe: (email) => `${email.id}: "${email.subject}" from ${email.from}`,
|
|
43
|
+
score: (email, spoken) => {
|
|
44
|
+
const said = new Set(wordsIn(spoken));
|
|
45
|
+
return wordsIn(`${email.from} ${email.subject}`).filter((word) => said.has(word)).length;
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* The email the executive named — and the two ways they name one are two
|
|
51
|
+
* different problems.
|
|
52
|
+
*
|
|
53
|
+
* An ID came off a list this desk read out, so an exact lookup is the whole
|
|
54
|
+
* answer and a miss means no such email. THEIR OWN WORDS — "the one from Dana",
|
|
55
|
+
* "the second one" — are a pick among eight rows that look alike, where taking
|
|
56
|
+
* the first overlap opens the wrong thread and drafts a reply in the
|
|
57
|
+
* executive's name against it. So the desk narrows by its own vocabulary (the
|
|
58
|
+
* scorer above) and `resolveOne` owns the half a template should not re-derive:
|
|
59
|
+
* a position is taken as read, nothing matching and several matching are
|
|
60
|
+
* DIFFERENT answers, and both come back naming what it could have meant so the
|
|
61
|
+
* assistant can ask on its own turn.
|
|
62
|
+
*/
|
|
63
|
+
function pick(state: FrozenAssistantState, which: string) {
|
|
64
|
+
const byId = findEmail(state.emails, which);
|
|
65
|
+
if (byId) return byId;
|
|
66
|
+
const live = state.emails.filter((email) => email.status !== "closed");
|
|
67
|
+
return resolveOne(live, which, BY_WHAT_IT_IS);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Start one thread's run — their graph's entry, from `triage_input` to the
|
|
72
|
+
* first node that needs a model.
|
|
73
|
+
*
|
|
74
|
+
* **The result IS the brief.** Their `draft_response` node reads
|
|
75
|
+
* `EMAIL_WRITING_INSTRUCTIONS` with the four memory prompts interpolated; a
|
|
76
|
+
* voice session's prompt is fixed at connect and memory changes mid-call, so the
|
|
77
|
+
* same text comes back as this tool's result — the last thing the model reads
|
|
78
|
+
* before it chooses a drafting tool, with whatever memory says NOW.
|
|
79
|
+
*
|
|
80
|
+
* Their `route_after_triage` is `sendFrom`: a `notify` skips drafting and lands
|
|
81
|
+
* straight in `awaitingDecision` with a heads-up staged, as their `notify` node
|
|
82
|
+
* halts for the human without drafting anything; `email` and `question` go to
|
|
83
|
+
* `drafting`. A `no` the executive opens anyway is opened — their `--rerun` —
|
|
84
|
+
* with the verdict in the result so the model knows it was filed.
|
|
85
|
+
*
|
|
86
|
+
* An untriaged email is triaged on the way in, so "open the one from Dana" works
|
|
87
|
+
* before `triage_inbox` has run.
|
|
88
|
+
*/
|
|
89
|
+
export default reviewFlow.tool({
|
|
90
|
+
description:
|
|
91
|
+
"Open the next email that needs the executive — or the one they named, by id or in their " +
|
|
92
|
+
"own words — and get the thread plus your brief for handling it. Replies come before " +
|
|
93
|
+
"heads-ups. One email is open at a time; settle it before opening another.",
|
|
94
|
+
when: AT_INBOX,
|
|
95
|
+
inputSchema: z.object({
|
|
96
|
+
which: z
|
|
97
|
+
.string()
|
|
98
|
+
.max(120)
|
|
99
|
+
.describe(
|
|
100
|
+
"An email id from triage_inbox or inbox_status, or how the executive referred to it " +
|
|
101
|
+
"in their own words — who sent it, what it is about, or which one in the list. " +
|
|
102
|
+
"Leave it out for the next one that needs them.",
|
|
103
|
+
)
|
|
104
|
+
.optional(),
|
|
105
|
+
}),
|
|
106
|
+
async execute(args, ctx) {
|
|
107
|
+
const state = assistantSlot.get(ctx);
|
|
108
|
+
const target = args.which ? pick(state, args.which) : nextToOpen(state);
|
|
109
|
+
if (isToolFailure(target)) return target;
|
|
110
|
+
if (!target) {
|
|
111
|
+
return toolFailure(
|
|
112
|
+
"Nothing is queued. Run triage_inbox if you have not; otherwise the inbox is done.",
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
const verdict =
|
|
116
|
+
target.triage ??
|
|
117
|
+
(await triageEmail(
|
|
118
|
+
ctx.generate,
|
|
119
|
+
EXECUTIVE,
|
|
120
|
+
target,
|
|
121
|
+
similarExamples(state.triageExamples, target),
|
|
122
|
+
));
|
|
123
|
+
return assistantSlot.update(ctx, (draft) => {
|
|
124
|
+
const email = findEmail(draft.emails, target.id);
|
|
125
|
+
if (!email) return toolFailure(`Email ${target.id} disappeared.`);
|
|
126
|
+
const reopened = email.status === "closed";
|
|
127
|
+
email.triage = verdict;
|
|
128
|
+
email.status = "open";
|
|
129
|
+
draft.openId = email.id;
|
|
130
|
+
draft.exchange = [`Draft a response to this email:\n\n${threadText(email)}`];
|
|
131
|
+
draft.log.push(`Opened: ${email.subject} (${verdict.response})`);
|
|
132
|
+
const thread = {
|
|
133
|
+
id: email.id,
|
|
134
|
+
from: email.from,
|
|
135
|
+
to: email.to,
|
|
136
|
+
subject: email.subject,
|
|
137
|
+
sentAt: email.sentAt,
|
|
138
|
+
body: email.body,
|
|
139
|
+
};
|
|
140
|
+
if (verdict.response === "notify") {
|
|
141
|
+
const proposal = { kind: "notify" as const };
|
|
142
|
+
draft.proposal = proposal;
|
|
143
|
+
draft.exchange.push("Assistant proposed — Heads-up: no reply needed.");
|
|
144
|
+
return {
|
|
145
|
+
route: "notify" as const,
|
|
146
|
+
email: thread,
|
|
147
|
+
triage: verdict,
|
|
148
|
+
allowed: ALLOWED.notify,
|
|
149
|
+
instructions: readBackFor(proposal),
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
return {
|
|
153
|
+
route: "draft" as const,
|
|
154
|
+
email: thread,
|
|
155
|
+
triage: verdict,
|
|
156
|
+
reopened,
|
|
157
|
+
instructions:
|
|
158
|
+
(verdict.response === "no"
|
|
159
|
+
? `Triage filed this one as not worth a reply; ${EXECUTIVE.name} opened it anyway, so only draft if they ask. `
|
|
160
|
+
: "") + draftingBrief(EXECUTIVE, draft.memory),
|
|
161
|
+
};
|
|
162
|
+
});
|
|
163
|
+
},
|
|
164
|
+
sendFrom: (result) => ({ type: result.route === "notify" ? "NOTIFY" : "OPENED" }),
|
|
165
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `respond` — one of the four answers to a proposal, their `HumanResponse`
|
|
3
|
+
* `"respond"`. The four live together in `../review.ts` because they share the one
|
|
4
|
+
* place anything is sent and the reflection scope table; this file is what
|
|
5
|
+
* gives this one its name.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { respondTool } from "../review.ts";
|
|
9
|
+
|
|
10
|
+
export default respondTool();
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { EXECUTIVE } from "../inbox.ts";
|
|
2
|
+
import { assistantSlot } from "../shared.ts";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* What the assistant has learned — the four memory prompts their store holds,
|
|
6
|
+
* and every rewrite this call made to them. A read, so ungated: "what have you
|
|
7
|
+
* picked up about how I write?" is answerable at any point.
|
|
8
|
+
*/
|
|
9
|
+
export default assistantSlot.tool({
|
|
10
|
+
description:
|
|
11
|
+
`Read back what you currently believe about how ${EXECUTIVE.name} likes emails written, ` +
|
|
12
|
+
"what to include, how to schedule, and the background you are working from — plus what " +
|
|
13
|
+
"you learned on this call. For when they ask what you have picked up, or to check a rule.",
|
|
14
|
+
execute: (_args, state) => ({
|
|
15
|
+
tone: state.memory.rewriteInstructions,
|
|
16
|
+
content: state.memory.responsePreferences || "(nothing yet)",
|
|
17
|
+
scheduling: state.memory.schedulePreferences,
|
|
18
|
+
background: state.memory.backgroundPreferences,
|
|
19
|
+
learnedThisCall: state.reflections.map((r) => `${r.memory}: ${r.logic}`),
|
|
20
|
+
examplesRemembered: state.triageExamples.length,
|
|
21
|
+
}),
|
|
22
|
+
});
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { clockTime, isoDate, spokenDate, spokenTime, toolFailure } from "@alexkroman1/aai";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { EXECUTIVE } from "../inbox.ts";
|
|
4
|
+
import { clashOn } from "../meeting.ts";
|
|
5
|
+
import { propose } from "../review.ts";
|
|
6
|
+
import { assistantSlot, DRAFTING, reviewFlow } from "../shared.ts";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Their `SendCalendarInvite` → `send_cal_invite`: staged, read back, and sent
|
|
10
|
+
* by `accept` alone. Their schema's own warning rides on the field: "Do NOT
|
|
11
|
+
* make any emails up!"
|
|
12
|
+
*
|
|
13
|
+
* **The day and the two times are three CIVIL fields**, not one ISO datetime.
|
|
14
|
+
* The pair of regexes that shape used to carry accepted `2026-02-30T99:99` —
|
|
15
|
+
* both halves are checked now, by the same predicates the SDK's date and clock
|
|
16
|
+
* fields put in front of the model as JSON Schema, so a bad value is refused
|
|
17
|
+
* before `execute` runs rather than by a sentence written here. It also makes
|
|
18
|
+
* the read-back speakable: `2026-03-17T14:00:00` is what a TTS engine spells
|
|
19
|
+
* out digit by digit.
|
|
20
|
+
*
|
|
21
|
+
* **And the calendar is CHECKED.** The description asks for `meeting_assistant`
|
|
22
|
+
* first, and a rule the model can skip is not a rule (see `retail`'s
|
|
23
|
+
* confirmation gate): a slot the calendar already holds is refused here, naming
|
|
24
|
+
* what is in it, so the one tool that books time in the executive's name cannot
|
|
25
|
+
* double-book them because a model went straight to it.
|
|
26
|
+
*/
|
|
27
|
+
export default reviewFlow.tool({
|
|
28
|
+
description:
|
|
29
|
+
`Book a meeting on ${EXECUTIVE.name}'s calendar and invite the people on the thread. Only ` +
|
|
30
|
+
"once you are sure they want it and meeting_assistant has said the slot is free. Staged " +
|
|
31
|
+
"for read-back, not sent.",
|
|
32
|
+
when: DRAFTING,
|
|
33
|
+
send: { type: "PROPOSED" },
|
|
34
|
+
inputSchema: z.object({
|
|
35
|
+
emails: z
|
|
36
|
+
.array(z.string().max(120))
|
|
37
|
+
.min(1)
|
|
38
|
+
.max(10)
|
|
39
|
+
.describe("Who to invite. Do NOT make any emails up!"),
|
|
40
|
+
title: z.string().min(1).max(120).describe("Name of the meeting"),
|
|
41
|
+
date: isoDate("the day of the meeting"),
|
|
42
|
+
startTime: clockTime(`when it starts, 24-hour, local to ${EXECUTIVE.timezone}`),
|
|
43
|
+
endTime: clockTime("when it ends, same format"),
|
|
44
|
+
}),
|
|
45
|
+
execute: (args, ctx) => {
|
|
46
|
+
if (args.endTime <= args.startTime) {
|
|
47
|
+
return toolFailure("The meeting ends before it starts — check the times.");
|
|
48
|
+
}
|
|
49
|
+
const clash = clashOn(args.date, args.startTime, args.endTime);
|
|
50
|
+
if (clash) {
|
|
51
|
+
return toolFailure(
|
|
52
|
+
`${EXECUTIVE.name} already has "${clash.title}" on ${spokenDate(args.date)} from ` +
|
|
53
|
+
`${spokenTime(clash.start)} to ${spokenTime(clash.end)}. Ask meeting_assistant for a ` +
|
|
54
|
+
"free slot and offer that instead.",
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
return assistantSlot.update(ctx, (state) =>
|
|
58
|
+
propose(state, {
|
|
59
|
+
kind: "invite",
|
|
60
|
+
emails: [...args.emails],
|
|
61
|
+
title: args.title,
|
|
62
|
+
date: args.date,
|
|
63
|
+
startTime: args.startTime,
|
|
64
|
+
endTime: args.endTime,
|
|
65
|
+
}),
|
|
66
|
+
);
|
|
67
|
+
},
|
|
68
|
+
});
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { EXECUTIVE } from "../inbox.ts";
|
|
2
|
+
import { triageEmail } from "../nodes.ts";
|
|
3
|
+
import { assistantSlot, closeEmail, findEmail, reviewFlow, similarExamples } from "../shared.ts";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Their `triage_input`, over every email that has not been triaged yet.
|
|
7
|
+
*
|
|
8
|
+
* **All of them at once, and that is the voice adaptation.** Their cron runs the
|
|
9
|
+
* graph once per thread as mail arrives; a caller wants to hear the shape of the
|
|
10
|
+
* inbox before opening anything, so the verdicts are fetched concurrently and
|
|
11
|
+
* applied in one window. Their `route_after_triage` is applied here too: a `no`
|
|
12
|
+
* is marked read on the spot (`filed`), and only `email`, `question` and
|
|
13
|
+
* `notify` are queued for the executive.
|
|
14
|
+
*
|
|
15
|
+
* The few-shot examples are chosen per email from what THIS call has settled —
|
|
16
|
+
* their `get_few_shot_examples`, over the session's own store.
|
|
17
|
+
*/
|
|
18
|
+
export default reviewFlow.tool({
|
|
19
|
+
description:
|
|
20
|
+
"Triage every new email: decide which need a reply, which are just worth knowing " +
|
|
21
|
+
"about, and which to file unread. Call this first on a call, and again if new mail is " +
|
|
22
|
+
"mentioned. Tell the executive the counts, then open_email.",
|
|
23
|
+
when: "onCall",
|
|
24
|
+
async execute(_args, ctx) {
|
|
25
|
+
const state = assistantSlot.get(ctx);
|
|
26
|
+
const pending = state.emails.filter((email) => email.status === "untriaged");
|
|
27
|
+
const verdicts = await Promise.all(
|
|
28
|
+
pending.map(async (email) => ({
|
|
29
|
+
id: email.id,
|
|
30
|
+
verdict: await triageEmail(
|
|
31
|
+
ctx.generate,
|
|
32
|
+
EXECUTIVE,
|
|
33
|
+
email,
|
|
34
|
+
similarExamples(state.triageExamples, email),
|
|
35
|
+
),
|
|
36
|
+
})),
|
|
37
|
+
);
|
|
38
|
+
return assistantSlot.update(ctx, (draft) => {
|
|
39
|
+
const filed: string[] = [];
|
|
40
|
+
for (const { id, verdict } of verdicts) {
|
|
41
|
+
const email = findEmail(draft.emails, id);
|
|
42
|
+
if (!email) continue;
|
|
43
|
+
email.triage = verdict;
|
|
44
|
+
if (verdict.response === "no") {
|
|
45
|
+
closeEmail(draft, email.id, "filed");
|
|
46
|
+
filed.push(email.subject);
|
|
47
|
+
} else {
|
|
48
|
+
email.status = "queued";
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (verdicts.length > 0) {
|
|
52
|
+
draft.log.push(
|
|
53
|
+
`Triaged ${verdicts.length}: ${verdicts.length - filed.length} queued, ${filed.length} filed`,
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
const queued = draft.emails.filter((email) => email.status === "queued");
|
|
57
|
+
const brief = (email: (typeof queued)[number]) => ({
|
|
58
|
+
id: email.id,
|
|
59
|
+
from: email.from,
|
|
60
|
+
subject: email.subject,
|
|
61
|
+
why: email.triage?.logic ?? "",
|
|
62
|
+
});
|
|
63
|
+
return {
|
|
64
|
+
triaged: verdicts.length,
|
|
65
|
+
needReply: queued.filter((email) => email.triage?.response !== "notify").map(brief),
|
|
66
|
+
headsUp: queued.filter((email) => email.triage?.response === "notify").map(brief),
|
|
67
|
+
filed,
|
|
68
|
+
next:
|
|
69
|
+
queued.length > 0
|
|
70
|
+
? `Say how many need ${EXECUTIVE.name}, then open_email to start with the first.`
|
|
71
|
+
: "The inbox is clear.",
|
|
72
|
+
};
|
|
73
|
+
});
|
|
74
|
+
},
|
|
75
|
+
});
|
|
@@ -1,7 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
type InferToolInput,
|
|
3
|
+
type InferToolOutput,
|
|
4
|
+
isToolFailure,
|
|
5
|
+
type ToolFailure,
|
|
6
|
+
} from "@alexkroman1/aai";
|
|
7
|
+
import {
|
|
8
|
+
expectDeployable,
|
|
9
|
+
expectPromptBuiltinsDeclared,
|
|
10
|
+
toolInputIssues,
|
|
11
|
+
toolRunner,
|
|
12
|
+
} from "@alexkroman1/aai/testing";
|
|
3
13
|
import { beforeEach, describe, expect, test, vi } from "vitest";
|
|
4
14
|
import { excerptAround, type FdaLabel, toDrugInfo } from "./fda.ts";
|
|
15
|
+
import type CheckDrugInteraction from "./tools/check_drug_interaction.ts";
|
|
16
|
+
import type MedicationLookup from "./tools/medication_lookup.ts";
|
|
5
17
|
|
|
6
18
|
/**
|
|
7
19
|
* Only the NETWORK half of `fda.ts` is faked.
|
|
@@ -32,6 +44,37 @@ import agentDef from "virtual:aai/agent";
|
|
|
32
44
|
*/
|
|
33
45
|
const run = toolRunner(agentDef);
|
|
34
46
|
|
|
47
|
+
/**
|
|
48
|
+
* The two tools, reached through their OWN input types.
|
|
49
|
+
*
|
|
50
|
+
* `run` takes `Record<string, unknown>`, so `run("medication_lookup", { drug:
|
|
51
|
+
* "advil" })` compiles and fails at run time as a schema rejection — in the one
|
|
52
|
+
* spec that is supposed to be the worked example of calling this tool.
|
|
53
|
+
* `InferToolInput` reads the argument type off the tool's `execute`, which is
|
|
54
|
+
* the zod schema the tool really declares, so a renamed or retyped field breaks
|
|
55
|
+
* the BUILD here and the two files cannot drift apart quietly.
|
|
56
|
+
*
|
|
57
|
+
* The imports are TYPE-only, deliberately: the defs under test still come from
|
|
58
|
+
* `agentDef`, which is what a deploy resolves, and nothing here re-registers a
|
|
59
|
+
* tool module by importing it.
|
|
60
|
+
*/
|
|
61
|
+
const lookUp = (args: InferToolInput<typeof MedicationLookup>) => run("medication_lookup", args);
|
|
62
|
+
const check = (args: InferToolInput<typeof CheckDrugInteraction>) =>
|
|
63
|
+
run("check_drug_interaction", args);
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* What `check_drug_interaction` answers when it did NOT refuse.
|
|
67
|
+
*
|
|
68
|
+
* `run` is typed `unknown` — the registry lookup is by string — so reading a
|
|
69
|
+
* field off the answer needs an assertion either way. `InferToolOutput` makes
|
|
70
|
+
* it an assertion about the tool's OWN return type rather than a shape retyped
|
|
71
|
+
* beside it, so renaming `interactions_found` reddens here instead of quietly
|
|
72
|
+
* comparing `undefined`. The SDK's `expectToolOk` is deliberately not used: it
|
|
73
|
+
* unwraps a `dialog()` envelope and throws for a plain `tool()`, which both of
|
|
74
|
+
* these are.
|
|
75
|
+
*/
|
|
76
|
+
type CheckResult = Exclude<InferToolOutput<typeof CheckDrugInteraction>, ToolFailure>;
|
|
77
|
+
|
|
35
78
|
const IBUPROFEN: FdaLabel = {
|
|
36
79
|
openfda: { generic_name: ["IBUPROFEN"], brand_name: ["Advil"], manufacturer_name: ["Acme"] },
|
|
37
80
|
purpose: ["Pain reliever"],
|
|
@@ -66,31 +109,92 @@ describe("health-assistant template", () => {
|
|
|
66
109
|
expect.arrayContaining(["check_drug_interaction", "medication_lookup"]),
|
|
67
110
|
);
|
|
68
111
|
});
|
|
112
|
+
|
|
113
|
+
test("is deployable: validates, is nameable, and every stage its mode needs is filled", () => {
|
|
114
|
+
// The same conversion `aai build`/`aai deploy` run, and the only thing that
|
|
115
|
+
// checks the three builtin NAMES against the SDK's own enum — so a typo in
|
|
116
|
+
// `builtinTools` fails here rather than shipping an agent whose prompt
|
|
117
|
+
// commands a tool the platform never resolved. This template declares no
|
|
118
|
+
// provider at all, so the default all-AssemblyAI cascade is what makes it
|
|
119
|
+
// run the moment it is deployed; `expectDeployable` asserts that per MODE,
|
|
120
|
+
// so it survives a swap. `not.toThrow()` because the helper's throw IS the
|
|
121
|
+
// finding: vitest quotes the message, which names the invariant that went.
|
|
122
|
+
expect(() => expectDeployable(agentDef)).not.toThrow();
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
test("all three builtins survive into the config a deploy carries", () => {
|
|
126
|
+
const builtins = expectDeployable(agentDef).builtinTools ?? [];
|
|
127
|
+
|
|
128
|
+
// Asserted on the CONFIG rather than the def because that is what a deploy
|
|
129
|
+
// ships, and because `DEFAULT_BUILTIN_TOOLS` is empty: a builtin is
|
|
130
|
+
// something an agent asks for, never something it has to notice and switch
|
|
131
|
+
// off. So a dropped entry is not a quieter Dr. Sage — it is the same one
|
|
132
|
+
// with a prompt rule addressed to nothing. Adding builtins beside these
|
|
133
|
+
// three is an ordinary edit; losing one is the regression.
|
|
134
|
+
//
|
|
135
|
+
// `run_code` is the arithmetic rule's only mechanism (a BMI or a
|
|
136
|
+
// weight-based dose worked out in the model's head reads exactly like a
|
|
137
|
+
// computed one), `web_search` the only route to current symptom
|
|
138
|
+
// information, and `fetch_json` the only route to the adverse-event
|
|
139
|
+
// dataset — which is a COUNTING query the two `tools/` files cannot
|
|
140
|
+
// answer, since they read the label endpoint and a label is what the
|
|
141
|
+
// manufacturer wrote.
|
|
142
|
+
expect(builtins).toEqual(expect.arrayContaining(["web_search", "run_code", "fetch_json"]));
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
test("every builtin the prompt tells Dr. Sage to use is one it declares", () => {
|
|
146
|
+
// The pairing this template's prose is built on: the prompt holds the
|
|
147
|
+
// formulas, the endpoint and the caveats, each list headed by the tool that
|
|
148
|
+
// consumes it, and `agent.ts` holds the array that makes those tools exist.
|
|
149
|
+
// The failure is silent in both directions and shows up in a diff of
|
|
150
|
+
// neither file — a prompt commanding `fetch_json` at an agent that never
|
|
151
|
+
// declared it produces a model apologizing for a tool it cannot see, and a
|
|
152
|
+
// builtin dropped from `agent.ts` alone leaves the endpoint addressed to
|
|
153
|
+
// nothing.
|
|
154
|
+
//
|
|
155
|
+
// Which snake_case tokens in the prose are tool NAMES is a question for the
|
|
156
|
+
// SDK's own schema rather than a catalog restated here: this prompt also
|
|
157
|
+
// names `weight_kg`, `dose_mg`, `medication_lookup` and
|
|
158
|
+
// `patient.reaction.reactionmeddrapt.exact`, so matching every underscored
|
|
159
|
+
// word would redden on a formula or a query field.
|
|
160
|
+
// `expectPromptBuiltinsDeclared` asks the schema, and it also FAILS on a
|
|
161
|
+
// prompt naming no builtin at all — the state this template lands in when
|
|
162
|
+
// `system-prompt.md` was not applied, since the framework default names
|
|
163
|
+
// none. The converse is deliberately not asserted: declaring a builtin the
|
|
164
|
+
// prompt never mentions is an ordinary edit.
|
|
165
|
+
expect(expectPromptBuiltinsDeclared(agentDef)).toEqual(
|
|
166
|
+
expect.arrayContaining(["web_search", "run_code", "fetch_json"]),
|
|
167
|
+
);
|
|
168
|
+
});
|
|
69
169
|
});
|
|
70
170
|
|
|
71
171
|
describe("medication_lookup", () => {
|
|
72
172
|
test("folds the label's array fields into one flat answer", async () => {
|
|
73
173
|
label.mockResolvedValue(IBUPROFEN);
|
|
74
|
-
const result = await
|
|
174
|
+
const result = await lookUp({ name: "advil" });
|
|
75
175
|
expect(result).toMatchObject({
|
|
76
176
|
name: "IBUPROFEN",
|
|
77
177
|
brand_names: ["Advil"],
|
|
78
178
|
purpose: "Pain reliever",
|
|
79
179
|
manufacturer: "Acme",
|
|
80
180
|
});
|
|
181
|
+
// And the lookup carried the caller's `ctx.signal` down to openFDA — the
|
|
182
|
+
// `CallOptions` half. A tool that forgets it leaves a request running past
|
|
183
|
+
// the turn that wanted it, which nothing else here would notice.
|
|
184
|
+
expect(label.mock.calls[0]?.[1]?.signal).toBeInstanceOf(AbortSignal);
|
|
81
185
|
});
|
|
82
186
|
|
|
83
187
|
test("an unknown drug is a tool FAILURE, not an empty answer", async () => {
|
|
84
188
|
// The model has to be able to tell "no such drug" from "a drug with no
|
|
85
189
|
// warnings", which is why this is a failure rather than a record of "N/A".
|
|
86
190
|
label.mockResolvedValue(null);
|
|
87
|
-
const result = await
|
|
191
|
+
const result = await lookUp({ name: "sparkleforin" });
|
|
88
192
|
expect(isToolFailure(result) && result.error).toContain("sparkleforin");
|
|
89
193
|
});
|
|
90
194
|
|
|
91
195
|
test("a missing section reads N/A rather than undefined", async () => {
|
|
92
196
|
label.mockResolvedValue(WARFARIN);
|
|
93
|
-
expect(await
|
|
197
|
+
expect(await lookUp({ name: "warfarin" })).toMatchObject({
|
|
94
198
|
warnings: "N/A",
|
|
95
199
|
dosage: "N/A",
|
|
96
200
|
side_effects: "N/A",
|
|
@@ -104,10 +208,9 @@ describe("check_drug_interaction", () => {
|
|
|
104
208
|
label.mockImplementation(async (name: string) =>
|
|
105
209
|
name.includes("ibuprofen") ? IBUPROFEN : WARFARIN,
|
|
106
210
|
);
|
|
107
|
-
const result = await
|
|
108
|
-
expect(result).
|
|
109
|
-
|
|
110
|
-
expect(first).toMatchObject({ drug: "ibuprofen", mentions: "warfarin" });
|
|
211
|
+
const result = (await check({ drugs: ["ibuprofen", "warfarin"] })) as CheckResult;
|
|
212
|
+
expect(result.interactions_found).toBe(1);
|
|
213
|
+
expect(result.interactions[0]).toMatchObject({ drug: "ibuprofen", mentions: "warfarin" });
|
|
111
214
|
});
|
|
112
215
|
|
|
113
216
|
test("matches on a BRAND alias, not only the name the caller used", async () => {
|
|
@@ -120,7 +223,7 @@ describe("check_drug_interaction", () => {
|
|
|
120
223
|
label.mockImplementation(async (name: string) =>
|
|
121
224
|
name.includes("ibuprofen") ? coumadinMention : WARFARIN,
|
|
122
225
|
);
|
|
123
|
-
const result = await
|
|
226
|
+
const result = await check({ drugs: ["ibuprofen", "warfarin"] });
|
|
124
227
|
expect(result).toMatchObject({ interactions_found: 1 });
|
|
125
228
|
});
|
|
126
229
|
|
|
@@ -130,21 +233,37 @@ describe("check_drug_interaction", () => {
|
|
|
130
233
|
label.mockImplementation(async (name: string) =>
|
|
131
234
|
name.includes("ibuprofen") ? IBUPROFEN : null,
|
|
132
235
|
);
|
|
133
|
-
const result = await
|
|
236
|
+
const result = await check({ drugs: ["ibuprofen", "sparkleforin"] });
|
|
134
237
|
expect(isToolFailure(result) && result.error).toContain("sparkleforin");
|
|
135
238
|
});
|
|
136
239
|
|
|
137
240
|
test("two drugs with no cross-mention are reported as such, with the caveat", async () => {
|
|
138
241
|
label.mockResolvedValue(WARFARIN);
|
|
139
|
-
const result = await
|
|
140
|
-
expect(result).
|
|
141
|
-
|
|
242
|
+
const result = (await check({ drugs: ["warfarin", "aspirin"] })) as CheckResult;
|
|
243
|
+
expect(result.interactions_found).toBe(0);
|
|
244
|
+
// The caveat is the point of the zero case: "no cross-mention" is not
|
|
245
|
+
// "safe", and this tool must never be read as saying it was.
|
|
246
|
+
expect(result.note).toContain("does not guarantee");
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
test("every drug in the fan-out is looked up under the caller's signal", async () => {
|
|
250
|
+
// The reason `fetchFdaLabel` takes `CallOptions` at all: this tool fires one
|
|
251
|
+
// request per drug the caller named, so a hang-up mid-check has N of them
|
|
252
|
+
// to take down, not one.
|
|
253
|
+
label.mockResolvedValue(WARFARIN);
|
|
254
|
+
|
|
255
|
+
await check({ drugs: ["warfarin", "aspirin"] });
|
|
256
|
+
|
|
257
|
+
expect(label).toHaveBeenCalledTimes(2);
|
|
258
|
+
for (const [, options] of label.mock.calls) {
|
|
259
|
+
expect(options?.signal).toBeInstanceOf(AbortSignal);
|
|
260
|
+
}
|
|
142
261
|
});
|
|
143
262
|
|
|
144
263
|
test("whitespace-only names are refused before any lookup happens", async () => {
|
|
145
264
|
// The schema's `min(2)` counts entries, not real names, so the body
|
|
146
265
|
// re-checks after trimming — and must do so BEFORE touching the network.
|
|
147
|
-
const result = await
|
|
266
|
+
const result = await check({ drugs: ["ibuprofen", " "] });
|
|
148
267
|
expect(isToolFailure(result) && result.error).toContain("at least two");
|
|
149
268
|
expect(label).not.toHaveBeenCalled();
|
|
150
269
|
});
|