@agent-native/core 0.22.32 → 0.22.34
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/action.d.ts +7 -0
- package/dist/action.d.ts.map +1 -1
- package/dist/action.js.map +1 -1
- package/dist/client/extensions/ExtensionViewer.d.ts.map +1 -1
- package/dist/client/extensions/ExtensionViewer.js +26 -1
- package/dist/client/extensions/ExtensionViewer.js.map +1 -1
- package/dist/client/extensions/ExtensionViewer.spec.d.ts +2 -0
- package/dist/client/extensions/ExtensionViewer.spec.d.ts.map +1 -0
- package/dist/client/extensions/ExtensionViewer.spec.js +94 -0
- package/dist/client/extensions/ExtensionViewer.spec.js.map +1 -0
- package/dist/deploy/build.d.ts.map +1 -1
- package/dist/deploy/build.js +5 -50
- package/dist/deploy/build.js.map +1 -1
- package/dist/mcp/build-server.d.ts +8 -0
- package/dist/mcp/build-server.d.ts.map +1 -1
- package/dist/mcp/build-server.js +55 -13
- package/dist/mcp/build-server.js.map +1 -1
- package/dist/mcp/embed-app.d.ts.map +1 -1
- package/dist/mcp/embed-app.js +19 -0
- package/dist/mcp/embed-app.js.map +1 -1
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +13 -1
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/stdio.d.ts.map +1 -1
- package/dist/mcp/stdio.js +9 -2
- package/dist/mcp/stdio.js.map +1 -1
- package/dist/scripts/dev-session.d.ts +9 -13
- package/dist/scripts/dev-session.d.ts.map +1 -1
- package/dist/scripts/dev-session.js +28 -18
- package/dist/scripts/dev-session.js.map +1 -1
- package/dist/scripts/runner.js +1 -1
- package/dist/scripts/runner.js.map +1 -1
- package/dist/server/auth-marketing.d.ts +14 -0
- package/dist/server/auth-marketing.d.ts.map +1 -0
- package/dist/server/auth-marketing.js +268 -0
- package/dist/server/auth-marketing.js.map +1 -0
- package/dist/server/auth.d.ts.map +1 -1
- package/dist/server/auth.js +34 -25
- package/dist/server/auth.js.map +1 -1
- package/dist/server/embed-route.d.ts.map +1 -1
- package/dist/server/embed-route.js +39 -1
- package/dist/server/embed-route.js.map +1 -1
- package/dist/server/onboarding-html.d.ts +6 -0
- package/dist/server/onboarding-html.d.ts.map +1 -1
- package/dist/server/onboarding-html.js +6 -1
- package/dist/server/onboarding-html.js.map +1 -1
- package/dist/server/ssr-handler.d.ts +0 -1
- package/dist/server/ssr-handler.d.ts.map +1 -1
- package/dist/server/ssr-handler.js +6 -7
- package/dist/server/ssr-handler.js.map +1 -1
- package/docs/content/actions.md +1 -1
- package/docs/content/external-agents.md +43 -10
- package/docs/content/mcp-protocol.md +18 -1
- package/package.json +1 -1
|
@@ -9,20 +9,16 @@
|
|
|
9
9
|
* this helper every db-* CLI run hands the user a stack trace.
|
|
10
10
|
*
|
|
11
11
|
* What this does: when the runner is about to dispatch, resolve a real
|
|
12
|
-
* email
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* identity.
|
|
12
|
+
* email from the legacy `sessions` table (the same table that
|
|
13
|
+
* `addSession()` writes from google-oauth.ts and the A2A receiver fallback
|
|
14
|
+
* already consults). The runner then wraps dispatch in
|
|
15
|
+
* `runWithRequestContext({ userEmail })` so the action sees a real identity.
|
|
17
16
|
*
|
|
18
|
-
* SHARED-DEV-BOX CAVEAT:
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* `AGENT_USER_EMAIL=<your-email>` in your shell or `.env`; explicit env
|
|
24
|
-
* always wins. A `[dev-session]` log line is emitted so wrong-binding
|
|
25
|
-
* is easy to spot.
|
|
17
|
+
* SHARED-DEV-BOX CAVEAT: this table is unscoped. To avoid silently binding
|
|
18
|
+
* to another developer, auto-binding only happens when the table contains
|
|
19
|
+
* exactly one distinct real email. If multiple developers have signed in,
|
|
20
|
+
* set `AGENT_USER_EMAIL=<your-email>` in your shell or `.env`; explicit env
|
|
21
|
+
* always wins.
|
|
26
22
|
*
|
|
27
23
|
* Strict gating mirrors the A2A precedent in
|
|
28
24
|
* `server/agent-chat-plugin.ts` (search for "latest session"):
|
|
@@ -59,14 +55,28 @@ export async function resolveDevUserEmail() {
|
|
|
59
55
|
try {
|
|
60
56
|
const { getDbExec } = await import("../db/client.js");
|
|
61
57
|
const { rows } = await getDbExec().execute({
|
|
62
|
-
sql: `SELECT email
|
|
63
|
-
|
|
64
|
-
|
|
58
|
+
sql: `SELECT email
|
|
59
|
+
FROM (
|
|
60
|
+
SELECT TRIM(email) AS email, MAX(created_at) AS last_seen
|
|
61
|
+
FROM sessions
|
|
62
|
+
WHERE email IS NOT NULL AND TRIM(email) <> ?
|
|
63
|
+
GROUP BY TRIM(email)
|
|
64
|
+
) AS session_owners
|
|
65
|
+
WHERE email <> ''
|
|
66
|
+
ORDER BY last_seen DESC
|
|
67
|
+
LIMIT 2`,
|
|
65
68
|
args: [DEV_FALLBACK_EMAIL],
|
|
66
69
|
});
|
|
67
|
-
const
|
|
68
|
-
|
|
70
|
+
const emails = rows
|
|
71
|
+
.map((row) => (typeof row.email === "string" ? row.email.trim() : ""))
|
|
72
|
+
.filter((email) => email.length > 0);
|
|
73
|
+
if (emails.length === 0)
|
|
69
74
|
return undefined;
|
|
75
|
+
if (emails.length > 1) {
|
|
76
|
+
console.warn(`[dev-session] multiple session owners found (${emails.join(", ")}); set AGENT_USER_EMAIL=<email> to choose one`);
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
79
|
+
const email = emails[0];
|
|
70
80
|
console.log(`[dev-session] auto-bound to ${email} (set AGENT_USER_EMAIL to override)`);
|
|
71
81
|
return email;
|
|
72
82
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev-session.js","sourceRoot":"","sources":["../../src/scripts/dev-session.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"dev-session.js","sourceRoot":"","sources":["../../src/scripts/dev-session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;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DAAgD,MAAM,CAAC,IAAI,CACzD,IAAI,CACL,+CAA+C,CACjD,CAAC;YACF,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;QACxB,OAAO,CAAC,GAAG,CACT,+BAA+B,KAAK,qCAAqC,CAC1E,CAAC;QACF,OAAO,KAAK,CAAC;IACf,CAAC;IAAC,MAAM,CAAC;QACP,oEAAoE;QACpE,kEAAkE;QAClE,+DAA+D;QAC/D,mCAAmC;QACnC,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC","sourcesContent":["/**\n * Dev-only session bootstrap for `pnpm action <name>` (and any other CLI\n * caller of `runScript`).\n *\n * After changes-53, db-exec / db-query / db-patch refuse to run unless\n * `getRequestUserEmail()` returns a real identity. In an HTTP request the\n * Nitro plugin wraps the handler in `runWithRequestContext({ userEmail })`\n * so scoping just works. CLI invocations have no such wrapper, so without\n * this helper every db-* CLI run hands the user a stack trace.\n *\n * What this does: when the runner is about to dispatch, resolve a real\n * email from the legacy `sessions` table (the same table that\n * `addSession()` writes from google-oauth.ts and the A2A receiver fallback\n * already consults). The runner then wraps dispatch in\n * `runWithRequestContext({ userEmail })` so the action sees a real identity.\n *\n * SHARED-DEV-BOX CAVEAT: this table is unscoped. To avoid silently binding\n * to another developer, auto-binding only happens when the table contains\n * exactly one distinct real email. If multiple developers have signed in,\n * set `AGENT_USER_EMAIL=<your-email>` in your shell or `.env`; explicit env\n * always wins.\n *\n * Strict gating mirrors the A2A precedent in\n * `server/agent-chat-plugin.ts` (search for \"latest session\"):\n * - NODE_ENV !== \"production\".\n * - AUTH_MODE unset or === \"local\" — don't auto-impersonate when an\n * admin or hosted auth mode is in use.\n *\n * If `process.env.AGENT_USER_EMAIL` is already set we return it unchanged\n * — explicit env wins over any DB-derived guess (matches how\n * `getRequestUserEmail()` itself behaves).\n */\n\nconst DEV_FALLBACK_EMAIL = \"local@localhost\"; // guard:allow-localhost-fallback — sentinel intentionally rejected so the resolver doesn't return it\n\n/**\n * Resolve the local dev user's email for the current CLI invocation.\n *\n * Returns the resolved email, or `undefined` when no real identity is\n * available. Callers should let the downstream \"no authenticated user\"\n * error propagate — its message points the user at the two fixes\n * (sign in via the running app, or set `AGENT_USER_EMAIL`).\n */\nexport async function resolveDevUserEmail(): Promise<string | undefined> {\n const explicit = process.env.AGENT_USER_EMAIL;\n if (explicit) return explicit;\n\n // Hard refusal: this helper must never source identity in prod.\n if (process.env.NODE_ENV === \"production\") return undefined;\n\n // AUTH_MODE may be unset (default dev shim) or \"local\". Anything else\n // means a non-dev auth mode is in play; don't try to fish a session\n // out of the DB on its behalf.\n const authMode = process.env.AUTH_MODE;\n if (authMode && authMode !== \"local\") return undefined;\n\n try {\n const { getDbExec } = await import(\"../db/client.js\");\n const { rows } = await getDbExec().execute({\n sql: `SELECT email\n FROM (\n SELECT TRIM(email) AS email, MAX(created_at) AS last_seen\n FROM sessions\n WHERE email IS NOT NULL AND TRIM(email) <> ?\n GROUP BY TRIM(email)\n ) AS session_owners\n WHERE email <> ''\n ORDER BY last_seen DESC\n LIMIT 2`,\n args: [DEV_FALLBACK_EMAIL],\n });\n const emails = rows\n .map((row) => (typeof row.email === \"string\" ? row.email.trim() : \"\"))\n .filter((email) => email.length > 0);\n if (emails.length === 0) return undefined;\n if (emails.length > 1) {\n console.warn(\n `[dev-session] multiple session owners found (${emails.join(\n \", \",\n )}); set AGENT_USER_EMAIL=<email> to choose one`,\n );\n return undefined;\n }\n const email = emails[0];\n console.log(\n `[dev-session] auto-bound to ${email} (set AGENT_USER_EMAIL to override)`,\n );\n return email;\n } catch {\n // The sessions table doesn't exist yet (fresh install where the web\n // server has never booted) or the DB isn't reachable. Either way,\n // we can't produce an identity — let the caller throw with the\n // friendlier \"sign in first\" hint.\n return undefined;\n }\n}\n"]}
|
package/dist/scripts/runner.js
CHANGED
|
@@ -84,7 +84,7 @@ export async function runScript(options = {}) {
|
|
|
84
84
|
// it, db-exec / db-query / db-patch and any action that calls
|
|
85
85
|
// `getRequestUserEmail()` see no identity and refuse to run. The
|
|
86
86
|
// resolver picks up `AGENT_USER_EMAIL` if explicitly set, otherwise
|
|
87
|
-
// reads the
|
|
87
|
+
// reads the DB session owner only when it is unambiguous (dev-only,
|
|
88
88
|
// narrowly gated — see dev-session.ts).
|
|
89
89
|
//
|
|
90
90
|
// This wrap is intentionally a single point of injection: it covers
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../../src/scripts/runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAGhE,kFAAkF;AAClF,OAAO,EAAE,CAAC;AAYV,KAAK,UAAU,uBAAuB;IACpC,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,sBAAsB,CAAC,CAAC;IACzE,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC;QAAE,OAAO;IAEzC,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,kBAAkB,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,CAAC;IAC9E,MAAM,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC;IAC3B,IAAI,OAAO,MAAM,K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,CAAC,CAAC;YACpC,OAAO,CAAC,KAAK,CAAC,WAAW,UAAU,WAAW,EAAE,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC,CAAC;YACpE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;IAED,+BAA+B;IAC/B,MAAM,UAAU,GAAG,WAAW,CAAC,UAAU,CAAC,CAAC;IAC3C,IAAI,UAAU,EAAE,CAAC;QACf,IAAI,CAAC;YACH,MAAM,UAAU,CAAC,IAAI,CAAC,CAAC;YACvB,MAAM,WAAW,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;YACpC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,MAAM,WAAW,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;YACpC,OAAO,CAAC,KAAK,CAAC,gBAAgB,UAAU,WAAW,EAAE,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC,CAAC;YACzE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;IAED,wBAAwB;IACxB,OAAO,CAAC,KAAK,CACX,kBAAkB,UAAU,8DAA8D,CAC3F,CAAC;IACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC","sourcesContent":["/**\n * Generic action dispatcher for @agent-native/core apps.\n *\n * Dynamically imports and runs actions from the app's actions/ directory.\n * Falls back to scripts/ directory for backwards compatibility, then to\n * core scripts (db-schema, db-query, db-exec, etc.) when no local action is found.\n *\n * Actions must export a default function: (args: string[]) => Promise<void>\n *\n * Usage: pnpm action <action-name> [--args]\n */\n\nimport path from \"path\";\nimport fs from \"fs\";\nimport { pathToFileURL } from \"url\";\nimport { coreScripts, getCoreScriptNames } from \"./core-scripts.js\";\nimport { closeDbExec } from \"../db/client.js\";\nimport { loadEnv } from \"./utils.js\";\nimport { runWithRequestContext } from \"../server/request-context.js\";\nimport { resolveDevUserEmail } from \"./dev-session.js\";\nimport { notifyActionChange } from \"../server/action-change.js\";\nimport type { ActionEntry } from \"../agent/production-agent.js\";\n\n// Load .env from cwd so DATABASE_URL and other vars are available to all actions.\nloadEnv();\n\nexport interface RunScriptOptions {\n /**\n * Actions contributed by packages rather than the app's local `actions/`\n * directory. Local app actions still win on name collision.\n */\n packageActions?: Record<string, ActionEntry>;\n /** Help-section label for package actions. */\n packageActionLabel?: string;\n}\n\nasync function runAppDbPluginIfPresent(): Promise<void> {\n const dbPluginPath = path.resolve(process.cwd(), \"server/plugins/db.ts\");\n if (!fs.existsSync(dbPluginPath)) return;\n\n const mod = await import(/* @vite-ignore */ pathToFileURL(dbPluginPath).href);\n const plugin = mod.default;\n if (typeof plugin === \"function\") {\n await plugin({});\n }\n}\n\n/**\n * Run the action dispatcher. Call this from your app's actions/run.ts (or scripts/run.ts):\n *\n * import { runScript } from \"@agent-native/core\";\n * runScript();\n */\nexport async function runScript(options: RunScriptOptions = {}): Promise<void> {\n const actionName = process.argv[2];\n\n if (!actionName || actionName === \"--help\") {\n console.log(`Usage: pnpm action <action-name> [--arg value ...]`);\n console.log(`\\nRun any action with --help for usage details.`);\n\n // List local actions (try actions/ first, then scripts/)\n const actionsDir = path.resolve(process.cwd(), \"actions\");\n const scriptsDir = path.resolve(process.cwd(), \"scripts\");\n const localDir = fs.existsSync(actionsDir) ? actionsDir : scriptsDir;\n if (fs.existsSync(localDir)) {\n const locals = fs\n .readdirSync(localDir)\n .filter((f) => f.endsWith(\".ts\") && f !== \"run.ts\")\n .map((f) => f.replace(/\\.ts$/, \"\"));\n if (locals.length > 0) {\n console.log(`\\nApp actions:`);\n for (const name of locals) {\n console.log(` ${name}`);\n }\n }\n }\n\n const packageActionNames = Object.keys(options.packageActions ?? {}).sort();\n if (packageActionNames.length > 0) {\n console.log(`\\n${options.packageActionLabel ?? \"Package actions\"}:`);\n for (const name of packageActionNames) {\n console.log(` ${name}`);\n }\n }\n\n // List core scripts\n const coreNames = getCoreScriptNames();\n if (coreNames.length > 0) {\n console.log(`\\nCore actions (built-in):`);\n for (const name of coreNames) {\n console.log(` ${name}`);\n }\n }\n\n process.exit(0);\n }\n\n // Validate action name (only allow alphanumeric + hyphens)\n if (!/^[a-z][a-z0-9-]*$/.test(actionName)) {\n console.error(`Error: Invalid action name \"${actionName}\"`);\n process.exit(1);\n }\n\n const args = process.argv.slice(3);\n\n // Establish a request context for the duration of this CLI run. Without\n // it, db-exec / db-query / db-patch and any action that calls\n // `getRequestUserEmail()` see no identity and refuse to run. The\n // resolver picks up `AGENT_USER_EMAIL` if explicitly set, otherwise\n // reads the most-recent signed-in session from the DB (dev-only,\n // narrowly gated — see dev-session.ts).\n //\n // This wrap is intentionally a single point of injection: it covers\n // both the local-action branch and the fall-through to core scripts\n // (db-query, db-exec, …) so every CLI entrypoint runs scoped to a real\n // user. It uses `runWithRequestContext` rather than mutating\n // `process.env.AGENT_USER_EMAIL` because env mutation leaks across\n // boundaries — see the cautionary comment in\n // `server/request-context.ts` about exactly that pattern.\n const userEmail = await resolveDevUserEmail();\n const orgId = process.env.AGENT_ORG_ID || undefined;\n\n return runWithRequestContext({ userEmail, orgId }, () =>\n dispatchAction(actionName, args, options),\n );\n}\n\nfunction coerceCliValue(\n value: string,\n coerceBooleans: boolean,\n): string | boolean {\n if (!coerceBooleans) return value;\n if (value === \"true\") return true;\n if (value === \"false\") return false;\n return value;\n}\n\nfunction setParsedArg(\n parsed: Record<string, unknown>,\n key: string,\n value: unknown,\n) {\n const existing = parsed[key];\n if (existing === undefined) {\n parsed[key] = value;\n return;\n }\n parsed[key] = Array.isArray(existing)\n ? [...existing, value]\n : [existing, value];\n}\n\nfunction parseActionArgs(\n args: string[],\n options: { coerceBooleans?: boolean } = {},\n): Record<string, unknown> {\n const parsed: Record<string, unknown> = {};\n const coerceBooleans = options.coerceBooleans ?? false;\n for (let i = 0; i < args.length; i++) {\n const arg = args[i];\n if (!arg.startsWith(\"--\")) continue;\n const eqIdx = arg.indexOf(\"=\");\n if (eqIdx > 0) {\n setParsedArg(\n parsed,\n arg.slice(2, eqIdx),\n coerceCliValue(arg.slice(eqIdx + 1), coerceBooleans),\n );\n } else {\n const key = arg.slice(2);\n const next = args[i + 1];\n if (next && !next.startsWith(\"--\")) {\n setParsedArg(parsed, key, coerceCliValue(next, coerceBooleans));\n i++;\n } else {\n setParsedArg(parsed, key, coerceBooleans ? true : \"true\");\n }\n }\n }\n return parsed;\n}\n\nasync function dispatchAction(\n actionName: string,\n args: string[],\n options: RunScriptOptions,\n): Promise<void> {\n // 1. Try local app action first (actions/ then scripts/ for backwards compat)\n const actionsPath = path.resolve(\n process.cwd(),\n \"actions\",\n `${actionName}.ts`,\n );\n const scriptsPath = path.resolve(\n process.cwd(),\n \"scripts\",\n `${actionName}.ts`,\n );\n const localPath = fs.existsSync(actionsPath) ? actionsPath : scriptsPath;\n\n if (fs.existsSync(localPath)) {\n try {\n await runAppDbPluginIfPresent();\n const mod = await import(\n /* @vite-ignore */ pathToFileURL(localPath).href\n );\n const handler = mod.default;\n // Support defineAction-style default exports (object with run method)\n if (\n handler &&\n typeof handler === \"object\" &&\n typeof handler.run === \"function\"\n ) {\n const parsed = parseActionArgs(args, { coerceBooleans: true });\n const result = await handler.run(parsed);\n if (handler.readOnly !== true) {\n await notifyActionChange({ actionName }).catch(() => {});\n }\n if (result) console.log(result);\n } else if (typeof handler === \"function\") {\n await handler(args);\n } else {\n console.error(\n `Action \"${actionName}\" does not export a default function or defineAction.`,\n );\n process.exit(1);\n }\n await closeDbExec().catch(() => {});\n process.exit(0);\n } catch (err: any) {\n await closeDbExec().catch(() => {});\n console.error(`Action \"${actionName}\" failed:`, err.message || err);\n process.exit(1);\n }\n }\n\n // 2. Try package-contributed actions (e.g. @agent-native/dispatch)\n const packageAction = options.packageActions?.[actionName];\n if (packageAction) {\n try {\n await runAppDbPluginIfPresent();\n const parsed = parseActionArgs(args, { coerceBooleans: true });\n const result = await packageAction.run(parsed as Record<string, string>);\n if (packageAction.readOnly !== true) {\n await notifyActionChange({ actionName }).catch(() => {});\n }\n if (result) console.log(result);\n await closeDbExec().catch(() => {});\n process.exit(0);\n } catch (err: any) {\n await closeDbExec().catch(() => {});\n console.error(`Action \"${actionName}\" failed:`, err.message || err);\n process.exit(1);\n }\n }\n\n // 3. Fall back to core scripts\n const coreScript = coreScripts[actionName];\n if (coreScript) {\n try {\n await coreScript(args);\n await closeDbExec().catch(() => {});\n process.exit(0);\n } catch (err: any) {\n await closeDbExec().catch(() => {});\n console.error(`Core action \"${actionName}\" failed:`, err.message || err);\n process.exit(1);\n }\n }\n\n // 4. Not found anywhere\n console.error(\n `Error: Action \"${actionName}\" not found. Run \"pnpm action --help\" for available actions.`,\n );\n process.exit(1);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../../src/scripts/runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAGhE,kFAAkF;AAClF,OAAO,EAAE,CAAC;AAYV,KAAK,UAAU,uBAAuB;IACpC,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,sBAAsB,CA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AAC,MAAM,CAAC,CAAC;YAChC,MAAM,WAAW,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;YACpC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,MAAM,WAAW,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;YACpC,OAAO,CAAC,KAAK,CAAC,WAAW,UAAU,WAAW,EAAE,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC,CAAC;YACpE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;IAED,+BAA+B;IAC/B,MAAM,UAAU,GAAG,WAAW,CAAC,UAAU,CAAC,CAAC;IAC3C,IAAI,UAAU,EAAE,CAAC;QACf,IAAI,CAAC;YACH,MAAM,UAAU,CAAC,IAAI,CAAC,CAAC;YACvB,MAAM,WAAW,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;YACpC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,MAAM,WAAW,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;YACpC,OAAO,CAAC,KAAK,CAAC,gBAAgB,UAAU,WAAW,EAAE,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC,CAAC;YACzE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;IAED,wBAAwB;IACxB,OAAO,CAAC,KAAK,CACX,kBAAkB,UAAU,8DAA8D,CAC3F,CAAC;IACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC","sourcesContent":["/**\n * Generic action dispatcher for @agent-native/core apps.\n *\n * Dynamically imports and runs actions from the app's actions/ directory.\n * Falls back to scripts/ directory for backwards compatibility, then to\n * core scripts (db-schema, db-query, db-exec, etc.) when no local action is found.\n *\n * Actions must export a default function: (args: string[]) => Promise<void>\n *\n * Usage: pnpm action <action-name> [--args]\n */\n\nimport path from \"path\";\nimport fs from \"fs\";\nimport { pathToFileURL } from \"url\";\nimport { coreScripts, getCoreScriptNames } from \"./core-scripts.js\";\nimport { closeDbExec } from \"../db/client.js\";\nimport { loadEnv } from \"./utils.js\";\nimport { runWithRequestContext } from \"../server/request-context.js\";\nimport { resolveDevUserEmail } from \"./dev-session.js\";\nimport { notifyActionChange } from \"../server/action-change.js\";\nimport type { ActionEntry } from \"../agent/production-agent.js\";\n\n// Load .env from cwd so DATABASE_URL and other vars are available to all actions.\nloadEnv();\n\nexport interface RunScriptOptions {\n /**\n * Actions contributed by packages rather than the app's local `actions/`\n * directory. Local app actions still win on name collision.\n */\n packageActions?: Record<string, ActionEntry>;\n /** Help-section label for package actions. */\n packageActionLabel?: string;\n}\n\nasync function runAppDbPluginIfPresent(): Promise<void> {\n const dbPluginPath = path.resolve(process.cwd(), \"server/plugins/db.ts\");\n if (!fs.existsSync(dbPluginPath)) return;\n\n const mod = await import(/* @vite-ignore */ pathToFileURL(dbPluginPath).href);\n const plugin = mod.default;\n if (typeof plugin === \"function\") {\n await plugin({});\n }\n}\n\n/**\n * Run the action dispatcher. Call this from your app's actions/run.ts (or scripts/run.ts):\n *\n * import { runScript } from \"@agent-native/core\";\n * runScript();\n */\nexport async function runScript(options: RunScriptOptions = {}): Promise<void> {\n const actionName = process.argv[2];\n\n if (!actionName || actionName === \"--help\") {\n console.log(`Usage: pnpm action <action-name> [--arg value ...]`);\n console.log(`\\nRun any action with --help for usage details.`);\n\n // List local actions (try actions/ first, then scripts/)\n const actionsDir = path.resolve(process.cwd(), \"actions\");\n const scriptsDir = path.resolve(process.cwd(), \"scripts\");\n const localDir = fs.existsSync(actionsDir) ? actionsDir : scriptsDir;\n if (fs.existsSync(localDir)) {\n const locals = fs\n .readdirSync(localDir)\n .filter((f) => f.endsWith(\".ts\") && f !== \"run.ts\")\n .map((f) => f.replace(/\\.ts$/, \"\"));\n if (locals.length > 0) {\n console.log(`\\nApp actions:`);\n for (const name of locals) {\n console.log(` ${name}`);\n }\n }\n }\n\n const packageActionNames = Object.keys(options.packageActions ?? {}).sort();\n if (packageActionNames.length > 0) {\n console.log(`\\n${options.packageActionLabel ?? \"Package actions\"}:`);\n for (const name of packageActionNames) {\n console.log(` ${name}`);\n }\n }\n\n // List core scripts\n const coreNames = getCoreScriptNames();\n if (coreNames.length > 0) {\n console.log(`\\nCore actions (built-in):`);\n for (const name of coreNames) {\n console.log(` ${name}`);\n }\n }\n\n process.exit(0);\n }\n\n // Validate action name (only allow alphanumeric + hyphens)\n if (!/^[a-z][a-z0-9-]*$/.test(actionName)) {\n console.error(`Error: Invalid action name \"${actionName}\"`);\n process.exit(1);\n }\n\n const args = process.argv.slice(3);\n\n // Establish a request context for the duration of this CLI run. Without\n // it, db-exec / db-query / db-patch and any action that calls\n // `getRequestUserEmail()` see no identity and refuse to run. The\n // resolver picks up `AGENT_USER_EMAIL` if explicitly set, otherwise\n // reads the DB session owner only when it is unambiguous (dev-only,\n // narrowly gated — see dev-session.ts).\n //\n // This wrap is intentionally a single point of injection: it covers\n // both the local-action branch and the fall-through to core scripts\n // (db-query, db-exec, …) so every CLI entrypoint runs scoped to a real\n // user. It uses `runWithRequestContext` rather than mutating\n // `process.env.AGENT_USER_EMAIL` because env mutation leaks across\n // boundaries — see the cautionary comment in\n // `server/request-context.ts` about exactly that pattern.\n const userEmail = await resolveDevUserEmail();\n const orgId = process.env.AGENT_ORG_ID || undefined;\n\n return runWithRequestContext({ userEmail, orgId }, () =>\n dispatchAction(actionName, args, options),\n );\n}\n\nfunction coerceCliValue(\n value: string,\n coerceBooleans: boolean,\n): string | boolean {\n if (!coerceBooleans) return value;\n if (value === \"true\") return true;\n if (value === \"false\") return false;\n return value;\n}\n\nfunction setParsedArg(\n parsed: Record<string, unknown>,\n key: string,\n value: unknown,\n) {\n const existing = parsed[key];\n if (existing === undefined) {\n parsed[key] = value;\n return;\n }\n parsed[key] = Array.isArray(existing)\n ? [...existing, value]\n : [existing, value];\n}\n\nfunction parseActionArgs(\n args: string[],\n options: { coerceBooleans?: boolean } = {},\n): Record<string, unknown> {\n const parsed: Record<string, unknown> = {};\n const coerceBooleans = options.coerceBooleans ?? false;\n for (let i = 0; i < args.length; i++) {\n const arg = args[i];\n if (!arg.startsWith(\"--\")) continue;\n const eqIdx = arg.indexOf(\"=\");\n if (eqIdx > 0) {\n setParsedArg(\n parsed,\n arg.slice(2, eqIdx),\n coerceCliValue(arg.slice(eqIdx + 1), coerceBooleans),\n );\n } else {\n const key = arg.slice(2);\n const next = args[i + 1];\n if (next && !next.startsWith(\"--\")) {\n setParsedArg(parsed, key, coerceCliValue(next, coerceBooleans));\n i++;\n } else {\n setParsedArg(parsed, key, coerceBooleans ? true : \"true\");\n }\n }\n }\n return parsed;\n}\n\nasync function dispatchAction(\n actionName: string,\n args: string[],\n options: RunScriptOptions,\n): Promise<void> {\n // 1. Try local app action first (actions/ then scripts/ for backwards compat)\n const actionsPath = path.resolve(\n process.cwd(),\n \"actions\",\n `${actionName}.ts`,\n );\n const scriptsPath = path.resolve(\n process.cwd(),\n \"scripts\",\n `${actionName}.ts`,\n );\n const localPath = fs.existsSync(actionsPath) ? actionsPath : scriptsPath;\n\n if (fs.existsSync(localPath)) {\n try {\n await runAppDbPluginIfPresent();\n const mod = await import(\n /* @vite-ignore */ pathToFileURL(localPath).href\n );\n const handler = mod.default;\n // Support defineAction-style default exports (object with run method)\n if (\n handler &&\n typeof handler === \"object\" &&\n typeof handler.run === \"function\"\n ) {\n const parsed = parseActionArgs(args, { coerceBooleans: true });\n const result = await handler.run(parsed);\n if (handler.readOnly !== true) {\n await notifyActionChange({ actionName }).catch(() => {});\n }\n if (result) console.log(result);\n } else if (typeof handler === \"function\") {\n await handler(args);\n } else {\n console.error(\n `Action \"${actionName}\" does not export a default function or defineAction.`,\n );\n process.exit(1);\n }\n await closeDbExec().catch(() => {});\n process.exit(0);\n } catch (err: any) {\n await closeDbExec().catch(() => {});\n console.error(`Action \"${actionName}\" failed:`, err.message || err);\n process.exit(1);\n }\n }\n\n // 2. Try package-contributed actions (e.g. @agent-native/dispatch)\n const packageAction = options.packageActions?.[actionName];\n if (packageAction) {\n try {\n await runAppDbPluginIfPresent();\n const parsed = parseActionArgs(args, { coerceBooleans: true });\n const result = await packageAction.run(parsed as Record<string, string>);\n if (packageAction.readOnly !== true) {\n await notifyActionChange({ actionName }).catch(() => {});\n }\n if (result) console.log(result);\n await closeDbExec().catch(() => {});\n process.exit(0);\n } catch (err: any) {\n await closeDbExec().catch(() => {});\n console.error(`Action \"${actionName}\" failed:`, err.message || err);\n process.exit(1);\n }\n }\n\n // 3. Fall back to core scripts\n const coreScript = coreScripts[actionName];\n if (coreScript) {\n try {\n await coreScript(args);\n await closeDbExec().catch(() => {});\n process.exit(0);\n } catch (err: any) {\n await closeDbExec().catch(() => {});\n console.error(`Core action \"${actionName}\" failed:`, err.message || err);\n process.exit(1);\n }\n }\n\n // 4. Not found anywhere\n console.error(\n `Error: Action \"${actionName}\" not found. Run \"pnpm action --help\" for available actions.`,\n );\n process.exit(1);\n}\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface AuthMarketingContent {
|
|
2
|
+
appName: string;
|
|
3
|
+
tagline: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
features?: string[];
|
|
6
|
+
runLocalCommand?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface ResolveBuiltInAuthMarketingOptions {
|
|
9
|
+
requestHost?: string;
|
|
10
|
+
requestPath?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare const BUILT_IN_AUTH_MARKETING: Record<string, AuthMarketingContent>;
|
|
13
|
+
export declare function resolveBuiltInAuthMarketing(opts?: ResolveBuiltInAuthMarketingOptions): AuthMarketingContent | undefined;
|
|
14
|
+
//# sourceMappingURL=auth-marketing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-marketing.d.ts","sourceRoot":"","sources":["../../src/server/auth-marketing.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,kCAAkC;IACjD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,eAAO,MAAM,uBAAuB,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CA0MxE,CAAC;AAiFF,wBAAgB,2BAA2B,CACzC,IAAI,GAAE,kCAAuC,GAC5C,oBAAoB,GAAG,SAAS,CAMlC"}
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
export const BUILT_IN_AUTH_MARKETING = {
|
|
2
|
+
analytics: {
|
|
3
|
+
appName: "Agent-Native Analytics",
|
|
4
|
+
tagline: "Your AI agent queries your data sources, builds dashboards, and answers business questions alongside you.",
|
|
5
|
+
features: [
|
|
6
|
+
"Ask any question and get answers from BigQuery, HubSpot, Jira, and more",
|
|
7
|
+
"Agent-built dashboards that pull live data from all your sources",
|
|
8
|
+
"Saved analyses the agent can re-run on demand with fresh numbers",
|
|
9
|
+
],
|
|
10
|
+
},
|
|
11
|
+
brain: {
|
|
12
|
+
appName: "Agent-Native Brain",
|
|
13
|
+
tagline: "A company memory layer where raw conversations become reviewed, searchable institutional knowledge.",
|
|
14
|
+
features: [
|
|
15
|
+
"Import transcripts, notes, Slack exports, and Granola summaries",
|
|
16
|
+
"Validate every fact against exact source quotes",
|
|
17
|
+
"Review company-wide knowledge through proposal workflows",
|
|
18
|
+
],
|
|
19
|
+
},
|
|
20
|
+
calendar: {
|
|
21
|
+
appName: "Agent-Native Calendar",
|
|
22
|
+
tagline: "Your AI agent schedules, reschedules, and manages your calendar so you never have to.",
|
|
23
|
+
features: [
|
|
24
|
+
"Finds open slots and books meetings on your behalf",
|
|
25
|
+
"Manages availability and booking links automatically",
|
|
26
|
+
"Answers schedule questions and resolves conflicts instantly",
|
|
27
|
+
],
|
|
28
|
+
},
|
|
29
|
+
calls: {
|
|
30
|
+
appName: "Agent-Native Calls",
|
|
31
|
+
tagline: "Your AI agent transcribes, summarizes, and surfaces key moments from every conversation.",
|
|
32
|
+
features: [
|
|
33
|
+
"Automatic recaps, action items, and next steps after every call",
|
|
34
|
+
"Smart trackers that detect competitor mentions, objections, and custom topics",
|
|
35
|
+
"Shareable snippets for the exact moment that matters",
|
|
36
|
+
],
|
|
37
|
+
},
|
|
38
|
+
clips: {
|
|
39
|
+
appName: "Agent-Native Clips",
|
|
40
|
+
tagline: "Your AI agent transcribes, summarizes, and searches everything you record alongside you.",
|
|
41
|
+
features: [
|
|
42
|
+
"One-click screen recording with automatic titles, summaries, and chapters",
|
|
43
|
+
"Calendar-synced meeting notes with live transcripts and action items",
|
|
44
|
+
"One searchable library across recordings, meetings, and dictations",
|
|
45
|
+
],
|
|
46
|
+
},
|
|
47
|
+
code: {
|
|
48
|
+
appName: "Agent-Native Code",
|
|
49
|
+
tagline: "A customizable local Agent-Native Code UI for long-running coding sessions, slash commands, and migration goals.",
|
|
50
|
+
features: [
|
|
51
|
+
"Start and resume local coding sessions",
|
|
52
|
+
"Use the same transcript store as the CLI and Desktop",
|
|
53
|
+
"Customize the UI while reusing the agent-native run harness",
|
|
54
|
+
],
|
|
55
|
+
},
|
|
56
|
+
content: {
|
|
57
|
+
appName: "Agent-Native Content",
|
|
58
|
+
tagline: "Your AI agent creates, edits, and organizes documents alongside you in a Notion-like workspace.",
|
|
59
|
+
features: [
|
|
60
|
+
"Create and restructure entire document trees from a single prompt",
|
|
61
|
+
"Surgical edits that sync live to your editor via real-time collaboration",
|
|
62
|
+
"Search, summarize, and cross-reference documents instantly",
|
|
63
|
+
],
|
|
64
|
+
},
|
|
65
|
+
design: {
|
|
66
|
+
appName: "Agent-Native Design",
|
|
67
|
+
tagline: "Design and prototype by describing what you want. The AI agent turns your ideas into interactive, fully responsive designs in seconds.",
|
|
68
|
+
features: [
|
|
69
|
+
"Create polished prototypes just by describing them",
|
|
70
|
+
"Build and apply design systems to keep everything on-brand",
|
|
71
|
+
"Export your work or share it with a link",
|
|
72
|
+
],
|
|
73
|
+
},
|
|
74
|
+
dispatch: {
|
|
75
|
+
appName: "Agent-Native Dispatch",
|
|
76
|
+
tagline: "Your AI agent manages secrets, orchestrates other agents, and routes messages across your workspace.",
|
|
77
|
+
features: [
|
|
78
|
+
"Centralized vault for secrets with granular per-app grants",
|
|
79
|
+
"Cross-agent orchestration and delegation to specialist apps",
|
|
80
|
+
"Slack and Telegram routing with approval workflows",
|
|
81
|
+
],
|
|
82
|
+
},
|
|
83
|
+
forms: {
|
|
84
|
+
appName: "Agent-Native Forms",
|
|
85
|
+
tagline: "Your AI agent builds, publishes, and analyzes forms alongside you.",
|
|
86
|
+
features: [
|
|
87
|
+
"Create complete forms from a single sentence",
|
|
88
|
+
"Instant publishing with shareable links and captcha",
|
|
89
|
+
"Response summaries, exports, and trend analysis on demand",
|
|
90
|
+
],
|
|
91
|
+
},
|
|
92
|
+
images: {
|
|
93
|
+
appName: "Agent-Native Images",
|
|
94
|
+
tagline: "Your AI agent creates, refines, and organizes on-brand images alongside you.",
|
|
95
|
+
features: [
|
|
96
|
+
"Build reusable brand image libraries from logos, product shots, and references",
|
|
97
|
+
"Generate heroes, diagrams, slide art, and product visuals from a prompt",
|
|
98
|
+
"Audit prompts, references, outputs, and refinements across every run",
|
|
99
|
+
],
|
|
100
|
+
},
|
|
101
|
+
mail: {
|
|
102
|
+
appName: "Agent-Native Mail",
|
|
103
|
+
tagline: "Your AI agent reads, drafts, and organizes email alongside you.",
|
|
104
|
+
features: [
|
|
105
|
+
"Replies that match your tone and style",
|
|
106
|
+
"Multi-account Gmail in a single unified inbox",
|
|
107
|
+
"Autonomous triage, archiving, and follow-ups",
|
|
108
|
+
],
|
|
109
|
+
runLocalCommand: "npx @agent-native/core create my-mail-app --template mail",
|
|
110
|
+
},
|
|
111
|
+
"meeting-notes": {
|
|
112
|
+
appName: "Agent-Native Meeting Notes",
|
|
113
|
+
tagline: "Your AI agent transcribes, enhances, and organizes your meeting notes while you focus on the conversation.",
|
|
114
|
+
features: [
|
|
115
|
+
"AI-enhanced meeting notes that merge raw notes with transcripts",
|
|
116
|
+
"Smart contact and company tracking from meeting attendees",
|
|
117
|
+
"Reusable templates for consistent note formatting",
|
|
118
|
+
],
|
|
119
|
+
},
|
|
120
|
+
migration: {
|
|
121
|
+
appName: "Migration Workbench",
|
|
122
|
+
tagline: "Move existing apps to agent-native with assessment, human approval, and deterministic verification.",
|
|
123
|
+
features: [
|
|
124
|
+
"Inventory routes, components, behavior, and content before touching output",
|
|
125
|
+
"Approve plans before generated writes begin",
|
|
126
|
+
"Verify output with structured migration reports",
|
|
127
|
+
],
|
|
128
|
+
},
|
|
129
|
+
recruiting: {
|
|
130
|
+
appName: "Agent-Native Recruiting",
|
|
131
|
+
tagline: "Your AI agent screens candidates, manages pipelines, and keeps your hiring on track.",
|
|
132
|
+
features: [
|
|
133
|
+
"AI resume analysis and candidate comparison",
|
|
134
|
+
"Pipeline management with automated stage progression",
|
|
135
|
+
"Scorecard tracking and overdue feedback alerts",
|
|
136
|
+
],
|
|
137
|
+
},
|
|
138
|
+
scheduling: {
|
|
139
|
+
appName: "Agent-Native Scheduling",
|
|
140
|
+
tagline: "Your AI agent manages availability, books meetings, and handles rescheduling alongside you.",
|
|
141
|
+
features: [
|
|
142
|
+
"Automatic round-robin and team scheduling across hosts",
|
|
143
|
+
"Smart availability management with conflict detection",
|
|
144
|
+
"Autonomous rescheduling, reminders, and follow-ups",
|
|
145
|
+
],
|
|
146
|
+
},
|
|
147
|
+
slides: {
|
|
148
|
+
appName: "Agent-Native Slides",
|
|
149
|
+
tagline: "Your AI agent builds, edits, and refines presentations alongside you.",
|
|
150
|
+
features: [
|
|
151
|
+
"Generate entire decks from a single prompt",
|
|
152
|
+
"Surgical slide edits while you present or review",
|
|
153
|
+
"Real-time collaboration between you and the agent",
|
|
154
|
+
],
|
|
155
|
+
},
|
|
156
|
+
starter: {
|
|
157
|
+
appName: "Blank app",
|
|
158
|
+
tagline: "Build an agent-native app where the AI agent and UI share state, actions, and context.",
|
|
159
|
+
features: [
|
|
160
|
+
"Define once, use everywhere: actions work as agent tools and API endpoints",
|
|
161
|
+
"The agent always knows what you are looking at and can act on it",
|
|
162
|
+
"Modify your app's own code, routes, and styles through conversation",
|
|
163
|
+
],
|
|
164
|
+
},
|
|
165
|
+
videos: {
|
|
166
|
+
appName: "Agent-Native Videos",
|
|
167
|
+
tagline: "Your AI agent builds, animates, and refines programmatic videos alongside you.",
|
|
168
|
+
features: [
|
|
169
|
+
"Generate animated components and compositions from a description",
|
|
170
|
+
"Fine-tune tracks, keyframes, and easing without touching code",
|
|
171
|
+
"Camera moves, interactive elements, and effects the agent wires for you",
|
|
172
|
+
],
|
|
173
|
+
},
|
|
174
|
+
voice: {
|
|
175
|
+
appName: "Agent-Native Voice",
|
|
176
|
+
tagline: "Speak to type anywhere with context-aware formatting, snippets, and custom vocabulary.",
|
|
177
|
+
features: [
|
|
178
|
+
"Push-to-talk or hands-free dictation with Whisper transcription",
|
|
179
|
+
"Context-aware style presets for formal, casual, and excited tones",
|
|
180
|
+
"Text expansion snippets and custom dictionary for tricky words",
|
|
181
|
+
],
|
|
182
|
+
},
|
|
183
|
+
};
|
|
184
|
+
const SLUG_ALIASES = {
|
|
185
|
+
"agent-native": "",
|
|
186
|
+
"blank-app": "starter",
|
|
187
|
+
"migration-goal-surface": "migration",
|
|
188
|
+
video: "videos",
|
|
189
|
+
};
|
|
190
|
+
function cloneMarketing(marketing) {
|
|
191
|
+
return {
|
|
192
|
+
...marketing,
|
|
193
|
+
features: marketing.features ? [...marketing.features] : undefined,
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
function normalizeSlug(value) {
|
|
197
|
+
if (!value)
|
|
198
|
+
return undefined;
|
|
199
|
+
let slug = value.trim().toLowerCase();
|
|
200
|
+
if (!slug)
|
|
201
|
+
return undefined;
|
|
202
|
+
slug = slug.replace(/^@agent-native\//, "");
|
|
203
|
+
slug = slug
|
|
204
|
+
.replace(/&/g, " and ")
|
|
205
|
+
.replace(/[^a-z0-9]+/g, "-")
|
|
206
|
+
.replace(/^-+|-+$/g, "");
|
|
207
|
+
slug = slug.replace(/^agent-native-/, "");
|
|
208
|
+
slug = SLUG_ALIASES[slug] ?? slug;
|
|
209
|
+
if (!slug)
|
|
210
|
+
return undefined;
|
|
211
|
+
return BUILT_IN_AUTH_MARKETING[slug] ? slug : undefined;
|
|
212
|
+
}
|
|
213
|
+
function slugFromUrl(value) {
|
|
214
|
+
if (!value)
|
|
215
|
+
return undefined;
|
|
216
|
+
try {
|
|
217
|
+
const url = new URL(value);
|
|
218
|
+
return slugFromHost(url.host) ?? slugFromPath(url.pathname);
|
|
219
|
+
}
|
|
220
|
+
catch {
|
|
221
|
+
return undefined;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
function slugFromHost(value) {
|
|
225
|
+
if (!value)
|
|
226
|
+
return undefined;
|
|
227
|
+
const host = value.split(",")[0]?.trim().split(":")[0]?.toLowerCase();
|
|
228
|
+
if (!host)
|
|
229
|
+
return undefined;
|
|
230
|
+
if (host.endsWith(".agent-native.com")) {
|
|
231
|
+
return normalizeSlug(host.slice(0, -".agent-native.com".length));
|
|
232
|
+
}
|
|
233
|
+
return undefined;
|
|
234
|
+
}
|
|
235
|
+
function slugFromPath(value) {
|
|
236
|
+
if (!value)
|
|
237
|
+
return undefined;
|
|
238
|
+
const firstSegment = value.split("?")[0]?.split("/").filter(Boolean)[0];
|
|
239
|
+
return normalizeSlug(firstSegment);
|
|
240
|
+
}
|
|
241
|
+
function candidateSlugs(opts = {}) {
|
|
242
|
+
const env = process.env;
|
|
243
|
+
const candidates = [
|
|
244
|
+
opts.requestHost ? slugFromHost(opts.requestHost) : undefined,
|
|
245
|
+
opts.requestPath ? slugFromPath(opts.requestPath) : undefined,
|
|
246
|
+
normalizeSlug(env.AGENT_NATIVE_TEMPLATE),
|
|
247
|
+
normalizeSlug(env.APP_NAME),
|
|
248
|
+
normalizeSlug(env.npm_package_name),
|
|
249
|
+
slugFromPath(env.APP_BASE_PATH),
|
|
250
|
+
slugFromPath(env.VITE_APP_BASE_PATH),
|
|
251
|
+
slugFromUrl(env.APP_URL),
|
|
252
|
+
slugFromUrl(env.BETTER_AUTH_URL),
|
|
253
|
+
slugFromUrl(env.VITE_BETTER_AUTH_URL),
|
|
254
|
+
slugFromUrl(env.URL),
|
|
255
|
+
slugFromUrl(env.DEPLOY_URL),
|
|
256
|
+
slugFromUrl(env.DEPLOY_PRIME_URL),
|
|
257
|
+
];
|
|
258
|
+
return candidates.filter((slug) => !!slug);
|
|
259
|
+
}
|
|
260
|
+
export function resolveBuiltInAuthMarketing(opts = {}) {
|
|
261
|
+
for (const slug of candidateSlugs(opts)) {
|
|
262
|
+
const marketing = BUILT_IN_AUTH_MARKETING[slug];
|
|
263
|
+
if (marketing)
|
|
264
|
+
return cloneMarketing(marketing);
|
|
265
|
+
}
|
|
266
|
+
return undefined;
|
|
267
|
+
}
|
|
268
|
+
//# sourceMappingURL=auth-marketing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-marketing.js","sourceRoot":"","sources":["../../src/server/auth-marketing.ts"],"names":[],"mappings":"AAaA,MAAM,CAAC,MAAM,uBAAuB,GAAyC;IAC3E,SAAS,EAAE;QACT,OAAO,EAAE,wBAAwB;QACjC,OAAO,EACL,2GAA2G;QAC7G,QAAQ,EAAE;YACR,yEAAyE;YACzE,kEAAkE;YAClE,kEAAkE;SACnE;KACF;IACD,KAAK,EAAE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{\n appName: string;\n tagline: string;\n description?: string;\n features?: string[];\n runLocalCommand?: string;\n}\n\nexport interface ResolveBuiltInAuthMarketingOptions {\n requestHost?: string;\n requestPath?: string;\n}\n\nexport const BUILT_IN_AUTH_MARKETING: Record<string, AuthMarketingContent> = {\n analytics: {\n appName: \"Agent-Native Analytics\",\n tagline:\n \"Your AI agent queries your data sources, builds dashboards, and answers business questions alongside you.\",\n features: [\n \"Ask any question and get answers from BigQuery, HubSpot, Jira, and more\",\n \"Agent-built dashboards that pull live data from all your sources\",\n \"Saved analyses the agent can re-run on demand with fresh numbers\",\n ],\n },\n brain: {\n appName: \"Agent-Native Brain\",\n tagline:\n \"A company memory layer where raw conversations become reviewed, searchable institutional knowledge.\",\n features: [\n \"Import transcripts, notes, Slack exports, and Granola summaries\",\n \"Validate every fact against exact source quotes\",\n \"Review company-wide knowledge through proposal workflows\",\n ],\n },\n calendar: {\n appName: \"Agent-Native Calendar\",\n tagline:\n \"Your AI agent schedules, reschedules, and manages your calendar so you never have to.\",\n features: [\n \"Finds open slots and books meetings on your behalf\",\n \"Manages availability and booking links automatically\",\n \"Answers schedule questions and resolves conflicts instantly\",\n ],\n },\n calls: {\n appName: \"Agent-Native Calls\",\n tagline:\n \"Your AI agent transcribes, summarizes, and surfaces key moments from every conversation.\",\n features: [\n \"Automatic recaps, action items, and next steps after every call\",\n \"Smart trackers that detect competitor mentions, objections, and custom topics\",\n \"Shareable snippets for the exact moment that matters\",\n ],\n },\n clips: {\n appName: \"Agent-Native Clips\",\n tagline:\n \"Your AI agent transcribes, summarizes, and searches everything you record alongside you.\",\n features: [\n \"One-click screen recording with automatic titles, summaries, and chapters\",\n \"Calendar-synced meeting notes with live transcripts and action items\",\n \"One searchable library across recordings, meetings, and dictations\",\n ],\n },\n code: {\n appName: \"Agent-Native Code\",\n tagline:\n \"A customizable local Agent-Native Code UI for long-running coding sessions, slash commands, and migration goals.\",\n features: [\n \"Start and resume local coding sessions\",\n \"Use the same transcript store as the CLI and Desktop\",\n \"Customize the UI while reusing the agent-native run harness\",\n ],\n },\n content: {\n appName: \"Agent-Native Content\",\n tagline:\n \"Your AI agent creates, edits, and organizes documents alongside you in a Notion-like workspace.\",\n features: [\n \"Create and restructure entire document trees from a single prompt\",\n \"Surgical edits that sync live to your editor via real-time collaboration\",\n \"Search, summarize, and cross-reference documents instantly\",\n ],\n },\n design: {\n appName: \"Agent-Native Design\",\n tagline:\n \"Design and prototype by describing what you want. The AI agent turns your ideas into interactive, fully responsive designs in seconds.\",\n features: [\n \"Create polished prototypes just by describing them\",\n \"Build and apply design systems to keep everything on-brand\",\n \"Export your work or share it with a link\",\n ],\n },\n dispatch: {\n appName: \"Agent-Native Dispatch\",\n tagline:\n \"Your AI agent manages secrets, orchestrates other agents, and routes messages across your workspace.\",\n features: [\n \"Centralized vault for secrets with granular per-app grants\",\n \"Cross-agent orchestration and delegation to specialist apps\",\n \"Slack and Telegram routing with approval workflows\",\n ],\n },\n forms: {\n appName: \"Agent-Native Forms\",\n tagline:\n \"Your AI agent builds, publishes, and analyzes forms alongside you.\",\n features: [\n \"Create complete forms from a single sentence\",\n \"Instant publishing with shareable links and captcha\",\n \"Response summaries, exports, and trend analysis on demand\",\n ],\n },\n images: {\n appName: \"Agent-Native Images\",\n tagline:\n \"Your AI agent creates, refines, and organizes on-brand images alongside you.\",\n features: [\n \"Build reusable brand image libraries from logos, product shots, and references\",\n \"Generate heroes, diagrams, slide art, and product visuals from a prompt\",\n \"Audit prompts, references, outputs, and refinements across every run\",\n ],\n },\n mail: {\n appName: \"Agent-Native Mail\",\n tagline: \"Your AI agent reads, drafts, and organizes email alongside you.\",\n features: [\n \"Replies that match your tone and style\",\n \"Multi-account Gmail in a single unified inbox\",\n \"Autonomous triage, archiving, and follow-ups\",\n ],\n runLocalCommand:\n \"npx @agent-native/core create my-mail-app --template mail\",\n },\n \"meeting-notes\": {\n appName: \"Agent-Native Meeting Notes\",\n tagline:\n \"Your AI agent transcribes, enhances, and organizes your meeting notes while you focus on the conversation.\",\n features: [\n \"AI-enhanced meeting notes that merge raw notes with transcripts\",\n \"Smart contact and company tracking from meeting attendees\",\n \"Reusable templates for consistent note formatting\",\n ],\n },\n migration: {\n appName: \"Migration Workbench\",\n tagline:\n \"Move existing apps to agent-native with assessment, human approval, and deterministic verification.\",\n features: [\n \"Inventory routes, components, behavior, and content before touching output\",\n \"Approve plans before generated writes begin\",\n \"Verify output with structured migration reports\",\n ],\n },\n recruiting: {\n appName: \"Agent-Native Recruiting\",\n tagline:\n \"Your AI agent screens candidates, manages pipelines, and keeps your hiring on track.\",\n features: [\n \"AI resume analysis and candidate comparison\",\n \"Pipeline management with automated stage progression\",\n \"Scorecard tracking and overdue feedback alerts\",\n ],\n },\n scheduling: {\n appName: \"Agent-Native Scheduling\",\n tagline:\n \"Your AI agent manages availability, books meetings, and handles rescheduling alongside you.\",\n features: [\n \"Automatic round-robin and team scheduling across hosts\",\n \"Smart availability management with conflict detection\",\n \"Autonomous rescheduling, reminders, and follow-ups\",\n ],\n },\n slides: {\n appName: \"Agent-Native Slides\",\n tagline:\n \"Your AI agent builds, edits, and refines presentations alongside you.\",\n features: [\n \"Generate entire decks from a single prompt\",\n \"Surgical slide edits while you present or review\",\n \"Real-time collaboration between you and the agent\",\n ],\n },\n starter: {\n appName: \"Blank app\",\n tagline:\n \"Build an agent-native app where the AI agent and UI share state, actions, and context.\",\n features: [\n \"Define once, use everywhere: actions work as agent tools and API endpoints\",\n \"The agent always knows what you are looking at and can act on it\",\n \"Modify your app's own code, routes, and styles through conversation\",\n ],\n },\n videos: {\n appName: \"Agent-Native Videos\",\n tagline:\n \"Your AI agent builds, animates, and refines programmatic videos alongside you.\",\n features: [\n \"Generate animated components and compositions from a description\",\n \"Fine-tune tracks, keyframes, and easing without touching code\",\n \"Camera moves, interactive elements, and effects the agent wires for you\",\n ],\n },\n voice: {\n appName: \"Agent-Native Voice\",\n tagline:\n \"Speak to type anywhere with context-aware formatting, snippets, and custom vocabulary.\",\n features: [\n \"Push-to-talk or hands-free dictation with Whisper transcription\",\n \"Context-aware style presets for formal, casual, and excited tones\",\n \"Text expansion snippets and custom dictionary for tricky words\",\n ],\n },\n};\n\nconst SLUG_ALIASES: Record<string, string> = {\n \"agent-native\": \"\",\n \"blank-app\": \"starter\",\n \"migration-goal-surface\": \"migration\",\n video: \"videos\",\n};\n\nfunction cloneMarketing(marketing: AuthMarketingContent): AuthMarketingContent {\n return {\n ...marketing,\n features: marketing.features ? [...marketing.features] : undefined,\n };\n}\n\nfunction normalizeSlug(value: string | undefined): string | undefined {\n if (!value) return undefined;\n let slug = value.trim().toLowerCase();\n if (!slug) return undefined;\n\n slug = slug.replace(/^@agent-native\\//, \"\");\n slug = slug\n .replace(/&/g, \" and \")\n .replace(/[^a-z0-9]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\");\n slug = slug.replace(/^agent-native-/, \"\");\n slug = SLUG_ALIASES[slug] ?? slug;\n if (!slug) return undefined;\n return BUILT_IN_AUTH_MARKETING[slug] ? slug : undefined;\n}\n\nfunction slugFromUrl(value: string | undefined): string | undefined {\n if (!value) return undefined;\n try {\n const url = new URL(value);\n return slugFromHost(url.host) ?? slugFromPath(url.pathname);\n } catch {\n return undefined;\n }\n}\n\nfunction slugFromHost(value: string | undefined): string | undefined {\n if (!value) return undefined;\n const host = value.split(\",\")[0]?.trim().split(\":\")[0]?.toLowerCase();\n if (!host) return undefined;\n if (host.endsWith(\".agent-native.com\")) {\n return normalizeSlug(host.slice(0, -\".agent-native.com\".length));\n }\n return undefined;\n}\n\nfunction slugFromPath(value: string | undefined): string | undefined {\n if (!value) return undefined;\n const firstSegment = value.split(\"?\")[0]?.split(\"/\").filter(Boolean)[0];\n return normalizeSlug(firstSegment);\n}\n\nfunction candidateSlugs(\n opts: ResolveBuiltInAuthMarketingOptions = {},\n): string[] {\n const env = process.env;\n const candidates = [\n opts.requestHost ? slugFromHost(opts.requestHost) : undefined,\n opts.requestPath ? slugFromPath(opts.requestPath) : undefined,\n normalizeSlug(env.AGENT_NATIVE_TEMPLATE),\n normalizeSlug(env.APP_NAME),\n normalizeSlug(env.npm_package_name),\n slugFromPath(env.APP_BASE_PATH),\n slugFromPath(env.VITE_APP_BASE_PATH),\n slugFromUrl(env.APP_URL),\n slugFromUrl(env.BETTER_AUTH_URL),\n slugFromUrl(env.VITE_BETTER_AUTH_URL),\n slugFromUrl(env.URL),\n slugFromUrl(env.DEPLOY_URL),\n slugFromUrl(env.DEPLOY_PRIME_URL),\n ];\n\n return candidates.filter((slug): slug is string => !!slug);\n}\n\nexport function resolveBuiltInAuthMarketing(\n opts: ResolveBuiltInAuthMarketingOptions = {},\n): AuthMarketingContent | undefined {\n for (const slug of candidateSlugs(opts)) {\n const marketing = BUILT_IN_AUTH_MARKETING[slug];\n if (marketing) return cloneMarketing(marketing);\n }\n return undefined;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/server/auth.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAyChE,KAAK,KAAK,GAAG,SAAS,CAAC;AAQvB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/server/auth.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAyChE,KAAK,KAAK,GAAG,SAAS,CAAC;AAQvB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAUlE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAwB5D,OAAO,EAIL,KAAK,oBAAoB,EAC1B,MAAM,qCAAqC,C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C,GAAG,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI,CAEzE"}
|
package/dist/server/auth.js
CHANGED
|
@@ -40,7 +40,7 @@ function toWebRequest(event) {
|
|
|
40
40
|
import { getDbExec, isPostgres, intType, retryOnDdlRace, } from "../db/client.js";
|
|
41
41
|
import { getBetterAuth, getBetterAuthSync } from "./better-auth-instance.js";
|
|
42
42
|
import { getAllowedCorsOrigin, readCorsAllowedOrigins, } from "./cors-origins.js";
|
|
43
|
-
import { getOnboardingHtml, getResetPasswordHtml } from "./onboarding-html.js";
|
|
43
|
+
import { getOnboardingHtml, getResetPasswordHtml, } from "./onboarding-html.js";
|
|
44
44
|
import { readBody } from "../server/h3-helpers.js";
|
|
45
45
|
import { readDesktopSso, writeDesktopSso, clearDesktopSso, } from "./desktop-sso.js";
|
|
46
46
|
import { isElectron as isElectronRequest, getAppBasePath, getAppUrl, encodeOAuthState, decodeOAuthState, createOAuthSession, oauthCallbackResponse, oauthErrorPage, resolveOAuthRedirectUri, isAllowedOAuthRedirectUri, } from "./google-oauth.js";
|
|
@@ -594,6 +594,32 @@ export async function getSessionEmail(token) {
|
|
|
594
594
|
let customGetSession = null;
|
|
595
595
|
let _authGuardConfig = null;
|
|
596
596
|
const _genericGoogleOAuthRoutesEnabled = new WeakMap();
|
|
597
|
+
function getRequestHost(event) {
|
|
598
|
+
return (getHeader(event, "x-forwarded-host") ??
|
|
599
|
+
getHeader(event, "host") ??
|
|
600
|
+
undefined);
|
|
601
|
+
}
|
|
602
|
+
function getOnboardingHtmlOptions(options, event, rawPath) {
|
|
603
|
+
return {
|
|
604
|
+
googleOnly: options.googleOnly,
|
|
605
|
+
marketing: options.marketing,
|
|
606
|
+
googleSignInNotice: options.googleSignInNotice,
|
|
607
|
+
googleAuthMode: options.googleAuthMode,
|
|
608
|
+
requestHost: event ? getRequestHost(event) : undefined,
|
|
609
|
+
requestPath: rawPath,
|
|
610
|
+
};
|
|
611
|
+
}
|
|
612
|
+
function getAuthOnboardingHtml(options, event, rawPath) {
|
|
613
|
+
return getOnboardingHtml(getOnboardingHtmlOptions(options, event, rawPath));
|
|
614
|
+
}
|
|
615
|
+
function getOnboardingLoginHtmlConfig(options) {
|
|
616
|
+
if (options.loginHtml)
|
|
617
|
+
return { loginHtml: options.loginHtml };
|
|
618
|
+
return {
|
|
619
|
+
loginHtml: getAuthOnboardingHtml(options),
|
|
620
|
+
getLoginHtml: (event, rawPath) => getAuthOnboardingHtml(options, event, rawPath),
|
|
621
|
+
};
|
|
622
|
+
}
|
|
597
623
|
function resolveWorkspaceAppAudience(options = {}) {
|
|
598
624
|
return normalizeWorkspaceAppAudience(options.workspaceAppAudience ?? workspaceAppAudienceFromEnv());
|
|
599
625
|
}
|
|
@@ -2558,15 +2584,9 @@ async function mountBetterAuthRoutes(app, options) {
|
|
|
2558
2584
|
}));
|
|
2559
2585
|
// Auth guard — stored both in framework middleware registry AND in
|
|
2560
2586
|
// _authGuardFn so the server middleware can enforce it on ALL routes.
|
|
2561
|
-
const
|
|
2562
|
-
getOnboardingHtml({
|
|
2563
|
-
googleOnly: options.googleOnly,
|
|
2564
|
-
marketing: options.marketing,
|
|
2565
|
-
googleSignInNotice: options.googleSignInNotice,
|
|
2566
|
-
googleAuthMode: options.googleAuthMode,
|
|
2567
|
-
});
|
|
2587
|
+
const loginHtmlConfig = getOnboardingLoginHtmlConfig(options);
|
|
2568
2588
|
_authGuardConfig = {
|
|
2569
|
-
|
|
2589
|
+
...loginHtmlConfig,
|
|
2570
2590
|
publicPaths,
|
|
2571
2591
|
workspaceAppAudience,
|
|
2572
2592
|
workspaceAppPublicPaths: workspaceAppRouteAccess.publicPaths,
|
|
@@ -2778,14 +2798,9 @@ export async function autoMountAuth(app, options = {}) {
|
|
|
2778
2798
|
options.loginHtml ||
|
|
2779
2799
|
options.marketing ||
|
|
2780
2800
|
options.googleSignInNotice) {
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
googleOnly: options.googleOnly,
|
|
2785
|
-
marketing: options.marketing,
|
|
2786
|
-
googleSignInNotice: options.googleSignInNotice,
|
|
2787
|
-
googleAuthMode: options.googleAuthMode,
|
|
2788
|
-
});
|
|
2801
|
+
const loginHtmlConfig = getOnboardingLoginHtmlConfig(options);
|
|
2802
|
+
_authGuardConfig.loginHtml = loginHtmlConfig.loginHtml;
|
|
2803
|
+
_authGuardConfig.getLoginHtml = loginHtmlConfig.getLoginHtml;
|
|
2789
2804
|
}
|
|
2790
2805
|
if (options.publicPaths) {
|
|
2791
2806
|
_authGuardConfig.publicPaths = [
|
|
@@ -2893,15 +2908,9 @@ export async function autoMountAuth(app, options = {}) {
|
|
|
2893
2908
|
// CRITICAL: Even if Better Auth fails, register the auth guard so
|
|
2894
2909
|
// unauthenticated users can't access the app. They'll see the login
|
|
2895
2910
|
// page but won't be able to sign in until the DB is available.
|
|
2896
|
-
const
|
|
2897
|
-
getOnboardingHtml({
|
|
2898
|
-
googleOnly: options.googleOnly,
|
|
2899
|
-
marketing: options.marketing,
|
|
2900
|
-
googleSignInNotice: options.googleSignInNotice,
|
|
2901
|
-
googleAuthMode: options.googleAuthMode,
|
|
2902
|
-
});
|
|
2911
|
+
const loginHtmlConfig = getOnboardingLoginHtmlConfig(options);
|
|
2903
2912
|
_authGuardConfig = {
|
|
2904
|
-
|
|
2913
|
+
...loginHtmlConfig,
|
|
2905
2914
|
publicPaths,
|
|
2906
2915
|
workspaceAppAudience,
|
|
2907
2916
|
workspaceAppPublicPaths: workspaceAppRouteAccess.publicPaths,
|