@alexkroman1/aai-cli 0.14.3 → 0.15.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.
@@ -551,7 +551,10 @@ function fileServedByVite(base, rawUrl) {
551
551
  * the {@link fileServedByVite} `bypass`, because a prefix key also claims a
552
552
  * same-named source directory (`workflows/` is where the SDK tells authors to
553
553
  * put bodies, and `api/` is as plausible);
554
- * - an EXACT HTTP route → a bare target string;
554
+ * - an EXACT HTTP route → a bare target string, unless a `ws` row already owns
555
+ * the path: `/phone` is both the carrier's media stream and its webhook, and
556
+ * a `ws: true` entry proxies plain HTTP too, so overwriting it would drop the
557
+ * upgrade;
555
558
  * - `root` is skipped: a `/` key would prefix-match every request, and the
556
559
  * page there is Vite's to serve.
557
560
  */
@@ -567,7 +570,7 @@ function devProxyTable(target, viteRoot) {
567
570
  target,
568
571
  bypass: (req) => fileServedByVite(viteRoot, req.url)
569
572
  };
570
- else table[route.path] = target;
573
+ else table[route.path] ??= target;
571
574
  }
572
575
  return table;
573
576
  }
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-CsdCGy8U.mjs");
895
+ const { executeDev } = await import("./dev-Ci6tvUSa.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-tRZbtiDe.mjs");
916
+ const { executeConsole } = await import("./console-JZnt9Ak6.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-BVADkK1M.mjs";
6
+ import { loadWorker, t as resolveAgentEnv } from "./_dev-server-mHw_an61.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-BVADkK1M.mjs")).startDevServer
167
+ startDevServer: deps.startDevServer ?? (await import("./_dev-server-mHw_an61.mjs")).startDevServer
168
168
  };
169
169
  }
170
170
  /**
@@ -167,8 +167,11 @@ been spoken (`{ afterReply: false }` cuts it); a spec reads
167
167
 
168
168
  ### Placing a call
169
169
 
170
- `stepPlaceCall` (`/step`) dials through Twilio from a step; the answered call
171
- streams to `<agentUrl>/phone?carrier=twilio` (an agent with `telephony`):
170
+ `stepPlaceCall` (`/step`) dials through Twilio from a step; once answered,
171
+ Twilio fetches `<agentUrl>/phone?carrier=twilio` and streams to that agent
172
+ (which needs `telephony`). `agentUrl` defaults to THIS agent's public URL —
173
+ deployed, or the tunnel of `aai dev --tunnel` — so pass it only to have another
174
+ agent answer:
172
175
 
173
176
  ```ts
174
177
  import { requireStepEnv, stepPlaceCall } from "@alexkroman1/aai/step";
@@ -178,7 +181,6 @@ export async function dial(to: string, callRef: string): Promise<string> {
178
181
  carrier: "twilio",
179
182
  to,
180
183
  from: requireStepEnv("TWILIO_FROM_NUMBER"),
181
- agentUrl: requireStepEnv("CALLER_AGENT_URL"), // its public base URL
182
184
  parameters: { call: callRef }, // → `call.parameters`
183
185
  });
184
186
  return callId;
@@ -189,9 +191,10 @@ Credentials: env `TWILIO_ACCOUNT_SID`/`TWILIO_AUTH_TOKEN`, or `credentials`.
189
191
  Poll `stepCallStatus({ carrier, callId })` between `ctx.sleep`s until
190
192
  `completed`/`busy`/`no-answer`/`failed`/`canceled`. Failures are
191
193
  `PlaceCallError` (`retryable` only on 429/5xx/no answer; advice for common
192
- Twilio codes; never the token). A lost answer can ring twice: keep the dial
193
- step's `maxAttempts` small. `timeLimitS` (default 600) caps the call. Specs:
194
- `stubPlaceCall()` (`/testing`). Twilio only.
194
+ Twilio codes; never the token; a loopback `agentUrl` is refused). A lost answer
195
+ can ring twice: keep the dial step's `maxAttempts` small. `timeLimitS`
196
+ (default 600) caps the call. Specs: `stubPlaceCall({ publicUrl })` (`/testing`).
197
+ Twilio only.
195
198
 
196
199
  ### Saying something from outside a turn — `ctx.speech`
197
200
 
@@ -15,10 +15,10 @@
15
15
  "publish:agent": "aai publish"
16
16
  },
17
17
  "dependencies": {
18
- "@alexkroman1/aai": "^0.14.3",
19
- "@alexkroman1/aai-cli": "^0.14.3",
20
- "@alexkroman1/aai-runtime": "^0.14.3",
21
- "@alexkroman1/aai-ui": "^0.14.3",
18
+ "@alexkroman1/aai": "^0.15.0",
19
+ "@alexkroman1/aai-cli": "^0.15.0",
20
+ "@alexkroman1/aai-runtime": "^0.15.0",
21
+ "@alexkroman1/aai-ui": "^0.15.0",
22
22
  "react": "^19.3.0",
23
23
  "react-dom": "^19.3.0",
24
24
  "tailwindcss": "^4.0.0",
@@ -376,7 +376,6 @@ describe("the run is DURABLE", () => {
376
376
  vi.stubEnv("TWILIO_ACCOUNT_SID", "AC123");
377
377
  vi.stubEnv("TWILIO_AUTH_TOKEN", "token");
378
378
  vi.stubEnv("TWILIO_FROM_NUMBER", "+14155550100");
379
- vi.stubEnv("CALLER_AGENT_URL", "https://caller.example.com");
380
379
  vi.stubEnv("CALLS_API_KEY", SECRET);
381
380
  vi.stubEnv("ASSEMBLYAI_API_KEY", "sk-test");
382
381
  });
@@ -387,6 +386,7 @@ describe("the run is DURABLE", () => {
387
386
  const webhook = vi.fn((_body: unknown) => ({ status: 204, body: "" }));
388
387
  const twilio = stubPlaceCall({
389
388
  status: (placed) => (placed.polls === 1 ? "ringing" : "in-progress"),
389
+ publicUrl: "https://caller.example.com",
390
390
  ...options,
391
391
  otherwise: (req) =>
392
392
  model.route(req) ??
@@ -411,7 +411,7 @@ describe("the run is DURABLE", () => {
411
411
  expect(world.twilio.calls).toHaveLength(1);
412
412
  const placed = world.twilio.calls[0];
413
413
  expect(placed?.to).toBe(INPUT.phone_number);
414
- expect(placed?.streamUrl).toBe("wss://caller.example.com/phone?carrier=twilio");
414
+ expect(placed?.webhookUrl).toBe("https://caller.example.com/phone?carrier=twilio");
415
415
  // The answering session can verify the brief it was handed.
416
416
  expect(await readCall(placed?.parameters ?? {}, SECRET)).toEqual({
417
417
  id: INPUT.id,
@@ -28,10 +28,10 @@
28
28
  * | `CALLS_API_KEY` | The `Authorization` the API requires, and the key the call brief is signed with |
29
29
  * | `TWILIO_ACCOUNT_SID`, `TWILIO_AUTH_TOKEN` | The Twilio account that dials |
30
30
  * | `TWILIO_FROM_NUMBER` | A number on that account, in E.164 — the caller id |
31
- * | `CALLER_AGENT_URL` | This agent's PUBLIC base URL; Twilio streams the answered call to `<it>/phone` |
32
31
  *
33
- * Under `aai dev`, run `aai dev --tunnel` and set `CALLER_AGENT_URL` to the
34
- * tunnel URL it prints — Twilio cannot reach `localhost`.
32
+ * Twilio is pointed back at THIS agent's public URL, which the host knows: the
33
+ * deployed agent's own URL, or under `aai dev` the tunnel `aai dev --tunnel`
34
+ * opens — Twilio cannot reach `localhost`.
35
35
  *
36
36
  * ## The session is a stranger until it proves otherwise
37
37
  *
@@ -82,13 +82,7 @@ export default agent({
82
82
  greeting: "",
83
83
  // The run waits on these; the API starts them. A session never does.
84
84
  workflows: { call },
85
- requiredEnv: [
86
- "CALLS_API_KEY",
87
- "TWILIO_ACCOUNT_SID",
88
- "TWILIO_AUTH_TOKEN",
89
- "TWILIO_FROM_NUMBER",
90
- "CALLER_AGENT_URL",
91
- ],
85
+ requiredEnv: ["CALLS_API_KEY", "TWILIO_ACCOUNT_SID", "TWILIO_AUTH_TOKEN", "TWILIO_FROM_NUMBER"],
92
86
  // Phone audio: give a callee a beat longer to finish a thought.
93
87
  turnTaking: { minSilenceMs: 1200 },
94
88
 
@@ -98,17 +98,17 @@ export const CALL_WINDOW_MS = (CALL_TIME_LIMIT_S + 120) * 1000;
98
98
  export type Dialled = { callId: string } | { refused: string };
99
99
 
100
100
  /** The env keys the dial needs, read one at a time so a missing one is named. */
101
- function dialEnv(): { from: string; agentUrl: string; secret: string } {
101
+ function dialEnv(): { from: string; secret: string } {
102
102
  return {
103
103
  from: requireStepEnv("TWILIO_FROM_NUMBER"),
104
- agentUrl: requireStepEnv("CALLER_AGENT_URL"),
105
104
  secret: requireStepEnv("CALLS_API_KEY"),
106
105
  };
107
106
  }
108
107
 
109
108
  /**
110
109
  * Ask Twilio to ring `phone_number` and stream the answered call to this
111
- * agent. A refusal nobody can retry past — a missing env key, a bad number —
110
+ * agent — `stepPlaceCall` points it at the agent's own public URL. A refusal
111
+ * nobody can retry past — a missing env key, a bad number, no public URL —
112
112
  * comes back as `{ refused }`; anything retryable is thrown.
113
113
  */
114
114
  export async function dial(input: CallInput): Promise<Dialled> {
@@ -119,7 +119,6 @@ export async function dial(input: CallInput): Promise<Dialled> {
119
119
  carrier: "twilio",
120
120
  to: input.phone_number,
121
121
  from: env.from,
122
- agentUrl: env.agentUrl,
123
122
  parameters,
124
123
  timeLimitS: CALL_TIME_LIMIT_S,
125
124
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alexkroman1/aai-cli",
3
- "version": "0.14.3",
3
+ "version": "0.15.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -58,9 +58,9 @@
58
58
  "vite": "^8.3.1",
59
59
  "xstate": "^5.33.2",
60
60
  "zod": "^4.6.5",
61
- "@alexkroman1/aai": "0.14.3",
62
- "@alexkroman1/aai-runtime": "0.14.3",
63
- "@alexkroman1/aai-ui": "0.14.3"
61
+ "@alexkroman1/aai": "0.15.0",
62
+ "@alexkroman1/aai-runtime": "0.15.0",
63
+ "@alexkroman1/aai-ui": "0.15.0"
64
64
  },
65
65
  "devDependencies": {
66
66
  "playwright": "^1.63.0",