@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,424 @@
|
|
|
1
|
+
/** The def a DEPLOYED agent runs: authored, plus what `tools/` declares. */
|
|
2
|
+
import agentDef from "virtual:aai/agent";
|
|
3
|
+
import type { InferToolInput, TelephonyAccess, TelephonyCarrier } from "@alexkroman1/aai";
|
|
4
|
+
import { isToolFailure } from "@alexkroman1/aai/utils";
|
|
5
|
+
import {
|
|
6
|
+
createToolContext,
|
|
7
|
+
expectToolOk,
|
|
8
|
+
runTool,
|
|
9
|
+
type StubGenerateRoute,
|
|
10
|
+
stubGenerate,
|
|
11
|
+
type TestToolContext,
|
|
12
|
+
toolRunner,
|
|
13
|
+
} from "@alexkroman1/aai-runtime/testing";
|
|
14
|
+
import { describe, expect, test } from "vitest";
|
|
15
|
+
import { retrieve } from "./knowledge.ts";
|
|
16
|
+
import { MAX_ATTEMPTS, runCorrectiveRag } from "./procedure.ts";
|
|
17
|
+
import {
|
|
18
|
+
ANSWER_SYSTEM,
|
|
19
|
+
ANSWERS_SYSTEM,
|
|
20
|
+
DOC_GRADER_SYSTEM,
|
|
21
|
+
GROUNDED_SYSTEM,
|
|
22
|
+
REWRITE_SYSTEM,
|
|
23
|
+
} from "./prompts.ts";
|
|
24
|
+
import { ASKED_CAP, supportSlot, supportView } from "./shared.ts";
|
|
25
|
+
/** The tool FILES themselves: a file's default export is the very object
|
|
26
|
+
* `agentDef` registers under its name, and handing it to `runTool` is what
|
|
27
|
+
* types the call's arguments and its result. */
|
|
28
|
+
import AnswerQuestion from "./tools/answer_question.ts";
|
|
29
|
+
import LogTicket from "./tools/log_ticket.ts";
|
|
30
|
+
|
|
31
|
+
// ─── A scripted model ────────────────────────────────────────────────────────
|
|
32
|
+
//
|
|
33
|
+
// Every node in the graph is one `ctx.generate` call, and each call is
|
|
34
|
+
// identified by the system prompt it carries — so a fake that switches on
|
|
35
|
+
// `options.system` can drive the graph down any path, deterministically, with
|
|
36
|
+
// no model and no network. `calls` is the transcript, which is what the routing
|
|
37
|
+
// assertions read: the point of these tests is WHICH nodes ran, not what a
|
|
38
|
+
// model would have said.
|
|
39
|
+
|
|
40
|
+
interface Script {
|
|
41
|
+
/** Whether the grader passes a document, per retrieval attempt (1-based). */
|
|
42
|
+
relevant?: (docId: string, attempt: number) => boolean;
|
|
43
|
+
/** What `transform_query` rewrites to. */
|
|
44
|
+
rewrite?: string;
|
|
45
|
+
/** Answers, consumed one per `generate` node. */
|
|
46
|
+
answers?: string[];
|
|
47
|
+
/** Verdicts, consumed one per grader call. Default: pass. */
|
|
48
|
+
grounded?: ("yes" | "no")[];
|
|
49
|
+
useful?: ("yes" | "no")[];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function scriptedModel(script: Script = {}) {
|
|
53
|
+
// The NODE transcript, which is this template's own and is why the routes
|
|
54
|
+
// below are functions: `stubGenerate` records the calls, and what these
|
|
55
|
+
// assertions need is the graph's node names, labelled with their verdicts.
|
|
56
|
+
const calls: string[] = [];
|
|
57
|
+
let attempt = 1;
|
|
58
|
+
const answers = [...(script.answers ?? [])];
|
|
59
|
+
const grounded = [...(script.grounded ?? [])];
|
|
60
|
+
const useful = [...(script.useful ?? [])];
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* One of the two GENERATION graders, which differ only in their queue and the
|
|
64
|
+
* node they record.
|
|
65
|
+
*
|
|
66
|
+
* `StubGenerateRoute` is what one entry of the table below is, and naming it
|
|
67
|
+
* is the check worth having here: a route may answer a bare string — right
|
|
68
|
+
* for the free-text nodes, and for a grader it would leave the schema
|
|
69
|
+
* overload with no `object` to read, which is the one failure a stub of a
|
|
70
|
+
* `ctx.generate({ schema })` can produce.
|
|
71
|
+
*/
|
|
72
|
+
const verdictRoute =
|
|
73
|
+
(node: string, queue: ("yes" | "no")[], reason: string): StubGenerateRoute =>
|
|
74
|
+
() => {
|
|
75
|
+
const verdict = queue.shift() ?? "yes";
|
|
76
|
+
calls.push(`${node}:${verdict}`);
|
|
77
|
+
return { object: { score: verdict, reason } };
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const { generate } = stubGenerate({
|
|
81
|
+
routes: {
|
|
82
|
+
[DOC_GRADER_SYSTEM]: (call) => {
|
|
83
|
+
const id = /\[(D\d+)\]/.exec(call.prompt)?.[1] ?? "?";
|
|
84
|
+
calls.push(`grade_documents:${id}`);
|
|
85
|
+
const pass = script.relevant ? script.relevant(id, attempt) : true;
|
|
86
|
+
return { object: { score: pass ? "yes" : "no", reason: `graded ${id}` } };
|
|
87
|
+
},
|
|
88
|
+
[REWRITE_SYSTEM]: () => {
|
|
89
|
+
calls.push("transform_query");
|
|
90
|
+
attempt++;
|
|
91
|
+
return script.rewrite ?? "rewritten query";
|
|
92
|
+
},
|
|
93
|
+
[ANSWER_SYSTEM]: () => {
|
|
94
|
+
calls.push("generate");
|
|
95
|
+
return answers.shift() ?? "The documented answer.";
|
|
96
|
+
},
|
|
97
|
+
[GROUNDED_SYSTEM]: verdictRoute(
|
|
98
|
+
"grade_generation_v_documents",
|
|
99
|
+
grounded,
|
|
100
|
+
"not in the documents",
|
|
101
|
+
),
|
|
102
|
+
[ANSWERS_SYSTEM]: verdictRoute(
|
|
103
|
+
"grade_generation_v_question",
|
|
104
|
+
useful,
|
|
105
|
+
"answers something else",
|
|
106
|
+
),
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
return { generate, calls };
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** A tool by the name the model calls it by, bound to this agent. The lookup,
|
|
114
|
+
* its "no such tool" message and the args-or-context shape are all
|
|
115
|
+
* `toolRunner`'s (`@alexkroman1/aai-runtime/testing`); what is local is only which
|
|
116
|
+
* agent it runs against. */
|
|
117
|
+
const run = toolRunner(agentDef);
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* A tool context wired to a scripted model — the pair every tool case needs.
|
|
121
|
+
*
|
|
122
|
+
* `TestToolContext` is the SDK's `ToolContext` plus the `sent` log, and naming
|
|
123
|
+
* it is what lets this hand one value back where a case was destructuring a
|
|
124
|
+
* `{ generate }` only to feed it straight into `createToolContext`. The
|
|
125
|
+
* isolation case below deliberately does NOT use it: its claim is two contexts
|
|
126
|
+
* over ONE model, which is the pair this collapses.
|
|
127
|
+
*/
|
|
128
|
+
function supportContext(script: Script): TestToolContext {
|
|
129
|
+
return createToolContext({ generate: scriptedModel(script).generate });
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/** Node names without the per-call suffix, for sequence assertions. */
|
|
133
|
+
function nodes(calls: string[]): string[] {
|
|
134
|
+
return calls.map((call) => call.split(":")[0] ?? call);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/** The same sequence with consecutive repeats collapsed — `grade_documents`
|
|
138
|
+
* runs once per retrieved document, and the count is `RETRIEVE_K`'s business
|
|
139
|
+
* rather than the routing's. */
|
|
140
|
+
function phases(calls: string[]): string[] {
|
|
141
|
+
return nodes(calls).filter((node, index, all) => node !== all[index - 1]);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// ─── 1. The retriever ────────────────────────────────────────────────────────
|
|
145
|
+
|
|
146
|
+
describe("retrieval (knowledge.ts)", () => {
|
|
147
|
+
test("ranks the document a caller's words actually point at", () => {
|
|
148
|
+
expect(retrieve("my broadband light is red")[0]?.doc.id).toBe("D1");
|
|
149
|
+
expect(retrieve("nobody was home for the engineer")[0]?.doc.id).toBe("D6");
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
test("and gets the neighbouring document first often enough to need a grader", () => {
|
|
153
|
+
// "what does it cost to leave my contract early" ranks D7 (moving home,
|
|
154
|
+
// which mentions the contract AND the early exit fee) above D5, the
|
|
155
|
+
// document that actually answers it. Both come back, which is what makes
|
|
156
|
+
// the run recoverable — the document grader is the node that stops the
|
|
157
|
+
// neighbour being spoken as the answer, and this is the retrieval it is
|
|
158
|
+
// grading.
|
|
159
|
+
const ranked = retrieve("what does it cost to leave my contract early").map(
|
|
160
|
+
(one) => one.doc.id,
|
|
161
|
+
);
|
|
162
|
+
expect(ranked[0]).toBe("D7");
|
|
163
|
+
expect(ranked).toContain("D5");
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
test("returns nothing for a query with no content words", () => {
|
|
167
|
+
// Every term is a stopword, so there is nothing to rank — which the graph
|
|
168
|
+
// treats as a failed retrieval rather than as an empty knowledge base.
|
|
169
|
+
expect(retrieve("what about the one that you have")).toEqual([]);
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
test("a question phrased the way a caller speaks misses, which is the case the rewrite exists for", () => {
|
|
173
|
+
// The bait for the whole template: no document contains "dying", so lexical
|
|
174
|
+
// retrieval cannot reach D10 until `transform_query` supplies the words a
|
|
175
|
+
// document about it would use.
|
|
176
|
+
const spoken = retrieve("my internet keeps dying at night").map((one) => one.doc.id);
|
|
177
|
+
expect(spoken).not.toContain("D10");
|
|
178
|
+
expect(retrieve("evening slowdown congestion peak time")[0]?.doc.id).toBe("D10");
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
// ─── 2. The graph's routing ──────────────────────────────────────────────────
|
|
183
|
+
|
|
184
|
+
describe("corrective-RAG graph", () => {
|
|
185
|
+
test("the straight path grades, answers, and checks the answer twice", async () => {
|
|
186
|
+
const { generate, calls } = scriptedModel({
|
|
187
|
+
relevant: (id) => id === "D2",
|
|
188
|
+
answers: ["Power the hub off at the wall for thirty seconds."],
|
|
189
|
+
});
|
|
190
|
+
const trace = await runCorrectiveRag(generate, "how do I reboot the hub");
|
|
191
|
+
|
|
192
|
+
expect(phases(calls)).toEqual([
|
|
193
|
+
"grade_documents",
|
|
194
|
+
"generate",
|
|
195
|
+
"grade_generation_v_documents",
|
|
196
|
+
"grade_generation_v_question",
|
|
197
|
+
]);
|
|
198
|
+
expect(trace.answer).toContain("thirty seconds");
|
|
199
|
+
expect(trace.grounded).toBe(true);
|
|
200
|
+
expect(trace.useful).toBe(true);
|
|
201
|
+
expect(trace.rewrites).toBe(0);
|
|
202
|
+
expect(trace.exhausted).toBe(false);
|
|
203
|
+
expect(trace.docs.filter((doc) => doc.relevant).map((doc) => doc.id)).toEqual(["D2"]);
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
test("nothing relevant rewrites the query and retries — the corrective edge", async () => {
|
|
207
|
+
const { generate, calls } = scriptedModel({
|
|
208
|
+
// First retrieval is graded useless; after the rewrite everything passes.
|
|
209
|
+
relevant: (_id, attempt) => attempt > 1,
|
|
210
|
+
rewrite: "evening slowdown congestion peak time",
|
|
211
|
+
answers: ["There is no traffic management, so evening slowdowns are local."],
|
|
212
|
+
});
|
|
213
|
+
const trace = await runCorrectiveRag(generate, "my internet keeps dying at night");
|
|
214
|
+
|
|
215
|
+
expect(calls.filter((call) => call === "transform_query")).toHaveLength(1);
|
|
216
|
+
expect(trace.rewrites).toBe(1);
|
|
217
|
+
expect(trace.query).toBe("evening slowdown congestion peak time");
|
|
218
|
+
expect(trace.answer).toContain("traffic management");
|
|
219
|
+
// The trace names the nodes the way their graph does, which is what the
|
|
220
|
+
// sidebar renders.
|
|
221
|
+
expect(trace.steps.map((entry) => entry.node)).toContain("transform_query");
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
test("a caller question nothing covers ends exhausted, with no answer", async () => {
|
|
225
|
+
const { generate, calls } = scriptedModel({ relevant: () => false });
|
|
226
|
+
const trace = await runCorrectiveRag(generate, "can I get a landline installed");
|
|
227
|
+
|
|
228
|
+
expect(trace.answer).toBeNull();
|
|
229
|
+
expect(trace.exhausted).toBe(true);
|
|
230
|
+
expect(trace.rewrites).toBe(MAX_ATTEMPTS - 1);
|
|
231
|
+
// It never reached the answer node: nothing was graded relevant to answer
|
|
232
|
+
// FROM, which is the whole point of grading before generating.
|
|
233
|
+
expect(nodes(calls)).not.toContain("generate");
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
test("an ungrounded answer is regenerated once and then withheld", async () => {
|
|
237
|
+
const { generate, calls } = scriptedModel({
|
|
238
|
+
relevant: (id) => id === "D5",
|
|
239
|
+
answers: ["The exit fee is nine months.", "The exit fee is still nine months."],
|
|
240
|
+
grounded: ["no", "no"],
|
|
241
|
+
});
|
|
242
|
+
const trace = await runCorrectiveRag(generate, "what is the early exit fee");
|
|
243
|
+
|
|
244
|
+
expect(calls.filter((call) => call === "generate")).toHaveLength(2);
|
|
245
|
+
// Withheld rather than spoken with a caveat: an answer the grader says is
|
|
246
|
+
// not in the documents is the one thing a support line must never say.
|
|
247
|
+
expect(trace.answer).toBeNull();
|
|
248
|
+
expect(trace.grounded).toBe(false);
|
|
249
|
+
expect(trace.exhausted).toBe(true);
|
|
250
|
+
expect(nodes(calls)).not.toContain("grade_generation_v_question");
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
test("a grounded but beside-the-point answer rewrites once, then is returned with its verdict", async () => {
|
|
254
|
+
const { generate } = scriptedModel({
|
|
255
|
+
relevant: () => true,
|
|
256
|
+
useful: ["no", "no"],
|
|
257
|
+
// The rewrite has to retrieve something, or the second attempt ends in
|
|
258
|
+
// the no-documents branch instead of the one under test.
|
|
259
|
+
rewrite: "direct debit bill payment date",
|
|
260
|
+
answers: ["Bills go out on the first.", "Bills go out on the first."],
|
|
261
|
+
});
|
|
262
|
+
const trace = await runCorrectiveRag(generate, "when will my money actually leave my account");
|
|
263
|
+
|
|
264
|
+
expect(trace.rewrites).toBe(1);
|
|
265
|
+
expect(trace.useful).toBe(false);
|
|
266
|
+
expect(trace.exhausted).toBe(true);
|
|
267
|
+
// Still returned: it is grounded, and the tool tells the model to offer a
|
|
268
|
+
// ticket alongside it rather than to withhold it.
|
|
269
|
+
expect(trace.answer).toBe("Bills go out on the first.");
|
|
270
|
+
});
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
// ─── 3. The tools ────────────────────────────────────────────────────────────
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* The tool's OWN input type, so a field renamed in `tools/answer_question.ts`
|
|
277
|
+
* reddens here — `toolRunner` looks a tool up by string and takes a bare
|
|
278
|
+
* record, which is exactly enough freedom to pass `{ questoin }` and watch the
|
|
279
|
+
* graph retrieve nothing.
|
|
280
|
+
*/
|
|
281
|
+
function asks(question: string): InferToolInput<typeof AnswerQuestion> {
|
|
282
|
+
return { question };
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
describe("answer_question", () => {
|
|
286
|
+
test("hands back the answer, its sources and its verdicts, and records the trace", async () => {
|
|
287
|
+
const ctx = supportContext({
|
|
288
|
+
relevant: (id) => id === "D8",
|
|
289
|
+
answers: ["Area outages are on the status page, and rebooting will not help."],
|
|
290
|
+
});
|
|
291
|
+
const result = expectToolOk(await runTool(AnswerQuestion, asks("is there an outage"), ctx));
|
|
292
|
+
// `answer_question` has two legal outcomes past a refusal; this case is
|
|
293
|
+
// about the graded one, and the null check is what narrows to it.
|
|
294
|
+
if (result.answer === null) throw new Error(`expected a graded answer, got ${result.guidance}`);
|
|
295
|
+
|
|
296
|
+
expect(result.answer).toContain("status page");
|
|
297
|
+
expect(result.sources).toEqual(["Checking for an outage in your area"]);
|
|
298
|
+
expect(result.grounded).toBe(true);
|
|
299
|
+
expect(result.answersTheQuestion).toBe(true);
|
|
300
|
+
expect(result.guidance).toBeUndefined();
|
|
301
|
+
|
|
302
|
+
const state = supportSlot.get(ctx);
|
|
303
|
+
expect(state.asked).toEqual(["is there an outage"]);
|
|
304
|
+
expect(state.trace?.answer).toBe(result.answer);
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
test("with nothing grounded it returns no answer and points at the ticket", async () => {
|
|
308
|
+
const ctx = supportContext({ relevant: () => false });
|
|
309
|
+
const result = expectToolOk(await runTool(AnswerQuestion, asks("do you sell phones"), ctx));
|
|
310
|
+
expect(result.answer).toBeNull();
|
|
311
|
+
expect(result.guidance).toContain("log_ticket");
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
test("a broken model call is reported rather than thrown at the turn", async () => {
|
|
315
|
+
// ctx.generate rejecting is the default `createToolContext` gives — a bad
|
|
316
|
+
// key in production looks the same from here.
|
|
317
|
+
const ctx = createToolContext({});
|
|
318
|
+
const result = await run("answer_question", asks("anything"), ctx);
|
|
319
|
+
// The failure envelope is the SDK's, so the spec asks the SDK whether this
|
|
320
|
+
// is one rather than casting to `{ error }` — a cast reads `undefined` off
|
|
321
|
+
// a SUCCESS and fails three lines later on something else.
|
|
322
|
+
if (!isToolFailure(result))
|
|
323
|
+
throw new Error(`expected a refusal, got ${JSON.stringify(result)}`);
|
|
324
|
+
expect(result.error).toContain("knowledge base lookup failed");
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
test("two independent contexts never see each other's traces or tickets", async () => {
|
|
328
|
+
// What this really checks: the state lives in the SLOT and not in a
|
|
329
|
+
// module-level variable. `createToolContext()` hands each call its own
|
|
330
|
+
// detached slot store, so the isolation is per CONTEXT — two distinct
|
|
331
|
+
// session ids would prove nothing extra, and `sessionSlot` could stop
|
|
332
|
+
// keying by session with this still passing.
|
|
333
|
+
const { generate } = scriptedModel({ relevant: (id) => id === "D2", answers: ["Reboot it."] });
|
|
334
|
+
const first = createToolContext({ generate });
|
|
335
|
+
const second = createToolContext({ generate });
|
|
336
|
+
|
|
337
|
+
await run("answer_question", asks("how do I reboot"), first);
|
|
338
|
+
expect(supportSlot.get(second).trace).toBeNull();
|
|
339
|
+
expect(supportSlot.get(first).trace).not.toBeNull();
|
|
340
|
+
});
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
describe("the support slot", () => {
|
|
344
|
+
test("bounds the asked list at the cap it declares, dropping the oldest", () => {
|
|
345
|
+
// The bound is `caps` on the SLOT rather than a `pushCapped` inside the
|
|
346
|
+
// tool, so it holds for whatever path wrote — which is what this drives:
|
|
347
|
+
// plain `update` windows, no tool call. `asked` rides in every `syncState`
|
|
348
|
+
// frame, so an unbounded one is a call that grows its own state forever.
|
|
349
|
+
const ctx = createToolContext({});
|
|
350
|
+
for (let n = 1; n <= ASKED_CAP + 3; n++) {
|
|
351
|
+
supportSlot.update(ctx, (state) => {
|
|
352
|
+
state.asked.push(`question ${n}`);
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
const { asked } = supportSlot.get(ctx);
|
|
356
|
+
expect(asked).toHaveLength(ASKED_CAP);
|
|
357
|
+
expect(asked[0]).toBe("question 4");
|
|
358
|
+
expect(asked.at(-1)).toBe(`question ${ASKED_CAP + 3}`);
|
|
359
|
+
});
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
describe("log_ticket", () => {
|
|
363
|
+
test("logs a reference and keeps the callback number off the wire", async () => {
|
|
364
|
+
const ctx = createToolContext({});
|
|
365
|
+
const args: InferToolInput<typeof LogTicket> = {
|
|
366
|
+
question: "landline install",
|
|
367
|
+
callback: "07700 900123",
|
|
368
|
+
};
|
|
369
|
+
const logged = expectToolOk(await runTool(LogTicket, args, ctx));
|
|
370
|
+
expect(logged.reference).toBe("TCK4001");
|
|
371
|
+
|
|
372
|
+
const state = supportSlot.get(ctx);
|
|
373
|
+
expect(state.ticket?.callback).toBe("07700 900123");
|
|
374
|
+
// The projection is the privacy boundary — only the reference crosses.
|
|
375
|
+
const view = supportView(state);
|
|
376
|
+
expect(view.ticket).toBe("TCK4001");
|
|
377
|
+
expect(JSON.stringify(view)).not.toContain("900123");
|
|
378
|
+
});
|
|
379
|
+
});
|
|
380
|
+
|
|
381
|
+
// ─── 4. The front door ───────────────────────────────────────────────────────
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* Does this agent admit a call from `carrier`?
|
|
385
|
+
*
|
|
386
|
+
* `TelephonyAccess` is `true` (every carrier the runtime ships a codec for) OR
|
|
387
|
+
* an allow-list, and only the second is a claim about a PARTICULAR one — so a
|
|
388
|
+
* spec asserting "twilio reaches this line" has to handle both arms rather than
|
|
389
|
+
* compare the field to an array. `undefined` is the third state and the one
|
|
390
|
+
* that matters most: `WS /phone` is an allow-list, so an agent that says
|
|
391
|
+
* nothing about carriers answers no calls at all.
|
|
392
|
+
*/
|
|
393
|
+
function admits(access: TelephonyAccess | undefined, carrier: TelephonyCarrier): boolean {
|
|
394
|
+
if (access === undefined) return false;
|
|
395
|
+
// `true` admits every carrier the runtime ships a codec for and `false` is
|
|
396
|
+
// the explicit refusal; only an allow-list is a claim about one carrier.
|
|
397
|
+
if (typeof access === "boolean") return access;
|
|
398
|
+
return access.includes(carrier);
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
describe("the phone route", () => {
|
|
402
|
+
test("is armed, and named narrowly", () => {
|
|
403
|
+
// A support line is a PHONE line — the premise of the whole template — and
|
|
404
|
+
// nothing else here would notice the day `telephony` came off the def.
|
|
405
|
+
expect(admits(agentDef.telephony, "twilio")).toBe(true);
|
|
406
|
+
// `["twilio"]` rather than `true`: the narrower statement is the one to
|
|
407
|
+
// copy, and it is only a statement if a carrier this agent did not name is
|
|
408
|
+
// actually refused.
|
|
409
|
+
expect(admits(agentDef.telephony, "telnyx")).toBe(false);
|
|
410
|
+
});
|
|
411
|
+
});
|
|
412
|
+
|
|
413
|
+
describe("supportView projection", () => {
|
|
414
|
+
test("an untouched call projects an empty trace, not undefined", () => {
|
|
415
|
+
// Exactly the frame `client.tsx` renders before the first push — it passes
|
|
416
|
+
// this same projection to `useAgentState`.
|
|
417
|
+
expect(supportSlot.projected()).toMatchObject({
|
|
418
|
+
product: "Meridian Fibre",
|
|
419
|
+
trace: null,
|
|
420
|
+
asked: [],
|
|
421
|
+
ticket: null,
|
|
422
|
+
});
|
|
423
|
+
});
|
|
424
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { agent } from "@alexkroman1/aai";
|
|
2
|
+
import { PRODUCT, supportSlot } from "./shared.ts";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A support line that grades its own retrieval before it speaks — the
|
|
6
|
+
* self-RAG / CRAG graph, ported to voice. `procedure.ts` holds the loop, `prompts.ts`
|
|
7
|
+
* the attribution and the graders, `knowledge.ts` the knowledge base and why its
|
|
8
|
+
* retriever is lexical.
|
|
9
|
+
*
|
|
10
|
+
* **Why this shape is worth the model calls on a phone line.** A naive RAG voice
|
|
11
|
+
* agent retrieves, stuffs the documents into the prompt and speaks — and when
|
|
12
|
+
* retrieval missed, it answers from the nearest document it was handed, which
|
|
13
|
+
* over a phone is indistinguishable from a confident correct answer. The
|
|
14
|
+
* template's own knowledge base is built to bait exactly that: "cancelling your
|
|
15
|
+
* contract" and "cancelling an engineer visit" are two documents, two fees, and
|
|
16
|
+
* one word apart. The document grader is what makes the second one not get
|
|
17
|
+
* spoken as the answer to the first.
|
|
18
|
+
*/
|
|
19
|
+
export default agent({
|
|
20
|
+
name: `${PRODUCT} Support`,
|
|
21
|
+
// For a reader of a LIST of agents, not for the model. It says what the line
|
|
22
|
+
// does with a question it cannot answer, because that is the half a caller
|
|
23
|
+
// reading a directory wants to know.
|
|
24
|
+
description: `Answers ${PRODUCT} support questions from a graded knowledge base, and logs a ticket when it cannot`,
|
|
25
|
+
// The trace exists before the first tool call, so a resumed connection has
|
|
26
|
+
// something to project.
|
|
27
|
+
// The projection is also the privacy boundary: a logged ticket carries the
|
|
28
|
+
// caller's callback number, and only its reference crosses to the browser.
|
|
29
|
+
syncState: supportSlot.projected,
|
|
30
|
+
greeting: `${PRODUCT} support, you're through to the automated line. What's happened?`,
|
|
31
|
+
// A support line is a PHONE line, so this one declares the carrier its number
|
|
32
|
+
// is with. Nothing serves `WS /phone` without this — the route is an
|
|
33
|
+
// allow-list, and an agent that says nothing about carriers answers none — so
|
|
34
|
+
// point a Twilio number's webhook at the deployed agent's `/phone` and the
|
|
35
|
+
// call lands in an ordinary session. `true` admits every carrier the runtime
|
|
36
|
+
// ships a codec for; a list is the narrower statement, and it is the one to
|
|
37
|
+
// copy.
|
|
38
|
+
telephony: ["twilio"],
|
|
39
|
+
});
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { plural } from "@alexkroman1/aai/utils";
|
|
2
|
+
import "@alexkroman1/aai-ui/styles.css";
|
|
3
|
+
import { AutoScroll, Facts, mountClient, useAgentState } from "@alexkroman1/aai-ui";
|
|
4
|
+
import { PRODUCT, supportSlot } from "./shared.ts";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The graph, as it ran for the last question.
|
|
8
|
+
*
|
|
9
|
+
* This is the panel worth having: the whole argument for the corrective loop is
|
|
10
|
+
* work the caller never hears — four documents retrieved, three rejected, the
|
|
11
|
+
* question rewritten once — and a support line whose grading is invisible is a
|
|
12
|
+
* support line nobody can tell apart from one that just guesses well.
|
|
13
|
+
*/
|
|
14
|
+
function TraceSidebar() {
|
|
15
|
+
const support = useAgentState(supportSlot.projected);
|
|
16
|
+
const trace = support.trace;
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<div className="flex h-full min-h-0 flex-col gap-4 p-4 text-aai-text">
|
|
20
|
+
<div>
|
|
21
|
+
<h3 className="text-sm font-bold uppercase tracking-wide opacity-60">{support.product}</h3>
|
|
22
|
+
{/* A conditional segment is an ITEM, not a ` · ` spliced into a
|
|
23
|
+
template string: `Facts` drops anything false and owns the
|
|
24
|
+
separator, which is the join both of this sidebar's muted lines
|
|
25
|
+
were writing by hand. */}
|
|
26
|
+
<Facts
|
|
27
|
+
size="xs"
|
|
28
|
+
items={[
|
|
29
|
+
`${support.asked.length} ${plural(support.asked.length, "question")} this call`,
|
|
30
|
+
support.ticket !== null && `ticket ${support.ticket}`,
|
|
31
|
+
]}
|
|
32
|
+
/>
|
|
33
|
+
</div>
|
|
34
|
+
|
|
35
|
+
{!trace && (
|
|
36
|
+
<p className="text-sm opacity-50">
|
|
37
|
+
Ask a question and the retrieval, the grades and the verdicts appear here.
|
|
38
|
+
</p>
|
|
39
|
+
)}
|
|
40
|
+
|
|
41
|
+
{trace && (
|
|
42
|
+
<AutoScroll
|
|
43
|
+
scrollClassName="min-h-0 overflow-y-auto"
|
|
44
|
+
contentClassName="flex flex-col gap-4 pr-1"
|
|
45
|
+
>
|
|
46
|
+
<div className="rounded-lg p-3 bg-aai-surface">
|
|
47
|
+
<p className="text-[11px] font-bold uppercase tracking-wide opacity-60">Question</p>
|
|
48
|
+
<p className="text-sm">{trace.question}</p>
|
|
49
|
+
{trace.rewrites > 0 && (
|
|
50
|
+
<p className="mt-1 text-xs opacity-60">
|
|
51
|
+
rewritten to <span className="italic">{trace.query}</span>
|
|
52
|
+
</p>
|
|
53
|
+
)}
|
|
54
|
+
</div>
|
|
55
|
+
|
|
56
|
+
<div className="flex flex-col gap-1.5">
|
|
57
|
+
<p className="text-[11px] font-bold uppercase tracking-wide opacity-60">
|
|
58
|
+
Retrieved & graded
|
|
59
|
+
</p>
|
|
60
|
+
{trace.docs.length === 0 && <p className="text-xs opacity-50">Nothing retrieved.</p>}
|
|
61
|
+
{trace.docs.map((doc) => (
|
|
62
|
+
<div
|
|
63
|
+
key={doc.id}
|
|
64
|
+
className={`flex items-start gap-2 rounded-lg p-2 bg-aai-surface ${
|
|
65
|
+
doc.relevant ? "" : "opacity-50"
|
|
66
|
+
}`}
|
|
67
|
+
>
|
|
68
|
+
<span className={doc.relevant ? "text-aai-primary" : "text-aai-text"}>
|
|
69
|
+
{doc.relevant ? "✓" : "×"}
|
|
70
|
+
</span>
|
|
71
|
+
<div className="min-w-0">
|
|
72
|
+
<p className="text-sm">{doc.title}</p>
|
|
73
|
+
<p className="text-xs opacity-60">{doc.reason}</p>
|
|
74
|
+
</div>
|
|
75
|
+
</div>
|
|
76
|
+
))}
|
|
77
|
+
</div>
|
|
78
|
+
|
|
79
|
+
<div className="flex flex-col gap-1">
|
|
80
|
+
<p className="text-[11px] font-bold uppercase tracking-wide opacity-60">Procedure</p>
|
|
81
|
+
{trace.steps.map((entry, index) => (
|
|
82
|
+
// Steps are append-only within a run, so the index is stable.
|
|
83
|
+
<p key={`${index}-${entry.node}`} className="text-xs">
|
|
84
|
+
<span className="font-mono opacity-80">{entry.node}</span>
|
|
85
|
+
<span className="opacity-50"> — {entry.detail}</span>
|
|
86
|
+
</p>
|
|
87
|
+
))}
|
|
88
|
+
</div>
|
|
89
|
+
|
|
90
|
+
<div className="rounded-lg p-3 bg-aai-surface">
|
|
91
|
+
<p className="text-[11px] font-bold uppercase tracking-wide opacity-60">Verdict</p>
|
|
92
|
+
{trace.answer ? (
|
|
93
|
+
<p className="text-sm">{trace.answer}</p>
|
|
94
|
+
) : (
|
|
95
|
+
<p className="text-sm opacity-60">No answer could be grounded.</p>
|
|
96
|
+
)}
|
|
97
|
+
<Facts
|
|
98
|
+
size="xs"
|
|
99
|
+
className="mt-2"
|
|
100
|
+
items={[
|
|
101
|
+
`grounded: ${String(trace.grounded)}`,
|
|
102
|
+
`answers the question: ${String(trace.useful)}`,
|
|
103
|
+
trace.exhausted && "budget exhausted",
|
|
104
|
+
]}
|
|
105
|
+
/>
|
|
106
|
+
</div>
|
|
107
|
+
</AutoScroll>
|
|
108
|
+
)}
|
|
109
|
+
</div>
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
mountClient({
|
|
114
|
+
// Derived, not typed twice: `PRODUCT` comes off `knowledge.json`, which is
|
|
115
|
+
// what `agent.ts` names the agent and greets with. A knowledge base swapped
|
|
116
|
+
// for another product otherwise leaves the browser tab advertising the old
|
|
117
|
+
// one.
|
|
118
|
+
name: `${PRODUCT} Support`,
|
|
119
|
+
sidebar: TraceSidebar,
|
|
120
|
+
theme: {
|
|
121
|
+
bg: "#0b1220",
|
|
122
|
+
primary: "#4ea8de",
|
|
123
|
+
text: "#e8eef6",
|
|
124
|
+
surface: "#141d2e",
|
|
125
|
+
border: "#1f2b3f",
|
|
126
|
+
},
|
|
127
|
+
tools: {
|
|
128
|
+
answer_question: { icon: "\u{1F50D}", label: "Checking the knowledge base" },
|
|
129
|
+
list_topics: { icon: "\u{1F4DA}", label: "Listing topics" },
|
|
130
|
+
log_ticket: { icon: "\u{1F4DD}", label: "Logging a ticket" },
|
|
131
|
+
},
|
|
132
|
+
});
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"product": "Meridian Fibre",
|
|
3
|
+
"docs": [
|
|
4
|
+
{
|
|
5
|
+
"id": "D1",
|
|
6
|
+
"title": "Router lights and what they mean",
|
|
7
|
+
"topic": "connection",
|
|
8
|
+
"text": "The Meridian hub has three lights. A solid white power light means the hub is on. A solid blue broadband light means the line is synced. A flashing blue light means the hub is still syncing, which can take up to fifteen minutes after a power cut. A red broadband light means the line is down: check the fibre cable is pushed fully into the grey socket, then leave the hub powered on for fifteen minutes before doing anything else."
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"id": "D2",
|
|
12
|
+
"title": "Rebooting the hub",
|
|
13
|
+
"topic": "connection",
|
|
14
|
+
"text": "Power the hub off at the wall, wait thirty seconds, and power it back on. Do not use the pinhole reset button unless an agent asks you to: that clears your wifi name and password as well, and every device in the house then has to be reconnected. A normal reboot keeps all your settings."
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"id": "D3",
|
|
18
|
+
"title": "Slow speeds over wifi",
|
|
19
|
+
"topic": "speed",
|
|
20
|
+
"text": "Wifi speed drops with distance and with walls. Keep the hub off the floor, out of a cupboard, and away from the microwave and the TV. A wired device plugged into a yellow ethernet port is the only way to measure your real line speed; a speed test over wifi measures the wifi, not the fibre. If a wired test is more than twenty percent below your plan speed for three days running, that is a line fault and we will send an engineer."
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"id": "D4",
|
|
24
|
+
"title": "Your bill and when it is taken",
|
|
25
|
+
"topic": "billing",
|
|
26
|
+
"text": "Bills are issued on the first of the month and the direct debit is taken eight working days later. Your first bill also carries a part month charge for the days between your activation date and the first of the month, so it is usually larger than the ones that follow. You can change the payment date once every twelve months from the account page."
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"id": "D5",
|
|
30
|
+
"title": "Cancelling your contract",
|
|
31
|
+
"topic": "account",
|
|
32
|
+
"text": "You can cancel at any time by giving thirty days notice. If you are still inside your minimum term, an early exit fee applies: it is the remaining months of the term multiplied by your monthly price, capped at six months. Notice starts on the day we receive it, not the day you post the equipment back. The hub must be returned within fourteen days of the service ending or a fifty pound non return fee is charged."
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"id": "D6",
|
|
36
|
+
"title": "Cancelling or rebooking an engineer visit",
|
|
37
|
+
"topic": "appointments",
|
|
38
|
+
"text": "An engineer visit can be moved or cancelled free of charge until midnight the day before. After that, and for a missed appointment where nobody over eighteen was at the property, a sixty pound abortive visit charge applies. Rebooking is done from the appointments page or by asking us on the phone; the next available slot is usually within three working days."
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"id": "D7",
|
|
42
|
+
"title": "Moving home",
|
|
43
|
+
"topic": "account",
|
|
44
|
+
"text": "Tell us at least four weeks before you move. If Meridian Fibre is available at the new address we move the service and your contract continues unchanged, with a one off activation charge of thirty five pounds. If we cannot serve the new address, the contract ends with no early exit fee, which is the one case where the fee is waived."
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"id": "D8",
|
|
48
|
+
"title": "Checking for an outage in your area",
|
|
49
|
+
"topic": "connection",
|
|
50
|
+
"text": "Area outages are listed on the status page and the phone line plays a recorded message naming the affected postcodes. During a confirmed outage there is nothing to fix at your end: rebooting the hub will not help and an engineer cannot be booked until the area work is closed. Compensation of eight pounds per full day starts after the second full day of a confirmed total loss of service."
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"id": "D9",
|
|
54
|
+
"title": "Static IP addresses",
|
|
55
|
+
"topic": "advanced",
|
|
56
|
+
"text": "A static IP address is available on business plans only, at five pounds a month. It cannot be added to a residential plan; upgrading to business is the only route, and that starts a new twelve month term. Port forwarding, by contrast, works on every plan and needs no static IP."
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"id": "D10",
|
|
60
|
+
"title": "Data caps and traffic management",
|
|
61
|
+
"topic": "speed",
|
|
62
|
+
"text": "There is no data cap on any Meridian Fibre plan and no traffic management at peak times. If your speed drops every evening at the same time, that is congestion in your own home, usually a device backing up or streaming in the background, and not something we apply."
|
|
63
|
+
}
|
|
64
|
+
]
|
|
65
|
+
}
|