@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
package/dist/init.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { type PackageManager, type PackageManagerInfo } from "./_init.ts";
|
|
1
2
|
import { type CommandResult } from "./_output.ts";
|
|
2
3
|
type InitData = {
|
|
3
4
|
dir: string;
|
|
4
5
|
template: string;
|
|
5
6
|
/**
|
|
6
7
|
* Diagnostics a human sees as `log.warn` lines — today only a failed
|
|
7
|
-
*
|
|
8
|
+
* dependency install.
|
|
8
9
|
*
|
|
9
10
|
* They have to ride the result for the same reason `PushOutcome.warnings`
|
|
10
11
|
* does — `log.warn` is silenced in JSON mode and JSON mode is AUTO-DETECTED
|
|
@@ -28,8 +29,47 @@ type InitData = {
|
|
|
28
29
|
* JSON mode (auto-detected on a pipe) resolve the default without prompting.
|
|
29
30
|
*/
|
|
30
31
|
export declare function promptTemplate(list?: () => Promise<string[]>): Promise<string>;
|
|
31
|
-
/**
|
|
32
|
-
|
|
32
|
+
/**
|
|
33
|
+
* The manager that INVOKED this process, from `npm_config_user_agent`.
|
|
34
|
+
*
|
|
35
|
+
* Every one of the four sets it when it runs a binary or a script, so this is
|
|
36
|
+
* the strongest signal available and it is checked first: a user who followed
|
|
37
|
+
* the documented `npm i -g @alexkroman1/aai-cli` and then ran `npx aai init`
|
|
38
|
+
* has said which manager they use, and the old code installed with pnpm
|
|
39
|
+
* regardless. An unrecognized head (`deno/…`, nothing at all) falls through to
|
|
40
|
+
* the PATH probe rather than guessing.
|
|
41
|
+
*/
|
|
42
|
+
export declare function packageManagerFromUserAgent(ua?: string | undefined): PackageManagerInfo | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* Which package manager `aai init` installs with.
|
|
45
|
+
*
|
|
46
|
+
* It used to be pnpm, unconditionally, reached through `corepack enable` — and
|
|
47
|
+
* corepack is absent from Node >= 25, half the range the scaffold's `engines`
|
|
48
|
+
* allow, so on a current Node the documented install path (`npm i -g
|
|
49
|
+
* @alexkroman1/aai-cli`) produced a scaffold whose install step needed a
|
|
50
|
+
* manager the user had never been asked to have. The generated README then said
|
|
51
|
+
* `npm install` beside the pnpm lockfile.
|
|
52
|
+
*
|
|
53
|
+
* Two signals, in order, and pnpm stays the preference in the second: the
|
|
54
|
+
* manager that invoked us, then the first of {@link PACKAGE_MANAGERS} that is
|
|
55
|
+
* really on PATH. npm is the last resort because every Node install ships one,
|
|
56
|
+
* so the install command is at worst attempted rather than skipped.
|
|
57
|
+
*
|
|
58
|
+
* Note what this does NOT do: enable corepack, or install a manager. Running
|
|
59
|
+
* only something that answered `--version` is what makes the corepack call
|
|
60
|
+
* unnecessary, and it is the whole reason this function exists.
|
|
61
|
+
*/
|
|
62
|
+
export declare function detectPackageManager(ua?: string | undefined, probe?: (name: PackageManager) => Promise<string | undefined>): Promise<PackageManagerInfo>;
|
|
63
|
+
/**
|
|
64
|
+
* Build the command + args that install `pm`'s dependencies.
|
|
65
|
+
*
|
|
66
|
+
* The safe-chain routing is pnpm-only and stays that way: it is what this repo
|
|
67
|
+
* installs with, `--safe-chain-skip-minimum-package-age` exists because the
|
|
68
|
+
* scaffold pins freshly published `@alexkroman1/*` versions, and safe-chain's
|
|
69
|
+
* other wrappers are not what anything here was verified against. npm has no
|
|
70
|
+
* such quarantine to skip, so nothing is lost on that path.
|
|
71
|
+
*/
|
|
72
|
+
export declare function resolveInstallCommand(pm: PackageManager, checkSafeChain?: () => Promise<boolean>): Promise<{
|
|
33
73
|
cmd: string;
|
|
34
74
|
args: string[];
|
|
35
75
|
}>;
|
package/dist/scaffold/CLAUDE.md
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
#
|
|
1
|
+
# AssemblyAI Agent SDK
|
|
2
2
|
|
|
3
|
-
You are helping build a voice agent
|
|
3
|
+
You are helping build a voice agent with the **AssemblyAI Agent SDK**.
|
|
4
4
|
|
|
5
5
|
## Workflow
|
|
6
6
|
|
|
7
7
|
The fast loop: edit → `pnpm dev` (browser, talk to it) →
|
|
8
8
|
`pnpm test` (logic) → `pnpm build` (validate bundle).
|
|
9
9
|
|
|
10
|
-
1. **Iterate in `pnpm dev`** — browser UI, and
|
|
11
|
-
|
|
12
|
-
end-to-end. This is the primary feedback loop. Watching is
|
|
13
|
-
restart ends in-flight voice sessions, which
|
|
14
|
-
and wrong while something
|
|
15
|
-
|
|
10
|
+
1. **Iterate in `pnpm dev`** — browser UI, and it rebuilds and restarts on
|
|
11
|
+
every save when you are at a terminal. Speak to the agent to verify behavior
|
|
12
|
+
end-to-end. This is the primary feedback loop. Watching is on for a PERSON
|
|
13
|
+
and off for everything else: a restart ends in-flight voice sessions, which
|
|
14
|
+
is right while you are editing and wrong while something drives the agent
|
|
15
|
+
for twenty minutes, and a harness or supervisor has no TTY. `AAI_DEV_WATCH=0`
|
|
16
|
+
turns it off at a terminal, `AAI_DEV_WATCH=1` on for a process supervisor.
|
|
16
17
|
2. **Run `pnpm test` after logic changes** — vitest. Co-locate tests as
|
|
17
18
|
`agent.test.ts` (see `custom-pipeline-agent` template for a reference).
|
|
18
19
|
**When the project has an `agent.test.ts` (the default `quickstart-agent`
|
|
@@ -41,6 +42,7 @@ The fast loop: edit → `pnpm dev` (browser, talk to it) →
|
|
|
41
42
|
Cases live in `agent.eval.test.ts` (the `quickstart-agent` template ships one):
|
|
42
43
|
|
|
43
44
|
```ts no-check
|
|
45
|
+
import { expectCalled } from "@alexkroman1/aai-runtime/eval";
|
|
44
46
|
import { describeEval } from "@alexkroman1/aai-runtime/eval/vitest";
|
|
45
47
|
import { expect } from "vitest";
|
|
46
48
|
import agentDef from "./agent.ts";
|
|
@@ -51,7 +53,7 @@ The fast loop: edit → `pnpm dev` (browser, talk to it) →
|
|
|
51
53
|
async ({ session }) => {
|
|
52
54
|
// `say()` returns THAT turn — the reply, its tool calls, its events.
|
|
53
55
|
const turn = await session.say("where is order W1234?");
|
|
54
|
-
|
|
56
|
+
expectCalled(turn, "look_up");
|
|
55
57
|
expect(turn.text).toMatch(/shipped/i);
|
|
56
58
|
},
|
|
57
59
|
// What a SCRIPTED model answers with when there is no key (below).
|
|
@@ -117,8 +119,8 @@ Then:
|
|
|
117
119
|
aai init # Scaffold a new agent
|
|
118
120
|
aai templates # List available templates
|
|
119
121
|
aai dev # Start local dev server
|
|
120
|
-
aai test # Run
|
|
121
|
-
aai test --
|
|
122
|
+
aai test # Run the project's specs via vitest
|
|
123
|
+
aai test --only # ...or agent.test.ts alone
|
|
122
124
|
aai eval # Run agent.eval.test.ts against a model
|
|
123
125
|
aai build # Bundle and validate
|
|
124
126
|
aai deploy # Deploy to production
|
|
@@ -132,12 +134,11 @@ The scaffold's `package.json` exposes `dev`, `build`, `test`, `eval` and
|
|
|
132
134
|
`deploy` as `pnpm <name>` shortcuts, which run the project's own copy of the
|
|
133
135
|
CLI. Other commands (`init`, `templates`, `delete`, `secret`) are CLI-only.
|
|
134
136
|
|
|
135
|
-
**`aai test`
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
gate in front of `aai build`.
|
|
137
|
+
**`aai test` runs every non-eval spec in the project**, which `--only` narrows
|
|
138
|
+
to `agent.test.ts` for the fast inner loop. A narrowed run does not report
|
|
139
|
+
itself as a pass: it names the spec files it did not cover and answers
|
|
140
|
+
`complete: false`. `pnpm test` (the scaffold's own script) is `aai test`, and so
|
|
141
|
+
is the gate in front of `aai build`.
|
|
141
142
|
|
|
142
143
|
## Running it yourself (`npm start`)
|
|
143
144
|
|
|
@@ -312,6 +313,8 @@ export default agent({
|
|
|
312
313
|
// all four types are on "@alexkroman1/aai",
|
|
313
314
|
// and on their own stage subpath
|
|
314
315
|
sttPrompt?: string; // STT guidance for jargon/acronyms
|
|
316
|
+
voicePresets?: VoicePresetName[]; // opt-in prompt presets — see below; each one
|
|
317
|
+
// costs tokens on EVERY model request
|
|
315
318
|
builtinTools?: BuiltinTool[]; // see built-in tools table
|
|
316
319
|
// (there is no `tools` field — a tool is a FILE;
|
|
317
320
|
// see "A file in tools/ IS a tool")
|
|
@@ -327,9 +330,12 @@ export default agent({
|
|
|
327
330
|
silencePrompt?: string; // instruction injected on silence timeout (requires silenceTimeoutMs)
|
|
328
331
|
minBargeInWords?: number; // pipeline only — words before user speech interrupts the reply (default 2)
|
|
329
332
|
interruptionMinDurationMs?: number; // pipeline only — sustained speech (ms) before an interim barge-in interrupts (default 500; 0 disables)
|
|
330
|
-
deadAirCoverMs?: number; // pipeline only — speak a short filler after this much silence in a turn (default
|
|
333
|
+
deadAirCoverMs?: number; // pipeline only — speak a short filler after this much silence in a turn (default 2400; 0 disables)
|
|
331
334
|
resumeFalseInterruption?: boolean; // pipeline only — resume an interrupted reply if no user turn commits (default true)
|
|
332
335
|
preemptiveGeneration?: boolean; // pipeline only — start the reply from a high-confidence interim (default false; true opts in)
|
|
336
|
+
userTurnLimit?: { maxWords?: number; // pipeline only — cap ONE user turn: end it after this many words
|
|
337
|
+
maxDurationMs?: number };// and/or this long (ms). Default: no cap. Emits `user-turn.exceeded`.
|
|
338
|
+
turnDetection?: "auto" | "manual"; // pipeline only — "manual" is push-to-talk: the CLIENT ends each turn
|
|
333
339
|
syncState?: StateProjection; // show a slot to the client: slot.projection(view)
|
|
334
340
|
// (read it with useAgentState; see UI hooks)
|
|
335
341
|
minTurnSilenceMs?: number; // pipeline only — pause (ms) that ENDS a user turn once the
|
|
@@ -343,7 +349,9 @@ export default agent({
|
|
|
343
349
|
// missing key fails at `aai push` instead of mid-call.
|
|
344
350
|
// Declare every key any tool or step reads.
|
|
345
351
|
text?: true; // text-only agent: no STT, no TTS, `llm` is the one stage
|
|
346
|
-
events?: SessionEventHandlers; // observe the session
|
|
352
|
+
events?: SessionEventHandlers; // observe the session; "metrics.collected" is each
|
|
353
|
+
// reply's latency/tokens: createMetricsCollector()
|
|
354
|
+
personas?: Personas; // see "Personas"
|
|
347
355
|
});
|
|
348
356
|
```
|
|
349
357
|
|
|
@@ -353,8 +361,8 @@ export default agent({
|
|
|
353
361
|
> through the Vercel AI Gateway (`AI_GATEWAY_API_KEY`), a bare id through
|
|
354
362
|
> the AssemblyAI LLM Gateway (`ASSEMBLYAI_API_KEY`).
|
|
355
363
|
|
|
356
|
-
Minimal agent — a cascaded pipeline,
|
|
357
|
-
|
|
364
|
+
Minimal agent — a cascaded pipeline, what to build unless the user asks
|
|
365
|
+
for speech-to-speech:
|
|
358
366
|
|
|
359
367
|
```ts
|
|
360
368
|
import { agent } from "@alexkroman1/aai";
|
|
@@ -366,8 +374,7 @@ export default agent({
|
|
|
366
374
|
|
|
367
375
|
No provider fields means the default all-AssemblyAI pipeline: all three
|
|
368
376
|
stages bill to the one key a published agent is guaranteed to have. Pick
|
|
369
|
-
its voice with the `voice` field
|
|
370
|
-
voice:
|
|
377
|
+
its voice with the `voice` field:
|
|
371
378
|
|
|
372
379
|
```ts
|
|
373
380
|
import { agent } from "@alexkroman1/aai";
|
|
@@ -378,9 +385,8 @@ export default agent({
|
|
|
378
385
|
});
|
|
379
386
|
```
|
|
380
387
|
|
|
381
|
-
Swap
|
|
382
|
-
|
|
383
|
-
string:
|
|
388
|
+
Swap one stage by declaring just that field; the rest stay default.
|
|
389
|
+
`llm` accepts the gateway model id as a plain string:
|
|
384
390
|
|
|
385
391
|
```ts
|
|
386
392
|
import { agent } from "@alexkroman1/aai";
|
|
@@ -411,18 +417,12 @@ import { agent } from "@alexkroman1/aai";
|
|
|
411
417
|
export default agent({ name: "My Agent" });
|
|
412
418
|
```
|
|
413
419
|
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
export default agent({
|
|
422
|
-
name: "My Agent",
|
|
423
|
-
systemPrompt: `${DEFAULT_SYSTEM_PROMPT}\n\nYou only ever discuss pizza.`,
|
|
424
|
-
});
|
|
425
|
-
```
|
|
420
|
+
**Your prompt is ADDED to the defaults, never a replacement** — the framework
|
|
421
|
+
emits its voice sections and appends yours last, yours winning on conflict.
|
|
422
|
+
Write ONLY your own domain rules; never interpolate `DEFAULT_SYSTEM_PROMPT`
|
|
423
|
+
(exported to be READ). Nothing is replaced, so composing sends ~10,000
|
|
424
|
+
characters twice a turn; a leading copy is dropped with a warning, one
|
|
425
|
+
elsewhere is sent.
|
|
426
426
|
|
|
427
427
|
```markdown
|
|
428
428
|
<!-- system-prompt.md -->
|
|
@@ -1338,13 +1338,13 @@ descriptor (the descriptor owns its own voice). A raw config that skips
|
|
|
1338
1338
|
```ts
|
|
1339
1339
|
import { agent } from "@alexkroman1/aai";
|
|
1340
1340
|
import { assemblyAIStt } from "@alexkroman1/aai/stt";
|
|
1341
|
-
import {
|
|
1341
|
+
import { llm } from "@alexkroman1/aai/llm";
|
|
1342
1342
|
import { cartesiaTts } from "@alexkroman1/aai/tts";
|
|
1343
1343
|
|
|
1344
1344
|
export default agent({
|
|
1345
1345
|
name: "My Agent",
|
|
1346
1346
|
stt: assemblyAIStt({ model: "universal-3-5-pro" }),
|
|
1347
|
-
llm:
|
|
1347
|
+
llm: llm({ provider: "anthropic", model: "claude-haiku-4-5" }),
|
|
1348
1348
|
tts: cartesiaTts(),
|
|
1349
1349
|
});
|
|
1350
1350
|
```
|
|
@@ -1394,9 +1394,7 @@ bridge transcodes in both directions, so the agent, its tools and its slots
|
|
|
1394
1394
|
behave exactly as they do in the browser — a phone call is a transport, not a
|
|
1395
1395
|
mode. Nothing else about `agent.ts` changes to support one.
|
|
1396
1396
|
|
|
1397
|
-
**An agent that declares nothing answers no carrier
|
|
1398
|
-
earlier releases: every voice agent used to serve both carriers' framing from
|
|
1399
|
-
the moment it booted, whether or not it had a phone number. `/phone` is the one
|
|
1397
|
+
**An agent that declares nothing answers no carrier.** `/phone` is the one
|
|
1400
1398
|
door dialled from OUTSIDE your deployment, by a carrier following a number, so
|
|
1401
1399
|
it is opened by a sentence in `agent.ts` rather than inherited. `aai dev` and a
|
|
1402
1400
|
deployed sandbox honour the same declaration, so a call refused after a deploy
|
|
@@ -1415,9 +1413,9 @@ assistant proactively take a turn after that much user silence (e.g.
|
|
|
1415
1413
|
assistant stops nudging after 3 consecutive unanswered nudges until the
|
|
1416
1414
|
user speaks again.
|
|
1417
1415
|
|
|
1418
|
-
**Voice-UX tuning (pipeline only):**
|
|
1419
|
-
words of user speech interrupt the
|
|
1420
|
-
one-word
|
|
1416
|
+
**Voice-UX tuning (`PipelineVoiceTuning`, pipeline only):**
|
|
1417
|
+
`minBargeInWords` controls how many words of user speech interrupt the
|
|
1418
|
+
assistant mid-reply (default 2, so a one-word "yeah" doesn't cut it off);
|
|
1421
1419
|
`interruptionMinDurationMs` adds a sustained-speech gate on top (default
|
|
1422
1420
|
500 ms; `0` disables; interim transcripts only — committed turns always
|
|
1423
1421
|
land). End-of-turn detection (how long a pause ends the user's turn)
|
|
@@ -1431,23 +1429,22 @@ promptly pays nothing; `0` disables it. The wording is not yours to set — the
|
|
|
1431
1429
|
filler must be purely declarative and never a request for patience, or the
|
|
1432
1430
|
caller answers it and the answer barges in.
|
|
1433
1431
|
`resumeFalseInterruption` (default `true`) resumes an interrupted reply when
|
|
1434
|
-
a barge-in turns out to be noise — no user turn ever commits.
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
`
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
tool-heavy one, where a speculation that reaches a tool call is thrown away.
|
|
1432
|
+
a barge-in turns out to be noise — no user turn ever commits. It fires once the
|
|
1433
|
+
transcript stream goes quiet with no final, so it never races a real turn.
|
|
1434
|
+
`userTurnLimit` (a `UserTurnLimit`; default: no cap) bounds ONE user turn —
|
|
1435
|
+
`{ maxWords }`, `{ maxDurationMs }`, or both. A caller who never pauses never
|
|
1436
|
+
ends a turn; past either cap the transcriber ends it as a pause would — what
|
|
1437
|
+
was heard commits,
|
|
1438
|
+
the rest opens the next turn. Each cut is a `user-turn.exceeded` event
|
|
1439
|
+
(`limit`, `words`, `durationMs`); `{}` is refused. Inert (logged once) on a
|
|
1440
|
+
transcriber that cannot end a turn on demand; the default `assemblyAIStt()` can.
|
|
1441
|
+
`turnDetection: "manual"` is PUSH-TO-TALK (`usePushToTalk()` in `aai-ui`):
|
|
1442
|
+
the mic is heard only while held, all of it is ONE turn answered on release,
|
|
1443
|
+
and pressing is the barge-in.
|
|
1444
|
+
`preemptiveGeneration` (default **`false`**) starts the reply from a confident
|
|
1445
|
+
interim and adopts it if the committed transcript matches. Off because it
|
|
1446
|
+
measured net **+8ms per turn**, 44% of requests thrown away; a speculation never
|
|
1447
|
+
speaks or calls a tool until adopted.
|
|
1451
1448
|
|
|
1452
1449
|
## Providers
|
|
1453
1450
|
|
|
@@ -1480,41 +1477,41 @@ API keys require it; the US endpoints reject them. Example:
|
|
|
1480
1477
|
|
|
1481
1478
|
### LLM — `@alexkroman1/aai/llm`
|
|
1482
1479
|
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
| `
|
|
1487
|
-
|
|
|
1488
|
-
| `
|
|
1489
|
-
| `
|
|
1490
|
-
| `
|
|
1491
|
-
| `
|
|
1492
|
-
| `
|
|
1493
|
-
| `
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
`
|
|
1498
|
-
|
|
1499
|
-
`
|
|
1500
|
-
|
|
1501
|
-
`
|
|
1502
|
-
|
|
1503
|
-
`"creator/model"
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
`
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
`
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
`assemblyAILlm` routes through the [AssemblyAI LLM
|
|
1480
|
+
ONE factory, `llm({ provider, model, baseUrl?, apiKeyEnv?, providerOptions? })`.
|
|
1481
|
+
The provider is a string, not a function name:
|
|
1482
|
+
|
|
1483
|
+
| `provider` | SDK package | Env var |
|
|
1484
|
+
| -------------- | ------------------- | ------------------------------ |
|
|
1485
|
+
| `"anthropic"` | `@ai-sdk/anthropic` | `ANTHROPIC_API_KEY` |
|
|
1486
|
+
| `"openai"` | `@ai-sdk/openai` | `OPENAI_API_KEY` |
|
|
1487
|
+
| `"google"` | `@ai-sdk/google` | `GOOGLE_GENERATIVE_AI_API_KEY` |
|
|
1488
|
+
| `"mistral"` | `@ai-sdk/mistral` | `MISTRAL_API_KEY` |
|
|
1489
|
+
| `"xai"` | `@ai-sdk/xai` | `XAI_API_KEY` |
|
|
1490
|
+
| `"groq"` | `@ai-sdk/groq` | `GROQ_API_KEY` |
|
|
1491
|
+
| `"cerebras"` | `@ai-sdk/openai` | `CEREBRAS_API_KEY` |
|
|
1492
|
+
| `"openrouter"` | `@ai-sdk/openai` | `OPENROUTER_API_KEY` |
|
|
1493
|
+
| `"gateway"` | `ai` (built in) | `AI_GATEWAY_API_KEY` |
|
|
1494
|
+
| `"assemblyai"` | `@ai-sdk/openai` | `ASSEMBLYAI_API_KEY` |
|
|
1495
|
+
|
|
1496
|
+
`model` is required. Example:
|
|
1497
|
+
`llm({ provider: "anthropic", model: "claude-haiku-4-5" })`.
|
|
1498
|
+
`"openrouter"` and `"gateway"` (the [Vercel AI
|
|
1499
|
+
Gateway](https://vercel.com/docs/ai-gateway)) address a model as
|
|
1500
|
+
`"creator/model"`; every other provider takes its own bare id.
|
|
1501
|
+
|
|
1502
|
+
`provider` is OPEN: any other string compiles. A provider with no built-in
|
|
1503
|
+
entry is reached as an OpenAI-compatible endpoint by naming its `baseUrl` (and
|
|
1504
|
+
`apiKeyEnv`, the variable its key is in); `aai build` warns about an unknown
|
|
1505
|
+
provider that has neither. `providerOptions` carries provider-specific
|
|
1506
|
+
settings: a native client's AI SDK `providerOptions`; on `openrouter`,
|
|
1507
|
+
`cerebras` or a `baseUrl` provider, raw request-body fields (`top_k`).
|
|
1508
|
+
|
|
1509
|
+
`"assemblyai"` routes through the [AssemblyAI LLM
|
|
1514
1510
|
Gateway](https://www.assemblyai.com/docs/llm-gateway) — an
|
|
1515
1511
|
OpenAI-compatible endpoint fronting 25+ models (Claude, GPT, Gemini,
|
|
1516
1512
|
etc.) with the same API key as AssemblyAI STT. A bare model-id string on
|
|
1517
|
-
`llm` is shorthand for it
|
|
1513
|
+
`llm` is shorthand for it (and a `"creator/model"` string for `"gateway"`), and
|
|
1514
|
+
unset stages keep the AssemblyAI default:
|
|
1518
1515
|
|
|
1519
1516
|
```ts
|
|
1520
1517
|
import { agent } from "@alexkroman1/aai";
|
|
@@ -1525,8 +1522,9 @@ export default agent({
|
|
|
1525
1522
|
});
|
|
1526
1523
|
```
|
|
1527
1524
|
|
|
1528
|
-
`
|
|
1529
|
-
selects EU data residency
|
|
1525
|
+
`llm({ provider: "assemblyai", model, providerOptions: { region: "eu" } })` is
|
|
1526
|
+
the explicit form; `region` selects EU data residency, and `reasoningEffort`
|
|
1527
|
+
beside it sets the model's reasoning effort.
|
|
1530
1528
|
|
|
1531
1529
|
Mixing providers works the same way — declare the stages you're changing:
|
|
1532
1530
|
|
|
@@ -1815,7 +1813,7 @@ an SDK dependency. `technical-support-agent` is the worked example.
|
|
|
1815
1813
|
|
|
1816
1814
|
`ctx.generate` is ONE prompt. When answering takes an unknown number of tool
|
|
1817
1815
|
calls whose intermediate results the conversation has no reason to carry,
|
|
1818
|
-
delegate to a **subagent
|
|
1816
|
+
delegate to a **subagent**: a second tool loop with its own system
|
|
1819
1817
|
prompt, model, tools and — the whole point — its own context window.
|
|
1820
1818
|
|
|
1821
1819
|
```ts
|
|
@@ -1824,11 +1822,8 @@ import { z } from "zod";
|
|
|
1824
1822
|
|
|
1825
1823
|
const researcher = subagent({
|
|
1826
1824
|
name: "researcher",
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
systemPrompt:
|
|
1830
|
-
"Research the task with the tools you have. IMPORTANT: your final message " +
|
|
1831
|
-
"is the only thing the caller sees — end with a self-contained summary.",
|
|
1825
|
+
systemPrompt: "Research the task with the tools you have.",
|
|
1826
|
+
expectedOutput: "A self-contained summary — the only thing the caller sees.",
|
|
1832
1827
|
builtinTools: ["web_search", "visit_webpage"],
|
|
1833
1828
|
maxSteps: 6,
|
|
1834
1829
|
});
|
|
@@ -1843,37 +1838,45 @@ export default tool({
|
|
|
1843
1838
|
});
|
|
1844
1839
|
```
|
|
1845
1840
|
|
|
1846
|
-
Four rules, each
|
|
1841
|
+
Four rules, each the way a subagent disappoints when skipped: you receive its
|
|
1842
|
+
FINAL message, so declare `expectedOutput`; its context is isolated, so `task`
|
|
1843
|
+
must be a complete brief; `maxSteps` bounds the loop, and a capped run is asked
|
|
1844
|
+
for its answer with tools withheld; and say you are looking it up before you
|
|
1845
|
+
call. A subagent may name its own `llm` and its own `tools` map; **delegation is
|
|
1846
|
+
one level deep**. In tests, `stubDelegate` (`@alexkroman1/aai/testing`) fakes it
|
|
1847
|
+
by subagent name.
|
|
1847
1848
|
|
|
1848
|
-
|
|
1849
|
-
signs off with "Done." has thrown away everything it read.
|
|
1850
|
-
- **Write the task as a complete brief.** Its context is isolated — it has not
|
|
1851
|
-
heard the conversation. Anything it needs from the call goes in `task`, or in
|
|
1852
|
-
the optional `context` string.
|
|
1853
|
-
- **Give it a budget.** `maxSteps` (default: the framework's) bounds the loop;
|
|
1854
|
-
past it the subagent is asked for its answer with its tools withheld, so a
|
|
1855
|
-
capped run still answers. In a voice session the tool timeout bounds the
|
|
1856
|
-
whole thing, so keep it small.
|
|
1857
|
-
- **Say you are looking it up before you call.** A delegated run takes a
|
|
1858
|
-
moment, and a silent line is the worst thing on a phone call.
|
|
1849
|
+
### Personas and `handoff` (`personas()`)
|
|
1859
1850
|
|
|
1860
|
-
|
|
1861
|
-
|
|
1851
|
+
When the SPEAKER has to change — triage verifies the caller, billing takes over
|
|
1852
|
+
with its own instructions and tools, one history — declare a roster of
|
|
1853
|
+
**personas**; the first entry answers the call.
|
|
1862
1854
|
|
|
1863
|
-
```ts
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1855
|
+
```ts
|
|
1856
|
+
import { agent, persona, personas } from "@alexkroman1/aai";
|
|
1857
|
+
|
|
1858
|
+
const triage = persona({
|
|
1859
|
+
name: "triage",
|
|
1860
|
+
description: "Answers the phone and picks the desk",
|
|
1861
|
+
systemPrompt: "Bill or fault? Find out, then hand off.",
|
|
1862
|
+
});
|
|
1863
|
+
const billing = persona({
|
|
1864
|
+
name: "billing",
|
|
1865
|
+
description: "Invoices, payments and refunds",
|
|
1866
|
+
systemPrompt: "You are the billing desk.",
|
|
1867
|
+
});
|
|
1868
|
+
export const desk = personas([triage, billing]);
|
|
1868
1869
|
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
run a strictly smaller surface than the agent has. **Delegation is one level
|
|
1872
|
-
deep**: a subagent's own tools get a `ctx.delegate` that refuses.
|
|
1870
|
+
export default agent({ name: "Front Desk", personas: desk });
|
|
1871
|
+
```
|
|
1873
1872
|
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1873
|
+
The roster mints one `handoff` tool the model routes with, described by each
|
|
1874
|
+
persona's `description`. A tool body hands off in code with
|
|
1875
|
+
`desk.handoff(ctx, billing, { note })` and returns the result; the same turn
|
|
1876
|
+
continues as the new persona. A persona's `tools` (a map) refuse at
|
|
1877
|
+
execution while another persona speaks, naming who is and how to hand off.
|
|
1878
|
+
`tools/` and `system-prompt.md` hold under every persona; a dialog state pins one
|
|
1879
|
+
with `persona`. Example: `front-desk-agent`.
|
|
1877
1880
|
|
|
1878
1881
|
### A tool that calls an API
|
|
1879
1882
|
|
|
@@ -2013,10 +2016,9 @@ the tool simply never reached the model.
|
|
|
2013
2016
|
|
|
2014
2017
|
## Built-in tools
|
|
2015
2018
|
|
|
2016
|
-
Enable via `builtinTools` in `agent()`. **
|
|
2017
|
-
are
|
|
2018
|
-
|
|
2019
|
-
something it has to notice and switch off.
|
|
2019
|
+
Enable via `builtinTools` in `agent()`. **Omitted, only `think` is on**; the
|
|
2020
|
+
rest are opt-in. Setting the field REPLACES the default: list `"think"` to keep
|
|
2021
|
+
it, `[]` for none.
|
|
2020
2022
|
|
|
2021
2023
|
| Tool | Description | Params |
|
|
2022
2024
|
| --- | --- | --- |
|
|
@@ -2118,10 +2120,8 @@ before this subpath existed.
|
|
|
2118
2120
|
|
|
2119
2121
|
## Persisting data — bring your own client
|
|
2120
2122
|
|
|
2121
|
-
**There is no `ctx.db`.**
|
|
2122
|
-
|
|
2123
|
-
author set. The platform provisions no database, and no longer hands tool code
|
|
2124
|
-
one either.
|
|
2123
|
+
**There is no `ctx.db`.** The platform provisions no database and hands tool
|
|
2124
|
+
code none.
|
|
2125
2125
|
|
|
2126
2126
|
So a tool that needs to persist anything uses a client of its own:
|
|
2127
2127
|
|
|
@@ -2448,14 +2448,24 @@ Never hardcode secrets in agent code.
|
|
|
2448
2448
|
|
|
2449
2449
|
## Voice rules for systemPrompt
|
|
2450
2450
|
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2451
|
+
**Don't restate the voice rules — the framework always emits them** (read
|
|
2452
|
+
`DEFAULT_SYSTEM_PROMPT`; your own prompt is APPENDED to it). Write only what
|
|
2453
|
+
the defaults cannot say: "use run_code for ANY math", "you ARE the game".
|
|
2454
|
+
"Search first" and "don't guess" they already say.
|
|
2455
|
+
|
|
2456
|
+
### Opt-in prompt presets
|
|
2457
|
+
|
|
2458
|
+
`agent({ voicePresets: ["echoVerification", "natoAlphabet"] })` switches on
|
|
2459
|
+
named behaviours instead of writing them. They compose, each is removable on
|
|
2460
|
+
its own, and each is paid for on EVERY model request: `echoVerification`
|
|
2461
|
+
(~190 tokens — read critical values back and get a yes), `speechNormalization`
|
|
2462
|
+
(~920 — money, dates, phone numbers and emails as spoken words, `"$758.08"`
|
|
2463
|
+
as "seven fifty-eight dollars and eight cents") and `natoAlphabet` (~190 —
|
|
2464
|
+
"That's B as in Bravo, 7, K as in Kilo, 2 — correct?"). `VOICE_PRESETS` holds
|
|
2465
|
+
the exact text. The two spelling presets override the default "don't spell
|
|
2466
|
+
things back", so use them where a wrong value costs more than a slow call;
|
|
2467
|
+
`speechNormalization` is the PROMPT layer only, and for the agent's OWN data
|
|
2468
|
+
the renderers below do it in code for free.
|
|
2459
2469
|
|
|
2460
2470
|
**Speech goes both ways, and `@alexkroman1/aai` publishes both conversions.**
|
|
2461
2471
|
Inbound: `spokenDigits("four one five")` is `"415"`, `spokenOrdinal("the third
|
|
@@ -2464,7 +2474,7 @@ phrase meant — answering a `ToolFailure` when nothing matches or several do, t
|
|
|
2464
2474
|
case a hand-written `.find()` gets wrong.
|
|
2465
2475
|
|
|
2466
2476
|
Outbound: an engine handed `$240.50` may read "dollar sign two hundred forty
|
|
2467
|
-
point five zero"
|
|
2477
|
+
point five zero" — right text, wrong call.
|
|
2468
2478
|
Render the words first: `spokenMoney(240.5)` is `"240 dollars and 50 cents"`,
|
|
2469
2479
|
`spokenDate("2026-06-08")` is `"Monday, June 8"`, `spokenTime("18:30")` is
|
|
2470
2480
|
`"6:30 PM"`. `mintCode("HTL")` mints a reference with no `0`/`O`, `1`/`I` or
|
|
@@ -2481,19 +2491,9 @@ substitute, so a dice roll or a minted code is something a spec can assert.
|
|
|
2481
2491
|
`randomInt`, `pickOne` and `shuffled` take it last. A WORKFLOW body wants its
|
|
2482
2492
|
own journaled `ctx.random()` instead.
|
|
2483
2493
|
|
|
2484
|
-
Patterns by agent type:
|
|
2485
|
-
|
|
2486
|
-
- **Code execution:** "You MUST use run_code for ANY math, counting, or
|
|
2487
|
-
data processing. NEVER do mental math."
|
|
2488
|
-
- **Research:** "Search first. Never guess or rely on memory for factual
|
|
2489
|
-
questions."
|
|
2490
|
-
- **FAQ/support:** "Base answers strictly on your knowledge — don't guess."
|
|
2491
|
-
- **Game/interactive:** "You ARE the game. Keep descriptions to 2-4
|
|
2492
|
-
sentences. No visual formatting."
|
|
2493
|
-
|
|
2494
2494
|
## Gotchas
|
|
2495
2495
|
|
|
2496
|
-
Common mistakes when working in
|
|
2496
|
+
Common mistakes when working in agent projects:
|
|
2497
2497
|
|
|
2498
2498
|
- **Tool execute must return a value.** A missing return = `undefined` in
|
|
2499
2499
|
LLM context = the model thinks the tool failed.
|
|
@@ -2513,20 +2513,15 @@ Common mistakes when working in aai projects:
|
|
|
2513
2513
|
`client.tsx`. Missing this = unstyled UI.
|
|
2514
2514
|
- **Don't create `tailwind.config.js`.** Tailwind v4 is configured via
|
|
2515
2515
|
CSS; the config file is ignored.
|
|
2516
|
-
- **Voice prompts ≠ chat prompts.** No bullets, no bold, no exclamation
|
|
2517
|
-
points. See "Voice rules" above.
|
|
2518
2516
|
- **`fetch` to private IPs is blocked** (SSRF protection). Use public URLs.
|
|
2519
2517
|
- **`run_code` only executes on the deployed platform.** It runs inside the
|
|
2520
2518
|
platform's Modal/Deno sandbox; the self-hosted `aai dev` server has no
|
|
2521
2519
|
sandbox, so there `run_code` refuses with an error result. Deploy to test
|
|
2522
2520
|
it end-to-end, or use the `calculate` builtin for simple arithmetic in dev.
|
|
2523
|
-
- **There is no `ctx.db`.**
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
the next deploy rather than immediately; and a database you bring is shared by
|
|
2528
|
-
every session of the deployment, so key rows yourself if sessions must not see
|
|
2529
|
-
each other's data (or keep session-scoped data in a `sessionSlot`).
|
|
2521
|
+
- **There is no `ctx.db`.** A tool that persists brings its own client — see
|
|
2522
|
+
"Persisting data". A secret is read when the sandbox is BUILT, so a newly set
|
|
2523
|
+
`DATABASE_URL` arrives on the next deploy rather than immediately, and the
|
|
2524
|
+
database is shared by every session, so key rows yourself.
|
|
2530
2525
|
- **Rime language codes are ISO 639-3** (3-letter, e.g. `"eng"`), not
|
|
2531
2526
|
ISO 639-1 (`"en"`).
|
|
2532
2527
|
|
|
@@ -9,16 +9,16 @@
|
|
|
9
9
|
"prestart": "aai build --skip-tests",
|
|
10
10
|
"start": "aai start",
|
|
11
11
|
"build": "aai build",
|
|
12
|
-
"test": "
|
|
13
|
-
"test:agent": "aai test",
|
|
12
|
+
"test": "aai test",
|
|
13
|
+
"test:agent": "aai test --only",
|
|
14
14
|
"eval": "aai eval",
|
|
15
15
|
"publish:agent": "aai publish"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@alexkroman1/aai": "^
|
|
19
|
-
"@alexkroman1/aai-cli": "^
|
|
20
|
-
"@alexkroman1/aai-runtime": "^
|
|
21
|
-
"@alexkroman1/aai-ui": "^
|
|
18
|
+
"@alexkroman1/aai": "^18.0.0",
|
|
19
|
+
"@alexkroman1/aai-cli": "^18.0.0",
|
|
20
|
+
"@alexkroman1/aai-runtime": "^18.0.0",
|
|
21
|
+
"@alexkroman1/aai-ui": "^18.0.0",
|
|
22
22
|
"react": "^19.2.8",
|
|
23
23
|
"react-dom": "^19.2.8",
|
|
24
24
|
"tailwindcss": "^4.0.0",
|