@agent-native/core 0.121.1 → 0.122.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 (465) hide show
  1. package/corpus/README.md +2 -2
  2. package/corpus/core/CHANGELOG.md +145 -0
  3. package/corpus/core/docs/content/actions.mdx +2 -2
  4. package/corpus/core/docs/content/agent-surfaces.mdx +1 -1
  5. package/corpus/core/docs/content/authentication.mdx +2 -0
  6. package/corpus/core/docs/content/deployment.mdx +36 -0
  7. package/corpus/core/docs/content/getting-started.mdx +477 -115
  8. package/corpus/core/docs/content/http-api.mdx +266 -0
  9. package/corpus/core/docs/content/syncing-template-changes.mdx +159 -0
  10. package/corpus/core/package.json +2 -1
  11. package/corpus/core/src/a2a/activity.ts +38 -27
  12. package/corpus/core/src/agent/engine/builder-engine.ts +35 -4
  13. package/corpus/core/src/agent/run-manager.ts +20 -1
  14. package/corpus/core/src/agent/run-store.ts +4 -1
  15. package/corpus/core/src/agent/types.ts +28 -8
  16. package/corpus/core/src/chat-threads/store.ts +45 -0
  17. package/corpus/core/src/checkpoints/index.ts +2 -0
  18. package/corpus/core/src/checkpoints/route-match.ts +13 -0
  19. package/corpus/core/src/cli/create.ts +105 -17
  20. package/corpus/core/src/cli/index.ts +20 -0
  21. package/corpus/core/src/cli/template-baseline.ts +410 -0
  22. package/corpus/core/src/cli/template-sync.ts +1004 -0
  23. package/corpus/core/src/cli/templates-meta.ts +1 -0
  24. package/corpus/core/src/client/AssistantChat.tsx +38 -12
  25. package/corpus/core/src/client/NewWorkspaceAppFlow.tsx +75 -10
  26. package/corpus/core/src/client/chat/message-components.tsx +127 -66
  27. package/corpus/core/src/client/chat/tool-call-display.tsx +29 -5
  28. package/corpus/core/src/client/error-format.ts +18 -0
  29. package/corpus/core/src/client/org/OrgSwitcher.tsx +30 -8
  30. package/corpus/core/src/client/org/TeamPage.tsx +7 -6
  31. package/corpus/core/src/client/sse-event-processor.ts +3 -0
  32. package/corpus/core/src/data-widgets/index.ts +41 -0
  33. package/corpus/core/src/deploy/build.ts +11 -9
  34. package/corpus/core/src/integrations/webhook-handler.ts +63 -9
  35. package/corpus/core/src/org/auto-join-domain.ts +4 -3
  36. package/corpus/core/src/org/context.ts +108 -39
  37. package/corpus/core/src/org/index.ts +5 -0
  38. package/corpus/core/src/org/service-identity.ts +60 -0
  39. package/corpus/core/src/provider-api/index.ts +22 -1
  40. package/corpus/core/src/scripts/docs/search.ts +12 -1
  41. package/corpus/core/src/server/agent-chat/context-tools.ts +9 -4
  42. package/corpus/core/src/server/agent-chat/framework-prompts.ts +38 -66
  43. package/corpus/core/src/server/agent-chat-plugin.ts +17 -10
  44. package/corpus/core/src/server/agents-bundle.ts +84 -5
  45. package/corpus/core/src/server/auth.ts +4 -3
  46. package/corpus/core/src/server/builder-browser.ts +47 -19
  47. package/corpus/core/src/server/core-routes-plugin.ts +2 -2
  48. package/corpus/core/src/server/credential-provider.ts +209 -68
  49. package/corpus/core/src/server/index.ts +3 -0
  50. package/corpus/core/src/server/prompts/framework-core-compact.ts +6 -13
  51. package/corpus/core/src/server/prompts/framework-core.ts +9 -21
  52. package/corpus/core/src/server/prompts/index.ts +0 -1
  53. package/corpus/core/src/server/prompts/shared-rules.ts +19 -11
  54. package/corpus/core/src/server/ssr-handler.ts +13 -2
  55. package/corpus/core/src/settings/user-settings.ts +13 -1
  56. package/corpus/core/src/shared/cache-control.ts +141 -0
  57. package/corpus/core/src/templates/chat/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
  58. package/corpus/core/src/templates/chat/_gitignore +1 -0
  59. package/corpus/core/src/templates/default/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
  60. package/corpus/core/src/templates/headless/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
  61. package/corpus/core/src/templates/workspace-core/.agents/skills/performance/SKILL.md +19 -0
  62. package/corpus/core/src/templates/workspace-core/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
  63. package/corpus/core/src/templates/workspace-core/.agents/skills/visual-answer/SKILL.md +1 -0
  64. package/corpus/core/src/vite/agents-bundle-plugin.ts +7 -6
  65. package/corpus/core/src/vite/client.ts +5 -0
  66. package/corpus/templates/analytics/.agents/skills/adhoc-analysis/SKILL.md +4 -5
  67. package/corpus/templates/analytics/.agents/skills/admin-surfaces/SKILL.md +55 -0
  68. package/corpus/templates/analytics/.agents/skills/dashboard-management/SKILL.md +10 -0
  69. package/corpus/templates/analytics/.agents/skills/dashboard-management/references/template-catalog-and-demo.md +62 -0
  70. package/corpus/templates/analytics/.agents/skills/dashboard-ops/SKILL.md +85 -0
  71. package/corpus/templates/analytics/.agents/skills/data-querying/SKILL.md +27 -2
  72. package/corpus/templates/analytics/.agents/skills/data-querying/references/inline-chart-embeds.md +139 -0
  73. package/corpus/templates/analytics/.agents/skills/monitoring/SKILL.md +77 -0
  74. package/corpus/templates/analytics/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
  75. package/corpus/templates/analytics/AGENTS.md +91 -563
  76. package/corpus/templates/analytics/_gitignore +1 -0
  77. package/corpus/templates/analytics/actions/bigquery.ts +12 -4
  78. package/corpus/templates/analytics/actions/generate-chart.ts +5 -5
  79. package/corpus/templates/analytics/app/components/dashboard/SqlChart.tsx +30 -1
  80. package/corpus/templates/analytics/app/pages/adhoc/sql-dashboard/DashboardFilterBar.tsx +3 -0
  81. package/corpus/templates/analytics/app/pages/adhoc/sql-dashboard/SqlChartCard.tsx +1 -1
  82. package/corpus/templates/analytics/app/pages/adhoc/sql-dashboard/index.tsx +1 -0
  83. package/corpus/templates/analytics/changelog/2026-07-24-analytics-finds-saved-dashboards-and-queries-far-more-reliab.md +6 -0
  84. package/corpus/templates/analytics/changelog/2026-07-24-notion-access-errors-now-explain-that-a-page-needs-sharing-w.md +6 -0
  85. package/corpus/templates/analytics/server/lib/agent-chat-plan-mode.ts +7 -0
  86. package/corpus/templates/analytics/server/lib/analytics-query-catalog.ts +191 -30
  87. package/corpus/templates/analytics/server/lib/bigquery.ts +11 -1
  88. package/corpus/templates/analytics/server/lib/notion.ts +15 -4
  89. package/corpus/templates/analytics/server/plugins/agent-chat.ts +10 -0
  90. package/corpus/templates/assets/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
  91. package/corpus/templates/brain/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
  92. package/corpus/templates/brain/_gitignore +1 -0
  93. package/corpus/templates/calendar/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
  94. package/corpus/templates/calendar/_gitignore +1 -0
  95. package/corpus/templates/chat/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
  96. package/corpus/templates/chat/_gitignore +1 -0
  97. package/corpus/templates/clips/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
  98. package/corpus/templates/clips/.agents/skills/video-sharing/SKILL.md +34 -0
  99. package/corpus/templates/clips/AGENTS.md +5 -4
  100. package/corpus/templates/clips/_gitignore +1 -0
  101. package/corpus/templates/clips/actions/cleanup-transcript.ts +5 -0
  102. package/corpus/templates/clips/actions/get-recording-insights.ts +44 -8
  103. package/corpus/templates/clips/actions/get-recording-player-data.ts +39 -70
  104. package/corpus/templates/clips/actions/list-clip-views.ts +2 -4
  105. package/corpus/templates/clips/actions/list-recordings.ts +69 -19
  106. package/corpus/templates/clips/actions/list-viewers.ts +5 -2
  107. package/corpus/templates/clips/actions/regenerate-summary.ts +5 -1
  108. package/corpus/templates/clips/actions/request-transcript.ts +28 -1
  109. package/corpus/templates/clips/app/components/editor/stitch-manager.tsx +21 -1
  110. package/corpus/templates/clips/app/components/meetings/quick-ask-sidebar.tsx +14 -1
  111. package/corpus/templates/clips/app/components/player/insights-panel.tsx +8 -20
  112. package/corpus/templates/clips/app/components/player/recording-views-badge.tsx +335 -0
  113. package/corpus/templates/clips/app/components/player/video-player.tsx +13 -8
  114. package/corpus/templates/clips/app/components/sharing/share-ui.tsx +2 -1
  115. package/corpus/templates/clips/app/i18n/en-US.ts +13 -2
  116. package/corpus/templates/clips/app/lib/capture-permissions.ts +110 -0
  117. package/corpus/templates/clips/app/lib/recording-link.ts +32 -0
  118. package/corpus/templates/clips/app/routes/_app.meetings.$meetingId.tsx +27 -0
  119. package/corpus/templates/clips/app/routes/r.$recordingId.tsx +46 -15
  120. package/corpus/templates/clips/app/routes/record.tsx +77 -31
  121. package/corpus/templates/clips/app/routes/share.$shareId.tsx +42 -31
  122. package/corpus/templates/clips/changelog/2026-07-24-clip-pages-now-show-a-view-count-with-viewer-avatars-next-to.md +6 -0
  123. package/corpus/templates/clips/changelog/2026-07-24-clip-summaries-read-like-a-description-you-d-write-yourself-.md +6 -0
  124. package/corpus/templates/clips/changelog/2026-07-24-clip-view-counts-now-separate-human-views-from-agent-views-s.md +6 -0
  125. package/corpus/templates/clips/changelog/2026-07-24-clips-actions-can-now-be-called-by-org-service-tokens-so-ext.md +6 -0
  126. package/corpus/templates/clips/changelog/2026-07-24-clips-no-longer-briefly-shows-a-dock-icon-while-launching.md +6 -0
  127. package/corpus/templates/clips/changelog/2026-07-24-fixed-owner-and-editor-share-links-redirecting-to-the-record.md +6 -0
  128. package/corpus/templates/clips/changelog/2026-07-24-meeting-and-note-recordings-now-start-as-a-compact-pill-on-t.md +6 -0
  129. package/corpus/templates/clips/changelog/2026-07-24-new-clips-now-copy-a-shareable-link-instead-of-the-owner-onl.md +6 -0
  130. package/corpus/templates/clips/changelog/2026-07-24-opening-a-share-link-as-the-clip-s-owner-now-goes-straight-t.md +6 -0
  131. package/corpus/templates/clips/changelog/2026-07-24-permissions-and-rewind-controls-now-use-compact-consistent-h.md +6 -0
  132. package/corpus/templates/clips/changelog/2026-07-24-quitting-the-desktop-app-no-longer-shows-a-false-macos-crash.md +6 -0
  133. package/corpus/templates/clips/changelog/2026-07-24-screen-recording-permission-errors-now-name-the-exact-app-to.md +6 -0
  134. package/corpus/templates/clips/changelog/2026-07-24-the-desktop-app-now-copies-a-new-clip-s-share-link-to-your-c.md +6 -0
  135. package/corpus/templates/clips/changelog/2026-07-24-the-recording-toolbar-now-stays-above-other-apps-including-o.md +6 -0
  136. package/corpus/templates/clips/changelog/2026-07-24-transcript-captions-now-use-real-speech-timings-instead-of-a.md +6 -0
  137. package/corpus/templates/clips/changelog/2026-07-24-video-playback-no-longer-stutters-and-replays-the-last-momen.md +6 -0
  138. package/corpus/templates/clips/chrome-extension/src/background.ts +17 -1
  139. package/corpus/templates/clips/desktop/package.json +2 -0
  140. package/corpus/templates/clips/desktop/src/app.tsx +89 -0
  141. package/corpus/templates/clips/desktop/src/hooks/useMeetingTranscription.ts +9 -3
  142. package/corpus/templates/clips/desktop/src/lib/audio-meter.ts +51 -0
  143. package/corpus/templates/clips/desktop/src/lib/native-notification.ts +44 -0
  144. package/corpus/templates/clips/desktop/src/lib/recording-link.ts +67 -0
  145. package/corpus/templates/clips/desktop/src/overlays/live-audio-bars.tsx +35 -35
  146. package/corpus/templates/clips/desktop/src/overlays/live-transcript.tsx +3 -2
  147. package/corpus/templates/clips/desktop/src/overlays/recording-pill.tsx +47 -46
  148. package/corpus/templates/clips/desktop/src/styles.css +127 -78
  149. package/corpus/templates/clips/desktop/src-tauri/Cargo.toml +7 -0
  150. package/corpus/templates/clips/desktop/src-tauri/Info.plist +6 -0
  151. package/corpus/templates/clips/desktop/src-tauri/capabilities/default.json +1 -0
  152. package/corpus/templates/clips/desktop/src-tauri/src/clips/mod.rs +7 -3
  153. package/corpus/templates/clips/desktop/src-tauri/src/lib.rs +4 -1
  154. package/corpus/templates/clips/desktop/src-tauri/src/main.rs +8 -0
  155. package/corpus/templates/clips/desktop/src-tauri/src/recording_indicator.rs +21 -10
  156. package/corpus/templates/clips/desktop/src-tauri/src/util.rs +40 -0
  157. package/corpus/templates/clips/server/db/schema.ts +25 -0
  158. package/corpus/templates/clips/server/lib/agent-views.ts +145 -0
  159. package/corpus/templates/clips/server/lib/public-agent-context.ts +7 -0
  160. package/corpus/templates/clips/server/lib/recording-share-grant.ts +79 -0
  161. package/corpus/templates/clips/server/lib/recordings.ts +51 -3
  162. package/corpus/templates/clips/server/plugins/db.ts +23 -0
  163. package/corpus/templates/clips/server/routes/api/public-recording.get.ts +49 -17
  164. package/corpus/templates/clips/shared/recording-link.ts +43 -0
  165. package/corpus/templates/clips/shared/share-attribution.ts +4 -0
  166. package/corpus/templates/clips/shared/share-dashboard-redirect.ts +42 -0
  167. package/corpus/templates/clips/shared/view-analytics.ts +26 -0
  168. package/corpus/templates/content/.agents/skills/content/SKILL.md +5 -0
  169. package/corpus/templates/content/.agents/skills/content/references/local-file-mode.md +135 -0
  170. package/corpus/templates/content/.agents/skills/document-editing/SKILL.md +12 -0
  171. package/corpus/templates/content/.agents/skills/document-editing/references/databases.md +238 -0
  172. package/corpus/templates/content/.agents/skills/document-editing/references/document-behavior.md +91 -0
  173. package/corpus/templates/content/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
  174. package/corpus/templates/content/AGENTS.md +62 -583
  175. package/corpus/templates/content/_gitignore +1 -0
  176. package/corpus/templates/design/.agents/skills/creative-context/SKILL.md +11 -0
  177. package/corpus/templates/design/.agents/skills/design-generation/SKILL.md +50 -8
  178. package/corpus/templates/design/.agents/skills/design-generation/references/code-layers.md +81 -0
  179. package/corpus/templates/design/.agents/skills/design-generation/references/code-workspace.md +42 -0
  180. package/corpus/templates/design/.agents/skills/design-generation/references/editor-extensions.md +34 -0
  181. package/corpus/templates/design/.agents/skills/responsive-breakpoints/SKILL.md +4 -1
  182. package/corpus/templates/design/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
  183. package/corpus/templates/design/.agents/skills/visual-edit/SKILL.md +17 -0
  184. package/corpus/templates/design/.generated/bridge/editor-chrome.generated.ts +8196 -0
  185. package/corpus/templates/design/.generated/bridge/embedded-wheel.generated.ts +265 -0
  186. package/corpus/templates/design/.generated/bridge/hit-test.generated.ts +642 -0
  187. package/corpus/templates/design/.generated/bridge/motion-preview.generated.ts +571 -0
  188. package/corpus/templates/design/.generated/bridge/nav.generated.ts +91 -0
  189. package/corpus/templates/design/.generated/bridge/sample.generated.ts +23 -0
  190. package/corpus/templates/design/.generated/bridge/shader-fill-preview.generated.ts +263 -0
  191. package/corpus/templates/design/.generated/bridge/shader-runtime.generated.ts +518 -0
  192. package/corpus/templates/design/.generated/bridge/tweak.generated.ts +20 -0
  193. package/corpus/templates/design/.generated/bridge/zoom.generated.ts +32 -0
  194. package/corpus/templates/design/AGENTS.md +88 -503
  195. package/corpus/templates/design/_gitignore +1 -0
  196. package/corpus/templates/dispatch/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
  197. package/corpus/templates/dispatch/_gitignore +1 -0
  198. package/corpus/templates/dispatch/changelog/2026-07-24-signing-in-now-puts-you-in-your-companys-workspace.md +6 -0
  199. package/corpus/templates/forms/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
  200. package/corpus/templates/forms/_gitignore +1 -0
  201. package/corpus/templates/forms/server/lib/public-form-ssr.ts +2 -2
  202. package/corpus/templates/macros/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
  203. package/corpus/templates/macros/_gitignore +1 -0
  204. package/corpus/templates/mail/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
  205. package/corpus/templates/mail/_gitignore +1 -0
  206. package/corpus/templates/plan/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
  207. package/corpus/templates/plan/_gitignore +1 -0
  208. package/corpus/templates/slides/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
  209. package/corpus/templates/slides/_gitignore +1 -0
  210. package/corpus/templates/slides/server/plugins/db.ts +4 -0
  211. package/corpus/templates/tasks/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
  212. package/corpus/templates/tasks/AGENTS.md +1 -1
  213. package/corpus/templates/tasks/_gitignore +1 -0
  214. package/dist/a2a/activity.d.ts +4 -1
  215. package/dist/a2a/activity.d.ts.map +1 -1
  216. package/dist/a2a/activity.js +27 -16
  217. package/dist/a2a/activity.js.map +1 -1
  218. package/dist/agent/engine/builder-engine.d.ts +1 -0
  219. package/dist/agent/engine/builder-engine.d.ts.map +1 -1
  220. package/dist/agent/engine/builder-engine.js +31 -4
  221. package/dist/agent/engine/builder-engine.js.map +1 -1
  222. package/dist/agent/run-manager.d.ts.map +1 -1
  223. package/dist/agent/run-manager.js +18 -1
  224. package/dist/agent/run-manager.js.map +1 -1
  225. package/dist/agent/run-store.d.ts +1 -0
  226. package/dist/agent/run-store.d.ts.map +1 -1
  227. package/dist/agent/run-store.js +2 -1
  228. package/dist/agent/run-store.js.map +1 -1
  229. package/dist/agent/types.d.ts +12 -1
  230. package/dist/agent/types.d.ts.map +1 -1
  231. package/dist/agent/types.js +21 -1
  232. package/dist/agent/types.js.map +1 -1
  233. package/dist/chat-threads/store.d.ts +10 -0
  234. package/dist/chat-threads/store.d.ts.map +1 -1
  235. package/dist/chat-threads/store.js +41 -0
  236. package/dist/chat-threads/store.js.map +1 -1
  237. package/dist/checkpoints/index.d.ts +1 -0
  238. package/dist/checkpoints/index.d.ts.map +1 -1
  239. package/dist/checkpoints/index.js +1 -0
  240. package/dist/checkpoints/index.js.map +1 -1
  241. package/dist/checkpoints/route-match.d.ts +8 -0
  242. package/dist/checkpoints/route-match.d.ts.map +1 -0
  243. package/dist/checkpoints/route-match.js +13 -0
  244. package/dist/checkpoints/route-match.js.map +1 -0
  245. package/dist/cli/create.d.ts +35 -4
  246. package/dist/cli/create.d.ts.map +1 -1
  247. package/dist/cli/create.js +69 -19
  248. package/dist/cli/create.js.map +1 -1
  249. package/dist/cli/index.js +19 -0
  250. package/dist/cli/index.js.map +1 -1
  251. package/dist/cli/template-baseline.d.ts +54 -0
  252. package/dist/cli/template-baseline.d.ts.map +1 -0
  253. package/dist/cli/template-baseline.js +334 -0
  254. package/dist/cli/template-baseline.js.map +1 -0
  255. package/dist/cli/template-sync.d.ts +57 -0
  256. package/dist/cli/template-sync.d.ts.map +1 -0
  257. package/dist/cli/template-sync.js +787 -0
  258. package/dist/cli/template-sync.js.map +1 -0
  259. package/dist/cli/templates-meta.d.ts.map +1 -1
  260. package/dist/cli/templates-meta.js +1 -0
  261. package/dist/cli/templates-meta.js.map +1 -1
  262. package/dist/client/AssistantChat.d.ts +2 -1
  263. package/dist/client/AssistantChat.d.ts.map +1 -1
  264. package/dist/client/AssistantChat.js +38 -10
  265. package/dist/client/AssistantChat.js.map +1 -1
  266. package/dist/client/NewWorkspaceAppFlow.d.ts.map +1 -1
  267. package/dist/client/NewWorkspaceAppFlow.js +32 -2
  268. package/dist/client/NewWorkspaceAppFlow.js.map +1 -1
  269. package/dist/client/chat/message-components.d.ts +20 -0
  270. package/dist/client/chat/message-components.d.ts.map +1 -1
  271. package/dist/client/chat/message-components.js +81 -46
  272. package/dist/client/chat/message-components.js.map +1 -1
  273. package/dist/client/chat/tool-call-display.d.ts.map +1 -1
  274. package/dist/client/chat/tool-call-display.js +14 -6
  275. package/dist/client/chat/tool-call-display.js.map +1 -1
  276. package/dist/client/error-format.d.ts.map +1 -1
  277. package/dist/client/error-format.js +13 -0
  278. package/dist/client/error-format.js.map +1 -1
  279. package/dist/client/org/OrgSwitcher.d.ts +8 -1
  280. package/dist/client/org/OrgSwitcher.d.ts.map +1 -1
  281. package/dist/client/org/OrgSwitcher.js +3 -2
  282. package/dist/client/org/OrgSwitcher.js.map +1 -1
  283. package/dist/client/org/TeamPage.d.ts.map +1 -1
  284. package/dist/client/org/TeamPage.js +1 -1
  285. package/dist/client/org/TeamPage.js.map +1 -1
  286. package/dist/client/sse-event-processor.d.ts.map +1 -1
  287. package/dist/client/sse-event-processor.js +3 -0
  288. package/dist/client/sse-event-processor.js.map +1 -1
  289. package/dist/collab/awareness.d.ts +2 -2
  290. package/dist/collab/awareness.d.ts.map +1 -1
  291. package/dist/data-widgets/index.d.ts +3 -0
  292. package/dist/data-widgets/index.d.ts.map +1 -1
  293. package/dist/data-widgets/index.js +33 -0
  294. package/dist/data-widgets/index.js.map +1 -1
  295. package/dist/deploy/build.d.ts.map +1 -1
  296. package/dist/deploy/build.js +11 -7
  297. package/dist/deploy/build.js.map +1 -1
  298. package/dist/eject/provider-api-definitions.d.ts +1 -0
  299. package/dist/eject/provider-api-definitions.d.ts.map +1 -1
  300. package/dist/integrations/webhook-handler.d.ts.map +1 -1
  301. package/dist/integrations/webhook-handler.js +46 -9
  302. package/dist/integrations/webhook-handler.js.map +1 -1
  303. package/dist/notifications/routes.d.ts +3 -3
  304. package/dist/observability/routes.d.ts +3 -3
  305. package/dist/org/auto-join-domain.d.ts +3 -2
  306. package/dist/org/auto-join-domain.d.ts.map +1 -1
  307. package/dist/org/auto-join-domain.js +1 -1
  308. package/dist/org/auto-join-domain.js.map +1 -1
  309. package/dist/org/context.d.ts.map +1 -1
  310. package/dist/org/context.js +84 -28
  311. package/dist/org/context.js.map +1 -1
  312. package/dist/org/index.d.ts +1 -0
  313. package/dist/org/index.d.ts.map +1 -1
  314. package/dist/org/index.js +1 -0
  315. package/dist/org/index.js.map +1 -1
  316. package/dist/org/service-identity.d.ts +43 -0
  317. package/dist/org/service-identity.d.ts.map +1 -0
  318. package/dist/org/service-identity.js +34 -0
  319. package/dist/org/service-identity.js.map +1 -0
  320. package/dist/provider-api/actions/custom-provider-registration.d.ts +14 -14
  321. package/dist/provider-api/actions/provider-api.d.ts +13 -11
  322. package/dist/provider-api/actions/provider-api.d.ts.map +1 -1
  323. package/dist/provider-api/index.d.ts +4 -0
  324. package/dist/provider-api/index.d.ts.map +1 -1
  325. package/dist/provider-api/index.js +17 -1
  326. package/dist/provider-api/index.js.map +1 -1
  327. package/dist/resources/handlers.d.ts +1 -1
  328. package/dist/scripts/docs/search.d.ts.map +1 -1
  329. package/dist/scripts/docs/search.js +12 -1
  330. package/dist/scripts/docs/search.js.map +1 -1
  331. package/dist/server/agent-chat/context-tools.d.ts.map +1 -1
  332. package/dist/server/agent-chat/context-tools.js +3 -3
  333. package/dist/server/agent-chat/context-tools.js.map +1 -1
  334. package/dist/server/agent-chat/framework-prompts.d.ts +8 -3
  335. package/dist/server/agent-chat/framework-prompts.d.ts.map +1 -1
  336. package/dist/server/agent-chat/framework-prompts.js +33 -62
  337. package/dist/server/agent-chat/framework-prompts.js.map +1 -1
  338. package/dist/server/agent-chat-plugin.d.ts.map +1 -1
  339. package/dist/server/agent-chat-plugin.js +16 -10
  340. package/dist/server/agent-chat-plugin.js.map +1 -1
  341. package/dist/server/agents-bundle.d.ts +18 -0
  342. package/dist/server/agents-bundle.d.ts.map +1 -1
  343. package/dist/server/agents-bundle.js +70 -4
  344. package/dist/server/agents-bundle.js.map +1 -1
  345. package/dist/server/auth.d.ts.map +1 -1
  346. package/dist/server/auth.js +4 -3
  347. package/dist/server/auth.js.map +1 -1
  348. package/dist/server/builder-browser.d.ts.map +1 -1
  349. package/dist/server/builder-browser.js +43 -19
  350. package/dist/server/builder-browser.js.map +1 -1
  351. package/dist/server/core-routes-plugin.js +2 -2
  352. package/dist/server/core-routes-plugin.js.map +1 -1
  353. package/dist/server/credential-provider.d.ts +38 -2
  354. package/dist/server/credential-provider.d.ts.map +1 -1
  355. package/dist/server/credential-provider.js +142 -64
  356. package/dist/server/credential-provider.js.map +1 -1
  357. package/dist/server/index.d.ts +1 -1
  358. package/dist/server/index.d.ts.map +1 -1
  359. package/dist/server/index.js +1 -1
  360. package/dist/server/index.js.map +1 -1
  361. package/dist/server/prompts/framework-core-compact.d.ts +1 -1
  362. package/dist/server/prompts/framework-core-compact.d.ts.map +1 -1
  363. package/dist/server/prompts/framework-core-compact.js +7 -13
  364. package/dist/server/prompts/framework-core-compact.js.map +1 -1
  365. package/dist/server/prompts/framework-core.d.ts +1 -1
  366. package/dist/server/prompts/framework-core.d.ts.map +1 -1
  367. package/dist/server/prompts/framework-core.js +10 -21
  368. package/dist/server/prompts/framework-core.js.map +1 -1
  369. package/dist/server/prompts/index.d.ts +1 -1
  370. package/dist/server/prompts/index.d.ts.map +1 -1
  371. package/dist/server/prompts/index.js +1 -1
  372. package/dist/server/prompts/index.js.map +1 -1
  373. package/dist/server/prompts/shared-rules.d.ts +16 -10
  374. package/dist/server/prompts/shared-rules.d.ts.map +1 -1
  375. package/dist/server/prompts/shared-rules.js +19 -10
  376. package/dist/server/prompts/shared-rules.js.map +1 -1
  377. package/dist/server/ssr-handler.d.ts +1 -1
  378. package/dist/server/ssr-handler.d.ts.map +1 -1
  379. package/dist/server/ssr-handler.js +10 -3
  380. package/dist/server/ssr-handler.js.map +1 -1
  381. package/dist/server/transcribe-voice.d.ts +1 -1
  382. package/dist/settings/user-settings.d.ts.map +1 -1
  383. package/dist/settings/user-settings.js +13 -1
  384. package/dist/settings/user-settings.js.map +1 -1
  385. package/dist/shared/cache-control.d.ts +52 -0
  386. package/dist/shared/cache-control.d.ts.map +1 -1
  387. package/dist/shared/cache-control.js +107 -0
  388. package/dist/shared/cache-control.js.map +1 -1
  389. package/dist/templates/chat/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
  390. package/dist/templates/chat/_gitignore +1 -0
  391. package/dist/templates/default/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
  392. package/dist/templates/headless/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
  393. package/dist/templates/workspace-core/.agents/skills/performance/SKILL.md +19 -0
  394. package/dist/templates/workspace-core/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
  395. package/dist/templates/workspace-core/.agents/skills/visual-answer/SKILL.md +1 -0
  396. package/dist/vite/agents-bundle-plugin.d.ts.map +1 -1
  397. package/dist/vite/agents-bundle-plugin.js +8 -7
  398. package/dist/vite/agents-bundle-plugin.js.map +1 -1
  399. package/dist/vite/client.d.ts.map +1 -1
  400. package/dist/vite/client.js +2 -0
  401. package/dist/vite/client.js.map +1 -1
  402. package/docs/content/actions.mdx +2 -2
  403. package/docs/content/agent-surfaces.mdx +1 -1
  404. package/docs/content/authentication.mdx +2 -0
  405. package/docs/content/deployment.mdx +36 -0
  406. package/docs/content/getting-started.mdx +477 -115
  407. package/docs/content/http-api.mdx +266 -0
  408. package/docs/content/syncing-template-changes.mdx +159 -0
  409. package/package.json +4 -3
  410. package/src/a2a/activity.ts +38 -27
  411. package/src/agent/engine/builder-engine.ts +35 -4
  412. package/src/agent/run-manager.ts +20 -1
  413. package/src/agent/run-store.ts +4 -1
  414. package/src/agent/types.ts +28 -8
  415. package/src/chat-threads/store.ts +45 -0
  416. package/src/checkpoints/index.ts +2 -0
  417. package/src/checkpoints/route-match.ts +13 -0
  418. package/src/cli/create.ts +105 -17
  419. package/src/cli/index.ts +20 -0
  420. package/src/cli/template-baseline.ts +410 -0
  421. package/src/cli/template-sync.ts +1004 -0
  422. package/src/cli/templates-meta.ts +1 -0
  423. package/src/client/AssistantChat.tsx +38 -12
  424. package/src/client/NewWorkspaceAppFlow.tsx +75 -10
  425. package/src/client/chat/message-components.tsx +127 -66
  426. package/src/client/chat/tool-call-display.tsx +29 -5
  427. package/src/client/error-format.ts +18 -0
  428. package/src/client/org/OrgSwitcher.tsx +30 -8
  429. package/src/client/org/TeamPage.tsx +7 -6
  430. package/src/client/sse-event-processor.ts +3 -0
  431. package/src/data-widgets/index.ts +41 -0
  432. package/src/deploy/build.ts +11 -9
  433. package/src/integrations/webhook-handler.ts +63 -9
  434. package/src/org/auto-join-domain.ts +4 -3
  435. package/src/org/context.ts +108 -39
  436. package/src/org/index.ts +5 -0
  437. package/src/org/service-identity.ts +60 -0
  438. package/src/provider-api/index.ts +22 -1
  439. package/src/scripts/docs/search.ts +12 -1
  440. package/src/server/__snapshots__/agent-chat-plugin.surface.spec.ts.snap +25 -36
  441. package/src/server/agent-chat/context-tools.ts +9 -4
  442. package/src/server/agent-chat/framework-prompts.ts +38 -66
  443. package/src/server/agent-chat-plugin.ts +17 -10
  444. package/src/server/agents-bundle.ts +84 -5
  445. package/src/server/auth.ts +4 -3
  446. package/src/server/builder-browser.ts +47 -19
  447. package/src/server/core-routes-plugin.ts +2 -2
  448. package/src/server/credential-provider.ts +209 -68
  449. package/src/server/index.ts +3 -0
  450. package/src/server/prompts/framework-core-compact.ts +6 -13
  451. package/src/server/prompts/framework-core.ts +9 -21
  452. package/src/server/prompts/index.ts +0 -1
  453. package/src/server/prompts/shared-rules.ts +19 -11
  454. package/src/server/ssr-handler.ts +13 -2
  455. package/src/settings/user-settings.ts +13 -1
  456. package/src/shared/cache-control.ts +141 -0
  457. package/src/templates/chat/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
  458. package/src/templates/chat/_gitignore +1 -0
  459. package/src/templates/default/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
  460. package/src/templates/headless/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
  461. package/src/templates/workspace-core/.agents/skills/performance/SKILL.md +19 -0
  462. package/src/templates/workspace-core/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
  463. package/src/templates/workspace-core/.agents/skills/visual-answer/SKILL.md +1 -0
  464. package/src/vite/agents-bundle-plugin.ts +7 -6
  465. package/src/vite/client.ts +5 -0
@@ -1 +1 @@
1
- {"version":3,"file":"framework-prompts.js","sourceRoot":"","sources":["../../../src/server/agent-chat/framework-prompts.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,WAAW,CAAC;AAIjC,OAAO,EACL,kBAAkB,EAClB,yBAAyB,GAE1B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EACL,6BAA6B,EAC7B,0BAA0B,GAC3B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D,8EAA8E;AAC9E,yEAAyE;AACzE,2EAA2E;AAC3E,yEAAyE;AACzE,8EAA8E;AAE9E,MAAM,oCAAoC,GAAG,GAAG,CAAC;AAEjD;;;;;;;;GAQG;AACH,MAAM,UAAU,qBAAqB,CACnC,QAAyB,EACzB,OAA2E;IAS3E,MAAM,cAAc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AC,CAAC;IACzD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO;IACT,CAAC;IACD,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC5B,IAAI,OAAO,CAAC,MAAM,IAAI,GAAG;YAAE,OAAO;QAClC,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;YAAE,SAAS;QACjE,MAAM,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC;QAChE,MAAM,KAAK,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC;QAClC,OAAO,CAAC,IAAI,CAAC;YACX,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM;SAChC,CAAC,CAAC;QACH,IAAI,KAAK;YACP,MAAM,YAAY,CAChB,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,EAC9B,OAAO,EACP,KAAK,GAAG,CAAC,EACT,OAAO,CACR,CAAC;IACN,CAAC;AACH,CAAC","sourcesContent":["import nodePath from \"node:path\";\n\nimport type { ActionEntry } from \"../../agent/production-agent.js\";\nimport type { DatabaseToolsOption } from \"../../scripts/db/tool-mode.js\";\nimport {\n buildFrameworkCore,\n buildFrameworkCoreCompact,\n type PromptExamples,\n} from \"../prompts/index.js\";\nimport { getRequestOrgId } from \"../request-context.js\";\nimport { loadSchemaPromptBlock } from \"../schema-prompt.js\";\nimport { resolveInitialToolNames } from \"./action-filters-a2a.js\";\nimport {\n createDataWidgetActionEntries,\n FRAMEWORK_CONTEXT_SECTIONS,\n} from \"./context-tools.js\";\nimport { lazyFs } from \"./lazy-fs.js\";\nimport { compactPromptLine } from \"./prompt-resources.js\";\n\n// ---------------------------------------------------------------------------\n// Framework-level system prompt assembly (production/dev, full/compact),\n// the \"Available Actions\" and corpus-tools prompt sections, the SQL schema\n// block, and the codebase file-tree walker used by a few dev-mode tools.\n// ---------------------------------------------------------------------------\n\nconst MAX_ACTION_SUMMARY_DESCRIPTION_CHARS = 140;\n\n/**\n * Framework-level instructions injected into every agent's system prompt.\n * Prompt text lives in packages/core/src/server/prompts/ so this file stays\n * focused on routing and assembly logic.\n *\n * buildFrameworkPrompts() is called once per plugin instantiation (not per\n * request) with the template's promptExamples, producing the four assembled\n * prompt strings used at request time.\n */\nexport function buildFrameworkPrompts(\n examples?: PromptExamples,\n options?: { databaseTools?: DatabaseToolsOption; extensionTools?: boolean },\n): {\n FRAMEWORK_CORE: string;\n FRAMEWORK_CORE_COMPACT: string;\n PROD_FRAMEWORK_PROMPT: string;\n DEV_FRAMEWORK_PROMPT: string;\n PROD_FRAMEWORK_PROMPT_COMPACT: string;\n DEV_FRAMEWORK_PROMPT_COMPACT: string;\n} {\n const FRAMEWORK_CORE = buildFrameworkCore(examples, options);\n const FRAMEWORK_CORE_COMPACT = buildFrameworkCoreCompact(examples, options);\n const extensionToolsEnabled = options?.extensionTools !== false;\n const planModeArtifactList = extensionToolsEnabled\n ? \"source-code handoffs and app-created artifacts such as extensions, widgets, dashboards, calculators, mini-apps, documents, designs, slides, or videos\"\n : \"source-code handoffs and app-created artifacts such as documents, designs, slides, or videos\";\n const planModeBlockedTools = extensionToolsEnabled\n ? \"`render-inline-extension`, `create-extension`, `update-extension`, `connect-builder`, or any action that creates, updates, deletes, sends, publishes, or persists data\"\n : \"`connect-builder`, or any action that creates, updates, deletes, sends, publishes, or persists data\";\n const extensionConnectBuilderGuard = extensionToolsEnabled\n ? \"If the complete request can be satisfied by a self-contained extension or an existing named slot, use `render-inline-extension`, `create-extension`, `show-extension-inline`, or `update-extension` instead. If the exact placement or behavior requires changing the host UI or no suitable slot exists, continue with the normal `connect-builder` source-change flow even if the user called it an extension; never stop at saying extensions cannot do it.\"\n : \"Because extension tools are disabled, do NOT invent an extension workflow. Only use `connect-builder` when the request genuinely requires changing the host app's source code.\";\n const extensionInstructionsFull = extensionToolsEnabled\n ? `### Generative UI and Extensions (Mini-Apps)\n\nIn Act mode, if the user asks for generated interactive UI in chat, choose the smallest extension action that matches the lifetime:\n\n- For a **one-time inline UI** that answers the current chat turn (knobs, controls, pickers, calculators, temporary dashboards, visualizers), call \\`render-inline-extension\\` immediately with a self-contained Alpine.js HTML body. It renders inside the transcript and is not saved.\n- For a **reusable or saved UI** (an extension/widget/dashboard/calculator/mini-app the user can reopen from Extensions), call \\`create-extension\\` with a self-contained Alpine.js HTML body. It saves to the Extensions view and also renders inline in chat.\n- To **reuse an existing saved extension inline**, call \\`show-extension-inline\\` with its id, or a search string when the id is unknown.\n\nThese are **NOT** source-code changes and do **NOT** go through \\`connect-builder\\`. Extensions are sandboxed mini-apps — no source files are touched, no PR is opened, no build is required. Saved extensions can be edited later via \\`update-extension\\`.\n\nIf the app exposes native actions or instructions for dashboards, reports, analyses, charts, documents, decks, or other domain artifacts, use those app-native actions first. Choose an extension only when the user explicitly asks for an extension/custom mini-app, or when the app's native artifact format cannot faithfully express the requested interaction.\n\nKeep \\`create-extension\\` payloads compact enough to finish quickly. For complex extensions, create a useful working v1 first, then call \\`update-extension\\` with focused edits for refinements instead of trying to assemble one enormous initial tool input.\n\nGenerated UI content can use appAction(), appFetch(), dbQuery(), extensionFetch(), extensionData, agentNative.ui.output(value, opts?), and agentNative.chat.send(...)/sendToAgentChat(...). Use appAction() for app data writes, and dbQuery() only for read-only inspection of known app SQL tables. It can receive chat inputs through slotContext/window.onSlotContext. Use agentNative.ui.output for passive current values from knobs, sliders, selections, and controls; it writes application state at \\`inline-ui:<extensionId>:output\\` scoped to the inline extension id returned by \\`render-inline-extension\\` or \\`show-extension-inline\\`. When the user later says \"use that value\", \"apply the current setting\", or similar, read it with \\`readAppState(\"inline-ui:<id>:output\")\\` instead of asking them to send it again. Use agentNative.chat.send for visible submit/apply actions that should put a message into chat. Transient extensionData is browser-local and not agent-readable, synced, promoted, or garbage-collected; use application_state/appFetch, appAction, ui.output, or chat.send for anything the agent or app must observe. Use semantic Tailwind classes like bg-background, text-foreground, bg-primary, border-border, and text-muted-foreground so the UI inherits the parent app theme.\n\nIf the user asks to change, edit, fix, style, rename, or add behavior to an existing extension/widget/dashboard/calculator/mini-app, use the current extension id from \\`<current-screen>\\` or \\`<current-url>\\` when present. Call \\`get-extension\\` only if you need to inspect its content, then call \\`update-extension\\` with exactly \\`id\\`, \\`operation\\`, and \\`payloadJson\\`; encode the operation payload as a JSON string and never send empty placeholder fields. After one content read, keep the body in working memory and use \\`operation=\"edit\"\\` with focused \\`edits\\`/\\`patches\\` inside \\`payloadJson\\`; do not loop on repeated \\`get-extension\\` + \\`run-code\\` string scans before writing. For a data-only repair, preserve the existing layout, CSS, copy, and interactions. Use \\`operation=\"replace\"\\` only when the user explicitly requests a broad visual rewrite or supplies a complete replacement body. Use \\`operation=\"metadata\"\\` for name/description/icon, and use \\`set-resource-visibility\\` for sharing changes. If a focused patch fails, read the current body and change the target rather than retrying identical arguments. Use \\`list-extensions\\` only when no current id/name is available. Existing extension edits are SQL data updates, not source-code changes, even when the request says \"change the UI\" or \"fix this\". Do **NOT** call \\`connect-builder\\` for existing extension edits.\n\nIn Act mode, when in doubt — if the request asks for a new small interactive utility and does not need reuse, choose \\`render-inline-extension\\`; if it mentions saving/reuse or asks for an extension/widget/dashboard/calculator/mini-app, choose \\`create-extension\\`. If it references an existing one or the current extension page, choose \\`update-extension\\`. Do **not** preface the call with planning text like \"let me build the dashboard…\" — just call the right extension action directly.\n\nNote: \"extension\" is the user-facing primitive (the sandboxed Alpine.js mini-app). Don't confuse it with the LLM concept of \"tools\" (function calls) — those are how you invoke ANY action, including \\`create-extension\\` itself.\n\nFor existing extensions, use \\`get-extension\\` or \\`update-extension\\` directly when \\`<current-screen>\\` or \\`<current-url>\\` provides an \\`extensionId\\`. Use \\`list-extensions\\` only to browse or resolve an unknown name. If the user wants a shared extension removed only from their view, use \\`hide-extension\\` — do not query or mutate the legacy \\`tools\\` table directly.\n\n### Extensions vs. Code Changes — Pick the Right Path\n\nRoute by the exact outcome, not by whether the user calls it an extension. Extensions render in their own sandboxed iframe, either on their own page or inside an existing named slot. They CANNOT change the host app's nav, restyle or inject elements into existing native components, replace built-in views, or render at an arbitrary location that has no slot.\n\n<routing>\n| The request is for… | Path |\n| ---------------------------------------------------------------- | ------------------------------ |\n| A one-off interactive answer inside chat (controls, picker, calculator, temporary visualizer) | \\`render-inline-extension\\` — inline only |\n| A new self-contained surface (widget, dashboard, calculator, viewer, list, tracker) | \\`create-extension\\` — ships instantly, no PR |\n| Loading a saved extension inside chat | \\`show-extension-inline\\` |\n| Editing an existing extension (fix, restyle, rename, add behavior) | \\`update-extension\\` |\n| The host app's own chrome (nav bar, sidebar, layout, routes, shipped components, existing styles, business logic) | \\`connect-builder\\` — a real source-code change |\n| UI inside or beside a native component where no named slot exists | \\`connect-builder\\` — add the native UI or a suitable slot in source |\n| Ambiguous, satisfiable either way (e.g. \"give me an unread view\") | \\`render-inline-extension\\` for chat-only, \\`create-extension\\` for reusable |\n</routing>\n\nIf an extension could only approximate the request in a different location, do not silently downgrade the requirement and do not end with \"extensions cannot do that.\" Briefly explain the boundary, then follow the normal source-code handoff so the app can still be customized fully.\n\nWorked examples: \"a widget showing unread emails grouped by sender\", \"a tracker for my newsletter subscriptions\", \"a custom kanban board with drag-and-drop rules the app does not have\" → \\`create-extension\\`. \"Add an Unread tab to the left navigation\", \"show local time beside every native Calendar attendee row\", \"make the subject lines wrap\", \"change the inbox grouping logic\", \"add a field to the compose form\" → \\`connect-builder\\`.`\n : `### Extensions Disabled\n\nExtension creation and management tools are disabled for this app. Do not claim you can create, edit, hide, or delete Agent-Native extensions unless the template exposes its own typed action for that workflow. For requests that would otherwise be handled as an extension/widget/dashboard/calculator mini-app, explain that this app has disabled extension tools and use the app's available actions instead.`;\n const extensionInstructionsCompact = extensionToolsEnabled\n ? `### Generative UI and Extensions (Mini-Apps)\n\nIn Act mode, if the user asks for generated interactive UI in chat, call \\`render-inline-extension\\` for one-time inline controls/knobs/calculators/visualizers that do not need saving. If the user asks for an **extension**, **widget**, **dashboard**, **calculator**, or **mini-app** that should be reusable or saved, call \\`create-extension\\` with a self-contained Alpine.js HTML body. To load a saved extension inline, call \\`show-extension-inline\\`. These are NOT code changes — extensions are sandboxed mini-apps. Do not preface with \"let me build…\" — just call the right extension action.\n\nUse app-native artifact actions first when they exist for dashboards, reports, analyses, charts, documents, decks, or similar domain artifacts. Pick \\`create-extension\\` only for explicit extension/custom mini-app requests or for behavior the native artifact format cannot support.\n\nKeep the first \\`create-extension\\` call compact and working. If the request is complex, create the v1 first and then refine with focused \\`update-extension\\` edits.\n\nGenerated UI can read chat inputs from slotContext/window.onSlotContext, see/update app state through appFetch/appAction, use extensionData, record passive current values through agentNative.ui.output(value, opts?), and send visible results through agentNative.chat.send(...) or sendToAgentChat(...). ui.output writes \\`inline-ui:<extensionId>:output\\` in application state; when the user asks to use the current slider/selection/value, read \\`readAppState(\"inline-ui:<id>:output\")\\`. Transient extensionData is browser-local only, so do not rely on it for values the agent or app must observe. Use semantic Tailwind theme classes.\n\nIf the user asks to change, edit, fix, style, rename, or add behavior to an existing extension/widget/dashboard/calculator/mini-app, use the current extension id from \\`<current-screen>\\` or \\`<current-url>\\` when present. Call \\`get-extension\\` only if you need to inspect its content, then call \\`update-extension\\` with exactly \\`id\\`, \\`operation\\`, and \\`payloadJson\\`; encode the operation payload as a JSON string and never send empty placeholder fields. After one content read, use \\`operation=\"edit\"\\` with focused \\`edits\\`/\\`patches\\` inside \\`payloadJson\\`; do not repeatedly re-read and scan the same HTML with \\`run-code\\` before writing. For a data-only repair, preserve the existing layout, CSS, copy, and interactions. Use \\`operation=\"replace\"\\` only when the user explicitly requests a broad visual rewrite or supplies a complete replacement body. Use \\`operation=\"metadata\"\\` for name/description/icon, and use \\`set-resource-visibility\\` for sharing changes. If a focused patch fails, read the current body and change the target rather than retrying identical arguments. Use \\`list-extensions\\` only when no current id/name is available. Existing extension edits are SQL data updates, not source-code changes. Do NOT call \\`connect-builder\\` for them.\n\nFor existing extensions, use \\`get-extension\\` or \\`update-extension\\` directly when \\`<current-screen>\\` or \\`<current-url>\\` provides an \\`extensionId\\`. Use \\`list-extensions\\` only to browse or resolve an unknown name. Use \\`hide-extension\\` when the user wants a shared extension removed only from their own view. Do not query the legacy \\`tools\\` table directly.\n\n### Extensions vs. Code Changes — Pick the Right Path\n\nIf the user wants a **one-off interactive answer in chat**, use \\`render-inline-extension\\`. If they want a **new reusable self-contained surface** (custom widget, dashboard, list, viewer, calculator), use \\`create-extension\\` — extensions ship instantly without a PR. Extensions can render only on their own page or in an existing named slot; they cannot inject UI into arbitrary native components. If the exact request changes host chrome, native components, layout, styles, routes, business logic, or needs placement where no slot exists, treat it as a source-code change and use the normal \\`connect-builder\\` flow even if the user called it an extension. Never stop at \"extensions cannot do that\" or silently offer a different placement; explain the boundary briefly and continue the code-change handoff.`\n : `### Extensions Disabled\n\nExtension creation and management tools are disabled for this app. Do not claim you can create, edit, hide, or delete Agent-Native extensions unless the template exposes its own typed action for that workflow.`;\n\n const PROD_FRAMEWORK_PROMPT = `## Agent-Native Framework — Production Mode\n\nYou are an AI agent in an agent-native application, running in **production mode**.\n\nThe agent and the UI are equal partners — everything the UI can do, you can do via your tools, and vice versa. They share the same SQL database and stay in sync automatically.\n\n**In production mode, you operate through registered actions exposed as tools.** These are your capabilities — use them to read data, take actions, and help the user. You cannot edit source code or access the filesystem directly. Your tools are the app's API.\n\n### Plan Mode\n\nIf the current turn is in Plan mode, plan before anything gets written. This applies to ${planModeArtifactList}. Use only read-only tools, clarify the goal when needed, and return a concrete plan for approval. Do not call ${planModeBlockedTools} until the user switches back to Act mode.\n\n${extensionInstructionsFull}\n\n### Code Changes Not Available — Call \\`connect-builder\\` Immediately\n\n${extensionConnectBuilderGuard}\n\nIn Act mode, when the user asks you to change the UI, modify code, add a feature, fix a bug in the app itself, change styles, add a hook, create a component, add a route, add an integration, or anything else that requires editing source files — you MUST take exactly these steps, in order:\n\n1. Briefly acknowledge the user's specific request in their own terms — one short clause naming what they asked for (e.g. \"Got it — wider subject lines in the email list.\"). Do NOT restate the request verbatim, do NOT add a generic preamble, and do NOT promise outcomes. Skip this step entirely if the user already knows you're handing off (e.g. they said \"send this to Builder\").\n2. Call the \\`connect-builder\\` tool, passing the user's full request verbatim as the \\`prompt\\` argument. This renders an inline card. The returned \\`builderEnabled\\` flag is authoritative: \\`true\\` means Builder Cloud Agents can take the code-change handoff; \\`false\\` means this still requires a code change, but no Builder Cloud Agent can run from this workspace. If Builder is connected and \\`builderEnabled\\` is true, the card hands the prompt off to Builder's cloud agent on one click and returns a branch URL. If Builder is not connected and \\`builderEnabled\\` is true, it shows the Connect Builder flow. If \\`builderEnabled\\` is false, it still shows the card, but as a code-change fallback instead of a runnable cloud handoff.\n3. After the card renders, inspect the tool result and write one sentence that frames the next click around what the user just asked — not as a Builder pitch. If \\`builderEnabled\\` is true and the card can send, say something like \"Click Send to Builder and it'll wire that up for you.\" If the user needs to connect first, say something like \"Connect Builder once and it'll handle this and future changes.\" If \\`builderEnabled\\` is false, say: \"This requires a code change. Edit locally or use Builder.io to edit this code in the cloud and continue customizing the app any way you like.\" Do NOT say \"click Send to Builder\", mention a branch URL, say the card is pre-loaded, or imply a Builder Cloud Agent can run when \\`builderEnabled\\` is false.\n\nWhen \\`builderEnabled\\` is false, Builder Cloud Agents are not self-serve from Builder org settings. Do NOT tell the user to go to Builder org settings, beta features, \"Cloud Agents\", or \"AI Agents\" to enable them. The only allowed guidance is the card's code-change fallback: edit locally, use Agent Native Desktop, or use Builder.io to edit this code in the cloud and continue customizing the app any way you like.\n\n**Act-mode handoff — do exactly this:** The moment a code change is requested, call \\`connect-builder\\` with the user's verbatim request, then write one sentence framing the next click. That is the whole job: Builder plans and edits in its own sandbox, so the planning, file-mapping, and code all happen there, not here. Keep your turn to the call plus that one sentence — skip code exploration, implementation plans, \\`resources\\` writes of specs, and sub-agents (they have no code-editing tools either). You don't need filesystem access to recommend Builder, so don't reach for it or list tools you lack.\n\nBuilder Cloud Agents are the recommended path when \\`builderEnabled\\` is true because they are one-click and run in the cloud. Local dev, Agent Native Desktop, and Builder.io cloud editing are the fallback when \\`builderEnabled\\` is false.\n${FRAMEWORK_CORE}`;\n\n const DEV_FRAMEWORK_PROMPT = `## Agent-Native Framework — Development Mode\n\nYou are an AI agent in an agent-native application, running in **development mode**.\n\nThe agent and the UI are equal partners — everything the UI can do, you can do via tools/scripts, and vice versa. They share the same SQL database and stay in sync automatically.\n\n**In development mode, you have full local access — use it with senior-engineer judgment** (read before you edit, keep changes scoped, verify before you claim done):\n- Run any shell command via the \\`bash\\` tool (node, curl, pnpm, rg, git, etc.), including arbitrary code: \\`bash({ command: 'node -e \"console.log(1+1)\"' })\\`\n- Read and write any file on the filesystem; edit source, install packages, modify the app\n- Query and modify the database\n- Call external APIs (via bash with curl, or via scripts)\n\nWhen no dedicated tool/action exists for what you need, reach for \\`bash\\` — e.g. \\`bash({ command: 'curl -s https://api.example.com/data' })\\`.\n\n**Template-specific actions are invoked via bash, NOT as direct tools.** In dev mode, the only tools registered as native tool calls are framework-level utilities (bash, read, edit, write, database, resources, chat, teams, jobs). Anything from the template's \\`actions/\\` directory must be run through bash: \\`bash({ command: 'pnpm action <name> --arg value' })\\`. The \"Available Actions\" section below shows the exact CLI syntax for each one — copy that command verbatim and pass it to \\`bash\\`. Do not try to call template actions by name as if they were tools; they will not appear in your tool list.\n\nWhen editing code, follow the agent-native architecture:\n- Every feature needs all four areas: UI + scripts + skills/instructions + application-state sync\n- All SQL must be dialect-agnostic (works on SQLite and Postgres)\n- No Node.js-specific APIs in server routes (must work on Cloudflare Workers, etc.)\n- Use shadcn/ui components and Tabler Icons for all UI work\n${FRAMEWORK_CORE}`;\n\n const PROD_FRAMEWORK_PROMPT_COMPACT = `## Agent-Native Framework — Production Mode\n\nYou are an AI agent in an agent-native application, running in **production mode**.\n\nThe agent and the UI are equal partners — everything the UI can do, you can do via your tools, and vice versa. They share the same SQL database and stay in sync automatically.\n\n**In production mode, you operate through registered actions exposed as tools.** These are your capabilities — use them to read data, take actions, and help the user. You cannot edit source code or access the filesystem directly. Your tools are the app's API.\n\n### Plan Mode\n\nIf the turn is in Plan mode, plan before anything gets written — including ${planModeArtifactList}. Use read-only tools only and do not call ${planModeBlockedTools} until the user switches back to Act mode.\n\n${extensionInstructionsCompact}\n\n### Code Changes — Call \\`connect-builder\\`\n\nIn Act mode, when a request genuinely needs a source-code edit (per the rules above), do this in order: (1) briefly acknowledge the user's specific ask in their own terms — one short clause, no preamble — then (2) call \\`connect-builder\\` with the user's request as the \\`prompt\\`, then (3) inspect \\`builderEnabled\\` in the result and write one sentence framing the next click around what they asked for, not a Builder pitch. When \\`builderEnabled\\` is true, Builder Cloud Agents can take the handoff; when \\`builderEnabled\\` is false, say this requires a code change and they can edit locally or use Builder.io to edit this code in the cloud and continue customizing the app any way they like. Do NOT write code, list files, make plans, or spawn sub-agents. Mention \\`npx agent-native create <app-name>\\`, Agent Native Desktop, or the code-change fallback when Builder Cloud Agents aren't available. Never tell users to enable Builder Cloud Agents from Builder org settings, beta features, \"Cloud Agents\", or \"AI Agents\"; they are not self-serve there.\n${FRAMEWORK_CORE_COMPACT}`;\n\n const DEV_FRAMEWORK_PROMPT_COMPACT = `## Agent-Native Framework — Development Mode\n\nYou are an AI agent in an agent-native application, running in **development mode**.\n\nThe agent and the UI are equal partners — everything the UI can do, you can do via tools/scripts, and vice versa. They share the same SQL database and stay in sync automatically.\n\n**In development mode, you have full local access** — shell, filesystem, database, external APIs, source edits, and package installs. Use it with senior-engineer judgment: read before you edit, keep changes scoped, verify before you claim done.\n\n**Template-specific actions are invoked via bash, NOT as direct tools.** Run them with: \\`bash({ command: 'pnpm action <name> --arg value' })\\`. See the \"Available Actions\" section below for CLI syntax.\n\nWhen editing code, follow the agent-native architecture:\n- Every feature needs all four areas: UI + scripts + skills/instructions + application-state sync\n- All SQL must be dialect-agnostic (works on SQLite and Postgres)\n- No Node.js-specific APIs in server routes (must work on Cloudflare Workers, etc.)\n- Use shadcn/ui components and Tabler Icons for all UI work\n${FRAMEWORK_CORE_COMPACT}`;\n\n return {\n FRAMEWORK_CORE,\n FRAMEWORK_CORE_COMPACT,\n PROD_FRAMEWORK_PROMPT,\n DEV_FRAMEWORK_PROMPT,\n PROD_FRAMEWORK_PROMPT_COMPACT,\n DEV_FRAMEWORK_PROMPT_COMPACT,\n };\n}\n\nexport const _agentChatPromptSectionsForTests = (() => {\n // Built with default (no template-specific) examples for test stability.\n const {\n FRAMEWORK_CORE: frameworkCore,\n FRAMEWORK_CORE_COMPACT: frameworkCoreCompact,\n } = buildFrameworkPrompts();\n return {\n frameworkCore,\n frameworkCoreCompact,\n frameworkContextSections: FRAMEWORK_CONTEXT_SECTIONS,\n buildFrameworkPrompts,\n generateActionsPrompt,\n resolveInitialToolNames,\n createDataWidgetActionEntries,\n };\n})();\n\n/**\n * Build the per-request SQL-schema context block. Reads AGENT_ORG_ID live\n * from the environment so scheduler/A2A/HTTP call sites all see whatever\n * org was just resolved for this request.\n */\nexport async function buildSchemaBlock(\n owner: string,\n databaseTools: DatabaseToolsOption = \"read\",\n): Promise<string> {\n try {\n return await loadSchemaPromptBlock({\n owner,\n orgId: getRequestOrgId() ?? null,\n databaseTools,\n });\n } catch {\n return \"\";\n }\n}\n\n/**\n * Generates a system prompt section describing registered template actions.\n * This helps the agent prefer template-specific actions over raw db-query/db-exec.\n *\n * Two output modes:\n *\n * - `\"tool\"` — used in production, where template actions are registered\n * as native Anthropic tools. Output reads `name(arg*: type; ...) — desc`.\n * - `\"cli\"` — used in dev, where template actions are NOT registered as\n * native tools and must be invoked via `bash(command=\"pnpm action ...\")`.\n * Output reads `pnpm action name --arg <type> [--opt <type>] — desc`.\n */\nexport function generateActionsPrompt(\n registry: Record<string, ActionEntry>,\n mode: \"cli\" | \"tool\" = \"tool\",\n initialToolNames?: string[],\n): string {\n if (!registry || Object.keys(registry).length === 0) return \"\";\n\n const allActionEntries = Object.entries(registry);\n const initialNames = initialToolNames ? new Set(initialToolNames) : undefined;\n const actionEntries = initialNames\n ? allActionEntries.filter(([name]) => initialNames.has(name))\n : allActionEntries;\n const omittedActionCount = allActionEntries.length - actionEntries.length;\n const nativeWidgetNote = (entry: ActionEntry) =>\n entry.chatUI && typeof entry.chatUI.renderer === \"string\"\n ? ` Native chat widget: \\`${entry.chatUI.renderer}\\`.`\n : \"\";\n\n if (mode === \"tool\") {\n const summaryLines = actionEntries.map(([name, entry]) => {\n const desc = compactPromptLine(\n entry.tool.description,\n MAX_ACTION_SUMMARY_DESCRIPTION_CHARS,\n );\n return `- \\`${name}\\` — ${desc}${nativeWidgetNote(entry)}`;\n });\n\n return `\\n\\n## Available Actions\n\n**Use these actions directly as tool calls.** They handle database access, validation, and business logic internally. The native tool schemas contain the full parameter details.\n\n${summaryLines.join(\"\\n\")}${\n omittedActionCount > 0\n ? `\\n\\n${omittedActionCount} less-common app action${omittedActionCount === 1 ? \" is\" : \"s are\"} available on demand. Use \\`tool-search\\` with a specific capability query to load the matching schemas when needed.`\n : \"\"\n }`;\n }\n\n const lines = actionEntries.map(([name, entry]) => {\n const desc = entry.tool.description;\n const params = entry.tool.parameters?.properties;\n const requiredFields = new Set(entry.tool.parameters?.required ?? []);\n\n // CLI mode: emit `pnpm action <name> --required <type> [--optional <type>]`\n if (!params || Object.keys(params).length === 0) {\n return `- \\`pnpm action ${name}\\` — ${desc}${nativeWidgetNote(entry)}`;\n }\n const entries = Object.entries(params);\n // Required first (alphabetical), then optional (alphabetical)\n entries.sort(([a], [b]) => {\n const ar = requiredFields.has(a) ? 0 : 1;\n const br = requiredFields.has(b) ? 0 : 1;\n if (ar !== br) return ar - br;\n return a.localeCompare(b);\n });\n const required: string[] = [];\n const optional: string[] = [];\n const requiredNames: string[] = [];\n for (const [k, v] of entries) {\n const type = (v as { type?: string }).type ?? \"any\";\n const flag = `--${k} <${type}>`;\n if (requiredFields.has(k)) {\n required.push(flag);\n requiredNames.push(`--${k}`);\n } else {\n optional.push(`[${flag}]`);\n }\n }\n const cmd = [\"pnpm action \" + name, ...required, ...optional].join(\" \");\n const requiredNote =\n requiredNames.length > 0 ? ` Required: ${requiredNames.join(\", \")}.` : \"\";\n return `- \\`${cmd}\\` — ${desc}.${requiredNote}${nativeWidgetNote(entry)}`;\n });\n\n return `\\n\\n## Available Actions\n\n**These template actions are NOT exposed as direct tools in dev mode. To run any of them, use the \\`bash\\` tool with the exact command shown below.** Example: \\`bash(command=\"pnpm action add-slide --deckId abc --content 'Hello'\")\\`.\n\nDo NOT try to call these by name as if they were tools — they will not exist in your tool list. Always go through \\`bash\\`.\n\n${lines.join(\"\\n\")}`;\n}\n\n/**\n * Tool names `generateCorpusToolsPrompt` teaches BY NAME, in the same order\n * it lists them. Exported so callers that build a request's initial\n * engine-tool set can fold in exactly the subset present in a given\n * registry — keeping \"what the prompt just told the model exists\" and\n * \"what tools are actually callable on the first request\" in sync. See the\n * corpus-prompt/initial-tools note at this function's call site in\n * agent-chat-plugin.ts.\n */\nconst CORPUS_TOOL_NAMES = [\n \"provider-api-catalog\",\n \"provider-api-docs\",\n \"provider-api-request\",\n \"provider-corpus-job\",\n \"query-staged-dataset\",\n \"run-code\",\n] as const;\n\nexport function corpusToolNamesTaughtByPrompt(\n registry: Record<string, ActionEntry>,\n): string[] {\n return CORPUS_TOOL_NAMES.filter((name) => name in registry);\n}\n\nexport function generateCorpusToolsPrompt(\n registry: Record<string, ActionEntry>,\n): string {\n const hasProviderApi = \"provider-api-request\" in registry;\n const hasProviderCorpusJob = \"provider-corpus-job\" in registry;\n const providerDiscoveryTools = [\n \"provider-api-catalog\" in registry ? \"`provider-api-catalog`\" : null,\n \"provider-api-docs\" in registry ? \"`provider-api-docs`\" : null,\n ].filter(Boolean);\n const hasRunCode = \"run-code\" in registry;\n const hasStagedDataset = \"query-staged-dataset\" in registry;\n if (\n !hasProviderApi &&\n !hasProviderCorpusJob &&\n !hasRunCode &&\n !hasStagedDataset\n )\n return \"\";\n\n const available = [\n ...providerDiscoveryTools,\n hasProviderApi ? \"`provider-api-request`\" : null,\n hasProviderCorpusJob ? \"`provider-corpus-job`\" : null,\n hasStagedDataset ? \"`query-staged-dataset`\" : null,\n hasRunCode ? \"`run-code`\" : null,\n ].filter(Boolean);\n\n return `\\n\\n## Broad Provider And Corpus Workflows\n\nAvailable corpus-capable tools: ${available.join(\", \")}.\n\nThis workflow does not apply to ordinary structured lookups, bounded aggregates, or counts grouped over one known source. For those requests, use the single most directly authoritative source, run one bounded query, and answer as soon as it succeeds. Do not cross-check or expand into a corpus workflow unless the user asks for multiple sources, exhaustive unstructured-record coverage, or an absence claim.\n\nFor broad provider searches, raw API access, multi-page cohorts, cross-source joins, classification over unstructured records, or absence-sensitive answers, do not stop at a bounded shortcut action. Use the provider's broad API/search/list surface, fetch every relevant page or an explicit bounded cohort, stage/save large responses when needed, and reduce the corpus with durable corpus jobs, staged-dataset queries, or code execution.\n\nWhen \\`provider-corpus-job\\` is available, prefer it for transcript/message/ticket/issue/document scans that may exceed one turn, need provider-side backoff, or need a defensible \"not found\" conclusion. Use operation=\"start\" with mode=\"paginated-search\" for any paginated provider endpoint, or mode=\"batch-search\" when a prior cohort of ids/records must feed a second provider endpoint. Continue paused jobs with operation=\"continue\" until status is completed or quota_wait, then read operation=\"results\". In run-code, prefer providerFetchAll() for short cursor/page/offset pagination and providerRequest() when response status, headers, or truncation metadata matters. Report source, filters, row counts, pagination/truncation, failed pages, quota_wait times, and remaining gaps.`;\n}\n\n/**\n * Walks the local filesystem (dev mode only) to build a bounded file/folder\n * tree, used by a couple of dev-mode workspace-inspection tools.\n */\nexport async function collectFiles(\n dir: string,\n prefix: string,\n depth: number,\n results: Array<{ path: string; name: string; type: \"file\" | \"folder\" }>,\n): Promise<void> {\n if (depth > 4 || results.length >= 500) return;\n const skip = new Set([\n \"node_modules\",\n \".git\",\n \".next\",\n \".output\",\n \"dist\",\n \".cache\",\n \".turbo\",\n \"data\",\n ]);\n let entries: import(\"fs\").Dirent[];\n try {\n const fs = await lazyFs();\n entries = fs.readdirSync(dir, { withFileTypes: true });\n } catch {\n return;\n }\n for (const entry of entries) {\n if (results.length >= 500) return;\n if (skip.has(entry.name) || entry.name.startsWith(\".\")) continue;\n const relPath = prefix ? `${prefix}/${entry.name}` : entry.name;\n const isDir = entry.isDirectory();\n results.push({\n path: relPath,\n name: entry.name,\n type: isDir ? \"folder\" : \"file\",\n });\n if (isDir)\n await collectFiles(\n nodePath.join(dir, entry.name),\n relPath,\n depth + 1,\n results,\n );\n }\n}\n"]}
1
+ {"version":3,"file":"framework-prompts.js","sourceRoot":"","sources":["../../../src/server/agent-chat/framework-prompts.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,WAAW,CAAC;AAIjC,OAAO,EACL,kBAAkB,EAClB,yBAAyB,GAE1B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EACL,6BAA6B,EAC7B,0BAA0B,GAC3B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,8EAA8E;AAC9E,yEAAyE;AACzE,2EAA2E;AAC3E,yEAAyE;AACzE,8EAA8E;AAE9E;;;;;;;;GAQG;AACH,MAAM,UAAU,qBAAqB,CACnC,QAAyB,EACzB,OAA2E;IAS3E,MAAM,cAAc,GAAG,kBAAkB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC7D,MAAM,sBAAsB,GAAG,yBAAyB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC5E,MA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P,CAAC,CAAC;IACH,IAAI,OAA8B,CAAC;IACnC,IAAI,CAAC;QACH,MAAM,EAAE,GAAG,MAAM,MAAM,EAAE,CAAC;QAC1B,OAAO,GAAG,EAAE,CAAC,WAAW,CAAC,GAAG,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;IACzD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO;IACT,CAAC;IACD,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC5B,IAAI,OAAO,CAAC,MAAM,IAAI,GAAG;YAAE,OAAO;QAClC,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;YAAE,SAAS;QACjE,MAAM,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC;QAChE,MAAM,KAAK,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC;QAClC,OAAO,CAAC,IAAI,CAAC;YACX,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM;SAChC,CAAC,CAAC;QACH,IAAI,KAAK;YACP,MAAM,YAAY,CAChB,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,EAC9B,OAAO,EACP,KAAK,GAAG,CAAC,EACT,OAAO,CACR,CAAC;IACN,CAAC;AACH,CAAC","sourcesContent":["import nodePath from \"node:path\";\n\nimport type { ActionEntry } from \"../../agent/production-agent.js\";\nimport type { DatabaseToolsOption } from \"../../scripts/db/tool-mode.js\";\nimport {\n buildFrameworkCore,\n buildFrameworkCoreCompact,\n type PromptExamples,\n} from \"../prompts/index.js\";\nimport { getRequestOrgId } from \"../request-context.js\";\nimport { loadSchemaPromptBlock } from \"../schema-prompt.js\";\nimport { resolveInitialToolNames } from \"./action-filters-a2a.js\";\nimport {\n createDataWidgetActionEntries,\n FRAMEWORK_CONTEXT_SECTIONS,\n} from \"./context-tools.js\";\nimport { lazyFs } from \"./lazy-fs.js\";\n\n// ---------------------------------------------------------------------------\n// Framework-level system prompt assembly (production/dev, full/compact),\n// the \"Available Actions\" and corpus-tools prompt sections, the SQL schema\n// block, and the codebase file-tree walker used by a few dev-mode tools.\n// ---------------------------------------------------------------------------\n\n/**\n * Framework-level instructions injected into every agent's system prompt.\n * Prompt text lives in packages/core/src/server/prompts/ so this file stays\n * focused on routing and assembly logic.\n *\n * buildFrameworkPrompts() is called once per plugin instantiation (not per\n * request) with the template's promptExamples, producing the four assembled\n * prompt strings used at request time.\n */\nexport function buildFrameworkPrompts(\n examples?: PromptExamples,\n options?: { databaseTools?: DatabaseToolsOption; extensionTools?: boolean },\n): {\n FRAMEWORK_CORE: string;\n FRAMEWORK_CORE_COMPACT: string;\n PROD_FRAMEWORK_PROMPT: string;\n DEV_FRAMEWORK_PROMPT: string;\n PROD_FRAMEWORK_PROMPT_COMPACT: string;\n DEV_FRAMEWORK_PROMPT_COMPACT: string;\n} {\n const FRAMEWORK_CORE = buildFrameworkCore(examples, options);\n const FRAMEWORK_CORE_COMPACT = buildFrameworkCoreCompact(examples, options);\n const extensionToolsEnabled = options?.extensionTools !== false;\n const planModeArtifactList = extensionToolsEnabled\n ? \"source-code handoffs and app-created artifacts such as extensions, widgets, dashboards, calculators, mini-apps, documents, designs, slides, or videos\"\n : \"source-code handoffs and app-created artifacts such as documents, designs, slides, or videos\";\n const planModeBlockedTools = extensionToolsEnabled\n ? \"`render-inline-extension`, `create-extension`, `update-extension`, `connect-builder`, or any action that creates, updates, deletes, sends, publishes, or persists data\"\n : \"`connect-builder`, or any action that creates, updates, deletes, sends, publishes, or persists data\";\n const extensionConnectBuilderGuard = extensionToolsEnabled\n ? \"If the complete request can be satisfied by a self-contained extension or an existing named slot, use `render-inline-extension`, `create-extension`, `show-extension-inline`, or `update-extension` instead. If the exact placement or behavior requires changing the host UI or no suitable slot exists, continue with the normal `connect-builder` source-change flow even if the user called it an extension; never stop at saying extensions cannot do it.\"\n : \"Because extension tools are disabled, do NOT invent an extension workflow. Only use `connect-builder` when the request genuinely requires changing the host app's source code.\";\n const extensionInstructionsFull = extensionToolsEnabled\n ? `### Generative UI and Extensions (Mini-Apps)\n\nIn Act mode, if the user asks for generated interactive UI in chat, choose the smallest extension action for the lifetime: \\`render-inline-extension\\` (one-off, chat-only), \\`create-extension\\` (saved/reusable), \\`show-extension-inline\\` (reopen a saved one), or \\`update-extension\\` (edit an existing one) — call the right one directly, without a \"let me build…\" preamble. Each tool's own description covers its exact use case, arguments, and available helpers (appAction, dbQuery, extensionData, agentNative.ui.output, etc.). Extensions are sandboxed mini-apps, not source-code changes, and never go through \\`connect-builder\\`.\n\nIf the app exposes native actions or instructions for dashboards, reports, analyses, charts, documents, decks, or other domain artifacts, use those app-native actions first. Choose an extension only when the user explicitly asks for an extension/custom mini-app, or when the app's native artifact format cannot faithfully express the requested interaction.\n\nEditing an existing extension (fix, restyle, rename, add behavior) is a SQL data update — call \\`update-extension\\` directly using the extensionId from \\`<current-screen>\\`/\\`<current-url>\\` when present; never call \\`connect-builder\\` for it.\n\nExtensions render only on their own page or inside an existing named slot; they cannot inject UI into arbitrary native components. If an extension could only approximate the request in a different location, do not silently downgrade the requirement and do not end with \"extensions cannot do that.\" Briefly explain the boundary, then follow the normal source-code handoff so the app can still be customized fully.\n\nFor helper APIs, Alpine.js patterns, the extension-vs-code-change boundary, and worked examples, read the \\`extensions\\` and \\`generative-ui\\` skills.`\n : `### Extensions Disabled\n\nExtension creation and management tools are disabled for this app. Do not claim you can create, edit, hide, or delete Agent-Native extensions unless the template exposes its own typed action for that workflow. For requests that would otherwise be handled as an extension/widget/dashboard/calculator mini-app, explain that this app has disabled extension tools and use the app's available actions instead.`;\n const extensionInstructionsCompact = extensionToolsEnabled\n ? `### Generative UI and Extensions (Mini-Apps)\n\nIn Act mode, choose the smallest extension action for the lifetime: \\`render-inline-extension\\` (one-off, chat-only), \\`create-extension\\` (saved/reusable), \\`show-extension-inline\\` (reopen a saved one), or \\`update-extension\\` (edit an existing one) — each tool's own description covers its use case and helpers. These are sandboxed mini-apps, not code changes; never route them through \\`connect-builder\\`. Do not preface with \"let me build…\" — just call the right extension action.\n\nUse app-native artifact actions first when they exist for dashboards, reports, analyses, charts, documents, decks, or similar domain artifacts. Pick \\`create-extension\\` only for explicit extension/custom mini-app requests or for behavior the native artifact format cannot support.\n\nEditing an existing extension is a data update — call \\`update-extension\\` directly using the extensionId from \\`<current-screen>\\`/\\`<current-url>\\` when present; never \\`connect-builder\\`.\n\nExtensions can render only on their own page or in an existing named slot; they cannot inject UI into arbitrary native components. If the exact request changes host chrome, native components, layout, styles, routes, business logic, or needs placement where no slot exists, treat it as a source-code change and use the normal \\`connect-builder\\` flow even if the user called it an extension. Never stop at \"extensions cannot do that\" or silently offer a different placement; explain the boundary briefly and continue the code-change handoff.\n\nSee the \\`extensions\\` and \\`generative-ui\\` skills for helper APIs, Alpine.js patterns, and worked examples.`\n : `### Extensions Disabled\n\nExtension creation and management tools are disabled for this app. Do not claim you can create, edit, hide, or delete Agent-Native extensions unless the template exposes its own typed action for that workflow.`;\n\n const PROD_FRAMEWORK_PROMPT = `## Agent-Native Framework — Production Mode\n\nYou are an AI agent in an agent-native application, running in **production mode**.\n\nThe agent and the UI are equal partners — everything the UI can do, you can do via your tools, and vice versa. They share the same SQL database and stay in sync automatically.\n\n**In production mode, you operate through registered actions exposed as tools.** These are your capabilities — use them to read data, take actions, and help the user. You cannot edit source code or access the filesystem directly. Your tools are the app's API.\n\n### Plan Mode\n\nIf the current turn is in Plan mode, plan before anything gets written. This applies to ${planModeArtifactList}. Use only read-only tools, clarify the goal when needed, and return a concrete plan for approval. Do not call ${planModeBlockedTools} until the user switches back to Act mode.\n\n${extensionInstructionsFull}\n\n### Code Changes Not Available — Call \\`connect-builder\\` Immediately\n\n${extensionConnectBuilderGuard}\n\nIn Act mode, when the user asks you to change the UI, modify code, add a feature, fix a bug in the app itself, change styles, add a hook, create a component, add a route, add an integration, or anything else that requires editing source files — you MUST take exactly these steps, in order:\n\n1. Briefly acknowledge the user's specific request in their own terms — one short clause naming what they asked for (e.g. \"Got it — wider subject lines in the email list.\"). Do NOT restate the request verbatim, do NOT add a generic preamble, and do NOT promise outcomes. Skip this step entirely if the user already knows you're handing off (e.g. they said \"send this to Builder\").\n2. Call the \\`connect-builder\\` tool, passing the user's full request verbatim as the \\`prompt\\` argument. This renders an inline card. The returned \\`builderEnabled\\` flag is authoritative: \\`true\\` means Builder Cloud Agents can take the code-change handoff; \\`false\\` means this still requires a code change, but no Builder Cloud Agent can run from this workspace. If Builder is connected and \\`builderEnabled\\` is true, the card hands the prompt off to Builder's cloud agent on one click and returns a branch URL. If Builder is not connected and \\`builderEnabled\\` is true, it shows the Connect Builder flow. If \\`builderEnabled\\` is false, it still shows the card, but as a code-change fallback instead of a runnable cloud handoff.\n3. After the card renders, inspect the tool result and write one sentence that frames the next click around what the user just asked — not as a Builder pitch. If \\`builderEnabled\\` is true and the card can send, say something like \"Click Send to Builder and it'll wire that up for you.\" If the user needs to connect first, say something like \"Connect Builder once and it'll handle this and future changes.\" If \\`builderEnabled\\` is false, say: \"This requires a code change. Edit locally or use Builder.io to edit this code in the cloud and continue customizing the app any way you like.\" Do NOT say \"click Send to Builder\", mention a branch URL, say the card is pre-loaded, or imply a Builder Cloud Agent can run when \\`builderEnabled\\` is false.\n\nWhen \\`builderEnabled\\` is false, Builder Cloud Agents are not self-serve from Builder org settings. Do NOT tell the user to go to Builder org settings, beta features, \"Cloud Agents\", or \"AI Agents\" to enable them. The only allowed guidance is the card's code-change fallback: edit locally, use Agent Native Desktop, or use Builder.io to edit this code in the cloud and continue customizing the app any way you like.\n\n**Act-mode handoff — do exactly this:** The moment a code change is requested, call \\`connect-builder\\` with the user's verbatim request, then write one sentence framing the next click. That is the whole job: Builder plans and edits in its own sandbox, so the planning, file-mapping, and code all happen there, not here. Keep your turn to the call plus that one sentence — skip code exploration, implementation plans, \\`resources\\` writes of specs, and sub-agents (they have no code-editing tools either). You don't need filesystem access to recommend Builder, so don't reach for it or list tools you lack.\n\nBuilder Cloud Agents are the recommended path when \\`builderEnabled\\` is true because they are one-click and run in the cloud. Local dev, Agent Native Desktop, and Builder.io cloud editing are the fallback when \\`builderEnabled\\` is false.\n${FRAMEWORK_CORE}`;\n\n const DEV_FRAMEWORK_PROMPT = `## Agent-Native Framework — Development Mode\n\nYou are an AI agent in an agent-native application, running in **development mode**.\n\nThe agent and the UI are equal partners — everything the UI can do, you can do via tools/scripts, and vice versa. They share the same SQL database and stay in sync automatically.\n\n**In development mode, you have full local access — use it with senior-engineer judgment** (read before you edit, keep changes scoped, verify before you claim done):\n- Run any shell command via the \\`bash\\` tool (node, curl, pnpm, rg, git, etc.), including arbitrary code: \\`bash({ command: 'node -e \"console.log(1+1)\"' })\\`\n- Read and write any file on the filesystem; edit source, install packages, modify the app\n- Query and modify the database\n- Call external APIs (via bash with curl, or via scripts)\n\nWhen no dedicated tool/action exists for what you need, reach for \\`bash\\` — e.g. \\`bash({ command: 'curl -s https://api.example.com/data' })\\`.\n\n**Template-specific actions are invoked via bash, NOT as direct tools.** In dev mode, the only tools registered as native tool calls are framework-level utilities (bash, read, edit, write, database, resources, chat, teams, jobs). Anything from the template's \\`actions/\\` directory must be run through bash: \\`bash({ command: 'pnpm action <name> --arg value' })\\`. The \"Available Actions\" section below shows the exact CLI syntax for each one — copy that command verbatim and pass it to \\`bash\\`. Do not try to call template actions by name as if they were tools; they will not appear in your tool list.\n\nWhen editing code, follow the agent-native architecture:\n- Every feature needs all four areas: UI + scripts + skills/instructions + application-state sync\n- All SQL must be dialect-agnostic (works on SQLite and Postgres)\n- No Node.js-specific APIs in server routes (must work on Cloudflare Workers, etc.)\n- Use shadcn/ui components and Tabler Icons for all UI work\n${FRAMEWORK_CORE}`;\n\n const PROD_FRAMEWORK_PROMPT_COMPACT = `## Agent-Native Framework — Production Mode\n\nYou are an AI agent in an agent-native application, running in **production mode**.\n\nThe agent and the UI are equal partners — everything the UI can do, you can do via your tools, and vice versa. They share the same SQL database and stay in sync automatically.\n\n**In production mode, you operate through registered actions exposed as tools.** These are your capabilities — use them to read data, take actions, and help the user. You cannot edit source code or access the filesystem directly. Your tools are the app's API.\n\n### Plan Mode\n\nIf the turn is in Plan mode, plan before anything gets written — including ${planModeArtifactList}. Use read-only tools only and do not call ${planModeBlockedTools} until the user switches back to Act mode.\n\n${extensionInstructionsCompact}\n\n### Code Changes — Call \\`connect-builder\\`\n\nIn Act mode, when a request genuinely needs a source-code edit (per the rules above), do this in order: (1) briefly acknowledge the user's specific ask in their own terms — one short clause, no preamble — then (2) call \\`connect-builder\\` with the user's request as the \\`prompt\\`, then (3) inspect \\`builderEnabled\\` in the result and write one sentence framing the next click around what they asked for, not a Builder pitch. When \\`builderEnabled\\` is true, Builder Cloud Agents can take the handoff; when \\`builderEnabled\\` is false, say this requires a code change and they can edit locally or use Builder.io to edit this code in the cloud and continue customizing the app any way they like. Do NOT write code, list files, make plans, or spawn sub-agents. Mention \\`npx agent-native create <app-name>\\`, Agent Native Desktop, or the code-change fallback when Builder Cloud Agents aren't available. Never tell users to enable Builder Cloud Agents from Builder org settings, beta features, \"Cloud Agents\", or \"AI Agents\"; they are not self-serve there.\n${FRAMEWORK_CORE_COMPACT}`;\n\n const DEV_FRAMEWORK_PROMPT_COMPACT = `## Agent-Native Framework — Development Mode\n\nYou are an AI agent in an agent-native application, running in **development mode**.\n\nThe agent and the UI are equal partners — everything the UI can do, you can do via tools/scripts, and vice versa. They share the same SQL database and stay in sync automatically.\n\n**In development mode, you have full local access** — shell, filesystem, database, external APIs, source edits, and package installs. Use it with senior-engineer judgment: read before you edit, keep changes scoped, verify before you claim done.\n\n**Template-specific actions are invoked via bash, NOT as direct tools.** Run them with: \\`bash({ command: 'pnpm action <name> --arg value' })\\`. See the \"Available Actions\" section below for CLI syntax.\n\nWhen editing code, follow the agent-native architecture:\n- Every feature needs all four areas: UI + scripts + skills/instructions + application-state sync\n- All SQL must be dialect-agnostic (works on SQLite and Postgres)\n- No Node.js-specific APIs in server routes (must work on Cloudflare Workers, etc.)\n- Use shadcn/ui components and Tabler Icons for all UI work\n${FRAMEWORK_CORE_COMPACT}`;\n\n return {\n FRAMEWORK_CORE,\n FRAMEWORK_CORE_COMPACT,\n PROD_FRAMEWORK_PROMPT,\n DEV_FRAMEWORK_PROMPT,\n PROD_FRAMEWORK_PROMPT_COMPACT,\n DEV_FRAMEWORK_PROMPT_COMPACT,\n };\n}\n\nexport const _agentChatPromptSectionsForTests = (() => {\n // Built with default (no template-specific) examples for test stability.\n const {\n FRAMEWORK_CORE: frameworkCore,\n FRAMEWORK_CORE_COMPACT: frameworkCoreCompact,\n } = buildFrameworkPrompts();\n return {\n frameworkCore,\n frameworkCoreCompact,\n frameworkContextSections: FRAMEWORK_CONTEXT_SECTIONS,\n buildFrameworkPrompts,\n generateActionsPrompt,\n resolveInitialToolNames,\n createDataWidgetActionEntries,\n };\n})();\n\n/**\n * Build the per-request SQL-schema context block. Reads AGENT_ORG_ID live\n * from the environment so scheduler/A2A/HTTP call sites all see whatever\n * org was just resolved for this request.\n */\nexport async function buildSchemaBlock(\n owner: string,\n databaseTools: DatabaseToolsOption = \"read\",\n): Promise<string> {\n try {\n return await loadSchemaPromptBlock({\n owner,\n orgId: getRequestOrgId() ?? null,\n databaseTools,\n });\n } catch {\n return \"\";\n }\n}\n\n/**\n * Generates a system prompt section describing registered template actions.\n *\n * Two output modes:\n *\n * - `\"tool\"` — used in production, where template actions are registered\n * as native Anthropic tools. The native tool schema already carries each\n * action's name, full description, and parameters, so this mode does NOT\n * re-list every action — it only surfaces what the tool list can't:\n * native-chat-widget annotations and a `tool-search` pointer for actions\n * omitted from the initial tool set.\n * - `\"cli\"` — used in dev, where template actions are NOT registered as\n * native tools and must be invoked via `bash(command=\"pnpm action ...\")`.\n * This listing is load-bearing here (there is no tool schema to fall\n * back on), so it still emits the full\n * `pnpm action name --arg <type> [--opt <type>] — desc` line per action.\n */\nexport function generateActionsPrompt(\n registry: Record<string, ActionEntry>,\n mode: \"cli\" | \"tool\" = \"tool\",\n initialToolNames?: string[],\n): string {\n if (!registry || Object.keys(registry).length === 0) return \"\";\n\n const allActionEntries = Object.entries(registry);\n const initialNames = initialToolNames ? new Set(initialToolNames) : undefined;\n const actionEntries = initialNames\n ? allActionEntries.filter(([name]) => initialNames.has(name))\n : allActionEntries;\n const omittedActionCount = allActionEntries.length - actionEntries.length;\n const nativeWidgetNote = (entry: ActionEntry) =>\n entry.chatUI && typeof entry.chatUI.renderer === \"string\"\n ? ` Native chat widget: \\`${entry.chatUI.renderer}\\`.`\n : \"\";\n\n if (mode === \"tool\") {\n // Native tool schemas already carry name + full description + params\n // for every action, so this section only needs to surface what the tool\n // list itself can't: which actions render a native chat widget, and\n // which actions exist but aren't loaded as initial tools yet.\n const widgetLines = actionEntries\n .filter(([, entry]) => typeof entry.chatUI?.renderer === \"string\")\n .map(\n ([name, entry]) =>\n `- \\`${name}\\` — Native chat widget: \\`${entry.chatUI?.renderer ?? \"\"}\\`.`,\n );\n\n const sections: string[] = [];\n if (widgetLines.length > 0) {\n sections.push(\n `**Actions that render a native chat widget** — call these directly for their table/chart/insights view instead of recreating it in prose:\\n\\n${widgetLines.join(\"\\n\")}`,\n );\n }\n if (omittedActionCount > 0) {\n sections.push(\n `${omittedActionCount} less-common app action${omittedActionCount === 1 ? \" is\" : \"s are\"} available on demand. Use \\`tool-search\\` with a specific capability query to load the matching schemas when needed.`,\n );\n }\n if (sections.length === 0) return \"\";\n\n return `\\n\\n## Available Actions\\n\\n${sections.join(\"\\n\\n\")}`;\n }\n\n const lines = actionEntries.map(([name, entry]) => {\n const desc = entry.tool.description;\n const params = entry.tool.parameters?.properties;\n const requiredFields = new Set(entry.tool.parameters?.required ?? []);\n\n // CLI mode: emit `pnpm action <name> --required <type> [--optional <type>]`\n if (!params || Object.keys(params).length === 0) {\n return `- \\`pnpm action ${name}\\` — ${desc}${nativeWidgetNote(entry)}`;\n }\n const entries = Object.entries(params);\n // Required first (alphabetical), then optional (alphabetical)\n entries.sort(([a], [b]) => {\n const ar = requiredFields.has(a) ? 0 : 1;\n const br = requiredFields.has(b) ? 0 : 1;\n if (ar !== br) return ar - br;\n return a.localeCompare(b);\n });\n const required: string[] = [];\n const optional: string[] = [];\n const requiredNames: string[] = [];\n for (const [k, v] of entries) {\n const type = (v as { type?: string }).type ?? \"any\";\n const flag = `--${k} <${type}>`;\n if (requiredFields.has(k)) {\n required.push(flag);\n requiredNames.push(`--${k}`);\n } else {\n optional.push(`[${flag}]`);\n }\n }\n const cmd = [\"pnpm action \" + name, ...required, ...optional].join(\" \");\n const requiredNote =\n requiredNames.length > 0 ? ` Required: ${requiredNames.join(\", \")}.` : \"\";\n return `- \\`${cmd}\\` — ${desc}.${requiredNote}${nativeWidgetNote(entry)}`;\n });\n\n return `\\n\\n## Available Actions\n\n**These template actions are NOT exposed as direct tools in dev mode. To run any of them, use the \\`bash\\` tool with the exact command shown below.** Example: \\`bash(command=\"pnpm action add-slide --deckId abc --content 'Hello'\")\\`.\n\nDo NOT try to call these by name as if they were tools — they will not exist in your tool list. Always go through \\`bash\\`.\n\n${lines.join(\"\\n\")}`;\n}\n\n/**\n * Tool names `generateCorpusToolsPrompt` teaches BY NAME, in the same order\n * it lists them. Exported so callers that build a request's initial\n * engine-tool set can fold in exactly the subset present in a given\n * registry — keeping \"what the prompt just told the model exists\" and\n * \"what tools are actually callable on the first request\" in sync. See the\n * corpus-prompt/initial-tools note at this function's call site in\n * agent-chat-plugin.ts.\n */\nconst CORPUS_TOOL_NAMES = [\n \"provider-api-catalog\",\n \"provider-api-docs\",\n \"provider-api-request\",\n \"provider-corpus-job\",\n \"query-staged-dataset\",\n \"run-code\",\n] as const;\n\nexport function corpusToolNamesTaughtByPrompt(\n registry: Record<string, ActionEntry>,\n): string[] {\n return CORPUS_TOOL_NAMES.filter((name) => name in registry);\n}\n\nexport function generateCorpusToolsPrompt(\n registry: Record<string, ActionEntry>,\n): string {\n const hasProviderApi = \"provider-api-request\" in registry;\n const hasProviderCorpusJob = \"provider-corpus-job\" in registry;\n const providerDiscoveryTools = [\n \"provider-api-catalog\" in registry ? \"`provider-api-catalog`\" : null,\n \"provider-api-docs\" in registry ? \"`provider-api-docs`\" : null,\n ].filter(Boolean);\n const hasRunCode = \"run-code\" in registry;\n const hasStagedDataset = \"query-staged-dataset\" in registry;\n if (\n !hasProviderApi &&\n !hasProviderCorpusJob &&\n !hasRunCode &&\n !hasStagedDataset\n )\n return \"\";\n\n const available = [\n ...providerDiscoveryTools,\n hasProviderApi ? \"`provider-api-request`\" : null,\n hasProviderCorpusJob ? \"`provider-corpus-job`\" : null,\n hasStagedDataset ? \"`query-staged-dataset`\" : null,\n hasRunCode ? \"`run-code`\" : null,\n ].filter(Boolean);\n\n return `\\n\\n## Broad Provider And Corpus Workflows\n\nAvailable corpus-capable tools: ${available.join(\", \")}.\n\nThis workflow does not apply to ordinary structured lookups, bounded aggregates, or counts grouped over one known source. For those requests, use the single most directly authoritative source, run one bounded query, and answer as soon as it succeeds. Do not cross-check or expand into a corpus workflow unless the user asks for multiple sources, exhaustive unstructured-record coverage, or an absence claim.\n\nFor broad provider searches, raw API access, multi-page cohorts, cross-source joins, classification over unstructured records, or absence-sensitive answers, do not stop at a bounded shortcut action. Use the provider's broad API/search/list surface, fetch every relevant page or an explicit bounded cohort, stage/save large responses when needed, and reduce the corpus with durable corpus jobs, staged-dataset queries, or code execution.\n\nWhen \\`provider-corpus-job\\` is available, prefer it for transcript/message/ticket/issue/document scans that may exceed one turn, need provider-side backoff, or need a defensible \"not found\" conclusion. Use operation=\"start\" with mode=\"paginated-search\" for any paginated provider endpoint, or mode=\"batch-search\" when a prior cohort of ids/records must feed a second provider endpoint. Continue paused jobs with operation=\"continue\" until status is completed or quota_wait, then read operation=\"results\". In run-code, prefer providerFetchAll() for short cursor/page/offset pagination and providerRequest() when response status, headers, or truncation metadata matters. Report source, filters, row counts, pagination/truncation, failed pages, quota_wait times, and remaining gaps.`;\n}\n\n/**\n * Walks the local filesystem (dev mode only) to build a bounded file/folder\n * tree, used by a couple of dev-mode workspace-inspection tools.\n */\nexport async function collectFiles(\n dir: string,\n prefix: string,\n depth: number,\n results: Array<{ path: string; name: string; type: \"file\" | \"folder\" }>,\n): Promise<void> {\n if (depth > 4 || results.length >= 500) return;\n const skip = new Set([\n \"node_modules\",\n \".git\",\n \".next\",\n \".output\",\n \"dist\",\n \".cache\",\n \".turbo\",\n \"data\",\n ]);\n let entries: import(\"fs\").Dirent[];\n try {\n const fs = await lazyFs();\n entries = fs.readdirSync(dir, { withFileTypes: true });\n } catch {\n return;\n }\n for (const entry of entries) {\n if (results.length >= 500) return;\n if (skip.has(entry.name) || entry.name.startsWith(\".\")) continue;\n const relPath = prefix ? `${prefix}/${entry.name}` : entry.name;\n const isDir = entry.isDirectory();\n results.push({\n path: relPath,\n name: entry.name,\n type: isDir ? \"folder\" : \"file\",\n });\n if (isDir)\n await collectFiles(\n nodePath.join(dir, entry.name),\n relPath,\n depth + 1,\n results,\n );\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"agent-chat-plugin.d.ts","sourceRoot":"","sources":["../../src/server/agent-chat-plugin.ts"],"names":[],"mappings":"AAuCA,OAAO,KAAK,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAqH7D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAEvE,OAAO,EACL,yBAAyB,EACzB,KAAK,6BAA6B,EACnC,MAAM,+BAA+B,CAAC;AAkCvC,OAAO,EAAE,yBAAyB,EAAE,CAAC;AACrC,YAAY,EAAE,6BAA6B,EAAE,CAAC;AAwE9C,OAAO,EACL,0BAA0B,EAM1B,eAAe,EACf,eA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AAC,EAAE,sBAAsB,GAC/B,cAAc,CA24KhB;AAED;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,EAAE,cAAwC,CAAC;AAE9E,OAAO,EAEL,mBAAmB,EACnB,uBAAuB,EAGxB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,mBAAmB,EAAE,CAAC;AAC/B,OAAO,EAAE,uBAAuB,EAAE,CAAC"}
@@ -19,6 +19,7 @@ import { buildAssistantMessage, buildUserMessage, extractThreadMeta, foldAssista
19
19
  import { attachToolSearch } from "../agent/tool-search.js";
20
20
  import { readAppStateForCurrentTab } from "../application-state/script-helpers.js";
21
21
  import { createThread, forkThread, getThread, registerChatThreadsShareable, resolveThreadAccess, listThreads, searchThreads, renameThread, createThreadShareLink, getThreadByShareToken, getThreadShareState, revokeThreadShareLink, setThreadArchived, setThreadPinned, setThreadScope, updateThreadData, withThreadDataLock, deleteThread, setThreadQueuedMessages, } from "../chat-threads/store.js";
22
+ import { isCheckpointRestorePath } from "../checkpoints/route-match.js";
22
23
  import { createDbAdminAgentTools } from "../db-admin/agent-tools.js";
23
24
  import { isTransientDatabaseError } from "../db/client.js";
24
25
  import { verifyInternalToken, extractBearerToken, } from "../integrations/internal-token.js";
@@ -3791,11 +3792,9 @@ Non-code requests are still fine on this surface: read data, navigate the UI, su
3791
3792
  return [];
3792
3793
  }
3793
3794
  }
3794
- // POST /checkpoints — restore to a checkpoint
3795
- // h3 prefix-matches, so /checkpoints/restore hits this handler with
3796
- // event.path containing "/restore".
3797
- const remainder = (event.path || "").replace(/^\/+/, "");
3798
- if (method === "POST" && remainder.startsWith("restore")) {
3795
+ // POST /checkpoints/restore — restore to a checkpoint.
3796
+ const restorePath = event.path || event.node?.req?.url || "";
3797
+ if (method === "POST" && isCheckpointRestorePath(restorePath)) {
3799
3798
  if (!canToggle) {
3800
3799
  setResponseStatus(event, 403);
3801
3800
  return { error: "Checkpoints only available in dev mode" };
@@ -3806,16 +3805,23 @@ Non-code requests are still fine on this surface: read data, navigate the UI, su
3806
3805
  }
3807
3806
  const body = await readBody(event);
3808
3807
  const checkpointId = body?.checkpointId;
3809
- if (!checkpointId) {
3808
+ const restoreRunId = typeof body?.runId === "string" ? body.runId : "";
3809
+ if (!checkpointId && !restoreRunId) {
3810
3810
  setResponseStatus(event, 400);
3811
- return { error: "checkpointId is required" };
3811
+ return { error: "checkpointId or runId is required" };
3812
3812
  }
3813
3813
  try {
3814
- const { getCheckpointById } = await import("../checkpoints/store.js");
3815
- const checkpoint = await getCheckpointById(checkpointId);
3814
+ const { getCheckpointById, getCheckpointByRunId } = await import("../checkpoints/store.js");
3815
+ const checkpoint = checkpointId
3816
+ ? await getCheckpointById(checkpointId)
3817
+ : await getCheckpointByRunId(restoreRunId);
3816
3818
  if (!checkpoint) {
3817
3819
  setResponseStatus(event, 404);
3818
- return { error: "Checkpoint not found" };
3820
+ return {
3821
+ error: restoreRunId
3822
+ ? "No checkpoint was saved for this turn, so there is nothing to restore."
3823
+ : "Checkpoint not found",
3824
+ };
3819
3825
  }
3820
3826
  const owner = await getOwnerFromEvent(event);
3821
3827
  const thread = await getThread(checkpoint.threadId);