@agent-native/core 0.109.2 → 0.109.4

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 (334) hide show
  1. package/corpus/README.md +2 -2
  2. package/corpus/core/CHANGELOG.md +16 -0
  3. package/corpus/core/docs/content/agent-native-toolkit.mdx +46 -13
  4. package/corpus/core/docs/content/locales/ar-SA/agent-native-toolkit.mdx +79 -55
  5. package/corpus/core/docs/content/locales/ar-SA/toolkit-capability-packages.mdx +21 -0
  6. package/corpus/core/docs/content/locales/ar-SA/toolkit-context-knowledge.mdx +12 -0
  7. package/corpus/core/docs/content/locales/ar-SA/toolkit-editors-canvases.mdx +17 -0
  8. package/corpus/core/docs/content/locales/de-DE/agent-native-toolkit.mdx +82 -54
  9. package/corpus/core/docs/content/locales/de-DE/toolkit-capability-packages.mdx +21 -0
  10. package/corpus/core/docs/content/locales/de-DE/toolkit-context-knowledge.mdx +12 -0
  11. package/corpus/core/docs/content/locales/de-DE/toolkit-editors-canvases.mdx +17 -0
  12. package/corpus/core/docs/content/locales/es-ES/agent-native-toolkit.mdx +81 -52
  13. package/corpus/core/docs/content/locales/es-ES/toolkit-capability-packages.mdx +21 -0
  14. package/corpus/core/docs/content/locales/es-ES/toolkit-context-knowledge.mdx +12 -0
  15. package/corpus/core/docs/content/locales/es-ES/toolkit-editors-canvases.mdx +21 -0
  16. package/corpus/core/docs/content/locales/fr-FR/agent-native-toolkit.mdx +84 -54
  17. package/corpus/core/docs/content/locales/fr-FR/toolkit-capability-packages.mdx +21 -0
  18. package/corpus/core/docs/content/locales/fr-FR/toolkit-context-knowledge.mdx +12 -0
  19. package/corpus/core/docs/content/locales/fr-FR/toolkit-editors-canvases.mdx +21 -0
  20. package/corpus/core/docs/content/locales/hi-IN/agent-native-toolkit.mdx +69 -62
  21. package/corpus/core/docs/content/locales/hi-IN/toolkit-capability-packages.mdx +21 -0
  22. package/corpus/core/docs/content/locales/hi-IN/toolkit-context-knowledge.mdx +12 -0
  23. package/corpus/core/docs/content/locales/hi-IN/toolkit-editors-canvases.mdx +17 -0
  24. package/corpus/core/docs/content/locales/ja-JP/agent-native-toolkit.mdx +69 -62
  25. package/corpus/core/docs/content/locales/ja-JP/toolkit-capability-packages.mdx +21 -0
  26. package/corpus/core/docs/content/locales/ja-JP/toolkit-context-knowledge.mdx +12 -0
  27. package/corpus/core/docs/content/locales/ja-JP/toolkit-editors-canvases.mdx +17 -0
  28. package/corpus/core/docs/content/locales/ko-KR/agent-native-toolkit.mdx +69 -62
  29. package/corpus/core/docs/content/locales/ko-KR/toolkit-capability-packages.mdx +21 -0
  30. package/corpus/core/docs/content/locales/ko-KR/toolkit-context-knowledge.mdx +12 -0
  31. package/corpus/core/docs/content/locales/ko-KR/toolkit-editors-canvases.mdx +17 -0
  32. package/corpus/core/docs/content/locales/pt-BR/agent-native-toolkit.mdx +82 -54
  33. package/corpus/core/docs/content/locales/pt-BR/toolkit-capability-packages.mdx +21 -0
  34. package/corpus/core/docs/content/locales/pt-BR/toolkit-context-knowledge.mdx +12 -0
  35. package/corpus/core/docs/content/locales/pt-BR/toolkit-editors-canvases.mdx +17 -0
  36. package/corpus/core/docs/content/locales/zh-CN/agent-native-toolkit.mdx +69 -62
  37. package/corpus/core/docs/content/locales/zh-CN/toolkit-capability-packages.mdx +21 -0
  38. package/corpus/core/docs/content/locales/zh-CN/toolkit-context-knowledge.mdx +12 -0
  39. package/corpus/core/docs/content/locales/zh-CN/toolkit-editors-canvases.mdx +17 -0
  40. package/corpus/core/docs/content/locales/zh-TW/agent-native-toolkit.mdx +69 -62
  41. package/corpus/core/docs/content/locales/zh-TW/toolkit-capability-packages.mdx +21 -0
  42. package/corpus/core/docs/content/locales/zh-TW/toolkit-context-knowledge.mdx +12 -0
  43. package/corpus/core/docs/content/locales/zh-TW/toolkit-editors-canvases.mdx +17 -0
  44. package/corpus/core/docs/content/toolkit-capability-packages.mdx +52 -0
  45. package/corpus/core/docs/content/toolkit-context-knowledge.mdx +46 -0
  46. package/corpus/core/docs/content/toolkit-editors-canvases.mdx +55 -0
  47. package/corpus/core/package.json +35 -34
  48. package/corpus/core/src/cli/create.ts +57 -15
  49. package/corpus/core/src/cli/package-lifecycle.ts +2 -0
  50. package/corpus/core/src/cli/skills-content/visual-plan-skill.ts +2 -0
  51. package/corpus/core/src/client/context-xray/ContextMeter.tsx +31 -111
  52. package/corpus/core/src/client/context-xray/ContextSegmentRow.tsx +8 -111
  53. package/corpus/core/src/client/context-xray/ContextTreemap.tsx +6 -111
  54. package/corpus/core/src/client/context-xray/ContextXRayPanel.tsx +31 -391
  55. package/corpus/core/src/client/context-xray/SegmentProvenancePopover.tsx +4 -52
  56. package/corpus/core/src/client/context-xray/format.ts +0 -33
  57. package/corpus/core/src/client/require-session.tsx +19 -3
  58. package/corpus/core/src/client/rich-markdown-editor/index.ts +42 -57
  59. package/corpus/core/src/client/rich-markdown-editor/uploadEditorImage.ts +2 -1
  60. package/corpus/core/src/client/use-action.ts +145 -2
  61. package/corpus/core/src/client/use-session.ts +79 -48
  62. package/corpus/core/src/client/visual-style-controls.tsx +1 -1088
  63. package/corpus/core/src/collab/agent-identity.ts +5 -22
  64. package/corpus/core/src/collab/client.ts +1 -53
  65. package/corpus/core/src/db/client.ts +13 -7
  66. package/corpus/core/src/db/create-get-db.ts +20 -13
  67. package/corpus/core/src/db/request-telemetry.ts +154 -0
  68. package/corpus/core/src/integrations/index.ts +1 -0
  69. package/corpus/core/src/integrations/plugin.ts +9 -3
  70. package/corpus/core/src/integrations/remote-push-delivery-job.ts +48 -0
  71. package/corpus/core/src/integrations/remote-push-delivery.ts +370 -0
  72. package/corpus/core/src/integrations/remote-push-store.ts +275 -26
  73. package/corpus/core/src/server/better-auth-instance.ts +11 -3
  74. package/corpus/core/src/server/core-routes-plugin.ts +36 -14
  75. package/corpus/core/src/server/framework-request-handler.ts +11 -1
  76. package/corpus/core/src/server/http-response-telemetry.ts +233 -31
  77. package/corpus/core/src/styles/rich-markdown-editor.css +1 -510
  78. package/corpus/core/src/templates/workspace-core/.agents/skills/tracking/SKILL.md +19 -0
  79. package/corpus/core/src/testing.ts +1 -1
  80. package/corpus/core/src/vite/client.ts +3 -0
  81. package/corpus/templates/clips/actions/finalize-recording.ts +3 -1
  82. package/corpus/templates/clips/actions/set-mobile-capture-state.ts +4 -1
  83. package/corpus/templates/clips/app/components/library/library-layout.tsx +1 -6
  84. package/corpus/templates/clips/changelog/2026-07-18-new-recording-is-now-emphasized-as-the-primary-action-in-the.md +6 -0
  85. package/corpus/templates/clips/changelog/2026-07-18-recordings-now-remain-safely-recoverable-until-the-stored-me.md +6 -0
  86. package/corpus/templates/content/app/components/editor/VisualEditor.tsx +5 -3
  87. package/corpus/templates/content/app/components/editor/extensions/DragHandle.tsx +4 -4
  88. package/corpus/templates/content/package.json +25 -25
  89. package/corpus/templates/design/app/components/design/TweaksPanel.tsx +2 -1
  90. package/corpus/templates/design/package.json +1 -1
  91. package/corpus/templates/mail/package.json +9 -9
  92. package/corpus/templates/plan/.agents/skills/visual-plan/SKILL.md +2 -0
  93. package/corpus/templates/plan/app/components/editor/PlanDocumentEditor.tsx +8 -8
  94. package/corpus/templates/plan/app/components/editor/planSlashCommands.ts +6 -6
  95. package/corpus/templates/plan/app/components/plan/PlanImageNode.tsx +4 -7
  96. package/corpus/templates/plan/app/components/plan/PlanMarkdownEditor.tsx +6 -4
  97. package/corpus/templates/plan/app/components/plan/PlanVisualSurface.tsx +1 -1
  98. package/corpus/templates/plan/changelog/2026-07-18-visual-plans-now-open-on-wireframes-by-default-when-a-protot.md +6 -0
  99. package/corpus/templates/plan/package.json +3 -3
  100. package/corpus/templates/slides/app/components/editor/SlideStyleInspector.tsx +2 -2
  101. package/corpus/templates/slides/app/components/editor/TweaksPanel.tsx +2 -2
  102. package/corpus/templates/slides/package.json +13 -13
  103. package/corpus/templates/tasks/AGENTS.md +3 -0
  104. package/corpus/templates/tasks/actions/render-task-list-inline.ts +202 -0
  105. package/corpus/templates/tasks/changelog/2026-07-18-task-lists-can-now-appear-as-interactive-widgets-inline-in-c.md +6 -0
  106. package/corpus/templates/tasks/docs/features/f8-chat.mdx +2 -0
  107. package/corpus/templates/tasks/server/plugins/agent-chat.ts +2 -0
  108. package/dist/catalog.json +39 -1
  109. package/dist/cli/create.d.ts +10 -1
  110. package/dist/cli/create.d.ts.map +1 -1
  111. package/dist/cli/create.js +49 -16
  112. package/dist/cli/create.js.map +1 -1
  113. package/dist/cli/package-lifecycle.d.ts.map +1 -1
  114. package/dist/cli/package-lifecycle.js +2 -0
  115. package/dist/cli/package-lifecycle.js.map +1 -1
  116. package/dist/cli/skills-content/visual-plan-skill.d.ts +1 -1
  117. package/dist/cli/skills-content/visual-plan-skill.d.ts.map +1 -1
  118. package/dist/cli/skills-content/visual-plan-skill.js +2 -0
  119. package/dist/cli/skills-content/visual-plan-skill.js.map +1 -1
  120. package/dist/client/context-xray/ContextMeter.d.ts.map +1 -1
  121. package/dist/client/context-xray/ContextMeter.js +8 -23
  122. package/dist/client/context-xray/ContextMeter.js.map +1 -1
  123. package/dist/client/context-xray/ContextSegmentRow.d.ts.map +1 -1
  124. package/dist/client/context-xray/ContextSegmentRow.js +3 -19
  125. package/dist/client/context-xray/ContextSegmentRow.js.map +1 -1
  126. package/dist/client/context-xray/ContextTreemap.d.ts.map +1 -1
  127. package/dist/client/context-xray/ContextTreemap.js +3 -54
  128. package/dist/client/context-xray/ContextTreemap.js.map +1 -1
  129. package/dist/client/context-xray/ContextXRayPanel.d.ts.map +1 -1
  130. package/dist/client/context-xray/ContextXRayPanel.js +21 -163
  131. package/dist/client/context-xray/ContextXRayPanel.js.map +1 -1
  132. package/dist/client/context-xray/SegmentProvenancePopover.d.ts.map +1 -1
  133. package/dist/client/context-xray/SegmentProvenancePopover.js +3 -4
  134. package/dist/client/context-xray/SegmentProvenancePopover.js.map +1 -1
  135. package/dist/client/context-xray/format.d.ts +0 -4
  136. package/dist/client/context-xray/format.d.ts.map +1 -1
  137. package/dist/client/context-xray/format.js +0 -49
  138. package/dist/client/context-xray/format.js.map +1 -1
  139. package/dist/client/require-session.d.ts.map +1 -1
  140. package/dist/client/require-session.js +6 -3
  141. package/dist/client/require-session.js.map +1 -1
  142. package/dist/client/rich-markdown-editor/index.d.ts +1 -12
  143. package/dist/client/rich-markdown-editor/index.d.ts.map +1 -1
  144. package/dist/client/rich-markdown-editor/index.js +1 -12
  145. package/dist/client/rich-markdown-editor/index.js.map +1 -1
  146. package/dist/client/rich-markdown-editor/uploadEditorImage.d.ts +1 -1
  147. package/dist/client/rich-markdown-editor/uploadEditorImage.d.ts.map +1 -1
  148. package/dist/client/rich-markdown-editor/uploadEditorImage.js.map +1 -1
  149. package/dist/client/use-action.d.ts.map +1 -1
  150. package/dist/client/use-action.js +117 -1
  151. package/dist/client/use-action.js.map +1 -1
  152. package/dist/client/use-session.d.ts.map +1 -1
  153. package/dist/client/use-session.js +72 -50
  154. package/dist/client/use-session.js.map +1 -1
  155. package/dist/client/visual-style-controls.d.ts +1 -89
  156. package/dist/client/visual-style-controls.d.ts.map +1 -1
  157. package/dist/client/visual-style-controls.js +1 -498
  158. package/dist/client/visual-style-controls.js.map +1 -1
  159. package/dist/collab/agent-identity.d.ts +1 -14
  160. package/dist/collab/agent-identity.d.ts.map +1 -1
  161. package/dist/collab/agent-identity.js +1 -13
  162. package/dist/collab/agent-identity.js.map +1 -1
  163. package/dist/collab/awareness.d.ts +2 -2
  164. package/dist/collab/awareness.d.ts.map +1 -1
  165. package/dist/collab/client.d.ts +1 -19
  166. package/dist/collab/client.d.ts.map +1 -1
  167. package/dist/collab/client.js +1 -53
  168. package/dist/collab/client.js.map +1 -1
  169. package/dist/collab/struct-routes.d.ts +1 -1
  170. package/dist/db/client.d.ts.map +1 -1
  171. package/dist/db/client.js +7 -1
  172. package/dist/db/client.js.map +1 -1
  173. package/dist/db/create-get-db.d.ts +3 -6
  174. package/dist/db/create-get-db.d.ts.map +1 -1
  175. package/dist/db/create-get-db.js +9 -2
  176. package/dist/db/create-get-db.js.map +1 -1
  177. package/dist/db/request-telemetry.d.ts +23 -0
  178. package/dist/db/request-telemetry.d.ts.map +1 -0
  179. package/dist/db/request-telemetry.js +95 -0
  180. package/dist/db/request-telemetry.js.map +1 -0
  181. package/dist/integrations/index.d.ts +1 -0
  182. package/dist/integrations/index.d.ts.map +1 -1
  183. package/dist/integrations/index.js +1 -0
  184. package/dist/integrations/index.js.map +1 -1
  185. package/dist/integrations/plugin.d.ts.map +1 -1
  186. package/dist/integrations/plugin.js +8 -3
  187. package/dist/integrations/plugin.js.map +1 -1
  188. package/dist/integrations/remote-push-delivery-job.d.ts +4 -0
  189. package/dist/integrations/remote-push-delivery-job.d.ts.map +1 -0
  190. package/dist/integrations/remote-push-delivery-job.js +44 -0
  191. package/dist/integrations/remote-push-delivery-job.js.map +1 -0
  192. package/dist/integrations/remote-push-delivery.d.ts +11 -0
  193. package/dist/integrations/remote-push-delivery.d.ts.map +1 -0
  194. package/dist/integrations/remote-push-delivery.js +265 -0
  195. package/dist/integrations/remote-push-delivery.js.map +1 -0
  196. package/dist/integrations/remote-push-store.d.ts +33 -0
  197. package/dist/integrations/remote-push-store.d.ts.map +1 -1
  198. package/dist/integrations/remote-push-store.js +195 -26
  199. package/dist/integrations/remote-push-store.js.map +1 -1
  200. package/dist/notifications/routes.d.ts +3 -3
  201. package/dist/progress/routes.d.ts +1 -1
  202. package/dist/provider-api/corpus-jobs.d.ts +2 -2
  203. package/dist/resources/handlers.d.ts +3 -3
  204. package/dist/secrets/routes.d.ts +9 -9
  205. package/dist/server/agent-engine-api-key-route.d.ts +1 -1
  206. package/dist/server/better-auth-instance.js +7 -3
  207. package/dist/server/better-auth-instance.js.map +1 -1
  208. package/dist/server/core-routes-plugin.d.ts +8 -0
  209. package/dist/server/core-routes-plugin.d.ts.map +1 -1
  210. package/dist/server/core-routes-plugin.js +23 -8
  211. package/dist/server/core-routes-plugin.js.map +1 -1
  212. package/dist/server/framework-request-handler.d.ts.map +1 -1
  213. package/dist/server/framework-request-handler.js +9 -1
  214. package/dist/server/framework-request-handler.js.map +1 -1
  215. package/dist/server/http-response-telemetry.d.ts +3 -2
  216. package/dist/server/http-response-telemetry.d.ts.map +1 -1
  217. package/dist/server/http-response-telemetry.js +160 -27
  218. package/dist/server/http-response-telemetry.js.map +1 -1
  219. package/dist/server/transcribe-voice.d.ts +1 -1
  220. package/dist/styles/rich-markdown-editor.css +1 -510
  221. package/dist/templates/workspace-core/.agents/skills/tracking/SKILL.md +19 -0
  222. package/dist/testing.d.ts +1 -1
  223. package/dist/testing.d.ts.map +1 -1
  224. package/dist/testing.js +1 -1
  225. package/dist/testing.js.map +1 -1
  226. package/dist/vite/client.d.ts.map +1 -1
  227. package/dist/vite/client.js +3 -0
  228. package/dist/vite/client.js.map +1 -1
  229. package/docs/content/agent-native-toolkit.mdx +46 -13
  230. package/docs/content/locales/ar-SA/agent-native-toolkit.mdx +79 -55
  231. package/docs/content/locales/ar-SA/toolkit-capability-packages.mdx +21 -0
  232. package/docs/content/locales/ar-SA/toolkit-context-knowledge.mdx +12 -0
  233. package/docs/content/locales/ar-SA/toolkit-editors-canvases.mdx +17 -0
  234. package/docs/content/locales/de-DE/agent-native-toolkit.mdx +82 -54
  235. package/docs/content/locales/de-DE/toolkit-capability-packages.mdx +21 -0
  236. package/docs/content/locales/de-DE/toolkit-context-knowledge.mdx +12 -0
  237. package/docs/content/locales/de-DE/toolkit-editors-canvases.mdx +17 -0
  238. package/docs/content/locales/es-ES/agent-native-toolkit.mdx +81 -52
  239. package/docs/content/locales/es-ES/toolkit-capability-packages.mdx +21 -0
  240. package/docs/content/locales/es-ES/toolkit-context-knowledge.mdx +12 -0
  241. package/docs/content/locales/es-ES/toolkit-editors-canvases.mdx +21 -0
  242. package/docs/content/locales/fr-FR/agent-native-toolkit.mdx +84 -54
  243. package/docs/content/locales/fr-FR/toolkit-capability-packages.mdx +21 -0
  244. package/docs/content/locales/fr-FR/toolkit-context-knowledge.mdx +12 -0
  245. package/docs/content/locales/fr-FR/toolkit-editors-canvases.mdx +21 -0
  246. package/docs/content/locales/hi-IN/agent-native-toolkit.mdx +69 -62
  247. package/docs/content/locales/hi-IN/toolkit-capability-packages.mdx +21 -0
  248. package/docs/content/locales/hi-IN/toolkit-context-knowledge.mdx +12 -0
  249. package/docs/content/locales/hi-IN/toolkit-editors-canvases.mdx +17 -0
  250. package/docs/content/locales/ja-JP/agent-native-toolkit.mdx +69 -62
  251. package/docs/content/locales/ja-JP/toolkit-capability-packages.mdx +21 -0
  252. package/docs/content/locales/ja-JP/toolkit-context-knowledge.mdx +12 -0
  253. package/docs/content/locales/ja-JP/toolkit-editors-canvases.mdx +17 -0
  254. package/docs/content/locales/ko-KR/agent-native-toolkit.mdx +69 -62
  255. package/docs/content/locales/ko-KR/toolkit-capability-packages.mdx +21 -0
  256. package/docs/content/locales/ko-KR/toolkit-context-knowledge.mdx +12 -0
  257. package/docs/content/locales/ko-KR/toolkit-editors-canvases.mdx +17 -0
  258. package/docs/content/locales/pt-BR/agent-native-toolkit.mdx +82 -54
  259. package/docs/content/locales/pt-BR/toolkit-capability-packages.mdx +21 -0
  260. package/docs/content/locales/pt-BR/toolkit-context-knowledge.mdx +12 -0
  261. package/docs/content/locales/pt-BR/toolkit-editors-canvases.mdx +17 -0
  262. package/docs/content/locales/zh-CN/agent-native-toolkit.mdx +69 -62
  263. package/docs/content/locales/zh-CN/toolkit-capability-packages.mdx +21 -0
  264. package/docs/content/locales/zh-CN/toolkit-context-knowledge.mdx +12 -0
  265. package/docs/content/locales/zh-CN/toolkit-editors-canvases.mdx +17 -0
  266. package/docs/content/locales/zh-TW/agent-native-toolkit.mdx +69 -62
  267. package/docs/content/locales/zh-TW/toolkit-capability-packages.mdx +21 -0
  268. package/docs/content/locales/zh-TW/toolkit-context-knowledge.mdx +12 -0
  269. package/docs/content/locales/zh-TW/toolkit-editors-canvases.mdx +17 -0
  270. package/docs/content/toolkit-capability-packages.mdx +52 -0
  271. package/docs/content/toolkit-context-knowledge.mdx +46 -0
  272. package/docs/content/toolkit-editors-canvases.mdx +55 -0
  273. package/package.json +27 -26
  274. package/src/templates/workspace-core/.agents/skills/tracking/SKILL.md +19 -0
  275. package/corpus/core/src/client/rich-markdown-editor/BubbleToolbar.tsx +0 -253
  276. package/corpus/core/src/client/rich-markdown-editor/CodeBlockNode.tsx +0 -258
  277. package/corpus/core/src/client/rich-markdown-editor/DragHandle.ts +0 -1437
  278. package/corpus/core/src/client/rich-markdown-editor/ImageExtension.ts +0 -306
  279. package/corpus/core/src/client/rich-markdown-editor/RichMarkdownEditor.tsx +0 -80
  280. package/corpus/core/src/client/rich-markdown-editor/RunId.ts +0 -61
  281. package/corpus/core/src/client/rich-markdown-editor/SharedRichEditor.tsx +0 -321
  282. package/corpus/core/src/client/rich-markdown-editor/SlashCommandMenu.tsx +0 -310
  283. package/corpus/core/src/client/rich-markdown-editor/extensions.ts +0 -402
  284. package/corpus/core/src/client/rich-markdown-editor/gfmDoc.ts +0 -92
  285. package/corpus/core/src/client/rich-markdown-editor/surgical-apply.ts +0 -192
  286. package/corpus/core/src/client/rich-markdown-editor/useCollabReconcile.ts +0 -590
  287. package/dist/client/rich-markdown-editor/BubbleToolbar.d.ts +0 -37
  288. package/dist/client/rich-markdown-editor/BubbleToolbar.d.ts.map +0 -1
  289. package/dist/client/rich-markdown-editor/BubbleToolbar.js +0 -171
  290. package/dist/client/rich-markdown-editor/BubbleToolbar.js.map +0 -1
  291. package/dist/client/rich-markdown-editor/CodeBlockNode.d.ts +0 -49
  292. package/dist/client/rich-markdown-editor/CodeBlockNode.d.ts.map +0 -1
  293. package/dist/client/rich-markdown-editor/CodeBlockNode.js +0 -127
  294. package/dist/client/rich-markdown-editor/CodeBlockNode.js.map +0 -1
  295. package/dist/client/rich-markdown-editor/DragHandle.d.ts +0 -97
  296. package/dist/client/rich-markdown-editor/DragHandle.d.ts.map +0 -1
  297. package/dist/client/rich-markdown-editor/DragHandle.js +0 -1066
  298. package/dist/client/rich-markdown-editor/DragHandle.js.map +0 -1
  299. package/dist/client/rich-markdown-editor/ImageExtension.d.ts +0 -63
  300. package/dist/client/rich-markdown-editor/ImageExtension.d.ts.map +0 -1
  301. package/dist/client/rich-markdown-editor/ImageExtension.js +0 -243
  302. package/dist/client/rich-markdown-editor/ImageExtension.js.map +0 -1
  303. package/dist/client/rich-markdown-editor/RichMarkdownEditor.d.ts +0 -51
  304. package/dist/client/rich-markdown-editor/RichMarkdownEditor.d.ts.map +0 -1
  305. package/dist/client/rich-markdown-editor/RichMarkdownEditor.js +0 -37
  306. package/dist/client/rich-markdown-editor/RichMarkdownEditor.js.map +0 -1
  307. package/dist/client/rich-markdown-editor/RunId.d.ts +0 -28
  308. package/dist/client/rich-markdown-editor/RunId.d.ts.map +0 -1
  309. package/dist/client/rich-markdown-editor/RunId.js +0 -60
  310. package/dist/client/rich-markdown-editor/RunId.js.map +0 -1
  311. package/dist/client/rich-markdown-editor/SharedRichEditor.d.ts +0 -110
  312. package/dist/client/rich-markdown-editor/SharedRichEditor.d.ts.map +0 -1
  313. package/dist/client/rich-markdown-editor/SharedRichEditor.js +0 -144
  314. package/dist/client/rich-markdown-editor/SharedRichEditor.js.map +0 -1
  315. package/dist/client/rich-markdown-editor/SlashCommandMenu.d.ts +0 -41
  316. package/dist/client/rich-markdown-editor/SlashCommandMenu.d.ts.map +0 -1
  317. package/dist/client/rich-markdown-editor/SlashCommandMenu.js +0 -221
  318. package/dist/client/rich-markdown-editor/SlashCommandMenu.js.map +0 -1
  319. package/dist/client/rich-markdown-editor/extensions.d.ts +0 -178
  320. package/dist/client/rich-markdown-editor/extensions.d.ts.map +0 -1
  321. package/dist/client/rich-markdown-editor/extensions.js +0 -224
  322. package/dist/client/rich-markdown-editor/extensions.js.map +0 -1
  323. package/dist/client/rich-markdown-editor/gfmDoc.d.ts +0 -24
  324. package/dist/client/rich-markdown-editor/gfmDoc.d.ts.map +0 -1
  325. package/dist/client/rich-markdown-editor/gfmDoc.js +0 -83
  326. package/dist/client/rich-markdown-editor/gfmDoc.js.map +0 -1
  327. package/dist/client/rich-markdown-editor/surgical-apply.d.ts +0 -66
  328. package/dist/client/rich-markdown-editor/surgical-apply.d.ts.map +0 -1
  329. package/dist/client/rich-markdown-editor/surgical-apply.js +0 -147
  330. package/dist/client/rich-markdown-editor/surgical-apply.js.map +0 -1
  331. package/dist/client/rich-markdown-editor/useCollabReconcile.d.ts +0 -110
  332. package/dist/client/rich-markdown-editor/useCollabReconcile.d.ts.map +0 -1
  333. package/dist/client/rich-markdown-editor/useCollabReconcile.js +0 -441
  334. package/dist/client/rich-markdown-editor/useCollabReconcile.js.map +0 -1
@@ -4,7 +4,12 @@ import {
4
4
  intType,
5
5
  retryOnDdlRace,
6
6
  } from "../db/client.js";
7
- import { ensureTableExists, ensureIndexExists } from "../db/ddl-guard.js";
7
+ import {
8
+ ensureColumnExists,
9
+ ensureIndexExists,
10
+ ensureTableExists,
11
+ } from "../db/ddl-guard.js";
12
+ import { isDuplicateColumnError } from "../db/migrations.js";
8
13
  import type {
9
14
  PublicRemotePushRegistration,
10
15
  RemotePushNotification,
@@ -46,6 +51,10 @@ function buildCreateNotificationsSql(): string {
46
51
  payload_json TEXT NOT NULL,
47
52
  status TEXT NOT NULL,
48
53
  attempts ${intType()} NOT NULL DEFAULT 0,
54
+ provider_ticket_id TEXT,
55
+ next_attempt_at ${intType()} NOT NULL DEFAULT 0,
56
+ last_error TEXT,
57
+ delivered_at ${intType()},
49
58
  created_at ${intType()} NOT NULL,
50
59
  updated_at ${intType()} NOT NULL
51
60
  )
@@ -80,6 +89,30 @@ async function ensureTables(): Promise<void> {
80
89
  "idx_remote_push_notifications_owner",
81
90
  `CREATE INDEX IF NOT EXISTS idx_remote_push_notifications_owner ON integration_remote_push_notifications(owner_email, org_id, status, created_at)`,
82
91
  );
92
+ await ensureColumnExists(
93
+ "integration_remote_push_notifications",
94
+ "provider_ticket_id",
95
+ `ALTER TABLE integration_remote_push_notifications ADD COLUMN IF NOT EXISTS provider_ticket_id TEXT`,
96
+ );
97
+ await ensureColumnExists(
98
+ "integration_remote_push_notifications",
99
+ "next_attempt_at",
100
+ `ALTER TABLE integration_remote_push_notifications ADD COLUMN IF NOT EXISTS next_attempt_at ${intType()} NOT NULL DEFAULT 0`,
101
+ );
102
+ await ensureColumnExists(
103
+ "integration_remote_push_notifications",
104
+ "last_error",
105
+ `ALTER TABLE integration_remote_push_notifications ADD COLUMN IF NOT EXISTS last_error TEXT`,
106
+ );
107
+ await ensureColumnExists(
108
+ "integration_remote_push_notifications",
109
+ "delivered_at",
110
+ `ALTER TABLE integration_remote_push_notifications ADD COLUMN IF NOT EXISTS delivered_at ${intType()}`,
111
+ );
112
+ await ensureIndexExists(
113
+ "idx_remote_push_notifications_delivery",
114
+ `CREATE INDEX IF NOT EXISTS idx_remote_push_notifications_delivery ON integration_remote_push_notifications(status, next_attempt_at, updated_at)`,
115
+ );
83
116
  return;
84
117
  }
85
118
  // SQLite (local dev): keep existing behavior
@@ -101,6 +134,18 @@ async function ensureTables(): Promise<void> {
101
134
  `CREATE INDEX IF NOT EXISTS idx_remote_push_notifications_owner ON integration_remote_push_notifications(owner_email, org_id, status, created_at)`,
102
135
  ),
103
136
  );
137
+ await addNotificationColumnIfMissing("provider_ticket_id", "TEXT");
138
+ await addNotificationColumnIfMissing(
139
+ "next_attempt_at",
140
+ `${intType()} NOT NULL DEFAULT 0`,
141
+ );
142
+ await addNotificationColumnIfMissing("last_error", "TEXT");
143
+ await addNotificationColumnIfMissing("delivered_at", intType());
144
+ await retryOnDdlRace(() =>
145
+ client.execute(
146
+ `CREATE INDEX IF NOT EXISTS idx_remote_push_notifications_delivery ON integration_remote_push_notifications(status, next_attempt_at, updated_at)`,
147
+ ),
148
+ );
104
149
  })().catch((err) => {
105
150
  // Retry init on the next call after a failed startup.
106
151
  _initPromise = undefined;
@@ -110,6 +155,21 @@ async function ensureTables(): Promise<void> {
110
155
  return _initPromise;
111
156
  }
112
157
 
158
+ async function addNotificationColumnIfMissing(
159
+ name: string,
160
+ definition: string,
161
+ ): Promise<void> {
162
+ try {
163
+ await retryOnDdlRace(() =>
164
+ getDbExec().execute(
165
+ `ALTER TABLE integration_remote_push_notifications ADD COLUMN ${name} ${definition}`,
166
+ ),
167
+ );
168
+ } catch (error) {
169
+ if (!isDuplicateColumnError(error)) throw error;
170
+ }
171
+ }
172
+
113
173
  function rowToRegistration(
114
174
  row: Record<string, unknown>,
115
175
  ): RemotePushRegistration {
@@ -134,13 +194,18 @@ function rowToRegistration(
134
194
  function rowToNotification(
135
195
  row: Record<string, unknown>,
136
196
  ): RemotePushNotification {
197
+ const storedStatus = String(row.status ?? "pending");
198
+ const status =
199
+ storedStatus === "delivered" || storedStatus === "failed"
200
+ ? storedStatus
201
+ : "pending";
137
202
  return {
138
203
  id: row.id as string,
139
204
  ownerEmail: row.owner_email as string,
140
205
  orgId: (row.org_id as string | null) ?? null,
141
206
  registrationId: row.registration_id as string,
142
207
  payload: parseJson(row.payload_json, null),
143
- status: row.status as RemotePushNotification["status"],
208
+ status,
144
209
  attempts: Number(row.attempts ?? 0),
145
210
  createdAt: Number(row.created_at ?? 0),
146
211
  updatedAt: Number(row.updated_at ?? 0),
@@ -314,31 +379,34 @@ export async function queueRemotePushNotifications(input: {
314
379
  orgId: input.orgId ?? null,
315
380
  limit: 100,
316
381
  });
382
+ if (registrations.length === 0) return { queued: 0 };
383
+
317
384
  const client = getDbExec();
318
385
  const now = Date.now();
319
- let queued = 0;
320
- for (const registration of registrations) {
321
- const id = `remote-push-notification-${now}-${randomHex(8)}`;
322
- const result = await client.execute({
323
- sql: `INSERT INTO integration_remote_push_notifications
386
+ const payload = JSON.stringify(input.payload ?? null);
387
+ const values = registrations.map(
388
+ () => "(?, ?, ?, ?, ?, 'pending', 0, ?, ?, ?)",
389
+ );
390
+ const args = registrations.flatMap((registration) => [
391
+ `remote-push-notification-${now}-${randomHex(8)}`,
392
+ input.ownerEmail,
393
+ input.orgId ?? null,
394
+ registration.id,
395
+ payload,
396
+ now,
397
+ now,
398
+ now,
399
+ ]);
400
+ const result = await client.execute({
401
+ sql: `INSERT INTO integration_remote_push_notifications
324
402
  (id, owner_email, org_id, registration_id, payload_json, status,
325
- attempts, created_at, updated_at)
326
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`,
327
- args: [
328
- id,
329
- input.ownerEmail,
330
- input.orgId ?? null,
331
- registration.id,
332
- JSON.stringify(input.payload ?? null),
333
- "pending",
334
- 0,
335
- now,
336
- now,
337
- ],
338
- });
339
- queued += result.rowsAffected ?? (result as any).rowCount ?? 0;
340
- }
341
- return { queued };
403
+ attempts, next_attempt_at, created_at, updated_at)
404
+ VALUES ${values.join(", ")}`,
405
+ args,
406
+ });
407
+ return {
408
+ queued: result.rowsAffected ?? (result as any).rowCount ?? 0,
409
+ };
342
410
  }
343
411
 
344
412
  export async function listRemotePushNotificationsForOwner(input: {
@@ -349,13 +417,17 @@ export async function listRemotePushNotificationsForOwner(input: {
349
417
  }): Promise<RemotePushNotification[]> {
350
418
  await ensureTables();
351
419
  const limit = Math.max(1, Math.min(input.limit ?? 50, 100));
352
- const statusClause = input.status ? " AND status = ?" : "";
420
+ const statusClause = input.status
421
+ ? input.status === "pending"
422
+ ? " AND status IN ('pending', 'sending', 'sent', 'checking')"
423
+ : " AND status = ?"
424
+ : "";
353
425
  const args: Array<string | number | null> = [
354
426
  input.ownerEmail,
355
427
  input.orgId ?? null,
356
428
  input.orgId ?? null,
357
429
  ];
358
- if (input.status) args.push(input.status);
430
+ if (input.status && input.status !== "pending") args.push(input.status);
359
431
  args.push(limit);
360
432
  const { rows } = await getDbExec().execute({
361
433
  sql: `SELECT * FROM integration_remote_push_notifications
@@ -368,6 +440,183 @@ export async function listRemotePushNotificationsForOwner(input: {
368
440
  return rows.map((row) => rowToNotification(row as Record<string, unknown>));
369
441
  }
370
442
 
443
+ export interface ClaimedRemotePushDelivery {
444
+ id: string;
445
+ registrationId: string;
446
+ provider: string;
447
+ token: string;
448
+ payload: unknown;
449
+ phase: "send" | "receipt";
450
+ providerTicketId: string | null;
451
+ attempts: number;
452
+ }
453
+
454
+ export async function claimNextRemotePushDelivery(input?: {
455
+ now?: number;
456
+ staleAfterMs?: number;
457
+ }): Promise<ClaimedRemotePushDelivery | null> {
458
+ await ensureTables();
459
+ const client = getDbExec();
460
+ const now = input?.now ?? Date.now();
461
+ const staleBefore = now - Math.max(30_000, input?.staleAfterMs ?? 120_000);
462
+ const { rows } = await client.execute({
463
+ sql: `SELECT n.id, n.registration_id, n.payload_json, n.status, n.attempts,
464
+ n.provider_ticket_id, n.updated_at, r.provider, r.token
465
+ FROM integration_remote_push_notifications n
466
+ INNER JOIN integration_remote_push_registrations r
467
+ ON r.id = n.registration_id
468
+ WHERE r.status = 'active'
469
+ AND (
470
+ (n.status IN ('pending', 'sent') AND n.next_attempt_at <= ?)
471
+ OR (n.status IN ('sending', 'checking') AND n.updated_at <= ?)
472
+ )
473
+ ORDER BY n.created_at ASC
474
+ LIMIT 1`,
475
+ args: [now, staleBefore],
476
+ });
477
+ const row = rows[0] as Record<string, unknown> | undefined;
478
+ if (!row) return null;
479
+
480
+ const previousStatus = String(row.status ?? "pending");
481
+ const providerTicketId = sanitizeString(
482
+ row.provider_ticket_id as string | null,
483
+ 200,
484
+ );
485
+ const phase =
486
+ (previousStatus === "sent" || previousStatus === "checking") &&
487
+ providerTicketId
488
+ ? "receipt"
489
+ : "send";
490
+ const claimedStatus = phase === "receipt" ? "checking" : "sending";
491
+ const result = await client.execute({
492
+ sql: `UPDATE integration_remote_push_notifications
493
+ SET status = ?, attempts = attempts + 1, updated_at = ?
494
+ WHERE id = ? AND status = ? AND updated_at = ?`,
495
+ args: [
496
+ claimedStatus,
497
+ now,
498
+ row.id as string,
499
+ previousStatus,
500
+ Number(row.updated_at),
501
+ ],
502
+ });
503
+ if ((result.rowsAffected ?? (result as any).rowCount ?? 0) !== 1) return null;
504
+
505
+ return {
506
+ id: row.id as string,
507
+ registrationId: row.registration_id as string,
508
+ provider: String(row.provider ?? "unknown"),
509
+ token: row.token as string,
510
+ payload: parseJson(row.payload_json, null),
511
+ phase,
512
+ providerTicketId,
513
+ attempts: Number(row.attempts ?? 0) + 1,
514
+ };
515
+ }
516
+
517
+ export async function markRemotePushTicketAccepted(input: {
518
+ id: string;
519
+ providerTicketId: string;
520
+ checkAfter: number;
521
+ }): Promise<boolean> {
522
+ await ensureTables();
523
+ const now = Date.now();
524
+ const result = await getDbExec().execute({
525
+ sql: `UPDATE integration_remote_push_notifications
526
+ SET status = 'sent', provider_ticket_id = ?, next_attempt_at = ?,
527
+ last_error = NULL, updated_at = ?
528
+ WHERE id = ? AND status = 'sending'`,
529
+ args: [input.providerTicketId, input.checkAfter, now, input.id],
530
+ });
531
+ return (result.rowsAffected ?? (result as any).rowCount ?? 0) === 1;
532
+ }
533
+
534
+ export async function markRemotePushDelivered(id: string): Promise<boolean> {
535
+ await ensureTables();
536
+ const now = Date.now();
537
+ const result = await getDbExec().execute({
538
+ sql: `UPDATE integration_remote_push_notifications
539
+ SET status = 'delivered', last_error = NULL, delivered_at = ?,
540
+ updated_at = ?
541
+ WHERE id = ? AND status = 'checking'`,
542
+ args: [now, now, id],
543
+ });
544
+ return (result.rowsAffected ?? (result as any).rowCount ?? 0) === 1;
545
+ }
546
+
547
+ export async function retryRemotePushDelivery(input: {
548
+ id: string;
549
+ phase: "send" | "receipt";
550
+ retryAt: number;
551
+ errorCode: string;
552
+ resend?: boolean;
553
+ }): Promise<boolean> {
554
+ await ensureTables();
555
+ const currentStatus = input.phase === "receipt" ? "checking" : "sending";
556
+ const retryStatus =
557
+ input.phase === "receipt" && !input.resend ? "sent" : "pending";
558
+ const clearTicketClause = input.resend ? ", provider_ticket_id = NULL" : "";
559
+ const result = await getDbExec().execute({
560
+ sql: `UPDATE integration_remote_push_notifications
561
+ SET status = ?, next_attempt_at = ?, last_error = ?${clearTicketClause},
562
+ updated_at = ?
563
+ WHERE id = ? AND status = ?`,
564
+ args: [
565
+ retryStatus,
566
+ input.retryAt,
567
+ sanitizeString(input.errorCode, 160) ?? "temporary_error",
568
+ Date.now(),
569
+ input.id,
570
+ currentStatus,
571
+ ],
572
+ });
573
+ return (result.rowsAffected ?? (result as any).rowCount ?? 0) === 1;
574
+ }
575
+
576
+ export async function failRemotePushDelivery(input: {
577
+ id: string;
578
+ phase: "send" | "receipt";
579
+ errorCode: string;
580
+ }): Promise<boolean> {
581
+ await ensureTables();
582
+ const currentStatus = input.phase === "receipt" ? "checking" : "sending";
583
+ const result = await getDbExec().execute({
584
+ sql: `UPDATE integration_remote_push_notifications
585
+ SET status = 'failed', last_error = ?, updated_at = ?
586
+ WHERE id = ? AND status = ?`,
587
+ args: [
588
+ sanitizeString(input.errorCode, 160) ?? "delivery_failed",
589
+ Date.now(),
590
+ input.id,
591
+ currentStatus,
592
+ ],
593
+ });
594
+ return (result.rowsAffected ?? (result as any).rowCount ?? 0) === 1;
595
+ }
596
+
597
+ export async function deactivateRemotePushRegistration(
598
+ registrationId: string,
599
+ ): Promise<boolean> {
600
+ await ensureTables();
601
+ const client = getDbExec();
602
+ const now = Date.now();
603
+ const result = await client.execute({
604
+ sql: `UPDATE integration_remote_push_registrations
605
+ SET status = 'inactive', updated_at = ?
606
+ WHERE id = ? AND status = 'active'`,
607
+ args: [now, registrationId],
608
+ });
609
+ await client.execute({
610
+ sql: `UPDATE integration_remote_push_notifications
611
+ SET status = 'failed', last_error = 'registration_inactive',
612
+ updated_at = ?
613
+ WHERE registration_id = ?
614
+ AND status IN ('pending', 'sending', 'sent', 'checking')`,
615
+ args: [now, registrationId],
616
+ });
617
+ return (result.rowsAffected ?? (result as any).rowCount ?? 0) === 1;
618
+ }
619
+
371
620
  async function getRemotePushRegistrationByTokenHash(
372
621
  tokenHash: string,
373
622
  ): Promise<RemotePushRegistration | null> {
@@ -1105,7 +1105,11 @@ async function buildDatabaseConfig(
1105
1105
  ): Promise<BetterAuthOptions["database"]> {
1106
1106
  if (dialect === "postgres") {
1107
1107
  const url = getDatabaseUrl();
1108
- const { isNeonUrl } = await import("../db/create-get-db.js");
1108
+ const {
1109
+ buildResilientNeonPool,
1110
+ buildResilientPostgresJsClient,
1111
+ isNeonUrl,
1112
+ } = await import("../db/create-get-db.js");
1109
1113
 
1110
1114
  if (isPgliteUrl(url)) {
1111
1115
  const { drizzle } = await loadPgliteDrizzle();
@@ -1133,7 +1137,9 @@ async function buildDatabaseConfig(
1133
1137
  });
1134
1138
  attachNeonPoolErrorLogger(_neonAuthPool, "db/neon-auth");
1135
1139
  const { drizzle } = await import("drizzle-orm/neon-serverless");
1136
- const db = drizzle(_neonAuthPool, { schema: pgAuthSchema });
1140
+ const db = drizzle(buildResilientNeonPool(_neonAuthPool), {
1141
+ schema: pgAuthSchema,
1142
+ });
1137
1143
  const { drizzleAdapter } = await import("better-auth/adapters/drizzle");
1138
1144
  return drizzleAdapter(db, {
1139
1145
  provider: "pg",
@@ -1149,7 +1155,9 @@ async function buildDatabaseConfig(
1149
1155
  const { default: postgres } = await import("postgres");
1150
1156
  const sql = postgres(url, pgPoolOptions(url));
1151
1157
  const { drizzle } = await import("drizzle-orm/postgres-js");
1152
- const db = drizzle(sql, { schema: pgAuthSchema });
1158
+ const db = drizzle(buildResilientPostgresJsClient(sql), {
1159
+ schema: pgAuthSchema,
1160
+ });
1153
1161
  const { drizzleAdapter } = await import("better-auth/adapters/drizzle");
1154
1162
  return drizzleAdapter(db, {
1155
1163
  provider: "pg",
@@ -165,7 +165,6 @@ import {
165
165
  DEFAULT_UPLOAD_MAX_FILE_BYTES,
166
166
  isAllowedUploadMimeType,
167
167
  } from "./h3-helpers.js";
168
- import { createHttpResponseTelemetryMiddleware } from "./http-response-telemetry.js";
169
168
  import { isIdentitySsoEnabled } from "./identity-sso-store.js";
170
169
  import { handleIdentitySso } from "./identity-sso.js";
171
170
  import { createOpenRouteHandler } from "./open-route.js";
@@ -1069,6 +1068,35 @@ export interface CoreRoutesPluginOptions {
1069
1068
  anonymousOwner?: BuilderAnonymousOwnerResolver;
1070
1069
  }
1071
1070
 
1071
+ interface LegacyCoreRouteInitSettings {
1072
+ persistedEnvVars: Record<string, string> | null;
1073
+ builderDisconnected: { at?: number } | null;
1074
+ }
1075
+
1076
+ type CoreRouteSettingReader = (
1077
+ key: string,
1078
+ ) => Promise<Record<string, unknown> | null>;
1079
+
1080
+ export async function readLegacyCoreRouteInitSettings(
1081
+ readSetting: CoreRouteSettingReader = getSetting,
1082
+ ): Promise<LegacyCoreRouteInitSettings> {
1083
+ const readOrNull = async (key: string) => {
1084
+ try {
1085
+ return await readSetting(key);
1086
+ } catch {
1087
+ return null;
1088
+ }
1089
+ };
1090
+ const [persistedEnvVars, builderDisconnected] = await Promise.all([
1091
+ readOrNull("persisted-env-vars"),
1092
+ readOrNull("builder-disconnected"),
1093
+ ]);
1094
+ return {
1095
+ persistedEnvVars: persistedEnvVars as Record<string, string> | null,
1096
+ builderDisconnected: builderDisconnected as { at?: number } | null,
1097
+ };
1098
+ }
1099
+
1072
1100
  /**
1073
1101
  * Creates a Nitro plugin that mounts all standard agent-native framework routes.
1074
1102
  *
@@ -1110,18 +1138,17 @@ export function createCoreRoutesPlugin(
1110
1138
  try {
1111
1139
  await awaitBootstrap(nitroApp);
1112
1140
 
1141
+ const { persistedEnvVars, builderDisconnected } =
1142
+ await readLegacyCoreRouteInitSettings();
1143
+
1113
1144
  // Legacy cleanup: key saves now go to scoped app_secrets rows. Do not
1114
1145
  // rehydrate the old deployment-global `persisted-env-vars` row into
1115
1146
  // process.env; keep only the Builder scrub so stale leaked keys self-heal.
1116
1147
  try {
1117
- const persisted = (await getSetting("persisted-env-vars")) as Record<
1118
- string,
1119
- string
1120
- > | null;
1121
- if (persisted) {
1148
+ if (persistedEnvVars) {
1122
1149
  const builderKeys = new Set<string>(BUILDER_ENV_KEYS);
1123
1150
  let scrubbed = 0;
1124
- for (const k of Object.keys(persisted)) {
1151
+ for (const k of Object.keys(persistedEnvVars)) {
1125
1152
  if (builderKeys.has(k)) {
1126
1153
  scrubbed++;
1127
1154
  }
@@ -1129,7 +1156,7 @@ export function createCoreRoutesPlugin(
1129
1156
  if (scrubbed > 0) {
1130
1157
  try {
1131
1158
  const cleaned: Record<string, string> = {};
1132
- for (const [k, v] of Object.entries(persisted)) {
1159
+ for (const [k, v] of Object.entries(persistedEnvVars)) {
1133
1160
  if (!builderKeys.has(k)) cleaned[k] = v;
1134
1161
  }
1135
1162
  await putSetting("persisted-env-vars", cleaned);
@@ -1154,10 +1181,7 @@ export function createCoreRoutesPlugin(
1154
1181
  // plugin init while the flag is set. The flag is cleared by the
1155
1182
  // Builder cli-auth callback when the user re-connects.
1156
1183
  try {
1157
- const disconnected = (await getSetting("builder-disconnected")) as {
1158
- at?: number;
1159
- } | null;
1160
- if (disconnected) {
1184
+ if (builderDisconnected) {
1161
1185
  for (const key of BUILDER_ENV_KEYS) {
1162
1186
  delete process.env[key];
1163
1187
  }
@@ -1223,8 +1247,6 @@ export function createCoreRoutesPlugin(
1223
1247
  );
1224
1248
  }
1225
1249
 
1226
- getH3App(nitroApp).use(createHttpResponseTelemetryMiddleware());
1227
-
1228
1250
  // Security response headers — emitted on every framework response.
1229
1251
  // Mounted before route handlers so 4xx/5xx error pages also carry the
1230
1252
  // headers. Routes that need to tighten a specific header override via
@@ -19,6 +19,10 @@ import { MCP_PUBLIC_ROUTE_PREFIX } from "../mcp/route-paths.js";
19
19
  import { getConfiguredAppBasePath } from "./app-base-path.js";
20
20
  import { captureError } from "./capture-error.js";
21
21
  import { createCsrfMiddleware } from "./csrf.js";
22
+ import {
23
+ installHttpResponseTelemetryHooks,
24
+ recordFrameworkReadyWait,
25
+ } from "./http-response-telemetry.js";
22
26
 
23
27
  const BOOTSTRAPPED = new WeakSet<object>();
24
28
  const IN_BOOTSTRAP = new WeakSet<object>();
@@ -114,6 +118,7 @@ export function markDefaultPluginProvided(nitroApp: any, stem: string): void {
114
118
  export function getH3App(nitroApp: any): H3AppShim {
115
119
  if (!nitroApp) throw new Error("getH3App: nitroApp is required");
116
120
  ensureGlobalMiddlewareDispatch(nitroApp);
121
+ installHttpResponseTelemetryHooks(nitroApp);
117
122
 
118
123
  // Reuse the cached shim if we've wrapped this nitroApp before
119
124
  const cached = nitroApp[APP_SHIM_KEY] as H3AppShim | undefined;
@@ -204,7 +209,12 @@ export function getH3App(nitroApp: any): H3AppShim {
204
209
  resolveMountMatch(reqPath, WELL_KNOWN_PREFIX) ||
205
210
  resolveMountMatch(reqPath, MCP_PUBLIC_ROUTE_PREFIX)
206
211
  ) {
207
- await awaitFrameworkRoutesReadyForRequest(nitroApp, reqPath);
212
+ const startedAt = Date.now();
213
+ try {
214
+ await awaitFrameworkRoutesReadyForRequest(nitroApp, reqPath);
215
+ } finally {
216
+ recordFrameworkReadyWait(event, Date.now() - startedAt);
217
+ }
208
218
  }
209
219
  });
210
220
  }