@alexkroman1/aai-cli 15.1.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 +12 -11
- package/dist/{dev-Bx9gYBHM.mjs → dev-kodAY23K.mjs} +7 -1
- package/dist/{eval-B3I7FqN9.mjs → eval-DvoSz7SZ.mjs} +1 -1
- package/dist/{init-CQbj3ycf.mjs → init-D363Ls5u.mjs} +2 -2
- 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,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The meeting assistant — their `find_meeting_time`, which is a ReAct agent
|
|
3
|
+
* over one calendar tool, and is therefore a SUBAGENT here rather than a
|
|
4
|
+
* `ctx.generate`.
|
|
5
|
+
*
|
|
6
|
+
* Theirs builds `create_react_agent(llm, [get_events_for_days])` inside the
|
|
7
|
+
* node and hands it the thread; the agent looks days up until it can state the
|
|
8
|
+
* free slots, and its final message goes back to `draft_response` as a tool
|
|
9
|
+
* result. That is exactly what `ctx.delegate` is: a tool loop with its own
|
|
10
|
+
* context window, whose FINAL message is all the caller sees. The calendar
|
|
11
|
+
* lookups stay inside the run, so a week of events never lands in the phone
|
|
12
|
+
* call's own context.
|
|
13
|
+
*
|
|
14
|
+
* `expectedOutput` carries the "extremely high density" rule their prompt ends
|
|
15
|
+
* on, so it lands in the same place every time rather than at the bottom of the
|
|
16
|
+
* brief where a model may or may not still be reading. What `expectedOutput`
|
|
17
|
+
* cannot do is REFUSE an answer that ignored it, which is what
|
|
18
|
+
* {@link statesAvailability} is for.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import {
|
|
22
|
+
DEFAULT_GUARDRAIL_MAX_RETRIES,
|
|
23
|
+
type DelegateFn,
|
|
24
|
+
type GuardrailVerdict,
|
|
25
|
+
isoDate,
|
|
26
|
+
spokenDate,
|
|
27
|
+
subagent,
|
|
28
|
+
tool,
|
|
29
|
+
} from "@alexkroman1/aai";
|
|
30
|
+
import { z } from "zod";
|
|
31
|
+
import { CALENDAR, type CalendarEvent, EXECUTIVE, TODAY } from "./inbox.ts";
|
|
32
|
+
import { MEETING_EXPECTED_OUTPUT, meetingSystem } from "./prompts.ts";
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Their `get_events_for_days` over the frozen calendar. A subagent's tool, not
|
|
36
|
+
* one of the agent's: it lives here rather than in `tools/`, so the executive's
|
|
37
|
+
* own model never sees it — asking the meeting assistant is the only way in.
|
|
38
|
+
*
|
|
39
|
+
* The day is named twice, as the date and as `spokenDate` renders it, because
|
|
40
|
+
* the weekday is the half a model reasons about ("next Tuesday") and the half
|
|
41
|
+
* it gets wrong. That rendering is fixed ASCII: the `toLocaleDateString` this
|
|
42
|
+
* replaced answered to the host's ICU build, so the same lookup could name a
|
|
43
|
+
* different weekday inside the guest sandbox than on the author's laptop, with
|
|
44
|
+
* no spec able to see it.
|
|
45
|
+
*/
|
|
46
|
+
export const calendarTool = tool({
|
|
47
|
+
description:
|
|
48
|
+
"The executive's calendar for the given days. Returns each day's booked events with " +
|
|
49
|
+
"start and end times; anything not listed between 9am and 5pm is free.",
|
|
50
|
+
inputSchema: z.object({
|
|
51
|
+
days: z.array(isoDate("a day to look up")).min(1).max(10).describe("Dates to look up"),
|
|
52
|
+
}),
|
|
53
|
+
execute({ days }) {
|
|
54
|
+
return {
|
|
55
|
+
timezone: EXECUTIVE.timezone,
|
|
56
|
+
days: days.map((date) => ({
|
|
57
|
+
date,
|
|
58
|
+
day: spokenDate(date),
|
|
59
|
+
events: CALENDAR.filter((event) => event.date === date).map(
|
|
60
|
+
(event) => `${event.start}-${event.end} ${event.title}`,
|
|
61
|
+
),
|
|
62
|
+
})),
|
|
63
|
+
};
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* What the calendar already holds in that window, if anything.
|
|
69
|
+
*
|
|
70
|
+
* A zero-padded `HH:MM` compares as a string, which is why an invite takes a
|
|
71
|
+
* `clockTime()` for each end rather than one ISO datetime — and why
|
|
72
|
+
* `calendar.test.ts` holds {@link CALENDAR}'s own times to the same shape: a
|
|
73
|
+
* `9:00` in the fixture would sort before every event rather than after eight
|
|
74
|
+
* of them, and the clash it hid would be a double-booked executive.
|
|
75
|
+
*/
|
|
76
|
+
export function clashOn(date: string, start: string, end: string): CalendarEvent | undefined {
|
|
77
|
+
return CALENDAR.find((event) => event.date === date && start < event.end && event.start < end);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** A time the desk could actually offer back — "1pm-3pm", "10:30am". */
|
|
81
|
+
const NAMES_A_TIME = /\b\d{1,2}(:\d{2})?\s?[ap]m\b/i;
|
|
82
|
+
|
|
83
|
+
/** Nothing open, said plainly — the other answer `draft_reply` can act on. */
|
|
84
|
+
const NAMES_NO_TIME = /\bnot\s+(free|available)\b|\bno\s+(free|open|available)\b/i;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Their prompt asks for slots; what `draft_reply` needs is a slot it can OFFER.
|
|
88
|
+
*
|
|
89
|
+
* A report that says the calendar was checked and stops reads as availability
|
|
90
|
+
* to the desk and offers the sender nothing — and `expectedOutput` can ask for
|
|
91
|
+
* a dense sentence but cannot refuse one that is not. So the run is JUDGED, as
|
|
92
|
+
* `briefing-desk`'s fact checker is, and the complaint names the fix rather
|
|
93
|
+
* than restating the rule. A verdict the run never satisfies is not an error:
|
|
94
|
+
* there IS an answer, and {@link findMeetingTime} passes it on marked unusable.
|
|
95
|
+
*/
|
|
96
|
+
export function statesAvailability(text: string): GuardrailVerdict {
|
|
97
|
+
if (NAMES_A_TIME.test(text) || NAMES_NO_TIME.test(text)) return true;
|
|
98
|
+
return (
|
|
99
|
+
"State the answer as clock times — 'free Wednesday 1pm-3pm' — or say plainly that there " +
|
|
100
|
+
"is nothing open. A report with no time in it cannot be offered to the sender."
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** Steps the assistant may take: two weeks of lookups and an answer. */
|
|
105
|
+
export const MAX_MEETING_STEPS = 4;
|
|
106
|
+
|
|
107
|
+
export const meetingAssistant = subagent({
|
|
108
|
+
name: "meeting-assistant",
|
|
109
|
+
systemPrompt: meetingSystem(EXECUTIVE, `${spokenDate(TODAY)} (${TODAY})`),
|
|
110
|
+
expectedOutput: MEETING_EXPECTED_OUTPUT,
|
|
111
|
+
tools: { get_events_for_days: calendarTool },
|
|
112
|
+
maxSteps: MAX_MEETING_STEPS,
|
|
113
|
+
guardrail: (answer) => statesAvailability(answer.text),
|
|
114
|
+
// Stated rather than left to the default, because the guardrail is what makes
|
|
115
|
+
// a retry possible and a retry is another whole run: the executive is on the
|
|
116
|
+
// phone, and what they wait through is `MAX_MEETING_STEPS` lookups twice over.
|
|
117
|
+
maxRetries: DEFAULT_GUARDRAIL_MAX_RETRIES,
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Their `find_meeting_time`: hand the thread to the specialist and return what
|
|
122
|
+
* it concluded, plus what the wait cost — the sentence the caller was owed
|
|
123
|
+
* while the line was quiet.
|
|
124
|
+
*
|
|
125
|
+
* `usable` is the guardrail's verdict, not an error. The desk is mid-call with
|
|
126
|
+
* a sender waiting on an answer, so an unaccepted report is still read — with
|
|
127
|
+
* the tool telling the model that it may not turn it into an offer.
|
|
128
|
+
*/
|
|
129
|
+
export async function findMeetingTime(
|
|
130
|
+
delegate: DelegateFn,
|
|
131
|
+
thread: string,
|
|
132
|
+
request: string,
|
|
133
|
+
): Promise<{ availability: string; lookups: number; usable: boolean }> {
|
|
134
|
+
const run = await delegate(meetingAssistant, {
|
|
135
|
+
task: `${request}\n\nHere is the email thread:\n\n${thread}`,
|
|
136
|
+
});
|
|
137
|
+
return { availability: run.text, lookups: run.toolCalls.length, usable: run.accepted };
|
|
138
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The nodes that call a MODEL, one function each: their `triage_input`,
|
|
3
|
+
* `rewrite`, `determine_what_to_update` and `update_general`.
|
|
4
|
+
*
|
|
5
|
+
* Every function here is a plain async function of a `GenerateFn` and its
|
|
6
|
+
* arguments, so a spec drives one directly and the tools hold no prompt text.
|
|
7
|
+
* Each passes a distinct `system` — {@link TRIAGE_SYSTEM} and friends — which is
|
|
8
|
+
* what lets `stubGenerate` script the roles apart inside one tool call.
|
|
9
|
+
*
|
|
10
|
+
* What is NOT here is their `draft_response` node: that model is the voice
|
|
11
|
+
* agent itself, and its tool calls are the drafts (see `prompts.ts`). And their
|
|
12
|
+
* `find_meeting_time` is a subagent rather than a generate — `meeting.ts`.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import type { GenerateFn } from "@alexkroman1/aai";
|
|
16
|
+
import type { Memory } from "./inbox.ts";
|
|
17
|
+
import {
|
|
18
|
+
CHOOSE_MEMORY_SYSTEM,
|
|
19
|
+
chooseMemoryPrompt,
|
|
20
|
+
type Executive,
|
|
21
|
+
formatExamples,
|
|
22
|
+
generalResponse,
|
|
23
|
+
MEMORY,
|
|
24
|
+
type MemoryType,
|
|
25
|
+
memoryToUpdate,
|
|
26
|
+
REWRITE_SYSTEM,
|
|
27
|
+
respondTo,
|
|
28
|
+
reWriteEmail,
|
|
29
|
+
rewritePrompt,
|
|
30
|
+
TRIAGE_SYSTEM,
|
|
31
|
+
type TriageExample,
|
|
32
|
+
type TriageVerdict,
|
|
33
|
+
triagePrompt,
|
|
34
|
+
UPDATE_MEMORY_SYSTEM,
|
|
35
|
+
updateMemoryPrompt,
|
|
36
|
+
} from "./prompts.ts";
|
|
37
|
+
import type { AssistantState, Reflection } from "./shared.ts";
|
|
38
|
+
|
|
39
|
+
/** Their `triage_input`, with the few-shot examples already chosen. */
|
|
40
|
+
export async function triageEmail(
|
|
41
|
+
generate: GenerateFn,
|
|
42
|
+
exec: Executive,
|
|
43
|
+
email: { from: string; to: string; subject: string; body: string },
|
|
44
|
+
examples: readonly TriageExample[],
|
|
45
|
+
): Promise<TriageVerdict> {
|
|
46
|
+
const { object } = await generate({
|
|
47
|
+
system: TRIAGE_SYSTEM,
|
|
48
|
+
prompt: triagePrompt(exec, email, formatExamples(examples)),
|
|
49
|
+
schema: respondTo,
|
|
50
|
+
temperature: 0,
|
|
51
|
+
});
|
|
52
|
+
return object;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Their `rewrite` node: the same facts in the executive's voice.
|
|
57
|
+
*
|
|
58
|
+
* Takes the tone instructions rather than the memory, so the caller decides
|
|
59
|
+
* which prompt is current — which is the whole point of a memory that changes.
|
|
60
|
+
*/
|
|
61
|
+
export async function rewriteDraft(
|
|
62
|
+
generate: GenerateFn,
|
|
63
|
+
exec: Executive,
|
|
64
|
+
instructions: string,
|
|
65
|
+
draft: string,
|
|
66
|
+
thread: string,
|
|
67
|
+
): Promise<{ toneLogic: string; rewrittenContent: string }> {
|
|
68
|
+
const { object } = await generate({
|
|
69
|
+
system: REWRITE_SYSTEM,
|
|
70
|
+
prompt: rewritePrompt(exec, instructions, draft, thread),
|
|
71
|
+
schema: reWriteEmail,
|
|
72
|
+
temperature: 0,
|
|
73
|
+
});
|
|
74
|
+
return object;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** One prompt the reflection decided to rewrite — their `store.aput`, staged. */
|
|
78
|
+
export interface MemoryUpdate {
|
|
79
|
+
type: MemoryType;
|
|
80
|
+
memory: keyof Memory;
|
|
81
|
+
logic: string;
|
|
82
|
+
newPrompt: string;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Their `multi_reflection_graph`: decide which prompts the feedback touches,
|
|
87
|
+
* then rewrite each one — in parallel, as their `Send` fan-out runs them.
|
|
88
|
+
*
|
|
89
|
+
* Pure of the slot: it READS the current memory and returns the updates, and
|
|
90
|
+
* {@link applyReflection} writes them inside a synchronous window. Their
|
|
91
|
+
* `update_general` picks a reasoning model for this; here it runs on the agent's
|
|
92
|
+
* own `llm`, which a template may not assume a second key for.
|
|
93
|
+
*/
|
|
94
|
+
export async function reflect(
|
|
95
|
+
generate: GenerateFn,
|
|
96
|
+
input: {
|
|
97
|
+
memory: Memory;
|
|
98
|
+
trajectory: string;
|
|
99
|
+
feedback: string;
|
|
100
|
+
/** Their `prompt_types` — which memories THIS kind of feedback may touch. */
|
|
101
|
+
promptTypes: readonly MemoryType[];
|
|
102
|
+
},
|
|
103
|
+
): Promise<MemoryUpdate[]> {
|
|
104
|
+
const chosen = await generate({
|
|
105
|
+
system: CHOOSE_MEMORY_SYSTEM,
|
|
106
|
+
prompt: chooseMemoryPrompt(input.trajectory, input.feedback, input.promptTypes),
|
|
107
|
+
schema: memoryToUpdate,
|
|
108
|
+
temperature: 0,
|
|
109
|
+
});
|
|
110
|
+
// The chooser is offered only the allowed types, and is held to them: a model
|
|
111
|
+
// that names `tone` when told about a calendar preference rewrites nothing.
|
|
112
|
+
const types = [...new Set(chosen.object.memoryTypesToUpdate)].filter((t) =>
|
|
113
|
+
input.promptTypes.includes(t),
|
|
114
|
+
);
|
|
115
|
+
const rewritten = await Promise.all(
|
|
116
|
+
types.map(async (type) => {
|
|
117
|
+
const { key, instructions } = MEMORY[type];
|
|
118
|
+
const { object } = await generate({
|
|
119
|
+
system: UPDATE_MEMORY_SYSTEM,
|
|
120
|
+
prompt: updateMemoryPrompt(
|
|
121
|
+
input.memory[key],
|
|
122
|
+
input.trajectory,
|
|
123
|
+
input.feedback,
|
|
124
|
+
instructions,
|
|
125
|
+
),
|
|
126
|
+
schema: generalResponse,
|
|
127
|
+
temperature: 0,
|
|
128
|
+
});
|
|
129
|
+
return object.updatePrompt && object.newPrompt.trim() !== ""
|
|
130
|
+
? { type, memory: key, logic: object.logic, newPrompt: object.newPrompt }
|
|
131
|
+
: undefined;
|
|
132
|
+
}),
|
|
133
|
+
);
|
|
134
|
+
return rewritten.filter((update) => update !== undefined);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/** Write what the reflection decided, and remember that it did. */
|
|
138
|
+
export function applyReflection(state: AssistantState, updates: readonly MemoryUpdate[]): void {
|
|
139
|
+
for (const update of updates) {
|
|
140
|
+
state.memory[update.memory] = update.newPrompt;
|
|
141
|
+
const reflection: Reflection = { memory: update.memory, logic: update.logic };
|
|
142
|
+
state.reflections.push(reflection);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** What the assistant may SAY about a reflection — one clause per memory touched. */
|
|
147
|
+
export function describeUpdates(updates: readonly MemoryUpdate[]): string {
|
|
148
|
+
if (updates.length === 0) return "Nothing new to remember from that.";
|
|
149
|
+
return `Noted — updated ${updates.map((u) => u.type).join(" and ")} preferences: ${updates
|
|
150
|
+
.map((u) => u.logic)
|
|
151
|
+
.join(" ")}`;
|
|
152
|
+
}
|
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every prompt the assistant's MODELS read, and where each one comes from.
|
|
3
|
+
*
|
|
4
|
+
* **Adapted from LangChain's Executive AI Assistant** (MIT,
|
|
5
|
+
* <https://github.com/langchain-ai/executive-ai-assistant>) — EAIA, the email
|
|
6
|
+
* assistant that triages an inbox, drafts replies in its principal's voice,
|
|
7
|
+
* halts on a human decision through the Agent Inbox, and rewrites its own
|
|
8
|
+
* prompts from the corrections it gets. It is two LangGraph graphs and a cron,
|
|
9
|
+
* and this file is the prompts of both, compressed for a phone:
|
|
10
|
+
*
|
|
11
|
+
* | EAIA | here |
|
|
12
|
+
* | --- | --- |
|
|
13
|
+
* | `triage.py` — `triage_prompt` + `RespondTo` | {@link triagePrompt} + {@link respondTo} |
|
|
14
|
+
* | `fewshot.py` — similar triage examples from the store | {@link formatExamples}, over the session's own examples |
|
|
15
|
+
* | `draft_response.py` — `EMAIL_WRITING_INSTRUCTIONS` | {@link draftingBrief}, the RESULT of `open_email` |
|
|
16
|
+
* | `rewrite.py` — `rewrite_prompt` + `ReWriteEmail` | {@link rewritePrompt} + {@link reWriteEmail} |
|
|
17
|
+
* | `find_meeting_time.py` — `meeting_prompts` | {@link meetingSystem}, a subagent's prompt |
|
|
18
|
+
* | `reflection_graphs.py` — `CHOOSE_MEMORY_PROMPT`, `general_reflection_prompt` | {@link chooseMemoryPrompt}, {@link updateMemoryPrompt} |
|
|
19
|
+
* | `reflection_graphs.py` — `MEMORY_TO_UPDATE*` | {@link MEMORY} |
|
|
20
|
+
*
|
|
21
|
+
* **Their drafting model's TOOLS became this agent's tools**, which is the one
|
|
22
|
+
* move that decides the whole port. `draft_response` binds `ResponseEmailDraft`,
|
|
23
|
+
* `NewEmailDraft`, `Question`, `MeetingAssistant`, `SendCalendarInvite` and
|
|
24
|
+
* `Ignore` to a model with `tool_choice="required"`, and the tool call's
|
|
25
|
+
* ARGUMENTS are the draft. A voice session already has a model choosing tools
|
|
26
|
+
* every turn, so those six are `tools/` here — `draft_reply`, `new_email`,
|
|
27
|
+
* `ask_question`, `meeting_assistant`, `send_calendar_invite`, `ignore` — and
|
|
28
|
+
* `EMAIL_WRITING_INSTRUCTIONS` reaches it as the brief `open_email` hands back,
|
|
29
|
+
* with the four memory prompts interpolated the way their store lookups do.
|
|
30
|
+
*
|
|
31
|
+
* **Each model role has its own `system` constant**, and that is a testing
|
|
32
|
+
* decision as much as a prompting one: `stubGenerate` routes by system prompt,
|
|
33
|
+
* so a spec can script the triage and the rewriter differently in one tool call
|
|
34
|
+
* and fail NAMING the role when a tool reaches a model the script did not expect.
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
import { z } from "zod";
|
|
38
|
+
import type { EXECUTIVE, Memory } from "./inbox.ts";
|
|
39
|
+
|
|
40
|
+
/** The principal, as every prompt names them. */
|
|
41
|
+
export type Executive = typeof EXECUTIVE;
|
|
42
|
+
|
|
43
|
+
/** Their `email_template` — a thread as every prompt here quotes it. */
|
|
44
|
+
export function threadText(email: {
|
|
45
|
+
from: string;
|
|
46
|
+
to: string;
|
|
47
|
+
subject: string;
|
|
48
|
+
body: string;
|
|
49
|
+
}): string {
|
|
50
|
+
return `From: ${email.from}\nTo: ${email.to}\nSubject: ${email.subject}\n\n${email.body}`;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// ─── Triage ──────────────────────────────────────────────────────────────────
|
|
54
|
+
|
|
55
|
+
/** Their `RespondTo`. `question` routes exactly as `email` does, as their graph has it. */
|
|
56
|
+
export const respondTo = z.object({
|
|
57
|
+
logic: z.string().max(400).describe("Logic on WHY the response choice is the way it is"),
|
|
58
|
+
response: z.enum(["no", "email", "notify", "question"]),
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
export type TriageVerdict = z.infer<typeof respondTo>;
|
|
62
|
+
|
|
63
|
+
export const TRIAGE_SYSTEM = "You triage an executive's inbox.";
|
|
64
|
+
|
|
65
|
+
/** One remembered verdict, as their `triage_examples` namespace stores it. */
|
|
66
|
+
export interface TriageExample {
|
|
67
|
+
emailId: string;
|
|
68
|
+
subject: string;
|
|
69
|
+
from: string;
|
|
70
|
+
excerpt: string;
|
|
71
|
+
result: "email" | "no";
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** Their `fewshot.py` template, over the examples {@link similarExamples} picked. */
|
|
75
|
+
export function formatExamples(examples: readonly TriageExample[]): string {
|
|
76
|
+
if (examples.length === 0) return "";
|
|
77
|
+
const rendered = examples.map(
|
|
78
|
+
(eg) =>
|
|
79
|
+
`Email Subject: ${eg.subject}\nEmail From: ${eg.from}\nEmail Content:\n` +
|
|
80
|
+
`\`\`\`\n${eg.excerpt}\n\`\`\`\n> Triage Result: ${eg.result}`,
|
|
81
|
+
);
|
|
82
|
+
return ["Here are some previous examples:", ...rendered].join("\n\n------------\n\n");
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const bullets = (lines: readonly string[]): string => lines.map((line) => `- ${line}`).join("\n");
|
|
86
|
+
|
|
87
|
+
/** Their `triage_prompt`, with the config and the examples filled in. */
|
|
88
|
+
export function triagePrompt(
|
|
89
|
+
exec: Executive,
|
|
90
|
+
email: { from: string; to: string; subject: string; body: string },
|
|
91
|
+
examples: string,
|
|
92
|
+
): string {
|
|
93
|
+
return [
|
|
94
|
+
`You are ${exec.fullName}'s executive assistant. You are a top-notch executive assistant who cares about ${exec.name} performing as well as possible.`,
|
|
95
|
+
"",
|
|
96
|
+
`${exec.background}`,
|
|
97
|
+
"",
|
|
98
|
+
`${exec.name} gets lots of emails. Your job is to categorize the below email to see whether it is worth responding to.`,
|
|
99
|
+
"",
|
|
100
|
+
"Emails that are not worth responding to:",
|
|
101
|
+
bullets(exec.triageNo),
|
|
102
|
+
"",
|
|
103
|
+
"Emails that are worth responding to:",
|
|
104
|
+
bullets(exec.triageEmail),
|
|
105
|
+
"",
|
|
106
|
+
`There are also other things that ${exec.name} should know about, but don't require an email response. For these, you should notify ${exec.name} (using the \`notify\` response). Examples of this include:`,
|
|
107
|
+
bullets(exec.triageNotify),
|
|
108
|
+
"",
|
|
109
|
+
`For emails not worth responding to, respond \`no\`. For something where ${exec.name} should respond over email, respond \`email\`. If it's important to notify ${exec.name}, but no email is required, respond \`notify\`.`,
|
|
110
|
+
"",
|
|
111
|
+
`If unsure, opt to \`notify\` ${exec.name} — you will learn from this in the future.`,
|
|
112
|
+
"",
|
|
113
|
+
examples,
|
|
114
|
+
"",
|
|
115
|
+
"Please determine how to handle the below email thread:",
|
|
116
|
+
"",
|
|
117
|
+
threadText(email),
|
|
118
|
+
].join("\n");
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// ─── Drafting ────────────────────────────────────────────────────────────────
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Their `EMAIL_WRITING_INSTRUCTIONS`, as the brief `open_email` returns.
|
|
125
|
+
*
|
|
126
|
+
* Compressed to fit: a tool result is capped at 4000 characters and the thread
|
|
127
|
+
* rides in the same result, so this keeps every RULE of theirs (no placeholders,
|
|
128
|
+
* never agree to a meeting unasked, never invent an address, ask the meeting
|
|
129
|
+
* assistant rather than the principal for free time) and drops the repetition a
|
|
130
|
+
* chat model needed. The four memory prompts are interpolated exactly where
|
|
131
|
+
* theirs are, which is what makes a reflection change the next draft.
|
|
132
|
+
*/
|
|
133
|
+
export function draftingBrief(exec: Executive, memory: Memory): string {
|
|
134
|
+
const optional = (label: string, text: string) =>
|
|
135
|
+
text.trim() === "" ? [] : [`${label}: ${text.trim()}`];
|
|
136
|
+
return [
|
|
137
|
+
`You are ${exec.fullName}'s executive assistant, helping ${exec.name} respond to this email. ${exec.background}`,
|
|
138
|
+
"Choose ONE tool:",
|
|
139
|
+
`ask_question — when you lack information only ${exec.name} has. Never draft with a placeholder for a name, an email or a fact; ask instead. Never ask ${exec.name} when they are free — that is meeting_assistant's job.`,
|
|
140
|
+
`draft_reply — when you have enough to respond. Write as ${exec.name}, never as an assistant. Add a new recipient only when ${exec.name} asked for it and you know the address; never invent one.`,
|
|
141
|
+
`meeting_assistant — when a legitimate sender is trying to schedule a meeting. It reads ${exec.name}'s calendar and answers with the free slots. Not for a meeting already booked.`,
|
|
142
|
+
`send_calendar_invite — only once you are sure ${exec.name} wants the meeting and the calendar is free. Pick the time yourself.`,
|
|
143
|
+
`new_email — to start a new thread, such as an introduction ${exec.name} agreed to make.`,
|
|
144
|
+
`ignore — only when ${exec.name} has said to skip this one.`,
|
|
145
|
+
`Never agree to attend or meet unless ${exec.name} has explicitly okayed it. Never make things up.`,
|
|
146
|
+
...optional("Response preferences", memory.responsePreferences),
|
|
147
|
+
...optional("Scheduling preferences", memory.schedulePreferences),
|
|
148
|
+
...optional("Background", memory.backgroundPreferences),
|
|
149
|
+
].join("\n");
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// ─── Rewrite ─────────────────────────────────────────────────────────────────
|
|
153
|
+
|
|
154
|
+
/** Their `ReWriteEmail`. */
|
|
155
|
+
export const reWriteEmail = z.object({
|
|
156
|
+
toneLogic: z
|
|
157
|
+
.string()
|
|
158
|
+
.max(300)
|
|
159
|
+
.describe("Logic for what the tone of the rewritten email should be"),
|
|
160
|
+
rewrittenContent: z.string().max(4000).describe("Content rewritten with the new tone"),
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
export const REWRITE_SYSTEM = "You rewrite an email draft in its author's own voice.";
|
|
164
|
+
|
|
165
|
+
/** Their `rewrite_prompt`. */
|
|
166
|
+
export function rewritePrompt(
|
|
167
|
+
exec: Executive,
|
|
168
|
+
instructions: string,
|
|
169
|
+
draft: string,
|
|
170
|
+
thread: string,
|
|
171
|
+
): string {
|
|
172
|
+
return [
|
|
173
|
+
`Your job is to rewrite an email draft to sound more like ${exec.name}.`,
|
|
174
|
+
"",
|
|
175
|
+
`${exec.name}'s assistant just drafted an email. It is factually correct, but it may not sound like ${exec.name}. Your job is to rewrite the email keeping the information the same (do not add anything that is made up!) but adjusting the tone.`,
|
|
176
|
+
"",
|
|
177
|
+
instructions,
|
|
178
|
+
"",
|
|
179
|
+
"Here is the assistant's current draft:",
|
|
180
|
+
"",
|
|
181
|
+
`<draft>\n${draft}\n</draft>`,
|
|
182
|
+
"",
|
|
183
|
+
"Here is the email thread:",
|
|
184
|
+
"",
|
|
185
|
+
thread,
|
|
186
|
+
].join("\n");
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// ─── The meeting assistant ───────────────────────────────────────────────────
|
|
190
|
+
|
|
191
|
+
/** Their `meeting_prompts`, minus the thread — that arrives as the subagent's task. */
|
|
192
|
+
export function meetingSystem(exec: Executive, today: string): string {
|
|
193
|
+
return [
|
|
194
|
+
`You are ${exec.fullName}'s executive assistant. The email thread you are given has been flagged as requesting time to meet. Your SOLE purpose is to survey ${exec.name}'s calendar and find times for ${exec.name}.`,
|
|
195
|
+
`If the email suggests specific times, check whether ${exec.name} is available then. If it asks for time, use get_events_for_days to find valid times (always in ${exec.timezone}). Abide by any preferences the sender expressed, and never suggest a time they said would not work.`,
|
|
196
|
+
"Send available spots in as big a chunk as possible: '1pm-3pm', never four half-hour slots. Do not send slots shorter than 15 minutes.",
|
|
197
|
+
`Today is ${today}. Working hours are 9am to 5pm. Look up every day you mention before you mention it.`,
|
|
198
|
+
].join("\n");
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export const MEETING_EXPECTED_OUTPUT =
|
|
202
|
+
"One or two extremely dense sentences stating factually whether they are free and which " +
|
|
203
|
+
"slots are open, e.g. 'Maya is not free Tuesday afternoon, but is free Wednesday 1pm-3pm.' " +
|
|
204
|
+
"No greeting, no commentary, no reply to the email itself.";
|
|
205
|
+
|
|
206
|
+
// ─── Reflection ──────────────────────────────────────────────────────────────
|
|
207
|
+
|
|
208
|
+
/** Their `MEMORY_TO_UPDATE` keys — the four things a correction may teach. */
|
|
209
|
+
export const MEMORY_TYPES = ["tone", "email", "calendar", "background"] as const;
|
|
210
|
+
export type MemoryType = (typeof MEMORY_TYPES)[number];
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Their three parallel tables (`MEMORY_TO_UPDATE`, `MEMORY_TO_UPDATE_KEYS`,
|
|
214
|
+
* `MEMORY_TO_UPDATE_INSTRUCTIONS`) as one, so a type cannot be described in one
|
|
215
|
+
* and keyed to nothing in another.
|
|
216
|
+
*/
|
|
217
|
+
export const MEMORY: Record<
|
|
218
|
+
MemoryType,
|
|
219
|
+
{ key: keyof Memory; description: string; instructions: string }
|
|
220
|
+
> = {
|
|
221
|
+
tone: {
|
|
222
|
+
key: "rewriteInstructions",
|
|
223
|
+
description:
|
|
224
|
+
"Instruction about the tone and style and format of the resulting email. Update this if you learn new information about the tone in which the user likes to respond that may be relevant in future emails.",
|
|
225
|
+
instructions:
|
|
226
|
+
"Only update the prompt to include instructions on the **style and tone and format** of the response. Do NOT update the prompt to include anything about the actual content - only the style and tone and format. The user sometimes responds differently to different types of people - take that into account, but don't be too specific.",
|
|
227
|
+
},
|
|
228
|
+
email: {
|
|
229
|
+
key: "responsePreferences",
|
|
230
|
+
description:
|
|
231
|
+
"Instructions about the type of content to be included in email. Update this if you learn new information about how the user likes to respond to emails (not the tone, and not information about the user, but specifically about how or when they like to respond to emails) that may be relevant in the future.",
|
|
232
|
+
instructions:
|
|
233
|
+
"Only update the prompt to include instructions on the **content** of the response. Do NOT update the prompt to include anything about the tone or style or format of the response.",
|
|
234
|
+
},
|
|
235
|
+
calendar: {
|
|
236
|
+
key: "schedulePreferences",
|
|
237
|
+
description:
|
|
238
|
+
"Instructions about how to send calendar invites (including title, length, time, etc). Update this if you learn new information about how the user likes to schedule events that may be relevant in future emails.",
|
|
239
|
+
instructions:
|
|
240
|
+
"Only update the prompt to include instructions on how to send calendar invites - eg when to send them, what title should be, length, time of day, etc",
|
|
241
|
+
},
|
|
242
|
+
background: {
|
|
243
|
+
key: "backgroundPreferences",
|
|
244
|
+
description:
|
|
245
|
+
"Background information about the user. Update this if you learn new information about the user that may be relevant in future emails",
|
|
246
|
+
instructions:
|
|
247
|
+
"Only update the prompt to include pieces of information that are relevant to being the user's assistant. Do not update the instructions to include anything about the tone of emails sent, when to send calendar invites. Examples of good things to include are (but are not limited to): people's emails, addresses, etc.",
|
|
248
|
+
},
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
export const CHOOSE_MEMORY_SYSTEM =
|
|
252
|
+
"You decide which of an assistant's prompts a correction should change.";
|
|
253
|
+
|
|
254
|
+
/** Their `determine_what_to_update` output. */
|
|
255
|
+
export const memoryToUpdate = z.object({
|
|
256
|
+
memoryTypesToUpdate: z.array(z.enum(MEMORY_TYPES)),
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
/** Their `CHOOSE_MEMORY_PROMPT`. */
|
|
260
|
+
export function chooseMemoryPrompt(
|
|
261
|
+
trajectory: string,
|
|
262
|
+
feedback: string,
|
|
263
|
+
types: readonly MemoryType[],
|
|
264
|
+
): string {
|
|
265
|
+
const typesOfPrompts = types.map((t) => `\`${t}\`: ${MEMORY[t].description}`).join("\n");
|
|
266
|
+
return [
|
|
267
|
+
"You are helping an AI agent improve. You can do this by changing prompts.",
|
|
268
|
+
"",
|
|
269
|
+
"Here was the agent's trajectory:",
|
|
270
|
+
`<trajectory>\n${trajectory}\n</trajectory>`,
|
|
271
|
+
"",
|
|
272
|
+
"Here is the user's feedback:",
|
|
273
|
+
"",
|
|
274
|
+
`<feedback>\n${feedback}\n</feedback>`,
|
|
275
|
+
"",
|
|
276
|
+
"These are the different types of prompts that you can update in order to change their behavior:",
|
|
277
|
+
"",
|
|
278
|
+
`<types_of_prompts>\n${typesOfPrompts}\n</types_of_prompts>`,
|
|
279
|
+
"",
|
|
280
|
+
"Please choose the types of prompts that are worth updating based on this trajectory + feedback. Only do this if the feedback seems like it has info relevant to the prompt. You will update the prompts themselves in a separate step. You do not have to update any memory types if you don't want to! Just leave it empty.",
|
|
281
|
+
].join("\n");
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
export const UPDATE_MEMORY_SYSTEM = "You rewrite one of an assistant's prompts from feedback.";
|
|
285
|
+
|
|
286
|
+
/** Their `GeneralResponse`. */
|
|
287
|
+
export const generalResponse = z.object({
|
|
288
|
+
logic: z.string().max(400),
|
|
289
|
+
updatePrompt: z.boolean(),
|
|
290
|
+
newPrompt: z.string().max(4000),
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
/** Their `general_reflection_prompt`. */
|
|
294
|
+
export function updateMemoryPrompt(
|
|
295
|
+
currentPrompt: string,
|
|
296
|
+
trajectory: string,
|
|
297
|
+
feedback: string,
|
|
298
|
+
instructions: string,
|
|
299
|
+
): string {
|
|
300
|
+
return [
|
|
301
|
+
"You are helping an AI agent improve. You can do this by changing their system prompt.",
|
|
302
|
+
"",
|
|
303
|
+
"This is their current prompt:",
|
|
304
|
+
`<current_prompt>\n${currentPrompt}\n</current_prompt>`,
|
|
305
|
+
"",
|
|
306
|
+
"Here was the agent's trajectory:",
|
|
307
|
+
`<trajectory>\n${trajectory}\n</trajectory>`,
|
|
308
|
+
"",
|
|
309
|
+
"Here is the user's feedback:",
|
|
310
|
+
"",
|
|
311
|
+
`<feedback>\n${feedback}\n</feedback>`,
|
|
312
|
+
"",
|
|
313
|
+
"Here are instructions for updating the agent's prompt:",
|
|
314
|
+
"",
|
|
315
|
+
`<instructions>\n${instructions}\n</instructions>`,
|
|
316
|
+
"",
|
|
317
|
+
"Based on this, return an updated prompt.",
|
|
318
|
+
"",
|
|
319
|
+
"You should return the full prompt, so if there's anything from before that you want to include, make sure to do that. Feel free to override or change anything that seems irrelevant. You do not need to update the prompt - if you don't want to, just return `updatePrompt = false` and an empty string for the new prompt.",
|
|
320
|
+
].join("\n");
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
// ─── The voice agent's own prompt ────────────────────────────────────────────
|
|
324
|
+
|
|
325
|
+
/** Their `config.yaml` identity block, appended to `system-prompt.md` by `agent.ts`. */
|
|
326
|
+
export function principalBrief(exec: Executive): string {
|
|
327
|
+
return [
|
|
328
|
+
`You work for ${exec.fullName} — call them ${exec.name}. ${exec.background}`,
|
|
329
|
+
`Their timezone is ${exec.timezone}; every time you say is in it.`,
|
|
330
|
+
].join("\n");
|
|
331
|
+
}
|