@agent-native/core 0.96.0 → 0.98.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 (1241) hide show
  1. package/README.md +6 -0
  2. package/corpus/README.md +2 -2
  3. package/corpus/core/CHANGELOG.md +71 -0
  4. package/corpus/core/docs/content/audit-log.mdx +2 -1
  5. package/corpus/core/docs/content/authentication.mdx +3 -3
  6. package/corpus/core/docs/content/automations.mdx +7 -7
  7. package/corpus/core/docs/content/creating-templates.mdx +1 -1
  8. package/corpus/core/docs/content/doctor.mdx +170 -0
  9. package/corpus/core/docs/content/external-agents.mdx +8 -7
  10. package/corpus/core/docs/content/internationalization.mdx +2 -1
  11. package/corpus/core/docs/content/locales/ar-SA/audit-log.mdx +2 -1
  12. package/corpus/core/docs/content/locales/ar-SA/authentication.mdx +2 -2
  13. package/corpus/core/docs/content/locales/ar-SA/automations.mdx +7 -7
  14. package/corpus/core/docs/content/locales/ar-SA/external-agents.mdx +8 -7
  15. package/corpus/core/docs/content/locales/ar-SA/getting-started.mdx +7 -1
  16. package/corpus/core/docs/content/locales/ar-SA/internationalization.mdx +1 -1
  17. package/corpus/core/docs/content/locales/ar-SA/mcp-protocol.mdx +1 -1
  18. package/corpus/core/docs/content/locales/ar-SA/package-lifecycle.mdx +19 -0
  19. package/corpus/core/docs/content/locales/ar-SA/sandbox-adapters.mdx +18 -7
  20. package/corpus/core/docs/content/locales/ar-SA/security.mdx +10 -0
  21. package/corpus/core/docs/content/locales/de-DE/audit-log.mdx +2 -1
  22. package/corpus/core/docs/content/locales/de-DE/authentication.mdx +1 -1
  23. package/corpus/core/docs/content/locales/de-DE/automations.mdx +7 -7
  24. package/corpus/core/docs/content/locales/de-DE/external-agents.mdx +8 -7
  25. package/corpus/core/docs/content/locales/de-DE/getting-started.mdx +7 -1
  26. package/corpus/core/docs/content/locales/de-DE/internationalization.mdx +1 -1
  27. package/corpus/core/docs/content/locales/de-DE/mcp-protocol.mdx +1 -1
  28. package/corpus/core/docs/content/locales/de-DE/package-lifecycle.mdx +22 -0
  29. package/corpus/core/docs/content/locales/de-DE/sandbox-adapters.mdx +18 -7
  30. package/corpus/core/docs/content/locales/de-DE/security.mdx +10 -0
  31. package/corpus/core/docs/content/locales/es-ES/audit-log.mdx +2 -1
  32. package/corpus/core/docs/content/locales/es-ES/authentication.mdx +2 -2
  33. package/corpus/core/docs/content/locales/es-ES/automations.mdx +7 -7
  34. package/corpus/core/docs/content/locales/es-ES/external-agents.mdx +8 -7
  35. package/corpus/core/docs/content/locales/es-ES/getting-started.mdx +7 -1
  36. package/corpus/core/docs/content/locales/es-ES/internationalization.mdx +1 -1
  37. package/corpus/core/docs/content/locales/es-ES/mcp-protocol.mdx +1 -1
  38. package/corpus/core/docs/content/locales/es-ES/package-lifecycle.mdx +22 -0
  39. package/corpus/core/docs/content/locales/es-ES/sandbox-adapters.mdx +18 -7
  40. package/corpus/core/docs/content/locales/es-ES/security.mdx +10 -0
  41. package/corpus/core/docs/content/locales/fr-FR/audit-log.mdx +2 -1
  42. package/corpus/core/docs/content/locales/fr-FR/authentication.mdx +1 -1
  43. package/corpus/core/docs/content/locales/fr-FR/automations.mdx +7 -7
  44. package/corpus/core/docs/content/locales/fr-FR/external-agents.mdx +8 -7
  45. package/corpus/core/docs/content/locales/fr-FR/getting-started.mdx +7 -1
  46. package/corpus/core/docs/content/locales/fr-FR/internationalization.mdx +1 -1
  47. package/corpus/core/docs/content/locales/fr-FR/mcp-protocol.mdx +1 -1
  48. package/corpus/core/docs/content/locales/fr-FR/package-lifecycle.mdx +21 -0
  49. package/corpus/core/docs/content/locales/fr-FR/sandbox-adapters.mdx +19 -8
  50. package/corpus/core/docs/content/locales/fr-FR/security.mdx +10 -0
  51. package/corpus/core/docs/content/locales/hi-IN/audit-log.mdx +2 -1
  52. package/corpus/core/docs/content/locales/hi-IN/authentication.mdx +2 -2
  53. package/corpus/core/docs/content/locales/hi-IN/automations.mdx +7 -7
  54. package/corpus/core/docs/content/locales/hi-IN/external-agents.mdx +8 -7
  55. package/corpus/core/docs/content/locales/hi-IN/getting-started.mdx +7 -1
  56. package/corpus/core/docs/content/locales/hi-IN/internationalization.mdx +1 -1
  57. package/corpus/core/docs/content/locales/hi-IN/mcp-protocol.mdx +1 -1
  58. package/corpus/core/docs/content/locales/hi-IN/package-lifecycle.mdx +20 -0
  59. package/corpus/core/docs/content/locales/hi-IN/sandbox-adapters.mdx +18 -7
  60. package/corpus/core/docs/content/locales/hi-IN/security.mdx +10 -0
  61. package/corpus/core/docs/content/locales/ja-JP/audit-log.mdx +2 -1
  62. package/corpus/core/docs/content/locales/ja-JP/authentication.mdx +2 -2
  63. package/corpus/core/docs/content/locales/ja-JP/automations.mdx +7 -7
  64. package/corpus/core/docs/content/locales/ja-JP/external-agents.mdx +8 -7
  65. package/corpus/core/docs/content/locales/ja-JP/getting-started.mdx +7 -1
  66. package/corpus/core/docs/content/locales/ja-JP/internationalization.mdx +1 -1
  67. package/corpus/core/docs/content/locales/ja-JP/mcp-protocol.mdx +1 -1
  68. package/corpus/core/docs/content/locales/ja-JP/package-lifecycle.mdx +21 -0
  69. package/corpus/core/docs/content/locales/ja-JP/sandbox-adapters.mdx +17 -6
  70. package/corpus/core/docs/content/locales/ja-JP/security.mdx +10 -0
  71. package/corpus/core/docs/content/locales/ko-KR/audit-log.mdx +2 -1
  72. package/corpus/core/docs/content/locales/ko-KR/authentication.mdx +2 -2
  73. package/corpus/core/docs/content/locales/ko-KR/automations.mdx +7 -7
  74. package/corpus/core/docs/content/locales/ko-KR/external-agents.mdx +8 -7
  75. package/corpus/core/docs/content/locales/ko-KR/getting-started.mdx +7 -1
  76. package/corpus/core/docs/content/locales/ko-KR/internationalization.mdx +1 -1
  77. package/corpus/core/docs/content/locales/ko-KR/mcp-protocol.mdx +1 -1
  78. package/corpus/core/docs/content/locales/ko-KR/package-lifecycle.mdx +20 -0
  79. package/corpus/core/docs/content/locales/ko-KR/sandbox-adapters.mdx +17 -6
  80. package/corpus/core/docs/content/locales/ko-KR/security.mdx +10 -0
  81. package/corpus/core/docs/content/locales/pt-BR/audit-log.mdx +2 -1
  82. package/corpus/core/docs/content/locales/pt-BR/authentication.mdx +2 -2
  83. package/corpus/core/docs/content/locales/pt-BR/automations.mdx +7 -7
  84. package/corpus/core/docs/content/locales/pt-BR/external-agents.mdx +8 -7
  85. package/corpus/core/docs/content/locales/pt-BR/getting-started.mdx +7 -1
  86. package/corpus/core/docs/content/locales/pt-BR/internationalization.mdx +1 -1
  87. package/corpus/core/docs/content/locales/pt-BR/mcp-protocol.mdx +1 -1
  88. package/corpus/core/docs/content/locales/pt-BR/package-lifecycle.mdx +21 -0
  89. package/corpus/core/docs/content/locales/pt-BR/sandbox-adapters.mdx +18 -7
  90. package/corpus/core/docs/content/locales/pt-BR/security.mdx +10 -0
  91. package/corpus/core/docs/content/locales/zh-CN/audit-log.mdx +2 -1
  92. package/corpus/core/docs/content/locales/zh-CN/authentication.mdx +2 -2
  93. package/corpus/core/docs/content/locales/zh-CN/automations.mdx +7 -7
  94. package/corpus/core/docs/content/locales/zh-CN/external-agents.mdx +8 -7
  95. package/corpus/core/docs/content/locales/zh-CN/getting-started.mdx +6 -4
  96. package/corpus/core/docs/content/locales/zh-CN/internationalization.mdx +1 -1
  97. package/corpus/core/docs/content/locales/zh-CN/mcp-protocol.mdx +1 -1
  98. package/corpus/core/docs/content/locales/zh-CN/package-lifecycle.mdx +19 -0
  99. package/corpus/core/docs/content/locales/zh-CN/sandbox-adapters.mdx +17 -6
  100. package/corpus/core/docs/content/locales/zh-CN/security.mdx +10 -0
  101. package/corpus/core/docs/content/locales/zh-TW/audit-log.mdx +2 -1
  102. package/corpus/core/docs/content/locales/zh-TW/authentication.mdx +2 -2
  103. package/corpus/core/docs/content/locales/zh-TW/automations.mdx +7 -7
  104. package/corpus/core/docs/content/locales/zh-TW/external-agents.mdx +8 -7
  105. package/corpus/core/docs/content/locales/zh-TW/getting-started.mdx +6 -4
  106. package/corpus/core/docs/content/locales/zh-TW/internationalization.mdx +1 -1
  107. package/corpus/core/docs/content/locales/zh-TW/mcp-protocol.mdx +1 -1
  108. package/corpus/core/docs/content/locales/zh-TW/package-lifecycle.mdx +19 -0
  109. package/corpus/core/docs/content/locales/zh-TW/sandbox-adapters.mdx +18 -7
  110. package/corpus/core/docs/content/locales/zh-TW/security.mdx +10 -0
  111. package/corpus/core/docs/content/mcp-protocol.mdx +1 -1
  112. package/corpus/core/docs/content/package-lifecycle.mdx +51 -0
  113. package/corpus/core/docs/content/sandbox-adapters.mdx +16 -5
  114. package/corpus/core/docs/content/security.mdx +2 -0
  115. package/corpus/core/package.json +13 -2
  116. package/corpus/core/scripts/finalize-build.mjs +63 -3
  117. package/corpus/core/scripts/materialize-source-corpus.mjs +101 -15
  118. package/corpus/core/src/a2a/auth-policy.ts +33 -0
  119. package/corpus/core/src/action.ts +42 -0
  120. package/corpus/core/src/agent/durable-background.ts +15 -7
  121. package/corpus/core/src/agent/engine/builder-engine.ts +3 -0
  122. package/corpus/core/src/agent/engine/context-directives-transform.ts +69 -0
  123. package/corpus/core/src/agent/engine/continuation-dispatch-retry.ts +168 -0
  124. package/corpus/core/src/agent/engine/tool-call-journal-seed.ts +85 -0
  125. package/corpus/core/src/agent/production-agent.ts +129 -244
  126. package/corpus/core/src/agent/run-store.ts +13 -4
  127. package/corpus/core/src/audit/actions/export-audit-events.ts +162 -0
  128. package/corpus/core/src/audit/store.ts +8 -3
  129. package/corpus/core/src/audit/types.ts +3 -0
  130. package/corpus/core/src/cli/doctor.ts +402 -0
  131. package/corpus/core/src/cli/index.ts +56 -0
  132. package/corpus/core/src/cli/info.ts +3 -3
  133. package/corpus/core/src/cli/package-lifecycle.ts +821 -0
  134. package/corpus/core/src/cli/plan-local.ts +10 -2
  135. package/corpus/core/src/cli/skills-content/assets-skill.ts +83 -0
  136. package/corpus/core/src/cli/skills-content/canvas.ts +153 -0
  137. package/corpus/core/src/cli/skills-content/connection.ts +52 -0
  138. package/corpus/core/src/cli/skills-content/content-skill.ts +109 -0
  139. package/corpus/core/src/cli/skills-content/design-exploration-skill.ts +118 -0
  140. package/corpus/core/src/cli/skills-content/design-visual-edit-skill.ts +228 -0
  141. package/corpus/core/src/cli/skills-content/document-quality.ts +196 -0
  142. package/corpus/core/src/cli/skills-content/exemplar.ts +69 -0
  143. package/corpus/core/src/cli/skills-content/help.ts +77 -0
  144. package/corpus/core/src/cli/skills-content/index.ts +22 -0
  145. package/corpus/core/src/cli/skills-content/local-files.ts +95 -0
  146. package/corpus/core/src/cli/skills-content/plan-setup-auth.ts +80 -0
  147. package/corpus/core/src/cli/skills-content/visual-plan-skill.ts +470 -0
  148. package/corpus/core/src/cli/skills-content/visual-recap-skill.ts +547 -0
  149. package/corpus/core/src/cli/skills-content/visualize-repo-skill.ts +93 -0
  150. package/corpus/core/src/cli/skills-content/wireframe.ts +349 -0
  151. package/corpus/core/src/cli/skills.ts +27 -2733
  152. package/corpus/core/src/client/AgentPanel.tsx +6 -5
  153. package/corpus/core/src/client/CommandMenu.tsx +16 -5
  154. package/corpus/core/src/client/FeedbackButton.tsx +2 -2
  155. package/corpus/core/src/client/agent-chat-adapter.ts +9 -9
  156. package/corpus/core/src/client/app-providers.tsx +18 -5
  157. package/corpus/core/src/client/chat/tool-call-display.tsx +3 -3
  158. package/corpus/core/src/client/composer/PastedTextChip.tsx +1 -1
  159. package/corpus/core/src/client/composer/RealtimeVoiceMode.tsx +143 -45
  160. package/corpus/core/src/client/composer/TiptapComposer.tsx +1 -1
  161. package/corpus/core/src/client/composer/VoiceButton.tsx +21 -5
  162. package/corpus/core/src/client/composer/useRealtimeVoiceMode.tsx +107 -10
  163. package/corpus/core/src/client/context-xray/ContextXRayPanel.tsx +5 -2
  164. package/corpus/core/src/client/extensions/ExtensionEditor.tsx +37 -4
  165. package/corpus/core/src/client/extensions/ExtensionQueryErrorState.tsx +47 -0
  166. package/corpus/core/src/client/extensions/ExtensionSlot.tsx +39 -10
  167. package/corpus/core/src/client/extensions/ExtensionViewer.tsx +44 -6
  168. package/corpus/core/src/client/extensions/ExtensionsListPage.tsx +12 -3
  169. package/corpus/core/src/client/extensions/ExtensionsSidebarSection.tsx +49 -11
  170. package/corpus/core/src/client/index.ts +0 -13
  171. package/corpus/core/src/client/progress/RunsTray.tsx +10 -3
  172. package/corpus/core/src/client/settings/SettingsTabsPage.tsx +7 -0
  173. package/corpus/core/src/client/settings/useBuilderStatus.ts +6 -0
  174. package/corpus/core/src/client/tool-cells/EditCell.tsx +19 -16
  175. package/corpus/core/src/client/tool-cells/FilesChangedSummary.tsx +26 -23
  176. package/corpus/core/src/client/tool-cells/WriteCell.tsx +19 -16
  177. package/corpus/core/src/client/visual-style-controls.tsx +1 -1
  178. package/corpus/core/src/deploy/build.ts +36 -14
  179. package/corpus/core/src/guards/db-tool-scoping.ts +129 -0
  180. package/corpus/core/src/guards/index.ts +23 -0
  181. package/corpus/core/src/guards/no-drizzle-push.ts +116 -0
  182. package/corpus/core/src/guards/no-env-credentials.ts +229 -0
  183. package/corpus/core/src/guards/no-env-mutation.ts +114 -0
  184. package/corpus/core/src/guards/no-localhost-fallback.ts +124 -0
  185. package/corpus/core/src/guards/no-unscoped-credentials.ts +227 -0
  186. package/corpus/core/src/guards/no-unscoped-queries.ts +834 -0
  187. package/corpus/core/src/guards/scan-utils.ts +105 -0
  188. package/corpus/core/src/guards/types.ts +30 -0
  189. package/corpus/core/src/integrations/google-docs-poller.ts +23 -2
  190. package/corpus/core/src/integrations/plugin.ts +10 -0
  191. package/corpus/core/src/integrations/webhook-handler.ts +27 -2
  192. package/corpus/core/src/jobs/scheduler.ts +28 -2
  193. package/corpus/core/src/localization/default-messages.ts +8 -1
  194. package/corpus/core/src/mcp/oauth-token.ts +6 -1
  195. package/corpus/core/src/observability/routes.ts +36 -0
  196. package/corpus/core/src/observability/sentiment.ts +261 -0
  197. package/corpus/core/src/observability/store.ts +23 -0
  198. package/corpus/core/src/observability/traces.ts +49 -63
  199. package/corpus/core/src/observability/tracking-identity.ts +55 -0
  200. package/corpus/core/src/observability/types.ts +13 -0
  201. package/corpus/core/src/org/accept-pending.ts +9 -1
  202. package/corpus/core/src/org/migrations.ts +41 -0
  203. package/corpus/core/src/package-lifecycle/index.ts +1 -0
  204. package/corpus/core/src/package-lifecycle/manifest.ts +120 -0
  205. package/corpus/core/src/provider-api/custom-registry.ts +56 -0
  206. package/corpus/core/src/provider-api/index.ts +2 -0
  207. package/corpus/core/src/secrets/storage.ts +114 -30
  208. package/corpus/core/src/server/action-discovery.ts +4 -0
  209. package/corpus/core/src/server/agent-chat/action-filters-a2a.ts +199 -0
  210. package/corpus/core/src/server/agent-chat/browser-team-tools.ts +510 -0
  211. package/corpus/core/src/server/agent-chat/context-tools.ts +595 -0
  212. package/corpus/core/src/server/agent-chat/framework-prompts.ts +470 -0
  213. package/corpus/core/src/server/agent-chat/lazy-fs.ts +11 -0
  214. package/corpus/core/src/server/agent-chat/mcp-glue.ts +91 -0
  215. package/corpus/core/src/server/agent-chat/plugin-options.ts +350 -0
  216. package/corpus/core/src/server/agent-chat/process-run-failure.ts +62 -0
  217. package/corpus/core/src/server/agent-chat/prompt-resources.ts +688 -0
  218. package/corpus/core/src/server/agent-chat/recurring-jobs-runtime.ts +80 -0
  219. package/corpus/core/src/server/agent-chat/request-surface.ts +71 -0
  220. package/corpus/core/src/server/agent-chat/run-code-tools.ts +67 -0
  221. package/corpus/core/src/server/agent-chat/script-entries.ts +779 -0
  222. package/corpus/core/src/server/agent-chat/shared-thread.ts +301 -0
  223. package/corpus/core/src/server/agent-chat/skill-frontmatter.ts +41 -0
  224. package/corpus/core/src/server/agent-chat-plugin.ts +403 -4179
  225. package/corpus/core/src/server/agent-teams.ts +26 -3
  226. package/corpus/core/src/server/auth.ts +55 -57
  227. package/corpus/core/src/server/core-routes-plugin.ts +30 -14
  228. package/corpus/core/src/server/credential-provider.ts +22 -25
  229. package/corpus/core/src/server/csrf.ts +24 -5
  230. package/corpus/core/src/server/edge.ts +1 -0
  231. package/corpus/core/src/server/framework-request-handler.ts +34 -0
  232. package/corpus/core/src/server/google-realtime-session.ts +1 -36
  233. package/corpus/core/src/server/onboarding-html.ts +1 -16
  234. package/corpus/core/src/server/poll.ts +24 -2
  235. package/corpus/core/src/server/realtime-voice.ts +49 -5
  236. package/corpus/core/src/server/request-origin.ts +67 -0
  237. package/corpus/core/src/server/ssr-handler.ts +55 -2
  238. package/corpus/core/src/server/transcribe-voice.ts +1 -50
  239. package/corpus/core/src/sharing/access.ts +155 -11
  240. package/corpus/core/src/sharing/registry.ts +7 -0
  241. package/corpus/core/src/styles/agent-native.css +15 -14
  242. package/corpus/core/src/templates/default/.agents/skills/frontend-design/SKILL.md +1 -1
  243. package/corpus/core/src/templates/default/app/i18n/ar-SA.ts +6 -0
  244. package/corpus/core/src/templates/default/app/i18n/de-DE.ts +6 -0
  245. package/corpus/core/src/templates/default/app/i18n/en-US.ts +6 -0
  246. package/corpus/core/src/templates/default/app/i18n/es-ES.ts +6 -0
  247. package/corpus/core/src/templates/default/app/i18n/fr-FR.ts +6 -0
  248. package/corpus/core/src/templates/default/app/i18n/hi-IN.ts +6 -0
  249. package/corpus/core/src/templates/default/app/i18n/ja-JP.ts +6 -0
  250. package/corpus/core/src/templates/default/app/i18n/ko-KR.ts +6 -0
  251. package/corpus/core/src/templates/default/app/i18n/pt-BR.ts +6 -0
  252. package/corpus/core/src/templates/default/app/i18n/zh-CN.ts +6 -0
  253. package/corpus/core/src/templates/default/app/i18n/zh-TW.ts +6 -0
  254. package/corpus/core/src/templates/default/package.json +2 -2
  255. package/corpus/core/src/templates/headless/package.json +0 -1
  256. package/corpus/core/src/templates/workspace-core/.agents/skills/audit-log/SKILL.md +3 -0
  257. package/corpus/core/src/templates/workspace-core/.agents/skills/authentication/SKILL.md +27 -29
  258. package/corpus/core/src/templates/workspace-core/.agents/skills/automations/SKILL.md +1 -1
  259. package/corpus/core/src/templates/workspace-core/.agents/skills/external-agents/SKILL.md +2 -1
  260. package/corpus/core/src/templates/workspace-core/.agents/skills/frontend-design/SKILL.md +1 -1
  261. package/corpus/core/src/templates/workspace-core/.agents/skills/observability/SKILL.md +32 -0
  262. package/corpus/core/src/templates/workspace-core/.agents/skills/writing-agent-instructions/SKILL.md +25 -0
  263. package/corpus/core/src/templates/workspace-core/package.json +0 -1
  264. package/corpus/core/src/templates/workspace-core/src/server/index.ts +4 -2
  265. package/corpus/core/src/templates/workspace-root/package.json +0 -1
  266. package/corpus/core/src/testing.ts +26 -0
  267. package/corpus/core/src/triggers/actions.ts +11 -3
  268. package/corpus/core/src/triggers/dispatcher.ts +23 -2
  269. package/corpus/core/src/triggers/types.ts +7 -1
  270. package/corpus/core/src/vite/client.ts +126 -2
  271. package/corpus/core/tsconfig.cli.json +1 -1
  272. package/corpus/core/tsconfig.json +5 -1
  273. package/corpus/templates/analytics/.agents/skills/bigquery/SKILL.md +2 -2
  274. package/corpus/templates/analytics/.agents/skills/frontend-design/SKILL.md +1 -1
  275. package/corpus/templates/analytics/AGENTS.md +19 -6
  276. package/corpus/templates/analytics/actions/compose-dashboard.ts +65 -37
  277. package/corpus/templates/analytics/actions/install-dashboard-template.ts +79 -43
  278. package/corpus/templates/analytics/actions/list-explorer-dashboards.ts +3 -3
  279. package/corpus/templates/analytics/actions/list-sql-dashboards.ts +8 -3
  280. package/corpus/templates/analytics/actions/mutate-dashboard.ts +73 -24
  281. package/corpus/templates/analytics/actions/rename-analysis.ts +8 -2
  282. package/corpus/templates/analytics/actions/rename-dashboard.ts +8 -7
  283. package/corpus/templates/analytics/actions/reorder-dashboard-panels.ts +16 -13
  284. package/corpus/templates/analytics/actions/update-dashboard.ts +53 -42
  285. package/corpus/templates/analytics/actions/view-screen.ts +4 -23
  286. package/corpus/templates/analytics/app/components/ResourceLoadError.tsx +42 -0
  287. package/corpus/templates/analytics/app/components/layout/CommandPalette.tsx +85 -70
  288. package/corpus/templates/analytics/app/components/layout/Sidebar.tsx +107 -89
  289. package/corpus/templates/analytics/app/components/layout/SidebarLoadError.tsx +24 -0
  290. package/corpus/templates/analytics/app/hooks/use-dashboard-views.ts +15 -5
  291. package/corpus/templates/analytics/app/i18n/zh-TW.ts +4 -0
  292. package/corpus/templates/analytics/app/i18n-data.ts +40 -0
  293. package/corpus/templates/analytics/app/pages/Settings.tsx +6 -2
  294. package/corpus/templates/analytics/app/pages/adhoc/explorer/components/SqlPreview.tsx +36 -20
  295. package/corpus/templates/analytics/app/pages/adhoc/explorer/index.tsx +34 -20
  296. package/corpus/templates/analytics/app/pages/adhoc/explorer/use-explorer-config.ts +42 -41
  297. package/corpus/templates/analytics/app/pages/adhoc/explorer-dashboard/index.tsx +43 -36
  298. package/corpus/templates/analytics/app/pages/adhoc/sql-dashboard/ViewsMenu.tsx +11 -2
  299. package/corpus/templates/analytics/app/root.tsx +13 -1
  300. package/corpus/templates/analytics/app/routes/_index.tsx +14 -2
  301. package/corpus/templates/analytics/changelog/2026-07-03-agent-llm-observability-dashboard.md +1 -1
  302. package/corpus/templates/analytics/changelog/2026-07-10-dashboard-edits-from-the-agent-and-the-ui-at-the-same-time-n.md +6 -0
  303. package/corpus/templates/analytics/changelog/2026-07-10-timed-out-bigquery-jobs-are-now-cancelled-so-they-stop-consu.md +6 -0
  304. package/corpus/templates/analytics/changelog/2026-07-11-agent-feedback-sentiment-dashboard.md +6 -0
  305. package/corpus/templates/analytics/changelog/2026-07-11-analytics-chats-now-start-faster-by-loading-metric-definitio.md +6 -0
  306. package/corpus/templates/analytics/changelog/2026-07-11-command-and-sql-previews-now-respond-without-lag.md +6 -0
  307. package/corpus/templates/analytics/changelog/2026-07-11-command-search-now-reports-loading-failures-and-lets-you-ret.md +6 -0
  308. package/corpus/templates/analytics/changelog/2026-07-11-dashboard-navigation-now-loads-faster-and-reports-request-fa.md +6 -0
  309. package/corpus/templates/analytics/changelog/2026-07-11-inferred-message-sentiment-dashboard.md +6 -0
  310. package/corpus/templates/analytics/changelog/2026-07-11-microphone-settings-from-realtime-voice-mode-now-open-the-vo.md +6 -0
  311. package/corpus/templates/analytics/changelog/2026-07-11-more-dashboard-edit-paths-are-now-safe-against-simultaneous-.md +6 -0
  312. package/corpus/templates/analytics/changelog/2026-07-11-renaming-a-dashboard-is-now-safe-against-simultaneous-agent-.md +6 -0
  313. package/corpus/templates/analytics/changelog/2026-07-11-renaming-an-analysis-is-now-safe-against-simultaneous-edits.md +6 -0
  314. package/corpus/templates/analytics/changelog/2026-07-11-workspace-mounted-analytics-now-opens-ask-reliably-and-route.md +6 -0
  315. package/corpus/templates/analytics/docs/schemas/first-party-analytics.md +37 -3
  316. package/corpus/templates/analytics/package.json +1 -2
  317. package/corpus/templates/analytics/seeds/dashboards/agent-native-templates-first-party.json +339 -1
  318. package/corpus/templates/analytics/server/lib/bigquery.ts +3 -2
  319. package/corpus/templates/analytics/server/lib/dashboard-catalog.ts +1 -24
  320. package/corpus/templates/analytics/server/lib/dashboard-seeds.ts +0 -5
  321. package/corpus/templates/analytics/server/lib/dashboards-store.ts +443 -31
  322. package/corpus/templates/analytics/server/lib/data-dictionary-context.ts +106 -34
  323. package/corpus/templates/analytics/server/lib/demo-dashboards.ts +4 -1
  324. package/corpus/templates/analytics/server/plugins/agent-chat.ts +11 -39
  325. package/corpus/templates/assets/.agents/skills/frontend-design/SKILL.md +1 -1
  326. package/corpus/templates/assets/app/components/create/RecentDraftsSection.tsx +30 -4
  327. package/corpus/templates/assets/app/routes/library.tsx +49 -5
  328. package/corpus/templates/assets/changelog/2026-07-11-library-load-failures-now-show-a-retry-action.md +6 -0
  329. package/corpus/templates/assets/package.json +1 -2
  330. package/corpus/templates/brain/.agents/skills/frontend-design/SKILL.md +1 -1
  331. package/corpus/templates/brain/package.json +1 -2
  332. package/corpus/templates/calendar/.agents/skills/frontend-design/SKILL.md +1 -1
  333. package/corpus/templates/calendar/.env.example +5 -0
  334. package/corpus/templates/calendar/app/components/calendar/EventCard.tsx +2 -2
  335. package/corpus/templates/calendar/app/i18n/zh-TW.ts +2 -0
  336. package/corpus/templates/calendar/app/i18n-data.ts +20 -0
  337. package/corpus/templates/calendar/app/pages/BookingLinksPage.tsx +37 -1
  338. package/corpus/templates/calendar/app/pages/BookingsList.tsx +20 -3
  339. package/corpus/templates/calendar/changelog/2026-07-11-booking-load-failures-now-show-a-retry-action.md +6 -0
  340. package/corpus/templates/calendar/changelog/2026-07-11-event-cards-give-subtle-press-feedback-and-smoother-hover.md +6 -0
  341. package/corpus/templates/calendar/package.json +1 -2
  342. package/corpus/templates/chat/.agents/skills/frontend-design/SKILL.md +1 -1
  343. package/corpus/templates/chat/package.json +1 -2
  344. package/corpus/templates/clips/.agents/skills/frontend-design/SKILL.md +1 -1
  345. package/corpus/templates/clips/actions/decline-invite.ts +8 -0
  346. package/corpus/templates/clips/app/components/library/folder-tree.tsx +209 -187
  347. package/corpus/templates/clips/app/components/meetings/meeting-card.tsx +2 -2
  348. package/corpus/templates/clips/app/components/player/reactions-tray.tsx +17 -5
  349. package/corpus/templates/clips/app/components/player/scrubber.tsx +5 -3
  350. package/corpus/templates/clips/app/components/recorder/pre-record-panel.tsx +2 -2
  351. package/corpus/templates/clips/app/components/workspace/insights-hub.tsx +119 -95
  352. package/corpus/templates/clips/app/global.css +45 -0
  353. package/corpus/templates/clips/app/root.tsx +4 -0
  354. package/corpus/templates/clips/app/routes/_app.notifications.tsx +23 -2
  355. package/corpus/templates/clips/app/routes/_app.trash.tsx +24 -2
  356. package/corpus/templates/clips/changelog/2026-07-10-atomic-view-tracking.md +6 -0
  357. package/corpus/templates/clips/changelog/2026-07-11-controls-and-folders-now-move-more-smoothly.md +6 -0
  358. package/corpus/templates/clips/changelog/2026-07-11-declining-an-invitation-now-requires-being-its-recipient.md +6 -0
  359. package/corpus/templates/clips/changelog/2026-07-11-recording-overlays-are-lighter-weight-and-no-longer-cause-pa.md +6 -0
  360. package/corpus/templates/clips/changelog/2026-07-11-workspace-load-failures-now-show-a-retry-action.md +6 -0
  361. package/corpus/templates/clips/chrome-extension/package.json +3 -2
  362. package/corpus/templates/clips/chrome-extension/src/overlay.css +34 -5
  363. package/corpus/templates/clips/chrome-extension/src/styles.css +2 -2
  364. package/corpus/templates/clips/desktop/package.json +6 -4
  365. package/corpus/templates/clips/desktop/src/lib/recorder.ts +26 -13
  366. package/corpus/templates/clips/desktop/src/lib/voice-dictation.ts +4 -1
  367. package/corpus/templates/clips/desktop/src/styles.css +71 -26
  368. package/corpus/templates/clips/package.json +1 -2
  369. package/corpus/templates/clips/server/db/schema.ts +29 -17
  370. package/corpus/templates/clips/server/plugins/db.ts +8 -0
  371. package/corpus/templates/clips/server/routes/api/view-event.post.ts +260 -105
  372. package/corpus/templates/content/.agents/skills/frontend-design/SKILL.md +1 -1
  373. package/corpus/templates/content/.agents/skills/notion-integration/SKILL.md +16 -0
  374. package/corpus/templates/content/AGENTS.md +72 -62
  375. package/corpus/templates/content/actions/_content-database-source-adapters.ts +84 -0
  376. package/corpus/templates/content/actions/_database-source-utils.ts +206 -96
  377. package/corpus/templates/content/actions/_notion-database-source-adapter.ts +216 -0
  378. package/corpus/templates/content/actions/_position-utils.ts +76 -0
  379. package/corpus/templates/content/actions/_property-utils.ts +31 -20
  380. package/corpus/templates/content/actions/add-database-item.ts +52 -39
  381. package/corpus/templates/content/actions/attach-content-database-source.ts +95 -11
  382. package/corpus/templates/content/actions/change-content-database-source-role.ts +24 -1
  383. package/corpus/templates/content/actions/configure-document-property.ts +36 -27
  384. package/corpus/templates/content/actions/create-content-database.ts +40 -30
  385. package/corpus/templates/content/actions/create-document.ts +39 -32
  386. package/corpus/templates/content/actions/duplicate-document-property.ts +37 -28
  387. package/corpus/templates/content/actions/list-notion-database-sources.ts +80 -0
  388. package/corpus/templates/content/actions/move-document.ts +93 -61
  389. package/corpus/templates/content/actions/refresh-content-database-source.ts +42 -3
  390. package/corpus/templates/content/actions/share-local-file-document.ts +36 -27
  391. package/corpus/templates/content/actions/suggest-source-join-key.ts +39 -16
  392. package/corpus/templates/content/app/components/QueryErrorState.tsx +39 -0
  393. package/corpus/templates/content/app/components/editor/LinkHoverPreview.tsx +1 -1
  394. package/corpus/templates/content/app/components/editor/database/DatabaseView.tsx +323 -1467
  395. package/corpus/templates/content/app/components/editor/database/GalleryView.tsx +368 -0
  396. package/corpus/templates/content/app/components/editor/database/ListView.tsx +353 -0
  397. package/corpus/templates/content/app/components/editor/database/TimelineView.tsx +580 -0
  398. package/corpus/templates/content/app/components/editor/database/settings.tsx +1 -1
  399. package/corpus/templates/content/app/components/sidebar/DocumentSidebar.tsx +11 -2
  400. package/corpus/templates/content/app/global.css +19 -19
  401. package/corpus/templates/content/app/hooks/use-content-database.ts +18 -1
  402. package/corpus/templates/content/app/i18n/zh-TW.ts +4 -0
  403. package/corpus/templates/content/app/i18n-data.ts +40 -0
  404. package/corpus/templates/content/app/root.tsx +2 -2
  405. package/corpus/templates/content/app/routes/_app._index.tsx +11 -1
  406. package/corpus/templates/content/changelog/2026-07-10-failed-row-creation-and-source-attach-now-show-an-error-inst.md +6 -0
  407. package/corpus/templates/content/changelog/2026-07-10-items-added-at-the-same-time-no-longer-end-up-with-identical.md +6 -0
  408. package/corpus/templates/content/changelog/2026-07-10-notion-databases-can-add-read-only-details-to-content-tables.md +6 -0
  409. package/corpus/templates/content/changelog/2026-07-11-document-load-failures-now-show-a-retry-action.md +6 -0
  410. package/corpus/templates/content/changelog/2026-07-11-editor-toggle-feedback-now-feels-more-responsive.md +6 -0
  411. package/corpus/templates/content/changelog/2026-07-11-moving-documents-at-the-same-time-no-longer-scrambles-their-.md +6 -0
  412. package/corpus/templates/content/changelog/2026-07-11-public-document-chats-now-start-faster-while-keeping-full-do.md +6 -0
  413. package/corpus/templates/content/changelog/2026-07-11-reopening-a-comment-now-uses-consistent-permissions-everywhe.md +6 -0
  414. package/corpus/templates/content/changelog/2026-07-11-sidebar-resizing-now-tracks-your-cursor-instantly-instead-of.md +6 -0
  415. package/corpus/templates/content/package.json +1 -2
  416. package/corpus/templates/content/parity/matrix.md +25 -25
  417. package/corpus/templates/content/parity/matrix.ts +1 -0
  418. package/corpus/templates/content/server/lib/public-documents.ts +47 -10
  419. package/corpus/templates/content/server/routes/api/comments/[id].patch.ts +24 -24
  420. package/corpus/templates/content/server/routes/api/documents/[id]/move.patch.ts +43 -26
  421. package/corpus/templates/content/shared/api.ts +16 -1
  422. package/corpus/templates/design/.agents/skills/frontend-design/SKILL.md +1 -1
  423. package/corpus/templates/design/.agents/skills/visual-edit/SKILL.md +8 -4
  424. package/corpus/templates/design/AGENTS.md +12 -2
  425. package/corpus/templates/design/DEVELOPING.md +10 -6
  426. package/corpus/templates/design/actions/apply-visual-edit.ts +191 -6
  427. package/corpus/templates/design/actions/duplicate-design.ts +31 -25
  428. package/corpus/templates/design/app/components/QueryErrorState.tsx +24 -0
  429. package/corpus/templates/design/app/components/design/CanvasContextMenu.tsx +1 -1
  430. package/corpus/templates/design/app/components/design/DesignImportPanel.tsx +5 -2
  431. package/corpus/templates/design/app/components/design/EditPanel.tsx +326 -319
  432. package/corpus/templates/design/app/components/design/LayersPanel.tsx +198 -193
  433. package/corpus/templates/design/app/components/design/edit-panel/panel-primitives.tsx +11 -4
  434. package/corpus/templates/design/app/components/design/inspector/DesignColorPicker.tsx +1 -1
  435. package/corpus/templates/design/app/components/layout/Layout.tsx +1 -1
  436. package/corpus/templates/design/app/pages/DesignSystems.tsx +7 -1
  437. package/corpus/templates/design/app/pages/Index.tsx +14 -2
  438. package/corpus/templates/design/app/pages/Present.tsx +16 -3
  439. package/corpus/templates/design/app/pages/Templates.tsx +10 -4
  440. package/corpus/templates/design/app/pages/design-editor/canvas-primitive-insert.ts +484 -0
  441. package/corpus/templates/design/app/pages/design-editor/clone-and-pen-edit.ts +378 -0
  442. package/corpus/templates/design/app/pages/design-editor/design-data-geometry-utils.ts +138 -0
  443. package/corpus/templates/design/app/pages/design-editor/dom-utils.ts +15 -0
  444. package/corpus/templates/design/app/pages/design-editor/generation-prompt-directives.ts +180 -0
  445. package/corpus/templates/design/app/pages/design-editor/html-layer-positioning.ts +226 -0
  446. package/corpus/templates/design/app/pages/design-editor/pending-edits.ts +5 -1
  447. package/corpus/templates/design/app/pages/design-editor/png-export-render.ts +348 -0
  448. package/corpus/templates/design/app/pages/design-editor/screen-command-utils.ts +160 -0
  449. package/corpus/templates/design/app/pages/design-editor/text-edit-utils.ts +238 -0
  450. package/corpus/templates/design/app/pages/design-editor/tool-state.ts +23 -1
  451. package/corpus/templates/design/app/pages/design-editor/types.ts +25 -0
  452. package/corpus/templates/design/app/root.tsx +10 -1
  453. package/corpus/templates/design/changelog/2026-07-10-duplicating-a-design-can-no-longer-produce-a-copy-with-missi.md +6 -0
  454. package/corpus/templates/design/changelog/2026-07-10-local-visual-edits-can-now-save-safe-leaf-text-class-and.md +6 -0
  455. package/corpus/templates/design/changelog/2026-07-11-canvas-context-menus-now-open-without-motion-jitter.md +6 -0
  456. package/corpus/templates/design/changelog/2026-07-11-design-load-failures-now-show-a-retry-action.md +6 -0
  457. package/corpus/templates/design/changelog/2026-07-11-inspector-tooltips-appear-instantly-as-you-sweep-across-icon.md +6 -0
  458. package/corpus/templates/design/package.json +1 -1
  459. package/corpus/templates/design/shared/local-jsx-visual-edit.ts +388 -0
  460. package/corpus/templates/dispatch/.agents/skills/frontend-design/SKILL.md +1 -1
  461. package/corpus/templates/dispatch/app/i18n/zh-TW.ts +10 -0
  462. package/corpus/templates/dispatch/app/i18n-data.ts +123 -0
  463. package/corpus/templates/dispatch/app/routes/integrations.tsx +163 -144
  464. package/corpus/templates/dispatch/changelog/2026-07-11-dispatch-mcp-connections-now-start-with-safer-app-access-and.md +6 -0
  465. package/corpus/templates/dispatch/changelog/2026-07-11-overview-and-chat-now-share-a-cleaner-more-stable-flow.md +6 -0
  466. package/corpus/templates/dispatch/changelog/2026-07-11-query-errors-now-show-a-retry-option.md +6 -0
  467. package/corpus/templates/dispatch/package.json +1 -2
  468. package/corpus/templates/forms/.agents/skills/frontend-design/SKILL.md +1 -1
  469. package/corpus/templates/forms/actions/patch-form-fields.ts +82 -44
  470. package/corpus/templates/forms/app/components/layout/Sidebar.tsx +3 -3
  471. package/corpus/templates/forms/app/root.tsx +34 -8
  472. package/corpus/templates/forms/changelog/2026-07-10-simultaneous-edits-to-different-form-fields-no-longer-overwr.md +6 -0
  473. package/corpus/templates/forms/package.json +1 -2
  474. package/corpus/templates/macros/.agents/skills/frontend-design/SKILL.md +1 -1
  475. package/corpus/templates/macros/app/components/DailyProgress.tsx +25 -5
  476. package/corpus/templates/macros/app/components/QueryErrorState.tsx +31 -0
  477. package/corpus/templates/macros/app/components/WeightTracker.tsx +5 -1
  478. package/corpus/templates/macros/app/components/ui/button.tsx +1 -1
  479. package/corpus/templates/macros/app/components/ui/progress.tsx +1 -1
  480. package/corpus/templates/macros/app/components/ui/tabs.tsx +1 -1
  481. package/corpus/templates/macros/app/i18n/ar-SA.ts +2 -0
  482. package/corpus/templates/macros/app/i18n/de-DE.ts +2 -0
  483. package/corpus/templates/macros/app/i18n/en-US.ts +2 -0
  484. package/corpus/templates/macros/app/i18n/es-ES.ts +2 -0
  485. package/corpus/templates/macros/app/i18n/fr-FR.ts +2 -0
  486. package/corpus/templates/macros/app/i18n/hi-IN.ts +2 -0
  487. package/corpus/templates/macros/app/i18n/ja-JP.ts +2 -0
  488. package/corpus/templates/macros/app/i18n/ko-KR.ts +2 -0
  489. package/corpus/templates/macros/app/i18n/pt-BR.ts +2 -0
  490. package/corpus/templates/macros/app/i18n/zh-CN.ts +2 -0
  491. package/corpus/templates/macros/app/i18n/zh-TW.ts +2 -0
  492. package/corpus/templates/macros/app/routes/_index.tsx +22 -12
  493. package/corpus/templates/macros/app/routes/analytics.tsx +31 -10
  494. package/corpus/templates/macros/changelog/2026-07-11-daily-tracking-now-loads-and-updates-more-quickly.md +6 -0
  495. package/corpus/templates/macros/changelog/2026-07-11-data-load-failures-now-show-a-clear-error-with-a-retry-actio.md +6 -0
  496. package/corpus/templates/macros/package.json +1 -2
  497. package/corpus/templates/mail/.agents/skills/frontend-design/SKILL.md +1 -1
  498. package/corpus/templates/mail/.env.example +16 -11
  499. package/corpus/templates/mail/actions/list-emails.ts +39 -35
  500. package/corpus/templates/mail/app/components/email/ComposeModal.tsx +58 -6
  501. package/corpus/templates/mail/app/components/email/EmailListItem.tsx +35 -2
  502. package/corpus/templates/mail/app/components/email/EmailThread.tsx +3 -1
  503. package/corpus/templates/mail/app/components/layout/AppLayout.tsx +113 -104
  504. package/corpus/templates/mail/app/root.tsx +8 -10
  505. package/corpus/templates/mail/changelog/2026-07-10-fixed-calendar-rsvp-buttons-in-emails-firing-duplicate-respo.md +6 -0
  506. package/corpus/templates/mail/changelog/2026-07-11-compose-and-navigation-motion-now-feel-faster-and-smoother.md +6 -0
  507. package/corpus/templates/mail/changelog/2026-07-11-swipe-to-archive-or-snooze-now-responds-to-quick-flicks-not-.md +6 -0
  508. package/corpus/templates/mail/changelog/2026-07-11-the-assistant-now-sees-the-same-inbox-you-do-snoozed-mail-st.md +6 -0
  509. package/corpus/templates/mail/package.json +1 -2
  510. package/corpus/templates/mail/server/handlers/emails.ts +25 -69
  511. package/corpus/templates/mail/server/lib/list-inbox-emails.ts +169 -0
  512. package/corpus/templates/plan/.agents/skills/frontend-design/SKILL.md +1 -1
  513. package/corpus/templates/plan/.env.example +4 -0
  514. package/corpus/templates/plan/actions/create-plan-design.ts +89 -81
  515. package/corpus/templates/plan/actions/create-prototype-plan.ts +72 -59
  516. package/corpus/templates/plan/actions/create-ui-plan.ts +70 -55
  517. package/corpus/templates/plan/actions/create-visual-plan.ts +65 -51
  518. package/corpus/templates/plan/actions/restore-plan-version.ts +126 -96
  519. package/corpus/templates/plan/actions/update-local-plan-folder.ts +43 -30
  520. package/corpus/templates/plan/actions/update-visual-plan.ts +81 -64
  521. package/corpus/templates/plan/app/components/layout/Sidebar.tsx +17 -0
  522. package/corpus/templates/plan/app/components/ui/tabs.tsx +1 -1
  523. package/corpus/templates/plan/app/i18n/ar-SA.ts +10 -0
  524. package/corpus/templates/plan/app/i18n/de-DE.ts +10 -0
  525. package/corpus/templates/plan/app/i18n/en-US.ts +10 -0
  526. package/corpus/templates/plan/app/i18n/es-ES.ts +10 -0
  527. package/corpus/templates/plan/app/i18n/fr-FR.ts +10 -0
  528. package/corpus/templates/plan/app/i18n/hi-IN.ts +10 -0
  529. package/corpus/templates/plan/app/i18n/ja-JP.ts +10 -0
  530. package/corpus/templates/plan/app/i18n/ko-KR.ts +10 -0
  531. package/corpus/templates/plan/app/i18n/pt-BR.ts +10 -0
  532. package/corpus/templates/plan/app/i18n/zh-CN.ts +10 -0
  533. package/corpus/templates/plan/app/i18n/zh-TW.ts +10 -0
  534. package/corpus/templates/plan/app/lib/plan-local-bridge.ts +80 -1
  535. package/corpus/templates/plan/app/pages/PlansPage.tsx +152 -4
  536. package/corpus/templates/plan/app/root.tsx +11 -0
  537. package/corpus/templates/plan/changelog/2026-07-10-restoring-a-plan-version-can-no-longer-leave-a-plan-half-res.md +6 -0
  538. package/corpus/templates/plan/changelog/2026-07-11-local-plans-now-explain-and-recover-from-browser-permission-.md +6 -0
  539. package/corpus/templates/plan/changelog/2026-07-11-plan-edits-now-save-atomically-and-can-no-longer-partially-a.md +6 -0
  540. package/corpus/templates/plan/changelog/2026-07-11-plan-lists-now-show-a-clear-error-with-a-retry-action-when-t.md +6 -0
  541. package/corpus/templates/plan/package.json +1 -2
  542. package/corpus/templates/plan/server/plans.ts +9 -2
  543. package/corpus/templates/plan/shared/plan-content.ts +546 -260
  544. package/corpus/templates/slides/.agents/skills/frontend-design/SKILL.md +1 -1
  545. package/corpus/templates/slides/actions/delete-slide-comment.ts +49 -0
  546. package/corpus/templates/slides/actions/list-decks.ts +28 -0
  547. package/corpus/templates/slides/actions/update-slide-comment.ts +93 -0
  548. package/corpus/templates/slides/actions/view-screen.ts +14 -6
  549. package/corpus/templates/slides/app/components/comments/SlideCommentsPanel.tsx +33 -10
  550. package/corpus/templates/slides/app/components/deck/MermaidRenderer.tsx +41 -26
  551. package/corpus/templates/slides/app/components/design-system/DesignSystemSetup.tsx +4 -8
  552. package/corpus/templates/slides/app/components/editor/EditorSidebar.tsx +3 -5
  553. package/corpus/templates/slides/app/components/editor/EditorToolbar.tsx +5 -9
  554. package/corpus/templates/slides/app/components/editor/ExportMenu.tsx +5 -12
  555. package/corpus/templates/slides/app/components/editor/GenerateSlidesDialog.tsx +2 -2
  556. package/corpus/templates/slides/app/components/editor/HistoryPanel.tsx +3 -6
  557. package/corpus/templates/slides/app/components/editor/ImageDropPromptPopover.tsx +3 -6
  558. package/corpus/templates/slides/app/components/editor/PromptDialog.tsx +2 -5
  559. package/corpus/templates/slides/app/components/presentation/PresentationView.tsx +4 -2
  560. package/corpus/templates/slides/app/components/visual-editor/CanvasCommentPins.tsx +4 -3
  561. package/corpus/templates/slides/app/context/DeckContext.tsx +56 -4
  562. package/corpus/templates/slides/app/i18n/ar-SA.ts +6 -0
  563. package/corpus/templates/slides/app/i18n/de-DE.ts +6 -0
  564. package/corpus/templates/slides/app/i18n/en-US.ts +6 -0
  565. package/corpus/templates/slides/app/i18n/es-ES.ts +6 -0
  566. package/corpus/templates/slides/app/i18n/fr-FR.ts +6 -0
  567. package/corpus/templates/slides/app/i18n/hi-IN.ts +6 -0
  568. package/corpus/templates/slides/app/i18n/ja-JP.ts +6 -0
  569. package/corpus/templates/slides/app/i18n/ko-KR.ts +6 -0
  570. package/corpus/templates/slides/app/i18n/pt-BR.ts +6 -0
  571. package/corpus/templates/slides/app/i18n/zh-CN.ts +5 -0
  572. package/corpus/templates/slides/app/i18n/zh-TW.ts +5 -0
  573. package/corpus/templates/slides/app/pages/DeckEditor.tsx +11 -30
  574. package/corpus/templates/slides/app/pages/DesignSystems.tsx +23 -2
  575. package/corpus/templates/slides/app/pages/Index.tsx +31 -4
  576. package/corpus/templates/slides/app/root.tsx +0 -5
  577. package/corpus/templates/slides/changelog/2026-07-10-deck-lists-load-much-faster-and-no-longer-re-download-slide-.md +6 -0
  578. package/corpus/templates/slides/changelog/2026-07-11-comment-load-failures-now-show-a-retry-action-instead-of-say.md +6 -0
  579. package/corpus/templates/slides/changelog/2026-07-11-comment-pins-now-clear-with-a-faster-smoother-confirmation.md +6 -0
  580. package/corpus/templates/slides/changelog/2026-07-11-deck-and-design-system-load-failures-now-show-a-retry-action.md +6 -0
  581. package/corpus/templates/slides/changelog/2026-07-11-editor-toggles-and-toolbar-menus-now-animate-smoothly.md +6 -0
  582. package/corpus/templates/slides/changelog/2026-07-11-the-assistant-can-now-resolve-reopen-and-delete-slide-commen.md +6 -0
  583. package/corpus/templates/slides/changelog/2026-07-11-viewing-slides-no-longer-loads-every-deck-s-full-contents-in.md +6 -0
  584. package/corpus/templates/slides/package.json +1 -2
  585. package/corpus/templates/slides/server/routes/api/comments/[id].delete.ts +29 -48
  586. package/corpus/templates/slides/server/routes/api/comments/[id].patch.ts +29 -65
  587. package/dist/a2a/auth-policy.d.ts +19 -0
  588. package/dist/a2a/auth-policy.d.ts.map +1 -1
  589. package/dist/a2a/auth-policy.js +32 -0
  590. package/dist/a2a/auth-policy.js.map +1 -1
  591. package/dist/action.d.ts +23 -0
  592. package/dist/action.d.ts.map +1 -1
  593. package/dist/action.js +13 -0
  594. package/dist/action.js.map +1 -1
  595. package/dist/agent/durable-background.d.ts +8 -5
  596. package/dist/agent/durable-background.d.ts.map +1 -1
  597. package/dist/agent/durable-background.js +15 -8
  598. package/dist/agent/durable-background.js.map +1 -1
  599. package/dist/agent/engine/builder-engine.d.ts.map +1 -1
  600. package/dist/agent/engine/builder-engine.js +3 -0
  601. package/dist/agent/engine/builder-engine.js.map +1 -1
  602. package/dist/agent/engine/context-directives-transform.d.ts +25 -0
  603. package/dist/agent/engine/context-directives-transform.d.ts.map +1 -0
  604. package/dist/agent/engine/context-directives-transform.js +53 -0
  605. package/dist/agent/engine/context-directives-transform.js.map +1 -0
  606. package/dist/agent/engine/continuation-dispatch-retry.d.ts +40 -0
  607. package/dist/agent/engine/continuation-dispatch-retry.d.ts.map +1 -0
  608. package/dist/agent/engine/continuation-dispatch-retry.js +109 -0
  609. package/dist/agent/engine/continuation-dispatch-retry.js.map +1 -0
  610. package/dist/agent/engine/tool-call-journal-seed.d.ts +46 -0
  611. package/dist/agent/engine/tool-call-journal-seed.d.ts.map +1 -0
  612. package/dist/agent/engine/tool-call-journal-seed.js +60 -0
  613. package/dist/agent/engine/tool-call-journal-seed.js.map +1 -0
  614. package/dist/agent/production-agent.d.ts +7 -0
  615. package/dist/agent/production-agent.d.ts.map +1 -1
  616. package/dist/agent/production-agent.js +102 -222
  617. package/dist/agent/production-agent.js.map +1 -1
  618. package/dist/agent/run-store.d.ts.map +1 -1
  619. package/dist/agent/run-store.js +9 -4
  620. package/dist/agent/run-store.js.map +1 -1
  621. package/dist/audit/actions/export-audit-events.d.ts +27 -0
  622. package/dist/audit/actions/export-audit-events.d.ts.map +1 -0
  623. package/dist/audit/actions/export-audit-events.js +144 -0
  624. package/dist/audit/actions/export-audit-events.js.map +1 -0
  625. package/dist/audit/store.d.ts +1 -0
  626. package/dist/audit/store.d.ts.map +1 -1
  627. package/dist/audit/store.js +8 -3
  628. package/dist/audit/store.js.map +1 -1
  629. package/dist/audit/types.d.ts +3 -0
  630. package/dist/audit/types.d.ts.map +1 -1
  631. package/dist/audit/types.js.map +1 -1
  632. package/dist/cli/doctor.d.ts +83 -0
  633. package/dist/cli/doctor.d.ts.map +1 -0
  634. package/dist/cli/doctor.js +281 -0
  635. package/dist/cli/doctor.js.map +1 -0
  636. package/dist/cli/index.js +50 -0
  637. package/dist/cli/index.js.map +1 -1
  638. package/dist/cli/info.js +3 -3
  639. package/dist/cli/info.js.map +1 -1
  640. package/dist/cli/package-lifecycle.d.ts +50 -0
  641. package/dist/cli/package-lifecycle.d.ts.map +1 -0
  642. package/dist/cli/package-lifecycle.js +560 -0
  643. package/dist/cli/package-lifecycle.js.map +1 -0
  644. package/dist/cli/plan-local.d.ts.map +1 -1
  645. package/dist/cli/plan-local.js +8 -2
  646. package/dist/cli/plan-local.js.map +1 -1
  647. package/dist/cli/skills-content/assets-skill.d.ts +2 -0
  648. package/dist/cli/skills-content/assets-skill.d.ts.map +1 -0
  649. package/dist/cli/skills-content/assets-skill.js +84 -0
  650. package/dist/cli/skills-content/assets-skill.js.map +1 -0
  651. package/dist/cli/skills-content/canvas.d.ts +4 -0
  652. package/dist/cli/skills-content/canvas.d.ts.map +1 -0
  653. package/dist/cli/skills-content/canvas.js +152 -0
  654. package/dist/cli/skills-content/canvas.js.map +1 -0
  655. package/dist/cli/skills-content/connection.d.ts +2 -0
  656. package/dist/cli/skills-content/connection.d.ts.map +1 -0
  657. package/dist/cli/skills-content/connection.js +53 -0
  658. package/dist/cli/skills-content/connection.js.map +1 -0
  659. package/dist/cli/skills-content/content-skill.d.ts +2 -0
  660. package/dist/cli/skills-content/content-skill.d.ts.map +1 -0
  661. package/dist/cli/skills-content/content-skill.js +110 -0
  662. package/dist/cli/skills-content/content-skill.js.map +1 -0
  663. package/dist/cli/skills-content/design-exploration-skill.d.ts +2 -0
  664. package/dist/cli/skills-content/design-exploration-skill.d.ts.map +1 -0
  665. package/dist/cli/skills-content/design-exploration-skill.js +119 -0
  666. package/dist/cli/skills-content/design-exploration-skill.js.map +1 -0
  667. package/dist/cli/skills-content/design-visual-edit-skill.d.ts +2 -0
  668. package/dist/cli/skills-content/design-visual-edit-skill.d.ts.map +1 -0
  669. package/dist/cli/skills-content/design-visual-edit-skill.js +229 -0
  670. package/dist/cli/skills-content/design-visual-edit-skill.js.map +1 -0
  671. package/dist/cli/skills-content/document-quality.d.ts +4 -0
  672. package/dist/cli/skills-content/document-quality.d.ts.map +1 -0
  673. package/dist/cli/skills-content/document-quality.js +195 -0
  674. package/dist/cli/skills-content/document-quality.js.map +1 -0
  675. package/dist/cli/skills-content/exemplar.d.ts +4 -0
  676. package/dist/cli/skills-content/exemplar.d.ts.map +1 -0
  677. package/dist/cli/skills-content/exemplar.js +68 -0
  678. package/dist/cli/skills-content/exemplar.js.map +1 -0
  679. package/dist/cli/skills-content/help.d.ts +2 -0
  680. package/dist/cli/skills-content/help.d.ts.map +1 -0
  681. package/dist/cli/skills-content/help.js +78 -0
  682. package/dist/cli/skills-content/help.js.map +1 -0
  683. package/dist/cli/skills-content/index.d.ts +23 -0
  684. package/dist/cli/skills-content/index.d.ts.map +1 -0
  685. package/dist/cli/skills-content/index.js +23 -0
  686. package/dist/cli/skills-content/index.js.map +1 -0
  687. package/dist/cli/skills-content/local-files.d.ts +2 -0
  688. package/dist/cli/skills-content/local-files.d.ts.map +1 -0
  689. package/dist/cli/skills-content/local-files.js +96 -0
  690. package/dist/cli/skills-content/local-files.js.map +1 -0
  691. package/dist/cli/skills-content/plan-setup-auth.d.ts +9 -0
  692. package/dist/cli/skills-content/plan-setup-auth.d.ts.map +1 -0
  693. package/dist/cli/skills-content/plan-setup-auth.js +81 -0
  694. package/dist/cli/skills-content/plan-setup-auth.js.map +1 -0
  695. package/dist/cli/skills-content/visual-plan-skill.d.ts +2 -0
  696. package/dist/cli/skills-content/visual-plan-skill.d.ts.map +1 -0
  697. package/dist/cli/skills-content/visual-plan-skill.js +471 -0
  698. package/dist/cli/skills-content/visual-plan-skill.js.map +1 -0
  699. package/dist/cli/skills-content/visual-recap-skill.d.ts +2 -0
  700. package/dist/cli/skills-content/visual-recap-skill.d.ts.map +1 -0
  701. package/dist/cli/skills-content/visual-recap-skill.js +548 -0
  702. package/dist/cli/skills-content/visual-recap-skill.js.map +1 -0
  703. package/dist/cli/skills-content/visualize-repo-skill.d.ts +2 -0
  704. package/dist/cli/skills-content/visualize-repo-skill.d.ts.map +1 -0
  705. package/dist/cli/skills-content/visualize-repo-skill.js +94 -0
  706. package/dist/cli/skills-content/visualize-repo-skill.js.map +1 -0
  707. package/dist/cli/skills-content/wireframe.d.ts +4 -0
  708. package/dist/cli/skills-content/wireframe.d.ts.map +1 -0
  709. package/dist/cli/skills-content/wireframe.js +347 -0
  710. package/dist/cli/skills-content/wireframe.js.map +1 -0
  711. package/dist/cli/skills.d.ts +2 -10
  712. package/dist/cli/skills.d.ts.map +1 -1
  713. package/dist/cli/skills.js +2 -2710
  714. package/dist/cli/skills.js.map +1 -1
  715. package/dist/client/AgentPanel.d.ts.map +1 -1
  716. package/dist/client/AgentPanel.js +4 -2
  717. package/dist/client/AgentPanel.js.map +1 -1
  718. package/dist/client/CommandMenu.d.ts.map +1 -1
  719. package/dist/client/CommandMenu.js +15 -3
  720. package/dist/client/CommandMenu.js.map +1 -1
  721. package/dist/client/FeedbackButton.js +2 -2
  722. package/dist/client/FeedbackButton.js.map +1 -1
  723. package/dist/client/agent-chat-adapter.js +7 -3
  724. package/dist/client/agent-chat-adapter.js.map +1 -1
  725. package/dist/client/app-providers.d.ts +13 -5
  726. package/dist/client/app-providers.d.ts.map +1 -1
  727. package/dist/client/app-providers.js +9 -6
  728. package/dist/client/app-providers.js.map +1 -1
  729. package/dist/client/chat/tool-call-display.d.ts +4 -0
  730. package/dist/client/chat/tool-call-display.d.ts.map +1 -1
  731. package/dist/client/chat/tool-call-display.js +3 -3
  732. package/dist/client/chat/tool-call-display.js.map +1 -1
  733. package/dist/client/composer/PastedTextChip.js +1 -1
  734. package/dist/client/composer/PastedTextChip.js.map +1 -1
  735. package/dist/client/composer/RealtimeVoiceMode.d.ts +3 -1
  736. package/dist/client/composer/RealtimeVoiceMode.d.ts.map +1 -1
  737. package/dist/client/composer/RealtimeVoiceMode.js +35 -14
  738. package/dist/client/composer/RealtimeVoiceMode.js.map +1 -1
  739. package/dist/client/composer/TiptapComposer.js +1 -1
  740. package/dist/client/composer/TiptapComposer.js.map +1 -1
  741. package/dist/client/composer/VoiceButton.d.ts +2 -0
  742. package/dist/client/composer/VoiceButton.d.ts.map +1 -1
  743. package/dist/client/composer/VoiceButton.js +9 -3
  744. package/dist/client/composer/VoiceButton.js.map +1 -1
  745. package/dist/client/composer/useRealtimeVoiceMode.d.ts +5 -0
  746. package/dist/client/composer/useRealtimeVoiceMode.d.ts.map +1 -1
  747. package/dist/client/composer/useRealtimeVoiceMode.js +91 -12
  748. package/dist/client/composer/useRealtimeVoiceMode.js.map +1 -1
  749. package/dist/client/context-xray/ContextXRayPanel.d.ts.map +1 -1
  750. package/dist/client/context-xray/ContextXRayPanel.js +4 -1
  751. package/dist/client/context-xray/ContextXRayPanel.js.map +1 -1
  752. package/dist/client/extensions/ExtensionEditor.d.ts.map +1 -1
  753. package/dist/client/extensions/ExtensionEditor.js +15 -5
  754. package/dist/client/extensions/ExtensionEditor.js.map +1 -1
  755. package/dist/client/extensions/ExtensionQueryErrorState.d.ts +8 -0
  756. package/dist/client/extensions/ExtensionQueryErrorState.d.ts.map +1 -0
  757. package/dist/client/extensions/ExtensionQueryErrorState.js +11 -0
  758. package/dist/client/extensions/ExtensionQueryErrorState.js.map +1 -0
  759. package/dist/client/extensions/ExtensionSlot.d.ts.map +1 -1
  760. package/dist/client/extensions/ExtensionSlot.js +17 -7
  761. package/dist/client/extensions/ExtensionSlot.js.map +1 -1
  762. package/dist/client/extensions/ExtensionViewer.d.ts.map +1 -1
  763. package/dist/client/extensions/ExtensionViewer.js +17 -7
  764. package/dist/client/extensions/ExtensionViewer.js.map +1 -1
  765. package/dist/client/extensions/ExtensionsListPage.d.ts.map +1 -1
  766. package/dist/client/extensions/ExtensionsListPage.js +5 -3
  767. package/dist/client/extensions/ExtensionsListPage.js.map +1 -1
  768. package/dist/client/extensions/ExtensionsSidebarSection.d.ts.map +1 -1
  769. package/dist/client/extensions/ExtensionsSidebarSection.js +21 -8
  770. package/dist/client/extensions/ExtensionsSidebarSection.js.map +1 -1
  771. package/dist/client/index.d.ts +0 -2
  772. package/dist/client/index.d.ts.map +1 -1
  773. package/dist/client/index.js +0 -5
  774. package/dist/client/index.js.map +1 -1
  775. package/dist/client/progress/RunsTray.d.ts.map +1 -1
  776. package/dist/client/progress/RunsTray.js +7 -3
  777. package/dist/client/progress/RunsTray.js.map +1 -1
  778. package/dist/client/settings/SettingsTabsPage.d.ts.map +1 -1
  779. package/dist/client/settings/SettingsTabsPage.js +4 -0
  780. package/dist/client/settings/SettingsTabsPage.js.map +1 -1
  781. package/dist/client/settings/useBuilderStatus.d.ts +2 -0
  782. package/dist/client/settings/useBuilderStatus.d.ts.map +1 -1
  783. package/dist/client/settings/useBuilderStatus.js +4 -0
  784. package/dist/client/settings/useBuilderStatus.js.map +1 -1
  785. package/dist/client/tool-cells/EditCell.d.ts.map +1 -1
  786. package/dist/client/tool-cells/EditCell.js +2 -1
  787. package/dist/client/tool-cells/EditCell.js.map +1 -1
  788. package/dist/client/tool-cells/FilesChangedSummary.d.ts.map +1 -1
  789. package/dist/client/tool-cells/FilesChangedSummary.js +2 -1
  790. package/dist/client/tool-cells/FilesChangedSummary.js.map +1 -1
  791. package/dist/client/tool-cells/WriteCell.d.ts.map +1 -1
  792. package/dist/client/tool-cells/WriteCell.js +2 -1
  793. package/dist/client/tool-cells/WriteCell.js.map +1 -1
  794. package/dist/client/visual-style-controls.js +1 -1
  795. package/dist/client/visual-style-controls.js.map +1 -1
  796. package/dist/collab/routes.d.ts +1 -1
  797. package/dist/collab/struct-routes.d.ts +1 -1
  798. package/dist/deploy/build.d.ts.map +1 -1
  799. package/dist/deploy/build.js +36 -14
  800. package/dist/deploy/build.js.map +1 -1
  801. package/dist/guards/db-tool-scoping.d.ts +38 -0
  802. package/dist/guards/db-tool-scoping.d.ts.map +1 -0
  803. package/dist/guards/db-tool-scoping.js +114 -0
  804. package/dist/guards/db-tool-scoping.js.map +1 -0
  805. package/dist/guards/index.d.ts +23 -0
  806. package/dist/guards/index.d.ts.map +1 -0
  807. package/dist/guards/index.js +19 -0
  808. package/dist/guards/index.js.map +1 -0
  809. package/dist/guards/no-drizzle-push.d.ts +14 -0
  810. package/dist/guards/no-drizzle-push.d.ts.map +1 -0
  811. package/dist/guards/no-drizzle-push.js +97 -0
  812. package/dist/guards/no-drizzle-push.js.map +1 -0
  813. package/dist/guards/no-env-credentials.d.ts +36 -0
  814. package/dist/guards/no-env-credentials.d.ts.map +1 -0
  815. package/dist/guards/no-env-credentials.js +204 -0
  816. package/dist/guards/no-env-credentials.js.map +1 -0
  817. package/dist/guards/no-env-mutation.d.ts +23 -0
  818. package/dist/guards/no-env-mutation.d.ts.map +1 -0
  819. package/dist/guards/no-env-mutation.js +90 -0
  820. package/dist/guards/no-env-mutation.js.map +1 -0
  821. package/dist/guards/no-localhost-fallback.d.ts +30 -0
  822. package/dist/guards/no-localhost-fallback.d.ts.map +1 -0
  823. package/dist/guards/no-localhost-fallback.js +105 -0
  824. package/dist/guards/no-localhost-fallback.js.map +1 -0
  825. package/dist/guards/no-unscoped-credentials.d.ts +28 -0
  826. package/dist/guards/no-unscoped-credentials.d.ts.map +1 -0
  827. package/dist/guards/no-unscoped-credentials.js +199 -0
  828. package/dist/guards/no-unscoped-credentials.js.map +1 -0
  829. package/dist/guards/no-unscoped-queries.d.ts +32 -0
  830. package/dist/guards/no-unscoped-queries.d.ts.map +1 -0
  831. package/dist/guards/no-unscoped-queries.js +720 -0
  832. package/dist/guards/no-unscoped-queries.js.map +1 -0
  833. package/dist/guards/scan-utils.d.ts +28 -0
  834. package/dist/guards/scan-utils.d.ts.map +1 -0
  835. package/dist/guards/scan-utils.js +92 -0
  836. package/dist/guards/scan-utils.js.map +1 -0
  837. package/dist/guards/types.d.ts +28 -0
  838. package/dist/guards/types.d.ts.map +1 -0
  839. package/dist/guards/types.js +11 -0
  840. package/dist/guards/types.js.map +1 -0
  841. package/dist/integrations/google-docs-poller.d.ts +7 -0
  842. package/dist/integrations/google-docs-poller.d.ts.map +1 -1
  843. package/dist/integrations/google-docs-poller.js +13 -3
  844. package/dist/integrations/google-docs-poller.js.map +1 -1
  845. package/dist/integrations/plugin.d.ts.map +1 -1
  846. package/dist/integrations/plugin.js +10 -0
  847. package/dist/integrations/plugin.js.map +1 -1
  848. package/dist/integrations/webhook-handler.d.ts +11 -0
  849. package/dist/integrations/webhook-handler.d.ts.map +1 -1
  850. package/dist/integrations/webhook-handler.js +16 -4
  851. package/dist/integrations/webhook-handler.js.map +1 -1
  852. package/dist/jobs/scheduler.d.ts +12 -0
  853. package/dist/jobs/scheduler.d.ts.map +1 -1
  854. package/dist/jobs/scheduler.js +13 -3
  855. package/dist/jobs/scheduler.js.map +1 -1
  856. package/dist/localization/default-messages.d.ts +7 -0
  857. package/dist/localization/default-messages.d.ts.map +1 -1
  858. package/dist/localization/default-messages.js +8 -1
  859. package/dist/localization/default-messages.js.map +1 -1
  860. package/dist/mcp/oauth-token.d.ts +1 -1
  861. package/dist/mcp/oauth-token.d.ts.map +1 -1
  862. package/dist/mcp/oauth-token.js +6 -1
  863. package/dist/mcp/oauth-token.js.map +1 -1
  864. package/dist/notifications/routes.d.ts +2 -2
  865. package/dist/observability/routes.d.ts.map +1 -1
  866. package/dist/observability/routes.js +32 -0
  867. package/dist/observability/routes.js.map +1 -1
  868. package/dist/observability/sentiment.d.ts +42 -0
  869. package/dist/observability/sentiment.d.ts.map +1 -0
  870. package/dist/observability/sentiment.js +196 -0
  871. package/dist/observability/sentiment.js.map +1 -0
  872. package/dist/observability/store.d.ts +5 -0
  873. package/dist/observability/store.d.ts.map +1 -1
  874. package/dist/observability/store.js +17 -0
  875. package/dist/observability/store.js.map +1 -1
  876. package/dist/observability/traces.d.ts +2 -0
  877. package/dist/observability/traces.d.ts.map +1 -1
  878. package/dist/observability/traces.js +42 -57
  879. package/dist/observability/traces.js.map +1 -1
  880. package/dist/observability/tracking-identity.d.ts +3 -0
  881. package/dist/observability/tracking-identity.d.ts.map +1 -0
  882. package/dist/observability/tracking-identity.js +51 -0
  883. package/dist/observability/tracking-identity.js.map +1 -0
  884. package/dist/observability/types.d.ts +10 -0
  885. package/dist/observability/types.d.ts.map +1 -1
  886. package/dist/observability/types.js +3 -0
  887. package/dist/observability/types.js.map +1 -1
  888. package/dist/org/accept-pending.d.ts.map +1 -1
  889. package/dist/org/accept-pending.js +9 -1
  890. package/dist/org/accept-pending.js.map +1 -1
  891. package/dist/org/migrations.d.ts +7 -2
  892. package/dist/org/migrations.d.ts.map +1 -1
  893. package/dist/org/migrations.js +41 -0
  894. package/dist/org/migrations.js.map +1 -1
  895. package/dist/package-lifecycle/index.d.ts +2 -0
  896. package/dist/package-lifecycle/index.d.ts.map +1 -0
  897. package/dist/package-lifecycle/index.js +2 -0
  898. package/dist/package-lifecycle/index.js.map +1 -0
  899. package/dist/package-lifecycle/manifest.d.ts +24 -0
  900. package/dist/package-lifecycle/manifest.d.ts.map +1 -0
  901. package/dist/package-lifecycle/manifest.js +81 -0
  902. package/dist/package-lifecycle/manifest.js.map +1 -0
  903. package/dist/provider-api/corpus-jobs.d.ts +2 -2
  904. package/dist/provider-api/custom-registry.d.ts +32 -1
  905. package/dist/provider-api/custom-registry.d.ts.map +1 -1
  906. package/dist/provider-api/custom-registry.js +41 -1
  907. package/dist/provider-api/custom-registry.js.map +1 -1
  908. package/dist/provider-api/index.d.ts +1 -1
  909. package/dist/provider-api/index.d.ts.map +1 -1
  910. package/dist/provider-api/index.js +1 -1
  911. package/dist/provider-api/index.js.map +1 -1
  912. package/dist/resources/handlers.d.ts +1 -1
  913. package/dist/secrets/storage.d.ts +6 -0
  914. package/dist/secrets/storage.d.ts.map +1 -1
  915. package/dist/secrets/storage.js +105 -29
  916. package/dist/secrets/storage.js.map +1 -1
  917. package/dist/server/action-discovery.d.ts.map +1 -1
  918. package/dist/server/action-discovery.js +4 -0
  919. package/dist/server/action-discovery.js.map +1 -1
  920. package/dist/server/agent-chat/action-filters-a2a.d.ts +50 -0
  921. package/dist/server/agent-chat/action-filters-a2a.d.ts.map +1 -0
  922. package/dist/server/agent-chat/action-filters-a2a.js +127 -0
  923. package/dist/server/agent-chat/action-filters-a2a.js.map +1 -0
  924. package/dist/server/agent-chat/browser-team-tools.d.ts +21 -0
  925. package/dist/server/agent-chat/browser-team-tools.d.ts.map +1 -0
  926. package/dist/server/agent-chat/browser-team-tools.js +417 -0
  927. package/dist/server/agent-chat/browser-team-tools.js.map +1 -0
  928. package/dist/server/agent-chat/context-tools.d.ts +33 -0
  929. package/dist/server/agent-chat/context-tools.d.ts.map +1 -0
  930. package/dist/server/agent-chat/context-tools.js +520 -0
  931. package/dist/server/agent-chat/context-tools.js.map +1 -0
  932. package/dist/server/agent-chat/framework-prompts.d.ts +65 -0
  933. package/dist/server/agent-chat/framework-prompts.d.ts.map +1 -0
  934. package/dist/server/agent-chat/framework-prompts.js +403 -0
  935. package/dist/server/agent-chat/framework-prompts.js.map +1 -0
  936. package/dist/server/agent-chat/lazy-fs.d.ts +2 -0
  937. package/dist/server/agent-chat/lazy-fs.d.ts.map +1 -0
  938. package/dist/server/agent-chat/lazy-fs.js +11 -0
  939. package/dist/server/agent-chat/lazy-fs.js.map +1 -0
  940. package/dist/server/agent-chat/mcp-glue.d.ts +9 -0
  941. package/dist/server/agent-chat/mcp-glue.d.ts.map +1 -0
  942. package/dist/server/agent-chat/mcp-glue.js +63 -0
  943. package/dist/server/agent-chat/mcp-glue.js.map +1 -0
  944. package/dist/server/agent-chat/plugin-options.d.ts +322 -0
  945. package/dist/server/agent-chat/plugin-options.d.ts.map +1 -0
  946. package/dist/server/agent-chat/plugin-options.js +2 -0
  947. package/dist/server/agent-chat/plugin-options.js.map +1 -0
  948. package/dist/server/agent-chat/process-run-failure.d.ts +12 -0
  949. package/dist/server/agent-chat/process-run-failure.d.ts.map +1 -0
  950. package/dist/server/agent-chat/process-run-failure.js +24 -0
  951. package/dist/server/agent-chat/process-run-failure.js.map +1 -0
  952. package/dist/server/agent-chat/prompt-resources.d.ts +28 -0
  953. package/dist/server/agent-chat/prompt-resources.d.ts.map +1 -0
  954. package/dist/server/agent-chat/prompt-resources.js +514 -0
  955. package/dist/server/agent-chat/prompt-resources.js.map +1 -0
  956. package/dist/server/agent-chat/recurring-jobs-runtime.d.ts +5 -0
  957. package/dist/server/agent-chat/recurring-jobs-runtime.d.ts.map +1 -0
  958. package/dist/server/agent-chat/recurring-jobs-runtime.js +53 -0
  959. package/dist/server/agent-chat/recurring-jobs-runtime.js.map +1 -0
  960. package/dist/server/agent-chat/request-surface.d.ts +8 -0
  961. package/dist/server/agent-chat/request-surface.d.ts.map +1 -0
  962. package/dist/server/agent-chat/request-surface.js +56 -0
  963. package/dist/server/agent-chat/request-surface.js.map +1 -0
  964. package/dist/server/agent-chat/run-code-tools.d.ts +17 -0
  965. package/dist/server/agent-chat/run-code-tools.d.ts.map +1 -0
  966. package/dist/server/agent-chat/run-code-tools.js +55 -0
  967. package/dist/server/agent-chat/run-code-tools.js.map +1 -0
  968. package/dist/server/agent-chat/script-entries.d.ts +47 -0
  969. package/dist/server/agent-chat/script-entries.d.ts.map +1 -0
  970. package/dist/server/agent-chat/script-entries.js +633 -0
  971. package/dist/server/agent-chat/script-entries.js.map +1 -0
  972. package/dist/server/agent-chat/shared-thread.d.ts +33 -0
  973. package/dist/server/agent-chat/shared-thread.d.ts.map +1 -0
  974. package/dist/server/agent-chat/shared-thread.js +242 -0
  975. package/dist/server/agent-chat/shared-thread.js.map +1 -0
  976. package/dist/server/agent-chat/skill-frontmatter.d.ts +7 -0
  977. package/dist/server/agent-chat/skill-frontmatter.d.ts.map +1 -0
  978. package/dist/server/agent-chat/skill-frontmatter.js +26 -0
  979. package/dist/server/agent-chat/skill-frontmatter.js.map +1 -0
  980. package/dist/server/agent-chat-plugin.d.ts +45 -486
  981. package/dist/server/agent-chat-plugin.d.ts.map +1 -1
  982. package/dist/server/agent-chat-plugin.js +217 -3015
  983. package/dist/server/agent-chat-plugin.js.map +1 -1
  984. package/dist/server/agent-engine-api-key-route.d.ts +1 -1
  985. package/dist/server/agent-teams.d.ts +10 -0
  986. package/dist/server/agent-teams.d.ts.map +1 -1
  987. package/dist/server/agent-teams.js +13 -3
  988. package/dist/server/agent-teams.js.map +1 -1
  989. package/dist/server/auth.d.ts.map +1 -1
  990. package/dist/server/auth.js +50 -52
  991. package/dist/server/auth.js.map +1 -1
  992. package/dist/server/core-routes-plugin.d.ts.map +1 -1
  993. package/dist/server/core-routes-plugin.js +23 -12
  994. package/dist/server/core-routes-plugin.js.map +1 -1
  995. package/dist/server/credential-provider.d.ts.map +1 -1
  996. package/dist/server/credential-provider.js +22 -21
  997. package/dist/server/credential-provider.js.map +1 -1
  998. package/dist/server/csrf.d.ts.map +1 -1
  999. package/dist/server/csrf.js +18 -5
  1000. package/dist/server/csrf.js.map +1 -1
  1001. package/dist/server/edge.d.ts +1 -0
  1002. package/dist/server/edge.d.ts.map +1 -1
  1003. package/dist/server/edge.js +1 -0
  1004. package/dist/server/edge.js.map +1 -1
  1005. package/dist/server/framework-request-handler.d.ts.map +1 -1
  1006. package/dist/server/framework-request-handler.js +34 -0
  1007. package/dist/server/framework-request-handler.js.map +1 -1
  1008. package/dist/server/google-realtime-session.d.ts.map +1 -1
  1009. package/dist/server/google-realtime-session.js +2 -34
  1010. package/dist/server/google-realtime-session.js.map +1 -1
  1011. package/dist/server/onboarding-html.d.ts.map +1 -1
  1012. package/dist/server/onboarding-html.js +1 -16
  1013. package/dist/server/onboarding-html.js.map +1 -1
  1014. package/dist/server/poll.d.ts.map +1 -1
  1015. package/dist/server/poll.js +24 -2
  1016. package/dist/server/poll.js.map +1 -1
  1017. package/dist/server/realtime-voice.d.ts +3 -0
  1018. package/dist/server/realtime-voice.d.ts.map +1 -1
  1019. package/dist/server/realtime-voice.js +38 -5
  1020. package/dist/server/realtime-voice.js.map +1 -1
  1021. package/dist/server/request-origin.d.ts +10 -0
  1022. package/dist/server/request-origin.d.ts.map +1 -0
  1023. package/dist/server/request-origin.js +63 -0
  1024. package/dist/server/request-origin.js.map +1 -0
  1025. package/dist/server/ssr-handler.d.ts.map +1 -1
  1026. package/dist/server/ssr-handler.js +47 -2
  1027. package/dist/server/ssr-handler.js.map +1 -1
  1028. package/dist/server/transcribe-voice.d.ts.map +1 -1
  1029. package/dist/server/transcribe-voice.js +2 -48
  1030. package/dist/server/transcribe-voice.js.map +1 -1
  1031. package/dist/sharing/access.d.ts +63 -3
  1032. package/dist/sharing/access.d.ts.map +1 -1
  1033. package/dist/sharing/access.js +53 -15
  1034. package/dist/sharing/access.js.map +1 -1
  1035. package/dist/sharing/registry.d.ts +7 -0
  1036. package/dist/sharing/registry.d.ts.map +1 -1
  1037. package/dist/sharing/registry.js.map +1 -1
  1038. package/dist/styles/agent-native.css +15 -14
  1039. package/dist/templates/default/.agents/skills/frontend-design/SKILL.md +1 -1
  1040. package/dist/templates/default/app/i18n/ar-SA.ts +6 -0
  1041. package/dist/templates/default/app/i18n/de-DE.ts +6 -0
  1042. package/dist/templates/default/app/i18n/en-US.ts +6 -0
  1043. package/dist/templates/default/app/i18n/es-ES.ts +6 -0
  1044. package/dist/templates/default/app/i18n/fr-FR.ts +6 -0
  1045. package/dist/templates/default/app/i18n/hi-IN.ts +6 -0
  1046. package/dist/templates/default/app/i18n/ja-JP.ts +6 -0
  1047. package/dist/templates/default/app/i18n/ko-KR.ts +6 -0
  1048. package/dist/templates/default/app/i18n/pt-BR.ts +6 -0
  1049. package/dist/templates/default/app/i18n/zh-CN.ts +6 -0
  1050. package/dist/templates/default/app/i18n/zh-TW.ts +6 -0
  1051. package/dist/templates/default/package.json +2 -2
  1052. package/dist/templates/headless/package.json +0 -1
  1053. package/dist/templates/workspace-core/.agents/skills/audit-log/SKILL.md +3 -0
  1054. package/dist/templates/workspace-core/.agents/skills/authentication/SKILL.md +27 -29
  1055. package/dist/templates/workspace-core/.agents/skills/automations/SKILL.md +1 -1
  1056. package/dist/templates/workspace-core/.agents/skills/external-agents/SKILL.md +2 -1
  1057. package/dist/templates/workspace-core/.agents/skills/frontend-design/SKILL.md +1 -1
  1058. package/dist/templates/workspace-core/.agents/skills/observability/SKILL.md +32 -0
  1059. package/dist/templates/workspace-core/.agents/skills/writing-agent-instructions/SKILL.md +25 -0
  1060. package/dist/templates/workspace-core/package.json +0 -1
  1061. package/dist/templates/workspace-core/src/server/index.ts +4 -2
  1062. package/dist/templates/workspace-root/package.json +0 -1
  1063. package/dist/testing.d.ts +16 -0
  1064. package/dist/testing.d.ts.map +1 -0
  1065. package/dist/testing.js +16 -0
  1066. package/dist/testing.js.map +1 -0
  1067. package/dist/triggers/actions.d.ts.map +1 -1
  1068. package/dist/triggers/actions.js +8 -3
  1069. package/dist/triggers/actions.js.map +1 -1
  1070. package/dist/triggers/dispatcher.d.ts +7 -0
  1071. package/dist/triggers/dispatcher.d.ts.map +1 -1
  1072. package/dist/triggers/dispatcher.js +13 -3
  1073. package/dist/triggers/dispatcher.js.map +1 -1
  1074. package/dist/triggers/types.d.ts +7 -1
  1075. package/dist/triggers/types.d.ts.map +1 -1
  1076. package/dist/triggers/types.js.map +1 -1
  1077. package/dist/vite/client.d.ts +16 -1
  1078. package/dist/vite/client.d.ts.map +1 -1
  1079. package/dist/vite/client.js +105 -2
  1080. package/dist/vite/client.js.map +1 -1
  1081. package/docs/content/audit-log.mdx +2 -1
  1082. package/docs/content/authentication.mdx +3 -3
  1083. package/docs/content/automations.mdx +7 -7
  1084. package/docs/content/creating-templates.mdx +1 -1
  1085. package/docs/content/doctor.mdx +170 -0
  1086. package/docs/content/external-agents.mdx +8 -7
  1087. package/docs/content/internationalization.mdx +2 -1
  1088. package/docs/content/locales/ar-SA/audit-log.mdx +2 -1
  1089. package/docs/content/locales/ar-SA/authentication.mdx +2 -2
  1090. package/docs/content/locales/ar-SA/automations.mdx +7 -7
  1091. package/docs/content/locales/ar-SA/external-agents.mdx +8 -7
  1092. package/docs/content/locales/ar-SA/getting-started.mdx +7 -1
  1093. package/docs/content/locales/ar-SA/internationalization.mdx +1 -1
  1094. package/docs/content/locales/ar-SA/mcp-protocol.mdx +1 -1
  1095. package/docs/content/locales/ar-SA/package-lifecycle.mdx +19 -0
  1096. package/docs/content/locales/ar-SA/sandbox-adapters.mdx +18 -7
  1097. package/docs/content/locales/ar-SA/security.mdx +10 -0
  1098. package/docs/content/locales/de-DE/audit-log.mdx +2 -1
  1099. package/docs/content/locales/de-DE/authentication.mdx +1 -1
  1100. package/docs/content/locales/de-DE/automations.mdx +7 -7
  1101. package/docs/content/locales/de-DE/external-agents.mdx +8 -7
  1102. package/docs/content/locales/de-DE/getting-started.mdx +7 -1
  1103. package/docs/content/locales/de-DE/internationalization.mdx +1 -1
  1104. package/docs/content/locales/de-DE/mcp-protocol.mdx +1 -1
  1105. package/docs/content/locales/de-DE/package-lifecycle.mdx +22 -0
  1106. package/docs/content/locales/de-DE/sandbox-adapters.mdx +18 -7
  1107. package/docs/content/locales/de-DE/security.mdx +10 -0
  1108. package/docs/content/locales/es-ES/audit-log.mdx +2 -1
  1109. package/docs/content/locales/es-ES/authentication.mdx +2 -2
  1110. package/docs/content/locales/es-ES/automations.mdx +7 -7
  1111. package/docs/content/locales/es-ES/external-agents.mdx +8 -7
  1112. package/docs/content/locales/es-ES/getting-started.mdx +7 -1
  1113. package/docs/content/locales/es-ES/internationalization.mdx +1 -1
  1114. package/docs/content/locales/es-ES/mcp-protocol.mdx +1 -1
  1115. package/docs/content/locales/es-ES/package-lifecycle.mdx +22 -0
  1116. package/docs/content/locales/es-ES/sandbox-adapters.mdx +18 -7
  1117. package/docs/content/locales/es-ES/security.mdx +10 -0
  1118. package/docs/content/locales/fr-FR/audit-log.mdx +2 -1
  1119. package/docs/content/locales/fr-FR/authentication.mdx +1 -1
  1120. package/docs/content/locales/fr-FR/automations.mdx +7 -7
  1121. package/docs/content/locales/fr-FR/external-agents.mdx +8 -7
  1122. package/docs/content/locales/fr-FR/getting-started.mdx +7 -1
  1123. package/docs/content/locales/fr-FR/internationalization.mdx +1 -1
  1124. package/docs/content/locales/fr-FR/mcp-protocol.mdx +1 -1
  1125. package/docs/content/locales/fr-FR/package-lifecycle.mdx +21 -0
  1126. package/docs/content/locales/fr-FR/sandbox-adapters.mdx +19 -8
  1127. package/docs/content/locales/fr-FR/security.mdx +10 -0
  1128. package/docs/content/locales/hi-IN/audit-log.mdx +2 -1
  1129. package/docs/content/locales/hi-IN/authentication.mdx +2 -2
  1130. package/docs/content/locales/hi-IN/automations.mdx +7 -7
  1131. package/docs/content/locales/hi-IN/external-agents.mdx +8 -7
  1132. package/docs/content/locales/hi-IN/getting-started.mdx +7 -1
  1133. package/docs/content/locales/hi-IN/internationalization.mdx +1 -1
  1134. package/docs/content/locales/hi-IN/mcp-protocol.mdx +1 -1
  1135. package/docs/content/locales/hi-IN/package-lifecycle.mdx +20 -0
  1136. package/docs/content/locales/hi-IN/sandbox-adapters.mdx +18 -7
  1137. package/docs/content/locales/hi-IN/security.mdx +10 -0
  1138. package/docs/content/locales/ja-JP/audit-log.mdx +2 -1
  1139. package/docs/content/locales/ja-JP/authentication.mdx +2 -2
  1140. package/docs/content/locales/ja-JP/automations.mdx +7 -7
  1141. package/docs/content/locales/ja-JP/external-agents.mdx +8 -7
  1142. package/docs/content/locales/ja-JP/getting-started.mdx +7 -1
  1143. package/docs/content/locales/ja-JP/internationalization.mdx +1 -1
  1144. package/docs/content/locales/ja-JP/mcp-protocol.mdx +1 -1
  1145. package/docs/content/locales/ja-JP/package-lifecycle.mdx +21 -0
  1146. package/docs/content/locales/ja-JP/sandbox-adapters.mdx +17 -6
  1147. package/docs/content/locales/ja-JP/security.mdx +10 -0
  1148. package/docs/content/locales/ko-KR/audit-log.mdx +2 -1
  1149. package/docs/content/locales/ko-KR/authentication.mdx +2 -2
  1150. package/docs/content/locales/ko-KR/automations.mdx +7 -7
  1151. package/docs/content/locales/ko-KR/external-agents.mdx +8 -7
  1152. package/docs/content/locales/ko-KR/getting-started.mdx +7 -1
  1153. package/docs/content/locales/ko-KR/internationalization.mdx +1 -1
  1154. package/docs/content/locales/ko-KR/mcp-protocol.mdx +1 -1
  1155. package/docs/content/locales/ko-KR/package-lifecycle.mdx +20 -0
  1156. package/docs/content/locales/ko-KR/sandbox-adapters.mdx +17 -6
  1157. package/docs/content/locales/ko-KR/security.mdx +10 -0
  1158. package/docs/content/locales/pt-BR/audit-log.mdx +2 -1
  1159. package/docs/content/locales/pt-BR/authentication.mdx +2 -2
  1160. package/docs/content/locales/pt-BR/automations.mdx +7 -7
  1161. package/docs/content/locales/pt-BR/external-agents.mdx +8 -7
  1162. package/docs/content/locales/pt-BR/getting-started.mdx +7 -1
  1163. package/docs/content/locales/pt-BR/internationalization.mdx +1 -1
  1164. package/docs/content/locales/pt-BR/mcp-protocol.mdx +1 -1
  1165. package/docs/content/locales/pt-BR/package-lifecycle.mdx +21 -0
  1166. package/docs/content/locales/pt-BR/sandbox-adapters.mdx +18 -7
  1167. package/docs/content/locales/pt-BR/security.mdx +10 -0
  1168. package/docs/content/locales/zh-CN/audit-log.mdx +2 -1
  1169. package/docs/content/locales/zh-CN/authentication.mdx +2 -2
  1170. package/docs/content/locales/zh-CN/automations.mdx +7 -7
  1171. package/docs/content/locales/zh-CN/external-agents.mdx +8 -7
  1172. package/docs/content/locales/zh-CN/getting-started.mdx +6 -4
  1173. package/docs/content/locales/zh-CN/internationalization.mdx +1 -1
  1174. package/docs/content/locales/zh-CN/mcp-protocol.mdx +1 -1
  1175. package/docs/content/locales/zh-CN/package-lifecycle.mdx +19 -0
  1176. package/docs/content/locales/zh-CN/sandbox-adapters.mdx +17 -6
  1177. package/docs/content/locales/zh-CN/security.mdx +10 -0
  1178. package/docs/content/locales/zh-TW/audit-log.mdx +2 -1
  1179. package/docs/content/locales/zh-TW/authentication.mdx +2 -2
  1180. package/docs/content/locales/zh-TW/automations.mdx +7 -7
  1181. package/docs/content/locales/zh-TW/external-agents.mdx +8 -7
  1182. package/docs/content/locales/zh-TW/getting-started.mdx +6 -4
  1183. package/docs/content/locales/zh-TW/internationalization.mdx +1 -1
  1184. package/docs/content/locales/zh-TW/mcp-protocol.mdx +1 -1
  1185. package/docs/content/locales/zh-TW/package-lifecycle.mdx +19 -0
  1186. package/docs/content/locales/zh-TW/sandbox-adapters.mdx +18 -7
  1187. package/docs/content/locales/zh-TW/security.mdx +10 -0
  1188. package/docs/content/mcp-protocol.mdx +1 -1
  1189. package/docs/content/package-lifecycle.mdx +51 -0
  1190. package/docs/content/sandbox-adapters.mdx +16 -5
  1191. package/docs/content/security.mdx +2 -0
  1192. package/package.json +14 -3
  1193. package/src/templates/default/.agents/skills/frontend-design/SKILL.md +1 -1
  1194. package/src/templates/default/app/i18n/ar-SA.ts +6 -0
  1195. package/src/templates/default/app/i18n/de-DE.ts +6 -0
  1196. package/src/templates/default/app/i18n/en-US.ts +6 -0
  1197. package/src/templates/default/app/i18n/es-ES.ts +6 -0
  1198. package/src/templates/default/app/i18n/fr-FR.ts +6 -0
  1199. package/src/templates/default/app/i18n/hi-IN.ts +6 -0
  1200. package/src/templates/default/app/i18n/ja-JP.ts +6 -0
  1201. package/src/templates/default/app/i18n/ko-KR.ts +6 -0
  1202. package/src/templates/default/app/i18n/pt-BR.ts +6 -0
  1203. package/src/templates/default/app/i18n/zh-CN.ts +6 -0
  1204. package/src/templates/default/app/i18n/zh-TW.ts +6 -0
  1205. package/src/templates/default/package.json +2 -2
  1206. package/src/templates/headless/package.json +0 -1
  1207. package/src/templates/workspace-core/.agents/skills/audit-log/SKILL.md +3 -0
  1208. package/src/templates/workspace-core/.agents/skills/authentication/SKILL.md +27 -29
  1209. package/src/templates/workspace-core/.agents/skills/automations/SKILL.md +1 -1
  1210. package/src/templates/workspace-core/.agents/skills/external-agents/SKILL.md +2 -1
  1211. package/src/templates/workspace-core/.agents/skills/frontend-design/SKILL.md +1 -1
  1212. package/src/templates/workspace-core/.agents/skills/observability/SKILL.md +32 -0
  1213. package/src/templates/workspace-core/.agents/skills/writing-agent-instructions/SKILL.md +25 -0
  1214. package/src/templates/workspace-core/package.json +0 -1
  1215. package/src/templates/workspace-core/src/server/index.ts +4 -2
  1216. package/src/templates/workspace-root/package.json +0 -1
  1217. package/corpus/core/src/client/ProductionAgentPanel.tsx +0 -9
  1218. package/corpus/core/src/client/auth-redirect-url.ts +0 -23
  1219. package/corpus/core/src/client/useProductionAgent.ts +0 -253
  1220. package/corpus/core/src/shared/auth-redirect-url.ts +0 -1
  1221. package/corpus/templates/analytics/app/pages/Index.tsx +0 -16
  1222. package/corpus/templates/analytics/seeds/dashboards/agent-observability-llm.json +0 -173
  1223. package/corpus/templates/slides/app/components/ui/toast.tsx +0 -1
  1224. package/corpus/templates/slides/app/components/ui/toaster.tsx +0 -1
  1225. package/corpus/templates/slides/app/hooks/use-toast.ts +0 -1
  1226. package/dist/client/ProductionAgentPanel.d.ts +0 -6
  1227. package/dist/client/ProductionAgentPanel.d.ts.map +0 -1
  1228. package/dist/client/ProductionAgentPanel.js +0 -6
  1229. package/dist/client/ProductionAgentPanel.js.map +0 -1
  1230. package/dist/client/auth-redirect-url.d.ts +0 -2
  1231. package/dist/client/auth-redirect-url.d.ts.map +0 -1
  1232. package/dist/client/auth-redirect-url.js +0 -19
  1233. package/dist/client/auth-redirect-url.js.map +0 -1
  1234. package/dist/client/useProductionAgent.d.ts +0 -24
  1235. package/dist/client/useProductionAgent.d.ts.map +0 -1
  1236. package/dist/client/useProductionAgent.js +0 -179
  1237. package/dist/client/useProductionAgent.js.map +0 -1
  1238. package/dist/shared/auth-redirect-url.d.ts +0 -2
  1239. package/dist/shared/auth-redirect-url.d.ts.map +0 -1
  1240. package/dist/shared/auth-redirect-url.js +0 -2
  1241. package/dist/shared/auth-redirect-url.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"credential-provider.d.ts","sourceRoot":"","sources":["../../src/server/credential-provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAOH;;;;;;;;GAQG;AACH,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAChC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAC9B;IAAE,KAAK,EAAE,MAAM,GAAG,KAAK,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAK5C;AAED,qBAAa,yBAA0B,SAAQ,KAAK;IAClD,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;IACpC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IACpC,QAAQ,CAAC,WAAW,CAAC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E,wBAAgB,qBAAqB,IAAI,MAAM,CAO9C;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,IAAI,MAAM,CAKjD;AAED;;;GAGG;AACH,wBAAgB,gCAAgC,IAAI,MAAM,CAKzD;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,IAAI,MAAM,CAKnD;AAED,uEAAuE;AACvE,wBAAgB,oBAAoB,IAAI,MAAM,GAAG,IAAI,CAGpD"}
@@ -185,23 +185,24 @@ function readOptionalBuilderBoolean(value) {
185
185
  export function isBuilderPrivateKey(value) {
186
186
  return typeof value === "string" && value.trim().startsWith("bpk-");
187
187
  }
188
- async function readBuilderCredentialScope(readAppSecret, scope, scopeId) {
189
- const values = await Promise.all(BUILDER_CREDENTIAL_KEYS.map(async (key) => {
190
- const secret = await readAppSecret({ key, scope, scopeId });
191
- return [key, secret?.value ?? null];
192
- }));
193
- const map = new Map(values);
188
+ async function readBuilderCredentialScope(readAppSecrets, scope, scopeId) {
189
+ const secrets = await readAppSecrets({
190
+ keys: BUILDER_CREDENTIAL_KEYS,
191
+ scope,
192
+ scopeId,
193
+ });
194
+ const value = (key) => secrets.get(key)?.value ?? null;
194
195
  return {
195
- privateKey: map.get("BUILDER_PRIVATE_KEY") ?? null,
196
- publicKey: map.get("BUILDER_PUBLIC_KEY") ?? null,
197
- userId: map.get("BUILDER_USER_ID") ?? null,
198
- orgName: map.get("BUILDER_ORG_NAME") ?? null,
199
- orgKind: map.get("BUILDER_ORG_KIND") ?? null,
200
- subscription: map.get("BUILDER_SUBSCRIPTION") ?? null,
201
- subscriptionLevel: map.get("BUILDER_SUBSCRIPTION_LEVEL") ?? null,
202
- subscriptionName: map.get("BUILDER_SUBSCRIPTION_NAME") ?? null,
203
- isEnterprise: readOptionalBuilderBoolean(map.get("BUILDER_IS_ENTERPRISE")),
204
- isFreeAccount: readOptionalBuilderBoolean(map.get("BUILDER_IS_FREE_ACCOUNT")),
196
+ privateKey: value("BUILDER_PRIVATE_KEY"),
197
+ publicKey: value("BUILDER_PUBLIC_KEY"),
198
+ userId: value("BUILDER_USER_ID"),
199
+ orgName: value("BUILDER_ORG_NAME"),
200
+ orgKind: value("BUILDER_ORG_KIND"),
201
+ subscription: value("BUILDER_SUBSCRIPTION"),
202
+ subscriptionLevel: value("BUILDER_SUBSCRIPTION_LEVEL"),
203
+ subscriptionName: value("BUILDER_SUBSCRIPTION_NAME"),
204
+ isEnterprise: readOptionalBuilderBoolean(value("BUILDER_IS_ENTERPRISE")),
205
+ isFreeAccount: readOptionalBuilderBoolean(value("BUILDER_IS_FREE_ACCOUNT")),
205
206
  source: scope === "workspace" ? "workspace" : scope,
206
207
  };
207
208
  }
@@ -299,25 +300,25 @@ async function resolveScopedBuilderCredentials() {
299
300
  const traceLookup = shouldTraceCredentialResolve();
300
301
  let scopeAttempted = "user";
301
302
  try {
302
- const { readAppSecret } = await import("../secrets/storage.js");
303
+ const { readAppSecrets } = await import("../secrets/storage.js");
303
304
  const traceScope = (creds, scopeId) => {
304
305
  if (!traceLookup)
305
306
  return;
306
307
  console.log(`[builder-credential] scope=${creds.source} scopeId=${scopeId} email=${email} complete=${isCompleteBuilderConnection(creds)} private=${Boolean(creds.privateKey)} public=${Boolean(creds.publicKey)}`);
307
308
  };
308
- const userCreds = await readBuilderCredentialScope(readAppSecret, "user", email);
309
+ const userCreds = await readBuilderCredentialScope(readAppSecrets, "user", email);
309
310
  traceScope(userCreds, email);
310
311
  if (isCompleteBuilderConnection(userCreds))
311
312
  return userCreds;
312
313
  const orgId = getRequestOrgId();
313
314
  if (orgId) {
314
315
  scopeAttempted = "org";
315
- const orgCreds = await readBuilderCredentialScope(readAppSecret, "org", orgId);
316
+ const orgCreds = await readBuilderCredentialScope(readAppSecrets, "org", orgId);
316
317
  traceScope(orgCreds, orgId);
317
318
  if (isCompleteBuilderConnection(orgCreds))
318
319
  return orgCreds;
319
320
  scopeAttempted = "workspace";
320
- const workspaceCreds = await readBuilderCredentialScope(readAppSecret, "workspace", orgId);
321
+ const workspaceCreds = await readBuilderCredentialScope(readAppSecrets, "workspace", orgId);
321
322
  traceScope(workspaceCreds, orgId);
322
323
  if (isCompleteBuilderConnection(workspaceCreds))
323
324
  return workspaceCreds;
@@ -325,7 +326,7 @@ async function resolveScopedBuilderCredentials() {
325
326
  else {
326
327
  scopeAttempted = "workspace-solo";
327
328
  const scopeId = `solo:${email}`;
328
- const workspaceCreds = await readBuilderCredentialScope(readAppSecret, "workspace", scopeId);
329
+ const workspaceCreds = await readBuilderCredentialScope(readAppSecrets, "workspace", scopeId);
329
330
  traceScope(workspaceCreds, scopeId);
330
331
  if (isCompleteBuilderConnection(workspaceCreds))
331
332
  return workspaceCreds;
@@ -1 +1 @@
1
- {"version":3,"file":"credential-provider.js","sourceRoot":"","sources":["../../src/server/credential-provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5E;;;;;;;;GAQG;AACH,MAAM,UAAU,2BAA2B,CACzC,KAAa,EACb,KAAgC,EAChC,IAA+B;IAE/B,IAAI,KAAK,IAAI,CAAC,IAAI,KAAK,OAAO,IAAI,IAAI,KAAK,OAAO,CAAC,EAAE,CAAC;QACpD,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC1C,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;AAC3C,CAAC;AAED,MAAM,OAAO,yBAA0B,SAAQ,KAAK;IACzC,kBAAkB,CAAS;IAC3B,iBAAiB,CAAU;IAC3B,WAAW,CAAU;IAE9B,YAAY,IAKX;QACC,KAAK,CACH,IAAI,CAAC,OAAO;YACV,gCAAgC,IAAI,CAAC,kBAAk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C;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gCAAgC;IAC9C,OAAO,CACL,OAAO,CAAC,GAAG,CAAC,iCAAiC;QAC7C,+CAA+C,CAChD,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,0BAA0B;IACxC,OAAO,CACL,OAAO,CAAC,GAAG,CAAC,2BAA2B;QACvC,mDAAmD,CACpD,CAAC;AACJ,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,oBAAoB;IAClC,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC;IAC5C,OAAO,GAAG,CAAC,CAAC,CAAC,UAAU,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AACtC,CAAC","sourcesContent":["/**\n * Credential provider abstraction.\n *\n * Every feature that needs an external credential (Anthropic API key,\n * Google OAuth tokens, OpenAI key, Slack bot token, etc.) should go through\n * one of the resolve*() helpers here instead of reading `process.env`\n * directly. That way the same feature can work in three modes:\n *\n * 1. User set their own key in .env → use it directly\n * 2. User connected Builder via `/cli-auth` → route through Builder proxy\n * 3. Neither → throw FeatureNotConfigured\n *\n * Templates catch FeatureNotConfigured and show a \"Connect Builder (1 click) /\n * set up your own key (guide)\" card.\n *\n * Today these helpers are used by the Builder-hosted LLM gateway, and the\n * shape is meant to grow to cover future managed credential integrations\n * (e.g. additional Builder-hosted services) without rewrites.\n */\n\nimport { createHash } from \"node:crypto\";\n\nimport { isLocalDatabase } from \"../db/client.js\";\nimport { getRequestUserEmail, getRequestOrgId } from \"./request-context.js\";\n\n/**\n * Decide which `app_secrets` scope a Builder/credential write should use.\n *\n * Org scope (\"everyone in this org sees these credentials\") wins when the\n * connecting user is an owner or admin of an active org — the write\n * privileges shared infra. A plain member or a user without an active\n * org falls through to per-user scope so a teammate can't silently\n * overwrite the org-shared connection.\n */\nexport function resolveCredentialWriteScope(\n email: string,\n orgId: string | null | undefined,\n role: string | null | undefined,\n): { scope: \"user\" | \"org\"; scopeId: string } {\n if (orgId && (role === \"owner\" || role === \"admin\")) {\n return { scope: \"org\", scopeId: orgId };\n }\n return { scope: \"user\", scopeId: email };\n}\n\nexport class FeatureNotConfiguredError extends Error {\n readonly requiredCredential: string;\n readonly builderConnectUrl?: string;\n readonly byokDocsUrl?: string;\n\n constructor(opts: {\n requiredCredential: string;\n message?: string;\n builderConnectUrl?: string;\n byokDocsUrl?: string;\n }) {\n super(\n opts.message ??\n `Feature requires credential \"${opts.requiredCredential}\". Connect Builder or set your own key.`,\n );\n this.name = \"FeatureNotConfiguredError\";\n this.requiredCredential = opts.requiredCredential;\n this.builderConnectUrl = opts.builderConnectUrl;\n this.byokDocsUrl = opts.byokDocsUrl;\n }\n}\n\n/**\n * Deployment-level credential fallback for single-tenant/local operation.\n * Multi-tenant call sites must gate this explicitly before calling.\n */\nexport function readDeployCredentialEnv(key: string): string | undefined {\n return process.env[key] || undefined;\n}\n\nconst APP_PROVIDED_DEPLOY_CREDENTIAL_KEYS = new Set([\n \"ANTHROPIC_API_KEY\",\n \"OPENAI_API_KEY\",\n \"OPENAI_BASE_URL\",\n \"OPENROUTER_API_KEY\",\n \"GOOGLE_CLIENT_ID\",\n \"GOOGLE_CLIENT_SECRET\",\n \"GOOGLE_GENERATIVE_AI_API_KEY\",\n \"GROQ_API_KEY\",\n \"MISTRAL_API_KEY\",\n \"COHERE_API_KEY\",\n]);\n\nfunction isAppProvidedDeployCredentialKey(key: string | undefined): boolean {\n return !!key && APP_PROVIDED_DEPLOY_CREDENTIAL_KEYS.has(key);\n}\n\n/**\n * Deployment-level credentials are safe as a runtime fallback only in local /\n * single-tenant contexts. In hosted production with a shared database, every\n * signed-in user needs their own user/org/workspace credential for\n * identity-bearing provider keys so one deploy key does not silently\n * impersonate another tenant. App-provided service credentials are different:\n * they configure the deployed app itself rather than identifying a user. This\n * includes LLM keys that let the app developer pay for model usage and OAuth\n * client credentials whose per-user identity remains in scoped OAuth tokens.\n * Key-aware callers may use those env vars.\n *\n * @deprecated Use `canUseDeployCredentialFallbackForRequest()` for generic\n * provider secrets. This stricter helper remains for legacy call sites with\n * identity-bearing deploy credentials.\n */\nexport function isDeployCredentialFallbackAllowed(): boolean {\n if (!isProductionLikeRuntime()) return true;\n return isLocalDatabase();\n}\n\nexport function canUseDeployCredentialFallbackForRequest(\n key?: string,\n): boolean {\n const email = getRequestUserEmail();\n if (!email) return true;\n if (isAppProvidedDeployCredentialKey(key)) return true;\n if (isHostedWorkspaceRuntime()) return false;\n if (!isProductionLikeRuntime()) return true;\n return isLocalDatabase();\n}\n\nconst BUILDER_CREDENTIAL_KEYS = [\n \"BUILDER_PRIVATE_KEY\",\n \"BUILDER_PUBLIC_KEY\",\n \"BUILDER_USER_ID\",\n \"BUILDER_ORG_NAME\",\n \"BUILDER_ORG_KIND\",\n \"BUILDER_SUBSCRIPTION\",\n \"BUILDER_SUBSCRIPTION_LEVEL\",\n \"BUILDER_SUBSCRIPTION_NAME\",\n \"BUILDER_IS_ENTERPRISE\",\n \"BUILDER_IS_FREE_ACCOUNT\",\n] as const;\n\nfunction isBuilderCredentialKey(key: string): boolean {\n return (BUILDER_CREDENTIAL_KEYS as readonly string[]).includes(key);\n}\n\nfunction isHostedWorkspaceRuntime(): boolean {\n const hasFusionPreview = Boolean(\n process.env.FUSION_ENVIRONMENT ||\n process.env.FUSION_ENV_ORIGIN ||\n process.env.VITE_FUSION_ENV_ORIGIN,\n );\n return (\n /^(1|true)$/i.test(process.env.AGENT_NATIVE_WORKSPACE ?? \"\") ||\n /^(1|true)$/i.test(process.env.VITE_AGENT_NATIVE_WORKSPACE ?? \"\") ||\n hasFusionPreview\n );\n}\n\nfunction isProductionLikeRuntime(): boolean {\n return (\n process.env.NODE_ENV === \"production\" ||\n /^(1|true)$/i.test(process.env.NETLIFY ?? \"\") ||\n /^(1|true)$/i.test(process.env.VERCEL ?? \"\") ||\n /^(1|true)$/i.test(process.env.CF_PAGES ?? \"\") ||\n Boolean(\n process.env.AWS_LAMBDA_FUNCTION_NAME ||\n process.env.AWS_EXECUTION_ENV ||\n process.env.FUNCTIONS_WORKER_RUNTIME ||\n process.env.K_SERVICE ||\n process.env.RENDER,\n )\n );\n}\n\n/**\n * Whether deployment-level Builder env keys may back the current request.\n *\n * This is intentionally self-contained rather than delegating to\n * `canUseDeployCredentialFallbackForRequest`. That generic helper blocks the\n * deploy fallback for any signed-in user in a hosted workspace runtime, so the\n * Builder dogfooding escape hatch must apply its own hosted-workspace exception\n * here instead of inheriting the generic helper's stricter (and hatch-unaware)\n * decision. Reading the env once into locals keeps the rules legible.\n *\n * Rules (all evaluated against the live request/runtime, not a build-time value):\n * - No signed-in user → safe to use the deploy env (nobody to mis-identify).\n * - Hosted workspace + signed-in user → deploy-level Builder keys would\n * impersonate that user, so block them — UNLESS a developer has explicitly\n * opted into the local dogfooding escape hatch (non-prod only). Default OFF;\n * hosted/shared production deployments are never affected.\n * - Otherwise → allowed in non-prod, or on a local/single-tenant database.\n */\nfunction canUseBuilderDeployCredentialFallbackForRequest(): boolean {\n const email = getRequestUserEmail();\n if (!email) return true;\n\n const isProductionRuntime = isProductionLikeRuntime();\n // Local dogfooding escape hatch: lets the env / root-`.env` Builder key back\n // a signed-in user so running the app locally doesn't require completing the\n // Builder connect flow first. Non-prod only.\n const localDevOptIn =\n !isProductionRuntime &&\n /^(1|true)$/i.test(process.env.AGENT_NATIVE_LOCAL_BUILDER_ENV ?? \"\");\n\n if (isHostedWorkspaceRuntime() && !localDevOptIn) return false;\n\n // Deploy fallback is safe in non-prod or on a local/single-tenant database.\n return !isProductionRuntime || isLocalDatabase();\n}\n\nfunction shouldTraceCredentialResolve(): boolean {\n return /^(1|true)$/i.test(\n process.env.AGENT_NATIVE_DEBUG_CREDENTIAL_RESOLVE ??\n process.env.DEBUG_CREDENTIAL_RESOLVE ??\n \"\",\n );\n}\n\n// ---------------------------------------------------------------------------\n// Builder credential resolution:\n//\n// 1. **Request-scoped credentials.** A signed-in user can connect Builder\n// through the CLI-auth flow. Owner/admin connections land at org scope;\n// member/no-org connections land at user scope.\n//\n// 2. **Deployment fallback.** BUILDER_PRIVATE_KEY in env still makes local\n// and single-tenant deploys work out of the box, but it no longer blocks\n// per-user connect. Request-scoped credentials win whenever present.\n//\n// To run multi-tenant SaaS: prefer leaving BUILDER_PRIVATE_KEY unset unless a\n// shared fallback identity is intentional.\n// ---------------------------------------------------------------------------\n\ntype BuilderCredentialSource = \"user\" | \"org\" | \"workspace\" | \"env\";\ninterface BuilderResolvedCredentials {\n privateKey: string | null;\n publicKey: string | null;\n userId: string | null;\n orgName: string | null;\n orgKind: string | null;\n subscription: string | null;\n subscriptionLevel: string | null;\n subscriptionName: string | null;\n isEnterprise: boolean | null;\n isFreeAccount: boolean | null;\n source: Exclude<BuilderCredentialSource, \"env\">;\n}\n\nfunction isCompleteBuilderConnection(creds: BuilderResolvedCredentials) {\n return Boolean(creds.privateKey && creds.publicKey);\n}\n\nfunction readOptionalBuilderBoolean(\n value: string | null | undefined,\n): boolean | null {\n if (value == null || value === \"\") return null;\n return /^(1|true)$/i.test(value);\n}\n\nexport function isBuilderPrivateKey(value: string | null | undefined): boolean {\n return typeof value === \"string\" && value.trim().startsWith(\"bpk-\");\n}\n\nasync function readBuilderCredentialScope(\n readAppSecret: typeof import(\"../secrets/storage.js\").readAppSecret,\n scope: \"user\" | \"org\" | \"workspace\",\n scopeId: string,\n): Promise<BuilderResolvedCredentials> {\n const values = await Promise.all(\n BUILDER_CREDENTIAL_KEYS.map(async (key) => {\n const secret = await readAppSecret({ key, scope, scopeId });\n return [key, secret?.value ?? null] as const;\n }),\n );\n const map = new Map<string, string | null>(values);\n return {\n privateKey: map.get(\"BUILDER_PRIVATE_KEY\") ?? null,\n publicKey: map.get(\"BUILDER_PUBLIC_KEY\") ?? null,\n userId: map.get(\"BUILDER_USER_ID\") ?? null,\n orgName: map.get(\"BUILDER_ORG_NAME\") ?? null,\n orgKind: map.get(\"BUILDER_ORG_KIND\") ?? null,\n subscription: map.get(\"BUILDER_SUBSCRIPTION\") ?? null,\n subscriptionLevel: map.get(\"BUILDER_SUBSCRIPTION_LEVEL\") ?? null,\n subscriptionName: map.get(\"BUILDER_SUBSCRIPTION_NAME\") ?? null,\n isEnterprise: readOptionalBuilderBoolean(map.get(\"BUILDER_IS_ENTERPRISE\")),\n isFreeAccount: readOptionalBuilderBoolean(\n map.get(\"BUILDER_IS_FREE_ACCOUNT\"),\n ),\n source: scope === \"workspace\" ? \"workspace\" : scope,\n };\n}\n\nasync function resolveScopedBuilderCredential(\n key: string,\n): Promise<{ value: string; source: \"user\" | \"org\" | \"workspace\" } | null> {\n const email = getRequestUserEmail();\n if (!email) return null;\n\n // Trace only when explicitly requested. These diagnostics are useful for\n // support, but they include account identifiers and run on hot paths.\n const traceLookup = shouldTraceCredentialResolve();\n let scopeAttempted = \"user\";\n try {\n const { readAppSecret } = await import(\"../secrets/storage.js\");\n\n // 1. Per-user override: a user can paste their own key in settings to\n // overrule the org-shared one (handy for a personal sandbox).\n const userSecret = await readAppSecret({\n key,\n scope: \"user\",\n scopeId: email,\n });\n if (userSecret) {\n if (traceLookup) {\n console.log(\n `[builder-credential] key=${key} email=${email} scope=user hit=true`,\n );\n }\n return { value: userSecret.value, source: \"user\" };\n }\n\n // 2. Per-org shared credential: when one teammate connects Builder\n // as an owner/admin we write the OAuth result at org scope so\n // every member of that org gets the AI chat working without\n // re-running the connect flow. Resolution falls back here\n // silently — the caller never has to know which scope answered.\n const orgId = getRequestOrgId();\n if (orgId) {\n scopeAttempted = \"org\";\n const orgSecret = await readAppSecret({\n key,\n scope: \"org\",\n scopeId: orgId,\n });\n if (orgSecret) {\n if (traceLookup) {\n console.log(\n `[builder-credential] key=${key} email=${email} orgId=${orgId} scope=org hit=true`,\n );\n }\n return { value: orgSecret.value, source: \"org\" };\n }\n\n // Older setup flows wrote shared credentials at workspace scope.\n // Keep reading those rows so status UIs and runtime resolution agree\n // for users who connected before org-scoped Builder credentials existed.\n scopeAttempted = \"workspace\";\n const workspaceSecret = await readAppSecret({\n key,\n scope: \"workspace\",\n scopeId: orgId,\n });\n if (workspaceSecret) {\n if (traceLookup) {\n console.log(\n `[builder-credential] key=${key} email=${email} orgId=${orgId} scope=workspace hit=true`,\n );\n }\n return { value: workspaceSecret.value, source: \"workspace\" };\n }\n if (traceLookup) {\n console.log(\n `[builder-credential] key=${key} email=${email} orgId=${orgId} miss tried=user,org,workspace`,\n );\n }\n } else {\n scopeAttempted = \"workspace-solo\";\n const soloWorkspaceSecret = await readAppSecret({\n key,\n scope: \"workspace\",\n scopeId: `solo:${email}`,\n });\n if (soloWorkspaceSecret) {\n if (traceLookup) {\n console.log(\n `[builder-credential] key=${key} email=${email} scope=workspace-solo hit=true`,\n );\n }\n return { value: soloWorkspaceSecret.value, source: \"workspace\" };\n }\n if (traceLookup) {\n console.log(\n `[builder-credential] key=${key} email=${email} orgId=(none) miss tried=user,workspace-solo`,\n );\n }\n }\n } catch (err) {\n if (traceLookup) {\n console.log(\n `[builder-credential] key=${key} email=${email} scope=${scopeAttempted} error=${(err as Error)?.message ?? err}`,\n );\n }\n // Secrets table not ready — treat as missing.\n }\n return null;\n}\n\nasync function resolveScopedBuilderCredentials(): Promise<BuilderResolvedCredentials | null> {\n const email = getRequestUserEmail();\n if (!email) return null;\n\n const traceLookup = shouldTraceCredentialResolve();\n let scopeAttempted = \"user\";\n try {\n const { readAppSecret } = await import(\"../secrets/storage.js\");\n const traceScope = (creds: BuilderResolvedCredentials, scopeId: string) => {\n if (!traceLookup) return;\n console.log(\n `[builder-credential] scope=${creds.source} scopeId=${scopeId} email=${email} complete=${isCompleteBuilderConnection(creds)} private=${Boolean(creds.privateKey)} public=${Boolean(creds.publicKey)}`,\n );\n };\n\n const userCreds = await readBuilderCredentialScope(\n readAppSecret,\n \"user\",\n email,\n );\n traceScope(userCreds, email);\n if (isCompleteBuilderConnection(userCreds)) return userCreds;\n\n const orgId = getRequestOrgId();\n if (orgId) {\n scopeAttempted = \"org\";\n const orgCreds = await readBuilderCredentialScope(\n readAppSecret,\n \"org\",\n orgId,\n );\n traceScope(orgCreds, orgId);\n if (isCompleteBuilderConnection(orgCreds)) return orgCreds;\n\n scopeAttempted = \"workspace\";\n const workspaceCreds = await readBuilderCredentialScope(\n readAppSecret,\n \"workspace\",\n orgId,\n );\n traceScope(workspaceCreds, orgId);\n if (isCompleteBuilderConnection(workspaceCreds)) return workspaceCreds;\n } else {\n scopeAttempted = \"workspace-solo\";\n const scopeId = `solo:${email}`;\n const workspaceCreds = await readBuilderCredentialScope(\n readAppSecret,\n \"workspace\",\n scopeId,\n );\n traceScope(workspaceCreds, scopeId);\n if (isCompleteBuilderConnection(workspaceCreds)) return workspaceCreds;\n }\n } catch (err) {\n if (traceLookup) {\n console.log(\n `[builder-credential] email=${email} scope=${scopeAttempted} credentials error=${(err as Error)?.message ?? err}`,\n );\n }\n }\n return null;\n}\n\n/**\n * Resolve a Builder credential for the current request. User/org credentials\n * win; deployment env is only a fallback. This lets local/root .env keys keep\n * a template working while still allowing users to connect their own Builder\n * account from Settings or onboarding.\n */\nexport async function resolveBuilderCredential(\n key: string,\n): Promise<string | null> {\n const scoped = await resolveScopedBuilderCredential(key);\n if (scoped) return scoped.value;\n if (!canUseBuilderDeployCredentialFallbackForRequest()) return null;\n return readDeployCredentialEnv(key) ?? null;\n}\n\n/**\n * True when `BUILDER_PRIVATE_KEY` is set at the deployment level. This means\n * a deploy-level fallback exists; it does not prevent per-user connect.\n */\nexport function isBuilderEnvManaged(): boolean {\n return !!process.env.BUILDER_PRIVATE_KEY;\n}\n\n/**\n * Resolve the Builder private key for the current request. User/org OAuth\n * credentials win; deploy-level `BUILDER_PRIVATE_KEY` is the fallback.\n */\nexport async function resolveBuilderPrivateKey(): Promise<string | null> {\n return resolveBuilderCredential(\"BUILDER_PRIVATE_KEY\");\n}\n\n/**\n * Resolve the current user's Builder auth header.\n * Returns `\"Bearer <key>\"` or null.\n */\nexport async function resolveBuilderAuthHeader(): Promise<string | null> {\n const key = await resolveBuilderPrivateKey();\n return key ? `Bearer ${key}` : null;\n}\n\n/**\n * Check whether the current user has a Builder private key configured\n * (per-user or deployment-level).\n */\nexport async function resolveHasBuilderPrivateKey(): Promise<boolean> {\n return !!(await resolveBuilderPrivateKey());\n}\n\n/**\n * Check whether the current request has the complete Builder credential bundle\n * needed for Builder-backed assistant/image-generation calls.\n */\nexport async function resolveHasCompleteBuilderConnection(): Promise<boolean> {\n const creds = await resolveBuilderCredentials();\n return !!(creds.privateKey && creds.publicKey);\n}\n\n/**\n * Resolve where the effective Builder assistant connection came from. This\n * intentionally requires a complete private+public key pair from one scope so\n * status UIs don't report a mixed user/org credential set as connected.\n */\nexport async function resolveBuilderCredentialSource(): Promise<BuilderCredentialSource | null> {\n const scoped = await resolveScopedBuilderCredentials();\n if (scoped) return scoped.source;\n return canUseBuilderDeployCredentialFallbackForRequest() &&\n process.env.BUILDER_PRIVATE_KEY\n ? \"env\"\n : null;\n}\n\n/**\n * Resolve the Builder assistant credential bundle from one complete scope.\n * A partial user row is treated as a miss so the org-shared connection can\n * still power the assistant for teammates.\n */\nexport async function resolveBuilderCredentials(): Promise<{\n privateKey: string | null;\n publicKey: string | null;\n userId: string | null;\n orgName: string | null;\n orgKind: string | null;\n subscription: string | null;\n subscriptionLevel: string | null;\n subscriptionName: string | null;\n isEnterprise: boolean | null;\n isFreeAccount: boolean | null;\n}> {\n const scoped = await resolveScopedBuilderCredentials();\n if (scoped) {\n const {\n privateKey,\n publicKey,\n userId,\n orgName,\n orgKind,\n subscription,\n subscriptionLevel,\n subscriptionName,\n isEnterprise,\n isFreeAccount,\n } = scoped;\n return {\n privateKey,\n publicKey,\n userId,\n orgName,\n orgKind,\n subscription,\n subscriptionLevel,\n subscriptionName,\n isEnterprise,\n isFreeAccount,\n };\n }\n const privateKey = canUseBuilderDeployCredentialFallbackForRequest()\n ? (readDeployCredentialEnv(\"BUILDER_PRIVATE_KEY\") ?? null)\n : null;\n const publicKey = canUseBuilderDeployCredentialFallbackForRequest()\n ? (readDeployCredentialEnv(\"BUILDER_PUBLIC_KEY\") ?? null)\n : null;\n const userId = canUseBuilderDeployCredentialFallbackForRequest()\n ? (readDeployCredentialEnv(\"BUILDER_USER_ID\") ?? null)\n : null;\n const orgName = canUseBuilderDeployCredentialFallbackForRequest()\n ? (readDeployCredentialEnv(\"BUILDER_ORG_NAME\") ?? null)\n : null;\n const orgKind = canUseBuilderDeployCredentialFallbackForRequest()\n ? (readDeployCredentialEnv(\"BUILDER_ORG_KIND\") ?? null)\n : null;\n const subscription = canUseBuilderDeployCredentialFallbackForRequest()\n ? (readDeployCredentialEnv(\"BUILDER_SUBSCRIPTION\") ?? null)\n : null;\n const subscriptionLevel = canUseBuilderDeployCredentialFallbackForRequest()\n ? (readDeployCredentialEnv(\"BUILDER_SUBSCRIPTION_LEVEL\") ?? null)\n : null;\n const subscriptionName = canUseBuilderDeployCredentialFallbackForRequest()\n ? (readDeployCredentialEnv(\"BUILDER_SUBSCRIPTION_NAME\") ?? null)\n : null;\n const isEnterprise = canUseBuilderDeployCredentialFallbackForRequest()\n ? readOptionalBuilderBoolean(\n readDeployCredentialEnv(\"BUILDER_IS_ENTERPRISE\"),\n )\n : null;\n const isFreeAccount = canUseBuilderDeployCredentialFallbackForRequest()\n ? readOptionalBuilderBoolean(\n readDeployCredentialEnv(\"BUILDER_IS_FREE_ACCOUNT\"),\n )\n : null;\n return {\n privateKey,\n publicKey,\n userId,\n orgName,\n orgKind,\n subscription,\n subscriptionLevel,\n subscriptionName,\n isEnterprise,\n isFreeAccount,\n };\n}\n\nconst BUILDER_AUTH_FAILURE_SETTING_PREFIX = \"builder-auth-failure:\";\n\nexport interface BuilderCredentialAuthFailure {\n fingerprint: string;\n message: string;\n status?: number;\n code?: string;\n at: number;\n ownerEmail?: string | null;\n orgId?: string | null;\n}\n\nexport function builderCredentialFingerprint(\n privateKey?: string | null,\n publicKey?: string | null,\n): string | null {\n if (!privateKey || !publicKey) return null;\n return createHash(\"sha256\")\n .update(privateKey)\n .update(\"\\0\")\n .update(publicKey)\n .digest(\"hex\")\n .slice(0, 24);\n}\n\nfunction builderAuthFailureSettingKey(fingerprint: string): string {\n return `${BUILDER_AUTH_FAILURE_SETTING_PREFIX}${fingerprint}`;\n}\n\nexport async function getBuilderCredentialAuthFailure(\n creds: {\n privateKey?: string | null;\n publicKey?: string | null;\n } = {},\n): Promise<BuilderCredentialAuthFailure | null> {\n const fingerprint = builderCredentialFingerprint(\n creds.privateKey,\n creds.publicKey,\n );\n if (!fingerprint) return null;\n try {\n const { getSetting } = await import(\"../settings/store.js\");\n const row = await getSetting(builderAuthFailureSettingKey(fingerprint));\n if (!row) return null;\n return {\n fingerprint,\n message:\n typeof row.message === \"string\" && row.message\n ? row.message\n : \"Builder rejected the connected credentials. Reconnect Builder.io.\",\n status: typeof row.status === \"number\" ? row.status : undefined,\n code: typeof row.code === \"string\" ? row.code : undefined,\n at: typeof row.at === \"number\" ? row.at : Date.now(),\n ownerEmail:\n typeof row.ownerEmail === \"string\" ? row.ownerEmail : undefined,\n orgId: typeof row.orgId === \"string\" ? row.orgId : undefined,\n };\n } catch {\n return null;\n }\n}\n\nexport async function recordBuilderCredentialAuthFailure(details?: {\n status?: number;\n code?: string;\n message?: string;\n}): Promise<void> {\n try {\n const creds = await resolveBuilderCredentials();\n const fingerprint = builderCredentialFingerprint(\n creds.privateKey,\n creds.publicKey,\n );\n if (!fingerprint) return;\n const { putSetting } = await import(\"../settings/store.js\");\n await putSetting(builderAuthFailureSettingKey(fingerprint), {\n fingerprint,\n message:\n details?.message ||\n \"Builder rejected the connected credentials. Reconnect Builder.io.\",\n ...(typeof details?.status === \"number\" && { status: details.status }),\n ...(details?.code && { code: details.code }),\n at: Date.now(),\n ownerEmail: getRequestUserEmail() ?? null,\n orgId: getRequestOrgId() ?? null,\n });\n } catch {\n // Best-effort marker only; the chat error is still returned to the user.\n }\n}\n\nexport async function clearBuilderCredentialAuthFailure(creds: {\n privateKey?: string | null;\n publicKey?: string | null;\n}): Promise<void> {\n const fingerprint = builderCredentialFingerprint(\n creds.privateKey,\n creds.publicKey,\n );\n if (!fingerprint) return;\n try {\n const { deleteSetting } = await import(\"../settings/store.js\");\n await deleteSetting(builderAuthFailureSettingKey(fingerprint));\n } catch {\n // A stale failure marker should not block writing fresh credentials.\n }\n}\n\nconst PROVIDER_AUTH_FAILURE_SETTING_PREFIX = \"provider-auth-failure:\";\n/** Stale failure markers expire so a transient 401 cannot permanently block deploy keys. */\nexport const PROVIDER_AUTH_FAILURE_TTL_MS = 15 * 60 * 1000;\n\nexport interface ProviderCredentialAuthFailure {\n fingerprint: string;\n key: string;\n message: string;\n status?: number;\n code?: string;\n at: number;\n ownerEmail?: string | null;\n orgId?: string | null;\n}\n\nexport function providerCredentialFingerprint(\n key?: string | null,\n value?: string | null,\n): string | null {\n const normalizedKey = key?.trim().toUpperCase();\n const normalizedValue = value?.trim();\n if (!normalizedKey || !normalizedValue) return null;\n return createHash(\"sha256\")\n .update(normalizedKey)\n .update(\"\\0\")\n .update(normalizedValue)\n .digest(\"hex\")\n .slice(0, 24);\n}\n\nfunction providerAuthFailureSettingKey(fingerprint: string): string {\n return `${PROVIDER_AUTH_FAILURE_SETTING_PREFIX}${fingerprint}`;\n}\n\nexport async function getProviderCredentialAuthFailure(opts: {\n key?: string | null;\n value?: string | null;\n}): Promise<ProviderCredentialAuthFailure | null> {\n const key = opts.key?.trim().toUpperCase() ?? \"\";\n const fingerprint = providerCredentialFingerprint(key, opts.value);\n if (!fingerprint) return null;\n try {\n const settings = await import(\"../settings/store.js\");\n const settingKey = providerAuthFailureSettingKey(fingerprint);\n const row = await settings.getSetting(settingKey);\n if (!row) return null;\n if (row.fingerprint !== fingerprint) return null;\n const at = typeof row.at === \"number\" ? row.at : Date.now();\n if (Date.now() - at > PROVIDER_AUTH_FAILURE_TTL_MS) {\n if (typeof settings.deleteSetting === \"function\") {\n await settings.deleteSetting(settingKey).catch(() => {});\n }\n return null;\n }\n return {\n fingerprint,\n key:\n typeof row.key === \"string\" && row.key\n ? row.key\n : key || \"UNKNOWN_PROVIDER_KEY\",\n message:\n typeof row.message === \"string\" && row.message\n ? row.message\n : \"The model provider rejected the saved API key.\",\n status: typeof row.status === \"number\" ? row.status : undefined,\n code: typeof row.code === \"string\" ? row.code : undefined,\n at,\n ownerEmail:\n typeof row.ownerEmail === \"string\" ? row.ownerEmail : undefined,\n orgId: typeof row.orgId === \"string\" ? row.orgId : undefined,\n };\n } catch {\n return null;\n }\n}\n\nexport async function recordProviderCredentialAuthFailure(opts: {\n key?: string | null;\n value?: string | null;\n status?: number;\n code?: string;\n message?: string;\n}): Promise<void> {\n try {\n const key = opts.key?.trim().toUpperCase() ?? \"\";\n const value = opts.value?.trim();\n const fingerprint = providerCredentialFingerprint(key, value);\n if (!fingerprint) return;\n const { putSetting } = await import(\"../settings/store.js\");\n await putSetting(providerAuthFailureSettingKey(fingerprint), {\n fingerprint,\n key,\n message: opts.message || \"The model provider rejected the saved API key.\",\n ...(typeof opts.status === \"number\" && { status: opts.status }),\n ...(opts.code && { code: opts.code }),\n at: Date.now(),\n ownerEmail: getRequestUserEmail() ?? null,\n orgId: getRequestOrgId() ?? null,\n });\n } catch {\n // Best-effort marker only; the chat error is still returned to the user.\n }\n}\n\nexport async function clearProviderCredentialAuthFailure(opts: {\n key?: string | null;\n value?: string | null;\n}): Promise<void> {\n const fingerprint = providerCredentialFingerprint(opts.key, opts.value);\n if (!fingerprint) return;\n try {\n const { deleteSetting } = await import(\"../settings/store.js\");\n await deleteSetting(providerAuthFailureSettingKey(fingerprint));\n } catch {\n // A stale failure marker should not block writing or using fresh keys.\n }\n}\n\n/**\n * Write Builder credentials to `app_secrets`.\n *\n * Scope decision (see `resolveCredentialWriteScope`): when the connecting\n * user is owner/admin of an active org we write at `scope: \"org\"` so every\n * member of that org auto-resolves the credentials via\n * `resolveBuilderCredential`'s org fallback — no per-user re-connect\n * needed. A plain member or a user with no active org writes at\n * `scope: \"user\"` (the safe default that doesn't trample the org's shared\n * connection).\n *\n * Stale-credential cleanup: before writing the new values we (1) clear ALL\n * five BUILDER_* keys at the target scope, so optional fields the new\n * connection doesn't carry (e.g. user picked a Builder space that returns\n * no orgName) don't leave the previous connection's metadata behind, and\n * (2) when writing at org scope, also clear the writer's own user-scope\n * BUILDER_* rows so a stale personal override from an earlier connect\n * doesn't shadow the new org write on resolution (user scope wins org\n * scope by design — see `resolveScopedBuilderCredential`). The org-scope\n * row is intentionally left alone when writing at user scope: that row is\n * shared with the rest of the org and a single user's personal override\n * shouldn't blow it away. (Victoria's \"I signed in again with my Builder\n * space and it still says no credits\" report on 2026-05-11 was exactly\n * this stale-shadow case.)\n *\n * Returns the actual scope/scopeId used so the caller can show \"Connected\n * for Builder.io\" vs \"Connected (personal)\" in the UI.\n */\nexport async function writeBuilderCredentials(\n email: string,\n creds: {\n privateKey: string;\n publicKey: string;\n userId?: string | null;\n orgName?: string | null;\n orgKind?: string | null;\n subscription?: string | null;\n subscriptionLevel?: string | null;\n subscriptionName?: string | null;\n isEnterprise?: boolean | null;\n isFreeAccount?: boolean | null;\n },\n options?: { orgId?: string | null; role?: string | null },\n): Promise<{ scope: \"user\" | \"org\"; scopeId: string }> {\n const privateKey = creds.privateKey.trim();\n const publicKey = creds.publicKey.trim();\n if (!isBuilderPrivateKey(privateKey)) {\n throw new Error(\n \"Builder returned a credential that is not a Builder private key (expected bpk-...). Restart the Builder connect flow and choose a space that can issue a private key.\",\n );\n }\n if (!publicKey) {\n throw new Error(\n \"Builder did not return a public API key. Restart the Builder connect flow.\",\n );\n }\n\n const { writeAppSecret, deleteAppSecret } =\n await import(\"../secrets/storage.js\");\n const target = resolveCredentialWriteScope(\n email,\n options?.orgId ?? null,\n options?.role ?? null,\n );\n\n // Clear stale rows before writing the new connection. See the function's\n // doc comment for the two cases this handles.\n const cleanups: Array<Promise<unknown>> = BUILDER_CREDENTIAL_KEYS.map((key) =>\n deleteAppSecret({\n key,\n scope: target.scope,\n scopeId: target.scopeId,\n }).catch(() => {}),\n );\n if (target.scope === \"org\") {\n for (const key of BUILDER_CREDENTIAL_KEYS) {\n cleanups.push(\n deleteAppSecret({ key, scope: \"user\", scopeId: email }).catch(() => {}),\n );\n }\n }\n await Promise.all(cleanups);\n\n const entries: Array<{ key: string; value: string }> = [\n { key: \"BUILDER_PRIVATE_KEY\", value: privateKey },\n { key: \"BUILDER_PUBLIC_KEY\", value: publicKey },\n ];\n if (creds.userId) {\n entries.push({ key: \"BUILDER_USER_ID\", value: creds.userId });\n }\n if (creds.orgName) {\n entries.push({ key: \"BUILDER_ORG_NAME\", value: creds.orgName });\n }\n if (creds.orgKind) {\n entries.push({ key: \"BUILDER_ORG_KIND\", value: creds.orgKind });\n }\n if (creds.subscription) {\n entries.push({ key: \"BUILDER_SUBSCRIPTION\", value: creds.subscription });\n }\n if (creds.subscriptionLevel) {\n entries.push({\n key: \"BUILDER_SUBSCRIPTION_LEVEL\",\n value: creds.subscriptionLevel,\n });\n }\n if (creds.subscriptionName) {\n entries.push({\n key: \"BUILDER_SUBSCRIPTION_NAME\",\n value: creds.subscriptionName,\n });\n }\n if (typeof creds.isEnterprise === \"boolean\") {\n entries.push({\n key: \"BUILDER_IS_ENTERPRISE\",\n value: String(creds.isEnterprise),\n });\n }\n if (typeof creds.isFreeAccount === \"boolean\") {\n entries.push({\n key: \"BUILDER_IS_FREE_ACCOUNT\",\n value: String(creds.isFreeAccount),\n });\n }\n await Promise.all(\n entries.map(({ key, value }) =>\n writeAppSecret({\n key,\n value,\n scope: target.scope,\n scopeId: target.scopeId,\n }),\n ),\n );\n await clearBuilderCredentialAuthFailure({\n privateKey,\n publicKey,\n });\n return target;\n}\n\n/**\n * Delete Builder credentials.\n *\n * Default behaviour: clears only this user's per-user override (so a\n * member can disconnect their personal Builder identity without\n * collapsing the org-wide connection for every teammate). To revoke the\n * org's shared connection, pass `{ orgId, role }` for an owner/admin —\n * matching the same authority gate `writeBuilderCredentials` uses on\n * write. Plain members can never reach the org-scoped row.\n */\nexport async function deleteBuilderCredentials(\n email: string,\n options?: { orgId?: string | null; role?: string | null },\n): Promise<{ scope: \"user\" | \"org\"; scopeId: string }> {\n const { deleteAppSecret } = await import(\"../secrets/storage.js\");\n const target = resolveCredentialWriteScope(\n email,\n options?.orgId ?? null,\n options?.role ?? null,\n );\n await Promise.all(\n BUILDER_CREDENTIAL_KEYS.map((key) =>\n deleteAppSecret({\n key,\n scope: target.scope,\n scopeId: target.scopeId,\n }).catch(() => {}),\n ),\n );\n return target;\n}\n\n// ---------------------------------------------------------------------------\n// Generic request-scoped secret resolution\n//\n// New consumers should prefer this over reading `process.env.X` directly.\n// User-pasted and shared secrets live in `app_secrets` (encrypted). The\n// settings UI / onboarding panels can write user, org, or workspace rows.\n// Deploy-level env vars are the fallback for unauthenticated/CLI/background\n// contexts where there's no user to scope by. Authenticated requests may also\n// use app-provided LLM provider keys such as OPENAI_API_KEY or\n// ANTHROPIC_API_KEY, but Builder identity keys keep the stricter scoped policy.\n// ---------------------------------------------------------------------------\n\n/**\n * Resolve a request-scoped secret. Reads from `app_secrets` first (current\n * user override, active org, then workspace row); falls back to `process.env`\n * only when the deploy fallback policy allows it.\n */\nexport async function resolveSecret(key: string): Promise<string | null> {\n const traceLookup = shouldTraceCredentialResolve();\n const email = getRequestUserEmail();\n if (email) {\n try {\n const { readAppSecret } = await import(\"../secrets/storage.js\");\n // Per-user override first.\n const userSecret = await readAppSecret({\n key,\n scope: \"user\",\n scopeId: email,\n });\n if (userSecret?.value) {\n if (traceLookup) {\n console.log(\n `[resolve-secret] key=${key} email=${email} scope=user hit=true`,\n );\n }\n return userSecret.value;\n }\n\n const orgId = getRequestOrgId();\n if (orgId) {\n // Fall back to the active org's shared row, when present. Builder\n // Connect uses this first-class org scope.\n const orgSecret = await readAppSecret({\n key,\n scope: \"org\",\n scopeId: orgId,\n });\n if (orgSecret?.value) {\n if (traceLookup) {\n console.log(\n `[resolve-secret] key=${key} email=${email} orgId=${orgId} scope=org hit=true`,\n );\n }\n return orgSecret.value;\n }\n\n // Registered secrets historically used \"workspace\" scope for\n // org-shared configuration. Keep reading it so Settings status and\n // runtime resolution agree.\n const workspaceSecret = await readAppSecret({\n key,\n scope: \"workspace\",\n scopeId: orgId,\n });\n if (workspaceSecret?.value) {\n if (traceLookup) {\n console.log(\n `[resolve-secret] key=${key} email=${email} orgId=${orgId} scope=workspace hit=true`,\n );\n }\n return workspaceSecret.value;\n }\n } else {\n const soloWorkspaceSecret = await readAppSecret({\n key,\n scope: \"workspace\",\n scopeId: `solo:${email}`,\n });\n if (soloWorkspaceSecret?.value) {\n if (traceLookup) {\n console.log(\n `[resolve-secret] key=${key} email=${email} scope=workspace-solo hit=true`,\n );\n }\n return soloWorkspaceSecret.value;\n }\n }\n } catch (err) {\n if (traceLookup) {\n console.log(\n `[resolve-secret] key=${key} email=${email} scope=error err=${(err as Error)?.message ?? err}`,\n );\n }\n // Secrets table not ready — treat as missing.\n }\n // Read deployment-provided env values as fallbacks; framework code must not\n // write to `process.env`, but keys supplied by the host remain valid config.\n // Builder credentials keep a narrower path below because those keys carry a\n // Builder identity rather than just enabling a provider call.\n const envFallback = (\n isBuilderCredentialKey(key)\n ? canUseBuilderDeployCredentialFallbackForRequest()\n : canUseDeployCredentialFallbackForRequest(key)\n )\n ? process.env[key] || null\n : null;\n if (traceLookup) {\n console.log(\n `[resolve-secret] key=${key} email=${email} orgId=${getRequestOrgId() ?? \"(none)\"} scope=${envFallback ? \"env-fallback\" : \"none\"} hit=${!!envFallback}`,\n );\n }\n return envFallback;\n }\n // Unauthenticated / local-dev / CLI / background context: env fallback\n // is safe because there's no user to mis-identify.\n const value = process.env[key] || null;\n if (traceLookup) {\n console.log(\n `[resolve-secret] key=${key} email=(none) scope=env-anonymous hit=${!!value}`,\n );\n }\n return value;\n}\n\n// ---------------------------------------------------------------------------\n// Synchronous helpers — env-only fallbacks for contexts where per-user\n// lookup isn't possible (sync isConfigured checks, CLI scripts).\n// ---------------------------------------------------------------------------\n\n/**\n * True when a Builder private key is configured at the deployment level.\n *\n * This is the same env-only check as `isBuilderEnvManaged()`. For \"does this\n * request have access to Builder via user/org/env credentials?\" use the async\n * `resolveHasBuilderPrivateKey()`.\n */\nexport function hasBuilderPrivateKey(): boolean {\n return !!process.env.BUILDER_PRIVATE_KEY;\n}\n\n/** The origin for Builder-proxied API calls. Overridable for testing. */\nexport function getBuilderProxyOrigin(): string {\n return (\n process.env.BUILDER_PROXY_ORIGIN ||\n process.env.AIR_HOST ||\n process.env.BUILDER_API_HOST ||\n \"https://api.builder.io\"\n );\n}\n\n/**\n * Base URL for the public Builder LLM gateway, which lives at\n * api.builder.io/agent-native/gateway.\n * Override via BUILDER_GATEWAY_BASE_URL for staging / testing.\n */\nexport function getBuilderGatewayBaseUrl(): string {\n return (\n process.env.BUILDER_GATEWAY_BASE_URL ||\n \"https://api.builder.io/agent-native/gateway/v1\"\n );\n}\n\n/**\n * Base URL for Builder-managed image generation.\n * Override via BUILDER_IMAGE_GENERATION_BASE_URL for staging / testing.\n */\nexport function getBuilderImageGenerationBaseUrl(): string {\n return (\n process.env.BUILDER_IMAGE_GENERATION_BASE_URL ||\n \"https://api.builder.io/agent-native/images/v1\"\n );\n}\n\n/**\n * Base URL for Builder-managed web search.\n * Override via BUILDER_WEB_SEARCH_BASE_URL for staging / testing.\n */\nexport function getBuilderWebSearchBaseUrl(): string {\n return (\n process.env.BUILDER_WEB_SEARCH_BASE_URL ||\n \"https://api.builder.io/agent-native/web-search/v1\"\n );\n}\n\n/** Authorization header value for Builder-proxied calls (env-only). */\nexport function getBuilderAuthHeader(): string | null {\n const key = process.env.BUILDER_PRIVATE_KEY;\n return key ? `Bearer ${key}` : null;\n}\n"]}
1
+ {"version":3,"file":"credential-provider.js","sourceRoot":"","sources":["../../src/server/credential-provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;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AAoB;QAChC,OAAO,CAAC,GAAG,CAAC,QAAQ;QACpB,OAAO,CAAC,GAAG,CAAC,gBAAgB;QAC5B,wBAAwB,CACzB,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,wBAAwB;IACtC,OAAO,CACL,OAAO,CAAC,GAAG,CAAC,wBAAwB;QACpC,gDAAgD,CACjD,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gCAAgC;IAC9C,OAAO,CACL,OAAO,CAAC,GAAG,CAAC,iCAAiC;QAC7C,+CAA+C,CAChD,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,0BAA0B;IACxC,OAAO,CACL,OAAO,CAAC,GAAG,CAAC,2BAA2B;QACvC,mDAAmD,CACpD,CAAC;AACJ,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,oBAAoB;IAClC,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC;IAC5C,OAAO,GAAG,CAAC,CAAC,CAAC,UAAU,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AACtC,CAAC","sourcesContent":["/**\n * Credential provider abstraction.\n *\n * Every feature that needs an external credential (Anthropic API key,\n * Google OAuth tokens, OpenAI key, Slack bot token, etc.) should go through\n * one of the resolve*() helpers here instead of reading `process.env`\n * directly. That way the same feature can work in three modes:\n *\n * 1. User set their own key in .env → use it directly\n * 2. User connected Builder via `/cli-auth` → route through Builder proxy\n * 3. Neither → throw FeatureNotConfigured\n *\n * Templates catch FeatureNotConfigured and show a \"Connect Builder (1 click) /\n * set up your own key (guide)\" card.\n *\n * Today these helpers are used by the Builder-hosted LLM gateway, and the\n * shape is meant to grow to cover future managed credential integrations\n * (e.g. additional Builder-hosted services) without rewrites.\n */\n\nimport { createHash } from \"node:crypto\";\n\nimport { isLocalDatabase } from \"../db/client.js\";\nimport { getRequestUserEmail, getRequestOrgId } from \"./request-context.js\";\n\n/**\n * Decide which `app_secrets` scope a Builder/credential write should use.\n *\n * Org scope (\"everyone in this org sees these credentials\") wins when the\n * connecting user is an owner or admin of an active org — the write\n * privileges shared infra. A plain member or a user without an active\n * org falls through to per-user scope so a teammate can't silently\n * overwrite the org-shared connection.\n */\nexport function resolveCredentialWriteScope(\n email: string,\n orgId: string | null | undefined,\n role: string | null | undefined,\n): { scope: \"user\" | \"org\"; scopeId: string } {\n if (orgId && (role === \"owner\" || role === \"admin\")) {\n return { scope: \"org\", scopeId: orgId };\n }\n return { scope: \"user\", scopeId: email };\n}\n\nexport class FeatureNotConfiguredError extends Error {\n readonly requiredCredential: string;\n readonly builderConnectUrl?: string;\n readonly byokDocsUrl?: string;\n\n constructor(opts: {\n requiredCredential: string;\n message?: string;\n builderConnectUrl?: string;\n byokDocsUrl?: string;\n }) {\n super(\n opts.message ??\n `Feature requires credential \"${opts.requiredCredential}\". Connect Builder or set your own key.`,\n );\n this.name = \"FeatureNotConfiguredError\";\n this.requiredCredential = opts.requiredCredential;\n this.builderConnectUrl = opts.builderConnectUrl;\n this.byokDocsUrl = opts.byokDocsUrl;\n }\n}\n\n/**\n * Deployment-level credential fallback for single-tenant/local operation.\n * Multi-tenant call sites must gate this explicitly before calling.\n */\nexport function readDeployCredentialEnv(key: string): string | undefined {\n return process.env[key] || undefined;\n}\n\nconst APP_PROVIDED_DEPLOY_CREDENTIAL_KEYS = new Set([\n \"ANTHROPIC_API_KEY\",\n \"OPENAI_API_KEY\",\n \"OPENAI_BASE_URL\",\n \"OPENROUTER_API_KEY\",\n \"GOOGLE_CLIENT_ID\",\n \"GOOGLE_CLIENT_SECRET\",\n \"GOOGLE_GENERATIVE_AI_API_KEY\",\n \"GROQ_API_KEY\",\n \"MISTRAL_API_KEY\",\n \"COHERE_API_KEY\",\n]);\n\nfunction isAppProvidedDeployCredentialKey(key: string | undefined): boolean {\n return !!key && APP_PROVIDED_DEPLOY_CREDENTIAL_KEYS.has(key);\n}\n\n/**\n * Deployment-level credentials are safe as a runtime fallback only in local /\n * single-tenant contexts. In hosted production with a shared database, every\n * signed-in user needs their own user/org/workspace credential for\n * identity-bearing provider keys so one deploy key does not silently\n * impersonate another tenant. App-provided service credentials are different:\n * they configure the deployed app itself rather than identifying a user. This\n * includes LLM keys that let the app developer pay for model usage and OAuth\n * client credentials whose per-user identity remains in scoped OAuth tokens.\n * Key-aware callers may use those env vars.\n *\n * @deprecated Use `canUseDeployCredentialFallbackForRequest()` for generic\n * provider secrets. This stricter helper remains for legacy call sites with\n * identity-bearing deploy credentials.\n */\nexport function isDeployCredentialFallbackAllowed(): boolean {\n if (!isProductionLikeRuntime()) return true;\n return isLocalDatabase();\n}\n\nexport function canUseDeployCredentialFallbackForRequest(\n key?: string,\n): boolean {\n const email = getRequestUserEmail();\n if (!email) return true;\n if (isAppProvidedDeployCredentialKey(key)) return true;\n if (isHostedWorkspaceRuntime()) return false;\n if (!isProductionLikeRuntime()) return true;\n return isLocalDatabase();\n}\n\nconst BUILDER_CREDENTIAL_KEYS = [\n \"BUILDER_PRIVATE_KEY\",\n \"BUILDER_PUBLIC_KEY\",\n \"BUILDER_USER_ID\",\n \"BUILDER_ORG_NAME\",\n \"BUILDER_ORG_KIND\",\n \"BUILDER_SUBSCRIPTION\",\n \"BUILDER_SUBSCRIPTION_LEVEL\",\n \"BUILDER_SUBSCRIPTION_NAME\",\n \"BUILDER_IS_ENTERPRISE\",\n \"BUILDER_IS_FREE_ACCOUNT\",\n] as const;\n\nfunction isBuilderCredentialKey(key: string): boolean {\n return (BUILDER_CREDENTIAL_KEYS as readonly string[]).includes(key);\n}\n\nfunction isHostedWorkspaceRuntime(): boolean {\n const hasFusionPreview = Boolean(\n process.env.FUSION_ENVIRONMENT ||\n process.env.FUSION_ENV_ORIGIN ||\n process.env.VITE_FUSION_ENV_ORIGIN,\n );\n return (\n /^(1|true)$/i.test(process.env.AGENT_NATIVE_WORKSPACE ?? \"\") ||\n /^(1|true)$/i.test(process.env.VITE_AGENT_NATIVE_WORKSPACE ?? \"\") ||\n hasFusionPreview\n );\n}\n\nfunction isProductionLikeRuntime(): boolean {\n return (\n process.env.NODE_ENV === \"production\" ||\n /^(1|true)$/i.test(process.env.NETLIFY ?? \"\") ||\n /^(1|true)$/i.test(process.env.VERCEL ?? \"\") ||\n /^(1|true)$/i.test(process.env.CF_PAGES ?? \"\") ||\n Boolean(\n process.env.AWS_LAMBDA_FUNCTION_NAME ||\n process.env.AWS_EXECUTION_ENV ||\n process.env.FUNCTIONS_WORKER_RUNTIME ||\n process.env.K_SERVICE ||\n process.env.RENDER,\n )\n );\n}\n\n/**\n * Whether deployment-level Builder env keys may back the current request.\n *\n * This is intentionally self-contained rather than delegating to\n * `canUseDeployCredentialFallbackForRequest`. That generic helper blocks the\n * deploy fallback for any signed-in user in a hosted workspace runtime, so the\n * Builder dogfooding escape hatch must apply its own hosted-workspace exception\n * here instead of inheriting the generic helper's stricter (and hatch-unaware)\n * decision. Reading the env once into locals keeps the rules legible.\n *\n * Rules (all evaluated against the live request/runtime, not a build-time value):\n * - No signed-in user → safe to use the deploy env (nobody to mis-identify).\n * - Hosted workspace + signed-in user → deploy-level Builder keys would\n * impersonate that user, so block them — UNLESS a developer has explicitly\n * opted into the local dogfooding escape hatch (non-prod only). Default OFF;\n * hosted/shared production deployments are never affected.\n * - Otherwise → allowed in non-prod, or on a local/single-tenant database.\n */\nfunction canUseBuilderDeployCredentialFallbackForRequest(): boolean {\n const email = getRequestUserEmail();\n if (!email) return true;\n\n const isProductionRuntime = isProductionLikeRuntime();\n // Local dogfooding escape hatch: lets the env / root-`.env` Builder key back\n // a signed-in user so running the app locally doesn't require completing the\n // Builder connect flow first. Non-prod only.\n const localDevOptIn =\n !isProductionRuntime &&\n /^(1|true)$/i.test(process.env.AGENT_NATIVE_LOCAL_BUILDER_ENV ?? \"\");\n\n if (isHostedWorkspaceRuntime() && !localDevOptIn) return false;\n\n // Deploy fallback is safe in non-prod or on a local/single-tenant database.\n return !isProductionRuntime || isLocalDatabase();\n}\n\nfunction shouldTraceCredentialResolve(): boolean {\n return /^(1|true)$/i.test(\n process.env.AGENT_NATIVE_DEBUG_CREDENTIAL_RESOLVE ??\n process.env.DEBUG_CREDENTIAL_RESOLVE ??\n \"\",\n );\n}\n\n// ---------------------------------------------------------------------------\n// Builder credential resolution:\n//\n// 1. **Request-scoped credentials.** A signed-in user can connect Builder\n// through the CLI-auth flow. Owner/admin connections land at org scope;\n// member/no-org connections land at user scope.\n//\n// 2. **Deployment fallback.** BUILDER_PRIVATE_KEY in env still makes local\n// and single-tenant deploys work out of the box, but it no longer blocks\n// per-user connect. Request-scoped credentials win whenever present.\n//\n// To run multi-tenant SaaS: prefer leaving BUILDER_PRIVATE_KEY unset unless a\n// shared fallback identity is intentional.\n// ---------------------------------------------------------------------------\n\ntype BuilderCredentialSource = \"user\" | \"org\" | \"workspace\" | \"env\";\ninterface BuilderResolvedCredentials {\n privateKey: string | null;\n publicKey: string | null;\n userId: string | null;\n orgName: string | null;\n orgKind: string | null;\n subscription: string | null;\n subscriptionLevel: string | null;\n subscriptionName: string | null;\n isEnterprise: boolean | null;\n isFreeAccount: boolean | null;\n source: Exclude<BuilderCredentialSource, \"env\">;\n}\n\nfunction isCompleteBuilderConnection(creds: BuilderResolvedCredentials) {\n return Boolean(creds.privateKey && creds.publicKey);\n}\n\nfunction readOptionalBuilderBoolean(\n value: string | null | undefined,\n): boolean | null {\n if (value == null || value === \"\") return null;\n return /^(1|true)$/i.test(value);\n}\n\nexport function isBuilderPrivateKey(value: string | null | undefined): boolean {\n return typeof value === \"string\" && value.trim().startsWith(\"bpk-\");\n}\n\nasync function readBuilderCredentialScope(\n readAppSecrets: typeof import(\"../secrets/storage.js\").readAppSecrets,\n scope: \"user\" | \"org\" | \"workspace\",\n scopeId: string,\n): Promise<BuilderResolvedCredentials> {\n const secrets = await readAppSecrets({\n keys: BUILDER_CREDENTIAL_KEYS,\n scope,\n scopeId,\n });\n const value = (key: string): string | null => secrets.get(key)?.value ?? null;\n return {\n privateKey: value(\"BUILDER_PRIVATE_KEY\"),\n publicKey: value(\"BUILDER_PUBLIC_KEY\"),\n userId: value(\"BUILDER_USER_ID\"),\n orgName: value(\"BUILDER_ORG_NAME\"),\n orgKind: value(\"BUILDER_ORG_KIND\"),\n subscription: value(\"BUILDER_SUBSCRIPTION\"),\n subscriptionLevel: value(\"BUILDER_SUBSCRIPTION_LEVEL\"),\n subscriptionName: value(\"BUILDER_SUBSCRIPTION_NAME\"),\n isEnterprise: readOptionalBuilderBoolean(value(\"BUILDER_IS_ENTERPRISE\")),\n isFreeAccount: readOptionalBuilderBoolean(value(\"BUILDER_IS_FREE_ACCOUNT\")),\n source: scope === \"workspace\" ? \"workspace\" : scope,\n };\n}\n\nasync function resolveScopedBuilderCredential(\n key: string,\n): Promise<{ value: string; source: \"user\" | \"org\" | \"workspace\" } | null> {\n const email = getRequestUserEmail();\n if (!email) return null;\n\n // Trace only when explicitly requested. These diagnostics are useful for\n // support, but they include account identifiers and run on hot paths.\n const traceLookup = shouldTraceCredentialResolve();\n let scopeAttempted = \"user\";\n try {\n const { readAppSecret } = await import(\"../secrets/storage.js\");\n\n // 1. Per-user override: a user can paste their own key in settings to\n // overrule the org-shared one (handy for a personal sandbox).\n const userSecret = await readAppSecret({\n key,\n scope: \"user\",\n scopeId: email,\n });\n if (userSecret) {\n if (traceLookup) {\n console.log(\n `[builder-credential] key=${key} email=${email} scope=user hit=true`,\n );\n }\n return { value: userSecret.value, source: \"user\" };\n }\n\n // 2. Per-org shared credential: when one teammate connects Builder\n // as an owner/admin we write the OAuth result at org scope so\n // every member of that org gets the AI chat working without\n // re-running the connect flow. Resolution falls back here\n // silently — the caller never has to know which scope answered.\n const orgId = getRequestOrgId();\n if (orgId) {\n scopeAttempted = \"org\";\n const orgSecret = await readAppSecret({\n key,\n scope: \"org\",\n scopeId: orgId,\n });\n if (orgSecret) {\n if (traceLookup) {\n console.log(\n `[builder-credential] key=${key} email=${email} orgId=${orgId} scope=org hit=true`,\n );\n }\n return { value: orgSecret.value, source: \"org\" };\n }\n\n // Older setup flows wrote shared credentials at workspace scope.\n // Keep reading those rows so status UIs and runtime resolution agree\n // for users who connected before org-scoped Builder credentials existed.\n scopeAttempted = \"workspace\";\n const workspaceSecret = await readAppSecret({\n key,\n scope: \"workspace\",\n scopeId: orgId,\n });\n if (workspaceSecret) {\n if (traceLookup) {\n console.log(\n `[builder-credential] key=${key} email=${email} orgId=${orgId} scope=workspace hit=true`,\n );\n }\n return { value: workspaceSecret.value, source: \"workspace\" };\n }\n if (traceLookup) {\n console.log(\n `[builder-credential] key=${key} email=${email} orgId=${orgId} miss tried=user,org,workspace`,\n );\n }\n } else {\n scopeAttempted = \"workspace-solo\";\n const soloWorkspaceSecret = await readAppSecret({\n key,\n scope: \"workspace\",\n scopeId: `solo:${email}`,\n });\n if (soloWorkspaceSecret) {\n if (traceLookup) {\n console.log(\n `[builder-credential] key=${key} email=${email} scope=workspace-solo hit=true`,\n );\n }\n return { value: soloWorkspaceSecret.value, source: \"workspace\" };\n }\n if (traceLookup) {\n console.log(\n `[builder-credential] key=${key} email=${email} orgId=(none) miss tried=user,workspace-solo`,\n );\n }\n }\n } catch (err) {\n if (traceLookup) {\n console.log(\n `[builder-credential] key=${key} email=${email} scope=${scopeAttempted} error=${(err as Error)?.message ?? err}`,\n );\n }\n // Secrets table not ready — treat as missing.\n }\n return null;\n}\n\nasync function resolveScopedBuilderCredentials(): Promise<BuilderResolvedCredentials | null> {\n const email = getRequestUserEmail();\n if (!email) return null;\n\n const traceLookup = shouldTraceCredentialResolve();\n let scopeAttempted = \"user\";\n try {\n const { readAppSecrets } = await import(\"../secrets/storage.js\");\n const traceScope = (creds: BuilderResolvedCredentials, scopeId: string) => {\n if (!traceLookup) return;\n console.log(\n `[builder-credential] scope=${creds.source} scopeId=${scopeId} email=${email} complete=${isCompleteBuilderConnection(creds)} private=${Boolean(creds.privateKey)} public=${Boolean(creds.publicKey)}`,\n );\n };\n\n const userCreds = await readBuilderCredentialScope(\n readAppSecrets,\n \"user\",\n email,\n );\n traceScope(userCreds, email);\n if (isCompleteBuilderConnection(userCreds)) return userCreds;\n\n const orgId = getRequestOrgId();\n if (orgId) {\n scopeAttempted = \"org\";\n const orgCreds = await readBuilderCredentialScope(\n readAppSecrets,\n \"org\",\n orgId,\n );\n traceScope(orgCreds, orgId);\n if (isCompleteBuilderConnection(orgCreds)) return orgCreds;\n\n scopeAttempted = \"workspace\";\n const workspaceCreds = await readBuilderCredentialScope(\n readAppSecrets,\n \"workspace\",\n orgId,\n );\n traceScope(workspaceCreds, orgId);\n if (isCompleteBuilderConnection(workspaceCreds)) return workspaceCreds;\n } else {\n scopeAttempted = \"workspace-solo\";\n const scopeId = `solo:${email}`;\n const workspaceCreds = await readBuilderCredentialScope(\n readAppSecrets,\n \"workspace\",\n scopeId,\n );\n traceScope(workspaceCreds, scopeId);\n if (isCompleteBuilderConnection(workspaceCreds)) return workspaceCreds;\n }\n } catch (err) {\n if (traceLookup) {\n console.log(\n `[builder-credential] email=${email} scope=${scopeAttempted} credentials error=${(err as Error)?.message ?? err}`,\n );\n }\n }\n return null;\n}\n\n/**\n * Resolve a Builder credential for the current request. User/org credentials\n * win; deployment env is only a fallback. This lets local/root .env keys keep\n * a template working while still allowing users to connect their own Builder\n * account from Settings or onboarding.\n */\nexport async function resolveBuilderCredential(\n key: string,\n): Promise<string | null> {\n const scoped = await resolveScopedBuilderCredential(key);\n if (scoped) return scoped.value;\n if (!canUseBuilderDeployCredentialFallbackForRequest()) return null;\n return readDeployCredentialEnv(key) ?? null;\n}\n\n/**\n * True when `BUILDER_PRIVATE_KEY` is set at the deployment level. This means\n * a deploy-level fallback exists; it does not prevent per-user connect.\n */\nexport function isBuilderEnvManaged(): boolean {\n return !!process.env.BUILDER_PRIVATE_KEY;\n}\n\n/**\n * Resolve the Builder private key for the current request. User/org OAuth\n * credentials win; deploy-level `BUILDER_PRIVATE_KEY` is the fallback.\n */\nexport async function resolveBuilderPrivateKey(): Promise<string | null> {\n return resolveBuilderCredential(\"BUILDER_PRIVATE_KEY\");\n}\n\n/**\n * Resolve the current user's Builder auth header.\n * Returns `\"Bearer <key>\"` or null.\n */\nexport async function resolveBuilderAuthHeader(): Promise<string | null> {\n const key = await resolveBuilderPrivateKey();\n return key ? `Bearer ${key}` : null;\n}\n\n/**\n * Check whether the current user has a Builder private key configured\n * (per-user or deployment-level).\n */\nexport async function resolveHasBuilderPrivateKey(): Promise<boolean> {\n return !!(await resolveBuilderPrivateKey());\n}\n\n/**\n * Check whether the current request has the complete Builder credential bundle\n * needed for Builder-backed assistant/image-generation calls.\n */\nexport async function resolveHasCompleteBuilderConnection(): Promise<boolean> {\n const creds = await resolveBuilderCredentials();\n return !!(creds.privateKey && creds.publicKey);\n}\n\n/**\n * Resolve where the effective Builder assistant connection came from. This\n * intentionally requires a complete private+public key pair from one scope so\n * status UIs don't report a mixed user/org credential set as connected.\n */\nexport async function resolveBuilderCredentialSource(): Promise<BuilderCredentialSource | null> {\n const scoped = await resolveScopedBuilderCredentials();\n if (scoped) return scoped.source;\n return canUseBuilderDeployCredentialFallbackForRequest() &&\n process.env.BUILDER_PRIVATE_KEY\n ? \"env\"\n : null;\n}\n\n/**\n * Resolve the Builder assistant credential bundle from one complete scope.\n * A partial user row is treated as a miss so the org-shared connection can\n * still power the assistant for teammates.\n */\nexport async function resolveBuilderCredentials(): Promise<{\n privateKey: string | null;\n publicKey: string | null;\n userId: string | null;\n orgName: string | null;\n orgKind: string | null;\n subscription: string | null;\n subscriptionLevel: string | null;\n subscriptionName: string | null;\n isEnterprise: boolean | null;\n isFreeAccount: boolean | null;\n}> {\n const scoped = await resolveScopedBuilderCredentials();\n if (scoped) {\n const {\n privateKey,\n publicKey,\n userId,\n orgName,\n orgKind,\n subscription,\n subscriptionLevel,\n subscriptionName,\n isEnterprise,\n isFreeAccount,\n } = scoped;\n return {\n privateKey,\n publicKey,\n userId,\n orgName,\n orgKind,\n subscription,\n subscriptionLevel,\n subscriptionName,\n isEnterprise,\n isFreeAccount,\n };\n }\n const privateKey = canUseBuilderDeployCredentialFallbackForRequest()\n ? (readDeployCredentialEnv(\"BUILDER_PRIVATE_KEY\") ?? null)\n : null;\n const publicKey = canUseBuilderDeployCredentialFallbackForRequest()\n ? (readDeployCredentialEnv(\"BUILDER_PUBLIC_KEY\") ?? null)\n : null;\n const userId = canUseBuilderDeployCredentialFallbackForRequest()\n ? (readDeployCredentialEnv(\"BUILDER_USER_ID\") ?? null)\n : null;\n const orgName = canUseBuilderDeployCredentialFallbackForRequest()\n ? (readDeployCredentialEnv(\"BUILDER_ORG_NAME\") ?? null)\n : null;\n const orgKind = canUseBuilderDeployCredentialFallbackForRequest()\n ? (readDeployCredentialEnv(\"BUILDER_ORG_KIND\") ?? null)\n : null;\n const subscription = canUseBuilderDeployCredentialFallbackForRequest()\n ? (readDeployCredentialEnv(\"BUILDER_SUBSCRIPTION\") ?? null)\n : null;\n const subscriptionLevel = canUseBuilderDeployCredentialFallbackForRequest()\n ? (readDeployCredentialEnv(\"BUILDER_SUBSCRIPTION_LEVEL\") ?? null)\n : null;\n const subscriptionName = canUseBuilderDeployCredentialFallbackForRequest()\n ? (readDeployCredentialEnv(\"BUILDER_SUBSCRIPTION_NAME\") ?? null)\n : null;\n const isEnterprise = canUseBuilderDeployCredentialFallbackForRequest()\n ? readOptionalBuilderBoolean(\n readDeployCredentialEnv(\"BUILDER_IS_ENTERPRISE\"),\n )\n : null;\n const isFreeAccount = canUseBuilderDeployCredentialFallbackForRequest()\n ? readOptionalBuilderBoolean(\n readDeployCredentialEnv(\"BUILDER_IS_FREE_ACCOUNT\"),\n )\n : null;\n return {\n privateKey,\n publicKey,\n userId,\n orgName,\n orgKind,\n subscription,\n subscriptionLevel,\n subscriptionName,\n isEnterprise,\n isFreeAccount,\n };\n}\n\nconst BUILDER_AUTH_FAILURE_SETTING_PREFIX = \"builder-auth-failure:\";\n\nexport interface BuilderCredentialAuthFailure {\n fingerprint: string;\n message: string;\n status?: number;\n code?: string;\n at: number;\n ownerEmail?: string | null;\n orgId?: string | null;\n}\n\nexport function builderCredentialFingerprint(\n privateKey?: string | null,\n publicKey?: string | null,\n): string | null {\n if (!privateKey || !publicKey) return null;\n return createHash(\"sha256\")\n .update(privateKey)\n .update(\"\\0\")\n .update(publicKey)\n .digest(\"hex\")\n .slice(0, 24);\n}\n\nfunction builderAuthFailureSettingKey(fingerprint: string): string {\n return `${BUILDER_AUTH_FAILURE_SETTING_PREFIX}${fingerprint}`;\n}\n\nexport async function getBuilderCredentialAuthFailure(\n creds: {\n privateKey?: string | null;\n publicKey?: string | null;\n } = {},\n): Promise<BuilderCredentialAuthFailure | null> {\n const fingerprint = builderCredentialFingerprint(\n creds.privateKey,\n creds.publicKey,\n );\n if (!fingerprint) return null;\n try {\n const { getSetting } = await import(\"../settings/store.js\");\n const row = await getSetting(builderAuthFailureSettingKey(fingerprint));\n if (!row) return null;\n return {\n fingerprint,\n message:\n typeof row.message === \"string\" && row.message\n ? row.message\n : \"Builder rejected the connected credentials. Reconnect Builder.io.\",\n status: typeof row.status === \"number\" ? row.status : undefined,\n code: typeof row.code === \"string\" ? row.code : undefined,\n at: typeof row.at === \"number\" ? row.at : Date.now(),\n ownerEmail:\n typeof row.ownerEmail === \"string\" ? row.ownerEmail : undefined,\n orgId: typeof row.orgId === \"string\" ? row.orgId : undefined,\n };\n } catch {\n return null;\n }\n}\n\nexport async function recordBuilderCredentialAuthFailure(details?: {\n status?: number;\n code?: string;\n message?: string;\n}): Promise<void> {\n try {\n const creds = await resolveBuilderCredentials();\n const fingerprint = builderCredentialFingerprint(\n creds.privateKey,\n creds.publicKey,\n );\n if (!fingerprint) return;\n const { putSetting } = await import(\"../settings/store.js\");\n await putSetting(builderAuthFailureSettingKey(fingerprint), {\n fingerprint,\n message:\n details?.message ||\n \"Builder rejected the connected credentials. Reconnect Builder.io.\",\n ...(typeof details?.status === \"number\" && { status: details.status }),\n ...(details?.code && { code: details.code }),\n at: Date.now(),\n ownerEmail: getRequestUserEmail() ?? null,\n orgId: getRequestOrgId() ?? null,\n });\n } catch {\n // Best-effort marker only; the chat error is still returned to the user.\n }\n}\n\nexport async function clearBuilderCredentialAuthFailure(creds: {\n privateKey?: string | null;\n publicKey?: string | null;\n}): Promise<void> {\n const fingerprint = builderCredentialFingerprint(\n creds.privateKey,\n creds.publicKey,\n );\n if (!fingerprint) return;\n try {\n const { deleteSetting } = await import(\"../settings/store.js\");\n await deleteSetting(builderAuthFailureSettingKey(fingerprint));\n } catch {\n // A stale failure marker should not block writing fresh credentials.\n }\n}\n\nconst PROVIDER_AUTH_FAILURE_SETTING_PREFIX = \"provider-auth-failure:\";\n/** Stale failure markers expire so a transient 401 cannot permanently block deploy keys. */\nexport const PROVIDER_AUTH_FAILURE_TTL_MS = 15 * 60 * 1000;\n\nexport interface ProviderCredentialAuthFailure {\n fingerprint: string;\n key: string;\n message: string;\n status?: number;\n code?: string;\n at: number;\n ownerEmail?: string | null;\n orgId?: string | null;\n}\n\nexport function providerCredentialFingerprint(\n key?: string | null,\n value?: string | null,\n): string | null {\n const normalizedKey = key?.trim().toUpperCase();\n const normalizedValue = value?.trim();\n if (!normalizedKey || !normalizedValue) return null;\n return createHash(\"sha256\")\n .update(normalizedKey)\n .update(\"\\0\")\n .update(normalizedValue)\n .digest(\"hex\")\n .slice(0, 24);\n}\n\nfunction providerAuthFailureSettingKey(fingerprint: string): string {\n return `${PROVIDER_AUTH_FAILURE_SETTING_PREFIX}${fingerprint}`;\n}\n\nexport async function getProviderCredentialAuthFailure(opts: {\n key?: string | null;\n value?: string | null;\n}): Promise<ProviderCredentialAuthFailure | null> {\n const key = opts.key?.trim().toUpperCase() ?? \"\";\n const fingerprint = providerCredentialFingerprint(key, opts.value);\n if (!fingerprint) return null;\n try {\n const settings = await import(\"../settings/store.js\");\n const settingKey = providerAuthFailureSettingKey(fingerprint);\n const row = await settings.getSetting(settingKey);\n if (!row) return null;\n if (row.fingerprint !== fingerprint) return null;\n const at = typeof row.at === \"number\" ? row.at : Date.now();\n if (Date.now() - at > PROVIDER_AUTH_FAILURE_TTL_MS) {\n if (typeof settings.deleteSetting === \"function\") {\n await settings.deleteSetting(settingKey).catch(() => {});\n }\n return null;\n }\n return {\n fingerprint,\n key:\n typeof row.key === \"string\" && row.key\n ? row.key\n : key || \"UNKNOWN_PROVIDER_KEY\",\n message:\n typeof row.message === \"string\" && row.message\n ? row.message\n : \"The model provider rejected the saved API key.\",\n status: typeof row.status === \"number\" ? row.status : undefined,\n code: typeof row.code === \"string\" ? row.code : undefined,\n at,\n ownerEmail:\n typeof row.ownerEmail === \"string\" ? row.ownerEmail : undefined,\n orgId: typeof row.orgId === \"string\" ? row.orgId : undefined,\n };\n } catch {\n return null;\n }\n}\n\nexport async function recordProviderCredentialAuthFailure(opts: {\n key?: string | null;\n value?: string | null;\n status?: number;\n code?: string;\n message?: string;\n}): Promise<void> {\n try {\n const key = opts.key?.trim().toUpperCase() ?? \"\";\n const value = opts.value?.trim();\n const fingerprint = providerCredentialFingerprint(key, value);\n if (!fingerprint) return;\n const { putSetting } = await import(\"../settings/store.js\");\n await putSetting(providerAuthFailureSettingKey(fingerprint), {\n fingerprint,\n key,\n message: opts.message || \"The model provider rejected the saved API key.\",\n ...(typeof opts.status === \"number\" && { status: opts.status }),\n ...(opts.code && { code: opts.code }),\n at: Date.now(),\n ownerEmail: getRequestUserEmail() ?? null,\n orgId: getRequestOrgId() ?? null,\n });\n } catch {\n // Best-effort marker only; the chat error is still returned to the user.\n }\n}\n\nexport async function clearProviderCredentialAuthFailure(opts: {\n key?: string | null;\n value?: string | null;\n}): Promise<void> {\n const fingerprint = providerCredentialFingerprint(opts.key, opts.value);\n if (!fingerprint) return;\n try {\n const { deleteSetting } = await import(\"../settings/store.js\");\n await deleteSetting(providerAuthFailureSettingKey(fingerprint));\n } catch {\n // A stale failure marker should not block writing or using fresh keys.\n }\n}\n\n/**\n * Write Builder credentials to `app_secrets`.\n *\n * Scope decision (see `resolveCredentialWriteScope`): when the connecting\n * user is owner/admin of an active org we write at `scope: \"org\"` so every\n * member of that org auto-resolves the credentials via\n * `resolveBuilderCredential`'s org fallback — no per-user re-connect\n * needed. A plain member or a user with no active org writes at\n * `scope: \"user\"` (the safe default that doesn't trample the org's shared\n * connection).\n *\n * Stale-credential cleanup: before writing the new values we (1) clear ALL\n * five BUILDER_* keys at the target scope, so optional fields the new\n * connection doesn't carry (e.g. user picked a Builder space that returns\n * no orgName) don't leave the previous connection's metadata behind, and\n * (2) when writing at org scope, also clear the writer's own user-scope\n * BUILDER_* rows so a stale personal override from an earlier connect\n * doesn't shadow the new org write on resolution (user scope wins org\n * scope by design — see `resolveScopedBuilderCredential`). The org-scope\n * row is intentionally left alone when writing at user scope: that row is\n * shared with the rest of the org and a single user's personal override\n * shouldn't blow it away. (Victoria's \"I signed in again with my Builder\n * space and it still says no credits\" report on 2026-05-11 was exactly\n * this stale-shadow case.)\n *\n * Returns the actual scope/scopeId used so the caller can show \"Connected\n * for Builder.io\" vs \"Connected (personal)\" in the UI.\n */\nexport async function writeBuilderCredentials(\n email: string,\n creds: {\n privateKey: string;\n publicKey: string;\n userId?: string | null;\n orgName?: string | null;\n orgKind?: string | null;\n subscription?: string | null;\n subscriptionLevel?: string | null;\n subscriptionName?: string | null;\n isEnterprise?: boolean | null;\n isFreeAccount?: boolean | null;\n },\n options?: { orgId?: string | null; role?: string | null },\n): Promise<{ scope: \"user\" | \"org\"; scopeId: string }> {\n const privateKey = creds.privateKey.trim();\n const publicKey = creds.publicKey.trim();\n if (!isBuilderPrivateKey(privateKey)) {\n throw new Error(\n \"Builder returned a credential that is not a Builder private key (expected bpk-...). Restart the Builder connect flow and choose a space that can issue a private key.\",\n );\n }\n if (!publicKey) {\n throw new Error(\n \"Builder did not return a public API key. Restart the Builder connect flow.\",\n );\n }\n\n const { writeAppSecret, deleteAppSecret } =\n await import(\"../secrets/storage.js\");\n const target = resolveCredentialWriteScope(\n email,\n options?.orgId ?? null,\n options?.role ?? null,\n );\n\n // Clear stale rows before writing the new connection. See the function's\n // doc comment for the two cases this handles.\n const cleanups: Array<Promise<unknown>> = BUILDER_CREDENTIAL_KEYS.map((key) =>\n deleteAppSecret({\n key,\n scope: target.scope,\n scopeId: target.scopeId,\n }).catch(() => {}),\n );\n if (target.scope === \"org\") {\n for (const key of BUILDER_CREDENTIAL_KEYS) {\n cleanups.push(\n deleteAppSecret({ key, scope: \"user\", scopeId: email }).catch(() => {}),\n );\n }\n }\n await Promise.all(cleanups);\n\n const entries: Array<{ key: string; value: string }> = [\n { key: \"BUILDER_PRIVATE_KEY\", value: privateKey },\n { key: \"BUILDER_PUBLIC_KEY\", value: publicKey },\n ];\n if (creds.userId) {\n entries.push({ key: \"BUILDER_USER_ID\", value: creds.userId });\n }\n if (creds.orgName) {\n entries.push({ key: \"BUILDER_ORG_NAME\", value: creds.orgName });\n }\n if (creds.orgKind) {\n entries.push({ key: \"BUILDER_ORG_KIND\", value: creds.orgKind });\n }\n if (creds.subscription) {\n entries.push({ key: \"BUILDER_SUBSCRIPTION\", value: creds.subscription });\n }\n if (creds.subscriptionLevel) {\n entries.push({\n key: \"BUILDER_SUBSCRIPTION_LEVEL\",\n value: creds.subscriptionLevel,\n });\n }\n if (creds.subscriptionName) {\n entries.push({\n key: \"BUILDER_SUBSCRIPTION_NAME\",\n value: creds.subscriptionName,\n });\n }\n if (typeof creds.isEnterprise === \"boolean\") {\n entries.push({\n key: \"BUILDER_IS_ENTERPRISE\",\n value: String(creds.isEnterprise),\n });\n }\n if (typeof creds.isFreeAccount === \"boolean\") {\n entries.push({\n key: \"BUILDER_IS_FREE_ACCOUNT\",\n value: String(creds.isFreeAccount),\n });\n }\n await Promise.all(\n entries.map(({ key, value }) =>\n writeAppSecret({\n key,\n value,\n scope: target.scope,\n scopeId: target.scopeId,\n }),\n ),\n );\n await clearBuilderCredentialAuthFailure({\n privateKey,\n publicKey,\n });\n return target;\n}\n\n/**\n * Delete Builder credentials.\n *\n * Default behaviour: clears only this user's per-user override (so a\n * member can disconnect their personal Builder identity without\n * collapsing the org-wide connection for every teammate). To revoke the\n * org's shared connection, pass `{ orgId, role }` for an owner/admin —\n * matching the same authority gate `writeBuilderCredentials` uses on\n * write. Plain members can never reach the org-scoped row.\n */\nexport async function deleteBuilderCredentials(\n email: string,\n options?: { orgId?: string | null; role?: string | null },\n): Promise<{ scope: \"user\" | \"org\"; scopeId: string }> {\n const { deleteAppSecret } = await import(\"../secrets/storage.js\");\n const target = resolveCredentialWriteScope(\n email,\n options?.orgId ?? null,\n options?.role ?? null,\n );\n await Promise.all(\n BUILDER_CREDENTIAL_KEYS.map((key) =>\n deleteAppSecret({\n key,\n scope: target.scope,\n scopeId: target.scopeId,\n }).catch(() => {}),\n ),\n );\n return target;\n}\n\n// ---------------------------------------------------------------------------\n// Generic request-scoped secret resolution\n//\n// New consumers should prefer this over reading `process.env.X` directly.\n// User-pasted and shared secrets live in `app_secrets` (encrypted). The\n// settings UI / onboarding panels can write user, org, or workspace rows.\n// Deploy-level env vars are the fallback for unauthenticated/CLI/background\n// contexts where there's no user to scope by. Authenticated requests may also\n// use app-provided LLM provider keys such as OPENAI_API_KEY or\n// ANTHROPIC_API_KEY, but Builder identity keys keep the stricter scoped policy.\n// ---------------------------------------------------------------------------\n\n/**\n * Resolve a request-scoped secret. Reads from `app_secrets` first (current\n * user override, active org, then workspace row); falls back to `process.env`\n * only when the deploy fallback policy allows it.\n */\nexport async function resolveSecret(key: string): Promise<string | null> {\n const traceLookup = shouldTraceCredentialResolve();\n const email = getRequestUserEmail();\n if (email) {\n try {\n const { readAppSecret } = await import(\"../secrets/storage.js\");\n // Per-user override first.\n const userSecret = await readAppSecret({\n key,\n scope: \"user\",\n scopeId: email,\n });\n if (userSecret?.value) {\n if (traceLookup) {\n console.log(\n `[resolve-secret] key=${key} email=${email} scope=user hit=true`,\n );\n }\n return userSecret.value;\n }\n\n const orgId = getRequestOrgId();\n if (orgId) {\n // Fall back to the active org's shared row, when present. Builder\n // Connect uses this first-class org scope.\n const orgSecret = await readAppSecret({\n key,\n scope: \"org\",\n scopeId: orgId,\n });\n if (orgSecret?.value) {\n if (traceLookup) {\n console.log(\n `[resolve-secret] key=${key} email=${email} orgId=${orgId} scope=org hit=true`,\n );\n }\n return orgSecret.value;\n }\n\n // Registered secrets historically used \"workspace\" scope for\n // org-shared configuration. Keep reading it so Settings status and\n // runtime resolution agree.\n const workspaceSecret = await readAppSecret({\n key,\n scope: \"workspace\",\n scopeId: orgId,\n });\n if (workspaceSecret?.value) {\n if (traceLookup) {\n console.log(\n `[resolve-secret] key=${key} email=${email} orgId=${orgId} scope=workspace hit=true`,\n );\n }\n return workspaceSecret.value;\n }\n } else {\n const soloWorkspaceSecret = await readAppSecret({\n key,\n scope: \"workspace\",\n scopeId: `solo:${email}`,\n });\n if (soloWorkspaceSecret?.value) {\n if (traceLookup) {\n console.log(\n `[resolve-secret] key=${key} email=${email} scope=workspace-solo hit=true`,\n );\n }\n return soloWorkspaceSecret.value;\n }\n }\n } catch (err) {\n if (traceLookup) {\n console.log(\n `[resolve-secret] key=${key} email=${email} scope=error err=${(err as Error)?.message ?? err}`,\n );\n }\n // Secrets table not ready — treat as missing.\n }\n // Read deployment-provided env values as fallbacks; framework code must not\n // write to `process.env`, but keys supplied by the host remain valid config.\n // Builder credentials keep a narrower path below because those keys carry a\n // Builder identity rather than just enabling a provider call.\n const envFallback = (\n isBuilderCredentialKey(key)\n ? canUseBuilderDeployCredentialFallbackForRequest()\n : canUseDeployCredentialFallbackForRequest(key)\n )\n ? process.env[key] || null\n : null;\n if (traceLookup) {\n console.log(\n `[resolve-secret] key=${key} email=${email} orgId=${getRequestOrgId() ?? \"(none)\"} scope=${envFallback ? \"env-fallback\" : \"none\"} hit=${!!envFallback}`,\n );\n }\n return envFallback;\n }\n // Unauthenticated / local-dev / CLI / background context: env fallback\n // is safe because there's no user to mis-identify.\n const value = process.env[key] || null;\n if (traceLookup) {\n console.log(\n `[resolve-secret] key=${key} email=(none) scope=env-anonymous hit=${!!value}`,\n );\n }\n return value;\n}\n\n// ---------------------------------------------------------------------------\n// Synchronous helpers — env-only fallbacks for contexts where per-user\n// lookup isn't possible (sync isConfigured checks, CLI scripts).\n// ---------------------------------------------------------------------------\n\n/**\n * True when a Builder private key is configured at the deployment level.\n *\n * This is the same env-only check as `isBuilderEnvManaged()`. For \"does this\n * request have access to Builder via user/org/env credentials?\" use the async\n * `resolveHasBuilderPrivateKey()`.\n */\nexport function hasBuilderPrivateKey(): boolean {\n return !!process.env.BUILDER_PRIVATE_KEY;\n}\n\n/** The origin for Builder-proxied API calls. Overridable for testing. */\nexport function getBuilderProxyOrigin(): string {\n return (\n process.env.BUILDER_PROXY_ORIGIN ||\n process.env.AIR_HOST ||\n process.env.BUILDER_API_HOST ||\n \"https://api.builder.io\"\n );\n}\n\n/**\n * Base URL for the public Builder LLM gateway, which lives at\n * api.builder.io/agent-native/gateway.\n * Override via BUILDER_GATEWAY_BASE_URL for staging / testing.\n */\nexport function getBuilderGatewayBaseUrl(): string {\n return (\n process.env.BUILDER_GATEWAY_BASE_URL ||\n \"https://api.builder.io/agent-native/gateway/v1\"\n );\n}\n\n/**\n * Base URL for Builder-managed image generation.\n * Override via BUILDER_IMAGE_GENERATION_BASE_URL for staging / testing.\n */\nexport function getBuilderImageGenerationBaseUrl(): string {\n return (\n process.env.BUILDER_IMAGE_GENERATION_BASE_URL ||\n \"https://api.builder.io/agent-native/images/v1\"\n );\n}\n\n/**\n * Base URL for Builder-managed web search.\n * Override via BUILDER_WEB_SEARCH_BASE_URL for staging / testing.\n */\nexport function getBuilderWebSearchBaseUrl(): string {\n return (\n process.env.BUILDER_WEB_SEARCH_BASE_URL ||\n \"https://api.builder.io/agent-native/web-search/v1\"\n );\n}\n\n/** Authorization header value for Builder-proxied calls (env-only). */\nexport function getBuilderAuthHeader(): string | null {\n const key = process.env.BUILDER_PRIVATE_KEY;\n return key ? `Bearer ${key}` : null;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"csrf.d.ts","sourceRoot":"","sources":["../../src/server/csrf.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAoHH;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAClC,eAAe,GAAE,MAAyB;;GAqB3C"}
1
+ {"version":3,"file":"csrf.d.ts","sourceRoot":"","sources":["../../src/server/csrf.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAsIH;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAClC,eAAe,GAAE,MAAyB;;GAsB3C"}
@@ -43,6 +43,7 @@
43
43
  * cross-origin-callable route, add it there.
44
44
  */
45
45
  import { defineEventHandler, getMethod, getRequestHeader, setResponseStatus, } from "h3";
46
+ import { getConfiguredAppBasePath } from "./app-base-path.js";
46
47
  /**
47
48
  * Path prefixes (relative to the framework prefix `/_agent-native`) that are
48
49
  * allowed to receive cross-origin state-changing POSTs without first-party
@@ -131,9 +132,10 @@ function requestHasCookies(event) {
131
132
  return typeof cookie === "string" && cookie.trim().length > 0;
132
133
  }
133
134
  /**
134
- * Path passed in is the full request URL pathname (e.g. `/_agent-native/actions/foo`).
135
- * `frameworkPrefix` should be the framework route prefix without trailing slash,
136
- * e.g. `/_agent-native`.
135
+ * The path is the full request URL pathname (e.g.
136
+ * `/_agent-native/actions/foo` or `/app/_agent-native/actions/foo`).
137
+ * `frameworkPrefix` is the root framework route prefix without a trailing
138
+ * slash, e.g. `/_agent-native`.
137
139
  */
138
140
  function isOnAllowlist(pathname, frameworkPrefix) {
139
141
  if (!pathname.startsWith(frameworkPrefix))
@@ -145,6 +147,16 @@ function isOnAllowlist(pathname, frameworkPrefix) {
145
147
  }
146
148
  return false;
147
149
  }
150
+ function matchingFrameworkPrefix(pathname, frameworkPrefix) {
151
+ if (pathname.startsWith(frameworkPrefix))
152
+ return frameworkPrefix;
153
+ const basePath = getConfiguredAppBasePath();
154
+ const basePathFrameworkPrefix = `${basePath}${frameworkPrefix}`;
155
+ if (basePath && pathname.startsWith(basePathFrameworkPrefix)) {
156
+ return basePathFrameworkPrefix;
157
+ }
158
+ return undefined;
159
+ }
148
160
  /**
149
161
  * Create the framework CSRF middleware.
150
162
  *
@@ -162,9 +174,10 @@ export function createCsrfMiddleware(frameworkPrefix = "/_agent-native") {
162
174
  if (!STATE_CHANGING_METHODS.has(method))
163
175
  return undefined;
164
176
  const pathname = event.url?.pathname ?? "";
165
- if (!pathname.startsWith(frameworkPrefix))
177
+ const matchingPrefix = matchingFrameworkPrefix(pathname, frameworkPrefix);
178
+ if (!matchingPrefix)
166
179
  return undefined;
167
- if (isOnAllowlist(pathname, frameworkPrefix))
180
+ if (isOnAllowlist(pathname, matchingPrefix))
168
181
  return undefined;
169
182
  // No cookie = no risk of confused-deputy CSRF on the session cookie.
170
183
  if (!requestHasCookies(event))
@@ -1 +1 @@
1
- {"version":3,"file":"csrf.js","sourceRoot":"","sources":["../../src/server/csrf.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAEH,OAAO,EACL,kBAAkB,EAClB,SAAS,EACT,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,IAAI,CAAC;AAEZ;;;;;GAKG;AACH,MAAM,uBAAuB,GAAG;IAC9B,4EAA4E;IAC5E,gBAAgB;IAChB,2EAA2E;IAC3E,gEAAgE;IAChE,eAAe;IACf,qEAAqE;IACrE,4DAA4D;IAC5D,6BAA6B;IAC7B,2EAA2E;IAC3E,gEAAgE;IAChE,MAAM;IACN,sEAAsE;IACtE,0EAA0E;IAC1E,4DAA4D;IAC5D,QAAQ;IACR,8DAA8D;IAC9D,kBAAkB;IAClB,uEAAuE;IACvE,2EAA2E;IAC3E,SAAS;IACT,sEAAsE;IACtE,yEAAyE;IACzE,yEAAyE;IACzE,qEAAqE;IACrE,+BAA+B;IAC/B,SAAS;IACT,0EAA0E;IAC1E,uEAAuE;I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QAC9C,IAAI,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC;YAAE,OAAO,IAAI,CAAC;IAC3C,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,oBAAoB,CAClC,eAAe,GAAW,gBAAgB;IAE1C,OAAO,kBAAkB,CAAC,CAAC,KAAK,EAAE,EAAE;QAClC,MAAM,MAAM,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;QAChC,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,MAAM,CAAC;YAAE,OAAO,SAAS,CAAC;QAE1D,MAAM,QAAQ,GAAG,KAAK,CAAC,GAAG,EAAE,QAAQ,IAAI,EAAE,CAAC;QAC3C,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,eAAe,CAAC;YAAE,OAAO,SAAS,CAAC;QAC5D,IAAI,aAAa,CAAC,QAAQ,EAAE,eAAe,CAAC;YAAE,OAAO,SAAS,CAAC;QAE/D,qEAAqE;QACrE,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC;YAAE,OAAO,SAAS,CAAC;QAEhD,IAAI,eAAe,CAAC,KAAK,CAAC;YAAE,OAAO,SAAS,CAAC;QAE7C,iBAAiB,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAC9B,OAAO;YACL,KAAK,EACH,6IAA6I;SAChJ,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["/**\n * Defense-in-depth CSRF check for framework state-changing routes.\n *\n * Threat model: action endpoints (`/_agent-native/actions/*`), extension\n * endpoints (`/_agent-native/extensions/*` and the legacy\n * `/_agent-native/tools/*` alias), and a handful of other state-changing\n * `/_agent-native/*` routes use the better-auth session cookie, which is\n * configured with `SameSite=None; Secure; Partitioned` so the iframe editor\n * (and other cross-site embeds) can authenticate. `SameSite=None` means the\n * browser ships the session cookie on top-level form POSTs from any origin —\n * which is exactly the precondition for classic cross-site request forgery.\n *\n * The browser still gates \"non-simple\" requests behind a CORS preflight, so\n * an attacker who has to send `Content-Type: application/json` is forced\n * through OPTIONS, which our CORS middleware (`create-server.ts`) rejects\n * for disallowed origins. But the simple-request bypass (`Content-Type:\n * text/plain` on a `<form enctype=\"text/plain\">` POST, or `multipart/form-data`)\n * never preflights — the browser delivers it cross-origin with cookies.\n *\n * Mitigation: this middleware rejects any state-changing\n * (`POST/PUT/PATCH/DELETE`) request to `/_agent-native/*` that\n *\n * 1. carries the auth-cookie pattern (any cookie at all is a heuristic\n * good-enough proxy — we don't want to deny anonymous fetches), AND\n * 2. is NOT clearly same-origin / first-party. We trust:\n * - `Sec-Fetch-Site: same-origin` (sent by every modern browser on\n * same-origin fetch — Chrome/Firefox/Safari/Edge all support it).\n * - `X-Agent-Native-CSRF` custom header. Custom headers force a\n * preflight, so an attacker can't add one cross-origin.\n * - `Content-Type: application/json` request body. Same logic — JSON\n * Content-Type is a non-simple request that triggers preflight.\n *\n * Why the existing CORS check isn't enough: a simple-request POST never\n * preflights, so the browser sends it through and only blocks the *response*\n * from being readable cross-origin. The state change (delete-account, write\n * SQL, etc.) happens server-side regardless. We need a server-side check that\n * proves first-party intent before running the action.\n *\n * Opt-out marker: a handful of routes legitimately accept cross-origin POSTs\n * — webhook endpoints (Slack, Telegram, email), the public A2A endpoint\n * (`/_agent-native/a2a`), the integrations process-task self-fire, and so on.\n * Those are listed in `CSRF_ALLOWLIST_PREFIXES` below; if you add a new\n * cross-origin-callable route, add it there.\n */\n\nimport {\n defineEventHandler,\n getMethod,\n getRequestHeader,\n setResponseStatus,\n} from \"h3\";\n\n/**\n * Path prefixes (relative to the framework prefix `/_agent-native`) that are\n * allowed to receive cross-origin state-changing POSTs without first-party\n * markers. These are signed/authenticated through other mechanisms (HMAC,\n * JWT, internal token) so they don't need cookie-based CSRF protection.\n */\nconst CSRF_ALLOWLIST_PREFIXES = [\n // Integration webhooks — verified by HMAC against a per-integration secret.\n \"/integrations/\",\n // Agent Teams durable sub-agent processor self-fire — verified by the same\n // HMAC internal-token scheme as the integration/A2A processors.\n \"/agent-teams/\",\n // Durable sandbox-execution processor self-fire (run-code background\n // queue) — verified by the same HMAC internal-token scheme.\n \"/sandbox/_process-execution\",\n // A2A JSON-RPC endpoints — verified by signed JWT (when A2A_SECRET set) or\n // explicitly opt-in unauthenticated (handled at the A2A layer).\n \"/a2a\",\n // Better Auth's own login/sign-in/social-callback routes. Better Auth\n // ships its own CSRF protection (Origin/Sec-Fetch checks on its handlers)\n // and cookies are needed for the OAuth callback round-trip.\n \"/auth/\",\n // Stripe / Paddle / billing webhooks dropped in by templates.\n \"/billing/webhook\",\n // Public share endpoints — read-only and never cookie-driven, but kept\n // here so a templated POST (e.g. comment-on-public-recording) doesn't 403.\n \"/share/\",\n // OAuth callbacks (Builder, Google, Slack, Notion, Zoom). These get a\n // `code` query param via top-level navigation — they DO ride the session\n // cookie and they SHOULD validate state, but the framework can't see the\n // state token. Each callback handler is responsible for its own CSRF\n // check (signed state tokens).\n \"/oauth/\",\n // Builder's CLI-auth callback — uses the BUILDER_STATE_PARAM signed token\n // to authenticate the round-trip; framework CSRF check would block it.\n \"/builder/callback\",\n];\n\nconst STATE_CHANGING_METHODS = new Set([\"POST\", \"PUT\", \"PATCH\", \"DELETE\"]);\n\n/**\n * Decide whether a request is \"first-party enough\" to trust as not-CSRF.\n * Any of the following make a request non-CSRF:\n *\n * - `Sec-Fetch-Site: same-origin` (or `none` for top-level navigations\n * to our own pages — but state-changing methods don't ship `none`).\n * - `X-Agent-Native-CSRF` header (any value, even \"1\"). This is a custom\n * header so the browser forces a preflight cross-origin, which our\n * CORS layer rejects for disallowed origins.\n * - `Content-Type: application/json` (case-insensitive). JSON content\n * type is a non-simple request that triggers preflight.\n *\n * We accept ANY of these — the goal is \"did the request come through a\n * channel the browser would have preflighted\", not a strict-mode token.\n *\n * NOTE: `Sec-Fetch-Site: same-site` is deliberately NOT trusted. Under a\n * shared cookie domain (COOKIE_DOMAIN / crossSubDomainCookies), the browser\n * labels a request from a SIBLING subdomain (evil.example.com → app.example.com)\n * as `same-site` even though it is cross-origin and would ride the shared\n * session cookie — a CSRF vector. Legitimate first-party clients all also send\n * `X-Agent-Native-CSRF` or `application/json`, so they still pass via those\n * paths and iframe/embed flows are unaffected.\n */\nfunction looksFirstParty(event: any): boolean {\n const sfs = getRequestHeader(event, \"sec-fetch-site\");\n if (sfs === \"same-origin\" || sfs === \"none\") {\n return true;\n }\n if (getRequestHeader(event, \"x-agent-native-csrf\")) {\n return true;\n }\n const contentType = getRequestHeader(event, \"content-type\");\n if (\n contentType &&\n typeof contentType === \"string\" &&\n contentType.toLowerCase().includes(\"application/json\")\n ) {\n return true;\n }\n return false;\n}\n\n/**\n * Returns true when the request carries any cookie. We use \"has any cookie\"\n * as a coarse heuristic for \"the browser is going to attach the session\n * cookie\" — anonymous tools (curl, server-to-server) typically don't send\n * cookies, so they bypass this check entirely.\n */\nfunction requestHasCookies(event: any): boolean {\n const cookie = getRequestHeader(event, \"cookie\");\n return typeof cookie === \"string\" && cookie.trim().length > 0;\n}\n\n/**\n * Path passed in is the full request URL pathname (e.g. `/_agent-native/actions/foo`).\n * `frameworkPrefix` should be the framework route prefix without trailing slash,\n * e.g. `/_agent-native`.\n */\nfunction isOnAllowlist(pathname: string, frameworkPrefix: string): boolean {\n if (!pathname.startsWith(frameworkPrefix)) return false;\n const sub = pathname.slice(frameworkPrefix.length);\n for (const allowed of CSRF_ALLOWLIST_PREFIXES) {\n if (sub.startsWith(allowed)) return true;\n }\n return false;\n}\n\n/**\n * Create the framework CSRF middleware.\n *\n * Mount this BEFORE any state-changing route handler. The middleware\n * - lets every non-state-changing method through (GET/HEAD/OPTIONS).\n * - lets requests without cookies through (anonymous/server tools).\n * - lets allowlisted paths through (webhooks, A2A, OAuth callbacks).\n * - lets first-party-shaped requests through (custom header, JSON\n * Content-Type, or `Sec-Fetch-Site: same-origin`).\n * - rejects everything else with 403.\n */\nexport function createCsrfMiddleware(\n frameworkPrefix: string = \"/_agent-native\",\n) {\n return defineEventHandler((event) => {\n const method = getMethod(event);\n if (!STATE_CHANGING_METHODS.has(method)) return undefined;\n\n const pathname = event.url?.pathname ?? \"\";\n if (!pathname.startsWith(frameworkPrefix)) return undefined;\n if (isOnAllowlist(pathname, frameworkPrefix)) return undefined;\n\n // No cookie = no risk of confused-deputy CSRF on the session cookie.\n if (!requestHasCookies(event)) return undefined;\n\n if (looksFirstParty(event)) return undefined;\n\n setResponseStatus(event, 403);\n return {\n error:\n \"CSRF check failed: state-changing requests must include a same-origin marker. Set Content-Type: application/json or X-Agent-Native-CSRF: 1.\",\n };\n });\n}\n"]}
1
+ {"version":3,"file":"csrf.js","sourceRoot":"","sources":["../../src/server/csrf.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAEH,OAAO,EACL,kBAAkB,EAClB,SAAS,EACT,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,IAAI,CAAC;AAEZ,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAE9D;;;;;GAKG;AACH,MAAM,uBAAuB,GAAG;IAC9B,4EAA4E;IAC5E,gBAAgB;IAChB,2EAA2E;IAC3E,gEAAgE;IAChE,eAAe;IACf,qEAAqE;IACrE,4DAA4D;IAC5D,6BAA6B;IAC7B,2EAA2E;IAC3E,gEAAgE;IAChE,MAAM;IACN,sEAAsE;IACtE,0EAA0E;IAC1E,4DAA4D;IAC5D,QAAQ;IACR,8DAA8D;IAC9D,kBAAkB;IAClB,uEAAuE;IACvE,2EAA2E;IAC3E,SAAS;IACT,sEAAsE;IACtE,yEAAyE;IACzE,yEAAyE;IACzE,qEAAqE;IACrE,+BAA+B;IAC/B,SAAS;IACT,0EAA0E;IAC1E,uEAAuE;IACvE,mBAAmB;CACpB,CAAC;AAEF,MAAM,sBAAsB,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC,CAA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.\n *\n * Threat model: action endpoints (`/_agent-native/actions/*`), extension\n * endpoints (`/_agent-native/extensions/*` and the legacy\n * `/_agent-native/tools/*` alias), and a handful of other state-changing\n * `/_agent-native/*` routes use the better-auth session cookie, which is\n * configured with `SameSite=None; Secure; Partitioned` so the iframe editor\n * (and other cross-site embeds) can authenticate. `SameSite=None` means the\n * browser ships the session cookie on top-level form POSTs from any origin —\n * which is exactly the precondition for classic cross-site request forgery.\n *\n * The browser still gates \"non-simple\" requests behind a CORS preflight, so\n * an attacker who has to send `Content-Type: application/json` is forced\n * through OPTIONS, which our CORS middleware (`create-server.ts`) rejects\n * for disallowed origins. But the simple-request bypass (`Content-Type:\n * text/plain` on a `<form enctype=\"text/plain\">` POST, or `multipart/form-data`)\n * never preflights — the browser delivers it cross-origin with cookies.\n *\n * Mitigation: this middleware rejects any state-changing\n * (`POST/PUT/PATCH/DELETE`) request to `/_agent-native/*` that\n *\n * 1. carries the auth-cookie pattern (any cookie at all is a heuristic\n * good-enough proxy — we don't want to deny anonymous fetches), AND\n * 2. is NOT clearly same-origin / first-party. We trust:\n * - `Sec-Fetch-Site: same-origin` (sent by every modern browser on\n * same-origin fetch — Chrome/Firefox/Safari/Edge all support it).\n * - `X-Agent-Native-CSRF` custom header. Custom headers force a\n * preflight, so an attacker can't add one cross-origin.\n * - `Content-Type: application/json` request body. Same logic — JSON\n * Content-Type is a non-simple request that triggers preflight.\n *\n * Why the existing CORS check isn't enough: a simple-request POST never\n * preflights, so the browser sends it through and only blocks the *response*\n * from being readable cross-origin. The state change (delete-account, write\n * SQL, etc.) happens server-side regardless. We need a server-side check that\n * proves first-party intent before running the action.\n *\n * Opt-out marker: a handful of routes legitimately accept cross-origin POSTs\n * — webhook endpoints (Slack, Telegram, email), the public A2A endpoint\n * (`/_agent-native/a2a`), the integrations process-task self-fire, and so on.\n * Those are listed in `CSRF_ALLOWLIST_PREFIXES` below; if you add a new\n * cross-origin-callable route, add it there.\n */\n\nimport {\n defineEventHandler,\n getMethod,\n getRequestHeader,\n setResponseStatus,\n} from \"h3\";\n\nimport { getConfiguredAppBasePath } from \"./app-base-path.js\";\n\n/**\n * Path prefixes (relative to the framework prefix `/_agent-native`) that are\n * allowed to receive cross-origin state-changing POSTs without first-party\n * markers. These are signed/authenticated through other mechanisms (HMAC,\n * JWT, internal token) so they don't need cookie-based CSRF protection.\n */\nconst CSRF_ALLOWLIST_PREFIXES = [\n // Integration webhooks — verified by HMAC against a per-integration secret.\n \"/integrations/\",\n // Agent Teams durable sub-agent processor self-fire — verified by the same\n // HMAC internal-token scheme as the integration/A2A processors.\n \"/agent-teams/\",\n // Durable sandbox-execution processor self-fire (run-code background\n // queue) — verified by the same HMAC internal-token scheme.\n \"/sandbox/_process-execution\",\n // A2A JSON-RPC endpoints — verified by signed JWT (when A2A_SECRET set) or\n // explicitly opt-in unauthenticated (handled at the A2A layer).\n \"/a2a\",\n // Better Auth's own login/sign-in/social-callback routes. Better Auth\n // ships its own CSRF protection (Origin/Sec-Fetch checks on its handlers)\n // and cookies are needed for the OAuth callback round-trip.\n \"/auth/\",\n // Stripe / Paddle / billing webhooks dropped in by templates.\n \"/billing/webhook\",\n // Public share endpoints — read-only and never cookie-driven, but kept\n // here so a templated POST (e.g. comment-on-public-recording) doesn't 403.\n \"/share/\",\n // OAuth callbacks (Builder, Google, Slack, Notion, Zoom). These get a\n // `code` query param via top-level navigation — they DO ride the session\n // cookie and they SHOULD validate state, but the framework can't see the\n // state token. Each callback handler is responsible for its own CSRF\n // check (signed state tokens).\n \"/oauth/\",\n // Builder's CLI-auth callback — uses the BUILDER_STATE_PARAM signed token\n // to authenticate the round-trip; framework CSRF check would block it.\n \"/builder/callback\",\n];\n\nconst STATE_CHANGING_METHODS = new Set([\"POST\", \"PUT\", \"PATCH\", \"DELETE\"]);\n\n/**\n * Decide whether a request is \"first-party enough\" to trust as not-CSRF.\n * Any of the following make a request non-CSRF:\n *\n * - `Sec-Fetch-Site: same-origin` (or `none` for top-level navigations\n * to our own pages — but state-changing methods don't ship `none`).\n * - `X-Agent-Native-CSRF` header (any value, even \"1\"). This is a custom\n * header so the browser forces a preflight cross-origin, which our\n * CORS layer rejects for disallowed origins.\n * - `Content-Type: application/json` (case-insensitive). JSON content\n * type is a non-simple request that triggers preflight.\n *\n * We accept ANY of these — the goal is \"did the request come through a\n * channel the browser would have preflighted\", not a strict-mode token.\n *\n * NOTE: `Sec-Fetch-Site: same-site` is deliberately NOT trusted. Under a\n * shared cookie domain (COOKIE_DOMAIN / crossSubDomainCookies), the browser\n * labels a request from a SIBLING subdomain (evil.example.com → app.example.com)\n * as `same-site` even though it is cross-origin and would ride the shared\n * session cookie — a CSRF vector. Legitimate first-party clients all also send\n * `X-Agent-Native-CSRF` or `application/json`, so they still pass via those\n * paths and iframe/embed flows are unaffected.\n */\nfunction looksFirstParty(event: any): boolean {\n const sfs = getRequestHeader(event, \"sec-fetch-site\");\n if (sfs === \"same-origin\" || sfs === \"none\") {\n return true;\n }\n if (getRequestHeader(event, \"x-agent-native-csrf\")) {\n return true;\n }\n const contentType = getRequestHeader(event, \"content-type\");\n if (\n contentType &&\n typeof contentType === \"string\" &&\n contentType.toLowerCase().includes(\"application/json\")\n ) {\n return true;\n }\n return false;\n}\n\n/**\n * Returns true when the request carries any cookie. We use \"has any cookie\"\n * as a coarse heuristic for \"the browser is going to attach the session\n * cookie\" — anonymous tools (curl, server-to-server) typically don't send\n * cookies, so they bypass this check entirely.\n */\nfunction requestHasCookies(event: any): boolean {\n const cookie = getRequestHeader(event, \"cookie\");\n return typeof cookie === \"string\" && cookie.trim().length > 0;\n}\n\n/**\n * The path is the full request URL pathname (e.g.\n * `/_agent-native/actions/foo` or `/app/_agent-native/actions/foo`).\n * `frameworkPrefix` is the root framework route prefix without a trailing\n * slash, e.g. `/_agent-native`.\n */\nfunction isOnAllowlist(pathname: string, frameworkPrefix: string): boolean {\n if (!pathname.startsWith(frameworkPrefix)) return false;\n const sub = pathname.slice(frameworkPrefix.length);\n for (const allowed of CSRF_ALLOWLIST_PREFIXES) {\n if (sub.startsWith(allowed)) return true;\n }\n return false;\n}\n\nfunction matchingFrameworkPrefix(\n pathname: string,\n frameworkPrefix: string,\n): string | undefined {\n if (pathname.startsWith(frameworkPrefix)) return frameworkPrefix;\n\n const basePath = getConfiguredAppBasePath();\n const basePathFrameworkPrefix = `${basePath}${frameworkPrefix}`;\n if (basePath && pathname.startsWith(basePathFrameworkPrefix)) {\n return basePathFrameworkPrefix;\n }\n\n return undefined;\n}\n\n/**\n * Create the framework CSRF middleware.\n *\n * Mount this BEFORE any state-changing route handler. The middleware\n * - lets every non-state-changing method through (GET/HEAD/OPTIONS).\n * - lets requests without cookies through (anonymous/server tools).\n * - lets allowlisted paths through (webhooks, A2A, OAuth callbacks).\n * - lets first-party-shaped requests through (custom header, JSON\n * Content-Type, or `Sec-Fetch-Site: same-origin`).\n * - rejects everything else with 403.\n */\nexport function createCsrfMiddleware(\n frameworkPrefix: string = \"/_agent-native\",\n) {\n return defineEventHandler((event) => {\n const method = getMethod(event);\n if (!STATE_CHANGING_METHODS.has(method)) return undefined;\n\n const pathname = event.url?.pathname ?? \"\";\n const matchingPrefix = matchingFrameworkPrefix(pathname, frameworkPrefix);\n if (!matchingPrefix) return undefined;\n if (isOnAllowlist(pathname, matchingPrefix)) return undefined;\n\n // No cookie = no risk of confused-deputy CSRF on the session cookie.\n if (!requestHasCookies(event)) return undefined;\n\n if (looksFirstParty(event)) return undefined;\n\n setResponseStatus(event, 403);\n return {\n error:\n \"CSRF check failed: state-changing requests must include a same-origin marker. Set Content-Type: application/json or X-Agent-Native-CSRF: 1.\",\n };\n });\n}\n"]}
@@ -8,4 +8,5 @@ export { createOnboardingPlugin, defaultOnboardingPlugin, } from "../onboarding/
8
8
  export { createOrgPlugin, defaultOrgPlugin } from "../org/plugin.js";
9
9
  export { createResourcesPlugin, defaultResourcesPlugin, } from "./resources-plugin.js";
10
10
  export { getH3App, awaitBootstrap, markDefaultPluginProvided, type H3AppShim, } from "./framework-request-handler.js";
11
+ export { runWithRequestContext } from "./request-context.js";
11
12
  //# sourceMappingURL=edge.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"edge.d.ts","sourceRoot":"","sources":["../../src/server/edge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,uBAAuB,EACvB,KAAK,sBAAsB,GAC5B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,uBAAuB,EACvB,wBAAwB,GACzB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,sBAAsB,EACtB,KAAK,uBAAuB,GAC7B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,wBAAwB,EACxB,yBAAyB,EACzB,oBAAoB,EACpB,YAAY,EACZ,eAAe,EACf,eAAe,EACf,cAAc,EACd,qBAAqB,EACrB,YAAY,EACZ,wBAAwB,EACxB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,2BAA2B,EAChC,KAAK,wBAAwB,EAC7B,KAAK,iBAAiB,EACtB,KAAK,yBAAyB,EAC9B,4BAA4B,EAC5B,sBAAsB,EACtB,0BAA0B,EAC1B,8BAA8B,EAC9B,sBAAsB,EACtB,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACxB,KAAK,gCAAgC,EACrC,KAAK,kBAAkB,EACvB,KAAK,0BAA0B,GAChC,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,+BAA+B,EAC/B,gCAAgC,GACjC,MAAM,yCAAyC,CAAC;AACjD,OAAO,EACL,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,QAAQ,EACR,cAAc,EACd,yBAAyB,EACzB,KAAK,SAAS,GACf,MAAM,gCAAgC,CAAC"}
1
+ {"version":3,"file":"edge.d.ts","sourceRoot":"","sources":["../../src/server/edge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,uBAAuB,EACvB,KAAK,sBAAsB,GAC5B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,uBAAuB,EACvB,wBAAwB,GACzB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,sBAAsB,EACtB,KAAK,uBAAuB,GAC7B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,wBAAwB,EACxB,yBAAyB,EACzB,oBAAoB,EACpB,YAAY,EACZ,eAAe,EACf,eAAe,EACf,cAAc,EACd,qBAAqB,EACrB,YAAY,EACZ,wBAAwB,EACxB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,2BAA2B,EAChC,KAAK,wBAAwB,EAC7B,KAAK,iBAAiB,EACtB,KAAK,yBAAyB,EAC9B,4BAA4B,EAC5B,sBAAsB,EACtB,0BAA0B,EAC1B,8BAA8B,EAC9B,sBAAsB,EACtB,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACxB,KAAK,gCAAgC,EACrC,KAAK,kBAAkB,EACvB,KAAK,0BAA0B,GAChC,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,+BAA+B,EAC/B,gCAAgC,GACjC,MAAM,yCAAyC,CAAC;AACjD,OAAO,EACL,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,QAAQ,EACR,cAAc,EACd,yBAAyB,EACzB,KAAK,SAAS,GACf,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC"}
@@ -8,4 +8,5 @@ export { createOnboardingPlugin, defaultOnboardingPlugin, } from "../onboarding/
8
8
  export { createOrgPlugin, defaultOrgPlugin } from "../org/plugin.js";
9
9
  export { createResourcesPlugin, defaultResourcesPlugin, } from "./resources-plugin.js";
10
10
  export { getH3App, awaitBootstrap, markDefaultPluginProvided, } from "./framework-request-handler.js";
11
+ export { runWithRequestContext } from "./request-context.js";
11
12
  //# sourceMappingURL=edge.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"edge.js","sourceRoot":"","sources":["../../src/server/edge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,uBAAuB,GAExB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,uBAAuB,EACvB,wBAAwB,GACzB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,sBAAsB,GAEvB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,wBAAwB,EACxB,yBAAyB,EACzB,oBAAoB,EACpB,YAAY,EACZ,eAAe,EACf,eAAe,EACf,cAAc,EACd,qBAAqB,EACrB,YAAY,EACZ,wBAAwB,EAQxB,4BAA4B,EAC5B,sBAAsB,EACtB,0BAA0B,EAC1B,8BAA8B,EAC9B,sBAAsB,GASvB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,+BAA+B,EAC/B,gCAAgC,GACjC,MAAM,yCAAyC,CAAC;AACjD,OAAO,EACL,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,QAAQ,EACR,cAAc,EACd,yBAAyB,GAE1B,MAAM,gCAAgC,CAAC","sourcesContent":["export { createAuthPlugin, defaultAuthPlugin } from \"./auth-plugin.js\";\nexport {\n createAgentChatPlugin,\n defaultAgentChatPlugin,\n refreshGlobalMcpManager,\n type AgentChatPluginOptions,\n} from \"./agent-chat-plugin.js\";\nexport {\n createContextXrayPlugin,\n defaultContextXrayPlugin,\n} from \"../agent/context-xray/plugin.js\";\nexport {\n createCoreRoutesPlugin,\n defaultCoreRoutesPlugin,\n FRAMEWORK_ROUTE_PREFIX,\n type CoreRoutesPluginOptions,\n} from \"./core-routes-plugin.js\";\nexport {\n createIntegrationsPlugin,\n defaultIntegrationsPlugin,\n enqueueRemoteCommand,\n slackAdapter,\n telegramAdapter,\n whatsappAdapter,\n discordAdapter,\n microsoftTeamsAdapter,\n emailAdapter,\n assertPlatformCapability,\n type PlatformAdapter,\n type IncomingMessage,\n type OutgoingMessage,\n type PlatformAdapterCapabilities,\n type ImmediateWebhookResponse,\n type IntegrationStatus,\n type IntegrationsPluginOptions,\n BUILT_IN_INTEGRATION_CATALOG,\n INTEGRATION_CATEGORIES,\n getIntegrationCatalogEntry,\n listBuiltInChannelIntegrations,\n listIntegrationCatalog,\n type BuiltInChannelId,\n type ChannelCapabilities,\n type IntegrationAvailability,\n type IntegrationCatalogEntry,\n type IntegrationCategory,\n type IntegrationCredentialRequirement,\n type IntegrationIconKey,\n type IntegrationSupportMaturity,\n} from \"../integrations/index.js\";\nexport {\n createObservationalMemoryPlugin,\n defaultObservationalMemoryPlugin,\n} from \"../agent/observational-memory/plugin.js\";\nexport {\n createOnboardingPlugin,\n defaultOnboardingPlugin,\n} from \"../onboarding/plugin.js\";\nexport { createOrgPlugin, defaultOrgPlugin } from \"../org/plugin.js\";\nexport {\n createResourcesPlugin,\n defaultResourcesPlugin,\n} from \"./resources-plugin.js\";\nexport {\n getH3App,\n awaitBootstrap,\n markDefaultPluginProvided,\n type H3AppShim,\n} from \"./framework-request-handler.js\";\n"]}
1
+ {"version":3,"file":"edge.js","sourceRoot":"","sources":["../../src/server/edge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,uBAAuB,GAExB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,uBAAuB,EACvB,wBAAwB,GACzB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,sBAAsB,GAEvB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,wBAAwB,EACxB,yBAAyB,EACzB,oBAAoB,EACpB,YAAY,EACZ,eAAe,EACf,eAAe,EACf,cAAc,EACd,qBAAqB,EACrB,YAAY,EACZ,wBAAwB,EAQxB,4BAA4B,EAC5B,sBAAsB,EACtB,0BAA0B,EAC1B,8BAA8B,EAC9B,sBAAsB,GASvB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,+BAA+B,EAC/B,gCAAgC,GACjC,MAAM,yCAAyC,CAAC;AACjD,OAAO,EACL,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,QAAQ,EACR,cAAc,EACd,yBAAyB,GAE1B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC","sourcesContent":["export { createAuthPlugin, defaultAuthPlugin } from \"./auth-plugin.js\";\nexport {\n createAgentChatPlugin,\n defaultAgentChatPlugin,\n refreshGlobalMcpManager,\n type AgentChatPluginOptions,\n} from \"./agent-chat-plugin.js\";\nexport {\n createContextXrayPlugin,\n defaultContextXrayPlugin,\n} from \"../agent/context-xray/plugin.js\";\nexport {\n createCoreRoutesPlugin,\n defaultCoreRoutesPlugin,\n FRAMEWORK_ROUTE_PREFIX,\n type CoreRoutesPluginOptions,\n} from \"./core-routes-plugin.js\";\nexport {\n createIntegrationsPlugin,\n defaultIntegrationsPlugin,\n enqueueRemoteCommand,\n slackAdapter,\n telegramAdapter,\n whatsappAdapter,\n discordAdapter,\n microsoftTeamsAdapter,\n emailAdapter,\n assertPlatformCapability,\n type PlatformAdapter,\n type IncomingMessage,\n type OutgoingMessage,\n type PlatformAdapterCapabilities,\n type ImmediateWebhookResponse,\n type IntegrationStatus,\n type IntegrationsPluginOptions,\n BUILT_IN_INTEGRATION_CATALOG,\n INTEGRATION_CATEGORIES,\n getIntegrationCatalogEntry,\n listBuiltInChannelIntegrations,\n listIntegrationCatalog,\n type BuiltInChannelId,\n type ChannelCapabilities,\n type IntegrationAvailability,\n type IntegrationCatalogEntry,\n type IntegrationCategory,\n type IntegrationCredentialRequirement,\n type IntegrationIconKey,\n type IntegrationSupportMaturity,\n} from \"../integrations/index.js\";\nexport {\n createObservationalMemoryPlugin,\n defaultObservationalMemoryPlugin,\n} from \"../agent/observational-memory/plugin.js\";\nexport {\n createOnboardingPlugin,\n defaultOnboardingPlugin,\n} from \"../onboarding/plugin.js\";\nexport { createOrgPlugin, defaultOrgPlugin } from \"../org/plugin.js\";\nexport {\n createResourcesPlugin,\n defaultResourcesPlugin,\n} from \"./resources-plugin.js\";\nexport {\n getH3App,\n awaitBootstrap,\n markDefaultPluginProvided,\n type H3AppShim,\n} from \"./framework-request-handler.js\";\nexport { runWithRequestContext } from \"./request-context.js\";\n"]}