@alexkroman1/aai-cli 15.0.0 → 16.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -5
- package/bin.mjs +12 -3
- package/dist/_build-target-55dJisQ-.mjs +649 -0
- package/dist/_build-target.d.ts +105 -108
- package/dist/_deno-output.d.ts +23 -0
- package/dist/_deno-target.d.ts +73 -0
- package/dist/{_init-Bsi3DZNJ.mjs → _init-BzQbV8Zh.mjs} +3 -1
- package/dist/_modal-app.d.ts +77 -0
- package/dist/_modal-output.d.ts +31 -0
- package/dist/_modal-target.d.ts +64 -0
- package/dist/_target-bundle.d.ts +27 -0
- package/dist/_target-drain.d.ts +44 -0
- package/dist/_target-output.d.ts +63 -0
- package/dist/{_templates-CIlJ3Vay.mjs → _templates-CuP74F8D.mjs} +94 -4
- package/dist/_templates.d.ts +14 -1
- package/dist/_vercel-output.d.ts +4 -19
- package/dist/_vercel-target.d.ts +169 -0
- package/dist/{test-D032V2cA.mjs → _vitest-runner-AVR9VtXh.mjs} +28 -68
- package/dist/_vitest-runner.d.ts +154 -0
- package/dist/build-ButI2IKc.mjs +689 -0
- package/dist/build.d.ts +11 -0
- package/dist/cli.mjs +14 -20
- package/dist/{dev-Bx9gYBHM.mjs → dev-kodAY23K.mjs} +7 -1
- package/dist/{eval-B3I7FqN9.mjs → eval-DvoSz7SZ.mjs} +1 -1
- package/dist/{init-CFyusRbq.mjs → init-D363Ls5u.mjs} +13 -39
- package/dist/init.d.ts +5 -10
- package/dist/scaffold/CLAUDE.md +185 -35
- package/dist/scaffold/package.json +4 -4
- package/dist/start.mjs +3 -1
- package/dist/{studio-C_zuRC_z.mjs → studio-CtRBVVFR.mjs} +1 -1
- package/dist/templates/briefing-desk/agent.eval.test.ts +34 -6
- package/dist/templates/briefing-desk/agent.test.ts +347 -55
- package/dist/templates/briefing-desk/agent.ts +12 -0
- package/dist/templates/briefing-desk/shared.ts +220 -31
- package/dist/templates/briefing-desk/slack.ts +108 -0
- package/dist/templates/briefing-desk/system-prompt.md +12 -2
- package/dist/templates/briefing-desk/tools/briefing_so_far.ts +15 -7
- package/dist/templates/briefing-desk/tools/research_topic.ts +20 -28
- package/dist/templates/briefing-desk/tools/send_briefing.ts +77 -0
- package/dist/templates/briefing-desk/tools/verify_claim.ts +60 -14
- package/dist/templates/call-audit/agent.eval.test.ts +5 -0
- package/dist/templates/call-audit/agent.test.ts +6 -1
- package/dist/templates/call-audit/agent.ts +10 -23
- package/dist/templates/call-audit/client.tsx +30 -55
- package/dist/templates/call-audit/guards.test.ts +233 -0
- package/dist/templates/call-audit/workflows/audit.ts +95 -16
- package/dist/templates/call-audit/workflows/ingest.ts +107 -88
- package/dist/templates/call-audit/workflows/media.ts +98 -7
- package/dist/templates/call-audit/workflows/summarize.ts +35 -31
- package/dist/templates/call-audit/workflows/sync-api.ts +15 -6
- package/dist/templates/code-interpreter/agent.eval.test.ts +104 -56
- package/dist/templates/code-interpreter/agent.test.ts +44 -56
- package/dist/templates/code-interpreter/system-prompt.md +1 -1
- package/dist/templates/dispatch-center/agent.eval.test.ts +61 -24
- package/dist/templates/dispatch-center/agent.test.ts +253 -48
- package/dist/templates/dispatch-center/agent.ts +28 -1
- package/dist/templates/dispatch-center/client.tsx +126 -201
- package/dist/templates/dispatch-center/events.ts +48 -0
- package/dist/templates/dispatch-center/shared.ts +42 -1
- package/dist/templates/dispatch-center/tools/incident_create.ts +3 -2
- package/dist/templates/dispatch-center/tools/incident_escalate.ts +2 -1
- package/dist/templates/dispatch-center/tools/ops_dashboard.ts +35 -15
- package/dist/templates/dispatch-center/tools/ops_run_scenario.ts +3 -1
- package/dist/templates/dispatch-center/tools/resources_dispatch.ts +2 -2
- package/dist/templates/executive-assistant/agent.eval.test.ts +233 -0
- package/dist/templates/executive-assistant/agent.test.ts +672 -0
- package/dist/templates/executive-assistant/agent.ts +50 -0
- package/dist/templates/executive-assistant/calendar.test.ts +198 -0
- package/dist/templates/executive-assistant/client.tsx +195 -0
- package/dist/templates/executive-assistant/inbox.ts +233 -0
- package/dist/templates/executive-assistant/meeting.ts +138 -0
- package/dist/templates/executive-assistant/nodes.ts +152 -0
- package/dist/templates/executive-assistant/prompts.ts +331 -0
- package/dist/templates/executive-assistant/review.ts +425 -0
- package/dist/templates/executive-assistant/shared.ts +490 -0
- package/dist/templates/executive-assistant/system-prompt.md +15 -0
- package/dist/templates/executive-assistant/tools/accept.ts +10 -0
- package/dist/templates/executive-assistant/tools/ask_question.ts +30 -0
- package/dist/templates/executive-assistant/tools/draft_reply.ts +67 -0
- package/dist/templates/executive-assistant/tools/edit.ts +10 -0
- package/dist/templates/executive-assistant/tools/ignore.ts +10 -0
- package/dist/templates/executive-assistant/tools/inbox_status.ts +27 -0
- package/dist/templates/executive-assistant/tools/meeting_assistant.ts +52 -0
- package/dist/templates/executive-assistant/tools/new_email.ts +50 -0
- package/dist/templates/executive-assistant/tools/open_email.ts +165 -0
- package/dist/templates/executive-assistant/tools/respond.ts +10 -0
- package/dist/templates/executive-assistant/tools/review_memory.ts +22 -0
- package/dist/templates/executive-assistant/tools/send_calendar_invite.ts +68 -0
- package/dist/templates/executive-assistant/tools/triage_inbox.ts +75 -0
- package/dist/templates/health-assistant/agent.test.ts +134 -15
- package/dist/templates/health-assistant/agent.ts +8 -1
- package/dist/templates/health-assistant/fda.test.ts +130 -0
- package/dist/templates/health-assistant/fda.ts +75 -16
- package/dist/templates/health-assistant/system-prompt.md +9 -0
- package/dist/templates/health-assistant/tools/check_drug_interaction.ts +5 -2
- package/dist/templates/health-assistant/tools/medication_lookup.ts +16 -11
- package/dist/templates/hiring-desk/agent.eval.test.ts +242 -0
- package/dist/templates/hiring-desk/agent.test.ts +1021 -0
- package/dist/templates/hiring-desk/agent.ts +38 -0
- package/dist/templates/hiring-desk/client.tsx +154 -0
- package/dist/templates/hiring-desk/crews.ts +432 -0
- package/dist/templates/hiring-desk/leads.json +86 -0
- package/dist/templates/hiring-desk/screening-lock.test.ts +77 -0
- package/dist/templates/hiring-desk/screening-lock.ts +51 -0
- package/dist/templates/hiring-desk/shared.ts +480 -0
- package/dist/templates/hiring-desk/system-prompt.md +21 -0
- package/dist/templates/hiring-desk/tools/candidate_details.ts +49 -0
- package/dist/templates/hiring-desk/tools/proceed_to_emails.ts +127 -0
- package/dist/templates/hiring-desk/tools/read_email.ts +50 -0
- package/dist/templates/hiring-desk/tools/rescore_with_feedback.ts +140 -0
- package/dist/templates/hiring-desk/tools/screen_candidates.ts +128 -0
- package/dist/templates/hiring-desk/tools/screening_status.ts +51 -0
- package/dist/templates/hotel-desk/agent.eval.test.ts +177 -0
- package/dist/templates/hotel-desk/agent.test.ts +1128 -0
- package/dist/templates/hotel-desk/agent.ts +63 -0
- package/dist/templates/hotel-desk/booking.ts +159 -0
- package/dist/templates/hotel-desk/card.ts +92 -0
- package/dist/templates/hotel-desk/catalogs.ts +219 -0
- package/dist/templates/hotel-desk/client.tsx +137 -0
- package/dist/templates/hotel-desk/concierge.ts +99 -0
- package/dist/templates/hotel-desk/desk-seams.test.ts +334 -0
- package/dist/templates/hotel-desk/desk.ts +224 -0
- package/dist/templates/hotel-desk/disputes.ts +216 -0
- package/dist/templates/hotel-desk/events.ts +79 -0
- package/dist/templates/hotel-desk/hotel.ts +412 -0
- package/dist/templates/hotel-desk/policies.ts +209 -0
- package/dist/templates/hotel-desk/records.ts +384 -0
- package/dist/templates/hotel-desk/restaurant.ts +147 -0
- package/dist/templates/hotel-desk/seed.ts +955 -0
- package/dist/templates/hotel-desk/shared.ts +354 -0
- package/dist/templates/hotel-desk/system-prompt.md +76 -0
- package/dist/templates/hotel-desk/tools/abandon_booking.ts +30 -0
- package/dist/templates/hotel-desk/tools/add_to_waitlist.ts +41 -0
- package/dist/templates/hotel-desk/tools/book_airport_car.ts +57 -0
- package/dist/templates/hotel-desk/tools/book_business_center.ts +44 -0
- package/dist/templates/hotel-desk/tools/book_spa_appointment.ts +39 -0
- package/dist/templates/hotel-desk/tools/book_tour.ts +35 -0
- package/dist/templates/hotel-desk/tools/cancel_restaurant_reservation.ts +25 -0
- package/dist/templates/hotel-desk/tools/cancel_room_booking.ts +63 -0
- package/dist/templates/hotel-desk/tools/check_restaurant_availability.ts +24 -0
- package/dist/templates/hotel-desk/tools/check_room_availability.ts +40 -0
- package/dist/templates/hotel-desk/tools/choose_room.ts +93 -0
- package/dist/templates/hotel-desk/tools/confirm_booking.ts +153 -0
- package/dist/templates/hotel-desk/tools/dispatch_emergency.ts +61 -0
- package/dist/templates/hotel-desk/tools/dispute_charge.ts +90 -0
- package/dist/templates/hotel-desk/tools/flag_late_arrival.ts +26 -0
- package/dist/templates/hotel-desk/tools/lookup_booking.ts +48 -0
- package/dist/templates/hotel-desk/tools/lookup_guest_history.ts +28 -0
- package/dist/templates/hotel-desk/tools/lookup_invoice.ts +26 -0
- package/dist/templates/hotel-desk/tools/lookup_policy.ts +20 -0
- package/dist/templates/hotel-desk/tools/lookup_restaurant_reservation.ts +27 -0
- package/dist/templates/hotel-desk/tools/modify_restaurant_reservation.ts +75 -0
- package/dist/templates/hotel-desk/tools/order_flowers.ts +40 -0
- package/dist/templates/hotel-desk/tools/record_card.ts +46 -0
- package/dist/templates/hotel-desk/tools/record_followup.ts +50 -0
- package/dist/templates/hotel-desk/tools/record_group_inquiry.ts +44 -0
- package/dist/templates/hotel-desk/tools/record_guest_details.ts +71 -0
- package/dist/templates/hotel-desk/tools/reinstate_booking.ts +65 -0
- package/dist/templates/hotel-desk/tools/request_flight_reconfirmation.ts +54 -0
- package/dist/templates/hotel-desk/tools/resend_confirmation.ts +39 -0
- package/dist/templates/hotel-desk/tools/reserve_table.ts +87 -0
- package/dist/templates/hotel-desk/tools/resolve_room_conflict.ts +48 -0
- package/dist/templates/hotel-desk/tools/schedule_wakeup_call.ts +48 -0
- package/dist/templates/hotel-desk/tools/set_do_not_disturb.ts +28 -0
- package/dist/templates/hotel-desk/tools/set_extras.ts +51 -0
- package/dist/templates/hotel-desk/tools/set_stay.ts +97 -0
- package/dist/templates/hotel-desk/tools/start_booking_modification.ts +57 -0
- package/dist/templates/hotel-desk/tools/start_room_booking.ts +49 -0
- package/dist/templates/hotel-desk/tools/take_guest_message.ts +71 -0
- package/dist/templates/hotel-desk/tools/transfer_call.ts +47 -0
- package/dist/templates/hotel-desk/tools/update_card.ts +45 -0
- package/dist/templates/hotel-desk/tools/verify_booking.ts +95 -0
- package/dist/templates/infocom-adventure/agent.eval.test.ts +33 -1
- package/dist/templates/infocom-adventure/agent.test.ts +207 -52
- package/dist/templates/infocom-adventure/agent.ts +14 -3
- package/dist/templates/infocom-adventure/client.tsx +138 -176
- package/dist/templates/infocom-adventure/shared.ts +126 -6
- package/dist/templates/infocom-adventure/system-prompt.md +4 -4
- package/dist/templates/infocom-adventure/tools/game_state_drop.ts +20 -4
- package/dist/templates/infocom-adventure/tools/game_state_get.ts +6 -5
- package/dist/templates/infocom-adventure/tools/game_state_score.ts +9 -3
- package/dist/templates/link-digest/agent.eval.test.ts +8 -0
- package/dist/templates/link-digest/agent.test.ts +285 -29
- package/dist/templates/link-digest/agent.ts +9 -0
- package/dist/templates/link-digest/api-client.ts +144 -0
- package/dist/templates/link-digest/client.tsx +11 -30
- package/dist/templates/link-digest/workflows/digest.ts +72 -24
- package/dist/templates/night-owl/agent.eval.test.ts +55 -40
- package/dist/templates/night-owl/agent.test.ts +146 -12
- package/dist/templates/night-owl/client.tsx +50 -17
- package/dist/templates/night-owl/shared.ts +33 -2
- package/dist/templates/night-owl/system-prompt.md +3 -0
- package/dist/templates/night-owl/tools/recommend.ts +4 -1
- package/dist/templates/night-owl/tools/revisit.ts +49 -0
- package/dist/templates/pipeline-simple/agent.eval.test.ts +7 -6
- package/dist/templates/pipeline-simple/agent.test.ts +48 -91
- package/dist/templates/pipeline-simple/modes.test.ts +151 -0
- package/dist/templates/pipeline-simple/stages.test.ts +332 -0
- package/dist/templates/pizza-ordering/agent.test.ts +94 -38
- package/dist/templates/pizza-ordering/client.tsx +10 -5
- package/dist/templates/pizza-ordering/shared.ts +65 -6
- package/dist/templates/pizza-ordering/tools/add_pizza.ts +2 -7
- package/dist/templates/pizza-ordering/tools/place_order.ts +9 -6
- package/dist/templates/pizza-ordering/tools/remove_pizza.ts +6 -11
- package/dist/templates/pizza-ordering/tools/update_pizza.ts +8 -9
- package/dist/templates/pizza-ordering/tools/view_order.ts +2 -3
- package/dist/templates/plan-and-execute/agent.eval.test.ts +14 -6
- package/dist/templates/plan-and-execute/agent.test.ts +300 -113
- package/dist/templates/plan-and-execute/client.tsx +18 -7
- package/dist/templates/plan-and-execute/procedure.ts +162 -64
- package/dist/templates/plan-and-execute/prompts.ts +51 -15
- package/dist/templates/plan-and-execute/shared.ts +151 -45
- package/dist/templates/plan-and-execute/tools/plan_status.ts +15 -6
- package/dist/templates/plan-and-execute/tools/revise_plan.ts +2 -2
- package/dist/templates/plan-and-execute/tools/start_plan.ts +2 -2
- package/dist/templates/plan-and-execute/tools/work_next_step.ts +15 -13
- package/dist/templates/podcast-digest/agent.eval.test.ts +12 -7
- package/dist/templates/podcast-digest/agent.test.ts +126 -51
- package/dist/templates/podcast-digest/client.tsx +104 -68
- package/dist/templates/podcast-digest/workflows/digest.ts +71 -48
- package/dist/templates/podcast-digest/workflows/feeds.ts +5 -7
- package/dist/templates/podcast-digest/workflows/slack.ts +82 -17
- package/dist/templates/recap-workflow/agent.eval.test.ts +193 -209
- package/dist/templates/recap-workflow/agent.test.ts +207 -26
- package/dist/templates/recap-workflow/tools/recap_status.ts +2 -2
- package/dist/templates/recap-workflow/workflows/recap.ts +39 -28
- package/dist/templates/redline/agent.eval.test.ts +40 -3
- package/dist/templates/redline/agent.test.ts +216 -6
- package/dist/templates/redline/agent.ts +54 -34
- package/dist/templates/redline/client.tsx +82 -126
- package/dist/templates/redline/form.ts +74 -0
- package/dist/templates/redline/workflows/prompts.ts +3 -3
- package/dist/templates/redline/workflows/redline.ts +73 -4
- package/dist/templates/research-workflow/agent.eval.test.ts +152 -150
- package/dist/templates/research-workflow/agent.test.ts +436 -126
- package/dist/templates/research-workflow/agent.ts +20 -5
- package/dist/templates/research-workflow/tools/file_it_now.ts +11 -1
- package/dist/templates/research-workflow/tools/research_status.ts +39 -4
- package/dist/templates/research-workflow/workflows/filing.ts +164 -0
- package/dist/templates/research-workflow/workflows/notes.ts +69 -0
- package/dist/templates/research-workflow/workflows/prompts.ts +45 -31
- package/dist/templates/research-workflow/workflows/research.ts +227 -280
- package/dist/templates/research-workflow/workflows/review.ts +43 -0
- package/dist/templates/retail/address.ts +29 -35
- package/dist/templates/retail/agent.eval.test.ts +36 -16
- package/dist/templates/retail/agent.test.ts +104 -26
- package/dist/templates/retail/agent.ts +12 -0
- package/dist/templates/retail/cancel.ts +39 -42
- package/dist/templates/retail/client.tsx +111 -176
- package/dist/templates/retail/payment.ts +38 -43
- package/dist/templates/retail/pending.test.ts +16 -8
- package/dist/templates/retail/registry.test.ts +108 -49
- package/dist/templates/retail/resolve.test.ts +2 -63
- package/dist/templates/retail/resolve.ts +16 -56
- package/dist/templates/retail/returns.ts +53 -54
- package/dist/templates/retail/seed.test.ts +2 -1
- package/dist/templates/retail/shared.ts +58 -14
- package/dist/templates/retail/store.test.ts +40 -29
- package/dist/templates/retail/store.ts +60 -23
- package/dist/templates/retail/swap.ts +78 -81
- package/dist/templates/retail/tools/find_user_id_by_name_zip.ts +2 -1
- package/dist/templates/roadside-assist/agent.eval.test.ts +164 -0
- package/dist/templates/roadside-assist/agent.test.ts +617 -0
- package/dist/templates/roadside-assist/agent.ts +85 -0
- package/dist/templates/roadside-assist/call.ts +237 -0
- package/dist/templates/roadside-assist/events.ts +92 -0
- package/dist/templates/roadside-assist/shared.ts +334 -0
- package/dist/templates/roadside-assist/system-prompt.md +37 -0
- package/dist/templates/roadside-assist/tools/acknowledge_disclosure.ts +47 -0
- package/dist/templates/roadside-assist/tools/dispatch_truck.ts +148 -0
- package/dist/templates/roadside-assist/tools/job_status.ts +38 -0
- package/dist/templates/roadside-assist/tools/lookup_coverage.ts +72 -0
- package/dist/templates/roadside-assist/tools/report_location.ts +79 -0
- package/dist/templates/roadside-assist/tools/service_disclosure.ts +45 -0
- package/dist/templates/roadside-assist/yard.test.ts +158 -0
- package/dist/templates/roadside-assist/yard.ts +183 -0
- package/dist/templates/simple/agent.eval.test.ts +4 -1
- package/dist/templates/simple/agent.test.ts +54 -31
- package/dist/templates/solo-rpg/agent.eval.test.ts +19 -11
- package/dist/templates/solo-rpg/agent.test.ts +402 -175
- package/dist/templates/solo-rpg/agent.ts +14 -3
- package/dist/templates/solo-rpg/client.tsx +10 -10
- package/dist/templates/solo-rpg/shared.ts +198 -79
- package/dist/templates/solo-rpg/tools/action_roll.ts +7 -3
- package/dist/templates/solo-rpg/tools/burn_momentum.ts +16 -8
- package/dist/templates/solo-rpg/tools/oracle.ts +7 -7
- package/dist/templates/solo-rpg/tools/setup_character.ts +5 -5
- package/dist/templates/solo-rpg/tools/update_state.ts +29 -18
- package/dist/templates/spoken-summary/agent.test.ts +70 -15
- package/dist/templates/spoken-summary/agent.ts +25 -21
- package/dist/templates/spoken-summary/client.tsx +68 -88
- package/dist/templates/spoken-summary/workflows/summarize.ts +26 -8
- package/dist/templates/support-line/agent.test.ts +167 -36
- package/dist/templates/support-line/client.tsx +21 -9
- package/dist/templates/support-line/nodes.ts +74 -32
- package/dist/templates/support-line/procedure.ts +66 -21
- package/dist/templates/support-line/prompts.ts +9 -0
- package/dist/templates/support-line/shared.ts +55 -17
- package/dist/templates/support-line/tools/answer_question.ts +14 -14
- package/dist/templates/transcription-workflow/agent.test.ts +135 -13
- package/dist/templates/transcription-workflow/client.tsx +30 -23
- package/dist/templates/transcription-workflow/recover.test.ts +93 -12
- package/dist/templates/transcription-workflow/recover.ts +29 -5
- package/dist/templates/transcription-workflow/run-panel.tsx +40 -51
- package/dist/templates/transcription-workflow/workflows/normalize.ts +125 -24
- package/dist/templates/transcription-workflow/workflows/stream.ts +4 -1
- package/dist/templates/transcription-workflow/workflows/transcribe.ts +7 -5
- package/dist/templates/transcription-workflow/workflows/wav.ts +42 -117
- package/dist/templates/travel-concierge/agent.eval.test.ts +6 -4
- package/dist/templates/travel-concierge/agent.test.ts +209 -40
- package/dist/templates/travel-concierge/agent.ts +24 -4
- package/dist/templates/travel-concierge/call-events.ts +80 -0
- package/dist/templates/travel-concierge/client.tsx +3 -2
- package/dist/templates/travel-concierge/routing.ts +5 -7
- package/dist/templates/travel-concierge/shared.ts +202 -41
- package/dist/templates/travel-concierge/tools/book_car_rental.ts +2 -4
- package/dist/templates/travel-concierge/tools/book_excursion.ts +2 -4
- package/dist/templates/travel-concierge/tools/book_hotel.ts +2 -4
- package/dist/templates/travel-concierge/tools/cancel_ticket.ts +6 -4
- package/dist/templates/travel-concierge/tools/search_car_rentals.ts +3 -5
- package/dist/templates/travel-concierge/tools/search_excursions.ts +3 -5
- package/dist/templates/travel-concierge/tools/search_flights.ts +20 -9
- package/dist/templates/travel-concierge/tools/search_hotels.ts +3 -5
- package/dist/templates/travel-concierge/tools/update_ticket.ts +2 -4
- package/dist/templates/web-researcher/agent.eval.test.ts +3 -6
- package/dist/templates/web-researcher/agent.test.ts +102 -65
- package/dist/templates/web-researcher/agent.ts +93 -1
- package/dist/templates/web-researcher/system-prompt.md +7 -1
- package/dist/templates/word-wrangler/agent.eval.test.ts +157 -0
- package/dist/templates/word-wrangler/agent.test.ts +432 -0
- package/dist/templates/word-wrangler/agent.ts +35 -0
- package/dist/templates/word-wrangler/client.tsx +211 -0
- package/dist/templates/word-wrangler/game.ts +107 -0
- package/dist/templates/word-wrangler/guess.ts +63 -0
- package/dist/templates/word-wrangler/player.ts +68 -0
- package/dist/templates/word-wrangler/shared.ts +263 -0
- package/dist/templates/word-wrangler/system-prompt.md +15 -0
- package/dist/templates/word-wrangler/tools/final_score.ts +37 -0
- package/dist/templates/word-wrangler/tools/relay_description.ts +137 -0
- package/dist/templates/word-wrangler/tools/repeat_word.ts +19 -0
- package/dist/templates/word-wrangler/tools/skip_word.ts +31 -0
- package/dist/templates/word-wrangler/tools/start_game.ts +47 -0
- package/dist/templates/word-wrangler/words.ts +278 -0
- package/dist/test-Cllnx81G.mjs +83 -0
- package/dist/test.d.ts +9 -114
- package/package.json +5 -5
- package/dist/build-BhEaxBPu.mjs +0 -481
- package/dist/templates/embedded-assets/agent.eval.test.ts +0 -130
- package/dist/templates/embedded-assets/agent.test.ts +0 -79
- package/dist/templates/embedded-assets/agent.ts +0 -7
- package/dist/templates/embedded-assets/knowledge.json +0 -20
- package/dist/templates/embedded-assets/shared.ts +0 -17
- package/dist/templates/embedded-assets/system-prompt.md +0 -13
- package/dist/templates/embedded-assets/tools/list_topics.ts +0 -9
- package/dist/templates/embedded-assets/tools/search_knowledge.ts +0 -26
- package/dist/templates/math-buddy/agent.eval.test.ts +0 -128
- package/dist/templates/math-buddy/agent.test.ts +0 -126
- package/dist/templates/math-buddy/agent.ts +0 -15
- package/dist/templates/math-buddy/system-prompt.md +0 -12
- package/dist/templates/personal-finance/agent.eval.test.ts +0 -149
- package/dist/templates/personal-finance/agent.test.ts +0 -127
- package/dist/templates/personal-finance/agent.ts +0 -8
- package/dist/templates/personal-finance/system-prompt.md +0 -21
|
@@ -1,35 +1,36 @@
|
|
|
1
1
|
import { plural } from "@alexkroman1/aai/utils";
|
|
2
2
|
import "@alexkroman1/aai-ui/styles.css";
|
|
3
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
AgentState,
|
|
5
|
+
ChatMessage,
|
|
6
|
+
SessionControlButton,
|
|
7
|
+
ToolCallInfo,
|
|
8
|
+
} from "@alexkroman1/aai-ui";
|
|
4
9
|
import {
|
|
5
|
-
|
|
6
|
-
AutoScroll,
|
|
10
|
+
ConversationView,
|
|
7
11
|
mountClient,
|
|
12
|
+
SessionControls,
|
|
8
13
|
SessionErrorBanner,
|
|
14
|
+
SessionStateDot,
|
|
15
|
+
ToolCallRow,
|
|
9
16
|
useAgentState,
|
|
10
|
-
useConversation,
|
|
11
|
-
useSessionActions,
|
|
12
|
-
useSessionSelector,
|
|
13
|
-
useSessionStatus,
|
|
14
17
|
} from "@alexkroman1/aai-ui";
|
|
15
18
|
import type { DispatchState, IncidentSummary, Severity, Status } from "./shared.ts";
|
|
16
19
|
import { dashboardProjection } from "./shared.ts";
|
|
17
20
|
|
|
21
|
+
/*
|
|
22
|
+
* The board's own motion: the slide a new card and a new bubble make. The pulse
|
|
23
|
+
* it used to declare beside this was the SDK's `aai-pulse` under another name,
|
|
24
|
+
* and every dot here runs on that one now. The scrollbars are `.aai-scroll`
|
|
25
|
+
* from the same stylesheet; the one thing the board says about them is the
|
|
26
|
+
* thumb colour, as a custom property the utility reads.
|
|
27
|
+
*/
|
|
18
28
|
const CSS = `
|
|
19
|
-
@keyframes dc-pulse {
|
|
20
|
-
0%, 100% { opacity: 1; }
|
|
21
|
-
50% { opacity: 0.5; }
|
|
22
|
-
}
|
|
23
29
|
@keyframes dc-slide-in {
|
|
24
30
|
from { transform: translateY(10px); opacity: 0; }
|
|
25
31
|
to { transform: translateY(0); opacity: 1; }
|
|
26
32
|
}
|
|
27
|
-
.dc-
|
|
28
|
-
.dc-messages::-webkit-scrollbar-track { background: transparent; }
|
|
29
|
-
.dc-messages::-webkit-scrollbar-thumb { background: #334155; border-radius: 3px; }
|
|
30
|
-
.dc-sidebar::-webkit-scrollbar { width: 6px; }
|
|
31
|
-
.dc-sidebar::-webkit-scrollbar-track { background: transparent; }
|
|
32
|
-
.dc-sidebar::-webkit-scrollbar-thumb { background: #334155; border-radius: 3px; }
|
|
33
|
+
.dc-main { --aai-scrollbar-thumb: #334155; }
|
|
33
34
|
@media (max-width: 900px) {
|
|
34
35
|
.dc-main { grid-template-columns: 1fr !important; grid-template-rows: auto 1fr !important; }
|
|
35
36
|
}
|
|
@@ -66,11 +67,11 @@ const statusColors: Record<string, string> = {
|
|
|
66
67
|
// if-chain with a grey default.
|
|
67
68
|
//
|
|
68
69
|
// The palette is this template's own — every client here paints the same six
|
|
69
|
-
// states in its own colours, so
|
|
70
|
-
// the SDK does own is `AgentState`, and `satisfies
|
|
71
|
-
// is what borrows it: a state added there stops
|
|
72
|
-
// `state === "…"` chain this replaced answered a new
|
|
73
|
-
// badge in three separate files and no way to notice.
|
|
70
|
+
// states in its own colours, so it is the one prop `<SessionStateDot>` cannot
|
|
71
|
+
// default. What the SDK does own is `AgentState`, and `satisfies
|
|
72
|
+
// Record<AgentState, string>` is what borrows it: a state added there stops
|
|
73
|
+
// compiling here, where the `state === "…"` chain this replaced answered a new
|
|
74
|
+
// state with a silent grey badge in three separate files and no way to notice.
|
|
74
75
|
const STATE_COLORS = {
|
|
75
76
|
disconnected: "#6b7280",
|
|
76
77
|
connecting: "#6b7280",
|
|
@@ -82,14 +83,12 @@ const STATE_COLORS = {
|
|
|
82
83
|
} satisfies Record<AgentState, string>;
|
|
83
84
|
|
|
84
85
|
/*
|
|
85
|
-
* The board's own vocabulary
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
* ended on.
|
|
86
|
+
* The board's own vocabulary — only three of the seven states get a dispatch
|
|
87
|
+
* word. The rest are `<SessionStateDot>`'s defaults (`AGENT_STATE_LABELS`), so a
|
|
88
|
+
* state added upstream reads as something rather than falling through to
|
|
89
|
+
* whichever arm a ternary chain ended on.
|
|
90
90
|
*/
|
|
91
|
-
const STATE_LABELS: Record<AgentState, string
|
|
92
|
-
...AGENT_STATE_LABELS,
|
|
91
|
+
const STATE_LABELS: Partial<Record<AgentState, string>> = {
|
|
93
92
|
listening: "LISTENING",
|
|
94
93
|
thinking: "PROCESSING",
|
|
95
94
|
speaking: "TRANSMITTING",
|
|
@@ -158,31 +157,34 @@ function IncidentCard({ inc }: { inc: IncidentSummary }) {
|
|
|
158
157
|
);
|
|
159
158
|
}
|
|
160
159
|
|
|
161
|
-
/**
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
160
|
+
/**
|
|
161
|
+
* The tool the desk ran: the SDK's compact row, with the board's own dot in
|
|
162
|
+
* its icon slot. `ToolCallRow` owns the shimmer while the call is pending and
|
|
163
|
+
* the row's shape; the dot's colours are this board's.
|
|
164
|
+
*/
|
|
165
|
+
function ToolChip({ toolCall }: { toolCall: ToolCallInfo }) {
|
|
166
|
+
const pending = toolCall.status === "pending";
|
|
167
|
+
return (
|
|
168
|
+
<ToolCallRow
|
|
169
|
+
variant="compact"
|
|
170
|
+
className="self-start"
|
|
171
|
+
title={toolCall.name}
|
|
172
|
+
pending={pending}
|
|
173
|
+
icon={
|
|
174
174
|
<span
|
|
175
|
-
className="w-1.5 h-1.5 rounded-full inline-block"
|
|
175
|
+
className="w-1.5 h-1.5 rounded-full inline-block align-middle"
|
|
176
176
|
style={{
|
|
177
|
-
background:
|
|
178
|
-
animation:
|
|
177
|
+
background: pending ? "#eab308" : "#22c55e",
|
|
178
|
+
animation: pending ? "aai-pulse 1s ease-in-out infinite" : "none",
|
|
179
179
|
}}
|
|
180
180
|
/>
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
181
|
+
}
|
|
182
|
+
/>
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/** One radio line — the markup this template exists to show. */
|
|
187
|
+
function Bubble({ role, content }: ChatMessage) {
|
|
186
188
|
return (
|
|
187
189
|
<div
|
|
188
190
|
className="rounded-lg text-[13px] max-w-[85%] px-3.5 py-2.5"
|
|
@@ -206,191 +208,111 @@ function Row({ item }: { item: ConversationItem }) {
|
|
|
206
208
|
/**
|
|
207
209
|
* The radio log.
|
|
208
210
|
*
|
|
209
|
-
*
|
|
211
|
+
* `<ConversationView>` rather than a `session.messages.map(...)`: the messages
|
|
210
212
|
* were only half of it. This board runs eight tools and rendered NONE of them,
|
|
211
213
|
* because tool calls live in a second array this page never read — and it also
|
|
212
|
-
* dropped the streaming reply and the thinking indicator. The
|
|
214
|
+
* dropped the streaming reply and the thinking indicator. The view owns the
|
|
213
215
|
* interleave (a tool row follows its anchor message), the `null`-vs-`""`
|
|
214
|
-
* transcript distinction
|
|
215
|
-
* the markup, which is the part
|
|
216
|
+
* transcript distinction, the thinking-suppression rule and the announced
|
|
217
|
+
* thinking row; what stays here is the markup in each slot, which is the part
|
|
218
|
+
* this template exists to show. The live transcript is pinned BELOW the scroll
|
|
219
|
+
* as its own strip, which is what `transcriptPosition="below"` is for.
|
|
216
220
|
*
|
|
217
221
|
* It also subscribes per FIELD, so the conversation re-renders at the
|
|
218
222
|
* conversation's rate. The whole-page `useSession()` this replaced re-rendered
|
|
219
223
|
* the incident board on every STT partial.
|
|
220
224
|
*/
|
|
221
225
|
function Conversation() {
|
|
222
|
-
const { items, streaming, transcript, thinking } = useConversation();
|
|
223
226
|
return (
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
<Row
|
|
236
|
-
key={item.kind === "message" ? `m${item.message.id}` : item.toolCall.callId}
|
|
237
|
-
item={item}
|
|
238
|
-
/>
|
|
239
|
-
))}
|
|
240
|
-
{streaming !== null && (
|
|
241
|
-
<div
|
|
242
|
-
className="rounded-lg text-[13px] max-w-[85%] px-3.5 py-2.5 self-start"
|
|
243
|
-
style={{ lineHeight: 1.6, background: "#1e293b", borderLeft: "3px solid #3b82f6" }}
|
|
244
|
-
>
|
|
245
|
-
<div className="text-[10px] uppercase tracking-wider mb-1" style={{ color: "#64748b" }}>
|
|
246
|
-
DISPATCH
|
|
247
|
-
</div>
|
|
248
|
-
{streaming}
|
|
249
|
-
</div>
|
|
250
|
-
)}
|
|
251
|
-
{/* Same contract as the shipped `MessageList`'s indicator: three pulsing
|
|
252
|
-
dots are the only sign the desk is working, and to a screen reader
|
|
253
|
-
they are punctuation. */}
|
|
254
|
-
{thinking && (
|
|
255
|
-
<div
|
|
256
|
-
role="status"
|
|
257
|
-
aria-label="Dispatch is thinking"
|
|
258
|
-
className="self-start text-[11px] px-3.5"
|
|
259
|
-
style={{ color: "#64748b" }}
|
|
260
|
-
>
|
|
261
|
-
<span style={{ animation: "dc-pulse 1.2s ease-in-out infinite" }}>· · ·</span>
|
|
262
|
-
</div>
|
|
263
|
-
)}
|
|
264
|
-
</AutoScroll>
|
|
265
|
-
|
|
266
|
-
{transcript.speaking && (
|
|
227
|
+
<ConversationView
|
|
228
|
+
scrollClassName="aai-scroll overflow-y-auto"
|
|
229
|
+
contentClassName="p-4 flex flex-col gap-2"
|
|
230
|
+
empty={
|
|
231
|
+
<div className="text-center p-10 text-[13px]" style={{ color: "#475569" }}>
|
|
232
|
+
Dispatch Command Center standing by. Click START to begin operations.
|
|
233
|
+
</div>
|
|
234
|
+
}
|
|
235
|
+
renderMessage={(message) => <Bubble {...message} />}
|
|
236
|
+
renderTool={(toolCall) => <ToolChip toolCall={toolCall} />}
|
|
237
|
+
renderTranscript={({ text }) => (
|
|
267
238
|
<div
|
|
268
239
|
className="flex items-center px-4 py-2 text-xs italic min-h-8"
|
|
269
240
|
style={{ background: "#111827", borderTop: "1px solid #1e293b", color: "#64748b" }}
|
|
270
241
|
>
|
|
271
242
|
<span
|
|
272
243
|
className="w-2.5 h-2.5 rounded-full inline-block mr-2"
|
|
273
|
-
style={{ background: "#22c55e", animation: "
|
|
244
|
+
style={{ background: "#22c55e", animation: "aai-pulse 1.5s ease-in-out infinite" }}
|
|
274
245
|
/>
|
|
275
|
-
{
|
|
246
|
+
{text}
|
|
276
247
|
</div>
|
|
277
248
|
)}
|
|
278
|
-
|
|
249
|
+
transcriptPosition="below"
|
|
250
|
+
thinkingLabel="Dispatch is thinking"
|
|
251
|
+
thinkingClassName="self-start text-[11px] px-3.5 text-[#64748b]"
|
|
252
|
+
/>
|
|
279
253
|
);
|
|
280
254
|
}
|
|
281
255
|
|
|
282
256
|
/**
|
|
283
|
-
* The live status readout, on its own
|
|
284
|
-
*
|
|
285
|
-
*
|
|
286
|
-
*
|
|
287
|
-
* it one level up dragged the incident board through every snapshot change.
|
|
257
|
+
* The live status readout: the SDK's dot in the board's colours, on its own
|
|
258
|
+
* subscription — the header is the only thing here that cares about the session
|
|
259
|
+
* state, and reading it one level up dragged the incident board through every
|
|
260
|
+
* snapshot change.
|
|
288
261
|
*/
|
|
289
262
|
function StatusReadout() {
|
|
290
|
-
const state = useSessionStatus();
|
|
291
263
|
return (
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
state === "listening"
|
|
299
|
-
? "dc-pulse 1.5s ease-in-out infinite"
|
|
300
|
-
: state === "thinking"
|
|
301
|
-
? "dc-pulse 0.8s ease-in-out infinite"
|
|
302
|
-
: "none",
|
|
303
|
-
}}
|
|
304
|
-
title={state}
|
|
305
|
-
/>
|
|
306
|
-
<span className="text-[11px] font-normal normal-case" style={{ color: "#64748b" }}>
|
|
307
|
-
{STATE_LABELS[state]}
|
|
308
|
-
</span>
|
|
309
|
-
</>
|
|
264
|
+
<SessionStateDot
|
|
265
|
+
colors={STATE_COLORS}
|
|
266
|
+
labels={STATE_LABELS}
|
|
267
|
+
dotClassName="w-2.5 h-2.5"
|
|
268
|
+
labelClassName="text-[11px] font-normal normal-case text-[#64748b]"
|
|
269
|
+
/>
|
|
310
270
|
);
|
|
311
271
|
}
|
|
312
272
|
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
*
|
|
318
|
-
*
|
|
319
|
-
*
|
|
320
|
-
*
|
|
273
|
+
const SHIFT_BUTTON =
|
|
274
|
+
"px-4 py-2 border-none rounded-md font-mono text-xs font-semibold uppercase tracking-wider cursor-pointer";
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* One shift button in the board's colours. `<SessionControls>` decides WHICH
|
|
278
|
+
* buttons exist and what each presses — including that "New Conversation" is
|
|
279
|
+
* `end()` then `start()` and never `reset()`, which is argued once on that
|
|
280
|
+
* component rather than in a comment here; this decides only how they look.
|
|
281
|
+
*/
|
|
282
|
+
function shiftButton({ action, label, onClick, running }: SessionControlButton) {
|
|
283
|
+
const look =
|
|
284
|
+
action === "end"
|
|
285
|
+
? { background: "#dc2626", color: "white" }
|
|
286
|
+
: action === "restart"
|
|
287
|
+
? { background: "#1e293b", color: "#e2e8f0" }
|
|
288
|
+
: action === "toggle" && running
|
|
289
|
+
? { background: "#334155", color: "#e2e8f0" }
|
|
290
|
+
: { background: "#2563eb", color: "white" };
|
|
291
|
+
return (
|
|
292
|
+
<button type="button" className={SHIFT_BUTTON} style={look} onClick={onClick}>
|
|
293
|
+
{label}
|
|
294
|
+
</button>
|
|
295
|
+
);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* The shift controls: Start Dispatch before the shift, then Pause/Resume, New
|
|
300
|
+
* Conversation and End Shift. The row reads two one-field subscriptions through
|
|
301
|
+
* `useSessionControls`, so it re-renders when a flag flips and not at
|
|
302
|
+
* STT-partial rate the way the whole-snapshot `useSession()` it once held did.
|
|
321
303
|
*/
|
|
322
304
|
function ShiftControls({ logged }: { logged: number }) {
|
|
323
|
-
const { start, toggle, restart, end } = useSessionActions();
|
|
324
|
-
const started = useSessionSelector((s) => s.started);
|
|
325
|
-
const running = useSessionSelector((s) => s.running);
|
|
326
305
|
return (
|
|
327
|
-
<
|
|
328
|
-
className="
|
|
329
|
-
|
|
306
|
+
<SessionControls
|
|
307
|
+
className="px-4 py-3 bg-[#111827] border-t border-[#1e293b]"
|
|
308
|
+
labels={{ start: "Start Dispatch", end: "End Shift" }}
|
|
309
|
+
renderButton={shiftButton}
|
|
330
310
|
>
|
|
331
|
-
{!started ? (
|
|
332
|
-
<button
|
|
333
|
-
type="button"
|
|
334
|
-
className="px-4 py-2 border-none rounded-md font-mono text-xs font-semibold uppercase tracking-wider cursor-pointer text-white"
|
|
335
|
-
style={{ background: "#2563eb" }}
|
|
336
|
-
onClick={() => start()}
|
|
337
|
-
>
|
|
338
|
-
Start Dispatch
|
|
339
|
-
</button>
|
|
340
|
-
) : (
|
|
341
|
-
<>
|
|
342
|
-
<button
|
|
343
|
-
type="button"
|
|
344
|
-
className="px-4 py-2 border-none rounded-md font-mono text-xs font-semibold uppercase tracking-wider cursor-pointer"
|
|
345
|
-
style={{
|
|
346
|
-
background: running ? "#334155" : "#2563eb",
|
|
347
|
-
color: running ? "#e2e8f0" : "white",
|
|
348
|
-
}}
|
|
349
|
-
onClick={() => toggle()}
|
|
350
|
-
>
|
|
351
|
-
{running ? "Pause" : "Resume"}
|
|
352
|
-
</button>
|
|
353
|
-
{/* The one-click new conversation the default shell's
|
|
354
|
-
`<Controls>` gives every other template — a custom
|
|
355
|
-
`component:` renders no `<Controls>`, so a console like
|
|
356
|
-
this one has to say it itself.
|
|
357
|
-
|
|
358
|
-
end() then start(), NOT reset(): reset() clears the
|
|
359
|
-
conversation and leaves the agent's own session-scoped
|
|
360
|
-
state behind, so the next tool call would repopulate the
|
|
361
|
-
shift that was just abandoned. end() drops the resume
|
|
362
|
-
identity, so the redial is a brand-new session (fresh
|
|
363
|
-
incident board, greeting included), and start() puts the
|
|
364
|
-
console straight back on the call rather than at the
|
|
365
|
-
"Start Dispatch" screen. */}
|
|
366
|
-
<button
|
|
367
|
-
type="button"
|
|
368
|
-
className="px-4 py-2 border-none rounded-md font-mono text-xs font-semibold uppercase tracking-wider cursor-pointer"
|
|
369
|
-
style={{ background: "#1e293b", color: "#e2e8f0" }}
|
|
370
|
-
onClick={restart}
|
|
371
|
-
>
|
|
372
|
-
New Conversation
|
|
373
|
-
</button>
|
|
374
|
-
{/* end() hangs up and flips `started` back, so the UI
|
|
375
|
-
returns to "Start Dispatch" and the next start is a
|
|
376
|
-
brand-new shift (fresh incident board, greeting
|
|
377
|
-
included). reset() would keep the call live — the
|
|
378
|
-
buttons never toggle back. */}
|
|
379
|
-
<button
|
|
380
|
-
type="button"
|
|
381
|
-
className="px-4 py-2 border-none rounded-md font-mono text-xs font-semibold uppercase tracking-wider cursor-pointer text-white"
|
|
382
|
-
style={{ background: "#dc2626" }}
|
|
383
|
-
onClick={() => end()}
|
|
384
|
-
>
|
|
385
|
-
End Shift
|
|
386
|
-
</button>
|
|
387
|
-
</>
|
|
388
|
-
)}
|
|
389
311
|
<div className="flex-1" />
|
|
390
312
|
<span className="text-[10px]" style={{ color: "#475569" }}>
|
|
391
313
|
{logged} {plural(logged, "incident")} logged
|
|
392
314
|
</span>
|
|
393
|
-
</
|
|
315
|
+
</SessionControls>
|
|
394
316
|
);
|
|
395
317
|
}
|
|
396
318
|
|
|
@@ -440,12 +362,15 @@ function App() {
|
|
|
440
362
|
SYSTEM ALERT:
|
|
441
363
|
</span>
|
|
442
364
|
<span
|
|
443
|
-
className="px-3 py-1 rounded text-[11px] font-bold uppercase tracking-wider"
|
|
444
365
|
style={{
|
|
445
366
|
background: alertBg,
|
|
446
367
|
color: alertTextColor,
|
|
447
|
-
animation: alertLevel === "red" ? "dc-pulse 1s ease-in-out infinite" : "none",
|
|
448
368
|
}}
|
|
369
|
+
// Tailwind's own opacity pulse rather than `aai-pulse`, which also
|
|
370
|
+
// SCALES — right for a dot, wrong for a badge carrying a word.
|
|
371
|
+
className={`px-3 py-1 rounded text-[11px] font-bold uppercase tracking-wider${
|
|
372
|
+
alertLevel === "red" ? " animate-pulse" : ""
|
|
373
|
+
}`}
|
|
449
374
|
>
|
|
450
375
|
{alertLevel.toUpperCase()}
|
|
451
376
|
</span>
|
|
@@ -469,7 +394,7 @@ function App() {
|
|
|
469
394
|
|
|
470
395
|
{/* Right: sidebar dashboard */}
|
|
471
396
|
<div
|
|
472
|
-
className="
|
|
397
|
+
className="aai-scroll overflow-y-auto p-4 flex flex-col gap-4"
|
|
473
398
|
style={{ background: "#111827" }}
|
|
474
399
|
>
|
|
475
400
|
<Panel title="Operations Summary">
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { SessionEventHandlers } from "@alexkroman1/aai";
|
|
2
|
+
import { callInHand, dispatchSlot, logEvent } from "./shared.ts";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The one thing that happens on a 911 call which no tool can write down: the
|
|
6
|
+
* caller stops being there.
|
|
7
|
+
*
|
|
8
|
+
* Every line on an incident's timeline so far was written by a tool, so the
|
|
9
|
+
* board has nothing to say about the outcome that involves no tool at all — the
|
|
10
|
+
* line going dead. It arrives as a SESSION EVENT, and `agent({ events })` is
|
|
11
|
+
* how an agent observes its own stream.
|
|
12
|
+
*
|
|
13
|
+
* **The dialog deliberately does NOT move on it, and that is the difference
|
|
14
|
+
* between this desk and a phone desk.** `retail` and `roadside-assist` both
|
|
15
|
+
* carry `"@session.timed-out"` into a `final` state, because there the caller
|
|
16
|
+
* IS the conversation and a hang-up ends it. Here the caller is one input to a
|
|
17
|
+
* shift: units are rolling, the board is live, and the dispatcher goes on
|
|
18
|
+
* working every incident on it. So a hang-up is a FACT ABOUT ONE INCIDENT,
|
|
19
|
+
* recorded where the rest of that incident's history is, and `callFlow` stays
|
|
20
|
+
* exactly where it was.
|
|
21
|
+
*
|
|
22
|
+
* Which incident is {@link callInHand}'s question, and it is the same question
|
|
23
|
+
* the flow's position answers — see its doc. On a shift with nothing open there
|
|
24
|
+
* is nothing to write and nothing is written; a dropped call before the first
|
|
25
|
+
* `incident_create` left no record to annotate.
|
|
26
|
+
*
|
|
27
|
+
* Three properties of a handler this file depends on, all the SDK's: a handler
|
|
28
|
+
* is OBSERVE-ONLY (nothing here can make the desk say anything — a dispatcher
|
|
29
|
+
* finding out is the timeline's job), a throw in one is non-fatal, and delivery
|
|
30
|
+
* is at-least-once. The last one is why the line is worth checking against:
|
|
31
|
+
* a duplicated timeline entry is a cosmetic repeat, not a duplicated truck.
|
|
32
|
+
*/
|
|
33
|
+
export const DISPATCH_EVENTS: SessionEventHandlers = {
|
|
34
|
+
"session.timed-out": (_event, ctx) => {
|
|
35
|
+
// A `SessionEventContext` is a `SlotHolder`, which is all a slot write
|
|
36
|
+
// needs — and all it is: there is no `generate`, no `send`, and no way for
|
|
37
|
+
// this to reach the caller who has just gone.
|
|
38
|
+
dispatchSlot.update(ctx, (state) => {
|
|
39
|
+
const incident = callInHand(state);
|
|
40
|
+
if (incident === undefined) return;
|
|
41
|
+
logEvent(
|
|
42
|
+
incident,
|
|
43
|
+
"CALLER LOST — line dropped or went silent. Units stay committed; " +
|
|
44
|
+
"attempt callback on the number on file.",
|
|
45
|
+
);
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
};
|
|
@@ -263,7 +263,7 @@ export const dashboardProjection = dispatchSlot.projection(dashboardView);
|
|
|
263
263
|
* `as const` is what keeps the `on` keys literal, so `DialogEvent` synthesizes
|
|
264
264
|
* the event union from them and a misspelled `send` is a compile error.
|
|
265
265
|
*/
|
|
266
|
-
const callSpec = {
|
|
266
|
+
export const callSpec = {
|
|
267
267
|
initial: "standby",
|
|
268
268
|
states: {
|
|
269
269
|
standby: {
|
|
@@ -310,6 +310,13 @@ const callSpec = {
|
|
|
310
310
|
* about the conversation and the board is many facts about the world. One tool
|
|
311
311
|
* call moves both — every converted tool opens `dispatchSlot.update` inside its
|
|
312
312
|
* `execute` and lets the flow's own `send` follow it.
|
|
313
|
+
*
|
|
314
|
+
* **It is DECLARED on the agent** (`dialogs: [callFlow]`), which is what puts
|
|
315
|
+
* the active state's `instruction` in front of the model on every turn rather
|
|
316
|
+
* than only on the turns that happen to call a gated tool. Every sentence in
|
|
317
|
+
* the states below is written to be read that way; without the declaration the
|
|
318
|
+
* gate still holds and the instruction reaches nobody on a turn the dispatcher
|
|
319
|
+
* spends talking.
|
|
313
320
|
*/
|
|
314
321
|
export const callFlow = dialog("call", callSpec);
|
|
315
322
|
|
|
@@ -370,6 +377,40 @@ export function findIncident<I extends DeepReadonly<Incident>>(
|
|
|
370
377
|
return state.incidents[incidentId] ?? { error: `Incident ${incidentId} not found` };
|
|
371
378
|
}
|
|
372
379
|
|
|
380
|
+
/**
|
|
381
|
+
* The incident the dispatcher is working, or `undefined` on a shift with
|
|
382
|
+
* nothing open.
|
|
383
|
+
*
|
|
384
|
+
* This is {@link callFlow}'s own reading of the board, expressed over the data:
|
|
385
|
+
* `working.monitoring` means "the incident this dispatcher LAST TOUCHED has
|
|
386
|
+
* units on it", and every write goes through {@link logEvent}, which touches
|
|
387
|
+
* `updatedAt`. So the most recently updated OPEN incident is the one the
|
|
388
|
+
* position is about. A resolved incident is never it — its caller is off the
|
|
389
|
+
* line and its units have been released.
|
|
390
|
+
*
|
|
391
|
+
* Why a function rather than an `Incident.id` field on the board: a stored
|
|
392
|
+
* "current" pointer is a second copy of a fact `updatedAt` already carries, and
|
|
393
|
+
* the two disagree the first time a tool forgets to update it.
|
|
394
|
+
*
|
|
395
|
+
* Generic for the same reason {@link findIncident} is — one lookup serves a
|
|
396
|
+
* mutable draft and a frozen read alike.
|
|
397
|
+
*
|
|
398
|
+
* `updatedAt` is `Date.now()`, so two incidents touched inside one millisecond
|
|
399
|
+
* tie; `>=` breaks that toward the one enumerated LAST, which for an insertion-
|
|
400
|
+
* ordered record is the most recently logged. Real calls are seconds apart and
|
|
401
|
+
* the tie only shows up in a test that logs two incidents in a row.
|
|
402
|
+
*/
|
|
403
|
+
export function callInHand<I extends DeepReadonly<Incident>>(state: {
|
|
404
|
+
readonly incidents: { readonly [id: string]: I };
|
|
405
|
+
}): I | undefined {
|
|
406
|
+
let latest: I | undefined;
|
|
407
|
+
for (const inc of Object.values(state.incidents)) {
|
|
408
|
+
if (inc.status === "resolved") continue;
|
|
409
|
+
if (latest === undefined || inc.updatedAt >= latest.updatedAt) latest = inc;
|
|
410
|
+
}
|
|
411
|
+
return latest;
|
|
412
|
+
}
|
|
413
|
+
|
|
373
414
|
/** Append a timeline entry and touch `updatedAt`, holding
|
|
374
415
|
* {@link MAX_TIMELINE_ENTRIES}. Capped on APPEND rather than swept later, so
|
|
375
416
|
* a single long-running incident cannot outgrow the payload between sweeps. */
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { plural } from "@alexkroman1/aai/utils";
|
|
1
2
|
import { z } from "zod";
|
|
2
3
|
import {
|
|
3
4
|
calculateTriageScore,
|
|
@@ -87,8 +88,8 @@ export default dispatchSlot.updateTool({
|
|
|
87
88
|
recommendedResources: recommended.map(resourceBrief),
|
|
88
89
|
message:
|
|
89
90
|
recSeverity === "critical"
|
|
90
|
-
? `PRIORITY ONE — ${id} created. Immediate dispatch recommended. ${protocols.length} protocol
|
|
91
|
-
: `${id} created. Triage score ${triageScore}. ${recommended.length} resource
|
|
91
|
+
? `PRIORITY ONE — ${id} created. Immediate dispatch recommended. ${protocols.length} ${plural(protocols.length, "protocol")} applicable.`
|
|
92
|
+
: `${id} created. Triage score ${triageScore}. ${recommended.length} ${plural(recommended.length, "resource")} recommended.`,
|
|
92
93
|
};
|
|
93
94
|
},
|
|
94
95
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isToolFailure } from "@alexkroman1/aai";
|
|
2
|
+
import { plural } from "@alexkroman1/aai/utils";
|
|
2
3
|
import { z } from "zod";
|
|
3
4
|
import {
|
|
4
5
|
assertNotResolved,
|
|
@@ -89,7 +90,7 @@ export default callFlow.tool({
|
|
|
89
90
|
callsign: r.callsign,
|
|
90
91
|
type: r.type,
|
|
91
92
|
})),
|
|
92
|
-
message: `ESCALATION CONFIRMED — ${args.incidentId} now Level ${inc.escalationLevel}. ${additionalResources.length} additional resource
|
|
93
|
+
message: `ESCALATION CONFIRMED — ${args.incidentId} now Level ${inc.escalationLevel}. ${additionalResources.length} additional ${plural(additionalResources.length, "resource")} available for dispatch.`,
|
|
93
94
|
};
|
|
94
95
|
}),
|
|
95
96
|
});
|
|
@@ -1,26 +1,48 @@
|
|
|
1
1
|
import { dispatchSlot, incidentAgeMinutes, resourceBrief, resourceUtilization } from "../shared.ts";
|
|
2
2
|
|
|
3
|
+
/** Which `resourceSummary` counter a status belongs to — the two spellings differ. */
|
|
4
|
+
const COUNT_KEY = {
|
|
5
|
+
available: "available",
|
|
6
|
+
dispatched: "dispatched",
|
|
7
|
+
en_route: "enRoute",
|
|
8
|
+
on_scene: "onScene",
|
|
9
|
+
returning: "returning",
|
|
10
|
+
} as const;
|
|
11
|
+
|
|
3
12
|
export default dispatchSlot.tool({
|
|
4
13
|
description:
|
|
5
14
|
"Get the full operational dashboard: alert level, resource utilization, active incidents, and available resources.",
|
|
6
15
|
execute(_args, state) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
16
|
+
// The incidents, split in one pass rather than filtered twice over the same
|
|
17
|
+
// record: every incident is either active or resolved.
|
|
18
|
+
type Incident = (typeof state.incidents)[string];
|
|
19
|
+
const activeIncidents: Incident[] = [];
|
|
20
|
+
let resolvedCount = 0;
|
|
21
|
+
for (const incident of Object.values(state.incidents)) {
|
|
22
|
+
if (incident.status === "resolved") resolvedCount += 1;
|
|
23
|
+
else activeIncidents.push(incident);
|
|
24
|
+
}
|
|
25
|
+
activeIncidents.sort((a, b) => b.triageScore - a.triageScore);
|
|
14
26
|
|
|
27
|
+
// Likewise the resource breakdown: five `.filter().length` scans and a sixth
|
|
28
|
+
// for the briefs, all over the one list, become one walk of it.
|
|
15
29
|
const resourceSummary = {
|
|
16
30
|
total: state.resources.length,
|
|
17
|
-
available:
|
|
18
|
-
dispatched:
|
|
19
|
-
enRoute:
|
|
20
|
-
onScene:
|
|
21
|
-
returning:
|
|
31
|
+
available: 0,
|
|
32
|
+
dispatched: 0,
|
|
33
|
+
enRoute: 0,
|
|
34
|
+
onScene: 0,
|
|
35
|
+
returning: 0,
|
|
22
36
|
};
|
|
37
|
+
const availableResources: ReturnType<typeof resourceBrief>[] = [];
|
|
38
|
+
for (const resource of state.resources) {
|
|
39
|
+
resourceSummary[COUNT_KEY[resource.status]] += 1;
|
|
40
|
+
if (resource.status === "available") availableResources.push(resourceBrief(resource));
|
|
41
|
+
}
|
|
23
42
|
|
|
43
|
+
// Still `resourceUtilization`, not a ratio derived from the counts above:
|
|
44
|
+
// that function is deliberately the ONE definition of the word, shared with
|
|
45
|
+
// the alert level, and a second one here is how the two come to disagree.
|
|
24
46
|
const utilization = Math.round(resourceUtilization(state) * 100);
|
|
25
47
|
|
|
26
48
|
return {
|
|
@@ -44,9 +66,7 @@ export default dispatchSlot.tool({
|
|
|
44
66
|
ageMinutes: incidentAgeMinutes(i),
|
|
45
67
|
casualties: i.casualties,
|
|
46
68
|
})),
|
|
47
|
-
availableResources
|
|
48
|
-
.filter((r) => r.status === "available")
|
|
49
|
-
.map(resourceBrief),
|
|
69
|
+
availableResources,
|
|
50
70
|
};
|
|
51
71
|
},
|
|
52
72
|
});
|