@agent-native/core 0.90.10 → 0.91.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (360) hide show
  1. package/corpus/README.md +2 -2
  2. package/corpus/core/CHANGELOG.md +30 -0
  3. package/corpus/core/docs/content/toolkit-settings.mdx +56 -3
  4. package/corpus/core/package.json +2 -1
  5. package/corpus/core/src/agent/durable-background.ts +5 -5
  6. package/corpus/core/src/agent/engine/ai-sdk-engine.ts +40 -8
  7. package/corpus/core/src/agent/engine/anthropic-engine.ts +25 -7
  8. package/corpus/core/src/agent/engine/output-tokens.ts +94 -0
  9. package/corpus/core/src/agent/production-agent.ts +34 -6
  10. package/corpus/core/src/agent/run-ownership.ts +29 -1
  11. package/corpus/core/src/agent/types.ts +3 -2
  12. package/corpus/core/src/changelog/parse.ts +78 -0
  13. package/corpus/core/src/chat-threads/schema.ts +43 -0
  14. package/corpus/core/src/chat-threads/store.ts +144 -12
  15. package/corpus/core/src/cli/workspace-dev.ts +25 -5
  16. package/corpus/core/src/client/AgentPanel.tsx +79 -14
  17. package/corpus/core/src/client/AssistantChat.tsx +359 -425
  18. package/corpus/core/src/client/analytics-session.ts +70 -0
  19. package/corpus/core/src/client/analytics.ts +175 -49
  20. package/corpus/core/src/client/chat/message-components.tsx +22 -2
  21. package/corpus/core/src/client/components/ui/message-scroller.tsx +131 -0
  22. package/corpus/core/src/client/conversation/AgentConversation.tsx +63 -41
  23. package/corpus/core/src/client/error-capture.ts +616 -0
  24. package/corpus/core/src/client/index.ts +12 -0
  25. package/corpus/core/src/client/session-replay.ts +57 -7
  26. package/corpus/core/src/client/settings/SettingsPanel.tsx +123 -1
  27. package/corpus/core/src/client/settings/SettingsTabsPage.tsx +292 -45
  28. package/corpus/core/src/client/settings/index.ts +1 -0
  29. package/corpus/core/src/client/sharing/ShareButton.tsx +14 -11
  30. package/corpus/core/src/client/sharing/ShareDialog.tsx +13 -10
  31. package/corpus/core/src/db/client.ts +12 -9
  32. package/corpus/core/src/mcp/builtin-tools.ts +29 -2
  33. package/corpus/core/src/server/agent-chat-plugin.ts +174 -79
  34. package/corpus/core/src/server/onboarding-html.ts +28 -16
  35. package/corpus/core/src/shared/reasoning-effort.ts +23 -0
  36. package/corpus/core/src/sharing/actions/list-resource-shares.ts +45 -1
  37. package/corpus/core/src/sharing/actions/share-resource.ts +9 -0
  38. package/corpus/core/src/templates/workspace-core/.agents/skills/agent-native-toolkit/SKILL.md +4 -2
  39. package/corpus/core/src/templates/workspace-core/.agents/skills/changelog/SKILL.md +9 -6
  40. package/corpus/core/src/vite/client.ts +217 -35
  41. package/corpus/templates/analytics/.agents/skills/adhoc-analysis/SKILL.md +8 -7
  42. package/corpus/templates/analytics/.agents/skills/analysis-workspace/SKILL.md +14 -10
  43. package/corpus/templates/analytics/.agents/skills/bigquery/SKILL.md +15 -15
  44. package/corpus/templates/analytics/.agents/skills/cross-source-analysis/SKILL.md +1 -0
  45. package/corpus/templates/analytics/.agents/skills/dashboard-management/SKILL.md +38 -22
  46. package/corpus/templates/analytics/.agents/skills/data-programs/SKILL.md +114 -61
  47. package/corpus/templates/analytics/.agents/skills/data-querying/SKILL.md +1 -0
  48. package/corpus/templates/analytics/.agents/skills/gong/SKILL.md +7 -7
  49. package/corpus/templates/analytics/.agents/skills/hubspot/SKILL.md +1 -0
  50. package/corpus/templates/analytics/.agents/skills/prometheus/SKILL.md +1 -1
  51. package/corpus/templates/analytics/.builder/skills/bigquery/SKILL.md +17 -17
  52. package/corpus/templates/analytics/.builder/skills/gcloud/SKILL.md +5 -5
  53. package/corpus/templates/analytics/.builder/skills/github/SKILL.md +7 -7
  54. package/corpus/templates/analytics/.builder/skills/gong/SKILL.md +12 -12
  55. package/corpus/templates/analytics/.builder/skills/grafana/SKILL.md +7 -7
  56. package/corpus/templates/analytics/.builder/skills/sentry/SKILL.md +7 -7
  57. package/corpus/templates/analytics/.builder/skills/slack/SKILL.md +6 -6
  58. package/corpus/templates/analytics/.builder/skills/stripe/SKILL.md +7 -7
  59. package/corpus/templates/analytics/AGENTS.md +47 -2
  60. package/corpus/templates/analytics/actions/add-status-page-monitor.ts +36 -0
  61. package/corpus/templates/analytics/actions/capture-test-error.ts +33 -0
  62. package/corpus/templates/analytics/actions/delete-monitor.ts +24 -0
  63. package/corpus/templates/analytics/actions/delete-status-page.ts +23 -0
  64. package/corpus/templates/analytics/actions/get-error-issue.ts +36 -0
  65. package/corpus/templates/analytics/actions/get-monitor-stats.ts +55 -0
  66. package/corpus/templates/analytics/actions/get-monitor.ts +27 -0
  67. package/corpus/templates/analytics/actions/get-public-status-page.ts +41 -0
  68. package/corpus/templates/analytics/actions/get-status-page.ts +29 -0
  69. package/corpus/templates/analytics/actions/list-error-issues.ts +40 -0
  70. package/corpus/templates/analytics/actions/list-monitors.ts +21 -0
  71. package/corpus/templates/analytics/actions/list-status-pages.ts +21 -0
  72. package/corpus/templates/analytics/actions/match-error-issues.ts +51 -0
  73. package/corpus/templates/analytics/actions/navigate.ts +58 -4
  74. package/corpus/templates/analytics/actions/remove-status-page-monitor.ts +22 -0
  75. package/corpus/templates/analytics/actions/reorder-status-page-monitors.ts +25 -0
  76. package/corpus/templates/analytics/actions/resolve-error-issue.ts +38 -0
  77. package/corpus/templates/analytics/actions/run-monitor-check.ts +23 -0
  78. package/corpus/templates/analytics/actions/save-analysis.ts +1 -0
  79. package/corpus/templates/analytics/actions/save-monitor.ts +145 -0
  80. package/corpus/templates/analytics/actions/save-status-page.ts +47 -0
  81. package/corpus/templates/analytics/actions/view-screen.ts +212 -0
  82. package/corpus/templates/analytics/app/components/layout/Header.tsx +1 -0
  83. package/corpus/templates/analytics/app/components/layout/Layout.tsx +10 -1
  84. package/corpus/templates/analytics/app/components/layout/Sidebar.tsx +134 -39
  85. package/corpus/templates/analytics/app/components/monitoring/PublicStatusView.tsx +351 -0
  86. package/corpus/templates/analytics/app/components/monitoring/ResponseTimeChart.tsx +174 -0
  87. package/corpus/templates/analytics/app/components/monitoring/UptimeStatCards.tsx +85 -0
  88. package/corpus/templates/analytics/app/components/monitoring/UptimeTimelineBars.tsx +106 -0
  89. package/corpus/templates/analytics/app/components/monitoring/chart-utils.ts +101 -0
  90. package/corpus/templates/analytics/app/components/monitoring/index.ts +28 -0
  91. package/corpus/templates/analytics/app/components/monitoring/types.ts +42 -0
  92. package/corpus/templates/analytics/app/hooks/use-navigation-state.ts +34 -0
  93. package/corpus/templates/analytics/app/i18n/zh-TW.ts +6 -0
  94. package/corpus/templates/analytics/app/i18n-data.ts +33 -0
  95. package/corpus/templates/analytics/app/pages/DataSources.tsx +28 -0
  96. package/corpus/templates/analytics/app/pages/Settings.tsx +77 -9
  97. package/corpus/templates/analytics/app/pages/adhoc/sql-dashboard/SqlChartCard.tsx +3 -3
  98. package/corpus/templates/analytics/app/pages/adhoc/sql-dashboard/dashboard-layout.ts +7 -0
  99. package/corpus/templates/analytics/app/pages/monitoring/ErrorsPanel.tsx +205 -0
  100. package/corpus/templates/analytics/app/pages/monitoring/MonitoringPage.tsx +100 -0
  101. package/corpus/templates/analytics/app/pages/monitoring/UptimePanel.tsx +475 -0
  102. package/corpus/templates/analytics/app/pages/monitoring/errors/IssueDetail.tsx +372 -0
  103. package/corpus/templates/analytics/app/pages/monitoring/errors/IssueList.tsx +360 -0
  104. package/corpus/templates/analytics/app/pages/monitoring/errors/Sparkline.tsx +55 -0
  105. package/corpus/templates/analytics/app/pages/monitoring/errors/i18n.ts +106 -0
  106. package/corpus/templates/analytics/app/pages/monitoring/errors/types.ts +75 -0
  107. package/corpus/templates/analytics/app/pages/monitoring/errors/utils.ts +132 -0
  108. package/corpus/templates/analytics/app/pages/monitoring/uptime/MonitorDetail.tsx +535 -0
  109. package/corpus/templates/analytics/app/pages/monitoring/uptime/MonitorFormPage.tsx +1026 -0
  110. package/corpus/templates/analytics/app/pages/monitoring/uptime/MonitorList.tsx +311 -0
  111. package/corpus/templates/analytics/app/pages/monitoring/uptime/i18n.ts +235 -0
  112. package/corpus/templates/analytics/app/pages/monitoring/uptime/status-pages/StatusPageEditor.tsx +661 -0
  113. package/corpus/templates/analytics/app/pages/monitoring/uptime/status-pages/StatusPagesView.tsx +355 -0
  114. package/corpus/templates/analytics/app/pages/monitoring/uptime/status-pages/i18n.ts +106 -0
  115. package/corpus/templates/analytics/app/pages/monitoring/uptime/status-pages/slug.ts +24 -0
  116. package/corpus/templates/analytics/app/pages/monitoring/uptime/status-pages/types.ts +20 -0
  117. package/corpus/templates/analytics/app/pages/monitoring/uptime/status-summary.ts +87 -0
  118. package/corpus/templates/analytics/app/pages/monitoring/uptime/types.ts +161 -0
  119. package/corpus/templates/analytics/app/pages/monitoring/uptime/utils.ts +210 -0
  120. package/corpus/templates/analytics/app/pages/sessions/SessionDetailPage.tsx +76 -1
  121. package/corpus/templates/analytics/app/pages/sessions/SessionDevToolsPanel.tsx +74 -9
  122. package/corpus/templates/analytics/app/pages/sessions/SessionsPage.tsx +197 -20
  123. package/corpus/templates/analytics/app/root.tsx +33 -1
  124. package/corpus/templates/analytics/app/routes/monitoring._index.tsx +10 -0
  125. package/corpus/templates/analytics/app/routes/status.$slug.tsx +118 -0
  126. package/corpus/templates/analytics/changelog/2026-07-08-add-uptime-monitors-that-ping-your-urls-and-alert-you-when-t.md +6 -0
  127. package/corpus/templates/analytics/changelog/2026-07-08-analytics-chats-keep-large-data-dictionaries-compact-so-prov.md +6 -0
  128. package/corpus/templates/analytics/changelog/2026-07-08-create-public-status-pages-that-share-the-live-health-of-cho.md +6 -0
  129. package/corpus/templates/analytics/changelog/2026-07-08-dashboard-extension-panels-use-clearer-open-copy.md +6 -0
  130. package/corpus/templates/analytics/changelog/2026-07-08-error-capture.md +6 -0
  131. package/corpus/templates/analytics/changelog/2026-07-08-fixed-single-panel-dashboard-drags-so-they-no-longer-rewrite.md +6 -0
  132. package/corpus/templates/analytics/changelog/2026-07-08-jump-straight-from-an-error-in-a-session-recording-to-its-fu.md +6 -0
  133. package/corpus/templates/analytics/changelog/2026-07-08-monitor-detail-and-list-now-show-colorful-uptime-timelines-r.md +6 -0
  134. package/corpus/templates/analytics/changelog/2026-07-08-pinned-ask-chats-now-show-a-pin-icon-in-the-sidebar.md +6 -0
  135. package/corpus/templates/analytics/changelog/2026-07-08-publish-a-public-uptime-status-page-with-colorful-uptime-tim.md +6 -0
  136. package/corpus/templates/analytics/changelog/2026-07-08-sessions-now-hide-visitor-emails-in-demo-mode-and-show-clean.md +6 -0
  137. package/corpus/templates/analytics/changelog/2026-07-08-settings-are-cleaner-searchable-and-alerts-have-their-own-tab.md +5 -0
  138. package/corpus/templates/analytics/changelog/2026-07-08-sidebar-sections-stay-collapsed-until-opened.md +5 -0
  139. package/corpus/templates/analytics/changelog/2026-07-08-the-uptime-monitor-list-now-has-a-current-status-overview-wi.md +6 -0
  140. package/corpus/templates/analytics/docs/error-capture.md +172 -0
  141. package/corpus/templates/analytics/docs/uptime-monitoring.md +150 -0
  142. package/corpus/templates/analytics/server/db/schema-errors.ts +150 -0
  143. package/corpus/templates/analytics/server/db/schema-monitoring.ts +177 -0
  144. package/corpus/templates/analytics/server/db/schema.ts +6 -0
  145. package/corpus/templates/analytics/server/jobs/uptime-monitors.ts +123 -0
  146. package/corpus/templates/analytics/server/lib/agent-chat-plan-mode.ts +41 -0
  147. package/corpus/templates/analytics/server/lib/data-dictionary-context.ts +55 -12
  148. package/corpus/templates/analytics/server/lib/error-capture.ts +1331 -0
  149. package/corpus/templates/analytics/server/lib/first-party-analytics.ts +47 -1
  150. package/corpus/templates/analytics/server/lib/monitor-stats.ts +494 -0
  151. package/corpus/templates/analytics/server/lib/status-pages.ts +798 -0
  152. package/corpus/templates/analytics/server/lib/uptime-monitors.ts +1665 -0
  153. package/corpus/templates/analytics/server/plugins/agent-chat.ts +7 -37
  154. package/corpus/templates/analytics/server/plugins/auth.ts +11 -1
  155. package/corpus/templates/analytics/server/plugins/db.ts +408 -0
  156. package/corpus/templates/analytics/server/plugins/uptime-monitor-jobs.ts +63 -0
  157. package/corpus/templates/assets/app/routes/_index.tsx +1 -1
  158. package/corpus/templates/assets/app/routes/settings.tsx +22 -1
  159. package/corpus/templates/assets/changelog/2026-07-08-recent-drafts-keep-comfortable-side-padding.md +6 -0
  160. package/corpus/templates/assets/changelog/2026-07-08-settings-are-cleaner-and-searchable.md +5 -0
  161. package/corpus/templates/brain/app/routes/settings.tsx +43 -5
  162. package/corpus/templates/brain/changelog/2026-07-08-settings-are-cleaner-and-searchable.md +5 -0
  163. package/corpus/templates/calendar/app/pages/Settings.tsx +44 -6
  164. package/corpus/templates/calendar/changelog/2026-07-08-settings-are-cleaner-and-searchable.md +5 -0
  165. package/corpus/templates/chat/app/routes/settings.tsx +16 -1
  166. package/corpus/templates/chat/changelog/2026-07-08-settings-are-cleaner-and-searchable.md +5 -0
  167. package/corpus/templates/clips/actions/lib/audio-only-transcription.ts +79 -37
  168. package/corpus/templates/clips/actions/regenerate-chapters.ts +7 -0
  169. package/corpus/templates/clips/app/components/player/player-controls.tsx +35 -0
  170. package/corpus/templates/clips/app/components/player/video-player.tsx +162 -18
  171. package/corpus/templates/clips/app/hooks/use-auto-title.ts +15 -5
  172. package/corpus/templates/clips/app/routes/_app.settings._index.tsx +63 -6
  173. package/corpus/templates/clips/app/routes/download.tsx +12 -4
  174. package/corpus/templates/clips/app/routes/r.$recordingId.tsx +1 -0
  175. package/corpus/templates/clips/app/routes/record.tsx +18 -1
  176. package/corpus/templates/clips/changelog/2026-07-07-auto-generated-chapter-requests-now-open-the-matching-agent-.md +6 -0
  177. package/corpus/templates/clips/changelog/2026-07-07-shared-clips-start-playback-reliably-from-the-first-play-click.md +6 -0
  178. package/corpus/templates/clips/changelog/2026-07-07-the-clips-desktop-download-page-now-uses-the-agent-native-ap.md +6 -0
  179. package/corpus/templates/clips/changelog/2026-07-08-chrome-extension-camera-and-microphone-menus-now-show-which-.md +6 -0
  180. package/corpus/templates/clips/changelog/2026-07-08-chrome-extension-copies-new-clip-links-after-saving.md +6 -0
  181. package/corpus/templates/clips/changelog/2026-07-08-chrome-extension-recordings-now-continue-after-granting-came.md +6 -0
  182. package/corpus/templates/clips/changelog/2026-07-08-mobile-shared-clips-now-have-loom-style-tap-and-skip-controls.md +6 -0
  183. package/corpus/templates/clips/changelog/2026-07-08-recordings-and-uploads-copy-links-after-saving.md +6 -0
  184. package/corpus/templates/clips/changelog/2026-07-08-settings-are-cleaner-searchable-and-collapse-s3-with-builder.md +5 -0
  185. package/corpus/templates/clips/changelog/2026-07-08-transcripts-are-more-reliable-for-longer-desktop-recordings-.md +6 -0
  186. package/corpus/templates/clips/chrome-extension/public/manifest.json +1 -0
  187. package/corpus/templates/clips/chrome-extension/src/background.ts +162 -13
  188. package/corpus/templates/clips/chrome-extension/src/content-script.ts +14 -0
  189. package/corpus/templates/clips/chrome-extension/src/offscreen.ts +36 -0
  190. package/corpus/templates/clips/chrome-extension/src/overlay.ts +99 -25
  191. package/corpus/templates/clips/chrome-extension/src/permission.ts +63 -14
  192. package/corpus/templates/clips/chrome-extension/src/popup.ts +123 -23
  193. package/corpus/templates/content/actions/_builder-cms-read-client.ts +47 -0
  194. package/corpus/templates/content/actions/_database-source-utils.ts +33 -4
  195. package/corpus/templates/content/actions/add-content-database-source-field-property.ts +214 -29
  196. package/corpus/templates/content/actions/attach-content-database-source.ts +3 -0
  197. package/corpus/templates/content/actions/change-content-database-source-role.ts +1 -0
  198. package/corpus/templates/content/app/components/editor/DocumentProperties.tsx +42 -32
  199. package/corpus/templates/content/app/components/editor/database/DatabaseView.tsx +352 -81
  200. package/corpus/templates/content/app/components/editor/database/settings.tsx +49 -24
  201. package/corpus/templates/content/app/routes/_app.settings.tsx +19 -1
  202. package/corpus/templates/content/changelog/2026-07-07-builder-source-tag-fields-now-import-as-multi-select.md +6 -0
  203. package/corpus/templates/content/changelog/2026-07-08-settings-are-cleaner-and-searchable.md +5 -0
  204. package/corpus/templates/content/shared/api.ts +3 -0
  205. package/corpus/templates/content/shared/properties.ts +42 -0
  206. package/corpus/templates/design/actions/generate-design.ts +3 -0
  207. package/corpus/templates/design/actions/get-design-system.ts +147 -1
  208. package/corpus/templates/design/app/routes/settings.tsx +16 -1
  209. package/corpus/templates/design/changelog/2026-07-08-design-generation-now-follows-hydrated-builder-design-system.md +6 -0
  210. package/corpus/templates/design/changelog/2026-07-08-settings-are-cleaner-and-searchable.md +5 -0
  211. package/corpus/templates/dispatch/app/routes/settings.tsx +23 -2
  212. package/corpus/templates/dispatch/changelog/2026-07-08-settings-are-cleaner-and-searchable.md +5 -0
  213. package/corpus/templates/forms/app/routes/_app.settings.tsx +16 -1
  214. package/corpus/templates/forms/changelog/2026-07-08-settings-are-cleaner-and-searchable.md +5 -0
  215. package/corpus/templates/macros/app/routes/settings.tsx +16 -1
  216. package/corpus/templates/macros/changelog/2026-07-08-settings-are-cleaner-and-searchable.md +5 -0
  217. package/corpus/templates/mail/app/components/settings/GmailFiltersSection.tsx +1 -1
  218. package/corpus/templates/mail/app/components/settings/SnippetsSection.tsx +1 -1
  219. package/corpus/templates/mail/app/pages/SettingsPage.tsx +123 -105
  220. package/corpus/templates/mail/changelog/2026-07-08-settings-redesigned-with-a-consistent-searchable-layout.md +5 -0
  221. package/corpus/templates/plan/app/routes/settings.tsx +23 -2
  222. package/corpus/templates/plan/changelog/2026-07-08-settings-are-cleaner-and-searchable.md +5 -0
  223. package/corpus/templates/slides/actions/add-slide.ts +1 -0
  224. package/corpus/templates/slides/actions/get-design-system.ts +147 -1
  225. package/corpus/templates/slides/app/pages/Index.tsx +46 -1
  226. package/corpus/templates/slides/app/routes/settings.tsx +16 -1
  227. package/corpus/templates/slides/changelog/2026-07-08-deck-generation-now-follows-hydrated-builder-design-system-g.md +6 -0
  228. package/corpus/templates/slides/changelog/2026-07-08-settings-are-cleaner-and-searchable.md +5 -0
  229. package/dist/agent/durable-background.d.ts +1 -1
  230. package/dist/agent/durable-background.d.ts.map +1 -1
  231. package/dist/agent/durable-background.js +5 -3
  232. package/dist/agent/durable-background.js.map +1 -1
  233. package/dist/agent/engine/ai-sdk-engine.d.ts.map +1 -1
  234. package/dist/agent/engine/ai-sdk-engine.js +24 -4
  235. package/dist/agent/engine/ai-sdk-engine.js.map +1 -1
  236. package/dist/agent/engine/anthropic-engine.d.ts.map +1 -1
  237. package/dist/agent/engine/anthropic-engine.js +13 -3
  238. package/dist/agent/engine/anthropic-engine.js.map +1 -1
  239. package/dist/agent/engine/output-tokens.d.ts +27 -0
  240. package/dist/agent/engine/output-tokens.d.ts.map +1 -1
  241. package/dist/agent/engine/output-tokens.js +70 -0
  242. package/dist/agent/engine/output-tokens.js.map +1 -1
  243. package/dist/agent/production-agent.d.ts.map +1 -1
  244. package/dist/agent/production-agent.js +28 -7
  245. package/dist/agent/production-agent.js.map +1 -1
  246. package/dist/agent/run-ownership.d.ts +6 -0
  247. package/dist/agent/run-ownership.d.ts.map +1 -1
  248. package/dist/agent/run-ownership.js +11 -1
  249. package/dist/agent/run-ownership.js.map +1 -1
  250. package/dist/agent/types.d.ts +3 -2
  251. package/dist/agent/types.d.ts.map +1 -1
  252. package/dist/agent/types.js.map +1 -1
  253. package/dist/changelog/parse.d.ts +7 -0
  254. package/dist/changelog/parse.d.ts.map +1 -1
  255. package/dist/changelog/parse.js +64 -0
  256. package/dist/changelog/parse.js.map +1 -1
  257. package/dist/chat-threads/schema.d.ts +445 -0
  258. package/dist/chat-threads/schema.d.ts.map +1 -0
  259. package/dist/chat-threads/schema.js +39 -0
  260. package/dist/chat-threads/schema.js.map +1 -0
  261. package/dist/chat-threads/store.d.ts +12 -0
  262. package/dist/chat-threads/store.d.ts.map +1 -1
  263. package/dist/chat-threads/store.js +99 -10
  264. package/dist/chat-threads/store.js.map +1 -1
  265. package/dist/cli/workspace-dev.d.ts.map +1 -1
  266. package/dist/cli/workspace-dev.js +20 -5
  267. package/dist/cli/workspace-dev.js.map +1 -1
  268. package/dist/client/AgentPanel.d.ts.map +1 -1
  269. package/dist/client/AgentPanel.js +35 -7
  270. package/dist/client/AgentPanel.js.map +1 -1
  271. package/dist/client/AssistantChat.d.ts.map +1 -1
  272. package/dist/client/AssistantChat.js +105 -183
  273. package/dist/client/AssistantChat.js.map +1 -1
  274. package/dist/client/analytics-session.d.ts +3 -0
  275. package/dist/client/analytics-session.d.ts.map +1 -0
  276. package/dist/client/analytics-session.js +66 -0
  277. package/dist/client/analytics-session.js.map +1 -0
  278. package/dist/client/analytics.d.ts +32 -0
  279. package/dist/client/analytics.d.ts.map +1 -1
  280. package/dist/client/analytics.js +116 -46
  281. package/dist/client/analytics.js.map +1 -1
  282. package/dist/client/chat/message-components.d.ts +2 -1
  283. package/dist/client/chat/message-components.d.ts.map +1 -1
  284. package/dist/client/chat/message-components.js +16 -6
  285. package/dist/client/chat/message-components.js.map +1 -1
  286. package/dist/client/components/ui/message-scroller.d.ts +16 -0
  287. package/dist/client/components/ui/message-scroller.d.ts.map +1 -0
  288. package/dist/client/components/ui/message-scroller.js +25 -0
  289. package/dist/client/components/ui/message-scroller.js.map +1 -0
  290. package/dist/client/conversation/AgentConversation.d.ts +1 -1
  291. package/dist/client/conversation/AgentConversation.d.ts.map +1 -1
  292. package/dist/client/conversation/AgentConversation.js +3 -8
  293. package/dist/client/conversation/AgentConversation.js.map +1 -1
  294. package/dist/client/error-capture.d.ts +99 -0
  295. package/dist/client/error-capture.d.ts.map +1 -0
  296. package/dist/client/error-capture.js +437 -0
  297. package/dist/client/error-capture.js.map +1 -0
  298. package/dist/client/index.d.ts +2 -2
  299. package/dist/client/index.d.ts.map +1 -1
  300. package/dist/client/index.js +3 -1
  301. package/dist/client/index.js.map +1 -1
  302. package/dist/client/session-replay.d.ts +22 -0
  303. package/dist/client/session-replay.d.ts.map +1 -1
  304. package/dist/client/session-replay.js +45 -4
  305. package/dist/client/session-replay.js.map +1 -1
  306. package/dist/client/settings/SettingsPanel.d.ts.map +1 -1
  307. package/dist/client/settings/SettingsPanel.js +100 -5
  308. package/dist/client/settings/SettingsPanel.js.map +1 -1
  309. package/dist/client/settings/SettingsTabsPage.d.ts +49 -1
  310. package/dist/client/settings/SettingsTabsPage.d.ts.map +1 -1
  311. package/dist/client/settings/SettingsTabsPage.js +131 -19
  312. package/dist/client/settings/SettingsTabsPage.js.map +1 -1
  313. package/dist/client/settings/index.d.ts +1 -1
  314. package/dist/client/settings/index.d.ts.map +1 -1
  315. package/dist/client/settings/index.js.map +1 -1
  316. package/dist/client/sharing/ShareButton.d.ts.map +1 -1
  317. package/dist/client/sharing/ShareButton.js +13 -8
  318. package/dist/client/sharing/ShareButton.js.map +1 -1
  319. package/dist/client/sharing/ShareDialog.d.ts.map +1 -1
  320. package/dist/client/sharing/ShareDialog.js +12 -7
  321. package/dist/client/sharing/ShareDialog.js.map +1 -1
  322. package/dist/collab/routes.d.ts +1 -1
  323. package/dist/collab/struct-routes.d.ts +1 -1
  324. package/dist/db/client.d.ts.map +1 -1
  325. package/dist/db/client.js +12 -7
  326. package/dist/db/client.js.map +1 -1
  327. package/dist/mcp/builtin-tools.d.ts.map +1 -1
  328. package/dist/mcp/builtin-tools.js +21 -2
  329. package/dist/mcp/builtin-tools.js.map +1 -1
  330. package/dist/notifications/routes.d.ts +1 -1
  331. package/dist/observability/routes.d.ts +5 -5
  332. package/dist/org/schema.d.ts +15 -15
  333. package/dist/progress/routes.d.ts +1 -1
  334. package/dist/provider-api/corpus-jobs.d.ts +2 -2
  335. package/dist/resources/handlers.d.ts +3 -3
  336. package/dist/secrets/routes.d.ts +9 -9
  337. package/dist/server/agent-chat-plugin.d.ts.map +1 -1
  338. package/dist/server/agent-chat-plugin.js +109 -73
  339. package/dist/server/agent-chat-plugin.js.map +1 -1
  340. package/dist/server/agent-engine-api-key-route.d.ts +1 -1
  341. package/dist/server/onboarding-html.d.ts.map +1 -1
  342. package/dist/server/onboarding-html.js +28 -16
  343. package/dist/server/onboarding-html.js.map +1 -1
  344. package/dist/shared/reasoning-effort.d.ts +1 -0
  345. package/dist/shared/reasoning-effort.d.ts.map +1 -1
  346. package/dist/shared/reasoning-effort.js +18 -0
  347. package/dist/shared/reasoning-effort.js.map +1 -1
  348. package/dist/sharing/actions/list-resource-shares.js +30 -1
  349. package/dist/sharing/actions/list-resource-shares.js.map +1 -1
  350. package/dist/sharing/actions/share-resource.js +6 -0
  351. package/dist/sharing/actions/share-resource.js.map +1 -1
  352. package/dist/templates/workspace-core/.agents/skills/agent-native-toolkit/SKILL.md +4 -2
  353. package/dist/templates/workspace-core/.agents/skills/changelog/SKILL.md +9 -6
  354. package/dist/vite/client.d.ts.map +1 -1
  355. package/dist/vite/client.js +192 -30
  356. package/dist/vite/client.js.map +1 -1
  357. package/docs/content/toolkit-settings.mdx +56 -3
  358. package/package.json +2 -1
  359. package/src/templates/workspace-core/.agents/skills/agent-native-toolkit/SKILL.md +4 -2
  360. package/src/templates/workspace-core/.agents/skills/changelog/SKILL.md +9 -6
package/corpus/README.md CHANGED
@@ -27,5 +27,5 @@ rg -n "defineAction|useActionQuery" node_modules/@agent-native/core/corpus
27
27
 
28
28
  ## Generated Counts
29
29
 
30
- - core files: 2145
31
- - template files: 4841
30
+ - core files: 2149
31
+ - template files: 4940
@@ -1,5 +1,35 @@
1
1
  # @agent-native/core
2
2
 
3
+ ## 0.91.0
4
+
5
+ ### Minor Changes
6
+
7
+ - e310ac1: Add first-party, Sentry-style error capture to the analytics client SDK. `configureTracking({ errorCapture })` now auto-captures uncaught exceptions (`window.onerror`) and unhandled promise rejections, exposes a manual `captureException(error, context?)` / `captureMessage(message, level?)` API plus `addErrorBreadcrumb`, and ties each captured exception to the active session replay id so errors link straight to the recording they happened in. Captured exceptions are sent through the existing first-party analytics ingest as a dedicated `$exception` event and are redacted + deduped client-side. Additive and backward-compatible; error capture only installs when a public key is configured (or explicitly enabled).
8
+ - e310ac1: Revamp the shared settings shell (`SettingsTabsPage`): an edge-aligned,
9
+ independently scrolling left nav with consistent theming, a built-in settings
10
+ search that deep-links into tabs and sections via `searchEntries` /
11
+ `generalSearchEntries`, and a new controlled `value` / `onValueChange` mode so
12
+ apps can drive the active tab from their own routing and application state.
13
+ - e310ac1: Make agent-native chat threads shareable through the framework share dialog so collaborators can view or edit shared chats.
14
+
15
+ ### Patch Changes
16
+
17
+ - e310ac1: Populate in-app "What's new" surfaces from pending app changelog entries during dev and build.
18
+ - e310ac1: Use shadcn's message scroller primitives for core chat transcripts so streaming replies, turn anchoring, and scroll-to-bottom behavior stay smoother in long or dynamically resizing chats.
19
+ - e310ac1: Auto-continue recoverable chat run timeouts during reconnect without showing the internal resume prompt in chat history, and retry transient `ask_app_status` bridge fetch failures before surfacing an error.
20
+ - e310ac1: Recover Google popup sign-in pages when the session cookie is present but the parent page misses the automatic OAuth exchange redirect.
21
+ - e310ac1: Hide internal share principal ids in share dialogs by resolving organization names and using safe fallback labels.
22
+ - e310ac1: Fix Vite dev server resolution for Agent Native templates that load local or transitive `@agent-native/toolkit` subpath exports.
23
+ - e310ac1: Avoid repeated Sentry reports when workspace dev app discovery hits local filesystem permission errors.
24
+
25
+ ## 0.90.11
26
+
27
+ ### Patch Changes
28
+
29
+ - bba7332: Keep agent-chat workers on the hosted foreground timeout unless they are actually running inside a background function, preventing misrouted workers from being killed as stale runs.
30
+ - bba7332: Fix "The model returned an empty response" on hard/long-context chat turns: interactive chat now resolves max_output_tokens to min(model ceiling, 32K) instead of the flat 4096-8192 per-engine defaults, Anthropic/Gemini numeric thinking budgets are clamped to always leave real output headroom under max_tokens, and the empty-final-response retry now raises the token ceiling and steps reasoning effort down a tier (with the retry budget raised from 1 to 2 attempts) instead of re-issuing the identical doomed request.
31
+ - bba7332: Stop misrouted agent-chat workers from taking the large background Neon connection pool. `isBackgroundFunctionPoolContext()` no longer trusts the dispatch marker (`__AGENT_NATIVE_BACKGROUND_RUNTIME_EXPECTED__`) — a worker dispatched toward a `-background` URL but routed onto the ~60s synchronous function would otherwise open the 8-connection worker pool while running as one of many warm sync-function instances, exhausting the Neon pooled endpoint (connection terminated / statement timeouts / failed heartbeat writes surfacing as stale runs). Only the genuine `-background` runtime marker (set at cold start) unlocks the larger pool now, mirroring the same proof-of-landing tightening applied to the worker soft-timeout.
32
+
3
33
  ## 0.90.10
4
34
 
5
35
  ### Patch Changes
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: "Settings Kit"
3
- description: "A standard settings-page contract for app, agent, provider, team, and language settings."
3
+ description: "A standard, searchable settings-page contract for app, agent, provider, team, and language settings."
4
4
  ---
5
5
 
6
6
  # Settings Kit
@@ -10,11 +10,17 @@ not have to wonder whether model keys live in an app settings page, a giant
10
10
  agent sidebar panel, or a provider-specific setup card. The app route owns the
11
11
  page; framework tabs can be mounted inside it.
12
12
 
13
+ Every settings page is **searchable out of the box**: `<SettingsTabsPage>`
14
+ renders a search box that indexes tabs and their controls, so a user can type
15
+ "language", "S3", or "API key" and jump straight to the right section across any
16
+ tab — no hunting through the nav. This is a core value prop of the kit and comes
17
+ free the moment an app adopts the shared page.
18
+
13
19
  <WireframeBlock id="doc-block-toolkit-settings">
14
20
  <Screen
15
21
  surface="desktop"
16
22
  html={
17
- "<div style='min-height:520px;box-sizing:border-box;padding:26px;display:grid;grid-template-columns:200px 1fr;gap:18px'><aside class='wf-card' style='display:flex;flex-direction:column;gap:6px'><strong style='margin-bottom:4px'>Settings</strong><div style='padding:7px 9px;border-radius:8px'>General</div><div style='padding:7px 9px;border-radius:8px;background:var(--wf-accent-soft);display:flex;align-items:center;gap:8px'><span data-icon='settings'></span> AI and models</div><div style='padding:7px 9px;border-radius:8px'>Connections</div><div style='padding:7px 9px;border-radius:8px'>Team</div><div style='padding:7px 9px;border-radius:8px'>Developer</div></aside><main class='wf-card' style='display:flex;flex-direction:column;gap:14px'><h2 style='margin:0'>AI and models</h2><div style='display:flex;flex-direction:column;gap:6px'><small class='wf-muted'>Default model</small><div class='wf-box' style='display:flex;align-items:center;gap:8px'><div style='flex:1'>GPT-5</div><span data-icon='chevronDown'></span></div></div><div style='display:flex;flex-direction:column;gap:8px'><small class='wf-muted'>Provider keys</small><div class='wf-box' style='display:flex;align-items:center;gap:10px'><span data-icon='check'></span><div style='flex:1'>OpenAI</div><span class='wf-pill'>Connected</span></div><div class='wf-box' style='display:flex;align-items:center;gap:10px'><span data-icon='lock'></span><div style='flex:1'>Anthropic</div><button>Add key</button></div><div class='wf-box' style='display:flex;align-items:center;gap:10px'><span data-icon='check'></span><div style='flex:1'>Builder</div><span class='wf-pill'>Connected</span></div></div><div style='flex:1'></div><div style='display:flex;gap:10px'><button>Open agent settings</button><div style='flex:1'></div><button class='primary'>Save changes</button></div></main></div>"
23
+ "<div style='min-height:520px;box-sizing:border-box;padding:26px;display:grid;grid-template-columns:200px 1fr;gap:18px'><aside class='wf-card' style='display:flex;flex-direction:column;gap:6px'><strong style='margin-bottom:4px'>Settings</strong><div class='wf-box' style='display:flex;align-items:center;gap:8px;margin-bottom:4px'><span data-icon='search'></span><span class='wf-muted'>Search settings</span></div><div style='padding:7px 9px;border-radius:8px'>General</div><div style='padding:7px 9px;border-radius:8px;background:var(--wf-accent-soft);display:flex;align-items:center;gap:8px'><span data-icon='settings'></span> AI and models</div><div style='padding:7px 9px;border-radius:8px'>Connections</div><div style='padding:7px 9px;border-radius:8px'>Team</div><div style='padding:7px 9px;border-radius:8px'>Developer</div></aside><main class='wf-card' style='display:flex;flex-direction:column;gap:14px'><h2 style='margin:0'>AI and models</h2><div style='display:flex;flex-direction:column;gap:6px'><small class='wf-muted'>Default model</small><div class='wf-box' style='display:flex;align-items:center;gap:8px'><div style='flex:1'>GPT-5</div><span data-icon='chevronDown'></span></div></div><div style='display:flex;flex-direction:column;gap:8px'><small class='wf-muted'>Provider keys</small><div class='wf-box' style='display:flex;align-items:center;gap:10px'><span data-icon='check'></span><div style='flex:1'>OpenAI</div><span class='wf-pill'>Connected</span></div><div class='wf-box' style='display:flex;align-items:center;gap:10px'><span data-icon='lock'></span><div style='flex:1'>Anthropic</div><button>Add key</button></div><div class='wf-box' style='display:flex;align-items:center;gap:10px'><span data-icon='check'></span><div style='flex:1'>Builder</div><span class='wf-pill'>Connected</span></div></div><div style='flex:1'></div><div style='display:flex;gap:10px'><button>Open agent settings</button><div style='flex:1'></div><button class='primary'>Save changes</button></div></main></div>"
18
24
  }
19
25
  />
20
26
  </WireframeBlock>
@@ -23,8 +29,9 @@ page; framework tabs can be mounted inside it.
23
29
 
24
30
  | Piece | Purpose |
25
31
  | ------------------------ | ------------------------------------------------------------------------------------- |
26
- | `<SettingsTabsPage>` | Standard tabbed settings route surface. |
32
+ | `<SettingsTabsPage>` | Standard tabbed settings route surface with a built-in settings search box. |
27
33
  | `useAgentSettingsTabs()` | Framework-provided agent, model, key, automation, and voice tabs that apps can mount. |
34
+ | `SettingsSearchEntry` | A deep-link target (label, keywords, tab, and hash) that makes a control findable. |
28
35
  | `<LanguagePicker>` | Standard language selector for app settings. |
29
36
  | `openAgentSettings()` | Compatibility escape hatch for opening the sidebar settings tab when needed. |
30
37
  | Hash deep links | Stable links such as `/settings#secrets:OPENAI_API_KEY` and `/settings#connections`. |
@@ -52,10 +59,56 @@ export default function SettingsRoute() {
52
59
  }
53
60
  ```
54
61
 
62
+ ## Search {#search}
63
+
64
+ The search box is enabled by default. With no extra work it matches on tab
65
+ labels, so users can already filter the nav. To make individual controls
66
+ discoverable, register `SettingsSearchEntry` items — each result switches to the
67
+ right tab and scrolls to the target section:
68
+
69
+ ```tsx
70
+ const agentSettingsTabs = useAgentSettingsTabs(); // already ships search entries
71
+
72
+ return (
73
+ <SettingsTabsPage
74
+ extraTabs={[
75
+ {
76
+ id: "alerts",
77
+ label: "Alerts",
78
+ content: <AlertRulesSettingsCard />,
79
+ keywords: "notifications thresholds monitors",
80
+ searchEntries: [
81
+ { id: "alert-rules", label: "Alert rules", hash: "alert-rules" },
82
+ ],
83
+ },
84
+ ...agentSettingsTabs,
85
+ ]}
86
+ general={<LanguagePicker label="Interface language" />}
87
+ // Deep-link targets that live inside the General tab.
88
+ generalSearchEntries={[
89
+ {
90
+ id: "language",
91
+ label: "Language",
92
+ keywords: "locale translation interface",
93
+ hash: "language",
94
+ },
95
+ ]}
96
+ />
97
+ );
98
+ ```
99
+
100
+ Give each searchable card a matching `id` (e.g. `id="language"`) so the entry's
101
+ `hash` can scroll to it. Add `keywords` for synonyms and provider names the
102
+ label does not contain (e.g. "S3", "R2", "bucket" for replay storage). Set
103
+ `enableSearch={false}` only for trivial single-section pages; prefer keeping it
104
+ on so settings stay findable everywhere.
105
+
55
106
  ## UX Standard {#ux-standard}
56
107
 
57
108
  - Keep model keys, OAuth connections, Builder connect, language, team, and app
58
109
  preferences in one route.
110
+ - Keep search on and register a `SettingsSearchEntry` for every meaningful
111
+ control so users can find settings by name instead of scanning tabs.
59
112
  - Link to tabs by hash so setup prompts can send users to the exact missing
60
113
  credential.
61
114
  - Use the agent sidebar settings only as a compact access point, not as the
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-native/core",
3
- "version": "0.90.10",
3
+ "version": "0.91.0",
4
4
  "description": "Framework for agent-native application development — where AI agents and UI share SQL state, actions, and context",
5
5
  "homepage": "https://github.com/BuilderIO/agent-native#readme",
6
6
  "bugs": {
@@ -265,6 +265,7 @@
265
265
  "@rrweb/record": "2.0.1",
266
266
  "@sentry/browser": "10.60.0",
267
267
  "@sentry/node": "10.60.0",
268
+ "@shadcn/react": "^0.2.0",
268
269
  "@standard-schema/spec": "^1.1.0",
269
270
  "@tanstack/react-table": "^8.21.3",
270
271
  "@tiptap/core": "3.27.1",
@@ -260,12 +260,12 @@ export function backgroundRunMarkerExpectsBackgroundRuntime(
260
260
  }
261
261
 
262
262
  export function shouldUseBackgroundFunctionTimeoutForWorker(
263
- marker: unknown,
263
+ _marker: unknown,
264
264
  ): boolean {
265
- return (
266
- isInBackgroundFunctionRuntime() ||
267
- backgroundRunMarkerExpectsBackgroundRuntime(marker)
268
- );
265
+ // The dispatch marker says which URL the foreground targeted, not where the
266
+ // request actually landed. Only the worker runtime proof can safely lift the
267
+ // hosted 40s clamp to the 15-minute background-function budget.
268
+ return isInBackgroundFunctionRuntime();
269
269
  }
270
270
 
271
271
  export function backgroundRuntimeDiagnosticDetail(marker: unknown): string {
@@ -19,7 +19,10 @@ import {
19
19
  } from "../../server/credential-provider.js";
20
20
  import { normalizeReasoningEffortForModel } from "../../shared/reasoning-effort.js";
21
21
  import { AI_SDK_MODEL_CONFIG, type AISDKProvider } from "../model-config.js";
22
- import { resolveMaxOutputTokensForEngine } from "./output-tokens.js";
22
+ import {
23
+ clampThinkingBudgetTokens,
24
+ resolveMaxOutputTokensForEngine,
25
+ } from "./output-tokens.js";
23
26
  import {
24
27
  engineToolsToAISDK,
25
28
  engineMessagesToAISDK,
@@ -262,16 +265,34 @@ class AISDKEngine implements AgentEngine {
262
265
  toolResultImages: this.capabilities.vision,
263
266
  });
264
267
 
268
+ // Resolved once so both `maxOutputTokens` (below, in the streamText call)
269
+ // and the thinking-budget headroom clamp agree on the same ceiling.
270
+ const resolvedMaxOutputTokens = resolveMaxOutputTokensForEngine(
271
+ this.name,
272
+ opts.maxOutputTokens,
273
+ opts.model,
274
+ );
275
+
265
276
  // Build providerOptions for Anthropic-native features when using Anthropic provider
266
277
  const providerOpts: Record<string, unknown> = {};
267
278
  if (this.provider === "anthropic" && opts.providerOptions?.anthropic) {
268
279
  const anthropicOpts = opts.providerOptions.anthropic;
269
280
  if (anthropicOpts.thinking) {
281
+ // Only the "enabled" config carries a numeric budgetTokens; clamp it
282
+ // so thinking can't consume the entire maxOutputTokens budget and
283
+ // leave zero room for the actual response ("adaptive" thinking has
284
+ // no budgetTokens field at all per @ai-sdk/anthropic's schema).
270
285
  providerOpts.anthropic = {
271
286
  ...((providerOpts.anthropic as object) ?? {}),
272
287
  thinking: {
273
288
  type: "enabled",
274
- budgetTokens: anthropicOpts.thinking.budgetTokens,
289
+ budgetTokens:
290
+ typeof anthropicOpts.thinking.budgetTokens === "number"
291
+ ? clampThinkingBudgetTokens(
292
+ anthropicOpts.thinking.budgetTokens,
293
+ resolvedMaxOutputTokens,
294
+ )
295
+ : anthropicOpts.thinking.budgetTokens,
275
296
  },
276
297
  };
277
298
  }
@@ -309,11 +330,26 @@ class AISDKEngine implements AgentEngine {
309
330
  // Gemini 3.x models reject thinkingBudget — they require thinkingLevel.
310
331
  // Gemini 2.5.x models use thinkingBudget (integer token count or -1).
311
332
  const isGemini3 = /^gemini-3/.test(opts.model);
333
+ const thinkingBudget = googleThinkingBudget(reasoningEffort);
312
334
  providerOpts.google = {
313
335
  ...((providerOpts.google as object) ?? {}),
314
336
  thinkingConfig: isGemini3
315
337
  ? { thinkingLevel: gemini3ThinkingLevel(reasoningEffort) }
316
- : { thinkingBudget: googleThinkingBudget(reasoningEffort) },
338
+ : {
339
+ // Unlike Anthropic's adaptive thinking, Gemini 2.5's
340
+ // thinkingBudget IS a concrete numeric token count, so the
341
+ // same headroom clamp applies: at "max" effort this maps to
342
+ // 32000 tokens, which can equal (or exceed) a small
343
+ // maxOutputTokens cap and leave zero room for the actual
344
+ // response. Preserve Gemini's -1 "dynamic" sentinel.
345
+ thinkingBudget:
346
+ thinkingBudget > 0
347
+ ? clampThinkingBudgetTokens(
348
+ thinkingBudget,
349
+ resolvedMaxOutputTokens,
350
+ )
351
+ : thinkingBudget,
352
+ },
317
353
  };
318
354
  }
319
355
  }
@@ -326,11 +362,7 @@ class AISDKEngine implements AgentEngine {
326
362
  system: opts.systemPrompt,
327
363
  messages,
328
364
  tools: aiSdkTools,
329
- maxOutputTokens: resolveMaxOutputTokensForEngine(
330
- this.name,
331
- opts.maxOutputTokens,
332
- opts.model,
333
- ),
365
+ maxOutputTokens: resolvedMaxOutputTokens,
334
366
  ...(opts.temperature !== undefined
335
367
  ? { temperature: opts.temperature }
336
368
  : {}),
@@ -19,7 +19,10 @@ import {
19
19
  LLM_MISSING_CREDENTIALS_ERROR_CODE,
20
20
  LLM_MISSING_CREDENTIALS_MESSAGE,
21
21
  } from "./credential-errors.js";
22
- import { resolveMaxOutputTokensForEngine } from "./output-tokens.js";
22
+ import {
23
+ clampThinkingBudgetTokens,
24
+ resolveMaxOutputTokensForEngine,
25
+ } from "./output-tokens.js";
23
26
  import {
24
27
  engineToolsToAnthropic,
25
28
  engineMessagesToAnthropic,
@@ -67,12 +70,31 @@ class AnthropicEngine implements AgentEngine {
67
70
  const messages = engineMessagesToAnthropic(opts.messages);
68
71
  const anthropicOpts = opts.providerOptions?.anthropic;
69
72
 
73
+ // Resolved once so both max_tokens and the thinking-budget headroom
74
+ // clamp below agree on the same ceiling.
75
+ const resolvedMaxOutputTokens = resolveMaxOutputTokensForEngine(
76
+ this.name,
77
+ opts.maxOutputTokens,
78
+ opts.model,
79
+ );
80
+
70
81
  // Build extra body params for Anthropic-native features
71
82
  const extra: Record<string, unknown> = {};
72
83
  if (anthropicOpts?.thinking) {
73
84
  extra.thinking = {
74
85
  type: anthropicOpts.thinking.type,
75
- budget_tokens: anthropicOpts.thinking.budgetTokens,
86
+ // Only the "enabled" config carries a numeric budget_tokens; clamp it
87
+ // so thinking can't consume the entire max_tokens budget and leave
88
+ // zero room for the actual response ("adaptive" thinking has no
89
+ // budget_tokens field at all, so it passes through unclamped).
90
+ budget_tokens:
91
+ anthropicOpts.thinking.type === "enabled" &&
92
+ typeof anthropicOpts.thinking.budgetTokens === "number"
93
+ ? clampThinkingBudgetTokens(
94
+ anthropicOpts.thinking.budgetTokens,
95
+ resolvedMaxOutputTokens,
96
+ )
97
+ : anthropicOpts.thinking.budgetTokens,
76
98
  };
77
99
  }
78
100
  if (anthropicOpts?.topK !== undefined) {
@@ -139,11 +161,7 @@ class AnthropicEngine implements AgentEngine {
139
161
 
140
162
  const requestParams: any = {
141
163
  model: opts.model,
142
- max_tokens: resolveMaxOutputTokensForEngine(
143
- this.name,
144
- opts.maxOutputTokens,
145
- opts.model,
146
- ),
164
+ max_tokens: resolvedMaxOutputTokens,
147
165
  system: systemBlocks,
148
166
  tools: cachedTools.length > 0 ? cachedTools : undefined,
149
167
  messages: cachedMessages,
@@ -13,6 +13,100 @@ export const DEFAULT_AI_SDK_MAX_OUTPUT_TOKENS = 4096;
13
13
  export const DEFAULT_ANTHROPIC_MAX_OUTPUT_TOKENS = 8192;
14
14
  export const DEFAULT_BUILDER_MAX_OUTPUT_TOKENS = 8192;
15
15
 
16
+ // ---------------------------------------------------------------------------
17
+ // Main interactive chat path
18
+ //
19
+ // The per-engine defaults above (4096-8192) exist for internal/eval/
20
+ // observational-memory callers that intentionally want a small explicit cap.
21
+ // The main interactive chat turn (the one the end user is staring at) needs
22
+ // real headroom: on long-context or reasoning-heavy turns, a tiny completion
23
+ // budget means extended thinking alone can consume the entire response,
24
+ // leaving zero tokens for visible text/tool calls ("empty response" bug).
25
+ // These helpers give the chat path a much higher floor while staying at or
26
+ // under each model's documented ceiling — they never lower the ceiling.
27
+ // ---------------------------------------------------------------------------
28
+
29
+ /** Cap for the first attempt of an interactive chat turn. */
30
+ export const MAIN_CHAT_MAX_OUTPUT_TOKENS_CAP = 32_000;
31
+ /**
32
+ * Cap used only when retrying a turn that came back with an empty final
33
+ * response (see production-agent.ts's empty-final-response retry). Higher
34
+ * than the first-attempt cap so the retry meaningfully raises the ceiling.
35
+ */
36
+ export const EMPTY_RESPONSE_RETRY_MAX_OUTPUT_TOKENS_CAP = 64_000;
37
+
38
+ /**
39
+ * Resolve the max_output_tokens floor for the first attempt of an
40
+ * interactive chat turn: min(model ceiling, 32K). Always at or above the
41
+ * flat per-engine defaults above, regardless of whether the model is known.
42
+ */
43
+ export function resolveMainChatMaxOutputTokens(modelId?: string): number {
44
+ return Math.min(
45
+ getMaxOutputTokensForModel(modelId),
46
+ MAIN_CHAT_MAX_OUTPUT_TOKENS_CAP,
47
+ );
48
+ }
49
+
50
+ /**
51
+ * Resolve the max_output_tokens to use when retrying a turn after an empty
52
+ * final response: min(model ceiling, 64K).
53
+ */
54
+ export function resolveEmptyResponseRetryMaxOutputTokens(
55
+ modelId?: string,
56
+ ): number {
57
+ return Math.min(
58
+ getMaxOutputTokensForModel(modelId),
59
+ EMPTY_RESPONSE_RETRY_MAX_OUTPUT_TOKENS_CAP,
60
+ );
61
+ }
62
+
63
+ // ---------------------------------------------------------------------------
64
+ // Extended-thinking budget headroom
65
+ //
66
+ // Anthropic's `thinking: { type: "enabled", budget_tokens }` config requires
67
+ // budget_tokens >= 1024 and STRICTLY LESS THAN max_tokens (confirmed against
68
+ // the installed @anthropic-ai/sdk@0.90.0 type defs — see ThinkingConfigEnabled
69
+ // in resources/messages/messages.d.ts). budget_tokens counts toward
70
+ // max_tokens, so an unclamped large budget can leave too little (or zero)
71
+ // room for the actual visible completion. This clamp guarantees at least
72
+ // max(8000, 40% of maxOutputTokens) tokens of non-thinking headroom.
73
+ //
74
+ // Note: this only applies to the explicit numeric-budget "enabled" config.
75
+ // Anthropic's `type: "adaptive"` thinking config (used by the
76
+ // reasoningEffort -> output_config.effort mapping in anthropic-engine.ts /
77
+ // ai-sdk-engine.ts) has NO budget_tokens field at all per the SDK types, so
78
+ // there is nothing to clamp there — those callers rely on the raised
79
+ // maxOutputTokens ceiling above instead.
80
+ // ---------------------------------------------------------------------------
81
+
82
+ /** Anthropic's documented minimum extended-thinking budget. */
83
+ export const ANTHROPIC_MIN_THINKING_BUDGET_TOKENS = 1024;
84
+
85
+ /**
86
+ * Clamp a requested Anthropic thinking budget so it leaves guaranteed
87
+ * headroom under `maxOutputTokens` for non-thinking output, and stays within
88
+ * the provider's valid range (>= 1024, < maxOutputTokens).
89
+ */
90
+ export function clampThinkingBudgetTokens(
91
+ requestedBudgetTokens: number,
92
+ maxOutputTokens: number,
93
+ ): number | undefined {
94
+ if (maxOutputTokens <= ANTHROPIC_MIN_THINKING_BUDGET_TOKENS) {
95
+ return undefined;
96
+ }
97
+ const headroom = Math.max(8000, Math.round(0.4 * maxOutputTokens));
98
+ const budgetCapForHeadroom = Math.max(
99
+ ANTHROPIC_MIN_THINKING_BUDGET_TOKENS,
100
+ maxOutputTokens - headroom,
101
+ );
102
+ // budget_tokens must stay strictly below max_tokens per the API contract.
103
+ const strictUpperBound = maxOutputTokens - 1;
104
+ return Math.max(
105
+ ANTHROPIC_MIN_THINKING_BUDGET_TOKENS,
106
+ Math.min(requestedBudgetTokens, budgetCapForHeadroom, strictUpperBound),
107
+ );
108
+ }
109
+
16
110
  function parsePositiveInteger(value: unknown): number | null {
17
111
  if (typeof value === "string" && value.trim() === "") return null;
18
112
  const n =
@@ -45,6 +45,7 @@ import { fireInternalDispatch } from "../server/self-dispatch.js";
45
45
  import {
46
46
  isReasoningEffort,
47
47
  normalizeReasoningEffortForModel,
48
+ stepDownReasoningEffort,
48
49
  type ReasoningEffort,
49
50
  } from "../shared/reasoning-effort.js";
50
51
  import { actionPreparationContinuationNote } from "./action-continuation-guidance.js";
@@ -77,7 +78,11 @@ import {
77
78
  normalizeModelForEngine,
78
79
  isResolvedEngineUsableForRequest,
79
80
  } from "./engine/index.js";
80
- import { resolveMaxOutputTokensForEngine } from "./engine/output-tokens.js";
81
+ import {
82
+ resolveEmptyResponseRetryMaxOutputTokens,
83
+ resolveMainChatMaxOutputTokens,
84
+ resolveMaxOutputTokensForEngine,
85
+ } from "./engine/output-tokens.js";
81
86
  import { PROVIDER_TO_ENV } from "./engine/provider-env-vars.js";
82
87
  import {
83
88
  backfillEngineMessagesToolResults,
@@ -1015,7 +1020,10 @@ const TOOL_INPUT_ACTIVITY_INTERVAL_MS = 1500;
1015
1020
  const ACTION_PREPARATION_NO_PROGRESS_TIMEOUT_MS = 90_000;
1016
1021
  const ACTION_PREPARATION_ZERO_BYTE_RESTART_LIMIT = 2;
1017
1022
  const MODEL_STREAM_NO_PROGRESS_TIMEOUT_MS = 90_000;
1018
- const EMPTY_FINAL_RESPONSE_RETRY_LIMIT = 1;
1023
+ // Raised from 1 -> 2 now that each retry actually adapts (raises the token
1024
+ // ceiling and steps reasoning effort down a tier) instead of re-issuing the
1025
+ // exact same doomed request twice.
1026
+ const EMPTY_FINAL_RESPONSE_RETRY_LIMIT = 2;
1019
1027
  const MAIN_CHAT_INTERNAL_CONTINUATION_LIMIT = 6;
1020
1028
  const RUN_BUDGET_EXHAUSTED_ERROR_CODE = "run_budget_exhausted";
1021
1029
  const RUN_BUDGET_EXHAUSTED_MESSAGE =
@@ -2736,6 +2744,12 @@ export async function runAgentLoop(opts: {
2736
2744
  let finalGuardRetries = 0;
2737
2745
  let emptyFinalResponseRetries = 0;
2738
2746
  let iterations = 0;
2747
+ // Overridden (raised tokens, lowered effort) only after an empty-final-
2748
+ // response retry below — kept separate from `opts.maxOutputTokens`/
2749
+ // `opts.reasoningEffort` so the very first attempt is unaffected and later
2750
+ // tool-loop turns revert to the caller's original request after a success.
2751
+ let effectiveMaxOutputTokens = opts.maxOutputTokens;
2752
+ let effectiveReasoningEffort = opts.reasoningEffort;
2739
2753
 
2740
2754
  // Set when an in-loop processor aborts via `abort()` / throws a `TripWire`.
2741
2755
  // The loop emits the `tripwire` event, surfaces the reason as a final
@@ -2845,10 +2859,10 @@ export async function runAgentLoop(opts: {
2845
2859
  abortSignal: signal,
2846
2860
  maxOutputTokens: resolveMaxOutputTokensForEngine(
2847
2861
  engine.name,
2848
- opts.maxOutputTokens,
2862
+ effectiveMaxOutputTokens,
2849
2863
  model,
2850
2864
  ),
2851
- reasoningEffort: opts.reasoningEffort,
2865
+ reasoningEffort: effectiveReasoningEffort,
2852
2866
  providerOptions: opts.providerOptions,
2853
2867
  };
2854
2868
 
@@ -3351,8 +3365,10 @@ export async function runAgentLoop(opts: {
3351
3365
  // text — typically when reasoning consumes the entire output-token
3352
3366
  // budget. Without a final text part the SSE stream still ends with a
3353
3367
  // clean `done`, which renders as a totally empty assistant bubble.
3354
- // Retry once so a transient reasoning-budget miss can still finish; if
3355
- // the retry also has no visible content, surface a plain-language error.
3368
+ // Retry so a reasoning-budget miss can still finish; each retry raises
3369
+ // the token ceiling and steps reasoning effort down a tier so it's not
3370
+ // just re-issuing the identical doomed request. If retries also come
3371
+ // back empty, surface a plain-language error.
3356
3372
  const hasEmptyFinalResponse =
3357
3373
  !guardEmittedFallback &&
3358
3374
  collectTextParts(assistantContentForHistory).trim().length === 0 &&
@@ -3360,6 +3376,11 @@ export async function runAgentLoop(opts: {
3360
3376
  if (hasEmptyFinalResponse) {
3361
3377
  if (emptyFinalResponseRetries < EMPTY_FINAL_RESPONSE_RETRY_LIMIT) {
3362
3378
  emptyFinalResponseRetries += 1;
3379
+ effectiveMaxOutputTokens =
3380
+ resolveEmptyResponseRetryMaxOutputTokens(model);
3381
+ effectiveReasoningEffort = stepDownReasoningEffort(
3382
+ effectiveReasoningEffort,
3383
+ );
3363
3384
  appendAgentLoopContinuation(messages, "max_tokens");
3364
3385
  continue;
3365
3386
  }
@@ -3369,6 +3390,8 @@ export async function runAgentLoop(opts: {
3369
3390
  });
3370
3391
  } else {
3371
3392
  emptyFinalResponseRetries = 0;
3393
+ effectiveMaxOutputTokens = opts.maxOutputTokens;
3394
+ effectiveReasoningEffort = opts.reasoningEffort;
3372
3395
  }
3373
3396
  break;
3374
3397
  }
@@ -6795,6 +6818,11 @@ export function createProductionAgentHandler(
6795
6818
  orgId: getRequestOrgId() ?? null,
6796
6819
  attachments: requestAttachments,
6797
6820
  reasoningEffort,
6821
+ // The interactive chat turn needs real completion headroom — the
6822
+ // flat per-engine defaults (4096-8192) exist for internal/eval
6823
+ // callers and are far below what a hard, long-context turn needs
6824
+ // once extended thinking is in play. See output-tokens.ts.
6825
+ maxOutputTokens: resolveMainChatMaxOutputTokens(effectiveModel),
6798
6826
  providerOptions: options.providerOptions,
6799
6827
  executionMode: requestMode,
6800
6828
  maxIterations: loopSettings.maxIterations,
@@ -1,4 +1,6 @@
1
- import { getThread } from "../chat-threads/store.js";
1
+ import { getThread, resolveThreadAccess } from "../chat-threads/store.js";
2
+ import type { AccessContext } from "../sharing/access.js";
3
+ import type { ShareRole } from "../sharing/schema.js";
2
4
  /**
3
5
  * Ownership checks for the agent run HTTP routes (`/runs/:id/events`,
4
6
  * `/runs/:id/abort`, `/runs/active`).
@@ -38,6 +40,17 @@ export async function callerOwnsThread(
38
40
  return !!thread && thread.ownerEmail === owner;
39
41
  }
40
42
 
43
+ /** True when `owner` has at least `role` access to the chat thread. */
44
+ export async function callerHasThreadAccess(
45
+ owner: string,
46
+ threadId: string | null | undefined,
47
+ role: ShareRole | "owner" = "viewer",
48
+ ctx: Omit<AccessContext, "userEmail"> = {},
49
+ ): Promise<boolean> {
50
+ if (!threadId) return false;
51
+ return !!(await resolveThreadAccess(owner, threadId, role, ctx));
52
+ }
53
+
41
54
  /** True when `owner` owns the thread that run `runId` belongs to. */
42
55
  export async function callerOwnsRun(
43
56
  owner: string,
@@ -45,3 +58,18 @@ export async function callerOwnsRun(
45
58
  ): Promise<boolean> {
46
59
  return callerOwnsThread(owner, await resolveRunThreadId(runId));
47
60
  }
61
+
62
+ /** True when `owner` has at least `role` access to the thread behind `runId`. */
63
+ export async function callerHasRunAccess(
64
+ owner: string,
65
+ runId: string,
66
+ role: ShareRole | "owner" = "viewer",
67
+ ctx: Omit<AccessContext, "userEmail"> = {},
68
+ ): Promise<boolean> {
69
+ return callerHasThreadAccess(
70
+ owner,
71
+ await resolveRunThreadId(runId),
72
+ role,
73
+ ctx,
74
+ );
75
+ }
@@ -180,8 +180,9 @@ export interface AgentChatRequest {
180
180
  continuationCount?: number;
181
181
  /**
182
182
  * True when the dispatcher expects the self-POST to land in a real
183
- * Netlify `-background` function (15-min budget) rather than the ~60s
184
- * synchronous function. See `shouldUseBackgroundFunctionTimeoutForWorker`.
183
+ * Netlify `-background` function rather than the ~60s synchronous function.
184
+ * This is diagnostic only; the 15-minute budget is unlocked by the worker's
185
+ * actual runtime marker.
185
186
  */
186
187
  backgroundFunctionRuntimeExpected?: boolean;
187
188
  /**