@agent-native/core 0.22.18 → 0.22.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/dist/client/agent-chat.d.ts.map +1 -1
  2. package/dist/client/agent-chat.js +19 -6
  3. package/dist/client/agent-chat.js.map +1 -1
  4. package/dist/client/embed-auth.d.ts +5 -0
  5. package/dist/client/embed-auth.d.ts.map +1 -1
  6. package/dist/client/embed-auth.js +181 -12
  7. package/dist/client/embed-auth.js.map +1 -1
  8. package/dist/client/index.d.ts +1 -1
  9. package/dist/client/index.d.ts.map +1 -1
  10. package/dist/client/index.js +1 -1
  11. package/dist/client/index.js.map +1 -1
  12. package/dist/client/mcp-app-host.d.ts +5 -0
  13. package/dist/client/mcp-app-host.d.ts.map +1 -1
  14. package/dist/client/mcp-app-host.js +267 -2
  15. package/dist/client/mcp-app-host.js.map +1 -1
  16. package/dist/client/mcp-apps/McpAppRenderer.d.ts +3 -0
  17. package/dist/client/mcp-apps/McpAppRenderer.d.ts.map +1 -1
  18. package/dist/client/mcp-apps/McpAppRenderer.js +86 -9
  19. package/dist/client/mcp-apps/McpAppRenderer.js.map +1 -1
  20. package/dist/client/theme.js +1 -1
  21. package/dist/client/theme.js.map +1 -1
  22. package/dist/client/vite-dev-recovery-script.d.ts.map +1 -1
  23. package/dist/client/vite-dev-recovery-script.js +9 -0
  24. package/dist/client/vite-dev-recovery-script.js.map +1 -1
  25. package/dist/deploy/build.d.ts.map +1 -1
  26. package/dist/deploy/build.js +73 -5
  27. package/dist/deploy/build.js.map +1 -1
  28. package/dist/index.browser.d.ts +1 -1
  29. package/dist/index.browser.d.ts.map +1 -1
  30. package/dist/index.browser.js +1 -1
  31. package/dist/index.browser.js.map +1 -1
  32. package/dist/mcp/build-server.d.ts.map +1 -1
  33. package/dist/mcp/build-server.js +73 -8
  34. package/dist/mcp/build-server.js.map +1 -1
  35. package/dist/mcp/builtin-tools.d.ts.map +1 -1
  36. package/dist/mcp/builtin-tools.js +6 -3
  37. package/dist/mcp/builtin-tools.js.map +1 -1
  38. package/dist/mcp/embed-app.d.ts +2 -2
  39. package/dist/mcp/embed-app.d.ts.map +1 -1
  40. package/dist/mcp/embed-app.js +426 -23
  41. package/dist/mcp/embed-app.js.map +1 -1
  42. package/dist/server/core-routes-plugin.d.ts.map +1 -1
  43. package/dist/server/core-routes-plugin.js +37 -10
  44. package/dist/server/core-routes-plugin.js.map +1 -1
  45. package/dist/server/create-server.d.ts.map +1 -1
  46. package/dist/server/create-server.js +21 -7
  47. package/dist/server/create-server.js.map +1 -1
  48. package/dist/server/embed-route.d.ts.map +1 -1
  49. package/dist/server/embed-route.js +62 -21
  50. package/dist/server/embed-route.js.map +1 -1
  51. package/dist/server/open-route.d.ts.map +1 -1
  52. package/dist/server/open-route.js +7 -2
  53. package/dist/server/open-route.js.map +1 -1
  54. package/dist/server/security-headers.d.ts.map +1 -1
  55. package/dist/server/security-headers.js +9 -1
  56. package/dist/server/security-headers.js.map +1 -1
  57. package/dist/server/ssr-handler.d.ts +2 -0
  58. package/dist/server/ssr-handler.d.ts.map +1 -1
  59. package/dist/server/ssr-handler.js +66 -11
  60. package/dist/server/ssr-handler.js.map +1 -1
  61. package/dist/shared/mcp-embed-headers.d.ts +12 -0
  62. package/dist/shared/mcp-embed-headers.d.ts.map +1 -0
  63. package/dist/shared/mcp-embed-headers.js +51 -0
  64. package/dist/shared/mcp-embed-headers.js.map +1 -0
  65. package/dist/vite/client.d.ts.map +1 -1
  66. package/dist/vite/client.js +23 -0
  67. package/dist/vite/client.js.map +1 -1
  68. package/docs/content/actions.md +15 -5
  69. package/docs/content/client.md +6 -3
  70. package/docs/content/external-agents.md +61 -41
  71. package/docs/content/mcp-protocol.md +42 -7
  72. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/vite/client.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,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AO,CAAC,EAAE;gBACtD,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,UAAU,CAAC,EAAE;gBAC/D,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,WAAW,CAAC,EAAE,EAAE,CAAC,CAAC;oBACrE,IAAI;oBACJ,WAAW;iBACZ,CAAC,CAAC;aACJ;SACF;KACF,CAAC;AACJ,CAAC","sourcesContent":["import path from \"path\";\nimport fs from \"fs\";\nimport { createRequire } from \"module\";\nimport type { Plugin, UserConfig } from \"vite\";\nimport { nitro as nitroVitePlugin } from \"nitro/vite\";\nimport { actionTypesPlugin } from \"./action-types-plugin.js\";\nimport { agentsBundlePlugin } from \"./agents-bundle-plugin.js\";\nimport { findWorkspaceRoot } from \"../scripts/utils.js\";\nimport { getViteDevRecoveryScript } from \"../client/vite-dev-recovery-script.js\";\n\nimport { fileURLToPath } from \"url\";\n\nconst require = createRequire(import.meta.url);\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\n\n/**\n * Sync discovery for the workspace-core in an enterprise monorepo.\n *\n * Mirrors `getWorkspaceCoreExports` in deploy/workspace-core.ts but stays\n * synchronous so it can run inline in `defineConfig`. Returns the workspace\n * core's package name + absolute directory, or null if no workspace core is\n * declared in the ancestor chain.\n *\n * Walks up from `startDir` looking for a package.json with\n * `agent-native.workspaceCore`. Resolves the declared package name through\n * `<workspaceRoot>/node_modules/<name>` (pnpm symlink, fastest) or by\n * scanning `packages/*` for a matching `name` field (fallback for\n * pre-install scenarios).\n */\nfunction findWorkspaceCoreSync(\n startDir: string,\n): { packageName: string; packageDir: string } | null {\n // 1) Walk up looking for the root package.json that declares workspaceCore.\n let dir = path.resolve(startDir);\n let workspaceRoot: string | null = null;\n let packageName: string | null = null;\n for (let i = 0; i < 20; i++) {\n const pkgPath = path.join(dir, \"package.json\");\n if (fs.existsSync(pkgPath)) {\n try {\n const pkg = JSON.parse(fs.readFileSync(pkgPath, \"utf-8\"));\n const declared = pkg?.[\"agent-native\"]?.workspaceCore;\n if (typeof declared === \"string\" && declared.length > 0) {\n workspaceRoot = dir;\n packageName = declared;\n break;\n }\n } catch {\n // Malformed package.json — keep walking up.\n }\n }\n const parent = path.dirname(dir);\n if (parent === dir) break;\n dir = parent;\n }\n if (!workspaceRoot || !packageName) return null;\n\n // 2a) pnpm/npm symlink under workspaceRoot/node_modules.\n const nm = path.join(workspaceRoot, \"node_modules\", packageName);\n if (fs.existsSync(path.join(nm, \"package.json\"))) {\n return { packageName, packageDir: fs.realpathSync(nm) };\n }\n\n // 2b) Scan packages/* and packages/@scope/* for a matching `name`.\n const packagesDir = path.join(workspaceRoot, \"packages\");\n if (fs.existsSync(packagesDir)) {\n const candidates: string[] = [];\n for (const entry of fs.readdirSync(packagesDir, { withFileTypes: true })) {\n if (!entry.isDirectory()) continue;\n candidates.push(path.join(packagesDir, entry.name));\n if (entry.name.startsWith(\"@\")) {\n const scopeDir = path.join(packagesDir, entry.name);\n for (const sub of fs.readdirSync(scopeDir, { withFileTypes: true })) {\n if (sub.isDirectory()) candidates.push(path.join(scopeDir, sub.name));\n }\n }\n }\n for (const c of candidates) {\n const p = path.join(c, \"package.json\");\n if (!fs.existsSync(p)) continue;\n try {\n const pkg = JSON.parse(fs.readFileSync(p, \"utf-8\"));\n if (pkg?.name === packageName)\n return { packageName, packageDir: fs.realpathSync(c) };\n } catch {\n // ignore malformed package.json\n }\n }\n }\n return null;\n}\n\n/** Escape a string so it can be embedded as a regex literal. */\nfunction escapeRegex(s: string): string {\n return s.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n\n/** Check if a package is installed in the project */\nfunction hasDep(pkg: string, cwd: string): boolean {\n try {\n const pkgJson = JSON.parse(\n fs.readFileSync(path.join(cwd, \"package.json\"), \"utf-8\"),\n );\n return !!(\n pkgJson.dependencies?.[pkg] ||\n pkgJson.devDependencies?.[pkg] ||\n pkgJson.peerDependencies?.[pkg]\n );\n } catch {\n return false;\n }\n}\n\n/**\n * Build the `resolve.dedupe` list dynamically. Reads core's package.json and\n * collects every peerDependency that the consuming app also declares. This\n * ensures Vite resolves them from the app root, not from core's own\n * node_modules — preventing duplicate React context / singleton issues.\n */\nfunction getClientDedupe(cwd: string): string[] {\n // Always dedupe React internals (sub-path exports aren't in peerDeps)\n const always = new Set([\"react\", \"react-dom\", \"react-dom/client\"]);\n\n // Server-only packages that never run in the browser — no point deduping.\n const serverOnly = new Set([\n \"drizzle-kit\",\n \"node-pty\",\n \"postgres\",\n \"ws\",\n \"typescript\",\n \"vite\",\n \"@vitejs/plugin-react-swc\",\n \"tailwindcss\",\n \"@tailwindcss/vite\",\n ]);\n\n try {\n const corePkgPath = path.resolve(__dirname, \"../../package.json\");\n const corePkg = JSON.parse(fs.readFileSync(corePkgPath, \"utf-8\"));\n\n // Scan both peerDependencies and dependencies. Direct deps like\n // @radix-ui/* use React internally — they must resolve against the\n // app's React, not a second copy inside core's node_modules.\n const coreDeps = new Set([\n ...Object.keys(corePkg.peerDependencies ?? {}),\n ...Object.keys(corePkg.dependencies ?? {}),\n ]);\n\n // Read the consuming app's dependencies\n const appPkg = JSON.parse(\n fs.readFileSync(path.join(cwd, \"package.json\"), \"utf-8\"),\n );\n const appDeps = new Set([\n ...Object.keys(appPkg.dependencies ?? {}),\n ...Object.keys(appPkg.devDependencies ?? {}),\n ]);\n\n for (const dep of coreDeps) {\n if (serverOnly.has(dep)) continue;\n // Dedupe if the app also declares it, OR if it's a React-based\n // UI library (Radix, Tanstack) that must share the app's React.\n if (\n appDeps.has(dep) ||\n dep.startsWith(\"@radix-ui/\") ||\n dep.startsWith(\"@tanstack/\")\n ) {\n always.add(dep);\n }\n }\n } catch {\n // Can't read package.json — fall back to known singletons\n }\n\n return [...always];\n}\n\n/**\n * Locate `packages/core/src` if we're inside the framework monorepo.\n * Shared between `getCoreSourceAliases` (which redirects imports to src/)\n * and `getDefaultOptimizeDeps` (which must NOT prebundle from dist/ when\n * the alias is active — otherwise the prebundle is built from a snapshot\n * of dist/ at startup and never picks up new exports).\n */\nfunction findCoreSrcDir(cwd: string): string | null {\n const candidates = [\n path.resolve(cwd, \"../../packages/core\"), // templates/<name>/\n path.resolve(cwd, \"../core\"), // packages/<name>/\n ];\n for (const candidate of candidates) {\n if (fs.existsSync(path.join(candidate, \"src/index.ts\"))) {\n return path.join(candidate, \"src\");\n }\n }\n return null;\n}\n\n/**\n * Every `@agent-native/core` subpath that gets a source alias. Must stay in\n * sync with `getCoreSourceAliases`. Used by `getDefaultOptimizeDeps` to skip\n * prebundling in monorepo mode, and by the consumer config to add them to\n * `optimizeDeps.exclude` so Vite always resolves them through the source\n * alias on every request — never from a stale dist/ snapshot.\n */\nconst CORE_CLIENT_SUBPATHS = [\n \"@agent-native/core\",\n \"@agent-native/core/client\",\n \"@agent-native/core/client/extensions\",\n \"@agent-native/core/client/tools\", // legacy alias\n \"@agent-native/core/client/org\",\n \"@agent-native/core/client/observability\",\n \"@agent-native/core/client/onboarding\",\n \"@agent-native/core/client/sharing\",\n \"@agent-native/core/client/notifications\",\n \"@agent-native/core/client/progress\",\n];\n\nfunction getDefaultOptimizeDeps(cwd: string): string[] {\n const inMonorepo = findCoreSrcDir(cwd) !== null;\n const entries: Array<{ specifier: string; packageName?: string }> = [\n // In monorepo mode the source alias resolves these to src/ on every\n // import, so prebundling from dist/ would just create a stale snapshot.\n // Skip them entirely — `optimizeDeps.exclude` below makes that explicit.\n ...(inMonorepo\n ? []\n : ([\n { specifier: \"@agent-native/core\" },\n {\n specifier: \"@agent-native/core/client\",\n packageName: \"@agent-native/core\",\n },\n {\n specifier: \"@agent-native/core/client/org\",\n packageName: \"@agent-native/core\",\n },\n {\n specifier: \"@agent-native/core/client/extensions\",\n packageName: \"@agent-native/core\",\n },\n {\n // Legacy alias — prior name for @agent-native/core/client/extensions.\n // Keep so deployed templates that haven't been updated still resolve.\n specifier: \"@agent-native/core/client/tools\",\n packageName: \"@agent-native/core\",\n },\n ] as Array<{ specifier: string; packageName?: string }>)),\n { specifier: \"@libsql/client\" },\n { specifier: \"@radix-ui/react-accordion\" },\n { specifier: \"@radix-ui/react-alert-dialog\" },\n { specifier: \"@radix-ui/react-avatar\" },\n { specifier: \"@radix-ui/react-checkbox\" },\n { specifier: \"@radix-ui/react-collapsible\" },\n { specifier: \"@radix-ui/react-context-menu\" },\n { specifier: \"@radix-ui/react-dialog\" },\n { specifier: \"@radix-ui/react-dropdown-menu\" },\n { specifier: \"@radix-ui/react-hover-card\" },\n { specifier: \"@radix-ui/react-label\" },\n { specifier: \"@radix-ui/react-menubar\" },\n { specifier: \"@radix-ui/react-navigation-menu\" },\n { specifier: \"@radix-ui/react-popover\" },\n { specifier: \"@radix-ui/react-progress\" },\n { specifier: \"@radix-ui/react-radio-group\" },\n { specifier: \"@radix-ui/react-scroll-area\" },\n { specifier: \"@radix-ui/react-select\" },\n { specifier: \"@radix-ui/react-separator\" },\n { specifier: \"@radix-ui/react-slider\" },\n { specifier: \"@radix-ui/react-slot\" },\n { specifier: \"@radix-ui/react-switch\" },\n { specifier: \"@radix-ui/react-tabs\" },\n { specifier: \"@radix-ui/react-toast\" },\n { specifier: \"@radix-ui/react-toggle\" },\n { specifier: \"@radix-ui/react-toggle-group\" },\n { specifier: \"@radix-ui/react-tooltip\" },\n { specifier: \"@tanstack/react-query\" },\n { specifier: \"@tabler/icons-react\" },\n { specifier: \"class-variance-authority\" },\n { specifier: \"clsx\" },\n { specifier: \"cmdk\" },\n { specifier: \"drizzle-orm\" },\n { specifier: \"drizzle-orm/pg-core\", packageName: \"drizzle-orm\" },\n { specifier: \"drizzle-orm/sqlite-core\", packageName: \"drizzle-orm\" },\n { specifier: \"h3\" },\n { specifier: \"next-themes\" },\n { specifier: \"react-hook-form\" },\n { specifier: \"sonner\" },\n { specifier: \"tailwind-merge\" },\n { specifier: \"zod\" },\n ];\n\n return entries\n .filter(({ specifier, packageName }) =>\n hasDep(packageName ?? specifier, cwd),\n )\n .map(({ specifier }) => specifier);\n}\n\n/**\n * In monorepo dev mode, resolve @agent-native/core imports to source (src/)\n * instead of dist/ so that Vite HMR picks up changes without rebuilding.\n *\n * Returns Vite array-style aliases with exact matching (regex anchored with $)\n * to prevent `@agent-native/core` from prefix-matching and swallowing\n * sub-path imports like `@agent-native/core/client`.\n */\nfunction getCoreSourceAliases(\n cwd: string,\n): Array<{ find: RegExp; replacement: string }> {\n const coreSrc = findCoreSrcDir(cwd);\n if (!coreSrc) return []; // Not in monorepo — use dist as normal\n\n // Map every @agent-native/core/* export to its src/ equivalent.\n // Each entry uses a regex with $ anchor for exact matching.\n const entries: Record<string, string> = {\n \"@agent-native/core\": path.join(coreSrc, \"index.browser.ts\"),\n \"@agent-native/core/server\": path.join(coreSrc, \"server/index.ts\"),\n \"@agent-native/core/client\": path.join(coreSrc, \"client/index.ts\"),\n \"@agent-native/core/client/extensions\": path.join(\n coreSrc,\n \"client/extensions/index.ts\",\n ),\n // Legacy alias — see exports map note above.\n \"@agent-native/core/client/tools\": path.join(\n coreSrc,\n \"client/extensions/index.ts\",\n ),\n \"@agent-native/core/client/org\": path.join(coreSrc, \"client/org/index.ts\"),\n \"@agent-native/core/client/observability\": path.join(\n coreSrc,\n \"client/observability/index.ts\",\n ),\n \"@agent-native/core/client/onboarding\": path.join(\n coreSrc,\n \"client/onboarding/index.ts\",\n ),\n \"@agent-native/core/client/sharing\": path.join(\n coreSrc,\n \"client/sharing/index.ts\",\n ),\n \"@agent-native/core/client/notifications\": path.join(\n coreSrc,\n \"client/notifications/index.ts\",\n ),\n \"@agent-native/core/client/progress\": path.join(\n coreSrc,\n \"client/progress/index.ts\",\n ),\n \"@agent-native/core/db\": path.join(coreSrc, \"db/index.ts\"),\n \"@agent-native/core/db/schema\": path.join(coreSrc, \"db/schema.ts\"),\n \"@agent-native/core/shared\": path.join(coreSrc, \"shared/index.ts\"),\n \"@agent-native/core/scripts\": path.join(coreSrc, \"scripts/index.ts\"),\n \"@agent-native/core/application-state\": path.join(\n coreSrc,\n \"application-state/index.ts\",\n ),\n \"@agent-native/core/settings\": path.join(coreSrc, \"settings/index.ts\"),\n \"@agent-native/core/credentials\": path.join(\n coreSrc,\n \"credentials/index.ts\",\n ),\n \"@agent-native/core/resources\": path.join(coreSrc, \"resources/index.ts\"),\n \"@agent-native/core/oauth-tokens\": path.join(\n coreSrc,\n \"oauth-tokens/index.ts\",\n ),\n \"@agent-native/core/workspace-connections\": path.join(\n coreSrc,\n \"workspace-connections/index.ts\",\n ),\n \"@agent-native/core/a2a\": path.join(coreSrc, \"a2a/index.ts\"),\n \"@agent-native/core/router\": path.join(coreSrc, \"router/index.ts\"),\n \"@agent-native/core/terminal\": path.join(\n coreSrc,\n \"client/terminal/index.ts\",\n ),\n \"@agent-native/core/terminal/server\": path.join(\n coreSrc,\n \"terminal/index.ts\",\n ),\n \"@agent-native/core/adapters/cli\": path.join(\n coreSrc,\n \"adapters/cli/index.ts\",\n ),\n \"@agent-native/core/usage\": path.join(coreSrc, \"usage/store.ts\"),\n // Shared stylesheet — alias to src so CSS edits (composer/theme rules)\n // take effect live in dev instead of silently loading the stale built\n // copy at dist/styles/. From src/styles/ the `@source \"../client/**\"`\n // directive resolves to the real .tsx source, which is what dev should\n // scan for Tailwind classes anyway.\n \"@agent-native/core/styles/agent-native.css\": path.join(\n coreSrc,\n \"styles/agent-native.css\",\n ),\n };\n\n // Escape special regex chars in the key and anchor with $\n return Object.entries(entries).map(([find, replacement]) => ({\n find: new RegExp(`^${find.replace(/[/]/g, \"\\\\/\")}$`),\n replacement,\n }));\n}\n\nexport interface NitroOptions {\n /** Nitro deployment preset (e.g. \"node\", \"vercel\", \"netlify\", \"cloudflare_pages\"). Default: \"node\" */\n preset?: string;\n /** Source directory for server files. Default: \"./server\" */\n srcDir?: string;\n /** Routes directory name (relative to srcDir). Default: \"routes\" */\n routesDir?: string;\n /** Any additional Nitro config overrides */\n [key: string]: unknown;\n}\n\nexport interface ClientConfigOptions {\n /** Port for dev server. Default: 8080 */\n port?: number;\n /** Additional hostnames allowed to access the dev server. */\n allowedHosts?: NonNullable<NonNullable<UserConfig[\"server\"]>[\"allowedHosts\"]>;\n /** Vite log level. Workspace child apps default to \"warn\" so only the gateway URL is advertised. */\n logLevel?: UserConfig[\"logLevel\"];\n /** Additional Vite plugins */\n plugins?: any[];\n /** Nitro plugin options (preset, srcDir, etc) */\n nitro?: NitroOptions;\n /** Override resolve aliases */\n aliases?: Record<string, string>;\n /** Override build.outDir. Default: \"dist/spa\" */\n outDir?: string;\n /** Additional fs.allow paths */\n fsAllow?: string[];\n /** Additional fs.deny patterns */\n fsDeny?: string[];\n /** Additional Vite optimizeDeps configuration */\n optimizeDeps?: NonNullable<UserConfig[\"optimizeDeps\"]>;\n /**\n * Whether to auto-inject the Tailwind v4 Vite plugin (`@tailwindcss/vite`).\n * Defaults to true — set to `false` if a template wants to manage Tailwind\n * itself (e.g. the legacy v3 PostCSS pipeline).\n */\n tailwind?: boolean;\n /**\n * Package names to stub in the SSR bundle with an empty proxy object.\n *\n * Use this for dependencies that only run in the browser (canvas / diagram\n * libraries, editors, WebGL) but would otherwise get pulled into the\n * server bundle via SSR's noExternal policy — pushing the CF Pages\n * Functions bundle over the 25 MiB limit.\n *\n * Only add packages that are provably never called during SSR. If the\n * server imports one, it will receive a Proxy that throws on any real\n * use (which is better than bundling a 10 MiB dep the worker never calls).\n *\n * @example\n * ssrStubs: [\"mermaid\", \"@excalidraw/excalidraw\"]\n */\n ssrStubs?: string[];\n /**\n * @deprecated Pass `reactRouter()` directly in the `plugins` array instead.\n * Previously used to auto-load the React Router Vite plugin via require(),\n * but this fails in ESM contexts. Templates should now do:\n * ```ts\n * import { reactRouter } from \"@react-router/dev/vite\";\n * defineConfig({ plugins: [reactRouter()] })\n * ```\n */\n reactRouter?: boolean | Record<string, unknown>;\n}\n\n/**\n * Vite plugin that recovers the page when Vite's dependency optimizer\n * invalidates modules mid-load (the \"504 Outdated Optimize Dep\" error).\n *\n * Without this, the page silently fails: <script type=\"module\"> tags 504,\n * React never mounts, and the user is stuck on a blank screen until they\n * manually refresh. We catch the failure modes and auto-reload, with a\n * visible overlay so the user knows what's happening, and a loop guard\n * so we never thrash forever.\n *\n * CRITICAL: this must be a SYNCHRONOUS (non-module) script injected at\n * `head-prepend`. Module scripts are deferred — the browser starts fetching\n * all module scripts in parallel during HTML parsing, so a module listener\n * registers AFTER sibling modules have already started loading and\n * possibly errored out. A regular <script> blocks parsing and runs\n * synchronously, so the listener is registered before ANY module fetch\n * begins.\n *\n * Catches three failure modes (all before React needs to mount):\n * 1. <script type=\"module\"> / <link> 504 — window \"error\" event, capture phase\n * 2. Dynamic import 504 — \"unhandledrejection\" with \"dynamically imported module\"\n * 3. Child module 504 — resource timing when browser exposes the HTTP status\n */\nfunction autoReloadOnOptimizeDep(): Plugin {\n return {\n name: \"agent-native-auto-reload-optimize-dep\",\n apply: \"serve\",\n transformIndexHtml() {\n return [\n {\n tag: \"script\",\n // NOTE: no `type: \"module\"` — this must be a synchronous script.\n children: getViteDevRecoveryScript(),\n injectTo: \"head-prepend\",\n },\n ];\n },\n };\n}\n\n/**\n * Vite handles outdated optimized-dep requests inside its own transform\n * middleware and ends the HTTP response with `504 Outdated Optimize Dep`.\n * Browser module loaders do not consistently surface those child-module\n * failures to userland JavaScript, so also nudge the Vite HMR client from the\n * server side. This turns the confusing blank-screen state into the same\n * full-page reload Vite would have requested once optimization settled.\n */\nfunction fullReloadOnOptimizeDep504(): Plugin {\n return {\n name: \"agent-native-full-reload-optimize-dep-504\",\n apply: \"serve\",\n configureServer(server) {\n let lastReloadAt = 0;\n server.middlewares.use((req, res, next) => {\n const originalEnd = res.end;\n (res as unknown as { end: (...args: unknown[]) => unknown }).end = (\n ...endArgs: unknown[]\n ) => {\n const statusMessage = String(res.statusMessage || \"\");\n if (\n res.statusCode === 504 &&\n statusMessage === \"Outdated Optimize Dep\"\n ) {\n const now = Date.now();\n if (now - lastReloadAt > 500) {\n lastReloadAt = now;\n server.ws.send({ type: \"full-reload\" });\n server.config.logger.info(\n `[agent-native] Vite optimized deps changed while loading ${\n req.url ?? \"a module\"\n }; reloading the page.`,\n { timestamp: true },\n );\n }\n }\n return (originalEnd as (...args: unknown[]) => unknown).apply(\n res,\n endArgs,\n );\n };\n next();\n });\n },\n };\n}\n\n/**\n * Vite plugin that prevents the built-in base middleware from redirecting\n * \"/\" → \"/app/\" (or whatever the base is). When agent-native apps run with\n * --base /app/ in single-port mode, Vite's baseMiddleware sends a 302 from\n * \"/\" to the base path. This breaks Electron webview and iframe embeds\n * that load the app at the root. Instead, we rewrite \"/\" to the base path\n * internally so the app serves without a visible redirect.\n */\nfunction baseRedirectGuard(): Plugin {\n return {\n name: \"agent-native-base-redirect-guard\",\n apply: \"serve\",\n configureServer(server) {\n // Return a function so the middleware is added AFTER Vite's internal\n // middleware is built — but we insert BEFORE by using the pre-hook\n // approach: configureServer hooks that return nothing run before\n // internal middleware.\n server.middlewares.use((req, res, next) => {\n const base = server.config.base;\n if (base && base !== \"/\" && req.url?.startsWith(base)) {\n const relativeUrl = req.url.slice(base.length - 1);\n try {\n const url = new URL(relativeUrl, \"http://agent-native.local\");\n const publicDir = server.config.publicDir;\n if (typeof publicDir !== \"string\") {\n return next();\n }\n const publicPath = path.normalize(\n path.join(publicDir, decodeURIComponent(url.pathname)),\n );\n if (\n publicPath.startsWith(publicDir + path.sep) &&\n fs.existsSync(publicPath) &&\n fs.statSync(publicPath).isFile()\n ) {\n const contentType = contentTypeForPublicFile(publicPath);\n if (contentType) res.setHeader(\"content-type\", contentType);\n if (req.method === \"HEAD\") {\n res.statusCode = 200;\n res.end();\n return;\n }\n fs.createReadStream(publicPath).pipe(res);\n return;\n }\n } catch {\n // Fall through to Vite/Nitro. Malformed URLs should keep their\n // original path so the normal dev-server error handling applies.\n }\n }\n req.url = stripMountedDevApiPath(req.url, base);\n if (\n req.method === \"HEAD\" &&\n req.url &&\n !isFrameworkDevPath(req.url, base)\n ) {\n req.method = \"GET\";\n }\n if (\n base &&\n base !== \"/\" &&\n (req.url === \"/\" || req.url === \"/index.html\")\n ) {\n // Rewrite to the base path so Vite serves the app directly\n req.url = base;\n }\n next();\n });\n },\n };\n}\n\nfunction embedDevFrameHeaders(): Plugin {\n return {\n name: \"agent-native-embed-dev-frame-headers\",\n apply: \"serve\",\n configureServer(server) {\n server.middlewares.use((req, res, next) => {\n const cookieHeader = String(req.headers.cookie ?? \"\");\n let hasEmbedMarker = /\\ban_embed_session=/.test(cookieHeader);\n try {\n const url = new URL(req.url ?? \"/\", \"http://agent-native.local\");\n hasEmbedMarker =\n hasEmbedMarker || url.searchParams.has(\"__an_embed_token\");\n } catch {\n // Malformed URLs should continue through Vite's normal handling.\n }\n if (hasEmbedMarker) {\n res.setHeader(\"Cross-Origin-Embedder-Policy\", \"require-corp\");\n res.setHeader(\"Cross-Origin-Opener-Policy\", \"same-origin\");\n res.setHeader(\"Cross-Origin-Resource-Policy\", \"cross-origin\");\n res.setHeader(\"Referrer-Policy\", \"no-referrer\");\n }\n next();\n });\n },\n };\n}\n\nfunction contentTypeForPublicFile(filePath: string): string | null {\n switch (path.extname(filePath).toLowerCase()) {\n case \".css\":\n return \"text/css\";\n case \".html\":\n return \"text/html\";\n case \".ico\":\n return \"image/x-icon\";\n case \".json\":\n case \".webmanifest\":\n return \"application/json\";\n case \".js\":\n case \".mjs\":\n return \"text/javascript\";\n case \".png\":\n return \"image/png\";\n case \".svg\":\n return \"image/svg+xml\";\n case \".txt\":\n return \"text/plain\";\n case \".xml\":\n return \"application/xml\";\n default:\n return null;\n }\n}\n\nfunction devPathname(reqUrl: string): string {\n return new URL(reqUrl, \"http://agent-native.local\").pathname;\n}\n\nfunction isApiDevPath(reqUrl: string): boolean {\n const pathname = devPathname(reqUrl);\n return pathname === \"/api\" || pathname.startsWith(\"/api/\");\n}\n\nexport function stripMountedDevApiPath(\n reqUrl: string | undefined,\n base: string | undefined,\n): string | undefined {\n if (!reqUrl || !base || base === \"/\") return reqUrl;\n const normalizedBase = base.endsWith(\"/\") ? base : `${base}/`;\n if (!reqUrl.startsWith(normalizedBase)) return reqUrl;\n const stripped = reqUrl.slice(normalizedBase.length - 1) || \"/\";\n return isApiDevPath(stripped) ? stripped : reqUrl;\n}\n\nexport function isFrameworkDevPath(\n reqUrl: string,\n base: string | undefined,\n): boolean {\n const pathname = devPathname(reqUrl);\n if (pathname === \"/_agent-native\" || pathname.startsWith(\"/_agent-native/\")) {\n return true;\n }\n if (!base || base === \"/\") return false;\n const normalizedBase = base.endsWith(\"/\") ? base.slice(0, -1) : base;\n return (\n pathname === `${normalizedBase}/_agent-native` ||\n pathname.startsWith(`${normalizedBase}/_agent-native/`)\n );\n}\n\n/**\n * Work around a Rolldown bug where Nitro passes service entries as objects\n * ({index: \"path\"}) but Rolldown expects strings. This plugin normalizes\n * rollupOptions.input entries in the SSR environment.\n */\nfunction rolldownInputFix(): Plugin {\n return {\n name: \"agent-native-rolldown-input-fix\",\n configEnvironment(name, config) {\n const input = config.build?.rollupOptions?.input;\n if (!Array.isArray(input)) return;\n // Flatten any object entries to just their string values\n const fixed = input.map((entry: any) => {\n if (typeof entry === \"string\") return entry;\n if (typeof entry === \"object\" && entry !== null) {\n const values = Object.values(entry);\n return values[0] as string;\n }\n return entry;\n });\n config.build!.rollupOptions!.input = fixed;\n },\n };\n}\n\n/**\n * Expose the resolved Vite dev server port as process.env.PORT so that\n * in-process scripts (which use localFetch → http://localhost:${PORT}/api/...)\n * hit the right address even when Vite auto-increments the port.\n */\n/**\n * Replace caller-specified packages with an empty proxy stub during SSR\n * builds. For apps whose heavy browser-only deps would otherwise bloat the\n * edge worker past CF Pages' 25 MiB Functions limit.\n *\n * The template lists the packages in its `defineConfig({ ssrStubs })` call —\n * the framework never hardcodes package names.\n */\nfunction ssrStubPlugin(packages: string[]): Plugin | null {\n if (!packages.length) return null;\n const stubbed = new Set(packages);\n const STUB_ID = \"\\0agent-native-ssr-stub\";\n return {\n name: \"agent-native-ssr-stub-heavy-libs\",\n enforce: \"pre\",\n resolveId(id, _importer, opts) {\n if (!opts?.ssr) return null;\n // Match the bare package name or any subpath\n const pkg = id\n .split(\"/\")\n .slice(0, id.startsWith(\"@\") ? 2 : 1)\n .join(\"/\");\n if (stubbed.has(pkg)) return STUB_ID;\n return null;\n },\n load(id) {\n if (id !== STUB_ID) return null;\n // Proxy that answers any property access with itself — lets dead\n // import/re-export chains parse without blowing up, and still throws\n // if code actually tries to call any of it on the server.\n return (\n \"const handler = { get(_, p) { \" +\n \"if (p === Symbol.toPrimitive) return () => ''; \" +\n \"if (p === 'then') return undefined; \" +\n \"return new Proxy(() => {}, handler); \" +\n \"} };\" +\n \"const stub = new Proxy(() => {}, handler);\" +\n \"export default stub;\"\n );\n },\n };\n}\n\nfunction portExposer(): Plugin {\n return {\n name: \"agent-native-port-exposer\",\n apply: \"serve\",\n configureServer(server) {\n server.httpServer?.once(\"listening\", () => {\n const addr = server.httpServer?.address();\n if (addr && typeof addr === \"object\" && addr.port) {\n process.env.PORT = String(addr.port); // guard:allow-env-mutation — Vite dev server port published once at boot before any request\n }\n });\n },\n };\n}\n\n/**\n * Silence benign connection-reset noise from Vite's dev middleware.\n * Fires when a browser closes/reloads/navigates mid-request — the peer has\n * already gone away, there's nothing to fix, and Vite's error middleware\n * spams the terminal and browser HMR overlay with errors like\n * \"read ECONNRESET\" and \"socket hang up\". Our H3 server layer already\n * swallows these (create-server.ts onError); this plugin does the same for\n * Vite's own connect pipeline.\n */\nfunction silenceConnectionResets(): Plugin {\n const isBenign = (err: unknown) => {\n const e = err as\n | (NodeJS.ErrnoException & { cause?: NodeJS.ErrnoException })\n | undefined;\n const code = e?.code || (e?.cause as NodeJS.ErrnoException)?.code;\n const message = String(e?.message ?? \"\");\n return (\n code === \"ECONNRESET\" ||\n code === \"ECONNABORTED\" ||\n code === \"EPIPE\" ||\n /^(read ECONNRESET|write ECONNRESET|socket hang up|aborted|write EPIPE)$/i.test(\n message,\n )\n );\n };\n const isBenignErrorPayload = (payload: unknown) => {\n const p = payload as { type?: string; err?: unknown } | undefined;\n return p?.type === \"error\" && isBenign(p.err);\n };\n return {\n name: \"agent-native-silence-connection-resets\",\n apply: \"serve\",\n configureServer(server) {\n // Swallow socket-level resets so Node doesn't surface them as uncaught.\n server.httpServer?.on(\"connection\", (socket) => {\n socket.on(\"error\", (err) => {\n if (!isBenign(err)) throw err;\n });\n });\n // Drop Vite's \"Internal server error: read ECONNRESET\" log lines.\n const origError = server.config.logger.error.bind(server.config.logger);\n server.config.logger.error = (msg, opts) => {\n const text = typeof msg === \"string\" ? msg : String(msg ?? \"\");\n if (\n (opts?.error && isBenign(opts.error)) ||\n /Internal server error:\\s*(read ECONNRESET|write ECONNRESET|socket hang up|aborted|EPIPE)/i.test(\n text,\n )\n ) {\n return;\n }\n origError(msg, opts);\n };\n\n // Vite's error middleware sends these same benign errors to the HMR\n // client, which turns them into the full-screen browser overlay.\n // Suppress just those payloads while leaving real transform/runtime\n // errors untouched.\n const hot = (\n server as unknown as {\n environments?: { client?: { hot?: { send?: Function } } };\n }\n ).environments?.client?.hot;\n if (hot?.send) {\n const origHotSend = hot.send.bind(hot);\n hot.send = (payload: unknown, ...args: unknown[]) => {\n if (isBenignErrorPayload(payload)) return;\n return origHotSend(payload, ...args);\n };\n }\n\n const ws = (server as unknown as { ws?: { send?: Function } }).ws;\n if (ws?.send) {\n const origWsSend = ws.send.bind(ws);\n ws.send = (payload: unknown, ...args: unknown[]) => {\n if (isBenignErrorPayload(payload)) return;\n return origWsSend(payload, ...args);\n };\n }\n },\n };\n}\n\n/**\n * Create the client Vite config with sensible agent-native defaults.\n * Supports two modes:\n * - Legacy SPA mode (default): React SWC plugin, client-only routing\n * - React Router framework mode: SSR-capable with file-based routing\n *\n * Both modes include Nitro for API routes, path aliases, and fs restrictions.\n */\nexport function defineConfig(options: ClientConfigOptions = {}): UserConfig {\n // Check if React Router plugin was passed directly in plugins array\n const hasReactRouterPlugin = options.plugins?.some(\n (p: any) =>\n p?.name === \"react-router\" ||\n (Array.isArray(p) && p.some((pp: any) => pp?.name === \"react-router\")),\n );\n\n let reactTransformPlugin: any;\n\n if (!hasReactRouterPlugin && !options.reactRouter) {\n // Legacy SPA mode — use React SWC plugin (only when React Router is not used)\n try {\n reactTransformPlugin = require(\"@vitejs/plugin-react-swc\");\n if (reactTransformPlugin.default)\n reactTransformPlugin = reactTransformPlugin.default;\n } catch {\n // Will be resolved at runtime by Vite\n }\n }\n\n const cwd = process.cwd();\n\n // Workspace env fallback. If this app is inside a workspace, tell Vite to\n // also look for .env files at the workspace root. Per-app .env still wins\n // (Vite's loadEnv merges in precedence order — app dir is loaded after).\n const workspaceRoot = findWorkspaceRoot(cwd);\n const envDir = workspaceRoot && workspaceRoot !== cwd ? workspaceRoot : cwd;\n\n // Preload workspace-root .env into process.env so Nitro server code sees\n // shared keys during dev (Nitro reads process.env, not vite's envDir).\n if (workspaceRoot && workspaceRoot !== cwd) {\n try {\n const dotenv = require(\"dotenv\");\n dotenv.config({\n path: path.join(workspaceRoot, \".env\"),\n override: false,\n // Suppress the dotenv v17 tip line — this loader fires alongside\n // utils.ts loadEnv() during dev startup and would otherwise emit a\n // duplicate \"[dotenv] injecting env\" message.\n quiet: true,\n });\n } catch {}\n }\n\n // Build the React transform plugin (only for legacy SPA mode)\n const reactPluginInstance = reactTransformPlugin?.();\n\n // Auto-inject the Tailwind v4 Vite plugin if `@tailwindcss/vite` is\n // installed (which it is by default for all agent-native templates).\n // Templates can opt out by setting `options.tailwind = false`.\n let tailwindPluginInstance: any = null;\n if (options.tailwind !== false) {\n try {\n let tailwindPlugin = require(\"@tailwindcss/vite\");\n if (tailwindPlugin.default) tailwindPlugin = tailwindPlugin.default;\n // Tailwind's Vite optimizer uses Lightning CSS internally and runs\n // before Vite's own CSS minifier. Lightning CSS collapses the standard\n // `backdrop-filter` declaration when a `-webkit-` fallback is present,\n // so let Vite/esbuild handle the production CSS pass instead.\n tailwindPluginInstance = tailwindPlugin({ optimize: false });\n } catch {\n // Plugin not installed — silently skip. Old templates may still be on v3.\n }\n }\n\n // APP_BASE_PATH lets this app be mounted under a prefix (e.g. \"/mail\") as\n // part of a unified workspace deploy. Defaults to \"/\" for standalone apps.\n const appBasePath =\n process.env.VITE_APP_BASE_PATH || process.env.APP_BASE_PATH || \"/\";\n const isWorkspaceChild = process.env.AGENT_NATIVE_WORKSPACE === \"1\";\n const base = appBasePath.endsWith(\"/\") ? appBasePath : `${appBasePath}/`;\n const monorepoCoreAllow = [\n path.resolve(cwd, \"../../packages/core\"),\n path.resolve(cwd, \"../core\"),\n ].filter((candidate) => fs.existsSync(path.join(candidate, \"package.json\")));\n\n // Workspace-core (enterprise monorepo): pull its directory into Vite's\n // file watcher + module graph so edits to its TS sources hot-reload the\n // dev server, and its package name into ssr.noExternal so the dynamic\n // import in framework-request-handler.ts goes through Vite's transform\n // pipeline (TypeScript, SSR HMR, the works).\n const workspaceCore = findWorkspaceCoreSync(cwd);\n const workspaceCoreFsAllow = workspaceCore ? [workspaceCore.packageDir] : [];\n const workspaceCoreNoExternal = workspaceCore\n ? [new RegExp(`^${escapeRegex(workspaceCore.packageName)}(/.*)?$`)]\n : [];\n\n return {\n logLevel: options.logLevel ?? (isWorkspaceChild ? \"warn\" : undefined),\n envDir,\n base,\n server: {\n host: \"::\",\n port: options.port ?? 8080,\n allowedHosts: options.allowedHosts ?? [\n \".ngrok-free.dev\",\n \".ngrok-free.app\",\n \".ngrok.io\",\n ],\n fs: {\n allow: [\n \".\",\n ...monorepoCoreAllow,\n ...workspaceCoreFsAllow,\n ...(options.fsAllow ?? []),\n ],\n deny: [\n \".env\",\n \".env.*\",\n \"*.{crt,pem}\",\n \"**/.git/**\",\n ...(options.fsDeny ?? []),\n ],\n },\n },\n build: {\n outDir: options.outDir ?? \"dist/spa\",\n // Vite 8 defaults CSS minification to Lightning CSS, which collapses a\n // `backdrop-filter` + `-webkit-backdrop-filter` pair down to only the\n // prefixed form. Chrome ignores that, so glass effects disappear in\n // production. Keep esbuild as the CSS minifier and target Safari 18+ so\n // the standard property survives the production pipeline.\n cssMinify: \"esbuild\",\n cssTarget: [\"es2020\", \"safari18\"],\n },\n // Bundle all non-Node.js deps into the production SSR server build.\n // Edge runtimes (CF Workers, Deno) don't have node_modules at runtime.\n // In dev, React Router's Vite Environment runner expects CJS packages\n // like React to stay external; forcing them through the module runner\n // raises `module is not defined`.\n ssr: process.argv.includes(\"build\")\n ? {\n noExternal: /^(?!node:)/,\n // Pick the workspace-core's compiled `dist/` exports in prod —\n // Node-style `default` condition matches what edge runtimes (CF\n // Workers, Deno) can actually load. Without this, Vite's prod\n // build inherits the dev-condition src/ entry and ships unbuilt\n // TypeScript into the worker.\n resolve: {\n conditions: [\"node\", \"module\", \"import\", \"default\"],\n externalConditions: [\"node\", \"module\", \"import\", \"default\"],\n },\n }\n : {\n // Vite already sets `development` in the dev resolve conditions,\n // so the workspace-core template's exports.development → src/\n // entry is picked automatically — Vite handles TS compilation\n // and triggers a server restart when those files change.\n noExternal: [\n /^@agent-native\\/core(\\/.*)?$/,\n // Radix UI primitives are transitive deps of @agent-native/core\n // (used by FeedbackButton, AgentSidebar, ShareDialog, etc.). When\n // a consumer app SSRs a component that imports Radix, Node's\n // externalized resolver can't find @radix-ui/* from the app cwd\n // because pnpm doesn't hoist transitive deps. Bundling them\n // through Vite resolves them via the workspace store.\n /^@radix-ui\\//,\n // scheduling ships tsc-compiled dist files that contain literal\n // `@/` path-alias imports (e.g. `import { Input } from\n // \"@/components/ui/input\"`). In standalone (published) mode Node\n // treats the package as an external CJS dep and can't resolve\n // `@/components`. Adding it to noExternal makes Vite process it\n // through the module pipeline, where the consumer app's `@` →\n // `./app` alias is already registered.\n ...(hasDep(\"@agent-native/scheduling\", cwd)\n ? [/^@agent-native\\/scheduling(\\/.*)?$/]\n : []),\n ...workspaceCoreNoExternal,\n ],\n external: [\n \"react\",\n \"react-dom\",\n \"react-dom/server\",\n \"react-router\",\n \"react-router/dom\",\n \"react-router-dom\",\n ],\n },\n plugins: [\n // Stub packages from `options.ssrStubs` in the SSR bundle so they\n // don't bloat the edge worker. Opt-in per template — the framework\n // hardcodes nothing (e.g. docs sites legitimately import `shiki` on\n // the server, so we can't blanket-stub it here).\n ...(() => {\n const p = ssrStubPlugin(options.ssrStubs ?? []);\n return p ? [p] : [];\n })(),\n ...(options.plugins ?? []),\n actionTypesPlugin(),\n agentsBundlePlugin(),\n autoReloadOnOptimizeDep(),\n fullReloadOnOptimizeDep504(),\n embedDevFrameHeaders(),\n baseRedirectGuard(),\n portExposer(),\n silenceConnectionResets(),\n rolldownInputFix(),\n // Nitro Vite plugin for dev-mode API route serving and HMR.\n // Disabled during build — React Router's build handles production.\n ...(process.argv.includes(\"build\")\n ? []\n : [\n nitroVitePlugin({\n serverDir: \"./server\",\n ...(options.nitro ?? {}),\n } as any),\n ]),\n reactPluginInstance,\n tailwindPluginInstance,\n ].filter(Boolean),\n optimizeDeps: {\n include: [\n ...getDefaultOptimizeDeps(cwd),\n ...(hasDep(\"@agent-native/pinpoint\", cwd)\n ? [\"@agent-native/pinpoint/react\"]\n : []),\n ...(options.optimizeDeps?.include ?? []),\n ],\n // In monorepo mode: explicitly exclude @agent-native/core subpaths so\n // Vite never prebundles them from dist/. The source alias above\n // (`getCoreSourceAliases`) resolves every import to src/ on every\n // request, so HMR picks up new exports immediately. Without exclude,\n // the prebundle is built from dist/ once at startup and silently\n // serves stale code even after the source / dist is updated.\n exclude: [\n ...(findCoreSrcDir(cwd) !== null ? CORE_CLIENT_SUBPATHS : []),\n ...(options.optimizeDeps?.exclude ?? []),\n ],\n },\n resolve: {\n // Dedupe all client-side packages that core shares with the consuming\n // app. In pnpm monorepos, core's devDependencies can install separate\n // copies (linked to different React versions). Without deduping, each\n // copy creates its own React context — QueryClientProvider, RouterProvider,\n // Radix, etc. — causing \"No provider\" crashes at runtime.\n dedupe: getClientDedupe(cwd),\n alias: [\n // In monorepo dev: resolve @agent-native/core to source for HMR.\n // Uses regex with $ anchor for exact matching to prevent\n // @agent-native/core from prefix-matching @agent-native/core/client.\n ...getCoreSourceAliases(cwd),\n // Standard path aliases (prefix matching is fine here)\n { find: \"@\", replacement: path.resolve(cwd, \"./app\") },\n { find: \"@shared\", replacement: path.resolve(cwd, \"./shared\") },\n ...Object.entries(options.aliases ?? {}).map(([find, replacement]) => ({\n find,\n replacement,\n })),\n ],\n },\n };\n}\n"]}
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/vite/client.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAEvC,OAAO,EAAE,KAAK,IAAI,eAAe,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,wBAAwB,EAAE,MAAM,uCAAuC,CAAC;AACjF,OAAO,EACL,oBAAoB,EACpB,4BAA4B,EAC5B,8BAA8B,EAC9B,6BAA6B,GAC9B,MAAM,gCAAgC,CAAC;AAExC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/C,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAE/D;;;;;;;;;;;;;GAaG;AACH,SAAS,qBAAqB,CAC5B,QAAgB;IAEhB,4EAA4E;IAC5E,IAAI,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACjC,IAAI,aA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ACL,iEAAiE;gBACjE,yDAAyD;gBACzD,qEAAqE;gBACrE,GAAG,oBAAoB,CAAC,GAAG,CAAC;gBAC5B,uDAAuD;gBACvD,EAAE,IAAI,EAAE,GAAG,EAAE,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,EAAE;gBACtD,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,UAAU,CAAC,EAAE;gBAC/D,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,WAAW,CAAC,EAAE,EAAE,CAAC,CAAC;oBACrE,IAAI;oBACJ,WAAW;iBACZ,CAAC,CAAC;aACJ;SACF;KACF,CAAC;AACJ,CAAC","sourcesContent":["import path from \"path\";\nimport fs from \"fs\";\nimport { createRequire } from \"module\";\nimport type { Plugin, UserConfig } from \"vite\";\nimport { nitro as nitroVitePlugin } from \"nitro/vite\";\nimport { actionTypesPlugin } from \"./action-types-plugin.js\";\nimport { agentsBundlePlugin } from \"./agents-bundle-plugin.js\";\nimport { findWorkspaceRoot } from \"../scripts/utils.js\";\nimport { getViteDevRecoveryScript } from \"../client/vite-dev-recovery-script.js\";\nimport {\n isMcpEmbedCorsOrigin,\n MCP_EMBED_CORS_ALLOW_HEADERS,\n MCP_EMBED_STATIC_ASSET_HEADERS,\n mcpEmbedStaticAssetRouteRules,\n} from \"../shared/mcp-embed-headers.js\";\n\nimport { fileURLToPath } from \"url\";\n\nconst require = createRequire(import.meta.url);\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\n\n/**\n * Sync discovery for the workspace-core in an enterprise monorepo.\n *\n * Mirrors `getWorkspaceCoreExports` in deploy/workspace-core.ts but stays\n * synchronous so it can run inline in `defineConfig`. Returns the workspace\n * core's package name + absolute directory, or null if no workspace core is\n * declared in the ancestor chain.\n *\n * Walks up from `startDir` looking for a package.json with\n * `agent-native.workspaceCore`. Resolves the declared package name through\n * `<workspaceRoot>/node_modules/<name>` (pnpm symlink, fastest) or by\n * scanning `packages/*` for a matching `name` field (fallback for\n * pre-install scenarios).\n */\nfunction findWorkspaceCoreSync(\n startDir: string,\n): { packageName: string; packageDir: string } | null {\n // 1) Walk up looking for the root package.json that declares workspaceCore.\n let dir = path.resolve(startDir);\n let workspaceRoot: string | null = null;\n let packageName: string | null = null;\n for (let i = 0; i < 20; i++) {\n const pkgPath = path.join(dir, \"package.json\");\n if (fs.existsSync(pkgPath)) {\n try {\n const pkg = JSON.parse(fs.readFileSync(pkgPath, \"utf-8\"));\n const declared = pkg?.[\"agent-native\"]?.workspaceCore;\n if (typeof declared === \"string\" && declared.length > 0) {\n workspaceRoot = dir;\n packageName = declared;\n break;\n }\n } catch {\n // Malformed package.json — keep walking up.\n }\n }\n const parent = path.dirname(dir);\n if (parent === dir) break;\n dir = parent;\n }\n if (!workspaceRoot || !packageName) return null;\n\n // 2a) pnpm/npm symlink under workspaceRoot/node_modules.\n const nm = path.join(workspaceRoot, \"node_modules\", packageName);\n if (fs.existsSync(path.join(nm, \"package.json\"))) {\n return { packageName, packageDir: fs.realpathSync(nm) };\n }\n\n // 2b) Scan packages/* and packages/@scope/* for a matching `name`.\n const packagesDir = path.join(workspaceRoot, \"packages\");\n if (fs.existsSync(packagesDir)) {\n const candidates: string[] = [];\n for (const entry of fs.readdirSync(packagesDir, { withFileTypes: true })) {\n if (!entry.isDirectory()) continue;\n candidates.push(path.join(packagesDir, entry.name));\n if (entry.name.startsWith(\"@\")) {\n const scopeDir = path.join(packagesDir, entry.name);\n for (const sub of fs.readdirSync(scopeDir, { withFileTypes: true })) {\n if (sub.isDirectory()) candidates.push(path.join(scopeDir, sub.name));\n }\n }\n }\n for (const c of candidates) {\n const p = path.join(c, \"package.json\");\n if (!fs.existsSync(p)) continue;\n try {\n const pkg = JSON.parse(fs.readFileSync(p, \"utf-8\"));\n if (pkg?.name === packageName)\n return { packageName, packageDir: fs.realpathSync(c) };\n } catch {\n // ignore malformed package.json\n }\n }\n }\n return null;\n}\n\n/** Escape a string so it can be embedded as a regex literal. */\nfunction escapeRegex(s: string): string {\n return s.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n\n/** Check if a package is installed in the project */\nfunction hasDep(pkg: string, cwd: string): boolean {\n try {\n const pkgJson = JSON.parse(\n fs.readFileSync(path.join(cwd, \"package.json\"), \"utf-8\"),\n );\n return !!(\n pkgJson.dependencies?.[pkg] ||\n pkgJson.devDependencies?.[pkg] ||\n pkgJson.peerDependencies?.[pkg]\n );\n } catch {\n return false;\n }\n}\n\n/**\n * Build the `resolve.dedupe` list dynamically. Reads core's package.json and\n * collects every peerDependency that the consuming app also declares. This\n * ensures Vite resolves them from the app root, not from core's own\n * node_modules — preventing duplicate React context / singleton issues.\n */\nfunction getClientDedupe(cwd: string): string[] {\n // Always dedupe React internals (sub-path exports aren't in peerDeps)\n const always = new Set([\"react\", \"react-dom\", \"react-dom/client\"]);\n\n // Server-only packages that never run in the browser — no point deduping.\n const serverOnly = new Set([\n \"drizzle-kit\",\n \"node-pty\",\n \"postgres\",\n \"ws\",\n \"typescript\",\n \"vite\",\n \"@vitejs/plugin-react-swc\",\n \"tailwindcss\",\n \"@tailwindcss/vite\",\n ]);\n\n try {\n const corePkgPath = path.resolve(__dirname, \"../../package.json\");\n const corePkg = JSON.parse(fs.readFileSync(corePkgPath, \"utf-8\"));\n\n // Scan both peerDependencies and dependencies. Direct deps like\n // @radix-ui/* use React internally — they must resolve against the\n // app's React, not a second copy inside core's node_modules.\n const coreDeps = new Set([\n ...Object.keys(corePkg.peerDependencies ?? {}),\n ...Object.keys(corePkg.dependencies ?? {}),\n ]);\n\n // Read the consuming app's dependencies\n const appPkg = JSON.parse(\n fs.readFileSync(path.join(cwd, \"package.json\"), \"utf-8\"),\n );\n const appDeps = new Set([\n ...Object.keys(appPkg.dependencies ?? {}),\n ...Object.keys(appPkg.devDependencies ?? {}),\n ]);\n\n for (const dep of coreDeps) {\n if (serverOnly.has(dep)) continue;\n // Dedupe if the app also declares it, OR if it's a React-based\n // UI library (Radix, Tanstack) that must share the app's React.\n if (\n appDeps.has(dep) ||\n dep.startsWith(\"@radix-ui/\") ||\n dep.startsWith(\"@tanstack/\")\n ) {\n always.add(dep);\n }\n }\n } catch {\n // Can't read package.json — fall back to known singletons\n }\n\n return [...always];\n}\n\n/**\n * Locate `packages/core/src` if we're inside the framework monorepo.\n * Shared between `getCoreSourceAliases` (which redirects imports to src/)\n * and `getDefaultOptimizeDeps` (which must NOT prebundle from dist/ when\n * the alias is active — otherwise the prebundle is built from a snapshot\n * of dist/ at startup and never picks up new exports).\n */\nfunction findCoreSrcDir(cwd: string): string | null {\n const candidates = [\n path.resolve(cwd, \"../../packages/core\"), // templates/<name>/\n path.resolve(cwd, \"../core\"), // packages/<name>/\n ];\n for (const candidate of candidates) {\n if (fs.existsSync(path.join(candidate, \"src/index.ts\"))) {\n return path.join(candidate, \"src\");\n }\n }\n return null;\n}\n\n/**\n * Every `@agent-native/core` subpath that gets a source alias. Must stay in\n * sync with `getCoreSourceAliases`. Used by `getDefaultOptimizeDeps` to skip\n * prebundling in monorepo mode, and by the consumer config to add them to\n * `optimizeDeps.exclude` so Vite always resolves them through the source\n * alias on every request — never from a stale dist/ snapshot.\n */\nconst CORE_CLIENT_SUBPATHS = [\n \"@agent-native/core\",\n \"@agent-native/core/client\",\n \"@agent-native/core/client/extensions\",\n \"@agent-native/core/client/tools\", // legacy alias\n \"@agent-native/core/client/org\",\n \"@agent-native/core/client/observability\",\n \"@agent-native/core/client/onboarding\",\n \"@agent-native/core/client/sharing\",\n \"@agent-native/core/client/notifications\",\n \"@agent-native/core/client/progress\",\n];\n\nfunction getDefaultOptimizeDeps(cwd: string): string[] {\n const inMonorepo = findCoreSrcDir(cwd) !== null;\n const entries: Array<{ specifier: string; packageName?: string }> = [\n // In monorepo mode the source alias resolves these to src/ on every\n // import, so prebundling from dist/ would just create a stale snapshot.\n // Skip them entirely — `optimizeDeps.exclude` below makes that explicit.\n ...(inMonorepo\n ? []\n : ([\n { specifier: \"@agent-native/core\" },\n {\n specifier: \"@agent-native/core/client\",\n packageName: \"@agent-native/core\",\n },\n {\n specifier: \"@agent-native/core/client/org\",\n packageName: \"@agent-native/core\",\n },\n {\n specifier: \"@agent-native/core/client/extensions\",\n packageName: \"@agent-native/core\",\n },\n {\n // Legacy alias — prior name for @agent-native/core/client/extensions.\n // Keep so deployed templates that haven't been updated still resolve.\n specifier: \"@agent-native/core/client/tools\",\n packageName: \"@agent-native/core\",\n },\n ] as Array<{ specifier: string; packageName?: string }>)),\n { specifier: \"@libsql/client\" },\n { specifier: \"@radix-ui/react-accordion\" },\n { specifier: \"@radix-ui/react-alert-dialog\" },\n { specifier: \"@radix-ui/react-avatar\" },\n { specifier: \"@radix-ui/react-checkbox\" },\n { specifier: \"@radix-ui/react-collapsible\" },\n { specifier: \"@radix-ui/react-context-menu\" },\n { specifier: \"@radix-ui/react-dialog\" },\n { specifier: \"@radix-ui/react-dropdown-menu\" },\n { specifier: \"@radix-ui/react-hover-card\" },\n { specifier: \"@radix-ui/react-label\" },\n { specifier: \"@radix-ui/react-menubar\" },\n { specifier: \"@radix-ui/react-navigation-menu\" },\n { specifier: \"@radix-ui/react-popover\" },\n { specifier: \"@radix-ui/react-progress\" },\n { specifier: \"@radix-ui/react-radio-group\" },\n { specifier: \"@radix-ui/react-scroll-area\" },\n { specifier: \"@radix-ui/react-select\" },\n { specifier: \"@radix-ui/react-separator\" },\n { specifier: \"@radix-ui/react-slider\" },\n { specifier: \"@radix-ui/react-slot\" },\n { specifier: \"@radix-ui/react-switch\" },\n { specifier: \"@radix-ui/react-tabs\" },\n { specifier: \"@radix-ui/react-toast\" },\n { specifier: \"@radix-ui/react-toggle\" },\n { specifier: \"@radix-ui/react-toggle-group\" },\n { specifier: \"@radix-ui/react-tooltip\" },\n { specifier: \"@tanstack/react-query\" },\n { specifier: \"@tabler/icons-react\" },\n { specifier: \"class-variance-authority\" },\n { specifier: \"clsx\" },\n { specifier: \"cmdk\" },\n { specifier: \"drizzle-orm\" },\n { specifier: \"drizzle-orm/pg-core\", packageName: \"drizzle-orm\" },\n { specifier: \"drizzle-orm/sqlite-core\", packageName: \"drizzle-orm\" },\n { specifier: \"h3\" },\n { specifier: \"next-themes\" },\n { specifier: \"react-hook-form\" },\n { specifier: \"sonner\" },\n { specifier: \"tailwind-merge\" },\n { specifier: \"zod\" },\n ];\n\n return entries\n .filter(({ specifier, packageName }) =>\n hasDep(packageName ?? specifier, cwd),\n )\n .map(({ specifier }) => specifier);\n}\n\n/**\n * In monorepo dev mode, resolve @agent-native/core imports to source (src/)\n * instead of dist/ so that Vite HMR picks up changes without rebuilding.\n *\n * Returns Vite array-style aliases with exact matching (regex anchored with $)\n * to prevent `@agent-native/core` from prefix-matching and swallowing\n * sub-path imports like `@agent-native/core/client`.\n */\nfunction getCoreSourceAliases(\n cwd: string,\n): Array<{ find: RegExp; replacement: string }> {\n const coreSrc = findCoreSrcDir(cwd);\n if (!coreSrc) return []; // Not in monorepo — use dist as normal\n\n // Map every @agent-native/core/* export to its src/ equivalent.\n // Each entry uses a regex with $ anchor for exact matching.\n const entries: Record<string, string> = {\n \"@agent-native/core\": path.join(coreSrc, \"index.browser.ts\"),\n \"@agent-native/core/server\": path.join(coreSrc, \"server/index.ts\"),\n \"@agent-native/core/client\": path.join(coreSrc, \"client/index.ts\"),\n \"@agent-native/core/client/extensions\": path.join(\n coreSrc,\n \"client/extensions/index.ts\",\n ),\n // Legacy alias — see exports map note above.\n \"@agent-native/core/client/tools\": path.join(\n coreSrc,\n \"client/extensions/index.ts\",\n ),\n \"@agent-native/core/client/org\": path.join(coreSrc, \"client/org/index.ts\"),\n \"@agent-native/core/client/observability\": path.join(\n coreSrc,\n \"client/observability/index.ts\",\n ),\n \"@agent-native/core/client/onboarding\": path.join(\n coreSrc,\n \"client/onboarding/index.ts\",\n ),\n \"@agent-native/core/client/sharing\": path.join(\n coreSrc,\n \"client/sharing/index.ts\",\n ),\n \"@agent-native/core/client/notifications\": path.join(\n coreSrc,\n \"client/notifications/index.ts\",\n ),\n \"@agent-native/core/client/progress\": path.join(\n coreSrc,\n \"client/progress/index.ts\",\n ),\n \"@agent-native/core/db\": path.join(coreSrc, \"db/index.ts\"),\n \"@agent-native/core/db/schema\": path.join(coreSrc, \"db/schema.ts\"),\n \"@agent-native/core/shared\": path.join(coreSrc, \"shared/index.ts\"),\n \"@agent-native/core/scripts\": path.join(coreSrc, \"scripts/index.ts\"),\n \"@agent-native/core/application-state\": path.join(\n coreSrc,\n \"application-state/index.ts\",\n ),\n \"@agent-native/core/settings\": path.join(coreSrc, \"settings/index.ts\"),\n \"@agent-native/core/credentials\": path.join(\n coreSrc,\n \"credentials/index.ts\",\n ),\n \"@agent-native/core/resources\": path.join(coreSrc, \"resources/index.ts\"),\n \"@agent-native/core/oauth-tokens\": path.join(\n coreSrc,\n \"oauth-tokens/index.ts\",\n ),\n \"@agent-native/core/workspace-connections\": path.join(\n coreSrc,\n \"workspace-connections/index.ts\",\n ),\n \"@agent-native/core/a2a\": path.join(coreSrc, \"a2a/index.ts\"),\n \"@agent-native/core/router\": path.join(coreSrc, \"router/index.ts\"),\n \"@agent-native/core/terminal\": path.join(\n coreSrc,\n \"client/terminal/index.ts\",\n ),\n \"@agent-native/core/terminal/server\": path.join(\n coreSrc,\n \"terminal/index.ts\",\n ),\n \"@agent-native/core/adapters/cli\": path.join(\n coreSrc,\n \"adapters/cli/index.ts\",\n ),\n \"@agent-native/core/usage\": path.join(coreSrc, \"usage/store.ts\"),\n // Shared stylesheet — alias to src so CSS edits (composer/theme rules)\n // take effect live in dev instead of silently loading the stale built\n // copy at dist/styles/. From src/styles/ the `@source \"../client/**\"`\n // directive resolves to the real .tsx source, which is what dev should\n // scan for Tailwind classes anyway.\n \"@agent-native/core/styles/agent-native.css\": path.join(\n coreSrc,\n \"styles/agent-native.css\",\n ),\n };\n\n // Escape special regex chars in the key and anchor with $\n return Object.entries(entries).map(([find, replacement]) => ({\n find: new RegExp(`^${find.replace(/[/]/g, \"\\\\/\")}$`),\n replacement,\n }));\n}\n\nexport interface NitroOptions {\n /** Nitro deployment preset (e.g. \"node\", \"vercel\", \"netlify\", \"cloudflare_pages\"). Default: \"node\" */\n preset?: string;\n /** Source directory for server files. Default: \"./server\" */\n srcDir?: string;\n /** Routes directory name (relative to srcDir). Default: \"routes\" */\n routesDir?: string;\n /** Any additional Nitro config overrides */\n [key: string]: unknown;\n}\n\nexport interface ClientConfigOptions {\n /** Port for dev server. Default: 8080 */\n port?: number;\n /** Additional hostnames allowed to access the dev server. */\n allowedHosts?: NonNullable<NonNullable<UserConfig[\"server\"]>[\"allowedHosts\"]>;\n /** Vite log level. Workspace child apps default to \"warn\" so only the gateway URL is advertised. */\n logLevel?: UserConfig[\"logLevel\"];\n /** Additional Vite plugins */\n plugins?: any[];\n /** Nitro plugin options (preset, srcDir, etc) */\n nitro?: NitroOptions;\n /** Override resolve aliases */\n aliases?: Record<string, string>;\n /** Override build.outDir. Default: \"dist/spa\" */\n outDir?: string;\n /** Additional fs.allow paths */\n fsAllow?: string[];\n /** Additional fs.deny patterns */\n fsDeny?: string[];\n /** Additional Vite optimizeDeps configuration */\n optimizeDeps?: NonNullable<UserConfig[\"optimizeDeps\"]>;\n /**\n * Whether to auto-inject the Tailwind v4 Vite plugin (`@tailwindcss/vite`).\n * Defaults to true — set to `false` if a template wants to manage Tailwind\n * itself (e.g. the legacy v3 PostCSS pipeline).\n */\n tailwind?: boolean;\n /**\n * Package names to stub in the SSR bundle with an empty proxy object.\n *\n * Use this for dependencies that only run in the browser (canvas / diagram\n * libraries, editors, WebGL) but would otherwise get pulled into the\n * server bundle via SSR's noExternal policy — pushing the CF Pages\n * Functions bundle over the 25 MiB limit.\n *\n * Only add packages that are provably never called during SSR. If the\n * server imports one, it will receive a Proxy that throws on any real\n * use (which is better than bundling a 10 MiB dep the worker never calls).\n *\n * @example\n * ssrStubs: [\"mermaid\", \"@excalidraw/excalidraw\"]\n */\n ssrStubs?: string[];\n /**\n * @deprecated Pass `reactRouter()` directly in the `plugins` array instead.\n * Previously used to auto-load the React Router Vite plugin via require(),\n * but this fails in ESM contexts. Templates should now do:\n * ```ts\n * import { reactRouter } from \"@react-router/dev/vite\";\n * defineConfig({ plugins: [reactRouter()] })\n * ```\n */\n reactRouter?: boolean | Record<string, unknown>;\n}\n\n/**\n * Vite plugin that recovers the page when Vite's dependency optimizer\n * invalidates modules mid-load (the \"504 Outdated Optimize Dep\" error).\n *\n * Without this, the page silently fails: <script type=\"module\"> tags 504,\n * React never mounts, and the user is stuck on a blank screen until they\n * manually refresh. We catch the failure modes and auto-reload, with a\n * visible overlay so the user knows what's happening, and a loop guard\n * so we never thrash forever.\n *\n * CRITICAL: this must be a SYNCHRONOUS (non-module) script injected at\n * `head-prepend`. Module scripts are deferred — the browser starts fetching\n * all module scripts in parallel during HTML parsing, so a module listener\n * registers AFTER sibling modules have already started loading and\n * possibly errored out. A regular <script> blocks parsing and runs\n * synchronously, so the listener is registered before ANY module fetch\n * begins.\n *\n * Catches three failure modes (all before React needs to mount):\n * 1. <script type=\"module\"> / <link> 504 — window \"error\" event, capture phase\n * 2. Dynamic import 504 — \"unhandledrejection\" with \"dynamically imported module\"\n * 3. Child module 504 — resource timing when browser exposes the HTTP status\n */\nfunction autoReloadOnOptimizeDep(): Plugin {\n return {\n name: \"agent-native-auto-reload-optimize-dep\",\n apply: \"serve\",\n transformIndexHtml() {\n return [\n {\n tag: \"script\",\n // NOTE: no `type: \"module\"` — this must be a synchronous script.\n children: getViteDevRecoveryScript(),\n injectTo: \"head-prepend\",\n },\n ];\n },\n };\n}\n\n/**\n * Vite handles outdated optimized-dep requests inside its own transform\n * middleware and ends the HTTP response with `504 Outdated Optimize Dep`.\n * Browser module loaders do not consistently surface those child-module\n * failures to userland JavaScript, so also nudge the Vite HMR client from the\n * server side. This turns the confusing blank-screen state into the same\n * full-page reload Vite would have requested once optimization settled.\n */\nfunction fullReloadOnOptimizeDep504(): Plugin {\n return {\n name: \"agent-native-full-reload-optimize-dep-504\",\n apply: \"serve\",\n configureServer(server) {\n let lastReloadAt = 0;\n server.middlewares.use((req, res, next) => {\n const originalEnd = res.end;\n (res as unknown as { end: (...args: unknown[]) => unknown }).end = (\n ...endArgs: unknown[]\n ) => {\n const statusMessage = String(res.statusMessage || \"\");\n if (\n res.statusCode === 504 &&\n statusMessage === \"Outdated Optimize Dep\"\n ) {\n const now = Date.now();\n if (now - lastReloadAt > 500) {\n lastReloadAt = now;\n server.ws.send({ type: \"full-reload\" });\n server.config.logger.info(\n `[agent-native] Vite optimized deps changed while loading ${\n req.url ?? \"a module\"\n }; reloading the page.`,\n { timestamp: true },\n );\n }\n }\n return (originalEnd as (...args: unknown[]) => unknown).apply(\n res,\n endArgs,\n );\n };\n next();\n });\n },\n };\n}\n\n/**\n * Vite plugin that prevents the built-in base middleware from redirecting\n * \"/\" → \"/app/\" (or whatever the base is). When agent-native apps run with\n * --base /app/ in single-port mode, Vite's baseMiddleware sends a 302 from\n * \"/\" to the base path. This breaks Electron webview and iframe embeds\n * that load the app at the root. Instead, we rewrite \"/\" to the base path\n * internally so the app serves without a visible redirect.\n */\nfunction baseRedirectGuard(): Plugin {\n return {\n name: \"agent-native-base-redirect-guard\",\n apply: \"serve\",\n configureServer(server) {\n // Return a function so the middleware is added AFTER Vite's internal\n // middleware is built — but we insert BEFORE by using the pre-hook\n // approach: configureServer hooks that return nothing run before\n // internal middleware.\n server.middlewares.use((req, res, next) => {\n const base = server.config.base;\n if (base && base !== \"/\" && req.url?.startsWith(base)) {\n const relativeUrl = req.url.slice(base.length - 1);\n try {\n const url = new URL(relativeUrl, \"http://agent-native.local\");\n const publicDir = server.config.publicDir;\n if (typeof publicDir !== \"string\") {\n return next();\n }\n const publicPath = path.normalize(\n path.join(publicDir, decodeURIComponent(url.pathname)),\n );\n if (\n publicPath.startsWith(publicDir + path.sep) &&\n fs.existsSync(publicPath) &&\n fs.statSync(publicPath).isFile()\n ) {\n const contentType = contentTypeForPublicFile(publicPath);\n if (contentType) res.setHeader(\"content-type\", contentType);\n if (req.method === \"HEAD\") {\n res.statusCode = 200;\n res.end();\n return;\n }\n fs.createReadStream(publicPath).pipe(res);\n return;\n }\n } catch {\n // Fall through to Vite/Nitro. Malformed URLs should keep their\n // original path so the normal dev-server error handling applies.\n }\n }\n req.url = stripMountedDevApiPath(req.url, base);\n if (\n req.method === \"HEAD\" &&\n req.url &&\n !isFrameworkDevPath(req.url, base)\n ) {\n req.method = \"GET\";\n }\n if (\n base &&\n base !== \"/\" &&\n (req.url === \"/\" || req.url === \"/index.html\")\n ) {\n // Rewrite to the base path so Vite serves the app directly\n req.url = base;\n }\n next();\n });\n },\n };\n}\n\nfunction embedDevFrameHeaders(): Plugin {\n return {\n name: \"agent-native-embed-dev-frame-headers\",\n apply: \"serve\",\n configureServer(server) {\n server.middlewares.use((req, res, next) => {\n const origin = String(req.headers.origin ?? \"\");\n if (isMcpEmbedCorsOrigin(origin)) {\n res.setHeader(\"Access-Control-Allow-Origin\", origin);\n res.setHeader(\"Vary\", \"Origin\");\n res.setHeader(\n \"Access-Control-Allow-Methods\",\n \"GET,HEAD,POST,PUT,PATCH,DELETE,OPTIONS\",\n );\n res.setHeader(\n \"Access-Control-Allow-Headers\",\n MCP_EMBED_CORS_ALLOW_HEADERS,\n );\n for (const [name, value] of Object.entries(\n MCP_EMBED_STATIC_ASSET_HEADERS,\n )) {\n if (name === \"Access-Control-Allow-Origin\") continue;\n res.setHeader(name, value);\n }\n if (req.method === \"OPTIONS\") {\n res.statusCode = 204;\n res.end();\n return;\n }\n }\n\n const cookieHeader = String(req.headers.cookie ?? \"\");\n let hasEmbedMarker = /\\ban_embed_session=/.test(cookieHeader);\n try {\n const url = new URL(req.url ?? \"/\", \"http://agent-native.local\");\n hasEmbedMarker =\n hasEmbedMarker || url.searchParams.has(\"__an_embed_token\");\n } catch {\n // Malformed URLs should continue through Vite's normal handling.\n }\n if (hasEmbedMarker) {\n res.setHeader(\"Cross-Origin-Embedder-Policy\", \"require-corp\");\n res.setHeader(\"Cross-Origin-Opener-Policy\", \"same-origin\");\n res.setHeader(\"Cross-Origin-Resource-Policy\", \"cross-origin\");\n res.setHeader(\"Referrer-Policy\", \"no-referrer\");\n }\n next();\n });\n },\n };\n}\n\nfunction contentTypeForPublicFile(filePath: string): string | null {\n switch (path.extname(filePath).toLowerCase()) {\n case \".css\":\n return \"text/css\";\n case \".html\":\n return \"text/html\";\n case \".ico\":\n return \"image/x-icon\";\n case \".json\":\n case \".webmanifest\":\n return \"application/json\";\n case \".js\":\n case \".mjs\":\n return \"text/javascript\";\n case \".png\":\n return \"image/png\";\n case \".svg\":\n return \"image/svg+xml\";\n case \".txt\":\n return \"text/plain\";\n case \".xml\":\n return \"application/xml\";\n default:\n return null;\n }\n}\n\nfunction devPathname(reqUrl: string): string {\n return new URL(reqUrl, \"http://agent-native.local\").pathname;\n}\n\nfunction isApiDevPath(reqUrl: string): boolean {\n const pathname = devPathname(reqUrl);\n return pathname === \"/api\" || pathname.startsWith(\"/api/\");\n}\n\nexport function stripMountedDevApiPath(\n reqUrl: string | undefined,\n base: string | undefined,\n): string | undefined {\n if (!reqUrl || !base || base === \"/\") return reqUrl;\n const normalizedBase = base.endsWith(\"/\") ? base : `${base}/`;\n if (!reqUrl.startsWith(normalizedBase)) return reqUrl;\n const stripped = reqUrl.slice(normalizedBase.length - 1) || \"/\";\n return isApiDevPath(stripped) ? stripped : reqUrl;\n}\n\nexport function isFrameworkDevPath(\n reqUrl: string,\n base: string | undefined,\n): boolean {\n const pathname = devPathname(reqUrl);\n if (pathname === \"/_agent-native\" || pathname.startsWith(\"/_agent-native/\")) {\n return true;\n }\n if (!base || base === \"/\") return false;\n const normalizedBase = base.endsWith(\"/\") ? base.slice(0, -1) : base;\n return (\n pathname === `${normalizedBase}/_agent-native` ||\n pathname.startsWith(`${normalizedBase}/_agent-native/`)\n );\n}\n\n/**\n * Work around a Rolldown bug where Nitro passes service entries as objects\n * ({index: \"path\"}) but Rolldown expects strings. This plugin normalizes\n * rollupOptions.input entries in the SSR environment.\n */\nfunction rolldownInputFix(): Plugin {\n return {\n name: \"agent-native-rolldown-input-fix\",\n configEnvironment(name, config) {\n const input = config.build?.rollupOptions?.input;\n if (!Array.isArray(input)) return;\n // Flatten any object entries to just their string values\n const fixed = input.map((entry: any) => {\n if (typeof entry === \"string\") return entry;\n if (typeof entry === \"object\" && entry !== null) {\n const values = Object.values(entry);\n return values[0] as string;\n }\n return entry;\n });\n config.build!.rollupOptions!.input = fixed;\n },\n };\n}\n\n/**\n * Expose the resolved Vite dev server port as process.env.PORT so that\n * in-process scripts (which use localFetch → http://localhost:${PORT}/api/...)\n * hit the right address even when Vite auto-increments the port.\n */\n/**\n * Replace caller-specified packages with an empty proxy stub during SSR\n * builds. For apps whose heavy browser-only deps would otherwise bloat the\n * edge worker past CF Pages' 25 MiB Functions limit.\n *\n * The template lists the packages in its `defineConfig({ ssrStubs })` call —\n * the framework never hardcodes package names.\n */\nfunction ssrStubPlugin(packages: string[]): Plugin | null {\n if (!packages.length) return null;\n const stubbed = new Set(packages);\n const STUB_ID = \"\\0agent-native-ssr-stub\";\n return {\n name: \"agent-native-ssr-stub-heavy-libs\",\n enforce: \"pre\",\n resolveId(id, _importer, opts) {\n if (!opts?.ssr) return null;\n // Match the bare package name or any subpath\n const pkg = id\n .split(\"/\")\n .slice(0, id.startsWith(\"@\") ? 2 : 1)\n .join(\"/\");\n if (stubbed.has(pkg)) return STUB_ID;\n return null;\n },\n load(id) {\n if (id !== STUB_ID) return null;\n // Proxy that answers any property access with itself — lets dead\n // import/re-export chains parse without blowing up, and still throws\n // if code actually tries to call any of it on the server.\n return (\n \"const handler = { get(_, p) { \" +\n \"if (p === Symbol.toPrimitive) return () => ''; \" +\n \"if (p === 'then') return undefined; \" +\n \"return new Proxy(() => {}, handler); \" +\n \"} };\" +\n \"const stub = new Proxy(() => {}, handler);\" +\n \"export default stub;\"\n );\n },\n };\n}\n\nfunction portExposer(): Plugin {\n return {\n name: \"agent-native-port-exposer\",\n apply: \"serve\",\n configureServer(server) {\n server.httpServer?.once(\"listening\", () => {\n const addr = server.httpServer?.address();\n if (addr && typeof addr === \"object\" && addr.port) {\n process.env.PORT = String(addr.port); // guard:allow-env-mutation — Vite dev server port published once at boot before any request\n }\n });\n },\n };\n}\n\n/**\n * Silence benign connection-reset noise from Vite's dev middleware.\n * Fires when a browser closes/reloads/navigates mid-request — the peer has\n * already gone away, there's nothing to fix, and Vite's error middleware\n * spams the terminal and browser HMR overlay with errors like\n * \"read ECONNRESET\" and \"socket hang up\". Our H3 server layer already\n * swallows these (create-server.ts onError); this plugin does the same for\n * Vite's own connect pipeline.\n */\nfunction silenceConnectionResets(): Plugin {\n const isBenign = (err: unknown) => {\n const e = err as\n | (NodeJS.ErrnoException & { cause?: NodeJS.ErrnoException })\n | undefined;\n const code = e?.code || (e?.cause as NodeJS.ErrnoException)?.code;\n const message = String(e?.message ?? \"\");\n return (\n code === \"ECONNRESET\" ||\n code === \"ECONNABORTED\" ||\n code === \"EPIPE\" ||\n /^(read ECONNRESET|write ECONNRESET|socket hang up|aborted|write EPIPE)$/i.test(\n message,\n )\n );\n };\n const isBenignErrorPayload = (payload: unknown) => {\n const p = payload as { type?: string; err?: unknown } | undefined;\n return p?.type === \"error\" && isBenign(p.err);\n };\n return {\n name: \"agent-native-silence-connection-resets\",\n apply: \"serve\",\n configureServer(server) {\n // Swallow socket-level resets so Node doesn't surface them as uncaught.\n server.httpServer?.on(\"connection\", (socket) => {\n socket.on(\"error\", (err) => {\n if (!isBenign(err)) throw err;\n });\n });\n // Drop Vite's \"Internal server error: read ECONNRESET\" log lines.\n const origError = server.config.logger.error.bind(server.config.logger);\n server.config.logger.error = (msg, opts) => {\n const text = typeof msg === \"string\" ? msg : String(msg ?? \"\");\n if (\n (opts?.error && isBenign(opts.error)) ||\n /Internal server error:\\s*(read ECONNRESET|write ECONNRESET|socket hang up|aborted|EPIPE)/i.test(\n text,\n )\n ) {\n return;\n }\n origError(msg, opts);\n };\n\n // Vite's error middleware sends these same benign errors to the HMR\n // client, which turns them into the full-screen browser overlay.\n // Suppress just those payloads while leaving real transform/runtime\n // errors untouched.\n const hot = (\n server as unknown as {\n environments?: { client?: { hot?: { send?: Function } } };\n }\n ).environments?.client?.hot;\n if (hot?.send) {\n const origHotSend = hot.send.bind(hot);\n hot.send = (payload: unknown, ...args: unknown[]) => {\n if (isBenignErrorPayload(payload)) return;\n return origHotSend(payload, ...args);\n };\n }\n\n const ws = (server as unknown as { ws?: { send?: Function } }).ws;\n if (ws?.send) {\n const origWsSend = ws.send.bind(ws);\n ws.send = (payload: unknown, ...args: unknown[]) => {\n if (isBenignErrorPayload(payload)) return;\n return origWsSend(payload, ...args);\n };\n }\n },\n };\n}\n\n/**\n * Create the client Vite config with sensible agent-native defaults.\n * Supports two modes:\n * - Legacy SPA mode (default): React SWC plugin, client-only routing\n * - React Router framework mode: SSR-capable with file-based routing\n *\n * Both modes include Nitro for API routes, path aliases, and fs restrictions.\n */\nexport function defineConfig(options: ClientConfigOptions = {}): UserConfig {\n // Check if React Router plugin was passed directly in plugins array\n const hasReactRouterPlugin = options.plugins?.some(\n (p: any) =>\n p?.name === \"react-router\" ||\n (Array.isArray(p) && p.some((pp: any) => pp?.name === \"react-router\")),\n );\n\n let reactTransformPlugin: any;\n\n if (!hasReactRouterPlugin && !options.reactRouter) {\n // Legacy SPA mode — use React SWC plugin (only when React Router is not used)\n try {\n reactTransformPlugin = require(\"@vitejs/plugin-react-swc\");\n if (reactTransformPlugin.default)\n reactTransformPlugin = reactTransformPlugin.default;\n } catch {\n // Will be resolved at runtime by Vite\n }\n }\n\n const cwd = process.cwd();\n\n // Workspace env fallback. If this app is inside a workspace, tell Vite to\n // also look for .env files at the workspace root. Per-app .env still wins\n // (Vite's loadEnv merges in precedence order — app dir is loaded after).\n const workspaceRoot = findWorkspaceRoot(cwd);\n const envDir = workspaceRoot && workspaceRoot !== cwd ? workspaceRoot : cwd;\n\n // Preload workspace-root .env into process.env so Nitro server code sees\n // shared keys during dev (Nitro reads process.env, not vite's envDir).\n if (workspaceRoot && workspaceRoot !== cwd) {\n try {\n const dotenv = require(\"dotenv\");\n dotenv.config({\n path: path.join(workspaceRoot, \".env\"),\n override: false,\n // Suppress the dotenv v17 tip line — this loader fires alongside\n // utils.ts loadEnv() during dev startup and would otherwise emit a\n // duplicate \"[dotenv] injecting env\" message.\n quiet: true,\n });\n } catch {}\n }\n\n // Build the React transform plugin (only for legacy SPA mode)\n const reactPluginInstance = reactTransformPlugin?.();\n\n // Auto-inject the Tailwind v4 Vite plugin if `@tailwindcss/vite` is\n // installed (which it is by default for all agent-native templates).\n // Templates can opt out by setting `options.tailwind = false`.\n let tailwindPluginInstance: any = null;\n if (options.tailwind !== false) {\n try {\n let tailwindPlugin = require(\"@tailwindcss/vite\");\n if (tailwindPlugin.default) tailwindPlugin = tailwindPlugin.default;\n // Tailwind's Vite optimizer uses Lightning CSS internally and runs\n // before Vite's own CSS minifier. Lightning CSS collapses the standard\n // `backdrop-filter` declaration when a `-webkit-` fallback is present,\n // so let Vite/esbuild handle the production CSS pass instead.\n tailwindPluginInstance = tailwindPlugin({ optimize: false });\n } catch {\n // Plugin not installed — silently skip. Old templates may still be on v3.\n }\n }\n\n // APP_BASE_PATH lets this app be mounted under a prefix (e.g. \"/mail\") as\n // part of a unified workspace deploy. Defaults to \"/\" for standalone apps.\n const appBasePath =\n process.env.VITE_APP_BASE_PATH || process.env.APP_BASE_PATH || \"/\";\n const isWorkspaceChild = process.env.AGENT_NATIVE_WORKSPACE === \"1\";\n const base = appBasePath.endsWith(\"/\") ? appBasePath : `${appBasePath}/`;\n const monorepoCoreAllow = [\n path.resolve(cwd, \"../../packages/core\"),\n path.resolve(cwd, \"../core\"),\n ].filter((candidate) => fs.existsSync(path.join(candidate, \"package.json\")));\n\n // Workspace-core (enterprise monorepo): pull its directory into Vite's\n // file watcher + module graph so edits to its TS sources hot-reload the\n // dev server, and its package name into ssr.noExternal so the dynamic\n // import in framework-request-handler.ts goes through Vite's transform\n // pipeline (TypeScript, SSR HMR, the works).\n const workspaceCore = findWorkspaceCoreSync(cwd);\n const workspaceCoreFsAllow = workspaceCore ? [workspaceCore.packageDir] : [];\n const workspaceCoreNoExternal = workspaceCore\n ? [new RegExp(`^${escapeRegex(workspaceCore.packageName)}(/.*)?$`)]\n : [];\n\n return {\n logLevel: options.logLevel ?? (isWorkspaceChild ? \"warn\" : undefined),\n envDir,\n base,\n server: {\n host: \"::\",\n port: options.port ?? 8080,\n allowedHosts: options.allowedHosts ?? [\n \".ngrok-free.dev\",\n \".ngrok-free.app\",\n \".ngrok.io\",\n ],\n fs: {\n allow: [\n \".\",\n ...monorepoCoreAllow,\n ...workspaceCoreFsAllow,\n ...(options.fsAllow ?? []),\n ],\n deny: [\n \".env\",\n \".env.*\",\n \"*.{crt,pem}\",\n \"**/.git/**\",\n ...(options.fsDeny ?? []),\n ],\n },\n },\n build: {\n outDir: options.outDir ?? \"dist/spa\",\n // Vite 8 defaults CSS minification to Lightning CSS, which collapses a\n // `backdrop-filter` + `-webkit-backdrop-filter` pair down to only the\n // prefixed form. Chrome ignores that, so glass effects disappear in\n // production. Keep esbuild as the CSS minifier and target Safari 18+ so\n // the standard property survives the production pipeline.\n cssMinify: \"esbuild\",\n cssTarget: [\"es2020\", \"safari18\"],\n },\n // Bundle all non-Node.js deps into the production SSR server build.\n // Edge runtimes (CF Workers, Deno) don't have node_modules at runtime.\n // In dev, React Router's Vite Environment runner expects CJS packages\n // like React to stay external; forcing them through the module runner\n // raises `module is not defined`.\n ssr: process.argv.includes(\"build\")\n ? {\n noExternal: /^(?!node:)/,\n // Pick the workspace-core's compiled `dist/` exports in prod —\n // Node-style `default` condition matches what edge runtimes (CF\n // Workers, Deno) can actually load. Without this, Vite's prod\n // build inherits the dev-condition src/ entry and ships unbuilt\n // TypeScript into the worker.\n resolve: {\n conditions: [\"node\", \"module\", \"import\", \"default\"],\n externalConditions: [\"node\", \"module\", \"import\", \"default\"],\n },\n }\n : {\n // Vite already sets `development` in the dev resolve conditions,\n // so the workspace-core template's exports.development → src/\n // entry is picked automatically — Vite handles TS compilation\n // and triggers a server restart when those files change.\n noExternal: [\n /^@agent-native\\/core(\\/.*)?$/,\n // Radix UI primitives are transitive deps of @agent-native/core\n // (used by FeedbackButton, AgentSidebar, ShareDialog, etc.). When\n // a consumer app SSRs a component that imports Radix, Node's\n // externalized resolver can't find @radix-ui/* from the app cwd\n // because pnpm doesn't hoist transitive deps. Bundling them\n // through Vite resolves them via the workspace store.\n /^@radix-ui\\//,\n // scheduling ships tsc-compiled dist files that contain literal\n // `@/` path-alias imports (e.g. `import { Input } from\n // \"@/components/ui/input\"`). In standalone (published) mode Node\n // treats the package as an external CJS dep and can't resolve\n // `@/components`. Adding it to noExternal makes Vite process it\n // through the module pipeline, where the consumer app's `@` →\n // `./app` alias is already registered.\n ...(hasDep(\"@agent-native/scheduling\", cwd)\n ? [/^@agent-native\\/scheduling(\\/.*)?$/]\n : []),\n ...workspaceCoreNoExternal,\n ],\n external: [\n \"react\",\n \"react-dom\",\n \"react-dom/server\",\n \"react-router\",\n \"react-router/dom\",\n \"react-router-dom\",\n ],\n },\n plugins: [\n // Stub packages from `options.ssrStubs` in the SSR bundle so they\n // don't bloat the edge worker. Opt-in per template — the framework\n // hardcodes nothing (e.g. docs sites legitimately import `shiki` on\n // the server, so we can't blanket-stub it here).\n ...(() => {\n const p = ssrStubPlugin(options.ssrStubs ?? []);\n return p ? [p] : [];\n })(),\n ...(options.plugins ?? []),\n actionTypesPlugin(),\n agentsBundlePlugin(),\n autoReloadOnOptimizeDep(),\n fullReloadOnOptimizeDep504(),\n embedDevFrameHeaders(),\n baseRedirectGuard(),\n portExposer(),\n silenceConnectionResets(),\n rolldownInputFix(),\n // Nitro Vite plugin for dev-mode API route serving and HMR.\n // Disabled during build — React Router's build handles production.\n ...(process.argv.includes(\"build\")\n ? []\n : [\n nitroVitePlugin({\n serverDir: \"./server\",\n ...(options.nitro ?? {}),\n routeRules: {\n ...mcpEmbedStaticAssetRouteRules(appBasePath),\n ...((options.nitro as { routeRules?: Record<string, any> })\n ?.routeRules ?? {}),\n },\n } as any),\n ]),\n reactPluginInstance,\n tailwindPluginInstance,\n ].filter(Boolean),\n optimizeDeps: {\n include: [\n ...getDefaultOptimizeDeps(cwd),\n ...(hasDep(\"@agent-native/pinpoint\", cwd)\n ? [\"@agent-native/pinpoint/react\"]\n : []),\n ...(options.optimizeDeps?.include ?? []),\n ],\n // In monorepo mode: explicitly exclude @agent-native/core subpaths so\n // Vite never prebundles them from dist/. The source alias above\n // (`getCoreSourceAliases`) resolves every import to src/ on every\n // request, so HMR picks up new exports immediately. Without exclude,\n // the prebundle is built from dist/ once at startup and silently\n // serves stale code even after the source / dist is updated.\n exclude: [\n ...(findCoreSrcDir(cwd) !== null ? CORE_CLIENT_SUBPATHS : []),\n ...(options.optimizeDeps?.exclude ?? []),\n ],\n },\n resolve: {\n // Dedupe all client-side packages that core shares with the consuming\n // app. In pnpm monorepos, core's devDependencies can install separate\n // copies (linked to different React versions). Without deduping, each\n // copy creates its own React context — QueryClientProvider, RouterProvider,\n // Radix, etc. — causing \"No provider\" crashes at runtime.\n dedupe: getClientDedupe(cwd),\n alias: [\n // In monorepo dev: resolve @agent-native/core to source for HMR.\n // Uses regex with $ anchor for exact matching to prevent\n // @agent-native/core from prefix-matching @agent-native/core/client.\n ...getCoreSourceAliases(cwd),\n // Standard path aliases (prefix matching is fine here)\n { find: \"@\", replacement: path.resolve(cwd, \"./app\") },\n { find: \"@shared\", replacement: path.resolve(cwd, \"./shared\") },\n ...Object.entries(options.aliases ?? {}).map(([find, replacement]) => ({\n find,\n replacement,\n })),\n ],\n },\n };\n}\n"]}
@@ -199,13 +199,23 @@ export default defineAction({
199
199
  This advertises the MCP Apps extension (`io.modelcontextprotocol/ui`), exposes the HTML via MCP resources/templates, and includes standard MCP Apps plus ChatGPT Apps SDK widget metadata for compatible hosts. Keep `link` as the fallback for CLI and non-UI MCP clients; see [External Agents](/docs/external-agents#mcp-apps).
200
200
 
201
201
  The helper launches the action's `link` target through `/_agent-native/embed/start` with a short-lived browser session, so routes such as full dashboards, filtered inboxes, drafts, and extension pages can reuse the app's React components directly.
202
+ ChatGPT uses a controlled route iframe to avoid web-sandbox auto-height
203
+ feedback loops. Claude web uses a single-frame mount path automatically: the
204
+ launcher fetches the signed route HTML inside Claude's MCP resource frame,
205
+ mounts the real app document there, and rewrites app-origin network calls back
206
+ to the original app with the embed token.
202
207
 
203
208
  Embedded routes can use the exported client helpers for the MCP App host
204
- bridge. Under the hood, routes receive `agentNative.mcpHostContext` and may
205
- post `agentNative.mcpHost.updateModelContext`,
206
- `agentNative.mcpHost.openLink`, or
207
- `agentNative.mcpHost.requestDisplayMode`; the wrapper replies with
208
- `agentNative.mcpHost.response`.
209
+ bridge. Direct and Claude-mounted route embeds post standard `ui/*` JSON-RPC
210
+ messages to the host, while the ChatGPT controlled-frame path and explicit
211
+ nested-iframe diagnostic path proxy `agentNative.mcpHost.*` messages through
212
+ the launch wrapper.
213
+ When a submitted app prompt should continue the host chat, call
214
+ `sendToAgentChat()` from the embedded route; it sends hidden model context and
215
+ then posts a visible user message through the host bridge where supported.
216
+ Design those routes with their own scrolling, because the MCP resource reports
217
+ a bounded inline height rather than asking the host to size itself to the full
218
+ app document.
209
219
 
210
220
  ## Standard actions {#standard-actions}
211
221
 
@@ -75,8 +75,8 @@ Send a message to the agent chat via postMessage. Used to delegate AI tasks from
75
75
 
76
76
  When the app route is running inside an MCP App embed created with `embedApp()`,
77
77
  auto-submitted messages (`submit` omitted or `true`) are forwarded to the MCP
78
- App wrapper, which asks the containing host to add hidden context and send the
79
- visible user turn. `context` is sent as model context before the visible
78
+ App host bridge, which asks the containing host to add hidden context and send
79
+ the visible user turn. `context` is sent as model context before the visible
80
80
  message, so it stays model-visible without being posted as user-facing chat.
81
81
  `submit: false` keeps the local prefill/review behavior because MCP Apps do not
82
82
  define a standard draft-prefill API.
@@ -116,7 +116,10 @@ Routes embedded by `embedApp()` should be URL-first: load the current artifact
116
116
  from path/query params, render the real React route or a focused shared
117
117
  component, and use host bridge messages only for host-owned behavior.
118
118
 
119
- The wire contract is:
119
+ Default direct route embeds use the standard MCP Apps `ui/*` JSON-RPC bridge.
120
+ The exported helpers below send `ui/update-model-context`, `ui/open-link`, and
121
+ `ui/request-display-mode` directly to the host. The explicit nested diagnostic
122
+ mode still uses the wrapper relay:
120
123
 
121
124
  | Direction | Message type | Purpose |
122
125
  | --------------- | ---------------------------------------- | ------------------------------------------------- |
@@ -219,42 +219,55 @@ Claude Code and other CLI-first clients still receive the same resources and met
219
219
 
220
220
  MCP App embeds are route embeds, not separate mini-products. `embedApp()`
221
221
  starts from the action's `link` target, creates a short-lived embed session,
222
- and loads that URL in an iframe. Design embedded routes so a reload with the
223
- same URL reconstructs the same view.
224
-
225
- ChatGPT gets a dedicated compatibility path through `window.openai`: the
226
- wrapper reads `toolInput`, `toolOutput`, and `toolResponseMetadata` directly,
227
- then calls `create_embed_session` via `window.openai.callTool(...)`. Other MCP
228
- Apps hosts use the standard `ui/*` bridge. Keep the result shape identical for
229
- both paths: return a focused `link` and concise structured content.
230
-
231
- Some hosts support MCP Apps but still block nested iframes for a returned UI
232
- resource. `embedApp()` detects that case with a route-ready handshake and
233
- replaces the broken frame with an open-app fallback: the user can retry inline,
234
- open a freshly minted embed session through the host, or use the visible route
235
- URL. Keep the action's `link` target useful on its own because it is still the
236
- universal escape hatch.
237
-
238
- Do not try to make Claude render full app routes inline by redirecting the MCP
239
- App resource document to `/_agent-native/embed/start`. Claude first renders the
240
- `ui://` resource HTML on a `*.claudemcpcontent.com` sandbox origin; our app URL
241
- is only reached later by wrapper code. The `/embed/start` 302 works for the
242
- nested app iframe and for `ui/open-link` external opens, but it is not a
243
- portable substitute for the MCP resource document itself. True nested-frame-free
244
- Claude support would need a separate resource-shell mode that bootstraps the
245
- route inside the returned MCP App HTML document, with explicit asset/API CSP,
246
- CORS, and embed-session auth.
222
+ and launches that signed app route. Standard MCP Apps hosts can navigate the
223
+ MCP App frame itself. ChatGPT gets a controlled route iframe because its web
224
+ sandbox can otherwise auto-size a full app route into a feedback loop. Claude
225
+ web currently proxies MCP App content through `claudemcpcontent.com`; direct
226
+ route navigation can fetch the app HTML there without reliably running the
227
+ framework bootstrap, and a second nested iframe is easy for the host to block.
228
+ For Claude, the launcher fetches the signed app HTML and mounts that document
229
+ into the existing MCP resource frame, then rewrites app-origin
230
+ fetch/XHR/EventSource calls back to the app with the embed token. The app still
231
+ renders the normal route and React components. Design embedded routes so a
232
+ reload with the same signed URL reconstructs the same view.
233
+
234
+ ChatGPT gets a dedicated compatibility path through `window.openai`: the launch
235
+ document reads `toolInput`, `toolOutput`, and `toolResponseMetadata` directly,
236
+ then calls `create_embed_session` via `window.openai.callTool(...)`. Standard
237
+ MCP Apps hosts use the `ui/*` JSON-RPC bridge. Direct and Claude-mounted routes
238
+ can call `ui/update-model-context`, `ui/message`, `ui/open-link`, and
239
+ `ui/request-display-mode` through the host bridge helpers. When the ChatGPT or
240
+ explicit diagnostic iframe path is used, the wrapper relays the same host
241
+ actions over `agentNative.mcpHost.*` postMessage requests. Keep the result
242
+ shape identical for both paths: return a focused `link` and concise structured
243
+ content.
244
+
245
+ The resource shell owns the outer host size. Keep embedded app routes
246
+ internally scrollable and let the launcher report a bounded intrinsic height
247
+ rather than the full document height; otherwise host auto-resize can turn a
248
+ normal app page into a very tall chat artifact. A changed shell only affects
249
+ new MCP App resources and new tool calls. Old ChatGPT/Claude conversation
250
+ frames can keep the previous resource behavior, so verify sizing with a fresh
251
+ inline render before judging a fix.
252
+
253
+ You can force the nested diagnostic iframe with `embedMode: "iframe"`,
254
+ `renderMode: "iframe"`, `nested: true`, or `frame: "iframe"` when debugging
255
+ host behavior. If the iframe is blocked, `embedApp()` replaces it with an
256
+ open-app fallback: the user can retry inline, open a freshly minted embed
257
+ session through the host, or use the visible route URL. Keep the action's
258
+ `link` target useful on its own because it is still the universal escape hatch.
247
259
 
248
260
  The host bridge is deliberately small:
249
261
 
250
- | Direction | Message type | Use it for |
251
- | --------------- | ---------------------------------------- | ---------------------------------------- |
252
- | wrapper route | `agentNative.mcpHostContext` | Theme, locale, host platform, dimensions |
253
- | route wrapper | `agentNative.embeddedAppReady` | Confirm the nested route iframe loaded |
254
- | route wrapper | `agentNative.mcpHost.updateModelContext` | Hidden context for the host model |
255
- | route wrapper | `agentNative.mcpHost.openLink` | Open an external or app URL via the host |
256
- | route wrapper | `agentNative.mcpHost.requestDisplayMode` | Request `inline`, `fullscreen`, or `pip` |
257
- | wrapper route | `agentNative.mcpHost.response` | Correlate async request results |
262
+ | Mode | Message type | Use it for |
263
+ | ------------------------ | ------------------------------------- | ---------------------------------------- |
264
+ | direct / Claude | `ui/update-model-context` | Hidden context for the host model |
265
+ | direct / Claude | `ui/message` | Post a visible user turn into the host |
266
+ | direct / Claude | `ui/open-link` | Open an external or app URL via the host |
267
+ | direct / Claude | `ui/request-display-mode` | Request `inline`, `fullscreen`, or `pip` |
268
+ | ChatGPT / iframe wrapper | `agentNative.mcpHostContext` | Theme, locale, host platform, dimensions |
269
+ | ChatGPT / iframe wrapper | `agentNative.embeddedAppReady` | Confirm the route iframe loaded |
270
+ | ChatGPT / iframe wrapper | `agentNative.mcpHost.*` / `.response` | Wrapper relay for host requests |
258
271
 
259
272
  Embedded routes can use `updateMcpAppModelContext()`,
260
273
  `openMcpAppHostLink()`, `requestMcpAppDisplayMode()`,
@@ -283,7 +296,7 @@ On top of the per-action tools the MCP server exposes a stable verb set, so an e
283
296
 
284
297
  For OAuth callers that request `mcp:apps`, the server intentionally advertises a compact `tools/list` catalog so app hosts do not ingest every internal action schema. The model sees app-facing builtins (`list_apps`, `open_app`, app-only `create_embed_session`) and actions with `mcpApp`. Stdio/static-token developer clients still get the full connected action surface, and `publicAgent.expose` remains the opt-in for safe read/ingest tools outside the compact app catalog. If a UI-capable host should be able to call a new action from an MCP App conversation, mark it with `mcpApp`; use `publicAgent` for non-UI read/ingest handoff tools.
285
298
 
286
- For fast ChatGPT/Claude handoffs, the ideal path is direct: call the action that creates or opens the artifact, then let the MCP App widget launch the iframe. A Mail request should call `manage_draft` and render the real compose route. A dashboard request should call `open_app({ path, embed: true })` or a dashboard action with `mcpApp` and render the full Analytics route. Calendar, Forms, Content, Slides, Design, and Clips should follow the same pattern with their draft/create/search actions. `list_apps` is useful when the model must choose among granted apps; broad `resources/list`, full-catalog discovery, or `ask_app` delegation should not be the normal route for an obvious UI handoff.
299
+ For fast ChatGPT/Claude handoffs, the ideal path is direct: call the action that creates or opens the artifact, then let the MCP App launch the route. A Mail request should call `manage_draft` and render the real compose route. A dashboard request should call `open_app({ path, embed: true })` or a dashboard action with `mcpApp` and render the full Analytics route. Calendar, Forms, Content, Slides, Design, and Clips should follow the same pattern with their draft/create/search actions. `list_apps` is useful when the model must choose among granted apps; broad `resources/list`, full-catalog discovery, or `ask_app` delegation should not be the normal route for an obvious UI handoff.
287
300
 
288
301
  ### Per-app tour {#tour}
289
302
 
@@ -356,7 +369,6 @@ export default defineAction({
356
369
  description: "Open the generated draft in the real Mail compose UI.",
357
370
  iframeTitle: "Agent-Native Mail",
358
371
  openLabel: "Open in Mail",
359
- frameDomains: ["https:", "http://localhost:*", "http://127.0.0.1:*"],
360
372
  }),
361
373
  },
362
374
  });
@@ -364,13 +376,18 @@ export default defineAction({
364
376
 
365
377
  The MCP server advertises extension `io.modelcontextprotocol/ui`, adds `_meta.ui.resourceUri` plus `_meta["ui/resourceUri"]` to `tools/list`, and also emits ChatGPT Apps SDK compatibility metadata (`openai/outputTemplate`, widget CSP/description/accessibility). It exposes the HTML through `resources/list`, `resources/templates/list`, and `resources/read` using MIME `text/html;profile=mcp-app`. The stdio proxy forwards those resource handlers from the live app, so desktop and CLI clients see the same resources as HTTP clients.
366
378
 
367
- Keep the existing `link` builder even when adding `mcpApp`. CLI-only clients, older hosts, and any host that does not render MCP Apps will ignore the UI metadata and still need the `"Open in … →"` link. `embedApp()` uses that link as its launch target, calls the app-only `create_embed_session` helper, exchanges a one-time SQL ticket at `/_agent-native/embed/start`, and loads the target route in an iframe with a short-lived browser session plus a bearer fallback for same-origin fetches. `open_app({ app, path, embed: true })` is the generic escape hatch for routes such as full dashboards, filtered inboxes, calendar draft views, analyses, and extension pages, and should be used liberally when the full app is the clearest review/edit surface.
379
+ Keep the existing `link` builder even when adding `mcpApp`. CLI-only clients, older hosts, and any host that does not render MCP Apps will ignore the UI metadata and still need the `"Open in … →"` link. `embedApp()` uses that link as its launch target, calls the app-only `create_embed_session` helper, exchanges a one-time SQL ticket at `/_agent-native/embed/start`, and navigates the MCP App frame to the target route with a short-lived browser session plus a bearer fallback for same-origin fetches. `open_app({ app, path, embed: true })` is the generic escape hatch for routes such as full dashboards, filtered inboxes, calendar draft views, analyses, and extension pages, and should be used liberally when the full app is the clearest review/edit surface.
368
380
 
369
- Inside those `embedApp()` full-app iframes, `sendToAgentChat()` is host-aware:
370
- auto-submitted prompts are relayed to the wrapper, which uses the host's model
371
- context and message APIs for hidden context plus the visible user turn. Hosts
372
- without MCP Apps messaging support simply ignore the bridge, and
373
- `submit: false` remains a local review/prefill path.
381
+ `embedApp()` includes the MCP request origin in the resource CSP so the launcher
382
+ can fetch and, when explicitly requested, frame the signed first-party app
383
+ route. Only pass additional `frameDomains` for a custom MCP App that truly
384
+ embeds a third-party player.
385
+
386
+ Inside those `embedApp()` routes, `sendToAgentChat()` is embed-aware.
387
+ Auto-submitted prompts relay to the MCP host as `ui/update-model-context` plus
388
+ `ui/message`, so a button in the embedded app can intentionally continue the
389
+ Claude/ChatGPT conversation from the selected app state. `submit: false`
390
+ remains local prefill/review behavior.
374
391
 
375
392
  ### The `link` contract {#link-contract}
376
393
 
@@ -515,6 +532,9 @@ The fallback hosted `connect` flow never copies the deployment's shared secret.
515
532
  - Test MCP Apps with the lightweight fixtures around `embedApp()` and
516
533
  `McpAppRenderer`; they cover CSP, host context, app launch, and bridge
517
534
  message behavior without needing a real external host.
535
+ - When validating ChatGPT or Claude web, trigger a fresh tool call after shell
536
+ changes and measure the visible iframe. Previously rendered frames in the
537
+ same conversation may still show cached height or launch behavior.
518
538
 
519
539
  **Don't**
520
540