@alexkroman1/aai-cli 2.0.0 → 3.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.
@@ -5,7 +5,7 @@ import path from "node:path";
5
5
  import { fileURLToPath } from "node:url";
6
6
  import { VALID_SLUG_RE } from "@alexkroman1/aai/utils";
7
7
  //#region _agent.ts
8
- const DEFAULT_SERVER = "https://aai-agent.fly.dev";
8
+ const DEFAULT_SERVER = "https://alexkroman--aai-server-web-server.modal.run";
9
9
  const DEFAULT_DEV_SERVER = "http://localhost:8080";
10
10
  let _cachedMonorepoRoot;
11
11
  function getMonorepoRoot() {
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { n as log, u as ok } from "./_ui-CKEIHAtB.mjs";
3
3
  import { c as validateAgentExport, r as errorMessage } from "./_utils-C502jKo8.mjs";
4
- import { t as buildClient } from "./client-bundler-BO1Wm1wT.mjs";
4
+ import { t as buildClient } from "./client-bundler-B5HYJYYP.mjs";
5
5
  import { buildWorker } from "./worker-bundler.mjs";
6
6
  import path from "node:path";
7
7
  import { pathToFileURL } from "node:url";
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env node
2
2
  import { n as log } from "./_ui-CKEIHAtB.mjs";
3
3
  import { r as errorMessage, t as errorCode } from "./_utils-C502jKo8.mjs";
4
- import { n as fallbackHtmlPlugin } from "./client-bundler-BO1Wm1wT.mjs";
4
+ import { n as fallbackHtmlPlugin } from "./client-bundler-B5HYJYYP.mjs";
5
5
  import { buildWorker } from "./worker-bundler.mjs";
6
- import { createWorkerEvaluator } from "./_bundler-z6wTRMX8.mjs";
6
+ import { createWorkerEvaluator } from "./_bundler-Bp2vFV16.mjs";
7
7
  import { n as ensureApiKey } from "./_config-BWYgLjiI.mjs";
8
8
  import { t as resolveServerEnv } from "./_server-common-Bv-4Rskq.mjs";
9
9
  import { createRequire } from "node:module";
@@ -263,7 +263,6 @@ function viteDevConfig(cwd, vitePort, backendPort) {
263
263
  proxy: {
264
264
  "/health": target,
265
265
  "/client-config": target,
266
- "/sync": target,
267
266
  "/websocket": {
268
267
  target,
269
268
  ws: true
@@ -301,7 +300,6 @@ async function startDevServer(opts) {
301
300
  name: agentDef.name,
302
301
  env: hostModeEnv(providerEnv),
303
302
  hostBaseAgent: agentDef,
304
- ...agentDef.kind !== void 0 ? { kind: agentDef.kind } : {},
305
303
  greeting: agentDef.greeting,
306
304
  ...clientDirOpt
307
305
  });
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { a as isEexist, l as writeJson, o as readJson, r as errorMessage } from "./_utils-C502jKo8.mjs";
3
- import { r as isDevMode, t as getMonorepoRoot } from "./_agent-Ds5LyAq5.mjs";
3
+ import { r as isDevMode, t as getMonorepoRoot } from "./_agent-4rsUGPhx.mjs";
4
4
  import { existsSync } from "node:fs";
5
5
  import path from "node:path";
6
6
  import fs from "node:fs/promises";
@@ -11,9 +11,8 @@
11
11
  * - `aai dev` rebuilds on every file change, so the first rebuild would flip
12
12
  * the dev server into production mode.
13
13
  * - The platform studio builds inside the server process, where flipping
14
- * NODE_ENV makes the sandbox demand gVisor ("gVisor (runsc) is required in
15
- * production but not found on PATH") and refuse every subsequent deploy on a
16
- * dev machine.
14
+ * NODE_ENV switches the server into production behavior (strict credential
15
+ * and storage checks) and breaks every subsequent deploy on a dev machine.
17
16
  *
18
17
  * Snapshot and restore rather than pinning a value: callers that legitimately
19
18
  * run with NODE_ENV=production must keep it.
package/dist/cli.mjs CHANGED
@@ -119,7 +119,7 @@ const init = defineCommand({
119
119
  },
120
120
  async run({ args }) {
121
121
  await runCommand(args, async (mode) => {
122
- const { executeInit } = await import("./init-BC7sUpmo.mjs");
122
+ const { executeInit } = await import("./init-PIlI20Af.mjs");
123
123
  return executeInit({
124
124
  dir: args.dir,
125
125
  force: args.force,
@@ -143,7 +143,7 @@ const dev = defineCommand({
143
143
  async run({ args }) {
144
144
  await runCommand(args, async () => {
145
145
  const cwd = await setup({ agent: true });
146
- const { executeDev } = await import("./dev-MgeJANM3.mjs");
146
+ const { executeDev } = await import("./dev-DKDCcOb8.mjs");
147
147
  return executeDev({
148
148
  cwd,
149
149
  port: args.port
@@ -192,7 +192,7 @@ const build = defineCommand({
192
192
  throw toCliError(err);
193
193
  }
194
194
  }
195
- const { executeBuild } = await import("./_bundler-z6wTRMX8.mjs");
195
+ const { executeBuild } = await import("./_bundler-Bp2vFV16.mjs");
196
196
  return executeBuild(cwd);
197
197
  });
198
198
  }
@@ -209,7 +209,7 @@ const deploy = defineCommand({
209
209
  async run({ args }) {
210
210
  await runCommand(args, async () => {
211
211
  const cwd = await setup({ agent: true });
212
- const { executeDeploy } = await import("./deploy-b-3G8tdt.mjs");
212
+ const { executeDeploy } = await import("./deploy-kqBQT2kZ.mjs");
213
213
  return executeDeploy({
214
214
  cwd,
215
215
  ...args.server ? { server: args.server } : {}
@@ -229,7 +229,7 @@ const del = defineCommand({
229
229
  async run({ args }) {
230
230
  await runCommand(args, async () => {
231
231
  const cwd = await setup();
232
- const { executeDelete } = await import("./delete-CKNJodJg.mjs");
232
+ const { executeDelete } = await import("./delete-BHSeDVBT.mjs");
233
233
  return executeDelete({
234
234
  cwd,
235
235
  ...args.server ? { server: args.server } : {}
@@ -260,7 +260,7 @@ const secret = defineCommand({
260
260
  async run({ args }) {
261
261
  await runCommand(args, async (mode) => {
262
262
  const cwd = await setup();
263
- const { executeSecretPut, readStdin } = await import("./secret-Daqz2l7g.mjs");
263
+ const { executeSecretPut, readStdin } = await import("./secret-CJcR121q.mjs");
264
264
  const value = mode === "json" ? await readStdin() : void 0;
265
265
  if (mode === "json" && !value) throw new CliError("no_input", "No value provided", "Pipe secret value to stdin");
266
266
  return executeSecretPut(cwd, args.name, value, args.server);
@@ -284,7 +284,7 @@ const secret = defineCommand({
284
284
  async run({ args }) {
285
285
  await runCommand(args, async () => {
286
286
  const cwd = await setup();
287
- const { executeSecretDelete } = await import("./secret-Daqz2l7g.mjs");
287
+ const { executeSecretDelete } = await import("./secret-CJcR121q.mjs");
288
288
  return executeSecretDelete(cwd, args.name, args.server);
289
289
  });
290
290
  }
@@ -301,13 +301,90 @@ const secret = defineCommand({
301
301
  async run({ args }) {
302
302
  await runCommand(args, async () => {
303
303
  const cwd = await setup();
304
- const { executeSecretList } = await import("./secret-Daqz2l7g.mjs");
304
+ const { executeSecretList } = await import("./secret-CJcR121q.mjs");
305
305
  return executeSecretList(cwd, args.server);
306
306
  });
307
307
  }
308
308
  })
309
309
  }
310
310
  });
311
+ /** Resolve the working directory for a storage subcommand's optional [dir]. */
312
+ function resolveStorageCwd(dir) {
313
+ const cwd = resolveCwd();
314
+ return dir ? path.resolve(cwd, dir) : cwd;
315
+ }
316
+ const storageDir = {
317
+ type: "positional",
318
+ description: "Project directory",
319
+ required: false
320
+ };
321
+ const storage = defineCommand({
322
+ meta: {
323
+ name: "storage",
324
+ description: "Manage the agent's database (storage)"
325
+ },
326
+ subCommands: {
327
+ status: defineCommand({
328
+ meta: {
329
+ name: "status",
330
+ description: "Show whether storage is enabled"
331
+ },
332
+ args: {
333
+ dir: storageDir,
334
+ server: sharedArgs.server,
335
+ json: sharedArgs.json
336
+ },
337
+ async run({ args }) {
338
+ await runCommand(args, async () => {
339
+ const { executeStorageStatus } = await import("./storage-D0odnyBO.mjs");
340
+ return executeStorageStatus(resolveStorageCwd(args.dir), args.server);
341
+ });
342
+ }
343
+ }),
344
+ enable: defineCommand({
345
+ meta: {
346
+ name: "enable",
347
+ description: "Enable the agent's database (storage)"
348
+ },
349
+ args: {
350
+ dir: storageDir,
351
+ server: sharedArgs.server,
352
+ json: sharedArgs.json
353
+ },
354
+ async run({ args }) {
355
+ await runCommand(args, async () => {
356
+ const { executeStorageEnable } = await import("./storage-D0odnyBO.mjs");
357
+ return executeStorageEnable(resolveStorageCwd(args.dir), args.server);
358
+ });
359
+ }
360
+ }),
361
+ disable: defineCommand({
362
+ meta: {
363
+ name: "disable",
364
+ description: "Disable storage (DROPS the database schema and all its data)"
365
+ },
366
+ args: {
367
+ dir: storageDir,
368
+ force: {
369
+ type: "boolean",
370
+ alias: "f",
371
+ description: "Skip confirmation prompt"
372
+ },
373
+ server: sharedArgs.server,
374
+ json: sharedArgs.json
375
+ },
376
+ async run({ args }) {
377
+ await runCommand(args, async () => {
378
+ const { executeStorageDisable } = await import("./storage-D0odnyBO.mjs");
379
+ return executeStorageDisable(resolveStorageCwd(args.dir), {
380
+ server: args.server,
381
+ force: args.force
382
+ });
383
+ });
384
+ }
385
+ })
386
+ }
387
+ });
311
388
  const mainCommand = defineCommand({
312
389
  meta: {
313
390
  name: "aai",
@@ -321,7 +398,8 @@ const mainCommand = defineCommand({
321
398
  build,
322
399
  deploy,
323
400
  delete: del,
324
- secret
401
+ secret,
402
+ storage
325
403
  }
326
404
  });
327
405
  if (process.env.VITEST !== "true") {
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { i as fileExists, r as errorMessage } from "./_utils-C502jKo8.mjs";
3
- import { t as withPreservedNodeEnv } from "./_vite-env-DNb9R8xq.mjs";
3
+ import { t as withPreservedNodeEnv } from "./_vite-env-Dg_QlVv0.mjs";
4
4
  import { existsSync, unlinkSync, writeFileSync } from "node:fs";
5
5
  import path from "node:path";
6
6
  import fs from "node:fs/promises";
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
- import { t as buildClient } from "./client-bundler-BO1Wm1wT.mjs";
2
+ import { t as buildClient } from "./client-bundler-B5HYJYYP.mjs";
3
3
  export { buildClient };
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { n as log, u as ok } from "./_ui-CKEIHAtB.mjs";
3
- import { n as getServerInfo } from "./_agent-Ds5LyAq5.mjs";
3
+ import { n as getServerInfo } from "./_agent-4rsUGPhx.mjs";
4
4
  import { t as apiRequest } from "./_api-client-a6cPMebU.mjs";
5
5
  //#region delete.ts
6
6
  async function runDelete(opts) {
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
  import { n as log, t as fmtUrl, u as ok } from "./_ui-CKEIHAtB.mjs";
3
3
  import { r as errorMessage } from "./_utils-C502jKo8.mjs";
4
- import { buildAgentBundle } from "./_bundler-z6wTRMX8.mjs";
4
+ import { buildAgentBundle } from "./_bundler-Bp2vFV16.mjs";
5
5
  import { o as writeProjectConfig } from "./_config-BWYgLjiI.mjs";
6
6
  import { t as resolveServerEnv } from "./_server-common-Bv-4Rskq.mjs";
7
- import { i as resolveDeployTarget } from "./_agent-Ds5LyAq5.mjs";
7
+ import { i as resolveDeployTarget } from "./_agent-4rsUGPhx.mjs";
8
8
  import { t as apiRequest } from "./_api-client-a6cPMebU.mjs";
9
9
  import { gzipSync } from "node:zlib";
10
10
  //#region _deploy.ts
@@ -11,7 +11,7 @@ import pc from "picocolors";
11
11
  async function executeDev(opts) {
12
12
  const port = parsePort(opts.port);
13
13
  const agentName = path.basename(path.resolve(opts.cwd));
14
- const { startDevServer } = await import("./_dev-server-C10McqQ9.mjs");
14
+ const { startDevServer } = await import("./_dev-server-D5A4qGbj.mjs");
15
15
  let cleanup;
16
16
  let shuttingDown = false;
17
17
  const onSignal = () => {
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { a as unwrapCancel, n as log, u as ok } from "./_ui-CKEIHAtB.mjs";
3
3
  import { i as fileExists, o as readJson, r as errorMessage, s as resolveCwd } from "./_utils-C502jKo8.mjs";
4
- import { r as isDevMode, t as getMonorepoRoot } from "./_agent-Ds5LyAq5.mjs";
4
+ import { r as isDevMode, t as getMonorepoRoot } from "./_agent-4rsUGPhx.mjs";
5
5
  import path from "node:path";
6
6
  import * as p from "@clack/prompts";
7
7
  import pc from "picocolors";
@@ -74,7 +74,7 @@ function resolveTargetDir(dir) {
74
74
  }
75
75
  /** Run deploy after init and return deploy metadata if successful. */
76
76
  async function tryDeploy(cwd, server) {
77
- const { executeDeploy } = await import("./deploy-b-3G8tdt.mjs");
77
+ const { executeDeploy } = await import("./deploy-kqBQT2kZ.mjs");
78
78
  try {
79
79
  const result = await executeDeploy({
80
80
  cwd,
@@ -92,7 +92,7 @@ async function tryDeploy(cwd, server) {
92
92
  }
93
93
  /** Scaffold the project, optionally showing a spinner. */
94
94
  async function scaffoldProject(dir, cwd, template, silent) {
95
- const { runInit } = await import("./_init-BxI5nkzm.mjs");
95
+ const { runInit } = await import("./_init-C3xJKK3L.mjs");
96
96
  if (silent) {
97
97
  await runInit({
98
98
  targetDir: cwd,
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { a as unwrapCancel, n as log, s as fail, u as ok } from "./_ui-CKEIHAtB.mjs";
3
- import { n as getServerInfo } from "./_agent-Ds5LyAq5.mjs";
3
+ import { n as getServerInfo } from "./_agent-4rsUGPhx.mjs";
4
4
  import { t as apiRequest } from "./_api-client-a6cPMebU.mjs";
5
5
  import * as p from "@clack/prompts";
6
6
  import { text } from "node:stream/consumers";
@@ -0,0 +1,60 @@
1
+ #!/usr/bin/env node
2
+ import { n as log, s as fail, u as ok } from "./_ui-CKEIHAtB.mjs";
3
+ import { n as getServerInfo } from "./_agent-4rsUGPhx.mjs";
4
+ import { t as apiRequest } from "./_api-client-a6cPMebU.mjs";
5
+ import * as p from "@clack/prompts";
6
+ //#region storage.ts
7
+ async function storageRequest(cwd, init, server) {
8
+ const { serverUrl, slug, apiKey } = await getServerInfo(cwd, server);
9
+ return {
10
+ data: await apiRequest(`${serverUrl}/${slug}/storage`, {
11
+ ...init,
12
+ apiKey,
13
+ action: "storage",
14
+ hints: { 404: "The agent may not be deployed. Check `.aai/project.json` for the correct slug." }
15
+ }),
16
+ slug
17
+ };
18
+ }
19
+ async function executeStorageStatus(cwd, server) {
20
+ const { data: { enabled }, slug } = await storageRequest(cwd, void 0, server);
21
+ if (enabled) log.info(`Storage is enabled for ${slug}`);
22
+ else log.info(`Storage is disabled for ${slug}. Use \`aai storage enable\` to turn it on.`);
23
+ return ok({
24
+ slug,
25
+ enabled
26
+ });
27
+ }
28
+ async function executeStorageEnable(cwd, server) {
29
+ const { data: { enabled }, slug } = await storageRequest(cwd, { method: "POST" }, server);
30
+ log.success(`Storage enabled for ${slug}`);
31
+ log.info("Tool code can now use ctx.db.query(sql, params).");
32
+ return ok({
33
+ slug,
34
+ enabled
35
+ });
36
+ }
37
+ /**
38
+ * Disable storage — destructive: the server DROPS the app's database schema
39
+ * and all its data. On a TTY this requires interactive confirmation; without
40
+ * a TTY it refuses unless `--force` is passed, so a script can never drop
41
+ * data by accident.
42
+ */
43
+ async function executeStorageDisable(cwd, opts = {}) {
44
+ if (!opts.force) {
45
+ if (!(opts.isTTY ?? Boolean(process.stdin.isTTY && process.stdout.isTTY))) return fail("confirmation_required", "Disabling storage drops the app's database schema and ALL its data.", "Re-run with --force to disable storage without confirmation.");
46
+ const confirmed = await p.confirm({ message: "Disable storage? This DROPS the app's database schema and all its data." });
47
+ if (p.isCancel(confirmed) || confirmed !== true) {
48
+ log.info("Cancelled. Storage was left unchanged.");
49
+ return fail("cancelled", "Disable cancelled");
50
+ }
51
+ }
52
+ const { data: { enabled }, slug } = await storageRequest(cwd, { method: "DELETE" }, opts.server);
53
+ log.success(`Storage disabled for ${slug} — database schema and data dropped`);
54
+ return ok({
55
+ slug,
56
+ enabled
57
+ });
58
+ }
59
+ //#endregion
60
+ export { executeStorageDisable, executeStorageEnable, executeStorageStatus };
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as withPreservedNodeEnv } from "./_vite-env-DNb9R8xq.mjs";
2
+ import { t as withPreservedNodeEnv } from "./_vite-env-Dg_QlVv0.mjs";
3
3
  import path from "node:path";
4
4
  import { build } from "vite";
5
5
  //#region worker-bundler.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alexkroman1/aai-cli",
3
- "version": "2.0.0",
3
+ "version": "3.0.0",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "aai": "dist/cli.mjs"
@@ -32,8 +32,8 @@
32
32
  "rolldown": "~1.1.4",
33
33
  "vite": "^8.1.5",
34
34
  "zod": "^4.4.3",
35
- "@alexkroman1/aai": "2.0.0",
36
- "@alexkroman1/aai-ui": "2.0.0"
35
+ "@alexkroman1/aai-ui": "3.0.0",
36
+ "@alexkroman1/aai": "3.0.0"
37
37
  },
38
38
  "devDependencies": {
39
39
  "playwright": "^1.61.1",