@alexkroman1/aai-cli 0.13.0 → 0.14.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 +15 -15
- package/dist/{_bundler-CgBw5Bcu.mjs → _bundler-B6v31ROV.mjs} +1 -1
- package/dist/_console-audio.d.ts +18 -0
- package/dist/{_dev-server-BNq5OnUJ.mjs → _dev-server-GoEXEVpA.mjs} +2 -2
- package/dist/_resource-commands.d.ts +34 -2
- package/dist/{_slug-api-DJuwYZ6T.mjs → _slug-api-BnmTHtjd.mjs} +1 -1
- package/dist/{_studio-BH05zugt.mjs → _studio-B5m4jBTD.mjs} +14 -9
- package/dist/_studio.d.ts +16 -4
- package/dist/_target-bundle.d.ts +2 -0
- package/dist/{_templates-Bv-rd0SO.mjs → _templates-BVMVsQh0.mjs} +10 -6
- package/dist/_templates.d.ts +9 -2
- package/dist/{build-B37oBfEv.mjs → build-CKhanHVv.mjs} +28 -32
- package/dist/cli-workflow.d.ts +7 -0
- package/dist/cli.mjs +213 -181
- package/dist/{client-bundler-D4SeZJ8E.mjs → client-bundler-DZ_Zoznn.mjs} +2 -1
- package/dist/client-bundler.d.ts +7 -1
- package/dist/client-bundler.mjs +1 -1
- package/dist/{console-D6OOjjeJ.mjs → console-Dxq26Adz.mjs} +14 -10
- package/dist/{delete-Br0EOH0g.mjs → delete-DwXCHzTl.mjs} +8 -8
- package/dist/delete.d.ts +4 -3
- package/dist/{deploy-CLUH5cv2.mjs → deploy-CbA8Ibiu.mjs} +2 -2
- package/dist/{dev-ZVuyPLUk.mjs → dev-BWBDbUEb.mjs} +1 -1
- package/dist/{init-x3FsKl2q.mjs → init-CidslZZz.mjs} +1 -1
- package/dist/{logs-BfRq1HX9.mjs → logs-CnPK-Prw.mjs} +25 -3
- package/dist/scaffold/CLAUDE.md +52 -52
- package/dist/scaffold/agent-guide/AGENT-API.md +20 -20
- package/dist/scaffold/agent-guide/HOSTING.md +32 -33
- package/dist/scaffold/agent-guide/PIPELINE-TUNING.md +44 -47
- package/dist/scaffold/agent-guide/PROVIDERS.md +54 -57
- package/dist/scaffold/agent-guide/TESTING-EVALS.md +31 -31
- package/dist/scaffold/agent-guide/TOOLS.md +86 -87
- package/dist/scaffold/agent-guide/UI.md +59 -58
- package/dist/scaffold/agent-guide/WORKFLOWS.md +129 -127
- package/dist/scaffold/package.json +4 -4
- package/dist/scaffold/vitest.config.ts +3 -3
- package/dist/{secret-Db1UWLSZ.mjs → secret-DPdPEet2.mjs} +2 -2
- package/dist/{studio-DAoJApzD.mjs → studio-COjK25Rl.mjs} +23 -24
- package/dist/studio.d.ts +5 -4
- package/dist/templates/call-audit-workflow/agent.eval.test.ts +6 -6
- package/dist/templates/call-audit-workflow/agent.test.ts +2 -2
- package/dist/templates/document-redline-workflow/agent.eval.test.ts +14 -17
- package/dist/templates/home-assistant-agent/agent.test.ts +0 -1
- package/dist/templates/link-digest-workflow/agent.eval.test.ts +2 -2
- package/dist/templates/link-digest-workflow/agent.test.ts +24 -25
- package/dist/templates/medication-safety-agent/agent.test.ts +15 -18
- package/dist/templates/medication-safety-agent/fda.test.ts +16 -17
- package/dist/templates/medication-safety-agent/fda.ts +7 -0
- package/dist/templates/medication-safety-agent/tools/check_drug_interaction.ts +61 -53
- package/dist/templates/medication-safety-agent/tools/medication_lookup.ts +42 -32
- package/dist/templates/meeting-recap-agent/agent.eval.test.ts +29 -16
- package/dist/templates/podcast-digest-workflow/agent.eval.test.ts +3 -3
- package/dist/templates/podcast-digest-workflow/agent.test.ts +17 -17
- package/dist/templates/research-handoff-agent/agent.eval.test.ts +22 -15
- package/dist/templates/research-handoff-agent/agent.test.ts +2 -15
- package/dist/templates/research-planner-agent/agent.test.ts +22 -17
- package/dist/templates/research-planner-agent/shared.ts +122 -93
- package/dist/templates/retail-orders-agent/shared.ts +2 -2
- package/dist/templates/retail-orders-agent/tools/get_order_details.ts +1 -1
- package/dist/templates/spoken-summary-workflow/agent.eval.test.ts +6 -6
- package/dist/templates/spoken-summary-workflow/agent.test.ts +2 -2
- package/dist/templates/transcription-workflow/agent.eval.test.ts +3 -3
- package/dist/templates/transcription-workflow/agent.test.ts +2 -1
- package/dist/templates/transcription-workflow/recover.test.ts +4 -7
- package/dist/templates/web-research-agent/agent.test.ts +4 -3
- package/dist/templates/word-game-agent/agent.test.ts +11 -5
- package/package.json +6 -6
|
@@ -173,11 +173,6 @@ export interface SearchHit {
|
|
|
173
173
|
/**
|
|
174
174
|
* The executor's search.
|
|
175
175
|
*
|
|
176
|
-
* It was an INJECTED function, so a spec could drive the executor without the
|
|
177
|
-
* live web. That seam is gone with the loop it served — the executor is a
|
|
178
|
-
* subagent now, and a spec fakes the whole delegation with `stubDelegate` — so
|
|
179
|
-
* what is left is the type {@link searchTool} is written against.
|
|
180
|
-
*
|
|
181
176
|
* **A refusal is a RETURN, not a throw**, which is the `@alexkroman1/aai/tools`
|
|
182
177
|
* contract read straight through: `webSearch` answers `{ error }` and so does
|
|
183
178
|
* this, so a caller either narrows it or `orFail`s it and cannot ignore it.
|
|
@@ -186,106 +181,140 @@ export interface SearchHit {
|
|
|
186
181
|
*/
|
|
187
182
|
export type SearchFn = (query: string, options?: CallOptions) => Promise<SearchHit[] | ToolFailure>;
|
|
188
183
|
|
|
189
|
-
/** How many results one search reads. Enough to compare, short enough to hear. */
|
|
190
|
-
export const SEARCH_RESULTS = 4;
|
|
191
|
-
|
|
192
184
|
/**
|
|
193
|
-
*
|
|
194
|
-
*
|
|
195
|
-
* there is nothing out there. Measured: DuckDuckGo answers `403` often enough
|
|
196
|
-
* that this is the ordinary case, not an edge one.
|
|
185
|
+
* The two `@alexkroman1/aai/tools` calls the executor's tools make — the one
|
|
186
|
+
* place this template leaves the process.
|
|
197
187
|
*
|
|
198
|
-
*
|
|
199
|
-
*
|
|
200
|
-
* `
|
|
201
|
-
*
|
|
202
|
-
* UNCAUGHT tool bug on its way to the model, which a 403 from a free search
|
|
203
|
-
* endpoint is not.
|
|
188
|
+
* Taken as an argument by {@link createWebTools} so a spec can hand in fakes:
|
|
189
|
+
* both screen a URL and then really fetch it, through an undici dispatcher a
|
|
190
|
+
* `globalThis.fetch` stub cannot reach. Everything between the call and the
|
|
191
|
+
* model — the filtering, the rendering, the refusal handling — stays real.
|
|
204
192
|
*/
|
|
205
|
-
export
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
return (results.results ?? [])
|
|
215
|
-
.filter(
|
|
216
|
-
(one): one is { title?: string; url: string } =>
|
|
217
|
-
typeof one.url === "string" && one.url.length > 0,
|
|
218
|
-
)
|
|
219
|
-
.map((one) => ({ title: one.title || one.url, url: one.url }));
|
|
220
|
-
},
|
|
221
|
-
);
|
|
193
|
+
export type WebAccess = {
|
|
194
|
+
webSearch: (
|
|
195
|
+
spec: { query: string; maxResults?: number } & CallOptions,
|
|
196
|
+
) => Promise<{ results?: { title?: string; url?: string }[] } | ToolFailure>;
|
|
197
|
+
visitWebpage: (
|
|
198
|
+
url: string,
|
|
199
|
+
options?: CallOptions,
|
|
200
|
+
) => Promise<{ content?: string; text?: string } | ToolFailure>;
|
|
201
|
+
};
|
|
222
202
|
|
|
223
|
-
/**
|
|
224
|
-
const
|
|
225
|
-
const hits = orFail(await liveSearch(query, options));
|
|
226
|
-
if (hits.length === 0) return "No results.";
|
|
227
|
-
return hits.map((hit) => `- ${hit.title} (${hit.url})`).join("\n");
|
|
228
|
-
});
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
* `search` — {@link liveSearch} as a tool the EXECUTOR may call.
|
|
232
|
-
*
|
|
233
|
-
* The search is REAL: `webSearch` from `@alexkroman1/aai/tools` is the same
|
|
234
|
-
* DuckDuckGo-backed implementation behind the model-facing `web_search` builtin,
|
|
235
|
-
* with the same URL screening and size caps, and it needs no API key. Giving the
|
|
236
|
-
* subagent this rather than the builtin is what keeps that worked example alive
|
|
237
|
-
* — a subagent's `tools` are ordinary `ToolDef`s, so an agent's own code is as
|
|
238
|
-
* reachable from one as a framework builtin is.
|
|
239
|
-
*
|
|
240
|
-
* **`ctx.signal` goes down to the fetch.** A tool body gets one, `CallOptions`
|
|
241
|
-
* takes one, and until they were joined a caller who hung up mid-step left a
|
|
242
|
-
* search running against a third party — the runtime settles the tool's await
|
|
243
|
-
* on barge-in or reset, but the underlying request keeps going unless the body
|
|
244
|
-
* hands the signal on.
|
|
245
|
-
*/
|
|
246
|
-
export const searchTool = tool({
|
|
247
|
-
description:
|
|
248
|
-
"Search the web. Use it when the step turns on a current fact — a price, a " +
|
|
249
|
-
"date, an availability — that you do not reliably know.",
|
|
250
|
-
inputSchema: z.object({
|
|
251
|
-
query: z.string().max(120).describe("What to search for"),
|
|
252
|
-
}),
|
|
253
|
-
execute: ({ query }, ctx) => runSearch(query, { signal: ctx.signal }),
|
|
254
|
-
});
|
|
203
|
+
/** How many results one search reads. Enough to compare, short enough to hear. */
|
|
204
|
+
export const SEARCH_RESULTS = 4;
|
|
255
205
|
|
|
256
206
|
/** Characters of a page the executor is given. A step is answered from a page's
|
|
257
207
|
* substance, not from its whole text, and the rest is context it pays for. */
|
|
258
208
|
export const MAX_PAGE_CHARS = 4000;
|
|
259
209
|
|
|
260
|
-
/** One page's substance, or the refusal that stopped it being read. */
|
|
261
|
-
const readPage = failable(async (url: string, options: CallOptions = {}): Promise<string> => {
|
|
262
|
-
const page = orFail(await visitWebpage<{ content?: string; text?: string }>(url, options));
|
|
263
|
-
const body = String(page.content ?? page.text ?? "").slice(0, MAX_PAGE_CHARS);
|
|
264
|
-
return body.length > 0 ? body : "That page had no readable text.";
|
|
265
|
-
});
|
|
266
|
-
|
|
267
210
|
/**
|
|
268
|
-
* `
|
|
269
|
-
*
|
|
270
|
-
* `visitWebpage` is the second half of `@alexkroman1/aai/tools`, and the
|
|
271
|
-
* executor's prompt has always assumed it: "search once, READ what comes back"
|
|
272
|
-
* was in there while the loop offered no way to do it, so the executor answered
|
|
273
|
-
* every step from a list of titles. A subagent can hold both tools, so the
|
|
274
|
-
* instruction and the capability finally agree.
|
|
211
|
+
* The executor's `search` and `read` tools, over the web they are handed — the
|
|
212
|
+
* real one unless told otherwise.
|
|
275
213
|
*
|
|
276
|
-
*
|
|
277
|
-
*
|
|
278
|
-
*
|
|
214
|
+
* A function rather than two bare `tool()` constants for the reason
|
|
215
|
+
* {@link WebAccess} gives; the pair exported below it is what the executor
|
|
216
|
+
* holds.
|
|
279
217
|
*/
|
|
280
|
-
export
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
218
|
+
export function createWebTools(web: WebAccess = { webSearch, visitWebpage }) {
|
|
219
|
+
/**
|
|
220
|
+
* A REFUSED search is not an empty web, and `webSearch` answers with
|
|
221
|
+
* `{ error }` rather than throwing — so an unnarrowed `?? []` below would
|
|
222
|
+
* tell the executor there is nothing out there. Measured: DuckDuckGo answers
|
|
223
|
+
* `403` often enough that this is the ordinary case, not an edge one.
|
|
224
|
+
*
|
|
225
|
+
* `failable` + `orFail` is that narrowing: the refusal becomes this
|
|
226
|
+
* function's return value with the provider's own words intact. What it
|
|
227
|
+
* replaced was an `isToolFailure` check throwing a re-worded `Error`, and the
|
|
228
|
+
* rewording was the smaller half of the cost — a thrown tool error is logged
|
|
229
|
+
* by the runtime as an UNCAUGHT tool bug on its way to the model, which a 403
|
|
230
|
+
* from a free search endpoint is not.
|
|
231
|
+
*/
|
|
232
|
+
const search: SearchFn = failable(
|
|
233
|
+
async (query: string, options: CallOptions = {}): Promise<SearchHit[]> => {
|
|
234
|
+
const results = orFail(
|
|
235
|
+
await web.webSearch({
|
|
236
|
+
query,
|
|
237
|
+
maxResults: SEARCH_RESULTS,
|
|
238
|
+
...options,
|
|
239
|
+
}),
|
|
240
|
+
);
|
|
241
|
+
return (results.results ?? [])
|
|
242
|
+
.filter(
|
|
243
|
+
(one): one is { title?: string; url: string } =>
|
|
244
|
+
typeof one.url === "string" && one.url.length > 0,
|
|
245
|
+
)
|
|
246
|
+
.map((one) => ({ title: one.title || one.url, url: one.url }));
|
|
247
|
+
},
|
|
248
|
+
);
|
|
249
|
+
|
|
250
|
+
/** {@link search}, rendered for a model to reason over. */
|
|
251
|
+
const runSearch = failable(async (query: string, options: CallOptions = {}): Promise<string> => {
|
|
252
|
+
const hits = orFail(await search(query, options));
|
|
253
|
+
if (hits.length === 0) return "No results.";
|
|
254
|
+
return hits.map((hit) => `- ${hit.title} (${hit.url})`).join("\n");
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
/** One page's substance, or the refusal that stopped it being read. */
|
|
258
|
+
const readPage = failable(async (url: string, options: CallOptions = {}): Promise<string> => {
|
|
259
|
+
const page = orFail(await web.visitWebpage(url, options));
|
|
260
|
+
const body = String(page.content ?? page.text ?? "").slice(0, MAX_PAGE_CHARS);
|
|
261
|
+
return body.length > 0 ? body : "That page had no readable text.";
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
return {
|
|
265
|
+
/**
|
|
266
|
+
* `search` — the web search as a tool the EXECUTOR may call.
|
|
267
|
+
*
|
|
268
|
+
* The search is REAL: `webSearch` from `@alexkroman1/aai/tools` is the same
|
|
269
|
+
* DuckDuckGo-backed implementation behind the model-facing `web_search`
|
|
270
|
+
* builtin, with the same URL screening and size caps, and it needs no API
|
|
271
|
+
* key. Giving the subagent this rather than the builtin is what keeps that
|
|
272
|
+
* worked example alive — a subagent's `tools` are ordinary `ToolDef`s, so an
|
|
273
|
+
* agent's own code is as reachable from one as a framework builtin is.
|
|
274
|
+
*
|
|
275
|
+
* **`ctx.signal` goes down to the fetch.** A tool body gets one,
|
|
276
|
+
* `CallOptions` takes one, and until they were joined a caller who hung up
|
|
277
|
+
* mid-step left a search running against a third party — the runtime
|
|
278
|
+
* settles the tool's await on barge-in or reset, but the underlying request
|
|
279
|
+
* keeps going unless the body hands the signal on.
|
|
280
|
+
*/
|
|
281
|
+
searchTool: tool({
|
|
282
|
+
description:
|
|
283
|
+
"Search the web. Use it when the step turns on a current fact — a price, a " +
|
|
284
|
+
"date, an availability — that you do not reliably know.",
|
|
285
|
+
inputSchema: z.object({
|
|
286
|
+
query: z.string().max(120).describe("What to search for"),
|
|
287
|
+
}),
|
|
288
|
+
execute: ({ query }, ctx) => runSearch(query, { signal: ctx.signal }),
|
|
289
|
+
}),
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* `read` — open one page the search turned up.
|
|
293
|
+
*
|
|
294
|
+
* `visitWebpage` is the second half of `@alexkroman1/aai/tools`, and the
|
|
295
|
+
* executor's prompt has always assumed it: "search once, READ what comes
|
|
296
|
+
* back" was in there while the loop offered no way to do it, so the
|
|
297
|
+
* executor answered every step from a list of titles. A subagent can hold
|
|
298
|
+
* both tools, so the instruction and the capability finally agree.
|
|
299
|
+
*
|
|
300
|
+
* Answers a `ToolFailure` on a refusal for the same reason `search` does —
|
|
301
|
+
* a page that would not load is not a page that said nothing — and takes
|
|
302
|
+
* the same `CallOptions`, so a hung-up caller cancels the fetch.
|
|
303
|
+
*/
|
|
304
|
+
readTool: tool({
|
|
305
|
+
description:
|
|
306
|
+
"Open one page from a search result and read it. Prefer this over a second " +
|
|
307
|
+
"search when a result looks like it answers the step.",
|
|
308
|
+
inputSchema: z.object({
|
|
309
|
+
url: z.url().describe("The page to open, from a search result"),
|
|
310
|
+
}),
|
|
311
|
+
execute: ({ url }, ctx) => readPage(url, { signal: ctx.signal }),
|
|
312
|
+
}),
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/** The executor's two web tools, over the live web. */
|
|
317
|
+
export const { searchTool, readTool } = createWebTools();
|
|
289
318
|
|
|
290
319
|
// ─── The projection ──────────────────────────────────────────────────────────
|
|
291
320
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DeepReadonly } from "@alexkroman1/aai";
|
|
2
|
-
import { roundMoney } from "@alexkroman1/aai/utils";
|
|
2
|
+
import { omitUndefined, roundMoney } from "@alexkroman1/aai/utils";
|
|
3
3
|
import type { PendingAction } from "./pending.ts";
|
|
4
4
|
|
|
5
5
|
// ─── Store types ─────────────────────────────────────────────────────────────
|
|
@@ -461,7 +461,7 @@ export function storeView(state: FrozenRetailState): StoreView {
|
|
|
461
461
|
// though its details were already withheld from `orders`/`swapOptions`.
|
|
462
462
|
focus: {
|
|
463
463
|
...(focusedOrder && focusedOrderId ? { orderId: focusedOrderId } : {}),
|
|
464
|
-
...(
|
|
464
|
+
...omitUndefined({ productId: state.focus.productId }),
|
|
465
465
|
},
|
|
466
466
|
swapOptions: swapOptionsFor(state, focusedOrder),
|
|
467
467
|
pending:
|
|
@@ -30,7 +30,7 @@ export default retailTool({
|
|
|
30
30
|
})),
|
|
31
31
|
payment_history: order.payment_history,
|
|
32
32
|
...omitUndefined({ fulfillments: order.fulfillments }),
|
|
33
|
-
...(
|
|
33
|
+
...omitUndefined({ cancel_reason: order.cancel_reason }),
|
|
34
34
|
};
|
|
35
35
|
},
|
|
36
36
|
summary: (_args, result) => `read ${result.order_id}`,
|
|
@@ -55,7 +55,7 @@ import {
|
|
|
55
55
|
installStubUploads,
|
|
56
56
|
stubGatewayRoute,
|
|
57
57
|
} from "@alexkroman1/aai-runtime/testing/vitest";
|
|
58
|
-
import { expect } from "vitest";
|
|
58
|
+
import { assert, expect } from "vitest";
|
|
59
59
|
import agentDef, { spokenSummary } from "./agent.ts";
|
|
60
60
|
import { POLL_INTERVAL_MS } from "./workflows/transcribe.ts";
|
|
61
61
|
|
|
@@ -162,7 +162,7 @@ describeWorkflowEval(
|
|
|
162
162
|
expect(run.error).toBeUndefined();
|
|
163
163
|
expect(run.status).toBe("completed");
|
|
164
164
|
const output = run.output;
|
|
165
|
-
|
|
165
|
+
assert(output !== undefined, "a completed run must carry an output");
|
|
166
166
|
|
|
167
167
|
// EXACTLY one write. Two would mean the synthesis and the store had come
|
|
168
168
|
// apart into two steps, which is the mistake this template exists to argue
|
|
@@ -170,7 +170,7 @@ describeWorkflowEval(
|
|
|
170
170
|
// bytes do not.
|
|
171
171
|
expect(uploads.writes).toHaveLength(1);
|
|
172
172
|
const written = uploads.writes[0];
|
|
173
|
-
|
|
173
|
+
assert(written !== undefined, "the speaking step must have stored a file");
|
|
174
174
|
// The output carries the ID of that write, and an id is a string — not the
|
|
175
175
|
// audio. A run's output is read back as JSON.
|
|
176
176
|
expect(output.audio).toBe(written.id);
|
|
@@ -235,7 +235,7 @@ describeWorkflowEval(
|
|
|
235
235
|
// And the model was ASKED for both, over the transcript it was given. A
|
|
236
236
|
// prompt that stopped asking for a script is how the field goes missing.
|
|
237
237
|
const asked = model.calls[0];
|
|
238
|
-
|
|
238
|
+
assert(asked !== undefined, "the run must have asked the model for a summary");
|
|
239
239
|
expect(asked.prompt).toContain("READ ALOUD");
|
|
240
240
|
expect(asked.prompt).toContain("The launch is on for Tuesday the fourth");
|
|
241
241
|
});
|
|
@@ -316,7 +316,7 @@ describeWorkflowEval(
|
|
|
316
316
|
expect(run.error).toBeUndefined();
|
|
317
317
|
expect(run.status).toBe("completed");
|
|
318
318
|
const output = run.output;
|
|
319
|
-
|
|
319
|
+
assert(output !== undefined, "a completed run must carry an output");
|
|
320
320
|
|
|
321
321
|
// The transcript is of THIS recording — a news segment about smoke from
|
|
322
322
|
// Canadian wildfires reaching the US east coast.
|
|
@@ -344,7 +344,7 @@ describeWorkflowEval(
|
|
|
344
344
|
// The store really holds what the output names.
|
|
345
345
|
expect(uploads.writes).toHaveLength(1);
|
|
346
346
|
const stored = uploads.read(output.audio);
|
|
347
|
-
|
|
347
|
+
assert(stored !== undefined, "the run's `audio` id must name a stored file");
|
|
348
348
|
expect(String.fromCharCode(...stored.bytes.subarray(0, 4))).toBe("RIFF");
|
|
349
349
|
},
|
|
350
350
|
{ live: true },
|
|
@@ -68,8 +68,8 @@ beforeEach(() => {
|
|
|
68
68
|
{ writable: true },
|
|
69
69
|
);
|
|
70
70
|
// The step env, which is where `requireStepEnv` and `stepSpeak` read the key.
|
|
71
|
-
// `vi.stubEnv` rather than an assignment: `unstubEnvs`
|
|
72
|
-
// test, so nothing here has to remember to put it back.
|
|
71
|
+
// `vi.stubEnv` rather than an assignment: `unstubEnvs` (set by
|
|
72
|
+
// `defineAgentTestConfig`) undoes it after every test, so nothing here has to remember to put it back.
|
|
73
73
|
vi.stubEnv("ASSEMBLYAI_API_KEY", "test-key");
|
|
74
74
|
});
|
|
75
75
|
|
|
@@ -36,7 +36,7 @@ import {
|
|
|
36
36
|
installStubTranscribe,
|
|
37
37
|
installStubUploads,
|
|
38
38
|
} from "@alexkroman1/aai-runtime/testing/vitest";
|
|
39
|
-
import { expect } from "vitest";
|
|
39
|
+
import { assert, expect } from "vitest";
|
|
40
40
|
import agentDef, { transcribe } from "./agent.ts";
|
|
41
41
|
import { TRANSCRIPT_STREAM } from "./workflows/stitch.ts";
|
|
42
42
|
import { SEGMENT_SECONDS } from "./workflows/wav.ts";
|
|
@@ -122,7 +122,7 @@ describeWorkflowEval(agentDef, (test) => {
|
|
|
122
122
|
expect(run.error).toBeUndefined();
|
|
123
123
|
expect(run.status).toBe("completed");
|
|
124
124
|
const output = run.output;
|
|
125
|
-
|
|
125
|
+
assert(output !== undefined, "a completed run must carry an output");
|
|
126
126
|
|
|
127
127
|
// Three segments over 200 seconds at a 90-second stride, and the durations
|
|
128
128
|
// are the plan: each segment carries the 2-second OVERLAP that stops a cut
|
|
@@ -203,7 +203,7 @@ describeWorkflowEval(agentDef, (test) => {
|
|
|
203
203
|
expect(run.error).toBeUndefined();
|
|
204
204
|
expect(run.status).toBe("completed");
|
|
205
205
|
const output = run.output;
|
|
206
|
-
|
|
206
|
+
assert(output !== undefined, "a completed run must carry an output");
|
|
207
207
|
|
|
208
208
|
// ffmpeg ran, and the run said so before spending minutes on it.
|
|
209
209
|
expect(run.reported.some((line) => line.startsWith("Converting wildfires.mp3"))).toBe(true);
|
|
@@ -1392,7 +1392,8 @@ describe("normalizing the recording", () => {
|
|
|
1392
1392
|
// a unit test that spawns no binary. Without it a developer with ffmpeg
|
|
1393
1393
|
// installed runs a different test from CI, which has none — and the one
|
|
1394
1394
|
// assertion below that reaches `normalizeRecording` is about a reporter line
|
|
1395
|
-
// emitted BEFORE the spawn. `unstubEnvs` is
|
|
1395
|
+
// emitted BEFORE the spawn. `unstubEnvs` is in the agent test preset, so
|
|
1396
|
+
// there is no teardown.
|
|
1396
1397
|
beforeEach(() => {
|
|
1397
1398
|
vi.stubEnv("AAI_FFMPEG_PATH", "/nonexistent/ffmpeg");
|
|
1398
1399
|
vi.stubEnv("AAI_FFPROBE_PATH", "/nonexistent/ffprobe");
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* `recover.ts` matters — a page that cannot reach storage still has to render.
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
-
import {
|
|
24
|
+
import { describe, expect, test, vi } from "vitest";
|
|
25
25
|
import { type PendingNoteInput, pendingNote, recalledMode, rememberMode } from "./recover.ts";
|
|
26
26
|
|
|
27
27
|
/** The modes the page offers, in the page's own order. */
|
|
@@ -56,12 +56,9 @@ function refusingStorage() {
|
|
|
56
56
|
});
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
// owe. Without it the first file to stub storage decides every later one.
|
|
63
|
-
vi.unstubAllGlobals();
|
|
64
|
-
});
|
|
59
|
+
// No teardown: `unstubGlobals` (set by `defineAgentTestConfig`) undoes every
|
|
60
|
+
// stubbed storage after its test, so the first file to stub it cannot decide
|
|
61
|
+
// every later one.
|
|
65
62
|
|
|
66
63
|
describe("recalledMode", () => {
|
|
67
64
|
test("opens on the mode the last submission used", () => {
|
|
@@ -123,9 +123,10 @@ const ARCHIVE_URL = "https://archive.example.com/mcp";
|
|
|
123
123
|
*/
|
|
124
124
|
describe("the archive MCP server", () => {
|
|
125
125
|
afterEach(() => {
|
|
126
|
-
|
|
127
|
-
//
|
|
128
|
-
// this file's own top-level `agentDef`
|
|
126
|
+
// `unstubEnvs` puts the env back; the module registry is this file's to
|
|
127
|
+
// reset: the next spec file to load `agent.ts` must not inherit a module
|
|
128
|
+
// evaluated under a stubbed env, and this file's own top-level `agentDef`
|
|
129
|
+
// was evaluated before any stubbing.
|
|
129
130
|
vi.resetModules();
|
|
130
131
|
});
|
|
131
132
|
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
stubGenerate,
|
|
11
11
|
toolRunner,
|
|
12
12
|
} from "@alexkroman1/aai-runtime/testing";
|
|
13
|
-
import { afterEach, describe, expect, test, vi } from "vitest";
|
|
13
|
+
import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";
|
|
14
14
|
import { endsRound, gameFlow, TIME_UP_LINE } from "./game.ts";
|
|
15
15
|
import { containsWord, isCorrectGuess, normalizeWord } from "./guess.ts";
|
|
16
16
|
import { PLAYER_SYSTEM, playerPrompt } from "./player.ts";
|
|
@@ -26,6 +26,16 @@ import { allWords, pickWords, WORD_CATEGORIES } from "./words.ts";
|
|
|
26
26
|
|
|
27
27
|
// ─── Harness ─────────────────────────────────────────────────────────────────
|
|
28
28
|
|
|
29
|
+
// `start_game` arms a two-minute `setTimeout` (`armTimeUpLine`). Faked for every
|
|
30
|
+
// test so a round a test opens and abandons leaves no real timer behind; the
|
|
31
|
+
// clock itself stays real. Section 4 drives the fake clock on purpose.
|
|
32
|
+
beforeEach(() => {
|
|
33
|
+
vi.useFakeTimers({ toFake: ["setTimeout", "clearTimeout"] });
|
|
34
|
+
});
|
|
35
|
+
afterEach(() => {
|
|
36
|
+
vi.useRealTimers();
|
|
37
|
+
});
|
|
38
|
+
|
|
29
39
|
/** A tool by the name the model calls it by, bound to this agent. */
|
|
30
40
|
const run = toolRunner(agentDef);
|
|
31
41
|
|
|
@@ -91,10 +101,6 @@ async function startRound(ctx: ToolContext): Promise<string> {
|
|
|
91
101
|
return word;
|
|
92
102
|
}
|
|
93
103
|
|
|
94
|
-
afterEach(() => {
|
|
95
|
-
vi.restoreAllMocks();
|
|
96
|
-
});
|
|
97
|
-
|
|
98
104
|
// ─── 1. The referee ──────────────────────────────────────────────────────────
|
|
99
105
|
|
|
100
106
|
describe("guess.ts", () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alexkroman1/aai-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -57,9 +57,9 @@
|
|
|
57
57
|
"p-timeout": "^7.0.2",
|
|
58
58
|
"vite": "^8.3.1",
|
|
59
59
|
"zod": "^4.6.5",
|
|
60
|
-
"@alexkroman1/aai": "0.
|
|
61
|
-
"@alexkroman1/aai-runtime": "0.
|
|
62
|
-
"@alexkroman1/aai-ui": "0.
|
|
60
|
+
"@alexkroman1/aai": "0.14.0",
|
|
61
|
+
"@alexkroman1/aai-runtime": "0.14.0",
|
|
62
|
+
"@alexkroman1/aai-ui": "0.14.0"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"playwright": "^1.63.0",
|
|
@@ -85,8 +85,8 @@
|
|
|
85
85
|
"lint": "biome check .",
|
|
86
86
|
"test": "vitest run",
|
|
87
87
|
"test:coverage": "vitest run --coverage",
|
|
88
|
-
"test:e2e": "
|
|
89
|
-
"test:scenario": "
|
|
88
|
+
"test:e2e": "vitest run -c ../../vitest.slow.config.ts --project e2e",
|
|
89
|
+
"test:scenario": "vitest run -c ../../vitest.slow.config.ts --project scenario",
|
|
90
90
|
"typecheck": "tsc --noEmit"
|
|
91
91
|
}
|
|
92
92
|
}
|