@agent-native/core 0.22.44 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. package/dist/a2a/artifact-response.js +1 -1
  2. package/dist/a2a/artifact-response.js.map +1 -1
  3. package/dist/agent/production-agent.d.ts.map +1 -1
  4. package/dist/agent/production-agent.js +12 -4
  5. package/dist/agent/production-agent.js.map +1 -1
  6. package/dist/cli/app-skill.d.ts +139 -0
  7. package/dist/cli/app-skill.d.ts.map +1 -0
  8. package/dist/cli/app-skill.js +960 -0
  9. package/dist/cli/app-skill.js.map +1 -0
  10. package/dist/cli/create.d.ts.map +1 -1
  11. package/dist/cli/create.js +13 -4
  12. package/dist/cli/create.js.map +1 -1
  13. package/dist/cli/index.js +24 -0
  14. package/dist/cli/index.js.map +1 -1
  15. package/dist/cli/skills.d.ts +39 -0
  16. package/dist/cli/skills.d.ts.map +1 -0
  17. package/dist/cli/skills.js +363 -0
  18. package/dist/cli/skills.js.map +1 -0
  19. package/dist/cli/templates-meta.d.ts.map +1 -1
  20. package/dist/cli/templates-meta.js +9 -6
  21. package/dist/cli/templates-meta.js.map +1 -1
  22. package/dist/cli/workspace-dev.d.ts.map +1 -1
  23. package/dist/cli/workspace-dev.js +2 -0
  24. package/dist/cli/workspace-dev.js.map +1 -1
  25. package/dist/client/AgentPanel.d.ts +2 -0
  26. package/dist/client/AgentPanel.d.ts.map +1 -1
  27. package/dist/client/AgentPanel.js +2 -2
  28. package/dist/client/AgentPanel.js.map +1 -1
  29. package/dist/client/AssistantChat.d.ts +9 -0
  30. package/dist/client/AssistantChat.d.ts.map +1 -1
  31. package/dist/client/AssistantChat.js +15 -7
  32. package/dist/client/AssistantChat.js.map +1 -1
  33. package/dist/client/MultiTabAssistantChat.d.ts.map +1 -1
  34. package/dist/client/MultiTabAssistantChat.js +15 -0
  35. package/dist/client/MultiTabAssistantChat.js.map +1 -1
  36. package/dist/client/index.d.ts +1 -1
  37. package/dist/client/index.d.ts.map +1 -1
  38. package/dist/client/index.js.map +1 -1
  39. package/dist/client/use-chat-threads.d.ts +5 -1
  40. package/dist/client/use-chat-threads.d.ts.map +1 -1
  41. package/dist/client/use-chat-threads.js +14 -3
  42. package/dist/client/use-chat-threads.js.map +1 -1
  43. package/dist/collab/client.d.ts.map +1 -1
  44. package/dist/collab/client.js +20 -1
  45. package/dist/collab/client.js.map +1 -1
  46. package/dist/collab/routes.d.ts.map +1 -1
  47. package/dist/collab/routes.js +16 -2
  48. package/dist/collab/routes.js.map +1 -1
  49. package/dist/collab/storage.d.ts +8 -0
  50. package/dist/collab/storage.d.ts.map +1 -1
  51. package/dist/collab/storage.js +55 -7
  52. package/dist/collab/storage.js.map +1 -1
  53. package/dist/collab/ydoc-manager.d.ts.map +1 -1
  54. package/dist/collab/ydoc-manager.js +121 -69
  55. package/dist/collab/ydoc-manager.js.map +1 -1
  56. package/dist/deploy/workspace-deploy.js +6 -0
  57. package/dist/deploy/workspace-deploy.js.map +1 -1
  58. package/dist/mcp-client/index.d.ts +1 -1
  59. package/dist/mcp-client/index.d.ts.map +1 -1
  60. package/dist/mcp-client/index.js +1 -1
  61. package/dist/mcp-client/index.js.map +1 -1
  62. package/dist/mcp-client/routes.d.ts +1 -0
  63. package/dist/mcp-client/routes.d.ts.map +1 -1
  64. package/dist/mcp-client/routes.js +52 -0
  65. package/dist/mcp-client/routes.js.map +1 -1
  66. package/dist/mcp-client/workspace-servers.d.ts +15 -0
  67. package/dist/mcp-client/workspace-servers.d.ts.map +1 -0
  68. package/dist/mcp-client/workspace-servers.js +297 -0
  69. package/dist/mcp-client/workspace-servers.js.map +1 -0
  70. package/dist/resources/handlers.d.ts.map +1 -1
  71. package/dist/resources/handlers.js +38 -25
  72. package/dist/resources/handlers.js.map +1 -1
  73. package/dist/resources/store.d.ts +11 -3
  74. package/dist/resources/store.d.ts.map +1 -1
  75. package/dist/resources/store.js +220 -9
  76. package/dist/resources/store.js.map +1 -1
  77. package/dist/scripts/call-agent.js +1 -1
  78. package/dist/scripts/call-agent.js.map +1 -1
  79. package/dist/server/agent-chat-plugin.d.ts.map +1 -1
  80. package/dist/server/agent-chat-plugin.js +21 -6
  81. package/dist/server/agent-chat-plugin.js.map +1 -1
  82. package/dist/server/agent-discovery.d.ts.map +1 -1
  83. package/dist/server/agent-discovery.js +34 -9
  84. package/dist/server/agent-discovery.js.map +1 -1
  85. package/dist/server/auth-marketing.d.ts.map +1 -1
  86. package/dist/server/auth-marketing.js +8 -5
  87. package/dist/server/auth-marketing.js.map +1 -1
  88. package/dist/templates/default/AGENTS.md +12 -4
  89. package/dist/templates/default/DEVELOPING.md +7 -5
  90. package/dist/templates/workspace-core/AGENTS.md +7 -0
  91. package/dist/templates/workspace-root/AGENTS.md +6 -0
  92. package/docs/content/creating-templates.md +14 -9
  93. package/docs/content/database.md +44 -17
  94. package/docs/content/deployment.md +15 -7
  95. package/docs/content/dispatch.md +7 -1
  96. package/docs/content/embedding-sdk.md +79 -0
  97. package/docs/content/key-concepts.md +15 -17
  98. package/docs/content/mcp-clients.md +30 -0
  99. package/docs/content/multi-app-workspace.md +3 -2
  100. package/docs/content/multi-tenancy.md +4 -4
  101. package/docs/content/server.md +10 -7
  102. package/docs/content/skills-guide.md +75 -0
  103. package/docs/content/template-analytics.md +1 -1
  104. package/docs/content/template-assets.md +130 -0
  105. package/docs/content/template-dispatch.md +3 -2
  106. package/docs/content/template-slides.md +2 -2
  107. package/docs/content/workspace-management.md +2 -2
  108. package/docs/content/workspace.md +11 -9
  109. package/package.json +1 -1
  110. package/src/templates/default/AGENTS.md +12 -4
  111. package/src/templates/default/DEVELOPING.md +7 -5
  112. package/src/templates/workspace-core/AGENTS.md +7 -0
  113. package/src/templates/workspace-root/AGENTS.md +6 -0
  114. package/docs/content/template-images.md +0 -55
@@ -1 +1 @@
1
- {"version":3,"file":"agent-discovery.d.ts","sourceRoot":"","sources":["../../src/server/agent-discovery.ts"],"names":[],"mappings":"AAKA,OAAO,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AC,EAAE,MAAM,GACjB,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC,CAItC;AAyOD;;;;;;GAMG;AACH,eAAO,MAAM,0BAA0B,EAAE,eAAe,EAOnD,CAAC"}
@@ -19,6 +19,15 @@ const BUILTIN_AGENTS = TEMPLATES.filter((template) => (!template.hidden || templ
19
19
  color: template.color,
20
20
  }));
21
21
  const HIDDEN_FIRST_PARTY_AGENT_IDS = new Set(TEMPLATES.filter((template) => template.hidden && !template.defaultAgent && template.prodUrl).map((template) => template.name));
22
+ function normalizeAgentId(id) {
23
+ const normalized = id.trim().toLowerCase();
24
+ if (normalized === "image" ||
25
+ normalized === "images" ||
26
+ normalized === "asset") {
27
+ return "assets";
28
+ }
29
+ return normalized;
30
+ }
22
31
  const WORKSPACE_APPS_ENV_KEY = "AGENT_NATIVE_WORKSPACE_APPS_JSON";
23
32
  const WORKSPACE_APPS_MANIFEST_FILE = "workspace-apps.json";
24
33
  export const WORKSPACE_APP_METADATA_SETTINGS_KEY = "workspace-app-metadata";
@@ -159,8 +168,8 @@ export function shouldIncludeRemoteAgentManifest(manifest, selfAppId) {
159
168
  const id = manifest.id?.trim();
160
169
  if (!id)
161
170
  return false;
162
- const normalizedId = id.toLowerCase();
163
- const normalizedSelfAppId = selfAppId?.trim().toLowerCase();
171
+ const normalizedId = normalizeAgentId(id);
172
+ const normalizedSelfAppId = selfAppId ? normalizeAgentId(selfAppId) : "";
164
173
  if (normalizedSelfAppId && normalizedId === normalizedSelfAppId) {
165
174
  return false;
166
175
  }
@@ -170,7 +179,8 @@ export function shouldIncludeRemoteAgentManifest(manifest, selfAppId) {
170
179
  * Get built-in agents (static, no DB). Used as fallback and for seeding.
171
180
  */
172
181
  export function getBuiltinAgents(selfAppId) {
173
- return BUILTIN_AGENTS.filter((app) => app.id !== selfAppId && app.url).map((app) => ({
182
+ const normalizedSelfAppId = selfAppId ? normalizeAgentId(selfAppId) : "";
183
+ return BUILTIN_AGENTS.filter((app) => app.id !== normalizedSelfAppId && app.url).map((app) => ({
174
184
  id: app.id,
175
185
  name: app.name,
176
186
  description: app.description,
@@ -207,6 +217,7 @@ export async function discoverAgents(selfAppId) {
207
217
  const manifest = parseRemoteAgentManifest(full.content, r.path);
208
218
  if (!manifest || !shouldIncludeRemoteAgentManifest(manifest, selfAppId))
209
219
  continue;
220
+ const manifestId = normalizeAgentId(manifest.id);
210
221
  // If the resource override carries a localhost URL but we're running
211
222
  // in production (e.g. a stale dev-time seed got promoted to the prod
212
223
  // DB), fall back to the matching built-in's prod URL instead of
@@ -220,16 +231,30 @@ export async function discoverAgents(selfAppId) {
220
231
  if (isProduction &&
221
232
  typeof url === "string" &&
222
233
  /^https?:\/\/(localhost|127\.0\.0\.1|0\.0\.0\.0)(:|\/|$)/.test(url)) {
223
- const builtin = agentsById.get(manifest.id);
234
+ const builtin = agentsById.get(manifestId);
224
235
  if (builtin?.url)
225
236
  url = builtin.url;
226
237
  }
227
- agentsById.set(manifest.id, {
228
- id: manifest.id,
229
- name: manifest.name,
238
+ const builtin = agentsById.get(manifestId);
239
+ const isLegacyAssetsManifest = manifest.id.trim().toLowerCase() !== manifestId;
240
+ if (isLegacyAssetsManifest && builtin?.url) {
241
+ try {
242
+ if (new URL(url).hostname === "images.agent-native.com") {
243
+ url = builtin.url;
244
+ }
245
+ }
246
+ catch {
247
+ url = builtin.url;
248
+ }
249
+ }
250
+ agentsById.set(manifestId, {
251
+ id: manifestId,
252
+ name: isLegacyAssetsManifest && builtin?.name
253
+ ? builtin.name
254
+ : manifest.name,
230
255
  description: manifest.description || "",
231
256
  url,
232
- color: manifest.color || "#6B7280",
257
+ color: manifest.color || builtin?.color || "#6B7280",
233
258
  });
234
259
  }
235
260
  catch {
@@ -251,7 +276,7 @@ export async function discoverAgents(selfAppId) {
251
276
  * Look up a single agent by ID or name (case-insensitive).
252
277
  */
253
278
  export async function findAgent(idOrName, selfAppId) {
254
- const lower = idOrName.toLowerCase();
279
+ const lower = normalizeAgentId(idOrName);
255
280
  const agents = await discoverAgents(selfAppId);
256
281
  return agents.find((a) => a.id === lower || a.name.toLowerCase() === lower);
257
282
  }
@@ -1 +1 @@
1
- {"version":3,"file":"agent-discovery.js","sourceRoot":"","sources":["../../src/server/agent-discovery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EACL,8BAA8B,EAC9B,6BAA6B,EAC7B,6BAA6B,EAC7B,mCAAmC,EACnC,sCAAsC,GAEvC,MAAM,qCAAqC,CAAC;AAiC7C;;;;GAIG;AACH,MAAM,cAAc,GAAiB,SAAS,CAAC,MAAM,CACnD,CAAC,QAAQ,EAAE,EAAE,CACX,CAAC,CAAC,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,OAAO,CACpE,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;IACnB,EAAE,EAAE,QAAQ,CAAC,IAAI;IACjB,IAAI,EAAE,QAAQ,CAAC,KAAK;IACpB,WAAW,EAAE,QAAQ,CAAC,WAAW,IAAI,QAAQ,CAAC,IAAI;IAClD,GAAG,EAAE,QAAQ,CAAC,OAAQ;IACtB,MAAM,EAAE,oBAAoB,QAAQ,CAAC,OAAO,EAAE;IAC9C,OAAO,EAAE,QAAQ,CAAC,OAAO;IACzB,KAAK,EAAE,QAAQ,CAAC,KAAK;CACtB,CAAC,CAAC,CAAC;AAEJ,MAAM,4BAA4B,GAAG,IAAI,GAAG,CAC1C,SAAS,CAAC,MAAM,CACd,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,MAAM,IAAI,CAAC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AAE,CAAC,KAAK,CAAC,EAAE,KAAK,YAAY,CAAC,EAAE,CACxC,CAAC;QACF,OAAO;YACL,EAAE,EAAE,YAAY,CAAC,EAAE;YACnB,IAAI,EAAE,YAAY,CAAC,IAAI;YACvB,WAAW,EACT,YAAY,CAAC,WAAW;gBACxB,OAAO,EAAE,WAAW;gBACpB,4BAA4B,YAAY,CAAC,IAAI,EAAE;YACjD,GAAG;YACH,KAAK,EAAE,OAAO,EAAE,KAAK,IAAI,SAAS;SACT,CAAC;IAC9B,CAAC,CAAC;SACD,MAAM,CAAC,CAAC,KAAK,EAA4B,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;AAC1D,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,0BAA0B,GACrC,cAAc,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IACpD,EAAE,EAAE,GAAG,CAAC,EAAE;IACV,IAAI,EAAE,GAAG,CAAC,IAAI;IACd,WAAW,EAAE,GAAG,CAAC,WAAW;IAC5B,GAAG,EAAE,GAAG,CAAC,GAAG,EAAE,cAAc;IAC5B,KAAK,EAAE,GAAG,CAAC,KAAK;CACjB,CAAC,CAAC,CAAC","sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { TEMPLATES } from \"../cli/templates-meta.js\";\nimport { getRequestOrgId, getRequestUserEmail } from \"./request-context.js\";\nimport {\n DEFAULT_WORKSPACE_APP_AUDIENCE,\n normalizeWorkspaceAppAudience,\n normalizeWorkspaceAppPathList,\n workspaceAppAudienceFromPackageJson,\n workspaceAppRouteAccessFromPackageJson,\n type WorkspaceAppAudience,\n} from \"../shared/workspace-app-audience.js\";\n\nexport interface DiscoveredAgent {\n id: string;\n name: string;\n description: string;\n url: string;\n color: string;\n}\n\nexport interface WorkspaceAppMetadataOverride {\n name?: string;\n description?: string;\n generated?: boolean;\n sourcePrompt?: string;\n updatedAt?: string;\n updatedBy?: string;\n}\n\nexport interface WorkspaceAppMetadataSettings {\n apps: Record<string, WorkspaceAppMetadataOverride>;\n}\n\ninterface AgentEntry {\n id: string;\n name: string;\n description: string;\n url: string;\n devUrl?: string;\n devPort: number;\n color: string;\n}\n\n/**\n * Built-in agent registry. Derive this from the published CLI metadata so\n * connected-agent discovery stays aligned with first-party template metadata\n * without depending on @agent-native/shared-app-config at runtime.\n */\nconst BUILTIN_AGENTS: AgentEntry[] = TEMPLATES.filter(\n (template) =>\n (!template.hidden || template.defaultAgent) && !!template.prodUrl,\n).map((template) => ({\n id: template.name,\n name: template.label,\n description: template.description ?? template.hint,\n url: template.prodUrl!,\n devUrl: `http://localhost:${template.devPort}`,\n devPort: template.devPort,\n color: template.color,\n}));\n\nconst HIDDEN_FIRST_PARTY_AGENT_IDS = new Set(\n TEMPLATES.filter(\n (template) => template.hidden && !template.defaultAgent && template.prodUrl,\n ).map((template) => template.name),\n);\n\nconst WORKSPACE_APPS_ENV_KEY = \"AGENT_NATIVE_WORKSPACE_APPS_JSON\";\nconst WORKSPACE_APPS_MANIFEST_FILE = \"workspace-apps.json\";\nexport const WORKSPACE_APP_METADATA_SETTINGS_KEY = \"workspace-app-metadata\";\n\nexport interface WorkspaceAppManifestEntry {\n id: string;\n name: string;\n description: string;\n path: string;\n url?: string | null;\n isDispatch?: boolean;\n audience?: WorkspaceAppAudience;\n publicPaths?: string[];\n protectedPaths?: string[];\n}\n\nexport function workspaceAppMetadataSettingsKey(input?: {\n orgId?: string | null;\n userEmail?: string | null;\n}): string | null {\n const orgId = input?.orgId ?? getRequestOrgId() ?? null;\n if (orgId) return `${WORKSPACE_APP_METADATA_SETTINGS_KEY}:org:${orgId}`;\n\n const userEmail = input?.userEmail ?? getRequestUserEmail() ?? null;\n if (userEmail)\n return `${WORKSPACE_APP_METADATA_SETTINGS_KEY}:user:${userEmail}`;\n\n return null;\n}\n\nfunction cleanOptionalText(value: unknown): string | undefined {\n return typeof value === \"string\" && value.trim() ? value.trim() : undefined;\n}\n\nexport function parseWorkspaceAppMetadataSettings(\n raw: unknown,\n): WorkspaceAppMetadataSettings {\n const record =\n raw && typeof raw === \"object\" && !Array.isArray(raw)\n ? (raw as Record<string, unknown>)\n : {};\n const rawApps =\n record.apps &&\n typeof record.apps === \"object\" &&\n !Array.isArray(record.apps)\n ? (record.apps as Record<string, unknown>)\n : {};\n const apps: Record<string, WorkspaceAppMetadataOverride> = {};\n\n for (const [id, value] of Object.entries(rawApps)) {\n if (!id.trim() || !value || typeof value !== \"object\") continue;\n const item = value as Record<string, unknown>;\n const override: WorkspaceAppMetadataOverride = {};\n const name = cleanOptionalText(item.name);\n const description = cleanOptionalText(item.description);\n const sourcePrompt = cleanOptionalText(item.sourcePrompt);\n const updatedAt = cleanOptionalText(item.updatedAt);\n const updatedBy = cleanOptionalText(item.updatedBy);\n\n if (name) override.name = name;\n if (description) override.description = description;\n if (item.generated === true) override.generated = true;\n if (sourcePrompt) override.sourcePrompt = sourcePrompt;\n if (updatedAt) override.updatedAt = updatedAt;\n if (updatedBy) override.updatedBy = updatedBy;\n\n if (Object.keys(override).length > 0) apps[id.trim()] = override;\n }\n\n return { apps };\n}\n\nexport async function readWorkspaceAppMetadataSettings(): Promise<WorkspaceAppMetadataSettings> {\n const key = workspaceAppMetadataSettingsKey();\n if (!key) return { apps: {} };\n\n try {\n const { getSetting } = await import(\"../settings/index.js\");\n return parseWorkspaceAppMetadataSettings(await getSetting(key));\n } catch {\n return { apps: {} };\n }\n}\n\nexport async function writeWorkspaceAppMetadataOverride(input: {\n appId: string;\n name?: string | null;\n description?: string | null;\n generated?: boolean;\n sourcePrompt?: string | null;\n updatedBy?: string | null;\n}): Promise<WorkspaceAppMetadataSettings> {\n const key = workspaceAppMetadataSettingsKey();\n if (!key) throw new Error(\"no authenticated user\");\n\n const appId = input.appId.trim();\n if (!appId) throw new Error(\"appId is required\");\n\n const { getSetting, putSetting } = await import(\"../settings/index.js\");\n const current = parseWorkspaceAppMetadataSettings(await getSetting(key));\n const existing = current.apps[appId] ?? {};\n const next: WorkspaceAppMetadataOverride = {\n ...existing,\n updatedAt: new Date().toISOString(),\n };\n\n const name = cleanOptionalText(input.name);\n const description = cleanOptionalText(input.description);\n const sourcePrompt = cleanOptionalText(input.sourcePrompt);\n const updatedBy = cleanOptionalText(input.updatedBy);\n\n if (name) next.name = name;\n else delete next.name;\n if (description) next.description = description;\n else delete next.description;\n if (input.generated === true) next.generated = true;\n else if (input.generated === false) delete next.generated;\n if (sourcePrompt) next.sourcePrompt = sourcePrompt;\n if (updatedBy) next.updatedBy = updatedBy;\n\n current.apps[appId] = next;\n await putSetting(key, current as unknown as Record<string, unknown>);\n return current;\n}\n\nexport function applyWorkspaceAppMetadataOverride<\n T extends {\n id: string;\n name: string;\n description?: string | null;\n },\n>(app: T, settings: WorkspaceAppMetadataSettings): T {\n const override = settings.apps[app.id];\n if (!override) return app;\n\n const name = cleanOptionalText(override.name);\n const description = cleanOptionalText(override.description);\n const generated = override.generated === true;\n const shouldApplyName = !!name && !generated;\n const shouldApplyDescription =\n !!description && (!generated || !cleanOptionalText(app.description));\n if (!shouldApplyName && !shouldApplyDescription) return app;\n\n return {\n ...app,\n ...(shouldApplyName ? { name } : {}),\n ...(shouldApplyDescription ? { description } : {}),\n };\n}\n\n/**\n * Resolve the workspace app manifest from the same fallback chain that\n * `discoverWorkspaceAgents` uses: `AGENT_NATIVE_WORKSPACE_APPS_JSON` env →\n * `.agent-native/workspace-apps.json` (or sibling) on disk → live filesystem\n * scan of `apps/<id>/package.json` under the workspace root.\n *\n * Callers (e.g. the dispatch `/dispatch/<appId>` catch-all loader) need this\n * to behave the same in production deploys (which write the manifest file)\n * and during local dev (where new apps appear under `apps/` without an env\n * restart). Reading only the env var would silently downgrade the behavior\n * in both cases.\n */\nexport function loadWorkspaceAppsManifest():\n | WorkspaceAppManifestEntry[]\n | null {\n return (\n readWorkspaceAppsFromEnv() ??\n readWorkspaceAppsFromManifestFile() ??\n readWorkspaceAppsFromFilesystem()\n );\n}\n\nexport function shouldIncludeRemoteAgentManifest(\n manifest: { id?: string | null },\n selfAppId?: string,\n): boolean {\n const id = manifest.id?.trim();\n if (!id) return false;\n const normalizedId = id.toLowerCase();\n const normalizedSelfAppId = selfAppId?.trim().toLowerCase();\n if (normalizedSelfAppId && normalizedId === normalizedSelfAppId) {\n return false;\n }\n return !HIDDEN_FIRST_PARTY_AGENT_IDS.has(normalizedId);\n}\n\n/**\n * Get built-in agents (static, no DB). Used as fallback and for seeding.\n */\nexport function getBuiltinAgents(selfAppId?: string): DiscoveredAgent[] {\n return BUILTIN_AGENTS.filter((app) => app.id !== selfAppId && app.url).map(\n (app) => ({\n id: app.id,\n name: app.name,\n description: app.description,\n url: resolveAgentUrl(app),\n color: app.color,\n }),\n );\n}\n\n/**\n * Discover all agents: built-in + custom agents stored as resources.\n * Custom agents override built-in agents with the same ID.\n */\nexport async function discoverAgents(\n selfAppId?: string,\n): Promise<DiscoveredAgent[]> {\n const builtins = getBuiltinAgents(selfAppId);\n const agentsById = new Map<string, DiscoveredAgent>();\n\n // Start with built-ins\n for (const agent of builtins) {\n agentsById.set(agent.id, agent);\n }\n\n // Overlay custom agents from resources\n try {\n const { resourceList, resourceGet, SHARED_OWNER } =\n await import(\"../resources/store.js\");\n\n const { parseRemoteAgentManifest, REMOTE_AGENT_RESOURCE_PREFIXES } =\n await import(\"../resources/metadata.js\");\n\n const resources: Array<{ id: string; path: string }> = [];\n for (const prefix of [...REMOTE_AGENT_RESOURCE_PREFIXES].reverse()) {\n resources.push(...(await resourceList(SHARED_OWNER, prefix)));\n }\n\n for (const r of resources) {\n if (!r.path.endsWith(\".json\")) continue;\n try {\n const full = await resourceGet(r.id);\n if (!full) continue;\n const manifest = parseRemoteAgentManifest(full.content, r.path);\n if (!manifest || !shouldIncludeRemoteAgentManifest(manifest, selfAppId))\n continue;\n\n // If the resource override carries a localhost URL but we're running\n // in production (e.g. a stale dev-time seed got promoted to the prod\n // DB), fall back to the matching built-in's prod URL instead of\n // letting the override win — otherwise outbound `call-agent` fetches\n // from a serverless function would target localhost and fail with\n // \"fetch failed\" instantly. The override still wins for non-localhost\n // URLs (the supported case for self-hosted custom agents).\n let url = manifest.url;\n const isProduction =\n typeof process !== \"undefined\" &&\n process.env?.NODE_ENV === \"production\";\n if (\n isProduction &&\n typeof url === \"string\" &&\n /^https?:\\/\\/(localhost|127\\.0\\.0\\.1|0\\.0\\.0\\.0)(:|\\/|$)/.test(url)\n ) {\n const builtin = agentsById.get(manifest.id);\n if (builtin?.url) url = builtin.url;\n }\n\n agentsById.set(manifest.id, {\n id: manifest.id,\n name: manifest.name,\n description: manifest.description || \"\",\n url,\n color: manifest.color || \"#6B7280\",\n });\n } catch {\n // Skip unreadable resources\n }\n }\n } catch {\n // Resources not available — use built-ins only\n }\n\n // Overlay sibling workspace apps last so same-origin workspaces prefer the\n // app mounted in this workspace over the public template with the same id.\n for (const agent of await discoverWorkspaceAgents(selfAppId)) {\n agentsById.set(agent.id, agent);\n }\n\n return Array.from(agentsById.values());\n}\n\n/**\n * Look up a single agent by ID or name (case-insensitive).\n */\nexport async function findAgent(\n idOrName: string,\n selfAppId?: string,\n): Promise<DiscoveredAgent | undefined> {\n const lower = idOrName.toLowerCase();\n const agents = await discoverAgents(selfAppId);\n return agents.find((a) => a.id === lower || a.name.toLowerCase() === lower);\n}\n\nfunction isDevEnvironment(): boolean {\n return (\n typeof process !== \"undefined\" && process.env?.NODE_ENV !== \"production\"\n );\n}\n\nfunction resolveAgentUrl(app: AgentEntry): string {\n if (isDevEnvironment()) {\n return app.devUrl || `http://localhost:${app.devPort}`;\n }\n return app.url;\n}\n\nfunction readJson(file: string): any {\n try {\n return JSON.parse(fs.readFileSync(file, \"utf8\"));\n } catch {\n return null;\n }\n}\n\nfunction findWorkspaceRoot(startDir = process.cwd()): string | null {\n let dir = path.resolve(startDir);\n for (let i = 0; i < 20; i++) {\n const pkg = readJson(path.join(dir, \"package.json\"));\n if (typeof pkg?.[\"agent-native\"]?.workspaceCore === \"string\") {\n return dir;\n }\n const parent = path.dirname(dir);\n if (parent === dir) break;\n dir = parent;\n }\n return null;\n}\n\nfunction titleCase(value: string): string {\n return value\n .split(/[-_\\s]+/)\n .filter(Boolean)\n .map((part) => part.charAt(0).toUpperCase() + part.slice(1))\n .join(\" \");\n}\n\nfunction parseWorkspaceAppsManifest(\n parsed: any,\n): WorkspaceAppManifestEntry[] | null {\n const rawApps = Array.isArray(parsed?.apps)\n ? parsed.apps\n : Array.isArray(parsed)\n ? parsed\n : null;\n if (!rawApps) return null;\n\n const apps = rawApps\n .map((entry) => {\n if (!entry || typeof entry !== \"object\") return null;\n const id = typeof entry.id === \"string\" ? entry.id.trim() : \"\";\n const pathValue = typeof entry.path === \"string\" ? entry.path.trim() : \"\";\n if (!id || !pathValue.startsWith(\"/\")) return null;\n return {\n id,\n name:\n typeof entry.name === \"string\" && entry.name.trim()\n ? entry.name.trim()\n : titleCase(id),\n description:\n typeof entry.description === \"string\" ? entry.description : \"\",\n path: pathValue,\n url:\n typeof entry.url === \"string\" && entry.url.trim()\n ? entry.url.trim()\n : null,\n isDispatch:\n typeof entry.isDispatch === \"boolean\"\n ? entry.isDispatch\n : id === \"dispatch\",\n audience:\n entry.audience === undefined\n ? DEFAULT_WORKSPACE_APP_AUDIENCE\n : normalizeWorkspaceAppAudience(entry.audience),\n publicPaths: normalizeWorkspaceAppPathList(entry.publicPaths),\n protectedPaths: normalizeWorkspaceAppPathList(entry.protectedPaths),\n } satisfies WorkspaceAppManifestEntry;\n })\n .filter((app): app is WorkspaceAppManifestEntry => !!app)\n .sort((a, b) => {\n if (a.id === \"dispatch\") return -1;\n if (b.id === \"dispatch\") return 1;\n return a.name.localeCompare(b.name);\n });\n\n return apps.length ? apps : null;\n}\n\nfunction readWorkspaceAppsFromEnv(): WorkspaceAppManifestEntry[] | null {\n const raw = process.env[WORKSPACE_APPS_ENV_KEY];\n if (!raw) return null;\n try {\n return parseWorkspaceAppsManifest(JSON.parse(raw));\n } catch {\n return null;\n }\n}\n\nfunction workspaceAppsManifestCandidates(): string[] {\n const candidates: string[] = [];\n try {\n candidates.push(\n path.join(process.cwd(), \".agent-native\", WORKSPACE_APPS_MANIFEST_FILE),\n path.join(process.cwd(), WORKSPACE_APPS_MANIFEST_FILE),\n );\n } catch {\n // Some edge runtimes do not expose process.cwd().\n }\n try {\n const moduleDir = path.dirname(fileURLToPath(import.meta.url));\n candidates.push(\n path.join(moduleDir, \".agent-native\", WORKSPACE_APPS_MANIFEST_FILE),\n path.join(moduleDir, WORKSPACE_APPS_MANIFEST_FILE),\n );\n } catch {\n // Some edge runtimes expose non-file module URLs. The env manifest still\n // works there, so skip file-relative candidates.\n }\n return candidates;\n}\n\nfunction readWorkspaceAppsFromManifestFile():\n | WorkspaceAppManifestEntry[]\n | null {\n for (const file of workspaceAppsManifestCandidates()) {\n if (!fs.existsSync(file)) continue;\n const apps = parseWorkspaceAppsManifest(readJson(file));\n if (apps) return apps;\n }\n return null;\n}\n\nfunction readWorkspaceAppsFromFilesystem(): WorkspaceAppManifestEntry[] | null {\n const workspaceRoot = findWorkspaceRoot();\n if (!workspaceRoot) return null;\n const appsDir = path.join(workspaceRoot, \"apps\");\n if (!fs.existsSync(appsDir)) return null;\n\n const apps = fs\n .readdirSync(appsDir, { withFileTypes: true })\n .filter((entry) => entry.isDirectory())\n .map((entry): WorkspaceAppManifestEntry | null => {\n const appDir = path.join(appsDir, entry.name);\n const pkg = readJson(path.join(appDir, \"package.json\"));\n if (!pkg) return null;\n const routeAccess = workspaceAppRouteAccessFromPackageJson(pkg);\n return {\n id: entry.name,\n name: pkg.displayName || titleCase(entry.name),\n description: pkg.description || \"\",\n path: `/${entry.name}`,\n isDispatch: entry.name === \"dispatch\",\n audience:\n workspaceAppAudienceFromPackageJson(pkg) ??\n DEFAULT_WORKSPACE_APP_AUDIENCE,\n publicPaths: routeAccess.publicPaths ?? [],\n protectedPaths: routeAccess.protectedPaths ?? [],\n } satisfies WorkspaceAppManifestEntry;\n })\n .filter((app): app is WorkspaceAppManifestEntry => !!app)\n .sort((a, b) => {\n if (a.id === \"dispatch\") return -1;\n if (b.id === \"dispatch\") return 1;\n return a.name.localeCompare(b.name);\n });\n\n return apps.length ? apps : null;\n}\n\nfunction workspaceBaseUrl(): string | null {\n return (\n process.env.WORKSPACE_GATEWAY_URL ||\n process.env.APP_URL ||\n process.env.URL ||\n process.env.DEPLOY_URL ||\n process.env.BETTER_AUTH_URL ||\n null\n );\n}\n\nfunction workspaceAppUrl(app: WorkspaceAppManifestEntry): string | null {\n if (app.url) return app.url;\n const base = workspaceBaseUrl();\n if (!base) return null;\n try {\n return new URL(app.path, `${base.replace(/\\/$/, \"\")}/`).toString();\n } catch {\n return null;\n }\n}\n\nasync function discoverWorkspaceAgents(\n selfAppId?: string,\n): Promise<DiscoveredAgent[]> {\n const workspaceApps = loadWorkspaceAppsManifest();\n if (!workspaceApps) return [];\n\n const metadataSettings = await readWorkspaceAppMetadataSettings();\n\n return workspaceApps\n .filter((app) => app.id !== selfAppId)\n .map((app) => {\n const withOverride = applyWorkspaceAppMetadataOverride(\n app,\n metadataSettings,\n );\n const url = workspaceAppUrl(withOverride);\n if (!url) return null;\n const builtin = BUILTIN_AGENTS.find(\n (agent) => agent.id === withOverride.id,\n );\n return {\n id: withOverride.id,\n name: withOverride.name,\n description:\n withOverride.description ||\n builtin?.description ||\n `Workspace app mounted at ${withOverride.path}`,\n url,\n color: builtin?.color || \"#6B7280\",\n } satisfies DiscoveredAgent;\n })\n .filter((agent): agent is DiscoveredAgent => !!agent);\n}\n\n/**\n * Like `getBuiltinAgents`, but always returns the production URL — never the\n * env-resolved devUrl. Used by the resource seeder so that a one-time seed\n * (`ON CONFLICT DO NOTHING`) can't permanently bake a localhost URL into the\n * DB, which would override the built-in's prod URL for every later\n * production deploy.\n */\nexport const BUILTIN_AGENTS_FOR_SEEDING: DiscoveredAgent[] =\n BUILTIN_AGENTS.filter((app) => app.url).map((app) => ({\n id: app.id,\n name: app.name,\n description: app.description,\n url: app.url, // ALWAYS prod\n color: app.color,\n }));\n"]}
1
+ {"version":3,"file":"agent-discovery.js","sourceRoot":"","sources":["../../src/server/agent-discovery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EACL,8BAA8B,EAC9B,6BAA6B,EAC7B,6BAA6B,EAC7B,mCAAmC,EACnC,sCAAsC,GAEvC,MAAM,qCAAqC,CAAC;AAiC7C;;;;GAIG;AACH,MAAM,cAAc,GAAiB,SAAS,CAAC,MAAM,CACnD,CAAC,QAAQ,EAAE,EAAE,CACX,CAAC,CAAC,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,OAAO,CACpE,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;IACnB,EAAE,EAAE,QAAQ,CAAC,IAAI;IACjB,IAAI,EAAE,QAAQ,CAAC,KAAK;IACpB,WAAW,EAAE,QAAQ,CAAC,WAAW,IAAI,QAAQ,CAAC,IAAI;IAClD,GAAG,EAAE,QAAQ,CAAC,OAAQ;IACtB,MAAM,EAAE,oBAAoB,QAAQ,CAAC,OAAO,EAAE;IAC9C,OAAO,EAAE,QAAQ,CAAC,OAAO;IACzB,KAAK,EAAE,QAAQ,CAAC,KAAK;CACtB,CAAC,CAAC,CAAC;AAEJ,MAAM,4BAA4B,GAAG,IAAI,GAAG,CAC1C,SAAS,CAAC,MAAM,CACd,CAAC,QAAQ,EAAE,EAAE,CA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EACT,YAAY,CAAC,WAAW;gBACxB,OAAO,EAAE,WAAW;gBACpB,4BAA4B,YAAY,CAAC,IAAI,EAAE;YACjD,GAAG;YACH,KAAK,EAAE,OAAO,EAAE,KAAK,IAAI,SAAS;SACT,CAAC;IAC9B,CAAC,CAAC;SACD,MAAM,CAAC,CAAC,KAAK,EAA4B,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;AAC1D,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,0BAA0B,GACrC,cAAc,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IACpD,EAAE,EAAE,GAAG,CAAC,EAAE;IACV,IAAI,EAAE,GAAG,CAAC,IAAI;IACd,WAAW,EAAE,GAAG,CAAC,WAAW;IAC5B,GAAG,EAAE,GAAG,CAAC,GAAG,EAAE,cAAc;IAC5B,KAAK,EAAE,GAAG,CAAC,KAAK;CACjB,CAAC,CAAC,CAAC","sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { TEMPLATES } from \"../cli/templates-meta.js\";\nimport { getRequestOrgId, getRequestUserEmail } from \"./request-context.js\";\nimport {\n DEFAULT_WORKSPACE_APP_AUDIENCE,\n normalizeWorkspaceAppAudience,\n normalizeWorkspaceAppPathList,\n workspaceAppAudienceFromPackageJson,\n workspaceAppRouteAccessFromPackageJson,\n type WorkspaceAppAudience,\n} from \"../shared/workspace-app-audience.js\";\n\nexport interface DiscoveredAgent {\n id: string;\n name: string;\n description: string;\n url: string;\n color: string;\n}\n\nexport interface WorkspaceAppMetadataOverride {\n name?: string;\n description?: string;\n generated?: boolean;\n sourcePrompt?: string;\n updatedAt?: string;\n updatedBy?: string;\n}\n\nexport interface WorkspaceAppMetadataSettings {\n apps: Record<string, WorkspaceAppMetadataOverride>;\n}\n\ninterface AgentEntry {\n id: string;\n name: string;\n description: string;\n url: string;\n devUrl?: string;\n devPort: number;\n color: string;\n}\n\n/**\n * Built-in agent registry. Derive this from the published CLI metadata so\n * connected-agent discovery stays aligned with first-party template metadata\n * without depending on @agent-native/shared-app-config at runtime.\n */\nconst BUILTIN_AGENTS: AgentEntry[] = TEMPLATES.filter(\n (template) =>\n (!template.hidden || template.defaultAgent) && !!template.prodUrl,\n).map((template) => ({\n id: template.name,\n name: template.label,\n description: template.description ?? template.hint,\n url: template.prodUrl!,\n devUrl: `http://localhost:${template.devPort}`,\n devPort: template.devPort,\n color: template.color,\n}));\n\nconst HIDDEN_FIRST_PARTY_AGENT_IDS = new Set(\n TEMPLATES.filter(\n (template) => template.hidden && !template.defaultAgent && template.prodUrl,\n ).map((template) => template.name),\n);\n\nfunction normalizeAgentId(id: string): string {\n const normalized = id.trim().toLowerCase();\n if (\n normalized === \"image\" ||\n normalized === \"images\" ||\n normalized === \"asset\"\n ) {\n return \"assets\";\n }\n return normalized;\n}\n\nconst WORKSPACE_APPS_ENV_KEY = \"AGENT_NATIVE_WORKSPACE_APPS_JSON\";\nconst WORKSPACE_APPS_MANIFEST_FILE = \"workspace-apps.json\";\nexport const WORKSPACE_APP_METADATA_SETTINGS_KEY = \"workspace-app-metadata\";\n\nexport interface WorkspaceAppManifestEntry {\n id: string;\n name: string;\n description: string;\n path: string;\n url?: string | null;\n isDispatch?: boolean;\n audience?: WorkspaceAppAudience;\n publicPaths?: string[];\n protectedPaths?: string[];\n}\n\nexport function workspaceAppMetadataSettingsKey(input?: {\n orgId?: string | null;\n userEmail?: string | null;\n}): string | null {\n const orgId = input?.orgId ?? getRequestOrgId() ?? null;\n if (orgId) return `${WORKSPACE_APP_METADATA_SETTINGS_KEY}:org:${orgId}`;\n\n const userEmail = input?.userEmail ?? getRequestUserEmail() ?? null;\n if (userEmail)\n return `${WORKSPACE_APP_METADATA_SETTINGS_KEY}:user:${userEmail}`;\n\n return null;\n}\n\nfunction cleanOptionalText(value: unknown): string | undefined {\n return typeof value === \"string\" && value.trim() ? value.trim() : undefined;\n}\n\nexport function parseWorkspaceAppMetadataSettings(\n raw: unknown,\n): WorkspaceAppMetadataSettings {\n const record =\n raw && typeof raw === \"object\" && !Array.isArray(raw)\n ? (raw as Record<string, unknown>)\n : {};\n const rawApps =\n record.apps &&\n typeof record.apps === \"object\" &&\n !Array.isArray(record.apps)\n ? (record.apps as Record<string, unknown>)\n : {};\n const apps: Record<string, WorkspaceAppMetadataOverride> = {};\n\n for (const [id, value] of Object.entries(rawApps)) {\n if (!id.trim() || !value || typeof value !== \"object\") continue;\n const item = value as Record<string, unknown>;\n const override: WorkspaceAppMetadataOverride = {};\n const name = cleanOptionalText(item.name);\n const description = cleanOptionalText(item.description);\n const sourcePrompt = cleanOptionalText(item.sourcePrompt);\n const updatedAt = cleanOptionalText(item.updatedAt);\n const updatedBy = cleanOptionalText(item.updatedBy);\n\n if (name) override.name = name;\n if (description) override.description = description;\n if (item.generated === true) override.generated = true;\n if (sourcePrompt) override.sourcePrompt = sourcePrompt;\n if (updatedAt) override.updatedAt = updatedAt;\n if (updatedBy) override.updatedBy = updatedBy;\n\n if (Object.keys(override).length > 0) apps[id.trim()] = override;\n }\n\n return { apps };\n}\n\nexport async function readWorkspaceAppMetadataSettings(): Promise<WorkspaceAppMetadataSettings> {\n const key = workspaceAppMetadataSettingsKey();\n if (!key) return { apps: {} };\n\n try {\n const { getSetting } = await import(\"../settings/index.js\");\n return parseWorkspaceAppMetadataSettings(await getSetting(key));\n } catch {\n return { apps: {} };\n }\n}\n\nexport async function writeWorkspaceAppMetadataOverride(input: {\n appId: string;\n name?: string | null;\n description?: string | null;\n generated?: boolean;\n sourcePrompt?: string | null;\n updatedBy?: string | null;\n}): Promise<WorkspaceAppMetadataSettings> {\n const key = workspaceAppMetadataSettingsKey();\n if (!key) throw new Error(\"no authenticated user\");\n\n const appId = input.appId.trim();\n if (!appId) throw new Error(\"appId is required\");\n\n const { getSetting, putSetting } = await import(\"../settings/index.js\");\n const current = parseWorkspaceAppMetadataSettings(await getSetting(key));\n const existing = current.apps[appId] ?? {};\n const next: WorkspaceAppMetadataOverride = {\n ...existing,\n updatedAt: new Date().toISOString(),\n };\n\n const name = cleanOptionalText(input.name);\n const description = cleanOptionalText(input.description);\n const sourcePrompt = cleanOptionalText(input.sourcePrompt);\n const updatedBy = cleanOptionalText(input.updatedBy);\n\n if (name) next.name = name;\n else delete next.name;\n if (description) next.description = description;\n else delete next.description;\n if (input.generated === true) next.generated = true;\n else if (input.generated === false) delete next.generated;\n if (sourcePrompt) next.sourcePrompt = sourcePrompt;\n if (updatedBy) next.updatedBy = updatedBy;\n\n current.apps[appId] = next;\n await putSetting(key, current as unknown as Record<string, unknown>);\n return current;\n}\n\nexport function applyWorkspaceAppMetadataOverride<\n T extends {\n id: string;\n name: string;\n description?: string | null;\n },\n>(app: T, settings: WorkspaceAppMetadataSettings): T {\n const override = settings.apps[app.id];\n if (!override) return app;\n\n const name = cleanOptionalText(override.name);\n const description = cleanOptionalText(override.description);\n const generated = override.generated === true;\n const shouldApplyName = !!name && !generated;\n const shouldApplyDescription =\n !!description && (!generated || !cleanOptionalText(app.description));\n if (!shouldApplyName && !shouldApplyDescription) return app;\n\n return {\n ...app,\n ...(shouldApplyName ? { name } : {}),\n ...(shouldApplyDescription ? { description } : {}),\n };\n}\n\n/**\n * Resolve the workspace app manifest from the same fallback chain that\n * `discoverWorkspaceAgents` uses: `AGENT_NATIVE_WORKSPACE_APPS_JSON` env →\n * `.agent-native/workspace-apps.json` (or sibling) on disk → live filesystem\n * scan of `apps/<id>/package.json` under the workspace root.\n *\n * Callers (e.g. the dispatch `/dispatch/<appId>` catch-all loader) need this\n * to behave the same in production deploys (which write the manifest file)\n * and during local dev (where new apps appear under `apps/` without an env\n * restart). Reading only the env var would silently downgrade the behavior\n * in both cases.\n */\nexport function loadWorkspaceAppsManifest():\n | WorkspaceAppManifestEntry[]\n | null {\n return (\n readWorkspaceAppsFromEnv() ??\n readWorkspaceAppsFromManifestFile() ??\n readWorkspaceAppsFromFilesystem()\n );\n}\n\nexport function shouldIncludeRemoteAgentManifest(\n manifest: { id?: string | null },\n selfAppId?: string,\n): boolean {\n const id = manifest.id?.trim();\n if (!id) return false;\n const normalizedId = normalizeAgentId(id);\n const normalizedSelfAppId = selfAppId ? normalizeAgentId(selfAppId) : \"\";\n if (normalizedSelfAppId && normalizedId === normalizedSelfAppId) {\n return false;\n }\n return !HIDDEN_FIRST_PARTY_AGENT_IDS.has(normalizedId);\n}\n\n/**\n * Get built-in agents (static, no DB). Used as fallback and for seeding.\n */\nexport function getBuiltinAgents(selfAppId?: string): DiscoveredAgent[] {\n const normalizedSelfAppId = selfAppId ? normalizeAgentId(selfAppId) : \"\";\n return BUILTIN_AGENTS.filter(\n (app) => app.id !== normalizedSelfAppId && app.url,\n ).map((app) => ({\n id: app.id,\n name: app.name,\n description: app.description,\n url: resolveAgentUrl(app),\n color: app.color,\n }));\n}\n\n/**\n * Discover all agents: built-in + custom agents stored as resources.\n * Custom agents override built-in agents with the same ID.\n */\nexport async function discoverAgents(\n selfAppId?: string,\n): Promise<DiscoveredAgent[]> {\n const builtins = getBuiltinAgents(selfAppId);\n const agentsById = new Map<string, DiscoveredAgent>();\n\n // Start with built-ins\n for (const agent of builtins) {\n agentsById.set(agent.id, agent);\n }\n\n // Overlay custom agents from resources\n try {\n const { resourceList, resourceGet, SHARED_OWNER } =\n await import(\"../resources/store.js\");\n\n const { parseRemoteAgentManifest, REMOTE_AGENT_RESOURCE_PREFIXES } =\n await import(\"../resources/metadata.js\");\n\n const resources: Array<{ id: string; path: string }> = [];\n for (const prefix of [...REMOTE_AGENT_RESOURCE_PREFIXES].reverse()) {\n resources.push(...(await resourceList(SHARED_OWNER, prefix)));\n }\n\n for (const r of resources) {\n if (!r.path.endsWith(\".json\")) continue;\n try {\n const full = await resourceGet(r.id);\n if (!full) continue;\n const manifest = parseRemoteAgentManifest(full.content, r.path);\n if (!manifest || !shouldIncludeRemoteAgentManifest(manifest, selfAppId))\n continue;\n const manifestId = normalizeAgentId(manifest.id);\n\n // If the resource override carries a localhost URL but we're running\n // in production (e.g. a stale dev-time seed got promoted to the prod\n // DB), fall back to the matching built-in's prod URL instead of\n // letting the override win — otherwise outbound `call-agent` fetches\n // from a serverless function would target localhost and fail with\n // \"fetch failed\" instantly. The override still wins for non-localhost\n // URLs (the supported case for self-hosted custom agents).\n let url = manifest.url;\n const isProduction =\n typeof process !== \"undefined\" &&\n process.env?.NODE_ENV === \"production\";\n if (\n isProduction &&\n typeof url === \"string\" &&\n /^https?:\\/\\/(localhost|127\\.0\\.0\\.1|0\\.0\\.0\\.0)(:|\\/|$)/.test(url)\n ) {\n const builtin = agentsById.get(manifestId);\n if (builtin?.url) url = builtin.url;\n }\n\n const builtin = agentsById.get(manifestId);\n const isLegacyAssetsManifest =\n manifest.id.trim().toLowerCase() !== manifestId;\n if (isLegacyAssetsManifest && builtin?.url) {\n try {\n if (new URL(url).hostname === \"images.agent-native.com\") {\n url = builtin.url;\n }\n } catch {\n url = builtin.url;\n }\n }\n\n agentsById.set(manifestId, {\n id: manifestId,\n name:\n isLegacyAssetsManifest && builtin?.name\n ? builtin.name\n : manifest.name,\n description: manifest.description || \"\",\n url,\n color: manifest.color || builtin?.color || \"#6B7280\",\n });\n } catch {\n // Skip unreadable resources\n }\n }\n } catch {\n // Resources not available — use built-ins only\n }\n\n // Overlay sibling workspace apps last so same-origin workspaces prefer the\n // app mounted in this workspace over the public template with the same id.\n for (const agent of await discoverWorkspaceAgents(selfAppId)) {\n agentsById.set(agent.id, agent);\n }\n\n return Array.from(agentsById.values());\n}\n\n/**\n * Look up a single agent by ID or name (case-insensitive).\n */\nexport async function findAgent(\n idOrName: string,\n selfAppId?: string,\n): Promise<DiscoveredAgent | undefined> {\n const lower = normalizeAgentId(idOrName);\n const agents = await discoverAgents(selfAppId);\n return agents.find((a) => a.id === lower || a.name.toLowerCase() === lower);\n}\n\nfunction isDevEnvironment(): boolean {\n return (\n typeof process !== \"undefined\" && process.env?.NODE_ENV !== \"production\"\n );\n}\n\nfunction resolveAgentUrl(app: AgentEntry): string {\n if (isDevEnvironment()) {\n return app.devUrl || `http://localhost:${app.devPort}`;\n }\n return app.url;\n}\n\nfunction readJson(file: string): any {\n try {\n return JSON.parse(fs.readFileSync(file, \"utf8\"));\n } catch {\n return null;\n }\n}\n\nfunction findWorkspaceRoot(startDir = process.cwd()): string | null {\n let dir = path.resolve(startDir);\n for (let i = 0; i < 20; i++) {\n const pkg = readJson(path.join(dir, \"package.json\"));\n if (typeof pkg?.[\"agent-native\"]?.workspaceCore === \"string\") {\n return dir;\n }\n const parent = path.dirname(dir);\n if (parent === dir) break;\n dir = parent;\n }\n return null;\n}\n\nfunction titleCase(value: string): string {\n return value\n .split(/[-_\\s]+/)\n .filter(Boolean)\n .map((part) => part.charAt(0).toUpperCase() + part.slice(1))\n .join(\" \");\n}\n\nfunction parseWorkspaceAppsManifest(\n parsed: any,\n): WorkspaceAppManifestEntry[] | null {\n const rawApps = Array.isArray(parsed?.apps)\n ? parsed.apps\n : Array.isArray(parsed)\n ? parsed\n : null;\n if (!rawApps) return null;\n\n const apps = rawApps\n .map((entry) => {\n if (!entry || typeof entry !== \"object\") return null;\n const id = typeof entry.id === \"string\" ? entry.id.trim() : \"\";\n const pathValue = typeof entry.path === \"string\" ? entry.path.trim() : \"\";\n if (!id || !pathValue.startsWith(\"/\")) return null;\n return {\n id,\n name:\n typeof entry.name === \"string\" && entry.name.trim()\n ? entry.name.trim()\n : titleCase(id),\n description:\n typeof entry.description === \"string\" ? entry.description : \"\",\n path: pathValue,\n url:\n typeof entry.url === \"string\" && entry.url.trim()\n ? entry.url.trim()\n : null,\n isDispatch:\n typeof entry.isDispatch === \"boolean\"\n ? entry.isDispatch\n : id === \"dispatch\",\n audience:\n entry.audience === undefined\n ? DEFAULT_WORKSPACE_APP_AUDIENCE\n : normalizeWorkspaceAppAudience(entry.audience),\n publicPaths: normalizeWorkspaceAppPathList(entry.publicPaths),\n protectedPaths: normalizeWorkspaceAppPathList(entry.protectedPaths),\n } satisfies WorkspaceAppManifestEntry;\n })\n .filter((app): app is WorkspaceAppManifestEntry => !!app)\n .sort((a, b) => {\n if (a.id === \"dispatch\") return -1;\n if (b.id === \"dispatch\") return 1;\n return a.name.localeCompare(b.name);\n });\n\n return apps.length ? apps : null;\n}\n\nfunction readWorkspaceAppsFromEnv(): WorkspaceAppManifestEntry[] | null {\n const raw = process.env[WORKSPACE_APPS_ENV_KEY];\n if (!raw) return null;\n try {\n return parseWorkspaceAppsManifest(JSON.parse(raw));\n } catch {\n return null;\n }\n}\n\nfunction workspaceAppsManifestCandidates(): string[] {\n const candidates: string[] = [];\n try {\n candidates.push(\n path.join(process.cwd(), \".agent-native\", WORKSPACE_APPS_MANIFEST_FILE),\n path.join(process.cwd(), WORKSPACE_APPS_MANIFEST_FILE),\n );\n } catch {\n // Some edge runtimes do not expose process.cwd().\n }\n try {\n const moduleDir = path.dirname(fileURLToPath(import.meta.url));\n candidates.push(\n path.join(moduleDir, \".agent-native\", WORKSPACE_APPS_MANIFEST_FILE),\n path.join(moduleDir, WORKSPACE_APPS_MANIFEST_FILE),\n );\n } catch {\n // Some edge runtimes expose non-file module URLs. The env manifest still\n // works there, so skip file-relative candidates.\n }\n return candidates;\n}\n\nfunction readWorkspaceAppsFromManifestFile():\n | WorkspaceAppManifestEntry[]\n | null {\n for (const file of workspaceAppsManifestCandidates()) {\n if (!fs.existsSync(file)) continue;\n const apps = parseWorkspaceAppsManifest(readJson(file));\n if (apps) return apps;\n }\n return null;\n}\n\nfunction readWorkspaceAppsFromFilesystem(): WorkspaceAppManifestEntry[] | null {\n const workspaceRoot = findWorkspaceRoot();\n if (!workspaceRoot) return null;\n const appsDir = path.join(workspaceRoot, \"apps\");\n if (!fs.existsSync(appsDir)) return null;\n\n const apps = fs\n .readdirSync(appsDir, { withFileTypes: true })\n .filter((entry) => entry.isDirectory())\n .map((entry): WorkspaceAppManifestEntry | null => {\n const appDir = path.join(appsDir, entry.name);\n const pkg = readJson(path.join(appDir, \"package.json\"));\n if (!pkg) return null;\n const routeAccess = workspaceAppRouteAccessFromPackageJson(pkg);\n return {\n id: entry.name,\n name: pkg.displayName || titleCase(entry.name),\n description: pkg.description || \"\",\n path: `/${entry.name}`,\n isDispatch: entry.name === \"dispatch\",\n audience:\n workspaceAppAudienceFromPackageJson(pkg) ??\n DEFAULT_WORKSPACE_APP_AUDIENCE,\n publicPaths: routeAccess.publicPaths ?? [],\n protectedPaths: routeAccess.protectedPaths ?? [],\n } satisfies WorkspaceAppManifestEntry;\n })\n .filter((app): app is WorkspaceAppManifestEntry => !!app)\n .sort((a, b) => {\n if (a.id === \"dispatch\") return -1;\n if (b.id === \"dispatch\") return 1;\n return a.name.localeCompare(b.name);\n });\n\n return apps.length ? apps : null;\n}\n\nfunction workspaceBaseUrl(): string | null {\n return (\n process.env.WORKSPACE_GATEWAY_URL ||\n process.env.APP_URL ||\n process.env.URL ||\n process.env.DEPLOY_URL ||\n process.env.BETTER_AUTH_URL ||\n null\n );\n}\n\nfunction workspaceAppUrl(app: WorkspaceAppManifestEntry): string | null {\n if (app.url) return app.url;\n const base = workspaceBaseUrl();\n if (!base) return null;\n try {\n return new URL(app.path, `${base.replace(/\\/$/, \"\")}/`).toString();\n } catch {\n return null;\n }\n}\n\nasync function discoverWorkspaceAgents(\n selfAppId?: string,\n): Promise<DiscoveredAgent[]> {\n const workspaceApps = loadWorkspaceAppsManifest();\n if (!workspaceApps) return [];\n\n const metadataSettings = await readWorkspaceAppMetadataSettings();\n\n return workspaceApps\n .filter((app) => app.id !== selfAppId)\n .map((app) => {\n const withOverride = applyWorkspaceAppMetadataOverride(\n app,\n metadataSettings,\n );\n const url = workspaceAppUrl(withOverride);\n if (!url) return null;\n const builtin = BUILTIN_AGENTS.find(\n (agent) => agent.id === withOverride.id,\n );\n return {\n id: withOverride.id,\n name: withOverride.name,\n description:\n withOverride.description ||\n builtin?.description ||\n `Workspace app mounted at ${withOverride.path}`,\n url,\n color: builtin?.color || \"#6B7280\",\n } satisfies DiscoveredAgent;\n })\n .filter((agent): agent is DiscoveredAgent => !!agent);\n}\n\n/**\n * Like `getBuiltinAgents`, but always returns the production URL — never the\n * env-resolved devUrl. Used by the resource seeder so that a one-time seed\n * (`ON CONFLICT DO NOTHING`) can't permanently bake a localhost URL into the\n * DB, which would override the built-in's prod URL for every later\n * production deploy.\n */\nexport const BUILTIN_AGENTS_FOR_SEEDING: DiscoveredAgent[] =\n BUILTIN_AGENTS.filter((app) => app.url).map((app) => ({\n id: app.id,\n name: app.name,\n description: app.description,\n url: app.url, // ALWAYS prod\n color: app.color,\n }));\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"auth-marketing.d.ts","sourceRoot":"","sources":["../../src/server/auth-marketing.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,kCAAkC;IACjD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,eAAO,MAAM,uBAAuB,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CA0MxE,CAAC;AAiFF,wBAAgB,2BAA2B,CACzC,IAAI,GAAE,kCAAuC,GAC5C,oBAAoB,GAAG,SAAS,CAMlC"}
1
+ {"version":3,"file":"auth-marketing.d.ts","sourceRoot":"","sources":["../../src/server/auth-marketing.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,kCAAkC;IACjD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,eAAO,MAAM,uBAAuB,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CA0MxE,CAAC;AAoFF,wBAAgB,2BAA2B,CACzC,IAAI,GAAE,kCAAuC,GAC5C,oBAAoB,GAAG,SAAS,CAMlC"}
@@ -89,12 +89,12 @@ export const BUILT_IN_AUTH_MARKETING = {
89
89
  "Response summaries, exports, and trend analysis on demand",
90
90
  ],
91
91
  },
92
- images: {
93
- appName: "Agent-Native Images",
94
- tagline: "Your AI agent creates, refines, and organizes on-brand images alongside you.",
92
+ assets: {
93
+ appName: "Agent-Native Assets",
94
+ tagline: "Your AI agent creates, refines, and organizes on-brand assets alongside you.",
95
95
  features: [
96
- "Build reusable brand image libraries from logos, product shots, and references",
97
- "Generate heroes, diagrams, slide art, and product visuals from a prompt",
96
+ "Build reusable asset libraries from logos, product shots, videos, and references",
97
+ "Generate heroes, diagrams, slide art, product visuals, and videos from a prompt",
98
98
  "Audit prompts, references, outputs, and refinements across every run",
99
99
  ],
100
100
  },
@@ -185,6 +185,9 @@ const SLUG_ALIASES = {
185
185
  "agent-native": "",
186
186
  "blank-app": "starter",
187
187
  "migration-goal-surface": "migration",
188
+ asset: "assets",
189
+ image: "assets",
190
+ images: "assets",
188
191
  video: "videos",
189
192
  };
190
193
  function cloneMarketing(marketing) {
@@ -1 +1 @@
1
- {"version":3,"file":"auth-marketing.js","sourceRoot":"","sources":["../../src/server/auth-marketing.ts"],"names":[],"mappings":"AAaA,MAAM,CAAC,MAAM,uBAAuB,GAAyC;IAC3E,SAAS,EAAE;QACT,OAAO,EAAE,wBAAwB;QACjC,OAAO,EACL,2GAA2G;QAC7G,QAAQ,EAAE;YACR,yEAAyE;YACzE,kEAAkE;YAClE,kEAAkE;S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","sourcesContent":["export interface AuthMarketingContent {\n appName: string;\n tagline: string;\n description?: string;\n features?: string[];\n runLocalCommand?: string;\n}\n\nexport interface ResolveBuiltInAuthMarketingOptions {\n requestHost?: string;\n requestPath?: string;\n}\n\nexport const BUILT_IN_AUTH_MARKETING: Record<string, AuthMarketingContent> = {\n analytics: {\n appName: \"Agent-Native Analytics\",\n tagline:\n \"Your AI agent queries your data sources, builds dashboards, and answers business questions alongside you.\",\n features: [\n \"Ask any question and get answers from BigQuery, HubSpot, Jira, and more\",\n \"Agent-built dashboards that pull live data from all your sources\",\n \"Saved analyses the agent can re-run on demand with fresh numbers\",\n ],\n },\n brain: {\n appName: \"Agent-Native Brain\",\n tagline:\n \"A company memory layer where raw conversations become reviewed, searchable institutional knowledge.\",\n features: [\n \"Import transcripts, notes, Slack exports, and Granola summaries\",\n \"Validate every fact against exact source quotes\",\n \"Review company-wide knowledge through proposal workflows\",\n ],\n },\n calendar: {\n appName: \"Agent-Native Calendar\",\n tagline:\n \"Your AI agent schedules, reschedules, and manages your calendar so you never have to.\",\n features: [\n \"Finds open slots and books meetings on your behalf\",\n \"Manages availability and booking links automatically\",\n \"Answers schedule questions and resolves conflicts instantly\",\n ],\n },\n calls: {\n appName: \"Agent-Native Calls\",\n tagline:\n \"Your AI agent transcribes, summarizes, and surfaces key moments from every conversation.\",\n features: [\n \"Automatic recaps, action items, and next steps after every call\",\n \"Smart trackers that detect competitor mentions, objections, and custom topics\",\n \"Shareable snippets for the exact moment that matters\",\n ],\n },\n clips: {\n appName: \"Agent-Native Clips\",\n tagline:\n \"Your AI agent transcribes, summarizes, and searches everything you record alongside you.\",\n features: [\n \"One-click screen recording with automatic titles, summaries, and chapters\",\n \"Calendar-synced meeting notes with live transcripts and action items\",\n \"One searchable library across recordings, meetings, and dictations\",\n ],\n },\n code: {\n appName: \"Agent-Native Code\",\n tagline:\n \"A customizable local Agent-Native Code UI for long-running coding sessions, slash commands, and migration goals.\",\n features: [\n \"Start and resume local coding sessions\",\n \"Use the same transcript store as the CLI and Desktop\",\n \"Customize the UI while reusing the agent-native run harness\",\n ],\n },\n content: {\n appName: \"Agent-Native Content\",\n tagline:\n \"Your AI agent creates, edits, and organizes documents alongside you in a Notion-like workspace.\",\n features: [\n \"Create and restructure entire document trees from a single prompt\",\n \"Surgical edits that sync live to your editor via real-time collaboration\",\n \"Search, summarize, and cross-reference documents instantly\",\n ],\n },\n design: {\n appName: \"Agent-Native Design\",\n tagline:\n \"Design and prototype by describing what you want. The AI agent turns your ideas into interactive, fully responsive designs in seconds.\",\n features: [\n \"Create polished prototypes just by describing them\",\n \"Build and apply design systems to keep everything on-brand\",\n \"Export your work or share it with a link\",\n ],\n },\n dispatch: {\n appName: \"Agent-Native Dispatch\",\n tagline:\n \"Your AI agent manages secrets, orchestrates other agents, and routes messages across your workspace.\",\n features: [\n \"Centralized vault for secrets with granular per-app grants\",\n \"Cross-agent orchestration and delegation to specialist apps\",\n \"Slack and Telegram routing with approval workflows\",\n ],\n },\n forms: {\n appName: \"Agent-Native Forms\",\n tagline:\n \"Your AI agent builds, publishes, and analyzes forms alongside you.\",\n features: [\n \"Create complete forms from a single sentence\",\n \"Instant publishing with shareable links and captcha\",\n \"Response summaries, exports, and trend analysis on demand\",\n ],\n },\n images: {\n appName: \"Agent-Native Images\",\n tagline:\n \"Your AI agent creates, refines, and organizes on-brand images alongside you.\",\n features: [\n \"Build reusable brand image libraries from logos, product shots, and references\",\n \"Generate heroes, diagrams, slide art, and product visuals from a prompt\",\n \"Audit prompts, references, outputs, and refinements across every run\",\n ],\n },\n mail: {\n appName: \"Agent-Native Mail\",\n tagline: \"Your AI agent reads, drafts, and organizes email alongside you.\",\n features: [\n \"Replies that match your tone and style\",\n \"Multi-account Gmail in a single unified inbox\",\n \"Autonomous triage, archiving, and follow-ups\",\n ],\n runLocalCommand:\n \"npx @agent-native/core create my-mail-app --template mail\",\n },\n \"meeting-notes\": {\n appName: \"Agent-Native Meeting Notes\",\n tagline:\n \"Your AI agent transcribes, enhances, and organizes your meeting notes while you focus on the conversation.\",\n features: [\n \"AI-enhanced meeting notes that merge raw notes with transcripts\",\n \"Smart contact and company tracking from meeting attendees\",\n \"Reusable templates for consistent note formatting\",\n ],\n },\n migration: {\n appName: \"Migration Workbench\",\n tagline:\n \"Move existing apps to agent-native with assessment, human approval, and deterministic verification.\",\n features: [\n \"Inventory routes, components, behavior, and content before touching output\",\n \"Approve plans before generated writes begin\",\n \"Verify output with structured migration reports\",\n ],\n },\n recruiting: {\n appName: \"Agent-Native Recruiting\",\n tagline:\n \"Your AI agent screens candidates, manages pipelines, and keeps your hiring on track.\",\n features: [\n \"AI resume analysis and candidate comparison\",\n \"Pipeline management with automated stage progression\",\n \"Scorecard tracking and overdue feedback alerts\",\n ],\n },\n scheduling: {\n appName: \"Agent-Native Scheduling\",\n tagline:\n \"Your AI agent manages availability, books meetings, and handles rescheduling alongside you.\",\n features: [\n \"Automatic round-robin and team scheduling across hosts\",\n \"Smart availability management with conflict detection\",\n \"Autonomous rescheduling, reminders, and follow-ups\",\n ],\n },\n slides: {\n appName: \"Agent-Native Slides\",\n tagline:\n \"Your AI agent builds, edits, and refines presentations alongside you.\",\n features: [\n \"Generate entire decks from a single prompt\",\n \"Surgical slide edits while you present or review\",\n \"Real-time collaboration between you and the agent\",\n ],\n },\n starter: {\n appName: \"Blank app\",\n tagline:\n \"Build an agent-native app where the AI agent and UI share state, actions, and context.\",\n features: [\n \"Define once, use everywhere: actions work as agent tools and API endpoints\",\n \"The agent always knows what you are looking at and can act on it\",\n \"Modify your app's own code, routes, and styles through conversation\",\n ],\n },\n videos: {\n appName: \"Agent-Native Videos\",\n tagline:\n \"Your AI agent builds, animates, and refines programmatic videos alongside you.\",\n features: [\n \"Generate animated components and compositions from a description\",\n \"Fine-tune tracks, keyframes, and easing without touching code\",\n \"Camera moves, interactive elements, and effects the agent wires for you\",\n ],\n },\n voice: {\n appName: \"Agent-Native Voice\",\n tagline:\n \"Speak to type anywhere with context-aware formatting, snippets, and custom vocabulary.\",\n features: [\n \"Push-to-talk or hands-free dictation with Whisper transcription\",\n \"Context-aware style presets for formal, casual, and excited tones\",\n \"Text expansion snippets and custom dictionary for tricky words\",\n ],\n },\n};\n\nconst SLUG_ALIASES: Record<string, string> = {\n \"agent-native\": \"\",\n \"blank-app\": \"starter\",\n \"migration-goal-surface\": \"migration\",\n video: \"videos\",\n};\n\nfunction cloneMarketing(marketing: AuthMarketingContent): AuthMarketingContent {\n return {\n ...marketing,\n features: marketing.features ? [...marketing.features] : undefined,\n };\n}\n\nfunction normalizeSlug(value: string | undefined): string | undefined {\n if (!value) return undefined;\n let slug = value.trim().toLowerCase();\n if (!slug) return undefined;\n\n slug = slug.replace(/^@agent-native\\//, \"\");\n slug = slug\n .replace(/&/g, \" and \")\n .replace(/[^a-z0-9]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\");\n slug = slug.replace(/^agent-native-/, \"\");\n slug = SLUG_ALIASES[slug] ?? slug;\n if (!slug) return undefined;\n return BUILT_IN_AUTH_MARKETING[slug] ? slug : undefined;\n}\n\nfunction slugFromUrl(value: string | undefined): string | undefined {\n if (!value) return undefined;\n try {\n const url = new URL(value);\n return slugFromHost(url.host) ?? slugFromPath(url.pathname);\n } catch {\n return undefined;\n }\n}\n\nfunction slugFromHost(value: string | undefined): string | undefined {\n if (!value) return undefined;\n const host = value.split(\",\")[0]?.trim().split(\":\")[0]?.toLowerCase();\n if (!host) return undefined;\n if (host.endsWith(\".agent-native.com\")) {\n return normalizeSlug(host.slice(0, -\".agent-native.com\".length));\n }\n return undefined;\n}\n\nfunction slugFromPath(value: string | undefined): string | undefined {\n if (!value) return undefined;\n const firstSegment = value.split(\"?\")[0]?.split(\"/\").filter(Boolean)[0];\n return normalizeSlug(firstSegment);\n}\n\nfunction candidateSlugs(\n opts: ResolveBuiltInAuthMarketingOptions = {},\n): string[] {\n const env = process.env;\n const candidates = [\n opts.requestHost ? slugFromHost(opts.requestHost) : undefined,\n opts.requestPath ? slugFromPath(opts.requestPath) : undefined,\n normalizeSlug(env.AGENT_NATIVE_TEMPLATE),\n normalizeSlug(env.APP_NAME),\n normalizeSlug(env.npm_package_name),\n slugFromPath(env.APP_BASE_PATH),\n slugFromPath(env.VITE_APP_BASE_PATH),\n slugFromUrl(env.APP_URL),\n slugFromUrl(env.BETTER_AUTH_URL),\n slugFromUrl(env.VITE_BETTER_AUTH_URL),\n slugFromUrl(env.URL),\n slugFromUrl(env.DEPLOY_URL),\n slugFromUrl(env.DEPLOY_PRIME_URL),\n ];\n\n return candidates.filter((slug): slug is string => !!slug);\n}\n\nexport function resolveBuiltInAuthMarketing(\n opts: ResolveBuiltInAuthMarketingOptions = {},\n): AuthMarketingContent | undefined {\n for (const slug of candidateSlugs(opts)) {\n const marketing = BUILT_IN_AUTH_MARKETING[slug];\n if (marketing) return cloneMarketing(marketing);\n }\n return undefined;\n}\n"]}
1
+ {"version":3,"file":"auth-marketing.js","sourceRoot":"","sources":["../../src/server/auth-marketing.ts"],"names":[],"mappings":"AAaA,MAAM,CAAC,MAAM,uBAAuB,GAAyC;IAC3E,SAAS,EAAE;QACT,OAAO,EAAE,wBAAwB;QACjC,OAAO,EACL,2GAA2G;QAC7G,QAAQ,EAAE;YACR,yEAAyE;YACzE,kEAAkE;YAClE,kEAAkE;SACnE;KACF;IACD,KAAK,EAAE;QACL,OAAO,EAAE,oBAAoB;QAC7B,OAAO,EACL,qGAAqG;QACvG,QAAQ,EAAE;YACR,iEAAiE;YACjE,iDAAiD;YACjD,0DAA0D;SAC3D;KACF;IACD,QAAQ,EAAE;QACR,OAAO,EAAE,uBAAuB;QAChC,OAAO,EACL,uFAAuF;QACzF,QAAQ,EAAE;YACR,oDAAoD;YACpD,sDAAsD;YACtD,6DAA6D;SAC9D;KACF;IACD,KAAK,EAAE;QACL,OAAO,EAAE,oBAAoB;QAC7B,OAAO,EACL,0FAA0F;QAC5F,QAAQ,EAAE;YACR,iEAAiE;YACjE,+EAA+E;YAC/E,sDAAsD;SACvD;KACF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AAa,CAAC,GAAG,CAAC,qBAAqB,CAAC;QACxC,aAAa,CAAC,GAAG,CAAC,QAAQ,CAAC;QAC3B,aAAa,CAAC,GAAG,CAAC,gBAAgB,CAAC;QACnC,YAAY,CAAC,GAAG,CAAC,aAAa,CAAC;QAC/B,YAAY,CAAC,GAAG,CAAC,kBAAkB,CAAC;QACpC,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC;QACxB,WAAW,CAAC,GAAG,CAAC,eAAe,CAAC;QAChC,WAAW,CAAC,GAAG,CAAC,oBAAoB,CAAC;QACrC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC;QACpB,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC;QAC3B,WAAW,CAAC,GAAG,CAAC,gBAAgB,CAAC;KAClC,CAAC;IAEF,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC,IAAI,EAAkB,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AAC7D,CAAC;AAED,MAAM,UAAU,2BAA2B,CACzC,OAA2C,EAAE;IAE7C,KAAK,MAAM,IAAI,IAAI,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC;QACxC,MAAM,SAAS,GAAG,uBAAuB,CAAC,IAAI,CAAC,CAAC;QAChD,IAAI,SAAS;YAAE,OAAO,cAAc,CAAC,SAAS,CAAC,CAAC;IAClD,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["export interface AuthMarketingContent {\n appName: string;\n tagline: string;\n description?: string;\n features?: string[];\n runLocalCommand?: string;\n}\n\nexport interface ResolveBuiltInAuthMarketingOptions {\n requestHost?: string;\n requestPath?: string;\n}\n\nexport const BUILT_IN_AUTH_MARKETING: Record<string, AuthMarketingContent> = {\n analytics: {\n appName: \"Agent-Native Analytics\",\n tagline:\n \"Your AI agent queries your data sources, builds dashboards, and answers business questions alongside you.\",\n features: [\n \"Ask any question and get answers from BigQuery, HubSpot, Jira, and more\",\n \"Agent-built dashboards that pull live data from all your sources\",\n \"Saved analyses the agent can re-run on demand with fresh numbers\",\n ],\n },\n brain: {\n appName: \"Agent-Native Brain\",\n tagline:\n \"A company memory layer where raw conversations become reviewed, searchable institutional knowledge.\",\n features: [\n \"Import transcripts, notes, Slack exports, and Granola summaries\",\n \"Validate every fact against exact source quotes\",\n \"Review company-wide knowledge through proposal workflows\",\n ],\n },\n calendar: {\n appName: \"Agent-Native Calendar\",\n tagline:\n \"Your AI agent schedules, reschedules, and manages your calendar so you never have to.\",\n features: [\n \"Finds open slots and books meetings on your behalf\",\n \"Manages availability and booking links automatically\",\n \"Answers schedule questions and resolves conflicts instantly\",\n ],\n },\n calls: {\n appName: \"Agent-Native Calls\",\n tagline:\n \"Your AI agent transcribes, summarizes, and surfaces key moments from every conversation.\",\n features: [\n \"Automatic recaps, action items, and next steps after every call\",\n \"Smart trackers that detect competitor mentions, objections, and custom topics\",\n \"Shareable snippets for the exact moment that matters\",\n ],\n },\n clips: {\n appName: \"Agent-Native Clips\",\n tagline:\n \"Your AI agent transcribes, summarizes, and searches everything you record alongside you.\",\n features: [\n \"One-click screen recording with automatic titles, summaries, and chapters\",\n \"Calendar-synced meeting notes with live transcripts and action items\",\n \"One searchable library across recordings, meetings, and dictations\",\n ],\n },\n code: {\n appName: \"Agent-Native Code\",\n tagline:\n \"A customizable local Agent-Native Code UI for long-running coding sessions, slash commands, and migration goals.\",\n features: [\n \"Start and resume local coding sessions\",\n \"Use the same transcript store as the CLI and Desktop\",\n \"Customize the UI while reusing the agent-native run harness\",\n ],\n },\n content: {\n appName: \"Agent-Native Content\",\n tagline:\n \"Your AI agent creates, edits, and organizes documents alongside you in a Notion-like workspace.\",\n features: [\n \"Create and restructure entire document trees from a single prompt\",\n \"Surgical edits that sync live to your editor via real-time collaboration\",\n \"Search, summarize, and cross-reference documents instantly\",\n ],\n },\n design: {\n appName: \"Agent-Native Design\",\n tagline:\n \"Design and prototype by describing what you want. The AI agent turns your ideas into interactive, fully responsive designs in seconds.\",\n features: [\n \"Create polished prototypes just by describing them\",\n \"Build and apply design systems to keep everything on-brand\",\n \"Export your work or share it with a link\",\n ],\n },\n dispatch: {\n appName: \"Agent-Native Dispatch\",\n tagline:\n \"Your AI agent manages secrets, orchestrates other agents, and routes messages across your workspace.\",\n features: [\n \"Centralized vault for secrets with granular per-app grants\",\n \"Cross-agent orchestration and delegation to specialist apps\",\n \"Slack and Telegram routing with approval workflows\",\n ],\n },\n forms: {\n appName: \"Agent-Native Forms\",\n tagline:\n \"Your AI agent builds, publishes, and analyzes forms alongside you.\",\n features: [\n \"Create complete forms from a single sentence\",\n \"Instant publishing with shareable links and captcha\",\n \"Response summaries, exports, and trend analysis on demand\",\n ],\n },\n assets: {\n appName: \"Agent-Native Assets\",\n tagline:\n \"Your AI agent creates, refines, and organizes on-brand assets alongside you.\",\n features: [\n \"Build reusable asset libraries from logos, product shots, videos, and references\",\n \"Generate heroes, diagrams, slide art, product visuals, and videos from a prompt\",\n \"Audit prompts, references, outputs, and refinements across every run\",\n ],\n },\n mail: {\n appName: \"Agent-Native Mail\",\n tagline: \"Your AI agent reads, drafts, and organizes email alongside you.\",\n features: [\n \"Replies that match your tone and style\",\n \"Multi-account Gmail in a single unified inbox\",\n \"Autonomous triage, archiving, and follow-ups\",\n ],\n runLocalCommand:\n \"npx @agent-native/core create my-mail-app --template mail\",\n },\n \"meeting-notes\": {\n appName: \"Agent-Native Meeting Notes\",\n tagline:\n \"Your AI agent transcribes, enhances, and organizes your meeting notes while you focus on the conversation.\",\n features: [\n \"AI-enhanced meeting notes that merge raw notes with transcripts\",\n \"Smart contact and company tracking from meeting attendees\",\n \"Reusable templates for consistent note formatting\",\n ],\n },\n migration: {\n appName: \"Migration Workbench\",\n tagline:\n \"Move existing apps to agent-native with assessment, human approval, and deterministic verification.\",\n features: [\n \"Inventory routes, components, behavior, and content before touching output\",\n \"Approve plans before generated writes begin\",\n \"Verify output with structured migration reports\",\n ],\n },\n recruiting: {\n appName: \"Agent-Native Recruiting\",\n tagline:\n \"Your AI agent screens candidates, manages pipelines, and keeps your hiring on track.\",\n features: [\n \"AI resume analysis and candidate comparison\",\n \"Pipeline management with automated stage progression\",\n \"Scorecard tracking and overdue feedback alerts\",\n ],\n },\n scheduling: {\n appName: \"Agent-Native Scheduling\",\n tagline:\n \"Your AI agent manages availability, books meetings, and handles rescheduling alongside you.\",\n features: [\n \"Automatic round-robin and team scheduling across hosts\",\n \"Smart availability management with conflict detection\",\n \"Autonomous rescheduling, reminders, and follow-ups\",\n ],\n },\n slides: {\n appName: \"Agent-Native Slides\",\n tagline:\n \"Your AI agent builds, edits, and refines presentations alongside you.\",\n features: [\n \"Generate entire decks from a single prompt\",\n \"Surgical slide edits while you present or review\",\n \"Real-time collaboration between you and the agent\",\n ],\n },\n starter: {\n appName: \"Blank app\",\n tagline:\n \"Build an agent-native app where the AI agent and UI share state, actions, and context.\",\n features: [\n \"Define once, use everywhere: actions work as agent tools and API endpoints\",\n \"The agent always knows what you are looking at and can act on it\",\n \"Modify your app's own code, routes, and styles through conversation\",\n ],\n },\n videos: {\n appName: \"Agent-Native Videos\",\n tagline:\n \"Your AI agent builds, animates, and refines programmatic videos alongside you.\",\n features: [\n \"Generate animated components and compositions from a description\",\n \"Fine-tune tracks, keyframes, and easing without touching code\",\n \"Camera moves, interactive elements, and effects the agent wires for you\",\n ],\n },\n voice: {\n appName: \"Agent-Native Voice\",\n tagline:\n \"Speak to type anywhere with context-aware formatting, snippets, and custom vocabulary.\",\n features: [\n \"Push-to-talk or hands-free dictation with Whisper transcription\",\n \"Context-aware style presets for formal, casual, and excited tones\",\n \"Text expansion snippets and custom dictionary for tricky words\",\n ],\n },\n};\n\nconst SLUG_ALIASES: Record<string, string> = {\n \"agent-native\": \"\",\n \"blank-app\": \"starter\",\n \"migration-goal-surface\": \"migration\",\n asset: \"assets\",\n image: \"assets\",\n images: \"assets\",\n video: \"videos\",\n};\n\nfunction cloneMarketing(marketing: AuthMarketingContent): AuthMarketingContent {\n return {\n ...marketing,\n features: marketing.features ? [...marketing.features] : undefined,\n };\n}\n\nfunction normalizeSlug(value: string | undefined): string | undefined {\n if (!value) return undefined;\n let slug = value.trim().toLowerCase();\n if (!slug) return undefined;\n\n slug = slug.replace(/^@agent-native\\//, \"\");\n slug = slug\n .replace(/&/g, \" and \")\n .replace(/[^a-z0-9]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\");\n slug = slug.replace(/^agent-native-/, \"\");\n slug = SLUG_ALIASES[slug] ?? slug;\n if (!slug) return undefined;\n return BUILT_IN_AUTH_MARKETING[slug] ? slug : undefined;\n}\n\nfunction slugFromUrl(value: string | undefined): string | undefined {\n if (!value) return undefined;\n try {\n const url = new URL(value);\n return slugFromHost(url.host) ?? slugFromPath(url.pathname);\n } catch {\n return undefined;\n }\n}\n\nfunction slugFromHost(value: string | undefined): string | undefined {\n if (!value) return undefined;\n const host = value.split(\",\")[0]?.trim().split(\":\")[0]?.toLowerCase();\n if (!host) return undefined;\n if (host.endsWith(\".agent-native.com\")) {\n return normalizeSlug(host.slice(0, -\".agent-native.com\".length));\n }\n return undefined;\n}\n\nfunction slugFromPath(value: string | undefined): string | undefined {\n if (!value) return undefined;\n const firstSegment = value.split(\"?\")[0]?.split(\"/\").filter(Boolean)[0];\n return normalizeSlug(firstSegment);\n}\n\nfunction candidateSlugs(\n opts: ResolveBuiltInAuthMarketingOptions = {},\n): string[] {\n const env = process.env;\n const candidates = [\n opts.requestHost ? slugFromHost(opts.requestHost) : undefined,\n opts.requestPath ? slugFromPath(opts.requestPath) : undefined,\n normalizeSlug(env.AGENT_NATIVE_TEMPLATE),\n normalizeSlug(env.APP_NAME),\n normalizeSlug(env.npm_package_name),\n slugFromPath(env.APP_BASE_PATH),\n slugFromPath(env.VITE_APP_BASE_PATH),\n slugFromUrl(env.APP_URL),\n slugFromUrl(env.BETTER_AUTH_URL),\n slugFromUrl(env.VITE_BETTER_AUTH_URL),\n slugFromUrl(env.URL),\n slugFromUrl(env.DEPLOY_URL),\n slugFromUrl(env.DEPLOY_PRIME_URL),\n ];\n\n return candidates.filter((slug): slug is string => !!slug);\n}\n\nexport function resolveBuiltInAuthMarketing(\n opts: ResolveBuiltInAuthMarketingOptions = {},\n): AuthMarketingContent | undefined {\n for (const slug of candidateSlugs(opts)) {\n const marketing = BUILT_IN_AUTH_MARKETING[slug];\n if (marketing) return cloneMarketing(marketing);\n }\n return undefined;\n}\n"]}
@@ -6,12 +6,19 @@ This is an **@agent-native/core** application -- the AI agent and UI share state
6
6
 
7
7
  ### Core Principles
8
8
 
9
- 1. **Shared SQL database** -- All app state lives in SQL (SQLite locally, cloud DB via `DATABASE_URL` in production). Core stores: `application_state`, `settings`, `oauth_tokens`, `sessions`, `resources`.
9
+ 1. **Shared SQL database** -- All app state lives in SQL. Local SQLite at `data/app.db` is the zero-setup dev fallback; deployed apps need a persistent `DATABASE_URL` so data survives container/serverless restarts. Turso is optional, not required: Neon, Supabase, Turso/libSQL, plain Postgres, durable SQLite, D1 bindings, and Builder.io-managed environments are all valid when supported by the deploy. Core stores: `application_state`, `settings`, `oauth_tokens`, `sessions`, `resources`.
10
10
  2. **All AI through agent chat** -- No inline LLM calls. UI delegates to the AI via `sendToAgentChat()` / `agentChat.submit()`.
11
11
  3. **Actions for agent operations** -- `pnpm action <name>` dispatches to callable action files in `actions/`.
12
12
  4. **Live sync keeps the UI current** -- Database writes stream over `/_agent-native/events` first, with `/_agent-native/poll` as the fallback. **When you (the agent) write data, the UI must reflect the change without a manual refresh.** This is non-negotiable. Use `useActionQuery` / `useActionMutation` for action-backed data (preferred). If you use raw `useQuery`, fold `useChangeVersions([<source>, "action"])` into the key for targeted refreshes. See the `real-time-sync` and `adding-a-feature` skills.
13
13
  5. **Agent can update code** -- The agent can modify this app's source code directly.
14
14
 
15
+ ### Database Code
16
+
17
+ - Define tables with `@agent-native/core/db/schema` helpers (`table`, `text`, `integer`, `real`, `now`, sharing helpers), never `drizzle-orm/sqlite-core` or `drizzle-orm/pg-core`.
18
+ - Use Drizzle's query builder (`db.select`, `db.insert`, `db.update`, `db.delete`) plus portable operators from `drizzle-orm` (`eq`, `and`, `or`, `inArray`, `desc`, etc.) for app reads and writes.
19
+ - Keep raw SQL out of normal actions, handlers, and stores. Use it only for additive migrations, health checks, or last-resort maintenance, and keep it parameterized and dialect-agnostic.
20
+ - Do not write SQLite-only or Postgres-only syntax in product code. The same app should run on SQLite, Postgres, libSQL/Turso, D1, and other supported Drizzle backends.
21
+
15
22
  ### Authentication
16
23
 
17
24
  Auth is automatic and environment-driven:
@@ -77,12 +84,13 @@ You do NOT get auto-injected screen state. **Call `pnpm action view-screen` at t
77
84
  | `hello` | `[--name <name>]` | Example script |
78
85
  | `db-schema` | | Show all tables, columns, types |
79
86
  | `db-query` | `--sql "SELECT ..."` | Run a SELECT query |
80
- | `db-exec` | `--sql "INSERT ..."` | Run INSERT/UPDATE/DELETE (use for short/multi-column writes) |
87
+ | `db-exec` | `--sql "UPDATE ..."` | Last-resort ad-hoc maintenance; prefer domain actions and Drizzle code for product work |
81
88
  | `db-patch` | `--table <t> --column <c> --where "<clause>" --find "<old>" --replace "<new>"` | Surgical search/replace on a large text column — sends a diff instead of the full value |
82
89
 
83
- **Pick the right SQL tool:**
90
+ **For one-off maintenance, pick the right SQL tool:**
84
91
 
85
- - Use `db-exec UPDATE` for short columns, multi-column writes, or computed updates.
92
+ - Use domain actions first. They validate input, enforce access, and refresh the UI.
93
+ - Use `db-exec UPDATE` only when no domain action exists and you need a small ad-hoc change.
86
94
  - Use `db-patch` when you only need to tweak a small slice of a **large** text/JSON column (documents, slide HTML, dashboard/form JSON). It saves tokens by sending `{find, replace}` instead of re-transmitting the whole column. Targets exactly one row per call — narrow `--where` by primary key. Supports `--edits '[{find,replace},...]'` for batch edits and `--all` for replace-every-occurrence.
87
95
  - If a template-specific action exists (e.g. `edit-document`, `update-slide`), prefer it — those also push live updates to any open collaborative editor.
88
96
 
@@ -110,12 +110,14 @@ agentChat.submit("Generate something");
110
110
 
111
111
  ## Database
112
112
 
113
- By default, data is stored in SQLite at `data/app.db`. For production/cloud deployment, set `DATABASE_URL` to point to a remote database (Turso, Neon, Supabase, D1).
113
+ Local development defaults to a SQLite file at `data/app.db`. That local file is for development; containers, previews, and serverless deploys can reset their filesystem. For production/cloud deployment, set `DATABASE_URL` to point to a persistent SQL database. Turso is optional, not required; common choices include Neon, Supabase, Turso/libSQL, plain Postgres, durable SQLite, D1 bindings, and Builder.io-managed environments when available.
114
114
 
115
- | Variable | Required | Description |
116
- | --------------------- | ---------------- | ---------------------------------------------------------- |
117
- | `DATABASE_URL` | No (has default) | Database connection string (default: `file:./data/app.db`) |
118
- | `DATABASE_AUTH_TOKEN` | For remote DBs | Auth token for Turso or other remote databases |
115
+ When adding app data, define tables with `@agent-native/core/db/schema` helpers and use Drizzle's query builder for reads/writes. Do not import dialect-specific schema helpers from `drizzle-orm/sqlite-core` or `drizzle-orm/pg-core`, and do not write raw SQL in normal actions or handlers when Drizzle can express the query. Raw SQL belongs in additive migrations, health checks, or carefully scoped maintenance.
116
+
117
+ | Variable | Required | Description |
118
+ | --------------------- | ------------------------------- | -------------------------------------------------------------------------- |
119
+ | `DATABASE_URL` | Production yes, local dev no | Persistent SQL connection string (local dev default: `file:./data/app.db`) |
120
+ | `DATABASE_AUTH_TOKEN` | Only when the provider needs it | Auth token for providers such as Turso/libSQL |
119
121
 
120
122
  ## Tech Stack
121
123
 
@@ -77,6 +77,13 @@ the same data unless the route is for uploads, streaming, webhooks, OAuth, or
77
77
  another route-only concern. Action-backed UI is what makes agent-created or
78
78
  agent-edited records appear without a manual refresh.
79
79
 
80
+ App database code must be provider-agnostic. Define schemas with
81
+ `@agent-native/core/db/schema` helpers and write app reads/writes with Drizzle's
82
+ query builder and portable `drizzle-orm` operators. Do not import from
83
+ `drizzle-orm/sqlite-core` or `drizzle-orm/pg-core` in app templates. Keep raw SQL
84
+ for additive migrations, health checks, or carefully scoped maintenance, and
85
+ never write SQLite-only or Postgres-only product code.
86
+
80
87
  In local development, run
81
88
  `pnpm exec agent-native create <app-name> --template=<template>` from the
82
89
  workspace root. In production, Dispatch posts new-app requests to Builder
@@ -102,6 +102,12 @@ coding agents can discover the same workspace-wide guidance from the root.
102
102
  for the same data unless the route is for uploads, streaming, webhooks,
103
103
  OAuth, or another route-only concern. Action-backed UI is what makes
104
104
  agent-created or agent-edited records appear without a manual refresh.
105
+ - App database code must be provider-agnostic. Define schemas with
106
+ `@agent-native/core/db/schema` helpers and write app reads/writes with
107
+ Drizzle's query builder and portable `drizzle-orm` operators. Do not import
108
+ from `drizzle-orm/sqlite-core` or `drizzle-orm/pg-core` in app templates.
109
+ Keep raw SQL for additive migrations, health checks, or carefully scoped
110
+ maintenance, and never write SQLite-only or Postgres-only product code.
105
111
  - In local development, scaffold the app from the workspace root with
106
112
  `pnpm exec agent-native create <app-id> --template=<template>`. In production
107
113
  Dispatch posts the request to Builder branch creation; the Builder branch
@@ -70,7 +70,7 @@ Do not add a `data/` directory for application state. Durable app data belongs i
70
70
 
71
71
  ## Model Data In SQL {#data-models}
72
72
 
73
- Define domain tables with the framework Drizzle helpers so schemas stay portable across SQLite, Postgres, D1, Turso, Supabase, and Neon:
73
+ Define domain tables with the framework Drizzle helpers so schemas stay portable across SQLite, Postgres, D1, Turso, Supabase, Neon, and other supported backends:
74
74
 
75
75
  ```ts
76
76
  // server/db/schema.ts
@@ -102,14 +102,17 @@ export const projectShares = createSharesTable("project_shares", "project");
102
102
 
103
103
  Schema changes must be additive. Add tables and columns through `runMigrations()` in `server/plugins/db.ts`; never use destructive SQL, `drizzle-kit push`, table renames, or column drops.
104
104
 
105
+ For app reads and writes, use Drizzle's query builder and portable operators from `drizzle-orm`. Do not write product code with raw SQL when Drizzle can express the query, and do not import from `drizzle-orm/sqlite-core` or `drizzle-orm/pg-core` in templates.
106
+
105
107
  ```ts
106
108
  // server/plugins/db.ts
107
- import { runMigrations } from "@agent-native/core/db/migrations";
109
+ import { runMigrations } from "@agent-native/core/db";
108
110
 
109
- export default runMigrations([
110
- {
111
- id: "001_create_projects",
112
- sql: `CREATE TABLE IF NOT EXISTS projects (
111
+ export default runMigrations(
112
+ [
113
+ {
114
+ version: 1,
115
+ sql: `CREATE TABLE IF NOT EXISTS projects (
113
116
  id TEXT PRIMARY KEY,
114
117
  title TEXT NOT NULL,
115
118
  status TEXT NOT NULL DEFAULT 'draft',
@@ -120,8 +123,10 @@ export default runMigrations([
120
123
  created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
121
124
  updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP
122
125
  )`,
123
- },
124
- ]);
126
+ },
127
+ ],
128
+ { table: "my_app_migrations" },
129
+ );
125
130
  ```
126
131
 
127
132
  Use the [Database](/docs/database) and [Security](/docs/security) docs before adding schemas that hold user or org data.
@@ -273,7 +278,7 @@ Projects are the top-level resource. They contain tasks and notes.
273
278
  ## Rules
274
279
 
275
280
  - Use `view-screen` before acting on "this project" if the current screen is unclear.
276
- - Use actions for project changes; do not write raw SQL unless debugging.
281
+ - Use actions for project changes; do not write raw SQL except for one-off maintenance/debugging when no action exists.
277
282
  - For shared projects, check access through framework sharing helpers.
278
283
  ```
279
284