@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,987 @@
|
|
|
1
|
+
/** The def a DEPLOYED agent runs: authored, plus what `tools/` declares. */
|
|
2
|
+
import agentDef from "virtual:aai/agent";
|
|
3
|
+
import type { GenerateFn, GenerateOptions, GuardrailVerdict, ToolContext } from "@alexkroman1/aai";
|
|
4
|
+
import { isToolFailure } from "@alexkroman1/aai";
|
|
5
|
+
import {
|
|
6
|
+
createToolContext,
|
|
7
|
+
expectDialogOk,
|
|
8
|
+
expectDialogRefused,
|
|
9
|
+
expectToolOk,
|
|
10
|
+
parseSchemaInput,
|
|
11
|
+
runGuardrail,
|
|
12
|
+
runTool,
|
|
13
|
+
type SentEvent,
|
|
14
|
+
type StubDelegateCall,
|
|
15
|
+
type StubGenerateCall,
|
|
16
|
+
schemaInputIssues,
|
|
17
|
+
type TestToolContext,
|
|
18
|
+
toolRunner,
|
|
19
|
+
} from "@alexkroman1/aai-runtime/testing";
|
|
20
|
+
import { describe, expect, test } from "vitest";
|
|
21
|
+
import {
|
|
22
|
+
COORDINATOR_NAME,
|
|
23
|
+
candidateScoreSchema,
|
|
24
|
+
crewAgentPrompt,
|
|
25
|
+
crewExpectedOutput,
|
|
26
|
+
EMAIL_FOLLOWUP_AGENT,
|
|
27
|
+
EMAIL_GUARDRAIL_REVISIONS,
|
|
28
|
+
EVALUATOR_SYSTEM,
|
|
29
|
+
emailGuardrail,
|
|
30
|
+
emailTask,
|
|
31
|
+
emailWriter,
|
|
32
|
+
evaluationTask,
|
|
33
|
+
HR_EVALUATION_AGENT,
|
|
34
|
+
parseEmail,
|
|
35
|
+
SCORING_CONCURRENCY,
|
|
36
|
+
} from "./crews.ts";
|
|
37
|
+
import {
|
|
38
|
+
type CandidateScore,
|
|
39
|
+
DEFAULT_JOB,
|
|
40
|
+
emptyHiring,
|
|
41
|
+
hiringFlow,
|
|
42
|
+
hiringSlot,
|
|
43
|
+
hiringView,
|
|
44
|
+
LEADS,
|
|
45
|
+
MAX_FEEDBACK_ENTRIES,
|
|
46
|
+
MAX_FEEDBACK_ROUNDS,
|
|
47
|
+
ranked,
|
|
48
|
+
resolveCandidate,
|
|
49
|
+
SCREENING_PROGRESS,
|
|
50
|
+
SHORTLIST_SIZE,
|
|
51
|
+
stageLabel,
|
|
52
|
+
} from "./shared.ts";
|
|
53
|
+
import candidateDetails from "./tools/candidate_details.ts";
|
|
54
|
+
import readEmail from "./tools/read_email.ts";
|
|
55
|
+
import screenCandidates from "./tools/screen_candidates.ts";
|
|
56
|
+
import screeningStatus from "./tools/screening_status.ts";
|
|
57
|
+
|
|
58
|
+
// ─── A scripted desk ─────────────────────────────────────────────────────────
|
|
59
|
+
//
|
|
60
|
+
// TWO fakes, because the desk reaches a model two ways — and that split is the
|
|
61
|
+
// port showing through in the spec. The evaluator is a `ctx.generate` with a
|
|
62
|
+
// schema, so `stubGenerate` drives it, routed by its system prompt; the
|
|
63
|
+
// coordinator is a subagent, so `stubDelegate` drives it, routed by name.
|
|
64
|
+
// Nothing here runs a model: what is worth asserting is what the desk ASKS for
|
|
65
|
+
// and what it does with what comes back.
|
|
66
|
+
|
|
67
|
+
const run = toolRunner(agentDef);
|
|
68
|
+
|
|
69
|
+
/** What the evaluator says about each applicant, keyed by id — so the stub
|
|
70
|
+
* really "reads" the brief it was handed rather than answering by position. */
|
|
71
|
+
const SCORES: Readonly<Record<string, number>> = {
|
|
72
|
+
c01: 87,
|
|
73
|
+
c07: 84,
|
|
74
|
+
c04: 71,
|
|
75
|
+
c11: 69,
|
|
76
|
+
c05: 66,
|
|
77
|
+
c09: 63,
|
|
78
|
+
c02: 52,
|
|
79
|
+
c08: 47,
|
|
80
|
+
c12: 41,
|
|
81
|
+
c10: 38,
|
|
82
|
+
c03: 34,
|
|
83
|
+
c06: 22,
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
/** The same table after "weight TypeScript more": Aisha and Mei climb into the
|
|
87
|
+
* top three, Tom drops out, Priya stays. */
|
|
88
|
+
const TYPESCRIPT_SCORES: Readonly<Record<string, number>> = {
|
|
89
|
+
...SCORES,
|
|
90
|
+
c05: 86,
|
|
91
|
+
c11: 85,
|
|
92
|
+
c04: 60,
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
/** The candidate a brief is about, read back out of the prompt. */
|
|
96
|
+
function candidateIdIn(prompt: string): string {
|
|
97
|
+
const id = prompt.match(/Candidate ID: (c\d\d)/)?.[1];
|
|
98
|
+
if (!id) throw new Error("the evaluator's brief names no candidate");
|
|
99
|
+
return id;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** A coordinator's email, as the guardrail requires it. */
|
|
103
|
+
function emailFor(call: StubDelegateCall): string {
|
|
104
|
+
const name = call.task.match(/^Name: (.+)$/m)?.[1] ?? "there";
|
|
105
|
+
const proceed = call.task.includes("PROCEEDING WITH CANDIDATE: True");
|
|
106
|
+
const subject = proceed ? "Next steps on your application" : "Your application";
|
|
107
|
+
const body = proceed
|
|
108
|
+
? `Hi ${name},\n\nWe'd like to talk. Could you share your availability for a Zoom call this week?`
|
|
109
|
+
: `Hi ${name},\n\nThank you for applying. We've decided to move forward with other candidates.`;
|
|
110
|
+
return `Subject: ${subject}\n\n${body}\n\nBest,\n${COORDINATOR_NAME}`;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
interface Script {
|
|
114
|
+
/** The score table the evaluator answers from. */
|
|
115
|
+
scores?: Readonly<Record<string, number>>;
|
|
116
|
+
/** Candidate ids whose evaluation FAILS. */
|
|
117
|
+
failScoring?: readonly string[];
|
|
118
|
+
/** Candidate names whose email FAILS. */
|
|
119
|
+
failEmail?: readonly string[];
|
|
120
|
+
/** The coordinator's reply, when the default is not the case at hand. */
|
|
121
|
+
email?: (call: StubDelegateCall) => string | { text: string; complaint?: string };
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* The two fakes over one MUTABLE script: a test that screens and then re-scores
|
|
126
|
+
* changes `script.scores` between the two calls, and the routes read the script
|
|
127
|
+
* at call time — the slot is keyed by the context, so swapping the context to
|
|
128
|
+
* swap the model would also swap the state.
|
|
129
|
+
*/
|
|
130
|
+
function scriptedDesk(script: Script = {}) {
|
|
131
|
+
const ctx = createToolContext({
|
|
132
|
+
generate: {
|
|
133
|
+
routes: {
|
|
134
|
+
[EVALUATOR_SYSTEM]: (call: StubGenerateCall) => {
|
|
135
|
+
const id = candidateIdIn(call.prompt);
|
|
136
|
+
if (script.failScoring?.includes(id)) throw new Error(`gateway said no for ${id}`);
|
|
137
|
+
const table = script.scores ?? SCORES;
|
|
138
|
+
return { object: { score: table[id] ?? 50, reason: `Scripted reasoning for ${id}.` } };
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
delegate: {
|
|
143
|
+
routes: {
|
|
144
|
+
"hr-coordinator": (call) => {
|
|
145
|
+
const name = call.task.match(/^Name: (.+)$/m)?.[1] ?? "";
|
|
146
|
+
if (script.failEmail?.includes(name)) throw new Error(`coordinator timed out on ${name}`);
|
|
147
|
+
const reply = script.email ? script.email(call) : emailFor(call);
|
|
148
|
+
return typeof reply === "string" ? { text: reply } : reply;
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
});
|
|
153
|
+
return { ctx, model: ctx.model, desk: ctx.desk, script };
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const at = (ctx: ToolContext) => hiringFlow.position(ctx).state;
|
|
157
|
+
const stateOf = (ctx: ToolContext) => hiringSlot.get(ctx);
|
|
158
|
+
const nameAt = (ctx: ToolContext, rank: number) =>
|
|
159
|
+
ranked(stateOf(ctx)).find((one) => one.rank === rank)?.name;
|
|
160
|
+
|
|
161
|
+
/** A screening that has run, so a test about the review stage starts there. */
|
|
162
|
+
async function screened(script: Script = {}) {
|
|
163
|
+
const desk = scriptedDesk(script);
|
|
164
|
+
await run("screen_candidates", {}, desk.ctx);
|
|
165
|
+
desk.model.calls.length = 0;
|
|
166
|
+
return desk;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// ─── The flow ────────────────────────────────────────────────────────────────
|
|
170
|
+
|
|
171
|
+
describe("the flow", () => {
|
|
172
|
+
test("starts with nothing screened", () => {
|
|
173
|
+
const { ctx } = scriptedDesk();
|
|
174
|
+
expect(at(ctx)).toBe("idle");
|
|
175
|
+
expect(stageLabel(hiringFlow.position(ctx))).toBe("nothing screened yet");
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
test("refuses feedback and emails before anything is scored, spending no model", async () => {
|
|
179
|
+
const { ctx, model, desk } = scriptedDesk();
|
|
180
|
+
for (const [name, args] of [
|
|
181
|
+
["rescore_with_feedback", { feedback: "more TypeScript" }],
|
|
182
|
+
["proceed_to_emails", {}],
|
|
183
|
+
] as const) {
|
|
184
|
+
// Their router is only reachable after `score_leads`; here that is the
|
|
185
|
+
// gate, and its refusal names the position and quotes the state's own
|
|
186
|
+
// instruction so the model can recover on its turn.
|
|
187
|
+
const refused = expectDialogRefused(await run(name, args, ctx), "idle");
|
|
188
|
+
expect(refused.error).toMatch(/screen_candidates/);
|
|
189
|
+
}
|
|
190
|
+
expect(model.calls).toEqual([]);
|
|
191
|
+
expect(desk.calls).toEqual([]);
|
|
192
|
+
expect(at(ctx)).toBe("idle");
|
|
193
|
+
});
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
// ─── Crew A: screen_candidates ───────────────────────────────────────────────
|
|
197
|
+
|
|
198
|
+
describe("screen_candidates (their load_leads + score_leads)", () => {
|
|
199
|
+
test("scores every applicant once, through the evaluator, and lands in reviewing", async () => {
|
|
200
|
+
const { ctx, model } = scriptedDesk();
|
|
201
|
+
|
|
202
|
+
const result = expectToolOk(await runTool(screenCandidates, {}, ctx));
|
|
203
|
+
|
|
204
|
+
expect(model.calls).toHaveLength(LEADS.length);
|
|
205
|
+
expect(new Set(model.calls.map((call) => call.system))).toEqual(new Set([EVALUATOR_SYSTEM]));
|
|
206
|
+
// Every brief names a different applicant — one evaluation each, none twice.
|
|
207
|
+
expect(new Set(model.calls.map((call) => candidateIdIn(call.prompt))).size).toBe(LEADS.length);
|
|
208
|
+
expect(result.screened).toBe(LEADS.length);
|
|
209
|
+
expect(result.state).toBe("reviewing");
|
|
210
|
+
expect(at(ctx)).toBe("reviewing");
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
test("reads back the top three, best first, with the evaluator's reasoning", async () => {
|
|
214
|
+
const { ctx } = scriptedDesk();
|
|
215
|
+
const result = expectToolOk(await runTool(screenCandidates, {}, ctx));
|
|
216
|
+
|
|
217
|
+
expect(result.top.map((one) => one.name)).toEqual([
|
|
218
|
+
"Priya Raman",
|
|
219
|
+
"Sofia Lindqvist",
|
|
220
|
+
"Tom Whitfield",
|
|
221
|
+
]);
|
|
222
|
+
expect(result.top.map((one) => one.rank)).toEqual([1, 2, 3]);
|
|
223
|
+
expect(result.top.map((one) => one.score)).toEqual([87, 84, 71]);
|
|
224
|
+
for (const one of result.top) expect(one.reason).toMatch(/Scripted reasoning/);
|
|
225
|
+
expect(result.message).toContain("1. Priya Raman (87)");
|
|
226
|
+
expect(result.unscored).toBeUndefined();
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
test("screens against the shipped role unless the caller named another", async () => {
|
|
230
|
+
const { ctx, model } = scriptedDesk();
|
|
231
|
+
const result = expectToolOk(await runTool(screenCandidates, {}, ctx));
|
|
232
|
+
expect(result.job).toBe(DEFAULT_JOB.title);
|
|
233
|
+
expect(stateOf(ctx).job).toEqual(DEFAULT_JOB);
|
|
234
|
+
for (const call of model.calls) {
|
|
235
|
+
expect(call.prompt).toContain(`Title: ${DEFAULT_JOB.title}`);
|
|
236
|
+
// The first round carries no feedback section: there is nothing yet.
|
|
237
|
+
expect(call.prompt).not.toContain("hiring manager has reviewed");
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
test("carries a role the caller described into every brief", async () => {
|
|
242
|
+
const { ctx, model } = scriptedDesk();
|
|
243
|
+
await run(
|
|
244
|
+
"screen_candidates",
|
|
245
|
+
{ jobTitle: "Design Systems Engineer", jobDescription: "Storybook, tokens, accessibility." },
|
|
246
|
+
ctx,
|
|
247
|
+
);
|
|
248
|
+
for (const call of model.calls) {
|
|
249
|
+
expect(call.prompt).toContain("Title: Design Systems Engineer");
|
|
250
|
+
expect(call.prompt).toContain("Storybook, tokens, accessibility.");
|
|
251
|
+
}
|
|
252
|
+
// A title alone keeps the default's description under the caller's title.
|
|
253
|
+
const { ctx: ctx2, model: model2 } = scriptedDesk();
|
|
254
|
+
await run("screen_candidates", { jobTitle: "Frontend Engineer" }, ctx2);
|
|
255
|
+
expect(model2.calls[0]?.prompt).toContain("Title: Frontend Engineer");
|
|
256
|
+
expect(model2.calls[0]?.prompt).toContain("twelve-month contract");
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
test("runs the evaluations through a window, not all at once and not one by one", async () => {
|
|
260
|
+
const { model } = scriptedDesk();
|
|
261
|
+
let inFlight = 0;
|
|
262
|
+
let peak = 0;
|
|
263
|
+
// The fake answers on a microtask, so `inFlight` only ever exceeds 1 if the
|
|
264
|
+
// fan-out really issued several briefs before awaiting any — and it never
|
|
265
|
+
// exceeds the window if the window is real.
|
|
266
|
+
const generate = ((options: GenerateOptions) => {
|
|
267
|
+
inFlight += 1;
|
|
268
|
+
peak = Math.max(peak, inFlight);
|
|
269
|
+
return model.generate(options).finally(() => {
|
|
270
|
+
inFlight -= 1;
|
|
271
|
+
});
|
|
272
|
+
}) as GenerateFn;
|
|
273
|
+
const ctx = createToolContext({ generate });
|
|
274
|
+
|
|
275
|
+
await run("screen_candidates", {}, ctx);
|
|
276
|
+
|
|
277
|
+
expect(LEADS.length).toBeGreaterThan(SCORING_CONCURRENCY);
|
|
278
|
+
expect(peak).toBe(SCORING_CONCURRENCY);
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
test("a second screening in the same step waits: two fan-outs, never interleaved", async () => {
|
|
282
|
+
const { model } = scriptedDesk();
|
|
283
|
+
let inFlight = 0;
|
|
284
|
+
let peak = 0;
|
|
285
|
+
const generate = ((options: GenerateOptions) => {
|
|
286
|
+
inFlight += 1;
|
|
287
|
+
peak = Math.max(peak, inFlight);
|
|
288
|
+
return model.generate(options).finally(() => {
|
|
289
|
+
inFlight -= 1;
|
|
290
|
+
});
|
|
291
|
+
}) as GenerateFn;
|
|
292
|
+
const ctx = createToolContext({ generate });
|
|
293
|
+
|
|
294
|
+
await Promise.all([
|
|
295
|
+
run("screen_candidates", {}, ctx),
|
|
296
|
+
run("screen_candidates", { jobTitle: "Another role" }, ctx),
|
|
297
|
+
]);
|
|
298
|
+
|
|
299
|
+
// Both screenings really ran, and the window never held two fan-outs at
|
|
300
|
+
// once — which is what the screening lock buys. Without it the second reads
|
|
301
|
+
// and writes the table across the first's awaits, and the ranking the
|
|
302
|
+
// caller was just read is not the one the desk now holds.
|
|
303
|
+
expect(model.calls).toHaveLength(LEADS.length * 2);
|
|
304
|
+
expect(peak).toBe(SCORING_CONCURRENCY);
|
|
305
|
+
const state = stateOf(ctx);
|
|
306
|
+
expect(Object.keys(state.scores)).toHaveLength(LEADS.length);
|
|
307
|
+
expect(state.unscored).toEqual([]);
|
|
308
|
+
expect(at(ctx)).toBe("reviewing");
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
test("one applicant the evaluator could not score does not sink the screening", async () => {
|
|
312
|
+
const { ctx } = scriptedDesk({ failScoring: ["c07"] });
|
|
313
|
+
|
|
314
|
+
const result = expectToolOk(await runTool(screenCandidates, {}, ctx));
|
|
315
|
+
|
|
316
|
+
expect(result.screened).toBe(LEADS.length - 1);
|
|
317
|
+
expect(result.unscored).toBe("Sofia Lindqvist");
|
|
318
|
+
expect(result.message).toMatch(/could not be scored/);
|
|
319
|
+
// Not ranked at zero — absent, and named. A zero would read as a verdict.
|
|
320
|
+
expect(result.top.map((one) => one.name)).toEqual([
|
|
321
|
+
"Priya Raman",
|
|
322
|
+
"Tom Whitfield",
|
|
323
|
+
"Mei Tanaka",
|
|
324
|
+
]);
|
|
325
|
+
expect(stateOf(ctx).unscored).toEqual(["c07"]);
|
|
326
|
+
expect(hiringView(stateOf(ctx)).unscored).toEqual(["Sofia Lindqvist"]);
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
test("fails as a tool when nobody could be scored, and the flow does not move", async () => {
|
|
330
|
+
const { ctx } = scriptedDesk({ failScoring: LEADS.map((one) => one.id) });
|
|
331
|
+
|
|
332
|
+
const result = await run("screen_candidates", {}, ctx);
|
|
333
|
+
|
|
334
|
+
expect(result).toEqual({ error: expect.stringContaining("gateway said no") });
|
|
335
|
+
expect(at(ctx)).toBe("idle");
|
|
336
|
+
expect(stateOf(ctx)).toEqual(emptyHiring());
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
test("a second screening starts over: feedback, rounds, shortlist and drafts are cleared", async () => {
|
|
340
|
+
const { ctx } = await screened();
|
|
341
|
+
await run("rescore_with_feedback", { feedback: "more TypeScript" }, ctx);
|
|
342
|
+
await run("proceed_to_emails", {}, ctx);
|
|
343
|
+
expect(at(ctx)).toBe("emailed");
|
|
344
|
+
expect(stateOf(ctx).drafts).not.toEqual([]);
|
|
345
|
+
|
|
346
|
+
await run("screen_candidates", { jobTitle: "Another role" }, ctx);
|
|
347
|
+
|
|
348
|
+
const state = stateOf(ctx);
|
|
349
|
+
expect(state.feedback).toEqual([]);
|
|
350
|
+
expect(state.rounds).toBe(0);
|
|
351
|
+
expect(state.shortlist).toEqual([]);
|
|
352
|
+
expect(state.drafts).toEqual([]);
|
|
353
|
+
expect(state.job?.title).toBe("Another role");
|
|
354
|
+
expect(at(ctx)).toBe("reviewing");
|
|
355
|
+
});
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
// ─── The router's option 2: rescore_with_feedback ────────────────────────────
|
|
359
|
+
|
|
360
|
+
interface RescoreResult {
|
|
361
|
+
round: number;
|
|
362
|
+
roundsLeft: number;
|
|
363
|
+
feedbackApplied: string[];
|
|
364
|
+
top: { name: string; score: number }[];
|
|
365
|
+
promoted: string[];
|
|
366
|
+
dropped: string[];
|
|
367
|
+
message: string;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
describe("rescore_with_feedback (their option 2)", () => {
|
|
371
|
+
test("re-scores everyone with the feedback in every brief, and reports who moved", async () => {
|
|
372
|
+
const { ctx, model, script } = await screened();
|
|
373
|
+
// The evaluator reads the feedback, so the table changes with it.
|
|
374
|
+
script.scores = TYPESCRIPT_SCORES;
|
|
375
|
+
|
|
376
|
+
const moved = expectDialogOk<RescoreResult>(
|
|
377
|
+
await run("rescore_with_feedback", { feedback: "Weight TypeScript much more heavily" }, ctx),
|
|
378
|
+
);
|
|
379
|
+
|
|
380
|
+
expect(model.calls).toHaveLength(LEADS.length);
|
|
381
|
+
for (const call of model.calls) {
|
|
382
|
+
expect(call.prompt).toContain("hiring manager has reviewed");
|
|
383
|
+
expect(call.prompt).toContain("- Weight TypeScript much more heavily");
|
|
384
|
+
}
|
|
385
|
+
expect(moved.state).toBe("reviewing");
|
|
386
|
+
expect(moved.result.round).toBe(1);
|
|
387
|
+
expect(moved.result.roundsLeft).toBe(MAX_FEEDBACK_ROUNDS - 1);
|
|
388
|
+
expect(moved.result.top.map((one) => one.name)).toEqual([
|
|
389
|
+
"Priya Raman",
|
|
390
|
+
"Aisha Bello",
|
|
391
|
+
"Mei Tanaka",
|
|
392
|
+
]);
|
|
393
|
+
expect(moved.result.promoted).toEqual(["Aisha Bello", "Mei Tanaka"]);
|
|
394
|
+
expect(moved.result.dropped).toEqual(["Sofia Lindqvist", "Tom Whitfield"]);
|
|
395
|
+
expect(moved.result.message).toMatch(/moved in \(Aisha Bello, Mei Tanaka\)/);
|
|
396
|
+
expect(stateOf(ctx).rounds).toBe(1);
|
|
397
|
+
});
|
|
398
|
+
|
|
399
|
+
test("feedback ACCUMULATES across rounds, in order", async () => {
|
|
400
|
+
const { ctx, model } = await screened();
|
|
401
|
+
|
|
402
|
+
await run("rescore_with_feedback", { feedback: "more TypeScript" }, ctx);
|
|
403
|
+
await run("rescore_with_feedback", { feedback: "less weight on years of experience" }, ctx);
|
|
404
|
+
|
|
405
|
+
expect(stateOf(ctx).feedback).toEqual([
|
|
406
|
+
"more TypeScript",
|
|
407
|
+
"less weight on years of experience",
|
|
408
|
+
]);
|
|
409
|
+
const last = model.calls.at(-1)?.prompt ?? "";
|
|
410
|
+
// Theirs overwrote; a caller who said both meant both, and in that order.
|
|
411
|
+
expect(last.indexOf("- more TypeScript")).toBeGreaterThan(-1);
|
|
412
|
+
expect(last.indexOf("- more TypeScript")).toBeLessThan(
|
|
413
|
+
last.indexOf("- less weight on years of experience"),
|
|
414
|
+
);
|
|
415
|
+
expect(stateOf(ctx).rounds).toBe(2);
|
|
416
|
+
});
|
|
417
|
+
|
|
418
|
+
test("two re-scores in the same step count TWO rounds, and neither loses its feedback", async () => {
|
|
419
|
+
const { ctx, model } = await screened();
|
|
420
|
+
|
|
421
|
+
await Promise.all([
|
|
422
|
+
run("rescore_with_feedback", { feedback: "more TypeScript" }, ctx),
|
|
423
|
+
run("rescore_with_feedback", { feedback: "less weight on years of experience" }, ctx),
|
|
424
|
+
]);
|
|
425
|
+
|
|
426
|
+
// Read-modify-write across a fan-out: without the lock both read
|
|
427
|
+
// `rounds: 0`, both write `rounds: 1`, and one round of twelve model calls
|
|
428
|
+
// the caller was charged for is uncounted — which also unbounds the bound.
|
|
429
|
+
const state = stateOf(ctx);
|
|
430
|
+
expect(state.rounds).toBe(2);
|
|
431
|
+
expect(state.feedback).toHaveLength(2);
|
|
432
|
+
expect(state.feedback).toEqual(
|
|
433
|
+
expect.arrayContaining(["more TypeScript", "less weight on years of experience"]),
|
|
434
|
+
);
|
|
435
|
+
expect(model.calls).toHaveLength(LEADS.length * 2);
|
|
436
|
+
// The second round's briefs carry BOTH pieces of feedback, which is only
|
|
437
|
+
// true if it read the trail the first round had already written.
|
|
438
|
+
const last = model.calls.at(-1)?.prompt ?? "";
|
|
439
|
+
expect(last).toContain("- more TypeScript");
|
|
440
|
+
expect(last).toContain("- less weight on years of experience");
|
|
441
|
+
});
|
|
442
|
+
|
|
443
|
+
test("says so when the same three people are still on top", async () => {
|
|
444
|
+
const { ctx } = await screened();
|
|
445
|
+
const same = expectDialogOk<RescoreResult>(
|
|
446
|
+
await run("rescore_with_feedback", { feedback: "nothing really" }, ctx),
|
|
447
|
+
);
|
|
448
|
+
expect(same.result.promoted).toEqual([]);
|
|
449
|
+
expect(same.result.message).toMatch(/same people/);
|
|
450
|
+
});
|
|
451
|
+
|
|
452
|
+
test("refuses blank feedback without spending the evaluator", async () => {
|
|
453
|
+
const { ctx, model } = await screened();
|
|
454
|
+
const refused = await run("rescore_with_feedback", { feedback: " " }, ctx);
|
|
455
|
+
expect(refused).toEqual({ error: expect.stringContaining("what the caller wants changed") });
|
|
456
|
+
expect(model.calls).toEqual([]);
|
|
457
|
+
expect(stateOf(ctx).rounds).toBe(0);
|
|
458
|
+
});
|
|
459
|
+
|
|
460
|
+
test("is BOUNDED: past MAX_FEEDBACK_ROUNDS it refuses, naming the two ways out", async () => {
|
|
461
|
+
const { ctx, model } = await screened();
|
|
462
|
+
for (let round = 1; round <= MAX_FEEDBACK_ROUNDS; round++) {
|
|
463
|
+
const again = expectDialogOk<RescoreResult>(
|
|
464
|
+
await run("rescore_with_feedback", { feedback: `round ${round}` }, ctx),
|
|
465
|
+
);
|
|
466
|
+
expect(again.result.roundsLeft).toBe(MAX_FEEDBACK_ROUNDS - round);
|
|
467
|
+
}
|
|
468
|
+
// The last accepted round says it was the last.
|
|
469
|
+
model.calls.length = 0;
|
|
470
|
+
|
|
471
|
+
const refused = await run("rescore_with_feedback", { feedback: "one more" }, ctx);
|
|
472
|
+
|
|
473
|
+
expect(isToolFailure(refused)).toBe(true);
|
|
474
|
+
if (isToolFailure(refused)) {
|
|
475
|
+
expect(refused.error).toMatch(/limit is 3/);
|
|
476
|
+
expect(refused.error).toMatch(/proceed to emails/);
|
|
477
|
+
expect(refused.error).toMatch(/stop/);
|
|
478
|
+
}
|
|
479
|
+
// No model spent, no round counted, and the position did not move on a failure.
|
|
480
|
+
expect(model.calls).toEqual([]);
|
|
481
|
+
expect(stateOf(ctx).rounds).toBe(MAX_FEEDBACK_ROUNDS);
|
|
482
|
+
expect(stateOf(ctx).feedback).toHaveLength(MAX_FEEDBACK_ROUNDS);
|
|
483
|
+
expect(at(ctx)).toBe("reviewing");
|
|
484
|
+
});
|
|
485
|
+
|
|
486
|
+
test("tells the desk the last round was the last", async () => {
|
|
487
|
+
const { ctx } = await screened();
|
|
488
|
+
let last: RescoreResult | undefined;
|
|
489
|
+
for (let round = 1; round <= MAX_FEEDBACK_ROUNDS; round++) {
|
|
490
|
+
last = expectDialogOk<RescoreResult>(
|
|
491
|
+
await run("rescore_with_feedback", { feedback: `round ${round}` }, ctx),
|
|
492
|
+
).result;
|
|
493
|
+
}
|
|
494
|
+
expect(last?.message).toMatch(/last round of feedback/);
|
|
495
|
+
});
|
|
496
|
+
|
|
497
|
+
test("keeps the previous ranking when nobody could be re-scored", async () => {
|
|
498
|
+
const { ctx, script } = await screened();
|
|
499
|
+
const before = stateOf(ctx);
|
|
500
|
+
script.failScoring = LEADS.map((one) => one.id);
|
|
501
|
+
|
|
502
|
+
const result = await run("rescore_with_feedback", { feedback: "more TypeScript" }, ctx);
|
|
503
|
+
|
|
504
|
+
expect(result).toEqual({ error: expect.stringContaining("ranking is unchanged") });
|
|
505
|
+
expect(stateOf(ctx).scores).toEqual(before.scores);
|
|
506
|
+
expect(stateOf(ctx).rounds).toBe(0);
|
|
507
|
+
expect(stateOf(ctx).feedback).toEqual([]);
|
|
508
|
+
expect(at(ctx)).toBe("reviewing");
|
|
509
|
+
});
|
|
510
|
+
});
|
|
511
|
+
|
|
512
|
+
// ─── The router's option 3: proceed_to_emails ────────────────────────────────
|
|
513
|
+
|
|
514
|
+
interface ProceedResult {
|
|
515
|
+
invited: string[];
|
|
516
|
+
declined: number;
|
|
517
|
+
drafted: number;
|
|
518
|
+
failed: string[];
|
|
519
|
+
needsLook: string[];
|
|
520
|
+
message: string;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
describe("proceed_to_emails (their option 3 → write_and_save_emails)", () => {
|
|
524
|
+
test("writes EVERY applicant an email through the coordinator, inviting the top three", async () => {
|
|
525
|
+
const { ctx, desk } = await screened();
|
|
526
|
+
|
|
527
|
+
const done = expectDialogOk<ProceedResult>(await run("proceed_to_emails", {}, ctx));
|
|
528
|
+
|
|
529
|
+
expect(desk.calls).toHaveLength(LEADS.length);
|
|
530
|
+
expect(new Set(desk.calls.map((call) => call.subagent.name))).toEqual(
|
|
531
|
+
new Set(["hr-coordinator"]),
|
|
532
|
+
);
|
|
533
|
+
// Their `proceed_with_candidate`: True for the shortlist, False for everyone else.
|
|
534
|
+
const proceeding = desk.calls
|
|
535
|
+
.filter((call) => call.task.includes("PROCEEDING WITH CANDIDATE: True"))
|
|
536
|
+
.map((call) => call.task.match(/^Name: (.+)$/m)?.[1]);
|
|
537
|
+
// In ROSTER order — the fan-out walks the roster, not the ranking.
|
|
538
|
+
expect(proceeding).toEqual(["Priya Raman", "Tom Whitfield", "Sofia Lindqvist"]);
|
|
539
|
+
expect(done.state).toBe("emailed");
|
|
540
|
+
expect(done.done).toBe(false);
|
|
541
|
+
expect(done.result.invited).toEqual([
|
|
542
|
+
"1. Priya Raman (87)",
|
|
543
|
+
"2. Sofia Lindqvist (84)",
|
|
544
|
+
"3. Tom Whitfield (71)",
|
|
545
|
+
]);
|
|
546
|
+
expect(done.result.declined).toBe(LEADS.length - SHORTLIST_SIZE);
|
|
547
|
+
expect(done.result.drafted).toBe(LEADS.length);
|
|
548
|
+
expect(done.result.needsLook).toEqual([]);
|
|
549
|
+
expect(stateOf(ctx).shortlist).toEqual(["c01", "c07", "c04"]);
|
|
550
|
+
});
|
|
551
|
+
|
|
552
|
+
test("keeps each draft's subject apart from its body, and the role in the brief", async () => {
|
|
553
|
+
const { ctx, desk } = await screened();
|
|
554
|
+
await run("proceed_to_emails", {}, ctx);
|
|
555
|
+
const priya = stateOf(ctx).drafts.find((draft) => draft.candidateId === "c01");
|
|
556
|
+
expect(priya).toMatchObject({
|
|
557
|
+
proceed: true,
|
|
558
|
+
subject: "Next steps on your application",
|
|
559
|
+
accepted: true,
|
|
560
|
+
});
|
|
561
|
+
expect(priya?.body).toMatch(/^Hi Priya Raman,/);
|
|
562
|
+
expect(priya?.body).not.toMatch(/Subject:/);
|
|
563
|
+
// Theirs never told the coordinator which job; every brief here names it.
|
|
564
|
+
for (const call of desk.calls)
|
|
565
|
+
expect(call.task).toContain(`ROLE APPLIED FOR: ${DEFAULT_JOB.title}`);
|
|
566
|
+
});
|
|
567
|
+
|
|
568
|
+
test("a spoken shortlist replaces the top three, by name or by position", async () => {
|
|
569
|
+
const { ctx, desk } = await screened();
|
|
570
|
+
|
|
571
|
+
const done = expectDialogOk<ProceedResult>(
|
|
572
|
+
await run("proceed_to_emails", { shortlist: ["Priya", "the fifth one", "Mehta"] }, ctx),
|
|
573
|
+
);
|
|
574
|
+
|
|
575
|
+
expect(done.result.invited).toEqual([
|
|
576
|
+
"1. Priya Raman (87)",
|
|
577
|
+
"5. Aisha Bello (66)",
|
|
578
|
+
"8. Rahul Mehta (47)",
|
|
579
|
+
]);
|
|
580
|
+
const proceeding = desk.calls.filter((call) =>
|
|
581
|
+
call.task.includes("PROCEEDING WITH CANDIDATE: True"),
|
|
582
|
+
);
|
|
583
|
+
expect(proceeding).toHaveLength(3);
|
|
584
|
+
expect(stateOf(ctx).shortlist).toEqual(["c01", "c05", "c08"]);
|
|
585
|
+
});
|
|
586
|
+
|
|
587
|
+
test("names the same person twice as one invitation", async () => {
|
|
588
|
+
const { ctx } = await screened();
|
|
589
|
+
const done = expectDialogOk<ProceedResult>(
|
|
590
|
+
await run("proceed_to_emails", { shortlist: ["Priya", "Raman"] }, ctx),
|
|
591
|
+
);
|
|
592
|
+
expect(done.result.invited).toEqual(["1. Priya Raman (87)"]);
|
|
593
|
+
});
|
|
594
|
+
|
|
595
|
+
test("never guesses: a name that matches nobody is refused, listing the ranking, before any email", async () => {
|
|
596
|
+
const { ctx, desk } = await screened();
|
|
597
|
+
|
|
598
|
+
const refused = await run("proceed_to_emails", { shortlist: ["Priya", "Zelda"] }, ctx);
|
|
599
|
+
|
|
600
|
+
expect(isToolFailure(refused)).toBe(true);
|
|
601
|
+
if (isToolFailure(refused)) expect(refused.error).toContain("Priya Raman (87)");
|
|
602
|
+
expect(desk.calls).toEqual([]);
|
|
603
|
+
expect(at(ctx)).toBe("reviewing");
|
|
604
|
+
expect(stateOf(ctx).drafts).toEqual([]);
|
|
605
|
+
});
|
|
606
|
+
|
|
607
|
+
test("a draft the guardrail never accepted comes back flagged, not hidden", async () => {
|
|
608
|
+
const { ctx } = await screened({
|
|
609
|
+
email: (call) =>
|
|
610
|
+
call.task.includes("Name: Tom Whitfield")
|
|
611
|
+
? { text: "Hi Tom, let's talk soon.", complaint: "no subject line" }
|
|
612
|
+
: emailFor(call),
|
|
613
|
+
});
|
|
614
|
+
|
|
615
|
+
const done = expectDialogOk<ProceedResult>(await run("proceed_to_emails", {}, ctx));
|
|
616
|
+
|
|
617
|
+
expect(done.result.needsLook).toEqual(["Tom Whitfield"]);
|
|
618
|
+
expect(done.result.message).toMatch(/need a look/);
|
|
619
|
+
const tom = stateOf(ctx).drafts.find((draft) => draft.candidateId === "c04");
|
|
620
|
+
expect(tom).toMatchObject({ accepted: false, subject: "(no subject)" });
|
|
621
|
+
expect(hiringView(stateOf(ctx)).drafts.find((d) => d.name === "Tom Whitfield")?.accepted).toBe(
|
|
622
|
+
false,
|
|
623
|
+
);
|
|
624
|
+
});
|
|
625
|
+
|
|
626
|
+
test("one email the coordinator could not write does not sink the rest", async () => {
|
|
627
|
+
const { ctx } = await screened({ failEmail: ["Elena Vasquez"] });
|
|
628
|
+
|
|
629
|
+
const done = expectDialogOk<ProceedResult>(await run("proceed_to_emails", {}, ctx));
|
|
630
|
+
|
|
631
|
+
expect(done.result.drafted).toBe(LEADS.length - 1);
|
|
632
|
+
expect(done.result.failed).toEqual(["Elena Vasquez"]);
|
|
633
|
+
expect(done.result.message).toMatch(/No email could be written for Elena Vasquez/);
|
|
634
|
+
expect(done.state).toBe("emailed");
|
|
635
|
+
});
|
|
636
|
+
|
|
637
|
+
test("fails as a tool when no email could be written, and the flow does not move", async () => {
|
|
638
|
+
const { ctx } = await screened({ failEmail: LEADS.map((one) => one.name) });
|
|
639
|
+
|
|
640
|
+
const result = await run("proceed_to_emails", {}, ctx);
|
|
641
|
+
|
|
642
|
+
expect(result).toEqual({ error: expect.stringContaining("coordinator timed out") });
|
|
643
|
+
expect(at(ctx)).toBe("reviewing");
|
|
644
|
+
expect(stateOf(ctx).drafts).toEqual([]);
|
|
645
|
+
});
|
|
646
|
+
|
|
647
|
+
test("refuses a second round of emails for one ranking", async () => {
|
|
648
|
+
const { ctx, desk } = await screened();
|
|
649
|
+
await run("proceed_to_emails", {}, ctx);
|
|
650
|
+
desk.calls.length = 0;
|
|
651
|
+
|
|
652
|
+
// `emailed` accepts no PROCEEDED, so the gate — not the body — is what
|
|
653
|
+
// refuses. Asserted through the SDK's own unwrap, which fails HERE if the
|
|
654
|
+
// call succeeded instead of skipping every assertion after it.
|
|
655
|
+
const refused = expectDialogRefused(await run("proceed_to_emails", {}, ctx), "emailed");
|
|
656
|
+
expect(refused.error).toMatch(/read_email/);
|
|
657
|
+
expect(desk.calls).toEqual([]);
|
|
658
|
+
});
|
|
659
|
+
});
|
|
660
|
+
|
|
661
|
+
// ─── The wait ────────────────────────────────────────────────────────────────
|
|
662
|
+
|
|
663
|
+
/** What a tool sent the browser, filtered to the ticker's own event. */
|
|
664
|
+
const progressIn = (ctx: TestToolContext): SentEvent[] =>
|
|
665
|
+
ctx.sent.filter((sent) => sent.event === SCREENING_PROGRESS);
|
|
666
|
+
|
|
667
|
+
/** The ticks a fan-out over the roster should have produced, in order. */
|
|
668
|
+
const everyTick = (phase: "scoring" | "writing") =>
|
|
669
|
+
LEADS.map((_, index) => ({ phase, done: index + 1, total: LEADS.length }));
|
|
670
|
+
|
|
671
|
+
describe("the progress ticker", () => {
|
|
672
|
+
test("ticks once per applicant while the evaluator runs, ending on the total", async () => {
|
|
673
|
+
const { ctx } = scriptedDesk();
|
|
674
|
+
|
|
675
|
+
await run("screen_candidates", {}, ctx);
|
|
676
|
+
|
|
677
|
+
// A MOMENT rather than state: the slot is still written once, at the end,
|
|
678
|
+
// so nothing ever reads half a screening — see `shared.ts`.
|
|
679
|
+
expect(progressIn(ctx).map((tick) => tick.data)).toEqual(everyTick("scoring"));
|
|
680
|
+
expect(stateOf(ctx).candidates).toHaveLength(LEADS.length);
|
|
681
|
+
});
|
|
682
|
+
|
|
683
|
+
test("an applicant the evaluator refused ticks too, so the count reaches the total", async () => {
|
|
684
|
+
const { ctx } = scriptedDesk({ failScoring: ["c07"] });
|
|
685
|
+
|
|
686
|
+
await run("screen_candidates", {}, ctx);
|
|
687
|
+
|
|
688
|
+
// A ticker that stopped at eleven of twelve reads as a hang, and the wait
|
|
689
|
+
// for that applicant really is over.
|
|
690
|
+
expect(progressIn(ctx)).toHaveLength(LEADS.length);
|
|
691
|
+
});
|
|
692
|
+
|
|
693
|
+
test("the coordinator's fan-out ticks under its own phase", async () => {
|
|
694
|
+
const { ctx } = await screened();
|
|
695
|
+
ctx.sent.length = 0;
|
|
696
|
+
|
|
697
|
+
await run("proceed_to_emails", {}, ctx);
|
|
698
|
+
|
|
699
|
+
expect(progressIn(ctx).map((tick) => tick.data)).toEqual(everyTick("writing"));
|
|
700
|
+
});
|
|
701
|
+
});
|
|
702
|
+
|
|
703
|
+
// ─── The reads ───────────────────────────────────────────────────────────────
|
|
704
|
+
|
|
705
|
+
describe("candidate_details", () => {
|
|
706
|
+
test("has nothing to say before a screening", async () => {
|
|
707
|
+
const { ctx } = scriptedDesk();
|
|
708
|
+
expect(await run("candidate_details", { candidate: "Priya" }, ctx)).toEqual({
|
|
709
|
+
error: expect.stringContaining("screen_candidates"),
|
|
710
|
+
});
|
|
711
|
+
});
|
|
712
|
+
|
|
713
|
+
test("resolves 'the second one' against the RANKING the caller was read", async () => {
|
|
714
|
+
const { ctx } = await screened();
|
|
715
|
+
const second = expectToolOk(
|
|
716
|
+
await runTool(candidateDetails, { candidate: "the second one" }, ctx),
|
|
717
|
+
);
|
|
718
|
+
expect(second.rank).toBe(2);
|
|
719
|
+
expect(second.name).toBe(nameAt(ctx, 2));
|
|
720
|
+
expect(second.score).toBe(84);
|
|
721
|
+
expect(second.bio).toMatch(/Stockholm/);
|
|
722
|
+
expect(second.emailDrafted).toBeNull();
|
|
723
|
+
});
|
|
724
|
+
|
|
725
|
+
test("resolves a surname, and reports the draft once one exists", async () => {
|
|
726
|
+
const { ctx } = await screened();
|
|
727
|
+
await run("proceed_to_emails", {}, ctx);
|
|
728
|
+
const rahul = await runTool(candidateDetails, { candidate: "Mehta" }, ctx);
|
|
729
|
+
expect(rahul).toMatchObject({
|
|
730
|
+
name: "Rahul Mehta",
|
|
731
|
+
shortlisted: false,
|
|
732
|
+
emailDrafted: "decline",
|
|
733
|
+
});
|
|
734
|
+
const priya = await runTool(candidateDetails, { candidate: "Priya" }, ctx);
|
|
735
|
+
expect(priya).toMatchObject({ shortlisted: true, emailDrafted: "invitation" });
|
|
736
|
+
});
|
|
737
|
+
|
|
738
|
+
test("lists the ranking rather than guessing at a name nobody has", async () => {
|
|
739
|
+
const { ctx } = await screened();
|
|
740
|
+
const refused = await run("candidate_details", { candidate: "Zelda" }, ctx);
|
|
741
|
+
expect(isToolFailure(refused)).toBe(true);
|
|
742
|
+
if (isToolFailure(refused)) expect(refused.error).toContain("12. Daniel Kowalski (22)");
|
|
743
|
+
});
|
|
744
|
+
});
|
|
745
|
+
|
|
746
|
+
describe("read_email", () => {
|
|
747
|
+
test("says the emails are not written yet, naming the tool that writes them", async () => {
|
|
748
|
+
const { ctx } = await screened();
|
|
749
|
+
expect(await run("read_email", { candidate: "Priya" }, ctx)).toEqual({
|
|
750
|
+
error: expect.stringContaining("proceed_to_emails"),
|
|
751
|
+
});
|
|
752
|
+
});
|
|
753
|
+
|
|
754
|
+
test("reads back a draft's subject and body, saying which kind it is", async () => {
|
|
755
|
+
const { ctx } = await screened();
|
|
756
|
+
await run("proceed_to_emails", {}, ctx);
|
|
757
|
+
const invite = expectToolOk(await runTool(readEmail, { candidate: "the first one" }, ctx));
|
|
758
|
+
expect(invite).toMatchObject({
|
|
759
|
+
to: "Priya Raman",
|
|
760
|
+
kind: "invitation",
|
|
761
|
+
subject: "Next steps on your application",
|
|
762
|
+
});
|
|
763
|
+
expect(invite.body).toMatch(/availability/);
|
|
764
|
+
expect(invite.message).toMatch(/subject line/);
|
|
765
|
+
const decline = expectToolOk(await runTool(readEmail, { candidate: "Kowalski" }, ctx));
|
|
766
|
+
expect(decline.kind).toBe("decline");
|
|
767
|
+
});
|
|
768
|
+
|
|
769
|
+
test("warns before reading a draft the guardrail never accepted", async () => {
|
|
770
|
+
const { ctx } = await screened({
|
|
771
|
+
email: (call) =>
|
|
772
|
+
call.task.includes("Name: Priya Raman")
|
|
773
|
+
? { text: "Priya — let's talk.", complaint: "unsigned" }
|
|
774
|
+
: emailFor(call),
|
|
775
|
+
});
|
|
776
|
+
await run("proceed_to_emails", {}, ctx);
|
|
777
|
+
const flagged = expectToolOk(await runTool(readEmail, { candidate: "Priya" }, ctx));
|
|
778
|
+
expect(flagged.accepted).toBe(false);
|
|
779
|
+
expect(flagged.message).toMatch(/did not pass/);
|
|
780
|
+
});
|
|
781
|
+
|
|
782
|
+
test("says so when the coordinator's run for that person failed", async () => {
|
|
783
|
+
const { ctx } = await screened({ failEmail: ["Rahul Mehta"] });
|
|
784
|
+
await run("proceed_to_emails", {}, ctx);
|
|
785
|
+
expect(await run("read_email", { candidate: "Mehta" }, ctx)).toEqual({
|
|
786
|
+
error: expect.stringContaining("No email was written for Rahul Mehta"),
|
|
787
|
+
});
|
|
788
|
+
});
|
|
789
|
+
});
|
|
790
|
+
|
|
791
|
+
describe("screening_status", () => {
|
|
792
|
+
test("reads the stage off the flow, not off the data", async () => {
|
|
793
|
+
const { ctx, model } = scriptedDesk();
|
|
794
|
+
const idle = await runTool(screeningStatus, ctx);
|
|
795
|
+
expect(idle).toMatchObject({
|
|
796
|
+
stage: "nothing screened yet",
|
|
797
|
+
state: "idle",
|
|
798
|
+
screened: 0,
|
|
799
|
+
top: [],
|
|
800
|
+
});
|
|
801
|
+
expect(idle.message).toMatch(/offer to screen/);
|
|
802
|
+
expect(model.calls).toEqual([]);
|
|
803
|
+
});
|
|
804
|
+
|
|
805
|
+
test("sums the screening up once it has run", async () => {
|
|
806
|
+
const { ctx } = await screened({ failScoring: ["c06"] });
|
|
807
|
+
await run("rescore_with_feedback", { feedback: "more TypeScript" }, ctx);
|
|
808
|
+
await run("proceed_to_emails", {}, ctx);
|
|
809
|
+
const status = await runTool(screeningStatus, ctx);
|
|
810
|
+
expect(status).toMatchObject({
|
|
811
|
+
stage: "emails drafted",
|
|
812
|
+
job: DEFAULT_JOB.title,
|
|
813
|
+
screened: LEADS.length - 1,
|
|
814
|
+
unscored: 1,
|
|
815
|
+
feedbackRounds: `1 of ${MAX_FEEDBACK_ROUNDS}`,
|
|
816
|
+
feedback: ["more TypeScript"],
|
|
817
|
+
drafts: LEADS.length,
|
|
818
|
+
});
|
|
819
|
+
});
|
|
820
|
+
});
|
|
821
|
+
|
|
822
|
+
// ─── The crews ───────────────────────────────────────────────────────────────
|
|
823
|
+
|
|
824
|
+
/** The coordinator's guardrail, called the way the runtime calls it. */
|
|
825
|
+
const check = (text: string) => runGuardrail(emailWriter, text);
|
|
826
|
+
|
|
827
|
+
/** What a verdict COMPLAINED about, or `null` when it accepted.
|
|
828
|
+
* `GuardrailVerdict` is `true | string`, and narrowing it here is what stops
|
|
829
|
+
* an ACCEPTING verdict being matched against a complaint by accident — a
|
|
830
|
+
* stringified `true` matches no pattern in this file and would read as a pass. */
|
|
831
|
+
const complaint = (verdict: GuardrailVerdict): string | null => (verdict === true ? null : verdict);
|
|
832
|
+
|
|
833
|
+
describe("the crews", () => {
|
|
834
|
+
test("render a CrewAI agent through CrewAI's own role_playing template", () => {
|
|
835
|
+
expect(crewAgentPrompt(HR_EVALUATION_AGENT)).toBe(
|
|
836
|
+
`You are ${HR_EVALUATION_AGENT.role}. ${HR_EVALUATION_AGENT.backstory}\n` +
|
|
837
|
+
`Your personal goal is: ${HR_EVALUATION_AGENT.goal}`,
|
|
838
|
+
);
|
|
839
|
+
expect(EVALUATOR_SYSTEM).toMatch(/^You are Senior HR Evaluation Expert\./);
|
|
840
|
+
expect(emailWriter.systemPrompt).toBe(crewAgentPrompt(EMAIL_FOLLOWUP_AGENT));
|
|
841
|
+
expect(crewExpectedOutput("X")).toMatch(/expected criteria for your final answer: X/);
|
|
842
|
+
});
|
|
843
|
+
|
|
844
|
+
test("the evaluator's brief keeps their anti-round-number rule and asks for two sentences", () => {
|
|
845
|
+
const brief = evaluationTask(LEADS[0] as (typeof LEADS)[number], DEFAULT_JOB, []);
|
|
846
|
+
expect(brief).toContain("Don't use numbers like 100, 75, or 50");
|
|
847
|
+
expect(brief).toContain("two sentences");
|
|
848
|
+
expect(brief).toContain("Candidate ID: c01");
|
|
849
|
+
expect(brief).toContain("expected criteria for your final answer");
|
|
850
|
+
});
|
|
851
|
+
|
|
852
|
+
test("the coordinator's brief carries their proceed flag as they spelled it", () => {
|
|
853
|
+
const candidate = LEADS[0] as (typeof LEADS)[number];
|
|
854
|
+
expect(emailTask(candidate, DEFAULT_JOB, true)).toContain("PROCEEDING WITH CANDIDATE: True");
|
|
855
|
+
expect(emailTask(candidate, DEFAULT_JOB, false)).toContain("PROCEEDING WITH CANDIDATE: False");
|
|
856
|
+
});
|
|
857
|
+
|
|
858
|
+
test("the coordinator declares what a good email is, a guardrail, and its retry budget", () => {
|
|
859
|
+
expect(emailWriter.expectedOutput).toMatch(/Subject:/);
|
|
860
|
+
expect(emailWriter.expectedOutput).toContain(COORDINATOR_NAME);
|
|
861
|
+
expect(emailWriter.guardrail).toBe(emailGuardrail);
|
|
862
|
+
// No tools, one step: a writing pass, which is exactly what their agent is.
|
|
863
|
+
expect(emailWriter.tools).toBeUndefined();
|
|
864
|
+
expect(emailWriter.maxSteps).toBe(1);
|
|
865
|
+
// Their `guardrail` retries three times; this is one, written out at the
|
|
866
|
+
// declaration. Pinned to the NUMBER as well as to the constant, so an SDK
|
|
867
|
+
// default that moved is a decision this template makes again rather than
|
|
868
|
+
// one it inherits.
|
|
869
|
+
expect(emailWriter.maxRevisions).toBe(EMAIL_GUARDRAIL_REVISIONS);
|
|
870
|
+
expect(EMAIL_GUARDRAIL_REVISIONS).toBe(1);
|
|
871
|
+
});
|
|
872
|
+
|
|
873
|
+
test("the guardrail accepts a subject line and a signature, and names what is missing", () => {
|
|
874
|
+
expect(check("Subject: Hello\n\nHi,\n\nBest,\nSarah")).toBe(true);
|
|
875
|
+
expect(check(" Subject: Hello\nHi — Sarah")).toBe(true);
|
|
876
|
+
expect(complaint(check("Hi,\n\nBest,\nSarah"))).toMatch(/Subject:/);
|
|
877
|
+
expect(complaint(check("Subject: Hello\n\nHi,\n\nBest,\nThe team"))).toMatch(
|
|
878
|
+
/Sign the email as Sarah/,
|
|
879
|
+
);
|
|
880
|
+
});
|
|
881
|
+
|
|
882
|
+
test("the evaluator's schema IS their output_pydantic: a whole 1–100 score, a capped reason", async () => {
|
|
883
|
+
const verdict = await parseSchemaInput<CandidateScore>(
|
|
884
|
+
candidateScoreSchema,
|
|
885
|
+
{ score: 87, reason: "Ships React daily and has taken an LLM feature end to end." },
|
|
886
|
+
"the evaluator's verdict",
|
|
887
|
+
);
|
|
888
|
+
expect(verdict).toEqual({
|
|
889
|
+
score: 87,
|
|
890
|
+
reason: "Ships React daily and has taken an LLM feature end to end.",
|
|
891
|
+
});
|
|
892
|
+
// The three a model really does return, each of which the desk could not
|
|
893
|
+
// read back: a zero, a half point, and the "detailed reasoning" theirs
|
|
894
|
+
// asked for where two spoken sentences were wanted.
|
|
895
|
+
expect(await schemaInputIssues(candidateScoreSchema, { score: 0, reason: "r" })).toBeDefined();
|
|
896
|
+
expect(
|
|
897
|
+
await schemaInputIssues(candidateScoreSchema, { score: 87.5, reason: "r" }),
|
|
898
|
+
).toBeDefined();
|
|
899
|
+
expect(
|
|
900
|
+
await schemaInputIssues(candidateScoreSchema, { score: 87, reason: "x".repeat(501) }),
|
|
901
|
+
).toBeDefined();
|
|
902
|
+
});
|
|
903
|
+
|
|
904
|
+
test("parseEmail splits the subject from the body, and copes with a draft that has none", () => {
|
|
905
|
+
expect(parseEmail("Subject: Next steps\n\nHi Priya,\n\nSarah")).toEqual({
|
|
906
|
+
subject: "Next steps",
|
|
907
|
+
body: "Hi Priya,\n\nSarah",
|
|
908
|
+
});
|
|
909
|
+
expect(parseEmail("Hi Priya — talk soon.")).toEqual({
|
|
910
|
+
subject: "(no subject)",
|
|
911
|
+
body: "Hi Priya — talk soon.",
|
|
912
|
+
});
|
|
913
|
+
});
|
|
914
|
+
});
|
|
915
|
+
|
|
916
|
+
// ─── The state ───────────────────────────────────────────────────────────────
|
|
917
|
+
|
|
918
|
+
describe("the ranking", () => {
|
|
919
|
+
test("joins scores onto the roster, best first, and leaves the unscored out", () => {
|
|
920
|
+
const state = emptyHiring();
|
|
921
|
+
state.candidates = [...LEADS];
|
|
922
|
+
state.scores = { c03: { score: 40, reason: "r" }, c01: { score: 90, reason: "r" } };
|
|
923
|
+
const rows = ranked(state);
|
|
924
|
+
expect(rows.map((row) => [row.rank, row.id, row.score])).toEqual([
|
|
925
|
+
[1, "c01", 90],
|
|
926
|
+
[2, "c03", 40],
|
|
927
|
+
]);
|
|
928
|
+
});
|
|
929
|
+
|
|
930
|
+
test("breaks a tie by roster order, so a ranking is stable across reads", () => {
|
|
931
|
+
const state = emptyHiring();
|
|
932
|
+
state.candidates = [...LEADS];
|
|
933
|
+
state.scores = { c05: { score: 70, reason: "r" }, c02: { score: 70, reason: "r" } };
|
|
934
|
+
expect(ranked(state).map((row) => row.id)).toEqual(["c02", "c05"]);
|
|
935
|
+
expect(ranked(state).map((row) => row.id)).toEqual(["c02", "c05"]);
|
|
936
|
+
});
|
|
937
|
+
|
|
938
|
+
test("resolves a first name, a surname or a position, and lists the options otherwise", () => {
|
|
939
|
+
const state = emptyHiring();
|
|
940
|
+
state.candidates = [...LEADS];
|
|
941
|
+
state.scores = Object.fromEntries(
|
|
942
|
+
Object.entries(SCORES).map(([id, score]) => [id, { score, reason: "r" }]),
|
|
943
|
+
);
|
|
944
|
+
expect(resolveCandidate(state, "priya")).toMatchObject({ id: "c01" });
|
|
945
|
+
expect(resolveCandidate(state, "O'Connor")).toMatchObject({ id: "c10" });
|
|
946
|
+
expect(resolveCandidate(state, "the third one")).toMatchObject({ id: "c04" });
|
|
947
|
+
const nobody = resolveCandidate(state, "Zelda");
|
|
948
|
+
expect(isToolFailure(nobody)).toBe(true);
|
|
949
|
+
if (isToolFailure(nobody)) expect(nobody.error).toContain("1. Priya Raman (87)");
|
|
950
|
+
// An empty ranking is answered, not thrown at.
|
|
951
|
+
expect(isToolFailure(resolveCandidate(emptyHiring(), "Priya"))).toBe(true);
|
|
952
|
+
});
|
|
953
|
+
|
|
954
|
+
test("holds MAX_FEEDBACK_ENTRIES entries of feedback, dropping the oldest", () => {
|
|
955
|
+
// The bound is the SLOT's (`caps`), so it holds whatever pushed — a plain
|
|
956
|
+
// `push` here is the same write `rescore_with_feedback` makes.
|
|
957
|
+
const ctx = createToolContext();
|
|
958
|
+
hiringSlot.update(ctx, (state) => {
|
|
959
|
+
for (let index = 0; index < MAX_FEEDBACK_ENTRIES + 2; index++)
|
|
960
|
+
state.feedback.push(`f${index}`);
|
|
961
|
+
});
|
|
962
|
+
const { feedback } = stateOf(ctx);
|
|
963
|
+
expect(feedback).toHaveLength(MAX_FEEDBACK_ENTRIES);
|
|
964
|
+
expect(feedback[0]).toBe("f2");
|
|
965
|
+
// The cap is the round cap restated: no round can be dropped while it counts.
|
|
966
|
+
expect(MAX_FEEDBACK_ENTRIES).toBeGreaterThan(MAX_FEEDBACK_ROUNDS);
|
|
967
|
+
});
|
|
968
|
+
|
|
969
|
+
test("the projection carries names and scores, never an email address", async () => {
|
|
970
|
+
const { ctx } = await screened();
|
|
971
|
+
await run("proceed_to_emails", {}, ctx);
|
|
972
|
+
const view = hiringView(stateOf(ctx));
|
|
973
|
+
expect(view.jobTitle).toBe(DEFAULT_JOB.title);
|
|
974
|
+
expect(view.leaderboard).toHaveLength(LEADS.length);
|
|
975
|
+
expect(view.leaderboard[0]).toMatchObject({ rank: 1, name: "Priya Raman", shortlisted: true });
|
|
976
|
+
expect(view.leaderboard.filter((row) => row.shortlisted)).toHaveLength(SHORTLIST_SIZE);
|
|
977
|
+
expect(view.drafts).toHaveLength(LEADS.length);
|
|
978
|
+
expect(view.drafts[0]).toMatchObject({ name: "Priya Raman", proceed: true, accepted: true });
|
|
979
|
+
expect(JSON.stringify(view)).not.toContain("@example.com");
|
|
980
|
+
});
|
|
981
|
+
|
|
982
|
+
test("stageLabel reads every state", () => {
|
|
983
|
+
expect(stageLabel({ state: "idle", done: false })).toBe("nothing screened yet");
|
|
984
|
+
expect(stageLabel({ state: "reviewing", done: false })).toBe("shortlist under review");
|
|
985
|
+
expect(stageLabel({ state: "emailed", done: false })).toBe("emails drafted");
|
|
986
|
+
});
|
|
987
|
+
});
|