@alexkroman1/aai-cli 0.12.2 → 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 +1061 -194
- 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 +75 -24
- package/dist/_api-client-H4MFOr8j.mjs +0 -35
- package/dist/_bundler-2yKukgnU.mjs +0 -125
- package/dist/_discover-a8yIuqEp.mjs +0 -220
- package/dist/_init-VzVTpJFZ.mjs +0 -56
- package/dist/_templates-CtZBILce.mjs +0 -72
- package/dist/_ui-DWGXImbO.mjs +0 -30
- package/dist/delete-BvRel3Tw.mjs +0 -34
- package/dist/deploy-CnscqVZv.mjs +0 -92
- package/dist/dev-DEZKrw8v.mjs +0 -18
- package/dist/init-BYX6pxjd.mjs +0 -114
- package/dist/secret-DLosn47q.mjs +0 -47
- package/dist/test-CYoqKJP0.mjs +0 -38
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import { randomInt, tool } from "@alexkroman1/aai";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import {
|
|
4
|
+
ARCHETYPES,
|
|
5
|
+
chooseStoryStructure,
|
|
6
|
+
creativitySeed,
|
|
7
|
+
DEFAULT_CLOCK_SEGMENTS,
|
|
8
|
+
DEFAULT_STATE,
|
|
9
|
+
DISPOSITIONS,
|
|
10
|
+
GENRES,
|
|
11
|
+
gameSlot,
|
|
12
|
+
MAX_CLOCK_SEGMENTS,
|
|
13
|
+
MIN_CLOCK_SEGMENTS,
|
|
14
|
+
makeNpc,
|
|
15
|
+
shuffle,
|
|
16
|
+
stateSummary,
|
|
17
|
+
storyFlow,
|
|
18
|
+
TIME_PHASES,
|
|
19
|
+
TONES,
|
|
20
|
+
} from "../shared.ts";
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* **Not a `storyFlow.tool`, deliberately.** Setting up is legal in every state —
|
|
24
|
+
* a player may start over at any point, an ended story included — so a `when`
|
|
25
|
+
* listing all of them would be a gate that gates nothing. It drives the flow
|
|
26
|
+
* itself, which is what `dialog.reset` and `dialog.send` are public for, and reports
|
|
27
|
+
* the position it landed in so the narrator reads what the opening turn expects.
|
|
28
|
+
*
|
|
29
|
+
* **`reset` before `send`, because a restart is not a transition.** This body
|
|
30
|
+
* replaces the campaign with a pristine `DEFAULT_STATE`; resetting the flow is
|
|
31
|
+
* the same statement on the other side, and it is what makes starting over work
|
|
32
|
+
* from `gameOver` — a final state delivers no events, so a `SETUP` transition
|
|
33
|
+
* out of it would be dead config.
|
|
34
|
+
*/
|
|
35
|
+
export default tool({
|
|
36
|
+
description:
|
|
37
|
+
"Set up the entire game in one call. Starts a completely fresh game (any previous unsaved game is replaced), generates stats, initializes state, and marks the game as ready. After this returns, just narrate the opening scene. No need to call update_state — everything is already done.",
|
|
38
|
+
inputSchema: z.object({
|
|
39
|
+
genre: z.string().max(100).describe("Chosen genre code or custom description"),
|
|
40
|
+
tone: z.string().max(100).describe("Chosen tone code or custom description"),
|
|
41
|
+
archetype: z.string().max(100).describe("Chosen archetype code or custom description"),
|
|
42
|
+
playerName: z.string().max(100).describe("Character name"),
|
|
43
|
+
characterConcept: z.string().max(300).describe("One-line character concept"),
|
|
44
|
+
settingDescription: z.string().max(1000).describe("Two to three sentence setting description"),
|
|
45
|
+
startingLocation: z.string().max(200).describe("Name of starting location"),
|
|
46
|
+
locationDesc: z.string().max(500).describe("One sentence description of starting location"),
|
|
47
|
+
timeOfDay: z.enum(TIME_PHASES).describe("Starting time of day"),
|
|
48
|
+
openingSituation: z
|
|
49
|
+
.string()
|
|
50
|
+
.max(500)
|
|
51
|
+
.describe("One sentence dramatic hook for the opening scene"),
|
|
52
|
+
npc1Name: z.string().max(100).describe("First NPC name"),
|
|
53
|
+
npc1Desc: z.string().max(300).describe("First NPC one-line description"),
|
|
54
|
+
npc1Disposition: z.enum(DISPOSITIONS).describe("First NPC disposition"),
|
|
55
|
+
npc1Agenda: z.string().max(300).describe("First NPC agenda"),
|
|
56
|
+
threatClockName: z.string().max(100).describe("Name of initial threat clock"),
|
|
57
|
+
threatClockDesc: z.string().max(300).describe("What happens when the threat clock fills"),
|
|
58
|
+
threatClockSegments: z
|
|
59
|
+
.number()
|
|
60
|
+
.int()
|
|
61
|
+
.min(MIN_CLOCK_SEGMENTS)
|
|
62
|
+
.max(MAX_CLOCK_SEGMENTS)
|
|
63
|
+
.describe(`Segments for threat clock, default ${DEFAULT_CLOCK_SEGMENTS}`)
|
|
64
|
+
.optional(),
|
|
65
|
+
backstory: z.string().max(2000).optional(),
|
|
66
|
+
wishes: z.string().max(1000).optional(),
|
|
67
|
+
contentLines: z.string().max(1000).optional(),
|
|
68
|
+
kidMode: z.boolean().optional(),
|
|
69
|
+
}),
|
|
70
|
+
async execute(args, ctx) {
|
|
71
|
+
// Always start from a pristine state — re-running setup begins a new
|
|
72
|
+
// story instead of layering NPCs/clocks onto a stale one.
|
|
73
|
+
const state = structuredClone(DEFAULT_STATE);
|
|
74
|
+
|
|
75
|
+
// Store creation choices
|
|
76
|
+
state.settingGenre = args.genre;
|
|
77
|
+
state.settingTone = args.tone;
|
|
78
|
+
state.settingArchetype = args.archetype;
|
|
79
|
+
state.playerName = args.playerName;
|
|
80
|
+
state.characterConcept = args.characterConcept;
|
|
81
|
+
state.settingDescription = args.settingDescription;
|
|
82
|
+
state.backstory = args.backstory ?? "";
|
|
83
|
+
state.playerWishes = args.wishes ?? "";
|
|
84
|
+
state.contentLines = args.contentLines ?? "";
|
|
85
|
+
state.kidMode = args.kidMode ?? false;
|
|
86
|
+
|
|
87
|
+
// Generate stats: one at 3, two at 2, two at 1 (total = 7)
|
|
88
|
+
const statValues = shuffle([3, 2, 2, 1, 1], ctx.random);
|
|
89
|
+
const archetypeBias: Record<string, number> = {
|
|
90
|
+
outsider_loner: 0,
|
|
91
|
+
investigator: 4,
|
|
92
|
+
trickster: 3,
|
|
93
|
+
protector: 2,
|
|
94
|
+
hardboiled: 2,
|
|
95
|
+
scholar: 4,
|
|
96
|
+
healer: 1,
|
|
97
|
+
inventor: 4,
|
|
98
|
+
artist: 1,
|
|
99
|
+
};
|
|
100
|
+
const biasIdx = archetypeBias[args.archetype] ?? randomInt(5, ctx.random);
|
|
101
|
+
const highIdx = statValues.indexOf(3);
|
|
102
|
+
if (highIdx !== biasIdx) {
|
|
103
|
+
[statValues[highIdx], statValues[biasIdx]] = [statValues[biasIdx]!, statValues[highIdx]!];
|
|
104
|
+
}
|
|
105
|
+
state.edge = statValues[0]!;
|
|
106
|
+
state.heart = statValues[1]!;
|
|
107
|
+
state.iron = statValues[2]!;
|
|
108
|
+
state.shadow = statValues[3]!;
|
|
109
|
+
state.wits = statValues[4]!;
|
|
110
|
+
|
|
111
|
+
// Set location, time
|
|
112
|
+
state.currentLocation = args.startingLocation;
|
|
113
|
+
state.currentSceneContext = args.locationDesc;
|
|
114
|
+
state.timeOfDay = args.timeOfDay;
|
|
115
|
+
|
|
116
|
+
// Add initial NPC
|
|
117
|
+
state.npcs.push(
|
|
118
|
+
makeNpc({
|
|
119
|
+
id: "npc_1",
|
|
120
|
+
name: args.npc1Name,
|
|
121
|
+
description: args.npc1Desc,
|
|
122
|
+
disposition: args.npc1Disposition,
|
|
123
|
+
agenda: args.npc1Agenda,
|
|
124
|
+
}),
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
// Add threat clock
|
|
128
|
+
state.clocks.push({
|
|
129
|
+
id: "clock_1",
|
|
130
|
+
name: args.threatClockName,
|
|
131
|
+
clockType: "threat",
|
|
132
|
+
segments: args.threatClockSegments ?? DEFAULT_CLOCK_SEGMENTS,
|
|
133
|
+
filled: 0,
|
|
134
|
+
triggerDescription: args.threatClockDesc,
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
// Story blueprint
|
|
138
|
+
const structure = chooseStoryStructure(args.tone, ctx.random);
|
|
139
|
+
state.storyBlueprint = {
|
|
140
|
+
structureType: structure,
|
|
141
|
+
centralConflict: args.openingSituation,
|
|
142
|
+
antagonistForce: "",
|
|
143
|
+
thematicThread: "",
|
|
144
|
+
acts:
|
|
145
|
+
structure === "3act"
|
|
146
|
+
? [
|
|
147
|
+
{
|
|
148
|
+
phase: "setup",
|
|
149
|
+
title: "The Hook",
|
|
150
|
+
goal: "Establish the world and the conflict",
|
|
151
|
+
mood: args.tone,
|
|
152
|
+
transitionTrigger: "Player engages with the central conflict",
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
phase: "confrontation",
|
|
156
|
+
title: "Rising Stakes",
|
|
157
|
+
goal: "Escalate tension and complications",
|
|
158
|
+
mood: args.tone,
|
|
159
|
+
transitionTrigger: "A major setback or revelation",
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
phase: "climax",
|
|
163
|
+
title: "The Reckoning",
|
|
164
|
+
goal: "Resolve the central conflict",
|
|
165
|
+
mood: args.tone,
|
|
166
|
+
transitionTrigger: "Story reaches its conclusion",
|
|
167
|
+
},
|
|
168
|
+
]
|
|
169
|
+
: [
|
|
170
|
+
{
|
|
171
|
+
phase: "ki_introduction",
|
|
172
|
+
title: "Ki",
|
|
173
|
+
goal: "Introduce the world and characters",
|
|
174
|
+
mood: args.tone,
|
|
175
|
+
transitionTrigger: "World is established",
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
phase: "sho_development",
|
|
179
|
+
title: "Sho",
|
|
180
|
+
goal: "Develop relationships and deepen the world",
|
|
181
|
+
mood: args.tone,
|
|
182
|
+
transitionTrigger: "Relationships are tested",
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
phase: "ten_twist",
|
|
186
|
+
title: "Ten",
|
|
187
|
+
goal: "An unexpected twist changes everything",
|
|
188
|
+
mood: args.tone,
|
|
189
|
+
transitionTrigger: "The twist lands",
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
phase: "ketsu_resolution",
|
|
193
|
+
title: "Ketsu",
|
|
194
|
+
goal: "Resolve and reflect",
|
|
195
|
+
mood: args.tone,
|
|
196
|
+
transitionTrigger: "Story reaches its conclusion",
|
|
197
|
+
},
|
|
198
|
+
],
|
|
199
|
+
currentAct: 1,
|
|
200
|
+
storyComplete: false,
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
// Mark initialized. `initialized` is the CLIENT's render flag; the flow is
|
|
204
|
+
// what gates the tools, and `SETUP` is what puts it in `playing` — so the
|
|
205
|
+
// roll tools become available in the same call that gives them stats to
|
|
206
|
+
// roll against.
|
|
207
|
+
state.initialized = true;
|
|
208
|
+
state.sceneCount = 1;
|
|
209
|
+
|
|
210
|
+
gameSlot.set(ctx, state);
|
|
211
|
+
storyFlow.reset(ctx);
|
|
212
|
+
const at = storyFlow.send(ctx, { type: "SETUP" });
|
|
213
|
+
|
|
214
|
+
return {
|
|
215
|
+
success: true,
|
|
216
|
+
// Human-readable labels when a known code was used
|
|
217
|
+
genreLabel: GENRES[args.genre as keyof typeof GENRES] || args.genre,
|
|
218
|
+
toneLabel: TONES[args.tone as keyof typeof TONES] || args.tone,
|
|
219
|
+
archetypeLabel: ARCHETYPES[args.archetype as keyof typeof ARCHETYPES] || args.archetype,
|
|
220
|
+
openingSituation: args.openingSituation,
|
|
221
|
+
creativitySeed: creativitySeed(3, ctx.random),
|
|
222
|
+
// The position spread verbatim — the same keys every gated tool reports.
|
|
223
|
+
...at,
|
|
224
|
+
// The real saved state — never hardcoded values
|
|
225
|
+
...stateSummary(state),
|
|
226
|
+
};
|
|
227
|
+
},
|
|
228
|
+
});
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import {
|
|
3
|
+
DEFAULT_CLOCK_SEGMENTS,
|
|
4
|
+
DISPOSITIONS,
|
|
5
|
+
findClock,
|
|
6
|
+
gameSlot,
|
|
7
|
+
MAX_BOND,
|
|
8
|
+
MAX_CLOCK_SEGMENTS,
|
|
9
|
+
MAX_CLOCKS,
|
|
10
|
+
MAX_NPCS,
|
|
11
|
+
MAX_RESOURCE,
|
|
12
|
+
MIN_CLOCK_SEGMENTS,
|
|
13
|
+
MIN_MOMENTUM,
|
|
14
|
+
makeNpc,
|
|
15
|
+
nextSeqId,
|
|
16
|
+
stateSummary,
|
|
17
|
+
storyFlow,
|
|
18
|
+
TIME_PHASES,
|
|
19
|
+
} from "../shared.ts";
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Gated on `playing`: there is nothing to sync before a character exists (that
|
|
23
|
+
* is `setup_character`'s whole job, and the prompt says not to call this after
|
|
24
|
+
* it), and nothing to sync after the story has ended.
|
|
25
|
+
*
|
|
26
|
+
* It sends `SETTLED`, because moving the scene on is what SPENDS a standing
|
|
27
|
+
* roll: once the narrator has changed the location or logged the scene, the
|
|
28
|
+
* player's window to burn momentum on the last roll has closed.
|
|
29
|
+
*/
|
|
30
|
+
export default storyFlow.tool({
|
|
31
|
+
description:
|
|
32
|
+
"Lightweight state sync for during gameplay. Handles location changes, NPC additions, clock additions, time changes, and session log entries. Resource changes (health/spirit/supply/momentum) are auto-applied by action_roll — only use those fields here for manual adjustments like resting or trading. Pass only what changed.",
|
|
33
|
+
when: "playing",
|
|
34
|
+
inputSchema: z.object({
|
|
35
|
+
location: z.string().max(200).describe("New location name").optional(),
|
|
36
|
+
locationDesc: z.string().max(500).describe("Short location description").optional(),
|
|
37
|
+
timeOfDay: z.enum(TIME_PHASES).describe("New time of day").optional(),
|
|
38
|
+
health: z.number().int().optional(),
|
|
39
|
+
spirit: z.number().int().optional(),
|
|
40
|
+
supply: z.number().int().optional(),
|
|
41
|
+
momentum: z.number().int().optional(),
|
|
42
|
+
addNpcName: z.string().max(100).describe("New NPC name").optional(),
|
|
43
|
+
addNpcDesc: z.string().max(300).describe("New NPC one-line description").optional(),
|
|
44
|
+
addNpcDisposition: z.enum(DISPOSITIONS).describe("New NPC disposition").optional(),
|
|
45
|
+
addNpcAgenda: z.string().max(300).describe("New NPC agenda").optional(),
|
|
46
|
+
updateNpcId: z.string().max(32).describe("NPC id to update").optional(),
|
|
47
|
+
updateNpcDisposition: z.enum(DISPOSITIONS).optional(),
|
|
48
|
+
updateNpcBond: z.number().int().min(0).max(MAX_BOND).optional(),
|
|
49
|
+
updateNpcStatus: z.enum(["active", "background", "deceased"]).optional(),
|
|
50
|
+
addClockName: z.string().max(100).describe("New clock name").optional(),
|
|
51
|
+
addClockType: z.enum(["threat", "progress", "scheme"]).optional(),
|
|
52
|
+
addClockSegments: z
|
|
53
|
+
.number()
|
|
54
|
+
.int()
|
|
55
|
+
.min(MIN_CLOCK_SEGMENTS)
|
|
56
|
+
.max(MAX_CLOCK_SEGMENTS)
|
|
57
|
+
.describe(`Number of segments, default ${DEFAULT_CLOCK_SEGMENTS}`)
|
|
58
|
+
.optional(),
|
|
59
|
+
addClockTrigger: z.string().max(300).describe("What happens when clock fills").optional(),
|
|
60
|
+
advanceClockName: z
|
|
61
|
+
.string()
|
|
62
|
+
.max(100)
|
|
63
|
+
.describe('Clock to advance by 1, by name or by what the player called it ("the second")')
|
|
64
|
+
.optional(),
|
|
65
|
+
removeClockName: z
|
|
66
|
+
.string()
|
|
67
|
+
.max(100)
|
|
68
|
+
.describe('Clock to remove, by name or by what the player called it ("the first clock")')
|
|
69
|
+
.optional(),
|
|
70
|
+
advanceAct: z.boolean().describe("Move to next story act").optional(),
|
|
71
|
+
storyComplete: z.boolean().describe("Mark story as complete").optional(),
|
|
72
|
+
logEntry: z.string().max(500).describe("Short log entry for this scene").optional(),
|
|
73
|
+
}),
|
|
74
|
+
execute: (args, ctx) =>
|
|
75
|
+
gameSlot.update(ctx, (state) => {
|
|
76
|
+
const warnings: string[] = [];
|
|
77
|
+
const clockEvents: { clock: string; trigger: string }[] = [];
|
|
78
|
+
|
|
79
|
+
// Resources
|
|
80
|
+
if (args.health !== undefined)
|
|
81
|
+
state.health = Math.max(0, Math.min(MAX_RESOURCE, args.health));
|
|
82
|
+
if (args.spirit !== undefined)
|
|
83
|
+
state.spirit = Math.max(0, Math.min(MAX_RESOURCE, args.spirit));
|
|
84
|
+
if (args.supply !== undefined)
|
|
85
|
+
state.supply = Math.max(0, Math.min(MAX_RESOURCE, args.supply));
|
|
86
|
+
if (args.momentum !== undefined)
|
|
87
|
+
state.momentum = Math.max(MIN_MOMENTUM, Math.min(state.maxMomentum, args.momentum));
|
|
88
|
+
|
|
89
|
+
// Location
|
|
90
|
+
if (args.location !== undefined) state.currentLocation = args.location;
|
|
91
|
+
if (args.locationDesc !== undefined) state.currentSceneContext = args.locationDesc;
|
|
92
|
+
if (args.timeOfDay !== undefined) state.timeOfDay = args.timeOfDay;
|
|
93
|
+
|
|
94
|
+
// Add NPC
|
|
95
|
+
if (args.addNpcName) {
|
|
96
|
+
if (state.npcs.length >= MAX_NPCS) {
|
|
97
|
+
warnings.push(
|
|
98
|
+
`NPC limit of ${MAX_NPCS} reached — mark an existing NPC deceased or background instead.`,
|
|
99
|
+
);
|
|
100
|
+
} else {
|
|
101
|
+
state.npcs.push(
|
|
102
|
+
makeNpc({
|
|
103
|
+
id: nextSeqId(state.npcs, "npc"),
|
|
104
|
+
name: args.addNpcName,
|
|
105
|
+
description: args.addNpcDesc,
|
|
106
|
+
disposition: args.addNpcDisposition,
|
|
107
|
+
agenda: args.addNpcAgenda,
|
|
108
|
+
}),
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Update NPC
|
|
114
|
+
if (args.updateNpcId) {
|
|
115
|
+
const npc = state.npcs.find((n) => n.id === args.updateNpcId);
|
|
116
|
+
if (npc) {
|
|
117
|
+
if (args.updateNpcDisposition !== undefined) npc.disposition = args.updateNpcDisposition;
|
|
118
|
+
if (args.updateNpcBond !== undefined) npc.bond = args.updateNpcBond;
|
|
119
|
+
if (args.updateNpcStatus !== undefined) npc.status = args.updateNpcStatus;
|
|
120
|
+
} else {
|
|
121
|
+
warnings.push(`No NPC with id ${args.updateNpcId}.`);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// Add clock
|
|
126
|
+
if (args.addClockName) {
|
|
127
|
+
if (state.clocks.length >= MAX_CLOCKS) {
|
|
128
|
+
warnings.push(`Clock limit of ${MAX_CLOCKS} reached — remove a finished clock first.`);
|
|
129
|
+
} else {
|
|
130
|
+
state.clocks.push({
|
|
131
|
+
id: nextSeqId(state.clocks, "clock"),
|
|
132
|
+
name: args.addClockName,
|
|
133
|
+
clockType: args.addClockType ?? "threat",
|
|
134
|
+
segments: args.addClockSegments ?? DEFAULT_CLOCK_SEGMENTS,
|
|
135
|
+
filled: 0,
|
|
136
|
+
triggerDescription: args.addClockTrigger ?? "",
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// Advance clock. `findClock` accepts the ORDINAL the player can see in
|
|
142
|
+
// the sidebar as well as the name, which is what a spoken reference to a
|
|
143
|
+
// clock called "The Syndicate Closes In" usually is.
|
|
144
|
+
if (args.advanceClockName) {
|
|
145
|
+
const clock = findClock(state.clocks, args.advanceClockName);
|
|
146
|
+
if (!clock) {
|
|
147
|
+
warnings.push(`No clock matching "${args.advanceClockName}".`);
|
|
148
|
+
} else if (clock.filled < clock.segments) {
|
|
149
|
+
clock.filled = Math.min(clock.segments, clock.filled + 1);
|
|
150
|
+
if (clock.filled >= clock.segments) {
|
|
151
|
+
clockEvents.push({ clock: clock.name, trigger: clock.triggerDescription });
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// Remove clock. Resolved to ONE clock and dropped by id: filtering on the
|
|
157
|
+
// spoken string would delete every clock sharing a name, and would delete
|
|
158
|
+
// nothing at all when the player used an ordinal.
|
|
159
|
+
if (args.removeClockName) {
|
|
160
|
+
const clock = findClock(state.clocks, args.removeClockName);
|
|
161
|
+
if (clock) state.clocks = state.clocks.filter((c) => c.id !== clock.id);
|
|
162
|
+
else warnings.push(`No clock matching "${args.removeClockName}".`);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// Story arc
|
|
166
|
+
if (args.advanceAct && state.storyBlueprint) {
|
|
167
|
+
state.storyBlueprint.currentAct = Math.min(
|
|
168
|
+
state.storyBlueprint.acts.length,
|
|
169
|
+
state.storyBlueprint.currentAct + 1,
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
if (args.storyComplete && state.storyBlueprint) {
|
|
173
|
+
state.storyBlueprint.storyComplete = true;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// Session log
|
|
177
|
+
if (args.logEntry) {
|
|
178
|
+
state.sessionLog.push({
|
|
179
|
+
scene: state.sceneCount,
|
|
180
|
+
summary: args.logEntry,
|
|
181
|
+
location: state.currentLocation,
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return {
|
|
186
|
+
success: true,
|
|
187
|
+
...(warnings.length > 0 ? { warnings } : {}),
|
|
188
|
+
clockEvents,
|
|
189
|
+
...stateSummary(state),
|
|
190
|
+
};
|
|
191
|
+
}),
|
|
192
|
+
sendFrom: (result) =>
|
|
193
|
+
result.gameOver ? { type: "DOWNED" as const } : { type: "SETTLED" as const },
|
|
194
|
+
});
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
// An EVAL: does the line really refuse to say what it cannot ground? Run it
|
|
2
|
+
// with `aai eval`.
|
|
3
|
+
//
|
|
4
|
+
// `agent.test.ts` drives the retriever and each CRAG node directly. What it
|
|
5
|
+
// cannot see is the claim this template exists to make — that a MODEL holding
|
|
6
|
+
// this tool list cannot state a fee it did not just retrieve. So these cases
|
|
7
|
+
// drive a real session and read the verdicts off the tool results: which
|
|
8
|
+
// documents the grader passed, whether the answer was grounded, and whether an
|
|
9
|
+
// answer it could not ground was WITHHELD.
|
|
10
|
+
//
|
|
11
|
+
// **One thing a SCRIPTED run cannot reach: `ctx.generate` with a SCHEMA.** The
|
|
12
|
+
// stub model registers as an LLM provider, so `ctx.generate` resolves it, and it
|
|
13
|
+
// answers a plain text generation from the script. Every node in this template's
|
|
14
|
+
// loop passes a `schema` though (`binaryScore`), and that overload comes back
|
|
15
|
+
// `{"error":"The knowledge base lookup failed: No output generated."}` — so the
|
|
16
|
+
// whole corrective loop is unreachable scripted. That is the template's central
|
|
17
|
+
// tool, so the two cases that run without a key are written as invariants both
|
|
18
|
+
// modes satisfy (a failed lookup is REPORTED, never answered around), and the
|
|
19
|
+
// two that read a real verdict are `{ live: true }`.
|
|
20
|
+
//
|
|
21
|
+
// **`system-prompt.md` is applied HERE, not by `agent.ts`.** The build discovers
|
|
22
|
+
// the file, so an eval driving the raw default export would run this agent with
|
|
23
|
+
// the FRAMEWORK DEFAULT prompt — and the discipline that prompt imposes is the
|
|
24
|
+
// entire subject of this file. Measured against the default: the model answers
|
|
25
|
+
// product questions from its own knowledge and skips the tools the prompt exists
|
|
26
|
+
// to route it through, so a case run that way measures nothing it claims to.
|
|
27
|
+
|
|
28
|
+
/** The def a DEPLOYED agent runs — see `agent.test.ts` on why the glob is here. */
|
|
29
|
+
import agentDef from "virtual:aai/agent";
|
|
30
|
+
import {
|
|
31
|
+
describeEval,
|
|
32
|
+
describeToolCalls,
|
|
33
|
+
describeTurn,
|
|
34
|
+
type EvalSession,
|
|
35
|
+
statesIn,
|
|
36
|
+
toolResultIn,
|
|
37
|
+
} from "@alexkroman1/aai-runtime/testing/vitest";
|
|
38
|
+
import { expect } from "vitest";
|
|
39
|
+
import { z } from "zod";
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* What the BROWSER is sent, as this eval reads it.
|
|
43
|
+
*
|
|
44
|
+
* Parsed rather than cast: `state.updated` carries `unknown`, so a projection
|
|
45
|
+
* that stopped matching FAILS naming the field, where the cast this replaced
|
|
46
|
+
* handed the assertions `undefined` and failed a line later on something else.
|
|
47
|
+
* It names only the fields asserted below, so `supportView` may grow without
|
|
48
|
+
* touching this.
|
|
49
|
+
*/
|
|
50
|
+
const ProjectedSupport = z.object({
|
|
51
|
+
ticket: z.string().nullable(),
|
|
52
|
+
trace: z
|
|
53
|
+
.object({
|
|
54
|
+
exhausted: z.boolean(),
|
|
55
|
+
docs: z.array(z.object({ relevant: z.boolean() })),
|
|
56
|
+
steps: z.array(z.object({ node: z.string() })),
|
|
57
|
+
})
|
|
58
|
+
.nullable(),
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* What `answer_question` answered, validated.
|
|
63
|
+
*
|
|
64
|
+
* All-optional, and that is the shape of the CONTRACT rather than laxness: the
|
|
65
|
+
* tool has three legal outcomes — a graded answer, a withheld one carrying
|
|
66
|
+
* guidance, and a reported failure — so a required field would fail two of the
|
|
67
|
+
* three. What the schema still buys is that a field the case reads is the type
|
|
68
|
+
* the case thinks it is.
|
|
69
|
+
*/
|
|
70
|
+
const Lookup = z.object({
|
|
71
|
+
answer: z.string().nullable().optional(),
|
|
72
|
+
sources: z.array(z.string()).optional(),
|
|
73
|
+
grounded: z.boolean().optional(),
|
|
74
|
+
answersTheQuestion: z.boolean().optional(),
|
|
75
|
+
rewrites: z.number().optional(),
|
|
76
|
+
guidance: z.string().optional(),
|
|
77
|
+
error: z.string().optional(),
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Every `syncState` frame, in stream order.
|
|
82
|
+
*
|
|
83
|
+
* `statesIn` reads an EVENT LIST rather than a session, which is what lets a
|
|
84
|
+
* case slice the stream first; the schema above is what it takes one for.
|
|
85
|
+
*/
|
|
86
|
+
function frames(session: EvalSession) {
|
|
87
|
+
return statesIn(session.events(), "support", ProjectedSupport);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* What `answer_question` answered, in call order.
|
|
92
|
+
*
|
|
93
|
+
* `toolResultIn` over a ONE-CALL list per call: the name is that call's own, so
|
|
94
|
+
* the reader's "no such call" and "two calls" throws are unreachable and what is
|
|
95
|
+
* left is the parse, the schema, and its "never completed" failure — which is
|
|
96
|
+
* the half the hand-rolled `JSON.parse(call.result ?? "null")` this replaced got
|
|
97
|
+
* wrong, reading `null` for a tool that never came back.
|
|
98
|
+
*/
|
|
99
|
+
function lookups(session: EvalSession) {
|
|
100
|
+
return session
|
|
101
|
+
.toolCalls()
|
|
102
|
+
.filter((call) => call.name === "answer_question")
|
|
103
|
+
.map((call) => toolResultIn([call], call.name, Lookup));
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
describeEval(agentDef, (test) => {
|
|
107
|
+
test(
|
|
108
|
+
"nothing about the product is said without going through the knowledge base",
|
|
109
|
+
async ({ session }) => {
|
|
110
|
+
const turn = await session.say("How much notice do I have to give if I want to cancel?");
|
|
111
|
+
|
|
112
|
+
// The prompt's one rule: `answer_question` is the only route to anything
|
|
113
|
+
// about Meridian Fibre. A model that answered a notice period from its own
|
|
114
|
+
// knowledge would sound identical down a phone.
|
|
115
|
+
const asked = turn.toolCalls.filter((call) => call.name === "answer_question");
|
|
116
|
+
// The reply rides in the message, because the failure that matters here is
|
|
117
|
+
// a turn that SPOKE without looking anything up — "let me check that for
|
|
118
|
+
// you" and then nothing, or worse, a notice period from memory.
|
|
119
|
+
// `describeTurn` is that sentence, and it says the two things a
|
|
120
|
+
// hand-built one left out: "called no tools" rather than an empty
|
|
121
|
+
// bracket, and whether the reply was cancelled.
|
|
122
|
+
expect(asked.length, describeTurn(turn)).toBe(1);
|
|
123
|
+
|
|
124
|
+
for (const payload of lookups(session)) {
|
|
125
|
+
// Three legal outcomes, and the invariant that spans them: an answer the
|
|
126
|
+
// caller is given is an answer the hallucination grader passed. `grounded:
|
|
127
|
+
// false` reaching the model is the one thing the whole apparatus exists
|
|
128
|
+
// to prevent — and a broken lookup is REPORTED rather than worked around.
|
|
129
|
+
if (payload.error !== undefined) continue;
|
|
130
|
+
if (payload.answer === null) continue;
|
|
131
|
+
expect(payload.grounded, `ungrounded answer handed to the model: ${payload.answer}`).toBe(
|
|
132
|
+
true,
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
stubReply: [{ tool: "answer_question", args: { question: "notice to cancel" } }, "One sec."],
|
|
138
|
+
},
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
test(
|
|
142
|
+
"a logged ticket's callback number never leaves the server",
|
|
143
|
+
async ({ session }) => {
|
|
144
|
+
// Two turns, because that is the shape the prompt asks for: the lookup comes
|
|
145
|
+
// back empty, the line offers a ticket, and only then is there a number to
|
|
146
|
+
// take. Asked for in one breath, a live model reasonably answers the offer
|
|
147
|
+
// instead of acting on it.
|
|
148
|
+
await session.say("Can I add a pay-monthly mobile SIM to my broadband account?");
|
|
149
|
+
await session.say("Yes please, log that one — my callback number is 07700 900123.");
|
|
150
|
+
|
|
151
|
+
const logged = session.toolCalls().find((call) => call.name === "log_ticket");
|
|
152
|
+
// The claim spans both turns, so the message does too: `describeToolCalls`
|
|
153
|
+
// over the session's own list, where `describeTurn` would describe one.
|
|
154
|
+
expect(logged, describeToolCalls(session.toolCalls())).toBeDefined();
|
|
155
|
+
expect(logged?.result).toMatch(/TCK\d{4}/);
|
|
156
|
+
|
|
157
|
+
const latest = frames(session).at(-1);
|
|
158
|
+
// The projection carries the REFERENCE and nothing else — that is why
|
|
159
|
+
// `supportView` exists rather than `syncState` taking the state itself.
|
|
160
|
+
expect(latest?.ticket).toMatch(/^TCK\d{4}$/);
|
|
161
|
+
for (const frame of frames(session)) {
|
|
162
|
+
expect(JSON.stringify(frame)).not.toMatch(/900123/);
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
stubReply: [
|
|
167
|
+
{ tool: "answer_question", args: { question: "add a mobile SIM to my account" } },
|
|
168
|
+
"I don't have that documented. Shall I log a ticket for a callback?",
|
|
169
|
+
{
|
|
170
|
+
tool: "log_ticket",
|
|
171
|
+
args: { question: "add a mobile SIM to my account", callback: "07700 900123" },
|
|
172
|
+
},
|
|
173
|
+
"That's logged — the reference is T C K four thousand and one.",
|
|
174
|
+
],
|
|
175
|
+
},
|
|
176
|
+
);
|
|
177
|
+
|
|
178
|
+
test(
|
|
179
|
+
"the answer comes from the document the caller asked about, not the one next to it",
|
|
180
|
+
async ({ session }) => {
|
|
181
|
+
// Short and single, deliberately: the claim here is which document the
|
|
182
|
+
// grader passed, so the question is phrased to measure that and not the
|
|
183
|
+
// loop's pacing.
|
|
184
|
+
//
|
|
185
|
+
// It used to say the corrective path could not fit the runtime's 30s
|
|
186
|
+
// per-tool deadline. Re-measured against the live gateway, that is no
|
|
187
|
+
// longer true by an order of magnitude — the two-attempt path runs in
|
|
188
|
+
// 2.8s of nine model calls — so the phrasing above is a choice about what
|
|
189
|
+
// this case measures rather than a way around a clock. The numbers and
|
|
190
|
+
// what they do and do not license are on `LOOKUP_BUDGET_MS` in
|
|
191
|
+
// `tools/answer_question.ts`.
|
|
192
|
+
const turn = await session.say("How much notice do I have to give to cancel my contract?");
|
|
193
|
+
|
|
194
|
+
const [payload] = lookups(session);
|
|
195
|
+
expect(payload, describeTurn(turn)).toBeDefined();
|
|
196
|
+
// The whole verdict in the message: `grounded: undefined` on its own does
|
|
197
|
+
// not say whether the lookup failed, or ran and refused.
|
|
198
|
+
const verdict = JSON.stringify(payload);
|
|
199
|
+
expect(payload?.grounded, verdict).toBe(true);
|
|
200
|
+
expect(payload?.answersTheQuestion, verdict).toBe(true);
|
|
201
|
+
|
|
202
|
+
const sources = payload?.sources ?? [];
|
|
203
|
+
expect(sources).toContain("Cancelling your contract");
|
|
204
|
+
// THE claim, and the reason the knowledge base is built the way it is:
|
|
205
|
+
// "cancelling your contract" and "cancelling an engineer visit" are two
|
|
206
|
+
// documents, two fees and one word apart. A retriever with no grader hands
|
|
207
|
+
// back both, and sixty pounds gets read down the phone as the answer to a
|
|
208
|
+
// contract question.
|
|
209
|
+
expect(sources).not.toContain("Cancelling or rebooking an engineer visit");
|
|
210
|
+
// Either spelling: the claim is that the notice period came out of D5, not
|
|
211
|
+
// how the answer prompt chose to write a numeral.
|
|
212
|
+
expect(String(payload?.answer)).toMatch(/thirty days|30 days/i);
|
|
213
|
+
expect(String(payload?.answer)).not.toMatch(/sixty pound|abortive/i);
|
|
214
|
+
expect(turn.text).not.toMatch(/sixty|abortive/i);
|
|
215
|
+
},
|
|
216
|
+
// Live only: the grader's verdict IS the measurement.
|
|
217
|
+
//
|
|
218
|
+
// THE CLOCK, and it is no longer the limit it was recorded as here.
|
|
219
|
+
// `answer_question` is up to eleven sequential model calls and the tool
|
|
220
|
+
// executor abandons any tool at `TOOL_EXECUTION_TIMEOUT_MS` (30s) — a
|
|
221
|
+
// deadline neither an agent author nor an eval can raise — so this comment
|
|
222
|
+
// used to say the two-attempt corrective path did not fit, which made this
|
|
223
|
+
// case a coin toss on the gateway rather than a reading of the grader.
|
|
224
|
+
// Re-measured: the whole loop is 2.0-3.1s, the corrective path 2.8s of nine
|
|
225
|
+
// calls, and eight consecutive live runs of this suite were green. The
|
|
226
|
+
// margin belongs to the service, not to us, so the tool keeps its own
|
|
227
|
+
// budget and this case keeps a question that settles on one attempt; if the
|
|
228
|
+
// gateway slows down again the failure says which, because a spent budget
|
|
229
|
+
// comes back as the graph's own exit sentence rather than as a timeout.
|
|
230
|
+
{ live: true },
|
|
231
|
+
);
|
|
232
|
+
|
|
233
|
+
test(
|
|
234
|
+
"a question nothing covers is refused, after the corrective edge has tried",
|
|
235
|
+
async ({ session }) => {
|
|
236
|
+
const turn = await session.say(
|
|
237
|
+
"Can I add a pay-monthly mobile SIM with unlimited data to my broadband account?",
|
|
238
|
+
);
|
|
239
|
+
|
|
240
|
+
const [payload] = lookups(session);
|
|
241
|
+
expect(payload, describeTurn(turn)).toBeDefined();
|
|
242
|
+
// Withheld, not softened: `answer: null` is the tool refusing to hand the
|
|
243
|
+
// model something to read out, and the guidance is the exit the grading
|
|
244
|
+
// apparatus needs — a support line that can only answer will answer wrong.
|
|
245
|
+
// A lookup that BROKE and one that ran and found nothing are different
|
|
246
|
+
// findings, and neither is readable from "answer is not null".
|
|
247
|
+
expect(payload?.answer, JSON.stringify(payload)).toBeNull();
|
|
248
|
+
expect(String(payload?.guidance)).toMatch(/log_ticket/);
|
|
249
|
+
// The corrective edge really ran: nothing relevant means the RETRIEVAL was
|
|
250
|
+
// wrong, so the query is rewritten and retried before the loop gives up.
|
|
251
|
+
expect(payload?.rewrites).toBeGreaterThanOrEqual(1);
|
|
252
|
+
|
|
253
|
+
const trace = frames(session).at(-1)?.trace;
|
|
254
|
+
expect(trace?.exhausted).toBe(true);
|
|
255
|
+
expect(trace?.docs.every((doc) => !doc.relevant)).toBe(true);
|
|
256
|
+
expect(trace?.steps.map((step) => step.node)).toContain("transform_query");
|
|
257
|
+
},
|
|
258
|
+
{ live: true },
|
|
259
|
+
);
|
|
260
|
+
});
|