@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
|
@@ -86,7 +86,9 @@ import {
|
|
|
86
86
|
useCopy,
|
|
87
87
|
useFlash,
|
|
88
88
|
useWorkflowSubmit,
|
|
89
|
+
WorkflowPendingNote,
|
|
89
90
|
WorkflowProgress,
|
|
91
|
+
WorkflowRunError,
|
|
90
92
|
} from "@alexkroman1/aai-ui";
|
|
91
93
|
import "@alexkroman1/aai-ui/styles.css";
|
|
92
94
|
// ERASED at build time, so naming the agent's own type costs the browser bundle
|
|
@@ -95,24 +97,6 @@ import "@alexkroman1/aai-ui/styles.css";
|
|
|
95
97
|
import { useState } from "react";
|
|
96
98
|
import type { digest } from "./agent.ts";
|
|
97
99
|
|
|
98
|
-
/**
|
|
99
|
-
* What the page says while something is in flight — three situations, one line
|
|
100
|
-
* each, and none of them the sentence this page used to print.
|
|
101
|
-
*
|
|
102
|
-
* That one was "You can close this tab — the run continues without it": true
|
|
103
|
-
* about the run and false about the page, which is the worst shape a reassurance
|
|
104
|
-
* can have. The run did continue and the tab could never find it again. Now it
|
|
105
|
-
* can, so the promise gets stronger and the reload case gets its own words —
|
|
106
|
-
* somebody who did not press the button is owed an explanation for the work
|
|
107
|
-
* appearing in front of them.
|
|
108
|
-
*/
|
|
109
|
-
function pendingNote(startedHere: boolean, found: boolean): string {
|
|
110
|
-
if (startedHere)
|
|
111
|
-
return "You can close this tab or reload it — this page will find the run again.";
|
|
112
|
-
if (!found) return "Looking for a digest this tab started earlier…";
|
|
113
|
-
return "Still working on the digest this tab started earlier. Reloading is safe.";
|
|
114
|
-
}
|
|
115
|
-
|
|
116
100
|
/** The digest as one pasteable block — a headline and its bullets. */
|
|
117
101
|
function asText(headline: string, points: readonly string[]): string {
|
|
118
102
|
return [headline, ...points.map((point) => `- ${point}`)].join("\n");
|
|
@@ -137,8 +121,8 @@ export function App() {
|
|
|
137
121
|
// No `key` and no `recover`: this tab's handle on its own runs is minted and
|
|
138
122
|
// remembered by the hook, and read back as it mounts. See the module doc for
|
|
139
123
|
// what a page says when it wants a different one.
|
|
140
|
-
const
|
|
141
|
-
|
|
124
|
+
const submission = useWorkflowSubmit<typeof digest>("digest");
|
|
125
|
+
const { submit, run, pending, error, wake } = submission;
|
|
142
126
|
|
|
143
127
|
// `submit()` resolves as soon as the run exists — deliberately not when it
|
|
144
128
|
// finishes. That is the whole mechanism: the digest sleeps for a while, and
|
|
@@ -188,8 +172,10 @@ export function App() {
|
|
|
188
172
|
{/* A run that has not settled says so. `pending` is not derivable from the
|
|
189
173
|
snapshot alone — an id the agent never knew leaves `run` undefined,
|
|
190
174
|
which would otherwise read as "still waiting" forever, and on a reload
|
|
191
|
-
it is also true while the run is being looked up by key.
|
|
192
|
-
|
|
175
|
+
it is also true while the run is being looked up by key. The three
|
|
176
|
+
sentences — pressed here, still looking, found from earlier — are the
|
|
177
|
+
component's; this page only names what the run produces. */}
|
|
178
|
+
<WorkflowPendingNote submission={submission} subject="digest" />
|
|
193
179
|
|
|
194
180
|
{/* The run's own narration, newest line only. `lines={1}` is the window;
|
|
195
181
|
everything else — the replay, and the "serves no stream" case that is
|
|
@@ -216,14 +202,9 @@ export function App() {
|
|
|
216
202
|
</button>
|
|
217
203
|
)}
|
|
218
204
|
|
|
219
|
-
{/*
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
{run?.status === "failed" && (
|
|
223
|
-
<p role="alert" className="text-red-600">
|
|
224
|
-
That one failed: {run.error}
|
|
225
|
-
</p>
|
|
226
|
-
)}
|
|
205
|
+
{/* Announced, like the submit error above: this is the outcome the reader
|
|
206
|
+
has been waiting for, and it can arrive long after they looked away. */}
|
|
207
|
+
<WorkflowRunError run={run} />
|
|
227
208
|
|
|
228
209
|
{run?.status === "completed" && (
|
|
229
210
|
<article className="flex flex-col gap-3">
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
27
|
import type { WorkflowContext } from "@alexkroman1/aai";
|
|
28
|
-
import { htmlToText, pageMetadata } from "@alexkroman1/aai/html";
|
|
28
|
+
import { htmlToText, type PageMetadata, pageMetadata } from "@alexkroman1/aai/html";
|
|
29
29
|
import { stepInfo, stepReport } from "@alexkroman1/aai/step";
|
|
30
30
|
import { FatalError, stepFetchOrFail, stepGenerateJsonOrFail } from "@alexkroman1/aai/step-errors";
|
|
31
31
|
import { omitUndefined } from "@alexkroman1/aai/utils";
|
|
@@ -96,6 +96,15 @@ export type Article = {
|
|
|
96
96
|
url: string;
|
|
97
97
|
/** The `<title>`, or the hostname when there is none. */
|
|
98
98
|
title: string;
|
|
99
|
+
/**
|
|
100
|
+
* The page's OWN one-line summary (`og:description`, or the `description`
|
|
101
|
+
* meta tag), absent when it declares neither.
|
|
102
|
+
*
|
|
103
|
+
* Optional rather than an empty string, because the two mean different things
|
|
104
|
+
* to the prompt below — an author's abstract is worth showing a model, and a
|
|
105
|
+
* blank label is worth nothing and costs tokens.
|
|
106
|
+
*/
|
|
107
|
+
description?: string;
|
|
99
108
|
/** Readable text, capped — see {@link MAX_ARTICLE_CHARS}. */
|
|
100
109
|
text: string;
|
|
101
110
|
};
|
|
@@ -171,7 +180,17 @@ export async function fetchArticle(url: string): Promise<Article> {
|
|
|
171
180
|
// (rightly) want the original error kept.
|
|
172
181
|
throw new FatalError(`${hostname} returned no readable text — is the page rendered in JS?`);
|
|
173
182
|
}
|
|
174
|
-
|
|
183
|
+
// One parse of the head for both of the things it is worth reading. The
|
|
184
|
+
// description may be absent, and `omitUndefined` is what keeps the key off
|
|
185
|
+
// the object rather than sending a `"description": undefined` across the
|
|
186
|
+
// queue — the guard IS the value, which is the case that primitive is for.
|
|
187
|
+
const meta = extractMetadata(html);
|
|
188
|
+
return {
|
|
189
|
+
url,
|
|
190
|
+
title: meta.title ?? hostname,
|
|
191
|
+
text,
|
|
192
|
+
...omitUndefined({ description: meta.description }),
|
|
193
|
+
};
|
|
175
194
|
}
|
|
176
195
|
|
|
177
196
|
/**
|
|
@@ -203,24 +222,21 @@ export async function summarize(article: Article): Promise<Digest> {
|
|
|
203
222
|
// model that answered with prose may answer correctly on the next attempt,
|
|
204
223
|
// where a 401 will not. The `OrFail` suffix is what makes the 401 half
|
|
205
224
|
// terminal: it is `stepGenerateJson` with `throwStepError` already applied.
|
|
206
|
-
const parsed = await stepGenerateJsonOrFail(
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
...omitUndefined({ model }),
|
|
222
|
-
},
|
|
223
|
-
);
|
|
225
|
+
const parsed = await stepGenerateJsonOrFail(articlePrompt(article), {
|
|
226
|
+
schema: DigestReply,
|
|
227
|
+
system:
|
|
228
|
+
`You digest articles. Reply with JSON only: {"headline": string, "points": string[]}. ` +
|
|
229
|
+
`Give exactly ${POINTS} points. No markdown fence, no preamble.` +
|
|
230
|
+
// The instruction is blunter on the last try for the same reason the
|
|
231
|
+
// model is different: whatever it has been doing for five attempts is
|
|
232
|
+
// not working.
|
|
233
|
+
(lastChance ? " Keep every point to one short sentence." : ""),
|
|
234
|
+
// Read `isLastAttempt`, never `attempt === 6`: the ceiling lives at the
|
|
235
|
+
// `ctx.step` call site in `digestFlow`, so a number written here degrades
|
|
236
|
+
// early on every run the moment somebody changes it there — silently,
|
|
237
|
+
// because the step still returns an answer.
|
|
238
|
+
...omitUndefined({ model }),
|
|
239
|
+
});
|
|
224
240
|
|
|
225
241
|
return {
|
|
226
242
|
url: article.url,
|
|
@@ -256,14 +272,46 @@ export async function file(_digest: Digest): Promise<string> {
|
|
|
256
272
|
// ---- Pure helpers -----------------------------------------------------------
|
|
257
273
|
|
|
258
274
|
/**
|
|
259
|
-
*
|
|
275
|
+
* What the model is SHOWN: the page's own framing, then the page.
|
|
276
|
+
*
|
|
277
|
+
* The description line is the author's own abstract, which is the one thing a
|
|
278
|
+
* page states about itself that the body text usually does not — a news article
|
|
279
|
+
* opens on a scene, and its `og:description` opens on the claim. It is LABELLED
|
|
280
|
+
* rather than pasted in front of the text, and it is no more trusted than the
|
|
281
|
+
* body beside it: both come off a stranger's server, which is why the system
|
|
282
|
+
* prompt below states the job and this side of the boundary states nothing.
|
|
283
|
+
*
|
|
284
|
+
* Omitted entirely when the page declares none — a bare `Summary:` reads to a
|
|
285
|
+
* model as an empty summary rather than as an absent one.
|
|
286
|
+
*/
|
|
287
|
+
export function articlePrompt(article: Article): string {
|
|
288
|
+
const head = [`Title: ${article.title}`, `URL: ${article.url}`];
|
|
289
|
+
if (article.description !== undefined)
|
|
290
|
+
head.push(`The page's own summary: ${article.description}`);
|
|
291
|
+
return `${head.join("\n")}\n\n${article.text}`;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* What the page says about itself in its own head: a name and an abstract.
|
|
260
296
|
*
|
|
261
297
|
* `pageMetadata` prefers `og:title` over the `<title>` element, which is what a
|
|
262
298
|
* digest wants: a `<title>` usually carries the site name and a separator
|
|
263
|
-
* ("Otters and tools | Nature Weekly") that a one-line summary does not.
|
|
299
|
+
* ("Otters and tools | Nature Weekly") that a one-line summary does not. It
|
|
300
|
+
* reads `og:description` and the `description` meta tag the same way.
|
|
301
|
+
*
|
|
302
|
+
* Annotated `PageMetadata` rather than left to inference, and the annotation is
|
|
303
|
+
* what makes the spread below safe: this returns the SDK's own record with two
|
|
304
|
+
* of its fields tidied, so a field the SDK adds later rides through untouched
|
|
305
|
+
* instead of being silently dropped by a hand-written shape.
|
|
264
306
|
*/
|
|
265
|
-
export function
|
|
266
|
-
|
|
307
|
+
export function extractMetadata(html: string): PageMetadata {
|
|
308
|
+
const meta = pageMetadata(html);
|
|
309
|
+
return { ...meta, title: collapse(meta.title), description: collapse(meta.description) };
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/** One line of it, or nothing — a head field is often indented across three. */
|
|
313
|
+
function collapse(value: string | undefined): string | undefined {
|
|
314
|
+
return value?.replace(/\s+/g, " ").trim() || undefined;
|
|
267
315
|
}
|
|
268
316
|
|
|
269
317
|
/**
|
|
@@ -33,7 +33,8 @@ import {
|
|
|
33
33
|
customEventsIn,
|
|
34
34
|
describeTurn,
|
|
35
35
|
lastStateIn,
|
|
36
|
-
|
|
36
|
+
runCodeIn,
|
|
37
|
+
runCodeOutput,
|
|
37
38
|
toolNames,
|
|
38
39
|
toolResultIn,
|
|
39
40
|
} from "@alexkroman1/aai-runtime/eval";
|
|
@@ -70,24 +71,6 @@ const pushedRecs = (events: readonly SessionEvent[]) =>
|
|
|
70
71
|
/** The `wind_down` nudges in `events` — `customEventsIn` filters by name. */
|
|
71
72
|
const nudges = (events: readonly SessionEvent[]) => customEventsIn(events, "wind_down");
|
|
72
73
|
|
|
73
|
-
/**
|
|
74
|
-
* A `run_code` executor, so the sleep-cycle case can assert the bedtime NUMBER
|
|
75
|
-
* and not merely the call — this template's headline feature is the arithmetic.
|
|
76
|
-
* `createVmRunCode`'s own doc carries why the builtin refuses without one.
|
|
77
|
-
*/
|
|
78
|
-
const runCode = createVmRunCode();
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* The `code` argument a `run_code` call carries.
|
|
82
|
-
*
|
|
83
|
-
* The schema is what `toolArgsIn` takes one for: `args` is
|
|
84
|
-
* `Record<string, unknown>` on the wire — the model wrote it and nothing
|
|
85
|
-
* validated it — so the `String(c.args.code ?? "")` this replaced turned an
|
|
86
|
-
* argument the companion renamed, or never sent, into `""`, and the two
|
|
87
|
-
* constants asserted below would have been looked for in nothing at all.
|
|
88
|
-
*/
|
|
89
|
-
const RunCodeArgs = z.object({ code: z.string() });
|
|
90
|
-
|
|
91
74
|
/** Two-digit, for the clock arithmetic below. */
|
|
92
75
|
const pad = (n: number): string => String(n).padStart(2, "0");
|
|
93
76
|
|
|
@@ -169,6 +152,39 @@ describeEval(
|
|
|
169
152
|
},
|
|
170
153
|
);
|
|
171
154
|
|
|
155
|
+
test(
|
|
156
|
+
"reads an earlier pick back out of the LOG rather than out of the transcript",
|
|
157
|
+
async ({ session }) => {
|
|
158
|
+
await session.say("I want something cozy to watch tonight.");
|
|
159
|
+
await session.say("Now give me something spooky to read.");
|
|
160
|
+
const turn = await session.say("What was that first one you gave me again?");
|
|
161
|
+
|
|
162
|
+
// The regression this case exists for is a companion that answers from
|
|
163
|
+
// the conversation it can still see: it sounds right, and it is wrong
|
|
164
|
+
// the moment the night is long enough for the early turns to fall out
|
|
165
|
+
// of the context window. `revisit` is a lookup in the slot.
|
|
166
|
+
expect(toolNames(turn.toolCalls), describeTurn(turn)).toEqual(["revisit"]);
|
|
167
|
+
const rec = toolResultIn(turn.toolCalls, "revisit", RecSchema);
|
|
168
|
+
expect(rec).toMatchObject({ category: "movie", mood: "cozy" });
|
|
169
|
+
// And what came back is the shelf's, read out — the same claim the
|
|
170
|
+
// first case makes about a fresh recommendation.
|
|
171
|
+
expect(rec.picks.some((pick) => turn.text.includes(pick))).toBe(true);
|
|
172
|
+
|
|
173
|
+
// Reading it back is not recommending it again: the log still has two.
|
|
174
|
+
expect(pushedRecs(session.events())).toHaveLength(2);
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
stubReply: [
|
|
178
|
+
{ tool: "recommend", args: { category: "movie", mood: "cozy" } },
|
|
179
|
+
"Paddington 2 it is.",
|
|
180
|
+
{ tool: "recommend", args: { category: "book", mood: "spooky" } },
|
|
181
|
+
"Mexican Gothic, then.",
|
|
182
|
+
{ tool: "revisit", args: { which: "that first one you gave me" } },
|
|
183
|
+
"The first was Paddington 2 — cozy as it gets.",
|
|
184
|
+
],
|
|
185
|
+
},
|
|
186
|
+
);
|
|
187
|
+
|
|
172
188
|
test(
|
|
173
189
|
"the wind-down nudge arrives once, on the third pick",
|
|
174
190
|
async ({ session }) => {
|
|
@@ -208,30 +224,27 @@ describeEval(
|
|
|
208
224
|
"I need to be up at 7 in the morning. When should I fall asleep?",
|
|
209
225
|
);
|
|
210
226
|
|
|
211
|
-
//
|
|
212
|
-
//
|
|
213
|
-
//
|
|
214
|
-
|
|
215
|
-
//
|
|
216
|
-
|
|
217
|
-
// instead, and it names a cancelled reply, which is the usual reason a
|
|
218
|
-
// turn reached for nothing at all.
|
|
219
|
-
expect(ran, describeTurn(turn)).not.toEqual([]);
|
|
227
|
+
// That the companion reached for code AT ALL, first: `describeTurn` is
|
|
228
|
+
// the message, because "expected [] to contain 'run_code'" says nothing
|
|
229
|
+
// about a companion that talked its way through the sum instead, and it
|
|
230
|
+
// names a cancelled reply, which is the usual reason a turn reached for
|
|
231
|
+
// nothing.
|
|
232
|
+
expect(toolNames(turn.toolCalls), describeTurn(turn)).toContain("run_code");
|
|
220
233
|
// The recipe is the prompt's, and it is two constants: a 90-minute cycle
|
|
221
234
|
// plus the 15 minutes it takes to fall asleep. Arithmetic done in the
|
|
222
|
-
// model's head has neither of them anywhere in the code.
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
235
|
+
// model's head has neither of them anywhere in the code. `runCodeIn`
|
|
236
|
+
// reads the code through a schema, so a `code` argument the companion
|
|
237
|
+
// renamed fails naming the field rather than reading as `""`.
|
|
238
|
+
const code = runCodeIn(turn.toolCalls);
|
|
226
239
|
expect(code).toContain("90");
|
|
227
240
|
expect(code).toContain("15");
|
|
228
241
|
|
|
229
|
-
|
|
230
|
-
//
|
|
231
|
-
//
|
|
232
|
-
//
|
|
233
|
-
//
|
|
234
|
-
|
|
242
|
+
// The builtin really EXECUTED: with no `runCode` executor the result is
|
|
243
|
+
// the builtin's refusal, which every assertion about a CALL sails past —
|
|
244
|
+
// so this template's headline feature could be checked as a call and
|
|
245
|
+
// never as an answer. `runCodeOutput` THROWS on that refusal, naming the
|
|
246
|
+
// fix, rather than handing the sentence back as output.
|
|
247
|
+
const output = runCodeOutput(turn.toolCalls);
|
|
235
248
|
// And the answer is a whole number of cycles back from 07:00 with the
|
|
236
249
|
// quarter hour added. A tutor that dropped the 15 lands on :00 and a
|
|
237
250
|
// tutor that guessed lands anywhere; both fail here.
|
|
@@ -255,6 +268,8 @@ describeEval(
|
|
|
255
268
|
},
|
|
256
269
|
);
|
|
257
270
|
},
|
|
258
|
-
//
|
|
259
|
-
|
|
271
|
+
// The executor is what makes the sleep-cycle case about the bedtime NUMBER
|
|
272
|
+
// rather than a call — this template's headline feature is the arithmetic.
|
|
273
|
+
// `createVmRunCode`'s own doc carries why the builtin refuses without one.
|
|
274
|
+
{ runCode: createVmRunCode() },
|
|
260
275
|
);
|
|
@@ -1,14 +1,35 @@
|
|
|
1
1
|
/** The def a DEPLOYED agent runs: authored, plus what `tools/` declares. */
|
|
2
2
|
import agentDef from "virtual:aai/agent";
|
|
3
|
-
import {
|
|
3
|
+
import type { InferToolInput, InferToolOutput } from "@alexkroman1/aai";
|
|
4
4
|
import {
|
|
5
5
|
createToolContext,
|
|
6
|
+
expectDeployable,
|
|
7
|
+
expectPromptBuiltinsDeclared,
|
|
6
8
|
parseToolInput,
|
|
7
9
|
toolInputIssues,
|
|
8
10
|
toolRunner,
|
|
9
11
|
} from "@alexkroman1/aai/testing";
|
|
12
|
+
// The failure vocabulary from the subpath that DECLARES it — `/utils` is the
|
|
13
|
+
// zero-dependency half a tool body (and a page) reaches for, and `client.tsx`
|
|
14
|
+
// takes the same guard from the same place.
|
|
15
|
+
import { isToolFailure } from "@alexkroman1/aai/utils";
|
|
10
16
|
import { describe, expect, test } from "vitest";
|
|
11
|
-
import { CATEGORIES, MOODS, nightProjection, nightSlot } from "./shared.ts";
|
|
17
|
+
import { CATEGORIES, MAX_RECS, MOODS, nightProjection, nightSlot } from "./shared.ts";
|
|
18
|
+
import type recommend from "./tools/recommend.ts";
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* What `recommend` takes and answers, read off the tool itself.
|
|
22
|
+
*
|
|
23
|
+
* `InferToolInput`/`InferToolOutput` rather than the `{ category: string; mood:
|
|
24
|
+
* string }` and `{ picks: string[] }` this spec used to hand-type: those are a
|
|
25
|
+
* restatement of a schema declared two files away, they are WEAKER than it
|
|
26
|
+
* (`string`, not the two enums), and nothing makes them fail when the schema
|
|
27
|
+
* moves. Imported as a MODULE for it — `virtual:aai/agent` is the def a deploy
|
|
28
|
+
* ships and is what every assertion below still drives, but a def erases which
|
|
29
|
+
* tool has which shape.
|
|
30
|
+
*/
|
|
31
|
+
type RecommendInput = InferToolInput<typeof recommend>;
|
|
32
|
+
type RecommendResult = InferToolOutput<typeof recommend>;
|
|
12
33
|
|
|
13
34
|
/**
|
|
14
35
|
* `runTool` takes the context in the ARGUMENTS' place when a tool needs none,
|
|
@@ -19,16 +40,32 @@ import { CATEGORIES, MOODS, nightProjection, nightSlot } from "./shared.ts";
|
|
|
19
40
|
const run = toolRunner(agentDef);
|
|
20
41
|
|
|
21
42
|
describe("night-owl template", () => {
|
|
22
|
-
test("
|
|
23
|
-
//
|
|
24
|
-
expect(() => toAgentConfig(
|
|
43
|
+
test("is deployable: validates, is nameable, and every stage its mode needs is filled", () => {
|
|
44
|
+
// The same conversion `aai build`/`aai deploy` run. `expectDeployable`
|
|
45
|
+
// rather than `expect(() => toAgentConfig(…)).not.toThrow()`: that spelling
|
|
46
|
+
// fails as "expected function not to throw" and buries the sentence the
|
|
47
|
+
// conversion wrote, and it checks neither the nameable nor the per-mode
|
|
48
|
+
// stage cascade. `not.toThrow()` because the helper's throw IS the finding.
|
|
49
|
+
expect(() => expectDeployable(agentDef)).not.toThrow();
|
|
25
50
|
});
|
|
26
51
|
|
|
27
52
|
test("declares run_code, which is the other half of the template", () => {
|
|
28
53
|
// The sleep-time arithmetic is the builtin's job, not a tool's — that split
|
|
29
54
|
// IS this template's subject, so a dropped builtin leaves the agent doing
|
|
30
|
-
// mental arithmetic out loud.
|
|
31
|
-
|
|
55
|
+
// mental arithmetic out loud. Asserted on the CONFIG, which is what a
|
|
56
|
+
// deploy ships.
|
|
57
|
+
expect(expectDeployable(agentDef).builtinTools).toContain("run_code");
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
test("every builtin the prompt tells Night Owl to use is one it declares", () => {
|
|
61
|
+
// `system-prompt.md` heads its arithmetic rules with `run_code`, and
|
|
62
|
+
// `agent.ts` is what makes that tool exist. The failure is silent in both
|
|
63
|
+
// directions: a prompt commanding a builtin the agent never declared
|
|
64
|
+
// produces a model apologising for a tool it cannot see. Which snake_case
|
|
65
|
+
// tokens in the prose are tool NAMES is a question for the SDK's schema
|
|
66
|
+
// rather than a list restated here — this prompt also names `wake_time`
|
|
67
|
+
// and `cycles`, which any underscore-matching scan would redden on.
|
|
68
|
+
expect(expectPromptBuiltinsDeclared(agentDef)).toContain("run_code");
|
|
32
69
|
});
|
|
33
70
|
|
|
34
71
|
test("recommend is discovered from tools/", () => {
|
|
@@ -38,6 +75,8 @@ describe("night-owl template", () => {
|
|
|
38
75
|
// is that discovery ran at all — a template whose `tools/` is never
|
|
39
76
|
// resolved ships a model with no tools.
|
|
40
77
|
expect(Object.keys(agentDef.tools ?? {})).toContain("recommend");
|
|
78
|
+
// Its reading half, declared the same way and discovered the same way.
|
|
79
|
+
expect(Object.keys(agentDef.tools ?? {})).toContain("revisit");
|
|
41
80
|
});
|
|
42
81
|
|
|
43
82
|
test("the projection an untouched session pushes is an empty log", () => {
|
|
@@ -49,9 +88,9 @@ describe("night-owl template", () => {
|
|
|
49
88
|
|
|
50
89
|
describe("recommend", () => {
|
|
51
90
|
test("answers with picks for the category and mood asked for", async () => {
|
|
52
|
-
const result = await run("recommend", { category: "movie", mood: "cozy" });
|
|
91
|
+
const result = (await run("recommend", { category: "movie", mood: "cozy" })) as RecommendResult;
|
|
53
92
|
expect(result).toMatchObject({ category: "movie", mood: "cozy" });
|
|
54
|
-
expect(
|
|
93
|
+
expect(result.picks.length).toBeGreaterThan(0);
|
|
55
94
|
});
|
|
56
95
|
|
|
57
96
|
test("the picks land in the session's own log, newest first", async () => {
|
|
@@ -62,6 +101,27 @@ describe("recommend", () => {
|
|
|
62
101
|
const first = await run("recommend", { category: "book", mood: "spooky" }, ctx);
|
|
63
102
|
const second = await run("recommend", { category: "music", mood: "chill" }, ctx);
|
|
64
103
|
expect(nightProjection(nightSlot.get(ctx))).toEqual({ recs: [second, first] });
|
|
104
|
+
// The two orders are DIFFERENT and both are deliberate: the slot keeps the
|
|
105
|
+
// night in the order it happened, which is what a position word means and
|
|
106
|
+
// which end `caps` trims; newest-first is the sidebar's, and the projection
|
|
107
|
+
// is where that turn happens.
|
|
108
|
+
expect(nightSlot.get(ctx).recs).toEqual([first, second]);
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
test("the log stops at the cap the slot declares, and it is the OLDEST that goes", async () => {
|
|
112
|
+
// Declared on the slot rather than enforced by this tool, so the bound
|
|
113
|
+
// holds whatever writes — the wrapper form only caps the paths that
|
|
114
|
+
// remember to call it. The list rides every `syncState` frame, which is
|
|
115
|
+
// what makes an unbounded one a real cost rather than a tidiness point.
|
|
116
|
+
const ctx = createToolContext();
|
|
117
|
+
const asked = Array.from({ length: MAX_RECS + 2 }, (_, i) => ({
|
|
118
|
+
category: CATEGORIES[i % CATEGORIES.length]!,
|
|
119
|
+
mood: MOODS[i % MOODS.length]!,
|
|
120
|
+
}));
|
|
121
|
+
for (const args of asked) await run("recommend", args, ctx);
|
|
122
|
+
|
|
123
|
+
const key = (rec: { category: string; mood: string }) => `${rec.category}/${rec.mood}`;
|
|
124
|
+
expect(nightSlot.get(ctx).recs.map(key)).toEqual(asked.slice(2).map(key));
|
|
65
125
|
});
|
|
66
126
|
|
|
67
127
|
test("two calls with no shared context are two sessions", async () => {
|
|
@@ -95,14 +155,14 @@ describe("recommend", () => {
|
|
|
95
155
|
// package's guide records three shipped tools having.
|
|
96
156
|
for (const category of CATEGORIES) {
|
|
97
157
|
for (const mood of MOODS) {
|
|
98
|
-
const result = await run("recommend", { category, mood });
|
|
99
|
-
expect(
|
|
158
|
+
const result = (await run("recommend", { category, mood })) as RecommendResult;
|
|
159
|
+
expect(result.picks, `${category}/${mood}`).not.toHaveLength(0);
|
|
100
160
|
}
|
|
101
161
|
}
|
|
102
162
|
});
|
|
103
163
|
|
|
104
164
|
test("the schema accepts a category/mood pair from the enums", async () => {
|
|
105
|
-
const parsed = await parseToolInput<
|
|
165
|
+
const parsed = await parseToolInput<RecommendInput>(agentDef, "recommend", {
|
|
106
166
|
category: "movie",
|
|
107
167
|
mood: "cozy",
|
|
108
168
|
});
|
|
@@ -121,3 +181,77 @@ describe("recommend", () => {
|
|
|
121
181
|
).toBeDefined();
|
|
122
182
|
});
|
|
123
183
|
});
|
|
184
|
+
|
|
185
|
+
describe("revisit", () => {
|
|
186
|
+
/** Three picks, in the order the night gave them. */
|
|
187
|
+
const threePicks = async (ctx: ReturnType<typeof createToolContext>) => {
|
|
188
|
+
await run("recommend", { category: "movie", mood: "cozy" }, ctx);
|
|
189
|
+
await run("recommend", { category: "book", mood: "spooky" }, ctx);
|
|
190
|
+
await run("recommend", { category: "music", mood: "chill" }, ctx);
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
test("a position counts the order the NIGHT went in, not the order the sidebar paints", async () => {
|
|
194
|
+
const ctx = createToolContext();
|
|
195
|
+
await threePicks(ctx);
|
|
196
|
+
|
|
197
|
+
// The distinction is the whole reason the two orders are separate: the
|
|
198
|
+
// sidebar's top card is the newest, and a listener saying "the last one you
|
|
199
|
+
// gave me" means that same pick from the other end.
|
|
200
|
+
expect(nightProjection(nightSlot.get(ctx)).recs[0]).toMatchObject({ category: "music" });
|
|
201
|
+
expect(await run("revisit", { which: "the last one" }, ctx)).toMatchObject({
|
|
202
|
+
category: "music",
|
|
203
|
+
mood: "chill",
|
|
204
|
+
});
|
|
205
|
+
expect(await run("revisit", { which: "the second one" }, ctx)).toMatchObject({
|
|
206
|
+
category: "book",
|
|
207
|
+
mood: "spooky",
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
test("the listener's own words pick one out when they name no position", async () => {
|
|
212
|
+
const ctx = createToolContext();
|
|
213
|
+
await threePicks(ctx);
|
|
214
|
+
const found = (await run("revisit", { which: "those spooky books" }, ctx)) as RecommendResult;
|
|
215
|
+
expect(found).toMatchObject({ category: "book", mood: "spooky" });
|
|
216
|
+
// It answers with the shelf's own picks, which is what makes this a lookup
|
|
217
|
+
// rather than the model recalling three titles from a trimmed transcript.
|
|
218
|
+
expect(found.picks).toEqual(
|
|
219
|
+
((await run("recommend", { category: "book", mood: "spooky" })) as RecommendResult).picks,
|
|
220
|
+
);
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
test("words that fit two entries equally refuse, listing them", async () => {
|
|
224
|
+
// Never a guess: reading out the spooky book when they asked for the cozy
|
|
225
|
+
// one is worse than asking which. The failure has to name the candidates,
|
|
226
|
+
// because the companion reads it out as the question.
|
|
227
|
+
const ctx = createToolContext();
|
|
228
|
+
await run("recommend", { category: "movie", mood: "cozy" }, ctx);
|
|
229
|
+
await run("recommend", { category: "book", mood: "cozy" }, ctx);
|
|
230
|
+
|
|
231
|
+
const refused = await run("revisit", { which: "the cozy ones" }, ctx);
|
|
232
|
+
expect(isToolFailure(refused)).toBe(true);
|
|
233
|
+
expect(isToolFailure(refused) && refused.error).toMatch(/cozy movies/);
|
|
234
|
+
expect(isToolFailure(refused) && refused.error).toMatch(/cozy books/);
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
test("an empty log refuses rather than answering", async () => {
|
|
238
|
+
// The first thing `resolveOne` checks, and the one a hand-rolled lookup
|
|
239
|
+
// reports as "nothing matched" — which sends the companion looking for a
|
|
240
|
+
// pick it never gave.
|
|
241
|
+
const refused = await run("revisit", { which: "the first one" });
|
|
242
|
+
expect(isToolFailure(refused)).toBe(true);
|
|
243
|
+
expect(isToolFailure(refused) && refused.error).toMatch(/recommendation/);
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
test("reading the log back writes nothing to it", async () => {
|
|
247
|
+
// `slot.tool`, not `updateTool`: what a read is handed is frozen, so this
|
|
248
|
+
// is a compile-time guarantee as much as a runtime one — the test is here
|
|
249
|
+
// because the guarantee is the reason to declare a read tool as one.
|
|
250
|
+
const ctx = createToolContext();
|
|
251
|
+
await threePicks(ctx);
|
|
252
|
+
const before = nightProjection(nightSlot.get(ctx));
|
|
253
|
+
await run("revisit", { which: "the first one" }, ctx);
|
|
254
|
+
await run("revisit", { which: "nothing like this" }, ctx);
|
|
255
|
+
expect(nightProjection(nightSlot.get(ctx))).toEqual(before);
|
|
256
|
+
});
|
|
257
|
+
});
|