@alexkroman1/aai-cli 0.18.2 → 0.19.1

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.
Files changed (66) hide show
  1. package/dist/{_agent-BN21AHsJ.mjs → _agent-Bj6Q_vDG.mjs} +3 -4
  2. package/dist/{_api-client-Uljj0CQi.mjs → _api-client-BlnLXkZL.mjs} +3 -4
  3. package/dist/{_artifacts-BJOYGQPp.mjs → _artifacts-Drssawoc.mjs} +1 -2
  4. package/dist/{_build-target-C08aM-Es.mjs → _build-target-CWpq0VVa.mjs} +7 -14
  5. package/dist/{_bundler-DvZDEu2p.mjs → _bundler-BLy_GtuH.mjs} +7 -8
  6. package/dist/{_client-plugins-kR43nZnb.mjs → _client-plugins-BWryIN7z.mjs} +3 -4
  7. package/dist/{_config-Dlh8PRRp.mjs → _config-yWqkB0Qz.mjs} +5 -6
  8. package/dist/{_dev-env-D9Uy5wNt.mjs → _dev-env-DP0lLryD.mjs} +1 -2
  9. package/dist/{_dev-server-C_zidzWj.mjs → _dev-server--x-e22KR.mjs} +21 -28
  10. package/dist/_mock-registry.d.ts +5 -0
  11. package/dist/{_preflight-Bv6Ct4ss.mjs → _preflight-JRzjhjeI.mjs} +2 -3
  12. package/dist/{_run-code-deno-C0AtfHeH.mjs → _run-code-deno-D69GatOo.mjs} +3 -4
  13. package/dist/{_server-common-C6j67AcZ.mjs → _server-common-BB_ojN_l.mjs} +4 -5
  14. package/dist/{_slug-api-B9cptz7Q.mjs → _slug-api-Bydkac5S.mjs} +4 -5
  15. package/dist/{_start-workers-BNdOnTal.mjs → _start-workers-DBiICf6o.mjs} +8 -38
  16. package/dist/{_studio-zympBLlD.mjs → _studio-DlJnf9D5.mjs} +5 -6
  17. package/dist/{_templates-ChZuhW66.mjs → _templates-BIzBxGOW.mjs} +5 -6
  18. package/dist/{_typecheck-gate-BNF5cboL.mjs → _typecheck-gate-B60qpe6n.mjs} +3 -4
  19. package/dist/{_ui-C0RufoYZ.mjs → _ui-DOrhK1ET.mjs} +3 -4
  20. package/dist/{_utils-ChU85MEg.mjs → _utils-W_hmhlT5.mjs} +5 -7
  21. package/dist/{_vite-env-BiyJ0GQH.mjs → _vite-env-KVEx9r2_.mjs} +1 -3
  22. package/dist/{_vitest-runner-tzyto9IU.mjs → _vitest-runner-BIh-yKTG.mjs} +4 -5
  23. package/dist/{_workflow-determinism-CLxFQ5ox.mjs → _workflow-determinism-D5xr1EyE.mjs} +2 -3
  24. package/dist/{build-BHgd-QYb.mjs → build-Dab9cZiG.mjs} +23 -29
  25. package/dist/cli.mjs +26 -31
  26. package/dist/{client-bundler-CImhqcp2.mjs → client-bundler-iQhwQ3Y-.mjs} +8 -10
  27. package/dist/client-bundler.mjs +1 -2
  28. package/dist/{console-DwycgRkC.mjs → console-CAlP2e9Z.mjs} +8 -11
  29. package/dist/{delete-ZcA3J_3o.mjs → delete-D28hn7Gp.mjs} +7 -8
  30. package/dist/{deploy-CkfkiZE3.mjs → deploy-DBgwl03r.mjs} +13 -15
  31. package/dist/{dev-BX9g6qcf.mjs → dev-GwaVXLuc.mjs} +8 -10
  32. package/dist/{eval-CUKvfxRq.mjs → eval-K7IDiaYP.mjs} +5 -6
  33. package/dist/{init-B9Uw76-_.mjs → init--gLLPng0.mjs} +9 -11
  34. package/dist/{login-Ct73CqU1.mjs → login-DknFC9Or.mjs} +8 -9
  35. package/dist/{logs-BBsUy96d.mjs → logs-tqX6e7p-.mjs} +7 -8
  36. package/dist/project-config.mjs +1 -2
  37. package/dist/scaffold/CLAUDE.md +2 -2
  38. package/dist/scaffold/agent-guide/AGENT-API.md +1 -1
  39. package/dist/scaffold/agent-guide/HOSTING.md +1 -1
  40. package/dist/scaffold/agent-guide/PROVIDERS.md +6 -2
  41. package/dist/scaffold/package.json +14 -14
  42. package/dist/{secret-CKjHRrVX.mjs → secret-BW0vS0m2.mjs} +9 -11
  43. package/dist/start.mjs +16 -22
  44. package/dist/{studio-U6DvBNAx.mjs → studio-CMT2R7x8.mjs} +11 -12
  45. package/dist/templates/coding-agent/agent.test.ts +1 -1
  46. package/dist/templates/coding-agent/chat.ts +1 -1
  47. package/dist/templates/custom-pipeline-agent/stages.test.ts +3 -1
  48. package/dist/templates/front-desk-agent/agent.test.ts +3 -1
  49. package/dist/templates/front-door-agent/agent.test.ts +9 -12
  50. package/dist/templates/home-assistant-agent/agent.test.ts +9 -6
  51. package/dist/templates/hotel-reception-agent/agent.test.ts +2 -1
  52. package/dist/templates/hotel-reception-agent/booking.ts +5 -1
  53. package/dist/templates/hotel-reception-agent/hotel.ts +15 -5
  54. package/dist/templates/hotel-reception-agent/seed.ts +1 -1
  55. package/dist/templates/kitchen-coach-agent/agent.test.ts +3 -5
  56. package/dist/templates/tabletop-rpg-agent/agent.test.ts +1 -1
  57. package/dist/templates/technical-support-agent/knowledge.ts +3 -1
  58. package/dist/templates/text-adventure-agent/agent.test.ts +4 -1
  59. package/dist/templates/transcription-workflow/agent.test.ts +3 -8
  60. package/dist/templates/transcription-workflow/workflows/stream.ts +1 -1
  61. package/dist/{test-CW5cw5fy.mjs → test-C0YRaetz.mjs} +4 -5
  62. package/dist/typecheck.mjs +4 -5
  63. package/dist/{worker-bundler-D8uCzpYP.mjs → worker-bundler-B3HezfRu.mjs} +8 -10
  64. package/dist/worker-bundler.mjs +1 -2
  65. package/dist/{workflow-5gOZMB2M.mjs → workflow-CYBoqe23.mjs} +6 -7
  66. package/package.json +16 -16
@@ -1,15 +1,15 @@
1
1
  #!/usr/bin/env node
2
- import { C as CliError, D as ok, S as writeJson, _ as resolveCwd, c as fileExists, i as compareCodeUnits, m as readJson, s as errorMessage, t as AGENT_ENTRY, u as isEexist } from "./_utils-ChU85MEg.mjs";
3
- import { i as unwrapCancel, t as defaultUi } from "./_ui-C0RufoYZ.mjs";
4
- import { t as CLIENT_ONLY_DEPENDENCIES } from "./_client-plugins-kR43nZnb.mjs";
5
- import { r as isDevMode, t as getMonorepoRoot } from "./_agent-BN21AHsJ.mjs";
6
- import { REPO_URL, downloadAndMergeTemplate, listTemplates, n as writeFileNoFollow } from "./_templates-ChZuhW66.mjs";
7
- import { s as projectNameFromDir } from "./_studio-zympBLlD.mjs";
8
2
  import path from "node:path";
9
3
  import { styleText } from "node:util";
10
- import fs from "node:fs/promises";
11
4
  import { execa } from "execa";
12
- //#region src/_init.ts
5
+ import { r as isDevMode, t as getMonorepoRoot } from "./_agent-Bj6Q_vDG.mjs";
6
+ import fs from "node:fs/promises";
7
+ import { t as CLIENT_ONLY_DEPENDENCIES } from "./_client-plugins-BWryIN7z.mjs";
8
+ import { REPO_URL, downloadAndMergeTemplate, listTemplates, n as writeFileNoFollow } from "./_templates-BIzBxGOW.mjs";
9
+ import { C as CliError, D as ok, S as writeJson, _ as resolveCwd, c as fileExists, i as compareCodeUnits, m as readJson, s as errorMessage, t as AGENT_ENTRY, u as isEexist } from "./_utils-W_hmhlT5.mjs";
10
+ import { s as projectNameFromDir } from "./_studio-DlJnf9D5.mjs";
11
+ import { i as unwrapCancel, t as defaultUi } from "./_ui-DOrhK1ET.mjs";
12
+ // src/_init.ts
13
13
  /**
14
14
  * The package managers `aai init` can install a project with, in PREFERENCE
15
15
  * order — which is also the order `detectPackageManager` (`init.ts`) probes
@@ -341,8 +341,7 @@ async function runInit(opts) {
341
341
  if (!isEexist(err)) throw err;
342
342
  }
343
343
  }
344
- //#endregion
345
- //#region src/init.ts
344
+ // src/init.ts
346
345
  /**
347
346
  * Run `fn` behind a clack spinner, stopping it in EVERY outcome.
348
347
  *
@@ -635,5 +634,4 @@ async function executeInit(opts, deps = {}) {
635
634
  if (warnings.length > 0) data.warnings = warnings;
636
635
  return ok(data);
637
636
  }
638
- //#endregion
639
637
  export { executeInit };
@@ -1,13 +1,13 @@
1
1
  #!/usr/bin/env node
2
- import { C as CliError, D as ok } from "./_utils-ChU85MEg.mjs";
3
- import { t as defaultUi } from "./_ui-C0RufoYZ.mjs";
4
- import { a as updateGlobalConfig } from "./_config-Dlh8PRRp.mjs";
5
- import { a as resolveApprovedServer } from "./_agent-BN21AHsJ.mjs";
6
- import { c as guardedFetch, i as RequestTimeoutError, l as isGuardError, r as RedirectRefusedError } from "./_api-client-Uljj0CQi.mjs";
7
- import { linkConfirmationCode, sleep } from "@alexkroman1/aai/internal";
8
2
  import { spawn } from "node:child_process";
9
3
  import { randomBytes } from "node:crypto";
10
- //#region src/login.ts
4
+ import { linkConfirmationCode, sleep } from "@alexkroman1/aai/internal";
5
+ import { a as resolveApprovedServer } from "./_agent-Bj6Q_vDG.mjs";
6
+ import { c as guardedFetch, i as RequestTimeoutError, l as isGuardError, r as RedirectRefusedError } from "./_api-client-BlnLXkZL.mjs";
7
+ import { a as updateGlobalConfig } from "./_config-yWqkB0Qz.mjs";
8
+ import { C as CliError, D as ok } from "./_utils-W_hmhlT5.mjs";
9
+ import { t as defaultUi } from "./_ui-DOrhK1ET.mjs";
10
+ // src/login.ts
11
11
  /**
12
12
  * `aai login` — link the CLI to an account that is ALREADY signed in to the
13
13
  * browser studio, ending with the account's AssemblyAI API key stored in
@@ -110,7 +110,7 @@ function isLoopback(url) {
110
110
  */
111
111
  async function pollForGrant(fetchFn, serverUrl, code, opts) {
112
112
  let lastTransportError;
113
- for (;;) {
113
+ while (true) {
114
114
  let res = null;
115
115
  try {
116
116
  res = await fetchFn(`${serverUrl}/studio/cli-link/exchange`, {
@@ -186,5 +186,4 @@ async function executeLogin(opts, deps = {}) {
186
186
  server: serverUrl
187
187
  });
188
188
  }
189
- //#endregion
190
189
  export { executeLogin };
@@ -1,12 +1,12 @@
1
1
  #!/usr/bin/env node
2
- import { D as ok } from "./_utils-ChU85MEg.mjs";
3
- import { t as defaultUi } from "./_ui-C0RufoYZ.mjs";
4
- import { s as checkedResponse } from "./_api-client-Uljj0CQi.mjs";
5
- import { r as slugRequestOn, t as REAL_PLATFORM } from "./_slug-api-B9cptz7Q.mjs";
6
- import { isRecord, omitUndefined } from "@alexkroman1/aai/utils";
7
- import { sleep } from "@alexkroman1/aai/internal";
8
2
  import { formatLogTime } from "@alexkroman1/aai/host-internal";
9
- //#region src/logs.ts
3
+ import { sleep } from "@alexkroman1/aai/internal";
4
+ import { isRecord, omitUndefined } from "@alexkroman1/aai/utils";
5
+ import { s as checkedResponse } from "./_api-client-BlnLXkZL.mjs";
6
+ import { D as ok } from "./_utils-W_hmhlT5.mjs";
7
+ import { r as slugRequestOn, t as REAL_PLATFORM } from "./_slug-api-Bydkac5S.mjs";
8
+ import { t as defaultUi } from "./_ui-DOrhK1ET.mjs";
9
+ // src/logs.ts
10
10
  /**
11
11
  * `aai logs` — what the deployed agent has printed.
12
12
  *
@@ -138,5 +138,4 @@ function printPage(page, ui, seen) {
138
138
  }
139
139
  return count;
140
140
  }
141
- //#endregion
142
141
  export { FOLLOW_POLL_MS, executeLogs, formatLine };
@@ -1,3 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import { o as updateProjectConfig, s as writeGlobalConfig } from "./_config-Dlh8PRRp.mjs";
3
- export { updateProjectConfig, writeGlobalConfig as writeConfigHome };
2
+ export { o as updateProjectConfig, s as writeConfigHome } from "./_config-yWqkB0Qz.mjs";
@@ -208,8 +208,8 @@ agent({ name: "My Agent", turnTaking: { minSilenceMs: 1600, maxSilenceMs: 3500 }
208
208
 
209
209
  The default pipeline lowers the pair onto its STT stage; beside an explicit
210
210
  `stt` the shorthand is refused — set
211
- `assemblyAIStt({ minTurnSilenceMs, maxTurnSilenceMs })` instead. Defaults 800 /
212
- 3500 ms (800 needs continuation; 1600 without). **`maxSilenceMs` is the
211
+ `assemblyAIStt({ minTurnSilenceMs, maxTurnSilenceMs })` instead. Defaults 250 /
212
+ 1500 ms (250 needs continuation; 1600 without). **`maxSilenceMs` is the
213
213
  pause-tolerance knob** (raise it for hesitant or dictating callers; only turns
214
214
  that never read as complete pay it); `minSilenceMs` taxes every finished turn —
215
215
  the doc comments on `DEFAULT_MIN_TURN_SILENCE_MS`/`DEFAULT_MAX_TURN_SILENCE_MS`
@@ -80,7 +80,7 @@ export default agent({
80
80
  minSilenceMs?: number; // pause (ms) that ENDS a turn once the text reads
81
81
  // complete (default 250) — lowered onto the default
82
82
  maxSilenceMs?: number; // assemblyAIStt(); pause that ends it REGARDLESS of
83
- // content (default 3500). Invalid beside an explicit `stt`.
83
+ // content (default 1500). Invalid beside an explicit `stt`.
84
84
  detection?: "auto" | "manual"; // "manual" is push-to-talk: the CLIENT ends each turn
85
85
  userTurnLimit?: { maxWords?: number; maxDurationMs?: number }; // cap ONE user turn. Default: none.
86
86
  preemptiveGeneration?: boolean; // start the reply from a confident interim (default false)
@@ -77,7 +77,7 @@ process whose latency budget is a person waiting for an answer.
77
77
  so they are not in your `node_modules` until you ask for them:
78
78
 
79
79
  ```sh
80
- npm i @opentelemetry/api @opentelemetry/sdk-trace-base \
80
+ npm i @opentelemetry/api @opentelemetry/sdk-trace \
81
81
  @opentelemetry/exporter-trace-otlp-proto @opentelemetry/resources \
82
82
  @opentelemetry/context-async-hooks
83
83
  ```
@@ -21,8 +21,12 @@ providers you actually use.
21
21
  All STT factories accept `{ model?: string, ... }`. Bare calls (`deepgramStt()`,
22
22
  `sonioxStt()`, etc.) use the default model. Language is spelled `language` where
23
23
  the vendor takes one code (`deepgramStt`, `elevenLabsStt`) and `languages` where
24
- it takes a list (`assemblyAIStt`, `sonioxStt`) — and only `deepgramStt`'s unset
25
- value means English; the other three auto-detect.
24
+ it takes a list (`assemblyAIStt`, `sonioxStt`). Unset means English for
25
+ `deepgramStt` and for `assemblyAIStt` on its default Universal-3.5 Pro model
26
+ (other AssemblyAI models get no language default), and auto-detect for the other
27
+ two. For a multilingual line on `assemblyAIStt`, pass `languages: []` to
28
+ code-switch across every supported language, or several codes (`["en", "es"]`)
29
+ to code-switch within that set.
26
30
 
27
31
  `elevenLabsStt` carries the stage in its name because ElevenLabs is better known
28
32
  for TTS: when that stage arrives, `elevenLabs` is the name it should get.
@@ -15,24 +15,24 @@
15
15
  "publish:agent": "aai publish"
16
16
  },
17
17
  "dependencies": {
18
- "@alexkroman1/aai": "^0.18.2",
19
- "@alexkroman1/aai-cli": "^0.18.2",
20
- "@alexkroman1/aai-runtime": "^0.18.2",
21
- "@alexkroman1/aai-ui": "^0.18.2",
22
- "react": "^19.3.0",
23
- "react-dom": "^19.3.0",
18
+ "@alexkroman1/aai": "^0.19.1",
19
+ "@alexkroman1/aai-cli": "^0.19.1",
20
+ "@alexkroman1/aai-runtime": "^0.19.1",
21
+ "@alexkroman1/aai-ui": "^0.19.1",
22
+ "react": "^19.3.1",
23
+ "react-dom": "^19.3.1",
24
24
  "tailwindcss": "^4.0.0",
25
- "xstate": "^5.33.2",
26
- "zod": "^4.6.5"
25
+ "xstate": "^5.33.4",
26
+ "zod": "^4.6.7"
27
27
  },
28
28
  "devDependencies": {
29
- "@tailwindcss/vite": "^4.3.3",
30
- "@types/node": "^24.13.6",
31
- "@types/react": "^19.3.0",
29
+ "@tailwindcss/vite": "^4.3.5",
30
+ "@types/node": "^24.19.2",
31
+ "@types/react": "^19.3.1",
32
32
  "@types/react-dom": "^19.3.0",
33
- "@vitejs/plugin-react": "^6.1.1",
33
+ "@vitejs/plugin-react": "^6.3.0",
34
34
  "typescript": "^7.0.2",
35
- "vite": "^8.3.1",
36
- "vitest": "^5.0.1"
35
+ "vite": "^8.3.8",
36
+ "vitest": "^5.1.1"
37
37
  }
38
38
  }
@@ -1,14 +1,14 @@
1
1
  #!/usr/bin/env node
2
- import { C as CliError, D as ok, d as lstatOrNull, g as readTextIfPresent, w as fail, x as writeFileAtomic } from "./_utils-ChU85MEg.mjs";
3
- import { i as unwrapCancel, t as defaultUi } from "./_ui-C0RufoYZ.mjs";
4
- import { s as checkedResponse, u as isStringArray } from "./_api-client-Uljj0CQi.mjs";
5
- import { n as secretRequest, t as REAL_PLATFORM } from "./_slug-api-B9cptz7Q.mjs";
6
- import path from "node:path";
7
2
  import { isRecord, plural } from "@alexkroman1/aai/utils";
8
- import { isDeepStrictEqual, parseEnv } from "node:util";
9
- import fs from "node:fs/promises";
10
3
  import pTimeout from "p-timeout";
11
- //#region src/_dotenv-file.ts
4
+ import { s as checkedResponse, u as isStringArray } from "./_api-client-BlnLXkZL.mjs";
5
+ import fs from "node:fs/promises";
6
+ import path from "node:path";
7
+ import { isDeepStrictEqual, parseEnv } from "node:util";
8
+ import { C as CliError, D as ok, d as lstatOrNull, g as readTextIfPresent, w as fail, x as writeFileAtomic } from "./_utils-W_hmhlT5.mjs";
9
+ import { n as secretRequest, t as REAL_PLATFORM } from "./_slug-api-Bydkac5S.mjs";
10
+ import { i as unwrapCancel, t as defaultUi } from "./_ui-DOrhK1ET.mjs";
11
+ // src/_dotenv-file.ts
12
12
  /**
13
13
  * `aai secret put --local` / `delete --local` — edit the project's `.env`
14
14
  * rather than the platform's secrets.
@@ -186,8 +186,7 @@ async function deleteLocalSecret(cwd, name) {
186
186
  if (removed) await writeFileAtomic(file, text, { mode });
187
187
  return removed;
188
188
  }
189
- //#endregion
190
- //#region src/secret.ts
189
+ // src/secret.ts
191
190
  /**
192
191
  * The one `no_input` failure for `secret put`, shared by every path that can
193
192
  * reach it — the stdin read that came back empty, the refusal when stdin is a
@@ -373,5 +372,4 @@ async function executeSecretList(cwd, server, ui = defaultUi, platform = REAL_PL
373
372
  }
374
373
  return ok({ secrets: vars });
375
374
  }
376
- //#endregion
377
375
  export { executeLocalSecretDelete, executeLocalSecretPut, executeSecretDelete, executeSecretList, executeSecretPut, resolveSecretValue };
package/dist/start.mjs CHANGED
@@ -1,23 +1,23 @@
1
1
  #!/usr/bin/env node
2
- import { a as isProtocolMessage, c as nodeCluster, l as superviseWorkers, n as SLOTS_ENV, o as isStartWorker, r as SLOT_ENV, s as loadCluster } from "./_start-workers-BNdOnTal.mjs";
3
- import { t as defaultUi } from "./_ui-C0RufoYZ.mjs";
4
- import { n as WORKER_ARTIFACT_REL, t as CLIENT_ARTIFACT_REL } from "./_artifacts-BJOYGQPp.mjs";
5
- import { t as resolveDenoRunCode } from "./_run-code-deno-C0AtfHeH.mjs";
6
- import { a as resolveServerEnv, n as DEPLOY_ENV_FILES } from "./_server-common-C6j67AcZ.mjs";
7
2
  import { existsSync } from "node:fs";
8
3
  import path from "node:path";
9
4
  import { pathToFileURL } from "node:url";
10
- import { isRecord, omitUndefined } from "@alexkroman1/aai/utils";
11
5
  import { parseWsUpgradeParams, requestPath, sleep } from "@alexkroman1/aai/internal";
6
+ import { isRecord, omitUndefined } from "@alexkroman1/aai/utils";
12
7
  import { createAgentServer, ensureSessionStateSchema, ensureWorkflowJournalSchema } from "@alexkroman1/aai-runtime";
13
8
  import { SERVER_ROUTES, consoleLogger, notifyClientHere, routeMatches, setClientNotifyRelay, setSessionIdMinter, withHostCredentialFallback } from "@alexkroman1/aai-runtime/internal";
14
9
  import { startTracing } from "@alexkroman1/aai-runtime/tracing";
15
10
  import { defaultClientDir } from "@alexkroman1/aai-ui/client-dir";
11
+ import { n as WORKER_ARTIFACT_REL, t as CLIENT_ARTIFACT_REL } from "./_artifacts-Drssawoc.mjs";
12
+ import { t as resolveDenoRunCode } from "./_run-code-deno-D69GatOo.mjs";
13
+ import { a as resolveServerEnv, n as DEPLOY_ENV_FILES } from "./_server-common-BB_ojN_l.mjs";
16
14
  import http from "node:http";
17
15
  import { randomUUID } from "node:crypto";
18
16
  import { Socket } from "node:net";
19
17
  import { performance } from "node:perf_hooks";
20
- //#region src/_start-log.ts
18
+ import { a as isProtocolMessage, c as nodeCluster, l as superviseWorkers, n as SLOTS_ENV, o as isStartWorker, r as SLOT_ENV, s as loadCluster } from "./_start-workers-DBiICf6o.mjs";
19
+ import { t as defaultUi } from "./_ui-DOrhK1ET.mjs";
20
+ // src/_start-log.ts
21
21
  /**
22
22
  * The runtime's logger for `aai start`: the console logger in human mode, and
23
23
  * in JSON mode the same lines on STDERR.
@@ -71,8 +71,7 @@ function workerLogger(base, slot) {
71
71
  }
72
72
  };
73
73
  }
74
- //#endregion
75
- //#region src/_start-affinity.ts
74
+ // src/_start-affinity.ts
76
75
  /**
77
76
  * Which `aai start --workers` worker a request belongs to.
78
77
  *
@@ -112,15 +111,15 @@ function sessionKey(sessionId) {
112
111
  * `phone-2`, …) would fall into a regular pattern modulo a small worker count.
113
112
  */
114
113
  function slotOf(key, slots) {
115
- let hash = 2166136261;
114
+ let hash = 0x811c9dc5;
116
115
  for (let i = 0; i < key.length; i++) {
117
116
  hash ^= key.charCodeAt(i);
118
117
  hash = Math.imul(hash, 16777619);
119
118
  }
120
119
  hash ^= hash >>> 16;
121
- hash = Math.imul(hash, 2246822507);
120
+ hash = Math.imul(hash, 0x85ebca6b);
122
121
  hash ^= hash >>> 13;
123
- hash = Math.imul(hash, 3266489909);
122
+ hash = Math.imul(hash, 0xc2b2ae35);
124
123
  hash ^= hash >>> 16;
125
124
  return (hash >>> 0) % slots;
126
125
  }
@@ -130,7 +129,7 @@ function slotOf(key, slots) {
130
129
  * as unguessable as the default.
131
130
  */
132
131
  function mintIdForSlot(slot, slots, uuid = randomUUID) {
133
- for (;;) {
132
+ while (true) {
134
133
  const id = uuid();
135
134
  if (slotOf(sessionKey(id), slots) === slot) return id;
136
135
  }
@@ -199,8 +198,7 @@ function isResume(rawUrl, headers) {
199
198
  if (parseWsUpgradeParams(rawUrl ?? "/").resumeFrom !== void 0) return true;
200
199
  return presentedTicketSid(new URL(rawUrl ?? "/", "http://route.invalid"), headers) !== void 0;
201
200
  }
202
- //#endregion
203
- //#region src/_start-router.ts
201
+ // src/_start-router.ts
204
202
  /**
205
203
  * The `aai start --workers` primary's public listener: route each request to
206
204
  * the worker its affinity key names (`_start-affinity.ts`).
@@ -389,8 +387,7 @@ function createRouter(opts) {
389
387
  });
390
388
  return server;
391
389
  }
392
- //#endregion
393
- //#region src/_start-worker.ts
390
+ // src/_start-worker.ts
394
391
  /**
395
392
  * One `aai start --workers` worker joining its primary.
396
393
  *
@@ -758,8 +755,7 @@ function listenServer(server, port, host) {
758
755
  });
759
756
  });
760
757
  }
761
- //#endregion
762
- //#region src/_stop-server.ts
758
+ // src/_stop-server.ts
763
759
  /**
764
760
  * Stop what `aai start` started: close the server — which shuts the runtime
765
761
  * down too, so there is no separate `runtime.shutdown()` — then flush tracing
@@ -779,8 +775,7 @@ async function stopProjectServer(server, tracing) {
779
775
  await tracing?.shutdown();
780
776
  }
781
777
  }
782
- //#endregion
783
- //#region src/start.ts
778
+ // src/start.ts
784
779
  /**
785
780
  * `aai start` — serve a BUILT agent from a plain Node process.
786
781
  *
@@ -979,5 +974,4 @@ async function executeStart(options) {
979
974
  }
980
975
  });
981
976
  }
982
- //#endregion
983
977
  export { CLIENT_ARTIFACT_REL, DEFAULT_START_PORT, createProjectServer, executeStart, loadBuiltAgent };
@@ -1,18 +1,18 @@
1
1
  #!/usr/bin/env node
2
- import { C as CliError, D as ok, l as formatCappedList } from "./_utils-ChU85MEg.mjs";
3
- import { n as fmtUrl, t as defaultUi } from "./_ui-C0RufoYZ.mjs";
4
- import { o as updateProjectConfig } from "./_config-Dlh8PRRp.mjs";
5
- import { i as readUploadableEnv } from "./_server-common-C6j67AcZ.mjs";
6
- import { layerScaffold, n as writeFileNoFollow, refuseUnsafeScaffoldTargets, t as refuseUnsafeTarget } from "./_templates-ChZuhW66.mjs";
7
- import { s as checkedResponse } from "./_api-client-Uljj0CQi.mjs";
8
- import { a as isUsableProjectName, c as publishStudioProject, d as studioProjectUrl, i as isSlugShaped, l as pushStudioSource, n as collectSourceFiles, o as listStudioProjects, r as fetchStudioProject, s as projectNameFromDir, t as REAL_STUDIO_DEPS, u as studioProjectApiUrl } from "./_studio-zympBLlD.mjs";
9
2
  import { existsSync } from "node:fs";
3
+ import { readdir } from "node:fs/promises";
10
4
  import path from "node:path";
11
5
  import { isRecord, omitUndefined, plural } from "@alexkroman1/aai/utils";
12
- import { readdir } from "node:fs/promises";
13
- import { isPathInside } from "@alexkroman1/aai-runtime/internal";
14
6
  import { IGNORED_WORKSPACE_DIRS, isLocalOnlyFile } from "@alexkroman1/aai/workspace-files";
15
- //#region src/studio.ts
7
+ import { isPathInside } from "@alexkroman1/aai-runtime/internal";
8
+ import { s as checkedResponse } from "./_api-client-BlnLXkZL.mjs";
9
+ import { o as updateProjectConfig } from "./_config-yWqkB0Qz.mjs";
10
+ import { C as CliError, D as ok, l as formatCappedList } from "./_utils-W_hmhlT5.mjs";
11
+ import { layerScaffold, n as writeFileNoFollow, refuseUnsafeScaffoldTargets, t as refuseUnsafeTarget } from "./_templates-BIzBxGOW.mjs";
12
+ import { i as readUploadableEnv } from "./_server-common-BB_ojN_l.mjs";
13
+ import { a as isUsableProjectName, c as publishStudioProject, d as studioProjectUrl, i as isSlugShaped, l as pushStudioSource, n as collectSourceFiles, o as listStudioProjects, r as fetchStudioProject, s as projectNameFromDir, t as REAL_STUDIO_DEPS, u as studioProjectApiUrl } from "./_studio-DlJnf9D5.mjs";
14
+ import { n as fmtUrl, t as defaultUi } from "./_ui-DOrhK1ET.mjs";
15
+ // src/studio.ts
16
16
  /**
17
17
  * The studio-workspace commands: `aai list`, `aai pull`, `aai push`,
18
18
  * `aai publish`.
@@ -264,7 +264,7 @@ async function syncEnvSecrets(cwd, serverUrl, apiKey, project, ui, request) {
264
264
  }
265
265
  async function executePublish(opts, ui = defaultUi, deps = REAL_STUDIO_DEPS) {
266
266
  const target = await deps.resolveDeployTarget(opts.cwd, opts.server);
267
- const { assertTypechecks } = await import("./_typecheck-gate-BNF5cboL.mjs");
267
+ const { assertTypechecks } = await import("./_typecheck-gate-B60qpe6n.mjs");
268
268
  await assertTypechecks(opts.cwd, {
269
269
  skip: opts.skipTypecheck,
270
270
  ui
@@ -292,5 +292,4 @@ async function executePublish(opts, ui = defaultUi, deps = REAL_STUDIO_DEPS) {
292
292
  ...pushed.warnings.length > 0 ? { warnings: pushed.warnings } : {}
293
293
  });
294
294
  }
295
- //#endregion
296
295
  export { executeList, executePublish, executePull, executePush };
@@ -57,7 +57,7 @@ describeAgent(agentDef, (run) => {
57
57
  });
58
58
 
59
59
  test("declares the nine workspace tools, by the names the model calls", () => {
60
- expect(Object.keys(agentDef.tools).sort()).toEqual([
60
+ expect(Object.keys(agentDef.tools).sort((a, b) => Number(a > b) - Number(a < b))).toEqual([
61
61
  "bash",
62
62
  "delete_file",
63
63
  "edit_file",
@@ -48,7 +48,7 @@ const messages: Parameters<typeof chat.stream>[0]["messages"] = [];
48
48
  const io = createInterface({ input: process.stdin, output: process.stdout });
49
49
  console.log(`Working in ${WORKSPACE_DIR}\n(ctrl-c to quit)\n`);
50
50
 
51
- for (;;) {
51
+ while (true) {
52
52
  const line = (await io.question("> ")).trim();
53
53
  if (line.length === 0) continue;
54
54
  messages.push({ role: "user", content: line });
@@ -82,7 +82,9 @@ const NAME = "Line";
82
82
  * is what lets `aai build` serialize it into the bundle.
83
83
  */
84
84
  function shape(stage: ProviderDescriptor<string, Record<string, unknown>>): string {
85
- return `${stage.kind}(${Object.keys(stage.options).sort().join(", ")})`;
85
+ return `${stage.kind}(${Object.keys(stage.options)
86
+ .sort((a, b) => Number(a > b) - Number(a < b))
87
+ .join(", ")})`;
86
88
  }
87
89
 
88
90
  describe("the LLM stage: one factory, the provider is data", () => {
@@ -34,7 +34,9 @@ describeAgent(agentDef, (run) => {
34
34
  test("triage answers the phone, and every persona's tools plus `handoff` are on the agent", () => {
35
35
  expect(desk.list.map((one) => one.name)).toEqual(["triage", "billing", "support"]);
36
36
  // The `tools/` files are the shared ones; the roster minted the rest.
37
- expect(Object.keys(agentDef.tools).sort()).toEqual(["verify_account"]);
37
+ expect(Object.keys(agentDef.tools).sort((a, b) => Number(a > b) - Number(a < b))).toEqual([
38
+ "verify_account",
39
+ ]);
38
40
  for (const name of [
39
41
  HANDOFF_TOOL_NAME,
40
42
  "issue_refund",
@@ -93,18 +93,15 @@ describeAgent(deployedDef, (run) => {
93
93
  describe("the agent", () => {
94
94
  test("deploys with its tools, routes and workflows", () => {
95
95
  expect(expectDeployable(deployedDef).name).toBe("Front Door");
96
- expect(Object.keys(deployedDef.tools ?? {}).sort()).toEqual(["leave_message", "link_phone"]);
97
- expect(Object.keys(deployedDef.routes ?? {}).sort()).toEqual([
98
- "GET /pair/:runId",
99
- "POST /digest",
100
- "POST /pair",
101
- "POST /ring",
102
- ]);
103
- expect(Object.keys(deployedDef.workflows ?? {}).sort()).toEqual([
104
- "announce",
105
- "digest",
106
- "pair",
107
- ]);
96
+ expect(
97
+ Object.keys(deployedDef.tools ?? {}).sort((a, b) => Number(a > b) - Number(a < b)),
98
+ ).toEqual(["leave_message", "link_phone"]);
99
+ expect(
100
+ Object.keys(deployedDef.routes ?? {}).sort((a, b) => Number(a > b) - Number(a < b)),
101
+ ).toEqual(["GET /pair/:runId", "POST /digest", "POST /pair", "POST /ring"]);
102
+ expect(
103
+ Object.keys(deployedDef.workflows ?? {}).sort((a, b) => Number(a > b) - Number(a < b)),
104
+ ).toEqual(["announce", "digest", "pair"]);
108
105
  });
109
106
  });
110
107
 
@@ -51,7 +51,9 @@ describeAgent(deployedDef, (run) => {
51
51
  test("declares its prompt, its builtins and both workflows", () => {
52
52
  const config = expectDeployable(deployedDef);
53
53
  expect(config.name).toBe("Home Assistant");
54
- expect(Object.keys(deployedDef.workflows ?? {}).sort()).toEqual(["remind", "research"]);
54
+ expect(
55
+ Object.keys(deployedDef.workflows ?? {}).sort((a, b) => Number(a > b) - Number(a < b)),
56
+ ).toEqual(["remind", "research"]);
55
57
  // Every builtin the prompt names is one the agent declared.
56
58
  expect(() => expectPromptBuiltinsDeclared(deployedDef)).not.toThrow();
57
59
  });
@@ -69,7 +71,9 @@ describeAgent(deployedDef, (run) => {
69
71
  });
70
72
 
71
73
  test("the custom tools are exactly tools/, and none shadows a builtin", () => {
72
- const tools = Object.keys(deployedDef.tools ?? {}).sort();
74
+ const tools = Object.keys(deployedDef.tools ?? {}).sort(
75
+ (a, b) => Number(a > b) - Number(a < b),
76
+ );
73
77
  expect(tools).toEqual(["cancel_reminders", "deep_research", "remind_me", "stop"]);
74
78
  for (const name of tools) expect(agentDef.builtinTools).not.toContain(name);
75
79
  });
@@ -93,10 +97,9 @@ describeAgent(deployedDef, (run) => {
93
97
  });
94
98
 
95
99
  test("are the pair the page reads and cancels through", () => {
96
- expect(Object.keys(agentDef.routes ?? {}).sort()).toEqual([
97
- "DELETE /tasks/:runId",
98
- "GET /tasks",
99
- ]);
100
+ expect(
101
+ Object.keys(agentDef.routes ?? {}).sort((a, b) => Number(a > b) - Number(a < b)),
102
+ ).toEqual(["DELETE /tasks/:runId", "GET /tasks"]);
100
103
  });
101
104
 
102
105
  test("list this speaker's reminders and research, a research run with its newest line", async () => {
@@ -814,7 +814,8 @@ describeAgent(agentDef, (run) => {
814
814
  const stranger = expectToolOk(
815
815
  await run(takeGuestMessage, { ...args, recipient: "Nobody Here" }, ctx),
816
816
  );
817
- const shape = (r: Record<string, unknown>) => Object.keys(r).sort();
817
+ const shape = (r: Record<string, unknown>) =>
818
+ Object.keys(r).sort((a, b) => Number(a > b) - Number(a < b));
818
819
  expect(shape(guest)).toEqual(shape(stranger));
819
820
  for (const result of [guest, stranger]) {
820
821
  // Neither the verdict nor the room number the ledger knows reaches the model.
@@ -127,7 +127,11 @@ export function changedFields(d: BookingDraft, booking: RoomBooking, room: Room)
127
127
  // unchanged — the whole point of moving an unhappy guest.
128
128
  if (d.roomType !== null && (d.roomType !== room.type || d.view !== null)) changed.push("room");
129
129
  if (d.smoking !== room.smoking) changed.push("smoking");
130
- if ([...d.extras].sort().join() !== [...booking.extras].sort().join()) changed.push("extras");
130
+ if (
131
+ [...d.extras].sort((a, b) => Number(a > b) - Number(a < b)).join() !==
132
+ [...booking.extras].sort((a, b) => Number(a > b) - Number(a < b)).join()
133
+ )
134
+ changed.push("extras");
131
135
  return changed;
132
136
  }
133
137
 
@@ -58,6 +58,16 @@ function overlaps(
58
58
  return !(a.checkOut <= checkIn || a.checkIn >= checkOut);
59
59
  }
60
60
 
61
+ /** The later of two ISO dates. Not `Math.max`, which coerces a date string to `NaN`. */
62
+ function laterDate(a: string, b: string): string {
63
+ return a.localeCompare(b) >= 0 ? a : b;
64
+ }
65
+
66
+ /** The earlier of two ISO dates; see {@link laterDate}. */
67
+ function earlierDate(a: string, b: string): string {
68
+ return a.localeCompare(b) <= 0 ? a : b;
69
+ }
70
+
61
71
  /** Is `room` free for the whole window, ignoring the booking `exclude` names? */
62
72
  function roomFree(
63
73
  state: FrozenHotelState,
@@ -222,7 +232,7 @@ export function bookRoom(state: HotelState, input: BookRoomInput): RoomBooking |
222
232
  return toolFailure(`sold out: no ${what.replaceAll("_", " ")} is free for those dates`);
223
233
  }
224
234
  const nights = daysBetween(input.checkIn, input.checkOut);
225
- const extras = [...input.extras].sort();
235
+ const extras = [...input.extras].sort((a, b) => Number(a > b) - Number(a < b));
226
236
  const priced = computeInvoice(room.nightlyRate, nights, extras);
227
237
  const booking: RoomBooking = {
228
238
  code: mintCode("HTL", takenCodes(state)),
@@ -272,7 +282,7 @@ export const updateBooking = failable(
272
282
  return toolFailure(`sold out: no ${what.replaceAll("_", " ")} is free for those dates`);
273
283
  }
274
284
  const nights = daysBetween(input.checkIn, input.checkOut);
275
- const extras = [...input.extras].sort();
285
+ const extras = [...input.extras].sort((a, b) => Number(a > b) - Number(a < b));
276
286
  const priced = computeInvoice(room.nightlyRate, nights, extras);
277
287
  booking.roomId = room.id;
278
288
  booking.checkIn = input.checkIn;
@@ -328,8 +338,8 @@ export function roomConflict(
328
338
  );
329
339
  if (b === undefined) return null;
330
340
  return {
331
- from: a.checkIn > b.checkIn ? a.checkIn : b.checkIn,
332
- to: a.checkOut < b.checkOut ? a.checkOut : b.checkOut,
341
+ from: laterDate(a.checkIn, b.checkIn),
342
+ to: earlierDate(a.checkOut, b.checkOut),
333
343
  };
334
344
  }
335
345
 
@@ -353,7 +363,7 @@ export const resolveRoomConflict = failable(
353
363
  return toolFailure("no room conflict on this booking - nothing to resolve");
354
364
  }
355
365
  const original = orFail(requireFloorPlanRoom(state, booking.roomId));
356
- const start = booking.checkIn > TODAY ? booking.checkIn : TODAY;
366
+ const start = laterDate(booking.checkIn, TODAY);
357
367
 
358
368
  // Their `_SQL_FREE_BETTER_ROOM`: fits the party, matches smoking, same or
359
369
  // higher rate, free for the whole remaining stay, cheapest first.
@@ -880,7 +880,7 @@ export function seedHotel(today: string): HotelSeed {
880
880
  checkIn,
881
881
  checkOut: addDays(checkIn, nights),
882
882
  guests,
883
- extras: [...extras].sort(),
883
+ extras: [...extras].sort((a, b) => Number(a > b) - Number(a < b)),
884
884
  total: priced.total,
885
885
  cardLast4: card4,
886
886
  status,
@@ -38,11 +38,9 @@ describeAgent(agentDef, (run) => {
38
38
  describe("the agent", () => {
39
39
  test("deploys with its three tools and the history route", () => {
40
40
  expect(expectDeployable(agentDef).name).toBe("Kitchen Coach");
41
- expect(Object.keys(agentDef.tools ?? {}).sort()).toEqual([
42
- "get_kitchen",
43
- "scale_amount",
44
- "start_timer",
45
- ]);
41
+ expect(
42
+ Object.keys(agentDef.tools ?? {}).sort((a, b) => Number(a > b) - Number(a < b)),
43
+ ).toEqual(["get_kitchen", "scale_amount", "start_timer"]);
46
44
  expect(Object.keys(agentDef.routes ?? {})).toEqual(["GET /history"]);
47
45
  });
48
46
 
@@ -207,7 +207,7 @@ describeAgent(agentDef, (run) => {
207
207
  await run(setupCharacter, SETUP_ARGS, ctx);
208
208
  const state = gameSlot.get(ctx);
209
209
  const stats = [state.edge, state.heart, state.iron, state.shadow, state.wits];
210
- expect([...stats].sort()).toEqual([1, 1, 2, 2, 3]);
210
+ expect([...stats].sort((a, b) => Number(a > b) - Number(a < b))).toEqual([1, 1, 2, 2, 3]);
211
211
  // investigator biases wits (index 4) to the high stat
212
212
  expect(state.wits).toBe(3);
213
213
  });
@@ -40,7 +40,9 @@ export interface Doc {
40
40
 
41
41
  export const DOCS: Doc[] = docs;
42
42
 
43
- export const TOPICS: string[] = [...new Set(DOCS.map((doc) => doc.topic))].sort();
43
+ export const TOPICS: string[] = [...new Set(DOCS.map((doc) => doc.topic))].sort(
44
+ (a, b) => Number(a > b) - Number(a < b),
45
+ );
44
46
 
45
47
  // ─── Retrieval ───────────────────────────────────────────────────────────────
46
48