@alexkroman1/aai-cli 16.1.0 → 18.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.
- package/README.md +2 -1
- package/dist/{_build-target-ClEEuUuW.mjs → _build-target-C08aM-Es.mjs} +504 -43
- package/dist/_build-target.d.ts +98 -19
- package/dist/_console-audio.d.ts +17 -0
- package/dist/_console-session.d.ts +70 -0
- package/dist/_deno-target.d.ts +15 -14
- package/dist/_dev-env.d.ts +19 -13
- package/dist/{_dev-server-D1wKiA0_.mjs → _dev-server-Dtp4aAlo.mjs} +26 -18
- package/dist/_dev-server.d.ts +5 -3
- package/dist/_init.d.ts +39 -0
- package/dist/_modal-target.d.ts +11 -6
- package/dist/_preflight-CnW9QiE7.mjs +116 -0
- package/dist/_preflight.d.ts +110 -5
- package/dist/_target-bundle.d.ts +112 -0
- package/dist/_target-entry.d.ts +81 -0
- package/dist/_templates-DXadVNsL.mjs +135 -0
- package/dist/_templates.d.ts +11 -34
- package/dist/{_vitest-runner-BiAMIir1.mjs → _vitest-runner-CZNGj0ZC.mjs} +21 -16
- package/dist/_vitest-runner.d.ts +35 -23
- package/dist/{build-O6BT51x_.mjs → build-DrQTSc2R.mjs} +128 -293
- package/dist/build.d.ts +34 -4
- package/dist/cli.mjs +40 -16
- package/dist/console-BsyE3DyB.mjs +422 -0
- package/dist/console.d.ts +37 -0
- package/dist/{deploy-lldQyJVj.mjs → deploy-B68-x7xM.mjs} +12 -4
- package/dist/deploy.d.ts +9 -0
- package/dist/{dev-Du8pCWFq.mjs → dev-BGWU2zPP.mjs} +1 -1
- package/dist/dev.d.ts +1 -1
- package/dist/{eval-Ducmkt1n.mjs → eval-DB07kTxO.mjs} +1 -1
- package/dist/init-CbOhyNYe.mjs +559 -0
- package/dist/init.d.ts +43 -3
- package/dist/scaffold/CLAUDE.md +161 -166
- package/dist/scaffold/package.json +6 -6
- package/dist/scaffold/vite.config.ts +29 -1
- package/dist/start.d.ts +3 -3
- package/dist/{studio-It7SRfUN.mjs → studio-BRJsw7lr.mjs} +19 -9
- package/dist/templates/applicant-screening-agent/agent.eval.test.ts +20 -6
- package/dist/templates/applicant-screening-agent/agent.test.ts +17 -13
- package/dist/templates/applicant-screening-agent/agent.ts +28 -0
- package/dist/templates/applicant-screening-agent/crews.ts +4 -4
- package/dist/templates/applicant-screening-agent/shared.ts +11 -11
- package/dist/templates/call-audit-workflow/agent.ts +2 -0
- package/dist/templates/code-interpreter-agent/agent.eval.test.ts +3 -2
- package/dist/templates/code-interpreter-agent/agent.test.ts +2 -2
- package/dist/templates/code-interpreter-agent/agent.ts +1 -0
- package/dist/templates/coding-agent/agent.eval.test.ts +136 -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.ts +3 -2
- package/dist/templates/custom-pipeline-agent/modes.test.ts +4 -4
- package/dist/templates/custom-pipeline-agent/stages.test.ts +75 -83
- package/dist/templates/document-redline-workflow/agent.ts +2 -0
- package/dist/templates/emergency-dispatch-agent/agent.eval.test.ts +1 -1
- package/dist/templates/emergency-dispatch-agent/agent.test.ts +103 -0
- package/dist/templates/emergency-dispatch-agent/agent.ts +15 -0
- package/dist/templates/emergency-dispatch-agent/guardrails.ts +105 -0
- package/dist/templates/emergency-dispatch-agent/system-prompt.md +1 -0
- package/dist/templates/entertainment-picks-agent/agent.eval.test.ts +9 -2
- package/dist/templates/entertainment-picks-agent/agent.ts +1 -0
- package/dist/templates/entertainment-picks-agent/system-prompt.md +6 -0
- package/dist/templates/entertainment-picks-agent/tools/revisit.ts +7 -0
- package/dist/templates/executive-inbox-agent/agent.eval.test.ts +84 -23
- package/dist/templates/executive-inbox-agent/agent.test.ts +35 -25
- package/dist/templates/executive-inbox-agent/agent.ts +1 -0
- package/dist/templates/executive-inbox-agent/calendar.test.ts +13 -7
- package/dist/templates/executive-inbox-agent/meeting.ts +3 -3
- package/dist/templates/executive-inbox-agent/prompts.ts +3 -1
- package/dist/templates/executive-inbox-agent/system-prompt.md +3 -3
- package/dist/templates/executive-inbox-agent/tools/meeting_assistant.ts +3 -3
- package/dist/templates/executive-inbox-agent/tools/open_email.ts +8 -16
- package/dist/templates/front-desk-agent/agent.eval.test.ts +174 -0
- package/dist/templates/front-desk-agent/agent.test.ts +150 -0
- package/dist/templates/front-desk-agent/agent.ts +22 -0
- package/dist/templates/front-desk-agent/shared.ts +234 -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/hotel-reception-agent/agent.eval.test.ts +85 -21
- package/dist/templates/hotel-reception-agent/agent.test.ts +3 -3
- package/dist/templates/hotel-reception-agent/agent.ts +6 -3
- package/dist/templates/hotel-reception-agent/client.tsx +14 -2
- package/dist/templates/hotel-reception-agent/concierge.ts +2 -1
- package/dist/templates/hotel-reception-agent/desk-seams.test.ts +3 -3
- package/dist/templates/hotel-reception-agent/disputes.ts +9 -11
- package/dist/templates/hotel-reception-agent/events.ts +2 -1
- package/dist/templates/hotel-reception-agent/session.ts +56 -0
- package/dist/templates/hotel-reception-agent/shared.ts +20 -21
- package/dist/templates/hotel-reception-agent/system-prompt.md +1 -1
- package/dist/templates/hotel-reception-agent/tools/abandon_booking.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/add_to_waitlist.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/book_airport_car.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/cancel_restaurant_reservation.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/cancel_room_booking.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/check_restaurant_availability.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/check_room_availability.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/choose_room.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/confirm_booking.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/dispatch_emergency.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/dispute_charge.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/flag_late_arrival.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/lookup_booking.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/lookup_guest_history.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/lookup_invoice.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/lookup_restaurant_reservation.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/modify_restaurant_reservation.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/record_card.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/record_followup.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/record_group_inquiry.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/record_guest_details.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/reinstate_booking.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/request_flight_reconfirmation.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/resend_confirmation.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/reserve_table.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/resolve_room_conflict.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/schedule_wakeup_call.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/set_do_not_disturb.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/set_extras.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/set_stay.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/start_booking_modification.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/start_room_booking.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/take_guest_message.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/transfer_call.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/update_card.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/verify_booking.ts +2 -1
- package/dist/templates/link-digest-workflow/agent.eval.test.ts +16 -1
- package/dist/templates/link-digest-workflow/agent.ts +5 -0
- package/dist/templates/medication-safety-agent/agent.test.ts +57 -4
- package/dist/templates/medication-safety-agent/agent.ts +48 -1
- package/dist/templates/meeting-recap-agent/agent.test.ts +2 -2
- package/dist/templates/meeting-recap-agent/agent.ts +4 -0
- package/dist/templates/pizza-ordering-agent/agent.eval.test.ts +68 -2
- package/dist/templates/pizza-ordering-agent/agent.ts +3 -0
- package/dist/templates/podcast-digest-workflow/agent.ts +4 -0
- package/dist/templates/push-to-talk-agent/agent.eval.test.ts +74 -0
- package/dist/templates/push-to-talk-agent/agent.test.ts +61 -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 +34 -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 +91 -3
- package/dist/templates/quickstart-agent/agent.test.ts +22 -0
- package/dist/templates/quickstart-agent/agent.ts +18 -2
- 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 +1 -1
- package/dist/templates/research-handoff-agent/agent.test.ts +34 -26
- package/dist/templates/research-handoff-agent/agent.ts +4 -0
- package/dist/templates/research-planner-agent/agent.eval.test.ts +24 -2
- package/dist/templates/research-planner-agent/agent.test.ts +26 -16
- package/dist/templates/research-planner-agent/agent.ts +3 -0
- package/dist/templates/research-planner-agent/system-prompt.md +1 -1
- package/dist/templates/retail-orders-agent/agent.eval.test.ts +1 -1
- package/dist/templates/retail-orders-agent/agent.ts +32 -3
- package/dist/templates/retail-orders-agent/keyterms.ts +154 -0
- package/dist/templates/retail-orders-agent/resolve.ts +18 -3
- package/dist/templates/roadside-assistance-agent/agent.eval.test.ts +124 -5
- package/dist/templates/roadside-assistance-agent/agent.test.ts +39 -7
- package/dist/templates/roadside-assistance-agent/agent.ts +4 -0
- package/dist/templates/roadside-assistance-agent/shared.ts +12 -0
- package/dist/templates/roadside-assistance-agent/tools/acknowledge_disclosure.ts +14 -0
- package/dist/templates/roadside-assistance-agent/tools/lookup_coverage.ts +11 -0
- package/dist/templates/roadside-assistance-agent/tools/service_disclosure.ts +17 -11
- package/dist/templates/roadside-assistance-agent/yard.test.ts +4 -0
- package/dist/templates/spoken-summary-workflow/agent.ts +4 -0
- package/dist/templates/tabletop-rpg-agent/agent.eval.test.ts +6 -0
- package/dist/templates/tabletop-rpg-agent/agent.test.ts +125 -1
- package/dist/templates/tabletop-rpg-agent/agent.ts +30 -1
- package/dist/templates/tabletop-rpg-agent/shared.ts +81 -0
- package/dist/templates/tabletop-rpg-agent/system-prompt.md +1 -1
- package/dist/templates/tabletop-rpg-agent/tools/check_state.ts +16 -7
- package/dist/templates/technical-support-agent/agent.test.ts +29 -23
- package/dist/templates/technical-support-agent/agent.ts +5 -1
- package/dist/templates/technical-support-agent/knowledge.ts +165 -0
- package/dist/templates/technical-support-agent/nodes.ts +3 -2
- package/dist/templates/technical-support-agent/procedure.ts +7 -6
- package/dist/templates/technical-support-agent/shared.ts +10 -146
- package/dist/templates/technical-support-agent/tools/list_topics.ts +2 -1
- package/dist/templates/text-adventure-agent/agent.eval.test.ts +39 -6
- package/dist/templates/text-adventure-agent/agent.test.ts +79 -1
- package/dist/templates/text-adventure-agent/agent.ts +30 -1
- package/dist/templates/text-adventure-agent/shared.ts +37 -0
- package/dist/templates/text-adventure-agent/system-prompt.md +9 -2
- package/dist/templates/topic-briefing-agent/agent.eval.test.ts +18 -4
- package/dist/templates/topic-briefing-agent/agent.test.ts +61 -36
- package/dist/templates/topic-briefing-agent/agent.ts +4 -1
- package/dist/templates/topic-briefing-agent/shared.ts +19 -18
- package/dist/templates/topic-briefing-agent/system-prompt.md +13 -8
- package/dist/templates/topic-briefing-agent/tools/send_briefing.ts +43 -5
- package/dist/templates/transcription-workflow/agent.ts +3 -0
- package/dist/templates/travel-concierge-agent/agent.eval.test.ts +9 -7
- package/dist/templates/travel-concierge-agent/agent.test.ts +1 -2
- package/dist/templates/travel-concierge-agent/agent.ts +4 -0
- package/dist/templates/web-research-agent/agent.eval.test.ts +31 -5
- package/dist/templates/web-research-agent/agent.test.ts +16 -0
- package/dist/templates/web-research-agent/agent.ts +30 -0
- package/dist/templates/web-research-agent/system-prompt.md +8 -2
- package/dist/templates/word-game-agent/agent.eval.test.ts +79 -18
- package/dist/templates/word-game-agent/agent.test.ts +3 -1
- package/dist/templates/word-game-agent/agent.ts +20 -0
- package/dist/test-CjKPQ9_B.mjs +102 -0
- package/dist/test.d.ts +37 -12
- package/package.json +5 -5
- package/dist/_init-Bp1CjRrU.mjs +0 -199
- package/dist/_preflight-CcAR577V.mjs +0 -46
- package/dist/_templates-CuP74F8D.mjs +0 -291
- package/dist/init-CY4NAXAA.mjs +0 -183
- package/dist/test-PHHv0Vj6.mjs +0 -83
|
@@ -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
|
-
/**
|
|
31
|
-
|
|
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({
|
|
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
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
//
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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
|
-
|
|
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(
|
|
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
|
-
{
|
|
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,
|
|
@@ -41,7 +41,9 @@ const at = (ctx: ToolContext) => gameFlow.position(ctx).state;
|
|
|
41
41
|
function scriptedPlayer() {
|
|
42
42
|
let nextGuess = "nothing";
|
|
43
43
|
const model = stubGenerate({
|
|
44
|
-
|
|
44
|
+
routes: {
|
|
45
|
+
[PLAYER_SYSTEM]: () => ({ object: { guess: nextGuess, remark: `Is it a ${nextGuess}?` } }),
|
|
46
|
+
},
|
|
45
47
|
});
|
|
46
48
|
return {
|
|
47
49
|
model,
|
|
@@ -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
|
-
/**
|
|
39
|
-
|
|
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
|
-
* **
|
|
45
|
-
* `
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* `
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
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": "
|
|
3
|
+
"version": "18.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": "
|
|
61
|
-
"@alexkroman1/aai-
|
|
62
|
-
"@alexkroman1/aai-
|
|
60
|
+
"@alexkroman1/aai": "18.0.0",
|
|
61
|
+
"@alexkroman1/aai-ui": "18.0.0",
|
|
62
|
+
"@alexkroman1/aai-runtime": "18.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.
|
|
69
|
+
"aai-templates": "0.5.0"
|
|
70
70
|
},
|
|
71
71
|
"peerDependencies": {
|
|
72
72
|
"vitest": "^4.1.10"
|
package/dist/_init-Bp1CjRrU.mjs
DELETED
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { d as readJson, g as writeJson, i as compareCodeUnits, u as isEexist } from "./_utils-D5JGcjiW.mjs";
|
|
3
|
-
import { r as isDevMode, t as getMonorepoRoot } from "./_agent-BzUeqOdj.mjs";
|
|
4
|
-
import { REPO_URL, downloadAndMergeTemplate } from "./_templates-CuP74F8D.mjs";
|
|
5
|
-
import path from "node:path";
|
|
6
|
-
import fs from "node:fs/promises";
|
|
7
|
-
//#region src/_init.ts
|
|
8
|
-
/**
|
|
9
|
-
* The README every scaffolded project gets, and the first thing a new author
|
|
10
|
-
* reads. Three things in it are corrections rather than prose:
|
|
11
|
-
*
|
|
12
|
-
* - **`npm run dev`, never a bare `aai dev`.** The CLI is a devDependency, so
|
|
13
|
-
* after `npm install` the binary is in `node_modules/.bin` and NOT on
|
|
14
|
-
* `PATH`. The old quickstart said `aai dev`, which fails with
|
|
15
|
-
* `command not found` for everyone who has not installed the CLI globally.
|
|
16
|
-
* - **The key `aai dev` needs is named, with the two LOCAL ways first.** No
|
|
17
|
-
* step of local development needs a platform account; a twenty-persona DX
|
|
18
|
-
* audit read the account-shaped failure it used to get and concluded the
|
|
19
|
-
* opposite, then stopped using the loop this file documents.
|
|
20
|
-
* - **`aai login` appears where it is actually required.** It was in no
|
|
21
|
-
* user-facing doc at all, while the quickstart's own publish step needs it.
|
|
22
|
-
*/
|
|
23
|
-
function readmeContent(slug) {
|
|
24
|
-
return `# ${slug}
|
|
25
|
-
|
|
26
|
-
A voice agent built with [aai](${REPO_URL}).
|
|
27
|
-
|
|
28
|
-
## Getting started
|
|
29
|
-
|
|
30
|
-
\`\`\`sh
|
|
31
|
-
npm install # Install dependencies
|
|
32
|
-
npm run dev # Run locally on http://localhost:3000 (opens browser)
|
|
33
|
-
\`\`\`
|
|
34
|
-
|
|
35
|
-
The \`aai\` CLI is a devDependency of this project, so it lives in
|
|
36
|
-
\`node_modules/.bin\` rather than on your \`PATH\`. Run it through npm
|
|
37
|
-
(\`npm run dev\`, \`npm test\`, \`npm run build\`) or with \`npx aai <command>\`.
|
|
38
|
-
Installing it globally (\`npm i -g @alexkroman1/aai-cli\`) also works, and is
|
|
39
|
-
what the project docs assume.
|
|
40
|
-
|
|
41
|
-
### The one key local development needs
|
|
42
|
-
|
|
43
|
-
The default pipeline (speech-to-text → LLM → text-to-speech) runs on a single
|
|
44
|
-
AssemblyAI key. **Any one of these is enough, and the first two need no aai
|
|
45
|
-
account** — nothing about running this agent locally is gated on one:
|
|
46
|
-
|
|
47
|
-
1. Put \`ASSEMBLYAI_API_KEY=<your key>\` in \`.env\` (this project's \`.env.example\`
|
|
48
|
-
documents it, and it is the same file \`aai publish\` uploads as secrets).
|
|
49
|
-
2. Or export it in your shell: \`export ASSEMBLYAI_API_KEY=<your key>\`.
|
|
50
|
-
3. Or run \`npx aai login\`, and \`aai dev\` will use your account's key.
|
|
51
|
-
|
|
52
|
-
Get a key at <https://www.assemblyai.com/dashboard>.
|
|
53
|
-
|
|
54
|
-
## Publishing
|
|
55
|
-
|
|
56
|
-
Publishing (and the studio it syncs to) is the one part that does need an
|
|
57
|
-
account:
|
|
58
|
-
|
|
59
|
-
\`\`\`sh
|
|
60
|
-
npx aai login # Link your account — once per machine
|
|
61
|
-
npm run publish:agent # Publish to production (and sync to the studio)
|
|
62
|
-
\`\`\`
|
|
63
|
-
|
|
64
|
-
You can also run this agent as a plain Node server, with no aai account and
|
|
65
|
-
nothing managed:
|
|
66
|
-
|
|
67
|
-
\`\`\`sh
|
|
68
|
-
npm start # Builds, then serves on http://127.0.0.1:3000
|
|
69
|
-
\`\`\`
|
|
70
|
-
|
|
71
|
-
## Secrets
|
|
72
|
-
|
|
73
|
-
Access secrets in your agent via \`ctx.env.MY_KEY\`.
|
|
74
|
-
|
|
75
|
-
**Local development** — add secrets to \`.env\` (auto-loaded by \`aai dev\`):
|
|
76
|
-
|
|
77
|
-
\`\`\`sh
|
|
78
|
-
ALPHA_VANTAGE_KEY=sk-abc123
|
|
79
|
-
MY_API_KEY=secret-value
|
|
80
|
-
\`\`\`
|
|
81
|
-
|
|
82
|
-
**Production** — set secrets on the server:
|
|
83
|
-
|
|
84
|
-
\`\`\`sh
|
|
85
|
-
npx aai secret put MY_KEY # Set a secret (prompts for value)
|
|
86
|
-
npx aai secret list # List secret names
|
|
87
|
-
npx aai secret delete MY_KEY # Remove a secret
|
|
88
|
-
\`\`\`
|
|
89
|
-
|
|
90
|
-
`;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Map from npm package name to directory name under packages/.
|
|
94
|
-
* Used to rewrite published version ranges to link: paths in dev mode.
|
|
95
|
-
*/
|
|
96
|
-
const WORKSPACE_PKG_DIRS = {
|
|
97
|
-
"@alexkroman1/aai": "aai",
|
|
98
|
-
"@alexkroman1/aai-cli": "aai-cli",
|
|
99
|
-
"@alexkroman1/aai-runtime": "aai-runtime",
|
|
100
|
-
"@alexkroman1/aai-ui": "aai-ui"
|
|
101
|
-
};
|
|
102
|
-
/** Rewrite workspace deps to link: paths so pnpm links to local source. */
|
|
103
|
-
async function patchPackageJsonForWorkspace(targetDir) {
|
|
104
|
-
const pkgPath = path.join(targetDir, "package.json");
|
|
105
|
-
const pkgJson = await readJson(pkgPath);
|
|
106
|
-
if (!pkgJson) return;
|
|
107
|
-
pkgJson.name = path.basename(targetDir);
|
|
108
|
-
delete pkgJson.packageManager;
|
|
109
|
-
const root = getMonorepoRoot();
|
|
110
|
-
if (!root) return;
|
|
111
|
-
const packagesDir = path.join(root, "packages");
|
|
112
|
-
for (const field of ["dependencies", "devDependencies"]) {
|
|
113
|
-
const deps = pkgJson[field];
|
|
114
|
-
if (!deps) continue;
|
|
115
|
-
for (const key of Object.keys(deps)) {
|
|
116
|
-
const dir = WORKSPACE_PKG_DIRS[key];
|
|
117
|
-
if (dir) deps[key] = `link:${path.relative(targetDir, path.join(packagesDir, dir))}`;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
await writeJson(pkgPath, pkgJson);
|
|
121
|
-
await pinSharedDeps(targetDir, packagesDir, pkgJson);
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Pin every THIRD-PARTY dependency this project shares with a linked workspace
|
|
125
|
-
* package to the copy that workspace package resolved.
|
|
126
|
-
*
|
|
127
|
-
* Linking is what makes this necessary, and it only bites in dev mode. The
|
|
128
|
-
* project's `@alexkroman1/*` deps become `link:` paths, so the SDK's types come
|
|
129
|
-
* out of the WORKSPACE's `node_modules` — while the project installs its own
|
|
130
|
-
* copy of anything it also declares. Two copies of a structurally identical
|
|
131
|
-
* library are two NOMINALLY different types to TypeScript, and the error runs to
|
|
132
|
-
* a hundred lines of `Type 'AnyActorLogic' is not assignable to type
|
|
133
|
-
* 'AnyActorLogic'` with two absolute paths in it.
|
|
134
|
-
*
|
|
135
|
-
* Measured: `aai init --template technical-support-agent` produced exactly that. The
|
|
136
|
-
* workspace lockfile pinned `xstate@5.32.5`, the fresh project resolved
|
|
137
|
-
* `^5.32.5` to `5.32.6`, the CLI's typecheck gate failed, and the deploy was
|
|
138
|
-
* REFUSED — `"deployed": false` with the whole error as a warning. One
|
|
139
|
-
* `overrides` entry fixes it; verified end to end.
|
|
140
|
-
*
|
|
141
|
-
* A published install has no such problem, which is why this is dev-mode only:
|
|
142
|
-
* a user's project and the published SDK both ask for `^5.32.5` and pnpm
|
|
143
|
-
* resolves ONE copy. Nothing here changes what a user gets.
|
|
144
|
-
*
|
|
145
|
-
* Written to `pnpm-workspace.yaml` rather than `pnpm.overrides` in the manifest:
|
|
146
|
-
* the scaffold ships that file, which makes the project its own workspace root,
|
|
147
|
-
* and pnpm 10+ reads overrides from there. Verified both ways — the manifest
|
|
148
|
-
* spelling installed `5.32.6` anyway.
|
|
149
|
-
*/
|
|
150
|
-
async function pinSharedDeps(targetDir, packagesDir, pkgJson) {
|
|
151
|
-
const declared = {
|
|
152
|
-
...pkgJson.dependencies,
|
|
153
|
-
...pkgJson.devDependencies
|
|
154
|
-
};
|
|
155
|
-
const linked = Object.entries(WORKSPACE_PKG_DIRS).filter(([name]) => name in declared).map(([, dir]) => dir);
|
|
156
|
-
const resolved = await Promise.all(Object.keys(declared).filter((name) => !(name in WORKSPACE_PKG_DIRS)).map(async (name) => {
|
|
157
|
-
for (const dir of linked) {
|
|
158
|
-
const manifest = await readJson(path.join(packagesDir, dir, "node_modules", name, "package.json"));
|
|
159
|
-
if (typeof manifest?.version === "string") return [name, manifest.version];
|
|
160
|
-
}
|
|
161
|
-
return null;
|
|
162
|
-
}));
|
|
163
|
-
const pins = new Map(resolved.filter((entry) => entry !== null));
|
|
164
|
-
if (pins.size === 0) return;
|
|
165
|
-
const file = path.join(targetDir, "pnpm-workspace.yaml");
|
|
166
|
-
let existing;
|
|
167
|
-
try {
|
|
168
|
-
existing = await fs.readFile(file, "utf-8");
|
|
169
|
-
} catch {
|
|
170
|
-
return;
|
|
171
|
-
}
|
|
172
|
-
const block = [...pins].sort(([a], [b]) => compareCodeUnits(a, b)).map(([name, version]) => ` "${name}": "${version}"`).join("\n");
|
|
173
|
-
await fs.writeFile(file, `${existing.trimEnd()}\n\n# Added by \`aai init\` in DEV MODE only — see pinSharedDeps in\n# packages/aai-cli/src/_init.ts. The @alexkroman1/* packages above are LINKED to
|
|
174
|
-
# this checkout, so anything they and this project both depend on has to be
|
|
175
|
-
# ONE copy: two copies of xstate are two incompatible sets of types, and the
|
|
176
|
-
# typecheck gate refuses the deploy.\noverrides:\n${block}\n`);
|
|
177
|
-
}
|
|
178
|
-
async function runInit(opts) {
|
|
179
|
-
const { targetDir, template } = opts;
|
|
180
|
-
await downloadAndMergeTemplate(template, targetDir);
|
|
181
|
-
if (isDevMode()) {
|
|
182
|
-
await patchPackageJsonForWorkspace(targetDir);
|
|
183
|
-
try {
|
|
184
|
-
await fs.unlink(path.join(targetDir, ".npmrc"));
|
|
185
|
-
} catch {}
|
|
186
|
-
}
|
|
187
|
-
try {
|
|
188
|
-
await fs.copyFile(path.join(targetDir, ".env.example"), path.join(targetDir, ".env"), fs.constants.COPYFILE_EXCL);
|
|
189
|
-
} catch {}
|
|
190
|
-
const readmePath = path.join(targetDir, "README.md");
|
|
191
|
-
const slug = path.basename(path.resolve(targetDir));
|
|
192
|
-
try {
|
|
193
|
-
await fs.writeFile(readmePath, readmeContent(slug), { flag: "wx" });
|
|
194
|
-
} catch (err) {
|
|
195
|
-
if (!isEexist(err)) throw err;
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
//#endregion
|
|
199
|
-
export { runInit };
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { plural } from "@alexkroman1/aai/utils";
|
|
3
|
-
import { requiredProviderEnvVars } from "@alexkroman1/aai-runtime";
|
|
4
|
-
//#region src/_preflight.ts
|
|
5
|
-
/**
|
|
6
|
-
* The deploy-time credential preflight — the classic dev/prod failure, caught
|
|
7
|
-
* before the upload instead of at the deployed agent's first session.
|
|
8
|
-
*
|
|
9
|
-
* An agent that ran locally on shell-exported provider keys dies after deploy
|
|
10
|
-
* with what looks like a provider outage: `aai dev` falls back to the shell
|
|
11
|
-
* (`withHostCredentialFallback`), and the platform never will. Naming the key
|
|
12
|
-
* here turns that into one line of output while the developer is still in the
|
|
13
|
-
* directory that owns the `.env`.
|
|
14
|
-
*
|
|
15
|
-
* **This lives in the CLI because the agent's config does.** The platform
|
|
16
|
-
* stores no description of a bundle and never evaluates one (see "The
|
|
17
|
-
* platform stores no agent config" in packages/aai-server/CLAUDE.md), so the
|
|
18
|
-
* only place that knows an agent needs `CARTESIA_API_KEY` is the process that
|
|
19
|
-
* just built it.
|
|
20
|
-
*
|
|
21
|
-
* **It WARNS, and must not be turned into a hard failure.** The CLI sees the
|
|
22
|
-
* env it is about to upload; it cannot see what is already stored against the
|
|
23
|
-
* slug from an earlier `aai secret put`, so a key the platform holds looks
|
|
24
|
-
* missing from here. The server-side check this replaced could see both and
|
|
25
|
-
* so could reject — moving the config to where it is authored costs that
|
|
26
|
-
* accuracy, and a false rejection is worse than a false warning: it blocks a
|
|
27
|
-
* deploy that would have worked.
|
|
28
|
-
*/
|
|
29
|
-
/**
|
|
30
|
-
* Env var names the agent needs that the env being uploaded doesn't supply.
|
|
31
|
-
* Empty values count as missing — an empty credential authenticates nothing.
|
|
32
|
-
*
|
|
33
|
-
* Two sources: provider credentials derived from the stt/llm/tts/s2s
|
|
34
|
-
* descriptors (the same registry-backed derivation the runtime resolves keys
|
|
35
|
-
* with), and the agent's own declared `requiredEnv` — an `agent()` field for
|
|
36
|
-
* custom keys tools read from `ctx.env`, which no static derivation can see.
|
|
37
|
-
*/
|
|
38
|
-
function missingCredentials(config, env) {
|
|
39
|
-
return [.../* @__PURE__ */ new Set([...requiredProviderEnvVars(config), ...config.requiredEnv ?? []])].filter((name) => !env[name]);
|
|
40
|
-
}
|
|
41
|
-
/** One line naming the missing keys and what to do about them. */
|
|
42
|
-
function missingCredentialMessage(missing) {
|
|
43
|
-
return `Missing ${plural(missing.length, "credential")} the agent needs to start: ${missing.join(", ")}. Declare ${plural(missing.length, "it", "them")} in .env and redeploy (already set on the platform with \`aai secret put\`? then this is already handled).`;
|
|
44
|
-
}
|
|
45
|
-
//#endregion
|
|
46
|
-
export { missingCredentialMessage, missingCredentials };
|