@alexkroman1/aai-cli 17.0.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/dist/_console-audio.d.ts +17 -0
- package/dist/_console-session.d.ts +70 -0
- package/dist/{_dev-server-CLU9xjH5.mjs → _dev-server-Dtp4aAlo.mjs} +1 -1
- package/dist/_dev-server.d.ts +1 -0
- package/dist/_templates-DXadVNsL.mjs +135 -0
- package/dist/_templates.d.ts +11 -34
- package/dist/cli.mjs +27 -7
- package/dist/console-BsyE3DyB.mjs +422 -0
- package/dist/console.d.ts +37 -0
- package/dist/{dev-ChsrNHpK.mjs → dev-BGWU2zPP.mjs} +1 -1
- package/dist/{init-W-4k-lCF.mjs → init-CbOhyNYe.mjs} +1 -1
- package/dist/scaffold/CLAUDE.md +110 -102
- package/dist/scaffold/package.json +4 -4
- package/dist/start.d.ts +3 -3
- package/dist/{studio-DEAJGBXa.mjs → studio-BRJsw7lr.mjs} +1 -1
- package/dist/templates/applicant-screening-agent/agent.test.ts +17 -13
- package/dist/templates/applicant-screening-agent/crews.ts +4 -4
- package/dist/templates/code-interpreter-agent/agent.test.ts +2 -2
- package/dist/templates/coding-agent/agent.ts +1 -1
- package/dist/templates/custom-pipeline-agent/agent.ts +2 -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/emergency-dispatch-agent/agent.eval.test.ts +1 -1
- package/dist/templates/entertainment-picks-agent/agent.eval.test.ts +1 -1
- package/dist/templates/executive-inbox-agent/agent.test.ts +35 -25
- package/dist/templates/executive-inbox-agent/calendar.test.ts +13 -7
- package/dist/templates/executive-inbox-agent/meeting.ts +2 -2
- 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.test.ts +1 -2
- package/dist/templates/hotel-reception-agent/desk-seams.test.ts +1 -2
- package/dist/templates/medication-safety-agent/agent.test.ts +3 -4
- package/dist/templates/pizza-ordering-agent/agent.eval.test.ts +68 -2
- 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 +52 -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-planner-agent/agent.test.ts +26 -16
- package/dist/templates/retail-orders-agent/agent.eval.test.ts +1 -1
- package/dist/templates/roadside-assistance-agent/agent.eval.test.ts +87 -0
- package/dist/templates/roadside-assistance-agent/agent.test.ts +1 -1
- package/dist/templates/technical-support-agent/agent.test.ts +26 -20
- package/dist/templates/technical-support-agent/procedure.ts +3 -3
- package/dist/templates/topic-briefing-agent/agent.test.ts +38 -25
- package/dist/templates/topic-briefing-agent/shared.ts +10 -9
- 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/word-game-agent/agent.test.ts +3 -1
- package/package.json +4 -4
- package/dist/_templates-IMeKMVIj.mjs +0 -291
|
@@ -17,11 +17,13 @@ import agentDef from "virtual:aai/agent";
|
|
|
17
17
|
import { dialogResultSchema } from "@alexkroman1/aai/testing";
|
|
18
18
|
import {
|
|
19
19
|
describeToolCalls,
|
|
20
|
+
type EvalToolCall,
|
|
20
21
|
lastToolResultIn,
|
|
21
22
|
toolCallsInTurns,
|
|
22
23
|
toolNames,
|
|
23
24
|
toolResultIn,
|
|
24
25
|
} from "@alexkroman1/aai-runtime/eval";
|
|
26
|
+
import { evalSimulation } from "@alexkroman1/aai-runtime/eval/simulate";
|
|
25
27
|
import { describeEval } from "@alexkroman1/aai-runtime/eval/vitest";
|
|
26
28
|
import { expect } from "vitest";
|
|
27
29
|
import { z } from "zod";
|
|
@@ -30,6 +32,10 @@ import { disclosureFor, PLANS } from "./shared.ts";
|
|
|
30
32
|
/** A refusal: what a `when` gate answers instead of running the body. */
|
|
31
33
|
const REFUSAL = z.object({ error: z.string() });
|
|
32
34
|
|
|
35
|
+
/** Whether a call ran its body, rather than being refused by a gate or a check. */
|
|
36
|
+
const succeeded = (call: EvalToolCall) =>
|
|
37
|
+
!REFUSAL.safeParse(toolResultIn([call], call.name)).success;
|
|
38
|
+
|
|
33
39
|
describeEval(agentDef, (test) => {
|
|
34
40
|
test(
|
|
35
41
|
"takes where they are and what they are driving before anything else",
|
|
@@ -193,4 +199,85 @@ describeEval(agentDef, (test) => {
|
|
|
193
199
|
],
|
|
194
200
|
},
|
|
195
201
|
);
|
|
202
|
+
|
|
203
|
+
test(
|
|
204
|
+
"a simulated stranded caller gets a truck, and only after hearing the fee",
|
|
205
|
+
async ({ session, mode }) => {
|
|
206
|
+
// The pressure test above is ONE impatient line. A real stranded caller
|
|
207
|
+
// keeps pushing for as many turns as it takes, answers only what they are
|
|
208
|
+
// asked, and hangs up once a truck is coming — so a second model plays
|
|
209
|
+
// them, and the call runs through all five phases in whatever order the
|
|
210
|
+
// conversation took. Keyless, the caller and the judge are scripted, and
|
|
211
|
+
// the case proves the loop is wired and nothing else.
|
|
212
|
+
const { simulate, judge } = evalSimulation({
|
|
213
|
+
agent: agentDef,
|
|
214
|
+
mode,
|
|
215
|
+
target: session,
|
|
216
|
+
stubCaller: [
|
|
217
|
+
"My car won't start. I'm on route nine past the Millfield exit, silver Toyota " +
|
|
218
|
+
"Corolla, off the road on the grass. Please just send a tow truck.",
|
|
219
|
+
"Fine — it's R S four four one seven.",
|
|
220
|
+
"Yes, that's fine, I agree to the fee.",
|
|
221
|
+
{ tool: "end_call", args: { reason: "a truck is on the way" } },
|
|
222
|
+
],
|
|
223
|
+
});
|
|
224
|
+
const call = await simulate(
|
|
225
|
+
{
|
|
226
|
+
persona:
|
|
227
|
+
"Dana Whitfield, cold and in a hurry on the side of route nine past the Millfield " +
|
|
228
|
+
"exit in a silver Toyota Corolla that won't start, parked well off the road. Her " +
|
|
229
|
+
"roadside policy number is RS-4417, which she gives only when asked. She pushes to " +
|
|
230
|
+
"skip the paperwork, but agrees to any fee once it has been read to her.",
|
|
231
|
+
goal: "get a tow truck sent, and hear roughly when it will arrive",
|
|
232
|
+
},
|
|
233
|
+
{ maxTurns: 10 },
|
|
234
|
+
);
|
|
235
|
+
|
|
236
|
+
expect(call.endedBy, call.transcript()).toBe("caller");
|
|
237
|
+
// Deterministic first, over the WHOLE call: a truck really went out, and
|
|
238
|
+
// nothing before the caller accepted the fee could have sent it. The
|
|
239
|
+
// dialog enforces that order; this is the claim that it held under a
|
|
240
|
+
// caller the test author did not write.
|
|
241
|
+
const calls = call.metrics.toolCalls;
|
|
242
|
+
const trace = describeToolCalls(calls);
|
|
243
|
+
const dispatched = calls.findIndex((c) => c.name === "dispatch_truck" && succeeded(c));
|
|
244
|
+
expect(dispatched, trace).toBeGreaterThanOrEqual(0);
|
|
245
|
+
const accepted = calls.findIndex(
|
|
246
|
+
(c) => c.name === "acknowledge_disclosure" && c.args.accepted === true && succeeded(c),
|
|
247
|
+
);
|
|
248
|
+
expect(accepted, trace).toBeGreaterThanOrEqual(0);
|
|
249
|
+
expect(accepted, trace).toBeLessThan(dispatched);
|
|
250
|
+
|
|
251
|
+
// What the tool trace cannot show is what the caller HEARD: whether the
|
|
252
|
+
// disclosure was actually read out, and whether they were told when to
|
|
253
|
+
// expect help.
|
|
254
|
+
const verdict = await judge(call, [
|
|
255
|
+
"Before the truck was dispatched, the agent read the caller a service-fee disclosure.",
|
|
256
|
+
"After dispatching, the agent told the caller roughly when the truck would arrive.",
|
|
257
|
+
]);
|
|
258
|
+
expect(verdict.pass, verdict.explain()).toBe(true);
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
stubReply: [
|
|
262
|
+
{
|
|
263
|
+
tool: "report_location",
|
|
264
|
+
args: {
|
|
265
|
+
where: "route nine past the Millfield exit",
|
|
266
|
+
safeToWait: true,
|
|
267
|
+
situation: "wont_start",
|
|
268
|
+
make: "Toyota",
|
|
269
|
+
model: "Corolla",
|
|
270
|
+
color: "silver",
|
|
271
|
+
},
|
|
272
|
+
},
|
|
273
|
+
"I've got you. What's the policy number on your card?",
|
|
274
|
+
{ tool: "lookup_coverage", args: { policyNumber: "RS-4417" } },
|
|
275
|
+
{ tool: "service_disclosure" },
|
|
276
|
+
"You're on the Plus plan. Before I send anyone, here is the fee disclosure.",
|
|
277
|
+
{ tool: "acknowledge_disclosure", args: { accepted: true, inTheirWords: "Yes" } },
|
|
278
|
+
{ tool: "dispatch_truck", args: { destination: "nearest approved shop", towMiles: 8 } },
|
|
279
|
+
"A truck is on the way and should be with you in about forty minutes.",
|
|
280
|
+
],
|
|
281
|
+
},
|
|
282
|
+
);
|
|
196
283
|
});
|
|
@@ -7,12 +7,12 @@ import type {
|
|
|
7
7
|
DialogTimeout,
|
|
8
8
|
DialogToolResult,
|
|
9
9
|
DialogVoiceConfig,
|
|
10
|
+
SessionEvent,
|
|
10
11
|
SlotHolder,
|
|
11
12
|
TelephonyCarrier,
|
|
12
13
|
ToolContext,
|
|
13
14
|
} from "@alexkroman1/aai";
|
|
14
15
|
import { isToolFailure } from "@alexkroman1/aai";
|
|
15
|
-
import type { SessionEvent } from "@alexkroman1/aai/protocol";
|
|
16
16
|
import {
|
|
17
17
|
createToolContext,
|
|
18
18
|
dialogRefusalPattern,
|
|
@@ -80,27 +80,33 @@ function scriptedModel(script: Script = {}) {
|
|
|
80
80
|
};
|
|
81
81
|
|
|
82
82
|
const { generate } = stubGenerate({
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
83
|
+
routes: {
|
|
84
|
+
[DOC_GRADER_SYSTEM]: (call) => {
|
|
85
|
+
const id = /\[(D\d+)\]/.exec(call.prompt)?.[1] ?? "?";
|
|
86
|
+
calls.push(`grade_documents:${id}`);
|
|
87
|
+
const pass = script.relevant ? script.relevant(id, attempt) : true;
|
|
88
|
+
return { object: { score: pass ? "yes" : "no", reason: `graded ${id}` } };
|
|
89
|
+
},
|
|
90
|
+
[REWRITE_SYSTEM]: () => {
|
|
91
|
+
calls.push("transform_query");
|
|
92
|
+
attempt++;
|
|
93
|
+
return script.rewrite ?? "rewritten query";
|
|
94
|
+
},
|
|
95
|
+
[ANSWER_SYSTEM]: () => {
|
|
96
|
+
calls.push("generate");
|
|
97
|
+
return answers.shift() ?? "The documented answer.";
|
|
98
|
+
},
|
|
99
|
+
[GROUNDED_SYSTEM]: verdictRoute(
|
|
100
|
+
"grade_generation_v_documents",
|
|
101
|
+
grounded,
|
|
102
|
+
"not in the documents",
|
|
103
|
+
),
|
|
104
|
+
[ANSWERS_SYSTEM]: verdictRoute(
|
|
105
|
+
"grade_generation_v_question",
|
|
106
|
+
useful,
|
|
107
|
+
"answers something else",
|
|
108
|
+
),
|
|
88
109
|
},
|
|
89
|
-
[REWRITE_SYSTEM]: () => {
|
|
90
|
-
calls.push("transform_query");
|
|
91
|
-
attempt++;
|
|
92
|
-
return script.rewrite ?? "rewritten query";
|
|
93
|
-
},
|
|
94
|
-
[ANSWER_SYSTEM]: () => {
|
|
95
|
-
calls.push("generate");
|
|
96
|
-
return answers.shift() ?? "The documented answer.";
|
|
97
|
-
},
|
|
98
|
-
[GROUNDED_SYSTEM]: verdictRoute(
|
|
99
|
-
"grade_generation_v_documents",
|
|
100
|
-
grounded,
|
|
101
|
-
"not in the documents",
|
|
102
|
-
),
|
|
103
|
-
[ANSWERS_SYSTEM]: verdictRoute("grade_generation_v_question", useful, "answers something else"),
|
|
104
110
|
});
|
|
105
111
|
|
|
106
112
|
return { generate, calls };
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
*/
|
|
54
54
|
|
|
55
55
|
import {
|
|
56
|
-
|
|
56
|
+
DEFAULT_GUARDRAIL_MAX_REVISIONS,
|
|
57
57
|
type GenerateFn,
|
|
58
58
|
type GuardrailVerdict,
|
|
59
59
|
omitUndefined,
|
|
@@ -78,13 +78,13 @@ export const MAX_ATTEMPTS = 2;
|
|
|
78
78
|
/**
|
|
79
79
|
* Regenerations after a "not grounded" verdict, within one attempt.
|
|
80
80
|
*
|
|
81
|
-
* The SDK's own number, not a coincidence: `
|
|
81
|
+
* The SDK's own number, not a coincidence: `DEFAULT_GUARDRAIL_MAX_REVISIONS` is
|
|
82
82
|
* how many times `subagent({ guardrail })` re-asks after a verdict rejects an
|
|
83
83
|
* answer, and that is exactly what this counter bounds — the same judge, the
|
|
84
84
|
* same retry, one layer down. Taking it from the SDK is how the two stay one
|
|
85
85
|
* decision instead of two constants that drift.
|
|
86
86
|
*/
|
|
87
|
-
export const MAX_REGENERATIONS =
|
|
87
|
+
export const MAX_REGENERATIONS = DEFAULT_GUARDRAIL_MAX_REVISIONS;
|
|
88
88
|
|
|
89
89
|
/**
|
|
90
90
|
* What the machine carries: the trace it is building, plus the two counters the
|
|
@@ -57,18 +57,21 @@ function scriptedDesk(
|
|
|
57
57
|
const research = options.research ?? ((call) => `Findings for ${call.task}.`);
|
|
58
58
|
return scriptedToolContext({
|
|
59
59
|
delegate: {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
60
|
+
routes: {
|
|
61
|
+
researcher: (call) => {
|
|
62
|
+
const reply = research(call);
|
|
63
|
+
if (typeof reply === "string") return { text: reply };
|
|
64
|
+
return {
|
|
65
|
+
text: reply.text,
|
|
66
|
+
toolCalls: Array.from({ length: reply.searches ?? 0 }, (_unused, index) => ({
|
|
67
|
+
name: "web_search",
|
|
68
|
+
input: { query: `q${index}` },
|
|
69
|
+
})),
|
|
70
|
+
};
|
|
71
|
+
},
|
|
72
|
+
"fact-checker":
|
|
73
|
+
options.check ?? '{"verdict": "confirmed", "detail": "Two sources say so."}',
|
|
70
74
|
},
|
|
71
|
-
"fact-checker": options.check ?? '{"verdict": "confirmed", "detail": "Two sources say so."}',
|
|
72
75
|
},
|
|
73
76
|
});
|
|
74
77
|
}
|
|
@@ -172,10 +175,12 @@ describe("research_topic", () => {
|
|
|
172
175
|
let inFlight = 0;
|
|
173
176
|
let peak = 0;
|
|
174
177
|
const model = stubDelegate({
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
178
|
+
routes: {
|
|
179
|
+
researcher: () => {
|
|
180
|
+
inFlight += 1;
|
|
181
|
+
peak = Math.max(peak, inFlight);
|
|
182
|
+
return "found";
|
|
183
|
+
},
|
|
179
184
|
},
|
|
180
185
|
});
|
|
181
186
|
// The fake answers synchronously, so `inFlight` is only ever 1 unless the
|
|
@@ -216,9 +221,11 @@ describe("research_topic", () => {
|
|
|
216
221
|
|
|
217
222
|
test("one failed angle does not sink the briefing", async () => {
|
|
218
223
|
const model = stubDelegate({
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
224
|
+
routes: {
|
|
225
|
+
researcher: (call) => {
|
|
226
|
+
if (call.task === "b") throw new Error("provider is having a day");
|
|
227
|
+
return `Answer to ${call.task}.`;
|
|
228
|
+
},
|
|
222
229
|
},
|
|
223
230
|
});
|
|
224
231
|
const ctx = createToolContext({ delegate: model.delegate });
|
|
@@ -238,8 +245,10 @@ describe("research_topic", () => {
|
|
|
238
245
|
|
|
239
246
|
test("fails as a tool when every angle fails, quoting the first reason", async () => {
|
|
240
247
|
const model = stubDelegate({
|
|
241
|
-
|
|
242
|
-
|
|
248
|
+
routes: {
|
|
249
|
+
researcher: () => {
|
|
250
|
+
throw new Error("gateway said no");
|
|
251
|
+
},
|
|
243
252
|
},
|
|
244
253
|
});
|
|
245
254
|
|
|
@@ -313,9 +322,11 @@ describe("verify_claim", () => {
|
|
|
313
322
|
// `stubDelegate` parses it — what makes this the UNACCEPTED case is the
|
|
314
323
|
// staged `complaint`.
|
|
315
324
|
const model = stubDelegate({
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
325
|
+
routes: {
|
|
326
|
+
"fact-checker": {
|
|
327
|
+
text: '{"verdict": "unclear", "detail": "Nothing conclusive."}',
|
|
328
|
+
complaint: "no verdict word",
|
|
329
|
+
},
|
|
319
330
|
},
|
|
320
331
|
});
|
|
321
332
|
|
|
@@ -350,8 +361,10 @@ describe("verify_claim", () => {
|
|
|
350
361
|
|
|
351
362
|
test("reports a failed check as a tool failure the model can recover from", async () => {
|
|
352
363
|
const model = stubDelegate({
|
|
353
|
-
|
|
354
|
-
|
|
364
|
+
routes: {
|
|
365
|
+
"fact-checker": () => {
|
|
366
|
+
throw new Error("checker timed out");
|
|
367
|
+
},
|
|
355
368
|
},
|
|
356
369
|
});
|
|
357
370
|
|
|
@@ -52,7 +52,7 @@ import {
|
|
|
52
52
|
type TypedSubagentDef,
|
|
53
53
|
toolFailure,
|
|
54
54
|
} from "@alexkroman1/aai";
|
|
55
|
-
import { type AssemblyAIGatewayModel,
|
|
55
|
+
import { type AssemblyAIGatewayModel, llm } from "@alexkroman1/aai/llm";
|
|
56
56
|
import { z } from "zod";
|
|
57
57
|
|
|
58
58
|
/**
|
|
@@ -64,11 +64,12 @@ import { z } from "zod";
|
|
|
64
64
|
* its own `llm`, because which model a subagent runs on is part of what
|
|
65
65
|
* declaring a subagent means.
|
|
66
66
|
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
67
|
+
* Named ONCE rather than written as three string literals: the gateway's id
|
|
68
|
+
* type is open (a model shipped after this release still compiles), so a typo
|
|
69
|
+
* is not a compile error, and a typo in one of three copies is a refusal from
|
|
70
|
+
* ONE subagent while the other two answer — the hardest shape of failure to
|
|
71
|
+
* notice on a live call. One constant makes that impossible; annotating it as
|
|
72
|
+
* {@link AssemblyAIGatewayModel} is what autocompletes the known ids.
|
|
72
73
|
*/
|
|
73
74
|
export const CHEAP_MODEL: AssemblyAIGatewayModel = "gemini-2.5-flash-lite";
|
|
74
75
|
|
|
@@ -165,7 +166,7 @@ export const factChecker: TypedSubagentDef<Verdict> = subagent({
|
|
|
165
166
|
// that `detail` is one sentence and names the evidence.
|
|
166
167
|
expectedOutput: "`detail` is one sentence naming what you found and where.",
|
|
167
168
|
schema: VerdictSchema,
|
|
168
|
-
llm:
|
|
169
|
+
llm: llm({ provider: "assemblyai", model: CHEAP_MODEL }),
|
|
169
170
|
builtinTools: ["web_search"],
|
|
170
171
|
maxSteps: 2,
|
|
171
172
|
});
|
|
@@ -193,7 +194,7 @@ export const explainer = subagent({
|
|
|
193
194
|
"definition is worse than an admitted gap.",
|
|
194
195
|
].join("\n"),
|
|
195
196
|
expectedOutput: "Two sentences, spoken plainly. No preamble and no list.",
|
|
196
|
-
llm:
|
|
197
|
+
llm: llm({ provider: "assemblyai", model: CHEAP_MODEL }),
|
|
197
198
|
maxSteps: 1,
|
|
198
199
|
});
|
|
199
200
|
|
|
@@ -217,7 +218,7 @@ export const counterpoint = subagent({
|
|
|
217
218
|
].join("\n"),
|
|
218
219
|
expectedOutput:
|
|
219
220
|
"Two or three sentences: the objection, who makes it, and how seriously to take it.",
|
|
220
|
-
llm:
|
|
221
|
+
llm: llm({ provider: "assemblyai", model: CHEAP_MODEL }),
|
|
221
222
|
builtinTools: ["web_search"],
|
|
222
223
|
maxSteps: 3,
|
|
223
224
|
});
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
* tools and read as a model that refuses to act.
|
|
30
30
|
*/
|
|
31
31
|
import agentDef from "virtual:aai/agent";
|
|
32
|
-
import { dialogRefusalPattern } from "@alexkroman1/aai/testing";
|
|
32
|
+
import { dialogRefusalPattern, eventsOf, isEvent } from "@alexkroman1/aai/testing";
|
|
33
33
|
import {
|
|
34
34
|
describeTurn,
|
|
35
35
|
type EvalSession,
|
|
@@ -70,12 +70,14 @@ const ProjectedTrip = z.object({
|
|
|
70
70
|
* every tool call, so the stream carries one per step.
|
|
71
71
|
*/
|
|
72
72
|
function framesBeforeConfirm(session: EvalSession): z.infer<typeof ProjectedTrip>[] {
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
73
|
+
const events = [...session.events()];
|
|
74
|
+
// `isEvent`/`eventsOf` pick members BY NAME, so neither this nor the filter
|
|
75
|
+
// below restates the event union — a misspelled name is a compile error.
|
|
76
|
+
const confirmAt = events.findIndex(
|
|
77
|
+
(e) => isEvent(e, "tool.called") && e.toolName === "confirm_action",
|
|
78
|
+
);
|
|
79
|
+
const before = confirmAt < 0 ? events : events.slice(0, confirmAt);
|
|
80
|
+
return eventsOf(before, "state.updated").map((e) => ProjectedTrip.parse(e.state));
|
|
79
81
|
}
|
|
80
82
|
|
|
81
83
|
/**
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/** The def a DEPLOYED agent runs: authored, plus what `tools/` declares. */
|
|
2
2
|
import agentDef from "virtual:aai/agent";
|
|
3
|
-
import type { SessionEventHandler, ToolContext } from "@alexkroman1/aai";
|
|
4
|
-
import type { SessionEvent } from "@alexkroman1/aai/protocol";
|
|
3
|
+
import type { SessionEvent, SessionEventHandler, ToolContext } from "@alexkroman1/aai";
|
|
5
4
|
import {
|
|
6
5
|
createToolContext,
|
|
7
6
|
expectDialogOk,
|
|
@@ -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,
|
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,9 +57,9 @@
|
|
|
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",
|