@alexkroman1/aai-cli 13.3.0 → 15.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.
Files changed (158) hide show
  1. package/dist/{_agent-Clbq3a4h.mjs → _agent-BzUeqOdj.mjs} +32 -9
  2. package/dist/_agent.d.ts +23 -0
  3. package/dist/_artifacts-BJOYGQPp.mjs +21 -0
  4. package/dist/_artifacts.d.ts +16 -0
  5. package/dist/_build-target.d.ts +172 -0
  6. package/dist/{_bundler-DEkjO1d8.mjs → _bundler-DM0d0M7m.mjs} +8 -7
  7. package/dist/_cli-common.d.ts +45 -6
  8. package/dist/{_config-ZY2euhdh.mjs → _config-DYzC6WMD.mjs} +2 -2
  9. package/dist/_dev-env.d.ts +1 -1
  10. package/dist/{_dev-server-C13xuGB1.mjs → _dev-server-BzWB6-4y.mjs} +25 -24
  11. package/dist/_dev-vite-config.d.ts +3 -3
  12. package/dist/_e2e-test-utils.d.ts +1 -1
  13. package/dist/{_init-Ci4QGjp8.mjs → _init-Bsi3DZNJ.mjs} +9 -23
  14. package/dist/{_output-DbJt9gsl.mjs → _output-DBP9Op_d.mjs} +22 -13
  15. package/dist/_output.d.ts +10 -9
  16. package/dist/{_preflight-B2laWPdU.mjs → _preflight-CcAR577V.mjs} +2 -2
  17. package/dist/_resource-commands.d.ts +9 -9
  18. package/dist/_server-common-De0haHr9.mjs +70 -0
  19. package/dist/_server-common.d.ts +20 -1
  20. package/dist/{_slug-api-DlKpj91X.mjs → _slug-api-CGvc2YSQ.mjs} +18 -9
  21. package/dist/_slug-api.d.ts +19 -0
  22. package/dist/{_studio-DTi3EdXQ.mjs → _studio-DnR_BqFp.mjs} +7 -3
  23. package/dist/_studio-commands.d.ts +13 -13
  24. package/dist/{_templates-V4l5sZJy.mjs → _templates-CIlJ3Vay.mjs} +4 -4
  25. package/dist/_templates.d.ts +1 -1
  26. package/dist/{_typecheck-gate-sV4N5F93.mjs → _typecheck-gate-U3jcil8L.mjs} +3 -2
  27. package/dist/_typecheck-gate.d.ts +3 -1
  28. package/dist/{_utils-Dhd058D9.mjs → _utils-D5JGcjiW.mjs} +43 -1
  29. package/dist/_utils.d.ts +35 -0
  30. package/dist/_vercel-output.d.ts +63 -0
  31. package/dist/{_workflow-determinism-C9l8uC2R.mjs → _workflow-determinism-CvpqMpdh.mjs} +18 -26
  32. package/dist/_workflow-determinism.d.ts +3 -3
  33. package/dist/build-BhEaxBPu.mjs +481 -0
  34. package/dist/build.d.ts +23 -10
  35. package/dist/cli.d.ts +1 -2
  36. package/dist/cli.mjs +155 -138
  37. package/dist/{client-bundler-CT-_26c5.mjs → client-bundler-6mTLs6ny.mjs} +5 -5
  38. package/dist/client-bundler.d.ts +1 -1
  39. package/dist/client-bundler.mjs +1 -1
  40. package/dist/{delete-RqlQZ6Y_.mjs → delete-BdFnbnVR.mjs} +4 -4
  41. package/dist/{deploy-B7f3CK7v.mjs → deploy-CGqPU5U-.mjs} +11 -11
  42. package/dist/{dev-DamXieW_.mjs → dev-Bx9gYBHM.mjs} +3 -3
  43. package/dist/{eval-h3DTVfRw.mjs → eval-B3I7FqN9.mjs} +3 -3
  44. package/dist/{init-D-vFrV8h.mjs → init-CFyusRbq.mjs} +48 -20
  45. package/dist/init.d.ts +14 -0
  46. package/dist/{login-CDiemNmC.mjs → login-DaLrPOFg.mjs} +4 -6
  47. package/dist/{logs-DGwPNCzB.mjs → logs-7BRwq0cG.mjs} +21 -14
  48. package/dist/project-config.mjs +1 -1
  49. package/dist/scaffold/CLAUDE.md +155 -76
  50. package/dist/scaffold/package.json +6 -6
  51. package/dist/{secret-V1w7y9-j.mjs → secret-Cjp912yF.mjs} +5 -5
  52. package/dist/secret.d.ts +8 -6
  53. package/dist/start.d.ts +112 -0
  54. package/dist/start.mjs +156 -0
  55. package/dist/{studio-BpMCfUNx.mjs → studio-C_zuRC_z.mjs} +13 -15
  56. package/dist/templates/briefing-desk/agent.eval.test.ts +156 -0
  57. package/dist/templates/call-audit/agent.test.ts +11 -6
  58. package/dist/templates/call-audit/agent.ts +2 -2
  59. package/dist/templates/call-audit/client.tsx +27 -42
  60. package/dist/templates/call-audit/workflows/audit.ts +7 -5
  61. package/dist/templates/call-audit/workflows/ingest.ts +7 -7
  62. package/dist/templates/call-audit/workflows/media.ts +12 -37
  63. package/dist/templates/call-audit/workflows/summarize.ts +8 -8
  64. package/dist/templates/call-audit/workflows/sync-api.ts +3 -3
  65. package/dist/templates/code-interpreter/agent.test.ts +103 -0
  66. package/dist/templates/dispatch-center/agent.test.ts +7 -7
  67. package/dist/templates/dispatch-center/client.tsx +53 -61
  68. package/dist/templates/dispatch-center/shared.ts +0 -8
  69. package/dist/templates/dispatch-center/tools/ops_dashboard.ts +4 -1
  70. package/dist/templates/embedded-assets/agent.eval.test.ts +4 -2
  71. package/dist/templates/health-assistant/agent.eval.test.ts +4 -2
  72. package/dist/templates/infocom-adventure/client.tsx +40 -36
  73. package/dist/templates/link-digest/agent.test.ts +3 -3
  74. package/dist/templates/link-digest/agent.ts +2 -2
  75. package/dist/templates/link-digest/client.tsx +81 -19
  76. package/dist/templates/link-digest/workflows/digest.ts +13 -16
  77. package/dist/templates/math-buddy/agent.test.ts +126 -0
  78. package/dist/templates/night-owl/agent.eval.test.ts +4 -2
  79. package/dist/templates/night-owl/client.tsx +8 -2
  80. package/dist/templates/personal-finance/agent.test.ts +127 -0
  81. package/dist/templates/pipeline-simple/agent.test.ts +2 -2
  82. package/dist/templates/pizza-ordering/client.tsx +5 -4
  83. package/dist/templates/pizza-ordering/shared.ts +3 -8
  84. package/dist/templates/pizza-ordering/tools/add_pizza.ts +3 -2
  85. package/dist/templates/pizza-ordering/tools/place_order.ts +3 -2
  86. package/dist/templates/pizza-ordering/tools/remove_pizza.ts +3 -2
  87. package/dist/templates/pizza-ordering/tools/update_pizza.ts +3 -2
  88. package/dist/templates/pizza-ordering/tools/view_order.ts +3 -2
  89. package/dist/templates/plan-and-execute/agent.test.ts +10 -5
  90. package/dist/templates/plan-and-execute/client.tsx +2 -2
  91. package/dist/templates/podcast-digest/agent.test.ts +20 -11
  92. package/dist/templates/podcast-digest/client.tsx +16 -22
  93. package/dist/templates/podcast-digest/workflows/digest.ts +21 -19
  94. package/dist/templates/podcast-digest/workflows/feeds.ts +61 -33
  95. package/dist/templates/podcast-digest/workflows/slack.ts +7 -7
  96. package/dist/templates/recap-workflow/agent.eval.test.ts +21 -13
  97. package/dist/templates/recap-workflow/agent.test.ts +27 -23
  98. package/dist/templates/recap-workflow/workflows/recap.ts +24 -28
  99. package/dist/templates/redline/agent.eval.test.ts +5 -8
  100. package/dist/templates/redline/agent.test.ts +1 -1
  101. package/dist/templates/redline/client.tsx +36 -34
  102. package/dist/templates/redline/workflows/redline.ts +17 -17
  103. package/dist/templates/research-workflow/agent.eval.test.ts +5 -5
  104. package/dist/templates/research-workflow/agent.test.ts +10 -7
  105. package/dist/templates/research-workflow/workflows/research.ts +28 -30
  106. package/dist/templates/retail/agent.test.ts +17 -15
  107. package/dist/templates/retail/cancel.ts +7 -6
  108. package/dist/templates/retail/client.tsx +39 -58
  109. package/dist/templates/retail/payment.ts +4 -3
  110. package/dist/templates/retail/pending.test.ts +19 -19
  111. package/dist/templates/retail/store.test.ts +5 -5
  112. package/dist/templates/retail/swap.ts +8 -11
  113. package/dist/templates/solo-rpg/agent.eval.test.ts +2 -16
  114. package/dist/templates/solo-rpg/agent.test.ts +12 -12
  115. package/dist/templates/solo-rpg/client.tsx +3 -3
  116. package/dist/templates/spoken-summary/agent.test.ts +9 -9
  117. package/dist/templates/spoken-summary/agent.ts +3 -3
  118. package/dist/templates/spoken-summary/client.tsx +23 -30
  119. package/dist/templates/spoken-summary/workflows/summarize.ts +11 -11
  120. package/dist/templates/spoken-summary/workflows/transcribe.ts +14 -14
  121. package/dist/templates/support-line/agent.ts +8 -0
  122. package/dist/templates/support-line/client.tsx +4 -3
  123. package/dist/templates/support-line/prompts.ts +0 -2
  124. package/dist/templates/transcription-workflow/agent.test.ts +20 -12
  125. package/dist/templates/transcription-workflow/agent.ts +2 -2
  126. package/dist/templates/transcription-workflow/client.tsx +15 -14
  127. package/dist/templates/transcription-workflow/recover.ts +1 -1
  128. package/dist/templates/transcription-workflow/run-panel.tsx +34 -14
  129. package/dist/templates/transcription-workflow/total-latency.tsx +46 -20
  130. package/dist/templates/transcription-workflow/workflows/batch.ts +15 -15
  131. package/dist/templates/transcription-workflow/workflows/downsample.ts +1 -1
  132. package/dist/templates/transcription-workflow/workflows/normalize.ts +15 -19
  133. package/dist/templates/transcription-workflow/workflows/stream.ts +12 -12
  134. package/dist/templates/transcription-workflow/workflows/sync-api.ts +3 -3
  135. package/dist/templates/transcription-workflow/workflows/transcribe.ts +23 -34
  136. package/dist/templates/travel-concierge/agent.eval.test.ts +2 -2
  137. package/dist/templates/travel-concierge/agent.test.ts +15 -7
  138. package/dist/templates/travel-concierge/client.tsx +2 -2
  139. package/dist/templates/travel-concierge/routing.ts +64 -55
  140. package/dist/templates/travel-concierge/shared.ts +10 -14
  141. package/dist/templates/travel-concierge/tools/cancel_action.ts +3 -1
  142. package/dist/templates/travel-concierge/tools/complete_or_escalate.ts +3 -1
  143. package/dist/templates/travel-concierge/tools/confirm_action.ts +3 -1
  144. package/dist/templates/travel-concierge/tools/lookup_booking.ts +4 -3
  145. package/dist/templates/travel-concierge/tools/search_car_rentals.ts +3 -2
  146. package/dist/templates/travel-concierge/tools/search_excursions.ts +3 -2
  147. package/dist/templates/travel-concierge/tools/search_flights.ts +3 -2
  148. package/dist/templates/travel-concierge/tools/search_hotels.ts +3 -2
  149. package/dist/templates/web-researcher/agent.test.ts +130 -0
  150. package/dist/{test-guenJUxi.mjs → test-D032V2cA.mjs} +4 -17
  151. package/dist/typecheck.mjs +1 -1
  152. package/dist/worker-bundler.d.ts +1 -1
  153. package/dist/worker-bundler.mjs +8 -8
  154. package/dist/{workflow-BZyKLkhV.mjs → workflow-CVioyO3V.mjs} +6 -5
  155. package/package.json +9 -4
  156. package/dist/_server-common-BV4_CrP3.mjs +0 -43
  157. package/dist/build-CWyFGe-W.mjs +0 -69
  158. package/dist/scaffold/server.mjs +0 -204
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env node
2
- import { a as ok } from "./_output-DbJt9gsl.mjs";
2
+ import { a as ok } from "./_output-DBP9Op_d.mjs";
3
3
  import { n as log } from "./_ui-DCt4qZrk.mjs";
4
- import { l as writeProjectConfig } from "./_config-ZY2euhdh.mjs";
5
- import { a as resolveDeployTarget, i as requireDeployedSlug } from "./_agent-Clbq3a4h.mjs";
6
- import { d as apiTestSeam, l as HINT_NOT_DEPLOYED, s as studioProjectApiUrl, u as apiRequest } from "./_studio-DTi3EdXQ.mjs";
4
+ import { l as writeProjectConfig } from "./_config-DYzC6WMD.mjs";
5
+ import { i as requireDeployedSlug, o as resolveDeployTarget } from "./_agent-BzUeqOdj.mjs";
6
+ import { d as apiTestSeam, l as HINT_NOT_DEPLOYED, s as studioProjectApiUrl, u as apiRequest } from "./_studio-DnR_BqFp.mjs";
7
7
  import { omitUndefined } from "@alexkroman1/aai/utils";
8
8
  //#region src/delete.ts
9
9
  async function runDelete(opts) {
@@ -1,14 +1,14 @@
1
1
  #!/usr/bin/env node
2
- import { a as ok } from "./_output-DbJt9gsl.mjs";
2
+ import { a as ok } from "./_output-DBP9Op_d.mjs";
3
3
  import { n as log, r as notify, t as fmtUrl } from "./_ui-DCt4qZrk.mjs";
4
- import { o as errorMessage$1 } from "./_utils-Dhd058D9.mjs";
5
- import { s as updateProjectConfig } from "./_config-ZY2euhdh.mjs";
6
- import { i as evalWorkerConfig, t as buildAgentBundle } from "./_bundler-DEkjO1d8.mjs";
7
- import { t as resolveServerEnv } from "./_server-common-BV4_CrP3.mjs";
8
- import { a as resolveDeployTarget } from "./_agent-Clbq3a4h.mjs";
9
- import { assertTypechecks } from "./_typecheck-gate-sV4N5F93.mjs";
10
- import { n as scanWorkflowDeterminism, t as determinismWarnings } from "./_workflow-determinism-C9l8uC2R.mjs";
11
- import { d as apiTestSeam, f as checkedResponse, i as projectNameFromDir, u as apiRequest } from "./_studio-DTi3EdXQ.mjs";
4
+ import { s as errorMessage$1 } from "./_utils-D5JGcjiW.mjs";
5
+ import { s as updateProjectConfig } from "./_config-DYzC6WMD.mjs";
6
+ import { n as resolveServerEnv } from "./_server-common-De0haHr9.mjs";
7
+ import { i as evalWorkerConfig, t as buildAgentBundle } from "./_bundler-DM0d0M7m.mjs";
8
+ import { o as resolveDeployTarget } from "./_agent-BzUeqOdj.mjs";
9
+ import { assertTypechecks } from "./_typecheck-gate-U3jcil8L.mjs";
10
+ import { n as scanWorkflowDeterminism, t as determinismWarnings } from "./_workflow-determinism-CvpqMpdh.mjs";
11
+ import { d as apiTestSeam, f as checkedResponse, i as projectNameFromDir, u as apiRequest } from "./_studio-DnR_BqFp.mjs";
12
12
  import { isRecord, omitUndefined } from "@alexkroman1/aai/utils";
13
13
  import { gzipSync } from "node:zlib";
14
14
  //#region src/_deploy.ts
@@ -40,8 +40,8 @@ async function runDeploy(opts) {
40
40
  async function executeDeploy(opts) {
41
41
  const { cwd } = opts;
42
42
  const { config: projectConfig, serverUrl, apiKey } = await resolveDeployTarget(cwd, opts.server);
43
- if (!opts.skipTypecheck) await assertTypechecks(cwd);
44
- const preflightModule = import("./_preflight-B2laWPdU.mjs");
43
+ await assertTypechecks(cwd, { skip: opts.skipTypecheck });
44
+ const preflightModule = import("./_preflight-CcAR577V.mjs");
45
45
  const bundle = await buildAgentBundle(cwd, { minify: true });
46
46
  const slug = projectConfig?.slug ?? projectNameFromDir(cwd) ?? void 0;
47
47
  const uploadEnv = {
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
- import { a as ok } from "./_output-DbJt9gsl.mjs";
2
+ import { a as ok } from "./_output-DBP9Op_d.mjs";
3
3
  import { a as parsePort, n as log, r as notify, t as fmtUrl } from "./_ui-DCt4qZrk.mjs";
4
- import { a as errorDetail } from "./_utils-Dhd058D9.mjs";
4
+ import { o as errorDetail } from "./_utils-D5JGcjiW.mjs";
5
5
  import path from "node:path";
6
6
  import { styleText } from "node:util";
7
7
  //#region src/dev.ts
@@ -12,7 +12,7 @@ import { styleText } from "node:util";
12
12
  async function executeDev(opts) {
13
13
  const port = parsePort(opts.port);
14
14
  const agentName = path.basename(path.resolve(opts.cwd));
15
- const { startDevServer } = await import("./_dev-server-C13xuGB1.mjs");
15
+ const { startDevServer } = await import("./_dev-server-BzWB6-4y.mjs");
16
16
  let cleanup;
17
17
  let shuttingDown = false;
18
18
  const onSignal = () => {
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
- import { a as ok, n as fail } from "./_output-DbJt9gsl.mjs";
2
+ import { a as ok, n as fail } from "./_output-DBP9Op_d.mjs";
3
3
  import { n as log } from "./_ui-DCt4qZrk.mjs";
4
- import { t as resolveServerEnv } from "./_server-common-BV4_CrP3.mjs";
5
- import { classifyVitestError, runVitest } from "./test-guenJUxi.mjs";
4
+ import { n as resolveServerEnv } from "./_server-common-De0haHr9.mjs";
5
+ import { classifyVitestError, runVitest } from "./test-D032V2cA.mjs";
6
6
  //#region src/eval.ts
7
7
  /**
8
8
  * `aai eval` — run the agent's behaviour evals via vitest.
@@ -1,8 +1,9 @@
1
1
  #!/usr/bin/env node
2
- import { a as ok } from "./_output-DbJt9gsl.mjs";
2
+ import { a as ok } from "./_output-DBP9Op_d.mjs";
3
3
  import { n as log, s as unwrapCancel } from "./_ui-DCt4qZrk.mjs";
4
- import { d as resolveCwd, l as readJson, o as errorMessage$1, s as fileExists, t as AGENT_ENTRY } from "./_utils-Dhd058D9.mjs";
5
- import { r as isDevMode, t as getMonorepoRoot } from "./_agent-Clbq3a4h.mjs";
4
+ import { c as fileExists, d as readJson, p as resolveCwd, s as errorMessage$1, t as AGENT_ENTRY } from "./_utils-D5JGcjiW.mjs";
5
+ import { r as isDevMode, t as getMonorepoRoot } from "./_agent-BzUeqOdj.mjs";
6
+ import { listTemplates } from "./_templates-CIlJ3Vay.mjs";
6
7
  import path from "node:path";
7
8
  import { omitUndefined } from "@alexkroman1/aai/utils";
8
9
  import { styleText } from "node:util";
@@ -39,6 +40,41 @@ async function promptProjectName(yes) {
39
40
  defaultValue: DEFAULT_PROJECT_NAME
40
41
  }), "Setup cancelled") || DEFAULT_PROJECT_NAME;
41
42
  }
43
+ /**
44
+ * The template a non-interactive `init` gets, and the entry the selector opens
45
+ * on — so an author who just presses Enter lands where they used to.
46
+ */
47
+ const DEFAULT_TEMPLATE = "simple";
48
+ /**
49
+ * Ask which template to scaffold, listing what this CLI actually ships.
50
+ *
51
+ * The options are derived from {@link listTemplates} rather than a roster kept
52
+ * here: that function already backs `aai templates` AND the unknown-template
53
+ * error, so a template added to the package shows up in the picker with no
54
+ * second list to update. {@link DEFAULT_TEMPLATE} is hoisted to the top and
55
+ * pre-selected, which is what keeps a bare `aai init` a single Enter away from
56
+ * the project it produced before there was a picker.
57
+ *
58
+ * Callers must not reach here when there is nobody to answer — `--yes` and
59
+ * JSON mode (auto-detected on a pipe) resolve the default without prompting.
60
+ */
61
+ async function promptTemplate(list = listTemplates) {
62
+ const [first, ...rest] = await list();
63
+ if (first === void 0) return DEFAULT_TEMPLATE;
64
+ if (rest.length === 0) return first;
65
+ const names = [first, ...rest];
66
+ const hasDefault = names.includes(DEFAULT_TEMPLATE);
67
+ const ordered = hasDefault ? [DEFAULT_TEMPLATE, ...names.filter((name) => name !== DEFAULT_TEMPLATE)] : names;
68
+ return unwrapCancel(await p.select({
69
+ message: "Which template?",
70
+ maxItems: 12,
71
+ initialValue: hasDefault ? DEFAULT_TEMPLATE : first,
72
+ options: ordered.map((name) => name === DEFAULT_TEMPLATE ? {
73
+ value: name,
74
+ hint: "the default starting point"
75
+ } : { value: name })
76
+ }), "Setup cancelled");
77
+ }
42
78
  /** Best-effort corepack enable so pnpm is available (scaffold declares packageManager: pnpm). */
43
79
  async function ensurePnpm() {
44
80
  await execa("corepack", ["enable"], { reject: false });
@@ -106,7 +142,7 @@ function collectWarnings() {
106
142
  }
107
143
  /** Publish after init and return deploy metadata if successful. */
108
144
  async function tryPublish(cwd, server, warn) {
109
- const { executePublish } = await import("./studio-BpMCfUNx.mjs");
145
+ const { executePublish } = await import("./studio-C_zuRC_z.mjs");
110
146
  try {
111
147
  const result = await executePublish({
112
148
  cwd,
@@ -127,7 +163,7 @@ async function tryPublish(cwd, server, warn) {
127
163
  }
128
164
  /** Scaffold the project, optionally showing a spinner. */
129
165
  async function scaffoldProject(dir, cwd, template, silent) {
130
- const { runInit } = await import("./_init-Ci4QGjp8.mjs");
166
+ const { runInit } = await import("./_init-Bsi3DZNJ.mjs");
131
167
  await withSpinner(silent, {
132
168
  start: `Creating ${dir}`,
133
169
  done: "Project created",
@@ -150,30 +186,22 @@ async function executeInit(opts, extra) {
150
186
  const monorepoRoot = getMonorepoRoot();
151
187
  const cwd = resolveTargetDir(dir);
152
188
  if (!opts.force && await fileExists(path.join(cwd, "agent.ts"))) throw new Error(`${AGENT_ENTRY} already exists in this directory. Use ${styleText("cyanBright", "--force")} to overwrite.`);
153
- const template = opts.template ?? "simple";
189
+ const template = opts.template ?? (opts.yes || suppressUi ? DEFAULT_TEMPLATE : await promptTemplate());
154
190
  const { warn, warnings } = collectWarnings();
155
191
  await scaffoldProject(dir, cwd, template, suppressUi);
156
192
  const installed = await installDeps(cwd, warn, suppressUi);
157
- let deployed = false;
158
- let slug;
159
- let url;
160
193
  if (!installed) warn("Skipping publish because dependencies were not installed.");
161
- else if (!opts.skipDeploy) {
162
- const published = await tryPublish(cwd, opts.server, warn);
163
- if (published) {
164
- deployed = true;
165
- slug = published.slug;
166
- url = published.url;
167
- }
168
- }
194
+ const published = installed && !opts.skipDeploy ? await tryPublish(cwd, opts.server, warn) : null;
169
195
  if (!suppressUi) printPostInitInfo(cwd, monorepoRoot);
170
196
  const data = {
171
197
  dir: cwd,
172
198
  template,
173
- deployed
199
+ deployed: published !== null
174
200
  };
175
- if (slug) data.slug = slug;
176
- if (url) data.url = url;
201
+ if (published) {
202
+ data.slug = published.slug;
203
+ data.url = published.url;
204
+ }
177
205
  if (warnings.length > 0) data.warnings = warnings;
178
206
  return ok(data);
179
207
  }
package/dist/init.d.ts CHANGED
@@ -17,6 +17,20 @@ type InitData = {
17
17
  */
18
18
  warnings?: string[];
19
19
  };
20
+ /**
21
+ * Ask which template to scaffold, listing what this CLI actually ships.
22
+ *
23
+ * The options are derived from {@link listTemplates} rather than a roster kept
24
+ * here: that function already backs `aai templates` AND the unknown-template
25
+ * error, so a template added to the package shows up in the picker with no
26
+ * second list to update. {@link DEFAULT_TEMPLATE} is hoisted to the top and
27
+ * pre-selected, which is what keeps a bare `aai init` a single Enter away from
28
+ * the project it produced before there was a picker.
29
+ *
30
+ * Callers must not reach here when there is nobody to answer — `--yes` and
31
+ * JSON mode (auto-detected on a pipe) resolve the default without prompting.
32
+ */
33
+ export declare function promptTemplate(list?: () => Promise<string[]>): Promise<string>;
20
34
  /** Build the command + args for running pnpm, routing through safe-chain when available. */
21
35
  export declare function resolvePnpmCommand(checkSafeChain?: () => Promise<boolean>): Promise<{
22
36
  cmd: string;
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
- import { a as ok, t as CliError } from "./_output-DbJt9gsl.mjs";
2
+ import { a as ok, t as CliError } from "./_output-DBP9Op_d.mjs";
3
3
  import { n as log } from "./_ui-DCt4qZrk.mjs";
4
- import { o as updateGlobalConfig, r as readGlobalConfig, t as approveServer } from "./_config-ZY2euhdh.mjs";
5
- import { o as resolveServerUrl } from "./_agent-Clbq3a4h.mjs";
4
+ import { o as updateGlobalConfig } from "./_config-DYzC6WMD.mjs";
5
+ import { a as resolveApprovedServer } from "./_agent-BzUeqOdj.mjs";
6
6
  import { linkConfirmationCode, sleep } from "@alexkroman1/aai/internal";
7
7
  import { spawn } from "node:child_process";
8
8
  import { randomBytes } from "node:crypto";
@@ -133,9 +133,7 @@ function defaultOpenBrowser(url) {
133
133
  async function executeLogin(opts, deps = {}) {
134
134
  const fetchFn = deps.fetchFn ?? globalThis.fetch;
135
135
  requireTty();
136
- const globalConfig = await readGlobalConfig();
137
- const serverUrl = resolveServerUrl(opts.server, void 0, globalConfig.approvedServers ?? []);
138
- if (opts.server) await approveServer(serverUrl);
136
+ const { serverUrl } = await resolveApprovedServer(null, opts.server);
139
137
  if ((await jsonBody(await reachable(fetchFn, `${serverUrl}/studio/auth`, serverUrl), "Reading the server's login configuration")).mode === "none") throw new CliError("login_unavailable", "This server has no browser login configured, so there is no account to link.", "Point `--server` at a platform with browser login configured — linking an account there is the only way to authenticate.");
140
138
  const code = randomBytes(32).toString("base64url");
141
139
  const linkUrl = `${serverUrl}/?cli-link=${code}`;
@@ -1,8 +1,9 @@
1
1
  #!/usr/bin/env node
2
- import { a as ok } from "./_output-DbJt9gsl.mjs";
2
+ import { a as ok } from "./_output-DBP9Op_d.mjs";
3
3
  import { n as log } from "./_ui-DCt4qZrk.mjs";
4
- import { f as checkedResponse } from "./_studio-DTi3EdXQ.mjs";
5
- import { n as slugRequest } from "./_slug-api-DlKpj91X.mjs";
4
+ import { n as getServerInfo } from "./_agent-BzUeqOdj.mjs";
5
+ import { f as checkedResponse } from "./_studio-DnR_BqFp.mjs";
6
+ import { n as slugRequestOn } from "./_slug-api-CGvc2YSQ.mjs";
6
7
  import { isRecord, omitUndefined } from "@alexkroman1/aai/utils";
7
8
  import { sleep } from "@alexkroman1/aai/internal";
8
9
  function isLogsPage(value) {
@@ -19,12 +20,16 @@ function formatLine(line) {
19
20
  const mark = line.stream === "stderr" ? " ERR" : "";
20
21
  return `${formatTime(line.at)}${mark} ${line.text}`;
21
22
  }
22
- async function readPage(cwd, after, server) {
23
- const { data, slug } = await slugRequest(cwd, `/logs?after=${after}`, { action: "logs" }, server);
24
- return {
25
- page: checkedResponse(data, isLogsPage, `the logs route for ${slug}`),
26
- slug
27
- };
23
+ /**
24
+ * One page, against a target resolved ONCE by the caller.
25
+ *
26
+ * `slugRequestOn` rather than `slugRequest`: under `--follow` this runs every
27
+ * second for the life of the command, and the target is immutable — see that
28
+ * function's doc for what re-resolving it cost.
29
+ */
30
+ async function readPage(target, after) {
31
+ const data = await slugRequestOn(target, `/logs?after=${after}`, { action: "logs" });
32
+ return checkedResponse(data, isLogsPage, `the logs route for ${target.slug}`);
28
33
  }
29
34
  /**
30
35
  * Print the agent's buffered output, once or continuously.
@@ -34,7 +39,9 @@ async function readPage(cwd, after, server) {
34
39
  * into a result object would duplicate what it just printed.
35
40
  */
36
41
  async function executeLogs(cwd, opts = {}) {
37
- const { page, slug } = await readPage(cwd, -1, opts.server);
42
+ const target = await getServerInfo(cwd, opts.server);
43
+ const { slug } = target;
44
+ const page = await readPage(target, -1);
38
45
  let cursor = page.cursor;
39
46
  let printed = printPage(page);
40
47
  if (!opts.follow) {
@@ -52,11 +59,11 @@ async function executeLogs(cwd, opts = {}) {
52
59
  while (!opts.signal?.aborted) {
53
60
  await sleep(pollMs, omitUndefined({ signal: opts.signal }));
54
61
  if (opts.signal?.aborted) break;
55
- const next = await readPage(cwd, cursor, opts.server).catch(() => void 0);
62
+ const next = await readPage(target, cursor).catch(() => void 0);
56
63
  if (!next) continue;
57
- cursor = next.page.cursor;
58
- running = next.page.running;
59
- printed += printPage(next.page);
64
+ cursor = next.cursor;
65
+ running = next.running;
66
+ printed += printPage(next);
60
67
  }
61
68
  return ok({
62
69
  slug,
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
- import { c as writeGlobalConfig, s as updateProjectConfig } from "./_config-ZY2euhdh.mjs";
2
+ import { c as writeGlobalConfig, s as updateProjectConfig } from "./_config-DYzC6WMD.mjs";
3
3
  export { updateProjectConfig, writeGlobalConfig as writeConfigHome };