@alexkroman1/aai-cli 15.1.0 → 16.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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
|
@@ -4,66 +4,100 @@ import type { ToolContext } from "@alexkroman1/aai";
|
|
|
4
4
|
import {
|
|
5
5
|
createToolContext,
|
|
6
6
|
expectDialogOk,
|
|
7
|
-
|
|
7
|
+
runGuardrail,
|
|
8
|
+
type ScriptedToolContext,
|
|
9
|
+
type StubDelegateRoute,
|
|
10
|
+
type StubGenerateRoute,
|
|
11
|
+
scriptedToolContext,
|
|
12
|
+
stubDelegate,
|
|
8
13
|
toolRunner,
|
|
9
14
|
} from "@alexkroman1/aai/testing";
|
|
10
|
-
import {
|
|
15
|
+
import { visitWebpage, webSearch } from "@alexkroman1/aai/tools";
|
|
16
|
+
import { describe, expect, test, vi } from "vitest";
|
|
11
17
|
|
|
12
|
-
import { executeStep,
|
|
13
|
-
import {
|
|
14
|
-
import
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
import { executeStep, executor, MAX_STEP_TURNS, normalizeAct, planNode } from "./procedure.ts";
|
|
19
|
+
import { PLANNER_SYSTEM, REPLANNER_SYSTEM, REVISE_SYSTEM, type StepAnswer } from "./prompts.ts";
|
|
20
|
+
import {
|
|
21
|
+
MAX_PAGE_CHARS,
|
|
22
|
+
MAX_PAST_STEPS,
|
|
23
|
+
MAX_REVISIONS,
|
|
24
|
+
planFlow,
|
|
25
|
+
planProjection,
|
|
26
|
+
planSlot,
|
|
27
|
+
planView,
|
|
28
|
+
readTool,
|
|
29
|
+
searchTool,
|
|
30
|
+
} from "./shared.ts";
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* The web, faked at the SDK's own seam.
|
|
34
|
+
*
|
|
35
|
+
* `webSearch` screens a URL and then really fetches it, through an undici
|
|
36
|
+
* dispatcher a `globalThis.fetch` stub cannot reach — so mocking the module is
|
|
37
|
+
* the only honest way to keep this suite offline. The EXECUTOR's own tests need
|
|
38
|
+
* none of it: they stub the delegation, which is the seam a subagent is reached
|
|
39
|
+
* through.
|
|
40
|
+
*/
|
|
41
|
+
vi.mock("@alexkroman1/aai/tools", () => ({ webSearch: vi.fn(), visitWebpage: vi.fn() }));
|
|
42
|
+
|
|
43
|
+
// ─── A scripted desk ─────────────────────────────────────────────────────────
|
|
18
44
|
//
|
|
19
|
-
//
|
|
20
|
-
// `
|
|
21
|
-
//
|
|
22
|
-
//
|
|
23
|
-
//
|
|
45
|
+
// TWO fakes, because the desk reaches a model two ways. The planner and the
|
|
46
|
+
// replanner are `ctx.generate` calls carrying their own system prompt, so the
|
|
47
|
+
// `generate` script — keyed by system prompt — drives them; the EXECUTOR is a
|
|
48
|
+
// subagent, so the `delegate` script drives it, routed by subagent name. That
|
|
49
|
+
// split is the conversion showing through in the test file, and it is the
|
|
50
|
+
// honest one: a spec that scripted the executor's turns was scripting a loop
|
|
51
|
+
// this template no longer owns. `scriptedToolContext` builds both fakes and
|
|
52
|
+
// the context they are wired into, so every test below starts from one call.
|
|
24
53
|
|
|
25
54
|
interface Script {
|
|
26
55
|
steps?: string[];
|
|
27
|
-
/** One entry per
|
|
28
|
-
|
|
56
|
+
/** One entry per executed step: what the executor concluded. */
|
|
57
|
+
answers?: (string | StepAnswer)[];
|
|
58
|
+
/** Searches to report on each executed step, as the run's tool calls. */
|
|
59
|
+
searches?: string[];
|
|
29
60
|
/** One entry per replan/revise call. */
|
|
30
61
|
acts?: { kind: "respond" | "plan"; response?: string; steps?: string[] }[];
|
|
31
62
|
}
|
|
32
63
|
|
|
33
|
-
|
|
34
|
-
|
|
64
|
+
/**
|
|
65
|
+
* One executor run's final message.
|
|
66
|
+
*
|
|
67
|
+
* The executor declares a `schema`, so its reply really is JSON on the wire and
|
|
68
|
+
* `stubDelegate` really parses it against that schema — a script that drifted
|
|
69
|
+
* from the shape fails HERE naming the subagent, rather than handing
|
|
70
|
+
* `executeStep` an `object` it never had. A bare string is the settled case,
|
|
71
|
+
* which is what most of these tests want to say.
|
|
72
|
+
*/
|
|
73
|
+
function stepReply(answer: string | StepAnswer): string {
|
|
74
|
+
return JSON.stringify(typeof answer === "string" ? { finding: answer, settled: true } : answer);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function scriptedDesk(script: Script = {}): ScriptedToolContext {
|
|
78
|
+
const answers = [...(script.answers ?? [])];
|
|
35
79
|
const acts = [...(script.acts ?? [])];
|
|
36
80
|
// The replanner and the reviser are the same node with a different brief, so
|
|
37
81
|
// they share one queue — which is what the "revise then carry on" test rests on.
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
},
|
|
48
|
-
[REPLANNER_SYSTEM]: act,
|
|
49
|
-
[REVISE_SYSTEM]: act,
|
|
82
|
+
// Annotated as the SDK's own route type: a route is a reply or a function of
|
|
83
|
+
// the call, and naming it is what keeps this queue honest about being the
|
|
84
|
+
// second form rather than a value computed once.
|
|
85
|
+
const act: StubGenerateRoute = () => ({
|
|
86
|
+
object: acts.shift() ?? { kind: "respond", response: "All done." },
|
|
87
|
+
});
|
|
88
|
+
const worksTheStep: StubDelegateRoute = () => ({
|
|
89
|
+
text: stepReply(answers.shift() ?? "Settled it."),
|
|
90
|
+
toolCalls: (script.searches ?? []).map((query) => ({ name: "search", input: { query } })),
|
|
50
91
|
});
|
|
51
|
-
}
|
|
52
92
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
queries.push(query);
|
|
62
|
-
const found = hits[query];
|
|
63
|
-
if (!found) throw new Error("search backend unavailable");
|
|
64
|
-
return found;
|
|
65
|
-
};
|
|
66
|
-
return { search, queries };
|
|
93
|
+
return scriptedToolContext({
|
|
94
|
+
generate: {
|
|
95
|
+
[PLANNER_SYSTEM]: { object: { steps: script.steps ?? ["Only step"] } },
|
|
96
|
+
[REPLANNER_SYSTEM]: act,
|
|
97
|
+
[REVISE_SYSTEM]: act,
|
|
98
|
+
},
|
|
99
|
+
delegate: { executor: worksTheStep },
|
|
100
|
+
});
|
|
67
101
|
}
|
|
68
102
|
|
|
69
103
|
/** A tool by the name the model calls it by, bound to this agent. The lookup,
|
|
@@ -80,62 +114,205 @@ function stateOf(ctx: ToolContext) {
|
|
|
80
114
|
|
|
81
115
|
describe("planNode", () => {
|
|
82
116
|
test("returns the steps the planner produced", async () => {
|
|
83
|
-
const {
|
|
84
|
-
expect(await planNode(generate, "get me to Lisbon in May")).toEqual([
|
|
117
|
+
const { model } = scriptedDesk({ steps: ["Check prices", "Book it"] });
|
|
118
|
+
expect(await planNode(model.generate, "get me to Lisbon in May")).toEqual([
|
|
85
119
|
"Check prices",
|
|
86
120
|
"Book it",
|
|
87
121
|
]);
|
|
88
|
-
expect(calls[0]?.prompt).toContain("get me to Lisbon in May");
|
|
122
|
+
expect(model.calls[0]?.prompt).toContain("get me to Lisbon in May");
|
|
89
123
|
});
|
|
90
124
|
});
|
|
91
125
|
|
|
92
126
|
describe("executeStep", () => {
|
|
93
|
-
test("
|
|
94
|
-
const {
|
|
95
|
-
|
|
127
|
+
test("hands the step to the executor, with the objective and the history as context", async () => {
|
|
128
|
+
const desk = stubDelegate({ executor: stepReply("Flights are around 180 return.") });
|
|
129
|
+
|
|
130
|
+
const outcome = await executeStep(desk.delegate, "get to Lisbon", "Check prices", [
|
|
131
|
+
{ step: "Pick dates", result: "Mid-May", settled: true, searches: [] },
|
|
132
|
+
]);
|
|
133
|
+
|
|
134
|
+
// `finding` off the schema's own output, not the raw final message: the
|
|
135
|
+
// executor is a TYPED subagent, so what crosses back is a parsed object.
|
|
136
|
+
expect(outcome.result).toBe("Flights are around 180 return.");
|
|
137
|
+
expect(outcome.settled).toBe(true);
|
|
138
|
+
// The STEP is the task; everything the executor needs to do it in context
|
|
139
|
+
// rides in `context`, because a subagent has not heard the call.
|
|
140
|
+
expect(desk.calls[0]?.task).toBe("Check prices");
|
|
141
|
+
expect(desk.calls[0]?.options.context).toContain("get to Lisbon");
|
|
142
|
+
expect(desk.calls[0]?.options.context).toContain("Mid-May");
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
test("reports what it searched, read off the calls the run made", async () => {
|
|
146
|
+
// A search's RESULTS stayed inside the executor's context — that is the
|
|
147
|
+
// delegation — so the calls are the only honest source for the desk's
|
|
148
|
+
// "what the wait bought" line.
|
|
149
|
+
const desk = stubDelegate({
|
|
150
|
+
executor: {
|
|
151
|
+
text: stepReply("Flights are around 180 return."),
|
|
152
|
+
toolCalls: [
|
|
153
|
+
{ name: "search", input: { query: "lisbon flights may" } },
|
|
154
|
+
{ name: "search", input: { query: "lisbon flights june" } },
|
|
155
|
+
],
|
|
156
|
+
},
|
|
96
157
|
});
|
|
97
|
-
|
|
98
|
-
|
|
158
|
+
|
|
159
|
+
const outcome = await executeStep(desk.delegate, "get to Lisbon", "Check prices", []);
|
|
160
|
+
|
|
161
|
+
expect(outcome.searches).toEqual(["lisbon flights may", "lisbon flights june"]);
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
test("the executor is given its two tools and a bounded budget", async () => {
|
|
165
|
+
// What this template still OWNS now that the loop is the runtime's: which
|
|
166
|
+
// capabilities the step is worth, and how long it may spend.
|
|
167
|
+
const desk = stubDelegate({ executor: stepReply("done") });
|
|
168
|
+
await executeStep(desk.delegate, "objective", "step", []);
|
|
169
|
+
|
|
170
|
+
const executor = desk.calls[0]?.subagent;
|
|
171
|
+
expect(Object.keys(executor?.tools ?? {})).toEqual(["search", "read"]);
|
|
172
|
+
expect(executor?.maxSteps).toBe(MAX_STEP_TURNS);
|
|
173
|
+
// No `builtinTools`: both are this template's own tools over
|
|
174
|
+
// `@alexkroman1/aai/tools`, which is the example that outlived the loop.
|
|
175
|
+
expect(executor?.builtinTools).toBeUndefined();
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
test("an unsettled step is carried as a FIELD, not inferred from the wording", async () => {
|
|
179
|
+
// `settled` is what a prompt could not hold: "say plainly rather than
|
|
180
|
+
// inventing a result" was in `EXECUTOR_OUTPUT` from the start, and the desk
|
|
181
|
+
// read one string, so a step that found nothing and a step that answered
|
|
182
|
+
// arrived in the same shape.
|
|
183
|
+
const desk = stubDelegate({
|
|
184
|
+
executor: stepReply({ finding: "Nothing current on that route.", settled: false }),
|
|
99
185
|
});
|
|
100
186
|
|
|
101
|
-
const outcome = await executeStep(
|
|
102
|
-
|
|
103
|
-
expect(outcome.
|
|
104
|
-
expect(outcome.
|
|
105
|
-
// The results are what the second turn reasons over, not a note in a log.
|
|
106
|
-
expect(calls[1]?.prompt).toContain("https://example.test/fares");
|
|
187
|
+
const outcome = await executeStep(desk.delegate, "get to Lisbon", "Check prices", []);
|
|
188
|
+
|
|
189
|
+
expect(outcome.settled).toBe(false);
|
|
190
|
+
expect(outcome.result).toBe("Nothing current on that route.");
|
|
107
191
|
});
|
|
108
192
|
|
|
109
|
-
test("
|
|
110
|
-
//
|
|
111
|
-
//
|
|
112
|
-
|
|
113
|
-
|
|
193
|
+
test("an answer the guardrail never accepted is not a settled step", async () => {
|
|
194
|
+
// The run had its revision and still reported a step it never looked into,
|
|
195
|
+
// so `accepted` is false — and a `settled: true` from an answer the runtime
|
|
196
|
+
// refused is exactly the claim not to take at face value.
|
|
197
|
+
const desk = stubDelegate({
|
|
198
|
+
executor: {
|
|
199
|
+
text: stepReply({ finding: "Flights are cheap in May.", settled: true }),
|
|
200
|
+
complaint: "You reported the step as unsettled without searching for anything.",
|
|
201
|
+
},
|
|
114
202
|
});
|
|
115
|
-
const { search } = fakeSearch({});
|
|
116
203
|
|
|
117
|
-
const outcome = await executeStep(
|
|
118
|
-
|
|
119
|
-
expect(outcome.
|
|
204
|
+
const outcome = await executeStep(desk.delegate, "get to Lisbon", "Check prices", []);
|
|
205
|
+
|
|
206
|
+
expect(outcome.settled).toBe(false);
|
|
207
|
+
expect(outcome.result).toBe("Flights are cheap in May.");
|
|
120
208
|
});
|
|
209
|
+
});
|
|
121
210
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
211
|
+
describe("the executor's guardrail", () => {
|
|
212
|
+
// Driven through `runGuardrail` rather than by calling the function, so what
|
|
213
|
+
// is under test is the DEF: a guardrail dropped from `subagent()` fails here.
|
|
214
|
+
const verdict = (answer: StepAnswer, searched: number) =>
|
|
215
|
+
runGuardrail(executor, JSON.stringify(answer), {
|
|
216
|
+
toolCalls: Array.from({ length: searched }, () => ({
|
|
217
|
+
name: "search",
|
|
218
|
+
input: { query: "anything" },
|
|
219
|
+
})),
|
|
126
220
|
});
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
221
|
+
|
|
222
|
+
test("a settled step needs no search", () => {
|
|
223
|
+
// Plenty of steps are summaries of what earlier ones found. A general "did
|
|
224
|
+
// you search enough" would reject those and cost a whole extra run.
|
|
225
|
+
expect(verdict({ finding: "Two of the three are already booked.", settled: true }, 0)).toBe(
|
|
226
|
+
true,
|
|
227
|
+
);
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
test("an unsettled step that really looked is accepted", () => {
|
|
231
|
+
expect(verdict({ finding: "Could not find a fare for that date.", settled: false }, 2)).toBe(
|
|
232
|
+
true,
|
|
233
|
+
);
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
test("giving up without looking is sent back", () => {
|
|
237
|
+
// The failure this template's headline claim is exposed to: reporting a
|
|
238
|
+
// step unsettled from memory is cheaper than either honest move.
|
|
239
|
+
expect(verdict({ finding: "I do not know what that costs.", settled: false }, 0)).toMatch(
|
|
240
|
+
/without searching/,
|
|
241
|
+
);
|
|
242
|
+
});
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
describe("the executor's search tool", () => {
|
|
246
|
+
test("renders the hits the model reasons over", async () => {
|
|
247
|
+
vi.mocked(webSearch).mockResolvedValueOnce({
|
|
248
|
+
results: [{ title: "Fares to Lisbon", url: "https://example.test/fares" }],
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
const rendered = await searchTool.execute({ query: "lisbon flights" }, createToolContext());
|
|
252
|
+
|
|
253
|
+
expect(rendered).toContain("Fares to Lisbon");
|
|
254
|
+
expect(rendered).toContain("https://example.test/fares");
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
test("a REFUSED search comes back as a failure, not as an empty web", async () => {
|
|
258
|
+
// `webSearch` answers with `{ error }` rather than throwing, and measured,
|
|
259
|
+
// DuckDuckGo answers 403 often enough to be the ordinary case. `orFail`
|
|
260
|
+
// carries the refusal out as the tool's own `ToolFailure` — an empty list
|
|
261
|
+
// would tell the executor there is nothing out there, and a thrown `Error`
|
|
262
|
+
// would have the runtime log an ordinary 403 as an uncaught tool bug.
|
|
263
|
+
vi.mocked(webSearch).mockResolvedValueOnce({ error: "403 Forbidden" });
|
|
264
|
+
|
|
265
|
+
expect(await searchTool.execute({ query: "anything" }, createToolContext())).toEqual({
|
|
266
|
+
error: "403 Forbidden",
|
|
131
267
|
});
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
test("the caller's signal reaches the fetch", async () => {
|
|
271
|
+
// A tool body gets a signal and `CallOptions` takes one; until they were
|
|
272
|
+
// joined, a caller who hung up mid-step left a search running against a
|
|
273
|
+
// third party.
|
|
274
|
+
vi.mocked(webSearch).mockResolvedValueOnce({ results: [] });
|
|
275
|
+
const ctx = createToolContext();
|
|
276
|
+
|
|
277
|
+
await searchTool.execute({ query: "anything" }, ctx);
|
|
278
|
+
|
|
279
|
+
expect(vi.mocked(webSearch).mock.calls[0]?.[0]).toMatchObject({ signal: ctx.signal });
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
test("says so when the web really had nothing", async () => {
|
|
283
|
+
vi.mocked(webSearch).mockResolvedValueOnce({ results: [] });
|
|
284
|
+
expect(await searchTool.execute({ query: "anything" }, createToolContext())).toBe(
|
|
285
|
+
"No results.",
|
|
286
|
+
);
|
|
287
|
+
});
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
describe("the executor's read tool", () => {
|
|
291
|
+
test("hands back the page body, capped", async () => {
|
|
292
|
+
vi.mocked(visitWebpage).mockResolvedValueOnce({ content: "x".repeat(MAX_PAGE_CHARS + 500) });
|
|
293
|
+
|
|
294
|
+
const body = await readTool.execute({ url: "https://example.test/fares" }, createToolContext());
|
|
295
|
+
|
|
296
|
+
// A step is answered from a page's substance; the rest is context the run
|
|
297
|
+
// pays for and the executor does not read.
|
|
298
|
+
expect(String(body)).toHaveLength(MAX_PAGE_CHARS);
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
test("a page that would not load is not a page that said nothing", async () => {
|
|
302
|
+
vi.mocked(visitWebpage).mockResolvedValueOnce({ error: "404 Not Found" });
|
|
303
|
+
|
|
304
|
+
expect(
|
|
305
|
+
await readTool.execute({ url: "https://example.test/gone" }, createToolContext()),
|
|
306
|
+
).toEqual({ error: "404 Not Found" });
|
|
307
|
+
});
|
|
132
308
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
309
|
+
test("the caller's signal reaches the fetch here too", async () => {
|
|
310
|
+
vi.mocked(visitWebpage).mockResolvedValueOnce({ content: "anything" });
|
|
311
|
+
const ctx = createToolContext();
|
|
312
|
+
|
|
313
|
+
await readTool.execute({ url: "https://example.test/fares" }, ctx);
|
|
314
|
+
|
|
315
|
+
expect(vi.mocked(visitWebpage).mock.calls[0]?.[1]).toMatchObject({ signal: ctx.signal });
|
|
139
316
|
});
|
|
140
317
|
});
|
|
141
318
|
|
|
@@ -171,8 +348,9 @@ describe("normalizeAct", () => {
|
|
|
171
348
|
|
|
172
349
|
describe("start_plan", () => {
|
|
173
350
|
test("stores the objective and the steps", async () => {
|
|
174
|
-
const {
|
|
175
|
-
|
|
351
|
+
const { ctx } = scriptedDesk({
|
|
352
|
+
steps: ["Check prices", "Compare hotels", "Book"],
|
|
353
|
+
});
|
|
176
354
|
const result = (await run("start_plan", { objective: "a weekend in Lisbon" }, ctx)) as {
|
|
177
355
|
steps: string[];
|
|
178
356
|
};
|
|
@@ -197,8 +375,7 @@ describe("start_plan", () => {
|
|
|
197
375
|
|
|
198
376
|
describe("work_next_step", () => {
|
|
199
377
|
test("is refused before there is a plan, by the flow rather than by the body", async () => {
|
|
200
|
-
const {
|
|
201
|
-
const ctx = createToolContext({ generate });
|
|
378
|
+
const { ctx } = scriptedDesk();
|
|
202
379
|
// The gate is `when: "working"`, so the refusal names the state the call is
|
|
203
380
|
// actually in and quotes that state's instruction — which is what the model
|
|
204
381
|
// needs in order to do the right thing on its own next turn.
|
|
@@ -213,12 +390,11 @@ describe("work_next_step", () => {
|
|
|
213
390
|
});
|
|
214
391
|
|
|
215
392
|
test("does the head step, records it, and takes the replanner's next plan", async () => {
|
|
216
|
-
const {
|
|
393
|
+
const { ctx } = scriptedDesk({
|
|
217
394
|
steps: ["Check prices", "Compare hotels"],
|
|
218
|
-
|
|
395
|
+
answers: ["Fares are about 180 return."],
|
|
219
396
|
acts: [{ kind: "plan", steps: ["Compare hotels"] }],
|
|
220
397
|
});
|
|
221
|
-
const ctx = createToolContext({ generate });
|
|
222
398
|
await run("start_plan", { objective: "a weekend in Lisbon" }, ctx);
|
|
223
399
|
|
|
224
400
|
const first = expectDialogOk<{
|
|
@@ -241,12 +417,11 @@ describe("work_next_step", () => {
|
|
|
241
417
|
});
|
|
242
418
|
|
|
243
419
|
test("a 'respond' act finishes the plan and clears what is left", async () => {
|
|
244
|
-
const {
|
|
420
|
+
const { ctx } = scriptedDesk({
|
|
245
421
|
steps: ["Check prices", "Compare hotels"],
|
|
246
|
-
|
|
422
|
+
answers: ["Fares are about 180 return."],
|
|
247
423
|
acts: [{ kind: "respond", response: "Go in May — flights are about 180 return." }],
|
|
248
424
|
});
|
|
249
|
-
const ctx = createToolContext({ generate });
|
|
250
425
|
await run("start_plan", { objective: "a weekend in Lisbon" }, ctx);
|
|
251
426
|
const answered = expectDialogOk<{ finished: boolean; response: string }>(
|
|
252
427
|
await run("work_next_step", ctx),
|
|
@@ -275,17 +450,16 @@ describe("work_next_step", () => {
|
|
|
275
450
|
test("the completed-step trail is capped, so the executor's prompt cannot grow forever", async () => {
|
|
276
451
|
// `historyOf` renders every past step into the executor's prompt AND the
|
|
277
452
|
// replanner's, so an uncapped list is a model bill that grows linearly with
|
|
278
|
-
// the plan — the reason `
|
|
453
|
+
// the plan — the reason `planSlot` caps `pastSteps` at MAX_PAST_STEPS.
|
|
279
454
|
const total = MAX_PAST_STEPS + 3;
|
|
280
|
-
const {
|
|
455
|
+
const { ctx } = scriptedDesk({
|
|
281
456
|
steps: Array.from({ length: total }, (_, i) => `Step ${i + 1}`),
|
|
282
|
-
|
|
457
|
+
answers: Array.from({ length: total }, (_, i) => `Found ${i + 1}.`),
|
|
283
458
|
acts: Array.from({ length: total }, (_, i) => ({
|
|
284
459
|
kind: "plan" as const,
|
|
285
460
|
steps: Array.from({ length: total - i - 1 }, (_, j) => `Step ${i + j + 2}`),
|
|
286
461
|
})),
|
|
287
462
|
});
|
|
288
|
-
const ctx = createToolContext({ generate });
|
|
289
463
|
await run("start_plan", { objective: "a long one" }, ctx);
|
|
290
464
|
for (let i = 0; i < total; i++) await run("work_next_step", ctx);
|
|
291
465
|
|
|
@@ -299,13 +473,12 @@ describe("work_next_step", () => {
|
|
|
299
473
|
|
|
300
474
|
test("two independent contexts never share a plan", async () => {
|
|
301
475
|
// What this really checks: the state lives in the SLOT and not in a
|
|
302
|
-
// module-level variable. `
|
|
476
|
+
// module-level variable. `scriptedToolContext()` hands each call its own
|
|
303
477
|
// detached slot store, so the isolation is per CONTEXT — two distinct
|
|
304
478
|
// session ids would prove nothing extra, and `sessionSlot` could stop
|
|
305
479
|
// keying by session with this still passing.
|
|
306
|
-
const {
|
|
307
|
-
const
|
|
308
|
-
const second = createToolContext({ generate });
|
|
480
|
+
const { ctx: first } = scriptedDesk({ steps: ["Only step"] });
|
|
481
|
+
const { ctx: second } = scriptedDesk({ steps: ["Only step"] });
|
|
309
482
|
|
|
310
483
|
await run("start_plan", { objective: "mine" }, first);
|
|
311
484
|
expect(stateOf(second).objective).toBeNull();
|
|
@@ -319,15 +492,14 @@ describe("work_next_step", () => {
|
|
|
319
492
|
|
|
320
493
|
describe("revise_plan", () => {
|
|
321
494
|
test("rewrites what is left, keeps what is done, and reopens a finished plan", async () => {
|
|
322
|
-
const {
|
|
495
|
+
const { ctx, model } = scriptedDesk({
|
|
323
496
|
steps: ["Check Lisbon prices", "Book Lisbon"],
|
|
324
|
-
|
|
497
|
+
answers: ["Lisbon is about 180 return."],
|
|
325
498
|
acts: [
|
|
326
499
|
{ kind: "respond", response: "Lisbon in May, about 180." },
|
|
327
500
|
{ kind: "plan", steps: ["Check Porto prices"] },
|
|
328
501
|
],
|
|
329
502
|
});
|
|
330
|
-
const ctx = createToolContext({ generate });
|
|
331
503
|
await run("start_plan", { objective: "a weekend in Lisbon" }, ctx);
|
|
332
504
|
await run("work_next_step", ctx);
|
|
333
505
|
expect(stateOf(ctx).response).not.toBeNull();
|
|
@@ -349,23 +521,40 @@ describe("revise_plan", () => {
|
|
|
349
521
|
expect(state.pastSteps).toHaveLength(1);
|
|
350
522
|
expect(state.revisions.at(-1)).toContain("make it Porto instead");
|
|
351
523
|
// The caller's words reach the replanner, which is the whole node.
|
|
352
|
-
expect(calls.at(-1)?.prompt).toContain("make it Porto instead");
|
|
524
|
+
expect(model.calls.at(-1)?.prompt).toContain("make it Porto instead");
|
|
353
525
|
});
|
|
354
526
|
|
|
355
527
|
test("is refused before there is a plan", async () => {
|
|
356
|
-
const {
|
|
357
|
-
const ctx = createToolContext({ generate });
|
|
528
|
+
const { ctx } = scriptedDesk();
|
|
358
529
|
expect(await run("revise_plan", { instruction: "change it" }, ctx)).toMatchObject({
|
|
359
530
|
error: expect.stringContaining('this conversation is at "idle"'),
|
|
360
531
|
});
|
|
361
532
|
});
|
|
362
533
|
|
|
534
|
+
test("the revision trail is capped, because it rides in every syncState frame", async () => {
|
|
535
|
+
// The other cap `planSlot` declares, and the one nothing used to exercise:
|
|
536
|
+
// `revisions` is pushed to by every tool that changes the plan and is sent
|
|
537
|
+
// to the browser on each of them, so an uncapped trail is a frame that grows
|
|
538
|
+
// for the whole call.
|
|
539
|
+
const { ctx } = scriptedDesk({ steps: ["Only step"] });
|
|
540
|
+
await run("start_plan", { objective: "a weekend in Lisbon" }, ctx);
|
|
541
|
+
for (let index = 0; index < MAX_REVISIONS; index++) {
|
|
542
|
+
await run("revise_plan", { instruction: `change ${index}` }, ctx);
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
const state = stateOf(ctx);
|
|
546
|
+
expect(state.revisions).toHaveLength(MAX_REVISIONS);
|
|
547
|
+
// The OLDEST goes, so `start_plan`'s own entry is the one pushed out — the
|
|
548
|
+
// trail a caller wants read back is what has happened lately.
|
|
549
|
+
expect(state.revisions[0]).toContain("change 0");
|
|
550
|
+
expect(state.revisions.at(-1)).toContain(`change ${MAX_REVISIONS - 1}`);
|
|
551
|
+
});
|
|
552
|
+
|
|
363
553
|
test("a revision that answers outright lands in `answered`", async () => {
|
|
364
|
-
const {
|
|
554
|
+
const { ctx } = scriptedDesk({
|
|
365
555
|
steps: ["Check Lisbon prices"],
|
|
366
556
|
acts: [{ kind: "respond", response: "Nothing to do — you already booked it." }],
|
|
367
557
|
});
|
|
368
|
-
const ctx = createToolContext({ generate });
|
|
369
558
|
await run("start_plan", { objective: "a weekend in Lisbon" }, ctx);
|
|
370
559
|
const revised = expectDialogOk<{ finished: boolean }>(
|
|
371
560
|
await run("revise_plan", { instruction: "never mind, it is booked" }, ctx),
|
|
@@ -377,12 +566,11 @@ describe("revise_plan", () => {
|
|
|
377
566
|
|
|
378
567
|
describe("plan_status", () => {
|
|
379
568
|
test("reports done, remaining and the answer", async () => {
|
|
380
|
-
const {
|
|
569
|
+
const { ctx } = scriptedDesk({
|
|
381
570
|
steps: ["Check prices", "Book"],
|
|
382
|
-
|
|
571
|
+
answers: ["About 180 return."],
|
|
383
572
|
acts: [{ kind: "plan", steps: ["Book"] }],
|
|
384
573
|
});
|
|
385
|
-
const ctx = createToolContext({ generate });
|
|
386
574
|
// Legal in every state, so it READS the position rather than being gated on
|
|
387
575
|
// one — and "no plan yet" is the flow's own answer, not a third derivation
|
|
388
576
|
// of `!objective`.
|
|
@@ -420,12 +608,11 @@ describe("planView projection", () => {
|
|
|
420
608
|
});
|
|
421
609
|
|
|
422
610
|
test("progress is derived once, so the bar and any spoken count agree", async () => {
|
|
423
|
-
const {
|
|
611
|
+
const { ctx } = scriptedDesk({
|
|
424
612
|
steps: ["One", "Two", "Three"],
|
|
425
|
-
|
|
613
|
+
answers: ["Done one."],
|
|
426
614
|
acts: [{ kind: "plan", steps: ["Two", "Three"] }],
|
|
427
615
|
});
|
|
428
|
-
const ctx = createToolContext({ generate });
|
|
429
616
|
await run("start_plan", { objective: "three things" }, ctx);
|
|
430
617
|
expect(planView(stateOf(ctx)).progress).toBe(0);
|
|
431
618
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "@alexkroman1/aai-ui/styles.css";
|
|
2
|
-
import { AutoScroll, mountClient, useAgentState } from "@alexkroman1/aai-ui";
|
|
2
|
+
import { AutoScroll, Facts, mountClient, useAgentState } from "@alexkroman1/aai-ui";
|
|
3
3
|
import { planProjection } from "./shared.ts";
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -36,9 +36,10 @@ function PlanSidebar() {
|
|
|
36
36
|
style={{ width: `${Math.round(plan.progress * 100)}%` }}
|
|
37
37
|
/>
|
|
38
38
|
</div>
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
{/* The `·` line, its separator and the space either side of it are
|
|
40
|
+
`Facts`' rather than this file's — the one place a hand-written
|
|
41
|
+
version reliably gets wrong is the spacing around the separator. */}
|
|
42
|
+
<Facts size="xs" items={[`${plan.done.length} done`, `${plan.plan.length} to go`]} />
|
|
42
43
|
</div>
|
|
43
44
|
|
|
44
45
|
<AutoScroll
|
|
@@ -51,9 +52,19 @@ function PlanSidebar() {
|
|
|
51
52
|
<span className="text-aai-primary">✓</span> {past.step}
|
|
52
53
|
</p>
|
|
53
54
|
<p className="mt-1 text-xs opacity-70">{past.result}</p>
|
|
54
|
-
{
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
{/* Every fact here is conditional — an unsettled step may have
|
|
56
|
+
searched, a settled one may not have — and `Facts` drops the
|
|
57
|
+
falsy ones AND renders nothing at all when none survive, which
|
|
58
|
+
is the branch this line used to carry. */}
|
|
59
|
+
<Facts
|
|
60
|
+
size="xs"
|
|
61
|
+
className="mt-1"
|
|
62
|
+
items={[
|
|
63
|
+
!past.settled && "not settled",
|
|
64
|
+
past.searches.length > 0 && "searched",
|
|
65
|
+
...past.searches,
|
|
66
|
+
]}
|
|
67
|
+
/>
|
|
57
68
|
</div>
|
|
58
69
|
))}
|
|
59
70
|
{plan.plan.map((step, index) => (
|