@alexkroman1/aai-cli 0.14.2 → 0.14.4

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.
@@ -657,7 +657,7 @@ function devProxyTable(target, viteRoot) {
657
657
  * to ONE non-loopback interface was unreachable through the proxy before this and
658
658
  * still is.
659
659
  */
660
- function viteDevConfig(cwd, vitePort, backendPort, clientPlugins = []) {
660
+ function viteDevConfig(cwd, vitePort, backendPort, clientPlugins = [], publicUrl) {
661
661
  const target = `http://127.0.0.1:${backendPort}`;
662
662
  const viteRoot = path.resolve(cwd);
663
663
  const devSource = devSourceViteConfig();
@@ -673,10 +673,20 @@ function viteDevConfig(cwd, vitePort, backendPort, clientPlugins = []) {
673
673
  port: vitePort,
674
674
  strictPort: true,
675
675
  host: devBindHost() ?? DEFAULT_LISTEN_HOST,
676
+ ...omitUndefined({ allowedHosts: publicHost(publicUrl) }),
676
677
  proxy: devProxyTable(target, viteRoot)
677
678
  }
678
679
  };
679
680
  }
681
+ /** The hostname of a public URL as Vite's `allowedHosts`, or nothing to add. */
682
+ function publicHost(publicUrl) {
683
+ if (!publicUrl) return void 0;
684
+ try {
685
+ return [new URL(publicUrl).hostname];
686
+ } catch {
687
+ return;
688
+ }
689
+ }
680
690
  //#endregion
681
691
  //#region src/_dev-watch.ts
682
692
  /**
@@ -888,7 +898,7 @@ async function startDevServer(opts, seams = {}) {
888
898
  boundServer = initialServer;
889
899
  if (hasClient) {
890
900
  const clientPlugins = await defaultClientPlugins(cwd) ?? [];
891
- viteServer = await io.createViteServer(viteDevConfig(cwd, vitePort, backendPort, clientPlugins));
901
+ viteServer = await io.createViteServer(viteDevConfig(cwd, vitePort, backendPort, clientPlugins, process.env.PUBLIC_URL?.trim()));
892
902
  await viteServer.listen();
893
903
  viteServer.httpServer?.on("error", (err) => {
894
904
  ui.notify("error", `Vite dev server error: ${errorMessage$1(err)}`);
@@ -97,4 +97,10 @@ export declare function viteDevConfig(cwd: string, vitePort: number, backendPort
97
97
  * The client plugins when the project has no `vite.config.*` of its own
98
98
  * (`defaultClientPlugins`); empty when Vite loads the project's config.
99
99
  */
100
- clientPlugins?: import("vite").PluginOption[]): import("vite").InlineConfig;
100
+ clientPlugins?: import("vite").PluginOption[],
101
+ /**
102
+ * `PUBLIC_URL` (set by `--tunnel`): its host is the one non-loopback name
103
+ * Vite must answer. Vite 403s any other `Host` header, so without it a tunnel
104
+ * — and every webhook through it — is blocked before reaching the proxy.
105
+ */
106
+ publicUrl?: string): import("vite").InlineConfig;
package/dist/cli.mjs CHANGED
@@ -892,7 +892,7 @@ const dev = defineExec({
892
892
  },
893
893
  cwd: "agent",
894
894
  async run({ args, cwd, ui }) {
895
- const { executeDev } = await import("./dev-CWCsHFBX.mjs");
895
+ const { executeDev } = await import("./dev-CsdCGy8U.mjs");
896
896
  return executeDev({
897
897
  cwd,
898
898
  port: args.port,
@@ -913,7 +913,7 @@ const consoleCommand = defineExec({
913
913
  } },
914
914
  cwd: "agent",
915
915
  async run({ args, cwd, mode, ui }) {
916
- const { executeConsole } = await import("./console-B318NbnN.mjs");
916
+ const { executeConsole } = await import("./console-tRZbtiDe.mjs");
917
917
  return executeConsole({
918
918
  cwd,
919
919
  verbose: args.verbose,
@@ -3,7 +3,7 @@ import { a as ok, n as fail } from "./_output-DBP9Op_d.mjs";
3
3
  import { t as defaultUi } from "./_ui-Coe0zwmm.mjs";
4
4
  import { o as errorDetail, s as errorMessage } from "./_utils-BVLdBvdT.mjs";
5
5
  import { n as createWorkerEvaluator } from "./_bundler-B6v31ROV.mjs";
6
- import { loadWorker, t as resolveAgentEnv } from "./_dev-server-Cy-Mmetk.mjs";
6
+ import { loadWorker, t as resolveAgentEnv } from "./_dev-server-BVADkK1M.mjs";
7
7
  import { styleText } from "node:util";
8
8
  import { spawn } from "node:child_process";
9
9
  import { connectSession, createRuntime, ensureSessionStateSchema, ensureWorkflowJournalSchema } from "@alexkroman1/aai-runtime";
@@ -164,7 +164,7 @@ async function resolveDevDeps(deps) {
164
164
  ui: deps.ui ?? defaultUi,
165
165
  startQuickTunnel: deps.startQuickTunnel ?? startQuickTunnel,
166
166
  runPublicUrlHook: deps.runPublicUrlHook ?? runPublicUrlHook,
167
- startDevServer: deps.startDevServer ?? (await import("./_dev-server-Cy-Mmetk.mjs")).startDevServer
167
+ startDevServer: deps.startDevServer ?? (await import("./_dev-server-BVADkK1M.mjs")).startDevServer
168
168
  };
169
169
  }
170
170
  /**
@@ -15,10 +15,10 @@
15
15
  "publish:agent": "aai publish"
16
16
  },
17
17
  "dependencies": {
18
- "@alexkroman1/aai": "^0.14.2",
19
- "@alexkroman1/aai-cli": "^0.14.2",
20
- "@alexkroman1/aai-runtime": "^0.14.2",
21
- "@alexkroman1/aai-ui": "^0.14.2",
18
+ "@alexkroman1/aai": "^0.14.4",
19
+ "@alexkroman1/aai-cli": "^0.14.4",
20
+ "@alexkroman1/aai-runtime": "^0.14.4",
21
+ "@alexkroman1/aai-ui": "^0.14.4",
22
22
  "react": "^19.3.0",
23
23
  "react-dom": "^19.3.0",
24
24
  "tailwindcss": "^4.0.0",
@@ -0,0 +1,136 @@
1
+ // Copyright 2026 the AAI authors. MIT license.
2
+ // An EVAL: does the caller actually behave on a call? Run it with `aai eval`.
3
+ //
4
+ // `agent.test.ts` drives the API, the brief, the hand-over and the run. What
5
+ // none of that can say is whether the AGENT — a model reading
6
+ // `system-prompt.md` plus the task the call carried — opens the way an
7
+ // outbound caller should, stays inside the options it was given, and hangs up
8
+ // when it is done. Each case here is a placed call: `describeEval`'s `call` is
9
+ // the record a carrier's `start` frame produces, put through the runtime's own
10
+ // `sessionContext` step, so the brief is VERIFIED and handed to the session
11
+ // exactly as on a real call.
12
+ //
13
+ // Keyless, the model is SCRIPTED (each case's `stubReply`): that proves the
14
+ // wiring — the brief verifies, `end_call` is a tool the session can reach and
15
+ // it really hangs up — and nothing about what the agent says.
16
+ //
17
+ // What no eval here can see: anything below the audio boundary, the carrier,
18
+ // or the run that dialled. Those are the specs' and a real call's.
19
+
20
+ /**
21
+ * The def a DEPLOYED agent runs: authored, plus what `tools/` and
22
+ * `system-prompt.md` declare — `./agent.ts` alone has no `end_call`.
23
+ */
24
+ import agentDef from "virtual:aai/agent";
25
+ import { describeEval, toolArgsIn, toolNames } from "@alexkroman1/aai-runtime/testing/vitest";
26
+ import { expect } from "vitest";
27
+ import { signCall } from "./call-params.ts";
28
+
29
+ const SECRET = "eval-calls-key";
30
+ const PROMPT =
31
+ "Call Maria for Mission Dental to confirm her cleaning tomorrow at 2:30pm. " +
32
+ "If she needs to reschedule, offer Thursday at 10am or Friday at 4pm. " +
33
+ "If you get voicemail, ask her to call 415-555-0100.";
34
+
35
+ const parameters = await signCall({ id: "call_eval", prompt: PROMPT }, SECRET);
36
+
37
+ describeEval(
38
+ agentDef,
39
+ (test) => {
40
+ test(
41
+ "answers the callee's hello with who it is calling for, and why",
42
+ async ({ session }) => {
43
+ expect(session.refused).toBeUndefined();
44
+ const turn = await session.say("Hello?");
45
+
46
+ expect(turn.completed).toBe(true);
47
+ expect(turn.text).toMatch(/mission dental/i);
48
+ expect(turn.toolCalls).toEqual([]);
49
+ },
50
+ {
51
+ stubReply:
52
+ "Hi, is this Maria? I'm calling from Mission Dental about your cleaning tomorrow at 2:30.",
53
+ },
54
+ );
55
+
56
+ test(
57
+ "offers only the times it was given, and hangs up once it is settled",
58
+ async ({ session }) => {
59
+ await session.say("Hello?");
60
+ const offer = await session.say(
61
+ "Yes, this is Maria. Something came up at work — anything later this week?",
62
+ );
63
+ expect(offer.text).toMatch(/thursday/i);
64
+ expect(offer.text).toMatch(/friday/i);
65
+
66
+ const done = await session.say("Thursday at 10 works. Thanks, bye!");
67
+ expect(toolNames(done.toolCalls)).toContain("end_call");
68
+ expect(toolArgsIn(done.toolCalls, "end_call")[0]).toMatchObject({ reached: "person" });
69
+ expect(done.endedSession).toBe(true);
70
+ },
71
+ {
72
+ stubReply: [
73
+ "Hi, is this Maria? I'm calling from Mission Dental about your cleaning tomorrow at 2:30.",
74
+ "No problem. I have Thursday at 10am or Friday at 4pm.",
75
+ { tool: "end_call", args: { reached: "person" } },
76
+ "You're booked for Thursday at 10am. Goodbye!",
77
+ ],
78
+ },
79
+ );
80
+
81
+ test(
82
+ "answers a phone menu by pressing the key toward the callee, saying nothing",
83
+ async ({ session }) => {
84
+ const turn = await session.say(
85
+ "Thanks for calling. To leave a message for Maria, press 1. For all other calls, press 0.",
86
+ );
87
+ expect(toolArgsIn(turn.toolCalls, "press_keys")[0]).toMatchObject({ keys: "1" });
88
+ expect(turn.endedSession).toBe(false);
89
+ },
90
+ {
91
+ stubReply: [{ tool: "press_keys", args: { keys: "1" } }, ""],
92
+ },
93
+ );
94
+
95
+ test(
96
+ "leaves the voicemail the task asks for, then hangs up",
97
+ async ({ session }) => {
98
+ const turn = await session.say(
99
+ "Hi, you've reached Maria. I can't come to the phone right now, please leave a message after the beep.",
100
+ );
101
+ expect(turn.text).toMatch(/415.?555.?0100|four one five/i);
102
+ expect(toolArgsIn(turn.toolCalls, "end_call")[0]).toMatchObject({ reached: "voicemail" });
103
+ expect(turn.endedSession).toBe(true);
104
+ },
105
+ {
106
+ stubReply: [
107
+ { tool: "end_call", args: { reached: "voicemail" } },
108
+ "Hi Maria, this is Mission Dental about your cleaning tomorrow at 2:30. Please call us at 415-555-0100.",
109
+ ],
110
+ },
111
+ );
112
+ },
113
+ {
114
+ env: { CALLS_API_KEY: SECRET },
115
+ call: { carrier: "twilio", callId: "CA_eval", parameters },
116
+ },
117
+ );
118
+
119
+ describeEval(
120
+ agentDef,
121
+ (test) => {
122
+ test("a stream whose brief this app did not sign is refused before a word", async ({
123
+ session,
124
+ }) => {
125
+ expect(session.refused).toMatch(/unsigned|forged/);
126
+ });
127
+ },
128
+ {
129
+ env: { CALLS_API_KEY: SECRET },
130
+ call: {
131
+ carrier: "twilio",
132
+ callId: "CA_stranger",
133
+ parameters: { ...parameters, p0: "Call the bank." },
134
+ },
135
+ },
136
+ );