auth 1.5.4 → 1.5.6

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.
package/dist/index.mjs CHANGED
@@ -1,38 +1,584 @@
1
1
  #!/usr/bin/env node
2
2
  import { Command } from "commander";
3
+ import { exec, execSync, spawn } from "node:child_process";
3
4
  import * as fs$2 from "node:fs";
4
5
  import fs, { existsSync, readFileSync, readdirSync } from "node:fs";
5
- import fs$1 from "node:fs/promises";
6
+ import * as os$1 from "node:os";
7
+ import os from "node:os";
6
8
  import * as path$1 from "node:path";
7
9
  import path, { join } from "node:path";
8
- import { createTelemetry, getTelemetryAuthConfig } from "@better-auth/telemetry";
9
- import { getAdapter } from "better-auth/db/adapter";
10
10
  import chalk from "chalk";
11
11
  import prompts from "prompts";
12
12
  import yoctoSpinner from "yocto-spinner";
13
- import * as z$1 from "zod/v4";
13
+ import fs$1 from "node:fs/promises";
14
+ import { createTelemetry, getTelemetryAuthConfig } from "@better-auth/telemetry";
15
+ import { getAdapter } from "better-auth/db/adapter";
16
+ import * as z from "zod";
14
17
  import { initGetFieldName, initGetModelName } from "better-auth/adapters";
15
18
  import { getAuthTables } from "better-auth/db";
16
19
  import prettier, { format } from "prettier";
17
20
  import { getMigrations } from "better-auth/db/migration";
18
21
  import { capitalizeFirstLetter } from "@better-auth/core/utils/string";
19
22
  import { produceSchema } from "@mrleebo/prisma-ast";
20
- import { exec, execSync, spawn } from "node:child_process";
21
23
  import Crypto from "node:crypto";
22
24
  import babelPresetReact from "@babel/preset-react";
23
25
  import babelPresetTypeScript from "@babel/preset-typescript";
24
26
  import { BetterAuthError } from "@better-auth/core/error";
25
27
  import { loadConfig } from "c12";
26
- import * as os$1 from "node:os";
27
- import os from "node:os";
28
+ import { getTsconfig, parseTsconfig } from "get-tsconfig";
28
29
  import open from "open";
29
- import z from "zod";
30
30
  import { env } from "@better-auth/core/env";
31
31
  import { log } from "@clack/prompts";
32
32
  import { base64 } from "@better-auth/utils/base64";
33
33
  import * as semver from "semver";
34
34
  import "dotenv/config";
35
35
 
36
+ //#region src/commands/ai.ts
37
+ const PROTOCOL_URL = "https://agent-auth-protocol.com";
38
+ const AGENT_CLI_PKG = "@auth/agent-cli";
39
+ const AGENT_PLUGIN_PKG = "@better-auth/agent-auth";
40
+ const DEFAULT_REGISTRY = "https://agent-auth.directory";
41
+ const SKILLS_REPO = "better-auth/agent-auth";
42
+ function cancelled() {
43
+ console.log(chalk.yellow("\n✋ Setup cancelled."));
44
+ process.exit(0);
45
+ }
46
+ function check(value) {
47
+ if (value === void 0 || value === null) cancelled();
48
+ return value;
49
+ }
50
+ async function aiAction() {
51
+ console.log("\n" + [
52
+ ` ██ ████`,
53
+ ` ████ ██ ${chalk.bold("Agent Auth")} ${chalk.dim("Setup")}`,
54
+ ` ██ ████ ${chalk.gray("AI agent authentication & capability-based authorization.")}`
55
+ ].join("\n"));
56
+ console.log();
57
+ const { setup } = await prompts({
58
+ type: "select",
59
+ name: "setup",
60
+ message: "What would you like to do?",
61
+ choices: [{
62
+ title: "Integrate Agent Auth client",
63
+ value: "client",
64
+ description: "MCP server, CLI, or SDK for your agents"
65
+ }, {
66
+ title: "Create an Agent Auth server",
67
+ value: "server",
68
+ description: "expose capabilities from your service to AI agents"
69
+ }]
70
+ });
71
+ check(setup);
72
+ if (setup === "client") await setupClient();
73
+ else await setupServerSelection();
74
+ }
75
+ async function setupClient() {
76
+ const { method } = await prompts({
77
+ type: "select",
78
+ name: "method",
79
+ message: "How do you want to integrate?",
80
+ choices: [{
81
+ title: "MCP Server",
82
+ value: "mcp",
83
+ description: "for AI tools — Claude, Cursor, Windsurf, etc."
84
+ }, {
85
+ title: "CLI",
86
+ value: "cli",
87
+ description: "command-line tool for agent workflows"
88
+ }]
89
+ });
90
+ check(method);
91
+ if (method === "mcp") await setupMcp();
92
+ else await setupCli();
93
+ }
94
+ async function setupServerSelection() {
95
+ const { implementation } = await prompts({
96
+ type: "select",
97
+ name: "implementation",
98
+ message: "Choose an implementation",
99
+ choices: [{
100
+ title: "Better Auth + Agent Auth",
101
+ value: "better-auth",
102
+ description: "TypeScript"
103
+ }]
104
+ });
105
+ check(implementation);
106
+ await setupServer();
107
+ }
108
+ async function setupMcp() {
109
+ const { tool } = await prompts({
110
+ type: "select",
111
+ name: "tool",
112
+ message: "Which AI tool?",
113
+ choices: [
114
+ {
115
+ title: "Cursor",
116
+ value: "cursor"
117
+ },
118
+ {
119
+ title: "Claude Code",
120
+ value: "claude-code"
121
+ },
122
+ {
123
+ title: "Claude Desktop",
124
+ value: "claude-desktop"
125
+ },
126
+ {
127
+ title: "Windsurf",
128
+ value: "windsurf"
129
+ },
130
+ {
131
+ title: "VS Code / Copilot",
132
+ value: "vscode"
133
+ },
134
+ {
135
+ title: "Open Code",
136
+ value: "opencode"
137
+ },
138
+ {
139
+ title: "Other",
140
+ value: "other"
141
+ }
142
+ ]
143
+ });
144
+ check(tool);
145
+ let scope = "global";
146
+ if (tool === "cursor" || tool === "vscode") {
147
+ const { s } = await prompts({
148
+ type: "select",
149
+ name: "s",
150
+ message: "Where should it be configured?",
151
+ choices: [{
152
+ title: "This project",
153
+ value: "project",
154
+ description: tool === "cursor" ? ".cursor/mcp.json" : ".vscode/mcp.json"
155
+ }, {
156
+ title: "Global (all projects)",
157
+ value: "global",
158
+ description: tool === "cursor" ? "~/.cursor/mcp.json" : "user settings"
159
+ }]
160
+ });
161
+ check(s);
162
+ scope = s;
163
+ }
164
+ const { registryUrl } = await prompts({
165
+ type: "text",
166
+ name: "registryUrl",
167
+ message: "Registry URL",
168
+ initial: DEFAULT_REGISTRY
169
+ });
170
+ const mcpArgs = buildMcpArgs(registryUrl?.trim() || DEFAULT_REGISTRY);
171
+ if (tool === "claude-code") await setupClaudeCode(mcpArgs);
172
+ else if (tool === "opencode") await setupOpenCode(mcpArgs);
173
+ else if (tool === "other") showJsonConfig({
174
+ command: "npx",
175
+ args: mcpArgs
176
+ });
177
+ else await writeMcpConfigInteractive(tool, scope, mcpArgs);
178
+ await offerSkillInstall("agent-auth-mcp");
179
+ showNextSteps([`${chalk.cyan("Docs")} ${PROTOCOL_URL}/docs/integrate-client`, `${chalk.cyan("GitHub")} https://github.com/better-auth/agent-auth`]);
180
+ console.log(chalk.green("\n✔ ") + chalk.bold("Done! ") + "Restart your AI tool to connect.\n");
181
+ }
182
+ async function setupClaudeCode(args) {
183
+ const { scope } = await prompts({
184
+ type: "select",
185
+ name: "scope",
186
+ message: "Where should it be configured?",
187
+ choices: [{
188
+ title: "This project",
189
+ value: "project",
190
+ description: "--scope project"
191
+ }, {
192
+ title: "Global (all projects)",
193
+ value: "user",
194
+ description: "--scope user"
195
+ }]
196
+ });
197
+ check(scope);
198
+ const cmd = [
199
+ "claude",
200
+ "mcp",
201
+ "add",
202
+ "agent-auth",
203
+ "--scope",
204
+ scope,
205
+ "--",
206
+ "npx",
207
+ ...args
208
+ ].join(" ");
209
+ console.log(chalk.bold.white("\nRun this command:"));
210
+ console.log(chalk.cyan(` ${cmd}\n`));
211
+ const { run } = await prompts({
212
+ type: "confirm",
213
+ name: "run",
214
+ message: "Run it now?",
215
+ initial: true
216
+ });
217
+ if (run) {
218
+ const s = yoctoSpinner({
219
+ text: "Adding MCP server to Claude Code…",
220
+ color: "white"
221
+ });
222
+ s.start();
223
+ try {
224
+ execSync(cmd, { stdio: "pipe" });
225
+ s.success("Added to Claude Code.");
226
+ } catch {
227
+ s.stop();
228
+ console.log(chalk.yellow("⚠ Could not run the command automatically."));
229
+ console.log(chalk.gray(" Run the command above manually."));
230
+ }
231
+ }
232
+ }
233
+ async function setupOpenCode(args) {
234
+ const configPath = path$1.join(process.cwd(), "opencode.json");
235
+ const display = "opencode.json";
236
+ const openCodeEntry = {
237
+ type: "stdio",
238
+ command: "npx",
239
+ args,
240
+ enabled: true
241
+ };
242
+ const { write } = await prompts({
243
+ type: "confirm",
244
+ name: "write",
245
+ message: `Write config to ${chalk.cyan(display)}?`,
246
+ initial: true
247
+ });
248
+ if (write) {
249
+ writeOpenCodeConfig(configPath, openCodeEntry);
250
+ console.log(chalk.green(`\n✓ Written to ${display}`));
251
+ } else {
252
+ const json = JSON.stringify({
253
+ $schema: "https://opencode.ai/config.json",
254
+ mcp: { "agent-auth": openCodeEntry }
255
+ }, null, 2);
256
+ console.log(chalk.bold.white("\nAdd to your opencode.json:\n"));
257
+ console.log(json.split("\n").map((line) => chalk.cyan(` ${line}`)).join("\n"));
258
+ console.log();
259
+ }
260
+ }
261
+ function writeOpenCodeConfig(configPath, entry) {
262
+ let config = {};
263
+ if (fs$2.existsSync(configPath)) try {
264
+ config = JSON.parse(fs$2.readFileSync(configPath, "utf-8"));
265
+ } catch {}
266
+ const mcp = config.mcp ?? {};
267
+ mcp["agent-auth"] = entry;
268
+ config.$schema = "https://opencode.ai/config.json";
269
+ config.mcp = mcp;
270
+ fs$2.writeFileSync(configPath, JSON.stringify(config, null, 2) + "\n");
271
+ }
272
+ async function writeMcpConfigInteractive(tool, scope, args) {
273
+ const entry = {
274
+ command: "npx",
275
+ args
276
+ };
277
+ const configPath = getMcpConfigPath(tool, scope);
278
+ if (!configPath) {
279
+ showJsonConfig(entry);
280
+ return;
281
+ }
282
+ const display = displayPath(configPath, scope);
283
+ const { write } = await prompts({
284
+ type: "confirm",
285
+ name: "write",
286
+ message: `Write config to ${chalk.cyan(display)}?`,
287
+ initial: true
288
+ });
289
+ if (write) {
290
+ writeMcpConfig(configPath, entry);
291
+ console.log(chalk.green(`\n✓ Written to ${display}`));
292
+ } else showJsonConfig(entry);
293
+ }
294
+ async function setupCli() {
295
+ const { installCli } = await prompts({
296
+ type: "confirm",
297
+ name: "installCli",
298
+ message: `Install ${chalk.cyan(AGENT_CLI_PKG)} globally?`,
299
+ initial: true
300
+ });
301
+ if (installCli) {
302
+ const s = yoctoSpinner({
303
+ text: `Installing ${AGENT_CLI_PKG}…`,
304
+ color: "white"
305
+ });
306
+ s.start();
307
+ try {
308
+ execSync(`npm install -g ${AGENT_CLI_PKG}`, { stdio: "pipe" });
309
+ s.success(`${AGENT_CLI_PKG} installed globally.`);
310
+ } catch {
311
+ s.stop();
312
+ console.log(chalk.yellow("⚠ Could not install automatically. Run manually:"));
313
+ console.log(chalk.cyan(` npm install -g ${AGENT_CLI_PKG}\n`));
314
+ }
315
+ } else console.log(chalk.dim(`\n To install later: npm install -g ${AGENT_CLI_PKG}\n`));
316
+ await offerSkillInstall("agent-auth-cli");
317
+ console.log(chalk.bold.white("\nUsage:"));
318
+ console.log(chalk.gray(" # Discover a provider"));
319
+ console.log(chalk.cyan(" auth-agent discover https://api.example.com"));
320
+ console.log(chalk.gray("\n # Search the registry for providers"));
321
+ console.log(chalk.cyan(` auth-agent search "send email"`));
322
+ console.log(chalk.gray("\n # Connect an agent with capabilities"));
323
+ console.log(chalk.cyan(" auth-agent connect --provider <url> --capabilities <cap1> <cap2>"));
324
+ console.log(chalk.gray("\n # Execute a capability"));
325
+ console.log(chalk.cyan(` auth-agent execute <agent-id> <capability> --args '{"key":"value"}'`));
326
+ console.log(chalk.gray("\n # Run as MCP server"));
327
+ console.log(chalk.cyan(` auth-agent mcp`));
328
+ showNextSteps([`${chalk.cyan("Docs")} ${PROTOCOL_URL}/docs/integrate-client`, `${chalk.cyan("GitHub")} https://github.com/better-auth/agent-auth`]);
329
+ console.log(chalk.green("\n✔ ") + chalk.bold("Ready. ") + "Run auth-agent --help to see all commands.\n");
330
+ }
331
+ async function setupServer() {
332
+ const { source } = await prompts({
333
+ type: "select",
334
+ name: "source",
335
+ message: "How do you want to define capabilities?",
336
+ choices: [
337
+ {
338
+ title: "Default",
339
+ value: "manual",
340
+ description: "define capabilities in code"
341
+ },
342
+ {
343
+ title: "From an OpenAPI spec",
344
+ value: "openapi",
345
+ description: "derive capabilities from an OpenAPI document"
346
+ },
347
+ {
348
+ title: "From an MCP server",
349
+ value: "mcp",
350
+ description: "proxy an existing MCP server's tools"
351
+ }
352
+ ]
353
+ });
354
+ check(source);
355
+ const { name } = await prompts({
356
+ type: "text",
357
+ name: "name",
358
+ message: "What's your service called?",
359
+ validate: (v) => v?.trim() ? true : "Name is required."
360
+ });
361
+ check(name);
362
+ const { description } = await prompts({
363
+ type: "text",
364
+ name: "description",
365
+ message: `Short description ${chalk.dim("(press Enter to skip)")}`
366
+ });
367
+ const desc = description?.trim() || void 0;
368
+ let sourceUrl;
369
+ if (source === "openapi") {
370
+ const { url } = await prompts({
371
+ type: "text",
372
+ name: "url",
373
+ message: `OpenAPI spec URL ${chalk.dim("(e.g. https://api.example.com/openapi.json)")}`,
374
+ validate: (v) => v?.trim() ? true : "URL is required."
375
+ });
376
+ check(url);
377
+ sourceUrl = url.trim();
378
+ } else if (source === "mcp") {
379
+ const { url } = await prompts({
380
+ type: "text",
381
+ name: "url",
382
+ message: `MCP server URL ${chalk.dim("(e.g. https://api.example.com/mcp)")}`,
383
+ validate: (v) => v?.trim() ? true : "URL is required."
384
+ });
385
+ check(url);
386
+ sourceUrl = url.trim();
387
+ }
388
+ const code = generateServerCode(name.trim(), desc, source, sourceUrl);
389
+ const { write } = await prompts({
390
+ type: "confirm",
391
+ name: "write",
392
+ message: "Generate an auth config file?",
393
+ initial: true
394
+ });
395
+ if (write) {
396
+ const { filePath } = await prompts({
397
+ type: "text",
398
+ name: "filePath",
399
+ message: "File path",
400
+ initial: "lib/auth.ts"
401
+ });
402
+ const target = filePath?.trim() || "lib/auth.ts";
403
+ if (fs$2.existsSync(target)) {
404
+ const { overwrite } = await prompts({
405
+ type: "confirm",
406
+ name: "overwrite",
407
+ message: `${chalk.yellow(target)} already exists. Overwrite?`,
408
+ initial: false
409
+ });
410
+ if (!overwrite) {
411
+ showCodeBlock(code, "auth config");
412
+ showServerOutro();
413
+ return;
414
+ }
415
+ }
416
+ const dir = path$1.dirname(target);
417
+ if (dir && dir !== "." && !fs$2.existsSync(dir)) fs$2.mkdirSync(dir, { recursive: true });
418
+ fs$2.writeFileSync(target, code);
419
+ console.log(chalk.green(`\n✓ Created ${target}`));
420
+ } else showCodeBlock(code, "auth config");
421
+ showServerOutro();
422
+ }
423
+ function generateServerCode(name, description, source, sourceUrl) {
424
+ const descLine = description ? `\n\t\t\tproviderDescription: ${JSON.stringify(description)},` : "";
425
+ if (source === "openapi" && sourceUrl) return `import { betterAuth } from "better-auth";
426
+ import { agentAuth } from "${AGENT_PLUGIN_PKG}";
427
+ import { createFromOpenAPI } from "${AGENT_PLUGIN_PKG}/openapi";
428
+
429
+ const spec = await fetch(${JSON.stringify(sourceUrl)}).then(r => r.json());
430
+
431
+ const openapi = createFromOpenAPI(spec, {
432
+ \tbaseUrl: ${JSON.stringify(sourceUrl.replace(/\/openapi\.json$|\/openapi\.yaml$|\/swagger\.json$|\/docs\/openapi$/, ""))},
433
+ });
434
+
435
+ export const auth = betterAuth({
436
+ \tplugins: [
437
+ \t\tagentAuth({
438
+ \t\t\tproviderName: ${JSON.stringify(name)},${descLine}
439
+ \t\t\t...openapi,
440
+ \t\t}),
441
+ \t],
442
+ });
443
+ `;
444
+ if (source === "mcp" && sourceUrl) return `import { betterAuth } from "better-auth";
445
+ import { agentAuth } from "${AGENT_PLUGIN_PKG}";
446
+
447
+ export const auth = betterAuth({
448
+ \tplugins: [
449
+ \t\tagentAuth({
450
+ \t\t\tproviderName: ${JSON.stringify(name)},${descLine}
451
+ \t\t\tmcpServer: ${JSON.stringify(sourceUrl)},
452
+ \t\t}),
453
+ \t],
454
+ });
455
+ `;
456
+ return `import { betterAuth } from "better-auth";
457
+ import { agentAuth } from "${AGENT_PLUGIN_PKG}";
458
+
459
+ export const auth = betterAuth({
460
+ \tplugins: [
461
+ \t\tagentAuth({
462
+ \t\t\tproviderName: ${JSON.stringify(name)},${descLine}
463
+ \t\t\tcapabilities: [
464
+ \t\t\t\t{
465
+ \t\t\t\t\tname: "example",
466
+ \t\t\t\t\tdescription: "An example capability — replace with your own",
467
+ \t\t\t\t\tinput: {
468
+ \t\t\t\t\t\ttype: "object",
469
+ \t\t\t\t\t\tproperties: {
470
+ \t\t\t\t\t\t\tmessage: { type: "string", description: "Input message" },
471
+ \t\t\t\t\t\t},
472
+ \t\t\t\t\t},
473
+ \t\t\t\t},
474
+ \t\t\t],
475
+ \t\t\tasync onExecute({ capability, arguments: args }) {
476
+ \t\t\t\tswitch (capability) {
477
+ \t\t\t\t\tcase "example":
478
+ \t\t\t\t\t\treturn { message: \`Hello from \${(args as Record<string, string>).message}\` };
479
+ \t\t\t\t\tdefault:
480
+ \t\t\t\t\t\tthrow new Error(\`Unknown capability: \${capability}\`);
481
+ \t\t\t\t}
482
+ \t\t\t},
483
+ \t\t}),
484
+ \t],
485
+ });
486
+ `;
487
+ }
488
+ function showServerOutro() {
489
+ console.log(chalk.bold.white("\nNext steps:\n"));
490
+ console.log(chalk.white(" 1. Install dependencies:"));
491
+ console.log(chalk.cyan(` npm install better-auth ${AGENT_PLUGIN_PKG}\n`));
492
+ console.log(chalk.white(" 2. Configure your database:"));
493
+ console.log(chalk.gray(" Better Auth needs a database to store agents, hosts, and grants."));
494
+ console.log(chalk.cyan(" https://www.better-auth.com/docs/concepts/database\n"));
495
+ console.log(chalk.white(" 3. Run database migrations:"));
496
+ console.log(chalk.cyan(" npx auth migrate\n"));
497
+ console.log(chalk.white(" 4. Expose the discovery endpoint at your app root:"));
498
+ console.log(chalk.gray(" GET /.well-known/agent-configuration"));
499
+ console.log(chalk.gray(" → return auth.api.getAgentConfiguration({ headers })\n"));
500
+ console.log(` ${chalk.cyan("Docs")} ${PROTOCOL_URL}/docs/build-server`);
501
+ console.log(` ${chalk.cyan("GitHub")} https://github.com/better-auth/agent-auth`);
502
+ console.log(chalk.green("\n✔ ") + chalk.bold("Server scaffolded. ") + "Follow the steps above to finish setup.\n");
503
+ }
504
+ async function offerSkillInstall(skillName) {
505
+ const { installSkill } = await prompts({
506
+ type: "confirm",
507
+ name: "installSkill",
508
+ message: `Install the ${chalk.cyan(skillName)} skill for your coding agents?`,
509
+ initial: true
510
+ });
511
+ if (!installSkill) return;
512
+ const cmd = `npx -y skills add ${SKILLS_REPO} --skill ${skillName}`;
513
+ const s = yoctoSpinner({
514
+ text: `Installing ${skillName} skill…`,
515
+ color: "white"
516
+ });
517
+ s.start();
518
+ try {
519
+ execSync(cmd, { stdio: "pipe" });
520
+ s.success(`${skillName} skill installed.`);
521
+ } catch {
522
+ s.stop();
523
+ console.log(chalk.yellow("⚠ Could not install automatically. Run manually:"));
524
+ console.log(chalk.cyan(` ${cmd}\n`));
525
+ }
526
+ }
527
+ function buildMcpArgs(registry) {
528
+ const args = [
529
+ "-y",
530
+ AGENT_CLI_PKG,
531
+ "mcp"
532
+ ];
533
+ if (registry && registry !== DEFAULT_REGISTRY) args.push("--registry-url", registry);
534
+ return args;
535
+ }
536
+ function getMcpConfigPath(tool, scope) {
537
+ const home = os$1.homedir();
538
+ switch (tool) {
539
+ case "cursor": return scope === "global" ? path$1.join(home, ".cursor", "mcp.json") : path$1.join(process.cwd(), ".cursor", "mcp.json");
540
+ case "claude-desktop":
541
+ if (process.platform === "win32") return path$1.join(process.env.APPDATA || home, "Claude", "claude_desktop_config.json");
542
+ if (process.platform === "darwin") return path$1.join(home, "Library", "Application Support", "Claude", "claude_desktop_config.json");
543
+ return path$1.join(home, ".config", "Claude", "claude_desktop_config.json");
544
+ case "windsurf": return path$1.join(home, ".codeium", "windsurf", "mcp_config.json");
545
+ case "vscode": return scope === "global" ? null : path$1.join(process.cwd(), ".vscode", "mcp.json");
546
+ default: return null;
547
+ }
548
+ }
549
+ function writeMcpConfig(configPath, entry) {
550
+ let config = {};
551
+ if (fs$2.existsSync(configPath)) try {
552
+ config = JSON.parse(fs$2.readFileSync(configPath, "utf-8"));
553
+ } catch {}
554
+ const servers = config.mcpServers ?? {};
555
+ servers["agent-auth"] = entry;
556
+ config.mcpServers = servers;
557
+ const dir = path$1.dirname(configPath);
558
+ if (!fs$2.existsSync(dir)) fs$2.mkdirSync(dir, { recursive: true });
559
+ fs$2.writeFileSync(configPath, JSON.stringify(config, null, 2) + "\n");
560
+ }
561
+ function displayPath(filePath, scope) {
562
+ if (scope === "project") return path$1.relative(process.cwd(), filePath) || filePath;
563
+ return filePath.replace(os$1.homedir(), "~");
564
+ }
565
+ function showJsonConfig(entry) {
566
+ const json = JSON.stringify({ mcpServers: { "agent-auth": entry } }, null, 2);
567
+ console.log(chalk.bold.white("\nAdd to your MCP configuration:\n"));
568
+ console.log(json.split("\n").map((line) => chalk.cyan(` ${line}`)).join("\n"));
569
+ console.log();
570
+ }
571
+ function showCodeBlock(code, title) {
572
+ console.log(chalk.bold.white(`\n${title}:\n`));
573
+ console.log(code.split("\n").map((line) => chalk.dim(` ${line}`)).join("\n"));
574
+ }
575
+ function showNextSteps(lines) {
576
+ console.log(chalk.bold.white("\nLearn more:\n"));
577
+ for (const line of lines) console.log(` ${line}`);
578
+ }
579
+ const ai = new Command("ai").description("Interactive setup for Agent Auth — AI agent authentication").action(aiAction);
580
+
581
+ //#endregion
36
582
  //#region src/generators/drizzle.ts
37
583
  function convertToSnakeCase(str, camelCase) {
38
584
  if (camelCase) return str;
@@ -919,23 +1465,6 @@ const reserved = new Set([
919
1465
  "instanceof"
920
1466
  ]);
921
1467
 
922
- //#endregion
923
- //#region src/utils/get-tsconfig-info.ts
924
- function stripJsonComments(jsonString) {
925
- return jsonString.replace(/\\"|"(?:\\"|[^"])*"|(\/\/.*|\/\*[\s\S]*?\*\/)/g, (m, g) => g ? "" : m).replace(/,(?=\s*[}\]])/g, "");
926
- }
927
- function getTsconfigInfo(cwd, flatPath) {
928
- let tsConfigPath;
929
- if (flatPath) tsConfigPath = flatPath;
930
- else tsConfigPath = cwd ? path.join(cwd, "tsconfig.json") : path.join("tsconfig.json");
931
- try {
932
- const text = fs.readFileSync(tsConfigPath, "utf-8");
933
- return JSON.parse(stripJsonComments(text));
934
- } catch (error) {
935
- throw error;
936
- }
937
- }
938
-
939
1468
  //#endregion
940
1469
  //#region src/utils/get-config.ts
941
1470
  let possiblePaths$1 = [
@@ -966,49 +1495,63 @@ possiblePaths$1 = [
966
1495
  ...possiblePaths$1.map((it) => `src/${it}`),
967
1496
  ...possiblePaths$1.map((it) => `app/${it}`)
968
1497
  ];
969
- function resolveReferencePath(configDir, refPath) {
970
- const resolvedPath = path.resolve(configDir, refPath);
971
- if (refPath.endsWith(".json")) return resolvedPath;
972
- if (fs.existsSync(resolvedPath)) try {
973
- if (fs.statSync(resolvedPath).isFile()) return resolvedPath;
974
- } catch {}
975
- return path.resolve(configDir, refPath, "tsconfig.json");
1498
+ function mergeAliases(target, source) {
1499
+ for (const [alias, aliasPath] of Object.entries(source)) if (!(alias in target)) target[alias] = aliasPath;
976
1500
  }
977
- function getPathAliasesRecursive(tsconfigPath, visited = /* @__PURE__ */ new Set()) {
978
- if (visited.has(tsconfigPath)) return {};
979
- visited.add(tsconfigPath);
980
- if (!fs.existsSync(tsconfigPath)) {
981
- console.warn(`Referenced tsconfig not found: ${tsconfigPath}`);
982
- return {};
1501
+ function extractAliases(tsconfig) {
1502
+ const { paths = {}, baseUrl } = tsconfig.config.compilerOptions ?? {};
1503
+ const result = {};
1504
+ const configDir = path.dirname(tsconfig.path);
1505
+ const resolvedBaseUrl = baseUrl ? path.resolve(configDir, baseUrl) : configDir;
1506
+ for (const [alias, aliasPaths = []] of Object.entries(paths)) for (const aliasedPath of aliasPaths) {
1507
+ const finalAlias = alias.slice(-1) === "*" ? alias.slice(0, -1) : alias;
1508
+ const finalAliasedPath = aliasedPath.slice(-1) === "*" ? aliasedPath.slice(0, -1) : aliasedPath;
1509
+ result[finalAlias || ""] = path.join(resolvedBaseUrl, finalAliasedPath);
983
1510
  }
1511
+ return result;
1512
+ }
1513
+ /**
1514
+ * Reads raw tsconfig JSON to get `references` (which get-tsconfig strips out).
1515
+ */
1516
+ function readRawTsconfigReferences(tsconfigPath) {
984
1517
  try {
985
- const tsConfig = getTsconfigInfo(void 0, tsconfigPath);
986
- const { paths = {}, baseUrl = "." } = tsConfig.compilerOptions || {};
987
- const result = {};
988
- const configDir = path.dirname(tsconfigPath);
989
- const obj = Object.entries(paths);
990
- for (const [alias, aliasPaths] of obj) for (const aliasedPath of aliasPaths) {
991
- const resolvedBaseUrl = path.resolve(configDir, baseUrl);
992
- const finalAlias = alias.slice(-1) === "*" ? alias.slice(0, -1) : alias;
993
- const finalAliasedPath = aliasedPath.slice(-1) === "*" ? aliasedPath.slice(0, -1) : aliasedPath;
994
- result[finalAlias || ""] = path.join(resolvedBaseUrl, finalAliasedPath);
995
- }
996
- if (tsConfig.references) for (const ref of tsConfig.references) {
997
- const refAliases = getPathAliasesRecursive(resolveReferencePath(configDir, ref.path), visited);
998
- for (const [alias, aliasPath] of Object.entries(refAliases)) if (!(alias in result)) result[alias] = aliasPath;
1518
+ const stripped = fs.readFileSync(tsconfigPath, "utf-8").replace(/\\"|"(?:\\"|[^"])*"|(\/\/.*|\/\*[\s\S]*?\*\/)/g, (m, g) => g ? "" : m).replace(/,(?=\s*[}\]])/g, "");
1519
+ return JSON.parse(stripped).references;
1520
+ } catch {
1521
+ return;
1522
+ }
1523
+ }
1524
+ /**
1525
+ * Collect path aliases from tsconfig references recursively.
1526
+ */
1527
+ function collectReferencesAliases(tsconfigPath, visited = /* @__PURE__ */ new Set()) {
1528
+ const result = {};
1529
+ const refs = readRawTsconfigReferences(tsconfigPath);
1530
+ if (!refs) return result;
1531
+ const configDir = path.dirname(tsconfigPath);
1532
+ for (const ref of refs) {
1533
+ const resolvedRef = path.resolve(configDir, ref.path);
1534
+ const refTsconfigPath = resolvedRef.endsWith(".json") ? resolvedRef : path.join(resolvedRef, "tsconfig.json");
1535
+ if (visited.has(refTsconfigPath)) continue;
1536
+ visited.add(refTsconfigPath);
1537
+ try {
1538
+ mergeAliases(result, extractAliases({
1539
+ path: refTsconfigPath,
1540
+ config: parseTsconfig(refTsconfigPath)
1541
+ }));
1542
+ } catch {
1543
+ continue;
999
1544
  }
1000
- return result;
1001
- } catch (error) {
1002
- console.warn(`Error parsing tsconfig at ${tsconfigPath}: ${error}`);
1003
- return {};
1545
+ mergeAliases(result, collectReferencesAliases(refTsconfigPath, visited));
1004
1546
  }
1547
+ return result;
1005
1548
  }
1006
1549
  function getPathAliases(cwd) {
1007
- let tsConfigPath = path.join(cwd, "tsconfig.json");
1008
- if (!fs.existsSync(tsConfigPath)) tsConfigPath = path.join(cwd, "jsconfig.json");
1009
- if (!fs.existsSync(tsConfigPath)) return null;
1550
+ const tsconfig = getTsconfig(cwd, fs.existsSync(path.join(cwd, "tsconfig.json")) ? "tsconfig.json" : "jsconfig.json");
1551
+ if (!tsconfig) return null;
1010
1552
  try {
1011
- const result = getPathAliasesRecursive(tsConfigPath);
1553
+ const result = extractAliases(tsconfig);
1554
+ mergeAliases(result, collectReferencesAliases(tsconfig.path));
1012
1555
  addSvelteKitEnvModules(result);
1013
1556
  addCloudflareModules(result);
1014
1557
  return result;
@@ -1145,14 +1688,14 @@ function createMockAdapter$1(adapterId, dialect) {
1145
1688
  };
1146
1689
  }
1147
1690
  async function generateAction(opts) {
1148
- const options = z$1.object({
1149
- cwd: z$1.string(),
1150
- config: z$1.string().optional(),
1151
- output: z$1.string().optional(),
1152
- adapter: z$1.string().optional(),
1153
- dialect: z$1.string().optional(),
1154
- y: z$1.boolean().optional(),
1155
- yes: z$1.boolean().optional()
1691
+ const options = z.object({
1692
+ cwd: z.string(),
1693
+ config: z.string().optional(),
1694
+ output: z.string().optional(),
1695
+ adapter: z.string().optional(),
1696
+ dialect: z.string().optional(),
1697
+ y: z.boolean().optional(),
1698
+ yes: z.boolean().optional()
1156
1699
  }).parse(opts);
1157
1700
  const cwd = path.resolve(options.cwd);
1158
1701
  if (!existsSync(cwd)) {
@@ -2428,7 +2971,7 @@ const tempPluginsConfig = {
2428
2971
  argument: {
2429
2972
  index: 0,
2430
2973
  isProperty: "issuer",
2431
- schema: z$1.coerce.string().optional()
2974
+ schema: z.coerce.string().optional()
2432
2975
  }
2433
2976
  },
2434
2977
  {
@@ -2440,7 +2983,7 @@ const tempPluginsConfig = {
2440
2983
  argument: {
2441
2984
  index: 0,
2442
2985
  isProperty: "skipVerificationOnEnable",
2443
- schema: z$1.coerce.boolean().optional()
2986
+ schema: z.coerce.boolean().optional()
2444
2987
  }
2445
2988
  },
2446
2989
  {
@@ -2457,7 +3000,7 @@ const tempPluginsConfig = {
2457
3000
  argument: {
2458
3001
  index: 0,
2459
3002
  isProperty: "digits",
2460
- schema: z$1.coerce.number().positive().optional()
3003
+ schema: z.coerce.number().positive().optional()
2461
3004
  }
2462
3005
  }, {
2463
3006
  flag: "totp-otp-period",
@@ -2468,7 +3011,7 @@ const tempPluginsConfig = {
2468
3011
  argument: {
2469
3012
  index: 0,
2470
3013
  isProperty: "period",
2471
- schema: z$1.coerce.number().positive().optional()
3014
+ schema: z.coerce.number().positive().optional()
2472
3015
  }
2473
3016
  }],
2474
3017
  argument: {
@@ -2490,7 +3033,7 @@ const tempPluginsConfig = {
2490
3033
  argument: {
2491
3034
  index: 0,
2492
3035
  isProperty: "period",
2493
- schema: z$1.coerce.number().positive().optional()
3036
+ schema: z.coerce.number().positive().optional()
2494
3037
  }
2495
3038
  }, {
2496
3039
  flag: "otp-store-otp",
@@ -2515,7 +3058,7 @@ const tempPluginsConfig = {
2515
3058
  argument: {
2516
3059
  index: 0,
2517
3060
  isProperty: "storeOTP",
2518
- schema: z$1.enum([
3061
+ schema: z.enum([
2519
3062
  "plain",
2520
3063
  "encrypted",
2521
3064
  "hashed"
@@ -2540,7 +3083,7 @@ const tempPluginsConfig = {
2540
3083
  argument: {
2541
3084
  index: 0,
2542
3085
  isProperty: "amount",
2543
- schema: z$1.coerce.number().positive().optional()
3086
+ schema: z.coerce.number().positive().optional()
2544
3087
  }
2545
3088
  }, {
2546
3089
  flag: "backup-code-length",
@@ -2551,7 +3094,7 @@ const tempPluginsConfig = {
2551
3094
  argument: {
2552
3095
  index: 0,
2553
3096
  isProperty: "length",
2554
- schema: z$1.coerce.number().positive().optional()
3097
+ schema: z.coerce.number().positive().optional()
2555
3098
  }
2556
3099
  }],
2557
3100
  argument: {
@@ -2576,7 +3119,7 @@ const tempPluginsConfig = {
2576
3119
  argument: {
2577
3120
  index: 0,
2578
3121
  isProperty: "twoFactorTable",
2579
- schema: z$1.coerce.string().optional()
3122
+ schema: z.coerce.string().optional()
2580
3123
  }
2581
3124
  }]
2582
3125
  }
@@ -2610,7 +3153,7 @@ const tempPluginsConfig = {
2610
3153
  argument: {
2611
3154
  index: 0,
2612
3155
  isProperty: "maxUsernameLength",
2613
- schema: z$1.coerce.number().min(0).positive().optional()
3156
+ schema: z.coerce.number().min(0).positive().optional()
2614
3157
  }
2615
3158
  },
2616
3159
  {
@@ -2622,7 +3165,7 @@ const tempPluginsConfig = {
2622
3165
  argument: {
2623
3166
  index: 0,
2624
3167
  isProperty: "minUsernameLength",
2625
- schema: z$1.coerce.number().min(0).positive().optional()
3168
+ schema: z.coerce.number().min(0).positive().optional()
2626
3169
  }
2627
3170
  },
2628
3171
  {
@@ -2645,7 +3188,7 @@ const tempPluginsConfig = {
2645
3188
  argument: {
2646
3189
  index: 0,
2647
3190
  isProperty: "username",
2648
- schema: z$1.enum(["pre-normalization", "post-normalization"]).optional()
3191
+ schema: z.enum(["pre-normalization", "post-normalization"]).optional()
2649
3192
  }
2650
3193
  }, {
2651
3194
  flag: "username-validation-order-display-username",
@@ -2663,7 +3206,7 @@ const tempPluginsConfig = {
2663
3206
  argument: {
2664
3207
  index: 0,
2665
3208
  isProperty: "displayUsername",
2666
- schema: z$1.enum(["pre-normalization", "post-normalization"]).optional()
3209
+ schema: z.enum(["pre-normalization", "post-normalization"]).optional()
2667
3210
  }
2668
3211
  }],
2669
3212
  argument: {
@@ -2702,7 +3245,7 @@ const tempPluginsConfig = {
2702
3245
  argument: {
2703
3246
  index: 0,
2704
3247
  isProperty: "expiresIn",
2705
- schema: z$1.coerce.number().optional()
3248
+ schema: z.coerce.number().optional()
2706
3249
  }
2707
3250
  },
2708
3251
  {
@@ -2717,7 +3260,7 @@ const tempPluginsConfig = {
2717
3260
  argument: {
2718
3261
  index: 0,
2719
3262
  isProperty: "sendMagicLink",
2720
- schema: z$1.coerce.string()
3263
+ schema: z.coerce.string()
2721
3264
  }
2722
3265
  },
2723
3266
  {
@@ -2734,7 +3277,7 @@ const tempPluginsConfig = {
2734
3277
  argument: {
2735
3278
  index: 0,
2736
3279
  isProperty: "window",
2737
- schema: z$1.coerce.number().optional()
3280
+ schema: z.coerce.number().optional()
2738
3281
  }
2739
3282
  }, {
2740
3283
  flag: "magic-link-rate-limit-max",
@@ -2746,7 +3289,7 @@ const tempPluginsConfig = {
2746
3289
  argument: {
2747
3290
  index: 0,
2748
3291
  isProperty: "max",
2749
- schema: z$1.coerce.number().optional()
3292
+ schema: z.coerce.number().optional()
2750
3293
  }
2751
3294
  }],
2752
3295
  argument: {
@@ -2770,7 +3313,7 @@ const tempPluginsConfig = {
2770
3313
  argument: {
2771
3314
  index: 0,
2772
3315
  isProperty: "storeToken",
2773
- schema: z$1.enum(["plain", "hashed"]).optional()
3316
+ schema: z.enum(["plain", "hashed"]).optional()
2774
3317
  }
2775
3318
  }
2776
3319
  ]
@@ -2806,7 +3349,7 @@ const tempPluginsConfig = {
2806
3349
  argument: {
2807
3350
  index: 0,
2808
3351
  isProperty: "sendVerificationOTP",
2809
- schema: z$1.coerce.string()
3352
+ schema: z.coerce.string()
2810
3353
  }
2811
3354
  },
2812
3355
  {
@@ -2819,7 +3362,7 @@ const tempPluginsConfig = {
2819
3362
  argument: {
2820
3363
  index: 0,
2821
3364
  isProperty: "otpLength",
2822
- schema: z$1.coerce.number().optional()
3365
+ schema: z.coerce.number().optional()
2823
3366
  }
2824
3367
  },
2825
3368
  {
@@ -2832,7 +3375,7 @@ const tempPluginsConfig = {
2832
3375
  argument: {
2833
3376
  index: 0,
2834
3377
  isProperty: "expiresIn",
2835
- schema: z$1.coerce.number().optional()
3378
+ schema: z.coerce.number().optional()
2836
3379
  }
2837
3380
  },
2838
3381
  {
@@ -2845,7 +3388,7 @@ const tempPluginsConfig = {
2845
3388
  argument: {
2846
3389
  index: 0,
2847
3390
  isProperty: "sendVerificationOnSignUp",
2848
- schema: z$1.coerce.boolean().optional()
3391
+ schema: z.coerce.boolean().optional()
2849
3392
  }
2850
3393
  },
2851
3394
  {
@@ -2858,7 +3401,7 @@ const tempPluginsConfig = {
2858
3401
  argument: {
2859
3402
  index: 0,
2860
3403
  isProperty: "disableSignUp",
2861
- schema: z$1.coerce.boolean().optional()
3404
+ schema: z.coerce.boolean().optional()
2862
3405
  }
2863
3406
  },
2864
3407
  {
@@ -2871,7 +3414,7 @@ const tempPluginsConfig = {
2871
3414
  argument: {
2872
3415
  index: 0,
2873
3416
  isProperty: "allowedAttempts",
2874
- schema: z$1.coerce.number().optional()
3417
+ schema: z.coerce.number().optional()
2875
3418
  }
2876
3419
  },
2877
3420
  {
@@ -2897,7 +3440,7 @@ const tempPluginsConfig = {
2897
3440
  argument: {
2898
3441
  index: 0,
2899
3442
  isProperty: "storeOTP",
2900
- schema: z$1.enum([
3443
+ schema: z.enum([
2901
3444
  "plain",
2902
3445
  "encrypted",
2903
3446
  "hashed"
@@ -2914,7 +3457,7 @@ const tempPluginsConfig = {
2914
3457
  argument: {
2915
3458
  index: 0,
2916
3459
  isProperty: "overrideDefaultEmailVerification",
2917
- schema: z$1.coerce.boolean().optional()
3460
+ schema: z.coerce.boolean().optional()
2918
3461
  }
2919
3462
  }
2920
3463
  ]
@@ -3041,7 +3584,7 @@ const tempPluginsConfig = {
3041
3584
  argument: {
3042
3585
  index: 0,
3043
3586
  isProperty: "defaultRole",
3044
- schema: z$1.coerce.string().optional()
3587
+ schema: z.coerce.string().optional()
3045
3588
  }
3046
3589
  }, {
3047
3590
  flag: "admin-roles",
@@ -3052,7 +3595,7 @@ const tempPluginsConfig = {
3052
3595
  argument: {
3053
3596
  index: 0,
3054
3597
  isProperty: "adminRoles",
3055
- schema: z$1.array(z$1.string()).optional()
3598
+ schema: z.array(z.string()).optional()
3056
3599
  }
3057
3600
  }]
3058
3601
  },
@@ -3084,7 +3627,7 @@ const tempPluginsConfig = {
3084
3627
  argument: {
3085
3628
  index: 0,
3086
3629
  isProperty: "apiKeyHeaders",
3087
- schema: z$1.coerce.string().optional()
3630
+ schema: z.coerce.string().optional()
3088
3631
  }
3089
3632
  },
3090
3633
  {
@@ -3097,7 +3640,7 @@ const tempPluginsConfig = {
3097
3640
  argument: {
3098
3641
  index: 0,
3099
3642
  isProperty: "defaultKeyLength",
3100
- schema: z$1.coerce.number().positive().optional()
3643
+ schema: z.coerce.number().positive().optional()
3101
3644
  }
3102
3645
  },
3103
3646
  {
@@ -3109,7 +3652,7 @@ const tempPluginsConfig = {
3109
3652
  argument: {
3110
3653
  index: 0,
3111
3654
  isProperty: "disableKeyHashing",
3112
- schema: z$1.coerce.boolean().optional()
3655
+ schema: z.coerce.boolean().optional()
3113
3656
  }
3114
3657
  },
3115
3658
  {
@@ -3121,7 +3664,7 @@ const tempPluginsConfig = {
3121
3664
  argument: {
3122
3665
  index: 0,
3123
3666
  isProperty: "enableMetadata",
3124
- schema: z$1.coerce.boolean().optional()
3667
+ schema: z.coerce.boolean().optional()
3125
3668
  }
3126
3669
  },
3127
3670
  {
@@ -3133,7 +3676,7 @@ const tempPluginsConfig = {
3133
3676
  argument: {
3134
3677
  index: 0,
3135
3678
  isProperty: "enableSessionForAPIKeys",
3136
- schema: z$1.coerce.boolean().optional()
3679
+ schema: z.coerce.boolean().optional()
3137
3680
  }
3138
3681
  }
3139
3682
  ]
@@ -3165,7 +3708,7 @@ const tempPluginsConfig = {
3165
3708
  argument: {
3166
3709
  index: 0,
3167
3710
  isProperty: "requireSignature",
3168
- schema: z$1.coerce.boolean().optional()
3711
+ schema: z.coerce.boolean().optional()
3169
3712
  }
3170
3713
  }]
3171
3714
  },
@@ -3206,7 +3749,7 @@ const tempPluginsConfig = {
3206
3749
  argument: {
3207
3750
  index: 0,
3208
3751
  isProperty: "provider",
3209
- schema: z$1.enum([
3752
+ schema: z.enum([
3210
3753
  "google-recaptcha",
3211
3754
  "cloudflare-turnstile",
3212
3755
  "hcaptcha",
@@ -3221,7 +3764,7 @@ const tempPluginsConfig = {
3221
3764
  argument: {
3222
3765
  index: 0,
3223
3766
  isProperty: "secretKey",
3224
- schema: z$1.coerce.string()
3767
+ schema: z.coerce.string()
3225
3768
  }
3226
3769
  },
3227
3770
  {
@@ -3232,7 +3775,7 @@ const tempPluginsConfig = {
3232
3775
  argument: {
3233
3776
  index: 0,
3234
3777
  isProperty: "siteKey",
3235
- schema: z$1.coerce.string().optional()
3778
+ schema: z.coerce.string().optional()
3236
3779
  }
3237
3780
  },
3238
3781
  {
@@ -3245,7 +3788,7 @@ const tempPluginsConfig = {
3245
3788
  argument: {
3246
3789
  index: 0,
3247
3790
  isProperty: "minScore",
3248
- schema: z$1.coerce.number().min(0).max(1).optional()
3791
+ schema: z.coerce.number().min(0).max(1).optional()
3249
3792
  }
3250
3793
  }
3251
3794
  ]
@@ -3270,7 +3813,7 @@ const tempPluginsConfig = {
3270
3813
  argument: {
3271
3814
  index: 0,
3272
3815
  isProperty: "shouldMutateListDeviceSessionsEndpoint",
3273
- schema: z$1.coerce.boolean().optional()
3816
+ schema: z.coerce.boolean().optional()
3274
3817
  }
3275
3818
  }]
3276
3819
  },
@@ -3302,7 +3845,7 @@ const tempPluginsConfig = {
3302
3845
  argument: {
3303
3846
  index: 0,
3304
3847
  isProperty: "expiresIn",
3305
- schema: z$1.coerce.string().optional()
3848
+ schema: z.coerce.string().optional()
3306
3849
  }
3307
3850
  },
3308
3851
  {
@@ -3314,7 +3857,7 @@ const tempPluginsConfig = {
3314
3857
  argument: {
3315
3858
  index: 0,
3316
3859
  isProperty: "interval",
3317
- schema: z$1.coerce.string().optional()
3860
+ schema: z.coerce.string().optional()
3318
3861
  }
3319
3862
  },
3320
3863
  {
@@ -3327,7 +3870,7 @@ const tempPluginsConfig = {
3327
3870
  argument: {
3328
3871
  index: 0,
3329
3872
  isProperty: "deviceCodeLength",
3330
- schema: z$1.coerce.number().positive().optional()
3873
+ schema: z.coerce.number().positive().optional()
3331
3874
  }
3332
3875
  },
3333
3876
  {
@@ -3340,7 +3883,7 @@ const tempPluginsConfig = {
3340
3883
  argument: {
3341
3884
  index: 0,
3342
3885
  isProperty: "userCodeLength",
3343
- schema: z$1.coerce.number().positive().optional()
3886
+ schema: z.coerce.number().positive().optional()
3344
3887
  }
3345
3888
  }
3346
3889
  ]
@@ -3371,7 +3914,7 @@ const tempPluginsConfig = {
3371
3914
  argument: {
3372
3915
  index: 0,
3373
3916
  isProperty: "customPasswordCompromisedMessage",
3374
- schema: z$1.coerce.string().optional()
3917
+ schema: z.coerce.string().optional()
3375
3918
  }
3376
3919
  }]
3377
3920
  },
@@ -3395,7 +3938,7 @@ const tempPluginsConfig = {
3395
3938
  argument: {
3396
3939
  index: 0,
3397
3940
  isProperty: "disableSettingJwtHeader",
3398
- schema: z$1.coerce.boolean().optional()
3941
+ schema: z.coerce.boolean().optional()
3399
3942
  }
3400
3943
  }]
3401
3944
  },
@@ -3427,7 +3970,7 @@ const tempPluginsConfig = {
3427
3970
  argument: {
3428
3971
  index: 0,
3429
3972
  isProperty: "cookieName",
3430
- schema: z$1.coerce.string().optional()
3973
+ schema: z.coerce.string().optional()
3431
3974
  }
3432
3975
  },
3433
3976
  {
@@ -3440,7 +3983,7 @@ const tempPluginsConfig = {
3440
3983
  argument: {
3441
3984
  index: 0,
3442
3985
  isProperty: "maxAge",
3443
- schema: z$1.coerce.number().positive().optional()
3986
+ schema: z.coerce.number().positive().optional()
3444
3987
  }
3445
3988
  },
3446
3989
  {
@@ -3452,7 +3995,7 @@ const tempPluginsConfig = {
3452
3995
  argument: {
3453
3996
  index: 0,
3454
3997
  isProperty: "storeInDatabase",
3455
- schema: z$1.coerce.boolean().optional()
3998
+ schema: z.coerce.boolean().optional()
3456
3999
  }
3457
4000
  }
3458
4001
  ]
@@ -3482,7 +4025,7 @@ const tempPluginsConfig = {
3482
4025
  argument: {
3483
4026
  index: 0,
3484
4027
  isProperty: "loginPage",
3485
- schema: z$1.coerce.string()
4028
+ schema: z.coerce.string()
3486
4029
  }
3487
4030
  }, {
3488
4031
  flag: "mcp-resource",
@@ -3492,7 +4035,7 @@ const tempPluginsConfig = {
3492
4035
  argument: {
3493
4036
  index: 0,
3494
4037
  isProperty: "resource",
3495
- schema: z$1.coerce.string().optional()
4038
+ schema: z.coerce.string().optional()
3496
4039
  }
3497
4040
  }]
3498
4041
  },
@@ -3517,7 +4060,7 @@ const tempPluginsConfig = {
3517
4060
  argument: {
3518
4061
  index: 0,
3519
4062
  isProperty: "maximumSessions",
3520
- schema: z$1.coerce.number().positive().optional()
4063
+ schema: z.coerce.number().positive().optional()
3521
4064
  }
3522
4065
  }]
3523
4066
  },
@@ -3547,7 +4090,7 @@ const tempPluginsConfig = {
3547
4090
  argument: {
3548
4091
  index: 0,
3549
4092
  isProperty: "currentURL",
3550
- schema: z$1.coerce.string().optional()
4093
+ schema: z.coerce.string().optional()
3551
4094
  }
3552
4095
  }, {
3553
4096
  flag: "oauth-proxy-production-url",
@@ -3557,7 +4100,7 @@ const tempPluginsConfig = {
3557
4100
  argument: {
3558
4101
  index: 0,
3559
4102
  isProperty: "productionURL",
3560
- schema: z$1.coerce.string().optional()
4103
+ schema: z.coerce.string().optional()
3561
4104
  }
3562
4105
  }]
3563
4106
  },
@@ -3581,7 +4124,7 @@ const tempPluginsConfig = {
3581
4124
  argument: {
3582
4125
  index: 0,
3583
4126
  isProperty: "disableSignup",
3584
- schema: z$1.coerce.boolean().optional()
4127
+ schema: z.coerce.boolean().optional()
3585
4128
  }
3586
4129
  }, {
3587
4130
  flag: "one-tap-client-id",
@@ -3591,7 +4134,7 @@ const tempPluginsConfig = {
3591
4134
  argument: {
3592
4135
  index: 0,
3593
4136
  isProperty: "clientId",
3594
- schema: z$1.coerce.string().optional()
4137
+ schema: z.coerce.string().optional()
3595
4138
  }
3596
4139
  }]
3597
4140
  },
@@ -3624,7 +4167,7 @@ const tempPluginsConfig = {
3624
4167
  argument: {
3625
4168
  index: 0,
3626
4169
  isProperty: "expiresIn",
3627
- schema: z$1.coerce.number().positive().optional()
4170
+ schema: z.coerce.number().positive().optional()
3628
4171
  }
3629
4172
  },
3630
4173
  {
@@ -3636,7 +4179,7 @@ const tempPluginsConfig = {
3636
4179
  argument: {
3637
4180
  index: 0,
3638
4181
  isProperty: "disableClientRequest",
3639
- schema: z$1.coerce.boolean().optional()
4182
+ schema: z.coerce.boolean().optional()
3640
4183
  }
3641
4184
  },
3642
4185
  {
@@ -3655,7 +4198,7 @@ const tempPluginsConfig = {
3655
4198
  argument: {
3656
4199
  index: 0,
3657
4200
  isProperty: "storeToken",
3658
- schema: z$1.enum(["plain", "hashed"]).optional()
4201
+ schema: z.enum(["plain", "hashed"]).optional()
3659
4202
  }
3660
4203
  }
3661
4204
  ]
@@ -3688,7 +4231,7 @@ const tempPluginsConfig = {
3688
4231
  argument: {
3689
4232
  index: 0,
3690
4233
  isProperty: "path",
3691
- schema: z$1.coerce.string().optional()
4234
+ schema: z.coerce.string().optional()
3692
4235
  }
3693
4236
  },
3694
4237
  {
@@ -3700,7 +4243,7 @@ const tempPluginsConfig = {
3700
4243
  argument: {
3701
4244
  index: 0,
3702
4245
  isProperty: "disableDefaultReference",
3703
- schema: z$1.coerce.boolean().optional()
4246
+ schema: z.coerce.boolean().optional()
3704
4247
  }
3705
4248
  },
3706
4249
  {
@@ -3762,7 +4305,7 @@ const tempPluginsConfig = {
3762
4305
  argument: {
3763
4306
  index: 0,
3764
4307
  isProperty: "theme",
3765
- schema: z$1.enum([
4308
+ schema: z.enum([
3766
4309
  "alternate",
3767
4310
  "default",
3768
4311
  "moon",
@@ -3801,7 +4344,7 @@ const tempPluginsConfig = {
3801
4344
  argument: {
3802
4345
  index: 0,
3803
4346
  isProperty: "allowUserToCreateOrganization",
3804
- schema: z$1.coerce.boolean().optional()
4347
+ schema: z.coerce.boolean().optional()
3805
4348
  }
3806
4349
  },
3807
4350
  {
@@ -3813,7 +4356,7 @@ const tempPluginsConfig = {
3813
4356
  argument: {
3814
4357
  index: 0,
3815
4358
  isProperty: "creatorRole",
3816
- schema: z$1.coerce.string().optional()
4359
+ schema: z.coerce.string().optional()
3817
4360
  }
3818
4361
  },
3819
4362
  {
@@ -3826,7 +4369,7 @@ const tempPluginsConfig = {
3826
4369
  argument: {
3827
4370
  index: 0,
3828
4371
  isProperty: "membershipLimit",
3829
- schema: z$1.coerce.number().positive().optional()
4372
+ schema: z.coerce.number().positive().optional()
3830
4373
  }
3831
4374
  }
3832
4375
  ]
@@ -3857,7 +4400,7 @@ const tempPluginsConfig = {
3857
4400
  argument: {
3858
4401
  index: 0,
3859
4402
  isProperty: "domain",
3860
- schema: z$1.coerce.string()
4403
+ schema: z.coerce.string()
3861
4404
  }
3862
4405
  },
3863
4406
  {
@@ -3868,7 +4411,7 @@ const tempPluginsConfig = {
3868
4411
  argument: {
3869
4412
  index: 0,
3870
4413
  isProperty: "emailDomainName",
3871
- schema: z$1.coerce.string().optional()
4414
+ schema: z.coerce.string().optional()
3872
4415
  }
3873
4416
  },
3874
4417
  {
@@ -3880,7 +4423,7 @@ const tempPluginsConfig = {
3880
4423
  argument: {
3881
4424
  index: 0,
3882
4425
  isProperty: "anonymous",
3883
- schema: z$1.coerce.boolean().optional()
4426
+ schema: z.coerce.boolean().optional()
3884
4427
  }
3885
4428
  }
3886
4429
  ]
@@ -3935,7 +4478,7 @@ const tempPluginsConfig = {
3935
4478
  argument: {
3936
4479
  index: 0,
3937
4480
  isProperty: "defaultOverrideUserInfo",
3938
- schema: z$1.coerce.boolean().optional()
4481
+ schema: z.coerce.boolean().optional()
3939
4482
  }
3940
4483
  },
3941
4484
  {
@@ -3948,7 +4491,7 @@ const tempPluginsConfig = {
3948
4491
  argument: {
3949
4492
  index: 0,
3950
4493
  isProperty: "disableImplicitSignUp",
3951
- schema: z$1.coerce.boolean().optional()
4494
+ schema: z.coerce.boolean().optional()
3952
4495
  }
3953
4496
  },
3954
4497
  {
@@ -3962,7 +4505,7 @@ const tempPluginsConfig = {
3962
4505
  argument: {
3963
4506
  index: 0,
3964
4507
  isProperty: "providersLimit",
3965
- schema: z$1.coerce.number().int().positive().optional()
4508
+ schema: z.coerce.number().int().positive().optional()
3966
4509
  }
3967
4510
  },
3968
4511
  {
@@ -3975,7 +4518,7 @@ const tempPluginsConfig = {
3975
4518
  argument: {
3976
4519
  index: 0,
3977
4520
  isProperty: "trustEmailVerified",
3978
- schema: z$1.coerce.boolean().optional()
4521
+ schema: z.coerce.boolean().optional()
3979
4522
  }
3980
4523
  },
3981
4524
  {
@@ -3986,7 +4529,7 @@ const tempPluginsConfig = {
3986
4529
  argument: {
3987
4530
  index: 0,
3988
4531
  isProperty: "domainVerification",
3989
- schema: z$1.object({ enabled: z$1.coerce.boolean().optional() }).optional()
4532
+ schema: z.object({ enabled: z.coerce.boolean().optional() }).optional()
3990
4533
  },
3991
4534
  isNestedObject: [{
3992
4535
  flag: "sso-domain-verification-enabled",
@@ -3998,7 +4541,7 @@ const tempPluginsConfig = {
3998
4541
  argument: {
3999
4542
  index: 0,
4000
4543
  isProperty: "enabled",
4001
- schema: z$1.coerce.boolean().optional()
4544
+ schema: z.coerce.boolean().optional()
4002
4545
  }
4003
4546
  }]
4004
4547
  }
@@ -4019,7 +4562,7 @@ const tempPluginsConfig = {
4019
4562
  argument: {
4020
4563
  index: 0,
4021
4564
  isProperty: "domainVerification",
4022
- schema: z$1.object({ enabled: z$1.coerce.boolean().optional() }).optional()
4565
+ schema: z.object({ enabled: z.coerce.boolean().optional() }).optional()
4023
4566
  },
4024
4567
  isNestedObject: [{
4025
4568
  flag: "sso-client-domain-verification-enabled",
@@ -4031,7 +4574,7 @@ const tempPluginsConfig = {
4031
4574
  argument: {
4032
4575
  index: 0,
4033
4576
  isProperty: "enabled",
4034
- schema: z$1.coerce.boolean().optional()
4577
+ schema: z.coerce.boolean().optional()
4035
4578
  }
4036
4579
  }]
4037
4580
  }]
@@ -6247,11 +6790,11 @@ const mcp = new Command("mcp").description("Add Better Auth MCP server to MCP Cl
6247
6790
  //#region src/commands/migrate.ts
6248
6791
  /** @internal */
6249
6792
  async function migrateAction(opts) {
6250
- const options = z$1.object({
6251
- cwd: z$1.string(),
6252
- config: z$1.string().optional(),
6253
- y: z$1.boolean().optional(),
6254
- yes: z$1.boolean().optional()
6793
+ const options = z.object({
6794
+ cwd: z.string(),
6795
+ config: z.string().optional(),
6796
+ y: z.boolean().optional(),
6797
+ yes: z.boolean().optional()
6255
6798
  }).parse(opts);
6256
6799
  const cwd = path.resolve(options.cwd);
6257
6800
  if (!existsSync(cwd)) {
@@ -6403,9 +6946,9 @@ function isBetterAuthPackage(name) {
6403
6946
  return name === "better-auth" || name.startsWith("@better-auth/");
6404
6947
  }
6405
6948
  async function upgradeAction(opts) {
6406
- const options = z$1.object({
6407
- cwd: z$1.string(),
6408
- yes: z$1.boolean().optional()
6949
+ const options = z.object({
6950
+ cwd: z.string(),
6951
+ yes: z.boolean().optional()
6409
6952
  }).parse(opts);
6410
6953
  const cwd = path.resolve(options.cwd);
6411
6954
  if (!existsSync(cwd)) {
@@ -6514,7 +7057,7 @@ async function main() {
6514
7057
  packageInfo = await getPackageInfo();
6515
7058
  cliVersion = packageInfo.version || "1.1.2";
6516
7059
  } catch {}
6517
- program.addCommand(init).addCommand(migrate).addCommand(generate).addCommand(generateSecret).addCommand(info).addCommand(login).addCommand(logout).addCommand(mcp).addCommand(upgrade).version(cliVersion).description("Better Auth CLI").action(() => program.help());
7060
+ program.addCommand(ai).addCommand(init).addCommand(migrate).addCommand(generate).addCommand(generateSecret).addCommand(info).addCommand(login).addCommand(logout).addCommand(mcp).addCommand(upgrade).version(cliVersion).description("Better Auth CLI").action(() => program.help());
6518
7061
  program.parse();
6519
7062
  }
6520
7063
  main().catch((error) => {