@agent-native/core 0.145.5 → 0.145.7

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 (393) hide show
  1. package/corpus/README.md +1 -1
  2. package/corpus/templates/analytics/.agents/skills/actions/SKILL.md +18 -0
  3. package/corpus/templates/analytics/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
  4. package/corpus/templates/analytics/.agents/skills/dashboard-management/SKILL.md +17 -1
  5. package/corpus/templates/analytics/.agents/skills/delegate-to-agent/SKILL.md +45 -47
  6. package/corpus/templates/analytics/.agents/skills/frontend-design/SKILL.md +1 -0
  7. package/corpus/templates/analytics/.agents/skills/gong/SKILL.md +22 -3
  8. package/corpus/templates/analytics/.agents/skills/turn-into-app/SKILL.md +76 -23
  9. package/corpus/templates/analytics/.agents/skills/turn-into-app/agents/openai.yaml +2 -2
  10. package/corpus/templates/analytics/.agents/skills/turn-into-app/references/fresh-project.md +64 -0
  11. package/corpus/templates/analytics/AGENTS.md +2 -1
  12. package/corpus/templates/analytics/actions/account-deep-dive.ts +83 -47
  13. package/corpus/templates/analytics/actions/create-dashboard-folder.ts +27 -0
  14. package/corpus/templates/analytics/actions/gong-calls.ts +3 -3
  15. package/corpus/templates/analytics/actions/list-dashboard-folders.ts +26 -0
  16. package/corpus/templates/analytics/actions/list-sql-dashboards.ts +1 -0
  17. package/corpus/templates/analytics/actions/set-dashboard-folder.ts +26 -0
  18. package/corpus/templates/analytics/app/components/ProviderCorpusJobNotifier.tsx +18 -3
  19. package/corpus/templates/analytics/app/components/layout/CommandPalette.tsx +6 -4
  20. package/corpus/templates/analytics/app/components/layout/Header.tsx +1 -0
  21. package/corpus/templates/analytics/app/components/layout/NewDashboardDialog.tsx +12 -2
  22. package/corpus/templates/analytics/app/components/layout/Sidebar.tsx +35 -20
  23. package/corpus/templates/analytics/app/global.css +17 -0
  24. package/corpus/templates/analytics/app/hooks/use-dashboard-revisions.ts +29 -15
  25. package/corpus/templates/analytics/app/hooks/use-dashboard-views.ts +15 -3
  26. package/corpus/templates/analytics/app/i18n-data.ts +296 -0
  27. package/corpus/templates/analytics/app/lib/prefetch-keys.ts +23 -2
  28. package/corpus/templates/analytics/app/pages/DashboardOverview.tsx +642 -0
  29. package/corpus/templates/analytics/app/pages/adhoc/sql-dashboard/index.tsx +66 -31
  30. package/corpus/templates/analytics/app/root.tsx +4 -0
  31. package/corpus/templates/analytics/app/routes/dashboards._index.tsx +5 -1
  32. package/corpus/templates/analytics/changelog/2026-08-07-added-a-dashboards-overview-with-personal-and-shared-folders.md +6 -0
  33. package/corpus/templates/analytics/changelog/2026-08-07-analytics-no-longer-stalls-under-bursts-of-event-ingest-key-.md +6 -0
  34. package/corpus/templates/analytics/changelog/2026-08-07-analytics-tracking-and-chat-startup-no-longer-emit-avoidable.md +6 -0
  35. package/corpus/templates/analytics/changelog/2026-08-07-dashboard-panels-now-load-custom-api-data-programs-reliably.md +6 -0
  36. package/corpus/templates/analytics/changelog/2026-08-07-gong-searches-conserve-api-quota-and-report-incomplete-coverage.md +6 -0
  37. package/corpus/templates/analytics/changelog/2026-08-07-searchable-dashboards-make-personal-and-shared-folders-easie.md +6 -0
  38. package/corpus/templates/analytics/netlify.toml +3 -0
  39. package/corpus/templates/analytics/scripts/emit-netlify-dashboard-report-cron.ts +112 -0
  40. package/corpus/templates/analytics/server/db/index.ts +12 -0
  41. package/corpus/templates/analytics/server/db/schema.ts +14 -0
  42. package/corpus/templates/analytics/server/jobs/analytics-rollup-backfill.ts +4 -0
  43. package/corpus/templates/analytics/server/lib/agent-chat-plan-mode.ts +1 -0
  44. package/corpus/templates/analytics/server/lib/analytics-query-catalog.ts +85 -15
  45. package/corpus/templates/analytics/server/lib/dashboard-folders-store.ts +168 -0
  46. package/corpus/templates/analytics/server/lib/dashboard-panel-query.ts +9 -4
  47. package/corpus/templates/analytics/server/lib/dashboards-store.ts +116 -1
  48. package/corpus/templates/analytics/server/lib/first-party-analytics-rollups.ts +4 -8
  49. package/corpus/templates/analytics/server/lib/first-party-analytics.ts +65 -10
  50. package/corpus/templates/analytics/server/lib/gong.ts +139 -78
  51. package/corpus/templates/analytics/server/lib/session-replay.ts +5 -5
  52. package/corpus/templates/analytics/server/plugins/db.ts +55 -15
  53. package/corpus/templates/analytics/server/plugins/session-replay-retention-jobs.ts +6 -2
  54. package/corpus/templates/analytics/server/routes/api/session-replay/retention.post.ts +65 -0
  55. package/corpus/templates/assets/.agents/skills/actions/SKILL.md +18 -0
  56. package/corpus/templates/assets/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
  57. package/corpus/templates/assets/.agents/skills/delegate-to-agent/SKILL.md +45 -47
  58. package/corpus/templates/assets/.agents/skills/frontend-design/SKILL.md +1 -0
  59. package/corpus/templates/assets/.agents/skills/turn-into-app/SKILL.md +76 -23
  60. package/corpus/templates/assets/.agents/skills/turn-into-app/agents/openai.yaml +2 -2
  61. package/corpus/templates/assets/.agents/skills/turn-into-app/references/fresh-project.md +64 -0
  62. package/corpus/templates/brain/.agents/skills/actions/SKILL.md +18 -0
  63. package/corpus/templates/brain/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
  64. package/corpus/templates/brain/.agents/skills/delegate-to-agent/SKILL.md +45 -47
  65. package/corpus/templates/brain/.agents/skills/frontend-design/SKILL.md +1 -0
  66. package/corpus/templates/brain/.agents/skills/turn-into-app/SKILL.md +76 -23
  67. package/corpus/templates/brain/.agents/skills/turn-into-app/agents/openai.yaml +2 -2
  68. package/corpus/templates/brain/.agents/skills/turn-into-app/references/fresh-project.md +64 -0
  69. package/corpus/templates/calendar/.agents/skills/actions/SKILL.md +18 -0
  70. package/corpus/templates/calendar/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
  71. package/corpus/templates/calendar/.agents/skills/delegate-to-agent/SKILL.md +45 -47
  72. package/corpus/templates/calendar/.agents/skills/frontend-design/SKILL.md +1 -0
  73. package/corpus/templates/calendar/.agents/skills/turn-into-app/SKILL.md +76 -23
  74. package/corpus/templates/calendar/.agents/skills/turn-into-app/agents/openai.yaml +2 -2
  75. package/corpus/templates/calendar/.agents/skills/turn-into-app/references/fresh-project.md +64 -0
  76. package/corpus/templates/chat/.agents/skills/actions/SKILL.md +18 -0
  77. package/corpus/templates/chat/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
  78. package/corpus/templates/chat/.agents/skills/delegate-to-agent/SKILL.md +45 -47
  79. package/corpus/templates/chat/.agents/skills/frontend-design/SKILL.md +1 -0
  80. package/corpus/templates/chat/.agents/skills/turn-into-app/SKILL.md +76 -23
  81. package/corpus/templates/chat/.agents/skills/turn-into-app/agents/openai.yaml +2 -2
  82. package/corpus/templates/chat/.agents/skills/turn-into-app/references/fresh-project.md +64 -0
  83. package/corpus/templates/chat/.env.example +3 -0
  84. package/corpus/templates/chat/AGENTS.md +4 -0
  85. package/corpus/templates/clips/.agents/skills/actions/SKILL.md +18 -0
  86. package/corpus/templates/clips/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
  87. package/corpus/templates/clips/.agents/skills/delegate-to-agent/SKILL.md +45 -47
  88. package/corpus/templates/clips/.agents/skills/frontend-design/SKILL.md +1 -0
  89. package/corpus/templates/clips/.agents/skills/turn-into-app/SKILL.md +76 -23
  90. package/corpus/templates/clips/.agents/skills/turn-into-app/agents/openai.yaml +2 -2
  91. package/corpus/templates/clips/.agents/skills/turn-into-app/references/fresh-project.md +64 -0
  92. package/corpus/templates/clips/actions/lib/audio-only-transcription.ts +4 -0
  93. package/corpus/templates/clips/actions/request-transcript.ts +52 -3
  94. package/corpus/templates/clips/app/components/recorder/recorder-engine.ts +3 -10
  95. package/corpus/templates/clips/app/routes/r.$recordingId.tsx +1 -0
  96. package/corpus/templates/clips/changelog/2026-08-07-screen-recordings-now-capture-tab-and-system-audio-even-when.md +6 -0
  97. package/corpus/templates/clips/changelog/2026-08-07-transcription-now-retries-transient-cloud-failures-automatic.md +6 -0
  98. package/corpus/templates/clips/server/db/schema.ts +7 -0
  99. package/corpus/templates/clips/server/plugins/db.ts +8 -0
  100. package/corpus/templates/clips/shared/recording-capture.ts +38 -0
  101. package/corpus/templates/clips/shared/transcript-failure.ts +89 -0
  102. package/corpus/templates/content/.agents/skills/actions/SKILL.md +18 -0
  103. package/corpus/templates/content/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
  104. package/corpus/templates/content/.agents/skills/delegate-to-agent/SKILL.md +45 -47
  105. package/corpus/templates/content/.agents/skills/frontend-design/SKILL.md +1 -0
  106. package/corpus/templates/content/.agents/skills/turn-into-app/SKILL.md +76 -23
  107. package/corpus/templates/content/.agents/skills/turn-into-app/agents/openai.yaml +2 -2
  108. package/corpus/templates/content/.agents/skills/turn-into-app/references/fresh-project.md +64 -0
  109. package/corpus/templates/content/.env.example +9 -3
  110. package/corpus/templates/content/app/components/sidebar/DocumentSidebar.tsx +1 -0
  111. package/corpus/templates/content/changelog/2026-08-07-collapsed-sidebar-utility-buttons-stay-anchored-at-the-botto.md +6 -0
  112. package/corpus/templates/crm/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
  113. package/corpus/templates/crm/.agents/skills/turn-into-app/SKILL.md +76 -23
  114. package/corpus/templates/crm/.agents/skills/turn-into-app/agents/openai.yaml +2 -2
  115. package/corpus/templates/crm/.agents/skills/turn-into-app/references/fresh-project.md +64 -0
  116. package/corpus/templates/design/.agents/skills/actions/SKILL.md +18 -0
  117. package/corpus/templates/design/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
  118. package/corpus/templates/design/.agents/skills/delegate-to-agent/SKILL.md +45 -47
  119. package/corpus/templates/design/.agents/skills/frontend-design/SKILL.md +1 -0
  120. package/corpus/templates/design/.agents/skills/turn-into-app/SKILL.md +76 -23
  121. package/corpus/templates/design/.agents/skills/turn-into-app/agents/openai.yaml +2 -2
  122. package/corpus/templates/design/.agents/skills/turn-into-app/references/fresh-project.md +64 -0
  123. package/corpus/templates/dispatch/.agents/skills/actions/SKILL.md +18 -0
  124. package/corpus/templates/dispatch/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
  125. package/corpus/templates/dispatch/.agents/skills/delegate-to-agent/SKILL.md +45 -47
  126. package/corpus/templates/dispatch/.agents/skills/frontend-design/SKILL.md +1 -0
  127. package/corpus/templates/dispatch/.agents/skills/turn-into-app/SKILL.md +76 -23
  128. package/corpus/templates/dispatch/.agents/skills/turn-into-app/agents/openai.yaml +2 -2
  129. package/corpus/templates/dispatch/.agents/skills/turn-into-app/references/fresh-project.md +64 -0
  130. package/corpus/templates/factory/.agents/skills/actions/SKILL.md +18 -0
  131. package/corpus/templates/factory/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
  132. package/corpus/templates/factory/.agents/skills/delegate-to-agent/SKILL.md +45 -47
  133. package/corpus/templates/factory/.agents/skills/frontend-design/SKILL.md +1 -0
  134. package/corpus/templates/factory/.agents/skills/turn-into-app/SKILL.md +76 -23
  135. package/corpus/templates/factory/.agents/skills/turn-into-app/agents/openai.yaml +2 -2
  136. package/corpus/templates/factory/.agents/skills/turn-into-app/references/fresh-project.md +64 -0
  137. package/corpus/templates/factory/actions/babysit-agent-native-pull-request.ts +279 -0
  138. package/corpus/templates/factory/actions/get-factory-automation-health.ts +23 -4
  139. package/corpus/templates/factory/app/components/factory/FactoryCanvas.tsx +1 -1
  140. package/corpus/templates/factory/app/routes/factory.tsx +21 -3
  141. package/corpus/templates/factory/changelog/2026-08-07-factory-can-keep-builder-bot-pull-requests-moving-by-request.md +6 -0
  142. package/corpus/templates/factory/server/lib/require-factory-automation.ts +1 -0
  143. package/corpus/templates/factory/server/plugins/agent-chat.ts +4 -1
  144. package/corpus/templates/factory/server/plugins/factory-scheduler-job.ts +81 -12
  145. package/corpus/templates/factory/server/triage/github-client.ts +31 -0
  146. package/corpus/templates/factory/server/triage/pr-babysit.ts +75 -1
  147. package/corpus/templates/forms/.agents/skills/actions/SKILL.md +18 -0
  148. package/corpus/templates/forms/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
  149. package/corpus/templates/forms/.agents/skills/delegate-to-agent/SKILL.md +45 -47
  150. package/corpus/templates/forms/.agents/skills/frontend-design/SKILL.md +1 -0
  151. package/corpus/templates/forms/.agents/skills/turn-into-app/SKILL.md +76 -23
  152. package/corpus/templates/forms/.agents/skills/turn-into-app/agents/openai.yaml +2 -2
  153. package/corpus/templates/forms/.agents/skills/turn-into-app/references/fresh-project.md +64 -0
  154. package/corpus/templates/macros/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
  155. package/corpus/templates/macros/.agents/skills/frontend-design/SKILL.md +1 -0
  156. package/corpus/templates/macros/.agents/skills/turn-into-app/SKILL.md +76 -23
  157. package/corpus/templates/macros/.agents/skills/turn-into-app/agents/openai.yaml +2 -2
  158. package/corpus/templates/macros/.agents/skills/turn-into-app/references/fresh-project.md +64 -0
  159. package/corpus/templates/mail/.agents/skills/actions/SKILL.md +18 -0
  160. package/corpus/templates/mail/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
  161. package/corpus/templates/mail/.agents/skills/delegate-to-agent/SKILL.md +45 -47
  162. package/corpus/templates/mail/.agents/skills/frontend-design/SKILL.md +1 -0
  163. package/corpus/templates/mail/.agents/skills/turn-into-app/SKILL.md +76 -23
  164. package/corpus/templates/mail/.agents/skills/turn-into-app/agents/openai.yaml +2 -2
  165. package/corpus/templates/mail/.agents/skills/turn-into-app/references/fresh-project.md +64 -0
  166. package/corpus/templates/plan/.agents/skills/actions/SKILL.md +18 -0
  167. package/corpus/templates/plan/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
  168. package/corpus/templates/plan/.agents/skills/delegate-to-agent/SKILL.md +45 -47
  169. package/corpus/templates/plan/.agents/skills/frontend-design/SKILL.md +1 -0
  170. package/corpus/templates/plan/.agents/skills/turn-into-app/SKILL.md +76 -23
  171. package/corpus/templates/plan/.agents/skills/turn-into-app/agents/openai.yaml +2 -2
  172. package/corpus/templates/plan/.agents/skills/turn-into-app/references/fresh-project.md +64 -0
  173. package/corpus/templates/plan/app/pages/PlansPage.tsx +2 -1
  174. package/corpus/templates/plan/changelog/2026-08-07-inline-help-icons-now-stay-visually-balanced-with-nearby-tex.md +6 -0
  175. package/corpus/templates/slides/.agents/skills/actions/SKILL.md +18 -0
  176. package/corpus/templates/slides/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
  177. package/corpus/templates/slides/.agents/skills/delegate-to-agent/SKILL.md +45 -47
  178. package/corpus/templates/slides/.agents/skills/frontend-design/SKILL.md +1 -0
  179. package/corpus/templates/slides/.agents/skills/turn-into-app/SKILL.md +76 -23
  180. package/corpus/templates/slides/.agents/skills/turn-into-app/agents/openai.yaml +2 -2
  181. package/corpus/templates/slides/.agents/skills/turn-into-app/references/fresh-project.md +64 -0
  182. package/corpus/templates/slides/.env.example +5 -0
  183. package/corpus/templates/slides/changelog/2026-08-07-fixed-generated-slides-briefly-disappearing-while-they-are-b.md +6 -0
  184. package/corpus/templates/slides/server/plugins/collab.ts +20 -8
  185. package/corpus/templates/tasks/.agents/skills/actions/SKILL.md +18 -0
  186. package/corpus/templates/tasks/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
  187. package/corpus/templates/tasks/.agents/skills/delegate-to-agent/SKILL.md +45 -47
  188. package/corpus/templates/tasks/.agents/skills/frontend-design/SKILL.md +1 -0
  189. package/corpus/templates/tasks/.agents/skills/turn-into-app/SKILL.md +76 -23
  190. package/corpus/templates/tasks/.agents/skills/turn-into-app/agents/openai.yaml +2 -2
  191. package/corpus/templates/tasks/.agents/skills/turn-into-app/references/fresh-project.md +64 -0
  192. package/corpus/templates/tasks/.env.example +3 -0
  193. package/dist/agent/production-agent.js +24 -3
  194. package/dist/client/AgentPanel.d.ts +6 -0
  195. package/dist/client/AgentPanel.js +176 -30
  196. package/dist/client/AssistantChat.d.ts +2 -0
  197. package/dist/client/AssistantChat.js +4 -1
  198. package/dist/client/ConnectBuilderCard.js +6 -11
  199. package/dist/client/MultiTabAssistantChat.js +1 -1
  200. package/dist/client/RuntimeConfigNotice.d.ts +1 -0
  201. package/dist/client/RuntimeConfigNotice.js +94 -0
  202. package/dist/client/agent-chat/index.d.ts +1 -1
  203. package/dist/client/agent-chat/index.js +1 -1
  204. package/dist/client/agent-chat-adapter.js +85 -4
  205. package/dist/client/agent-page/AgentTabsPage.js +1 -1
  206. package/dist/client/agent-sidebar-state.d.ts +6 -0
  207. package/dist/client/agent-sidebar-state.js +25 -0
  208. package/dist/client/app-providers.js +2 -1
  209. package/dist/client/assistant-ui-recovery.js +1 -1
  210. package/dist/client/chat/index.d.ts +1 -1
  211. package/dist/client/chat/index.js +1 -1
  212. package/dist/client/chat/markdown-renderer.d.ts +2 -1
  213. package/dist/client/chat/markdown-renderer.js +48 -2
  214. package/dist/client/chat/message-components.d.ts +6 -0
  215. package/dist/client/chat/message-components.js +182 -53
  216. package/dist/client/chat/tool-call-display.d.ts +16 -4
  217. package/dist/client/chat/tool-call-display.js +225 -18
  218. package/dist/client/extensions/ExtensionsSidebarSection.js +1 -1
  219. package/dist/client/frame-protocol.d.ts +4 -0
  220. package/dist/client/i18n.js +9 -0
  221. package/dist/client/integrations/IntegrationsPanel.js +2 -5
  222. package/dist/client/onboarding/FirstRunOnboarding.js +2 -3
  223. package/dist/client/org/TeamPage.js +49 -6
  224. package/dist/client/org/hooks.d.ts +7 -2
  225. package/dist/client/org/hooks.js +11 -4
  226. package/dist/client/resources/McpConnectionSuggestion.js +2 -3
  227. package/dist/client/resources/McpIntegrationDialog.js +2 -16
  228. package/dist/client/resources/McpIntegrationLogo.d.ts +11 -0
  229. package/dist/client/resources/McpIntegrationLogo.js +14 -0
  230. package/dist/client/resources/ResourceTree.js +1 -1
  231. package/dist/client/resources/mcp-integration-logos.d.ts +1 -0
  232. package/dist/client/resources/mcp-integration-logos.js +47 -18
  233. package/dist/client/settings/useBuilderStatus.js +6 -0
  234. package/dist/client/ui/index.d.ts +1 -0
  235. package/dist/client/ui/index.js +1 -0
  236. package/dist/client/use-db-sync.js +4 -0
  237. package/dist/collab/struct-routes.d.ts +1 -1
  238. package/dist/config.d.ts +26 -3
  239. package/dist/config.js +106 -14
  240. package/dist/db/ddl-guard.d.ts +15 -2
  241. package/dist/db/ddl-guard.js +53 -5
  242. package/dist/file-upload/actions/upload-image.d.ts +1 -1
  243. package/dist/jobs/scheduler.js +7 -0
  244. package/dist/localization/default-messages.d.ts +17 -0
  245. package/dist/localization/default-messages.js +17 -0
  246. package/dist/mcp/oauth-client-metadata.js +5 -1
  247. package/dist/mcp/oauth-route.d.ts +5 -4
  248. package/dist/mcp/oauth-route.js +25 -9
  249. package/dist/mcp/screen-memory-stdio.d.ts +7 -7
  250. package/dist/mcp/server.d.ts +1 -1
  251. package/dist/mcp/server.js +9 -10
  252. package/dist/notifications/routes.d.ts +2 -2
  253. package/dist/observability/routes.d.ts +3 -3
  254. package/dist/org/handlers.d.ts +1 -0
  255. package/dist/org/handlers.js +17 -2
  256. package/dist/provider-api/actions/custom-provider-registration.d.ts +5 -5
  257. package/dist/provider-api/actions/provider-api.d.ts +7 -7
  258. package/dist/provider-api/corpus-jobs.d.ts +12 -2
  259. package/dist/provider-api/corpus-jobs.js +31 -1
  260. package/dist/provider-api/index.d.ts +2 -0
  261. package/dist/provider-api/index.js +7 -1
  262. package/dist/secrets/routes.d.ts +3 -3
  263. package/dist/server/agent-chat/recurring-jobs-runtime.d.ts +1 -1
  264. package/dist/server/agent-chat/recurring-jobs-runtime.js +14 -2
  265. package/dist/server/agent-chat/script-entries.js +12 -1
  266. package/dist/server/agent-chat-plugin.js +2 -2
  267. package/dist/server/agent-engine-api-key-route.d.ts +1 -1
  268. package/dist/server/auth.d.ts +1 -0
  269. package/dist/server/auth.js +85 -1
  270. package/dist/server/better-auth-instance.d.ts +9 -0
  271. package/dist/server/better-auth-instance.js +25 -11
  272. package/dist/server/core-routes-plugin.d.ts +7 -0
  273. package/dist/server/core-routes-plugin.js +51 -5
  274. package/dist/server/create-server.js +23 -2
  275. package/dist/server/db-pressure.d.ts +38 -0
  276. package/dist/server/db-pressure.js +147 -0
  277. package/dist/server/index.d.ts +1 -0
  278. package/dist/server/index.js +1 -0
  279. package/dist/server/legacy-auth-migration.d.ts +10 -0
  280. package/dist/server/legacy-auth-migration.js +37 -0
  281. package/dist/server/onboarding-html.js +206 -2
  282. package/dist/server/poll.d.ts +26 -0
  283. package/dist/server/poll.js +108 -13
  284. package/dist/server/ssr-handler.js +4 -1
  285. package/dist/server/transcribe-voice.d.ts +1 -1
  286. package/dist/shared/index.d.ts +1 -0
  287. package/dist/shared/index.js +1 -0
  288. package/dist/shared/runtime-config.d.ts +44 -0
  289. package/dist/shared/runtime-config.js +284 -0
  290. package/dist/styles/agent-native.css +48 -1
  291. package/dist/templates/chat/.agents/skills/actions/SKILL.md +18 -0
  292. package/dist/templates/chat/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
  293. package/dist/templates/chat/.agents/skills/delegate-to-agent/SKILL.md +45 -47
  294. package/dist/templates/chat/.agents/skills/frontend-design/SKILL.md +1 -0
  295. package/dist/templates/chat/.agents/skills/turn-into-app/SKILL.md +76 -23
  296. package/dist/templates/chat/.agents/skills/turn-into-app/agents/openai.yaml +2 -2
  297. package/dist/templates/chat/.agents/skills/turn-into-app/references/fresh-project.md +64 -0
  298. package/dist/templates/chat/.env.example +3 -0
  299. package/dist/templates/chat/AGENTS.md +4 -0
  300. package/dist/templates/default/.agents/skills/actions/SKILL.md +18 -0
  301. package/dist/templates/default/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
  302. package/dist/templates/default/.agents/skills/delegate-to-agent/SKILL.md +45 -47
  303. package/dist/templates/default/.agents/skills/frontend-design/SKILL.md +1 -0
  304. package/dist/templates/default/.agents/skills/turn-into-app/SKILL.md +76 -23
  305. package/dist/templates/default/.agents/skills/turn-into-app/agents/openai.yaml +2 -2
  306. package/dist/templates/default/.agents/skills/turn-into-app/references/fresh-project.md +64 -0
  307. package/dist/templates/default/AGENTS.md +6 -1
  308. package/dist/templates/default/app/i18n/ar-SA.ts +6 -0
  309. package/dist/templates/default/app/i18n/de-DE.ts +6 -0
  310. package/dist/templates/default/app/i18n/en-US.ts +6 -0
  311. package/dist/templates/default/app/i18n/es-ES.ts +6 -0
  312. package/dist/templates/default/app/i18n/fr-FR.ts +6 -0
  313. package/dist/templates/default/app/i18n/hi-IN.ts +6 -0
  314. package/dist/templates/default/app/i18n/ja-JP.ts +6 -0
  315. package/dist/templates/default/app/i18n/ko-KR.ts +6 -0
  316. package/dist/templates/default/app/i18n/pt-BR.ts +6 -0
  317. package/dist/templates/default/app/i18n/zh-CN.ts +6 -0
  318. package/dist/templates/default/app/i18n/zh-TW.ts +6 -0
  319. package/dist/templates/headless/.agents/skills/actions/SKILL.md +18 -0
  320. package/dist/templates/headless/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
  321. package/dist/templates/headless/.agents/skills/turn-into-app/SKILL.md +76 -23
  322. package/dist/templates/headless/.agents/skills/turn-into-app/agents/openai.yaml +2 -2
  323. package/dist/templates/headless/.agents/skills/turn-into-app/references/fresh-project.md +64 -0
  324. package/dist/templates/workspace-core/.agents/skills/actions/SKILL.md +18 -0
  325. package/dist/templates/workspace-core/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
  326. package/dist/templates/workspace-core/.agents/skills/delegate-to-agent/SKILL.md +45 -47
  327. package/dist/templates/workspace-core/.agents/skills/frontend-design/SKILL.md +1 -0
  328. package/dist/templates/workspace-core/.agents/skills/turn-into-app/SKILL.md +76 -23
  329. package/dist/templates/workspace-core/.agents/skills/turn-into-app/agents/openai.yaml +2 -2
  330. package/dist/templates/workspace-core/.agents/skills/turn-into-app/references/fresh-project.md +64 -0
  331. package/dist/templates/workspace-core/.agents/skills/workspace-conventions/SKILL.md +4 -0
  332. package/dist/templates/workspace-core/.agents/skills/writing-agent-instructions/SKILL.md +8 -0
  333. package/dist/templates/workspace-core/AGENTS.md +7 -2
  334. package/dist/templates/workspace-root/AGENTS.md +5 -0
  335. package/dist/vite/client.d.ts +3 -3
  336. package/dist/vite/client.js +47 -1
  337. package/dist/vite/index.d.ts +1 -1
  338. package/docs/content/agent-native-config.mdx +240 -139
  339. package/docs/content/authentication.mdx +17 -0
  340. package/docs/content/deployment.mdx +19 -14
  341. package/docs/content/drop-in-agent.mdx +19 -2
  342. package/docs/content/environment-variables.mdx +63 -38
  343. package/docs/content/getting-started-actions.mdx +15 -6
  344. package/docs/content/getting-started-database.mdx +14 -10
  345. package/docs/content/getting-started-pages.mdx +32 -35
  346. package/docs/content/getting-started.mdx +7 -6
  347. package/package.json +1 -1
  348. package/src/templates/chat/.agents/skills/actions/SKILL.md +18 -0
  349. package/src/templates/chat/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
  350. package/src/templates/chat/.agents/skills/delegate-to-agent/SKILL.md +45 -47
  351. package/src/templates/chat/.agents/skills/frontend-design/SKILL.md +1 -0
  352. package/src/templates/chat/.agents/skills/turn-into-app/SKILL.md +76 -23
  353. package/src/templates/chat/.agents/skills/turn-into-app/agents/openai.yaml +2 -2
  354. package/src/templates/chat/.agents/skills/turn-into-app/references/fresh-project.md +64 -0
  355. package/src/templates/chat/.env.example +3 -0
  356. package/src/templates/chat/AGENTS.md +4 -0
  357. package/src/templates/default/.agents/skills/actions/SKILL.md +18 -0
  358. package/src/templates/default/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
  359. package/src/templates/default/.agents/skills/delegate-to-agent/SKILL.md +45 -47
  360. package/src/templates/default/.agents/skills/frontend-design/SKILL.md +1 -0
  361. package/src/templates/default/.agents/skills/turn-into-app/SKILL.md +76 -23
  362. package/src/templates/default/.agents/skills/turn-into-app/agents/openai.yaml +2 -2
  363. package/src/templates/default/.agents/skills/turn-into-app/references/fresh-project.md +64 -0
  364. package/src/templates/default/AGENTS.md +6 -1
  365. package/src/templates/default/app/i18n/ar-SA.ts +6 -0
  366. package/src/templates/default/app/i18n/de-DE.ts +6 -0
  367. package/src/templates/default/app/i18n/en-US.ts +6 -0
  368. package/src/templates/default/app/i18n/es-ES.ts +6 -0
  369. package/src/templates/default/app/i18n/fr-FR.ts +6 -0
  370. package/src/templates/default/app/i18n/hi-IN.ts +6 -0
  371. package/src/templates/default/app/i18n/ja-JP.ts +6 -0
  372. package/src/templates/default/app/i18n/ko-KR.ts +6 -0
  373. package/src/templates/default/app/i18n/pt-BR.ts +6 -0
  374. package/src/templates/default/app/i18n/zh-CN.ts +6 -0
  375. package/src/templates/default/app/i18n/zh-TW.ts +6 -0
  376. package/src/templates/headless/.agents/skills/actions/SKILL.md +18 -0
  377. package/src/templates/headless/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
  378. package/src/templates/headless/.agents/skills/turn-into-app/SKILL.md +76 -23
  379. package/src/templates/headless/.agents/skills/turn-into-app/agents/openai.yaml +2 -2
  380. package/src/templates/headless/.agents/skills/turn-into-app/references/fresh-project.md +64 -0
  381. package/src/templates/workspace-core/.agents/skills/actions/SKILL.md +18 -0
  382. package/src/templates/workspace-core/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
  383. package/src/templates/workspace-core/.agents/skills/delegate-to-agent/SKILL.md +45 -47
  384. package/src/templates/workspace-core/.agents/skills/frontend-design/SKILL.md +1 -0
  385. package/src/templates/workspace-core/.agents/skills/turn-into-app/SKILL.md +76 -23
  386. package/src/templates/workspace-core/.agents/skills/turn-into-app/agents/openai.yaml +2 -2
  387. package/src/templates/workspace-core/.agents/skills/turn-into-app/references/fresh-project.md +64 -0
  388. package/src/templates/workspace-core/.agents/skills/workspace-conventions/SKILL.md +4 -0
  389. package/src/templates/workspace-core/.agents/skills/writing-agent-instructions/SKILL.md +8 -0
  390. package/src/templates/workspace-core/AGENTS.md +7 -2
  391. package/src/templates/workspace-root/AGENTS.md +5 -0
  392. package/corpus/templates/dispatch/app/routes/admin.apps.$appId.tsx +0 -1
  393. package/corpus/templates/dispatch/app/routes/admin.apps.tsx +0 -1
@@ -27,6 +27,7 @@ import { EMPTY_SPECULATION_RULES, resolveSsrCacheHeaders, } from "../shared/cach
27
27
  import { EMBED_TARGET_HEADER } from "../shared/embed-auth.js";
28
28
  import { llmConnectionTrackingProperties } from "../shared/llm-connection.js";
29
29
  import { EMBED_TRANSPLANT_HEADER, isMcpEmbedCorsOrigin, MCP_EMBED_CORS_ALLOW_HEADERS, shouldAllowMcpEmbedCredentials, } from "../shared/mcp-embed-headers.js";
30
+ import { getRuntimeConfigReport } from "../shared/runtime-config.js";
30
31
  import { captureException } from "../tracking/error-capture.js";
31
32
  import { track } from "../tracking/index.js";
32
33
  import { registerBuiltinProviders } from "../tracking/providers.js";
@@ -41,6 +42,7 @@ import { BUILDER_CONNECT_PARAM, BUILDER_CONNECT_OWNER_COOKIE, BUILDER_ENV_KEYS,
41
42
  import { captureError, registerErrorCaptureProvider } from "./capture-error.js";
42
43
  import { getAllowedCorsOrigin, readCorsAllowedOrigins, } from "./cors-origins.js";
43
44
  import { canUseDeployCredentialFallbackForRequest, prefetchSecrets, readDeployCredentialEnv, resolveSecret, } from "./credential-provider.js";
45
+ import { probeDbPressure } from "./db-pressure.js";
44
46
  import { resolveDeployEnvironment, resolveServerRelease, } from "./deploy-environment.js";
45
47
  import { createEmbedStartRouteHandler } from "./embed-route.js";
46
48
  import { shouldReportError } from "./error-noise-filter.js";
@@ -264,6 +266,7 @@ const DB_HEALTH_PROBE_DEADLINE_MS = 5_000;
264
266
  export async function runDbHealthProbe(exec = getDbExec, options = {}) {
265
267
  const startedAt = Date.now();
266
268
  let db = false;
269
+ let trivialQueryMs;
267
270
  let schema;
268
271
  const dbExec = exec();
269
272
  let dbTimedOut = false;
@@ -278,8 +281,10 @@ export async function runDbHealthProbe(exec = getDbExec, options = {}) {
278
281
  timer = setTimeout(() => reject(new Error("db probe deadline")), DB_HEALTH_PROBE_DEADLINE_MS);
279
282
  });
280
283
  try {
284
+ const trivialQueryStartedAt = Date.now();
281
285
  await Promise.race([dbExec.execute("SELECT 1"), deadline]);
282
286
  db = true;
287
+ trivialQueryMs = Date.now() - trivialQueryStartedAt;
283
288
  }
284
289
  finally {
285
290
  if (timer)
@@ -296,6 +301,14 @@ export async function runDbHealthProbe(exec = getDbExec, options = {}) {
296
301
  });
297
302
  }
298
303
  const database = getDatabaseRuntimeFingerprint();
304
+ // Measured on the connection `SELECT 1` just warmed, so the number reflects
305
+ // the database's own load rather than a serverless cold start.
306
+ let pressure;
307
+ if (options.pressure) {
308
+ pressure = db
309
+ ? await probeDbPressure(dbExec, database.dialect, { trivialQueryMs })
310
+ : { measured: false, reason: "database unreachable" };
311
+ }
299
312
  return {
300
313
  ok: true,
301
314
  ready: db && (!schema || schema.ok),
@@ -312,6 +325,7 @@ export async function runDbHealthProbe(exec = getDbExec, options = {}) {
312
325
  netlifyDatabaseUrlConfigured: database.netlifyDatabaseUrlConfigured,
313
326
  },
314
327
  ...(schema ? { schema } : {}),
328
+ ...(pressure ? { pressure } : {}),
315
329
  };
316
330
  }
317
331
  const DEFAULT_BUILDER_WAITLIST_FORM_ID = "DYTHuM0jlV";
@@ -809,7 +823,7 @@ export async function readLegacyCoreRouteInitSettings(readSetting = getSetting)
809
823
  * Routes:
810
824
  * GET /_agent-native/poll — polling endpoint for change detection
811
825
  * GET /_agent-native/events (or custom) — SSE endpoint for real-time sync
812
- * GET /_agent-native/ping — health check
826
+ * GET /_agent-native/ping — health check; add ?configuration=1 for redacted deploy diagnostics
813
827
  * GET /_agent-native/health — DB liveness probe + scale-to-zero warmup
814
828
  * GET /_agent-native/env-status — env key configuration status (when envKeys provided)
815
829
  * POST /_agent-native/env-vars — compatibility route that saves keys to scoped DB secrets
@@ -1197,9 +1211,30 @@ export function createCoreRoutesPlugin(options = {}) {
1197
1211
  }
1198
1212
  // Ping
1199
1213
  if (!options.disablePing) {
1200
- getH3App(nitroApp).use(`${P}/ping`, defineEventHandler(() => ({
1201
- message: process.env.PING_MESSAGE ?? "pong",
1202
- })));
1214
+ getH3App(nitroApp).use(`${P}/ping`, defineEventHandler((event) => {
1215
+ const message = process.env.PING_MESSAGE ?? "pong";
1216
+ const configuration = event.url?.searchParams.get("configuration") === "1" ||
1217
+ event.url?.searchParams.get("configuration") === "true";
1218
+ if (!configuration)
1219
+ return { message };
1220
+ // Custom required keys must come from server-side app configuration;
1221
+ // never let an anonymous caller turn this into an env-name oracle.
1222
+ const requirements = {
1223
+ ...(event.url?.searchParams.get("auth") === "0"
1224
+ ? { authEnabled: false }
1225
+ : {}),
1226
+ ...(event.url?.searchParams.get("database") === "0"
1227
+ ? { databaseRequired: false }
1228
+ : {}),
1229
+ };
1230
+ return {
1231
+ message,
1232
+ configuration: getRuntimeConfigReport(process.env, requirements, {
1233
+ phase: "runtime",
1234
+ appName: process.env.APP_NAME,
1235
+ }),
1236
+ };
1237
+ }));
1203
1238
  }
1204
1239
  // ─── Durable sandbox execution processor ─────────────────────────
1205
1240
  // Self-fired by run-code's background queue (see
@@ -1294,7 +1329,18 @@ export function createCoreRoutesPlugin(options = {}) {
1294
1329
  const strict = event.url?.searchParams.get("strict") === "1" ||
1295
1330
  event.url?.searchParams.get("strict") === "true" ||
1296
1331
  process.env.AGENT_NATIVE_HEALTH_STRICT_SCHEMA === "true";
1297
- const result = await runDbHealthProbe(getDbExec, { schema });
1332
+ // Off by default: the one-minute warm cron does not need it, and
1333
+ // an extra `pg_stat_activity` read every minute per app is waste.
1334
+ // Pressure deliberately does NOT change `ready` or the status
1335
+ // code — a pressured database is still serving, and an uptime
1336
+ // monitor that pages on it would learn to ignore this route. The
1337
+ // fleet audit reads the counters and decides.
1338
+ const pressure = event.url?.searchParams.get("pressure") === "1" ||
1339
+ event.url?.searchParams.get("pressure") === "true";
1340
+ const result = await runDbHealthProbe(getDbExec, {
1341
+ schema,
1342
+ pressure,
1343
+ });
1298
1344
  if (strict && !result.ready)
1299
1345
  setResponseStatus(event, 503);
1300
1346
  return result;
@@ -3,6 +3,7 @@ import { getOrgContext } from "../org/context.js";
3
3
  import { readBody } from "../server/h3-helpers.js";
4
4
  import { EMBED_TARGET_HEADER } from "../shared/embed-auth.js";
5
5
  import { EMBED_TRANSPLANT_HEADER, isMcpEmbedCorsOrigin, MCP_EMBED_CORS_ALLOW_HEADERS, shouldAllowMcpEmbedCredentials, } from "../shared/mcp-embed-headers.js";
6
+ import { getRuntimeConfigReport } from "../shared/runtime-config.js";
6
7
  import { getSession } from "./auth.js";
7
8
  import { getAllowedCorsOrigin, readCorsAllowedOrigins, } from "./cors-origins.js";
8
9
  import { resolveSecret } from "./credential-provider.js";
@@ -107,9 +108,29 @@ export function createServer(options = {}) {
107
108
  const router = createRouter();
108
109
  // Health check
109
110
  if (!options.disablePing) {
110
- router.get("/_agent-native/ping", defineEventHandler(() => {
111
+ router.get("/_agent-native/ping", defineEventHandler((event) => {
111
112
  const message = options.pingMessage ?? process.env.PING_MESSAGE ?? "pong";
112
- return { message };
113
+ const configuration = event.url?.searchParams.get("configuration") === "1" ||
114
+ event.url?.searchParams.get("configuration") === "true";
115
+ if (!configuration)
116
+ return { message };
117
+ // Custom required keys must come from server-side app configuration;
118
+ // never let an anonymous caller turn this into an env-name oracle.
119
+ const requirements = {
120
+ ...(event.url?.searchParams.get("auth") === "0"
121
+ ? { authEnabled: false }
122
+ : {}),
123
+ ...(event.url?.searchParams.get("database") === "0"
124
+ ? { databaseRequired: false }
125
+ : {}),
126
+ };
127
+ return {
128
+ message,
129
+ configuration: getRuntimeConfigReport(process.env, requirements, {
130
+ phase: "runtime",
131
+ appName: process.env.APP_NAME,
132
+ }),
133
+ };
113
134
  }));
114
135
  }
115
136
  // Env key management routes
@@ -0,0 +1,38 @@
1
+ /** Counters taken in one shot from `pg_stat_activity`. */
2
+ export interface DbPressureCounters {
3
+ connections: number;
4
+ idleInTxn: number;
5
+ oldestIdleTxnS: number;
6
+ maxSameQuery: number;
7
+ /** Round-trip of this statement on an already-open connection. */
8
+ trivialQueryMs: number;
9
+ }
10
+ /**
11
+ * Measured counters, or an explicit reason they could not be taken.
12
+ *
13
+ * A monitor must never read "not measured" as "healthy", so the two are
14
+ * different shapes rather than an empty warning list.
15
+ */
16
+ export type DbPressure = ({
17
+ measured: true;
18
+ warnings: string[];
19
+ } & DbPressureCounters) | {
20
+ measured: false;
21
+ reason: string;
22
+ };
23
+ export declare const MAX_IDLE_TXN_AGE_S = 60;
24
+ export declare const MAX_TRIVIAL_QUERY_MS = 1000;
25
+ export declare const MAX_SAME_QUERY_CONCURRENCY = 10;
26
+ export declare const DB_PRESSURE_SQL = "\nSELECT\n count(*)::int AS connections,\n count(*) FILTER (WHERE state = 'idle in transaction')::int AS idle_in_txn,\n coalesce(round(max(extract(epoch from (now() - state_change)))\n FILTER (WHERE state = 'idle in transaction'))::int, 0) AS oldest_idle_txn_s,\n coalesce((\n SELECT max(c) FROM (\n SELECT count(*)::int AS c FROM pg_stat_activity\n WHERE pid <> pg_backend_pid()\n AND state = 'active'\n AND query <> ''\n GROUP BY left(query, 60)\n ) q\n ), 0)::int AS max_same_query\nFROM pg_stat_activity\nWHERE pid <> pg_backend_pid()";
27
+ /** Reasons this database looks pressured, or [] when it looks fine. */
28
+ export declare function dbPressureWarnings(p: DbPressureCounters): string[];
29
+ /**
30
+ * Read the pressure counters. Postgres-only: `pg_stat_activity` does not exist
31
+ * on SQLite/libSQL/D1, and a dialect that cannot answer reports `measured:
32
+ * false` rather than a clean-looking zero.
33
+ */
34
+ export declare function probeDbPressure(exec: {
35
+ execute: (sql: string) => Promise<unknown>;
36
+ }, dialect: string, options?: {
37
+ trivialQueryMs?: number;
38
+ }): Promise<DbPressure>;
@@ -0,0 +1,147 @@
1
+ // Database pressure — the three signals that precede an outage, measured from
2
+ // inside the app that owns the database.
3
+ //
4
+ // The analytics app degraded for hours on 2026-08-06 before it fell over, and
5
+ // every check we had said UP until the moment it said DOWN. What was actually
6
+ // true, and visible in `pg_stat_activity` the whole time:
7
+ //
8
+ // - 11-20 connections stuck `idle in transaction` up to 283s, left behind by
9
+ // serverless workers killed mid-transaction. They hold locks; nothing
10
+ // reaped them.
11
+ // - `SELECT 1` drifting from ~0.2s to 6s as those locks accumulated.
12
+ // - 47-56 concurrent copies of one unprojected query, each dragging a JSON
13
+ // blob per row.
14
+ //
15
+ // None of that is "down". All of it is the hour before down. A monitor that
16
+ // only distinguishes 200 from 500 cannot see any of it.
17
+ //
18
+ // This lives in core rather than in a workstation script because the numbers
19
+ // require a database credential, and the app already has its own. Reading them
20
+ // here means the scheduled fleet audit needs no production credentials at all.
21
+ // `scripts/chat-health.mjs` measures the same three signals locally against
22
+ // every app at once; `db-pressure.spec.ts` pins the two threshold sets equal.
23
+ // Thresholds set from that outage, not intuition. Healthy analytics reads
24
+ // 0 / 128ms / 1; at the point it went down it read 20 / 6000ms / 56.
25
+ export const MAX_IDLE_TXN_AGE_S = 60;
26
+ export const MAX_TRIVIAL_QUERY_MS = 1_000;
27
+ export const MAX_SAME_QUERY_CONCURRENCY = 10;
28
+ /**
29
+ * A hung probe must not hang the health route — that is the defect that took
30
+ * the docs site permanently cold. Short because this runs on a connection the
31
+ * liveness probe just proved is answering.
32
+ */
33
+ const PRESSURE_PROBE_DEADLINE_MS = 3_000;
34
+ export const DB_PRESSURE_SQL = `
35
+ SELECT
36
+ count(*)::int AS connections,
37
+ count(*) FILTER (WHERE state = 'idle in transaction')::int AS idle_in_txn,
38
+ coalesce(round(max(extract(epoch from (now() - state_change)))
39
+ FILTER (WHERE state = 'idle in transaction'))::int, 0) AS oldest_idle_txn_s,
40
+ coalesce((
41
+ SELECT max(c) FROM (
42
+ SELECT count(*)::int AS c FROM pg_stat_activity
43
+ WHERE pid <> pg_backend_pid()
44
+ AND state = 'active'
45
+ AND query <> ''
46
+ GROUP BY left(query, 60)
47
+ ) q
48
+ ), 0)::int AS max_same_query
49
+ FROM pg_stat_activity
50
+ WHERE pid <> pg_backend_pid()`;
51
+ /** Reasons this database looks pressured, or [] when it looks fine. */
52
+ export function dbPressureWarnings(p) {
53
+ const out = [];
54
+ if (p.idleInTxn > 0 && p.oldestIdleTxnS > MAX_IDLE_TXN_AGE_S) {
55
+ out.push(`${p.idleInTxn} idle-in-transaction (oldest ${p.oldestIdleTxnS}s) — workers killed mid-transaction still holding locks`);
56
+ }
57
+ if (p.trivialQueryMs > MAX_TRIVIAL_QUERY_MS) {
58
+ out.push(`trivial query took ${p.trivialQueryMs}ms — the database itself is slow, not the app`);
59
+ }
60
+ if (p.maxSameQuery >= MAX_SAME_QUERY_CONCURRENCY) {
61
+ out.push(`${p.maxSameQuery} concurrent copies of one query — a hot path is stampeding`);
62
+ }
63
+ return out;
64
+ }
65
+ function readCount(row, key) {
66
+ const value = row[key];
67
+ if (typeof value === "number" && Number.isFinite(value))
68
+ return value;
69
+ // Some drivers hand back bigint-ish columns as strings.
70
+ if (typeof value === "string" && value.trim() !== "") {
71
+ const parsed = Number(value);
72
+ if (Number.isFinite(parsed))
73
+ return parsed;
74
+ }
75
+ return null;
76
+ }
77
+ /**
78
+ * Read the pressure counters. Postgres-only: `pg_stat_activity` does not exist
79
+ * on SQLite/libSQL/D1, and a dialect that cannot answer reports `measured:
80
+ * false` rather than a clean-looking zero.
81
+ */
82
+ export async function probeDbPressure(exec, dialect, options = {}) {
83
+ if (dialect !== "postgres") {
84
+ return {
85
+ measured: false,
86
+ reason: `dialect ${dialect} has no pg_stat_activity`,
87
+ };
88
+ }
89
+ let timer;
90
+ try {
91
+ const trivialQueryMs = options.trivialQueryMs ?? (await measureTrivialQuery(exec));
92
+ const deadline = new Promise((_, reject) => {
93
+ timer = setTimeout(() => reject(new Error("pressure probe deadline")), PRESSURE_PROBE_DEADLINE_MS);
94
+ });
95
+ const result = (await Promise.race([
96
+ exec.execute(DB_PRESSURE_SQL),
97
+ deadline,
98
+ ]));
99
+ const row = result?.rows?.[0];
100
+ if (!row) {
101
+ return { measured: false, reason: "pressure query returned no rows" };
102
+ }
103
+ const counters = {
104
+ connections: readCount(row, "connections") ?? -1,
105
+ idleInTxn: readCount(row, "idle_in_txn") ?? -1,
106
+ oldestIdleTxnS: readCount(row, "oldest_idle_txn_s") ?? -1,
107
+ maxSameQuery: readCount(row, "max_same_query") ?? -1,
108
+ trivialQueryMs,
109
+ };
110
+ if (Object.values(counters).some((n) => n < 0)) {
111
+ return {
112
+ measured: false,
113
+ reason: "pressure query returned unreadable counters",
114
+ };
115
+ }
116
+ return {
117
+ measured: true,
118
+ ...counters,
119
+ warnings: dbPressureWarnings(counters),
120
+ };
121
+ }
122
+ catch (err) {
123
+ return {
124
+ measured: false,
125
+ reason: err instanceof Error ? err.message : String(err),
126
+ };
127
+ }
128
+ finally {
129
+ if (timer)
130
+ clearTimeout(timer);
131
+ }
132
+ }
133
+ async function measureTrivialQuery(exec) {
134
+ let timer;
135
+ const startedAt = Date.now();
136
+ try {
137
+ const deadline = new Promise((_, reject) => {
138
+ timer = setTimeout(() => reject(new Error("trivial query deadline")), PRESSURE_PROBE_DEADLINE_MS);
139
+ });
140
+ await Promise.race([exec.execute("SELECT 1"), deadline]);
141
+ return Date.now() - startedAt;
142
+ }
143
+ finally {
144
+ if (timer)
145
+ clearTimeout(timer);
146
+ }
147
+ }
@@ -37,6 +37,7 @@ export { configureAgentNativeEmbeddedEnvironment, createAgentNativeEmbeddedAuthO
37
37
  export { createThread, getThread, listThreads, updateThreadData, deleteThread, setThreadArchived, setThreadPinned, setThreadScope, type ChatThread, type ChatThreadScope, type ChatThreadSummary, type ListThreadsOptions, } from "../chat-threads/store.js";
38
38
  export { createResourcesPlugin, defaultResourcesPlugin, } from "./resources-plugin.js";
39
39
  export { createCoreRoutesPlugin, defaultCoreRoutesPlugin, FRAMEWORK_ROUTE_PREFIX, type CoreRoutesPluginOptions, } from "./core-routes-plugin.js";
40
+ export { buildRuntimeConfigPrompt, formatRuntimeConfigReport, getRuntimeConfigReport, parseRuntimeConfigReport, runtimeConfigRequirementsFromSearchParams, type RuntimeConfigEnvironment, type RuntimeConfigIssue, type RuntimeConfigIssueCode, type RuntimeConfigIssueSeverity, type RuntimeConfigPhase, type RuntimeConfigReport, type RuntimeConfigRequirements, } from "../shared/runtime-config.js";
40
41
  export { AGENT_NATIVE_OG_IMAGE_CACHE_CONTROL, AGENT_NATIVE_OG_IMAGE_HEIGHT, AGENT_NATIVE_OG_IMAGE_NETLIFY_CACHE_CONTROL, AGENT_NATIVE_OG_IMAGE_WIDTH, agentNativeOgImageResponseHeaders, createAgentNativeOgImageHandler, renderAgentNativeOgImagePng, renderAgentNativeOgImageSvg, type AgentNativeOgImageInput, } from "./social-og-image.js";
41
42
  export { OG_FONT_FAMILY, resolveOgFontFiles } from "./og-fonts.js";
42
43
  export { createBrowserSessionActionEntries, type CreateBrowserSessionActionEntriesOptions, } from "../browser-sessions/actions.js";
@@ -38,6 +38,7 @@ export { configureAgentNativeEmbeddedEnvironment, createAgentNativeEmbeddedAuthO
38
38
  export { createThread, getThread, listThreads, updateThreadData, deleteThread, setThreadArchived, setThreadPinned, setThreadScope, } from "../chat-threads/store.js";
39
39
  export { createResourcesPlugin, defaultResourcesPlugin, } from "./resources-plugin.js";
40
40
  export { createCoreRoutesPlugin, defaultCoreRoutesPlugin, FRAMEWORK_ROUTE_PREFIX, } from "./core-routes-plugin.js";
41
+ export { buildRuntimeConfigPrompt, formatRuntimeConfigReport, getRuntimeConfigReport, parseRuntimeConfigReport, runtimeConfigRequirementsFromSearchParams, } from "../shared/runtime-config.js";
41
42
  export { AGENT_NATIVE_OG_IMAGE_CACHE_CONTROL, AGENT_NATIVE_OG_IMAGE_HEIGHT, AGENT_NATIVE_OG_IMAGE_NETLIFY_CACHE_CONTROL, AGENT_NATIVE_OG_IMAGE_WIDTH, agentNativeOgImageResponseHeaders, createAgentNativeOgImageHandler, renderAgentNativeOgImagePng, renderAgentNativeOgImageSvg, } from "./social-og-image.js";
42
43
  export { OG_FONT_FAMILY, resolveOgFontFiles } from "./og-fonts.js";
43
44
  export { createBrowserSessionActionEntries, } from "../browser-sessions/actions.js";
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Backfill the canonical Better Auth user for a verified legacy session.
3
+ *
4
+ * Older OAuth sessions were keyed by email in the framework `sessions` table
5
+ * before every deployment required a Better Auth `user` row. Keep the legacy
6
+ * session as the authentication proof, and use Better Auth's adapter only to
7
+ * create the missing canonical user. Do not invent a provider account: the
8
+ * next provider sign-in owns that link.
9
+ */
10
+ export declare function ensureCanonicalUserForLegacySession(email: string): Promise<boolean>;
@@ -0,0 +1,37 @@
1
+ import { getBetterAuthInternalAdapter } from "./better-auth-instance.js";
2
+ /**
3
+ * Backfill the canonical Better Auth user for a verified legacy session.
4
+ *
5
+ * Older OAuth sessions were keyed by email in the framework `sessions` table
6
+ * before every deployment required a Better Auth `user` row. Keep the legacy
7
+ * session as the authentication proof, and use Better Auth's adapter only to
8
+ * create the missing canonical user. Do not invent a provider account: the
9
+ * next provider sign-in owns that link.
10
+ */
11
+ export async function ensureCanonicalUserForLegacySession(email) {
12
+ const normalizedEmail = email.trim().toLowerCase();
13
+ if (!normalizedEmail || !normalizedEmail.includes("@"))
14
+ return false;
15
+ const adapter = await getBetterAuthInternalAdapter();
16
+ if (!adapter) {
17
+ throw new Error("Better Auth internal adapter is unavailable");
18
+ }
19
+ const findExisting = () => adapter.findUserByEmail(normalizedEmail, { includeAccounts: false });
20
+ if (await findExisting())
21
+ return false;
22
+ try {
23
+ await adapter.createUser({
24
+ email: normalizedEmail,
25
+ name: normalizedEmail.split("@")[0] || "User",
26
+ emailVerified: true,
27
+ });
28
+ return true;
29
+ }
30
+ catch (error) {
31
+ // A concurrent request may have created the same canonical user. Treat
32
+ // that race as success only after the adapter can read the winner.
33
+ if (await findExisting())
34
+ return false;
35
+ throw error;
36
+ }
37
+ }