@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,635 @@
|
|
|
1
|
+
/** The def a DEPLOYED agent runs: authored, plus what `tools/` declares. */
|
|
2
|
+
import agentDef from "virtual:aai/agent";
|
|
3
|
+
import type { ToolContext } from "@alexkroman1/aai";
|
|
4
|
+
import { visitWebpage, webSearch } from "@alexkroman1/aai/tools";
|
|
5
|
+
import {
|
|
6
|
+
createToolContext,
|
|
7
|
+
expectDialogOk,
|
|
8
|
+
expectToolOk,
|
|
9
|
+
runGuardrail,
|
|
10
|
+
runTool,
|
|
11
|
+
type StubDelegateRoute,
|
|
12
|
+
type StubGenerateRoute,
|
|
13
|
+
stubDelegate,
|
|
14
|
+
toolRunner,
|
|
15
|
+
} from "@alexkroman1/aai-runtime/testing";
|
|
16
|
+
import { describe, expect, test, vi } from "vitest";
|
|
17
|
+
import { executeStep, executor, MAX_STEP_TURNS, normalizeAct, planNode } from "./procedure.ts";
|
|
18
|
+
import { PLANNER_SYSTEM, REPLANNER_SYSTEM, REVISE_SYSTEM, type StepAnswer } from "./prompts.ts";
|
|
19
|
+
import {
|
|
20
|
+
MAX_PAGE_CHARS,
|
|
21
|
+
MAX_PAST_STEPS,
|
|
22
|
+
MAX_REVISIONS,
|
|
23
|
+
planFlow,
|
|
24
|
+
planSlot,
|
|
25
|
+
planView,
|
|
26
|
+
readTool,
|
|
27
|
+
searchTool,
|
|
28
|
+
} from "./shared.ts";
|
|
29
|
+
import startPlan from "./tools/start_plan.ts";
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The web, faked at the SDK's own seam.
|
|
33
|
+
*
|
|
34
|
+
* `webSearch` screens a URL and then really fetches it, through an undici
|
|
35
|
+
* dispatcher a `globalThis.fetch` stub cannot reach — so mocking the module is
|
|
36
|
+
* the only honest way to keep this suite offline. The EXECUTOR's own tests need
|
|
37
|
+
* none of it: they stub the delegation, which is the seam a subagent is reached
|
|
38
|
+
* through.
|
|
39
|
+
*/
|
|
40
|
+
vi.mock("@alexkroman1/aai/tools", () => ({ webSearch: vi.fn(), visitWebpage: vi.fn() }));
|
|
41
|
+
|
|
42
|
+
// ─── A scripted desk ─────────────────────────────────────────────────────────
|
|
43
|
+
//
|
|
44
|
+
// TWO fakes, because the desk reaches a model two ways. The planner and the
|
|
45
|
+
// replanner are `ctx.generate` calls carrying their own system prompt, so the
|
|
46
|
+
// `generate` script — keyed by system prompt — drives them; the EXECUTOR is a
|
|
47
|
+
// subagent, so the `delegate` script drives it, routed by subagent name. That
|
|
48
|
+
// split is the conversion showing through in the test file, and it is the
|
|
49
|
+
// honest one: a spec that scripted the executor's turns was scripting a loop
|
|
50
|
+
// this template no longer owns. `createToolContext` builds both fakes and
|
|
51
|
+
// the context they are wired into, so every test below starts from one call.
|
|
52
|
+
|
|
53
|
+
interface Script {
|
|
54
|
+
steps?: string[];
|
|
55
|
+
/** One entry per executed step: what the executor concluded. */
|
|
56
|
+
answers?: (string | StepAnswer)[];
|
|
57
|
+
/** Searches to report on each executed step, as the run's tool calls. */
|
|
58
|
+
searches?: string[];
|
|
59
|
+
/** One entry per replan/revise call. */
|
|
60
|
+
acts?: { kind: "respond" | "plan"; response?: string; steps?: string[] }[];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* One executor run's final message.
|
|
65
|
+
*
|
|
66
|
+
* The executor declares a `schema`, so its reply really is JSON on the wire and
|
|
67
|
+
* `stubDelegate` really parses it against that schema — a script that drifted
|
|
68
|
+
* from the shape fails HERE naming the subagent, rather than handing
|
|
69
|
+
* `executeStep` an `object` it never had. A bare string is the settled case,
|
|
70
|
+
* which is what most of these tests want to say.
|
|
71
|
+
*/
|
|
72
|
+
function stepReply(answer: string | StepAnswer): string {
|
|
73
|
+
return JSON.stringify(typeof answer === "string" ? { finding: answer, settled: true } : answer);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function scriptedDesk(script: Script = {}) {
|
|
77
|
+
const answers = [...(script.answers ?? [])];
|
|
78
|
+
const acts = [...(script.acts ?? [])];
|
|
79
|
+
// The replanner and the reviser are the same node with a different brief, so
|
|
80
|
+
// they share one queue — which is what the "revise then carry on" test rests on.
|
|
81
|
+
// Annotated as the SDK's own route type: a route is a reply or a function of
|
|
82
|
+
// the call, and naming it is what keeps this queue honest about being the
|
|
83
|
+
// second form rather than a value computed once.
|
|
84
|
+
const act: StubGenerateRoute = () => ({
|
|
85
|
+
object: acts.shift() ?? { kind: "respond", response: "All done." },
|
|
86
|
+
});
|
|
87
|
+
const worksTheStep: StubDelegateRoute = () => ({
|
|
88
|
+
text: stepReply(answers.shift() ?? "Settled it."),
|
|
89
|
+
toolCalls: (script.searches ?? []).map((query) => ({ name: "search", input: { query } })),
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
const ctx = createToolContext({
|
|
93
|
+
generate: {
|
|
94
|
+
routes: {
|
|
95
|
+
[PLANNER_SYSTEM]: { object: { steps: script.steps ?? ["Only step"] } },
|
|
96
|
+
[REPLANNER_SYSTEM]: act,
|
|
97
|
+
[REVISE_SYSTEM]: act,
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
delegate: { routes: { executor: worksTheStep } },
|
|
101
|
+
});
|
|
102
|
+
return { ctx, model: ctx.model, desk: ctx.desk };
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** A tool by the name the model calls it by, bound to this agent. The lookup,
|
|
106
|
+
* its "no such tool" message and the args-or-context shape are all
|
|
107
|
+
* `toolRunner`'s (`@alexkroman1/aai-runtime/testing`); what is local is only which
|
|
108
|
+
* agent it runs against. */
|
|
109
|
+
const run = toolRunner(agentDef);
|
|
110
|
+
|
|
111
|
+
function stateOf(ctx: ToolContext) {
|
|
112
|
+
return planSlot.get(ctx);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// ─── 1. The nodes ────────────────────────────────────────────────────────────
|
|
116
|
+
|
|
117
|
+
describe("planNode", () => {
|
|
118
|
+
test("returns the steps the planner produced", async () => {
|
|
119
|
+
const { model } = scriptedDesk({ steps: ["Check prices", "Book it"] });
|
|
120
|
+
expect(await planNode(model.generate, "get me to Lisbon in May")).toEqual([
|
|
121
|
+
"Check prices",
|
|
122
|
+
"Book it",
|
|
123
|
+
]);
|
|
124
|
+
expect(model.calls[0]?.prompt).toContain("get me to Lisbon in May");
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
describe("executeStep", () => {
|
|
129
|
+
test("hands the step to the executor, with the objective and the history as context", async () => {
|
|
130
|
+
const desk = stubDelegate({
|
|
131
|
+
routes: { executor: stepReply("Flights are around 180 return.") },
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
const outcome = await executeStep(desk.delegate, "get to Lisbon", "Check prices", [
|
|
135
|
+
{ step: "Pick dates", result: "Mid-May", settled: true, searches: [] },
|
|
136
|
+
]);
|
|
137
|
+
|
|
138
|
+
// `finding` off the schema's own output, not the raw final message: the
|
|
139
|
+
// executor is a TYPED subagent, so what crosses back is a parsed object.
|
|
140
|
+
expect(outcome.result).toBe("Flights are around 180 return.");
|
|
141
|
+
expect(outcome.settled).toBe(true);
|
|
142
|
+
// The STEP is the task; everything the executor needs to do it in context
|
|
143
|
+
// rides in `context`, because a subagent has not heard the call.
|
|
144
|
+
expect(desk.calls[0]?.task).toBe("Check prices");
|
|
145
|
+
expect(desk.calls[0]?.options.context).toContain("get to Lisbon");
|
|
146
|
+
expect(desk.calls[0]?.options.context).toContain("Mid-May");
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
test("reports what it searched, read off the calls the run made", async () => {
|
|
150
|
+
// A search's RESULTS stayed inside the executor's context — that is the
|
|
151
|
+
// delegation — so the calls are the only honest source for the desk's
|
|
152
|
+
// "what the wait bought" line.
|
|
153
|
+
const desk = stubDelegate({
|
|
154
|
+
routes: {
|
|
155
|
+
executor: {
|
|
156
|
+
text: stepReply("Flights are around 180 return."),
|
|
157
|
+
toolCalls: [
|
|
158
|
+
{ name: "search", input: { query: "lisbon flights may" } },
|
|
159
|
+
{ name: "search", input: { query: "lisbon flights june" } },
|
|
160
|
+
],
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
const outcome = await executeStep(desk.delegate, "get to Lisbon", "Check prices", []);
|
|
166
|
+
|
|
167
|
+
expect(outcome.searches).toEqual(["lisbon flights may", "lisbon flights june"]);
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
test("the executor is given its two tools and a bounded budget", async () => {
|
|
171
|
+
// What this template still OWNS now that the loop is the runtime's: which
|
|
172
|
+
// capabilities the step is worth, and how long it may spend.
|
|
173
|
+
const desk = stubDelegate({ routes: { executor: stepReply("done") } });
|
|
174
|
+
await executeStep(desk.delegate, "objective", "step", []);
|
|
175
|
+
|
|
176
|
+
const executor = desk.calls[0]?.subagent;
|
|
177
|
+
expect(Object.keys(executor?.tools ?? {})).toEqual(["search", "read"]);
|
|
178
|
+
expect(executor?.maxSteps).toBe(MAX_STEP_TURNS);
|
|
179
|
+
// No `builtinTools`: both are this template's own tools over
|
|
180
|
+
// `@alexkroman1/aai/tools`, which is the example that outlived the loop.
|
|
181
|
+
expect(executor?.builtinTools).toBeUndefined();
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
test("an unsettled step is carried as a FIELD, not inferred from the wording", async () => {
|
|
185
|
+
// `settled` is what a prompt could not hold: "say plainly rather than
|
|
186
|
+
// inventing a result" was in `EXECUTOR_OUTPUT` from the start, and the desk
|
|
187
|
+
// read one string, so a step that found nothing and a step that answered
|
|
188
|
+
// arrived in the same shape.
|
|
189
|
+
const desk = stubDelegate({
|
|
190
|
+
routes: {
|
|
191
|
+
executor: stepReply({ finding: "Nothing current on that route.", settled: false }),
|
|
192
|
+
},
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
const outcome = await executeStep(desk.delegate, "get to Lisbon", "Check prices", []);
|
|
196
|
+
|
|
197
|
+
expect(outcome.settled).toBe(false);
|
|
198
|
+
expect(outcome.result).toBe("Nothing current on that route.");
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
test("an answer the guardrail never accepted is not a settled step", async () => {
|
|
202
|
+
// The run had its revision and still reported a step it never looked into,
|
|
203
|
+
// so `accepted` is false — and a `settled: true` from an answer the runtime
|
|
204
|
+
// refused is exactly the claim not to take at face value.
|
|
205
|
+
const desk = stubDelegate({
|
|
206
|
+
routes: {
|
|
207
|
+
executor: {
|
|
208
|
+
text: stepReply({ finding: "Flights are cheap in May.", settled: true }),
|
|
209
|
+
complaint: "You reported the step as unsettled without searching for anything.",
|
|
210
|
+
},
|
|
211
|
+
},
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
const outcome = await executeStep(desk.delegate, "get to Lisbon", "Check prices", []);
|
|
215
|
+
|
|
216
|
+
expect(outcome.settled).toBe(false);
|
|
217
|
+
expect(outcome.result).toBe("Flights are cheap in May.");
|
|
218
|
+
});
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
describe("the executor's guardrail", () => {
|
|
222
|
+
// Driven through `runGuardrail` rather than by calling the function, so what
|
|
223
|
+
// is under test is the DEF: a guardrail dropped from `subagent()` fails here.
|
|
224
|
+
const verdict = (answer: StepAnswer, searched: number) =>
|
|
225
|
+
runGuardrail(executor, JSON.stringify(answer), {
|
|
226
|
+
toolCalls: Array.from({ length: searched }, () => ({
|
|
227
|
+
name: "search",
|
|
228
|
+
input: { query: "anything" },
|
|
229
|
+
})),
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
test("a settled step needs no search", () => {
|
|
233
|
+
// Plenty of steps are summaries of what earlier ones found. A general "did
|
|
234
|
+
// you search enough" would reject those and cost a whole extra run.
|
|
235
|
+
expect(verdict({ finding: "Two of the three are already booked.", settled: true }, 0)).toBe(
|
|
236
|
+
true,
|
|
237
|
+
);
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
test("an unsettled step that really looked is accepted", () => {
|
|
241
|
+
expect(verdict({ finding: "Could not find a fare for that date.", settled: false }, 2)).toBe(
|
|
242
|
+
true,
|
|
243
|
+
);
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
test("giving up without looking is sent back", () => {
|
|
247
|
+
// The failure this template's headline claim is exposed to: reporting a
|
|
248
|
+
// step unsettled from memory is cheaper than either honest move.
|
|
249
|
+
expect(verdict({ finding: "I do not know what that costs.", settled: false }, 0)).toMatch(
|
|
250
|
+
/without searching/,
|
|
251
|
+
);
|
|
252
|
+
});
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
describe("the executor's search tool", () => {
|
|
256
|
+
test("renders the hits the model reasons over", async () => {
|
|
257
|
+
vi.mocked(webSearch).mockResolvedValueOnce({
|
|
258
|
+
results: [{ title: "Fares to Lisbon", url: "https://example.test/fares" }],
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
const rendered = await searchTool.execute({ query: "lisbon flights" }, createToolContext());
|
|
262
|
+
|
|
263
|
+
expect(rendered).toContain("Fares to Lisbon");
|
|
264
|
+
expect(rendered).toContain("https://example.test/fares");
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
test("a REFUSED search comes back as a failure, not as an empty web", async () => {
|
|
268
|
+
// `webSearch` answers with `{ error }` rather than throwing, and measured,
|
|
269
|
+
// DuckDuckGo answers 403 often enough to be the ordinary case. `orFail`
|
|
270
|
+
// carries the refusal out as the tool's own `ToolFailure` — an empty list
|
|
271
|
+
// would tell the executor there is nothing out there, and a thrown `Error`
|
|
272
|
+
// would have the runtime log an ordinary 403 as an uncaught tool bug.
|
|
273
|
+
vi.mocked(webSearch).mockResolvedValueOnce({ error: "403 Forbidden" });
|
|
274
|
+
|
|
275
|
+
expect(await searchTool.execute({ query: "anything" }, createToolContext())).toEqual({
|
|
276
|
+
error: "403 Forbidden",
|
|
277
|
+
});
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
test("the caller's signal reaches the fetch", async () => {
|
|
281
|
+
// A tool body gets a signal and `CallOptions` takes one; until they were
|
|
282
|
+
// joined, a caller who hung up mid-step left a search running against a
|
|
283
|
+
// third party.
|
|
284
|
+
vi.mocked(webSearch).mockResolvedValueOnce({ results: [] });
|
|
285
|
+
const ctx = createToolContext();
|
|
286
|
+
|
|
287
|
+
await searchTool.execute({ query: "anything" }, ctx);
|
|
288
|
+
|
|
289
|
+
expect(vi.mocked(webSearch).mock.calls[0]?.[0]).toMatchObject({ signal: ctx.signal });
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
test("says so when the web really had nothing", async () => {
|
|
293
|
+
vi.mocked(webSearch).mockResolvedValueOnce({ results: [] });
|
|
294
|
+
expect(await searchTool.execute({ query: "anything" }, createToolContext())).toBe(
|
|
295
|
+
"No results.",
|
|
296
|
+
);
|
|
297
|
+
});
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
describe("the executor's read tool", () => {
|
|
301
|
+
test("hands back the page body, capped", async () => {
|
|
302
|
+
vi.mocked(visitWebpage).mockResolvedValueOnce({ content: "x".repeat(MAX_PAGE_CHARS + 500) });
|
|
303
|
+
|
|
304
|
+
const body = await readTool.execute({ url: "https://example.test/fares" }, createToolContext());
|
|
305
|
+
|
|
306
|
+
// A step is answered from a page's substance; the rest is context the run
|
|
307
|
+
// pays for and the executor does not read.
|
|
308
|
+
expect(String(body)).toHaveLength(MAX_PAGE_CHARS);
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
test("a page that would not load is not a page that said nothing", async () => {
|
|
312
|
+
vi.mocked(visitWebpage).mockResolvedValueOnce({ error: "404 Not Found" });
|
|
313
|
+
|
|
314
|
+
expect(
|
|
315
|
+
await readTool.execute({ url: "https://example.test/gone" }, createToolContext()),
|
|
316
|
+
).toEqual({ error: "404 Not Found" });
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
test("the caller's signal reaches the fetch here too", async () => {
|
|
320
|
+
vi.mocked(visitWebpage).mockResolvedValueOnce({ content: "anything" });
|
|
321
|
+
const ctx = createToolContext();
|
|
322
|
+
|
|
323
|
+
await readTool.execute({ url: "https://example.test/fares" }, ctx);
|
|
324
|
+
|
|
325
|
+
expect(vi.mocked(visitWebpage).mock.calls[0]?.[1]).toMatchObject({ signal: ctx.signal });
|
|
326
|
+
});
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
describe("normalizeAct", () => {
|
|
330
|
+
test("a plan with steps is a plan", () => {
|
|
331
|
+
expect(normalizeAct({ kind: "plan", steps: ["Do X"] }, "fallback")).toEqual({
|
|
332
|
+
kind: "plan",
|
|
333
|
+
steps: ["Do X"],
|
|
334
|
+
});
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
test("'respond' with no response falls back rather than looping", () => {
|
|
338
|
+
// The failure mode that matters on a phone call is a desk that never stops.
|
|
339
|
+
expect(normalizeAct({ kind: "respond" }, "the last thing we know")).toEqual({
|
|
340
|
+
kind: "respond",
|
|
341
|
+
response: "the last thing we know",
|
|
342
|
+
});
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
test("'plan' with no usable steps is read as an answer", () => {
|
|
346
|
+
expect(normalizeAct({ kind: "plan", steps: [" "] }, "nothing left")).toEqual({
|
|
347
|
+
kind: "respond",
|
|
348
|
+
response: "nothing left",
|
|
349
|
+
});
|
|
350
|
+
expect(normalizeAct({ kind: "plan", response: "here it is" }, "nothing left")).toEqual({
|
|
351
|
+
kind: "respond",
|
|
352
|
+
response: "here it is",
|
|
353
|
+
});
|
|
354
|
+
});
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
// ─── 2. The tools ────────────────────────────────────────────────────────────
|
|
358
|
+
|
|
359
|
+
describe("start_plan", () => {
|
|
360
|
+
test("stores the objective and the steps", async () => {
|
|
361
|
+
const { ctx } = scriptedDesk({
|
|
362
|
+
steps: ["Check prices", "Compare hotels", "Book"],
|
|
363
|
+
});
|
|
364
|
+
const result = expectToolOk(
|
|
365
|
+
await runTool(startPlan, { objective: "a weekend in Lisbon" }, ctx),
|
|
366
|
+
);
|
|
367
|
+
expect(result.steps).toHaveLength(3);
|
|
368
|
+
|
|
369
|
+
const state = stateOf(ctx);
|
|
370
|
+
expect(state.objective).toBe("a weekend in Lisbon");
|
|
371
|
+
expect(state.plan).toEqual(["Check prices", "Compare hotels", "Book"]);
|
|
372
|
+
expect(state.pastSteps).toEqual([]);
|
|
373
|
+
expect(state.revisions[0]).toContain("Planned 3 step(s)");
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
test("a broken model call is reported rather than thrown at the turn", async () => {
|
|
377
|
+
// The default `createToolContext` generate rejects — a bad key looks the
|
|
378
|
+
// same from here.
|
|
379
|
+
const ctx = createToolContext({});
|
|
380
|
+
expect(await run("start_plan", { objective: "anything" }, ctx)).toMatchObject({
|
|
381
|
+
error: expect.stringContaining("planner failed"),
|
|
382
|
+
});
|
|
383
|
+
});
|
|
384
|
+
});
|
|
385
|
+
|
|
386
|
+
describe("work_next_step", () => {
|
|
387
|
+
test("is refused before there is a plan, by the flow rather than by the body", async () => {
|
|
388
|
+
const { ctx } = scriptedDesk();
|
|
389
|
+
// The gate is `when: "working"`, so the refusal names the state the call is
|
|
390
|
+
// actually in and quotes that state's instruction — which is what the model
|
|
391
|
+
// needs in order to do the right thing on its own next turn.
|
|
392
|
+
expect(await run("work_next_step", ctx)).toMatchObject({
|
|
393
|
+
error: expect.stringContaining('this conversation is at "idle"'),
|
|
394
|
+
});
|
|
395
|
+
expect(await run("work_next_step", ctx)).toMatchObject({
|
|
396
|
+
error: expect.stringContaining("use start_plan"),
|
|
397
|
+
});
|
|
398
|
+
// Refused means the body did not run: nothing was claimed off the plan.
|
|
399
|
+
expect(stateOf(ctx).pastSteps).toEqual([]);
|
|
400
|
+
});
|
|
401
|
+
|
|
402
|
+
test("does the head step, records it, and takes the replanner's next plan", async () => {
|
|
403
|
+
const { ctx } = scriptedDesk({
|
|
404
|
+
steps: ["Check prices", "Compare hotels"],
|
|
405
|
+
answers: ["Fares are about 180 return."],
|
|
406
|
+
acts: [{ kind: "plan", steps: ["Compare hotels"] }],
|
|
407
|
+
});
|
|
408
|
+
await run("start_plan", { objective: "a weekend in Lisbon" }, ctx);
|
|
409
|
+
|
|
410
|
+
const first = expectDialogOk<{
|
|
411
|
+
finished: boolean;
|
|
412
|
+
step: string;
|
|
413
|
+
result: string;
|
|
414
|
+
remaining: string[];
|
|
415
|
+
}>(await run("work_next_step", ctx));
|
|
416
|
+
expect(first.result.finished).toBe(false);
|
|
417
|
+
expect(first.result.step).toBe("Check prices");
|
|
418
|
+
expect(first.result.result).toContain("180");
|
|
419
|
+
expect(first.result.remaining).toEqual(["Compare hotels"]);
|
|
420
|
+
// Still working: nothing was concluded, so the flow has not moved on.
|
|
421
|
+
expect(first.state).toBe("working");
|
|
422
|
+
|
|
423
|
+
const state = stateOf(ctx);
|
|
424
|
+
expect(state.pastSteps).toHaveLength(1);
|
|
425
|
+
expect(state.plan).toEqual(["Compare hotels"]);
|
|
426
|
+
expect(state.response).toBeNull();
|
|
427
|
+
});
|
|
428
|
+
|
|
429
|
+
test("a 'respond' act finishes the plan and clears what is left", async () => {
|
|
430
|
+
const { ctx } = scriptedDesk({
|
|
431
|
+
steps: ["Check prices", "Compare hotels"],
|
|
432
|
+
answers: ["Fares are about 180 return."],
|
|
433
|
+
acts: [{ kind: "respond", response: "Go in May — flights are about 180 return." }],
|
|
434
|
+
});
|
|
435
|
+
await run("start_plan", { objective: "a weekend in Lisbon" }, ctx);
|
|
436
|
+
const answered = expectDialogOk<{ finished: boolean; response: string }>(
|
|
437
|
+
await run("work_next_step", ctx),
|
|
438
|
+
);
|
|
439
|
+
|
|
440
|
+
expect(answered.result.finished).toBe(true);
|
|
441
|
+
expect(answered.result.response).toContain("180");
|
|
442
|
+
// A response is what sends ANSWERED — the flow and the data agree because
|
|
443
|
+
// one tool call moved both.
|
|
444
|
+
expect(answered.state).toBe("answered");
|
|
445
|
+
expect(planFlow.position(ctx).state).toBe("answered");
|
|
446
|
+
|
|
447
|
+
const state = stateOf(ctx);
|
|
448
|
+
// The replanner deciding early is a good outcome, so the pending step goes.
|
|
449
|
+
expect(state.plan).toEqual([]);
|
|
450
|
+
expect(state.response).toBe(answered.result.response);
|
|
451
|
+
|
|
452
|
+
// A finished plan is not worked again, and now it CANNOT be: the tool is
|
|
453
|
+
// gated out of `answered` rather than returning a done-shaped result.
|
|
454
|
+
expect(await run("work_next_step", ctx)).toMatchObject({
|
|
455
|
+
error: expect.stringContaining('this conversation is at "answered"'),
|
|
456
|
+
});
|
|
457
|
+
expect(stateOf(ctx).pastSteps).toHaveLength(1);
|
|
458
|
+
});
|
|
459
|
+
|
|
460
|
+
test("the completed-step trail is capped, so the executor's prompt cannot grow forever", async () => {
|
|
461
|
+
// `historyOf` renders every past step into the executor's prompt AND the
|
|
462
|
+
// replanner's, so an uncapped list is a model bill that grows linearly with
|
|
463
|
+
// the plan — the reason `planSlot` caps `pastSteps` at MAX_PAST_STEPS.
|
|
464
|
+
const total = MAX_PAST_STEPS + 3;
|
|
465
|
+
const { ctx } = scriptedDesk({
|
|
466
|
+
steps: Array.from({ length: total }, (_, i) => `Step ${i + 1}`),
|
|
467
|
+
answers: Array.from({ length: total }, (_, i) => `Found ${i + 1}.`),
|
|
468
|
+
acts: Array.from({ length: total }, (_, i) => ({
|
|
469
|
+
kind: "plan" as const,
|
|
470
|
+
steps: Array.from({ length: total - i - 1 }, (_, j) => `Step ${i + j + 2}`),
|
|
471
|
+
})),
|
|
472
|
+
});
|
|
473
|
+
await run("start_plan", { objective: "a long one" }, ctx);
|
|
474
|
+
for (let i = 0; i < total; i++) await run("work_next_step", ctx);
|
|
475
|
+
|
|
476
|
+
const state = stateOf(ctx);
|
|
477
|
+
expect(state.pastSteps).toHaveLength(MAX_PAST_STEPS);
|
|
478
|
+
// The OLDEST go: the replanner decides from what was just found, and its
|
|
479
|
+
// fallback answer is the last entry.
|
|
480
|
+
expect(state.pastSteps[0]?.step).toBe(`Step ${total - MAX_PAST_STEPS + 1}`);
|
|
481
|
+
expect(state.pastSteps.at(-1)?.step).toBe(`Step ${total}`);
|
|
482
|
+
});
|
|
483
|
+
|
|
484
|
+
test("two independent contexts never share a plan", async () => {
|
|
485
|
+
// What this really checks: the state lives in the SLOT and not in a
|
|
486
|
+
// module-level variable. `createToolContext()` hands each call its own
|
|
487
|
+
// detached slot store, so the isolation is per CONTEXT — two distinct
|
|
488
|
+
// session ids would prove nothing extra, and `sessionSlot` could stop
|
|
489
|
+
// keying by session with this still passing.
|
|
490
|
+
const { ctx: first } = scriptedDesk({ steps: ["Only step"] });
|
|
491
|
+
const { ctx: second } = scriptedDesk({ steps: ["Only step"] });
|
|
492
|
+
|
|
493
|
+
await run("start_plan", { objective: "mine" }, first);
|
|
494
|
+
expect(stateOf(second).objective).toBeNull();
|
|
495
|
+
// The FLOW is per-session too, not just the plan — `second` is still idle.
|
|
496
|
+
expect(planFlow.position(second).state).toBe("idle");
|
|
497
|
+
expect(await run("work_next_step", second)).toMatchObject({
|
|
498
|
+
error: expect.stringContaining('this conversation is at "idle"'),
|
|
499
|
+
});
|
|
500
|
+
});
|
|
501
|
+
});
|
|
502
|
+
|
|
503
|
+
describe("revise_plan", () => {
|
|
504
|
+
test("rewrites what is left, keeps what is done, and reopens a finished plan", async () => {
|
|
505
|
+
const { ctx, model } = scriptedDesk({
|
|
506
|
+
steps: ["Check Lisbon prices", "Book Lisbon"],
|
|
507
|
+
answers: ["Lisbon is about 180 return."],
|
|
508
|
+
acts: [
|
|
509
|
+
{ kind: "respond", response: "Lisbon in May, about 180." },
|
|
510
|
+
{ kind: "plan", steps: ["Check Porto prices"] },
|
|
511
|
+
],
|
|
512
|
+
});
|
|
513
|
+
await run("start_plan", { objective: "a weekend in Lisbon" }, ctx);
|
|
514
|
+
await run("work_next_step", ctx);
|
|
515
|
+
expect(stateOf(ctx).response).not.toBeNull();
|
|
516
|
+
|
|
517
|
+
const revised = expectDialogOk<{ finished: boolean; remaining: string[] }>(
|
|
518
|
+
await run("revise_plan", { instruction: "make it Porto instead" }, ctx),
|
|
519
|
+
);
|
|
520
|
+
expect(revised.result.finished).toBe(false);
|
|
521
|
+
expect(revised.result.remaining).toEqual(["Check Porto prices"]);
|
|
522
|
+
// REOPENED: the one transition that goes backwards, and the reason
|
|
523
|
+
// `revise_plan` is legal in `answered` at all.
|
|
524
|
+
expect(revised.state).toBe("working");
|
|
525
|
+
|
|
526
|
+
const state = stateOf(ctx);
|
|
527
|
+
// The old answer is no longer the answer — the caller moved the goalposts.
|
|
528
|
+
expect(state.response).toBeNull();
|
|
529
|
+
// Completed work survives a revision; that is what "only add steps that
|
|
530
|
+
// still NEED to be done" means.
|
|
531
|
+
expect(state.pastSteps).toHaveLength(1);
|
|
532
|
+
expect(state.revisions.at(-1)).toContain("make it Porto instead");
|
|
533
|
+
// The caller's words reach the replanner, which is the whole node.
|
|
534
|
+
expect(model.calls.at(-1)?.prompt).toContain("make it Porto instead");
|
|
535
|
+
});
|
|
536
|
+
|
|
537
|
+
test("is refused before there is a plan", async () => {
|
|
538
|
+
const { ctx } = scriptedDesk();
|
|
539
|
+
expect(await run("revise_plan", { instruction: "change it" }, ctx)).toMatchObject({
|
|
540
|
+
error: expect.stringContaining('this conversation is at "idle"'),
|
|
541
|
+
});
|
|
542
|
+
});
|
|
543
|
+
|
|
544
|
+
test("the revision trail is capped, because it rides in every syncState frame", async () => {
|
|
545
|
+
// The other cap `planSlot` declares, and the one nothing used to exercise:
|
|
546
|
+
// `revisions` is pushed to by every tool that changes the plan and is sent
|
|
547
|
+
// to the browser on each of them, so an uncapped trail is a frame that grows
|
|
548
|
+
// for the whole call.
|
|
549
|
+
const { ctx } = scriptedDesk({ steps: ["Only step"] });
|
|
550
|
+
await run("start_plan", { objective: "a weekend in Lisbon" }, ctx);
|
|
551
|
+
for (let index = 0; index < MAX_REVISIONS; index++) {
|
|
552
|
+
await run("revise_plan", { instruction: `change ${index}` }, ctx);
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
const state = stateOf(ctx);
|
|
556
|
+
expect(state.revisions).toHaveLength(MAX_REVISIONS);
|
|
557
|
+
// The OLDEST goes, so `start_plan`'s own entry is the one pushed out — the
|
|
558
|
+
// trail a caller wants read back is what has happened lately.
|
|
559
|
+
expect(state.revisions[0]).toContain("change 0");
|
|
560
|
+
expect(state.revisions.at(-1)).toContain(`change ${MAX_REVISIONS - 1}`);
|
|
561
|
+
});
|
|
562
|
+
|
|
563
|
+
test("a revision that answers outright lands in `answered`", async () => {
|
|
564
|
+
const { ctx } = scriptedDesk({
|
|
565
|
+
steps: ["Check Lisbon prices"],
|
|
566
|
+
acts: [{ kind: "respond", response: "Nothing to do — you already booked it." }],
|
|
567
|
+
});
|
|
568
|
+
await run("start_plan", { objective: "a weekend in Lisbon" }, ctx);
|
|
569
|
+
const revised = expectDialogOk<{ finished: boolean }>(
|
|
570
|
+
await run("revise_plan", { instruction: "never mind, it is booked" }, ctx),
|
|
571
|
+
);
|
|
572
|
+
expect(revised.result.finished).toBe(true);
|
|
573
|
+
expect(revised.state).toBe("answered");
|
|
574
|
+
});
|
|
575
|
+
});
|
|
576
|
+
|
|
577
|
+
describe("plan_status", () => {
|
|
578
|
+
test("reports done, remaining and the answer", async () => {
|
|
579
|
+
const { ctx } = scriptedDesk({
|
|
580
|
+
steps: ["Check prices", "Book"],
|
|
581
|
+
answers: ["About 180 return."],
|
|
582
|
+
acts: [{ kind: "plan", steps: ["Book"] }],
|
|
583
|
+
});
|
|
584
|
+
// Legal in every state, so it READS the position rather than being gated on
|
|
585
|
+
// one — and "no plan yet" is the flow's own answer, not a third derivation
|
|
586
|
+
// of `!objective`.
|
|
587
|
+
expect(await run("plan_status", ctx)).toMatchObject({
|
|
588
|
+
stage: "idle",
|
|
589
|
+
next: expect.stringContaining("start_plan"),
|
|
590
|
+
objective: null,
|
|
591
|
+
});
|
|
592
|
+
|
|
593
|
+
await run("start_plan", { objective: "a weekend in Lisbon" }, ctx);
|
|
594
|
+
await run("work_next_step", ctx);
|
|
595
|
+
expect(await run("plan_status", ctx)).toMatchObject({
|
|
596
|
+
stage: "working",
|
|
597
|
+
objective: "a weekend in Lisbon",
|
|
598
|
+
remaining: ["Book"],
|
|
599
|
+
response: null,
|
|
600
|
+
});
|
|
601
|
+
});
|
|
602
|
+
});
|
|
603
|
+
|
|
604
|
+
// ─── 3. The projection contract with client.tsx ─────────────────────────────
|
|
605
|
+
|
|
606
|
+
describe("planView projection", () => {
|
|
607
|
+
test("an untouched call projects an empty plan, not undefined", () => {
|
|
608
|
+
// Exactly the frame `client.tsx` renders before the first push — it passes
|
|
609
|
+
// this same projection to `useAgentState`.
|
|
610
|
+
expect(planSlot.projected()).toEqual({
|
|
611
|
+
objective: null,
|
|
612
|
+
plan: [],
|
|
613
|
+
done: [],
|
|
614
|
+
response: null,
|
|
615
|
+
revisions: [],
|
|
616
|
+
progress: 0,
|
|
617
|
+
});
|
|
618
|
+
});
|
|
619
|
+
|
|
620
|
+
test("progress is derived once, so the bar and any spoken count agree", async () => {
|
|
621
|
+
const { ctx } = scriptedDesk({
|
|
622
|
+
steps: ["One", "Two", "Three"],
|
|
623
|
+
answers: ["Done one."],
|
|
624
|
+
acts: [{ kind: "plan", steps: ["Two", "Three"] }],
|
|
625
|
+
});
|
|
626
|
+
await run("start_plan", { objective: "three things" }, ctx);
|
|
627
|
+
expect(planView(stateOf(ctx)).progress).toBe(0);
|
|
628
|
+
|
|
629
|
+
await run("work_next_step", ctx);
|
|
630
|
+
const view = planView(stateOf(ctx));
|
|
631
|
+
expect(view.progress).toBeCloseTo(1 / 3, 5);
|
|
632
|
+
expect(view.done[0]?.step).toBe("One");
|
|
633
|
+
expect(view.plan).toEqual(["Two", "Three"]);
|
|
634
|
+
});
|
|
635
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { agent } from "@alexkroman1/aai";
|
|
2
|
+
import { planSlot } from "./shared.ts";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A planning desk you can phone: plan-and-execute, with the caller in the loop.
|
|
6
|
+
* `prompts.ts` carries the attribution, `procedure.ts` the three nodes, `shared.ts`
|
|
7
|
+
* the state (which is their `PlanExecute`, field for field).
|
|
8
|
+
*
|
|
9
|
+
* **The steps do real work.** `work_next_step` runs a bounded search/answer loop
|
|
10
|
+
* on `webSearch` — the same DuckDuckGo-backed implementation behind the
|
|
11
|
+
* `web_search` builtin, no API key — so a plan about anything current is worked
|
|
12
|
+
* against what is actually out there rather than against what a model
|
|
13
|
+
* remembers. That is the difference between this and a template that "plans" by
|
|
14
|
+
* asking a model to imagine having looked something up.
|
|
15
|
+
*/
|
|
16
|
+
export default agent({
|
|
17
|
+
name: "Planning Desk",
|
|
18
|
+
// For a reader of a list of agents. It says the LOOP rather than "research",
|
|
19
|
+
// because a caller who wants an answer in one turn is on the wrong line.
|
|
20
|
+
description: "Turns an objective into a plan and works it one step at a time with the caller",
|
|
21
|
+
// The plan exists before the first tool call, so a resumed connection has
|
|
22
|
+
// something to project.
|
|
23
|
+
// The plan, its progress and its revision trail, pushed after every tool call.
|
|
24
|
+
syncState: planSlot.projected,
|
|
25
|
+
greeting: "Planning desk. Tell me what you're trying to get done and I'll work out the steps.",
|
|
26
|
+
});
|