@alexkroman1/aai-cli 0.12.3 → 0.13.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 +69 -0
- package/bin.mjs +58 -0
- package/dist/_agent-BopNO5Bq.mjs +152 -0
- package/dist/_agent.d.ts +83 -0
- package/dist/_api-client.d.ts +92 -0
- package/dist/_artifacts-BJOYGQPp.mjs +21 -0
- package/dist/_artifacts.d.ts +16 -0
- package/dist/_build-target-C08aM-Es.mjs +1119 -0
- package/dist/_build-target.d.ts +276 -0
- package/dist/_bundler-CgBw5Bcu.mjs +102 -0
- package/dist/_bundler.d.ts +60 -0
- package/dist/_cli-common.d.ts +173 -0
- package/dist/_client-plugins.d.ts +57 -0
- package/dist/_config-mq1I5Cva.mjs +263 -0
- package/dist/_config.d.ts +122 -0
- package/dist/_console-audio.d.ts +17 -0
- package/dist/_console-session.d.ts +70 -0
- package/dist/_default-html.d.ts +33 -0
- package/dist/_deno-output.d.ts +23 -0
- package/dist/_deno-target.d.ts +74 -0
- package/dist/_deploy.d.ts +22 -0
- package/dist/_dev-agent-env.d.ts +27 -0
- package/dist/_dev-env-D9Uy5wNt.mjs +89 -0
- package/dist/_dev-env.d.ts +77 -0
- package/dist/_dev-restart.d.ts +64 -0
- package/dist/_dev-server-BNq5OnUJ.mjs +737 -0
- package/dist/_dev-server.d.ts +89 -0
- package/dist/_dev-session-ticket.d.ts +63 -0
- package/dist/_dev-source.d.ts +55 -0
- package/dist/_dev-tunnel.d.ts +90 -0
- package/dist/_dev-typecheck.d.ts +38 -0
- package/dist/_dev-vite-config.d.ts +100 -0
- package/dist/_dev-watch.d.ts +35 -0
- package/dist/_dotenv-file.d.ts +45 -0
- package/dist/_e2e-test-utils.d.ts +120 -0
- package/dist/_fault-mode.d.ts +194 -0
- package/dist/_help.d.ts +31 -0
- package/dist/_init.d.ts +66 -0
- package/dist/_mock-api.d.ts +22 -0
- package/dist/_mock-registry.d.ts +17 -0
- package/dist/_modal-app.d.ts +77 -0
- package/dist/_modal-output.d.ts +31 -0
- package/dist/_modal-target.d.ts +69 -0
- package/dist/_output-DBP9Op_d.mjs +120 -0
- package/dist/_output.d.ts +74 -0
- package/dist/_preflight-Bv6Ct4ss.mjs +149 -0
- package/dist/_preflight.d.ts +170 -0
- package/dist/_resource-commands.d.ts +22 -0
- package/dist/_run-code-deno-C0AtfHeH.mjs +268 -0
- package/dist/_run-code-deno.d.ts +130 -0
- package/dist/_server-common-CVXIeWrY.mjs +114 -0
- package/dist/_server-common.d.ts +75 -0
- package/dist/_slug-api-DJuwYZ6T.mjs +68 -0
- package/dist/_slug-api.d.ts +61 -0
- package/dist/_stop-server.d.ts +17 -0
- package/dist/_studio-BH05zugt.mjs +251 -0
- package/dist/_studio-commands.d.ts +73 -0
- package/dist/_studio.d.ts +80 -0
- package/dist/_target-bundle.d.ts +139 -0
- package/dist/_target-drain.d.ts +44 -0
- package/dist/_target-entry.d.ts +81 -0
- package/dist/_target-output.d.ts +63 -0
- package/dist/_templates-Bv-rd0SO.mjs +135 -0
- package/dist/_templates.d.ts +82 -0
- package/dist/_typecheck-gate-CcX2gLJZ.mjs +19 -0
- package/dist/_typecheck-gate.d.ts +11 -0
- package/dist/_ui-Coe0zwmm.mjs +102 -0
- package/dist/_ui.d.ts +90 -0
- package/dist/_utils-BVLdBvdT.mjs +186 -0
- package/dist/_utils.d.ts +126 -0
- package/dist/_vercel-output.d.ts +48 -0
- package/dist/_vercel-target.d.ts +169 -0
- package/dist/_vite-env-BiyJ0GQH.mjs +105 -0
- package/dist/_vite-env.d.ts +38 -0
- package/dist/_vitest-runner-CKI8_K1b.mjs +207 -0
- package/dist/_vitest-runner.d.ts +182 -0
- package/dist/_workflow-determinism-CLxFQ5ox.mjs +198 -0
- package/dist/_workflow-determinism.d.ts +118 -0
- package/dist/build-B37oBfEv.mjs +592 -0
- package/dist/build.d.ts +146 -0
- package/dist/cli-workflow.d.ts +10 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.mjs +1063 -198
- package/dist/client-bundler-D4SeZJ8E.mjs +240 -0
- package/dist/client-bundler.d.ts +32 -0
- package/dist/client-bundler.mjs +3 -0
- package/dist/console-D6OOjjeJ.mjs +443 -0
- package/dist/console.d.ts +70 -0
- package/dist/delete-Br0EOH0g.mjs +55 -0
- package/dist/delete.d.ts +25 -0
- package/dist/deploy-CLUH5cv2.mjs +97 -0
- package/dist/deploy.d.ts +25 -0
- package/dist/dev-ZVuyPLUk.mjs +274 -0
- package/dist/dev.d.ts +34 -0
- package/dist/eval-Dl8o91yC.mjs +74 -0
- package/dist/eval.d.ts +46 -0
- package/dist/init-x3FsKl2q.mjs +609 -0
- package/dist/init.d.ts +101 -0
- package/dist/login-oJdBWu2B.mjs +166 -0
- package/dist/login.d.ts +54 -0
- package/dist/logs-BfRq1HX9.mjs +80 -0
- package/dist/logs.d.ts +65 -0
- package/dist/project-config.d.ts +23 -0
- package/dist/project-config.mjs +3 -0
- package/dist/scaffold/.env.example +51 -0
- package/dist/scaffold/CLAUDE.md +390 -0
- package/dist/scaffold/agent-guide/AGENT-API.md +223 -0
- package/dist/scaffold/agent-guide/HOSTING.md +140 -0
- package/dist/scaffold/agent-guide/PIPELINE-TUNING.md +235 -0
- package/dist/scaffold/agent-guide/PROVIDERS.md +143 -0
- package/dist/scaffold/agent-guide/TESTING-EVALS.md +158 -0
- package/dist/scaffold/agent-guide/TOOLS.md +628 -0
- package/dist/scaffold/agent-guide/UI.md +291 -0
- package/dist/scaffold/agent-guide/WORKFLOWS.md +801 -0
- package/dist/scaffold/package.json +38 -0
- package/dist/scaffold/pnpm-workspace.yaml +45 -0
- package/dist/scaffold/tsconfig.json +3 -0
- package/dist/scaffold/vitest.config.ts +8 -0
- package/dist/secret-Db1UWLSZ.mjs +300 -0
- package/dist/secret.d.ts +70 -0
- package/dist/start.d.ts +112 -0
- package/dist/start.mjs +183 -0
- package/dist/studio-DAoJApzD.mjs +209 -0
- package/dist/studio.d.ts +55 -0
- package/dist/templates/applicant-screening-agent/agent.eval.test.ts +258 -0
- package/dist/templates/applicant-screening-agent/agent.test.ts +987 -0
- package/dist/templates/applicant-screening-agent/agent.ts +66 -0
- package/dist/templates/applicant-screening-agent/client.tsx +154 -0
- package/dist/templates/applicant-screening-agent/crews.ts +432 -0
- package/dist/templates/applicant-screening-agent/leads.json +86 -0
- package/dist/templates/applicant-screening-agent/screening-lock.test.ts +77 -0
- package/dist/templates/applicant-screening-agent/screening-lock.ts +51 -0
- package/dist/templates/applicant-screening-agent/shared.ts +483 -0
- package/dist/templates/applicant-screening-agent/system-prompt.md +21 -0
- package/dist/templates/applicant-screening-agent/tools/candidate_details.ts +49 -0
- package/dist/templates/applicant-screening-agent/tools/proceed_to_emails.ts +127 -0
- package/dist/templates/applicant-screening-agent/tools/read_email.ts +50 -0
- package/dist/templates/applicant-screening-agent/tools/rescore_with_feedback.ts +140 -0
- package/dist/templates/applicant-screening-agent/tools/screen_candidates.ts +128 -0
- package/dist/templates/applicant-screening-agent/tools/screening_status.ts +51 -0
- package/dist/templates/call-audit-workflow/agent.eval.test.ts +492 -0
- package/dist/templates/call-audit-workflow/agent.test.ts +1032 -0
- package/dist/templates/call-audit-workflow/agent.ts +161 -0
- package/dist/templates/call-audit-workflow/client.tsx +236 -0
- package/dist/templates/call-audit-workflow/guards.test.ts +233 -0
- package/dist/templates/call-audit-workflow/workflows/audit.ts +391 -0
- package/dist/templates/call-audit-workflow/workflows/ingest.ts +279 -0
- package/dist/templates/call-audit-workflow/workflows/media.ts +729 -0
- package/dist/templates/call-audit-workflow/workflows/summarize.ts +201 -0
- package/dist/templates/call-audit-workflow/workflows/sync-api.ts +54 -0
- package/dist/templates/code-interpreter-agent/agent.eval.test.ts +195 -0
- package/dist/templates/code-interpreter-agent/agent.test.ts +91 -0
- package/dist/templates/code-interpreter-agent/agent.ts +9 -0
- package/dist/templates/code-interpreter-agent/system-prompt.md +18 -0
- package/dist/templates/coding-agent/agent.eval.test.ts +135 -0
- package/dist/templates/coding-agent/agent.test.ts +109 -0
- package/dist/templates/coding-agent/agent.ts +45 -0
- package/dist/templates/coding-agent/chat.ts +63 -0
- package/dist/templates/coding-agent/shared.ts +46 -0
- package/dist/templates/coding-agent/system-prompt.md +32 -0
- package/dist/templates/coding-agent/tools/bash.ts +6 -0
- package/dist/templates/coding-agent/tools/delete_file.ts +6 -0
- package/dist/templates/coding-agent/tools/edit_file.ts +6 -0
- package/dist/templates/coding-agent/tools/glob.ts +6 -0
- package/dist/templates/coding-agent/tools/grep.ts +6 -0
- package/dist/templates/coding-agent/tools/list_files.ts +6 -0
- package/dist/templates/coding-agent/tools/read_file.ts +6 -0
- package/dist/templates/coding-agent/tools/todo_write.ts +6 -0
- package/dist/templates/coding-agent/tools/write_file.ts +6 -0
- package/dist/templates/custom-pipeline-agent/agent.eval.test.ts +79 -0
- package/dist/templates/custom-pipeline-agent/agent.test.ts +79 -0
- package/dist/templates/custom-pipeline-agent/agent.ts +13 -0
- package/dist/templates/custom-pipeline-agent/modes.test.ts +162 -0
- package/dist/templates/custom-pipeline-agent/stages.test.ts +330 -0
- package/dist/templates/document-redline-workflow/agent.eval.test.ts +254 -0
- package/dist/templates/document-redline-workflow/agent.test.ts +552 -0
- package/dist/templates/document-redline-workflow/agent.ts +112 -0
- package/dist/templates/document-redline-workflow/client.tsx +224 -0
- package/dist/templates/document-redline-workflow/form.ts +74 -0
- package/dist/templates/document-redline-workflow/workflows/prompts.ts +68 -0
- package/dist/templates/document-redline-workflow/workflows/redline.ts +317 -0
- package/dist/templates/emergency-dispatch-agent/agent.eval.test.ts +372 -0
- package/dist/templates/emergency-dispatch-agent/agent.test.ts +576 -0
- package/dist/templates/emergency-dispatch-agent/agent.ts +63 -0
- package/dist/templates/emergency-dispatch-agent/client.tsx +453 -0
- package/dist/templates/emergency-dispatch-agent/events.ts +48 -0
- package/dist/templates/emergency-dispatch-agent/guardrails.ts +105 -0
- package/dist/templates/emergency-dispatch-agent/shared.ts +768 -0
- package/dist/templates/emergency-dispatch-agent/system-prompt.md +42 -0
- package/dist/templates/emergency-dispatch-agent/tools/incident_add_note.ts +28 -0
- package/dist/templates/emergency-dispatch-agent/tools/incident_create.ts +95 -0
- package/dist/templates/emergency-dispatch-agent/tools/incident_escalate.ts +96 -0
- package/dist/templates/emergency-dispatch-agent/tools/incident_get.ts +40 -0
- package/dist/templates/emergency-dispatch-agent/tools/incident_triage.ts +90 -0
- package/dist/templates/emergency-dispatch-agent/tools/incident_update_status.ts +75 -0
- package/dist/templates/emergency-dispatch-agent/tools/ops_dashboard.ts +72 -0
- package/dist/templates/emergency-dispatch-agent/tools/ops_protocols.ts +27 -0
- package/dist/templates/emergency-dispatch-agent/tools/ops_run_scenario.ts +154 -0
- package/dist/templates/emergency-dispatch-agent/tools/resources_dispatch.ts +112 -0
- package/dist/templates/emergency-dispatch-agent/tools/resources_get_available.ts +34 -0
- package/dist/templates/emergency-dispatch-agent/tools/resources_update_status.ts +63 -0
- package/dist/templates/entertainment-picks-agent/agent.eval.test.ts +281 -0
- package/dist/templates/entertainment-picks-agent/agent.test.ts +260 -0
- package/dist/templates/entertainment-picks-agent/agent.ts +14 -0
- package/dist/templates/entertainment-picks-agent/client.tsx +169 -0
- package/dist/templates/entertainment-picks-agent/shared.ts +50 -0
- package/dist/templates/entertainment-picks-agent/system-prompt.md +19 -0
- package/dist/templates/entertainment-picks-agent/tools/recommend.ts +79 -0
- package/dist/templates/entertainment-picks-agent/tools/revisit.ts +56 -0
- package/dist/templates/executive-inbox-agent/agent.eval.test.ts +296 -0
- package/dist/templates/executive-inbox-agent/agent.test.ts +682 -0
- package/dist/templates/executive-inbox-agent/agent.ts +51 -0
- package/dist/templates/executive-inbox-agent/calendar.test.ts +203 -0
- package/dist/templates/executive-inbox-agent/client.tsx +195 -0
- package/dist/templates/executive-inbox-agent/inbox.ts +233 -0
- package/dist/templates/executive-inbox-agent/meeting.ts +138 -0
- package/dist/templates/executive-inbox-agent/nodes.ts +148 -0
- package/dist/templates/executive-inbox-agent/prompts.ts +333 -0
- package/dist/templates/executive-inbox-agent/review.ts +425 -0
- package/dist/templates/executive-inbox-agent/shared.ts +486 -0
- package/dist/templates/executive-inbox-agent/system-prompt.md +15 -0
- package/dist/templates/executive-inbox-agent/tools/accept.ts +10 -0
- package/dist/templates/executive-inbox-agent/tools/ask_question.ts +30 -0
- package/dist/templates/executive-inbox-agent/tools/draft_reply.ts +67 -0
- package/dist/templates/executive-inbox-agent/tools/edit.ts +10 -0
- package/dist/templates/executive-inbox-agent/tools/ignore.ts +10 -0
- package/dist/templates/executive-inbox-agent/tools/inbox_status.ts +27 -0
- package/dist/templates/executive-inbox-agent/tools/meeting_assistant.ts +52 -0
- package/dist/templates/executive-inbox-agent/tools/new_email.ts +50 -0
- package/dist/templates/executive-inbox-agent/tools/open_email.ts +157 -0
- package/dist/templates/executive-inbox-agent/tools/respond.ts +10 -0
- package/dist/templates/executive-inbox-agent/tools/review_memory.ts +22 -0
- package/dist/templates/executive-inbox-agent/tools/send_calendar_invite.ts +68 -0
- package/dist/templates/executive-inbox-agent/tools/triage_inbox.ts +75 -0
- package/dist/templates/front-desk-agent/agent.eval.test.ts +177 -0
- package/dist/templates/front-desk-agent/agent.test.ts +155 -0
- package/dist/templates/front-desk-agent/agent.ts +22 -0
- package/dist/templates/front-desk-agent/shared.ts +239 -0
- package/dist/templates/front-desk-agent/system-prompt.md +13 -0
- package/dist/templates/front-desk-agent/tools/verify_account.ts +41 -0
- package/dist/templates/home-assistant-agent/agent.eval.test.ts +176 -0
- package/dist/templates/home-assistant-agent/agent.test.ts +513 -0
- package/dist/templates/home-assistant-agent/agent.ts +37 -0
- package/dist/templates/home-assistant-agent/client.tsx +176 -0
- package/dist/templates/home-assistant-agent/ring.tsx +55 -0
- package/dist/templates/home-assistant-agent/shared.ts +130 -0
- package/dist/templates/home-assistant-agent/system-prompt.md +43 -0
- package/dist/templates/home-assistant-agent/tools/cancel_reminders.ts +16 -0
- package/dist/templates/home-assistant-agent/tools/deep_research.ts +55 -0
- package/dist/templates/home-assistant-agent/tools/remind_me.ts +53 -0
- package/dist/templates/home-assistant-agent/tools/stop.ts +25 -0
- package/dist/templates/home-assistant-agent/use-speaker.ts +98 -0
- package/dist/templates/home-assistant-agent/workflows/remind.ts +25 -0
- package/dist/templates/home-assistant-agent/workflows/research-prompts.ts +41 -0
- package/dist/templates/home-assistant-agent/workflows/research.ts +110 -0
- package/dist/templates/home-assistant-agent/workflows/text.ts +30 -0
- package/dist/templates/hotel-reception-agent/agent.eval.test.ts +241 -0
- package/dist/templates/hotel-reception-agent/agent.test.ts +1121 -0
- package/dist/templates/hotel-reception-agent/agent.ts +66 -0
- package/dist/templates/hotel-reception-agent/booking.ts +159 -0
- package/dist/templates/hotel-reception-agent/card.ts +92 -0
- package/dist/templates/hotel-reception-agent/catalogs.ts +219 -0
- package/dist/templates/hotel-reception-agent/client.tsx +150 -0
- package/dist/templates/hotel-reception-agent/concierge.ts +104 -0
- package/dist/templates/hotel-reception-agent/desk-seams.test.ts +339 -0
- package/dist/templates/hotel-reception-agent/desk.ts +220 -0
- package/dist/templates/hotel-reception-agent/disputes.ts +214 -0
- package/dist/templates/hotel-reception-agent/events.ts +80 -0
- package/dist/templates/hotel-reception-agent/hotel.ts +412 -0
- package/dist/templates/hotel-reception-agent/policies.ts +209 -0
- package/dist/templates/hotel-reception-agent/records.ts +384 -0
- package/dist/templates/hotel-reception-agent/restaurant.ts +147 -0
- package/dist/templates/hotel-reception-agent/seed.ts +955 -0
- package/dist/templates/hotel-reception-agent/session.ts +50 -0
- package/dist/templates/hotel-reception-agent/shared.ts +353 -0
- package/dist/templates/hotel-reception-agent/system-prompt.md +76 -0
- package/dist/templates/hotel-reception-agent/tools/abandon_booking.ts +31 -0
- package/dist/templates/hotel-reception-agent/tools/add_to_waitlist.ts +42 -0
- package/dist/templates/hotel-reception-agent/tools/book_airport_car.ts +58 -0
- package/dist/templates/hotel-reception-agent/tools/book_business_center.ts +44 -0
- package/dist/templates/hotel-reception-agent/tools/book_spa_appointment.ts +39 -0
- package/dist/templates/hotel-reception-agent/tools/book_tour.ts +35 -0
- package/dist/templates/hotel-reception-agent/tools/cancel_restaurant_reservation.ts +26 -0
- package/dist/templates/hotel-reception-agent/tools/cancel_room_booking.ts +64 -0
- package/dist/templates/hotel-reception-agent/tools/check_restaurant_availability.ts +24 -0
- package/dist/templates/hotel-reception-agent/tools/check_room_availability.ts +40 -0
- package/dist/templates/hotel-reception-agent/tools/choose_room.ts +93 -0
- package/dist/templates/hotel-reception-agent/tools/confirm_booking.ts +154 -0
- package/dist/templates/hotel-reception-agent/tools/dispatch_emergency.ts +62 -0
- package/dist/templates/hotel-reception-agent/tools/dispute_charge.ts +91 -0
- package/dist/templates/hotel-reception-agent/tools/flag_late_arrival.ts +27 -0
- package/dist/templates/hotel-reception-agent/tools/lookup_booking.ts +49 -0
- package/dist/templates/hotel-reception-agent/tools/lookup_guest_history.ts +28 -0
- package/dist/templates/hotel-reception-agent/tools/lookup_invoice.ts +27 -0
- package/dist/templates/hotel-reception-agent/tools/lookup_policy.ts +20 -0
- package/dist/templates/hotel-reception-agent/tools/lookup_restaurant_reservation.ts +27 -0
- package/dist/templates/hotel-reception-agent/tools/modify_restaurant_reservation.ts +75 -0
- package/dist/templates/hotel-reception-agent/tools/order_flowers.ts +40 -0
- package/dist/templates/hotel-reception-agent/tools/record_card.ts +46 -0
- package/dist/templates/hotel-reception-agent/tools/record_followup.ts +51 -0
- package/dist/templates/hotel-reception-agent/tools/record_group_inquiry.ts +45 -0
- package/dist/templates/hotel-reception-agent/tools/record_guest_details.ts +71 -0
- package/dist/templates/hotel-reception-agent/tools/reinstate_booking.ts +65 -0
- package/dist/templates/hotel-reception-agent/tools/request_flight_reconfirmation.ts +55 -0
- package/dist/templates/hotel-reception-agent/tools/resend_confirmation.ts +40 -0
- package/dist/templates/hotel-reception-agent/tools/reserve_table.ts +87 -0
- package/dist/templates/hotel-reception-agent/tools/resolve_room_conflict.ts +49 -0
- package/dist/templates/hotel-reception-agent/tools/schedule_wakeup_call.ts +49 -0
- package/dist/templates/hotel-reception-agent/tools/set_do_not_disturb.ts +29 -0
- package/dist/templates/hotel-reception-agent/tools/set_extras.ts +51 -0
- package/dist/templates/hotel-reception-agent/tools/set_stay.ts +98 -0
- package/dist/templates/hotel-reception-agent/tools/start_booking_modification.ts +58 -0
- package/dist/templates/hotel-reception-agent/tools/start_room_booking.ts +50 -0
- package/dist/templates/hotel-reception-agent/tools/take_guest_message.ts +72 -0
- package/dist/templates/hotel-reception-agent/tools/transfer_call.ts +48 -0
- package/dist/templates/hotel-reception-agent/tools/update_card.ts +46 -0
- package/dist/templates/hotel-reception-agent/tools/verify_booking.ts +96 -0
- package/dist/templates/link-digest-workflow/agent.eval.test.ts +231 -0
- package/dist/templates/link-digest-workflow/agent.test.ts +647 -0
- package/dist/templates/link-digest-workflow/agent.ts +100 -0
- package/dist/templates/link-digest-workflow/api-client.ts +144 -0
- package/dist/templates/link-digest-workflow/client.tsx +231 -0
- package/dist/templates/link-digest-workflow/workflows/digest.ts +334 -0
- package/dist/templates/medication-safety-agent/agent.eval.test.ts +182 -0
- package/dist/templates/medication-safety-agent/agent.test.ts +332 -0
- package/dist/templates/medication-safety-agent/agent.ts +62 -0
- package/dist/templates/medication-safety-agent/fda.test.ts +130 -0
- package/dist/templates/medication-safety-agent/fda.ts +159 -0
- package/dist/templates/medication-safety-agent/system-prompt.md +26 -0
- package/dist/templates/medication-safety-agent/tools/check_drug_interaction.ts +62 -0
- package/dist/templates/medication-safety-agent/tools/medication_lookup.ts +36 -0
- package/dist/templates/meeting-recap-agent/agent.eval.test.ts +446 -0
- package/dist/templates/meeting-recap-agent/agent.test.ts +1408 -0
- package/dist/templates/meeting-recap-agent/agent.ts +104 -0
- package/dist/templates/meeting-recap-agent/shared.ts +44 -0
- package/dist/templates/meeting-recap-agent/tools/cancel_recap.ts +23 -0
- package/dist/templates/meeting-recap-agent/tools/keep_transcript.ts +31 -0
- package/dist/templates/meeting-recap-agent/tools/recap_progress.ts +24 -0
- package/dist/templates/meeting-recap-agent/tools/recap_status.ts +45 -0
- package/dist/templates/meeting-recap-agent/tools/request_recap.ts +44 -0
- package/dist/templates/meeting-recap-agent/workflows/recap.ts +838 -0
- package/dist/templates/meeting-recap-agent/workflows/tokens.ts +47 -0
- package/dist/templates/pizza-ordering-agent/agent.eval.test.ts +228 -0
- package/dist/templates/pizza-ordering-agent/agent.test.ts +299 -0
- package/dist/templates/pizza-ordering-agent/agent.ts +24 -0
- package/dist/templates/pizza-ordering-agent/client.tsx +104 -0
- package/dist/templates/pizza-ordering-agent/shared.ts +225 -0
- package/dist/templates/pizza-ordering-agent/system-prompt.md +23 -0
- package/dist/templates/pizza-ordering-agent/tools/add_pizza.ts +27 -0
- package/dist/templates/pizza-ordering-agent/tools/place_order.ts +26 -0
- package/dist/templates/pizza-ordering-agent/tools/remove_pizza.ts +18 -0
- package/dist/templates/pizza-ordering-agent/tools/set_customer_name.ts +13 -0
- package/dist/templates/pizza-ordering-agent/tools/update_pizza.ts +28 -0
- package/dist/templates/pizza-ordering-agent/tools/view_order.ts +21 -0
- package/dist/templates/podcast-digest-workflow/agent.eval.test.ts +421 -0
- package/dist/templates/podcast-digest-workflow/agent.test.ts +1225 -0
- package/dist/templates/podcast-digest-workflow/agent.ts +143 -0
- package/dist/templates/podcast-digest-workflow/client.tsx +259 -0
- package/dist/templates/podcast-digest-workflow/workflows/digest.ts +499 -0
- package/dist/templates/podcast-digest-workflow/workflows/feeds.ts +575 -0
- package/dist/templates/podcast-digest-workflow/workflows/slack.ts +153 -0
- package/dist/templates/push-to-talk-agent/agent.eval.test.ts +78 -0
- package/dist/templates/push-to-talk-agent/agent.test.ts +63 -0
- package/dist/templates/push-to-talk-agent/agent.ts +22 -0
- package/dist/templates/push-to-talk-agent/client.tsx +124 -0
- package/dist/templates/push-to-talk-agent/shared.ts +28 -0
- package/dist/templates/push-to-talk-agent/system-prompt.md +11 -0
- package/dist/templates/push-to-talk-agent/tools/list_notes.ts +15 -0
- package/dist/templates/push-to-talk-agent/tools/save_note.ts +26 -0
- package/dist/templates/quickstart-agent/agent.eval.test.ts +148 -0
- package/dist/templates/quickstart-agent/agent.test.ts +96 -0
- package/dist/templates/quickstart-agent/agent.ts +25 -0
- package/dist/templates/quickstart-agent/system-prompt.md +8 -0
- package/dist/templates/quickstart-agent/tools/get_weather.ts +59 -0
- package/dist/templates/research-handoff-agent/agent.eval.test.ts +341 -0
- package/dist/templates/research-handoff-agent/agent.test.ts +831 -0
- package/dist/templates/research-handoff-agent/agent.ts +118 -0
- package/dist/templates/research-handoff-agent/shared.ts +41 -0
- package/dist/templates/research-handoff-agent/tools/file_it_now.ts +32 -0
- package/dist/templates/research-handoff-agent/tools/request_research.ts +33 -0
- package/dist/templates/research-handoff-agent/tools/research_progress.ts +23 -0
- package/dist/templates/research-handoff-agent/tools/research_status.ts +73 -0
- package/dist/templates/research-handoff-agent/workflows/filing.ts +164 -0
- package/dist/templates/research-handoff-agent/workflows/prompts.ts +46 -0
- package/dist/templates/research-handoff-agent/workflows/research.ts +100 -0
- package/dist/templates/research-handoff-agent/workflows/review.ts +43 -0
- package/dist/templates/research-planner-agent/agent.eval.test.ts +241 -0
- package/dist/templates/research-planner-agent/agent.test.ts +635 -0
- package/dist/templates/research-planner-agent/agent.ts +26 -0
- package/dist/templates/research-planner-agent/client.tsx +120 -0
- package/dist/templates/research-planner-agent/procedure.ts +287 -0
- package/dist/templates/research-planner-agent/prompts.ts +153 -0
- package/dist/templates/research-planner-agent/shared.ts +327 -0
- package/dist/templates/research-planner-agent/system-prompt.md +18 -0
- package/dist/templates/research-planner-agent/tools/plan_status.ts +41 -0
- package/dist/templates/research-planner-agent/tools/revise_plan.ts +71 -0
- package/dist/templates/research-planner-agent/tools/start_plan.ts +62 -0
- package/dist/templates/research-planner-agent/tools/work_next_step.ts +177 -0
- package/dist/templates/retail-orders-agent/address.ts +109 -0
- package/dist/templates/retail-orders-agent/agent.eval.test.ts +305 -0
- package/dist/templates/retail-orders-agent/agent.test.ts +1260 -0
- package/dist/templates/retail-orders-agent/agent.ts +103 -0
- package/dist/templates/retail-orders-agent/authenticate.ts +34 -0
- package/dist/templates/retail-orders-agent/cancel.ts +114 -0
- package/dist/templates/retail-orders-agent/client.tsx +579 -0
- package/dist/templates/retail-orders-agent/keyterms.ts +154 -0
- package/dist/templates/retail-orders-agent/payment.ts +103 -0
- package/dist/templates/retail-orders-agent/pending.test.ts +204 -0
- package/dist/templates/retail-orders-agent/pending.ts +137 -0
- package/dist/templates/retail-orders-agent/refund.ts +19 -0
- package/dist/templates/retail-orders-agent/registry.test.ts +446 -0
- package/dist/templates/retail-orders-agent/resolve.test.ts +100 -0
- package/dist/templates/retail-orders-agent/resolve.ts +114 -0
- package/dist/templates/retail-orders-agent/returns.ts +101 -0
- package/dist/templates/retail-orders-agent/seed.json +4260 -0
- package/dist/templates/retail-orders-agent/seed.test.ts +233 -0
- package/dist/templates/retail-orders-agent/shared.test.ts +240 -0
- package/dist/templates/retail-orders-agent/shared.ts +547 -0
- package/dist/templates/retail-orders-agent/store.test.ts +331 -0
- package/dist/templates/retail-orders-agent/store.ts +485 -0
- package/dist/templates/retail-orders-agent/swap.test.ts +189 -0
- package/dist/templates/retail-orders-agent/swap.ts +358 -0
- package/dist/templates/retail-orders-agent/system-prompt.md +152 -0
- package/dist/templates/retail-orders-agent/tools/cancel_change.ts +33 -0
- package/dist/templates/retail-orders-agent/tools/cancel_pending_order.ts +31 -0
- package/dist/templates/retail-orders-agent/tools/confirm_change.ts +42 -0
- package/dist/templates/retail-orders-agent/tools/exchange_delivered_order_items.ts +47 -0
- package/dist/templates/retail-orders-agent/tools/find_user_id_by_email.ts +31 -0
- package/dist/templates/retail-orders-agent/tools/find_user_id_by_name_zip.ts +36 -0
- package/dist/templates/retail-orders-agent/tools/get_item_details.ts +27 -0
- package/dist/templates/retail-orders-agent/tools/get_order_details.ts +37 -0
- package/dist/templates/retail-orders-agent/tools/get_product_details.ts +30 -0
- package/dist/templates/retail-orders-agent/tools/get_user_details.ts +37 -0
- package/dist/templates/retail-orders-agent/tools/list_all_product_types.ts +22 -0
- package/dist/templates/retail-orders-agent/tools/modify_pending_order_address.ts +27 -0
- package/dist/templates/retail-orders-agent/tools/modify_pending_order_items.ts +48 -0
- package/dist/templates/retail-orders-agent/tools/modify_pending_order_payment.ts +32 -0
- package/dist/templates/retail-orders-agent/tools/modify_user_address.ts +26 -0
- package/dist/templates/retail-orders-agent/tools/return_delivered_order_items.ts +37 -0
- package/dist/templates/retail-orders-agent/tools/transfer_to_human_agents.ts +28 -0
- package/dist/templates/roadside-assistance-agent/agent.eval.test.ts +283 -0
- package/dist/templates/roadside-assistance-agent/agent.test.ts +650 -0
- package/dist/templates/roadside-assistance-agent/agent.ts +89 -0
- package/dist/templates/roadside-assistance-agent/call.ts +232 -0
- package/dist/templates/roadside-assistance-agent/events.ts +92 -0
- package/dist/templates/roadside-assistance-agent/shared.ts +346 -0
- package/dist/templates/roadside-assistance-agent/system-prompt.md +37 -0
- package/dist/templates/roadside-assistance-agent/tools/acknowledge_disclosure.ts +61 -0
- package/dist/templates/roadside-assistance-agent/tools/dispatch_truck.ts +149 -0
- package/dist/templates/roadside-assistance-agent/tools/job_status.ts +38 -0
- package/dist/templates/roadside-assistance-agent/tools/lookup_coverage.ts +83 -0
- package/dist/templates/roadside-assistance-agent/tools/report_location.ts +79 -0
- package/dist/templates/roadside-assistance-agent/tools/service_disclosure.ts +51 -0
- package/dist/templates/roadside-assistance-agent/yard.test.ts +162 -0
- package/dist/templates/roadside-assistance-agent/yard.ts +183 -0
- package/dist/templates/spoken-summary-workflow/agent.eval.test.ts +354 -0
- package/dist/templates/spoken-summary-workflow/agent.test.ts +493 -0
- package/dist/templates/spoken-summary-workflow/agent.ts +164 -0
- package/dist/templates/spoken-summary-workflow/client.tsx +220 -0
- package/dist/templates/spoken-summary-workflow/workflows/summarize.ts +260 -0
- package/dist/templates/spoken-summary-workflow/workflows/transcribe.ts +137 -0
- package/dist/templates/tabletop-rpg-agent/agent.eval.test.ts +314 -0
- package/dist/templates/tabletop-rpg-agent/agent.test.ts +1000 -0
- package/dist/templates/tabletop-rpg-agent/agent.ts +58 -0
- package/dist/templates/tabletop-rpg-agent/client.tsx +814 -0
- package/dist/templates/tabletop-rpg-agent/shared.ts +1028 -0
- package/dist/templates/tabletop-rpg-agent/system-prompt.md +116 -0
- package/dist/templates/tabletop-rpg-agent/tools/action_roll.ts +119 -0
- package/dist/templates/tabletop-rpg-agent/tools/burn_momentum.ts +110 -0
- package/dist/templates/tabletop-rpg-agent/tools/check_state.ts +37 -0
- package/dist/templates/tabletop-rpg-agent/tools/oracle.ts +255 -0
- package/dist/templates/tabletop-rpg-agent/tools/setup_character.ts +228 -0
- package/dist/templates/tabletop-rpg-agent/tools/update_state.ts +194 -0
- package/dist/templates/technical-support-agent/agent.eval.test.ts +260 -0
- package/dist/templates/technical-support-agent/agent.test.ts +424 -0
- package/dist/templates/technical-support-agent/agent.ts +39 -0
- package/dist/templates/technical-support-agent/client.tsx +132 -0
- package/dist/templates/technical-support-agent/knowledge.json +65 -0
- package/dist/templates/technical-support-agent/knowledge.ts +165 -0
- package/dist/templates/technical-support-agent/nodes.ts +143 -0
- package/dist/templates/technical-support-agent/procedure.ts +453 -0
- package/dist/templates/technical-support-agent/prompts.ts +102 -0
- package/dist/templates/technical-support-agent/shared.ts +128 -0
- package/dist/templates/technical-support-agent/system-prompt.md +18 -0
- package/dist/templates/technical-support-agent/tools/answer_question.ts +134 -0
- package/dist/templates/technical-support-agent/tools/list_topics.ts +23 -0
- package/dist/templates/technical-support-agent/tools/log_ticket.ts +30 -0
- package/dist/templates/text-adventure-agent/agent.eval.test.ts +222 -0
- package/dist/templates/text-adventure-agent/agent.test.ts +429 -0
- package/dist/templates/text-adventure-agent/agent.ts +76 -0
- package/dist/templates/text-adventure-agent/client.tsx +359 -0
- package/dist/templates/text-adventure-agent/shared.ts +210 -0
- package/dist/templates/text-adventure-agent/system-prompt.md +50 -0
- package/dist/templates/text-adventure-agent/tools/game_state_drop.ts +29 -0
- package/dist/templates/text-adventure-agent/tools/game_state_flag.ts +13 -0
- package/dist/templates/text-adventure-agent/tools/game_state_get.ts +17 -0
- package/dist/templates/text-adventure-agent/tools/game_state_move.ts +15 -0
- package/dist/templates/text-adventure-agent/tools/game_state_restart.ts +13 -0
- package/dist/templates/text-adventure-agent/tools/game_state_score.ts +19 -0
- package/dist/templates/text-adventure-agent/tools/game_state_take.ts +13 -0
- package/dist/templates/topic-briefing-agent/agent.eval.test.ts +202 -0
- package/dist/templates/topic-briefing-agent/agent.test.ts +651 -0
- package/dist/templates/topic-briefing-agent/agent.ts +45 -0
- package/dist/templates/topic-briefing-agent/shared.ts +392 -0
- package/dist/templates/topic-briefing-agent/slack.ts +108 -0
- package/dist/templates/topic-briefing-agent/system-prompt.md +54 -0
- package/dist/templates/topic-briefing-agent/tools/briefing_so_far.ts +43 -0
- package/dist/templates/topic-briefing-agent/tools/research_topic.ts +80 -0
- package/dist/templates/topic-briefing-agent/tools/send_briefing.ts +115 -0
- package/dist/templates/topic-briefing-agent/tools/verify_claim.ts +123 -0
- package/dist/templates/transcription-workflow/agent.eval.test.ts +237 -0
- package/dist/templates/transcription-workflow/agent.test.ts +2032 -0
- package/dist/templates/transcription-workflow/agent.ts +188 -0
- package/dist/templates/transcription-workflow/client.tsx +511 -0
- package/dist/templates/transcription-workflow/recover.test.ts +222 -0
- package/dist/templates/transcription-workflow/recover.ts +154 -0
- package/dist/templates/transcription-workflow/run-panel.tsx +212 -0
- package/dist/templates/transcription-workflow/total-latency.tsx +170 -0
- package/dist/templates/transcription-workflow/workflows/batch.ts +189 -0
- package/dist/templates/transcription-workflow/workflows/downsample.ts +273 -0
- package/dist/templates/transcription-workflow/workflows/normalize.ts +385 -0
- package/dist/templates/transcription-workflow/workflows/stitch.ts +122 -0
- package/dist/templates/transcription-workflow/workflows/stream.ts +690 -0
- package/dist/templates/transcription-workflow/workflows/sync-api.ts +81 -0
- package/dist/templates/transcription-workflow/workflows/transcribe.ts +479 -0
- package/dist/templates/transcription-workflow/workflows/wav.ts +250 -0
- package/dist/templates/travel-concierge-agent/agent.eval.test.ts +300 -0
- package/dist/templates/travel-concierge-agent/agent.test.ts +601 -0
- package/dist/templates/travel-concierge-agent/agent.ts +62 -0
- package/dist/templates/travel-concierge-agent/call-events.ts +80 -0
- package/dist/templates/travel-concierge-agent/client.tsx +146 -0
- package/dist/templates/travel-concierge-agent/routing.ts +170 -0
- package/dist/templates/travel-concierge-agent/shared.ts +862 -0
- package/dist/templates/travel-concierge-agent/system-prompt.md +30 -0
- package/dist/templates/travel-concierge-agent/tools/book_car_rental.ts +21 -0
- package/dist/templates/travel-concierge-agent/tools/book_excursion.ts +19 -0
- package/dist/templates/travel-concierge-agent/tools/book_hotel.ts +21 -0
- package/dist/templates/travel-concierge-agent/tools/cancel_action.ts +9 -0
- package/dist/templates/travel-concierge-agent/tools/cancel_ticket.ts +21 -0
- package/dist/templates/travel-concierge-agent/tools/complete_or_escalate.ts +9 -0
- package/dist/templates/travel-concierge-agent/tools/confirm_action.ts +9 -0
- package/dist/templates/travel-concierge-agent/tools/lookup_booking.ts +36 -0
- package/dist/templates/travel-concierge-agent/tools/search_car_rentals.ts +36 -0
- package/dist/templates/travel-concierge-agent/tools/search_excursions.ts +40 -0
- package/dist/templates/travel-concierge-agent/tools/search_flights.ts +58 -0
- package/dist/templates/travel-concierge-agent/tools/search_hotels.ts +39 -0
- package/dist/templates/travel-concierge-agent/tools/to_car_rental_assistant.ts +11 -0
- package/dist/templates/travel-concierge-agent/tools/to_excursion_assistant.ts +11 -0
- package/dist/templates/travel-concierge-agent/tools/to_flight_assistant.ts +11 -0
- package/dist/templates/travel-concierge-agent/tools/to_hotel_assistant.ts +11 -0
- package/dist/templates/travel-concierge-agent/tools/update_ticket.ts +23 -0
- package/dist/templates/web-research-agent/agent.eval.test.ts +144 -0
- package/dist/templates/web-research-agent/agent.test.ts +181 -0
- package/dist/templates/web-research-agent/agent.ts +128 -0
- package/dist/templates/web-research-agent/system-prompt.md +33 -0
- package/dist/templates/word-game-agent/agent.eval.test.ts +222 -0
- package/dist/templates/word-game-agent/agent.test.ts +484 -0
- package/dist/templates/word-game-agent/agent.ts +55 -0
- package/dist/templates/word-game-agent/client.tsx +211 -0
- package/dist/templates/word-game-agent/game.ts +133 -0
- package/dist/templates/word-game-agent/guess.ts +63 -0
- package/dist/templates/word-game-agent/player.ts +67 -0
- package/dist/templates/word-game-agent/shared.ts +249 -0
- package/dist/templates/word-game-agent/system-prompt.md +15 -0
- package/dist/templates/word-game-agent/tools/final_score.ts +37 -0
- package/dist/templates/word-game-agent/tools/relay_description.ts +137 -0
- package/dist/templates/word-game-agent/tools/repeat_word.ts +19 -0
- package/dist/templates/word-game-agent/tools/skip_word.ts +31 -0
- package/dist/templates/word-game-agent/tools/start_game.ts +52 -0
- package/dist/templates/word-game-agent/words.ts +278 -0
- package/dist/test-XufelYGW.mjs +104 -0
- package/dist/test.d.ts +81 -0
- package/dist/typecheck.d.ts +44 -0
- package/dist/typecheck.mjs +185 -0
- package/dist/worker-bundler.d.ts +37 -0
- package/dist/worker-bundler.mjs +156 -0
- package/dist/workflow-CDUlTD5B.mjs +239 -0
- package/dist/workflow.d.ts +76 -0
- package/package.json +74 -28
- package/dist/_api-client-H4MFOr8j.mjs +0 -35
- package/dist/_bundler-DQtFVeww.mjs +0 -125
- package/dist/_discover-DzsMlg3G.mjs +0 -218
- package/dist/_init-CbMs9S2O.mjs +0 -56
- package/dist/_templates-BDkbj3TM.mjs +0 -72
- package/dist/_ui-DWGXImbO.mjs +0 -30
- package/dist/delete-CalIL6Pg.mjs +0 -34
- package/dist/deploy-CLs8gLHV.mjs +0 -53
- package/dist/dev-DEZKrw8v.mjs +0 -18
- package/dist/init-CNuntiij.mjs +0 -114
- package/dist/secret-xmLQ96Yz.mjs +0 -46
- package/dist/test-yqHGZPF3.mjs +0 -44
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
/** The def a DEPLOYED agent runs: authored, plus what `tools/` declares. */
|
|
2
|
+
import agentDef from "virtual:aai/agent";
|
|
3
|
+
import type { InferToolInput } from "@alexkroman1/aai";
|
|
4
|
+
// The failure vocabulary from the subpath that DECLARES it — `/utils` is the
|
|
5
|
+
// zero-dependency half a tool body (and a page) reaches for, and `client.tsx`
|
|
6
|
+
// takes the same guard from the same place.
|
|
7
|
+
import { isToolFailure } from "@alexkroman1/aai/utils";
|
|
8
|
+
import {
|
|
9
|
+
createToolContext,
|
|
10
|
+
expectDeployable,
|
|
11
|
+
expectPromptBuiltinsDeclared,
|
|
12
|
+
expectToolOk,
|
|
13
|
+
parseToolInput,
|
|
14
|
+
runTool,
|
|
15
|
+
toolInputIssues,
|
|
16
|
+
toolRunner,
|
|
17
|
+
} from "@alexkroman1/aai-runtime/testing";
|
|
18
|
+
import { describe, expect, test } from "vitest";
|
|
19
|
+
import { CATEGORIES, MAX_RECS, MOODS, nightSlot } from "./shared.ts";
|
|
20
|
+
import recommend from "./tools/recommend.ts";
|
|
21
|
+
import revisit from "./tools/revisit.ts";
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* What `recommend` takes, read off the tool itself — and what it answers,
|
|
25
|
+
* which `runTool(recommend, …)` types from the same place.
|
|
26
|
+
*
|
|
27
|
+
* `InferToolInput` rather than the `{ category: string; mood: string }` this
|
|
28
|
+
* spec used to hand-type: that is a restatement of a schema declared two files
|
|
29
|
+
* away, it is WEAKER than it (`string`, not the two enums), and nothing makes
|
|
30
|
+
* it fail when the schema moves. Imported as a MODULE for it — a tool file's
|
|
31
|
+
* default export is the very object `virtual:aai/agent` registers under its
|
|
32
|
+
* name, so handing it to `runTool` drives the same code, and a def looked up
|
|
33
|
+
* by name erases which tool has which shape.
|
|
34
|
+
*/
|
|
35
|
+
type RecommendInput = InferToolInput<typeof recommend>;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* `runTool` takes the context in the ARGUMENTS' place when a tool needs none,
|
|
39
|
+
* so `toolRunner`'s second parameter takes either — which is why it is one
|
|
40
|
+
* signature rather than an overload pair. An omitted context is a fresh one,
|
|
41
|
+
* i.e. a distinct session with an empty slot.
|
|
42
|
+
*/
|
|
43
|
+
const run = toolRunner(agentDef);
|
|
44
|
+
|
|
45
|
+
describe("entertainment-picks-agent template", () => {
|
|
46
|
+
test("is deployable: validates, is nameable, and every stage its mode needs is filled", () => {
|
|
47
|
+
// The same conversion `aai build`/`aai deploy` run. `expectDeployable`
|
|
48
|
+
// rather than `expect(() => toAgentConfig(…)).not.toThrow()`: that spelling
|
|
49
|
+
// fails as "expected function not to throw" and buries the sentence the
|
|
50
|
+
// conversion wrote, and it checks neither the nameable nor the per-mode
|
|
51
|
+
// stage cascade. `not.toThrow()` because the helper's throw IS the finding.
|
|
52
|
+
expect(() => expectDeployable(agentDef)).not.toThrow();
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
test("declares run_code, which is the other half of the template", () => {
|
|
56
|
+
// The sleep-time arithmetic is the builtin's job, not a tool's — that split
|
|
57
|
+
// IS this template's subject, so a dropped builtin leaves the agent doing
|
|
58
|
+
// mental arithmetic out loud. Asserted on the CONFIG, which is what a
|
|
59
|
+
// deploy ships.
|
|
60
|
+
expect(expectDeployable(agentDef).builtinTools).toContain("run_code");
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
test("every builtin the prompt tells Night Owl to use is one it declares", () => {
|
|
64
|
+
// `system-prompt.md` heads its arithmetic rules with `run_code`, and
|
|
65
|
+
// `agent.ts` is what makes that tool exist. The failure is silent in both
|
|
66
|
+
// directions: a prompt commanding a builtin the agent never declared
|
|
67
|
+
// produces a model apologising for a tool it cannot see. Which snake_case
|
|
68
|
+
// tokens in the prose are tool NAMES is a question for the SDK's schema
|
|
69
|
+
// rather than a list restated here — this prompt also names `wake_time`
|
|
70
|
+
// and `cycles`, which any underscore-matching scan would redden on.
|
|
71
|
+
expect(expectPromptBuiltinsDeclared(agentDef)).toContain("run_code");
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
test("recommend is discovered from tools/", () => {
|
|
75
|
+
// `toContain` rather than an exact list: a file in `tools/` IS a tool, so
|
|
76
|
+
// adding one is the edit this template most invites, and an exact list
|
|
77
|
+
// would make that edit fail a test the author never wrote. What has to hold
|
|
78
|
+
// is that discovery ran at all — a template whose `tools/` is never
|
|
79
|
+
// resolved ships a model with no tools.
|
|
80
|
+
expect(Object.keys(agentDef.tools ?? {})).toContain("recommend");
|
|
81
|
+
// Its reading half, declared the same way and discovered the same way.
|
|
82
|
+
expect(Object.keys(agentDef.tools ?? {})).toContain("revisit");
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
test("the projection an untouched session pushes is an empty log", () => {
|
|
86
|
+
// What `useAgentState(nightSlot.projected)` reads before the first tool call —
|
|
87
|
+
// derived from the slot's own default rather than guessed at in the page.
|
|
88
|
+
expect(nightSlot.projected()).toEqual({ recs: [] });
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
describe("recommend", () => {
|
|
93
|
+
test("answers with picks for the category and mood asked for", async () => {
|
|
94
|
+
const result = await runTool(recommend, { category: "movie", mood: "cozy" });
|
|
95
|
+
expect(result).toMatchObject({ category: "movie", mood: "cozy" });
|
|
96
|
+
expect(result.picks.length).toBeGreaterThan(0);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
test("the picks land in the session's own log, newest first", async () => {
|
|
100
|
+
// The log is STATE, not an event stream: `syncState` pushes this projection
|
|
101
|
+
// after every tool call, so a page that reloads mid-session resumes with it
|
|
102
|
+
// rather than starting empty.
|
|
103
|
+
const ctx = createToolContext();
|
|
104
|
+
const first = await run("recommend", { category: "book", mood: "spooky" }, ctx);
|
|
105
|
+
const second = await run("recommend", { category: "music", mood: "chill" }, ctx);
|
|
106
|
+
expect(nightSlot.projected(nightSlot.get(ctx))).toEqual({ recs: [second, first] });
|
|
107
|
+
// The two orders are DIFFERENT and both are deliberate: the slot keeps the
|
|
108
|
+
// night in the order it happened, which is what a position word means and
|
|
109
|
+
// which end `caps` trims; newest-first is the sidebar's, and the projection
|
|
110
|
+
// is where that turn happens.
|
|
111
|
+
expect(nightSlot.get(ctx).recs).toEqual([first, second]);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
test("the log stops at the cap the slot declares, and it is the OLDEST that goes", async () => {
|
|
115
|
+
// Declared on the slot rather than enforced by this tool, so the bound
|
|
116
|
+
// holds whatever writes — the wrapper form only caps the paths that
|
|
117
|
+
// remember to call it. The list rides every `syncState` frame, which is
|
|
118
|
+
// what makes an unbounded one a real cost rather than a tidiness point.
|
|
119
|
+
const ctx = createToolContext();
|
|
120
|
+
const asked = Array.from({ length: MAX_RECS + 2 }, (_, i) => ({
|
|
121
|
+
category: CATEGORIES[i % CATEGORIES.length]!,
|
|
122
|
+
mood: MOODS[i % MOODS.length]!,
|
|
123
|
+
}));
|
|
124
|
+
for (const args of asked) await run("recommend", args, ctx);
|
|
125
|
+
|
|
126
|
+
const key = (rec: { category: string; mood: string }) => `${rec.category}/${rec.mood}`;
|
|
127
|
+
expect(nightSlot.get(ctx).recs.map(key)).toEqual(asked.slice(2).map(key));
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
test("two calls with no shared context are two sessions", async () => {
|
|
131
|
+
// The other half of the same rule, and the one that bites: an omitted
|
|
132
|
+
// context is a FRESH session, so nothing accumulates across these calls.
|
|
133
|
+
const ctx = createToolContext();
|
|
134
|
+
await run("recommend", { category: "book", mood: "cozy" });
|
|
135
|
+
expect(nightSlot.get(ctx).recs).toHaveLength(0);
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
test("the wind-down nudge is sent once, on the third pick", async () => {
|
|
139
|
+
// A moment rather than state, which is why it is a `ctx.send` the page
|
|
140
|
+
// consumes with `useEvent` and not a field on the projection: re-delivering
|
|
141
|
+
// it on every reconnect would be nagging.
|
|
142
|
+
const ctx = createToolContext();
|
|
143
|
+
await run("recommend", { category: "movie", mood: "cozy" }, ctx);
|
|
144
|
+
await run("recommend", { category: "music", mood: "cozy" }, ctx);
|
|
145
|
+
expect(ctx.sent).toEqual([]);
|
|
146
|
+
await run("recommend", { category: "book", mood: "cozy" }, ctx);
|
|
147
|
+
expect(ctx.sent).toEqual([
|
|
148
|
+
{ event: "wind_down", data: "Three picks in. Want me to work out your bedtime?" },
|
|
149
|
+
]);
|
|
150
|
+
await run("recommend", { category: "movie", mood: "chill" }, ctx);
|
|
151
|
+
expect(ctx.sent).toHaveLength(1);
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
test("every category/mood pair the schema admits has picks behind it", async () => {
|
|
155
|
+
// The table is hand-written and the schema is generated from the same two
|
|
156
|
+
// const arrays, so a category added to `shared.ts` and forgotten in the
|
|
157
|
+
// table is a `TypeError` on the first call — the exact failure this
|
|
158
|
+
// package's guide records three shipped tools having.
|
|
159
|
+
for (const category of CATEGORIES) {
|
|
160
|
+
for (const mood of MOODS) {
|
|
161
|
+
const result = await runTool(recommend, { category, mood });
|
|
162
|
+
expect(result.picks, `${category}/${mood}`).not.toHaveLength(0);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
test("the schema accepts a category/mood pair from the enums", async () => {
|
|
168
|
+
const parsed = await parseToolInput<RecommendInput>(agentDef, "recommend", {
|
|
169
|
+
category: "movie",
|
|
170
|
+
mood: "cozy",
|
|
171
|
+
});
|
|
172
|
+
expect(parsed).toEqual({ category: "movie", mood: "cozy" });
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
test("a mood outside the enum is refused by the schema", async () => {
|
|
176
|
+
// The wire boundary: an LLM tool call is untyped, so the schema is the only
|
|
177
|
+
// thing between a hallucinated mood and an index into `undefined`.
|
|
178
|
+
// `toolInputIssues` is the SDK's own ask — `~standard` is a vendor wire
|
|
179
|
+
// contract, and the detail a hand-rolled version gets wrong first is that
|
|
180
|
+
// `.validate` may be sync or async, so a missing `await` leaves `.issues`
|
|
181
|
+
// undefined and the negative test passes for the wrong reason.
|
|
182
|
+
expect(
|
|
183
|
+
await toolInputIssues(agentDef, "recommend", { category: "movie", mood: "melancholy" }),
|
|
184
|
+
).toBeDefined();
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
describe("revisit", () => {
|
|
189
|
+
/** Three picks, in the order the night gave them. */
|
|
190
|
+
const threePicks = async (ctx: ReturnType<typeof createToolContext>) => {
|
|
191
|
+
await run("recommend", { category: "movie", mood: "cozy" }, ctx);
|
|
192
|
+
await run("recommend", { category: "book", mood: "spooky" }, ctx);
|
|
193
|
+
await run("recommend", { category: "music", mood: "chill" }, ctx);
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
test("a position counts the order the NIGHT went in, not the order the sidebar paints", async () => {
|
|
197
|
+
const ctx = createToolContext();
|
|
198
|
+
await threePicks(ctx);
|
|
199
|
+
|
|
200
|
+
// The distinction is the whole reason the two orders are separate: the
|
|
201
|
+
// sidebar's top card is the newest, and a listener saying "the last one you
|
|
202
|
+
// gave me" means that same pick from the other end.
|
|
203
|
+
expect(nightSlot.projected(nightSlot.get(ctx)).recs[0]).toMatchObject({ category: "music" });
|
|
204
|
+
expect(await run("revisit", { which: "the last one" }, ctx)).toMatchObject({
|
|
205
|
+
category: "music",
|
|
206
|
+
mood: "chill",
|
|
207
|
+
});
|
|
208
|
+
expect(await run("revisit", { which: "the second one" }, ctx)).toMatchObject({
|
|
209
|
+
category: "book",
|
|
210
|
+
mood: "spooky",
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
test("the listener's own words pick one out when they name no position", async () => {
|
|
215
|
+
const ctx = createToolContext();
|
|
216
|
+
await threePicks(ctx);
|
|
217
|
+
const found = expectToolOk(await runTool(revisit, { which: "those spooky books" }, ctx));
|
|
218
|
+
expect(found).toMatchObject({ category: "book", mood: "spooky" });
|
|
219
|
+
// It answers with the shelf's own picks, which is what makes this a lookup
|
|
220
|
+
// rather than the model recalling three titles from a trimmed transcript.
|
|
221
|
+
expect(found.picks).toEqual(
|
|
222
|
+
(await runTool(recommend, { category: "book", mood: "spooky" })).picks,
|
|
223
|
+
);
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
test("words that fit two entries equally refuse, listing them", async () => {
|
|
227
|
+
// Never a guess: reading out the spooky book when they asked for the cozy
|
|
228
|
+
// one is worse than asking which. The failure has to name the candidates,
|
|
229
|
+
// because the companion reads it out as the question.
|
|
230
|
+
const ctx = createToolContext();
|
|
231
|
+
await run("recommend", { category: "movie", mood: "cozy" }, ctx);
|
|
232
|
+
await run("recommend", { category: "book", mood: "cozy" }, ctx);
|
|
233
|
+
|
|
234
|
+
const refused = await run("revisit", { which: "the cozy ones" }, ctx);
|
|
235
|
+
expect(isToolFailure(refused)).toBe(true);
|
|
236
|
+
expect(isToolFailure(refused) && refused.error).toMatch(/cozy movies/);
|
|
237
|
+
expect(isToolFailure(refused) && refused.error).toMatch(/cozy books/);
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
test("an empty log refuses rather than answering", async () => {
|
|
241
|
+
// The first thing `resolveOne` checks, and the one a hand-rolled lookup
|
|
242
|
+
// reports as "nothing matched" — which sends the companion looking for a
|
|
243
|
+
// pick it never gave.
|
|
244
|
+
const refused = await run("revisit", { which: "the first one" });
|
|
245
|
+
expect(isToolFailure(refused)).toBe(true);
|
|
246
|
+
expect(isToolFailure(refused) && refused.error).toMatch(/recommendation/);
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
test("reading the log back writes nothing to it", async () => {
|
|
250
|
+
// `slot.tool`, not `updateTool`: what a read is handed is frozen, so this
|
|
251
|
+
// is a compile-time guarantee as much as a runtime one — the test is here
|
|
252
|
+
// because the guarantee is the reason to declare a read tool as one.
|
|
253
|
+
const ctx = createToolContext();
|
|
254
|
+
await threePicks(ctx);
|
|
255
|
+
const before = nightSlot.projected(nightSlot.get(ctx));
|
|
256
|
+
await run("revisit", { which: "the first one" }, ctx);
|
|
257
|
+
await run("revisit", { which: "nothing like this" }, ctx);
|
|
258
|
+
expect(nightSlot.projected(nightSlot.get(ctx))).toEqual(before);
|
|
259
|
+
});
|
|
260
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { agent } from "@alexkroman1/aai";
|
|
2
|
+
import { nightSlot } from "./shared.ts";
|
|
3
|
+
|
|
4
|
+
export default agent({
|
|
5
|
+
name: "Night Owl",
|
|
6
|
+
description: "Recommends films, music and books for the evening, and works out when to go to bed",
|
|
7
|
+
// The night's recommendation log, pushed to the client after every tool
|
|
8
|
+
// call. The page renders `useAgentState(nightSlot.projected)` and keeps no copy
|
|
9
|
+
// of its own, so a reload resumes with the list intact.
|
|
10
|
+
syncState: nightSlot.projected,
|
|
11
|
+
greeting:
|
|
12
|
+
"Hey there, night owl. Try asking me for a cozy movie recommendation, or tell me what time you need to wake up and I'll calculate the best time to fall asleep.",
|
|
13
|
+
builtinTools: ["run_code"],
|
|
14
|
+
});
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Three kinds of thing arrive from the agent, and this page keeps them apart.
|
|
3
|
+
*
|
|
4
|
+
* The recommendation LOG is state: the agent owns it in a `sessionSlot`,
|
|
5
|
+
* `syncState` projects it, and `useAgentState(nightSlot.projected)` reads it. The
|
|
6
|
+
* page stores no copy, so a reload resumes with every pick still there. That is
|
|
7
|
+
* the pattern to reach for by default — see `pizza-ordering-agent` for the same shape
|
|
8
|
+
* over a shopping cart.
|
|
9
|
+
*
|
|
10
|
+
* The "recommending…" flash and the wind-down nudge are MOMENTS someone else
|
|
11
|
+
* ends. Neither is worth storing and neither should replay: a spinner for a
|
|
12
|
+
* call that finished before this component mounted would be a lie, and a nudge
|
|
13
|
+
* re-shown on every reconnect is nagging. `useToolCallStart`/`useToolResult`
|
|
14
|
+
* and `useEvent` are for exactly this — they fire once, carry no history, and
|
|
15
|
+
* drive throwaway `useState`.
|
|
16
|
+
*
|
|
17
|
+
* The read-back line is the third: a moment TIME ends, with nothing coming to
|
|
18
|
+
* clear it. That is `useFlash`, and it is a hook rather than four lines here
|
|
19
|
+
* because the two things a `useState` + `setTimeout` at a call site gets wrong
|
|
20
|
+
* are exactly the two this page would meet — a second read-back while the
|
|
21
|
+
* first line is still up must re-arm the timer rather than stack a second one,
|
|
22
|
+
* and neither may fire into a component React has thrown away.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import "@alexkroman1/aai-ui/styles.css";
|
|
26
|
+
import { isToolFailure, type ToolFailure } from "@alexkroman1/aai/utils";
|
|
27
|
+
import {
|
|
28
|
+
BulletList,
|
|
29
|
+
Button,
|
|
30
|
+
mountClient,
|
|
31
|
+
useAgentState,
|
|
32
|
+
useEvent,
|
|
33
|
+
useFlash,
|
|
34
|
+
useToolCallStart,
|
|
35
|
+
useToolResult,
|
|
36
|
+
} from "@alexkroman1/aai-ui";
|
|
37
|
+
import { useState } from "react";
|
|
38
|
+
import { MOODS, nightSlot, type Rec } from "./shared.ts";
|
|
39
|
+
|
|
40
|
+
const MOOD_EMOJI: Record<string, string> = {
|
|
41
|
+
chill: "\u{1F60C}",
|
|
42
|
+
intense: "\u{1F525}",
|
|
43
|
+
cozy: "\u{1F9E3}",
|
|
44
|
+
spooky: "\u{1F47B}",
|
|
45
|
+
funny: "\u{1F602}",
|
|
46
|
+
};
|
|
47
|
+
const CAT_EMOJI: Record<string, string> = {
|
|
48
|
+
movie: "\u{1F3AC}",
|
|
49
|
+
music: "\u{1F3B5}",
|
|
50
|
+
book: "\u{1F4DA}",
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
function RecSidebar() {
|
|
54
|
+
// State: the agent's own log. No `useState` mirror, no event diffing.
|
|
55
|
+
const { recs } = useAgentState(nightSlot.projected);
|
|
56
|
+
// Page-local view state — which mood chip is pressed. Nothing to sync.
|
|
57
|
+
const [activeMood, setActiveMood] = useState<string | null>(null);
|
|
58
|
+
// Moments. Both are cleared by this page, never re-delivered by the session.
|
|
59
|
+
const [pendingMood, setPendingMood] = useState<string | null>(null);
|
|
60
|
+
const [nudge, setNudge] = useState<string | null>(null);
|
|
61
|
+
|
|
62
|
+
// The flash is armed by the call STARTING and cleared by that same call
|
|
63
|
+
// SETTLING — the two halves of one tool call, which is what these two hooks
|
|
64
|
+
// are. Clearing it off `recs.length` instead was a proxy: a `recommend` that
|
|
65
|
+
// returned no picks, or whose picks were all deduped away, left "Finding
|
|
66
|
+
// something chill…" pulsing for the rest of the call.
|
|
67
|
+
useToolCallStart("recommend", (tc) => setPendingMood(String(tc.args.mood)));
|
|
68
|
+
useToolResult("recommend", () => setPendingMood(null));
|
|
69
|
+
useEvent<string>("wind_down", (text) => setNudge(text));
|
|
70
|
+
|
|
71
|
+
// A read-back names a pick the sidebar is ALREADY showing, so there is
|
|
72
|
+
// nothing to add to the list — the line just says which one is being read
|
|
73
|
+
// out, for as long as reading it out takes. Five seconds rather than the
|
|
74
|
+
// hook's 1500ms default for that reason: this one is paced by a voice.
|
|
75
|
+
// `revisit` answers the entry or a refusal that lists the candidates, so the
|
|
76
|
+
// guard is `isToolFailure` — the refusal is the model's to read, not a line
|
|
77
|
+
// on this page.
|
|
78
|
+
const { value: readingBack, flash } = useFlash<string>(5000);
|
|
79
|
+
useToolResult<Rec | ToolFailure>("revisit", (rec) => {
|
|
80
|
+
if (!isToolFailure(rec)) flash(`${rec.mood} ${rec.category}s`);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
const filtered = activeMood ? recs.filter((r) => r.mood === activeMood) : recs;
|
|
84
|
+
|
|
85
|
+
return (
|
|
86
|
+
<div className="flex flex-col h-full text-sm bg-aai-bg text-aai-text">
|
|
87
|
+
<div className="px-4 py-3 border-b border-aai-border shrink-0">
|
|
88
|
+
<h2 className="text-xs font-bold uppercase tracking-wide opacity-60">Recommendations</h2>
|
|
89
|
+
</div>
|
|
90
|
+
|
|
91
|
+
<div className="flex flex-wrap gap-1.5 px-3 py-2.5 border-b border-aai-border shrink-0">
|
|
92
|
+
{MOODS.map((mood) => (
|
|
93
|
+
<Button
|
|
94
|
+
key={mood}
|
|
95
|
+
variant={activeMood === mood ? "default" : "ghost"}
|
|
96
|
+
onClick={() => setActiveMood(activeMood === mood ? null : mood)}
|
|
97
|
+
>
|
|
98
|
+
{MOOD_EMOJI[mood]} {mood}
|
|
99
|
+
</Button>
|
|
100
|
+
))}
|
|
101
|
+
</div>
|
|
102
|
+
|
|
103
|
+
{nudge && (
|
|
104
|
+
<div className="flex items-center gap-2 px-3 py-2 border-b border-aai-border shrink-0">
|
|
105
|
+
<p className="flex-1 text-xs text-aai-primary">{nudge}</p>
|
|
106
|
+
<Button variant="ghost" onClick={() => setNudge(null)}>
|
|
107
|
+
Dismiss
|
|
108
|
+
</Button>
|
|
109
|
+
</div>
|
|
110
|
+
)}
|
|
111
|
+
|
|
112
|
+
<div className="flex-1 overflow-y-auto px-3 py-2">
|
|
113
|
+
{pendingMood && (
|
|
114
|
+
<p className="text-xs py-2 opacity-60 animate-pulse">
|
|
115
|
+
Finding something {pendingMood}…
|
|
116
|
+
</p>
|
|
117
|
+
)}
|
|
118
|
+
{readingBack && (
|
|
119
|
+
<p className="text-xs py-2 text-aai-primary">Reading back the {readingBack}…</p>
|
|
120
|
+
)}
|
|
121
|
+
{filtered.length === 0 && !pendingMood && (
|
|
122
|
+
<p className="text-xs text-center py-8 opacity-40">
|
|
123
|
+
Ask me to recommend a movie, album, or book
|
|
124
|
+
</p>
|
|
125
|
+
)}
|
|
126
|
+
{filtered.map((rec, i) => (
|
|
127
|
+
<div
|
|
128
|
+
key={`${rec.category}-${rec.mood}-${i}`}
|
|
129
|
+
className="mb-3 p-2.5 rounded-lg border border-aai-border bg-aai-surface"
|
|
130
|
+
>
|
|
131
|
+
<div className="flex items-center gap-2 mb-1.5">
|
|
132
|
+
<span className="text-xs">{CAT_EMOJI[rec.category]}</span>
|
|
133
|
+
<span className="text-xs font-semibold capitalize text-aai-primary">
|
|
134
|
+
{rec.category}s
|
|
135
|
+
</span>
|
|
136
|
+
<span className="text-xs capitalize opacity-50">{rec.mood}</span>
|
|
137
|
+
</div>
|
|
138
|
+
{/*
|
|
139
|
+
The package's list rather than a `map` to `<p>`: three picks are
|
|
140
|
+
a list and read as one, and the keying is the part a hand-rolled
|
|
141
|
+
copy gets wrong — this one keyed by the TITLE, and two shelves
|
|
142
|
+
recommending the same album is a duplicate React key.
|
|
143
|
+
*/}
|
|
144
|
+
<BulletList items={rec.picks} className="text-xs opacity-80" />
|
|
145
|
+
</div>
|
|
146
|
+
))}
|
|
147
|
+
</div>
|
|
148
|
+
</div>
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
mountClient({
|
|
153
|
+
name: "Night Owl",
|
|
154
|
+
icon: "\u{1F989}",
|
|
155
|
+
subtitle: "A cozy companion for the small hours",
|
|
156
|
+
buttonText: "Settle in",
|
|
157
|
+
sidebar: RecSidebar,
|
|
158
|
+
theme: {
|
|
159
|
+
bg: "#0c0e1a",
|
|
160
|
+
primary: "#a78bfa",
|
|
161
|
+
text: "#e2e0f0",
|
|
162
|
+
surface: "#131627",
|
|
163
|
+
border: "#1e2340",
|
|
164
|
+
},
|
|
165
|
+
tools: {
|
|
166
|
+
recommend: { icon: "\u{1F989}", label: "Recommending" },
|
|
167
|
+
revisit: { icon: "\u{1F50E}", label: "Looking back" },
|
|
168
|
+
},
|
|
169
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { sessionSlot } from "@alexkroman1/aai";
|
|
2
|
+
|
|
3
|
+
export const CATEGORIES = ["movie", "music", "book"] as const;
|
|
4
|
+
export const MOODS = ["chill", "intense", "cozy", "spooky", "funny"] as const;
|
|
5
|
+
|
|
6
|
+
export type Category = (typeof CATEGORIES)[number];
|
|
7
|
+
export type Mood = (typeof MOODS)[number];
|
|
8
|
+
|
|
9
|
+
/** One answer from `recommend`, as the sidebar renders it. */
|
|
10
|
+
export type Rec = { category: Category; mood: Mood; picks: string[] };
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The most picks one night keeps.
|
|
14
|
+
*
|
|
15
|
+
* A bound is not optional here: the log rides EVERY `syncState` frame, so an
|
|
16
|
+
* unbounded list is a frame that grows for as long as the session lasts — and
|
|
17
|
+
* a night owl asking for one more album at a time is exactly the session that
|
|
18
|
+
* lasts. Twelve is a scroll of the sidebar; older than that is history nobody
|
|
19
|
+
* is going to ask about.
|
|
20
|
+
*/
|
|
21
|
+
export const MAX_RECS = 12;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The night's recommendation log — the agent's own state, not the page's.
|
|
25
|
+
*
|
|
26
|
+
* It used to live in a `useState` in `client.tsx`, rebuilt from a
|
|
27
|
+
* `ctx.send("recommendations", …)` event per call. That made the list a
|
|
28
|
+
* DERIVED thing: a page that mounted late, or reloaded mid-session, started
|
|
29
|
+
* empty while the session it reconnected to still remembered every pick. A
|
|
30
|
+
* slot is the same list stored once, on the side that already survives a
|
|
31
|
+
* reload.
|
|
32
|
+
*
|
|
33
|
+
* Stored OLDEST FIRST, which is two decisions rather than one:
|
|
34
|
+
*
|
|
35
|
+
* - **`caps` keeps the TAIL.** The bound is declared on the slot, so it holds
|
|
36
|
+
* for whatever path wrote — the alternative is a `pushCapped` wrapper each
|
|
37
|
+
* writer has to remember, and the writer that forgets is the one that ships.
|
|
38
|
+
* A trim drops from the front, so a log that grew by `unshift` would lose
|
|
39
|
+
* the pick it just took.
|
|
40
|
+
* - **A position word means the order the CONVERSATION happened in.** "The
|
|
41
|
+
* last one you gave me" is the newest, and `revisit` resolves it with
|
|
42
|
+
* `at(-1)`; the sidebar's newest-first painting is a display choice, and it
|
|
43
|
+
* is the view on the slot below that makes it.
|
|
44
|
+
*/
|
|
45
|
+
export const nightSlot = sessionSlot("night", () => ({ recs: [] as Rec[] }), {
|
|
46
|
+
// What the browser sees: newest first, over a copy — the slot stays
|
|
47
|
+
// chronological, and reversing here keeps both ends agreeing which end is new.
|
|
48
|
+
view: (night) => ({ recs: [...night.recs].reverse() }),
|
|
49
|
+
caps: { recs: MAX_RECS },
|
|
50
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
You are Night Owl, a cozy evening companion. You help people wind down,
|
|
2
|
+
recommend entertainment, and share interesting facts about the night sky. Keep
|
|
3
|
+
your tone warm and relaxed. Use short, conversational responses.
|
|
4
|
+
|
|
5
|
+
Every recommendation goes through the recommend tool — call it, then say what
|
|
6
|
+
it gave you. Naming something out of your own head instead leaves the night's
|
|
7
|
+
log empty, so the sidebar shows nothing and revisit has nothing to find later.
|
|
8
|
+
Call it before you speak: saying the title first ends your turn and the pick is
|
|
9
|
+
never recorded.
|
|
10
|
+
|
|
11
|
+
When someone asks about something you already recommended tonight, look it up
|
|
12
|
+
with revisit and pass along their own words — never recall it from memory.
|
|
13
|
+
|
|
14
|
+
Use run_code for sleep calculations:
|
|
15
|
+
|
|
16
|
+
- Each sleep cycle is 90 minutes, plus 15 minutes to fall asleep
|
|
17
|
+
- Bedtime = wake_time - (cycles \* 90 + 15) minutes
|
|
18
|
+
- If result is negative, add 1440 (24 hours in minutes)
|
|
19
|
+
- Format as HH:MM
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { CATEGORIES, type Category, MOODS, type Mood, nightSlot, type Rec } from "../shared.ts";
|
|
3
|
+
|
|
4
|
+
const PICKS: Record<Category, Record<Mood, string[]>> = {
|
|
5
|
+
movie: {
|
|
6
|
+
chill: ["Lost in Translation", "The Grand Budapest Hotel", "Amelie"],
|
|
7
|
+
intense: ["Inception", "Interstellar", "The Dark Knight"],
|
|
8
|
+
cozy: ["When Harry Met Sally", "The Holiday", "Paddington 2"],
|
|
9
|
+
spooky: ["The Shining", "Get Out", "Hereditary"],
|
|
10
|
+
funny: ["The Big Lebowski", "Airplane!", "Superbad"],
|
|
11
|
+
},
|
|
12
|
+
music: {
|
|
13
|
+
chill: ["Khruangbin — Con Todo El Mundo", "Tycho — Dive", "Bonobo — Migration"],
|
|
14
|
+
intense: ["Radiohead — OK Computer", "Tool — Lateralus", "Deftones — White Pony"],
|
|
15
|
+
cozy: [
|
|
16
|
+
"Norah Jones — Come Away with Me",
|
|
17
|
+
"Iron & Wine — Our Endless Numbered Days",
|
|
18
|
+
"Bon Iver — For Emma, Forever Ago",
|
|
19
|
+
],
|
|
20
|
+
spooky: [
|
|
21
|
+
"Portishead — Dummy",
|
|
22
|
+
"Massive Attack — Mezzanine",
|
|
23
|
+
"Boards of Canada — Music Has the Right to Children",
|
|
24
|
+
],
|
|
25
|
+
funny: [
|
|
26
|
+
"Weird Al — Running with Scissors",
|
|
27
|
+
"Flight of the Conchords — S/T",
|
|
28
|
+
"Tenacious D — S/T",
|
|
29
|
+
],
|
|
30
|
+
},
|
|
31
|
+
book: {
|
|
32
|
+
chill: ["Norwegian Wood — Murakami", "The Alchemist — Coelho", "Siddhartha — Hesse"],
|
|
33
|
+
intense: ["Blood Meridian — McCarthy", "House of Leaves — Danielewski", "Neuromancer — Gibson"],
|
|
34
|
+
cozy: [
|
|
35
|
+
"The House in the Cerulean Sea — Klune",
|
|
36
|
+
"A Man Called Ove — Backman",
|
|
37
|
+
"Anxious People — Backman",
|
|
38
|
+
],
|
|
39
|
+
spooky: [
|
|
40
|
+
"The Haunting of Hill House — Jackson",
|
|
41
|
+
"Mexican Gothic — Moreno-Garcia",
|
|
42
|
+
"The Turn of the Screw — James",
|
|
43
|
+
],
|
|
44
|
+
funny: ["Good Omens — Pratchett & Gaiman", "Hitchhiker's Guide — Adams", "Catch-22 — Heller"],
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* `updateTool` rather than `tool`: the body is handed the night's own draft and
|
|
50
|
+
* whatever it leaves behind is stored, so the log the client renders and the
|
|
51
|
+
* value this returns to the model are written in one place. It must be
|
|
52
|
+
* SYNCHRONOUS — the mutation is committed when it returns.
|
|
53
|
+
*/
|
|
54
|
+
export default nightSlot.updateTool({
|
|
55
|
+
description: "Get recommendations for movies, music, or books based on mood.",
|
|
56
|
+
inputSchema: z.object({
|
|
57
|
+
category: z.enum(CATEGORIES),
|
|
58
|
+
mood: z.enum(MOODS),
|
|
59
|
+
}),
|
|
60
|
+
execute: (args, night, ctx) => {
|
|
61
|
+
const result: Rec = {
|
|
62
|
+
category: args.category,
|
|
63
|
+
mood: args.mood,
|
|
64
|
+
picks: PICKS[args.category][args.mood],
|
|
65
|
+
};
|
|
66
|
+
// APPENDED, so the log reads in the order the night happened. The slot's
|
|
67
|
+
// `caps` trims the front when it bites, and `nightSlot.projected` is what turns
|
|
68
|
+
// it around for the sidebar — `shared.ts` carries both halves.
|
|
69
|
+
night.recs.push(result);
|
|
70
|
+
// A NUDGE, not state: shown once, when the third pick lands. It is a
|
|
71
|
+
// `ctx.send` rather than a field on the projection precisely because
|
|
72
|
+
// replaying it on every reconnect would be nagging — the distinction the
|
|
73
|
+
// client's header comment spells out.
|
|
74
|
+
if (night.recs.length === 3) {
|
|
75
|
+
ctx.send("wind_down", "Three picks in. Want me to work out your bedtime?");
|
|
76
|
+
}
|
|
77
|
+
return result;
|
|
78
|
+
},
|
|
79
|
+
});
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { resolveOne } from "@alexkroman1/aai";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { nightSlot } from "../shared.ts";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* `nightSlot.tool` rather than `updateTool`: reading the log back writes
|
|
7
|
+
* nothing, and the declaration is what says so — what a read is handed is
|
|
8
|
+
* FROZEN, so a body that tried to edit the night on the way past would not
|
|
9
|
+
* compile. `recommend` beside it is the writing half of the same slot.
|
|
10
|
+
*
|
|
11
|
+
* The log is the reason this tool exists at all. It outlives the transcript
|
|
12
|
+
* the model is holding — a long night trims early turns out of the context
|
|
13
|
+
* window while the slot still has every pick — so "what was that second album
|
|
14
|
+
* again?" is a lookup, not a memory.
|
|
15
|
+
*
|
|
16
|
+
* `resolveOne` is what turns the listener's own words into one of them, and it
|
|
17
|
+
* is the whole body: an index argument would make the model guess a number it
|
|
18
|
+
* cannot see, and the two answers that are not "here it is" — nothing logged
|
|
19
|
+
* yet, and words that fit two entries equally — are refusals it writes,
|
|
20
|
+
* LISTING the candidates so the companion can read them back and ask. Never a
|
|
21
|
+
* guess: reading out the spooky book when they asked for the cozy one is worse
|
|
22
|
+
* than asking which.
|
|
23
|
+
*
|
|
24
|
+
* Positions are chronological, because that is what a listener means: `recs`
|
|
25
|
+
* is stored oldest-first, so "the first one you gave me" is `at(0)` and "the
|
|
26
|
+
* last one" is `at(-1)`. The sidebar paints the same list newest-first, which
|
|
27
|
+
* is `nightSlot.projected`'s doing and no business of this lookup.
|
|
28
|
+
*/
|
|
29
|
+
export default nightSlot.tool({
|
|
30
|
+
description:
|
|
31
|
+
'Read back one recommendation already given tonight — the listener names it in their own words ("the second one", "the last one", "those cozy movies").',
|
|
32
|
+
inputSchema: z.object({
|
|
33
|
+
which: z
|
|
34
|
+
.string()
|
|
35
|
+
.describe("How the listener referred to it, in their words — do not translate it."),
|
|
36
|
+
}),
|
|
37
|
+
execute: ({ which }, night) =>
|
|
38
|
+
resolveOne(night.recs, which, {
|
|
39
|
+
label: "recommendation",
|
|
40
|
+
// How a refusal reads them back, so it has to be sayable: "cozy movies,
|
|
41
|
+
// spooky books". The picks themselves are what the answer carries.
|
|
42
|
+
describe: (rec) => `${rec.mood} ${rec.category}s`,
|
|
43
|
+
// Two words the listener can name, scored independently: "the spooky
|
|
44
|
+
// books" beats a spooky MOVIE and a cozy BOOK, and "the spooky ones"
|
|
45
|
+
// ties them — which is a refusal that asks, not a coin flip.
|
|
46
|
+
//
|
|
47
|
+
// A hand-written scorer where four sibling templates use `resolveOne`'s
|
|
48
|
+
// built-in `match`, and deliberately: a listener says "books" where the
|
|
49
|
+
// field says `book`, and the built-in matches whole WORDS on both sides
|
|
50
|
+
// with no stemming, so the plural would score nothing and every category
|
|
51
|
+
// would tie. Substring containment against two NAMED fields is the
|
|
52
|
+
// domain fact here, which is exactly what `score` is kept for.
|
|
53
|
+
score: (rec, text) =>
|
|
54
|
+
(text.includes(rec.mood) ? 1 : 0) + (text.includes(rec.category) ? 1 : 0),
|
|
55
|
+
}),
|
|
56
|
+
});
|