@alexkroman1/aai-cli 16.1.0 → 17.0.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.
Files changed (183) hide show
  1. package/README.md +2 -1
  2. package/dist/{_build-target-ClEEuUuW.mjs → _build-target-C08aM-Es.mjs} +504 -43
  3. package/dist/_build-target.d.ts +98 -19
  4. package/dist/_deno-target.d.ts +15 -14
  5. package/dist/_dev-env.d.ts +19 -13
  6. package/dist/{_dev-server-D1wKiA0_.mjs → _dev-server-CLU9xjH5.mjs} +25 -17
  7. package/dist/_dev-server.d.ts +4 -3
  8. package/dist/_init.d.ts +39 -0
  9. package/dist/_modal-target.d.ts +11 -6
  10. package/dist/_preflight-CnW9QiE7.mjs +116 -0
  11. package/dist/_preflight.d.ts +110 -5
  12. package/dist/_target-bundle.d.ts +112 -0
  13. package/dist/_target-entry.d.ts +81 -0
  14. package/dist/{_templates-CuP74F8D.mjs → _templates-IMeKMVIj.mjs} +1 -1
  15. package/dist/{_vitest-runner-BiAMIir1.mjs → _vitest-runner-CZNGj0ZC.mjs} +21 -16
  16. package/dist/_vitest-runner.d.ts +35 -23
  17. package/dist/{build-O6BT51x_.mjs → build-DrQTSc2R.mjs} +128 -293
  18. package/dist/build.d.ts +34 -4
  19. package/dist/cli.mjs +20 -16
  20. package/dist/{deploy-lldQyJVj.mjs → deploy-B68-x7xM.mjs} +12 -4
  21. package/dist/deploy.d.ts +9 -0
  22. package/dist/{dev-Du8pCWFq.mjs → dev-ChsrNHpK.mjs} +1 -1
  23. package/dist/dev.d.ts +1 -1
  24. package/dist/{eval-Ducmkt1n.mjs → eval-DB07kTxO.mjs} +1 -1
  25. package/dist/init-W-4k-lCF.mjs +559 -0
  26. package/dist/init.d.ts +43 -3
  27. package/dist/scaffold/CLAUDE.md +51 -64
  28. package/dist/scaffold/package.json +6 -6
  29. package/dist/scaffold/vite.config.ts +29 -1
  30. package/dist/{studio-It7SRfUN.mjs → studio-DEAJGBXa.mjs} +19 -9
  31. package/dist/templates/applicant-screening-agent/agent.eval.test.ts +20 -6
  32. package/dist/templates/applicant-screening-agent/agent.ts +28 -0
  33. package/dist/templates/applicant-screening-agent/shared.ts +11 -11
  34. package/dist/templates/call-audit-workflow/agent.ts +2 -0
  35. package/dist/templates/code-interpreter-agent/agent.eval.test.ts +3 -2
  36. package/dist/templates/code-interpreter-agent/agent.ts +1 -0
  37. package/dist/templates/coding-agent/agent.eval.test.ts +136 -0
  38. package/dist/templates/coding-agent/agent.test.ts +109 -0
  39. package/dist/templates/coding-agent/agent.ts +45 -0
  40. package/dist/templates/coding-agent/chat.ts +63 -0
  41. package/dist/templates/coding-agent/shared.ts +46 -0
  42. package/dist/templates/coding-agent/system-prompt.md +32 -0
  43. package/dist/templates/coding-agent/tools/bash.ts +6 -0
  44. package/dist/templates/coding-agent/tools/delete_file.ts +6 -0
  45. package/dist/templates/coding-agent/tools/edit_file.ts +6 -0
  46. package/dist/templates/coding-agent/tools/glob.ts +6 -0
  47. package/dist/templates/coding-agent/tools/grep.ts +6 -0
  48. package/dist/templates/coding-agent/tools/list_files.ts +6 -0
  49. package/dist/templates/coding-agent/tools/read_file.ts +6 -0
  50. package/dist/templates/coding-agent/tools/todo_write.ts +6 -0
  51. package/dist/templates/coding-agent/tools/write_file.ts +6 -0
  52. package/dist/templates/custom-pipeline-agent/agent.ts +1 -0
  53. package/dist/templates/document-redline-workflow/agent.ts +2 -0
  54. package/dist/templates/emergency-dispatch-agent/agent.test.ts +103 -0
  55. package/dist/templates/emergency-dispatch-agent/agent.ts +15 -0
  56. package/dist/templates/emergency-dispatch-agent/guardrails.ts +105 -0
  57. package/dist/templates/emergency-dispatch-agent/system-prompt.md +1 -0
  58. package/dist/templates/entertainment-picks-agent/agent.eval.test.ts +8 -1
  59. package/dist/templates/entertainment-picks-agent/agent.ts +1 -0
  60. package/dist/templates/entertainment-picks-agent/system-prompt.md +6 -0
  61. package/dist/templates/entertainment-picks-agent/tools/revisit.ts +7 -0
  62. package/dist/templates/executive-inbox-agent/agent.eval.test.ts +84 -23
  63. package/dist/templates/executive-inbox-agent/agent.ts +1 -0
  64. package/dist/templates/executive-inbox-agent/meeting.ts +1 -1
  65. package/dist/templates/executive-inbox-agent/prompts.ts +3 -1
  66. package/dist/templates/executive-inbox-agent/system-prompt.md +3 -3
  67. package/dist/templates/executive-inbox-agent/tools/meeting_assistant.ts +3 -3
  68. package/dist/templates/executive-inbox-agent/tools/open_email.ts +8 -16
  69. package/dist/templates/hotel-reception-agent/agent.eval.test.ts +85 -21
  70. package/dist/templates/hotel-reception-agent/agent.test.ts +2 -1
  71. package/dist/templates/hotel-reception-agent/agent.ts +6 -3
  72. package/dist/templates/hotel-reception-agent/client.tsx +14 -2
  73. package/dist/templates/hotel-reception-agent/concierge.ts +2 -1
  74. package/dist/templates/hotel-reception-agent/desk-seams.test.ts +2 -1
  75. package/dist/templates/hotel-reception-agent/disputes.ts +9 -11
  76. package/dist/templates/hotel-reception-agent/events.ts +2 -1
  77. package/dist/templates/hotel-reception-agent/session.ts +56 -0
  78. package/dist/templates/hotel-reception-agent/shared.ts +20 -21
  79. package/dist/templates/hotel-reception-agent/system-prompt.md +1 -1
  80. package/dist/templates/hotel-reception-agent/tools/abandon_booking.ts +2 -1
  81. package/dist/templates/hotel-reception-agent/tools/add_to_waitlist.ts +2 -1
  82. package/dist/templates/hotel-reception-agent/tools/book_airport_car.ts +2 -1
  83. package/dist/templates/hotel-reception-agent/tools/cancel_restaurant_reservation.ts +2 -1
  84. package/dist/templates/hotel-reception-agent/tools/cancel_room_booking.ts +2 -1
  85. package/dist/templates/hotel-reception-agent/tools/check_restaurant_availability.ts +1 -1
  86. package/dist/templates/hotel-reception-agent/tools/check_room_availability.ts +1 -1
  87. package/dist/templates/hotel-reception-agent/tools/choose_room.ts +1 -1
  88. package/dist/templates/hotel-reception-agent/tools/confirm_booking.ts +2 -1
  89. package/dist/templates/hotel-reception-agent/tools/dispatch_emergency.ts +2 -1
  90. package/dist/templates/hotel-reception-agent/tools/dispute_charge.ts +2 -1
  91. package/dist/templates/hotel-reception-agent/tools/flag_late_arrival.ts +2 -1
  92. package/dist/templates/hotel-reception-agent/tools/lookup_booking.ts +2 -1
  93. package/dist/templates/hotel-reception-agent/tools/lookup_guest_history.ts +1 -1
  94. package/dist/templates/hotel-reception-agent/tools/lookup_invoice.ts +2 -1
  95. package/dist/templates/hotel-reception-agent/tools/lookup_restaurant_reservation.ts +1 -1
  96. package/dist/templates/hotel-reception-agent/tools/modify_restaurant_reservation.ts +1 -1
  97. package/dist/templates/hotel-reception-agent/tools/record_card.ts +1 -1
  98. package/dist/templates/hotel-reception-agent/tools/record_followup.ts +2 -1
  99. package/dist/templates/hotel-reception-agent/tools/record_group_inquiry.ts +2 -1
  100. package/dist/templates/hotel-reception-agent/tools/record_guest_details.ts +1 -1
  101. package/dist/templates/hotel-reception-agent/tools/reinstate_booking.ts +1 -1
  102. package/dist/templates/hotel-reception-agent/tools/request_flight_reconfirmation.ts +2 -1
  103. package/dist/templates/hotel-reception-agent/tools/resend_confirmation.ts +2 -1
  104. package/dist/templates/hotel-reception-agent/tools/reserve_table.ts +1 -1
  105. package/dist/templates/hotel-reception-agent/tools/resolve_room_conflict.ts +2 -1
  106. package/dist/templates/hotel-reception-agent/tools/schedule_wakeup_call.ts +2 -1
  107. package/dist/templates/hotel-reception-agent/tools/set_do_not_disturb.ts +2 -1
  108. package/dist/templates/hotel-reception-agent/tools/set_extras.ts +1 -1
  109. package/dist/templates/hotel-reception-agent/tools/set_stay.ts +2 -1
  110. package/dist/templates/hotel-reception-agent/tools/start_booking_modification.ts +2 -1
  111. package/dist/templates/hotel-reception-agent/tools/start_room_booking.ts +2 -1
  112. package/dist/templates/hotel-reception-agent/tools/take_guest_message.ts +2 -1
  113. package/dist/templates/hotel-reception-agent/tools/transfer_call.ts +2 -1
  114. package/dist/templates/hotel-reception-agent/tools/update_card.ts +2 -1
  115. package/dist/templates/hotel-reception-agent/tools/verify_booking.ts +2 -1
  116. package/dist/templates/link-digest-workflow/agent.eval.test.ts +16 -1
  117. package/dist/templates/link-digest-workflow/agent.ts +5 -0
  118. package/dist/templates/medication-safety-agent/agent.test.ts +54 -0
  119. package/dist/templates/medication-safety-agent/agent.ts +48 -1
  120. package/dist/templates/meeting-recap-agent/agent.test.ts +2 -2
  121. package/dist/templates/meeting-recap-agent/agent.ts +4 -0
  122. package/dist/templates/pizza-ordering-agent/agent.ts +3 -0
  123. package/dist/templates/podcast-digest-workflow/agent.ts +4 -0
  124. package/dist/templates/quickstart-agent/agent.eval.test.ts +39 -3
  125. package/dist/templates/quickstart-agent/agent.test.ts +22 -0
  126. package/dist/templates/quickstart-agent/agent.ts +18 -2
  127. package/dist/templates/quickstart-agent/system-prompt.md +8 -0
  128. package/dist/templates/quickstart-agent/tools/get_weather.ts +59 -0
  129. package/dist/templates/research-handoff-agent/agent.ts +4 -0
  130. package/dist/templates/research-planner-agent/agent.eval.test.ts +24 -2
  131. package/dist/templates/research-planner-agent/agent.ts +3 -0
  132. package/dist/templates/research-planner-agent/system-prompt.md +1 -1
  133. package/dist/templates/retail-orders-agent/agent.ts +32 -3
  134. package/dist/templates/retail-orders-agent/keyterms.ts +154 -0
  135. package/dist/templates/retail-orders-agent/resolve.ts +18 -3
  136. package/dist/templates/roadside-assistance-agent/agent.eval.test.ts +37 -5
  137. package/dist/templates/roadside-assistance-agent/agent.test.ts +38 -6
  138. package/dist/templates/roadside-assistance-agent/agent.ts +4 -0
  139. package/dist/templates/roadside-assistance-agent/shared.ts +12 -0
  140. package/dist/templates/roadside-assistance-agent/tools/acknowledge_disclosure.ts +14 -0
  141. package/dist/templates/roadside-assistance-agent/tools/lookup_coverage.ts +11 -0
  142. package/dist/templates/roadside-assistance-agent/tools/service_disclosure.ts +17 -11
  143. package/dist/templates/roadside-assistance-agent/yard.test.ts +4 -0
  144. package/dist/templates/spoken-summary-workflow/agent.ts +4 -0
  145. package/dist/templates/tabletop-rpg-agent/agent.eval.test.ts +6 -0
  146. package/dist/templates/tabletop-rpg-agent/agent.test.ts +125 -1
  147. package/dist/templates/tabletop-rpg-agent/agent.ts +30 -1
  148. package/dist/templates/tabletop-rpg-agent/shared.ts +81 -0
  149. package/dist/templates/tabletop-rpg-agent/system-prompt.md +1 -1
  150. package/dist/templates/tabletop-rpg-agent/tools/check_state.ts +16 -7
  151. package/dist/templates/technical-support-agent/agent.test.ts +3 -3
  152. package/dist/templates/technical-support-agent/agent.ts +5 -1
  153. package/dist/templates/technical-support-agent/knowledge.ts +165 -0
  154. package/dist/templates/technical-support-agent/nodes.ts +3 -2
  155. package/dist/templates/technical-support-agent/procedure.ts +4 -3
  156. package/dist/templates/technical-support-agent/shared.ts +10 -146
  157. package/dist/templates/technical-support-agent/tools/list_topics.ts +2 -1
  158. package/dist/templates/text-adventure-agent/agent.eval.test.ts +39 -6
  159. package/dist/templates/text-adventure-agent/agent.test.ts +79 -1
  160. package/dist/templates/text-adventure-agent/agent.ts +30 -1
  161. package/dist/templates/text-adventure-agent/shared.ts +37 -0
  162. package/dist/templates/text-adventure-agent/system-prompt.md +9 -2
  163. package/dist/templates/topic-briefing-agent/agent.eval.test.ts +18 -4
  164. package/dist/templates/topic-briefing-agent/agent.test.ts +23 -11
  165. package/dist/templates/topic-briefing-agent/agent.ts +4 -1
  166. package/dist/templates/topic-briefing-agent/shared.ts +10 -10
  167. package/dist/templates/topic-briefing-agent/system-prompt.md +13 -8
  168. package/dist/templates/topic-briefing-agent/tools/send_briefing.ts +43 -5
  169. package/dist/templates/transcription-workflow/agent.ts +3 -0
  170. package/dist/templates/travel-concierge-agent/agent.ts +4 -0
  171. package/dist/templates/web-research-agent/agent.eval.test.ts +31 -5
  172. package/dist/templates/web-research-agent/agent.test.ts +16 -0
  173. package/dist/templates/web-research-agent/agent.ts +30 -0
  174. package/dist/templates/web-research-agent/system-prompt.md +8 -2
  175. package/dist/templates/word-game-agent/agent.eval.test.ts +79 -18
  176. package/dist/templates/word-game-agent/agent.ts +20 -0
  177. package/dist/test-CjKPQ9_B.mjs +102 -0
  178. package/dist/test.d.ts +37 -12
  179. package/package.json +5 -5
  180. package/dist/_init-Bp1CjRrU.mjs +0 -199
  181. package/dist/_preflight-CcAR577V.mjs +0 -46
  182. package/dist/init-CY4NAXAA.mjs +0 -183
  183. package/dist/test-PHHv0Vj6.mjs +0 -83
@@ -14,7 +14,7 @@
14
14
  // `../code-interpreter-agent/agent.eval.test.ts`.
15
15
 
16
16
  import agentDef from "virtual:aai/agent";
17
- import { expectToolBeforeSpeech } from "@alexkroman1/aai-runtime/eval";
17
+ import { describeTurn, expectToolBeforeSpeech } from "@alexkroman1/aai-runtime/eval";
18
18
  import { describeEval } from "@alexkroman1/aai-runtime/eval/vitest";
19
19
  import { expect } from "vitest";
20
20
 
@@ -66,16 +66,42 @@ describeEval(agentDef, (test) => {
66
66
  test(
67
67
  "cites a site that appeared in its own results",
68
68
  async ({ session }) => {
69
- const turn = await session.say("Who is the current CEO of Boeing?");
69
+ // A fact with ABUNDANT, stable sources, because this case measures the
70
+ // CITATION and everything else has to be a foregone conclusion. Two other
71
+ // questions failed here for opposite reasons: "who is the current CEO of
72
+ // Boeing" is answerable from training data, so a run answered it from
73
+ // memory and cited nothing; "the latest news about Boeing this week" made
74
+ // the desk really search and come back empty ("I'm having trouble pulling
75
+ // up the latest news"), which is a thin news day and not a citation bug.
76
+ // Whether Scout searches a fact it is sure of is the case ABOVE.
77
+ const turn = await session.say("Who was the first person to walk on the moon?");
70
78
 
71
79
  const labels = hostLabels(turn);
72
- expect(labels.length).toBeGreaterThan(0);
80
+ const spoken = turn.text.toLowerCase();
81
+
82
+ // BOTH branches are the same rule, and the open web decides which one
83
+ // this run gets. A search that comes back empty or errors is not a
84
+ // citation bug — but it is where the stronger half of the claim lives, so
85
+ // the case measures that instead of failing on a thin result. Measured
86
+ // failing exactly here: "I couldn't reach the information right now. But
87
+ // according to historical records, Neil Armstrong was the first person to
88
+ // walk on the moon" obeyed "say that instead of naming a source" to the
89
+ // letter while stating a fact it had never read. The prompt now says to
90
+ // stop there, and this is what holds it to that.
91
+ if (labels.length === 0) {
92
+ expect(spoken, describeTurn(turn)).toMatch(/could ?n.?t|cannot|unable|no results|nothing/);
93
+ expect(spoken, describeTurn(turn)).not.toMatch(/armstrong/);
94
+ return;
95
+ }
96
+
73
97
  // "Cite sources by website name" — and cite one you read. A reply that
74
98
  // names an outlet absent from the results is the fabrication this case
75
99
  // exists to catch, and it fails here exactly like a reply that cites
76
100
  // nothing at all.
77
- const spoken = turn.text.toLowerCase();
78
- expect(labels.filter((label) => spoken.includes(label))).not.toEqual([]);
101
+ expect(
102
+ labels.filter((label) => spoken.includes(label)),
103
+ describeTurn(turn),
104
+ ).not.toEqual([]);
79
105
  },
80
106
  { live: true },
81
107
  );
@@ -85,6 +85,22 @@ describe("web-research-agent template", () => {
85
85
  // never says "search" is the framework default wearing Scout's name.
86
86
  expect(expectPromptBuiltinsDeclared(agentDef)).toContain("web_search");
87
87
  });
88
+
89
+ test("one call has a ceiling on what it can spend", () => {
90
+ // Scout is the only starter whose context grows with text it did not write:
91
+ // every `visit_webpage` result is appended to the conversation and re-sent
92
+ // on every later turn, and `maxSteps` bounds one reply rather than a call.
93
+ // So the failure this catches is a deletion — the budget is a whole line
94
+ // that reads like tidy-up, and losing it is invisible until somebody's bill
95
+ // arrives.
96
+ //
97
+ // The NUMBER is deliberately not pinned, per this file's own rule: raising
98
+ // or lowering the ceiling is a first customization, and a spec that fails
99
+ // on it fails inside a file the user never wrote. What must survive is that
100
+ // there is a ceiling at all.
101
+ const totalTokens = expectDeployable(agentDef).usageLimits?.totalTokens;
102
+ expect(totalTokens).toBeGreaterThan(0);
103
+ });
88
104
  });
89
105
 
90
106
  /** A plausible endpoint, only ever read back out of the config this sets. */
@@ -90,9 +90,39 @@ const mcpServers: McpServers | undefined = ARCHIVE ? { [ARCHIVE_KEY]: ARCHIVE }
90
90
 
91
91
  export default agent({
92
92
  name: "Scout",
93
+ // The listing line — a registry row, `aai list`, the studio's picker. Never
94
+ // the model: the researcher rules are `system-prompt.md`'s. It names the
95
+ // citation because that is what separates Scout from a model guessing.
96
+ description: "Answers questions by searching the open web and citing what it found",
93
97
  greeting:
94
98
  "Hey, I'm Scout. I search the web for answers. Try asking me something like, what happened in tech news today, or who won the last World Cup.",
95
99
  builtinTools: ["web_search", "visit_webpage"],
100
+ /**
101
+ * A ceiling on what one call may spend — the one knob this starter needs and
102
+ * the other templates do not.
103
+ *
104
+ * Scout is the only agent here whose context grows with text it did not
105
+ * write. Every `visit_webpage` result (capped at `MAX_PAGE_CHARS`, ~2,500
106
+ * tokens) is appended to the conversation and RE-SENT on every later turn, so
107
+ * a long call reading a dozen pages spends roughly the square of what it
108
+ * read. Nothing else bounds that: `maxSteps` bounds one reply, not a call.
109
+ *
110
+ * The number is deliberately far above any real research call — a few pages
111
+ * over a few dozen turns lands an order of magnitude under it — so it is a
112
+ * runaway guard and not a budget a caller can feel. It is here because this
113
+ * is a STARTER: it deploys with two builtins and no credential of its own, on
114
+ * somebody's URL, and the shape of "left running" is exactly what this
115
+ * catches.
116
+ *
117
+ * **What it costs is stated rather than hidden.** Crossing it is fatal: the
118
+ * session ends with an `error.reported` frame and a browser client releases
119
+ * the microphone, so the caller hears a dropped call rather than an
120
+ * explanation. An agent that wants to say something first watches
121
+ * `usage.updated` through `agent({ events })` and speaks before the cap
122
+ * arrives — a fair amount of machinery for a starter, which is why this one
123
+ * takes the blunt version and says so.
124
+ */
125
+ usageLimits: { totalTokens: 500_000 },
96
126
  // Spread rather than `mcpServers: undefined`: an agent with no archive
97
127
  // declares no server and asks a deploy for no credential, which is the
98
128
  // shape every field on this call already has.
@@ -4,6 +4,13 @@ THE RULE: every turn where the caller asks for a fact begins with a web_search
4
4
  call. Not a sentence, not a reply — the search. You have no knowledge of your
5
5
  own, so until a result comes back you have nothing to say.
6
6
 
7
+ - WHEN A SEARCH COMES BACK EMPTY OR ERRORS, the whole of your reply is that you
8
+ could not find it and they can ask again. Nothing else. Do not add the answer
9
+ you already knew, not after "but", not as background, not as "historical
10
+ records say", not even if you are sure — a fact with no source is the one
11
+ thing this desk must never say, and putting an apology in front of it makes it
12
+ worse rather than better. There is no version of this reply that contains the
13
+ answer.
7
14
  - Search even when you are certain. Certainty is the case this rule exists for:
8
15
  "Who won the 2022 World Cup?" is a search, because a fact you did not just
9
16
  read is stale and has no source to attach to it.
@@ -11,8 +18,7 @@ own, so until a result comes back you have nothing to say.
11
18
  appear in a web_search or visit_webpage result you read in THIS turn.
12
19
  - Name the source in the answer, every time: "According to Reuters, ..." or
13
20
  "Wikipedia says ...". Name the site the result actually came from — naming a
14
- publication you did not just read is a fabrication. If nothing usable came
15
- back, say that instead of naming a source.
21
+ publication you did not just read is a fabrication.
16
22
  - Use visit_webpage when the search snippets aren't detailed enough.
17
23
  - Some deployments give you extra research tools whose names begin with `mcp_`
18
24
  — a private archive, a wiki, a docs server the open web cannot reach. Use
@@ -17,6 +17,8 @@ import { lastStateIn, toolNames, toolResultIn } from "@alexkroman1/aai-runtime/e
17
17
  import { describeEval } from "@alexkroman1/aai-runtime/eval/vitest";
18
18
  import { expect } from "vitest";
19
19
  import { z } from "zod";
20
+ import { isCorrectGuess } from "./guess.ts";
21
+ import { allWords } from "./words.ts";
20
22
 
21
23
  /** The scoreboard, as these cases read it. */
22
24
  const Board = z.object({
@@ -27,8 +29,29 @@ const Board = z.object({
27
29
  wrongGuesses: z.array(z.string()),
28
30
  });
29
31
 
30
- /** A scripted player who is always wrong — the word is random, so a script cannot be right. */
31
- const WRONG_PLAYER = ['{"guess":"zebra crossing","remark":"Is it a zebra crossing?"}'];
32
+ /**
33
+ * A scripted player who is always wrong.
34
+ *
35
+ * The old guess here was "zebra crossing", under the reasoning that "the word is
36
+ * random, so a script cannot be right". That reasoning does not hold, and the
37
+ * case failed in CI on it: `isCorrectGuess` rules a guess correct when the WORD
38
+ * appears as a whole word INSIDE it (`containsWord`, so that "Is it a giraffe?"
39
+ * relayed whole still scores), `zebra` is one of the 220 words, and
40
+ * `pickWords` draws the round's word at random — so roughly one run in 220 drew
41
+ * `zebra`, matched it inside "zebra crossing", and scored the wrong guess
42
+ * correct.
43
+ *
44
+ * A guess is only reliably wrong if NO word in the list matches it, which is a
45
+ * fact about the list rather than a thing to eyeball — {@link wrongEverywhere}
46
+ * below asserts it, so a future word list that adds "wombat" fails this case
47
+ * loudly instead of flaking once every few hundred runs.
48
+ */
49
+ const WRONG_GUESS = "purple wombat";
50
+ const WRONG_PLAYER = [`{"guess":"${WRONG_GUESS}","remark":"Is it a ${WRONG_GUESS}?"}`];
51
+
52
+ /** Every word this guess would be scored CORRECT against — must be none. */
53
+ const wrongEverywhere = (): string[] =>
54
+ allWords().filter((word) => isCorrectGuess(WRONG_GUESS, word));
32
55
 
33
56
  describeEval(agentDef, (test) => {
34
57
  test(
@@ -56,7 +79,7 @@ describeEval(agentDef, (test) => {
56
79
 
57
80
  test(
58
81
  "a description goes to the player, and a wrong guess is relayed without a point",
59
- async ({ session }) => {
82
+ async ({ session, mode }) => {
60
83
  await session.say("Ready!");
61
84
  const turn = await session.say(
62
85
  "It's an animal with black and white stripes, lives in Africa.",
@@ -67,20 +90,49 @@ describeEval(agentDef, (test) => {
67
90
  turn.toolCalls,
68
91
  "relay_description",
69
92
  dialogResultSchema(
70
- z.object({ verdict: z.string(), playerSaid: z.string(), score: z.number() }),
93
+ z.object({
94
+ verdict: z.string(),
95
+ playerSaid: z.string(),
96
+ guess: z.string(),
97
+ score: z.number(),
98
+ }),
71
99
  ),
72
100
  );
73
- expect(relayed.result).toMatchObject({
74
- verdict: "wrong",
75
- playerSaid: "Is it a zebra crossing?",
76
- score: 0,
77
- });
78
- // The round is still on: a wrong guess moves nothing.
79
- expect(relayed.state).toBe("playing");
80
- expect(lastStateIn(turn.events, Board)).toMatchObject({
81
- score: 0,
82
- wrongGuesses: ["zebra crossing"],
83
- });
101
+ // The player really answered, and the host relayed rather than ruling on
102
+ // the guess itself — the claim in this case's name, and the half that
103
+ // holds in either mode.
104
+ expect(relayed.result.playerSaid.length).toBeGreaterThan(0);
105
+ // WHICH verdict came back is the game's business, not this case's: the
106
+ // word is drawn at random and `zebra` is in the pool, so live — where a
107
+ // real model plays the player — this description is right about as often
108
+ // as the draw allows. What holds either way is that the verdict and the
109
+ // score agree, and that a wrong guess leaves the round standing.
110
+ if (relayed.result.verdict === "wrong") {
111
+ expect(relayed.result.score).toBe(0);
112
+ expect(relayed.state).toBe("playing");
113
+ expect(lastStateIn(turn.events, Board)).toMatchObject({
114
+ score: 0,
115
+ wrongGuesses: [relayed.result.guess],
116
+ });
117
+ } else {
118
+ expect(relayed.result.verdict).toBe("correct");
119
+ expect(relayed.result.score).toBe(1);
120
+ }
121
+ // Only a SCRIPT can pin the player's exact words. `WRONG_PLAYER` is what
122
+ // makes them predictable, so asserting them against a live model asserts
123
+ // the script rather than the agent — which is how this case used to fail
124
+ // on "Is it a zebra?" being a perfectly good wrong guess.
125
+ if (mode === "stub") {
126
+ // The claim this case rests on, checked rather than assumed — see
127
+ // WRONG_GUESS for the run that proved assuming it is not enough.
128
+ expect(wrongEverywhere()).toEqual([]);
129
+ expect(relayed.result).toMatchObject({
130
+ verdict: "wrong",
131
+ playerSaid: `Is it a ${WRONG_GUESS}?`,
132
+ guess: WRONG_GUESS,
133
+ score: 0,
134
+ });
135
+ }
84
136
  },
85
137
  {
86
138
  stubReply: [
@@ -90,7 +142,7 @@ describeEval(agentDef, (test) => {
90
142
  tool: "relay_description",
91
143
  args: { description: "an animal with black and white stripes, lives in Africa" },
92
144
  },
93
- "The player asks: is it a zebra crossing?",
145
+ `The player asks: is it a ${WRONG_GUESS}?`,
94
146
  ],
95
147
  stubGenerate: WRONG_PLAYER,
96
148
  },
@@ -105,9 +157,15 @@ describeEval(agentDef, (test) => {
105
157
  "start_game",
106
158
  dialogResultSchema(z.object({ word: z.string() })),
107
159
  ).result;
160
+ // A DESCRIPTION that happens to contain the word, not a question about it.
161
+ // "How would I even describe that?" is the describer asking for help, and
162
+ // a host that answered it in words — or reached for `repeat_word` — was
163
+ // reading the turn correctly while this case failed it for not relaying.
108
164
  // The host's relay below is sanitized — the word is not in the script's
109
165
  // args — and the tool still rules a foul off what the caller actually said.
110
- const turn = await session.say(`Okay, my word is ${word}. How would I even describe that?`);
166
+ const turn = await session.say(
167
+ `Okay, so ${word} — it's the sort of thing you would find around a house.`,
168
+ );
111
169
 
112
170
  const relayed = toolResultIn(
113
171
  turn.toolCalls,
@@ -122,7 +180,10 @@ describeEval(agentDef, (test) => {
122
180
  stubReply: [
123
181
  { tool: "start_game" },
124
182
  "Here's your first word.",
125
- { tool: "relay_description", args: { description: "how would I even describe that" } },
183
+ {
184
+ tool: "relay_description",
185
+ args: { description: "it's the sort of thing you would find around a house" },
186
+ },
126
187
  "You said the word - that one's forfeited. Your next word is on the screen.",
127
188
  ],
128
189
  stubGenerate: WRONG_PLAYER,
@@ -11,9 +11,29 @@ import { GAME_EVENTS, gameProjection } from "./shared.ts";
11
11
  * `relay_description`, on its own prompt with only the current word's context —
12
12
  * which is what their parallel pipeline, resampler and per-word reconnect were
13
13
  * built to arrange. The referee is a function.
14
+ *
15
+ * **No guardrails, though a game about a forbidden word looks like the template
16
+ * for them.** The rule the game turns on is the DESCRIBER's, and it is already
17
+ * mechanical — `isFoul` over `game.spoken`. It is also not a refusal: a foul
18
+ * FORFEITS the word and scores it, so an `inputGuardrails` entry, which answers
19
+ * instead of the model and runs no tool, would swallow the very turn that has to
20
+ * be recorded.
21
+ *
22
+ * The host's own rule ("never say the current word") has a legal exception every
23
+ * round — it says the word when it GIVES or REPEATS one, out of a tool result —
24
+ * and an output guardrail is handed the text and `AgentSessionContext`, which
25
+ * deliberately carries no `messages`. So it cannot tell the round's opening line
26
+ * from a hint. It would also be paid for in this template's one currency: a held
27
+ * reply cannot stream, turning time-to-first-word into time-to-last-token on a
28
+ * two-minute clock whose `bargeIn: { minWords: 1 }` exists so the describer can
29
+ * talk over the host.
14
30
  */
15
31
  export default agent({
16
32
  name: "Word Wrangler",
33
+ // The listing line — a registry row, the studio's picker, never the model.
34
+ // Three participants in one sentence, because that is the whole shape of the
35
+ // thing and what makes it worth reading `shared.ts` for.
36
+ description: "Hosts a two-minute word game between the caller and an A.I. guesser",
17
37
  // The scoreboard: the word the describer is looking at, the score, the clock.
18
38
  syncState: gameProjection,
19
39
  /**
@@ -0,0 +1,102 @@
1
+ #!/usr/bin/env node
2
+ import { a as ok, n as fail } from "./_output-DBP9Op_d.mjs";
3
+ import { n as log } from "./_ui-DCt4qZrk.mjs";
4
+ import { l as formatCappedList } from "./_utils-D5JGcjiW.mjs";
5
+ import { i as unrunSpecFiles, n as classifyVitestError, r as runVitest, t as WIDEN_HINT } from "./_vitest-runner-CZNGj0ZC.mjs";
6
+ //#region src/test.ts
7
+ /**
8
+ * `aai test` — run agent tests via vitest.
9
+ *
10
+ * The launcher is `_vitest-runner.ts`, shared with `aai eval` and `aai build`'s
11
+ * pre-build gate. What is here is the COMMAND: which files the test tier runs,
12
+ * and the verdict over the ones a run did not cover.
13
+ */
14
+ /**
15
+ * The files a NARROWED `aai test` runs, in preference order.
16
+ *
17
+ * The tier's filenames belong to the command, not to the runner — `aai eval`
18
+ * declares `EVAL_FILES` the same way one module over, and neither names the
19
+ * other's. `aai build` imports this one because its pre-build gate runs the
20
+ * TEST tier.
21
+ *
22
+ * They are no longer what a BARE `aai test` runs — see {@link executeTest} for
23
+ * why the default is the whole project — so this list is now reached only by
24
+ * `--only`.
25
+ */
26
+ const TEST_FILES = ["agent.test.ts", "agent.test.js"];
27
+ /**
28
+ * Execute agent tests and return structured result.
29
+ *
30
+ * **The default is the whole project, and it used to be one file.**
31
+ * `aai test` ran `agent.test.ts` alone and then FAILED (`incomplete_run`) over
32
+ * every other spec it had skipped — so on any project with a second spec file
33
+ * the default invocation could never be green, and the scaffold routed around
34
+ * the command it was supposed to wire into CI (`"test": "vitest run --exclude
35
+ * …"`, with `aai test` demoted to `test:agent`). Nine shipped templates carry
36
+ * two or more non-eval specs, so that was the normal case rather than the edge:
37
+ * the command's own remedy was "do not run this command".
38
+ *
39
+ * The narrow default was defensible when it was written — running a project's
40
+ * other specs could reach ones that are slow or want credentials — but the
41
+ * verdict is what made it unusable, and `aai build`'s pre-build gate had
42
+ * already gone the other way (`all: true`) for the same reason a build is run
43
+ * deliberately. So the widening is the default here too and `--only` is the
44
+ * inner loop, which leaves the two halves of the original defect closed: a
45
+ * complete run is a green run, and a narrowed one is honest about what it
46
+ * skipped instead of failing over it.
47
+ *
48
+ * **An incomplete run is still not a pass.** For as long as this command
49
+ * answered `{"ok":true,"data":{"passed":true}}` with exit 0 over specs it had
50
+ * not run, adding one tool could break `registry.test.ts` in 17 assertions with
51
+ * `pnpm test` and `pnpm build` both staying green throughout. What carries that
52
+ * now is the RESULT (`unrun`, `complete: false`) plus the runner's own warning,
53
+ * because the reader of a deliberate `--only` asked for the narrowing.
54
+ */
55
+ async function executeTest(cwd, opts = {}) {
56
+ const narrowed = opts.only === true;
57
+ log.step(narrowed ? "Running agent tests" : "Running project tests");
58
+ try {
59
+ const ran = runVitest(cwd, {
60
+ candidates: TEST_FILES,
61
+ all: !narrowed
62
+ });
63
+ const unrun = unrunSpecFiles(cwd, ran);
64
+ if (ran === false) {
65
+ if (unrun.length > 0) return noNarrowTarget(unrun);
66
+ log.info("No test file found. Create agent.test.ts to add tests.");
67
+ return ok({
68
+ passed: true,
69
+ skipped: true,
70
+ ran: [],
71
+ unrun: [],
72
+ complete: true
73
+ });
74
+ }
75
+ log.success(`Tests passed (${ran.length} spec file(s))`);
76
+ return ok({
77
+ passed: true,
78
+ ran,
79
+ unrun,
80
+ complete: unrun.length === 0
81
+ });
82
+ } catch (err) {
83
+ const { code, message } = classifyVitestError(err);
84
+ return fail(code, message);
85
+ }
86
+ }
87
+ /**
88
+ * The verdict for `--only` in a project with no `agent.test.ts`.
89
+ *
90
+ * This is the arm that had misled longest, and it is the one place the
91
+ * `incomplete_run` failure is still right: `aai test` printed "No test file
92
+ * found" while the project's specs sat right there unrun, which reads as "this
93
+ * project has no tests". Measured on a project whose only spec was
94
+ * `tools/echo_back.test.ts` — `{"passed":true,"skipped":true}`, exit 0, and not
95
+ * a word about it. Bare `aai test` runs those specs now; `--only` asked for a
96
+ * file that is not there, and the honest answer is neither a pass nor silence.
97
+ */
98
+ function noNarrowTarget(unrun) {
99
+ return fail("incomplete_run", `\`aai test --only\` found no ${TEST_FILES[0]}, so it ran nothing, but ${unrun.length} spec file(s) exist: ${formatCappedList(unrun)}. An unrun spec is not a passing one, so this is not a green result.`, WIDEN_HINT);
100
+ }
101
+ //#endregion
102
+ export { TEST_FILES, executeTest };
package/dist/test.d.ts CHANGED
@@ -25,31 +25,56 @@ type TestData = {
25
25
  complete: boolean;
26
26
  };
27
27
  /**
28
- * The files `aai test` runs, in preference order.
28
+ * The files a NARROWED `aai test` runs, in preference order.
29
29
  *
30
30
  * The tier's filenames belong to the command, not to the runner — `aai eval`
31
31
  * declares `EVAL_FILES` the same way one module over, and neither names the
32
32
  * other's. `aai build` imports this one because its pre-build gate runs the
33
33
  * TEST tier.
34
+ *
35
+ * They are no longer what a BARE `aai test` runs — see {@link executeTest} for
36
+ * why the default is the whole project — so this list is now reached only by
37
+ * `--only`.
34
38
  */
35
39
  export declare const TEST_FILES: readonly ["agent.test.ts", "agent.test.js"];
36
40
  /** What `aai test` was asked to cover. */
37
41
  export type TestOptions = {
38
- /** Run every non-eval spec in the project rather than `agent.test.ts` alone. */
39
- readonly all?: boolean | undefined;
42
+ /**
43
+ * Narrow the run to {@link TEST_FILES} rather than every non-eval spec.
44
+ *
45
+ * The fast inner loop, and the OPT-IN half of the pair: it is what the old
46
+ * default did, minus the false verdict — a narrowed run reports the specs it
47
+ * skipped through `warnUnrunSpecs` and says `complete: false`.
48
+ */
49
+ readonly only?: boolean | undefined;
40
50
  };
41
51
  /**
42
52
  * Execute agent tests and return structured result.
43
53
  *
44
- * **An incomplete run is not a pass.** For as long as this command answered
45
- * `{"ok":true,"data":{"passed":true}}` with exit 0 over specs it had not run,
46
- * the scaffold's `"test": "aai test"` was what users wired into CI — so a suite
47
- * of 25 tests could go red in the editor and green in the pipeline, and adding
48
- * one tool could break `registry.test.ts` in 17 assertions with `pnpm test` and
49
- * `pnpm build` both staying green throughout. It is the same defect
50
- * `defineExec`'s `cwd` policy exists for (a green result for a project that is
51
- * not there), one directory over, and it gets the same answer: the command
52
- * fails, names the files, and names the flag that runs them.
54
+ * **The default is the whole project, and it used to be one file.**
55
+ * `aai test` ran `agent.test.ts` alone and then FAILED (`incomplete_run`) over
56
+ * every other spec it had skipped — so on any project with a second spec file
57
+ * the default invocation could never be green, and the scaffold routed around
58
+ * the command it was supposed to wire into CI (`"test": "vitest run --exclude
59
+ * …"`, with `aai test` demoted to `test:agent`). Nine shipped templates carry
60
+ * two or more non-eval specs, so that was the normal case rather than the edge:
61
+ * the command's own remedy was "do not run this command".
62
+ *
63
+ * The narrow default was defensible when it was written — running a project's
64
+ * other specs could reach ones that are slow or want credentials — but the
65
+ * verdict is what made it unusable, and `aai build`'s pre-build gate had
66
+ * already gone the other way (`all: true`) for the same reason a build is run
67
+ * deliberately. So the widening is the default here too and `--only` is the
68
+ * inner loop, which leaves the two halves of the original defect closed: a
69
+ * complete run is a green run, and a narrowed one is honest about what it
70
+ * skipped instead of failing over it.
71
+ *
72
+ * **An incomplete run is still not a pass.** For as long as this command
73
+ * answered `{"ok":true,"data":{"passed":true}}` with exit 0 over specs it had
74
+ * not run, adding one tool could break `registry.test.ts` in 17 assertions with
75
+ * `pnpm test` and `pnpm build` both staying green throughout. What carries that
76
+ * now is the RESULT (`unrun`, `complete: false`) plus the runner's own warning,
77
+ * because the reader of a deliberate `--only` asked for the narrowing.
53
78
  */
54
79
  export declare function executeTest(cwd: string, opts?: TestOptions): Promise<CommandResult<TestData>>;
55
80
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alexkroman1/aai-cli",
3
- "version": "16.1.0",
3
+ "version": "17.0.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -57,16 +57,16 @@
57
57
  "p-timeout": "^7.0.1",
58
58
  "vite": "^8.2.2",
59
59
  "zod": "^4.5.4",
60
- "@alexkroman1/aai": "16.1.0",
61
- "@alexkroman1/aai-runtime": "16.1.0",
62
- "@alexkroman1/aai-ui": "16.1.0"
60
+ "@alexkroman1/aai": "17.0.0",
61
+ "@alexkroman1/aai-runtime": "17.0.0",
62
+ "@alexkroman1/aai-ui": "17.0.0"
63
63
  },
64
64
  "devDependencies": {
65
65
  "playwright": "^1.62.1",
66
66
  "tsdown": "^0.22.14",
67
67
  "verdaccio": "^6.10.1",
68
68
  "vitest": "^4.1.11",
69
- "aai-templates": "0.4.0"
69
+ "aai-templates": "0.5.0"
70
70
  },
71
71
  "peerDependencies": {
72
72
  "vitest": "^4.1.10"